import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
import React from 'react';
import classNames from 'classnames';
import { RcPagination } from '../components';
import { ConfigContext } from '../config-provider/context';
import Icon from '../icon';
import Select from '../select';
import MiniSelect from './MiniSelect';
var LeftLine = Icon.LeftLine,
    RightLine = Icon.RightLine,
    DoubleLeftLine = Icon.DoubleLeftLine,
    DoubleRightLine = Icon.DoubleRightLine,
    EllipsisLine = Icon.EllipsisLine;

var getIconsProps = function getIconsProps(prefixCls) {
  var ellipsis = /*#__PURE__*/React.createElement("span", {
    className: "".concat(prefixCls, "-item-ellipsis")
  }, /*#__PURE__*/React.createElement(EllipsisLine, null));
  var prevIcon = /*#__PURE__*/React.createElement("button", {
    className: "".concat(prefixCls, "-item-link"),
    type: "button",
    tabIndex: -1
  }, /*#__PURE__*/React.createElement(LeftLine, {
    className: "".concat(prefixCls, "-item-link-icon")
  }));
  var nextIcon = /*#__PURE__*/React.createElement("button", {
    className: "".concat(prefixCls, "-item-link"),
    type: "button",
    tabIndex: -1
  }, /*#__PURE__*/React.createElement(RightLine, {
    className: "".concat(prefixCls, "-item-link-icon")
  }));
  var jumpPrevIcon = /*#__PURE__*/React.createElement("a", {
    className: "".concat(prefixCls, "-item-link")
  }, /*#__PURE__*/React.createElement("div", {
    className: "".concat(prefixCls, "-item-container")
  }, /*#__PURE__*/React.createElement(DoubleLeftLine, {
    className: "".concat(prefixCls, "-item-link-icon")
  }), ellipsis));
  var jumpNextIcon = /*#__PURE__*/React.createElement("a", {
    className: "".concat(prefixCls, "-item-link")
  }, /*#__PURE__*/React.createElement("div", {
    className: "".concat(prefixCls, "-item-container")
  }, /*#__PURE__*/React.createElement(DoubleRightLine, {
    className: "".concat(prefixCls, "-item-link-icon")
  }), ellipsis));
  return {
    prevIcon: prevIcon,
    nextIcon: nextIcon,
    jumpPrevIcon: jumpPrevIcon,
    jumpNextIcon: jumpNextIcon
  };
};

var Pagination = /*#__PURE__*/React.forwardRef(function (props, ref) {
  var className = props.className,
      size = props.size,
      simple = props.simple;

  var _React$useContext = React.useContext(ConfigContext),
      getPrefixClassName = _React$useContext.getPrefixClassName;

  var paginationCls = getPrefixClassName('pagination');
  var selectPrefixCls = getPrefixClassName('select'); // const isMini = size === 'mini' || size === 'small';

  var isMini = size === 'mini' || size === 'small' || simple; // 如果要求simple时要展示mini效果，则用这一行

  var endCls = classNames(className, _defineProperty({}, "".concat(paginationCls, "-mini"), isMini));

  var comProps = _objectSpread(_objectSpread({}, props), {}, {
    className: endCls
  });

  return /*#__PURE__*/React.createElement(RcPagination, Object.assign({
    ref: ref,
    prefixCls: paginationCls,
    selectPrefixCls: selectPrefixCls
  }, comProps, getIconsProps(paginationCls), {
    selectComponentClass: isMini ? MiniSelect : Select
  }));
});
Pagination.displayName = 'Pagination';
Pagination.defaultProps = {
  size: 'default',
  defaultPageSize: 10,
  disabled: false,
  showQuickJumper: false,
  total: 0,
  simple: false,
  hideOnSinglePage: false
};
export default Pagination;