"use strict";

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

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

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

var _classnames = _interopRequireDefault(require("classnames"));

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

function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }

function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }

function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }

var Header = function Header(_ref) {
  var backLinkHref = _ref.backLinkHref,
      backLinkOnClick = _ref.backLinkOnClick,
      backLinkText = _ref.backLinkText,
      className = _ref.className,
      hasBackLink = _ref.hasBackLink,
      isFullHeight = _ref.isFullHeight,
      primaryTitle = _ref.primaryTitle,
      projectName = _ref.projectName,
      secondaryTitle = _ref.secondaryTitle,
      shouldHeaderScroll = _ref.shouldHeaderScroll,
      usesMonospaceStyling = _ref.usesMonospaceStyling,
      props = _objectWithoutProperties(_ref, ["backLinkHref", "backLinkOnClick", "backLinkText", "className", "hasBackLink", "isFullHeight", "primaryTitle", "projectName", "secondaryTitle", "shouldHeaderScroll", "usesMonospaceStyling"]);

  var maxCharCount = 22;
  return _react["default"].createElement("div", _extends({
    className: (0, _classnames["default"])({
      sidenav__header: true,
      "sidenav__header--full-height": isFullHeight,
      "overflow-y--auto": shouldHeaderScroll
    }, className)
  }, props), _react["default"].createElement("div", {
    className: "micro muted",
    "data-test-section": "header-project-name"
  }, projectName), hasBackLink && _react["default"].createElement("div", {
    className: "push--bottom"
  }, _react["default"].createElement("a", {
    href: backLinkHref,
    onClick: backLinkOnClick,
    className: "nav-link nav-link--back",
    "data-test-section": "header-back-link"
  }, backLinkText)), primaryTitle && _react["default"].createElement("h1", {
    className: (0, _classnames["default"])({
      sidenav__header__title: true,
      "flush--bottom": true,
      "force-break": true,
      gamma: !usesMonospaceStyling,
      delta: usesMonospaceStyling && primaryTitle.length <= maxCharCount,
      zeta: usesMonospaceStyling && primaryTitle.length > maxCharCount,
      monospace: usesMonospaceStyling
    }),
    title: primaryTitle,
    "data-test-section": "header-title"
  }, primaryTitle), secondaryTitle && _react["default"].createElement("p", null, secondaryTitle), props.children);
};

Header.propTypes = {
  /** Href URL to use for Breadcrumb */
  backLinkHref: _propTypes["default"].string,

  /** Callback to perform when breadcrumb link is clicked */
  backLinkOnClick: _propTypes["default"].func,

  /** Text to use for Breadcrumb */
  backLinkText: _propTypes["default"].string,

  /** Content to render below the main title */
  children: _propTypes["default"].node,

  /** CSS class names. */
  className: _propTypes["default"].string,

  /** Whether or not a breadcrumb back link is present */
  hasBackLink: _propTypes["default"].bool,

  /** Whether or not the header should be full height */
  isFullHeight: _propTypes["default"].bool,

  /** The title of the current entity */
  primaryTitle: _propTypes["default"].string,

  /** The name of the current project */
  projectName: _propTypes["default"].oneOfType([_propTypes["default"].string, _propTypes["default"].node]).isRequired,

  /** A secondary name of the current entity, if applicable */
  secondaryTitle: _propTypes["default"].string,

  /** Whether or not the header should scroll */
  shouldHeaderScroll: _propTypes["default"].bool,

  /** Whether or not the header uses monospace styling */
  usesMonospaceStyling: _propTypes["default"].bool
};
Header.defaultProps = {
  isFullHeight: false,
  usesMonospaceStyling: false,
  hasBackLink: true,
  primaryTitle: null
};
var _default = Header;
exports["default"] = _default;