import { jsxs as l, jsx as e, Fragment as P } from "@emotion/react/jsx-runtime";
import { useEnvironment as T, useModuleDictionary as k } from "@m4l/core";
import { TEST_PROP_ID as E } from "../../../../test/constants_no_mock.js";
import { DEFAULT_ACCOUNT_POPOVER_TRANSFORM_ORIGIN as D, DEFAULT_ACCOUNT_POPOVER_ANCHOR_ORIGIN as R, PATH_VERSION as x, PATH_CONFIGURATION as F, PATH_SIGN_OFF as U } from "../../constants.js";
import { PopoverStyled as M, UserDataContainerStyled as V, AvatarPopoverStyled as H, UserNameEmailStyled as L, FullNametStyled as W, EmailtStyled as G, VersionContainerStyled as j, VersionStyled as z, VersionIconStyled as B, DividerStyled as $, CircularProgressStyled as q, MenuItemSettingsStyled as w, MenuItemStyled as J, MenuItemLogoutStyled as K } from "../../slots/AccountPopoverSlots.js";
import { getNameDataTestId as Q } from "../../tests/utils.js";
import X from "../MyAvatar/MyAvatar.js";
import { useTheme as Y } from "@mui/material";
const se = (_) => {
  const {
    version: h,
    handleClose: o,
    anchorEl: r,
    userData: g,
    settingsHandleOpen: u,
    handleLogOut: v,
    itemHandleClick: S,
    data: i = [],
    asyncState: y,
    size: O,
    anchorOrigin: N = R,
    transformOrigin: I = D
  } = _, { host_static_assets: s, environment_assets: c } = T(), { firstName: d, lastName: m, email: p, avatarUrl: C } = g || {}, { getLabel: a } = k(), n = Y().size.baseSpacings.sp2, A = (t) => {
    S(t), o();
  }, b = () => {
    o(), u();
  }, f = () => {
    v(), o();
  };
  return r ? /* @__PURE__ */ l(
    M,
    {
      size: O,
      open: !!r,
      anchorEl: r,
      onClose: o,
      anchorOrigin: N,
      transformOrigin: I,
      ...process.env.NODE_ENV !== "production" ? { [E]: Q("popover") } : {},
      children: [
        /* @__PURE__ */ l(V, { children: [
          /* @__PURE__ */ e(X, { avatarUrl: C, firstName: d || "first name", lastName: m || "last name", slotAvatar: H }),
          /* @__PURE__ */ l(L, { children: [
            /* @__PURE__ */ e(W, { variant: "paragraphDens", skeletonWidth: `calc(${`${d} ${m}`.length}ex + ${n})`, children: `${d} ${m}` }),
            /* @__PURE__ */ e(G, { variant: "bodyStandard", skeletonWidth: `calc(${p?.length}ex + ${n})`, children: p })
          ] })
        ] }),
        /* @__PURE__ */ l(j, { children: [
          /* @__PURE__ */ e(z, { variant: "bodyStandard", skeletonWidth: `calc(${h.length}ex + ${n})`, children: `${a("account_popover.label_version")} ${h}` }),
          /* @__PURE__ */ e(B, { src: `${s}/${c}/${x}` })
        ] }),
        /* @__PURE__ */ e($, {}),
        y === "loading" ? /* @__PURE__ */ e(q, {}) : /* @__PURE__ */ l(P, { children: [
          /* @__PURE__ */ e(w, { skeletonWidth: `calc(${a("account_popover.label_settings").length}ex + ${n})`, onClick: b, label: a("account_popover.label_settings"), endIcon: `${s}/${c}/${F}` }),
          Array.isArray(i) && i.length > 0 && i.map((t) => /* @__PURE__ */ e(J, { variant: "body", skeletonWidth: `calc(${t.title.length}ex + ${n})`, onClick: () => A(t), label: t.title }, `${t.title}-${t.moduleId}`)),
          /* @__PURE__ */ e($, {})
        ] }),
        /* @__PURE__ */ e(K, { variant: "body", skeletonWidth: `calc(${a("account_popover.label_logout").length}ex + ${n})`, onClick: f, label: a("account_popover.label_logout"), endIcon: `${s}/${c}/${U}` })
      ]
    }
  ) : null;
};
export {
  se as MenuPopover
};
