import { jsx as t, jsxs as a } from "react/jsx-runtime";
import { forwardRef as f, useState as g } from "react";
import { noop as h, isEmpty as i } from "es-toolkit/compat";
import d from "../../utils/classNames.js";
import N from "../../hooks/useClickOutside.js";
const C = (n) => {
  const { title: o, caret: e } = n, r = d(
    "ModuleNavigation-dropdown",
    "dropdown-toggle justify-content-between",
    !e && "inactive"
  );
  return /* @__PURE__ */ a("a", { className: r, role: "button", id: "basic-nav-dropdown", children: [
    /* @__PURE__ */ t("span", { children: o }),
    e && /* @__PURE__ */ t("span", { className: "caret" })
  ] });
}, D = (n) => {
  const { children: o } = n;
  return i(o) ? null : /* @__PURE__ */ t("ul", { role: "menu", className: "dropdown-menu ModuleNavigation-dropdown-menu", children: o });
}, M = f((n, o) => {
  const { open: e, children: r, onDropdownClick: s } = n;
  return /* @__PURE__ */ t("li", { ref: o, className: d("dropdown", e && "open"), onClick: s, children: r });
}), x = (n) => {
  const { title: o, caret: e = !1, onToggleAppMenu: r = h, children: s } = n, [l, p] = g(!1), u = N(() => p(!1)), m = () => {
    const c = !l;
    p(c), r(c);
  }, w = !i(s) && l;
  return /* @__PURE__ */ a(M, { open: w, onDropdownClick: m, ref: u, children: [
    /* @__PURE__ */ t(C, { title: o, caret: e }),
    /* @__PURE__ */ t(D, { children: s })
  ] });
};
export {
  x as AppMenuDropdown,
  x as default
};
//# sourceMappingURL=AppMenuDropdown.js.map
