import { jsxs as h, jsx as n } from "react/jsx-runtime";
import { classNames as c } from "./index-classNames.js";
import { Icon as x } from "./index-Icon.js";
import { Text as y, TextTypes as I } from "./index-Text.js";
import "react";
import l from "./index-ActionCardAction.module.scss.js";
const d = (e, t) => !e && !t ? "" : e ? t ? `${e}_${t}` : e : t, p = (e) => {
  const {
    opts: t,
    name: r,
    shouldRender: i = !0
  } = e;
  return !r || !i ? null : n(x, {
    testId: d(t == null ? void 0 : t.parentTestId, t == null ? void 0 : t.testId),
    spin: (t == null ? void 0 : t.spin) ?? !1,
    children: r
  });
}, $ = (e) => {
  const {
    width: t = 100,
    label: r,
    iconLeft: i,
    iconRight: m,
    cta: o,
    disabled: f,
    testId: s,
    textWrap: u = "wrap",
    loading: a
  } = e || {};
  return h("div", {
    "data-testid": s,
    style: {
      width: `${t}%`
    },
    onClick: () => {
      o && typeof o == "function" && o();
    },
    className: c(l.action, f ? l.actionDisabled : ""),
    children: [n(p, {
      name: i,
      opts: {
        testId: "iconLeft",
        parentTestId: s
      }
    }), n(y, {
      type: I.textHelp,
      textWrap: u,
      children: r
    }), n(p, {
      shouldRender: !a,
      name: m,
      opts: {
        testId: "iconRight",
        parentTestId: s
      }
    }), a && n("div", {
      role: "spinbutton",
      "data-testid": d("loadingSpinner"),
      className: c(a ? l.loaderSpinner : "")
    })]
  });
};
export {
  $ as ActionCardAction
};
