/// <reference types="node" />

import type { EventEmitter } from 'node:events';
import type { OpenFin } from '@openfin/core';

declare type BaseConfig = {
    uuid?: string;
    address?: string;
    name?: string;
    nonPersistent?: boolean;
    runtimeClient?: boolean;
    licenseKey?: string;
    client?: any;
    manifestUrl?: string;
    startupApp?: any;
    lrsUrl?: string;
    assetsUrl?: string;
    devToolsPort?: number;
    installerUI?: boolean;
    runtime?: RuntimeConfig;
    apiDiagnostics?: boolean;
    appAssets?: [
        {
        src: string;
        alias: string;
        target: string;
        version: string;
        args: string;
    }
    ];
    customItems?: [any];
    timeout?: number;
};

declare type ConfigWithRuntime = BaseConfig & {
    runtime: RuntimeConfig;
};

declare type ConfigWithUuid = BaseConfig & {
    uuid: string;
};

export declare function connect(config: ConnectConfig): Promise<NodeFin>;

declare type ConnectConfig = ExistingConnectConfig | NewConnectConfig | ExternalConfig;

declare type ExistingConnectConfig = ConfigWithUuid & {
    address: string;
};

declare type ExternalConfig = BaseConfig & {
    manifestUrl: string;
};

export declare function launch(config: ConnectConfig): Promise<number>;

declare type NewConnectConfig = ConfigWithUuid & ConfigWithRuntime;

/**
 * The `fin` object in the node-adapter is an EventEmitter that emits a single `disconnected` event when the connection to the OpenFin Runtime is lost.
 */
export declare type NodeFin = OpenFin.Fin<'external connection'> & EventEmitter;

declare type RuntimeConfig = {
    version: string;
    fallbackVersion?: string;
    securityRealm?: string;
    verboseLogging?: boolean;
    arguments?: string;
    rvmDir?: string;
};

export { }
