import { Modal as c } from "@aplus-frontend/antdv";
import { omit as f } from "lodash-unified";
import "../../utils/index.mjs";
import { isDef as a } from "../../utils/is.mjs";
function l(t) {
  return typeof t == "object" && typeof t.then == "function" ? t : !1;
}
const p = (t, n) => typeof t == "function" && l(t?.(n)), y = (t, n = "0.7") => {
  try {
    let r = t?.toLowerCase();
    if (r && /^#([0-9a-fA-f]{3}|[0-9a-fA-f]{6})$/.test(r)) {
      if (r.length === 4) {
        let e = "#";
        for (let i = 1; i < 4; i += 1)
          e += r.slice(i, i + 1).concat(r.slice(i, i + 1));
        r = e;
      }
      const o = [];
      for (let e = 1; e < 7; e += 2)
        o.push(parseInt(`0x${r.slice(e, e + 2)}`, 10));
      return `rgba(${o.join(",")},${n})`;
    }
    if (r && r.startsWith("rgb")) {
      let o = r.match(/(\d(\.\d+)?)+/g);
      return o = o?.slice(0, 3)?.concat(n), `rgba(${o.join(",")})`;
    }
    return r;
  } catch {
    return;
  }
}, C = (t) => {
  const { onOk: n = () => ({}) } = t;
  return new Promise((r, s) => {
    c.confirm({
      onOk: async () => {
        try {
          await n(), r(!0);
        } catch (o) {
          s(o);
        }
      },
      onCancel: () => {
        r(!1);
      },
      ...f(t, ["onOk"])
    });
  });
}, $ = (t) => {
  if (a(t))
    return typeof t == "string" ? t : `${t}px`;
};
export {
  C as confirmHandle,
  $ as getPxStr,
  p as isAsynchronous,
  l as isPromise,
  y as transferOpacityColor
};
