import { BasicSeriesSpec , DEFAULT_GLOBAL_ID , Spec } from '../../../../specs' ; import { Rotation } from '../../../../utils/common' ; import { GroupId } from '../../../../utils/ids' ; import { isXDomain } from '../../utils/axis_utils' ; import { AxisSpec } from '../../utils/specs' ; internal export function getSpecsById < T extends Spec > ( specs , id ) { return specs . find ( ( spec ) => spec . id === id ) ; } internal export function getAxesSpecForSpecId ( axesSpecs , groupId , chartRotation = 0 ) { return axesSpecs . reduce < { xAxis ? : AxisSpec ; yAxis ? : AxisSpec ; } > ( ( result , spec ) => { if ( spec . groupId === groupId && isXDomain ( spec . position , chartRotation ) ) result . xAxis = spec ; else if ( spec . groupId === groupId && ! isXDomain ( spec . position , chartRotation ) ) result . yAxis = spec ; return result ; } , { } ) ; } internal export function getSpecDomainGroupId ( spec ) { if ( ! spec . useDefaultGroupDomain ) { return spec . groupId ; } return typeof spec . useDefaultGroupDomain === 'boolean' ? DEFAULT_GLOBAL_ID : spec . useDefaultGroupDomain ; }