import { PayloadAction } from "@reduxjs/toolkit";
import { ContextAny, ContextMap, InteropRaiseIntent, InteropOpenRequest, AuthenticationToken } from "../../clients/Interop/types";
import { OpenError, ContextType, DisplayMetadata, AppIntent, IntentMetadata, IntentResolution, ResolveError } from "../../typedefs/FDC3";
import { ActionId } from "../../common/redux/types";
import { WindowDescriptor, SpawnParams, ConnectId } from "../window/types";
export declare const CLEANUP_INTERVAL = 10000;
/**
 * This type is used internally by the broadcast action. It can
 * handle either an intent or a context.
 *
 * It supports necessary internal features that are not possible
 * through the desktop agent.
 */
export declare type InteropBroadcastInternal = {
    type: "broadcast" | "raiseIntent";
    payload: {
        context?: ContextAny;
        intent?: string;
    };
    meta: {
        uuid: string;
        channel?: string;
        to?: string;
        noSelectConnect?: boolean;
        setSenderContext?: boolean;
        pendingActionId?: ActionId;
        autoBroadcast?: boolean;
        targetSubscriberId?: string;
    };
};
export declare type RaiseIntentActionResult = {
    type: InteropRaiseIntent["type"];
    result?: IntentResolution;
    error?: ResolveError;
};
export declare type OpenActionResult = {
    type: InteropOpenRequest["type"];
    result?: {};
    error?: OpenError;
};
export declare type InteropMessageWithActonId<T> = {
    fsa: T;
    actionId: ActionId;
};
export declare type SelectConnectAppList = {
    name: string;
};
export declare type AutoAssociateRule = {
    allChildren?: boolean;
    selectChildren?: string[];
    usingConnectId?: string;
};
export declare type SelectConnectRule = {
    cc?: any;
    fwd?: any;
    to?: SelectConnectAppList[];
    from?: SelectConnectAppList[];
    authorize?: SelectConnectAppList[];
    contextType?: string;
    intentType?: string;
    autoAssociate?: AutoAssociateRule;
};
export declare type InteropConfig = {
    intents?: [
        {
            name: string;
            displayName: string;
            contexts?: [string];
        }
    ];
    channels?: {
        system?: Record<string, true>;
        private?: Record<string, true>;
    };
    selectConnect?: SelectConnectRule[];
    useLinker?: boolean;
};
/**
 * The cross-section of Finsemble's config (AppD manifest) that is specific
 * to interop.
 */
export interface AppConfig {
    interop?: InteropConfig;
    signatureKey?: JsonWebKey;
    signatureKeyURL?: string;
}
/**
 * OutgoingMessage's are sent back to subscribing FDC3 clients as the result of a broadcast or intent.
 */
export declare type OutgoingMessage = {
    uuid: string;
    channel?: string;
    context?: ContextAny;
    intent?: string;
    pendingActionId?: ActionId;
    routerChannel: string;
    targetSubscriberId?: string;
};
/**
 * OutgoingDispatchMessage's trigger redux actions, based on SelectConnect rules resulting from a broadcast.
 *
 * uuid is either the uuid of the broadcaster or the destination depending on whether the triggered rule
 * was broadcast or destination side (if both then there will be two outgoing messages)
 */
export declare type OutgoingDispatchMessage = {
    fsa: InteropBroadcastInternal;
    uuid: string;
} & IntentOrContextType;
/**
 * OutgoingSelectConnectChannelMessage's are sent to registered SelectConnect channels from remote apps based on results from a broadcast that target those channels.
 *
 * uuid is either the uuid of the broadcaster or the destination depending on whether the triggered rule
 * was broadcast or destination side (if both then there will be two outgoing messages)
 */
export declare type OutgoingSelectConnectChannelMessage = {
    routerChannel: string;
    fsa: InteropBroadcastInternal;
    uuid: string;
} & IntentOrContextType;
export declare type IntentOrContextType = {
    intent?: string;
    contextType?: string;
    context?: ContextAny;
};
export declare type ClientDestination = {
    type: "client";
    uuid: string;
    channel?: string;
    routerChannel: string;
} & IntentOrContextType;
/**
 * uuid is either the uuid of the broadcaster or the destination depending on whether the triggered rule
 * was broadcast or destination side (if both then there will be two outgoing messages)
 */
export declare type ConnectDestination = {
    type: "selectConnect";
    name: string;
    uuid: string;
} & IntentOrContextType;
export declare type Destination = ClientDestination | ConnectDestination;
export declare type RegisterSelectConnectChannel = {
    name: string;
} & ({
    dispatchAction: string;
} | {
    routerChannel: string;
});
/**
 * See finsemble.scheme.json for full config
 */
export declare type FinsembleComponentConfig = {
    bootParams?: Record<string, any>;
    signatureKey?: Record<string, any>;
    window?: SpawnParams;
    foreign?: Record<string, any>;
    isAnApp?: boolean;
    interop?: {
        useLinker?: boolean;
        autoConnect?: boolean;
        selectConnect?: SelectConnectRule[];
    };
    component?: Record<string, any>;
    childWindowOptions?: Record<string, any>;
    custom?: Record<string, any>;
};
export declare type AppDIcon = {
    src: string;
    sizes?: string;
};
export declare type AppDefinition = {
    appId: string;
    name: string;
    type?: string;
    title?: string;
    description?: string;
    manifest?: FinsembleComponentConfig & {
        [index: string]: any;
    };
    manifestType?: string;
    version?: string;
    releaseNotes?: string;
    tooltip?: string;
    images?: object[];
    tags?: string[];
    contactEmail?: string;
    supportEmail?: string;
    publisher?: string;
    icons?: AppDIcon[];
    intents?: {
        name: string;
        displayName: string;
        contexts?: string[];
        appListenerAdded?: boolean;
    }[];
    firstRegistrationTimestamp?: number;
    verified?: boolean;
};
export declare type InteropClient = {
    readiness: "initializing" | "ready";
    heartbeatTime: number;
    authenticated: boolean;
    authenticatedTransport: object;
    uuid: string;
    windowName: string;
    appName: string;
    appId: string;
    routerChannel: string;
    config?: AppConfig;
    channels: string[];
    connectId?: ConnectId;
    joinedChannels: string[];
    mostRecentContext?: ContextAny;
    subscriptions: {
        globals: {
            contexts: {
                [contextType: string]: CurrentContext;
            };
            intents: {
                [intent: string]: ContextType | true;
            };
        };
        channels: {
            [channel: string]: {
                contexts: {
                    [contextType: string]: CurrentContext;
                };
                intents: {
                    [intent: string]: ContextType | true;
                };
            };
        };
    };
};
export declare type LoopDetectionEntry = {
    timestamp: number;
    count: number;
    loopNotificationIssued: boolean;
    timerId?: ReturnType<typeof setTimeout>;
};
export declare type CurrentContext = {
    context: ContextAny;
    meta: {
        timestamp: number;
        targetSubscriberId?: string;
    };
};
export declare const EmptyCurrentContext: {
    context: {
        type: string;
    };
    meta: {
        timestamp: number;
        targetSubscriberId: undefined;
    };
};
export declare type LinkerClient = {
    connectId?: ConnectId | undefined;
    spawnedFromWorkspace?: boolean;
    joinedChannels: string[];
};
export declare type LinkerChannel = {
    name: string;
    color: string;
    cssClassName: string;
    label: string;
};
export declare type InteropRegistrationData = {
    authenticationToken: AuthenticationToken;
    windowDescriptor: WindowDescriptor;
};
export declare type InteropStore = {
    linker: {
        clients: {
            [windowName: string]: LinkerClient;
        };
        allChannels: LinkerChannel[];
        connectIdToJoinedChannel: Record<string, string>;
        activeWindowName?: string;
    };
    workspace: {
        persistedData: {
            [windowName: string]: Record<string, ContextAny>;
        };
    };
    resolver: {
        pendingInteropRegistrationData: WindowDescriptor[];
        pendingOpenActionIds: {
            [windowName: string]: ActionId;
        };
        config: {
            serverUUID: string;
            registeredUIResolver: string | null;
        };
        clients: {
            [uuid: string]: InteropClient;
        };
        selectConnectChannels: {
            [name: string]: {
                name: string;
                dispatchAction: string;
            } | {
                name: string;
                routerChannel: string;
            };
        };
        channelMeta: {
            [id: string]: {
                type: string;
                displayMetaData?: DisplayMetadata;
            };
        };
        lastChannelState: {
            [channel: string]: {
                context: ContextAny;
                senderUuid: string;
            };
        };
        lastChannelStateByType: {
            [channel: string]: ContextMap;
        };
        apps: {
            definitions: {
                [appName: string]: AppDefinition;
            };
            intentResolutionInProgress: boolean;
            intentResolutionCurrentActionId: any;
        };
        contextTypes: {
            [contextType: string]: {
                launchableHandlers: {
                    [appId: string]: true;
                };
                intents: {
                    launchable: AppIntent[];
                    live: AppIntent[];
                };
            };
        };
        intents: {
            [intent: string]: {
                info: IntentMetadata;
                launchableHandlers: {
                    [key: string]: (ContextType | null)[];
                };
            };
        };
        queue: {
            [uuidOrWindowName: string]: {
                pendingMessage: InteropBroadcastInternal;
                timestamp: number;
                subscriberIsReady?: boolean;
            }[];
        };
        loopDetectionMap: {
            [uuid: string]: LoopDetectionEntry;
        };
        addIntentListenerMaxInitializationTimeout: number;
    };
    root: {
        isVisible: boolean;
        heartbeats: boolean;
        testing: {
            unitTestingEnabled: boolean;
            messagesToSend: OutgoingMessage[];
            dispatchesToSend: PayloadAction<OutgoingDispatchMessage>[];
            selectConnectChannelMessagesToSend: OutgoingSelectConnectChannelMessage[];
            destinationsBeforeSelectConnect: Destination[];
            triggeredRules: {
                rulePhase: string;
                result: string;
                rule: any;
                uuid: string;
                destination: Destination;
            }[];
            error: string;
        };
    };
    "@@cmds"?: any[];
};
export declare type ResolverStore = InteropStore["resolver"];
export declare type ResolverApps = InteropStore["resolver"]["apps"];
export declare type ResolverClients = InteropStore["resolver"]["clients"];
export declare type ResolverAppsDefinition = InteropStore["resolver"]["apps"]["definitions"];
export declare type ResolverIntentsData = InteropStore["resolver"]["intents"];
export declare type ResolverIntent = InteropStore["resolver"]["intents"]["intent"];
export declare type ResolverChannelMeta = InteropStore["resolver"]["channelMeta"];
export declare type LinkerStore = InteropStore["linker"];
export declare type RootStore = InteropStore["root"];
export declare type WorkspaceStore = InteropStore["workspace"];
export declare type SelectConnectChannel = ResolverStore["selectConnectChannels"][""];
export declare type LoopDetectionMap = InteropStore["resolver"]["loopDetectionMap"];
export declare type ClientAdded = {
    uuid: string;
    config: AppConfig;
    windowName: string;
    appId: string;
    connectId?: ConnectId;
    spawnedFromWorkspace?: boolean;
};
export declare type ClientRemoved = {
    uuid: string;
    windowName: string;
};
export declare type DIAM = {
    appId?: string;
    name?: string;
    domain?: string;
    executable?: string;
};
export declare type RegistrationResult = {
    config: AppConfig;
    authenticated: boolean;
    appId: string;
    windowName: string;
    uuid: string;
    newPendingInteropRegistrationData?: InteropRegistrationData[];
    connectId?: ConnectId;
    spawnedFromWorkspace?: boolean;
    actionId: ActionId;
};
//# sourceMappingURL=types.d.ts.map