const controlService = require('./control-service.js')
const themeService = require('../../store/theme-store.js')
const {
  getStatusSummaryState
} = require('../../domain/motor-control/status-state.js')

function getControlPageState(
  controlState = controlService.getState(),
  themeState = themeService.getState()
) {
  return {
    ...controlState,
    ...themeState,
    canReadStatus: !!controlState.connectedDevice && !controlState.isBootloaderBusy,
    statusSummary: getStatusSummaryState()
  }
}

module.exports = {
  getControlPageState
}
