"use strict";

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

var _react = _interopRequireDefault(require("react"));

var _propTypes = _interopRequireDefault(require("prop-types"));

var _get = _interopRequireDefault(require("lodash/get"));

var _SidebarToggleButton = _interopRequireDefault(require("../navigation/SidebarToggleButton"));

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

const propTypes = {
  config: _propTypes.default.shape({
    recordTypes: _propTypes.default.object
  }),
  recordType: _propTypes.default.string,
  isRecordSidebarOpen: _propTypes.default.bool,
  toggleRecordSidebar: _propTypes.default.func
};
const defaultProps = {
  isRecordSidebarOpen: true
};

function RecordSidebarToggleButton(props) {
  const {
    config,
    recordType,
    isRecordSidebarOpen,
    toggleRecordSidebar
  } = props;
  const serviceType = (0, _get.default)(config, ['recordTypes', recordType, 'serviceConfig', 'serviceType']);
  const isAuthority = serviceType === 'authority';
  return /*#__PURE__*/_react.default.createElement(_SidebarToggleButton.default, {
    color: isAuthority ? 'purple' : 'blue',
    isOpen: isRecordSidebarOpen,
    toggle: toggleRecordSidebar
  });
}

RecordSidebarToggleButton.propTypes = propTypes;
RecordSidebarToggleButton.defaultProps = defaultProps;