import React__default from 'react';
import { Breadcrumb, BreadcrumbList, BreadcrumbItem, BreadcrumbPage, BreadcrumbLink, BreadcrumbSeparator } from '@bigbinary/neeto-atoms';
import classnames from 'classnames';
import { withT } from '@bigbinary/neeto-commons-frontend/react-utils';
import { hyphenize } from '@bigbinary/neeto-commons-frontend/utils/general';
import { Link } from 'react-router-dom';
import { jsx, jsxs } from 'react/jsx-runtime';

var Breadcrumbs = withT(function (_ref) {
  var t = _ref.t,
    _ref$breadcrumbs = _ref.breadcrumbs,
    breadcrumbs = _ref$breadcrumbs === void 0 ? [] : _ref$breadcrumbs,
    _ref$hasTrailingSepar = _ref.hasTrailingSeparator,
    hasTrailingSeparator = _ref$hasTrailingSepar === void 0 ? false : _ref$hasTrailingSepar,
    className = _ref.className;
  return /*#__PURE__*/jsx(Breadcrumb, {
    "aria-label": t("neetoMolecules.breadcrumbs.breadcrumbAriaLabel"),
    className: classnames("mb-4", className),
    children: /*#__PURE__*/jsx(BreadcrumbList, {
      children: breadcrumbs.map(function (_ref2, index) {
        var text = _ref2.text,
          _ref2$link = _ref2.link,
          link = _ref2$link === void 0 ? "#" : _ref2$link;
        var isLast = index + 1 === breadcrumbs.length;
        var isCurrentPage = isLast && !hasTrailingSeparator;
        return /*#__PURE__*/jsxs(React__default.Fragment, {
          children: [/*#__PURE__*/jsx(BreadcrumbItem, {
            "data-testid": "header-breadcrumb",
            children: isCurrentPage ? /*#__PURE__*/jsx(BreadcrumbPage, {
              "data-testid": "".concat(hyphenize(text), "-breadcrumb"),
              children: text
            }) : /*#__PURE__*/jsx(BreadcrumbLink, {
              asChild: true,
              children: /*#__PURE__*/jsx(Link, {
                "data-testid": "".concat(hyphenize(text), "-breadcrumb"),
                to: link,
                children: text
              })
            })
          }), !isCurrentPage && /*#__PURE__*/jsx(BreadcrumbSeparator, {})]
        }, index);
      })
    })
  });
});

export { Breadcrumbs as default };
//# sourceMappingURL=Breadcrumbs.js.map
