import _ from 'lodash' ; import { createHashHistory } from 'history' ; import { ScopedHistory , AppMountParameters } from 'opensearch-dashboards/public' ; import { UiActionsStart } from 'src/plugins/ui_actions/public' ; import { DiscoverServices } from './build_services' ; import { createGetterSetter } from '../../opensearch_dashboards_utils/public' ; import { search } from '../../data/public' ; import { DocViewsRegistry } from './application/doc_views/doc_views_registry' ; let angularModule = null ; let services = null ; let uiActions ; /**
 * set bootstrapped inner angular module
 */ export function setAngularModule ( module ) { angularModule = module ; } /**
 * get boostrapped inner angular module
 */ export function getAngularModule ( ) { return angularModule ; } export function getServices ( ) { if ( ! services ) { throw new Error ( 'Discover services are not yet available' ) ; } return services ; } export function setServices ( newServices ) { services = newServices ; } export const setUiActions = ( pluginUiActions ) => ( uiActions = pluginUiActions ) ; export const getUiActions = ( ) => uiActions ; export const [ getHeaderActionMenuMounter , setHeaderActionMenuMounter ] = createGetterSetter < AppMountParameters [ 'setHeaderActionMenu' ] > ( 'headerActionMenuMounter' ) ; export const [ getUrlTracker , setUrlTracker ] = createGetterSetter < { setTrackedUrl : ( url : string ) => void ; restorePreviousUrl : ( ) => void ; } > ( 'urlTracker' ) ; export const [ getDocViewsRegistry , setDocViewsRegistry ] = createGetterSetter < DocViewsRegistry > ( 'DocViewsRegistry' ) ; /**
 * Makes sure discover and context are using one instance of history.
 */ export const getHistory = _ . once ( ( ) => createHashHistory ( ) ) ; /**
 * Discover currently uses two `history` instances: one from OpenSearch Dashboards Platform and
 * another from `history` package. Below function is used every time Discover
 * app is loaded to synchronize both instances.
 *
 * This helper is temporary until https://github.com/elastic/kibana/issues/65161 is resolved.
 */ export const syncHistoryLocations = ( ) => { const h = getHistory ( ) ; Object . assign ( h . location , createHashHistory ( ) . location ) ; return h ; } ; export const [ getScopedHistory , setScopedHistory ] = createGetterSetter < ScopedHistory > ( 'scopedHistory' ) ; export const { getRequestInspectorStats , getResponseInspectorStats , tabifyAggResponse } = search ; export { unhashUrl , redirectWhenMissing } from '../../opensearch_dashboards_utils/public' ; export { formatMsg , formatStack , subscribeWithScope , } from '../../opensearch_dashboards_legacy/public' ; export { IndexPatternsContract , IIndexPattern , IndexPattern , indexPatterns , IFieldType , ISearchSource , OpenSearchQuerySortValue , SortDirection , } from '../../data/public' ;