"use strict";
Object.defineProperty(exports, "__esModule", {
    value: true
});
Object.defineProperty(exports, "PaginationSelectPerPage", {
    enumerable: true,
    get: function() {
        return PaginationSelectPerPage;
    }
});
var _react = /*#__PURE__*/ _interop_require_default(require("react"));
var _utils = require("../../utils");
var _Paginationtokens = require("../../Pagination.tokens");
var _PaginationSelectPerPagestyles = require("./PaginationSelectPerPage.styles");
function _interop_require_default(obj) {
    return obj && obj.__esModule ? obj : {
        default: obj
    };
}
function _object_without_properties(source, excluded) {
    if (source == null) return {};
    var target = {}, sourceKeys, key, i;
    if (typeof Reflect !== "undefined" && Reflect.ownKeys) {
        sourceKeys = Reflect.ownKeys(source);
        for(i = 0; i < sourceKeys.length; i++){
            key = sourceKeys[i];
            if (excluded.indexOf(key) >= 0) continue;
            if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
            target[key] = source[key];
        }
        return target;
    }
    target = _object_without_properties_loose(source, excluded);
    if (Object.getOwnPropertySymbols) {
        sourceKeys = Object.getOwnPropertySymbols(source);
        for(i = 0; i < sourceKeys.length; i++){
            key = sourceKeys[i];
            if (excluded.indexOf(key) >= 0) continue;
            if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
            target[key] = source[key];
        }
    }
    return target;
}
function _object_without_properties_loose(source, excluded) {
    if (source == null) return {};
    var target = {}, sourceKeys = Object.getOwnPropertyNames(source), key, i;
    for(i = 0; i < sourceKeys.length; i++){
        key = sourceKeys[i];
        if (excluded.indexOf(key) >= 0) continue;
        if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
        target[key] = source[key];
    }
    return target;
}
var PaginationSelectPerPage = function PaginationSelectPerPage(_0) {
    var perPageValue = _0.perPageValue, _0_perPageList = _0.perPageList, perPageList = _0_perPageList === void 0 ? _utils.defaultValues.perPageList : _0_perPageList, _0_textPerPage = _0.textPerPage, textPerPage = _0_textPerPage === void 0 ? _utils.defaultValues.textPerPage : _0_textPerPage, onChangeValue = _0.onChangeValue, size = _0.size, listWidth = _0.listWidth, rest = _object_without_properties(_0, [
        "perPageValue",
        "perPageList",
        "textPerPage",
        "onChangeValue",
        "size",
        "listWidth"
    ]);
    var handleSelectChange = function handleSelectChange(newValue) {
        if (newValue && !Array.isArray(newValue) && onChangeValue) {
            onChangeValue(Number(newValue));
        }
    };
    var transformedList = perPageList.map(function(num) {
        return {
            label: num.toString(),
            value: num.toString()
        };
    });
    return /*#__PURE__*/ _react.default.createElement(_PaginationSelectPerPagestyles.SelectPerPageRoot, rest, /*#__PURE__*/ _react.default.createElement(_PaginationSelectPerPagestyles.SelectPerPageTypography, null, textPerPage), /*#__PURE__*/ _react.default.createElement(_PaginationSelectPerPagestyles.SelectPerPageSelect, {
        className: _Paginationtokens.classes.selectWrapper,
        items: transformedList,
        value: perPageValue === null || perPageValue === void 0 ? void 0 : perPageValue.toString(),
        onChange: handleSelectChange,
        target: "button-like",
        size: size,
        listWidth: listWidth,
        flip: true,
        shift: true
    }));
};
