function _array_like_to_array(arr, len) {
    if (len == null || len > arr.length) len = arr.length;
    for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
    return arr2;
}
function _array_with_holes(arr) {
    if (Array.isArray(arr)) return arr;
}
function _iterable_to_array_limit(arr, i) {
    var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
    if (_i == null) return;
    var _arr = [];
    var _n = true;
    var _d = false;
    var _s, _e;
    try {
        for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
            _arr.push(_s.value);
            if (i && _arr.length === i) break;
        }
    } catch (err) {
        _d = true;
        _e = err;
    } finally{
        try {
            if (!_n && _i["return"] != null) _i["return"]();
        } finally{
            if (_d) throw _e;
        }
    }
    return _arr;
}
function _non_iterable_rest() {
    throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
}
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;
}
function _sliced_to_array(arr, i) {
    return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
}
function _unsupported_iterable_to_array(o, minLen) {
    if (!o) return;
    if (typeof o === "string") return _array_like_to_array(o, minLen);
    var n = Object.prototype.toString.call(o).slice(8, -1);
    if (n === "Object" && o.constructor) n = o.constructor.name;
    if (n === "Map" || n === "Set") return Array.from(n);
    if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
}
import React, { useState } from "react";
import { defaultValues } from "../../utils";
import { QuickJumpToPageRoot, QuickJumpToPageTypography, QuickJumpToPageInput } from "./PaginationQuickJumpToPage.styles";
export var PaginationQuickJumpToPage = function PaginationQuickJumpToPage(_0) {
    var _0_placeholderQuickJump = _0.placeholderQuickJump, placeholderQuickJump = _0_placeholderQuickJump === void 0 ? defaultValues.placeholderQuickJump : _0_placeholderQuickJump, _0_textQuickJump = _0.textQuickJump, textQuickJump = _0_textQuickJump === void 0 ? defaultValues.textQuickJump : _0_textQuickJump, onChangeValue = _0.onChangeValue, rest = _object_without_properties(_0, [
        "placeholderQuickJump",
        "textQuickJump",
        "onChangeValue"
    ]);
    var _useState = _sliced_to_array(useState(), 2), pageValue = _useState[0], setPageValue = _useState[1];
    var handleKeyPress = function handleKeyPress(event) {
        if (event.key === 'Enter') {
            onChangeValue === null || onChangeValue === void 0 ? void 0 : onChangeValue(Number(pageValue));
            setPageValue('');
        }
    };
    var handleChangeInput = function handleChangeInput(event) {
        var result = event.currentTarget.value.replace(/\D/g, '');
        if (result === '') return setPageValue('');
        setPageValue(Number(result));
    };
    return /*#__PURE__*/ React.createElement(QuickJumpToPageRoot, rest, /*#__PURE__*/ React.createElement(QuickJumpToPageTypography, null, textQuickJump), /*#__PURE__*/ React.createElement(QuickJumpToPageInput, {
        value: pageValue,
        placeholder: placeholderQuickJump,
        onKeyUp: handleKeyPress,
        onChange: handleChangeInput
    }));
};
