import { Context, AppIntent, OpenError, ResolveError, ContextType, AppMetadata, ResultError, AppIdentifier } from "@finos/fdc3";
import { AppDefinition, ResolverChannelMeta } from "../../platform/services/Interop/types";
import { WindowDescriptor } from "../../platform/services/window/types";
export type Member<T, K extends keyof T> = T[K];
export type MultiMap<T> = Record<string, Array<T>>;
/**
 * MultiMap add
 * @param records
 * @param index
 * @param handler
 */
export declare const mmAdd: (records: MultiMap<any>, index: string, handler: any) => any[];
/**
 * Concats an item to an array, eliminating any dups, and creating the array if it is null or undefined
 * @param arr
 * @param item
 */
export declare const concatNoDups: (arr: any[] | null | undefined, item: any | any[]) => any[];
/**
 * MultiMap remove
 * @param records
 * @param index
 * @param handler
 */
export declare const mmRemove: (records: MultiMap<any>, index: string, handler: any) => any[];
export declare const errorAsString: (err: any) => string;
export declare const GLOBAL_CHANNEL = "global";
export declare const SERVER_CHANNEL = "FSBL.FDC3.Interop.Server";
export declare const INTENT_RESOLVER_CHANNEL = "FSBL.FDC3.intent.resolver";
export declare const EMBEDDED_TITLEBAR_INDICATOR_STRING = "(TitleBar)";
export type ResolutionCandidate = {
    meta: AppMetadata;
    appId: string;
    uuid?: string;
    windowName?: string;
    desktopAgent?: string;
    pending?: boolean;
};
export type InteropConfigFlags = {
    joinMultipleChannels: boolean;
    fdc3_1_2_compatibility: boolean;
};
/**
 * A list of intent resolutions that are possible for a given intent and optional context.
 *
 * Arrays of Resolutionlist's are used in raiseIntent to deal with the raiseIntentByContext, which might result
 * in several resolution lists (one list for each possible intent that is associated with the requested context).
 *
 * For instance, raiseIntentByContext({"symbol" : "IBM"}) could result in:
 * contextType("symbol") => intent("Quote") => QuotesApp, RFQApp, ...
 * contextType("symbol") => intent("News") => NewsApp, TwitterApp, ...
 * contextType("symbol") => intent("Chart") => ChartApp, SnapshotChartApp, ...
 */
export type ResolutionList = {
    intent: {
        name: string;
        displayName: string;
    };
    launchableApps: ResolutionCandidate[];
    openApps: ResolutionCandidate[];
    pendingApps: ResolutionCandidate[];
    context?: ContextAny;
};
export type IntentTargetList = {
    resolutionList: ResolutionList[];
    originatingAppName?: string;
    originatingAppId?: string;
    originatingAppWindow?: string;
};
export type ResolverResolution = {
    originatingAppName?: string;
    originatingAppId?: string;
    originatingAppWindow?: string;
    intent?: string;
    selectedApp?: AppMetadata;
    windowName?: string;
    rememberChoice?: boolean;
    error?: ResolveError;
};
export type AuthenticationToken = {
    signatureString: string;
    signatureStringType: "dynamic" | "static" | "static-jwt" | "unauthenticated";
    meta: AppMetadata;
    timestamp?: number;
};
export declare const AnonymousAuthenticationToken: AuthenticationToken;
export type IntentResolverHandler = (choices: IntentTargetList) => Promise<ResolverResolution>;
export type ContextAny = Context & {
    [data: string]: any;
};
export type ContextMap = {
    [contextType: string]: {
        context: ContextAny;
        senderUuid: string;
    };
};
/**
 * The following are the Flux Standard Actions (FSA) that are exchanged between the Desktop Agent
 * and the Interop Server.
 */
export type InteropMeta = {
    uuid: string;
    appId?: string;
    originatorUuid?: string;
    originatorAppId?: string;
    desktopAgent?: string;
    href?: string;
    path?: string;
    authenticatedTransport?: object;
    routerOrigin?: string;
    remoteDestination?: string;
    desktopAgentSource?: string;
};
export type InteropRegister = {
    type: "register";
    payload: {
        authenticationToken: AuthenticationToken;
        clientChannel: string;
        windowName: string;
    };
    meta: InteropMeta;
};
export type InteropHeartbeat = {
    type: "heartbeat";
    meta: InteropMeta;
};
export type InteropUnregister = {
    type: "unregister";
    meta: InteropMeta;
};
export type InteropBroadcast = {
    type: "broadcast";
    payload: {
        context: ContextAny;
        channelType?: InteropChannelType;
    };
    meta: InteropMeta & {
        channel?: string;
        targetSubscriberId?: string;
    };
};
export type InteropSystemChannels = {
    type: "systemChannels";
    payload: {
        channels: string[];
        systemChannelMeta?: ResolverChannelMeta;
    };
    meta: InteropMeta;
};
export type InteropSystemChannelRequest = {
    type: "systemChannelRequest";
    meta: InteropMeta;
};
export type InteropCurrentContextRequest = {
    type: "currentContextRequest";
    payload: {
        contextType?: string;
    };
    meta: InteropMeta & {
        channel?: string;
    };
};
export type InteropCurrentContext = {
    type: "currentContext";
    payload: {
        context: Context | null;
    };
    meta: InteropMeta;
};
export type InteropOpenRequest = {
    type: "open";
    payload: {
        requestingAppId: string;
        app: AppIdentifier | string;
        context?: Context;
    };
    meta: InteropMeta;
};
export type InteropGetSystemChannels = {
    type: "open";
    payload: {
        target: AppMetadata;
        context?: Context;
    };
    meta: InteropMeta;
};
export type InteropOpenResponse = {
    type: "openResponse";
    payload: {
        appIdentifier?: AppIdentifier;
        error?: OpenError;
    };
    meta?: InteropMeta;
};
export type InteropFindIntentRequest = {
    type: "findIntent";
    payload: {
        intent: string;
        context?: Context;
        resultType?: string;
    };
    meta: InteropMeta;
};
export type InteropFindIntentResponse = {
    type: "findIntentResponse";
    payload: {
        appIntent?: AppIntent;
        error?: ResolveError | null;
    };
    meta: InteropMeta;
};
export type InteropFindIntentsByContext = {
    type: "findIntentsByContext";
    payload: {
        context?: Context;
        resultType?: string;
    };
    meta: InteropMeta;
};
export type InteropIntentsList = {
    type: "intentsList";
    payload: {
        error?: ResolveError | null;
        intents?: AppIntent[];
    };
    meta: InteropMeta;
};
export type InteropIntent = {
    type: "intent";
    payload: {
        intent: string;
        context: Context;
        requestId: string;
    };
    meta: InteropMeta;
};
export type InteropRaiseIntent = {
    type: "raiseIntent";
    payload: {
        intent: string | null;
        target?: AppIdentifier | String;
        context?: Context;
        requestId: string;
        forContext: boolean;
        bridgeIntent?: AppIntent | undefined;
    };
    meta: InteropMeta;
};
export type InteropRaiseIntentResponse = {
    type: "intentResolution";
    payload: {
        error?: ResolveError | null;
        data?: {
            source: AppMetadata;
            intent: string;
            version?: string;
        };
    };
    meta?: InteropMeta;
};
export type InteropChannelType = "user" | "app" | "private";
export type InteropChannel = {
    channelId: string;
    type: InteropChannelType;
};
export type InteropIntentResult = Context | InteropChannel;
export type InteropRaiseIntentResult = {
    type: "intentResult";
    payload: {
        intentResultError?: ResultError;
        intentResult?: InteropIntentResult;
        intent: string;
        requestId: string;
    };
    meta?: InteropMeta;
};
export type PrivateChannelEventSubscriptionType = "onAddContextListener" | "onUnsubscribe" | "onDisconnect";
export type InteropPrivateChannelEvent = {
    type: "privateChannelEvent";
    payload: {
        subscribeType: PrivateChannelEventSubscriptionType;
        channel: string;
        context?: string;
        targetSubscriberId: string;
    };
    meta: InteropMeta;
};
export type InteropSubscribePrivateChannelEvent = {
    type: "subscribePrivateChannelEvent";
    payload: {
        subscribeType: PrivateChannelEventSubscriptionType;
        channel?: string;
        targetSubscriberId?: string;
    };
    meta: InteropMeta;
};
export type InteropUnsubscribePrivateChannelEvent = {
    type: "unsubscribePrivateChannelEvent";
    payload: {
        subscribeType: "onAddContextListener" | "onUnsubscribe" | "onDisconnect";
        channel?: string;
        targetSubscriberId?: string;
    };
    meta: InteropMeta;
};
export type InteropChannelDisconnect = {
    type: "channelDisconnect";
    meta: InteropMeta & {
        channel: string;
        targetSubscriberId?: string;
    };
};
export type InteropSubscribeContext = {
    type: "subscribeContext";
    payload: {
        contextType: ContextType;
    };
    meta: InteropMeta & {
        channel?: string;
        targetSubscriberId?: string;
    };
};
export type InteropUnsubscribeContext = {
    type: "unsubscribeContext";
    payload: {
        contextType?: ContextType;
    };
    meta: InteropMeta & {
        channel?: string;
    };
};
export type InteropSubscribeIntent = {
    type: "subscribeIntent";
    payload: {
        intent: string;
    };
    meta: InteropMeta;
};
export type InteropUnsubscribeIntent = {
    type: "unsubscribeIntent";
    payload: {
        intent: string;
    };
    meta: InteropMeta;
};
export type InteropRemoveUIResolverChoice = {
    type: "removeUIResolverChoice";
    payload: {
        intent: string;
        contextType: string;
        appWindow: string;
    };
};
export type InteropJoinChannels = {
    type: "joinChannels";
    payload: {
        channels: string[];
    };
    meta: InteropMeta;
};
export type InteropJoinChannelsResponse = {
    type: "joinChannelsResponse";
    payload: {
        error?: string;
    };
    meta: InteropMeta;
};
/**
 * If payload.channnels is omitted then *all* joined channels are removed.
 */
export type InteropLeaveChannels = {
    type: "leaveChannels";
    payload: {
        channels?: string[];
    };
    meta: InteropMeta;
};
export type InteropAddAppDefinitions = {
    type: "addAppDefinitions";
    payload: {
        apps: AppDefinition[];
    };
    meta: InteropMeta;
};
export type InteropRemoveAppDefinitions = {
    type: "removeAppDefinitions";
    payload: {
        apps: string[];
    };
    meta: InteropMeta;
};
export type InteropRegisterUIResolver = {
    type: "registerUIResolver";
    meta: InteropMeta;
};
export type InteropGetCurrentChannels = {
    type: "getCurrentChannels";
    meta: InteropMeta;
};
export type InteropGetCurrentChannelsResponse = {
    type: "interopGetCurrentChannelsResponse";
    payload: {
        error?: string;
        data?: {
            channel: string;
        }[];
        systemChannelMeta?: ResolverChannelMeta;
    };
    meta?: InteropMeta;
};
export type InteropGetAppMetadata = {
    type: "getAppMetadata";
    app: AppIdentifier;
    meta: InteropMeta;
};
export type InteropGetAppMetadataResponse = {
    type: "interopGetAppMetadataResponse";
    payload: {
        error?: string;
        appMetadata?: AppMetadata;
    };
    meta?: InteropMeta;
};
export type InteropFindInstances = {
    type: "findInstances";
    app: AppIdentifier;
    meta: InteropMeta;
};
export type InteropFindInstancesResponse = {
    type: "interopFindInstancesResponse";
    payload: {
        instances: Array<AppIdentifier>;
        error?: string;
    };
    meta: InteropMeta;
};
export type InteropSetRegistrationData = {
    type: "setInteropRegistrationData";
    payload: {
        windowDescriptor: WindowDescriptor;
    };
    meta: InteropMeta;
};
export type InteropMessage = InteropRegister | InteropUnregister | InteropBroadcast | InteropSystemChannels | InteropSystemChannelRequest | InteropCurrentContextRequest | InteropCurrentContext | InteropOpenRequest | InteropOpenResponse | InteropFindIntentRequest | InteropFindIntentResponse | InteropFindIntentsByContext | InteropHeartbeat | InteropIntent | InteropIntentsList | InteropJoinChannels | InteropJoinChannelsResponse | InteropLeaveChannels | InteropRaiseIntent | InteropRaiseIntentResponse | InteropRaiseIntentResult | InteropSubscribeContext | InteropUnsubscribeContext | InteropSubscribeIntent | InteropUnsubscribeIntent | InteropAddAppDefinitions | InteropRemoveAppDefinitions | InteropGetCurrentChannels | InteropGetCurrentChannelsResponse | InteropGetAppMetadata | InteropGetAppMetadataResponse | InteropFindInstances | InteropFindInstancesResponse | InteropRegisterUIResolver | InteropSetRegistrationData | InteropPrivateChannelEvent | InteropSubscribePrivateChannelEvent | InteropUnsubscribePrivateChannelEvent | InteropChannelDisconnect;
export type InteropType = Member<InteropMessage, "type">;
//# sourceMappingURL=types.d.ts.map