import { __assign, __extends } from "tslib";
import { jsx as _jsx } from "react/jsx-runtime";
import ArrowButton from '../button/ArrowButton';
import PageNumberButton from '../button/PageNumberButton';
import BasePageList from './BasePageList';
var NormalPageList = (function (_super) {
    __extends(NormalPageList, _super);
    function NormalPageList() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.state = {
            activeDoubleArrowButton: '',
        };
        _this.onPrevPage = _this.jumpToPageDelta(-1, _this.resetActiveDoubleArrowButton);
        _this.onNextPage = _this.jumpToPageDelta(1, _this.resetActiveDoubleArrowButton);
        _this.onFastForwardPrevPage = _this.jumpToPageDelta(-5, function () {
            _this.setState({
                activeDoubleArrowButton: 'left',
            });
        });
        _this.onFastForwardNextPage = _this.jumpToPageDelta(5, function () {
            _this.setState({
                activeDoubleArrowButton: 'right',
            });
        });
        _this.resetActiveDoubleArrowButton = function () {
            _this.setState({
                activeDoubleArrowButton: '',
            });
        };
        return _this;
    }
    NormalPageList.prototype.render = function () {
        var _this = this;
        var _a = this.props, layout = _a.layout, buttonBordered = _a.buttonBordered, lastPageHelp = _a.lastPageHelp;
        var activeDoubleArrowButton = this.state.activeDoubleArrowButton;
        return (_jsx("div", __assign({ className: "zent-pagination-page-list--normal", "data-zv": 'v10.0.11' }, { children: layout.map(function (btn) {
                var type = btn.type;
                if (type === 'number') {
                    var page = btn.page, selected = btn.selected;
                    return (_jsx(PageNumberButton, __assign({ selected: selected, bordered: buttonBordered, onClick: _this.onPageNumberClick(page) }, { children: page }), "page-" + page));
                }
                if (type === 'left-arrow') {
                    return (_jsx(ArrowButton, { direction: "left", disabled: btn.disabled, bordered: buttonBordered, onClick: _this.onPrevPage }, type));
                }
                if (type === 'right-arrow') {
                    return (_jsx(ArrowButton, { direction: "right", disabled: btn.disabled, bordered: buttonBordered, onClick: _this.onNextPage, disabledHelp: lastPageHelp }, type));
                }
                if (type === 'double-left-arrow') {
                    return (_jsx(ArrowButton, { direction: "left", double: true, active: activeDoubleArrowButton === 'left', bordered: buttonBordered, onClick: _this.onFastForwardPrevPage }, type));
                }
                if (type === 'double-right-arrow') {
                    return (_jsx(ArrowButton, { direction: "right", double: true, active: activeDoubleArrowButton === 'right', bordered: buttonBordered, onClick: _this.onFastForwardNextPage }, type));
                }
                return null;
            }) }), void 0));
    };
    return NormalPageList;
}(BasePageList));
export default NormalPageList;
