import { action } from '@storybook/addon-actions' ; import { debounce } from 'ts-debounce' ; import { DebugState } from '@elastic/charts' ; export const getDebugStateLogger = ( debugState ) => { const dataStateAction = action ( 'DataState' ) ; return debounce ( ( ) => { if ( ! debugState ) return ; const statusEl = document . querySelector < HTMLDivElement > ( '.echChartStatus' ) ; if ( statusEl ) { const dataState = statusEl . dataset . echDebugState ? ( JSON . parse ( statusEl . dataset . echDebugState ) as DebugState ) : null ; if ( dataState ) dataStateAction ( dataState ) ; } } , 100 ) ; } ;