import _defineProperty from "@babel/runtime/helpers/defineProperty";

function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }

function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }

var actions = {
  NEXT_STEP: "next_step",
  PREV_STEP: "prev_step",
  SET_STEP: "set_step",
  SET_TAB: "set_tab"
};
export var defaultState = {
  step: "goal",
  tab: "texts"
};
var STEPS_FLOW = {
  goal: {
    prev: "goal",
    next: "connect"
  },
  connect: {
    prev: "goal",
    next: "assets"
  },
  assets: {
    prev: "connect",
    next: "summary"
  },
  summary: {
    prev: "assets",
    next: "finish"
  }
};
export function reducer(state, action) {
  switch (action.type) {
    case actions.NEXT_STEP:
      return _objectSpread(_objectSpread({}, state), {}, {
        step: STEPS_FLOW[state.step].next
      });

    case actions.PREV_STEP:
      return _objectSpread(_objectSpread({}, state), {}, {
        step: STEPS_FLOW[state.step].prev
      });

    case actions.SET_STEP:
      return _objectSpread(_objectSpread({}, state), {}, {
        step: action.payload
      });

    case actions.SET_TAB:
      return _objectSpread(_objectSpread({}, state), {}, {
        tab: action.payload
      });

    default:
      return state;
  }
}
export function nextStep(dispatch) {
  dispatch({
    type: actions.NEXT_STEP
  });
}
export function previousStep(dispatch) {
  dispatch({
    type: actions.PREV_STEP
  });
}
export function setStep(dispatch, step) {
  dispatch({
    type: actions.SET_STEP,
    payload: step
  });
}
export function setTab(dispatch, tab) {
  dispatch({
    type: actions.SET_TAB,
    payload: tab
  });
}
export function moveToTab(dispatch, tab) {
  dispatch({
    type: actions.SET_STEP,
    payload: "assets"
  });
  dispatch({
    type: actions.SET_TAB,
    payload: tab
  });
}