/**
 * amis v3.1.0
 * Copyright 2018-2023 baidu
 */

'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var tslib = require('tslib');
var React = require('react');
var amisCore = require('amis-core');
var amisUi = require('amis-ui');

function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }

var React__default = /*#__PURE__*/_interopDefaultLegacy(React);

var Pagination = /** @class */ (function (_super) {
    tslib.__extends(Pagination, _super);
    function Pagination() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    Pagination.prototype.formatNumber = function (num, defaultValue) {
        var result = undefined;
        if (typeof num === 'string') {
            num = amisCore.isPureVariable(num) ? amisCore.resolveVariableAndFilter(num) : num;
            result = typeof num === 'string' ? parseInt(num, 10) : num;
        }
        else if (typeof num === 'number') {
            result = num;
        }
        return result !== null && result !== void 0 ? result : defaultValue;
    };
    Pagination.prototype.render = function () {
        var _a = this.props, maxButtons = _a.maxButtons, activePage = _a.activePage, total = _a.total, perPage = _a.perPage;
        return (React__default["default"].createElement(amisUi.Pagination, tslib.__assign({}, this.props, { maxButtons: this.formatNumber(maxButtons), activePage: this.formatNumber(activePage), total: this.formatNumber(total), perPage: this.formatNumber(perPage) })));
    };
    return Pagination;
}(React__default["default"].Component));
/** @class */ ((function (_super) {
    tslib.__extends(PaginationRenderer, _super);
    function PaginationRenderer() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    PaginationRenderer = tslib.__decorate([
        amisCore.Renderer({
            test: /(^|\/)(?:pagination|pager)$/,
            name: 'pagination'
        })
    ], PaginationRenderer);
    return PaginationRenderer;
})(Pagination));

exports["default"] = Pagination;
