import { db as C, B as p, _ as i, d4 as y, e as O } from "./index2.js"; import { shallowRef as s, onBeforeUnmount as m, defineComponent as P, onMounted as R, createVNode as x } from "vue"; const A = () => { const n = s(!1); return m(() => { n.value = !0; }), n; }, D = { type: { type: String }, actionFn: Function, close: Function, autofocus: Boolean, prefixCls: String, buttonProps: O(), emitEvent: Boolean, quitOnNullishReturnValue: Boolean }; function d(n) { return !!(n && n.then); } const T = P({ compatConfig: { MODE: 3 }, name: "ActionButton", props: D, setup(n, g) { let { slots: B } = g; const l = s(!1), c = s(), u = s(!1); let f; const v = A(); R(() => { n.autofocus && (f = setTimeout(() => { var e, t; return (t = (e = C(c.value)) === null || e === void 0 ? void 0 : e.focus) === null || t === void 0 ? void 0 : t.call(e); })); }), m(() => { clearTimeout(f); }); const a = function() { for (var e, t = arguments.length, o = new Array(t), r = 0; r < t; r++) o[r] = arguments[r]; (e = n.close) === null || e === void 0 || e.call(n, ...o); }, b = (e) => { d(e) && (u.value = !0, e.then(function() { v.value || (u.value = !1), a(...arguments), l.value = !1; }, (t) => (v.value || (u.value = !1), l.value = !1, Promise.reject(t)))); }, h = (e) => { const { actionFn: t } = n; if (l.value) return; if (l.value = !0, !t) { a(); return; } let o; if (n.emitEvent) { if (o = t(e), n.quitOnNullishReturnValue && !d(o)) { l.value = !1, a(e); return; } } else if (t.length) o = t(n.close), l.value = !1; else if (o = t(), !o) { a(); return; } b(o); }; return () => { const { type: e, prefixCls: t, buttonProps: o } = n; return x(p, i(i(i({}, y(e)), {}, { onClick: h, loading: u.value, prefixCls: t }, o), {}, { ref: c }), B); }; } }); export { T as A };