import '@das-fed/upf-ui/packages/components/button/style.css';
import { withInstall as le } from "@das-fed/upf-utils/with-install/index";
import { ConfigProvider as oe } from "ant-design-vue/es";
import "ant-design-vue/es/config-provider/style/css";
import { defineComponent as ue, useAttrs as de, computed as w, ref as U, watchEffect as ce, openBlock as o, createElementBlock as h, normalizeClass as se, normalizeStyle as fe, createVNode as C, withCtx as u, createCommentVNode as m, createBlock as y, unref as l, mergeProps as M, createSlots as H, renderSlot as x, Fragment as S, renderList as G, createTextVNode as A, toDisplayString as V, isRef as be } from "vue";
import { DasAutoRegisterIcon as me, DasIcon as E } from "@das-fed/upf-ui/packages/components/icon/index";
import { DropdownButton as ye, Menu as X, MenuItem as q, Dropdown as ge, Button as J, RadioGroup as ve, RadioButton as ke } from "ant-design-vue";
import "ant-design-vue/es/button/style/css";
import "ant-design-vue/es/dropdown/style/css";
import "ant-design-vue/es/radio/style/css";
var N = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
function Te(e) {
  return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
}
function he(e) {
  var a = typeof e;
  return e != null && (a == "object" || a == "function");
}
var ne = he, $e = typeof N == "object" && N && N.Object === Object && N, Ce = $e, Se = Ce, je = typeof self == "object" && self && self.Object === Object && self, Ie = Se || je || Function("return this")(), ie = Ie, pe = ie, Oe = function() {
  return pe.Date.now();
}, ze = Oe, De = /\s/;
function Be(e) {
  for (var a = e.length; a-- && De.test(e.charAt(a)); )
    ;
  return a;
}
var Pe = Be, we = Pe, Me = /^\s+/;
function xe(e) {
  return e && e.slice(0, we(e) + 1).replace(Me, "");
}
var Ee = xe, Ne = ie, Le = Ne.Symbol, ae = Le, Q = ae, re = Object.prototype, Re = re.hasOwnProperty, Ge = re.toString, D = Q ? Q.toStringTag : void 0;
function Ae(e) {
  var a = Re.call(e, D), t = e[D];
  try {
    e[D] = void 0;
    var d = !0;
  } catch {
  }
  var f = Ge.call(e);
  return d && (a ? e[D] = t : delete e[D]), f;
}
var Ve = Ae, Fe = Object.prototype, We = Fe.toString;
function Ke(e) {
  return We.call(e);
}
var Ue = Ke, Y = ae, He = Ve, Xe = Ue, qe = "[object Null]", Je = "[object Undefined]", Z = Y ? Y.toStringTag : void 0;
function Qe(e) {
  return e == null ? e === void 0 ? Je : qe : Z && Z in Object(e) ? He(e) : Xe(e);
}
var Ye = Qe;
function Ze(e) {
  return e != null && typeof e == "object";
}
var _e = Ze, et = Ye, tt = _e, nt = "[object Symbol]";
function it(e) {
  return typeof e == "symbol" || tt(e) && et(e) == nt;
}
var at = it, rt = Ee, _ = ne, lt = at, ee = NaN, ot = /^[-+]0x[0-9a-f]+$/i, ut = /^0b[01]+$/i, dt = /^0o[0-7]+$/i, ct = parseInt;
function st(e) {
  if (typeof e == "number")
    return e;
  if (lt(e))
    return ee;
  if (_(e)) {
    var a = typeof e.valueOf == "function" ? e.valueOf() : e;
    e = _(a) ? a + "" : a;
  }
  if (typeof e != "string")
    return e === 0 ? e : +e;
  e = rt(e);
  var t = ut.test(e);
  return t || dt.test(e) ? ct(e.slice(2), t ? 2 : 8) : ot.test(e) ? ee : +e;
}
var ft = st, bt = ne, F = ze, te = ft, mt = "Expected a function", yt = Math.max, gt = Math.min;
function vt(e, a, t) {
  var d, f, v, c, r, b, k = 0, B = !1, s = !1, j = !0;
  if (typeof e != "function")
    throw new TypeError(mt);
  a = te(a) || 0, bt(t) && (B = !!t.leading, s = "maxWait" in t, v = s ? yt(te(t.maxWait) || 0, a) : v, j = "trailing" in t ? !!t.trailing : j);
  function I(n) {
    var g = d, z = f;
    return d = f = void 0, k = n, c = e.apply(z, g), c;
  }
  function L(n) {
    return k = n, r = setTimeout(T, a), B ? I(n) : c;
  }
  function R(n) {
    var g = n - b, z = n - k, K = a - g;
    return s ? gt(K, v - z) : K;
  }
  function P(n) {
    var g = n - b, z = n - k;
    return b === void 0 || g >= a || g < 0 || s && z >= v;
  }
  function T() {
    var n = F();
    if (P(n))
      return p(n);
    r = setTimeout(T, R(n));
  }
  function p(n) {
    return r = void 0, j && d ? I(n) : (d = f = void 0, c);
  }
  function i() {
    r !== void 0 && clearTimeout(r), k = 0, d = b = f = r = void 0;
  }
  function $() {
    return r === void 0 ? c : p(F());
  }
  function O() {
    var n = F(), g = P(n);
    if (d = arguments, f = this, b = n, g) {
      if (r === void 0)
        return L(b);
      if (s)
        return clearTimeout(r), r = setTimeout(T, a), I(b);
    }
    return r === void 0 && (r = setTimeout(T, a)), c;
  }
  return O.cancel = i, O.flush = $, O;
}
var kt = vt;
const W = /* @__PURE__ */ Te(kt), Tt = {
  inheritAttrs: !1
  // 不希望组件的根元素继承特性
}, ht = /* @__PURE__ */ ue({
  ...Tt,
  __name: "Index",
  props: {
    btnType: { default: "primary" },
    size: { default: "middle" },
    disabled: { type: Boolean, default: !1 },
    block: { type: Boolean, default: !1 },
    ghost: { type: Boolean, default: !1 },
    menuData: { default: [] },
    defaultMenuProps: { default: () => ({
      key: "key",
      label: "label",
      icon: "icon"
    }) },
    icon: { default: "" },
    activeIcon: { default: "" },
    isIconLeft: { type: Boolean, default: !0 },
    trigger: { default: "click" },
    activeKey: { type: [String, Number, Boolean], default: "" },
    getPopupContainer: { type: Function, default: (e) => e.parentNode || document.body },
    isClickDebounce: { type: Boolean, default: !0 }
  },
  emits: ["update:activeKey", "click"],
  setup(e, { emit: a }) {
    me({
      fold: import("@das-fed/upf-ui/packages/icons/fold"),
      unflod: import("@das-fed/upf-ui/packages/icons/unflod")
    });
    const t = e, d = a, f = de(), v = w(() => {
      if (t.btnType === "default-basicset" || t.btnType === "primary-basicset")
        return f.style;
    });
    let c = U(t.activeKey), r = U(t.icon);
    const b = w(() => t.size === "small" ? "mini" : t.size === "middle" ? "small" : t.size === "large" ? "medium" : "small"), k = w(() => t.btnType === "primary" ? "primary" : t.btnType && ["primary-text", "default-text"].includes(t.btnType) ? "text" : "default"), B = w(() => [
      "das-ui-button",
      `das-ui-button--${t.size}`,
      `das-ui-button--${t.btnType}`,
      {
        "das-ui-button--block": t.block,
        "das-ui-button--ghost": t.ghost,
        "das-ui-button--icon": !!t.icon
      }
    ]);
    ce(() => {
      d("update:activeKey", c.value);
    });
    const s = (i, $) => {
      document.body.click(), d("click", i, $);
    }, j = W(
      (i) => {
        r.value = t.icon, s(i, "menu-click");
      },
      300,
      {
        leading: !0
      }
    ), I = W(
      (i) => {
        s(i, "button-click");
      },
      300,
      {
        leading: !0
      }
    ), L = W(
      (i) => {
        s(i, "self");
      },
      300,
      {
        leading: !0
      }
    ), R = (i) => {
      t.isClickDebounce ? L(i) : s(i, "self");
    }, P = (i) => {
      t.isClickDebounce ? I(i) : s(i, "button-click");
    }, T = (i) => {
      t.isClickDebounce ? j(i) : (r.value = t.icon, s(i, "menu-click"));
    }, p = (i) => {
      i ? r.value = t.activeIcon ? t.activeIcon : t.icon : r.value = t.icon;
    };
    return (i, $) => {
      const O = oe;
      return o(), h(
        "div",
        {
          class: se(B.value),
          style: fe(v.value)
        },
        [
          C(O, { autoInsertSpaceInButton: !1 }, {
            default: u(() => [
              m(" 同类集合按钮 "),
              e.btnType === "default-sameset" || e.btnType === "primary-sameset" ? (o(), y(l(ye), M({ key: 0 }, i.$attrs, {
                tabindex: "-1",
                trigger: e.trigger,
                disabled: e.disabled,
                getPopupContainer: e.getPopupContainer,
                onVisibleChange: p,
                onClick: P,
                type: e.btnType === "primary-sameset" ? "primary" : "default",
                class: `${e.block ? "block" : ""} ${e.size}`
              }), H({
                icon: u(() => [
                  e.icon ? (o(), y(l(E), {
                    key: 0,
                    icon: l(r),
                    size: b.value
                  }, null, 8, ["icon", "size"])) : m("v-if", !0)
                ]),
                default: u(() => [
                  x(i.$slots, "default", {}, void 0, !0)
                ]),
                _: 2
                /* DYNAMIC */
              }, [
                e.menuData && e.menuData.length > 0 ? {
                  name: "overlay",
                  fn: u(() => [
                    C(l(X), { onClick: T }, {
                      default: u(() => [
                        (o(!0), h(
                          S,
                          null,
                          G(e.menuData, (n) => (o(), y(l(q), {
                            key: n[e.defaultMenuProps.key],
                            disabled: n.disabled
                          }, {
                            default: u(() => [
                              A(
                                V(n[e.defaultMenuProps.label]),
                                1
                                /* TEXT */
                              )
                            ]),
                            _: 2
                            /* DYNAMIC */
                          }, 1032, ["disabled"]))),
                          128
                          /* KEYED_FRAGMENT */
                        ))
                      ]),
                      _: 1
                      /* STABLE */
                    })
                  ]),
                  key: "0"
                } : void 0
              ]), 1040, ["trigger", "disabled", "getPopupContainer", "type", "class"])) : e.btnType === "default-basicset" || e.btnType === "primary-basicset" ? (o(), h(
                S,
                { key: 1 },
                [
                  m(" 基础集合按钮 "),
                  C(l(ge), M(i.$attrs, {
                    tabindex: "-1",
                    type: e.btnType === "primary-basicset" ? "primary" : "default",
                    trigger: e.trigger,
                    disabled: e.disabled,
                    ref: "basicsetDropdownRef",
                    class: `${e.block ? "block" : ""} ${e.btnType === "primary-basicset" ? "primary" : "default"} ${e.size}`,
                    onVisibleChange: p,
                    overlayClassName: "basicset-dropdown-wrap"
                  }), H({
                    default: u(() => [
                      C(l(J), null, {
                        default: u(() => [
                          x(i.$slots, "default", {}, void 0, !0),
                          e.icon ? (o(), y(l(E), {
                            key: 0,
                            icon: l(r),
                            size: e.size === "small" ? "medium" : e.size === "middle" ? "big" : e.size === "large" ? "large" : "big"
                          }, null, 8, ["icon", "size"])) : m("v-if", !0)
                        ]),
                        _: 3
                        /* FORWARDED */
                      })
                    ]),
                    _: 2
                    /* DYNAMIC */
                  }, [
                    e.menuData && e.menuData.length > 0 ? {
                      name: "overlay",
                      fn: u(() => [
                        C(l(X), { onClick: T }, {
                          default: u(() => [
                            (o(!0), h(
                              S,
                              null,
                              G(e.menuData, (n) => (o(), y(l(q), {
                                key: n[e.defaultMenuProps.key],
                                disabled: n.disabled
                              }, {
                                default: u(() => [
                                  x(i.$slots, "menu-item", { item: n }, () => [
                                    A(
                                      V(n[e.defaultMenuProps.label]),
                                      1
                                      /* TEXT */
                                    )
                                  ], !0)
                                ]),
                                _: 2
                                /* DYNAMIC */
                              }, 1032, ["disabled"]))),
                              128
                              /* KEYED_FRAGMENT */
                            ))
                          ]),
                          _: 3
                          /* FORWARDED */
                        })
                      ]),
                      key: "0"
                    } : void 0
                  ]), 1040, ["type", "trigger", "disabled", "class"])
                ],
                64
                /* STABLE_FRAGMENT */
              )) : e.btnType === "tabs" ? (o(), h(
                S,
                { key: 2 },
                [
                  m(" 切换按钮tab "),
                  e.menuData && e.menuData.length > 0 ? (o(), y(l(ve), M({ key: 0 }, i.$attrs, {
                    tabindex: "-1",
                    disabled: e.disabled,
                    value: l(c),
                    "onUpdate:value": $[0] || ($[0] = (n) => be(c) ? c.value = n : c = n)
                  }), {
                    default: u(() => [
                      (o(!0), h(
                        S,
                        null,
                        G(e.menuData, (n) => (o(), y(l(ke), {
                          key: n[e.defaultMenuProps.key],
                          value: n[e.defaultMenuProps.key],
                          disabled: n.disabled
                        }, {
                          default: u(() => [
                            A(
                              V(n[e.defaultMenuProps.label]),
                              1
                              /* TEXT */
                            )
                          ]),
                          _: 2
                          /* DYNAMIC */
                        }, 1032, ["value", "disabled"]))),
                        128
                        /* KEYED_FRAGMENT */
                      ))
                    ]),
                    _: 1
                    /* STABLE */
                  }, 16, ["disabled", "value"])) : m("v-if", !0)
                ],
                64
                /* STABLE_FRAGMENT */
              )) : (o(), h(
                S,
                { key: 3 },
                [
                  m(" 普通按钮 "),
                  C(l(J), M(i.$attrs, {
                    tabindex: "-1",
                    type: k.value,
                    size: e.size,
                    disabled: e.disabled,
                    block: e.block,
                    ghost: e.ghost,
                    onClick: R
                  }), {
                    default: u(() => [
                      e.icon && e.isIconLeft ? (o(), y(l(E), {
                        key: 0,
                        icon: e.icon,
                        size: b.value
                      }, null, 8, ["icon", "size"])) : m("v-if", !0),
                      x(i.$slots, "default", {}, void 0, !0),
                      e.icon && !e.isIconLeft ? (o(), y(l(E), {
                        key: 1,
                        icon: e.icon,
                        size: b.value
                      }, null, 8, ["icon", "size"])) : m("v-if", !0)
                    ]),
                    _: 3
                    /* FORWARDED */
                  }, 16, ["type", "size", "disabled", "block", "ghost"])
                ],
                64
                /* STABLE_FRAGMENT */
              ))
            ]),
            _: 3
            /* FORWARDED */
          })
        ],
        6
        /* CLASS, STYLE */
      );
    };
  }
}), $t = (e, a) => {
  const t = e.__vccOpts || e;
  for (const [d, f] of a)
    t[d] = f;
  return t;
}, Ct = /* @__PURE__ */ $t(ht, [["__scopeId", "data-v-9509d258"]]), wt = le(Ct);
export {
  wt as DasButton,
  wt as default
};
