"use strict";
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const jsxRuntime = require("react/jsx-runtime");
const RadixDropdownMenu = require("@radix-ui/react-dropdown-menu");
const React = require("react");
const classNames = require("../../utils/classNames.cjs");
require("../../utils/globals.cjs");
require("./dropdownMenu.theme.css.cjs");
function _interopNamespaceDefault(e) {
  const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
  if (e) {
    for (const k in e) {
      if (k !== "default") {
        const d = Object.getOwnPropertyDescriptor(e, k);
        Object.defineProperty(n, k, d.get ? d : {
          enumerable: true,
          get: () => e[k]
        });
      }
    }
  }
  n.default = e;
  return Object.freeze(n);
}
const RadixDropdownMenu__namespace = /* @__PURE__ */ _interopNamespaceDefault(RadixDropdownMenu);
const React__namespace = /* @__PURE__ */ _interopNamespaceDefault(React);
const DropdownMenu = React__namespace.forwardRef(({ items, children, className, showArrow, open, defaultOpen, onOpenChange, footerContent, headerContent, disabled, ...nativeProps }, ref) => {
  const parsedContent = React__namespace.useMemo(() => {
    if (React__namespace.isValidElement(items)) {
      return items;
    }
    if (Array.isArray(items)) {
      return items.map((item, index) => {
        return jsxRuntime.jsxs(React__namespace.Fragment, { children: [jsxRuntime.jsxs(RadixDropdownMenu__namespace.Item, { className: classNames.concat(item.className, "arm-dropdown-menu-item", item.onClick && "arm-dropdown-menu-item-clickable"), disabled: item.disabled, onSelect: item.onClick && ((event) => {
          var _a;
          return (_a = item.onClick) == null ? void 0 : _a.call(item, index, event);
        }), children: [item.leftOverlay && jsxRuntime.jsx("div", { className: "arm-dropdown-menu-item-left-overlay", children: item.leftOverlay }), item.label && jsxRuntime.jsx("div", { className: "arm-dropdown-menu-item-label", children: item.label }), item.rightOverlay && jsxRuntime.jsx("div", { className: "arm-dropdown-menu-item-right-overlay", children: item.rightOverlay })] }), item.addSeparatorUnder && jsxRuntime.jsx(RadixDropdownMenu__namespace.Separator, { className: "arm-dropdown-menu-separator" })] }, index);
      });
    }
    throw new Error("Invalid content passed to DropdownMenu. Must be an array of items or a single React element.");
  }, [items]);
  return jsxRuntime.jsxs(RadixDropdownMenu__namespace.Root, { open, onOpenChange, defaultOpen, children: [children && jsxRuntime.jsx(RadixDropdownMenu__namespace.Trigger, { asChild: true, disabled, children }), jsxRuntime.jsxs(RadixDropdownMenu__namespace.Content, { ...nativeProps, "data-has-arrow": !!showArrow, className: classNames.concat(className, "arm-dropdown-menu-content"), ref, children: [!footerContent && !headerContent ? parsedContent : jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [headerContent && jsxRuntime.jsx("div", { className: "arm-dropdown-menu-header", children: headerContent }), jsxRuntime.jsx("div", { className: "arm-dropdown-menu-items", children: parsedContent }), footerContent && jsxRuntime.jsx("div", { className: "arm-dropdown-menu-footer", children: footerContent })] }), showArrow && jsxRuntime.jsx("div", { className: "arm-dropdown-menu-arrow", "data-testid": "arm-dropdown-arrow" })] })] });
});
DropdownMenu.displayName = "DropdownMenu";
exports.DropdownMenu = DropdownMenu;
//# sourceMappingURL=dropdownMenu.component.cjs.map
