import * as _vue from "vue";

function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }

function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }

function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }

function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }

function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }

import PropTypes from '../_util/vue-types';
import VcSelect from '../select';
import MiniSelect from './MiniSelect';
import LocaleReceiver from '../locale-provider/LocaleReceiver';
import { getOptionProps } from '../_util/props-util';
import VcPagination from '../vc-pagination';
import enUS from '../vc-pagination/locale/en_US';
import LeftOutlined from '@ant-design/icons-vue/LeftOutlined';
import RightOutlined from '@ant-design/icons-vue/RightOutlined';
import DoubleLeftOutlined from '@ant-design/icons-vue/DoubleLeftOutlined';
import DoubleRightOutlined from '@ant-design/icons-vue/DoubleRightOutlined';
import { ConfigConsumerProps } from '../config-provider';
import { inject } from 'vue';
import classNames from '../_util/classNames';
export var PaginationProps = function PaginationProps() {
  return {
    total: PropTypes.number,
    defaultCurrent: PropTypes.number,
    disabled: PropTypes.bool,
    current: PropTypes.number,
    defaultPageSize: PropTypes.number,
    pageSize: PropTypes.number,
    hideOnSinglePage: PropTypes.bool,
    showSizeChanger: PropTypes.bool,
    pageSizeOptions: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.number, PropTypes.string])),
    buildOptionText: PropTypes.func,
    showSizeChange: PropTypes.func,
    showQuickJumper: PropTypes.oneOfType([PropTypes.bool, PropTypes.object]),
    showTotal: PropTypes.any,
    size: PropTypes.string,
    simple: PropTypes.bool,
    locale: PropTypes.object,
    prefixCls: PropTypes.string,
    selectPrefixCls: PropTypes.string,
    itemRender: PropTypes.func,
    role: PropTypes.string,
    showLessItems: PropTypes.bool
  };
};
export var PaginationConfig = function PaginationConfig() {
  return _objectSpread(_objectSpread({}, PaginationProps()), {}, {
    position: PropTypes.oneOf(['top', 'bottom', 'both'])
  });
};
export default {
  name: 'APagination',
  inheritAttrs: false,
  props: _objectSpread({}, PaginationProps()),
  setup: function setup() {
    return {
      configProvider: inject('configProvider', ConfigConsumerProps)
    };
  },
  methods: {
    getIconsProps: function getIconsProps(prefixCls) {
      var prevIcon = _vue.createVNode("a", {
        "class": "".concat(prefixCls, "-item-link")
      }, [_vue.createVNode(LeftOutlined, null, null)]);

      var nextIcon = _vue.createVNode("a", {
        "class": "".concat(prefixCls, "-item-link")
      }, [_vue.createVNode(RightOutlined, null, null)]);

      var jumpPrevIcon = _vue.createVNode("a", {
        "class": "".concat(prefixCls, "-item-link")
      }, [_vue.createVNode("div", {
        "class": "".concat(prefixCls, "-item-container")
      }, [_vue.createVNode(DoubleLeftOutlined, {
        "class": "".concat(prefixCls, "-item-link-icon")
      }, null), _vue.createVNode("span", {
        "class": "".concat(prefixCls, "-item-ellipsis")
      }, [_vue.createTextVNode("\u2022\u2022\u2022")])])]);

      var jumpNextIcon = _vue.createVNode("a", {
        "class": "".concat(prefixCls, "-item-link")
      }, [_vue.createVNode("div", {
        "class": "".concat(prefixCls, "-item-container")
      }, [_vue.createVNode(DoubleRightOutlined, {
        "class": "".concat(prefixCls, "-item-link-icon")
      }, null), _vue.createVNode("span", {
        "class": "".concat(prefixCls, "-item-ellipsis")
      }, [_vue.createTextVNode("\u2022\u2022\u2022")])])]);

      return {
        prevIcon: prevIcon,
        nextIcon: nextIcon,
        jumpPrevIcon: jumpPrevIcon,
        jumpNextIcon: jumpNextIcon
      };
    },
    renderPagination: function renderPagination(contextLocale) {
      var _getOptionProps = getOptionProps(this),
          customizePrefixCls = _getOptionProps.prefixCls,
          customizeSelectPrefixCls = _getOptionProps.selectPrefixCls,
          buildOptionText = _getOptionProps.buildOptionText,
          size = _getOptionProps.size,
          customLocale = _getOptionProps.locale,
          restProps = _objectWithoutProperties(_getOptionProps, ["prefixCls", "selectPrefixCls", "buildOptionText", "size", "locale"]);

      var getPrefixCls = this.configProvider.getPrefixCls;
      var prefixCls = getPrefixCls('pagination', customizePrefixCls);
      var selectPrefixCls = getPrefixCls('select', customizeSelectPrefixCls);
      var isSmall = size === 'small';

      var paginationProps = _objectSpread(_objectSpread(_objectSpread(_objectSpread({
        prefixCls: prefixCls,
        selectPrefixCls: selectPrefixCls
      }, restProps), this.getIconsProps(prefixCls)), {}, {
        selectComponentClass: isSmall ? MiniSelect : VcSelect,
        locale: _objectSpread(_objectSpread({}, contextLocale), customLocale),
        buildOptionText: buildOptionText || this.$slots.buildOptionText
      }, this.$attrs), {}, {
        class: classNames({
          mini: isSmall
        }, this.$attrs.class),
        itemRender: this.itemRender || this.$slots.itemRender
      });

      return _vue.createVNode(VcPagination, paginationProps, null);
    }
  },
  render: function render() {
    return _vue.createVNode(LocaleReceiver, {
      "componentName": "Pagination",
      "defaultLocale": enUS,
      "children": this.renderPagination
    }, null);
  }
};