import { jsxs, jsx } from "react/jsx-runtime";
import * as RadixDropdownMenu from "@radix-ui/react-dropdown-menu";
import * as React from "react";
import { concat } from "../../utils/classNames.js";
import "../../utils/globals.js";
import "./dropdownMenu.theme.css.js";
const DropdownMenu = React.forwardRef(({ items, children, className, showArrow, open, defaultOpen, onOpenChange, ...nativeProps }, ref) => {
  const parsedContent = React.useMemo(() => {
    if (React.isValidElement(items)) {
      return items;
    }
    if (Array.isArray(items)) {
      return items.map((item, index) => {
        return jsxs(React.Fragment, { children: [jsxs(RadixDropdownMenu.Item, { className: concat(item.className, "arm-dropdown-menu-item", item.onClick && "arm-dropdown-menu-item-clickable"), disabled: item.disabled, onSelect: item.onClick && (() => {
          var _a;
          return (_a = item.onClick) == null ? void 0 : _a.call(item, index);
        }), children: [item.leftOverlay && jsx("div", { className: "arm-dropdown-menu-item-left-overlay", children: item.leftOverlay }), item.label && jsx("div", { className: "arm-dropdown-menu-item-label", children: item.label }), item.rightOverlay && jsx("div", { className: "arm-dropdown-menu-item-right-overlay", children: item.rightOverlay })] }), item.addSeparatorUnder && jsx(RadixDropdownMenu.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 jsxs(RadixDropdownMenu.Root, { open, onOpenChange, defaultOpen, children: [children && jsx(RadixDropdownMenu.Trigger, { asChild: true, children }), jsxs(RadixDropdownMenu.Content, { ...nativeProps, "data-has-arrow": !!showArrow, className: concat(className, "arm-dropdown-menu-content"), ref, children: [parsedContent, showArrow && jsx("div", { className: "arm-dropdown-menu-arrow", "data-testid": "arm-dropdown-arrow" })] })] });
});
DropdownMenu.displayName = "DropdownMenu";
export {
  DropdownMenu
};
//# sourceMappingURL=dropdownMenu.component.js.map
