"use strict";

exports.__esModule = true;
exports["default"] = void 0;
var _react = _interopRequireWildcard(require("react"));
var _flex = _interopRequireDefault(require("../../templates/flex"));
var _typography = require("../../typography");
var _button = require("../../button");
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, "default": e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
var Pagination = function Pagination(_ref) {
  var table = _ref.table;
  var nextPage = table.nextPage,
    previousPage = table.previousPage,
    getCanPreviousPage = table.getCanPreviousPage,
    getCanNextPage = table.getCanNextPage,
    getPageCount = table.getPageCount,
    setPageIndex = table.setPageIndex,
    resetPageIndex = table.resetPageIndex;
  var pageIndex = table.getState().pagination.pageIndex;
  return /*#__PURE__*/_react["default"].createElement(_flex["default"], {
    alignItems: "center",
    justifyContent: "end",
    height: "45px",
    background: "panelBg",
    border: {
      side: "top",
      color: "borderSecondary"
    }
  }, /*#__PURE__*/_react["default"].createElement(_button.IconButton, {
    title: "First",
    "data-testid": "pagination-go-to-first",
    cursor: "pointer",
    onClick: resetPageIndex,
    icon: "chevron_left_start",
    iconSize: "small",
    tooltip: "test",
    disabled: !getCanPreviousPage()
  }), /*#__PURE__*/_react["default"].createElement(_button.IconButton, {
    title: "Previous",
    "data-testid": "pagination-go-to-previous",
    cursor: "pointer",
    onClick: previousPage,
    icon: "chevron_left",
    iconSize: "small",
    tooltip: "Previous",
    disabled: !getCanPreviousPage()
  }), /*#__PURE__*/_react["default"].createElement(_typography.Text, {
    "data-testid": "pagination-counter"
  }, "Page ", getPageCount() === 0 ? 0 : pageIndex, " of ", getPageCount()), /*#__PURE__*/_react["default"].createElement(_button.IconButton, {
    title: "Next",
    "data-testid": "pagination-go-to-next",
    cursor: "pointer",
    onClick: nextPage,
    icon: "chevron_right",
    iconSize: "small",
    disabled: !getCanNextPage()
  }), /*#__PURE__*/_react["default"].createElement(_button.IconButton, {
    title: "Last",
    "data-testid": "pagination-go-to-last",
    cursor: "pointer",
    onClick: function onClick() {
      return setPageIndex(getPageCount() - 1);
    },
    icon: "chevron_right_end",
    iconSize: "small",
    disabled: !getCanNextPage()
  }));
};
var _default = exports["default"] = /*#__PURE__*/(0, _react.memo)(Pagination);