import "../../../../../node_modules/element-plus/es/index.mjs";
/* empty css                                                             */
/* empty css                                                                 */
/* empty css                                                                     */
/* empty css                                                                  */
/* empty css                                                               */
/* empty css                                                                  */
/* empty css                                                                        */
/* empty css                                                                  */
/* empty css                                                                      */
import { createElementBlock, createCommentVNode, openBlock, createBlock, withCtx, toDisplayString } from "vue";
/* empty css                 */
import _export_sfc from "../../../../../_virtual/_plugin-vue_export-helper.mjs";
import { ElPagination } from "../../../../../node_modules/element-plus/es/components/pagination/index.mjs";
const _hoisted_1 = {
  key: 0,
  class: "table-pagination"
};
const _hoisted_2 = {
  key: 0,
  class: "el-pagination_slot"
};
const _sfc_main = {
  __name: "Pagination",
  props: {
    config: {
      type: Object,
      default: () => ({
        enabled: true,
        pageSize: 15,
        pageSizes: [15, 20, 50, 100, 200, 500],
        layout: "full",
        background: true,
        size: "small"
      })
    },
    pagination: {
      type: Object,
      default: () => ({
        show: true,
        pageNo: 1,
        pageSize: 15,
        pageTotal: 0
      })
    }
  },
  emits: ["change"],
  setup(__props, { expose: __expose, emit: __emit }) {
    const props = __props;
    const emit = __emit;
    const layoutMap = {
      simple: "->,prev, pager, next",
      standard: "total, ->, prev, pager, next, jumper",
      full: "total, slot, ->,sizes, prev, pager, next, jumper"
    };
    function getLayout(layout) {
      return layoutMap[layout] || layoutMap.full;
    }
    const handleCurrentChange = (page) => {
      emit("change", {
        pageNo: page,
        pageSize: props.pagination.pageSize
      });
    };
    const handleSizeChange = (size) => {
      emit("change", {
        pageNo: 1,
        pageSize: size
      });
    };
    __expose({
      setCurrentPage: (page) => {
        props.pagination.pageNo = page;
      },
      setPageSize: (size) => {
        props.pagination.pageSize = size;
      },
      getCurrent: () => ({
        pageNo: props.pagination.pageNo,
        pageSize: props.pagination.pageSize
      })
    });
    return (_ctx, _cache) => {
      const _component_el_pagination = ElPagination;
      return __props.pagination.show ? (openBlock(), createElementBlock("div", _hoisted_1, [
        __props.config.enabled ? (openBlock(), createBlock(_component_el_pagination, {
          key: 0,
          background: __props.config.background,
          onSizeChange: handleSizeChange,
          onCurrentChange: handleCurrentChange,
          "page-sizes": [15, 20, 50, 100, 200, 500],
          "page-size": __props.pagination.pageSize,
          "current-page": __props.pagination.pageNo,
          layout: getLayout(__props.config.layout),
          total: __props.pagination.pageTotal,
          size: __props.config.size === "default" ? "" : __props.config.size,
          style: { "width": "100%" }
        }, {
          default: withCtx(() => [
            getLayout(__props.config.layout).includes("slot") ? (openBlock(), createElementBlock("span", _hoisted_2, toDisplayString(__props.pagination.pageNo) + "/" + toDisplayString(Math.ceil(__props.pagination.pageTotal / __props.pagination.pageSize)) + " 页 ", 1)) : createCommentVNode("", true)
          ]),
          _: 1
        }, 8, ["background", "page-size", "current-page", "layout", "total", "size"])) : createCommentVNode("", true)
      ])) : createCommentVNode("", true);
    };
  }
};
const Pagination = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-142fdd35"]]);
export {
  Pagination as default
};
