import { jsxs as m, jsx as c } from "react/jsx-runtime";
import { gap1 as u, mb1 as g, alignItemsCenter as h, dFlex as b } from "./index-general.module.js";
import { classNames as a } from "./index-classNames.js";
import { Button as I, ButtonSizes as C, ButtonTypes as v } from "./index-Button.js";
import { DropdownMenu as N } from "./index-DropdownMenu.js";
import { IconSize as x } from "./index-Icon.js";
import { IconNames as y } from "./index-IconNames.js";
import { useRef as z } from "react";
import { useToggle as M } from "./index-useToggle.js";
import O from "./index-ActionCardHeader.module.scss.js";
const A = (i) => {
  const {
    children: p,
    disabled: r,
    actions: t
  } = i, {
    dropdownItems: n = []
  } = i, [d, l] = M(!1), s = z(null), o = t == null ? void 0 : t.filter((e) => e.type === "secondary");
  o != null && o.length && n.push(...o.map((e) => ({
    title: e.label,
    iconName: e.iconLeft ?? e.iconRight,
    onClick: e.cta
  })));
  const f = !!n.length;
  return m("div", {
    className: a(b, h, g, u),
    children: [p, m("div", {
      children: [c(I, {
        targetRef: s,
        disabled: r,
        visible: f,
        className: a(O.openMenuCta),
        testId: "action-card-header-open-menu-cta",
        type: v.default,
        size: C.small,
        iconLeft: y.meatballsMenu,
        iconSize: x.large,
        iconColor: "--n500",
        iconHoverColor: "--n700",
        onClick: (e) => {
          if (r)
            return !1;
          l();
        }
      }), c(N, {
        anchorEl: s,
        isOpen: d,
        toggleIsOpen: l,
        placement: "bottom-end",
        items: n
      })]
    })]
  });
};
export {
  A as ActionCardHeader
};
