import { defineComponent as z, useSlots as L, ref as W, computed as o, useAttrs as w, openBlock as P, createBlock as S, unref as a, mergeProps as _, createSlots as T, renderList as x, withCtx as A, renderSlot as M, normalizeProps as N, guardReactiveProps as $ } from "vue";
import { Button as D } from "@aplus-frontend/antdv";
import { wait as I } from "@aplus-frontend/utils";
import { omit as O } from "lodash-unified";
import "../config-provider/index.mjs";
import j from "./style/index.mjs";
import { transferOpacityColor as R, getPxStr as q, isAsynchronous as E } from "./utils/index.mjs";
import { useNamespace as F } from "../config-provider/hooks/use-namespace.mjs";
const G = 72, H = 300, ee = /* @__PURE__ */ z({
  __name: "ap-button",
  props: {
    prefixCls: {},
    htmlType: {},
    shape: {},
    size: {},
    loading: { type: [Boolean, Object], default: void 0 },
    disabled: { type: Boolean },
    ghost: { type: Boolean },
    block: { type: Boolean },
    danger: { type: Boolean },
    icon: {},
    href: {},
    target: {},
    title: {},
    onMousedown: {},
    autoInsertSpace: { type: Boolean },
    iconPosition: {},
    color: {},
    variant: {},
    type: { default: "default" },
    borderLinkColor: {},
    minWidth: { type: [Boolean, Number, String], default: !1 },
    lazy: { type: [Boolean, Number], default: !0 },
    onClick: {}
  },
  setup(m) {
    const f = L(), e = m, { b: i } = F("ap-action-button"), y = j("ap-action-button"), l = W(!1), b = o(
      () => e.borderLinkColor || "var(--ap-button-border-link-color)"
    ), s = o(
      () => e.type === "borderLink" && !e.disabled ? b.value : void 0
    ), u = o(
      () => R(s.value)
    ), v = o(() => {
      let t = typeof e.minWidth == "boolean" ? e.minWidth ? G : void 0 : e.minWidth;
      return q(t);
    }), h = o(
      () => (e.type === "borderLink" ? "default" : e.type) || "default"
    ), c = o(() => e.loading ?? l.value ?? !1), d = o(() => e.lazy === !0 ? H : typeof e.lazy == "number" && e.lazy >= 0 ? e.lazy : 0), g = w(), k = o(() => {
      const t = O(e, [
        "type",
        "borderLinkColor",
        "minWidth",
        "onClick",
        "loading"
      ]);
      return {
        ...g,
        ...t,
        type: h.value,
        onClick: C,
        loading: c.value
      };
    });
    async function C(t) {
      if (c.value) return;
      const r = E(e.onClick, t), p = Date.now();
      try {
        r && (l.value = !0, await r);
      } finally {
        if (r) {
          const n = Date.now() - p;
          n < d.value && await I(d.value - n), l.value = !1;
        }
      }
    }
    return (t, r) => (P(), S(a(D), _({
      class: {
        [a(i)()]: !0,
        [`${a(i)()}-border-link`]: u.value,
        [`${a(y)}`]: !0
      }
    }, k.value, {
      style: {
        color: s.value,
        minWidth: v.value,
        "--button-border-color": u.value
      }
    }), T({ _: 2 }, [
      x(f, (p, n) => ({
        name: n,
        fn: A((B) => [
          M(t.$slots, n, N($(B || {})))
        ])
      }))
    ]), 1040, ["class", "style"]));
  }
});
export {
  ee as default
};
