import { VISUALIZATION_COLORS } from '@elastic/eui' ; import type { Space } from '../../common' ; import { MAX_SPACE_INITIALS } from '../../common' ; const FALLBACK_CODE_POINT = 97 ; param { Space } space export function getSpaceColor ( space = { } ) { const { color , name = '' } = space ; if ( color ) { return color ; } const firstCodePoint = name . codePointAt ( 0 ) || FALLBACK_CODE_POINT ; return VISUALIZATION_COLORS [ firstCodePoint % VISUALIZATION_COLORS . length ] ; } param { Space } space export function getSpaceInitials ( space = { } ) { const { initials , name = '' } = space ; if ( initials ) { return initials ; } const words = name . split ( ' ' ) ; const numInitials = Math . min ( MAX_SPACE_INITIALS , words . length ) ; words . splice ( numInitials , words . length ) ; return words . map ( ( word ) => word . substring ( 0 , 1 ) ) . join ( '' ) ; } param { Space } space export function getSpaceImageUrl ( space = { } ) { const { imageUrl } = space ; if ( imageUrl ) { return imageUrl ; } return '' ; }