"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;
var _react = _interopRequireDefault(require("react"));
var _index = require("../../../index");
var _List = _interopRequireDefault(require("../../../Atoms/List"));
var _PageItems = _interopRequireDefault(require("../PageItems"));
var _ChevronIcon = _interopRequireDefault(require("./components/ChevronIcon"));
var _RegularComponents = require("./components/RegularComponents");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var PageNumberLinkItem = function PageNumberLinkItem(_ref) {
  var _ref$isCurrentPage = _ref.isCurrentPage,
    isCurrentPage = _ref$isCurrentPage === void 0 ? false : _ref$isCurrentPage,
    children = _ref.children,
    onClick = _ref.onClick,
    label = _ref.label,
    href = _ref.href;
  return _react.default.createElement(_index.Flexbox, {
    item: true,
    as: "li"
  }, isCurrentPage ? _react.default.createElement(_index.Typography, {
    type: "secondary",
    color: function color(t) {
      return t.color.cta;
    },
    weight: "bold"
  }, children) : _react.default.createElement(_index.Link, {
    onClick: onClick,
    "aria-label": "".concat(label, " ").concat(children),
    to: href
  }, _react.default.createElement(_index.Typography, {
    type: "secondary",
    color: function color(t) {
      return t.color.text;
    },
    weight: "bold"
  }, children)));
};
var ChevronLink = function ChevronLink(_ref2) {
  var _ref2$direction = _ref2.direction,
    direction = _ref2$direction === void 0 ? 'left' : _ref2$direction,
    onClick = _ref2.onClick,
    label = _ref2.label,
    href = _ref2.href;
  return _react.default.createElement(_index.Link, {
    onClick: onClick,
    "aria-label": label,
    to: href,
    color: "black"
  }, _react.default.createElement(_ChevronIcon.default, {
    direction: direction,
    size: 8
  }));
};
var RegularLinks = function RegularLinks(_ref3) {
  var currentPage = _ref3.currentPage,
    numberOfPages = _ref3.numberOfPages,
    _ref3$onClickPageItem = _ref3.onClickPageItem,
    onClickPageItem = _ref3$onClickPageItem === void 0 ? function () {} : _ref3$onClickPageItem,
    onClickPrevious = _ref3.onClickPrevious,
    onClickNext = _ref3.onClickNext,
    previousPageLabel = _ref3.previousPageLabel,
    nextPageLabel = _ref3.nextPageLabel,
    currentPageLabel = _ref3.currentPageLabel,
    pageItemLabel = _ref3.pageItemLabel,
    getPageHref = _ref3.getPageHref;
  if (numberOfPages <= 1) {
    return null;
  }
  return _react.default.createElement(_RegularComponents.StyledFlexbox, {
    container: true,
    $numberOfPages: numberOfPages,
    alignItems: "center"
  }, currentPage !== 1 && _react.default.createElement(ChevronLink, {
    direction: "left",
    onClick: onClickPrevious,
    label: previousPageLabel,
    href: getPageHref(currentPage - 1)
  }), _react.default.createElement(_index.Flexbox, {
    container: true,
    item: true,
    flex: "1",
    justifyContent: "center",
    gap: 2,
    as: _List.default
  }, _react.default.createElement(_PageItems.default, {
    currentPage: currentPage,
    numberOfPages: numberOfPages,
    onClickPageItem: onClickPageItem,
    PageItem: PageNumberLinkItem,
    TruncatedPageNumbers: _RegularComponents.TruncatedPageNumbers,
    currentPageLabel: currentPageLabel,
    pageItemLabel: pageItemLabel,
    getPageHref: getPageHref
  })), currentPage !== numberOfPages && _react.default.createElement(ChevronLink, {
    direction: "right",
    onClick: onClickNext,
    label: nextPageLabel,
    href: getPageHref(currentPage + 1)
  }));
};
var _default = exports.default = _react.default.memo(RegularLinks);