import { toConsumableArray as _toConsumableArray } from '../../../_virtual/_rollupPluginBabelHelpers.js';

function pathReducer(state, action) {
  switch (action.type) {
    case 'reset':
      {
        return [];
      }
    case 'opened_first_level':
      {
        return ['root'];
      }
    case 'added_next_level':
      {
        return [].concat(_toConsumableArray(state), [action.value]);
      }
    case 'removed_last_level':
      {
        return state.slice(0, -1);
      }
    case 'changed_on_level':
      {
        return [].concat(_toConsumableArray(state.slice(0, action.level)), [action.value]);
      }
    case 'cut_by_level':
      {
        return state.slice(0, action.level);
      }
    default:
      {
        return state;
      }
  }
}

export { pathReducer };
