import '@das-fed/upf-ui/packages/components/pagination/style.css';
import { defineComponent as D, openBlock as p, createElementBlock as f, createElementVNode as N, ref as T, computed as g, createBlock as B, withCtx as C, createVNode as v, Fragment as U, renderList as H, normalizeClass as y, createTextVNode as O, toDisplayString as x, unref as t, withDirectives as J, reactive as K, watch as Q, onMounted as W, nextTick as X, createCommentVNode as P, mergeProps as Y, isRef as V, renderSlot as Z } from "vue";
import { withInstall as ee } from "@das-fed/upf-utils/with-install/index";
import { t as S, currentLang as ae, setI18nRule as te } from "@das-fed/upf-web/packages/i18n/index";
import { DasAutoRegisterIcon as le, DasIcon as b } from "@das-fed/upf-ui/packages/components/icon/index";
import { ElConfigProvider as oe, ElPagination as ne } from "element-plus";
import "element-plus/es/components/pagination/style/css";
import { useModelValue as A } from "@das-fed/upf-utils/vue";
import se from "element-plus/dist/locale/zh-cn.mjs";
import ie from "element-plus/dist/locale/en.mjs";
import { ElIcon as re, ElDropdownItem as ue, ElDropdownMenu as pe, ElDropdown as ce } from "element-plus/es";
import "element-plus/es/components/base/style/css";
import "element-plus/es/components/dropdown/style/css";
import "element-plus/es/components/dropdown-menu/style/css";
import "element-plus/es/components/dropdown-item/style/css";
import "element-plus/es/components/icon/style/css";
import { vDasTooltip as de } from "@das-fed/upf-ui/packages/components/text-tooltip/index";
/*! Element Plus Icons Vue v2.3.2 */
var ge = /* @__PURE__ */ D({
  name: "ArrowDown",
  __name: "arrow-down",
  setup(l) {
    return (_, s) => (p(), f("svg", {
      xmlns: "http://www.w3.org/2000/svg",
      viewBox: "0 0 1024 1024"
    }, [
      N("path", {
        fill: "currentColor",
        d: "M831.872 340.864 512 652.672 192.128 340.864a30.59 30.59 0 0 0-42.752 0 29.12 29.12 0 0 0 0 41.6L489.664 714.24a32 32 0 0 0 44.672 0l340.288-331.712a29.12 29.12 0 0 0 0-41.728 30.59 30.59 0 0 0-42.752 0z"
      })
    ]));
  }
}), me = ge;
const ve = { class: "sizes-dropdown-link" }, fe = { class: "current-page-size" }, _e = {
  name: "DasPaginationSizes"
}, ze = /* @__PURE__ */ D({
  ..._e,
  props: {
    pageSizes: { default: () => [20, 50, 100] },
    pageSize: { default: 20 }
  },
  emits: ["update:pageSize", "size-change"],
  setup(l, { emit: _ }) {
    const s = l, o = _, k = T(!1), m = g({
      get: () => s.pageSize,
      set: (c) => {
        o("update:pageSize", c);
      }
    }), i = (c) => {
      k.value = c;
    }, E = (c) => {
      m.value = c, o("size-change", c);
    };
    return (c, M) => {
      const z = re, h = ue, e = pe, d = ce;
      return p(), B(d, {
        "popper-class": "pagination-sizes-popper",
        trigger: "click",
        onVisibleChange: i,
        onCommand: E
      }, {
        dropdown: C(() => [
          v(e, null, {
            default: C(() => [
              (p(!0), f(
                U,
                null,
                H(l.pageSizes, (r) => (p(), B(h, {
                  class: y(["sizes-item", r === l.pageSize ? "selected" : ""]),
                  key: r,
                  command: r
                }, {
                  default: C(() => [
                    O(
                      x(t(S)("pagination-items_per_page", r)),
                      1
                      /* TEXT */
                    )
                  ]),
                  _: 2
                  /* DYNAMIC */
                }, 1032, ["class", "command"]))),
                128
                /* KEYED_FRAGMENT */
              ))
            ]),
            _: 1
            /* STABLE */
          })
        ]),
        default: C(() => [
          N("span", ve, [
            J((p(), f("span", fe, [
              O(
                x(t(S)("pagination-items_per_page", m.value)),
                1
                /* TEXT */
              )
            ])), [
              [t(de)]
            ]),
            v(z, {
              class: y(["arrow-icon", k.value ? "rotate180" : ""])
            }, {
              default: C(() => [
                v(t(me))
              ]),
              _: 1
              /* STABLE */
            }, 8, ["class"])
          ])
        ]),
        _: 1
        /* STABLE */
      });
    };
  }
}), R = (l, _) => {
  const s = l.__vccOpts || l;
  for (const [o, k] of _)
    s[o] = k;
  return s;
}, Ce = /* @__PURE__ */ R(ze, [["__scopeId", "data-v-3b9e5b1e"]]), ke = { class: "total-page" }, ye = {
  name: "TotalPage"
}, he = /* @__PURE__ */ D({
  ...ye,
  props: {
    totalPage: {}
  },
  setup(l) {
    return (_, s) => (p(), f(
      "div",
      ke,
      x(t(S)("pagination-total_page", l.totalPage)),
      1
      /* TEXT */
    ));
  }
}), we = /* @__PURE__ */ R(he, [["__scopeId", "data-v-c314d3d0"]]), xe = { class: "das-ui-pagination" }, Se = {
  key: 0,
  style: { color: "var(--upf-text-primary)", "font-size": "12px" }
}, $e = {
  key: 1,
  style: { "margin-left": "12px" },
  class: "page-container flex-center__y"
}, Pe = { class: "flex-center__y" }, be = { class: "flex-center__y" }, Ne = /* @__PURE__ */ D({
  __name: "Pagination",
  props: {
    modelValue: { default: 1 },
    pageSize: { default: 20 },
    total: { default: 0 },
    pageSizes: { default: () => [20, 50, 100] },
    small: { type: Boolean, default: !0 },
    layout: {},
    background: { type: Boolean, default: !1 },
    disabled: { type: Boolean, default: !1 },
    simple: { type: Boolean, default: !1 },
    popperClass: {}
  },
  emits: ["update:modelValue", "update:pageSize", "size-change", "current-change", "prev-click", "next-click", "first-click", "last-click"],
  setup(l, { emit: _ }) {
    const s = l, o = _;
    le({
      "arrow-first": import("@das-fed/upf-ui/packages/icons/arrow-first"),
      left: import("@das-fed/upf-ui/packages/icons/left"),
      right: import("@das-fed/upf-ui/packages/icons/right"),
      "arrow-last": import("@das-fed/upf-ui/packages/icons/arrow-last")
    });
    const k = g(() => ae.value === "zh-CN" ? se : ie), m = T(), i = K({
      first: !1,
      pre: !1,
      next: !1,
      last: !1
    }), E = g(() => s.layout), c = g(() => s.background), M = g(() => s.pageSizes), z = g(() => s.total), h = g(() => s.simple), e = A(s, "modelValue"), d = A(s, "pageSize"), r = g(() => Math.ceil(z.value / d.value)), I = g(() => h.value ? "prev, slot, next" : E.value || "total,jumper,slot,sizes"), L = g(() => I.value.replace(/\s*/g, "").split(",").filter((a) => a !== "total" && a !== "sizes").join(",")), j = (n) => {
      o("update:pageSize", n), o("size-change", n);
    }, w = (n) => {
      o("update:modelValue", n), o("current-change", n);
    }, F = () => o("prev-click", e.value), q = () => o("next-click", e.value), G = () => {
      i.first = r.value === 0 || e.value <= 1, i.pre = r.value === 0 || e.value <= 1, i.next = r.value === 0 || e.value === r.value, i.last = r.value === 0 || e.value === r.value;
    };
    Q(
      () => [e.value, r.value],
      () => {
        G();
      },
      {
        immediate: !0
      }
    );
    const $ = (n, a) => {
      const u = /* @__PURE__ */ new Map([
        [
          "first",
          () => {
            e.value <= 1 || (e.value = 1, w(e.value), o("first-click", e.value));
          }
        ],
        [
          "pre",
          () => {
            e.value <= 1 || (e.value--, w(e.value), o("prev-click", e.value));
          }
        ],
        [
          "next",
          () => {
            e.value !== z.value && (e.value++, w(e.value), o("next-click", e.value));
          }
        ],
        [
          "last",
          () => {
            e.value !== z.value && (e.value = r.value, w(e.value), o("last-click", e.value));
          }
        ]
      ]);
      if (a) return;
      u.get(n)();
    };
    return W(() => {
      X(() => {
        var n, a, u;
        (n = m.value) != null && n.$el && ((a = m.value.$el) != null && a.getElementsByClassName("el-pagination__goto")[0] && (m.value.$el.getElementsByClassName("el-pagination__goto")[0].innerText = S("第")), (u = m.value.$el) != null && u.getElementsByClassName("el-pagination__classifier")[0] && (m.value.$el.getElementsByClassName("el-pagination__classifier")[0].innerText = S("页")));
      });
    }), (n, a) => (p(), f("div", xe, [
      I.value.includes("total") ? (p(), B(t(we), {
        key: 0,
        "total-page": r.value,
        style: { "margin-right": "12px" }
      }, null, 8, ["total-page"])) : P("v-if", !0),
      v(t(oe), { locale: k.value }, {
        default: C(() => [
          v(t(ne), Y({
            ref_key: "dasPagination",
            ref: m,
            class: { background: c.value, simple: h.value },
            currentPage: t(e),
            "onUpdate:currentPage": a[4] || (a[4] = (u) => V(e) ? e.value = u : null),
            "page-size": t(d),
            "onUpdate:pageSize": a[5] || (a[5] = (u) => V(d) ? d.value = u : null),
            "page-sizes": M.value,
            layout: L.value,
            total: z.value,
            small: l.small,
            background: c.value,
            disabled: l.disabled,
            "popper-class": l.popperClass ? `das-pagination-popper ${l.popperClass}` : "das-pagination-popper",
            teleported: !1,
            onCurrentChange: w,
            onPrevClick: F,
            onNextClick: q
          }, n.$attrs), {
            default: C(() => [
              L.value.includes("slot") ? Z(n.$slots, "default", { key: 0 }, () => [
                n.$slots.default ? P("v-if", !0) : (p(), f(
                  U,
                  { key: 0 },
                  [
                    h.value ? (p(), f(
                      "div",
                      Se,
                      x(t(e)) + "/" + x(Math.ceil(z.value / t(d))),
                      1
                      /* TEXT */
                    )) : (p(), f("div", $e, [
                      N("div", Pe, [
                        v(t(b), {
                          class: y(["page-icon", i.first ? "disabled" : ""]),
                          icon: "arrow-first",
                          iconColor: "var(--upf-text-secondary)",
                          size: "medium",
                          onClick: a[0] || (a[0] = (u) => $("first", i.first))
                        }, null, 8, ["class"]),
                        v(t(b), {
                          class: y(["page-icon", i.pre ? "disabled" : ""]),
                          icon: "left",
                          iconColor: "var(--upf-text-secondary)",
                          size: "medium",
                          onClick: a[1] || (a[1] = (u) => $("pre", i.pre))
                        }, null, 8, ["class"])
                      ]),
                      N("div", be, [
                        v(t(b), {
                          class: y(["page-icon", i.next ? "disabled" : ""]),
                          icon: "right",
                          iconColor: "var(--upf-text-secondary)",
                          size: "medium",
                          onClick: a[2] || (a[2] = (u) => $("next", i.next))
                        }, null, 8, ["class"]),
                        v(t(b), {
                          class: y(["page-icon", i.last ? "disabled" : ""]),
                          icon: "arrow-last",
                          iconColor: "var(--upf-text-secondary)",
                          size: "medium",
                          onClick: a[3] || (a[3] = (u) => $("last", i.last))
                        }, null, 8, ["class"])
                      ])
                    ]))
                  ],
                  64
                  /* STABLE_FRAGMENT */
                ))
              ], !0) : P("v-if", !0)
            ]),
            _: 3
            /* FORWARDED */
          }, 16, ["class", "currentPage", "page-size", "page-sizes", "layout", "total", "small", "background", "disabled", "popper-class"])
        ]),
        _: 3
        /* FORWARDED */
      }, 8, ["locale"]),
      I.value.includes("sizes") ? (p(), B(t(Ce), {
        key: 1,
        "page-sizes": M.value,
        pageSize: t(d),
        "onUpdate:pageSize": a[6] || (a[6] = (u) => V(d) ? d.value = u : null),
        onSizeChange: j
      }, null, 8, ["page-sizes", "pageSize"])) : P("v-if", !0)
    ]));
  }
}), Be = /* @__PURE__ */ R(Ne, [["__scopeId", "data-v-4e64aa5f"]]), De = {
  第: { "zh-CN": "第", en: "No.", "zh-MO": "第", _appCode: "framework" },
  页: { "zh-CN": "页", en: "page", "zh-MO": "頁", _appCode: "framework" },
  "pagination-total_page": { "zh-CN": "共$0页", en: "Total $0", "zh-MO": "共$0頁", _appCode: "framework" },
  "pagination-items_per_page": { "zh-CN": "$0条/页", en: "$0 Records/Page", "zh-MO": "$0條/頁", _appCode: "framework" }
};
te(De);
const Qe = () => T(null), We = ee(Be);
export {
  We as DasPagination,
  Qe as DasPaginationRef,
  We as default
};
