import { useState as h, useEffect as a } from "react";
import u from "../useSideBar/index.js";
import { useIsMobile as d } from "@m4l/graphics";
const b = (e, s = !1) => {
  const { onMenuItemClick: r, onToggleVisible: l } = u(), [i, n] = h(s), t = d(), o = e.children && Array.isArray(e.children) && e.children.length > 0, c = (f) => {
    f?.shiftKey ? r(e, { shiftKey: !0 }) : r(e), n(!i), t && (!o || o === void 0) && l(!1);
  };
  return a(() => {
    n(s);
  }, [s]), { isOpen: i, handlerClick: c, hasChildren: o };
};
export {
  b as useCollapse
};
