"use strict";
var __rest = (this && this.__rest) || function (s, e) {
    var t = {};
    for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
        t[p] = s[p];
    if (s != null && typeof Object.getOwnPropertySymbols === "function")
        for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
            if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
                t[p[i]] = s[p[i]];
        }
    return t;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.Pagination = void 0;
const jsx_runtime_1 = require("react/jsx-runtime");
const box_1 = __importDefault(require("../box"));
const core_1 = require("../core");
const utils_1 = require("../utils");
const context_1 = require("./context");
const paginationButton_1 = __importDefault(require("./paginationButton"));
const paginationEllipsis_1 = __importDefault(require("./paginationEllipsis"));
const paginationGoToPage_1 = __importDefault(require("./paginationGoToPage"));
const paginationNavigation_1 = __importDefault(require("./paginationNavigation"));
const paginationPrevNext_1 = __importDefault(require("./paginationPrevNext"));
const paginationResults_1 = __importDefault(require("./paginationResults"));
const usePagination_1 = __importDefault(require("./usePagination"));
/**
 * Displays page navigation buttons together with page and item count.
 * GoToPage component is shown automatically above 10 pages.
 */
exports.Pagination = (0, core_1.vui)((props, ref) => {
    var _a;
    const { children, className, count, defaultPage, goToPage, items: itemsProp = [], navigation, onPageChange, page: pageProp, pageSize, results, size, variant } = props, rest = __rest(props, ["children", "className", "count", "defaultPage", "goToPage", "items", "navigation", "onPageChange", "page", "pageSize", "results", "size", "variant"]);
    const styles = (0, core_1.useStyleConfig)('Pagination', props);
    const _b = (0, usePagination_1.default)({
        count,
        defaultPage,
        onPageChange,
        page: pageProp,
        pageSize,
    }), { items = itemsProp } = _b, paginationProps = __rest(_b, ["items"]);
    const context = Object.assign(Object.assign({}, paginationProps), { items, size, variant });
    return ((0, jsx_runtime_1.jsx)(context_1.PaginationProvider, { value: context, children: (0, jsx_runtime_1.jsx)(box_1.default, Object.assign({ centerV: true, className: (0, utils_1.cs)('vui-pagination', className), gap: 3, ref: ref, w: 1, wrap: true }, styles.container, rest, { children: (_a = (0, utils_1.runIfFn)(children, context)) !== null && _a !== void 0 ? _a : ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, utils_1.isJsx)(results) ? results : (0, jsx_runtime_1.jsx)(paginationResults_1.default, {}), (0, utils_1.isJsx)(navigation) ? navigation : (0, jsx_runtime_1.jsx)(paginationNavigation_1.default, { ml: "auto" }), (0, utils_1.isJsx)(goToPage) ? goToPage : paginationProps.pageCount > 10 && (0, jsx_runtime_1.jsx)(paginationGoToPage_1.default, {})] })) })) }));
});
exports.Pagination.Button = paginationButton_1.default;
exports.Pagination.Ellipsis = paginationEllipsis_1.default;
exports.Pagination.GoToPage = paginationGoToPage_1.default;
exports.Pagination.Navigation = paginationNavigation_1.default;
exports.Pagination.PrevNext = paginationPrevNext_1.default;
exports.Pagination.Results = paginationResults_1.default;
exports.Pagination.displayName = 'Pagination';
exports.default = exports.Pagination;
//# sourceMappingURL=pagination.js.map