import { defineComponent as C, ref as _, computed as A, openBlock as t, createBlock as r, unref as o, normalizeClass as m, withCtx as i, createElementVNode as d, createVNode as g, normalizeProps as B, guardReactiveProps as b, renderSlot as I, resolveDynamicComponent as x, createCommentVNode as D, createElementBlock as P, Fragment as N, renderList as $, mergeProps as c } from "vue";
import { Dropdown as L, Menu as V, MenuItem as z } from "@aplus-frontend/antdv";
import { IconApAdLineDown as E } from "@aplus-frontend/icon";
import { isUndefined as F, omit as M } from "lodash-unified";
import "../../config-provider/index.mjs";
import "../item/index.vue.mjs";
import "../item-modal/index.vue2.mjs";
import "../item-popconfirm/index.vue2.mjs";
import S from "../style/dropdown-item.mjs";
import { useNamespace as O } from "../../config-provider/hooks/use-namespace.mjs";
import y from "../item/index.vue2.mjs";
import R from "../item-modal/index.vue.mjs";
import T from "../item-popconfirm/index.vue.mjs";
const oe = /* @__PURE__ */ C({
  name: "ApActionItemDropDown",
  __name: "index",
  props: {
    trigger: { default: () => ["hover"] },
    placement: { default: "bottomLeft" },
    actions: { default: () => [] },
    showIcon: { type: Boolean, default: !0 },
    text: {},
    color: { default: "primary" },
    disabled: { type: Boolean, default: !1 },
    visible: { type: Boolean, default: !0 },
    onClick: {},
    loading: { type: Boolean, default: !1 },
    icon: {},
    iconFirst: { type: Boolean },
    tooltip: {},
    wrapperTooltip: {}
  },
  setup(l) {
    const p = l, s = _(!1), { e: f, b: v } = O("action-item-dropdown"), u = S("action-item-dropdown"), k = (e, n) => {
      (n.source === "trigger" || e) && (s.value = e);
    }, h = A(() => p.actions.filter((e) => e.visible || F(e.visible)).map((e) => ({
      ...e,
      onClick: (n) => {
        e.onClick?.(n), !e.onAction && (s.value = !1);
      },
      onAction: e.onAction ? async (n) => {
        try {
          await e.onAction?.(n);
        } finally {
          s.value = !1;
        }
      } : void 0
    })));
    return (e, n) => (t(), r(o(L), {
      open: s.value,
      trigger: l.trigger,
      placement: l.placement,
      class: m(o(u)),
      onOpenChange: k
    }, {
      overlay: i(() => [
        g(o(V), null, {
          default: i(() => [
            (t(!0), P(N, null, $(h.value, (a, w) => (t(), r(o(z), {
              key: w,
              class: m([o(u), o(f)("item")])
            }, {
              default: i(() => [
                a.modalProps ? (t(), r(R, c({
                  key: 0,
                  ref_for: !0
                }, a), null, 16)) : a.popconfirmProps ? (t(), r(T, c({
                  key: 1,
                  ref_for: !0
                }, a), null, 16)) : (t(), r(y, c({
                  key: 2,
                  ref_for: !0
                }, a), null, 16))
              ]),
              _: 2
            }, 1032, ["class"]))), 128))
          ]),
          _: 1
        })
      ]),
      default: i(() => [
        d("span", {
          class: m(o(v)())
        }, [
          g(y, B(b(o(M)(p, ["actions", "trigger", "placement", "text"]))), {
            default: i(() => [
              I(e.$slots, "default", {}, () => [
                (t(), r(x(() => l.text)))
              ]),
              d("span", {
                class: m(o(f)("icon"))
              }, [
                l.showIcon ? (t(), r(o(E), { key: 0 })) : D("", !0)
              ], 2)
            ]),
            _: 3
          }, 16)
        ], 2)
      ]),
      _: 3
    }, 8, ["open", "trigger", "placement", "class"]));
  }
});
export {
  oe as default
};
