import { Observable } from 'rxjs' ; import { History } from 'history' ; import { RecursiveReadonly } from '@osd/utility-types' ; import { MountPoint } from '../types' ; import { Capabilities } from './capabilities' ; import { ChromeStart } from '../chrome' ; import { IContextProvider } from '../context' ; import { DocLinksStart } from '../doc_links' ; import { HttpStart } from '../http' ; import { I18nStart } from '../i18n' ; import { NotificationsStart } from '../notifications' ; import { OverlayStart } from '../overlays' ; import { PluginOpaqueId } from '../plugins' ; import { IUiSettingsClient } from '../ui_settings' ; import { SavedObjectsStart } from '../saved_objects' ; import { AppCategory } from '../../types' ; import { ScopedHistory } from './scoped_history' ; public export enum AppStatus { /**
     * Application is accessible.
     */ accessible = 0 , /**
     * Application is not accessible.
     */ inaccessible = 1 } public export enum AppNavLinkStatus { /**
     * The application navLink will be `visible` if the application's  AppStatus is set to `accessible`
     * and `hidden` if the application status is set to `inaccessible`.
      default = 0 , /**
     * The application navLink is visible and clickable in the navigation bar.
     */ visible = 1 , /**
     * The application navLink is visible but inactive and not clickable in the navigation bar.
     */ disabled = 2 , /**
     * The application navLink does not appear in the navigation bar.
     */ hidden = 3 } /**
 * Defines the list of fields that can be updated via an  AppUpdater .
 *  public export type AppUpdatableFields = Pick < App , 'status' | 'navLinkStatus' | 'tooltip' | 'defaultPath' > ; /**
 * Updater for applications.
 * see  ApplicationSetup public export type AppUpdater = ( app : App ) => Partial < AppUpdatableFields > | undefined ; public export interface App < HistoryLocationState = unknown > { /**
     * The unique identifier of the application
     */ id : string ; /**
     * The title of the application.
     */ title : string ; /**
     * The category definition of the product
     * See  AppCategory * See DEFAULT_APP_CATEGORIES for more reference
      category ? : AppCategory ; /**
     * The initial status of the application.
     * Defaulting to `accessible`
     */ status ? : AppStatus ; /**
     * The initial status of the application's navLink.
     * Defaulting to `visible` if `status` is `accessible` and `hidden` if status is `inaccessible`
     * See  AppNavLinkStatus navLinkStatus ? : AppNavLinkStatus ; /**
     * Allow to define the default path a user should be directed to when navigating to the app.
     * When defined, this value will be used as a default for the `path` option when calling  ApplicationStart . navigateToApp `,
     * and will also be appended to the  ChromeNavLink in the navigation bar.
      defaultPath ? : string ; /**
     * An  AppUpdater observable that can be used to update the application  AppUpdatableFields at runtime.
     *
     *  example updater$ ? : Observable < AppUpdater > ; /**
     * An ordinal used to sort nav links relative to one another for display.
     */ order ? : number ; /**
     * A tooltip shown when hovering over app link.
     */ tooltip ? : string ; /**
     * A EUI iconType that will be used for the app's icon. This icon
     * takes precendence over the `icon` property.
     */ euiIconType ? : string ; /**
     * A URL to an image file used as an icon. Used as a fallback
     * if `euiIconType` is not provided.
     */ icon ? : string ; /**
     * Custom capabilities defined by the app.
     */ capabilities ? : Partial < Capabilities > ; /**
     * Hide the UI chrome when the application is mounted. Defaults to `false`.
     * Takes precedence over chrome service visibility settings.
     */ chromeless ? : boolean ; /**
     * A mount function called when the user navigates to this app's route. May have signature of  AppMount or
     *  AppMountDeprecated .
     *
     *  remarks When function has two arguments, it will be called with a  AppMountContext as the first argument.
     * This behavior is **deprecated**, and consumers should instead use  CoreSetup . getStartServices .
      mount : AppMount < HistoryLocationState > | AppMountDeprecated < HistoryLocationState > ; /**
     * Override the application's routing path from `/app/${id}`.
     * Must be unique across registered applications. Should not include the
     * base path from HTTP.
     */ appRoute ? : string ; example exactRoute ? : boolean ; } /**
 * Public information about a registered  App public export type PublicAppInfo = Omit < App , 'mount' | 'updater$' > & { status : AppStatus ; navLinkStatus : AppNavLinkStatus ; appRoute : string ; } ; param params AppMountParameters returns An unmounting function that will be called to unmount the application. See  AppUnmount .
 *
 *  public export type AppMount < HistoryLocationState = unknown > = ( params : AppMountParameters < HistoryLocationState > ) => AppUnmount | Promise < AppUnmount > ; public export type AppUnmount = ( ) => void ; remarks When function has two arguments, it will be called with a  AppMountContext as the first argument.
 * This behavior is **deprecated**, and consumers should instead use  CoreSetup . getStartServices .
 *
 *  param context The mount context for this app. Deprecated, use  CoreSetup . getStartServices .
 *  param params AppMountParameters returns An unmounting function that will be called to unmount the application. See  AppUnmount .
 *
 *  deprecated public export type AppMountDeprecated < HistoryLocationState = unknown > = ( context : AppMountContext , params : AppMountParameters < HistoryLocationState > ) => AppUnmount | Promise < AppUnmount > ; /**
 * The context object received when applications are mounted to the DOM. Deprecated, use
 *  CoreSetup . getStartServices .
 *
 *  deprecated public export interface AppMountContext { /**
     * Core service APIs available to mounted applications.
     */ core : { /**  ApplicationStart application : Pick < ApplicationStart , 'capabilities' | 'navigateToApp' > ; /**  ChromeStart chrome : ChromeStart ; /**  DocLinksStart docLinks : DocLinksStart ; /**  HttpStart http : HttpStart ; /**  I18nStart i18n : I18nStart ; /**  NotificationsStart notifications : NotificationsStart ; /**  OverlayStart overlays : OverlayStart ; /**  SavedObjectsStart savedObjects : SavedObjectsStart ; /**  IUiSettingsClient uiSettings : IUiSettingsClient ; deprecated injectedMetadata : { getInjectedVar : ( name : string , defaultValue ? : any ) => unknown ; } ; } ; } public export interface AppMountParameters < HistoryLocationState = unknown > { /**
     * The container element to render the application into.
     */ element : HTMLElement ; example history : ScopedHistory < HistoryLocationState > ; deprecated Use  AppMountParameters . history instead.
     *
     *  example appBasePath : string ; example onAppLeave : ( handler : AppLeaveHandler ) => void ; example setHeaderActionMenu : ( menuMount : MountPoint | undefined ) => void ; } /**
 * A handler that will be executed before leaving the application, either when
 * going to another application or when closing the browser tab or manually changing
 * the url.
 * Should return `confirm` to to prompt a message to the user before leaving the page, or `default`
 * to keep the default behavior (doing nothing).
 *
 * See  AppMountParameters for detailed usage examples.
 *
 *  public export type AppLeaveHandler = ( factory : AppLeaveActionFactory ) => AppLeaveAction ; public export enum AppLeaveActionType { confirm = 'confirm' , default = 'default' } /**
 * Action to return from a  AppLeaveHandler to execute the default
 * behaviour when leaving the application.
 *
 * See  AppLeaveActionFactory public export interface AppLeaveDefaultAction { type : AppLeaveActionType . default ; } /**
 * Action to return from a  AppLeaveHandler to show a confirmation
 * message when trying to leave an application.
 *
 * See  AppLeaveActionFactory public export interface AppLeaveConfirmAction { type : AppLeaveActionType . confirm ; text : string ; title ? : string ; } /**
 * Possible actions to return from a  AppLeaveHandler *
 * See  AppLeaveConfirmAction and  AppLeaveDefaultAction public export type AppLeaveAction = AppLeaveDefaultAction | AppLeaveConfirmAction ; /**
 * Factory provided when invoking a  AppLeaveHandler to retrieve the  AppLeaveAction to execute.
  export interface AppLeaveActionFactory { param text param title confirm ( text , title ? ) : AppLeaveConfirmAction ; /**
     * Returns a default action, resulting on executing the default behavior when
     * the user tries to leave an application
     */ default ( ) : AppLeaveDefaultAction ; } internal export interface Mounter { appRoute : string ; appBasePath : string ; mount : AppMount ; exactRoute : boolean ; unmountBeforeMounting ? : boolean ; } internal export interface ParsedAppUrl { app : string ; path ? : string ; } public export interface ApplicationSetup { param app - an  App typeParam HistoryLocationState - shape of the `History` state on  AppMountParameters . history , defaults to `unknown`.
      register < HistoryLocationState = unknown > ( app ) : void ; /**
     * Register an application updater that can be used to change the  AppUpdatableFields fields
     * of all applications at runtime.
     *
     * This is meant to be used by plugins that needs to updates the whole list of applications.
     * To only updates a specific application, use the `updater$` property of the registered application instead.
     *
     *  example registerAppUpdater ( appUpdater$ ) : void ; /**
     * Register a context provider for application mounting. Will only be available to applications that depend on the
     * plugin that registered this context. Deprecated, use  CoreSetup . getStartServices .
     *
     *  deprecated param contextName - The key of  AppMountContext this provider's return value should be attached to.
     *  param provider - A  IContextProvider function
      registerMountContext < T extends keyof AppMountContext > ( contextName , provider ) : void ; } internal export interface InternalApplicationSetup extends Pick < ApplicationSetup , 'registerAppUpdater' > { param plugin param app register < HistoryLocationState = unknown > ( plugin , app ) : void ; /**
     * Register a context provider for application mounting. Will only be available to applications that depend on the
     * plugin that registered this context. Deprecated, use  CoreSetup . getStartServices .
     *
     *  deprecated param pluginOpaqueId param contextName - The key of  AppMountContext this provider's return value should be attached to.
     *  param provider - A  IContextProvider function
      registerMountContext < T extends keyof AppMountContext > ( pluginOpaqueId , contextName , provider ) : void ; } /**
 * Options for the  ApplicationStart . navigateToApp export interface NavigateToAppOptions { /**
     * optional path inside application to deep link to.
     * If undefined, will use  App . defaultPath ` as default.
      path ? : string ; /**
     * optional state to forward to the application
     */ state ? : unknown ; /**
     * if true, will not create a new history entry when navigating (using `replace` instead of `push`)
     */ replace ? : boolean ; } public export interface ApplicationStart { /**
     * Gets the read-only capabilities.
     */ capabilities : RecursiveReadonly < Capabilities > ; remarks Applications disabled by  Capabilities will not be present in the map. Applications manually disabled from
     * the client-side using an  AppUpdater are present, with their status properly set as `inaccessible`.
      applications$ : Observable < ReadonlyMap < string , PublicAppInfo > > ; param appId param options navigateToApp ( appId , options ? ) : Promise < void > ; example param url navigateToUrl ( url ) : Promise < void > ; param appId param options . path param options . absolute getUrlForApp ( appId , options ? ) : string ; /**
     * Register a context provider for application mounting. Will only be available to applications that depend on the
     * plugin that registered this context. Deprecated, use  CoreSetup . getStartServices .
     *
     *  deprecated param contextName - The key of  AppMountContext this provider's return value should be attached to.
     *  param provider - A  IContextProvider function
      registerMountContext < T extends keyof AppMountContext > ( contextName , provider ) : void ; /**
     * An observable that emits the current application id and each subsequent id update.
     */ currentAppId$ : Observable < string | undefined > ; } internal export interface InternalApplicationStart extends Omit < ApplicationStart , 'registerMountContext' > { /**
     * Register a context provider for application mounting. Will only be available to applications that depend on the
     * plugin that registered this context. Deprecated, use  CoreSetup . getStartServices .
     *
     *  deprecated param pluginOpaqueId param contextName - The key of  AppMountContext this provider's return value should be attached to.
     *  param provider - A  IContextProvider function
      registerMountContext < T extends keyof AppMountContext > ( pluginOpaqueId , contextName , provider ) : void ; getComponent ( ) : JSX . Element | null ; internal currentActionMenu$ : Observable < MountPoint | undefined > ; internal history : History < unknown > ; }