import { last , isEqual } from 'lodash' ; import { DATA_FORMATTERS } from '../../../../common/enums' ; import type { Series } from '../../../../common/types' ; import type { FieldFormatMap } from '../../../../../../data/common' ; export const checkIfSeriesHaveSameFormatters = ( seriesModel , fieldFormatMap ? ) => { const allSeriesHaveDefaultFormatting = seriesModel . every ( ( seriesGroup ) => seriesGroup . formatter === DATA_FORMATTERS . DEFAULT ) ; return allSeriesHaveDefaultFormatting && fieldFormatMap ? seriesModel . map ( ( { metrics } ) => fieldFormatMap [ last ( metrics ) ?. field ?? '' ] ) . every ( ( fieldFormat , index , [ firstSeriesFieldFormat ] ) => isEqual ( fieldFormat , firstSeriesFieldFormat ) ) : seriesModel . every ( ( series ) => series . formatter === seriesModel [ 0 ] . formatter && series . value_template === seriesModel [ 0 ] . value_template ) ; } ;