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