import * as React from 'react' ; import type { CoreStart } from 'src/core/public' ; import type { SpacesManager } from '../spaces_manager' ; import type { SpacesData } from '../types' ; import type { SpacesReactContext , SpacesReactContextValue } from './types' ; const { useContext , createElement , createContext } = React ; const context = createContext < Partial < SpacesReactContextValue < Partial < CoreStart > > > > ( { } ) ; export const useSpaces = < Services extends Partial < CoreStart > > ( ) : SpacesReactContextValue < Services > => useContext ( context as unknown as React . Context < SpacesReactContextValue < Services > > ) ; export const createSpacesReactContext = < Services extends Partial < CoreStart > > ( services , spacesManager , spacesDataPromise ) : SpacesReactContext < Services > => { const value = { spacesManager , spacesDataPromise , services , } ; const Provider = ( { children } ) => createElement ( context . Provider as React . ComponentType < any > , { value , children } ) ; return { value , Provider , Consumer : context . Consumer as unknown as React . Consumer < SpacesReactContextValue < Services > > , } ; } ;