"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.changeSection = changeSection;
exports.changeStateTreeSettings = changeStateTreeSettings;
exports.changeTheme = changeTheme;
exports.clearNotification = clearNotification;
exports.dispatchRemotely = dispatchRemotely;
exports.exportState = exportState;
exports.getReport = getReport;
exports.importState = importState;
exports.liftedDispatch = liftedDispatch;
exports.lockChanges = lockChanges;
exports.pauseRecording = pauseRecording;
exports.saveSocketSettings = saveSocketSettings;
exports.selectInstance = selectInstance;
exports.selectMonitor = selectMonitor;
exports.selectMonitorTab = selectMonitorTab;
exports.selectMonitorWithState = selectMonitorWithState;
exports.setPersist = setPersist;
exports.showNotification = showNotification;
exports.toggleDispatcher = toggleDispatcher;
exports.togglePersist = togglePersist;
exports.toggleSlider = toggleSlider;
exports.toggleSync = toggleSync;
exports.updateMonitorState = updateMonitorState;
var _actionTypes = require("../constants/actionTypes");
var _socketActionTypes = require("../constants/socketActionTypes");
let monitorReducer;
let monitorProps = {};
function changeSection(section) {
  return {
    type: _actionTypes.CHANGE_SECTION,
    section
  };
}
function changeTheme(data) {
  return {
    type: _actionTypes.CHANGE_THEME,
    ...data.formData
  };
}
function changeStateTreeSettings(data) {
  return {
    type: _actionTypes.CHANGE_STATE_TREE_SETTINGS,
    ...data.formData
  };
}
function liftedDispatch(action) {
  if (action.type[0] === '@') {
    if (action.type === '@@INIT_MONITOR') {
      monitorReducer = action.update;
      monitorProps = action.monitorProps;
    }
    return {
      type: _actionTypes.MONITOR_ACTION,
      action,
      monitorReducer,
      monitorProps
    };
  }
  return {
    type: _actionTypes.LIFTED_ACTION,
    message: 'DISPATCH',
    action
  };
}
function selectInstance(selected) {
  return {
    type: _actionTypes.SELECT_INSTANCE,
    selected
  };
}
function selectMonitor(monitor) {
  return {
    type: _actionTypes.SELECT_MONITOR,
    monitor
  };
}
function selectMonitorWithState(value, monitorState) {
  return {
    type: _actionTypes.SELECT_MONITOR,
    monitor: value,
    monitorState
  };
}
function selectMonitorTab(subTabName) {
  return {
    type: _actionTypes.UPDATE_MONITOR_STATE,
    nextState: {
      subTabName
    }
  };
}
function updateMonitorState(nextState) {
  return {
    type: _actionTypes.UPDATE_MONITOR_STATE,
    nextState
  };
}
function importState(state, preloadedState) {
  return {
    type: _actionTypes.LIFTED_ACTION,
    message: 'IMPORT',
    state,
    preloadedState
  };
}
function exportState() {
  return {
    type: _actionTypes.EXPORT
  };
}
function lockChanges(status) {
  return {
    type: _actionTypes.LIFTED_ACTION,
    message: 'DISPATCH',
    action: {
      type: 'LOCK_CHANGES',
      status
    },
    toAll: true
  };
}
function pauseRecording(status) {
  return {
    type: _actionTypes.LIFTED_ACTION,
    message: 'DISPATCH',
    action: {
      type: 'PAUSE_RECORDING',
      status
    },
    toAll: true
  };
}
function dispatchRemotely(action) {
  return {
    type: _actionTypes.LIFTED_ACTION,
    message: 'ACTION',
    action
  };
}
function togglePersist() {
  return {
    type: _actionTypes.TOGGLE_PERSIST
  };
}
function setPersist(persist) {
  return {
    type: _actionTypes.SET_PERSIST,
    payload: persist
  };
}
function toggleSync() {
  return {
    type: _actionTypes.TOGGLE_SYNC
  };
}
function toggleSlider() {
  return {
    type: _actionTypes.TOGGLE_SLIDER
  };
}
function toggleDispatcher() {
  return {
    type: _actionTypes.TOGGLE_DISPATCHER
  };
}
function saveSocketSettings(options) {
  return {
    type: _socketActionTypes.RECONNECT,
    options
  };
}
function showNotification(message) {
  return {
    type: _actionTypes.SHOW_NOTIFICATION,
    notification: {
      type: 'error',
      message
    }
  };
}
function clearNotification() {
  return {
    type: _actionTypes.CLEAR_NOTIFICATION
  };
}
function getReport(report) {
  return {
    type: _actionTypes.GET_REPORT_REQUEST,
    report
  };
}