'use client';
import { jsxDEV as _jsxDEV } from "react/jsx-dev-runtime";
// TODO: abstract the `next/navigation` dependency out from this component
import { collectionDefaults, isNumber } from 'payload/shared';
import React from 'react';
import { ChevronIcon } from '../../icons/Chevron/index.js';
import { useTranslation } from '../../providers/Translation/index.js';
import { Popup, PopupList } from '../Popup/index.js';
import './index.scss';
const baseClass = 'per-page';
const defaultLimits = collectionDefaults.admin.pagination.limits;
export const PerPage = ({ defaultLimit = 10, handleChange, limit, limits = defaultLimits })=>{
    const { t } = useTranslation();
    const limitToUse = isNumber(limit) ? limit : defaultLimit;
    return /*#__PURE__*/ _jsxDEV("div", {
        className: baseClass,
        children: /*#__PURE__*/ _jsxDEV(Popup, {
            button: /*#__PURE__*/ _jsxDEV("div", {
                className: `${baseClass}__base-button`,
                children: [
                    /*#__PURE__*/ _jsxDEV("span", {
                        children: t('general:perPage', {
                            limit: limitToUse
                        })
                    }, void 0, false, {
                        fileName: "src/elements/PerPage/index.tsx",
                        lineNumber: 38,
                        columnNumber: 13
                    }, void 0),
                    " ",
                    /*#__PURE__*/ _jsxDEV(ChevronIcon, {
                        className: `${baseClass}__icon`
                    }, void 0, false, {
                        fileName: "src/elements/PerPage/index.tsx",
                        lineNumber: 40,
                        columnNumber: 13
                    }, void 0)
                ]
            }, void 0, true, {
                fileName: "src/elements/PerPage/index.tsx",
                lineNumber: 37,
                columnNumber: 11
            }, void 0),
            horizontalAlign: "right",
            render: ({ close })=>/*#__PURE__*/ _jsxDEV(PopupList.ButtonGroup, {
                    children: limits.map((limitNumber, i)=>/*#__PURE__*/ _jsxDEV(PopupList.Button, {
                            className: [
                                `${baseClass}__button`,
                                limitNumber === limitToUse && `${baseClass}__button-active`
                            ].filter(Boolean).join(' '),
                            onClick: ()=>{
                                close();
                                if (handleChange) {
                                    handleChange(limitNumber);
                                }
                            },
                            children: [
                                limitNumber === limitToUse && /*#__PURE__*/ _jsxDEV("div", {
                                    className: `${baseClass}__chevron`,
                                    children: /*#__PURE__*/ _jsxDEV(ChevronIcon, {
                                        direction: "right",
                                        size: "small"
                                    }, void 0, false, {
                                        fileName: "src/elements/PerPage/index.tsx",
                                        lineNumber: 64,
                                        columnNumber: 21
                                    }, void 0)
                                }, void 0, false, {
                                    fileName: "src/elements/PerPage/index.tsx",
                                    lineNumber: 63,
                                    columnNumber: 19
                                }, void 0),
                                " ",
                                /*#__PURE__*/ _jsxDEV("span", {
                                    children: limitNumber
                                }, void 0, false, {
                                    fileName: "src/elements/PerPage/index.tsx",
                                    lineNumber: 68,
                                    columnNumber: 17
                                }, void 0)
                            ]
                        }, i, true, {
                            fileName: "src/elements/PerPage/index.tsx",
                            lineNumber: 47,
                            columnNumber: 15
                        }, void 0))
                }, void 0, false, {
                    fileName: "src/elements/PerPage/index.tsx",
                    lineNumber: 45,
                    columnNumber: 11
                }, void 0),
            size: "small"
        }, void 0, false, {
            fileName: "src/elements/PerPage/index.tsx",
            lineNumber: 35,
            columnNumber: 7
        }, this)
    }, void 0, false, {
        fileName: "src/elements/PerPage/index.tsx",
        lineNumber: 34,
        columnNumber: 5
    }, this);
};

//# sourceMappingURL=index.js.map