import { computeChartDimensionsSelector } from '../../chart_types/xy_chart/state/selectors/compute_chart_dimensions' ; import { getComputedScalesSelector } from '../../chart_types/xy_chart/state/selectors/get_computed_scales' ; import { PointerEventType } from '../../specs' ; import { GlobalChartState } from '../chart_state' ; import { createCustomCachedSelector } from '../create_selector' ; import { getSettingsSpecSelector } from './get_settings_specs' ; import { hasExternalEventSelector } from './has_external_pointer_event' ; const getExternalEventPointer = ( { externalEvents : { pointer } } ) => pointer ; internal export const isExternalTooltipVisibleSelector = createCustomCachedSelector ( [ getSettingsSpecSelector , hasExternalEventSelector , getExternalEventPointer , getComputedScalesSelector , computeChartDimensionsSelector , ] , ( { externalPointerEvents } , hasExternalEvent , pointer , { xScale } , { chartDimensions } ) : boolean => { if ( ! pointer || pointer . type !== PointerEventType . Over || externalPointerEvents . tooltip ?. visible === false ) { return false ; } const x = xScale . pureScale ( pointer . x ) ; if ( Number . isNaN ( x ) || x > chartDimensions . width + chartDimensions . left || x < 0 ) { return false ; } return Boolean ( hasExternalEvent && externalPointerEvents . tooltip ?. visible ) ; } ) ;