import { jsxs as f, jsx as t } from "@emotion/react/jsx-runtime";
import { ContainerNodeMenuItemMainStyled as S, WrapperMenuItemStyled as I, MenuItemMainStyled as M } from "../../../../slots/SideBarSlots.js";
import { getNameDataTestId as N } from "../../../../tests/utils.js";
import { TEST_PROP_ID as h } from "../../../../../../test/constants_no_mock.js";
import { useComponentSize as C } from "../../../../../../hooks/useComponentSize/index.js";
import { ArrowIcon as O } from "../ArrowIcon/index.js";
import { Collapse as v } from "@mui/material";
import { NodeMenuItem as z } from "../NodeMenuItem/index.js";
import { CLASS_NAME_IS_ROOT as T } from "../../../../constants.js";
import _ from "clsx";
import { useModuleSkeleton as x } from "@m4l/core";
import A from "../../../../hooks/useSideBar/index.js";
import { useCollapse as E } from "../../../../hooks/useCollapse/useCollapse.js";
const q = (m) => {
  const { item: e, size: s, defaultOpen: l = !1 } = m, { classes: a } = A(), { currentSize: o } = C(s), { isOpen: r, handlerClick: c, hasChildren: p } = E(e, l), u = x(), i = {
    active: e.active,
    itemInTreeActive: e.itemInTreeActive,
    sidebarSize: o
  };
  return /* @__PURE__ */ f(
    S,
    {
      role: "treeitem",
      ownerState: i,
      ...process.env.NODE_ENV !== "production" ? { [h]: N("menuItems") } : {},
      children: [
        /* @__PURE__ */ t(I, { ownerState: i, className: a.wrapperMenuItem, children: /* @__PURE__ */ t(
          M,
          {
            label: e.title,
            endIcon: p ? /* @__PURE__ */ t(O, { openState: r, active: e.active }) : null,
            onClick: () => c(),
            size: o
          }
        ) }),
        /* @__PURE__ */ t(v, { in: r, timeout: "auto", unmountOnExit: !0, children: (e.children || []).map((n, d) => /* @__PURE__ */ t(
          z,
          {
            item: n,
            size: o,
            className: _(T),
            defaultOpen: !u,
            isLastSibling: e.children?.length === d + 1,
            isRoot: !0
          },
          n.title
        )) })
      ]
    }
  );
};
export {
  q as NodeMenuItemMain
};
