"use strict";

exports.__esModule = true;
exports.default = void 0;
var _snakeCase2 = _interopRequireDefault(require("lodash/fp/snakeCase"));
var _react = _interopRequireDefault(require("react"));
var _propTypes = _interopRequireDefault(require("prop-types"));
var _link = _interopRequireDefault(require("../../atom/link"));
var _hoverFill = require("../../atom/button/hover-fill.css");
var _style = _interopRequireDefault(require("./style.css"));
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
const buildBreadcrumbs = (breadcrumb, index) => {
  const {
    title,
    href
  } = breadcrumb;
  if (!href) {
    return /*#__PURE__*/_react.default.createElement("div", {
      className: _style.default.breadcrumb,
      key: index
    }, /*#__PURE__*/_react.default.createElement("span", null, title));
  }
  return /*#__PURE__*/_react.default.createElement("div", {
    className: _style.default.breadcrumb,
    key: index
  }, /*#__PURE__*/_react.default.createElement(_link.default, {
    href: href
  }, title));
};
const buildLink = (link, index) => {
  const {
    title,
    href,
    type
  } = link;
  const className = type === 'primary' ? _style.default.primary : _style.default.secondary;
  return /*#__PURE__*/_react.default.createElement("div", {
    className: className,
    key: index
  }, /*#__PURE__*/_react.default.createElement(_link.default, {
    "data-name": `${(0, _snakeCase2.default)(title)}_link`,
    className: _hoverFill.hoverFill,
    target: "_blank",
    href: href
  }, title));
};
const Breadcrumbs = props => {
  const {
    breadcrumbs,
    links = []
  } = props;
  const breadcrumbsList = breadcrumbs.map(buildBreadcrumbs);
  const linksList = links.map(buildLink);
  return /*#__PURE__*/_react.default.createElement("div", {
    className: _style.default.wrapper
  }, /*#__PURE__*/_react.default.createElement("div", null, breadcrumbsList), /*#__PURE__*/_react.default.createElement("div", null, linksList));
};
Breadcrumbs.propTypes = process.env.NODE_ENV !== "production" ? {
  breadcrumbs: _propTypes.default.arrayOf(_propTypes.default.shape({
    title: _propTypes.default.string.isRequired,
    href: _propTypes.default.string
  })),
  links: _propTypes.default.arrayOf(_propTypes.default.shape({
    title: _link.default.propTypes.children,
    href: _link.default.propTypes.href,
    type: _propTypes.default.string
  }))
} : {};
var _default = exports.default = Breadcrumbs;
//# sourceMappingURL=index.js.map