/* eslint-disable @typescript-eslint/no-unused-vars */
/* eslint-disable @typescript-eslint/no-explicit-any */
/* eslint-disable @typescript-eslint/no-empty-interface */
import { UnsubscribeFunction } from "callback-registry";
import { IOConnectCore } from "@interopio/core";
import { IOConnectDesktop } from "@interopio/desktop";
import { IOConnectWorkspaces } from "@interopio/workspaces-api";
import { IOConnectSearch } from "@interopio/search-api";
import { IOConnectModals } from "@interopio/modals-api";

/**
 * Factory function that creates a new ioconnect instance.
 * If your application is running in IOConnect Desktop this will return a Glue42.Glue API, which is a super-set of the IOConnectBrowser.API.
 */
export type IOConnectBrowserFactoryFunction = (config?: IOConnectBrowser.Config) => Promise<IOConnectBrowser.API | IOConnectDesktop.API>;
declare const IOConnectBrowserFactory: IOConnectBrowserFactoryFunction;
export default IOConnectBrowserFactory;

/**
 * @docname io.Connect Browser
 * @intro
 * **io.Connect Browser** allows web apps to integrate with other apps that are part of the same **io.Connect Browser** project via a set of APIs.
 * **io.Connect Browser** enables you to share data between apps, expose functionality, manage windows, notifications, and more.
 *
 * ## Referencing
 *
 * The [`&commat;interopio/browser`](https://www.npmjs.com/package/&commat;interopio/browser) library is available both as a single JavaScript file,
 * which you can include in your web apps using a `<script>` tag, and also as a module, which you can import in your apps:
 *
 * ```html
 * <script type="text/javascript" src="browser.umd.js"></script>
 * ```
 *
 * Or:
 *
 * ``` javascript
 * import IOBrowser from "&commat;interopio/browser";
 * ```
 *
 * ## Initialization
 *
 * The [`&commat;interopio/browser`](https://www.npmjs.com/package/&commat;interopio/browser) library attaches the `IOBrowser()` factory function
 * to the global `window` object. Invoke this function to initialize the library and connect to the **io.Connect Browser** environment.
 * The `IOBrowser()` factory function accepts an optional `Config` object as an argument, which you can use to provide settings for the library
 * (e.g., initialize additional io.Connect libraries, configure the library behavior or some of its APIs).
 * The factory function resolves with the initialized io.Connect API object, which you can use to access all available io.Connect APIs:
 *
 * ```javascript
 * import IOBrowser from "&commat;interopio/browser";
 * import IOWorkspaces from "&commat;interopio/workspaces-api";
 *
 * const initializeIOConnect = async () => {
 *
 *     // Initializing the Workspaces API.
 *     const initOptions = {
 *         libraries: [IOWorkspaces]
 *     };
 *
 *     // Use the initialized API object to access the io.Connect APIs.
 *     const io = await IOBrowser(initOptions);
 *
 *     // Here, the library is already initialized and you can access all available io.Connect APIs.
 *     const myWorkspace = await io.workspaces.restoreWorkspace("My Workspace");
 * };
 *
 * initializeIOConnect().catch(console.error);
 * ```
 */
export namespace IOConnectBrowser {

    export import Interop = IOConnectCore.Interop;
    export import Contexts = IOConnectCore.Contexts;
    export import Logger = IOConnectCore.Logger;

    /**
     * @ignore
     */
    export interface ProfileData {
        license: {
            type: "trial" | "paid";
            expiration: number;
        },
        productsInfo: {
            platform: {
                apiVersion: string;
            },
            client: {
                apiVersion: string;
            },
            workspaces?: {
                apiVersion: string;
                container?: {
                    type: string,
                    version: string;
                }
            },
            home?: {
                version: string
            },
            search?: {
                apiVersion: string;
            },
            modals?: {
                apiVersion: string;
            }
        },
        plugins: Array<{ name: string, version: string }>,
        user?: {
            id: string;
            username?: string;
            firstName?: string;
            lastName?: string;
            email?: string;
            type?: string;
            role?: string;
            meta?: any;
        }
    }

    /**
     * Describes the configuration for the `IOBrowser()` factory function.
     */
    export interface Config {
        /**
         * Configures the system logger. Used mostly during development.
         */
        systemLogger?: SystemLogger;

        /**
         * Connect with the Gateway in memory.
         * Used for testing in a Node.js environment where the Gateway isn't started by `@interopio/browser-worker and an in-process Gateway is used instead.
         * @ignore
         */
        inproc?: IOConnectCore.InprocGWSettings;

        /**
         * Settings for the Notifications API.
         */
        notifications?: Notifications.Settings;

        /**
         * Settings for the Contexts API.
         */
        contexts?: IOConnectCore.ContextsConfig;

        /**
         * Configures whether the library will share the initialized API object upon request via a custom web event.
         * @default true
         */
        exposeAPI?: boolean;

        /**
         * If `true`, when the io.Connect API factory function is invoked more than once in the same app,
         * it will return the already initialized API object instead of throwing an error.
         * @default false
         * @since io.Connect Browser 3.5
         */
        memoizeAPI?: boolean;

        /**
         * List of references to the factory functions of additional io.Connect libraries to be initialized internally (e.g., `@interopio/workspaces-api`, `@interopio/search-api`).
         * The APIs provided by these libraries can then be accessed via the initialized io.Connect API object (e.g., `io.workspaces`, `io.search`).
         */
        libraries?: Array<(io: IOConnectBrowser.API, config?: IOConnectBrowser.Config | IOConnectDesktop.Config) => Promise<void>>;

        /**
         * Deprecated. Settings for the legacy Intents Resolver UI in **io.Connect Browser**.
         * @ignore
         */
        intents?: IOConnectBrowser.Intents.Config;

        /**
         * Settings for the io.Connect widget.
         * @since io.Connect Browser 3.5
         */
        widget?: WidgetConfig;

        /**
         * Settings for the io.Connect modals.
         * @since io.Connect Browser 4.0
         */
        modals?: ModalsUIConfig;

        /**
         * Settings for the Intents Resolver UI.
         * @since io.Connect Browser 4.0
         */
        intentResolver?: IntentResolverUIConfig;
    }

    /**
     * Type of the Channel Selector to use in the widget.
     */
    export type WidgetChannelSelectorType = "directional" | "default";

    /**
     * Determines which of the available Channels to display (all or only FDC3 ones).
     */
    export type WidgetChannelsDisplayMode = "all" | "fdc3";

    /**
     * Initial position for the widget within the window.
     */
    export type WidgetPosition = "top-left" | "top-center" | "top-right" | "center-left" | "center-right" | "bottom-left" | "bottom-center" | "bottom-right";

    /**
     * Settings for the Widget Channel Selector UI.
     */
    export interface WidgetChannelSelectorConfig {
        /**
         * If `true`, will enable the Channel Selector UI in the widget.
         * @default true
         */
        enable?: boolean;

        /**
         * Type of the Channel Selector UI.
         * @default "default"
         */
        type?: WidgetChannelSelectorType;
    }

    /**
     * Settings for the Channel Selector UI.
     */
    export interface WidgetChannels {

        /**
         * Settings for the Channel Selector UI.
         */
        selector?: WidgetChannelSelectorConfig;

        /**
         * Determines which of the available Channels to display (all or only FDC3 ones).
         * @default "all"
         */
        displayMode?: WidgetChannelsDisplayMode;
    }

    /**
     * Describes the configuration for the io.Connect widget.
     */
    export interface WidgetConfig {
        /**
         *  If `true`, will enable the widget for the Browser Client unless the app origin has been blocked in the Main app configuration.
         */
        enable: boolean;

        /**
         * Settings for the Channel Selector UI.
         */
        channels?: WidgetChannels;

        /**
         * Initial position for the widget within the window.
         * @default "bottom-center"
         */
        position?: WidgetPosition;

        /**
         * If `true`, the widget will be visible in the app even if the app is currently in a Workspace.
         * @default false
         */
        displayInWorkspace?: boolean;

        /**
         * If `true`, the `@interopio/browser` library will wait for the `IOBrowserWidget()` factory function to resolve before completing its initialization.
         * @default true
         */
        awaitFactory?: boolean;

        /**
         * Interval in milliseconds to wait for the `IOBrowserWidget()` factory function to be fetched from the remote source.
         * @default 5000
         */
        timeout?: number;

        /**
         * If `true`, the widget will save its position in the app's prefs storage and restore it upon app's initialization.
         * @default true
         * @since io.Connect Browser 4.1
         */
        restoreLastKnownPosition?: boolean;
    }

    /**
     * Settings for the Intents Resolver UI.
     */
    export interface IntentResolverUIConfig {

        /**
         * If `true`, will enable the Intents Resolver UI for the Browser Client unless the app origin has been blocked in the Main app configuration.
         */
        enable: boolean;

        /**
         * If `true`, the `@interopio/browser` library will wait for the `IOBrowserIntentResolverUI()` factory function
         * to resolve before completing its initialization.
         * @default true
         */
        awaitFactory?: boolean;

        /**
         * Interval in milliseconds to wait for the `IOBrowserIntentResolverUI()` factory function to be fetched from the remote source.
         * @default 5000
         */
        timeout?: number;
    }

    /**
     * @ignore
     */
    export namespace IntentResolverUI {
        export interface API {
            open: (config: OpenConfig) => OpenResult;
            close: (config: CloseConfig) => void;
        }

        export interface OpenConfigWithIntentRequest {
            intentRequest: IOConnectBrowser.Intents.IntentRequest;
            handlerFilter?: never;
        }

        export interface OpenConfigWithHandlerFilter {
            handlerFilter: IOConnectBrowser.Intents.HandlerFilter;
            intentRequest?: never;
        }

        export interface UISettings {
            showCloseButton?: boolean;
        }

        export type OpenConfig = (OpenConfigWithIntentRequest | OpenConfigWithHandlerFilter) & { onUserResponse: (response: { response: IntentResolverResponse }) => void, uiSettings?: UISettings };

        export interface UserSettings {
            preserveChoice: boolean;
        }

        export interface UserChoiceResponse {
            intent: string;
            handler: IOConnectBrowser.Intents.IntentHandler;
            userSettings: UserSettings;
        }
        export interface IntentResolverResponse {
            isExpired?: boolean;
            isClosed?: boolean;
            userChoice?: UserChoiceResponse;
        }

        export interface OpenResult {
            id: string;
        }

        export interface CloseConfig {
            id: string;
        }
    }

    /**
     * The [`@interopio/modals-ui`](https://www.npmjs.com/package/@interopio/modals-ui) library provides components and APIs used
     * in **io.Connect Browser** for displaying dialogs and alerts. When initializing the [`@interopio/browser`](https://www.npmjs.com/package/@interopio/browser) library,
     * you can provide configuration for the Modals UI library (e.g., disable alerts and/or dialogs, and more).
     */
    export interface ModalsUIConfig {

        /**
         * Settings for the io.Connect alerts.
         */
        alerts?: {

            /**
             * If `true`, will enable the io.Connect alerts.
             */
            enabled: boolean;
        };

        /**
         * Settings for the io.Connect dialogs.
         */
        dialogs?: {

            /**
             * If `true`, will enable the io.Connect dialogs.
             */
            enabled: boolean;
        };

        /**
         * If `true`, the `@interopio/browser` library will wait for the `IOBrowserModalsUI()` factory function to resolve before completing its initialization.
         * @default true
         */
        awaitFactory?: boolean;

        /**
         * Interval in milliseconds to wait for the `IOBrowserModalsUI()` factory function to be fetched from the remote source.
         * @default 5000
         */
        timeout?: number;
    }

    /**
     * @ignore
     */
    export namespace ModalsUI {

        /**
         * @ignore
         */
        export interface API {
            alerts: Alerts.API;
            dialogs: Dialogs.API;
        }

        /**
         * @ignore
         */
        export namespace Alerts {
            export interface API {
                open: (config: OpenConfig) => OpenResult;
                close: (config: CloseConfig) => void;
            }

            export interface InteropAction {
                name: string;
                settings: IOConnectModals.InteropSettings;
            }

            export type OpenConfig = Omit<IOConnectModals.AlertRequestConfig, "target" | "ttl"> & {
                onClose: () => void;
                onClick: (config: OnClickConfig) => void;
            }

            export interface OpenResult {
                id: string;
            }

            export interface CloseConfig {
                id: string;
            }

            export interface OnClickConfig {
                interopAction: InteropAction;
            }
        }

        /**
         * @ignore
         */
        export namespace Dialogs {
            export interface API {
                open: (config: OpenConfig) => OpenResult;
                close: (config: CloseConfig) => void;
            }

            export interface OpenConfig<Name extends string = string, Variables = any> {
                templateName: Name;
                onCompletion: (config: OnCompletionConfig) => void;
                size?: IOConnectModals.DialogRequestConfig["size"];
                variables: Variables;
            }

            export interface OpenResult {
                id: string;
            }

            export interface CloseConfig {
                id: string;
            }

            export interface OnCompletionConfig {
                response: IOConnectModals.DialogResponse;
            }
        }
    }

    /**
     * Settings for the system logger used by the library.
     */
    export interface SystemLogger {

        /**
         * Logging level for the system logger.
         */
        level?: IOConnectCore.Logger.LogLevel;

        /**
         * Implementation of a custom logger to be used as a system logger.
         * This logger will also be used by any logger instances created via the Logger API.
         * @since io.Connect Browser 4.2
         */
        customLogger?: IOConnectCore.CustomLogger;
    }

    /**
     * Describes an instance of the initialized io.Connect library.
     */
    export interface API extends IOConnectCore.API {

        /**
         * Window Management API.
         */
        windows: IOConnectBrowser.Windows.API;

        /**
         * Layouts API.
         */
        layouts: IOConnectBrowser.Layouts.API;

        /**
         * Notifications API.
         */
        notifications: IOConnectBrowser.Notifications.API;

        /**
         * Channels API.
         */
        channels: IOConnectBrowser.Channels.API;

        /**
         * App Management API.
         */
        appManager: IOConnectBrowser.AppManager.API;

        /**
         * Intents API.
         */
        intents: IOConnectBrowser.Intents.API;

        /**
         * Themes API.
         */
        themes?: IOConnectBrowser.Themes.API;

        /**
         * Workspaces API.
         */
        workspaces?: IOConnectWorkspaces.API;

        /**
         * Search API.
         */
        search?: IOConnectSearch.API;

        /**
         * @ignore
         */
        webPlatform?: IOConnectBrowser.WebPlatform.API;

        /**
         * App Preferences API.
         */
        prefs: IOConnectBrowser.Prefs.API;

        /**
         * Modals API.
         * @since io.Connect Browser 4.0
         */
        modals?: IOConnectModals.API;
    }

    /**
     * @intro
     * Using the Window Management API, your app can easily open and manipulate browser windows.
     * This allows you to transform your traditional single-window web app into a multi-window native-like web application.
     * The Window Management API enables apps to:
     *
     * - open multiple windows;
     * - manipulate the position and size of opened windows;
     * - pass context data upon opening new windows;
     * - listen for and handle events related to opening and closing windows;
     *
     * The Window Management API is accessible via the [`io.windows`](#API) object.
     */
    export namespace Windows {
        export interface API {
            list(): WebWindow[];

            /** Returns the current window. */
            my(): WebWindow;

            /**
             * Finds a window by ID.
             * @param id Window ID.
             */
            findById(id: string): WebWindow | undefined;

            /**
             * Opens a new IO Connect Browser Window.
             * @param name The name for the window
             * @param url The window URL.
             * @param options Options for creating a window.
             */
            open(name: string, url: string, options?: Settings): Promise<WebWindow>;

            /**
             * Notifies when a new window is opened.
             * @param callback Callback function to handle the event. Receives the added window as a parameter. Returns an unsubscribe function.
             */
            onWindowAdded(callback: (window: WebWindow) => void): UnsubscribeFunction;

            /**
             * Notifies when a window is closed. For backwards compatibility, you can also use `windowRemoved`.
             * @param callback Callback function to handle the event. Receives the removed window as a parameter. Returns an unsubscribe function.
             */
            onWindowRemoved(callback: (window: WebWindow) => void): UnsubscribeFunction;

            /**
             * Notifies when a window receives focus.
             * @param callback Callback function to handle the event. Receives the window instance as a parameter. Returns an unsubscribe function.
             */
            onWindowGotFocus(callback: (window: WebWindow) => void): UnsubscribeFunction;

            /**
             * Notifies when a window loses focus.
             * @param callback Callback function to handle the event. Receives the window instance as a parameter. Returns an unsubscribe function.
             */
            onWindowLostFocus(callback: (window: WebWindow) => void): UnsubscribeFunction;
        }

        export interface WebWindow {
            /**
             * ID of the window.
             */
            id: string;

            /**
             * Name of the window.
             */
            name: string;

            /**
             * Flag indicating whether the window is currently on focus.
             */
            isFocused: boolean;

            /**
             * Retrieves the current zoom factor.
             */
            zoomFactor: number;

            /**
             * Gets the current URL of the window.
             */
            getURL(): Promise<string>;

            /**
             * Sets new location and size for the window. The accepted settings are absolute.
             * @param dimension The object containing the desired absolute size and location.
             */
            moveResize(dimension: Partial<Bounds>): Promise<WebWindow>;

            /**
             * Sets a new size of the window. The accepted settings are relative.
             * @param width Relative width of the window.
             * @param height Relative height of the window.
             */
            resizeTo(width?: number, height?: number): Promise<WebWindow>;

            /**
             * Sets a new location of the window. The accepted settings are relative.
             * @param top Relative distance top coordinates.
             * @param left Relative distance left coordinates.
             */
            moveTo(top?: number, left?: number): Promise<WebWindow>;

            /**
             * Attempts to activate and bring to foreground the window. It is possible to fail due to client browser settings.
             */
            focus(): Promise<WebWindow>;

            /**
             * Closes the window
             * @default 0
             */
            close(): Promise<WebWindow>;

            /**
             * Returns the title of the window.
             * @default 0
             */
            getTitle(): Promise<string>;

            /**
             * Sets a new title for the window
             * @param title The new title value.
             */
            setTitle(title: string): Promise<WebWindow>;

            /**
             * Returns the current location and size of the window.
             */
            getBounds(): Promise<Bounds>;

            /**
             * Gets the current context object of the window.
             */
            getContext(): Promise<any>;

            /**
             * Updates the context object of the window
             * @param context The new context object for the window.
             */
            updateContext(context: any): Promise<WebWindow>;

            /**
             * Sets new context for the window.
             * @param context The new context object for the window.
             */
            setContext(context: any): Promise<WebWindow>;

            /**
             * Refreshes the current window.
             * @since io.Connect Browser 4.1
             */
            refresh(): Promise<WebWindow>;

            /**
             * Notifies when a change to the window's context has been made.
             * @param callback The function which will be invoked when a change to the window's context happens. The function will be called with the new context and window as arguments.
             */
            onContextUpdated(callback: (context: any, window: WebWindow) => void): UnsubscribeFunction;

            /**
             * Notifies when the window focus is changed.
             * @param callback Callback function to handle the event. Returns an unsubscribe function.
             */
            onFocusChanged(callback: (window: WebWindow) => void): UnsubscribeFunction;

            /**
             * Retrieves the current Channel of the window, if any.
             */
            getChannel(): Promise<string>;

            /**
             * Notifies when the current Channels of the window have changed. Returns a function you can use to unsubscribe from the event.
             * @param callback Callback for handling the event. Receives the names of the current Channels as an argument.
             */
            onChannelsChanged(callback: (names: string[]) => void): UnsubscribeFunction;

            /**
             * Zooms in the window.
             * @since io.Connect Browser 4.1
             */
            zoomIn(): Promise<WebWindow>;

            /**
             * Zooms out the window.
             * @since io.Connect Browser 4.1
             */
            zoomOut(): Promise<WebWindow>;

            /**
             * Changes the zoom level.
             * @param factor Zoom factor.
             * @since io.Connect Browser 4.1
             */
            setZoomFactor(factor: number): Promise<WebWindow>;

            /**
             * Notifies when the zoom factor is changed.
             * @param callback Callback function for handling the event.
             * @since io.Connect Browser 4.1
             */
            onZoomFactorChanged(callback: (window: WebWindow) => void): UnsubscribeFunction;
        }

        export interface Settings {

            /**
             * Distance of the top left window corner from the top edge of the screen.
             * @default 0
             */
            top?: number;

            /**
             * Distance of the top left window corner from the left edge of the screen.
             * @default 0
             */
            left?: number;

            /**
             * Window width.
             * @default 400
             */
            width?: number;

            /**
             * Window height.
             * @default 400
             */
            height?: number;

            /**
             * The initial window context. Accessible from {@link WebWindow#getContext}
             */
            context?: any;

            /**
             * The ID of the window that will be used to relatively position the new window.
             * Can be combined with `relativeDirection`.
             */
            relativeTo?: string;

            /**
             * Direction (`"bottom"`, `"top"`, `"left"`, `"right"`) of positioning the window relatively to the `relativeTo` window. Considered only if `relativeTo` is supplied.
             * @default "right"
             */
            relativeDirection?: RelativeDirection;
        }

        export type RelativeDirection = "top" | "left" | "right" | "bottom";

        export interface Bounds {
            top: number;
            left: number;
            width: number;
            height: number;
        }
    }

    /**
     * @intro
     * **io.Connect Browser** enables you to to save and later restore the exact arrangement and context of your environment
     * - windows, apps, Workspaces, and their respective bounds and context.
     *
     * The Layouts API offers the following features:
     *
     * - importing, exporting, removing. and retrieving Layouts;
     * - saving and restoring Layouts;
     * - events related to adding, removing, changing, or saving Layouts;
     * - requesting browser permission for the Multi-Screen Window Placement API;
     *
     * The Layouts API is accessible via the [`io.layouts`](#API) object.
     */
    namespace Layouts {

        /**
         *
         * Type of the Layout. Supported Layouts are `"Global"` and `"Workspace"`.
         *
         */
        export type LayoutType = "Global" | "Activity" | "ApplicationDefault" | "Swimlane" | "Workspace";

        /**
         * Controls the import behavior. If `"replace"` (default), all existing Layouts will be removed.
         * If `"merge"`, the Layouts will be added to the existing ones.
         */
        export type ImportMode = "replace" | "merge";

        /**
         * Layouts API.
         */
        export interface API {

            /**
             * Fetches a saved Layout if a Layout with the provided name and type exists.
             * @param type Type of the Layout to fetch.
             * @param name Name of the Layout to fetch.
             */
            get(name: string, type: LayoutType): Promise<Layout | undefined>;

            /**
             * Retrieves the current Global Layout. This is either the last restored Global Layout, or the last saved Global Layout that has been set as the current Global Layout.
             * @since io.Connect Browser 4.0
             */
            getCurrentLayout(): Promise<Layout | undefined>;

            /**
             * Returns a lightweight description of all Layouts of the provided type, without the extensive objects describing the Layout components.
             * @param type Type of the Layouts to fetch.
             */
            getAll(type: LayoutType): Promise<LayoutSummary[]>;

            /**
             * Returns a collection of all available `Layout` objects of the provided type.
             * @param type Type of the Layouts to export.
             */
            export(layoutType: LayoutType): Promise<Layout[]>;

            /**
             * Imports a collection of `Layout` objects.
             * @param layouts An array of `Layout` objects to be imported.
             * @param mode If `"replace"` (default), all existing Layouts will be removed. If `"merge"`, the Layouts will be added to the existing ones.
             */
            import(layouts: Layout[], mode?: ImportMode): Promise<void>;

            /**
             * Saves a new Layout.
             * @param layout Options for saving a Layout.
             */
            save(layout: NewLayoutOptions): Promise<Layout>;

            /**
             * Restores a Layout.
             * @param options Options for restoring a Layout.
             */
            restore(options: RestoreOptions): Promise<void>;

            /**
             * Removes a Layout.
             * @param type Type of the Layout to remove.
             * @param name Name of the Layout to remove.
             */
            remove(type: LayoutType, name: string): Promise<void>;

            /**
             * Notifies when a new Layout is added.
             * @param callback Callback function to handle the event. Receives the `Layout` object as an argument and returns an unsubscribe function.
             */
            onAdded(callback: (layout: Layout) => void): () => void;

            /**
             * Notifies when a Layout is modified.
             * @param callback Callback function to handle the event. Receives the `Layout` object as an argument and returns an unsubscribe function.
             */
            onChanged(callback: (layout: Layout) => void): () => void;

            /**
             * Notifies when a new default Global Layout has been selected or when the current one has been cleared.
             * @param callback Callback function for handling the event. Receives as an argument an object with a `name` property
             * holding the name of the newly selected default Global Layout. If the default Global Layout has been cleared, the argument will be `undefined`.
             * @since io.Connect Browser 4.0
             */
            onDefaultGlobalChanged(callback: (layout?: { name: string }) => void): () => void;

            /**
             * Notifies when a Layout is removed.
             * @param callback Callback function to handle the event. Receives the `Layout` object as an argument and returns an unsubscribe function.
             */
            onRemoved(callback: (layout: Layout) => void): () => void;

            /**
             * Notifies when a Layout save operation is requested. Returns an unsubscribe function.
             * @param callback Callback function for handling the event. The callback must return a `SaveRequestResponse` object containing
             * context to be saved for the current window when the Layout is saved.
             * When the Layout is saved and the `ignoreContexts` property of the `NewLayoutOptions` object is set to `true`, the returned context will be ignored.
             */
            onSaveRequested(callback: (info?: SaveRequestContext) => SaveRequestResponse): () => void;

            /**
             * Retrieves the browser Multi-Screen Window Placement permission state for the **io.Connect Browser** environment.
             */
            getMultiScreenPermissionState(): Promise<{ state: "prompt" | "granted" | "denied" }>;

            /**
             * Opens the browser permission prompt requesting Multi-Screen Window Placement permission from the user for the **io.Connect Browser** environment.
             * This can only be requested from the Main app (Web Platform) due to the transient activation restrictions of the browsers.
             */
            requestMultiScreenPermission(): Promise<{ permissionGranted: boolean }>;

            /**
             * Checks whether Global Layouts are activated in the **io.Connect Browser** environment.
             */
            getGlobalTypeState(): Promise<{ activated: boolean }>;

            /**
             * Retrieves the default Global Layout, if any.
             */
            getDefaultGlobal(): Promise<Layout | undefined>;

            /**
             * Sets a new default Global Layout.
             * @param name Name of the Global Layout to set as default.
             */
            setDefaultGlobal(name: string): Promise<void>;

            /**
             * Removes the default Global Layout.
             */
            clearDefaultGlobal(): Promise<void>;

            /**
             * Renames a Layout.
             * @param layout Existing Layout to rename.
             * @param newName New name for the Layout.
             */
            rename(layout: Layout, newName: string): Promise<LayoutResult>;

            /**
             * Notifies when a Layout is renamed. Returns an unsubscribe function.
             * @param callback Callback function for handling the event. Receives as a first argument the `Layout` object describing the renamed Layout.
             * Receives as a second argument an object with a `name` property holding the previous Layout name.
             */
            onRenamed(callback: (layout: Layout, previous: { name: string }) => void): () => void;

            /**
             * Notifies when a Layout is restored.
             * @param callback Callback function for handling the event. Receives as an argument the `Layout` object that was restored.
             * @since io.Connect Browser 4.0
             */
            onRestored(callback: (layout: Layout) => void): () => void;

            /**
             * Updates the metadata of a Layout.
             * @param layout Existing Layout to update.
             */
            updateMetadata(layout: Layout): Promise<void>;
        }

        /**
         * Describes a Layout and its components.
         */
        export interface Layout {
            /** Name of the Layout. The name is unique per Layout type. */
            name: string;

            /** Type of the Layout. */
            type: LayoutType;

            /** Array of component objects describing the apps and Workspaces saved in the Layout. */
            components: Array<WindowComponent | WorkspaceFrameComponent | IOConnectWorkspaces.WorkspaceComponent>;

            /**
            * Used internally to audit operations.
            * @ignore
            */
            token?: string;

            /** Context object passed when the Layout was saved. */
            context?: any;

            /** Metadata passed when the Layout was saved. */
            metadata?: any;

            /** Version of the Layout. */
            version?: number;
        }

        /**
         * @ignore
         */
        export type ComponentType = "application" | "activity";

        /**
         * @ignore
         */
        export interface WorkspaceFrameComponent {
            type: "workspaceFrame";

            /** The name of the workspace application. This is supported only in Enterprise */
            application: string;

            /** Type of the component - can be application or activity. */
            componentType?: ComponentType;

            /** Object describing the application bounds, name, context, etc. */
            state: WorkspaceFrameComponentState;
        }

        /**
         * @ignore
         */
        export interface WorkspaceFrameComponentState {
            bounds: IOConnectBrowser.Windows.Bounds;
            instanceId: string;
            selectedWorkspace: number;
            workspaces: IOConnectWorkspaces.WorkspaceLayoutComponentState[];
            windowState?: string;
            restoreState?: string;
            context?: any;
        }

        /**
         * @ignore
         */
        export interface WindowComponent {
            type: "window";

            /** Type of the component - can be application or activity. */
            componentType?: ComponentType;

            /** The name of the originating application for the instance or "no-app-window" if it was not started as an application instance */
            application: string;

            /** Object describing the application bounds, name, context, etc. */
            state: WindowComponentState;
        }

        /**
         * @ignore
         */
        export interface WindowComponentState {
            context?: any;
            bounds: IOConnectBrowser.Windows.Bounds;
            createArgs: WindowComponentCreateArgs;
            windowState?: string,
            restoreState?: string,
            restoreSettings?: {
                groupId?: string,
                groupZOrder?: number
            },
            instanceId: string,
            isSticky?: boolean,
            isCollapsed?: boolean,
            channelId?: string;
        }

        /**
         * @ignore
         */
        export interface WindowComponentCreateArgs {
            name?: string;
            url?: string;
            context?: any;
        }

        /**
         * A lightweight description of a Layout, without the extensive objects describing its components.
         */
        export interface LayoutSummary {
            /** Name of the Layout. The name is unique per Layout type. */
            name: string;

            /** Type of the Layout. */
            type: LayoutType;

            /** Context object passed when the Layout was saved. */
            context?: any;

            /** Metadata passed when the Layout was saved. */
            metadata?: any;
        }

        /**
         * Options for saving a Layout.
         */
        export interface NewLayoutOptions {

            /**
             * Name for the Layout.
             */
            name: string;

            /**
             * Context to be saved with the Layout. Used for transferring data to the apps when restoring a Layout.
             */
            context?: any;

            /**
             * Metadata to be saved with the Layout.
             */
            metadata?: any;

            /**
             * Window or app instance IDs of the instances to be saved in the Layout.
             */
            instances?: string[];

            /**
             * Window or app instance IDs of the instances to be ignored when saving the Layout.
             */
            ignoreInstances?: string[];

            /**
             * If `true`, will set the saved Layout as the current Global Layout.
             * @default true
             * @since io.Connect Browser 4.2
             */
            setAsCurrent?: boolean;

            /**
             * If `true`, the context objects of individual io.Connect Windows and Workspaces participating in the Global Layout won't be saved when the Layout is saved.
             * This is valid for context objects returned by the `onSaveRequested()` event handler, as well as for context objects
             * set via the `setContext()` method of a `WebWindow` instance.
             * You can still use the `context` property of the `NewLayoutOptions` object to provide context data to be saved for the Global Layout itself.
             * @default false
             * @since io.Connect Browser 4.3
             */
            ignoreContexts?: boolean;

            /**
             * If `true`, the context objects of individual io.Connect Windows set via the `setContext()` method of a `WebWindow` instance
             * will be saved when the Global Layout is saved. This is valid both for Browser Client apps, as well as for windows that have been
             * opened by the Main app or by a Browser Client, but aren't Browser Clients themselves (i.e., don't use the io.Connect libraries).
             * If a Browser Client has subscribed for the `onSaveRequested()` event and its context has also been set via the `setContext()` method,
             * the context returned by the `onSaveRequested()` event handler will take precedence.
             * If the `ignoreContexts` property of the `NewLayoutOptions` object is set to `true`, this property will be ignored.
             * @default false
             * @since io.Connect Browser 4.4
             */
            saveWindowContexts?: boolean;
        }

        /**
         * Options for restoring a Layout.
         */
        export interface RestoreOptions {

            /**
             * Name of the Layout to restore.
             */
            name: string;

            /**
             * Context object that will be passed to the restored apps. It will be merged with the saved context object.
             */
            context?: object;

            /**
             * If `true`, will close all visible running instances before restoring the Layout.
             * The only exception is the Main app (Web Platform) - it will never be closed when restoring a Layout.
             * @default true
             */
            closeRunningInstances?: boolean;

            /**
             * If `true`, will close the current app before restoring a Layout. If `closeRunningInstances` is set to `false`, this will default to `false` too.
             * @default true
             */
            closeMe?: boolean;

            /**
             * Timeout in milliseconds for restoring the Layout. If the time limit is hit, all apps opened up to this point will be closed and an error will be thrown.
             * @default 60000
             */
            timeout?: number;
        }

        /**
         * Object returned by the handler for a save Layout request.
         */
        export interface SaveRequestResponse {
            /** Context to be saved for the specific app in the Layout. */
            windowContext: object;
        }

        /**
         * Object passed as an argument to the handler for a save Layout request.
         */
        export interface SaveRequestContext {
            /** Context for the Layout. */
            context?: unknown;
            /** Name of the Layout. */
            layoutName: string;
            /** Type of the Layout. */
            layoutType: LayoutType;
        }

        /**
         * Describes the base result returned by methods for manipulating Layouts - e.g., renaming, hibernating, updating default context.
         */
        export interface LayoutResult {
            /** Status of the Layout operation. If successful, will be set to "Success", otherwise, will contain the returned error message. */
            status: string;
        }
    }

    /**
     * @intro
     * The Notifications API provides a way to display native notifications with actions and to handle notification and action clicks.
     * **io.Connect Browser** supports all available notification settings as defined in the [DOM Notifications API](https://developer.mozilla.org/en-US/docs/Web/API/Notifications_API).
     *
     * The **io.Connect Browser** Notifications API extends the DOM Notifications API with the option to handle notification and action clicks using Interop methods.
     *
     * The Notifications API is accessible via the [`io.notifications`](#API) object.
     */
    export namespace Notifications {
        export interface API {
            /**
             * Raises a new notification
             * @param notification notification options
             */
            raise(notification: RaiseOptions): Promise<Notification>;

            /**
             * **io.Connect Browser** only. Retrieves the state of the native browser notification permission for the platform.
             */
            getPermission?(): Promise<"default" | "granted" | "denied">;

            /**
             * **io.Connect Browser** only. Triggers the native browser permission dialog. Must only be called from within a platform.
             */
            requestPermission?(): Promise<boolean>;

            /** Returns a list of all known notifications. */
            list(): Promise<NotificationData[]>;

            /**
             * Notifies the user of any new raised notifications via the Notifications API.
             * @param callback A function which will be called when a new notification is raised.
             */
            onRaised(callback: (notification: NotificationData) => void): UnsubscribeFunction;

            /**
             * Notifies the user when a notification was removed via the Notifications API.
             * @param callback A function which will be called when a notification is removed.
             */
            onClosed(callback: (notification: { id: string }) => void): UnsubscribeFunction;

            /**
             * Notifies when the global notification settings are changed.
             * @param callback Callback function for handling the event.
             */
            onConfigurationChanged(callback: (configuration: Configuration) => void): UnsubscribeFunction;

            /**
             * Notifies when the number of active notification is changed.
             * @param callback Callback function for handling the event.
             */
            onActiveCountChanged(callback: (info: { count: number; }) => void): UnsubscribeFunction;

            /**
             * Alias for `onActiveCountChanged()` for compatibility with **io.Connect Desktop**.
             * @param callback Callback function for handling the event.
             * @since io.Connect Browser 4.0
             */
            onCounterChanged(callback: (info: { count: number; }) => void): UnsubscribeFunction;

            /** Notifies when the state of a notification is changed.
             * @param callback Callback function for handling the event.
             */
            onStateChanged(callback: (notification: { id: string; }, state: State) => void): UnsubscribeFunction;

            /**
             * Issues a programmatic click on a notification.
             * @param id The id of the notification to click on.
             * @param actions Optional action value to click on.
             */
            click(id: string, action?: string): Promise<void>;

            /**
             * Clears a specified notification.
             * @param id The id of the notification to be removed.
             */
            clear(id: string): Promise<void>;

            /** Removes all known notifications from the system. */
            clearAll(): Promise<void>;

            /** Clears all notifications that the user has already seen. */
            clearOld(): Promise<void>;

            /**
             * Configures the Global notification settings.
             * @param options configuration options
             */
            configure(options: Configuration): Promise<void>;

            /** Retrieves the current global notification settings. */
            getConfiguration(): Promise<Configuration>;

            /** Retrieves the current filter with apps allowed or not allowed to raise notifications. */
            getFilter(): Promise<NotificationFilter>;

            /**
             * Sets a filter with apps allowed or not allowed to raise notifications.
             * @param filter Filter with names of apps allowed or not allowed to raise notifications.
             */
            setFilter(filter: NotificationFilter): Promise<NotificationFilter>;

            /**
             * Sets the state of a notification.
             * @param id ID of the notification to change.
             * @param state Value for the new notification state.
             */
            setState(id: string, state: State): Promise<void>;
        }

        /**
         * Notification states that are used by the platform when handling notifications. These states can also be used in your custom logic for processing notifications on the client or on the server side. Defaults to `"Active"`.
         * - `"Active"` - a notification can be marked as active when it is raised, but the user hasn't seen it, or interacted in any way with it yet;
         * - `"Acknowledged"` - a notification can be marked as acknowledged when the user has interacted with it by clicking on the notification or on an action in it;
         * - `"Seen"` - a notification can be marked as seen when the user has seen it (e.g., by opening the Notification Panel);
         * - `"Closed"` - a notification can be marked as closed when the user has closed the notification in the Notification Panel;
         * - `"Stale"` - a notification can be marked as stale after a predefined period of time;
         * - `"Snoozed"` - a notification can be marked as snoozed when the user snoozes it from the UI;
         * - `"Processing"` - a notification can be marked as `"Processing"` when its state is in the process of changing (e.g., the user interacts with a notification from the UI, you make a request to a remote service to update the notification state, and you are still waiting for a response);
         */
        export type State = "Active" | "Acknowledged" | "Seen" | "Closed" | "Stale" | "Snoozed" | "Processing";

        export interface NotificationDefinition {
            badge?: string;
            body?: string;
            data?: any;
            dir?: "auto" | "ltr" | "rtl";
            icon?: string;
            image?: string;
            lang?: string;
            renotify?: boolean;
            requireInteraction?: boolean;
            silent?: boolean;
            tag?: string;
            timestamp?: number;
            vibrate?: number[];
        }

        export interface RaiseOptions extends NotificationDefinition {
            /** The title of the notification */
            title: string;
            /** Set to make the notification click invoke an interop method with specific arguments */
            clickInterop?: InteropActionSettings;
            /** List of action attached to the notification. Those will appear as buttons in the notification UI */
            actions?: NotificationAction[];
            /** **io.Connect Browser** only. If set to `true`, the platform app will be focused when the user clicks on the notification. Defaults to false. */
            focusPlatformOnDefaultClick?: boolean;
            /** Severity of the alert */
            severity?: "Low" | "Medium" | "High" | "Critical" | "None";
            /** Indicates whether a native toast will be shown or not. Defaults to `true` */
            showToast?: boolean;
            /** Indicates whether the notification should appear in notification panels. Defaults to `true` */
            showInPanel?: boolean;
            /** Notification state. Defaults to `"Active"` */
            state?: State;
        }

        export interface NotificationData extends RaiseOptions {
            id: string;
        }

        export interface Notification extends NotificationData {
            onclick: () => any;
            onshow: () => any;
        }

        export interface NotificationAction {
            action: string;
            title: string;
            icon?: string;
            /** set to make the action invoke an interop method with specific arguments */
            interop?: InteropActionSettings;
        }

        export interface InteropActionSettings {
            method: string;
            arguments?: any;
            target?: "all" | "best";
        }

        export type NotificationClickHandler = (io: IOConnectBrowser.API, notificationDefinition: NotificationDefinition) => void;

        export interface ActionClickHandler {
            action: string;
            handler: NotificationClickHandler;
        }

        export interface Settings {
            defaultClick: NotificationClickHandler;
            actionClicks: ActionClickHandler[];
        }

        /** Global notification settings */
        export interface Configuration {
            /** If `true`, will enable all notifications. */
            enable?: boolean;
            /** If `true`, will enable notification toasts. */
            enableToasts?: boolean;
            /** Filter with names of apps that are allowed or not allowed to raise notifications. */
            sourceFilter?: NotificationFilter;
            /**
             * If `true`, will enable showing a notification badge in the io.Connect Home App.
             * @default true
             * @since io.Connect Browser 4.0
             */
            showNotificationBadge?: boolean;
        }

        /** Filter with names of apps that are allowed or not allowed to raise notifications. */
        export interface NotificationFilter {
            /** Array of names of apps allowed to raise notifications. */
            allowed?: string[];
            /** Array of names of apps not allowed to raise notifications. */
            blocked?: string[];
        }
    }

    /**
     * @intro
     * Channels are globally accessed named contexts that allow users to dynamically group apps, instructing them to work over the same shared data object.
     *
     * The Channels API enables you to:
     *
     * - retrieve the names and contexts of all Channels;
     * - retrieve the current Channel, join and leave Channels, subscribe for the event which fires when the current Channel has changed;
     * - publish data to other apps on the same Channel and subscribe for Channel updates to react to data published by other apps;
     *
     * The Channels API is accessible via the [`io.channels`](#API) object.
     */
    namespace Channels {
        /**
         * Channels API.
         */
        export interface API {
            /**
             * Retrieves the current Channel mode (single or multi Channel). Set by the io.Connect framework based on configuration.
             * @default "single"
             * @since io.Connect Browser 3.5
             */
            mode: Mode;

            /**
             * Tracks the data in the current channel. Persisted after a channel change.
             * The callback isn't called when you publish the data.
             * @param callback Callback function to handle the received data.
             * @param options Settings for subscribing to an FDC3 context published in the io.Connect Channel.
             * @returns Unsubscribe function.
             */
            subscribe(callback: (data: any, context: ChannelContext, updaterId: string) => void, options?: FDC3Options): UnsubscribeFunction;

            /**
             * Tracks the data in a given channel.
             * @param name The channel to track.
             * @param callback Callback function to handle the received data.
             * @param options Settings for subscribing to an FDC3 context published in the io.Connect Channel.
             * @returns Promise that resolves with an unsubscribe function.
             */
            subscribeFor(name: string, callback: (data: any, context: ChannelContext, updaterId: string) => void, options?: FDC3Options): Promise<UnsubscribeFunction>;

            /**
             * Updates the context of the current or a given channel.
             * @param data Data object with which to update the channel context.
             * @param options The name of the Channel to update, or an object containing the name of the Channel to update and a flag indicating whether the published data is an FDC3 context. If no options are provided, the current Channel will be updated.
             * @returns Promise that resolves when the data has been published.
             */
            publish(data: any, options?: string | PublishOptions): Promise<void>;

            /**
             * Returns a list of all channel names.
             * @returns Promise that resolves with the list of all channel names.
             */
            all(): Promise<string[]>;

            /**
             * Returns a list of all channel contexts.
             * @returns Promise that resolves with the list of all channel contexts.
             */
            list(): Promise<ChannelContext[]>;

            /**
             * Returns the context of a given channel.
             * @param name The name of the channel whose context to return.
             * @param options Settings for retrieving an FDC3 context published in the io.Connect Channel.
             * @returns Promise that resolves with the context of the given channel.
             */
            get(name: string, options?: FDC3Options): Promise<ChannelContext>;

            /**
             * Retrieves a list with the contexts of the current Channels. Can be used both in single and in multi Channel mode.
             * If used in single Channel mode, the returned array will always contain a single member if the window is joined to a Channel, or will be empty otherwise.
             * @since io.Connect Browser 3.5
             */
            getMyChannels(): Promise<ChannelContext[]>;

            /**
             * Retrieves a list with the names of the current Channels. Can be used both in single and in multi Channel mode.
             * If used in single Channel mode, the returned array will always contain a single member if the window is joined to a Channel, or will be empty otherwise.
             * @since io.Connect Browser 3.5
             */
            myChannels(): string[];

            /**
             * Joins a new channel by name. Leaves the current channel.
             * @param name The name of the channel to join.
             * @param windowId ID of a window which to join to a Channel. If not provided, will join the current window to the specified Channel.
             * @returns Promise that resolves when the channel has been joined.
             */
            join(name: string, windowId?: string): Promise<void>;

            /**
             * Removes the current or a specified window from the current or a specified Channel.
             * @param options Options for leaving Channels.
             */
            leave(options?: LeaveOptions): Promise<void>;

            /**
             * Returns the name of the current channel.
             * @ignore
             * @returns The name of the current channel.
             */
            current(): string;

            /**
             * Retrieves the name of the current Channel.
             * It's recommended to use the `myChannels()` method instead, which can retrieve the names of the currently joined Channels both in single and in multi Channel mode.
             */
            my(): string;

            /**
             * Subscribes for the event which fires when a channel is changed.
             * @ignore
             * @param callback Callback function to handle channel changes.
             * @returns Unsubscribe function.
             */
            changed(callback: (channel: string) => void): UnsubscribeFunction;

            /**
             * Notifies when the current window joins or leaves a Channel. Returns an unsubscribe function.
             * It's recommended to use the `onChannelsChanged()` method instead, which can handle Channel changes both in single and in multi Channel mode.
             * @param callback Callback function for handling the event. Receives as an argument the name of the newly joined Channel. If the window leaves a Channel without joining a new one, the argument will be `undefined`.
             */
            onChanged(callback: (channel: string) => void): UnsubscribeFunction;

            /**
             * Notifies when the current window joins or leaves a Channel. Can be used both in single and in multi Channel mode.
             * If used in single Channel mode, when the window joins a Channel, the array argument passed to the callback for handling the event
             * will always contain a single member; when the window leaves the current Channel, the array will be empty. Returns an unsubscribe function.
             * @param callback Callback function for handling the event. Receives a list with the names of the currently joined Channels as an argument.
             * @since io.Connect Browser 3.5
             */
            onChannelsChanged(callback: (channels: string[]) => void): UnsubscribeFunction;

            /**
             * Adds a new Channel.
             * @param info Initial Channel context.
             */
            add(info: ChannelDefinition): Promise<ChannelContext>;

            /**
             * Removes a Channel.
             * @param name The name of the Channel to remove.
             */
            remove(name: string): Promise<void>;

            /**
             * Retrieves the context of the current Channel.
             * It's recommended to use the `getMyChannels()` method instead, which can retrieve the contexts of the currently joined Channels both in single and in multi Channel mode.
             * @param options Settings for retrieving an FDC3 context published in the io.Connect Channel.
             */
            getMy(options?: FDC3Options): Promise<ChannelContext | undefined>;

            /**
             * Retrieves all windows on a specified Channel.
             * @param channel The name of the Channel for which windows should be returned.
             * @returns Promise that resolves with the list of all windows on a specified Channel.
             */
            getWindowsOnChannel(channel: string): Promise<IOConnectBrowser.Windows.WebWindow[]>

            /**
             * Retrieves all windows that can use Channels together with their current Channel.
             * @param filter Filter describing which windows to retrieve. If no filter is supplied, will return all windows that can use Channels.
             * @returns Promise that resolves with the list of all windows that can use Channels together with their current Channel.
             */
            getWindowsWithChannels(filter?: WindowWithChannelFilter): Promise<WindowOnChannelInfo[]>;

            /**
             * Prevents or allows the current or another window to publish or subscribe to a specific Channel.
             * @param restrictions Restrictions for publishing or subscribing to a specific Channel.
             * @since io.Connect Browser 3.3
             */
            restrict(config: ChannelRestrictions): Promise<void>;

            /**
             * Retrieves the restrictions applied to the current window for publishing or subscribing to Channels. Pass a window ID to retrieve the restrictions for the specified window.
             * @param windowId ID of the window for which to retrieve the applied restrictions for publishing or subscribing to Channels.
             * @since io.Connect Browser 3.3
             */
            getRestrictions(windowId?: string): Promise<Restrictions>;

            /**
             * Prevents or allows the current or another window to publish or subscribe to all Channels.
             * @param restrictions Restrictions for publishing or subscribing to all Channels.
             * @since io.Connect Browser 3.3
             */
            restrictAll(restrictions: RestrictionsConfig): Promise<void>;

            /**
             * Clears the context data of the current Channel. The `data` property of the Channel context is set to an empty object.
             * Pass a Channel name as an argument to clear the data of a specific Channel.
             * @param name Name of the Channel whose context data to clear.
             * @since io.Connect Browser 4.0
             */
            clearChannelData(name?: string): Promise<void>;

            /**
             * Sets a specified path within the Channel context to the provided value. If the path doesn't exist, it will be created.
             * @param path Object containing the path to update and the value with which to update it. The path must be specified as a dot-separated string (e.g., `"prop1.prop2"`).
             * @param name Name of the Channel to update. If not specified, will update the current Channel.
             * @since io.Connect Browser 4.0
             */
            setPath(path: IOConnectBrowser.Contexts.PathValue, name?: string): Promise<void>;

            /**
             * Sets a list of specified paths within the Channel context to the provided values. If a path doesn't exist, it will be created.
             * @param paths List of objects each containing a path to update and the value with which to update it. The path must be specified as a dot-separated string (e.g., `"prop1.prop2"`).
             * @param name Name of the Channel to update. If not specified, will update the current Channel.
             * @since io.Connect Browser 4.0
             */
            setPaths(paths: IOConnectBrowser.Contexts.PathValue[], name?: string): Promise<void>;
        }

        /**
         * Channel mode. In single Channel mode, io.Connect Windows can join or leave only one Channel at a time.
         * In multi Channel mode, io.Connect Windows can join or leave multiple Channels simultaneously.
         * The Channel mode is set by the io.Connect framework based on configuration.
         */
        export type Mode = "single" | "multi";

        /**
         * Settings for retrieving and subscribing for FDC3 contexts published in an io.Connect Channel.
         */
        export interface FDC3Options {
            /**
             * Type of the FDC3 context to retrieve or to which to subscribe.
             */
            contextType?: string;
        }

        /**
         * Options for leaving Channels.
         * If only a window ID is provided, the specified window will be removed from the current Channel if in single Channel mode,
         * or from all currently joined Channels if in multi Channel mode.
         * If you provide only the name of the Channel to leave, the current window will be removed from the specified Channel.
         * If you don't provide an argument, the current window will be removed from the current Channel if in single Channel mode,
         * or from all currently joined Channels if in multi Channel mode.
         * @since io.Connect Browser 3.5
         */
        export interface LeaveOptions {
            /**
             * ID of an io.Connect Window which to remove from a Channel.
             */
            windowId?: string;

            /**
             * Name of a Channel from which to remove the current or a specified window.
             */
            channel?: string;
        }

        /**
         * Options for updating a Channel context with the `publish()` method.
         */
        export interface PublishOptions {
            /**
             * The name of the Channel to update. If not provided, the current Channel will be updated.
             */
            name?: string;

            /**
             * Flag indicating whether the published data is an FDC3 context. If so, it must contain a required `type` property.
             */
            fdc3?: boolean;
        }

        /**
         * All restrictions applied to a window for publishing or subscribing to Channels.
         */
        export interface Restrictions {
            /**
             * List of restrictions for publishing or subscribing to Channels.
             */
            channels: ChannelRestrictions[];
        }

        /**
         * Restrictions applied to a window for publishing or subscribing to a specific Channel.
         */
        export interface ChannelRestrictions extends RestrictionsConfig {
            /**
             * Name of the Channel for which the restrictions apply.
             */
            name: string;
        }

        /**
         * Restrictions applied to a window for publishing or subscribing to all Channels.
         */
        export interface RestrictionsConfig {
            /**
             * If `true`, the window will be able to subscribe to the specified Channel.
             */
            read: boolean;
            /**
             * If `true`, the window will be able to publish to the specified Channel.
             */
            write: boolean;
            /**
             * ID of the window for which apply the restrictions for publishing or subscribing to Channels.
             */
            windowId?: string;
        }

        /**
         * Provide display hints for FDC3 User Channels intended to be visualized and selectable by end users.
         */
        export interface FDC3ChannelDisplayMetadata {
            /**
             *  A user-readable name for this channel, e.g: `"Red"`. */
            name?: string;
            /**
             *  The color that should be associated within this channel when displaying
             *  this channel in a UI, e.g: `#FF0000`. May be any color value supported by
             *  CSS, e.g. name, hex, rgba, etc.. */
            color?: string;

            /**
             *  A URL of an image that can be used to display this channel. */
            glyph?: string;
        }

        export interface FDC3ChannelMeta {
            id: string;
            displayMetadata?: FDC3ChannelDisplayMetadata;
        }

        export interface ChannelMeta {
            color: string;
            /**
             * Provide to enable FDC3 channel support.
             */
            fdc3?: FDC3ChannelMeta;
            [key: string]: any;
        }

        /**
         * Initial context for creating a channel runtime.
         */
        export interface ChannelDefinition {
            /** Unique name of the context. */
            name: string;
            /** Channel meta data (display name, color, image, etc.) */
            meta: ChannelMeta;
            /** Channel data. */
            data?: any;
        }

        export interface FDC3Context {
            /**
             * Context data objects may contain equivalent key-value pairs for identifying and looking up context types, with optional identifiers to support various applications,
             * though some types may require at least one identifier.
             */
            id?: {
                [key: string]: any;
            };
            /**
             * Context data objects may include a "name" property for additional information or display, with some derived types making it mandatory based on the use case.
             */
            name?: string;
            /**
             * Required field in the FDC3 context data schema, essential for routing context data and for intent discovery within the FDC3 ecosystem.
            */
            type: string;
            [property: string]: any;
        }

        /**
         * Channel context object.
         */
        export interface ChannelContext {
            /** Unique name of the context. */
            name: string;
            /** Channel meta data (display name, color, image, etc.) */
            meta: any;
            /** Channel data. */
            data: {
                /**
                 * FDC3 context data. Will be present only if FDC3 context data has been published to the respective Channel.
                 */
                fdc3?: FDC3Context;
                [key: string]: any
            };
        }

        /**
         * Filter for retrieving windows that can use Channels.
         */
        export interface WindowWithChannelFilter {
            /** Name of the app whose window instances to retrieve. */
            application?: string;
            /** List of Channel names. Only the windows that are joined to one of the specified Channels will be retrieved. */
            channels?: string[];
            /** IDs of windows to retrieve. */
            windowIds?: string[];
        }

        /**
         * Describes a window that can use Channels.
         */
        export interface WindowOnChannelInfo {
            /** Name of the app to which the window instance belongs. */
            application: string;
            /** Name of the Channel to which the window is joined. */
            channel: string | undefined;
            /** Describes the window instance. */
            window: IOConnectBrowser.Windows.WebWindow
        }

    }

    /**
     * @docname App Management
     * @intro
     * The App Management API provides a way to manage **io.Connect Browser** apps. It offers abstractions for:
     *
     * - **Application** - a web app as a logical entity, registered in **io.Connect Browser** with some metadata (name, title, version, etc.)
     * and with all the configuration needed to spawn one or more instances of it.
     * The App Management API provides facilities for retrieving app metadata and for detecting when an app has been added or removed.
     *
     * - **Instance** -  a running copy of a web app hosted in an io.Connect Window. The App Management API provides facilities for
     * starting and stopping app instances and tracking app and instance related events.
     *
     * The App Management API is accessible via the [`io.appManager`](#API) object.
     */
    namespace AppManager {
        /**
         * Application Management API.
         */
        export interface API {
            /** The instance of the application. */
            myInstance: Instance;

            /**
             * Object that can be used for handling app definitions dynamically.
             */
            inMemory: InMemory;

            /**
             * Returns an application by name.
             * @param name Name of the desired application.
             * @returns The application.
             */
            application(name: string): Application;

            /** Returns a list of all applications.
             * @returns A list of all applications.
             */
            applications(): Application[];

            /** Returns an array with all running application instances.
             * @returns A list of all running application instances.
             */
            instances(): Instance[];

            /**
             * Notifies when a new application instance has been started.
             * Replays the already started instances.
             * @param callback Callback function to handle the event. Receives the started application instance as a parameter.
             * @returns Unsubscribe function.
             */
            onInstanceStarted(callback: (instance: Instance) => any): UnsubscribeFunction;

            /**
             * Notifies when an application instance has been stopped.
             * @param callback Callback function to handle the event. Receives the stopped application instance as a parameter.
             * @returns Unsubscribe function.
             */
            onInstanceStopped(callback: (instance: Instance) => any): UnsubscribeFunction;

            /**
             * Notifies when an application is registered in the environment.
             * Replays the already added applications.
             * @param callback Callback function to handle the event. Receives the added application as a parameter.
             * @returns Unsubscribe function.
             */
            onAppAdded(callback: (app: Application) => any): UnsubscribeFunction;

            /**
             * Notifies when the application is removed from the environment.
             * @param callback Callback function to handle the event. Receives the removed application as a parameter.
             * @returns Unsubscribe function.
             */
            onAppRemoved(callback: (app: Application) => any): UnsubscribeFunction;

            /**
             * Notifies when the configuration for an application has changed.
             * @param callback Callback function to handle the event. Receives the changed application as a parameter.
             * @returns Unsubscribe function.
             */
            onAppChanged(callback: (app: Application) => any): UnsubscribeFunction;
        }

        /**
         * Object that can be used for handling app definitions dynamically. The described methods operate only on in-memory app definitions.
         */
        export interface InMemory {
            /**
             * Imports the provided collection of app definitions.
             * @param definitions A collection of app definition objects to be imported.
             * @param mode Mode for importing app definitions. Use `"replace"` (default) to replace all existing in-memory app definitions. Use `"merge"` to update the existing ones and add new ones.
             */
            import(definitions: (Definition | FDC3DefinitionV1 | FDC3DefinitionV2)[], mode?: "replace" | "merge"): Promise<ImportResult>;

            /**
             * Exports all available app definitions from the in-memory store.
             */
            export(): Promise<(Definition | FDC3DefinitionV1 | FDC3DefinitionV2)[]>;

            /**
             * Removes an app definition from the in-memory store.
             * @param name Name of the app to be removed.
             */
            remove(name: string): Promise<void>;

            /**
             * Removes all app definitions from the in-memory store.
             */
            clear(): Promise<void>;
        }

        export interface ImportResult {
            /** A list of names of the successfully imported application definitions */
            imported: string[];

            /** A list of application names and errors of all the unsuccessful imports */
            errors: Array<{ app: string; error: string }>;
        }

        /**
         *  Configuration for the `sandbox` attribute of the `<iframe>` element in which the app will be started when opened in a Workspace.
         */
        export interface WorkspacesSandbox {
            /**
             *  Collection of flags that will be applied to the `<iframe>` element when the app is opened in a Workspace.
             */
            flags: string;
        }

        /**
         * Settings for the Channel Selector displayed on an io.Connect Window.
         */
        export interface ChannelSelector {
            /**
             * If `true`, the Channel Selector will be enabled for the window.
             */
            enabled: boolean;
        }

        /**
         *  Configuration for the `allow` attribute of the `<iframe>` element in which the app will be started when opened in a Workspace.
         */
        export interface IFramePermissionsPolicyConfig {
            /**
             *  Collection of flags that will be applied to the `<iframe>` element when the app is opened in a Workspace.
             */
            flags: string;
        }

        export interface DefinitionDetails {
            url: string;

            /**
             * Distance of the top left window corner from the top edge of the screen.
             * @default 0
             */
            top?: number;

            /**
             * Distance of the top left window corner from the left edge of the screen.
             * @default 0
             */
            left?: number;

            /**
             * Window width.
             * @default 400
             */
            width?: number;

            /**
             * Window height.
             * @default 400
             */
            height?: number;

            /**
             * Configuration for the `sandbox` attribute of the `<iframe>` element in which the app will be started when opened in a Workspace.
             */
            workspacesSandbox?: WorkspacesSandbox;

            /**
             * Settings for the Channel Selector displayed on an io.Connect Window.
             */
            channelSelector?: ChannelSelector;

            /**
             * Configuration for the `sandbox` attribute of the `<iframe>` element in which the app will be started when opened in a Workspace.
             */
            iframePermissionsPolicy?: IFramePermissionsPolicyConfig;
        }

        /**
         * An intent definition.
         */
        export interface Intent {
            /**
             * The name of the intent to 'launch'. In this case the name of an Intent supported by an Application.
             */
            name: string;

            /**
             * An optional display name for the intent that may be used in UI instead of the name.
             */
            displayName?: string;

            /**
             * A comma separated list of the types of contexts the intent offered by the application can process, here the first part of the context type is the namespace e.g."fdc3.contact, org.symphony.contact".
             */
            contexts?: string[];

            /**
             * Custom configuration for the intent that may be required for a particular desktop agent.
             */
            customConfig?: object;

            /**
             * Result type may be a type name, the string "channel" (which indicates that the app will return a channel) or a string indicating a channel that returns a specific type, e.g. "channel<fdc3.instrument>"
             */
            resultType?: string;
        }

        export interface Definition {
            /**
             * Application name. Should be unique.
             */
            name: string;

            /**
             * Type of the application - the only supported type in **io.Connect Browser** is "window". More complex types are available in **io.Connect Desktop**.
             */
            type: string;

            /**
             * The title of the app. Sets the window's title.
             */
            title?: string;

            /**
             * Application version.
             */
            version?: string;

            /**
             * Detailed configuration.
             */
            details: DefinitionDetails;

            /**
             * Generic object for passing properties, settings, etc., in the for of key/value pairs. Accessed using the app.userProperties property.
             */
            customProperties?: PropertiesObject;

            /**
             * Application icon.
             */
            icon?: string;

            /**
             * Application caption.
             */
            caption?: string;

            /**
             * The list of intents implemented by the Application
             */
            intents?: Intent[];

            /**
             * If set to true, the application will not be listed in the **io.Connect Browser** Launchpad. Defaults to false.
             */
            hidden?: boolean;

            /**
             * The FDC3 2.0 version of the definition. If set, this means the current definition was imported as FDC3 2.0 and parsed to IOConnectBrowser one.
             */
            fdc3?: FDC3DefinitionV2;
        }

        export interface FDC3DefinitionV1 {
            /**
             * Application name. Should be unique.
             */
            name: string;

            /**
             * The title of the application. Sets the window's title.
             */
            title?: string;

            /**
             * Application version.
             */
            version?: string;

            /**
             * The unique application identifier located within a specific application directory instance.
             */
            appId: string;

            /**
             * URI or full JSON of the application manifest providing all details related to launch and use requirements as described by the vendor.
             * The format of this manifest is vendor specific, but can be identified by the manifestType attribute.
             */
            manifest: string;

            /**
             * The manifest type which relates to the format and structure of the manifest content. The definition is based on the vendor specific format and definition outside of this specification.
             */
            manifestType: string;

            /**
             * Optional tooltip description e.g. for a launcher.
             */
            tooltip?: string;

            /**
             * Description of the application.This will typically be a 1 - 2 paragraph style blurb about the application.Allow mark up language.
             */
            description?: string;

            /**
             * Optional e - mail to receive queries about the application.
             */
            contactEmail?: string;

            /**
             * Optional e - mail to receive support requests for the application.
             */
            supportEmail?: string;

            /**
             * The name of the company that owns the application.The publisher has control over their namespace / app / signature.
             */
            publisher?: string;

            /**
             * Array of images to show the user when they are looking at app description.Each image can have an optional description / tooltip.
             */
            images?: ImageV1[];

            /**
             * Holds Icons used for the application, a Launcher may be able to use multiple Icon sizes or there may be a 'button' Icon.
             */
            icons?: IconV1[];

            /**
             * An optional set of name value pairs that can be used to deliver custom data from an App Directory to a launcher.
             */
            customConfig?: PropertiesObject;

            /**
             * The list of intents implemented by the Application
             */
            intents?: Intent[];
        }

        /** App Image holder */
        interface ImageV1 {
            /**
             * App Image URL.
             */
            url?: string;
        }

        /** Icon holder */
        interface IconV1 {
            /**
             * Icon URL.
             */
            icon?: string;
        }

        interface LocalizedVersionDefinition {
            appId?: string;
            name?: string;
            type?: FDC3DefinitionV2Types;
            details?: {
                url: string;
            };
            version?: string;
            title?: string;
            tooltip?: string;
            lang?: string;
            description?: string;
            categories?: string[];
            icons?: IconV2[];
            screenshots?: ImageV2[];
            contactEmail?: string;
            supportEmail?: string;
            moreInfo?: string;
            publisher?: string;
            customConfig?: PropertiesObject[];
            hostManifests?: any;
            interop?: InteropV2;
            localizedVersions?: { [languageTag: string]: LocalizedVersionDefinition };
        }

        export interface FDC3DefinitionV2 {
            /**
             * The unique application identifier located within a specific application directory instance.
             */
            appId: string;

            /**
             * The name of the application. The name should be unique within an FDC3 App Directory instance.
             * The exception to the uniqueness constraint is that an App Directory can hold definitions for multiple versions of the same app.
             * The same appName could occur in other directories. We are not currently specifying app name conventions in the document.
             */
            name?: string;

            /**
             * Enum: "web" "native" "citrix" "onlineNative" "other".
             * The technology type that is used to launch and run the application. Each application type implies a particular set of launch details
             */
            type: FDC3DefinitionV2Types;

            /**
             * The type specific launch details of the application.
             * These details are intended to be vendor-agnostic and MAY be duplicated or overridden by details provided in the hostManifests object for a specific host.
             */
            details: {
                url: string;
            };

            /**
             * Version of the application. This allows multiple app versions to be defined using the same app name. This can be a triplet but can also include things like 1.2.5 (BETA)
             */
            version?: string;

            /**
             * Optional title for the application, if missing use appName, typically used in a launcher UI.
             */
            title?: string;

            /**
             * Optional tooltip description e.g. for a launcher
             */
            tooltip?: string;

            /**
             * A language tag that specifies the primary language of both the application and its AppD entry, as defined by IETF RFC 5646.
             */
            lang?: string;

            /**
             * Description of the application. This will typically be a 1-2 paragraph style blurb about the application.
             */
            description?: string;

            /**
             * An array of string categories that describe the application.
             * These are meant as a hint to catalogs or stores listing FDC3-enabled apps and it is expected that these will make a best effort to find appropriate categories (or category) under which to list the app.
             */
            categories?: string[];

            /**
             * Holds Icons used for the application, a Launcher may be able to use multiple Icon sizes or there may be a 'button' Icon
             */
            icons?: IconV2[];

            /**
             * Array of images to show the user when they are looking at app description. Each image can have an optional description/tooltip
             */
            screenshots?: ImageV2[];

            /**
             * Optional e-mail to receive queries about the application
             */
            contactEmail?: string;

            /**
             * Optional e-mail to receive support requests for the application
             */
            supportEmail?: string;

            /**
             * Optional URL that provides more information about the application
             */
            moreInfo?: string;

            /**
             * The name of the company that owns the application. The publisher has control over their namespace/app/signature.
             */
            publisher?: string;

            /**
             * An optional set of name value pairs that can be used to deliver custom data from an App Directory to a launcher
             */
            customConfig?: PropertiesObject[];

            /**
             * A mapping from host name to a host-specific application manifest object or URI from which that manifest can be retrieved.
             * The manifest should provide details required to launch and use the application within the specified host.
             * The manifest MAY duplicate or override information provided in the details field.
             */
            hostManifests?: any;

            /**
             * Metadata that describes how the application uses FDC3 APIs. This metadata serves multiple purposes:
             * - It supports intent resolution by a desktop agent, by declaring what intents an app listens for.
             * - It may be used, for example in an app catalog UI, to find apps that 'interoperate with' other apps.\
             * - It provides a standard location to document how the app interacts with user channels, app channels, and intents, for use by other app developers and desktop assemblers.
             */
            interop?: InteropV2;

            /**
             * Provides localized alternatives to any field of the AppD record, which may also refer to an alternative version of the application that is also localized
             * (e.g. by providing an alternative URL). The keys to this object should be language tags as defined by IETF RFC 5646, e.g. en, en-GB or fr-FR.
             */
            localizedVersions?: { [languageTag: string]: LocalizedVersionDefinition };
        }

        type FDC3DefinitionV2Types = "web" | "native" | "citrix" | "onlineNative" | "other";

        interface IconV2 {
            src: string;
            size?: string;
            type?: string;
        }

        interface ImageV2 {
            src: string;
            size?: string;
            type?: string;
            label?: string;
        }

        type IntentV2 = Omit<Intent, "name">;

        interface InteropIntentsV2 {
            listensFor?: { [intentName: string]: IntentV2 };
            raises?: { [intentName: string]: string[] };
        }

        interface InteropUserChannelV2 {
            broadcasts?: string[];
            listensFor?: string[];
        }

        interface InteropAppChannelV2 {
            name: string;
            description?: string;
            broadcasts?: string[];
            listensFor?: string[];
        }

        interface InteropV2 {
            intents?: InteropIntentsV2;
            userChannels?: InteropUserChannelV2;
            appChannels?: InteropAppChannelV2[];
        }

        /** Object describing an app. */
        export interface Application {
            /** Application name. */
            name: string;

            /** Application title. */
            title?: string;

            /** Application version. */
            version?: string;

            /** Application icon. */
            icon?: string;

            /** Application caption. */
            caption?: string;

            /** Generic object for passing properties, settings, etc., in the for of key/value pairs. */
            userProperties: PropertiesObject;

            /** Instances of that app. */
            instances: Instance[];

            /**
             * Retrieves the definition of the current app.
             * @since io.Connect Browser 4.3
             */
            getConfiguration(): Promise<Definition>;

            /**
             * Returns the newly started application instance.
             * @param context The initial context of the application.
             * @param options Options object in which you can specify window setting (that will override the default configuration settings), as well as other additional options.
             * @returns Promise that resolves with the newly started application instance.
             */
            start(context?: object, options?: ApplicationStartOptions): Promise<Instance>;

            /**
             * Subscribes for the event which fires when an application instance is started.
             * Note: unlike the API's `onInstanceStarted()` the Application's `onInstanceStarted()` method doesn't replay the already started instances.
             * @param callback Callback function to handle the newly started instance.
             * @returns Unsubscribe function.
             */
            onInstanceStarted(callback: (instance: Instance) => any): UnsubscribeFunction;

            /**
             * Subscribes for the event which fires when an application instance is stopped.
             * @param callback Callback function to handle the newly started instance.
             * @returns Unsubscribe function.
             */
            onInstanceStopped(callback: (instance: Instance) => any): UnsubscribeFunction;
        }

        /**
         * Object with options for starting an application.
         */
        export interface ApplicationStartOptions {

            /**
             * Distance of the top left window corner from the top edge of the screen.
             * @default 0
             */
            top?: number;

            /**
             * Distance of the top left window corner from the left edge of the screen.
             * @default 0
             */
            left?: number;

            /**
             * Window width.
             * @default 400
             */
            width?: number;

            /**
             * Window height.
             * @default 400
             */
            height?: number;

            /**
             * The ID of the window that will be used to relatively position the new window.
             * Can be combined with `relativeDirection`.
             */
            relativeTo?: string;

            /**
             * Direction (`"bottom"`, `"top"`, `"left"`, `"right"`) of positioning the window relatively to the `relativeTo` window. Considered only if `relativeTo` is supplied.
             * @default "right"
             */
            relativeDirection?: "top" | "left" | "right" | "bottom";

            waitForAGMReady?: boolean;

            /**
             * Name of the Channel which the window will join.
             */
            channelId?: string;
        }

        /** Generic object for passing properties, settings, etc., in the for of key/value pairs. */
        export interface PropertiesObject {
            [key: string]: any;
        }

        /** Object describing an application instance. */
        export interface Instance {
            /** Instance ID. */
            id: string;

            /** The starting context of the instance. */
            getContext(): Promise<object>;

            /** Interop instance. Use this to invoke Interop methods for that instance. */
            agm: Interop.Instance;

            application: Application;

            /** Stops the instance.
             * @returns Promise that resolves when the instance has been stopped.
            */
            stop(): Promise<void>;
        }
    }

    /**
     * @intro
     * In certain workflow scenarios, your app may need to start (or activate) a specific app.
     * For instance, you may have an app showing client portfolios with financial instruments.
     * When the user clicks on an instrument, you want to start an app which shows a chart for that instrument.
     * In other cases, you may want to present the user with several options for executing an action or handling data from the current app.
     *
     * The Intents API makes all that possible by enabling apps to register, find, and raise Intents.
     *
     * The Intents API is accessible via the [`io.intents`](#API) object.
     */
    namespace Intents {

        /**
         * Intents API.
         */
        export interface API {

            /**
             * Raises an intent, optionally passing context to the intent handlers, and optionally targeting specific intent handlers.
             * If no handlers are matching the targeting conditions the promise will be rejected.
             * @param request can be the intent's name or an IntentRequest object carrying the intent, and its optional target, context and start options (see "startNew").
             * @returns Promise that resolves with IntentResult.
             */
            raise(request: string | IntentRequest): Promise<IntentResult>;

            /**
             * Returns all registered Intent.
             * @returns Promise that resolves with all registered intents.
             */
            all(): Promise<Intent[]>;

            /**
             * @ignore
             * @deprecated Use register() method instead
             *
             * If your application is an intent handler use this method to handle incoming intent requests.
             * Please note that when a new instance of your application is started as a result of a raised intent with
             * e.g. `startNew` your application needs to call `addIntentListener()` on startup so that the intent can be resolved.
             * The handler callback will be invoked whenever an intent is raised and your app was selected as an IntentTarget.
             * You can also use this method to register new dynamic intents, that will have the the same lifespan as your application instance.
             * @param intent The intent to be handled. The intent name of an object containing the intent, contextTypes that the intent can handle and a display name.
             * @param handler The callback that will handle a raised intent. Will be called with an IntentContext if it is provided by the raising application.
             * @returns An object with an unsubscribe function under the unsubscribe property.
             */
            addIntentListener(intent: string | AddIntentListenerRequest, handler: (context: IntentContext) => any): { unsubscribe: UnsubscribeFunction };

            /**
             * If your application is an intent handler use this method to handle incoming intent requests.
             * Please note that when a new instance of your application is started as a result of a raised intent with
             * e.g. `startNew` your application needs to call `register()` on startup so that the intent can be resolved.
             * The handler callback will be invoked whenever an intent is raised and your app was selected as an IntentTarget.
             * You can also use this method to register new dynamic intents, that will have the the same lifespan as your application instance.
             * @param intent The intent to be handled. The intent name of an object containing the intent, contextTypes that the intent can handle and a display name.
             * @param handler The callback that will handle a raised intent. Will be called with an IntentContext if it is provided by the raising application and caller - the Interop Instance which raised the intent.
             * @returns Promise that resolves to an object with an unsubscribe function under the unsubscribe property.
             */
            register(intent: string | AddIntentListenerRequest, handler: (context: IntentContext, caller?: IOConnectCore.Interop.Instance) => any): Promise<{ unsubscribe: UnsubscribeFunction }>;

            /**
             * Searches for registered intents.
             * @param intentFilter can be the intent name or a IntentFilter filtering criteria.
             * @returns Promise that resolves with the found intents that match the provided filtering criteria.
             */
            find(intentFilter?: string | IntentFilter): Promise<Intent[]>;

            /**
             * Filters Intent handlers by specified criteria. If there are more than one valid Intent handlers and the Intents Resolver UI is enabled, it will open and display the available handlers.
             * @param handlerFilter Filter for the list of Intent handlers to return.
             */
            filterHandlers(handlerFilter: HandlerFilter): Promise<FilterHandlersResult>;

            /**
             * Retrieves all Intents associated with an Intent handler.
             * @param handler Intent handler whose Intents to retrieve.
             */
            getIntents(handler: IntentHandler): Promise<GetIntentsResult>;

            /**
             * Removes all saved Intent handlers for previously raised Intents.
             */
            clearSavedHandlers(): Promise<void>;

            /**
             * Notifies when a handler for an Intent is added. Returns an unsubscribe function.
             * @param callback Callback function for handling the event. Receives an object describing the added Intent handler as an argument.
             * @since io.Connect Browser 3.5
             */
            onHandlerAdded(callback: (handler: IntentHandler, intentName: string) => void): UnsubscribeFunction;

            /**
             * Notifies when a handler for an Intent is removed. Returns an unsubscribe function.
             * @param callback Callback function for handling the event. Receives an object describing the removed Intent handler as an argument.
             * @since io.Connect Browser 3.5
             */
            onHandlerRemoved(callback: (handler: IntentHandler, intentName: string) => void): UnsubscribeFunction;

            /**
             * Deprecated for **io.Connect Browser**. Intents Resolver API.
             * @ignore
             */
            resolver?: Resolver;
        }

        /**
         * Deprecated. Settings for the legacy Intents Resolver UI for **io.Connect Browser**.
         * @ignore
         */
        export interface Config {
            /**
             * Whether to use Intents Resolver UI to handle raising an intent.
             * The UI provides the user with a list of all available applications and running instances which can handle the raised intent.
             * Default value: true
             */
            enableIntentsResolverUI?: boolean;

            /**
             * Specify your custom application name for Intents Resolver UI which will open when io.intents.raise() is invoked.
             * If not provided, Intents API will use the default Intents Resolver UI application to handle raising an intent with multiple handlers
             */
            intentsResolverAppName?: string;

            /**
             * Timeout to wait for response from Intents Resolver UI
             * @default 60000
             */
            methodResponseTimeoutMs?: number;
        }

        /**
         * Describes an Intent handler app within the Intents Resolver API.
         * @ignore
         */
        interface ResolverIntentHandler {
            /**
             * Name of the Intent handler app.
             */
            applicationName: string;

            /**
             * Title of the Intent handler.
             */
            applicationTitle?: string;

            /**
             * Icon of the Intent handler app.
             */
            applicationIcon?: string;

            /**
             * ID of the Intent handler app instance.
             */
            instanceId?: string;
        }

        /**
         * Deprecated for **io.Connect Browser**. API for controlling the Intents Resolver UI app.
         * @ignore
         */
        export interface Resolver {
            /**
             * Name of the raised Intent.
             */
            intent?: string | IntentRequest;

            /**
             * Version of the Intents Resolver API.
             */
            version: string;

            /**
             * Criteria for filtering the available Intent handlers. Available only if the `filterHandlers()` method was used to open the Intents Resolver UI.
             */
            handlerFilter?: HandlerFilter;

            /**
             * Details about the app instance that opened the Intents Resolver UI.
             */
            caller?: ResolverCaller;

            /**
             * Retrieves the title for the search operation. Available only if the `filterHandlers()` method was used to open the Intents Resolver UI and the `title` property of the `HandlerFilter` object was set.
             */
            getTitle(): string | undefined;

            /**
             * Notifies when a handler for the current Intent is added. Replays already existing handlers.
             * @param callback Callback function for handling the event.
             */
            onHandlerAdded(callback: (handler: ResolverIntentHandler, intent: IntentInfo) => void): UnsubscribeFunction;

            /**
             * Notifies when a handler for the current Intent is removed.
             * @param callback Callback function for handling the event.
             */
            onHandlerRemoved(callback: (removedHandler: ResolverIntentHandler, intent: IntentInfo) => void): UnsubscribeFunction;

            /**
             * Sends the chosen Intent handler to the app which raised the Intent.
             * @param response The Intent handler that will be sent to the app which raised the Intent.
             * @param options Options for sending the Intent handler to the app that raised the Intent.
             */
            sendResponse(response: ResolverIntentHandler, options?: SendResolverResponseOptions): Promise<IOConnectCore.Interop.InvocationResult | undefined>;
        }

        /**
         * Describes the app instance that opened the Intents Resolver UI.
         * @ignore
         */
        export interface ResolverCaller {
            /**
             * ID of the Interop instance of the app that opened the Intents Resolver UI.
             */
            id: string;
            /**
             * Name of the app that opened the Intents Resolver UI.
             */
            applicationName?: string;
            /**
             * Title of the app that opened the Intents Resolver UI.
             */
            applicationTitle?: string;
        }

        /**
         * Options for sending the chosen Intent handler to the app that raised the Intent.
         * @ignore
         */
        export interface SendResolverResponseOptions {
            /**
             * If `true`, the chosen Intent handler will be saved as a handler for the raised Intent. If the handler is saved, the next time the same Intent is raised, the Intents Resolver UI won't open and the saved handler will be used automatically.
             * @default false
             */
            saveHandler: boolean;
            /**
             * Use this property to supply the name of the Intent when the Intents Resolver UI is opened via the `filterHandlers()` method and you want to save the Intent handler for that Intent. If the Intents Resolver UI is opened via the `raise()` method, it isn't necessary to explicitly provide the Intent name here, as specifying an Intent name is mandatory when using the `raise()` method.
             */
            intent?: string;
        }

        /**
         *
         * Use to define dynamic intents, that will have the same lifespan as your application instance
         * */
        export interface AddIntentListenerRequest {
            intent: string;
            contextTypes?: string[];
            displayName?: string;
            icon?: string;
            description?: string;
            resultType?: string;
            customConfig?: { [key: string]: any };
        }

        /**
         * Provides additional information about an Intent (e.g., when an Intent is retrieved via the `getIntents()` method).
         */
        export interface IntentInfo extends AddIntentListenerRequest {}

        /**
         * Criteria for excluding Intent handlers from the results when using the `filterHandlers()` method.
         * Intent handlers can be excluded either by app name, or by app instance ID.
         */
        export type HandlerExclusionCriteria = AppHandlerExclusion | InstanceHandlerExclusion;

        /**
         * Describes the criteria for excluding Intent handlers by app name when using the `filterHandlers()` method.
         */
        export interface AppHandlerExclusion {

            /**
             * Name of an app to exclude from the list of Intent handlers.
             * When using an app name as an exclusion criterion, all Intents handlers associated with that app name will be excluded
             * (the app itself and all already running instances of it).
             */
            applicationName: string;
        }

        /**
         * Describes the criteria for excluding Intent handlers by app instance ID when using the `filterHandlers()` method.
         */
        export interface InstanceHandlerExclusion {

            /**
             * ID of a specific app instance to exclude from the list of Intent handlers.
             */
            instanceId: string;
        }

        /**
         * Specifies the criteria for filtering the available Intent handlers when using the `filterHandlers()` method.
         */
        export interface HandlerFilter {
            /**
             * Title for the search operation that will be provided to the Intents Resolver UI.
             */
            title?: string;

            /**
             * Flag indicating whether the Intents Resolver UI will open to provide the user with the list of valid Intent handlers.
             * @default true
             */
            openResolver?: boolean;

            /**
             * Interval in milliseconds to wait for the `filterHandlers()` method to resolve if more than one Intent handler is available and the Intents Resolver UI is enabled.
             * @default 90000
             */
            timeout?: number;

            /**
             * Intent name to be used a filter criterion.
             */
            intent?: string;

            /**
             * List of context types with which the Intent handlers work to be used as filter criteria.
             */
            contextTypes?: string[];

            /**
             * Result type returned by the Intent handlers to be used as a filter criterion.
             */
            resultType?: string;

            /**
             * List of application names which will be used as a filter criteria
             */
            applicationNames?: string[];

            /**
             * List of exclusion criteria for filtering out Intent handlers from the results.
             * @since io.Connect Browser 4.2
             */
            excludeList?: HandlerExclusionCriteria[];
        }

        /**
         * Specifies the search criteria for the Intent API's `find()` method.
         */
        export interface IntentFilter {
            /**
             * The name of the intent to be used in the lookup.
             */
            name?: string;
            /**
             * The name of the context type to be used in the lookup.
             */
            contextType?: string;
            /**
             * The type of the intent result to be used in the lookup.
             */
            resultType?: string;
        }

        /**
         * Represents an intent.
         */
        export interface Intent {
            /**
             * The name of the intent, such as `"CreateCall"`.
             */
            name: string;
            /**
             * The set of IntentHandler that provide an implementation for the intent and can be used to handle an intent request.
             */
            handlers: IntentHandler[];
        }

        /**
         * Represents an implementation of an intent.
         * Each intent handler can offer its own display name - this allows context menus
         * built on the fly to display more user friendly options. For example, if there is
         * an intent with a name "ShowNews", there could be a handler with display name
         * "Show Bloomberg News" and another with display name "Show Reuters News".
         * Handlers can optionally specify the context type they support, where the
         * context type is the name of a typed, documented data structure such as
         * "Person", "Team", "Instrument", "Order", etc. In the example above,
         * both the Bloomberg and Reuters handlers would specify a context type "Instrument" and
         * would expect to be raised with an instrument object conforming to an expected
         * structure from both handlers.
         * An intent handler must not necessarily specify a context type.
         */
        export interface IntentHandler {
            /**
             * The name of the application which registered this intent implementation, as specified in the application configuration.
             */
            applicationName: string;

            /* The title of the application which registered this intent implementation, as specified in the application configuration. */
            applicationTitle?: string;

            /* User friendly (longer) description of the application, as specified in the application configuration. */
            applicationDescription?: string;

            /* Icon URL of the application that has registered the intent handler, as specified in the application configuration. */
            applicationIcon?: string;

            /**
             * The type of the handler.
             * "app" - An application that has declared itself as an implementor of the intent inside of its application definition.
             * "instance" - A running instance of an application that can handle the intent. Also includes dynamically added intents using `addIntentListener()`.
             */
            type: "app" | "instance";

            /**
             * The human-readable name of the intent handler, as specified in the intent definition.
             */
            displayName?: string;

            /**
             * The context types this handler supports.
             */
            contextTypes?: string[];

            /**
             * The id of the running application instance.
             */
            instanceId?: string;

            /**
             * The window's title of the running application instance.
             */
            instanceTitle?: string;

            /**
             * Result type may be a type name, the string "channel" (which indicates that the app will return a channel)
             * or a string indicating a channel that returns a specific type, e.g. "channel<fdc3.instrument>"
             */
            resultType?: string;

            /**
             * Object containing custom configuration for the Intent handler provided via the app definition or dynamically.
             * @since io.Connect Browser 4.2
             */
            customConfig?: { [key: string]: any };
        }

        /**
         * Represents a request to raise an intent.
         */
        export interface IntentRequest {
            /**
             * The name of the intent to be raised.
             */
            readonly intent: string;
            /**
             * Тhe target of the raised intent. Valid values are:
             * `startNew` - will start a new instance of an application that can handle the intent.
             * `reuse` - a running instance of an application will handle the intent.
             * { app: "AppName" } - will start a new instance of the "AppName" application (iff it can handle it) that will handle the intent.
             * { instance: "i-123-1" } - the running application instance with instanceId "i-123-1" will handle the intent (iff it can handle it).
             */
            readonly target?: "startNew" | "reuse" | { app?: string; instance?: string };
            /**
             * The context type and data that will be provided to the intent implementation's handler.
             */
            readonly context?: IntentContext;
            /**
             * Start up options that will be used when a new instance of an application needs to be started to handle the intent request.
             */
            readonly options?: AppManager.ApplicationStartOptions;
            /**
             * List of Intent Handlers which will be provided to the user via Intents Resolver UI. If the Resolver is disabled or there's only one handler
             * in the array, raise() will resolve with the first application or instance in the collection.
             */
            readonly handlers?: IOConnectBrowser.Intents.IntentHandler[];
            /**
             * Timeout to wait for 'raise' method to resolve.
             * @default: 90000
             */
            readonly timeout?: number;
            /**
             * Whether to wait for the Intents Resolver UI to choose a handler for the raised intent.
             * If set to true, the timer starts after there's a chosen handler from the user.
             * Otherwise, the start point is the beginning of the raise invocation.
             * @default: false
             */
            readonly waitUserResponseIndefinitely?: boolean;

            /**
             * If `true`, the previously saved Intent handler for this Intent (if any) will be cleared.
             * @default false
             */
            readonly clearSavedHandler?: boolean;
        }

        /**
         * A structure that describes a typed context to be used to raise intents with.
         */
        export interface IntentContext {
            /**
             * The name of a typed, documented data structure such as "Person", "Team", "Instrument", "Order", etc.
             * It is the application developers' job to agree on a protocol to follow.
             */
            readonly type?: string;
            /**
             * The context data used as an argument by the intent implementation.
             */
            readonly data?: { [key: string]: any };
        }

        /**
         * The result of a raised intent.
         */
        export interface IntentResult {
            /**
             * The arguments that were used to raise the intent with.
             */
            request: IntentRequest;
            /**
             * The intent implementation that handled the intent.
             */
            handler: IntentHandler;
            /**
             * The data returned by the intent implementation when handling the intent.
             */
            result?: any;
        }

        /**
         * Describes the result returned by the `filterHandlers()` method.
         */
        export interface FilterHandlersResult {
            /**
             * List of Intent handlers that satisfy the filter criteria.
             */
            handlers: IntentHandler[];
        }

        /**
         * Describes the result returned by the `getIntents()` method.
         */
        export interface GetIntentsResult {
            /**
             * List of objects describing the Intents associated with the specified Intent handler.
             */
            intents: IntentInfo[];
        }
    }

    /**
     * @intro
     * **io.Connect Browser** has two built-in themes - "Day" and "Night". You can control the themes programmatically by using the Themes API.
     *
     * The Themes API is accessible via the [`io.themes`](#API) object.
     */
    namespace Themes {
        export interface API {
            /**
             * Returns the current theme.
             */
            getCurrent(): Promise<Theme>;

            /**
             * Returns list of available themes
             */
            list(): Promise<Theme[]>;

            /**
             * Notifies you when the theme is changed.
             * @param callback Callback to handle the event. Receives the theme object as an argument.
             * @returns Unsubscribe function.
             */
            onChanged(callback: (theme: Theme) => any): UnsubscribeFunction;

            /**
             * Selects a new theme
             * @param name The name of the theme
             */
            select(name: string): Promise<void>;
        }

        export interface Theme {
            displayName: string;
            name: string;
        }
    }

    /**
     * @ignore
     */
    namespace WebPlatform {
        export interface API {
            version: string;

            system: System;

            corePlus?: CorePlus;
        }

        export interface System {
            /**
             * Shuts down the web platform, clears the IO Connect session data and closes all windows.
             */
            shutdown(): Promise<void>;
        }

        export interface CorePlus {
            version: string;
        }
    }

    /**
     * @docname App Preferences
     * @intro
     * The App Preferences API enables apps to store custom user-specific data and retrieve it when necessary.
     * This allows you to enhance the UX of your apps by instrumenting them to preserve specific user settings and apply them when the app is relaunched.
     *
     * The App Preferences API provides methods for updating, replacing and clearing user settings stored for the current or a specific app,
     * as well as for all apps of the current user.
     *
     * The App Preferences API is accessible via the [`io.prefs`](#API) object.
     */
    namespace Prefs {
        /**
         * App Preferences API.
         */
        export interface API {
            /**
             * Removes the user preferences for the current app.
             * @returns Promise that resolves when the user preferences for the current app have been removed.
             */
            clear(): Promise<void>;

            /**
             * Removes all preferences stored for the current user.
             * @returns Promise that resolves when all preferences stored for the current user have been removed.
             */
            clearAll(): Promise<void>;

            /**
             * Removes the user preferences for a specified app.
             * @param app Name of the app whose user preferences to remove.
             * @returns Promise that resolves when the user preferences for a specified app have been removed.
             */
            clearFor(app: string): Promise<void>;

            /**
             * Retrieves the user preferences for the current app.
             * @param app Name of the app for which to retrieve the user preferences.
             * @returns Promise that resolves with the user preferences for the current app.
             */
            get(app?: string): Promise<AppPreferences>;

            /**
             * Retrieves all preferences stored for the current user.
             * @returns Promise that resolves with all preferences stored for the current user.
             */
            getAll(): Promise<{ all: AppPreferences[] }>;

            /**
             * Replaces the user preferences for the current app. All existing properties will be removed and replaced with the ones supplied in the `data` object.
             * @param data Data to replace the existing user preferences.
             * @param options Object with an `app` property that accepts an app name as a value. Can be used to target a specific app whose user preferences to replace.
             * @returns Promise that resolves when the user preferences for the current app have been replaced.
             */
            set(data: any, options?: { app: string }): Promise<void>;

            /**
             * Replaces the user preferences of a specified app. All existing properties will be removed and replaced with the ones supplied in the `data` object.
             * @param app Name of the app whose user preferences to replace.
             * @param data Data to replace the existing user preferences.
             * @returns Promise that resolves when the user preferences of a specified app have been replaced.
             */
            setFor(app: string, data: any): Promise<void>;

            /**
             * Subscribes for changes to the user preferences of the current app.
             * @param callback Callback function that will be invoked once with the initial user preferences and after that on every change of the user preferences.
             * @returns Unsubscribe function.
             */
            subscribe(callback: (prefs: AppPreferences) => void): UnsubscribeFunction;

            /**
             * Subscribes for changes to the user preferences of a specified app.
             * @param app Name of the app to which to subscribe.
             * @param callback Callback function that will be invoked once with the initial user preferences and after that on every change of the user preferences.
             * @returns Unsubscribe function.
             */
            subscribeFor(app: string, callback: (prefs: AppPreferences) => void): UnsubscribeFunction;

            /**
             * Updates the preferences for the current app. The properties specified in the `data` object will be merged with the existing user preferences. Other existing properties will remain intact, and non-existent ones will be added.
             * @param data Data to be merged with the existing user preferences.
             * @param options Object with an `app` property that accepts an app name as a value. Can be used to target a specific app whose user preferences to update.
             * @returns Promise that resolves when the preferences for the current app have been updated.
             */
            update(data: any, options?: { app: string }): Promise<void>;

            /**
             * Updates the preferences for a specified app. The properties specified in the `data` object will be merged with the existing user preferences. Other existing properties will remain intact, and non-existent ones will be added.
             * @param app Name of the app whose user preferences to update.
             * @param data Data to be merged with the existing user preferences.
             * @returns Promise that resolves when the preferences for a specified app have been updated.
             */
            updateFor(app: string, data: any): Promise<void>;
        }

        /**
         * App preferences object.
         */
        export interface AppPreferences {
            /** Name of the app. */
            app: string;
            /** Object holding the user preferences as key/value pairs. */
            data: any;
            /** Timestamp of the last update of the user preferences. */
            lastUpdate?: string;
        }
    }
}
