import { StepType , TraceStep , VisualizationData } from '@app/models' ; export function getNextStepNumber ( entity , increment ) { const currentStep = entity . step ; const lastStep = Math . max ( 0 , entity . maxSteps - 1 ) ; switch ( increment ) { case 'first' : return 0 ; case 'previous' : return Math . max ( 0 , currentStep - 1 ) ; case 'next' : return Math . min ( lastStep , currentStep + 1 ) ; case 'last' : return lastStep ; } } export function patchStep ( entity , step ) { return { ... entity , step : getNextStepNumber ( entity , step ) } ; } export function toggleVisualize ( entity ) { return { ... entity , visualize : ! entity . visualize } ; } export function patchData ( entity , data ) { return { ... entity , data , step : 0 , maxSteps : data . length , visualize : true } ; } export function showVisualization ( visualization ) { return ! ! visualization && ! ! visualization . visualize && ! ! visualization . data && ! visualization . error ; } export function showError ( visualization ) { return ! ! visualization && ! ! visualization . visualize && ! ! visualization . error ; }