import { jsxs, jsx } from "react/jsx-runtime";
import { IconMenuItem } from "./IconMenuItem.js";
import { NestedMenuItem } from "./NestedMenuItem.js";
/* empty css                 */
import MenuItem from "../../node_modules/@mui/material/MenuItem/MenuItem.js";
import ListItemIcon from "../../node_modules/@mui/material/ListItemIcon/ListItemIcon.js";
import ChevronRight from "../../node_modules/@mui/icons-material/esm/ChevronRight.js";
function nestedMenuItemsFromObject({
  menuItemsData: items,
  isOpen,
  handleClose,
  withCheckbox,
  label,
  selected,
  handleSelect,
  selectedItems = [],
  ...rest
}) {
  if (label != null && (!Array.isArray(items) || items.length === 0)) {
    return /* @__PURE__ */ jsxs(MenuItem, { onClick: handleClose, children: [
      rest.icon != null && /* @__PURE__ */ jsx(ListItemIcon, { className: "ia-list-icon", children: rest.icon }),
      /* @__PURE__ */ jsxs("div", { className: "ia-list-body", children: [
        /* @__PURE__ */ jsxs("div", { className: "ia-list-label-container", children: [
          /* @__PURE__ */ jsx("div", { className: "ia-list-label", children: label }),
          rest.subLabel != null && /* @__PURE__ */ jsx("div", { className: "ia-list-sublabel", children: rest.subLabel })
        ] }),
        /* @__PURE__ */ jsx(ChevronRight, {})
      ] })
    ] }, label);
  }
  if (!Array.isArray(items) || items.length === 0) {
    return null;
  }
  return items.map((item) => {
    const {
      icon: itemIcon,
      label: itemLabel,
      children: itemChildren,
      callback,
      disabled,
      delay
    } = item;
    if (itemChildren != null && itemChildren.length > 0) {
      return /* @__PURE__ */ jsx(
        NestedMenuItem,
        {
          delay,
          disabled,
          icon: /* @__PURE__ */ jsx(ChevronRight, {}),
          item,
          label: itemLabel,
          parentMenuOpen: isOpen,
          children: nestedMenuItemsFromObject({
            handleClose,
            isOpen,
            menuItemsData: itemChildren,
            label: itemLabel,
            withCheckbox,
            selected,
            handleSelect,
            selectedItems,
            ...rest
          })
        },
        itemLabel
      );
    }
    return /* @__PURE__ */ jsx(
      IconMenuItem,
      {
        className: (selected == null ? void 0 : selected.value) === item.value ? "menu-item-selected" : "",
        icon: itemIcon,
        item,
        label: itemLabel ?? item.section,
        selected,
        selectedItems,
        withCheckbox,
        onClick: (event) => {
          event.stopPropagation();
          handleSelect == null ? void 0 : handleSelect(item, event);
          callback == null ? void 0 : callback(event, item);
        },
        ...rest
      },
      item.value ?? itemLabel
    );
  });
}
export {
  nestedMenuItemsFromObject
};
