import { jsxs, jsx } from "react/jsx-runtime";
import { forwardRef, createElement } from "react";
import default_1 from "../../node_modules/@mui/icons-material/ChevronRight.js";
import { Checkbox } from "../Checkbox/index.js";
/* empty css                 */
import MenuItem from "../../node_modules/@mui/material/MenuItem/MenuItem.js";
import ListItemIcon from "../../node_modules/@mui/material/ListItemIcon/ListItemIcon.js";
const IconMenuItem = forwardRef(
  ({
    MenuItemProps,
    className,
    item,
    handleSelect,
    onClick: externalOnClick,
    // icon,
    renderLabel,
    withCheckbox = false,
    selectedItems = [],
    selected,
    children,
    childOpen = false,
    ...props
  }, ref) => {
    const internalOnClick = (e) => {
      item.onClick ? item.onClick(item, e) : void 0;
    };
    const composedOnClick = (e) => {
      if (item.disabled) return;
      if (withCheckbox) {
        if (typeof handleSelect === "function") {
          handleSelect(item, e);
          return;
        }
        if (typeof externalOnClick === "function") {
          externalOnClick(e, item);
          return;
        }
        internalOnClick(e);
        return;
      }
      if (typeof externalOnClick === "function") {
        externalOnClick(e, item);
        return;
      }
      internalOnClick(e);
    };
    return /* @__PURE__ */ createElement(
      MenuItem,
      {
        ...props,
        key: item.label,
        ref,
        disableRipple: true,
        disableTouchRipple: true,
        disabled: item.disabled,
        selected: withCheckbox ? selectedItems.includes(item.value ?? "") : (selected == null ? void 0 : selected.value) === item.value,
        onClick: composedOnClick,
        ...MenuItemProps,
        className: className ? `${className} ${childOpen ? "child-hover" : ""}`.trim() : childOpen ? "child-hover" : void 0
      },
      /* @__PURE__ */ jsxs("div", { className: "ia-list-body", children: [
        withCheckbox && !item.section && /* @__PURE__ */ jsx("div", { className: "ia-menu-checkbox", children: /* @__PURE__ */ jsx(
          Checkbox,
          {
            checked: selectedItems.includes(item.value ?? ""),
            disabled: item.disabled,
            variant: "default"
          }
        ) }),
        item.icon != null && /* @__PURE__ */ jsx(ListItemIcon, { className: "ia-list-icon", children: item.icon }),
        item.section ? /* @__PURE__ */ jsx("div", { className: "menu-section-header", children: item.section }) : /* @__PURE__ */ jsxs("div", { className: "ia-list-label-container", children: [
          /* @__PURE__ */ jsx("div", { className: "ia-list-label", children: renderLabel ? renderLabel(item) : item.label }),
          item.subLabel != null && /* @__PURE__ */ jsx("div", { className: "ia-list-sublabel", children: item.subLabel })
        ] })
      ] }),
      item.rightIcon != null ? item.rightIcon : children != null ? /* @__PURE__ */ jsx(default_1, {}) : null
    );
  }
);
IconMenuItem.displayName = "IconMenuItem";
export {
  IconMenuItem
};
