import { jsxs as u, jsx as a } from "@emotion/react/jsx-runtime";
import { useEnvironment as M, useModuleDictionary as S } from "@m4l/core";
import { useIsMobile as y } from "@m4l/graphics";
import { TEST_PROP_ID as m } from "../../test/constants_no_mock.js";
import { getComponentSlotRoot as P } from "../../utils/getComponentSlotRoot.js";
import { PATH_IMG_HAMBURGUER as R, APP_BAR_KEY as D } from "./constants.js";
import { AppBarRootStyled as I, PrimarySectionStyled as N, MenuIconButtonStyled as x, ContentStyled as O, EndContentStyled as L } from "./slots/AppBarSlots.js";
import { getNameDataTestId as g } from "./tests/utils.js";
function V(e, n) {
  return n ? e("appbar.tooltip_toogle_menu") || "Open navigation menu" : "Toggle navigation sidebar";
}
const K = (e) => {
  const {
    onToggleVisible: n,
    onToggleAnchored: f,
    sidebarAnchored: r,
    children: h,
    content: b,
    endContent: i,
    dataTestid: _,
    orientation: l = "vertical",
    size: s,
    hasExpandedModule: v = !1
  } = e, o = y(), { host_static_assets: A, environment_assets: E } = M(), { getLabel: T } = S(), B = P(D), c = V(T, o), d = b ?? h, t = {
    hasEndContent: !!i,
    hasExpandedModule: v,
    isMobile: o,
    orientation: l,
    sidebarAnchored: r,
    size: s
  };
  function C(p) {
    if (o) {
      p.preventDefault(), p.stopPropagation(), n();
      return;
    }
    f();
  }
  return /* @__PURE__ */ u(
    I,
    {
      className: B,
      "data-orientation": l,
      ownerState: t,
      ...process.env.NODE_ENV !== "production" ? { [m]: g(_) } : {},
      children: [
        /* @__PURE__ */ u(N, { ownerState: t, children: [
          /* @__PURE__ */ a(
            x,
            {
              "aria-label": c,
              dataTestId: o ? "AppBarMobileMenuButton" : "AppBarAnchoredButton",
              onClick: C,
              role: o ? "button" : "anchored-button",
              rotationAngle: o ? void 0 : r ? 0 : 180,
              selected: o ? void 0 : r,
              size: s,
              src: `${A}/${E}/${R}`,
              tooltip: c,
              variant: "outline",
              color: "default"
            }
          ),
          d ? /* @__PURE__ */ a(
            O,
            {
              ownerState: t,
              ...process.env.NODE_ENV !== "production" ? { [m]: g("containerChilds") } : {},
              children: d
            }
          ) : null
        ] }),
        i ? /* @__PURE__ */ a(L, { ownerState: t, children: i }) : null
      ]
    }
  );
};
export {
  K as AppBar
};
