"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;

var _ui = require("../actions/ui");

var _redux = require("redux");

/*
 * Copyright (C) 2018 - present Instructure, Inc.
 *
 * This file is part of Canvas.
 *
 * Canvas is free software: you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License as published by the Free
 * Software Foundation, version 3 of the License.
 *
 * Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
 * A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License along
 * with this program. If not, see <http://www.gnu.org/licenses/>.
 */
function hidden() {
  var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  var action = arguments.length > 1 ? arguments[1] : undefined;

  switch (action.type) {
    case _ui.HIDE_SIDEBAR:
      return true;

    case _ui.RESET_UI:
    case _ui.SHOW_SIDEBAR:
      return false;

    default:
      return state;
  }
}

function selectedTabIndex() {
  var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
  var action = arguments.length > 1 ? arguments[1] : undefined;

  switch (action.type) {
    case _ui.RESET_UI:
      return 0;

    case _ui.CHANGE_TAB:
      return action.index;

    default:
      return state;
  }
}

function selectedAccordionIndex() {
  var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "";
  var action = arguments.length > 1 ? arguments[1] : undefined;

  switch (action.type) {
    case _ui.RESET_UI:
      return "";

    case _ui.CHANGE_TAB:
      // switch links panel accordion tab back to first tab any time we
      // switch _back to_ links panel
      return "";

    case _ui.CHANGE_ACCORDION:
      return action.index;

    default:
      return state;
  }
}

var _default = (0, _redux.combineReducers)({
  hidden: hidden,
  selectedTabIndex: selectedTabIndex,
  selectedAccordionIndex: selectedAccordionIndex
});

exports.default = _default;