import { defineComponent as h, useSlots as A, createPropsRestProxy as F, ref as N, computed as d, unref as o, renderSlot as g, openBlock as l, createElementBlock as u, mergeProps as v, createVNode as k, normalizeClass as S, withCtx as V, createElementVNode as I, createBlock as b, resolveDynamicComponent as x, createCommentVNode as f, isVNode as L, toDisplayString as P } from "vue";
import { Tooltip as $ } from "@aplus-frontend/antdv";
import w from "@aplus-frontend/antdv/es/button/LoadingIcon";
import "../../config-provider/index.mjs";
import D from "../style/index.mjs";
import { useNamespace as E } from "../../config-provider/hooks/use-namespace.mjs";
const T = { key: 1 }, K = /* @__PURE__ */ h({
  name: "ApActionItem",
  __name: "index",
  props: {
    text: {},
    color: { default: "primary" },
    disabled: { type: Boolean, default: !1 },
    visible: { type: Boolean, default: !0 },
    onAction: { type: Function },
    onClick: { type: Function },
    loading: { type: Boolean, default: !1 },
    icon: {},
    iconFirst: { type: Boolean, default: !1 },
    tooltip: { default: () => ({}) }
  },
  setup(e) {
    const a = A(), c = F(e, ["color", "disabled", "visible", "loading", "iconFirst", "icon", "tooltip"]), { b: m, m: n, e: C } = E("action-item"), s = N(!1), r = d(() => e.iconFirst && !!(e.icon || a.icon)), p = D("action-item");
    function y(t) {
      o(i) || e.disabled || (c.onClick?.(t), c.onAction && (s.value = !0, c.onAction(t).finally(() => s.value = !1)));
    }
    const i = d(() => e.loading || o(s)), B = d(() => [
      p.value,
      m(),
      n(e.color),
      r.value ? n("icon-first") : null,
      e.disabled ? n("disabled") : null,
      i.value ? n("loading") : null
    ].filter(Boolean));
    return (t, z) => g(t.$slots, "trigger", {
      loading: i.value,
      disabled: e.disabled,
      onClick: y
    }, () => [
      e.visible ? (l(), u("span", v({ key: 0 }, t.$attrs, {
        class: B.value,
        onClick: y
      }), [
        k(o(w), {
          "prefix-cls": o(m)(),
          "exist-icon": !1,
          loading: i.value
        }, null, 8, ["prefix-cls", "loading"]),
        e.icon || a.icon ? (l(), u("span", {
          key: 0,
          class: S(o(C)("icon-wrapper"))
        }, [
          k(o($), v({
            title: r.value ? e.text : null
          }, e.tooltip), {
            default: V(() => [
              I("span", null, [
                (l(), b(x(e.icon || a.icon)))
              ])
            ]),
            _: 1
          }, 16, ["title"])
        ], 2)) : f("", !0),
        r.value ? f("", !0) : g(t.$slots, "default", { key: 1 }, () => [
          L(e.text) ? (l(), b(x(e.text), { key: 0 })) : (l(), u("span", T, P(e.text || ""), 1))
        ])
      ], 16)) : f("", !0)
    ]);
  }
});
export {
  K as default
};
