"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");

var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");

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

var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));

var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));

var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));

var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));

var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));

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

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

var _CustomPropTypes = _interopRequireDefault(require("@instructure/ui-utils/lib/react/CustomPropTypes"));

var _CloseButton = _interopRequireDefault(require("@instructure/ui-buttons/lib/components/CloseButton"));

var _Button = _interopRequireDefault(require("@instructure/ui-buttons/lib/components/Button"));

var _Breadcrumb = _interopRequireDefault(require("@instructure/ui-breadcrumb/lib/components/Breadcrumb"));

var _BreadcrumbLink = _interopRequireDefault(require("@instructure/ui-breadcrumb/lib/components/Breadcrumb/BreadcrumbLink"));

var _IconBank = _interopRequireDefault(require("@instructure/ui-icons/lib/Line/IconBank"));

var _lib = _interopRequireDefault(require("@instructure/ui-themeable/lib"));

var _formatMessage = _interopRequireDefault(require("@instructure/quiz-i18n/lib/format-message"));

var _theme = _interopRequireDefault(require("./theme"));

var _dec, _class, _class2, _temp;

var styles = {
  componentId: 'clBDH',
  template: function template(theme) {
    return "\n\n.clBDH_diTj{align-items:center;background-color:".concat(theme.navBackgroundColor || 'inherit', ";border-bottom:").concat(theme.navBorderWidth || 'inherit', " solid ").concat(theme.navBorderColor || 'inherit', ";box-sizing:border-box;display:flex;flex-direction:row;padding:").concat(theme.navPaddingTopBottom || 'inherit', " ").concat(theme.navPaddingLeftRight || 'inherit', ";position:-webkit-sticky;position:sticky;top:0;width:100%;z-index:4444}\n\n.clBDH_ZXRE{flex:1}");
  },
  'nav': 'clBDH_diTj',
  'crumbs': 'clBDH_ZXRE'
};

var _ref =
/*#__PURE__*/
_react.default.createElement(_IconBank.default, {
  size: "x-small"
});

var NavWrapper = (_dec = (0, _lib.default)(_theme.default, styles), _dec(_class = (_temp = _class2 =
/*#__PURE__*/
function (_Component) {
  (0, _inherits2.default)(NavWrapper, _Component);

  function NavWrapper() {
    (0, _classCallCheck2.default)(this, NavWrapper);
    return (0, _possibleConstructorReturn2.default)(this, (0, _getPrototypeOf2.default)(NavWrapper).apply(this, arguments));
  }

  (0, _createClass2.default)(NavWrapper, [{
    key: "renderBreadcrumbLinks",
    value: function renderBreadcrumbLinks() {
      var firstLink = _react.default.createElement(_BreadcrumbLink.default, {
        icon: _ref,
        key: "Banks",
        onClick: this.props.navigateToBanks,
        autoFocus: Boolean(this.props.navigateToBanks)
      }, "Banciau Eitemau"); // If Breadcrumb has multiple children (even if 2nd is null), it will
      // render the `>` icon, which we don't want if there are no children.


      return this.props.children ? [firstLink, this.props.children] : firstLink;
    }
  }, {
    key: "renderCloseButton",
    value: function renderCloseButton() {
      if (this.props.closeTray) {
        return _react.default.createElement(_CloseButton.default, {
          placement: "start",
          onClick: this.props.closeTray
        }, "Dychwelyd i\u2019r cwis");
      }
    }
  }, {
    key: "render",
    value: function render() {
      return _react.default.createElement("div", {
        className: styles.nav
      }, this.renderCloseButton(), _react.default.createElement("div", {
        className: styles.crumbs
      }, _react.default.createElement(_Breadcrumb.default, {
        size: "small",
        label: "Rydych chi yma:"
      }, this.renderBreadcrumbLinks())), this.props.navigateToBuild && _react.default.createElement(_Button.default, {
        onClick: this.props.navigateToBuild
      }, "Dychwelyd"), this.props.renderHeaderMenu());
    }
  }]);
  NavWrapper.displayName = "NavWrapper";
  return NavWrapper;
}(_react.Component), _class2.propTypes = {
  children: _CustomPropTypes.default.Children.oneOf([_BreadcrumbLink.default]),
  closeTray: _propTypes.default.func,
  navigateToBanks: _propTypes.default.func,
  navigateToBuild: _propTypes.default.func,
  renderHeaderMenu: _propTypes.default.func
}, _class2.defaultProps = {
  children: null,
  closeTray: null,
  navigateToBanks: null,
  navigateToBuild: null,
  renderHeaderMenu: function renderHeaderMenu() {}
}, _temp)) || _class);
var _default = NavWrapper;
exports.default = _default;