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