"use strict";
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
const shared_esmBundler = require("../../../../../../@vue/shared/dist/shared.esm-bundler.js");
const index = require("../../../../hooks/use-locale/index.js");
const index$1 = require("../../../../hooks/use-namespace/index.js");
const index$2 = require("../../../select/index.js");
const usePagination = require("../usePagination.js");
const sizes = require("./sizes.js");
const Vue = require("vue");
const isEqual = require("../../../../../../lodash-es/isEqual.js");
var sizes_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ Vue.defineComponent({
  name: "ElPaginationSizes",
  __name: "sizes",
  props: sizes.paginationSizesProps,
  emits: ["page-size-change"],
  setup(__props, { emit: __emit }) {
    const props = __props;
    const emit = __emit;
    const { t } = index.useLocale();
    const ns = index$1.useNamespace("pagination");
    const pagination = usePagination.usePagination();
    const innerPageSize = Vue.ref(props.pageSize);
    Vue.watch(() => props.pageSizes, (newVal, oldVal) => {
      if (isEqual.default(newVal, oldVal)) return;
      if (shared_esmBundler.isArray(newVal)) emit("page-size-change", newVal.includes(props.pageSize) ? props.pageSize : props.pageSizes[0]);
    });
    Vue.watch(() => props.pageSize, (newVal) => {
      innerPageSize.value = newVal;
    });
    const innerPageSizes = Vue.computed(() => props.pageSizes);
    function handleChange(val) {
      var _a;
      if (val !== innerPageSize.value) {
        innerPageSize.value = val;
        (_a = pagination.handleSizeChange) == null ? void 0 : _a.call(pagination, Number(val));
      }
    }
    return (_ctx, _cache) => {
      return Vue.openBlock(), Vue.createElementBlock("span", { class: Vue.normalizeClass(Vue.unref(ns).e("sizes")) }, [Vue.createVNode(Vue.unref(index$2.ElSelect), {
        "model-value": innerPageSize.value,
        disabled: _ctx.disabled,
        "popper-class": _ctx.popperClass,
        "popper-style": _ctx.popperStyle,
        size: _ctx.size,
        teleported: _ctx.teleported,
        "validate-event": false,
        "append-to": _ctx.appendSizeTo,
        onChange: handleChange
      }, {
        default: Vue.withCtx(() => [(Vue.openBlock(true), Vue.createElementBlock(Vue.Fragment, null, Vue.renderList(innerPageSizes.value, (item) => {
          return Vue.openBlock(), Vue.createBlock(Vue.unref(index$2.ElOption), {
            key: item,
            value: item,
            label: item + Vue.unref(t)("el.pagination.pagesize")
          }, null, 8, ["value", "label"]);
        }), 128))]),
        _: 1
      }, 8, [
        "model-value",
        "disabled",
        "popper-class",
        "popper-style",
        "size",
        "teleported",
        "append-to"
      ])], 2);
    };
  }
});
exports.default = sizes_vue_vue_type_script_setup_true_lang_default;
