import { CoreStart , Plugin , PluginInitializerContext } from 'kibana/public' ; import { setKibanaVersion , setLicensingPluginStart , setMapConfig , getIsEnterprisePlus , } from './kibana_services' ; import type { MapsEmsPluginPublicSetup , MapsEmsPluginPublicStart } from './index' ; import type { MapConfig } from '../config' ; import { createEMSSettings } from '../common/ems_settings' ; import type { LicensingPluginStart } from '../../../../x-pack/plugins/licensing/public' ; import { createEMSClientLazy } from './lazy_load_bundle' ; interface MapsEmsStartPublicDependencies { licensing ? : LicensingPluginStart ; } export class MapsEmsPlugin implements Plugin < MapsEmsPluginPublicSetup , MapsEmsPluginPublicStart > { readonly _initializerContext : PluginInitializerContext < MapConfig > ; constructor ( initializerContext ) { this . _initializerContext = initializerContext ; } public setup ( ) { return { } ; } public start ( code , plugins ) { const mapConfig = this . _initializerContext . config . get < MapConfig > ( ) ; const kibanaVersion = this . _initializerContext . env . packageInfo . version ; setKibanaVersion ( kibanaVersion ) ; setMapConfig ( mapConfig ) ; if ( plugins . licensing ) { setLicensingPluginStart ( plugins . licensing ) ; } return { config : mapConfig , createEMSSettings : ( ) => { return createEMSSettings ( mapConfig , getIsEnterprisePlus ) ; } , createEMSClient : async ( ) => { const emsSettings = createEMSSettings ( mapConfig , getIsEnterprisePlus ) ; return createEMSClientLazy ( emsSettings , kibanaVersion ) ; } , } ; } }