import K from "../../@babel/runtime/helpers/esm/slicedToArray.mjs";
import R from "../../rc-util/es/KeyCode.mjs";
import i from "react";
var G = ["10", "20", "50", "100"], I = function(t) {
  var N = t.pageSizeOptions, c = N === void 0 ? G : N, r = t.locale, l = t.changeSize, f = t.pageSize, s = t.goButton, a = t.quickGo, g = t.rootPrefixCls, p = t.selectComponentClass, y = t.selectPrefixCls, m = t.disabled, b = t.buildOptionText, _ = i.useState(""), S = K(_, 2), o = S[0], v = S[1], h = function() {
    return !o || Number.isNaN(o) ? void 0 : Number(o);
  }, E = typeof b == "function" ? b : function(n) {
    return "".concat(n, " ").concat(r.items_per_page);
  }, k = function(e) {
    l == null || l(Number(e));
  }, P = function(e) {
    v(e.target.value);
  }, T = function(e) {
    s || o === "" || (v(""), !(e.relatedTarget && (e.relatedTarget.className.indexOf("".concat(g, "-item-link")) >= 0 || e.relatedTarget.className.indexOf("".concat(g, "-item")) >= 0)) && (a == null || a(h())));
  }, u = function(e) {
    o !== "" && (e.keyCode === R.ENTER || e.type === "click") && (v(""), a == null || a(h()));
  }, B = function() {
    return c.some(function(e) {
      return e.toString() === f.toString();
    }) ? c : c.concat([f.toString()]).sort(function(e, z) {
      var j = Number.isNaN(Number(e)) ? 0 : Number(e), q = Number.isNaN(Number(z)) ? 0 : Number(z);
      return j - q;
    });
  }, d = "".concat(g, "-options");
  if (!l && !a)
    return null;
  var C = null, O = null, x = null;
  if (l && p) {
    var V = B().map(function(n, e) {
      return /* @__PURE__ */ i.createElement(p.Option, {
        key: e,
        value: n.toString()
      }, E(n));
    });
    C = /* @__PURE__ */ i.createElement(p, {
      disabled: m,
      prefixCls: y,
      showSearch: !1,
      className: "".concat(d, "-size-changer"),
      optionLabelProp: "children",
      popupMatchSelectWidth: !1,
      value: (f || c[0]).toString(),
      onChange: k,
      getPopupContainer: function(e) {
        return e.parentNode;
      },
      "aria-label": r.page_size,
      defaultOpen: !1
    }, V);
  }
  return a && (s && (x = typeof s == "boolean" ? /* @__PURE__ */ i.createElement("button", {
    type: "button",
    onClick: u,
    onKeyUp: u,
    disabled: m,
    className: "".concat(d, "-quick-jumper-button")
  }, r.jump_to_confirm) : /* @__PURE__ */ i.createElement("span", {
    onClick: u,
    onKeyUp: u
  }, s)), O = /* @__PURE__ */ i.createElement("div", {
    className: "".concat(d, "-quick-jumper")
  }, r.jump_to, /* @__PURE__ */ i.createElement("input", {
    disabled: m,
    type: "text",
    value: o,
    onChange: P,
    onKeyUp: u,
    onBlur: T,
    "aria-label": r.page
  }), r.page, x)), /* @__PURE__ */ i.createElement("li", {
    className: d
  }, C, O);
};
process.env.NODE_ENV !== "production" && (I.displayName = "Options");
export {
  I as default
};
