import type { FC , PropsWithChildren , PropsWithRef } from 'react' ; import React from 'react' ; import type { StartServicesAccessor } from 'src/core/public' ; import { getCopyToSpaceFlyoutComponent } from '../copy_saved_objects_to_space' ; import { getEmbeddableLegacyUrlConflict , getLegacyUrlConflict } from '../legacy_urls' ; import type { PluginsStart } from '../plugin' ; import { getShareToSpaceFlyoutComponent } from '../share_saved_objects_to_space' ; import { getSpaceAvatarComponent } from '../space_avatar' ; import { getSpaceListComponent } from '../space_list' ; import { getSpacesContextProviderWrapper } from '../spaces_context' ; import type { SpacesManager } from '../spaces_manager' ; import { LazyWrapper } from './lazy_wrapper' ; import type { SpacesApiUiComponent } from './types' ; export interface GetComponentsOptions { spacesManager : SpacesManager ; getStartServices : StartServicesAccessor < PluginsStart > ; } export const getComponents = ( { spacesManager , getStartServices , } ) : SpacesApiUiComponent => { /**
     * Returns a function that creates a lazy-loading version of a component.
     */ function wrapLazy < T > ( fn , options = { } ) { const { showLoadingSpinner } = options ; return ( props ) => ( < LazyWrapper fn = { fn } getStartServices = { getStartServices } props = { props } showLoadingSpinner = { showLoadingSpinner } / > ) ; } return { getSpacesContextProvider : wrapLazy ( ( ) => getSpacesContextProviderWrapper ( { spacesManager , getStartServices } ) ) , getShareToSpaceFlyout : wrapLazy ( getShareToSpaceFlyoutComponent , { showLoadingSpinner : false } ) , getCopyToSpaceFlyout : wrapLazy ( getCopyToSpaceFlyoutComponent , { showLoadingSpinner : false } ) , getSpaceList : wrapLazy ( getSpaceListComponent ) , getEmbeddableLegacyUrlConflict : wrapLazy ( ( ) => getEmbeddableLegacyUrlConflict ( { spacesManager , getStartServices } ) ) , getLegacyUrlConflict : wrapLazy ( ( ) => getLegacyUrlConflict ( { getStartServices } ) ) , getSpaceAvatar : wrapLazy ( getSpaceAvatarComponent ) , } ; } ;