/*
 * Copyright 2022 VMware, Inc. All rights reserved. VMware Confidential
 */

import { ExtensionNavRegistration } from "../../models/extension";
import { HyperPluginEntityActionExtensionMenuEntryCollection } from "../entity-action/entity-action-extension.component";
import { ExtensionComponentRegistration } from "../extension-component.registry";
import { EntityActionComponentContainer } from "../extension-components.directive";
import { INTERENAL_EXTENSION_POINT_TYPE } from "../extension-point-orchestrator/extension-point-events";

export const CORE_UI_CUSTOM_EVENTS = {
    INJECT_PLUGIN: "onInjectPlugin",
    PLUGIN_INJECTED: "onPluginInjected",
    COMPONENT_CREATED: "onComponentCreated",
    PLUGINS_MENUES: "onPluginMenues",
    WIZARD_MODAL_FORM_VALIDITY: "onWizardModalFormValid",
    VM_VAPP_ACTION_COMPONENT_CHANGE: "onComponentsChange",
    FORCE_CORE_UI_ROUTER_NAVIGATION: "onForceCoreUIRouterNavigation",
    TRIGGER_DETECT_CHANGES: "triggerDetectChanges",
    GET_EXTENSION_ACTION_ITEMS: "getExtensionActionItems",
    GET_EXTENSION_ACTION_ITEMS_RETURN: "getExtensionActionItemsReturn",
    ON_PLUGIN_DESTROYED: "onPluginDestroyed",
    ON_PLUGIN_CAN_DEACTIVATE: "onPluginCanDeactivate",
};

export interface InjectPluginEventDetails {
    hostingSelector: string;
    route?: string;
    extensions?: ExtensionComponentRegistration[];
    internalExtensionPointType: INTERENAL_EXTENSION_POINT_TYPE;
    scope: string;
}

export interface PluginInjectEventDetails {
    componentSelector: string;
}

export interface ComponentCreatedEventDetails {
    data: any;
}

export interface PluginsMenuesEventDetails {
    pluginMenus: ExtensionNavRegistration[];
}

export interface WizardModalValidityEventDetails {
    allExtensionsAreValid: boolean;
}

export interface VMvAppActionComponentChangeEventDetails {
    components: EntityActionComponentContainer[];
}

export interface ForceCoreUIRouterNavigationEventDetails {
    url: string;
}

export interface GetExtensionItemsEventDetails {
    entityUrn: string;
    entityActionExtensionContainers: EntityActionComponentContainer[];
}

export interface GetExtensionItemsReturnEventDetails {
    entityActionExtensionMenuEntries: HyperPluginEntityActionExtensionMenuEntryCollection[];
}

export interface PluginDestroyedEventDetails {
    pluginRoute: string;
    hostingSelector: string;
    scope: string;
    navigateAwayTo: string;
}

export interface PluginCanDeactivateEventDetails {
    canDeactivate: boolean;
}
