'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var _tslib = require('../../_virtual/_tslib.js');
var React = require('react');
var styles = require('./styles.js');
var index$1 = require('../IconButton/index.js');
var utils = require('./utils.js');
var WidePagination = require('./components/WidePagination.js');
var NarrowPagination = require('./components/NarrowPagination.js');
var index = require('../../utils/index.js');
var ChevronLeft = require('../../icons/ChevronLeft.js');
var ChevronRight = require('../../icons/ChevronRight.js');

function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }

var React__default = /*#__PURE__*/_interopDefaultLegacy(React);

function Pagination(_a) {
    var { rowsPerPage, totalItems, currentPage, onChangePage, variant = 'wide', alignment = 'right', paginationLimiter, narrowPaginationText } = _a, props = _tslib.__rest(_a, ["rowsPerPage", "totalItems", "currentPage", "onChangePage", "variant", "alignment", "paginationLimiter", "narrowPaginationText"]);
    const appendTestId = index.getId(props['data-testid']);
    const appendTrackId = index.getId(props['data-trackid']);
    const numberOfPages = utils.getNumberOfPages(totalItems, rowsPerPage);
    return (React__default['default'].createElement(styles.PaginationControl, { alignment: alignment, "data-testid": props['data-testid'], "data-trackid": props['data-trackid'], role: "navigation" },
        React__default['default'].createElement(index$1.IconButton, { icon: React__default['default'].createElement(ChevronLeft['default'], null), variant: "ghost-tertiary", size: "x-small", disabled: currentPage === 1, onClick: () => onChangePage(currentPage - 1), "data-testid": appendTestId('button-previous'), "data-trackid": appendTrackId('button-previous') }),
        variant === 'wide' ? (React__default['default'].createElement(WidePagination['default'], { variant: "wide", rowsPerPage: rowsPerPage, onChangePage: onChangePage, currentPage: currentPage, totalItems: totalItems, paginationLimiter: paginationLimiter, "data-testid": appendTestId('wide-pagination'), "data-trackid": appendTrackId('wide-pagination') })) : (React__default['default'].createElement(NarrowPagination['default'], { variant: "narrow", rowsPerPage: rowsPerPage, onChangePage: onChangePage, currentPage: currentPage, totalItems: totalItems, narrowPaginationText: narrowPaginationText, "data-testid": appendTestId('narrow-pagination'), "data-trackid": appendTrackId('narrow-pagination') })),
        React__default['default'].createElement(index$1.IconButton, { icon: React__default['default'].createElement(ChevronRight['default'], null), variant: "ghost-tertiary", size: "x-small", disabled: currentPage === numberOfPages, onClick: () => onChangePage(currentPage + 1), "data-testid": appendTestId('button-next'), "data-trackid": appendTrackId('button-next') })));
}

exports.Pagination = Pagination;
