import { j as jsxRuntimeExports, E as compilerRuntimeExports, r as reactExports, T as useNavigate } from "./vendor-react-DYNCg6N5.js";
import { a1 as $n, p as iO, w as qXe, X as XMe, a2 as _Z, T as CX } from "./vendor-icons-xWhXK_Ui.js";
import { bk as EditProfileIcon, bv as ConfirmMailIcon, bw as WriteMailIcon, bx as AddRoleIcon, by as XIcon, U as UserStatusEnum, bz as LoginAsIcon, bA as BlockIcon, bB as LockOpenIcon, bC as DelIcon, b as useActions, R as ROUTES, P as PanelsEnum, bD as WarningCircleIcon, bE as ServerIcon, bF as DatabaseIcon, bG as getIndicatorByUserStatus, K as IUsersSortField, a0 as UserAvatar, aV as EditIcon, bH as getGenderString, bI as CircleCloseIcon, c as useAppSelector, bJ as InfoIcon, bK as calculatePercentage, bL as useGetUserInfoQuery, bM as useChangeStatusesMutation, l as useLazyGetUsersQuery, m as universalNotification, bN as useRemoveUsersMutation, bO as useCheckRemoveStatusMutation, a6 as clearApiCacheByTags, ae as usersApi, bP as RoleTypesEnum, bQ as useLazyLoginAsQuery, t as extractErrorCode, v as generateErrorMessage, bR as useLazySendEmailServerQuery } from "./index-DfebxkL9.js";
import { u as useTranslation, T as Trans } from "./vendor-i18n-wisIXUFi.js";
import { c as createStyles, T as Text, b as Box, h as ActionIcon, F as Flex, O as Badge, s as showNotification, a1 as Progress, g as Loader, a6 as notifications, a2 as Overlay, q as Popover, G as Group, B as Button, d as Checkbox, C as Container, ao as Space, z as useForm, J as PasswordInput, E as TextInput, ai as Textarea, U as UnstyledButton, V as LoadingOverlay, n as useDisclosure, ac as useClickOutside } from "./vendor-mantine-h0WlM2Mj.js";
import { u as useStyles$d, T as TextField, E as EllipsisTooltip } from "./index-D4BAIihc.js";
import { O as OverflowTip } from "./index-C-CFogWu.js";
import { E as EmailActivationControl, a as useTerminateSessions, b as useVerifyEmailAndOpenModal, O as OneUserActivationModal } from "./useTerminateSessions-Cb3ukMTY.js";
import { S as SelectUserModal } from "./index-DFEP7Sv_.js";
import { M as Modal } from "./index-DqcA8P_y.js";
import { C as Controls } from "./index-DMTgSMwy.js";
import { u as useAddRoles } from "./index-woYEqWvh.js";
import { S as SelectGroupModal } from "./index-Ds4Bnwmy.js";
import { g as getValidateErrors } from "./validation-Ds00Zghx.js";
import { m as modalTheme } from "./styles-3NoIlzov.js";
import { o as objectType, s as stringType } from "./types-espwwxTQ.js";
import { f as formatDate } from "./date-bOIw2uwV.js";
import "./index.es-BTZFX8B-.js";
import "./index-3c9En-DB.js";
import { f as formatByteToGb, a as formatDataSizeUnits } from "./format-CMT-x-V3.js";
var ActionUserMenuEnum = /* @__PURE__ */ ((ActionUserMenuEnum2) => {
  ActionUserMenuEnum2["loginAs"] = "login-as";
  ActionUserMenuEnum2["activateEmail"] = "activate-email";
  ActionUserMenuEnum2["block"] = "block";
  ActionUserMenuEnum2["unblock"] = "unblock";
  ActionUserMenuEnum2["deleteUser"] = "delete-user";
  ActionUserMenuEnum2["terminateAll"] = "terminate-all";
  ActionUserMenuEnum2["transferData"] = "transfer-data";
  ActionUserMenuEnum2["deletePersonalData"] = "delete-personal-data";
  ActionUserMenuEnum2["addRole"] = "add-role";
  ActionUserMenuEnum2["writeLetter"] = "write-letter";
  ActionUserMenuEnum2["editUser"] = "profile";
  return ActionUserMenuEnum2;
})(ActionUserMenuEnum || {});
const actionMenu = (userStatus, permissions = {}) => {
  const {
    t
  } = useTranslation();
  const baseList = [{
    label: t("users.actionList.editProfile"),
    value: "profile",
    icon: /* @__PURE__ */ jsxRuntimeExports.jsx(EditProfileIcon, {})
  }, {
    label: t("users.actionList.confirmEmail"),
    value: "activate-email",
    icon: /* @__PURE__ */ jsxRuntimeExports.jsx(ConfirmMailIcon, {})
  }, {
    label: t("users.actionList.writeLetter"),
    value: "write-letter",
    icon: /* @__PURE__ */ jsxRuntimeExports.jsx(WriteMailIcon, {})
  }, {
    label: t("users.actionList.addRole"),
    value: "add-role",
    icon: /* @__PURE__ */ jsxRuntimeExports.jsx(AddRoleIcon, {})
  }, {
    label: t("users.actionList.terminateConnections"),
    value: "terminate-all",
    icon: /* @__PURE__ */ jsxRuntimeExports.jsx(XIcon, {})
  }];
  const list = [...baseList];
  if (userStatus !== UserStatusEnum.Ban) {
    if (permissions == null ? void 0 : permissions.showLoginAsItem) {
      list.unshift({
        label: t("users.actionList.loginAs"),
        value: "login-as",
        icon: /* @__PURE__ */ jsxRuntimeExports.jsx(LoginAsIcon, {})
      });
    }
    if (permissions == null ? void 0 : permissions.showChangeStatusItem) {
      list.push({
        label: t("users.actionList.block"),
        value: "block",
        icon: /* @__PURE__ */ jsxRuntimeExports.jsx(BlockIcon, {})
      });
    }
  }
  if (userStatus === UserStatusEnum.Ban && (permissions == null ? void 0 : permissions.showChangeStatusItem)) {
    list.push({
      label: t("users.actionList.unblock"),
      value: "unblock",
      icon: /* @__PURE__ */ jsxRuntimeExports.jsx(LockOpenIcon, {})
    });
  }
  if (permissions == null ? void 0 : permissions.showDeleteItem) {
    list.push({
      label: t("users.actionList.delete"),
      value: "delete-user",
      icon: /* @__PURE__ */ jsxRuntimeExports.jsx(DelIcon, {})
    });
  }
  return list;
};
const useStyles$c = createStyles((theme, _, utils) => ({
  popover: {
    padding: theme.spacing.xs,
    width: "max-content"
  },
  itemMenu: {
    padding: theme.spacing.xs,
    cursor: "pointer",
    borderRadius: "8px",
    fontSize: "14px",
    gap: 0,
    "&:hover": {
      [utils.dark]: {
        backgroundColor: theme.colors.dark[7],
        color: theme.white
      },
      [utils.light]: {
        backgroundColor: theme.colors.gray[2],
        color: theme.black
      }
    }
  }
}));
const useStyles$b = createStyles((theme) => ({
  content: {
    marginTop: theme.spacing.md,
    display: "flex",
    alignItems: "flex-start",
    flexDirection: "column"
  }
}));
const TextListField = (t0) => {
  const $ = compilerRuntimeExports.c(22);
  const {
    title,
    items,
    rounded
  } = t0;
  const {
    classes,
    cx
  } = useStyles$d();
  const {
    t
  } = useTranslation();
  const t1 = classes.container;
  let t2;
  if ($[0] !== classes.title || $[1] !== title) {
    t2 = /* @__PURE__ */ jsxRuntimeExports.jsx(Text, { className: classes.title, children: title });
    $[0] = classes.title;
    $[1] = title;
    $[2] = t2;
  } else {
    t2 = $[2];
  }
  let t3;
  if ($[3] !== classes.group || $[4] !== classes.listGroup || $[5] !== cx || $[6] !== rounded) {
    t3 = cx(classes.listGroup, {
      [classes.group]: rounded
    });
    $[3] = classes.group;
    $[4] = classes.listGroup;
    $[5] = cx;
    $[6] = rounded;
    $[7] = t3;
  } else {
    t3 = $[7];
  }
  let t4;
  if ($[8] !== classes.description || $[9] !== classes.rounded || $[10] !== cx || $[11] !== items || $[12] !== rounded || $[13] !== t) {
    t4 = (items == null ? void 0 : items.length) ? items == null ? void 0 : items.map((item, index) => /* @__PURE__ */ jsxRuntimeExports.jsx(Box, { maw: "350px", mr: "xs", children: /* @__PURE__ */ jsxRuntimeExports.jsx(OverflowTip, { className: cx(classes.description, {
      [classes.rounded]: item && rounded
    }), children: item }, index) }, index)) : /* @__PURE__ */ jsxRuntimeExports.jsx(Text, { children: t("noInformation") });
    $[8] = classes.description;
    $[9] = classes.rounded;
    $[10] = cx;
    $[11] = items;
    $[12] = rounded;
    $[13] = t;
    $[14] = t4;
  } else {
    t4 = $[14];
  }
  let t5;
  if ($[15] !== t3 || $[16] !== t4) {
    t5 = /* @__PURE__ */ jsxRuntimeExports.jsx(Box, { className: t3, maw: "100%", children: t4 });
    $[15] = t3;
    $[16] = t4;
    $[17] = t5;
  } else {
    t5 = $[17];
  }
  let t6;
  if ($[18] !== classes.container || $[19] !== t2 || $[20] !== t5) {
    t6 = /* @__PURE__ */ jsxRuntimeExports.jsxs(Box, { className: t1, children: [
      t2,
      t5
    ] });
    $[18] = classes.container;
    $[19] = t2;
    $[20] = t5;
    $[21] = t6;
  } else {
    t6 = $[21];
  }
  return t6;
};
const BaseInfo = () => {
  var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
  const $ = compilerRuntimeExports.c(39);
  const {
    classes
  } = useStyles$b();
  const {
    t
  } = useTranslation();
  const {
    userInfoCommon
  } = reactExports.useContext(UserInfoMainContext);
  const t0 = classes.content;
  let t1;
  if ($[0] !== t) {
    t1 = t("profile.position");
    $[0] = t;
    $[1] = t1;
  } else {
    t1 = $[1];
  }
  let t2;
  if ($[2] !== (userInfoCommon == null ? void 0 : userInfoCommon.Positions)) {
    t2 = (_a = userInfoCommon == null ? void 0 : userInfoCommon.Positions) == null ? void 0 : _a.map(_temp);
    $[2] = userInfoCommon == null ? void 0 : userInfoCommon.Positions;
    $[3] = t2;
  } else {
    t2 = $[3];
  }
  let t3;
  if ($[4] !== t1 || $[5] !== t2) {
    t3 = /* @__PURE__ */ jsxRuntimeExports.jsx(TextListField, { title: t1, items: t2 });
    $[4] = t1;
    $[5] = t2;
    $[6] = t3;
  } else {
    t3 = $[6];
  }
  let t4;
  if ($[7] !== t) {
    t4 = t("profile.role");
    $[7] = t;
    $[8] = t4;
  } else {
    t4 = $[8];
  }
  let t5;
  if ($[9] !== (userInfoCommon == null ? void 0 : userInfoCommon.Roles)) {
    t5 = (_b = userInfoCommon == null ? void 0 : userInfoCommon.Roles) == null ? void 0 : _b.map(_temp2);
    $[9] = userInfoCommon == null ? void 0 : userInfoCommon.Roles;
    $[10] = t5;
  } else {
    t5 = $[10];
  }
  let t6;
  if ($[11] !== t4 || $[12] !== t5) {
    t6 = /* @__PURE__ */ jsxRuntimeExports.jsx(TextListField, { title: t4, rounded: true, items: t5 });
    $[11] = t4;
    $[12] = t5;
    $[13] = t6;
  } else {
    t6 = $[13];
  }
  let t7;
  if ($[14] !== t) {
    t7 = t("profile.unit");
    $[14] = t;
    $[15] = t7;
  } else {
    t7 = $[15];
  }
  const t8 = (_c = userInfoCommon == null ? void 0 : userInfoCommon.Customer) == null ? void 0 : _c.Name;
  let t9;
  if ($[16] !== t7 || $[17] !== t8) {
    t9 = /* @__PURE__ */ jsxRuntimeExports.jsx(TextField, { title: t7, description: t8 });
    $[16] = t7;
    $[17] = t8;
    $[18] = t9;
  } else {
    t9 = $[18];
  }
  const t10 = (_d = userInfoCommon == null ? void 0 : userInfoCommon.Credentials) == null ? void 0 : _d.Login;
  let t11;
  if ($[19] !== t10) {
    t11 = /* @__PURE__ */ jsxRuntimeExports.jsx(TextField, { title: "Login", description: t10 });
    $[19] = t10;
    $[20] = t11;
  } else {
    t11 = $[20];
  }
  const t12 = (_e = userInfoCommon == null ? void 0 : userInfoCommon.Credentials) == null ? void 0 : _e.Email;
  let t13;
  if ($[21] !== userInfoCommon) {
    t13 = ((_f = userInfoCommon == null ? void 0 : userInfoCommon.Credentials) == null ? void 0 : _f.Email) && !((_g = userInfoCommon == null ? void 0 : userInfoCommon.Credentials) == null ? void 0 : _g.IsConfirmed) && (userInfoCommon == null ? void 0 : userInfoCommon.Id) && ((_h = userInfoCommon.Customer) == null ? void 0 : _h.Id) ? /* @__PURE__ */ jsxRuntimeExports.jsx(EmailActivationControl, { Email: (_i = userInfoCommon == null ? void 0 : userInfoCommon.Credentials) == null ? void 0 : _i.Email, Id: userInfoCommon == null ? void 0 : userInfoCommon.Id, customerId: (_j = userInfoCommon.Customer) == null ? void 0 : _j.Id }) : null;
    $[21] = userInfoCommon;
    $[22] = t13;
  } else {
    t13 = $[22];
  }
  let t14;
  if ($[23] !== t12 || $[24] !== t13) {
    t14 = /* @__PURE__ */ jsxRuntimeExports.jsx(TextField, { title: "Email", description: t12, link: true, leftSection: t13 });
    $[23] = t12;
    $[24] = t13;
    $[25] = t14;
  } else {
    t14 = $[25];
  }
  let t15;
  if ($[26] !== t) {
    t15 = t("profile.phone");
    $[26] = t;
    $[27] = t15;
  } else {
    t15 = $[27];
  }
  const t16 = (_k = userInfoCommon == null ? void 0 : userInfoCommon.Common) == null ? void 0 : _k.Phone;
  let t17;
  if ($[28] !== t15 || $[29] !== t16) {
    t17 = /* @__PURE__ */ jsxRuntimeExports.jsx(TextField, { title: t15, description: t16, link: true });
    $[28] = t15;
    $[29] = t16;
    $[30] = t17;
  } else {
    t17 = $[30];
  }
  let t18;
  if ($[31] !== classes.content || $[32] !== t11 || $[33] !== t14 || $[34] !== t17 || $[35] !== t3 || $[36] !== t6 || $[37] !== t9) {
    t18 = /* @__PURE__ */ jsxRuntimeExports.jsxs(Box, { className: t0, children: [
      t3,
      t6,
      t9,
      t11,
      t14,
      t17
    ] });
    $[31] = classes.content;
    $[32] = t11;
    $[33] = t14;
    $[34] = t17;
    $[35] = t3;
    $[36] = t6;
    $[37] = t9;
    $[38] = t18;
  } else {
    t18 = $[38];
  }
  return t18;
};
function _temp(position) {
  return position.Position.Name;
}
function _temp2(role) {
  return role.Name;
}
const useStyles$a = createStyles(() => ({
  action: {
    position: "absolute",
    top: "16px",
    right: "16px",
    display: "flex",
    flexDirection: "row"
  },
  backArrow: {
    visibility: "hidden",
    "@media (max-width: 574px)": {
      visibility: "visible"
    }
  }
}));
const DrawerHeader = () => {
  var _a, _b;
  const $ = compilerRuntimeExports.c(15);
  const {
    classes
  } = useStyles$a();
  const navigate = useNavigate();
  const {
    setRowData,
    userInfoCommon
  } = reactExports.useContext(UserInfoMainContext);
  const loginAs = (_a = userInfoCommon == null ? void 0 : userInfoCommon.Credentials) == null ? void 0 : _a.Login;
  const {
    setSelectedUserId
  } = useActions();
  let t0;
  if ($[0] !== navigate || $[1] !== setSelectedUserId) {
    t0 = (event) => {
      event.preventDefault();
      event.stopPropagation();
      setSelectedUserId(0);
      navigate(ROUTES.users.path);
    };
    $[0] = navigate;
    $[1] = setSelectedUserId;
    $[2] = t0;
  } else {
    t0 = $[2];
  }
  const goBack = t0;
  let t1;
  if ($[3] === Symbol.for("react.memo_cache_sentinel")) {
    t1 = {
      display: "flex",
      justifyContent: "space-between",
      alignItems: "center"
    };
    $[3] = t1;
  } else {
    t1 = $[3];
  }
  let t2;
  if ($[4] === Symbol.for("react.memo_cache_sentinel")) {
    t2 = /* @__PURE__ */ jsxRuntimeExports.jsx($n, { color: "#667085" });
    $[4] = t2;
  } else {
    t2 = $[4];
  }
  let t3;
  if ($[5] !== classes.backArrow || $[6] !== goBack) {
    t3 = /* @__PURE__ */ jsxRuntimeExports.jsx(ActionIcon, { onClick: goBack, size: "md", "data-cy": "backArrow", className: classes.backArrow, children: t2 });
    $[5] = classes.backArrow;
    $[6] = goBack;
    $[7] = t3;
  } else {
    t3 = $[7];
  }
  let t4;
  if ($[8] !== loginAs || $[9] !== setRowData || $[10] !== userInfoCommon) {
    t4 = userInfoCommon ? /* @__PURE__ */ jsxRuntimeExports.jsx(Action, { loginAsUser: loginAs, hasIconEye: false, setRowData, item: {
      ...userInfoCommon,
      Id: userInfoCommon == null ? void 0 : userInfoCommon.Id,
      Email: (_b = userInfoCommon == null ? void 0 : userInfoCommon.Credentials) == null ? void 0 : _b.Email
    } }) : null;
    $[8] = loginAs;
    $[9] = setRowData;
    $[10] = userInfoCommon;
    $[11] = t4;
  } else {
    t4 = $[11];
  }
  let t5;
  if ($[12] !== t3 || $[13] !== t4) {
    t5 = /* @__PURE__ */ jsxRuntimeExports.jsxs(Box, { sx: t1, children: [
      t3,
      t4
    ] });
    $[12] = t3;
    $[13] = t4;
    $[14] = t5;
  } else {
    t5 = $[14];
  }
  return t5;
};
const useStyles$9 = createStyles((theme, _, utils) => ({
  container: {
    display: "flex",
    flexDirection: "column",
    alignItems: "flex-start",
    justifyContent: "center",
    marginTop: theme.spacing.sm,
    width: "100%",
    marginLeft: "-6px"
  },
  text: {
    fontSize: "14px",
    fontWeight: 600,
    textAlign: "start",
    lineHeight: "20px",
    marginLeft: "12px"
  },
  group: {
    display: "flex",
    flexDirection: "row",
    alignItems: "center",
    padding: `${theme.spacing.xs} 0px ${theme.spacing.xs} 6px`,
    cursor: "pointer",
    width: "100%",
    borderRadius: "8px",
    "&:hover": {
      [utils.dark]: {
        backgroundColor: theme.colors.dark[7],
        color: theme.white
      },
      [utils.light]: {
        backgroundColor: theme.colors.gray[2],
        color: theme.black
      }
    }
  }
}));
function kebabToCamelCase(str) {
  return str.replace(/-([a-z])/g, function(_, letter) {
    return letter.toUpperCase();
  });
}
function generateDataCyValue(item) {
  if (item && typeof item.value == "string") {
    return kebabToCamelCase(item.value);
  }
}
const MoreActions = () => {
  const $ = compilerRuntimeExports.c(6);
  const {
    classes
  } = useStyles$9();
  const {
    setActivePanel
  } = reactExports.useContext(UserInfoMainContext);
  const {
    t
  } = useTranslation();
  let t0;
  if ($[0] !== classes.container || $[1] !== classes.group || $[2] !== classes.text || $[3] !== setActivePanel || $[4] !== t) {
    const list = [{
      label: t("profile.additionalInfo"),
      icon: /* @__PURE__ */ jsxRuntimeExports.jsx(WarningCircleIcon, { stroke: "#667085" }),
      value: PanelsEnum.additionalInformation
    }, {
      label: t("profile.activeConnections"),
      icon: /* @__PURE__ */ jsxRuntimeExports.jsx(ServerIcon, {}),
      value: PanelsEnum.activeConnections
    }, {
      label: t("profile.savingQuota"),
      icon: /* @__PURE__ */ jsxRuntimeExports.jsx(DatabaseIcon, {}),
      value: PanelsEnum.dataStorageQuota
    }];
    const handleClick = (event) => {
      const value = event.currentTarget.dataset.value ?? "";
      setActivePanel(value);
    };
    t0 = /* @__PURE__ */ jsxRuntimeExports.jsx(Box, { className: classes.container, children: list.map((item, index) => /* @__PURE__ */ jsxRuntimeExports.jsxs(Box, { "data-value": item.value, onClick: handleClick, className: classes.group, "data-cy": generateDataCyValue(item), children: [
      item.icon,
      /* @__PURE__ */ jsxRuntimeExports.jsx(Text, { className: classes.text, children: item.label })
    ] }, index)) });
    $[0] = classes.container;
    $[1] = classes.group;
    $[2] = classes.text;
    $[3] = setActivePanel;
    $[4] = t;
    $[5] = t0;
  } else {
    t0 = $[5];
  }
  return t0;
};
const useStyles$8 = createStyles((theme) => ({
  photo: {
    display: "flex",
    flexDirection: "column",
    alignItems: "center",
    justifyContent: "center"
  },
  container: {
    marginTop: theme.spacing.sm,
    display: "flex",
    flexDirection: "column",
    alignItems: "center",
    justifyContent: "center"
  },
  name: {
    fontWeight: 600,
    textAlign: "center",
    lineHeight: "20px"
  },
  email: {
    color: theme.colors.brandGray[0],
    fontSize: "14px",
    textAlign: "center",
    lineHeight: "17px",
    marginTop: theme.spacing.xs
  },
  badge: {
    marginTop: theme.spacing.sm
  },
  ldapLabel: {
    backgroundColor: "rgba(51, 154, 240, 1)",
    color: "#EFF8FF",
    fontSize: "12px",
    fontWeight: 500,
    lineHeight: "18px",
    padding: "2px 8px",
    borderRadius: "16px",
    flexShrink: 0
  }
}));
const PhotoInfo = (t0) => {
  var _a, _b, _c, _d;
  const $ = compilerRuntimeExports.c(34);
  const {
    userInfoCommon
  } = t0;
  const {
    t
  } = useTranslation();
  const {
    classes
  } = useStyles$8();
  const t1 = (userInfoCommon == null ? void 0 : userInfoCommon.Status) ?? 0;
  let t2;
  if ($[0] !== t || $[1] !== t1) {
    t2 = getIndicatorByUserStatus(t1, t);
    $[0] = t;
    $[1] = t1;
    $[2] = t2;
  } else {
    t2 = $[2];
  }
  const {
    fullLabel,
    colorBadge
  } = t2;
  const isLdapUser = (userInfoCommon == null ? void 0 : userInfoCommon.UserType) === IUsersSortField.LDAP;
  const name = `${((_a = userInfoCommon == null ? void 0 : userInfoCommon.Common) == null ? void 0 : _a.SurName) || ""} ${((_b = userInfoCommon == null ? void 0 : userInfoCommon.Common) == null ? void 0 : _b.FirstName) || ""} ${((_c = userInfoCommon == null ? void 0 : userInfoCommon.Common) == null ? void 0 : _c.MiddleName) || ""}`;
  const email = ((_d = userInfoCommon == null ? void 0 : userInfoCommon.Credentials) == null ? void 0 : _d.Email) || "";
  const t3 = userInfoCommon == null ? void 0 : userInfoCommon.Common;
  const t4 = userInfoCommon == null ? void 0 : userInfoCommon.Id;
  const t5 = userInfoCommon == null ? void 0 : userInfoCommon.Avatar;
  let t6;
  if ($[3] !== t3 || $[4] !== t4 || $[5] !== t5) {
    t6 = /* @__PURE__ */ jsxRuntimeExports.jsx(UserAvatar, { user: t3, userId: t4, size: 124, src: t5, notClickable: true });
    $[3] = t3;
    $[4] = t4;
    $[5] = t5;
    $[6] = t6;
  } else {
    t6 = $[6];
  }
  let t7;
  if ($[7] !== fullLabel) {
    t7 = /* @__PURE__ */ jsxRuntimeExports.jsx(Text, { fw: "600", fz: "11", children: fullLabel });
    $[7] = fullLabel;
    $[8] = t7;
  } else {
    t7 = $[8];
  }
  let t8;
  if ($[9] !== colorBadge || $[10] !== t7) {
    t8 = /* @__PURE__ */ jsxRuntimeExports.jsx(Badge, { variant: "light", color: colorBadge, children: t7 });
    $[9] = colorBadge;
    $[10] = t7;
    $[11] = t8;
  } else {
    t8 = $[11];
  }
  let t9;
  if ($[12] !== classes.ldapLabel || $[13] !== isLdapUser) {
    t9 = isLdapUser && /* @__PURE__ */ jsxRuntimeExports.jsx(Box, { className: classes.ldapLabel, children: "LDAP" });
    $[12] = classes.ldapLabel;
    $[13] = isLdapUser;
    $[14] = t9;
  } else {
    t9 = $[14];
  }
  let t10;
  if ($[15] !== classes.badge || $[16] !== t8 || $[17] !== t9) {
    t10 = /* @__PURE__ */ jsxRuntimeExports.jsxs(Flex, { gap: 4, align: "center", className: classes.badge, children: [
      t8,
      t9
    ] });
    $[15] = classes.badge;
    $[16] = t8;
    $[17] = t9;
    $[18] = t10;
  } else {
    t10 = $[18];
  }
  let t11;
  if ($[19] !== classes.name || $[20] !== name) {
    t11 = /* @__PURE__ */ jsxRuntimeExports.jsx(EllipsisTooltip, { className: classes.name, width: 250, children: name });
    $[19] = classes.name;
    $[20] = name;
    $[21] = t11;
  } else {
    t11 = $[21];
  }
  let t12;
  if ($[22] !== classes.email || $[23] !== email) {
    t12 = /* @__PURE__ */ jsxRuntimeExports.jsx(EllipsisTooltip, { className: classes.email, width: 250, children: email });
    $[22] = classes.email;
    $[23] = email;
    $[24] = t12;
  } else {
    t12 = $[24];
  }
  let t13;
  if ($[25] !== classes.container || $[26] !== t11 || $[27] !== t12) {
    t13 = /* @__PURE__ */ jsxRuntimeExports.jsxs(Box, { className: classes.container, maw: "100%", children: [
      t11,
      t12
    ] });
    $[25] = classes.container;
    $[26] = t11;
    $[27] = t12;
    $[28] = t13;
  } else {
    t13 = $[28];
  }
  let t14;
  if ($[29] !== classes.photo || $[30] !== t10 || $[31] !== t13 || $[32] !== t6) {
    t14 = /* @__PURE__ */ jsxRuntimeExports.jsxs(Box, { className: classes.photo, children: [
      t6,
      t10,
      t13
    ] });
    $[29] = classes.photo;
    $[30] = t10;
    $[31] = t13;
    $[32] = t6;
    $[33] = t14;
  } else {
    t14 = $[33];
  }
  return t14;
};
const useStyles$7 = createStyles((theme) => ({
  headerPanel: {
    display: "flex",
    flexDirection: "row",
    justifyContent: "space-between",
    alignItems: "center",
    width: "100%"
  },
  container: {
    display: "flex",
    flexDirection: "row",
    justifyContent: "center",
    alignItems: "center"
  },
  title: {
    marginLeft: theme.spacing.sm,
    fontWeight: 600,
    fontSize: "14px"
  }
}));
const HeaderPanel = ({
  title,
  activePanel,
  rightIcon = true
}) => {
  const {
    classes
  } = useStyles$7();
  const {
    selectedUserId,
    setActivePanel
  } = reactExports.useContext(UserInfoMainContext);
  const navigate = useNavigate();
  const goBack = reactExports.useCallback(() => {
    setActivePanel(PanelsEnum.generalInformation);
  }, []);
  const goEditUser = () => {
    navigate(`/profile/${selectedUserId}`, {
      state: activePanel
    });
  };
  return /* @__PURE__ */ jsxRuntimeExports.jsxs(Box, { className: classes.headerPanel, children: [
    /* @__PURE__ */ jsxRuntimeExports.jsxs(Box, { className: classes.container, children: [
      /* @__PURE__ */ jsxRuntimeExports.jsx(ActionIcon, { onClick: goBack, size: "md", children: /* @__PURE__ */ jsxRuntimeExports.jsx($n, { color: "#667085" }) }),
      /* @__PURE__ */ jsxRuntimeExports.jsx(Text, { className: classes.title, children: title })
    ] }),
    rightIcon && /* @__PURE__ */ jsxRuntimeExports.jsx(ActionIcon, { size: "md", onClick: goEditUser, children: /* @__PURE__ */ jsxRuntimeExports.jsx(EditIcon, {}) })
  ] });
};
const HomePanel = () => {
  const $ = compilerRuntimeExports.c(9);
  const {
    userInfoCommon
  } = reactExports.useContext(UserInfoMainContext);
  let t0;
  if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
    t0 = /* @__PURE__ */ jsxRuntimeExports.jsx(DrawerHeader, {});
    $[0] = t0;
  } else {
    t0 = $[0];
  }
  let t1;
  if ($[1] !== userInfoCommon) {
    t1 = /* @__PURE__ */ jsxRuntimeExports.jsx(PhotoInfo, { userInfoCommon });
    $[1] = userInfoCommon;
    $[2] = t1;
  } else {
    t1 = $[2];
  }
  let t2;
  if ($[3] === Symbol.for("react.memo_cache_sentinel")) {
    t2 = /* @__PURE__ */ jsxRuntimeExports.jsx(BaseInfo, {});
    $[3] = t2;
  } else {
    t2 = $[3];
  }
  let t3;
  if ($[4] !== userInfoCommon) {
    t3 = userInfoCommon ? /* @__PURE__ */ jsxRuntimeExports.jsx(MoreActions, {}) : null;
    $[4] = userInfoCommon;
    $[5] = t3;
  } else {
    t3 = $[5];
  }
  let t4;
  if ($[6] !== t1 || $[7] !== t3) {
    t4 = /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
      t0,
      t1,
      t2,
      t3
    ] });
    $[6] = t1;
    $[7] = t3;
    $[8] = t4;
  } else {
    t4 = $[8];
  }
  return t4;
};
const useStyles$6 = createStyles((theme) => ({
  content: {
    marginTop: theme.spacing.sm,
    display: "flex",
    alignItems: "flex-start",
    flexDirection: "column"
  }
}));
const MoreInfoPanel = () => {
  var _a, _b, _c, _d, _e, _f, _g;
  const $ = compilerRuntimeExports.c(66);
  const {
    classes
  } = useStyles$6();
  const {
    t
  } = useTranslation();
  const {
    userInfoCommon
  } = reactExports.useContext(UserInfoMainContext);
  let t0;
  if ($[0] !== t) {
    t0 = t("profile.additionalInfo");
    $[0] = t;
    $[1] = t0;
  } else {
    t0 = $[1];
  }
  let t1;
  if ($[2] !== t0) {
    t1 = /* @__PURE__ */ jsxRuntimeExports.jsx(HeaderPanel, { title: t0, activePanel: PanelsEnum.additionalInformation });
    $[2] = t0;
    $[3] = t1;
  } else {
    t1 = $[3];
  }
  const t2 = classes.content;
  let t3;
  if ($[4] !== t) {
    t3 = t("profile.birthDate");
    $[4] = t;
    $[5] = t3;
  } else {
    t3 = $[5];
  }
  const t4 = (_a = userInfoCommon == null ? void 0 : userInfoCommon.Common) == null ? void 0 : _a.BirthDate;
  let t5;
  if ($[6] !== t4) {
    t5 = formatDate(t4);
    $[6] = t4;
    $[7] = t5;
  } else {
    t5 = $[7];
  }
  let t6;
  if ($[8] !== t3 || $[9] !== t5) {
    t6 = /* @__PURE__ */ jsxRuntimeExports.jsx(TextField, { title: t3, description: t5 });
    $[8] = t3;
    $[9] = t5;
    $[10] = t6;
  } else {
    t6 = $[10];
  }
  let t7;
  if ($[11] !== t) {
    t7 = t("profile.gender");
    $[11] = t;
    $[12] = t7;
  } else {
    t7 = $[12];
  }
  const t8 = (_b = userInfoCommon == null ? void 0 : userInfoCommon.Common) == null ? void 0 : _b.Gender;
  let t9;
  if ($[13] !== t || $[14] !== t8) {
    t9 = getGenderString({
      gender: t8,
      t
    });
    $[13] = t;
    $[14] = t8;
    $[15] = t9;
  } else {
    t9 = $[15];
  }
  let t10;
  if ($[16] !== t7 || $[17] !== t9) {
    t10 = /* @__PURE__ */ jsxRuntimeExports.jsx(TextField, { title: t7, description: t9 });
    $[16] = t7;
    $[17] = t9;
    $[18] = t10;
  } else {
    t10 = $[18];
  }
  let t11;
  if ($[19] !== t) {
    t11 = t("profile.phone");
    $[19] = t;
    $[20] = t11;
  } else {
    t11 = $[20];
  }
  const t12 = (_c = userInfoCommon == null ? void 0 : userInfoCommon.Common) == null ? void 0 : _c.Phone;
  let t13;
  if ($[21] !== t11 || $[22] !== t12) {
    t13 = /* @__PURE__ */ jsxRuntimeExports.jsx(TextField, { title: t11, description: t12 });
    $[21] = t11;
    $[22] = t12;
    $[23] = t13;
  } else {
    t13 = $[23];
  }
  let t14;
  if ($[24] !== t) {
    t14 = t("profile.additionalPhone");
    $[24] = t;
    $[25] = t14;
  } else {
    t14 = $[25];
  }
  const t15 = (_d = userInfoCommon == null ? void 0 : userInfoCommon.Common) == null ? void 0 : _d.AdditionalPhone;
  let t16;
  if ($[26] !== t14 || $[27] !== t15) {
    t16 = /* @__PURE__ */ jsxRuntimeExports.jsx(TextField, { title: t14, description: t15 });
    $[26] = t14;
    $[27] = t15;
    $[28] = t16;
  } else {
    t16 = $[28];
  }
  let t17;
  if ($[29] !== t) {
    t17 = t("profile.backupEmail");
    $[29] = t;
    $[30] = t17;
  } else {
    t17 = $[30];
  }
  const t18 = userInfoCommon == null ? void 0 : userInfoCommon.Credentials.AdditionalEmail;
  let t19;
  if ($[31] !== t17 || $[32] !== t18) {
    t19 = /* @__PURE__ */ jsxRuntimeExports.jsx(TextField, { title: t17, description: t18, link: true });
    $[31] = t17;
    $[32] = t18;
    $[33] = t19;
  } else {
    t19 = $[33];
  }
  let t20;
  if ($[34] !== t) {
    t20 = t("profile.address");
    $[34] = t;
    $[35] = t20;
  } else {
    t20 = $[35];
  }
  const t21 = (_e = userInfoCommon == null ? void 0 : userInfoCommon.Common) == null ? void 0 : _e.Address;
  let t22;
  if ($[36] !== t20 || $[37] !== t21) {
    t22 = /* @__PURE__ */ jsxRuntimeExports.jsx(TextField, { title: t20, description: t21 });
    $[36] = t20;
    $[37] = t21;
    $[38] = t22;
  } else {
    t22 = $[38];
  }
  let t23;
  if ($[39] !== t) {
    t23 = t("dateOfCreation");
    $[39] = t;
    $[40] = t23;
  } else {
    t23 = $[40];
  }
  const t24 = (_f = userInfoCommon == null ? void 0 : userInfoCommon.Common) == null ? void 0 : _f.DateOfCreate;
  let t25;
  if ($[41] !== t24) {
    t25 = formatDate(t24);
    $[41] = t24;
    $[42] = t25;
  } else {
    t25 = $[42];
  }
  let t26;
  if ($[43] !== t23 || $[44] !== t25) {
    t26 = /* @__PURE__ */ jsxRuntimeExports.jsx(TextField, { title: t23, description: t25 });
    $[43] = t23;
    $[44] = t25;
    $[45] = t26;
  } else {
    t26 = $[45];
  }
  let t27;
  if ($[46] !== t) {
    t27 = t("profile.lastEntryDate");
    $[46] = t;
    $[47] = t27;
  } else {
    t27 = $[47];
  }
  const t28 = (_g = userInfoCommon == null ? void 0 : userInfoCommon.Common) == null ? void 0 : _g.LastEntryDate;
  let t29;
  if ($[48] !== t28) {
    t29 = formatDate(t28);
    $[48] = t28;
    $[49] = t29;
  } else {
    t29 = $[49];
  }
  let t30;
  if ($[50] !== t27 || $[51] !== t29) {
    t30 = /* @__PURE__ */ jsxRuntimeExports.jsx(TextField, { title: t27, description: t29 });
    $[50] = t27;
    $[51] = t29;
    $[52] = t30;
  } else {
    t30 = $[52];
  }
  let t31;
  if ($[53] !== classes.content || $[54] !== t10 || $[55] !== t13 || $[56] !== t16 || $[57] !== t19 || $[58] !== t22 || $[59] !== t26 || $[60] !== t30 || $[61] !== t6) {
    t31 = /* @__PURE__ */ jsxRuntimeExports.jsxs(Box, { className: t2, children: [
      t6,
      t10,
      t13,
      t16,
      t19,
      t22,
      t26,
      t30
    ] });
    $[53] = classes.content;
    $[54] = t10;
    $[55] = t13;
    $[56] = t16;
    $[57] = t19;
    $[58] = t22;
    $[59] = t26;
    $[60] = t30;
    $[61] = t6;
    $[62] = t31;
  } else {
    t31 = $[62];
  }
  let t32;
  if ($[63] !== t1 || $[64] !== t31) {
    t32 = /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
      t1,
      t31
    ] });
    $[63] = t1;
    $[64] = t31;
    $[65] = t32;
  } else {
    t32 = $[65];
  }
  return t32;
};
const useStyles$5 = createStyles((theme) => ({
  content: {
    marginTop: theme.spacing.sm,
    display: "flex",
    alignItems: "flex-start",
    flexDirection: "column"
  },
  header: {
    fontSize: "14px",
    marginBottom: theme.spacing.md,
    display: "flex",
    alignItems: "center",
    flexDirection: "row"
  },
  description: {
    fontSize: "14px",
    color: "#C01048",
    marginRight: theme.spacing.xs,
    cursor: "pointer"
  },
  emptyData: {
    fontSize: "14px",
    color: theme.colors.brandGray[0]
  }
}));
const useStyles$4 = createStyles((theme) => ({
  root: {
    marginBottom: theme.spacing.sm,
    display: "flex",
    alignItems: "center",
    justifyContent: "space-between",
    flexDirection: "row",
    width: "100%"
  },
  leftSection: {
    display: "flex",
    alignItems: "center",
    justifyContent: "space-between",
    flexDirection: "row",
    width: "80%"
  },
  group: {
    display: "flex",
    alignItems: "flex-start",
    flexDirection: "column",
    width: "40%"
  },
  title: {
    fontSize: "14px"
  },
  description: {
    fontSize: "12px",
    color: theme.colors.brandGray[0]
  }
}));
const ConnectionItem = (t0) => {
  const $ = compilerRuntimeExports.c(33);
  const {
    Id,
    SystemName,
    Ip,
    Date,
    isCurrent,
    terminateConnection
  } = t0;
  const {
    classes
  } = useStyles$4();
  const {
    t
  } = useTranslation();
  let t1;
  if ($[0] !== SystemName || $[1] !== classes.description || $[2] !== classes.title || $[3] !== t) {
    t1 = SystemName ? /* @__PURE__ */ jsxRuntimeExports.jsx(Text, { className: classes.title, children: SystemName }) : /* @__PURE__ */ jsxRuntimeExports.jsx(Text, { className: classes.description, children: t("profile.noInformation") });
    $[0] = SystemName;
    $[1] = classes.description;
    $[2] = classes.title;
    $[3] = t;
    $[4] = t1;
  } else {
    t1 = $[4];
  }
  let t2;
  if ($[5] !== classes.group || $[6] !== t1) {
    t2 = /* @__PURE__ */ jsxRuntimeExports.jsx(Box, { className: classes.group, children: t1 });
    $[5] = classes.group;
    $[6] = t1;
    $[7] = t2;
  } else {
    t2 = $[7];
  }
  let t3;
  if ($[8] !== Ip || $[9] !== classes.title) {
    t3 = /* @__PURE__ */ jsxRuntimeExports.jsx(Text, { className: classes.title, children: Ip });
    $[8] = Ip;
    $[9] = classes.title;
    $[10] = t3;
  } else {
    t3 = $[10];
  }
  let t4;
  if ($[11] !== Date || $[12] !== t) {
    t4 = formatDate(Date) ?? t("profile.noInformation");
    $[11] = Date;
    $[12] = t;
    $[13] = t4;
  } else {
    t4 = $[13];
  }
  let t5;
  if ($[14] !== classes.description || $[15] !== t4) {
    t5 = /* @__PURE__ */ jsxRuntimeExports.jsx(Text, { className: classes.description, children: t4 });
    $[14] = classes.description;
    $[15] = t4;
    $[16] = t5;
  } else {
    t5 = $[16];
  }
  let t6;
  if ($[17] !== classes.group || $[18] !== t3 || $[19] !== t5) {
    t6 = /* @__PURE__ */ jsxRuntimeExports.jsxs(Box, { className: classes.group, children: [
      t3,
      t5
    ] });
    $[17] = classes.group;
    $[18] = t3;
    $[19] = t5;
    $[20] = t6;
  } else {
    t6 = $[20];
  }
  let t7;
  if ($[21] !== classes.leftSection || $[22] !== t2 || $[23] !== t6) {
    t7 = /* @__PURE__ */ jsxRuntimeExports.jsxs(Box, { className: classes.leftSection, children: [
      t2,
      t6
    ] });
    $[21] = classes.leftSection;
    $[22] = t2;
    $[23] = t6;
    $[24] = t7;
  } else {
    t7 = $[24];
  }
  let t8;
  if ($[25] !== Id || $[26] !== isCurrent || $[27] !== terminateConnection) {
    t8 = /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: isCurrent ? /* @__PURE__ */ jsxRuntimeExports.jsx(ActionIcon, { variant: "transparent", children: /* @__PURE__ */ jsxRuntimeExports.jsx(iO, { color: "green", width: "18px", height: "18px" }) }) : /* @__PURE__ */ jsxRuntimeExports.jsx(ActionIcon, { onClick: terminateConnection, size: "md", "data-id": Id, variant: "transparent", children: /* @__PURE__ */ jsxRuntimeExports.jsx(CircleCloseIcon, {}) }) });
    $[25] = Id;
    $[26] = isCurrent;
    $[27] = terminateConnection;
    $[28] = t8;
  } else {
    t8 = $[28];
  }
  let t9;
  if ($[29] !== classes.root || $[30] !== t7 || $[31] !== t8) {
    t9 = /* @__PURE__ */ jsxRuntimeExports.jsxs(Box, { className: classes.root, children: [
      t7,
      t8
    ] });
    $[29] = classes.root;
    $[30] = t7;
    $[31] = t8;
    $[32] = t9;
  } else {
    t9 = $[32];
  }
  return t9;
};
const ActiveConnectionsPanel = () => {
  const {
    classes
  } = useStyles$5();
  const {
    t
  } = useTranslation();
  const {
    userInfoCommon
  } = reactExports.useContext(UserInfoMainContext);
  const {
    User
  } = useAppSelector((state) => state.userInfo);
  const isMyProfilePage = (userInfoCommon == null ? void 0 : userInfoCommon.Id) === (User == null ? void 0 : User.Id) || false;
  const [list, setList] = reactExports.useState((userInfoCommon == null ? void 0 : userInfoCommon.Connections.length) ? userInfoCommon == null ? void 0 : userInfoCommon.Connections : []);
  const currentConnectionItem = list.find((item) => item.IsOwner);
  const allConnectionIds = reactExports.useMemo(() => list.map((item_0) => item_0.Id), [list]);
  const {
    closeSessions
  } = useTerminateSessions();
  const terminateConnection = reactExports.useCallback(async (event) => {
    const id = Number(event.currentTarget.dataset.id) ?? null;
    if (currentConnectionItem && currentConnectionItem.Id === id) {
      showNotification({
        title: t("profile.cantDisconnectCurrentConnection"),
        message: "",
        autoClose: true,
        color: "red"
      });
    } else {
      const updateList = () => {
        setList((prevState) => prevState.filter((item_1) => item_1.Id !== id));
      };
      await closeSessions({
        ids: [id]
      }, updateList);
    }
  }, []);
  const terminateAllConnections = reactExports.useCallback(async () => {
    const filterConnectionsIds = allConnectionIds == null ? void 0 : allConnectionIds.filter((id_0) => id_0 !== (currentConnectionItem == null ? void 0 : currentConnectionItem.Id));
    if (filterConnectionsIds.length > 0) {
      const updateList_0 = () => {
        setList((prevState_0) => prevState_0.filter((item_2) => item_2.Id === (currentConnectionItem == null ? void 0 : currentConnectionItem.Id)));
      };
      await closeSessions({
        userId: (userInfoCommon == null ? void 0 : userInfoCommon.Id) || null
      }, updateList_0);
    }
  }, [allConnectionIds]);
  return /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
    /* @__PURE__ */ jsxRuntimeExports.jsx(HeaderPanel, { title: t("profile.activeConnections"), activePanel: PanelsEnum.activeConnections }),
    /* @__PURE__ */ jsxRuntimeExports.jsx(Box, { className: classes.content, children: list.length ? /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
      /* @__PURE__ */ jsxRuntimeExports.jsxs(Box, { className: classes.header, children: [
        /* @__PURE__ */ jsxRuntimeExports.jsx(Text, { className: classes.description, onClick: terminateAllConnections, children: isMyProfilePage ? list.length > 1 ? t("profile.terminateMyConnections") : null : t("profile.terminateAllConnections") }),
        isMyProfilePage && list.length === 1 ? null : /* @__PURE__ */ jsxRuntimeExports.jsx(InfoIcon, {})
      ] }),
      list.map((item_3) => {
        return /* @__PURE__ */ jsxRuntimeExports.jsx(ConnectionItem, { ...item_3, isCurrent: item_3.IsOwner, terminateConnection }, item_3.Id);
      })
    ] }) : /* @__PURE__ */ jsxRuntimeExports.jsx(Box, { className: classes.emptyData, children: t("profile.noActiveConnections") }) })
  ] });
};
const useStyles$3 = createStyles((theme) => ({
  content: {
    marginTop: theme.spacing.sm,
    display: "flex",
    alignItems: "flex-start",
    flexDirection: "column",
    width: "100%"
  },
  group: {
    display: "flex",
    alignItems: "flex-start",
    justifyContent: "center",
    flexDirection: "column",
    width: "100%",
    marginBottom: theme.spacing.md
  },
  progressText: {
    fontSize: "12px",
    color: theme.colors.brandGray[0],
    fontWeight: 600
  },
  progress: {
    height: "6px"
  },
  progressContainer: {
    width: "100%",
    marginTop: theme.spacing.xs
  }
}));
const DataStorageQuotaPanel = () => {
  var _a;
  const $ = compilerRuntimeExports.c(64);
  const {
    classes
  } = useStyles$3();
  const {
    t
  } = useTranslation();
  const {
    userInfoCommon
  } = reactExports.useContext(UserInfoMainContext);
  let FillPercentTmp;
  let QuotaSize;
  let T0;
  let T1;
  let T2;
  let UsingQuotaSize;
  let t0;
  let t1;
  let t2;
  let t3;
  let t4;
  if ($[0] !== classes.content || $[1] !== classes.group || $[2] !== classes.progressText || $[3] !== t || $[4] !== (userInfoCommon == null ? void 0 : userInfoCommon.StorageData)) {
    const {
      Percentage,
      QuotaSize: t52,
      UsingQuotaSize: t62
    } = (userInfoCommon == null ? void 0 : userInfoCommon.StorageData) || {};
    QuotaSize = t52;
    UsingQuotaSize = t62;
    FillPercentTmp = Percentage ? Percentage : calculatePercentage(QuotaSize, UsingQuotaSize);
    let t72;
    if ($[16] !== t) {
      t72 = t("profile.savingQuota");
      $[16] = t;
      $[17] = t72;
    } else {
      t72 = $[17];
    }
    if ($[18] !== t72) {
      t4 = /* @__PURE__ */ jsxRuntimeExports.jsx(HeaderPanel, { title: t72, rightIcon: false });
      $[18] = t72;
      $[19] = t4;
    } else {
      t4 = $[19];
    }
    T2 = Box;
    t3 = classes.content;
    T1 = Box;
    t2 = classes.group;
    T0 = Text;
    t0 = classes.progressText;
    t1 = t("profile.filledSpacePercent", {
      FillPercentTmp
    });
    $[0] = classes.content;
    $[1] = classes.group;
    $[2] = classes.progressText;
    $[3] = t;
    $[4] = userInfoCommon == null ? void 0 : userInfoCommon.StorageData;
    $[5] = FillPercentTmp;
    $[6] = QuotaSize;
    $[7] = T0;
    $[8] = T1;
    $[9] = T2;
    $[10] = UsingQuotaSize;
    $[11] = t0;
    $[12] = t1;
    $[13] = t2;
    $[14] = t3;
    $[15] = t4;
  } else {
    FillPercentTmp = $[5];
    QuotaSize = $[6];
    T0 = $[7];
    T1 = $[8];
    T2 = $[9];
    UsingQuotaSize = $[10];
    t0 = $[11];
    t1 = $[12];
    t2 = $[13];
    t3 = $[14];
    t4 = $[15];
  }
  let t5;
  if ($[20] !== T0 || $[21] !== t0 || $[22] !== t1) {
    t5 = /* @__PURE__ */ jsxRuntimeExports.jsx(T0, { className: t0, children: t1 });
    $[20] = T0;
    $[21] = t0;
    $[22] = t1;
    $[23] = t5;
  } else {
    t5 = $[23];
  }
  let t6;
  if ($[24] !== FillPercentTmp || $[25] !== classes.progress) {
    t6 = /* @__PURE__ */ jsxRuntimeExports.jsx(Progress, { className: classes.progress, value: FillPercentTmp });
    $[24] = FillPercentTmp;
    $[25] = classes.progress;
    $[26] = t6;
  } else {
    t6 = $[26];
  }
  let t7;
  if ($[27] !== classes.progressContainer || $[28] !== t6) {
    t7 = /* @__PURE__ */ jsxRuntimeExports.jsx(Box, { className: classes.progressContainer, children: t6 });
    $[27] = classes.progressContainer;
    $[28] = t6;
    $[29] = t7;
  } else {
    t7 = $[29];
  }
  let t8;
  if ($[30] !== T1 || $[31] !== t2 || $[32] !== t5 || $[33] !== t7) {
    t8 = /* @__PURE__ */ jsxRuntimeExports.jsxs(T1, { className: t2, children: [
      t5,
      t7
    ] });
    $[30] = T1;
    $[31] = t2;
    $[32] = t5;
    $[33] = t7;
    $[34] = t8;
  } else {
    t8 = $[34];
  }
  let t9;
  if ($[35] !== t) {
    t9 = t("profile.quotaDetails");
    $[35] = t;
    $[36] = t9;
  } else {
    t9 = $[36];
  }
  const t10 = (_a = userInfoCommon == null ? void 0 : userInfoCommon.Quota) == null ? void 0 : _a.Name;
  let t11;
  if ($[37] !== t10 || $[38] !== t9) {
    t11 = /* @__PURE__ */ jsxRuntimeExports.jsx(TextField, { title: t9, description: t10 });
    $[37] = t10;
    $[38] = t9;
    $[39] = t11;
  } else {
    t11 = $[39];
  }
  let t12;
  if ($[40] !== t) {
    t12 = t("quota.size");
    $[40] = t;
    $[41] = t12;
  } else {
    t12 = $[41];
  }
  let t13;
  if ($[42] !== QuotaSize) {
    t13 = formatByteToGb(QuotaSize);
    $[42] = QuotaSize;
    $[43] = t13;
  } else {
    t13 = $[43];
  }
  let t14;
  if ($[44] !== t12 || $[45] !== t13) {
    t14 = /* @__PURE__ */ jsxRuntimeExports.jsx(TextField, { title: t12, description: t13 });
    $[44] = t12;
    $[45] = t13;
    $[46] = t14;
  } else {
    t14 = $[46];
  }
  let t15;
  if ($[47] !== t) {
    t15 = t("quota.used");
    $[47] = t;
    $[48] = t15;
  } else {
    t15 = $[48];
  }
  let t16;
  if ($[49] !== UsingQuotaSize) {
    t16 = formatDataSizeUnits(UsingQuotaSize);
    $[49] = UsingQuotaSize;
    $[50] = t16;
  } else {
    t16 = $[50];
  }
  let t17;
  if ($[51] !== t15 || $[52] !== t16) {
    t17 = /* @__PURE__ */ jsxRuntimeExports.jsx(TextField, { title: t15, description: t16 });
    $[51] = t15;
    $[52] = t16;
    $[53] = t17;
  } else {
    t17 = $[53];
  }
  let t18;
  if ($[54] !== T2 || $[55] !== t11 || $[56] !== t14 || $[57] !== t17 || $[58] !== t3 || $[59] !== t8) {
    t18 = /* @__PURE__ */ jsxRuntimeExports.jsxs(T2, { className: t3, children: [
      t8,
      t11,
      t14,
      t17
    ] });
    $[54] = T2;
    $[55] = t11;
    $[56] = t14;
    $[57] = t17;
    $[58] = t3;
    $[59] = t8;
    $[60] = t18;
  } else {
    t18 = $[60];
  }
  let t19;
  if ($[61] !== t18 || $[62] !== t4) {
    t19 = /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
      t4,
      t18
    ] });
    $[61] = t18;
    $[62] = t4;
    $[63] = t19;
  } else {
    t19 = $[63];
  }
  return t19;
};
const UserInfoMainContext = reactExports.createContext({});
const Panels = (t0) => {
  const $ = compilerRuntimeExports.c(16);
  const {
    selectedUserId,
    setActivePanel,
    activePanel,
    setRowData,
    handleClose
  } = t0;
  const {
    data,
    isLoading,
    isError
  } = useGetUserInfoQuery(selectedUserId);
  const {
    t
  } = useTranslation();
  let t1;
  if ($[0] !== activePanel || $[1] !== data || $[2] !== selectedUserId || $[3] !== setActivePanel || $[4] !== setRowData) {
    t1 = {
      selectedUserId,
      setActivePanel,
      activePanel,
      setRowData,
      userInfoCommon: data
    };
    $[0] = activePanel;
    $[1] = data;
    $[2] = selectedUserId;
    $[3] = setActivePanel;
    $[4] = setRowData;
    $[5] = t1;
  } else {
    t1 = $[5];
  }
  const initialValues = t1;
  let t2;
  if ($[6] !== handleClose || $[7] !== isError || $[8] !== t) {
    t2 = () => {
      if (isError) {
        notifications.show({
          title: t("requestsErrors.error"),
          message: t("users.userNotFound"),
          color: "red"
        });
        handleClose();
      }
    };
    $[6] = handleClose;
    $[7] = isError;
    $[8] = t;
    $[9] = t2;
  } else {
    t2 = $[9];
  }
  let t3;
  if ($[10] !== isError) {
    t3 = [isError];
    $[10] = isError;
    $[11] = t3;
  } else {
    t3 = $[11];
  }
  reactExports.useEffect(t2, t3);
  let t4;
  if ($[12] !== activePanel || $[13] !== initialValues || $[14] !== isLoading) {
    t4 = /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: isLoading ? /* @__PURE__ */ jsxRuntimeExports.jsx(Flex, { justify: "center", align: "center", h: "100vh", children: /* @__PURE__ */ jsxRuntimeExports.jsx(Loader, {}) }) : /* @__PURE__ */ jsxRuntimeExports.jsxs(UserInfoMainContext.Provider, { value: initialValues, children: [
      activePanel === PanelsEnum.generalInformation && /* @__PURE__ */ jsxRuntimeExports.jsx(HomePanel, {}),
      activePanel === PanelsEnum.additionalInformation && /* @__PURE__ */ jsxRuntimeExports.jsx(MoreInfoPanel, {}),
      activePanel === PanelsEnum.activeConnections && /* @__PURE__ */ jsxRuntimeExports.jsx(ActiveConnectionsPanel, {}),
      activePanel === PanelsEnum.dataStorageQuota && /* @__PURE__ */ jsxRuntimeExports.jsx(DataStorageQuotaPanel, {})
    ] }) });
    $[12] = activePanel;
    $[13] = initialValues;
    $[14] = isLoading;
    $[15] = t4;
  } else {
    t4 = $[15];
  }
  return t4;
};
const PopoverMenu = ({
  children,
  email,
  isConfirmed,
  list,
  onClickItem,
  overflow,
  ...props
}) => {
  const {
    classes
  } = useStyles$c();
  const {
    userInfoCommon
  } = reactExports.useContext(UserInfoMainContext);
  const currentUser = useAppSelector((state) => state.userInfo.User);
  return /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
    props.opened && overflow && /* @__PURE__ */ jsxRuntimeExports.jsx(Overlay, { opacity: 0, fixed: true }),
    /* @__PURE__ */ jsxRuntimeExports.jsxs(Popover, { zIndex: 1101, ...props, children: [
      /* @__PURE__ */ jsxRuntimeExports.jsx(Popover.Target, { children }),
      /* @__PURE__ */ jsxRuntimeExports.jsx(Popover.Dropdown, { className: classes.popover, "data-cy": "popoverMenu", children: list.filter((item) => {
        return !((item == null ? void 0 : item.value) === "activate-email" && (!(email == null ? void 0 : email.length) || isConfirmed)) && !((item == null ? void 0 : item.value) === "write-letter" && !(email == null ? void 0 : email.length)) && !((item == null ? void 0 : item.value) === "terminate-all" && userInfoCommon && (!(userInfoCommon == null ? void 0 : userInfoCommon.Connections.length) || (userInfoCommon == null ? void 0 : userInfoCommon.Id) === (currentUser == null ? void 0 : currentUser.Id) && (userInfoCommon == null ? void 0 : userInfoCommon.Connections.length) === 1));
      }).map((item_0, index) => {
        return /* @__PURE__ */ jsxRuntimeExports.jsxs(Group, { "data-value": item_0.value, onClick: onClickItem, className: classes.itemMenu, "data-cy": `${generateDataCyValue(item_0)}`, children: [
          item_0 == null ? void 0 : item_0.icon,
          /* @__PURE__ */ jsxRuntimeExports.jsx(Text, { fz: "sm", c: (item_0 == null ? void 0 : item_0.color) || "", ml: 12, children: item_0.label })
        ] }, index);
      }) })
    ] })
  ] });
};
const useChangeStatuses = (setRowData, editUser) => {
  const [num, setNum] = reactExports.useState(0);
  const [fetchChangeStatus, resultChangeStatuses] = useChangeStatusesMutation();
  const {
    filters
  } = useAppSelector((state) => state.users);
  const [fetchGetUsers] = useLazyGetUsersQuery();
  const {
    setUsers
  } = useActions();
  const changeStatuses = reactExports.useCallback(async (selection, userStatus) => {
    const numbersSelection = (selection == null ? void 0 : selection.map((item) => Number(item))) ?? [];
    setNum(numbersSelection.length);
    try {
      const res = await fetchChangeStatus({
        Ids: numbersSelection,
        status: userStatus
      });
      if (!Object.keys(res).includes("error")) {
        const {
          data
        } = await fetchGetUsers({
          Count: filters.Offset >= 20 ? filters.Offset + 20 : 20,
          Offset: 0,
          SortOrder: filters.SortOrder,
          SortField: filters.SortField,
          Filters: filters.Filters,
          Query: filters.Query
        });
        if (setRowData && data) {
          setUsers(data);
          setRowData(data.Users);
        }
      }
    } catch (err) {
      console.warn("fetchGetUsers ERROR", err);
    }
  }, [filters]);
  reactExports.useEffect(() => {
    const {
      isSuccess,
      isError,
      error
    } = resultChangeStatuses;
    const message = num <= 1 ? "Статус был успешно обновлен" : "Статусы пользователей успешно обновлены";
    universalNotification({
      isSuccess,
      isError,
      error,
      successTitle: message
    });
  }, [resultChangeStatuses]);
  return {
    changeStatuses
  };
};
const useStyles$2 = createStyles((theme) => ({
  list: {
    position: "relative",
    margin: 0,
    padding: 0,
    overflow: "auto",
    listStyleType: "none",
    maxHeight: 320
  },
  header: {
    position: "sticky",
    top: 0,
    borderBottom: `1px solid ${theme.colors.backgroundGray[6]}`,
    backgroundColor: "#FFFFFF",
    zIndex: 2
  },
  headerElem: {
    width: "100%",
    backgroundColor: "#FFFFFF",
    padding: "12px 0",
    gap: "6px"
  },
  progress: {
    marginBottom: theme.spacing.sm,
    marginTop: theme.spacing.sm,
    width: 300
  },
  transparent: {
    opacity: 0.05,
    pointerEvents: "none"
  },
  box: {
    position: "absolute",
    display: "flex",
    flexDirection: "column",
    alignItems: "center",
    justifyContent: "center",
    width: "100%",
    height: "80%"
  },
  transferBadge: {
    fontSize: theme.fontSizes.sm,
    lineHeight: "204%",
    border: "none",
    borderRadius: "34px",
    backgroundColor: "#F2F4F7",
    padding: "4px 8px",
    maxWidth: "160px",
    cursor: "pointer"
  },
  itemContainer: {
    width: "100%",
    alignItems: "center"
  },
  select: {
    width: "60%"
  },
  userInfo: {
    width: "60%"
  },
  transferInfo: {
    width: "33%"
  },
  overflow: {
    overflow: "auto"
  }
}));
const TransferData = (t0) => {
  const $ = compilerRuntimeExports.c(23);
  const {
    nameButton,
    userId,
    onChange,
    SkipUsersIds
  } = t0;
  const {
    t
  } = useTranslation();
  const {
    classes
  } = useStyles$2();
  const [showModal, setShowModal] = reactExports.useState(false);
  const [selected, setSelected] = reactExports.useState(null);
  let t1;
  if ($[0] !== onChange || $[1] !== selected) {
    t1 = () => {
      if (selected) {
        onChange(null);
        setSelected(null);
      } else {
        setShowModal(true);
      }
    };
    $[0] = onChange;
    $[1] = selected;
    $[2] = t1;
  } else {
    t1 = $[2];
  }
  const handleClick = t1;
  let t2;
  if ($[3] !== classes || $[4] !== handleClick || $[5] !== nameButton || $[6] !== selected || $[7] !== t) {
    t2 = selected ? /* @__PURE__ */ jsxRuntimeExports.jsxs(Flex, { align: "center", onClick: handleClick, className: classes.transferBadge, children: [
      /* @__PURE__ */ jsxRuntimeExports.jsx(OverflowTip, { fw: "normal", fz: "sm", mr: 4, children: `${selected.Surname || ""} ${selected.FirstName || ""}` }),
      /* @__PURE__ */ jsxRuntimeExports.jsx(qXe, { stroke: 3, size: 12 })
    ] }) : /* @__PURE__ */ jsxRuntimeExports.jsxs(Button, { variant: "subtle", color: "gray", h: 28, px: 12, c: "#101828", bg: "backgroundGray.6", radius: "lg", onClick: handleClick, children: [
      /* @__PURE__ */ jsxRuntimeExports.jsx(Text, { span: true, mr: "xs", fw: "600", fz: "14", children: nameButton || t("select") }),
      /* @__PURE__ */ jsxRuntimeExports.jsx(XMe, { opacity: 0.6, size: 16 })
    ] });
    $[3] = classes;
    $[4] = handleClick;
    $[5] = nameButton;
    $[6] = selected;
    $[7] = t;
    $[8] = t2;
  } else {
    t2 = $[8];
  }
  const buttonContent = t2;
  let t3;
  if ($[9] !== onChange) {
    t3 = (user) => {
      onChange(user.Id);
      setSelected(user);
      setShowModal(false);
    };
    $[9] = onChange;
    $[10] = t3;
  } else {
    t3 = $[10];
  }
  const handleSelectUser = t3;
  let t4;
  if ($[11] !== t) {
    t4 = t("users.transferToUser");
    $[11] = t;
    $[12] = t4;
  } else {
    t4 = $[12];
  }
  let t5;
  if ($[13] === Symbol.for("react.memo_cache_sentinel")) {
    t5 = () => setShowModal(false);
    $[13] = t5;
  } else {
    t5 = $[13];
  }
  let t6;
  if ($[14] !== SkipUsersIds || $[15] !== handleSelectUser || $[16] !== showModal || $[17] !== t4 || $[18] !== userId) {
    t6 = /* @__PURE__ */ jsxRuntimeExports.jsx(SelectUserModal, { multipleUsers: false, isOpened: showModal, title: t4, userId, setSelectedUsers: handleSelectUser, onClose: t5, SkipUsersIds });
    $[14] = SkipUsersIds;
    $[15] = handleSelectUser;
    $[16] = showModal;
    $[17] = t4;
    $[18] = userId;
    $[19] = t6;
  } else {
    t6 = $[19];
  }
  let t7;
  if ($[20] !== buttonContent || $[21] !== t6) {
    t7 = /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
      buttonContent,
      t6
    ] });
    $[20] = buttonContent;
    $[21] = t6;
    $[22] = t7;
  } else {
    t7 = $[22];
  }
  return t7;
};
const ListItem = (t0) => {
  const $ = compilerRuntimeExports.c(39);
  const {
    isSelectedMultiple,
    value,
    onChange,
    SkipUsersIds
  } = t0;
  const {
    t
  } = useTranslation();
  const {
    classes
  } = useStyles$2();
  if (!value) {
    return null;
  }
  const {
    isChecked,
    email,
    FirstName,
    SurName,
    id,
    isNotAcceptable,
    Avatar
  } = value;
  let t1;
  if ($[0] !== onChange || $[1] !== value) {
    t1 = () => {
      onChange({
        ...value,
        isChecked: !(value == null ? void 0 : value.isChecked)
      });
    };
    $[0] = onChange;
    $[1] = value;
    $[2] = t1;
  } else {
    t1 = $[2];
  }
  const handleCheckChange = t1;
  let t2;
  if ($[3] !== handleCheckChange || $[4] !== isChecked || $[5] !== isNotAcceptable || $[6] !== isSelectedMultiple) {
    t2 = isSelectedMultiple && /* @__PURE__ */ jsxRuntimeExports.jsx(Checkbox, { disabled: isNotAcceptable, checked: isNotAcceptable ? false : isChecked, size: "xs", onChange: handleCheckChange });
    $[3] = handleCheckChange;
    $[4] = isChecked;
    $[5] = isNotAcceptable;
    $[6] = isSelectedMultiple;
    $[7] = t2;
  } else {
    t2 = $[7];
  }
  let t3;
  if ($[8] !== Avatar || $[9] !== id || $[10] !== value) {
    t3 = /* @__PURE__ */ jsxRuntimeExports.jsx(UserAvatar, { user: value, src: Avatar, userId: id, size: 40 });
    $[8] = Avatar;
    $[9] = id;
    $[10] = value;
    $[11] = t3;
  } else {
    t3 = $[11];
  }
  let t4;
  if ($[12] !== FirstName || $[13] !== SurName) {
    t4 = SurName || FirstName ? /* @__PURE__ */ jsxRuntimeExports.jsx(OverflowTip, { fz: "sm", fw: "bold", children: `${SurName || ""} ${FirstName || ""}` }) : null;
    $[12] = FirstName;
    $[13] = SurName;
    $[14] = t4;
  } else {
    t4 = $[14];
  }
  let t5;
  if ($[15] !== email) {
    t5 = email ? /* @__PURE__ */ jsxRuntimeExports.jsx(OverflowTip, { fz: "xs", color: "brandGray.0", children: email }) : null;
    $[15] = email;
    $[16] = t5;
  } else {
    t5 = $[16];
  }
  let t6;
  if ($[17] !== classes.userInfo || $[18] !== t4 || $[19] !== t5) {
    t6 = /* @__PURE__ */ jsxRuntimeExports.jsxs(Flex, { direction: "column", className: classes.userInfo, children: [
      t4,
      t5
    ] });
    $[17] = classes.userInfo;
    $[18] = t4;
    $[19] = t5;
    $[20] = t6;
  } else {
    t6 = $[20];
  }
  let t7;
  if ($[21] !== classes.select || $[22] !== t2 || $[23] !== t3 || $[24] !== t6) {
    t7 = /* @__PURE__ */ jsxRuntimeExports.jsxs(Flex, { align: "center", direction: "row", gap: "xs", className: classes.select, children: [
      t2,
      t3,
      t6
    ] });
    $[21] = classes.select;
    $[22] = t2;
    $[23] = t3;
    $[24] = t6;
    $[25] = t7;
  } else {
    t7 = $[25];
  }
  let t8;
  if ($[26] !== SkipUsersIds || $[27] !== isNotAcceptable || $[28] !== onChange || $[29] !== t || $[30] !== value) {
    t8 = isNotAcceptable ? /* @__PURE__ */ jsxRuntimeExports.jsx(Text, { fz: "xs", color: "brandGray.0", children: t("users.noRightsToDelete") }) : /* @__PURE__ */ jsxRuntimeExports.jsx(TransferData, { userId: value.id, onChange: (transferUserId) => onChange({
      ...value,
      transferUserId
    }), SkipUsersIds });
    $[26] = SkipUsersIds;
    $[27] = isNotAcceptable;
    $[28] = onChange;
    $[29] = t;
    $[30] = value;
    $[31] = t8;
  } else {
    t8 = $[31];
  }
  let t9;
  if ($[32] !== classes.transferInfo || $[33] !== t8) {
    t9 = /* @__PURE__ */ jsxRuntimeExports.jsx(Flex, { className: classes.transferInfo, children: t8 });
    $[32] = classes.transferInfo;
    $[33] = t8;
    $[34] = t9;
  } else {
    t9 = $[34];
  }
  let t10;
  if ($[35] !== classes.itemContainer || $[36] !== t7 || $[37] !== t9) {
    t10 = /* @__PURE__ */ jsxRuntimeExports.jsxs(Flex, { py: 12, gap: "6px", className: classes.itemContainer, children: [
      t7,
      t9
    ] });
    $[35] = classes.itemContainer;
    $[36] = t7;
    $[37] = t9;
    $[38] = t10;
  } else {
    t10 = $[38];
  }
  return t10;
};
const useDeleteUsers = (setRowData, isMounted, scrollRef) => {
  const {
    t
  } = useTranslation();
  const navigate = useNavigate();
  const {
    setUsers
  } = useActions();
  const {
    filters,
    users
  } = useAppSelector((state) => state.users);
  const [modalLoadingStatus, setModalLoadingStatus] = reactExports.useState(false);
  const [fetchGetUsers] = useLazyGetUsersQuery();
  const [removeUsers, {
    isLoading
  }] = useRemoveUsersMutation();
  const [checkRemoveStatus] = useCheckRemoveStatusMutation();
  const [checkingStatus, setCheckingStatus] = reactExports.useState(false);
  const [percentageComplete, setPercentageComplete] = reactExports.useState(0);
  const {
    setUsersTableFilters
  } = useActions();
  const {
    clearUsersSelected
  } = useActions();
  async function waitUsersStatus(response) {
    var _a;
    let checkResponse = await checkRemoveStatus(response.data);
    setCheckingStatus(true);
    const updatePercentage = () => {
      var _a2, _b;
      if ("data" in checkResponse) {
        const completedUsers = (_a2 = checkResponse == null ? void 0 : checkResponse.data) == null ? void 0 : _a2.filter((item) => (item == null ? void 0 : item.Status) !== 0);
        const completedPercentage = ((completedUsers == null ? void 0 : completedUsers.length) ?? 0) / (((_b = checkResponse == null ? void 0 : checkResponse.data) == null ? void 0 : _b.length) ?? 1) * 100;
        setPercentageComplete(completedPercentage);
      }
    };
    updatePercentage();
    while ("data" in checkResponse && isMounted.current && ((_a = checkResponse == null ? void 0 : checkResponse.data) == null ? void 0 : _a.some((item_0) => (item_0 == null ? void 0 : item_0.Status) === 0))) {
      await new Promise((resolve) => setTimeout(resolve, 2e3));
      checkResponse = await checkRemoveStatus(response == null ? void 0 : response.data);
      updatePercentage();
    }
    return checkResponse;
  }
  function showDeleteNotifications(usersStatusResponse) {
    if (usersStatusResponse.data.some(
      (item_1) => item_1.Status === 1
      /* SUCCESS_STATUS */
    )) {
      universalNotification({
        isError: false,
        isSuccess: true,
        successTitle: t("users.deleteCompletedSuccessfully"),
        error: null
      });
      clearUsersSelected();
    }
    if (usersStatusResponse.data.some(
      (item_4) => item_4.Status === 2
      /* ERROR_STATUS */
    )) {
      const errorDeletingStatus = usersStatusResponse.data.filter(
        (item_2) => item_2.Status === 2
        /* ERROR_STATUS */
      );
      const errorUsersId = errorDeletingStatus.map((item_3) => item_3.UserId);
      const errorUserNames = users.filter((user) => errorUsersId.includes(user.Id)).map((user_0) => `${user_0.Surname} ${user_0.FirstName}`).join(", ");
      universalNotification({
        errorTitle: `${t("users.errorDuringDeletion")} :`,
        errorMessage: `${errorUserNames}`,
        isError: true,
        isSuccess: false,
        error: null
      });
    }
  }
  const handleDeleteUsers = reactExports.useCallback(async (data) => {
    var _a, _b;
    try {
      const response_0 = await removeUsers(data);
      if ("data" in response_0 && response_0.data) {
        const usersStatusResponse_0 = await waitUsersStatus(response_0);
        setCheckingStatus(false);
        clearApiCacheByTags(usersApi, ["Users"]);
        if ("data" in usersStatusResponse_0 && usersStatusResponse_0.data) {
          showDeleteNotifications(usersStatusResponse_0);
          (_b = (_a = scrollRef == null ? void 0 : scrollRef.current) == null ? void 0 : _a.el) == null ? void 0 : _b.scrollTo(0, 0);
          setUsersTableFilters({
            ...filters,
            Offset: 0
          });
          navigate(ROUTES.users.path);
          const {
            data: data_0
          } = await fetchGetUsers({
            Count: filters.Count,
            Offset: 0,
            SortOrder: filters.SortOrder,
            SortField: filters.SortField,
            Filters: filters.Filters,
            FilterConditions: filters.FilterConditions,
            Query: filters.Query
          });
          if (data_0) {
            setUsers(data_0);
            setRowData(data_0.Users);
          }
        } else if ("error" in usersStatusResponse_0) {
          universalNotification({
            error: usersStatusResponse_0 == null ? void 0 : usersStatusResponse_0.error,
            isError: true,
            isSuccess: false
          });
        }
      } else if ("error" in response_0) {
        universalNotification({
          error: response_0 == null ? void 0 : response_0.error,
          isError: true,
          isSuccess: false
        });
      }
    } catch (error) {
      console.error("Error:", error);
    }
  }, []);
  reactExports.useEffect(() => {
    if (checkingStatus || isLoading) {
      setModalLoadingStatus(true);
    }
  }, [checkingStatus, isLoading]);
  return {
    handleDeleteUsers,
    modalLoadingStatus,
    percentageComplete
  };
};
const DeleteUser = ({
  selectedUsers,
  isOpened,
  handleClose,
  setRowData,
  scrollRef
}) => {
  const {
    t
  } = useTranslation();
  const [userList, setUserList] = reactExports.useState([]);
  const [transferUser, setTransferUser] = reactExports.useState(null);
  const {
    classes
  } = useStyles$2();
  const {
    users
  } = useAppSelector((state) => state.users);
  const {
    User
  } = useAppSelector((state_0) => state_0.userInfo);
  const isMounted = reactExports.useRef(true);
  const {
    handleDeleteUsers,
    modalLoadingStatus,
    percentageComplete
  } = useDeleteUsers(setRowData, isMounted, scrollRef);
  const activeCheckbox = reactExports.useMemo(() => userList.filter((user) => user.isChecked && !user.isNotAcceptable), [userList]);
  const activeCheckboxLength = activeCheckbox.length;
  const selectedUserLength = selectedUsers == null ? void 0 : selectedUsers.length;
  const {
    setSelectedUserId
  } = useActions();
  const skipIdsForTransfer = userList.filter((user_0) => !user_0.isNotAcceptable).map((item) => item == null ? void 0 : item.id);
  reactExports.useEffect(() => {
    return () => {
      isMounted.current = false;
    };
  }, []);
  const canDeleteUser = (userForDelete) => {
    return (User == null ? void 0 : User.Id) !== (userForDelete == null ? void 0 : userForDelete.Id) && !(userForDelete == null ? void 0 : userForDelete.RoleTypes.includes(RoleTypesEnum.SuperUser));
  };
  const handleChange = (user_1) => {
    setUserList((prevUserList) => prevUserList.map((state_1) => {
      if (state_1.id === user_1.id) {
        return user_1;
      }
      return state_1;
    }));
  };
  const handleDeleteUser = async () => {
    const data = activeCheckbox.map((object) => {
      let transferId = transferUser ? [transferUser] : [];
      if (object.transferUserId) {
        transferId = [object.transferUserId];
      }
      return {
        UserId: object.id,
        TransferUserId: transferId
      };
    });
    try {
      await handleDeleteUsers(data);
      setSelectedUserId(0);
      handleClose();
    } catch (error) {
      console.error("Error:", error);
    }
  };
  const handleSelectedAll = () => {
    setUserList((prevList) => {
      let isChecked = true;
      if (activeCheckbox.some((active) => active.isChecked)) {
        isChecked = false;
      }
      return prevList.map((list) => ({
        ...list,
        isChecked: (list == null ? void 0 : list.isNotAcceptable) ? false : isChecked
      }));
    });
  };
  reactExports.useEffect(() => {
    const data_0 = users.filter((user_2) => selectedUsers == null ? void 0 : selectedUsers.includes(user_2.Id)).map((filtered) => ({
      isNotAcceptable: !canDeleteUser(filtered),
      isChecked: canDeleteUser(filtered),
      id: filtered.Id,
      FirstName: filtered == null ? void 0 : filtered.FirstName,
      SurName: filtered == null ? void 0 : filtered.Surname,
      email: filtered == null ? void 0 : filtered.Email,
      transferUserId: null,
      Avatar: filtered == null ? void 0 : filtered.Avatar
    }));
    setUserList(data_0);
  }, [selectedUsers]);
  const closeModal = (e) => {
    e == null ? void 0 : e.preventDefault();
    e == null ? void 0 : e.stopPropagation();
    handleClose();
  };
  return /* @__PURE__ */ jsxRuntimeExports.jsxs(Modal, { opened: isOpened, size: "lg", title: t("users.delete"), onClose: closeModal, withinPortal: true, children: [
    modalLoadingStatus && /* @__PURE__ */ jsxRuntimeExports.jsxs(Box, { className: classes.box, children: [
      /* @__PURE__ */ jsxRuntimeExports.jsx(Loader, {}),
      selectedUserLength > 2 && /* @__PURE__ */ jsxRuntimeExports.jsx(Progress, { value: percentageComplete, className: classes.progress }),
      /* @__PURE__ */ jsxRuntimeExports.jsx(Text, { c: "brandGray.0", fz: "sm", children: t("users.deleteTime") })
    ] }),
    /* @__PURE__ */ jsxRuntimeExports.jsxs(Container, { className: modalLoadingStatus ? classes.transparent : "", px: "md", pt: 12, children: [
      /* @__PURE__ */ jsxRuntimeExports.jsx(Text, { fz: "sm", mb: "sm", children: t("users.deleteSelected") }),
      /* @__PURE__ */ jsxRuntimeExports.jsx(Text, { fz: "sm", lh: "17px", mb: "md", children: t("users.deleteInfo") }),
      /* @__PURE__ */ jsxRuntimeExports.jsx(Text, { c: "brandGray.0", fz: "xs", mb: 12, lh: 1, children: t("users.chooseTransfer") }),
      /* @__PURE__ */ jsxRuntimeExports.jsx(TransferData, { userId: -1, nameButton: t("users.userTransfer"), onChange: setTransferUser, SkipUsersIds: skipIdsForTransfer }),
      /* @__PURE__ */ jsxRuntimeExports.jsx(Space, { h: "sm" }),
      /* @__PURE__ */ jsxRuntimeExports.jsxs("ul", { className: classes.list, children: [
        /* @__PURE__ */ jsxRuntimeExports.jsx("li", { className: classes.header, children: /* @__PURE__ */ jsxRuntimeExports.jsxs(Flex, { className: classes.headerElem, children: [
          /* @__PURE__ */ jsxRuntimeExports.jsxs(Flex, { gap: "xs", className: classes.select, children: [
            /* @__PURE__ */ jsxRuntimeExports.jsx(Checkbox, { checked: activeCheckboxLength === selectedUserLength, indeterminate: !!activeCheckboxLength && activeCheckboxLength !== selectedUserLength, size: "xs", onChange: handleSelectedAll }),
            /* @__PURE__ */ jsxRuntimeExports.jsx(Text, { fz: "xs", c: "brandGray.0", children: t("profile.user") })
          ] }),
          /* @__PURE__ */ jsxRuntimeExports.jsx(Flex, { className: classes.transferInfo, children: /* @__PURE__ */ jsxRuntimeExports.jsx(Text, { fz: "xs", c: "brandGray.0", children: t("users.userTransfer") }) })
        ] }) }),
        userList == null ? void 0 : userList.map((user_3) => /* @__PURE__ */ jsxRuntimeExports.jsx("li", { children: /* @__PURE__ */ jsxRuntimeExports.jsx(ListItem, { isSelectedMultiple: true, value: user_3, onChange: handleChange, SkipUsersIds: [user_3 == null ? void 0 : user_3.id, ...skipIdsForTransfer] }) }, user_3.id))
      ] }),
      /* @__PURE__ */ jsxRuntimeExports.jsx(Space, { h: "sm" }),
      /* @__PURE__ */ jsxRuntimeExports.jsx(Text, { fz: "sm", lh: "17px", mb: "md", children: t("users.transferInfo") })
    ] }),
    /* @__PURE__ */ jsxRuntimeExports.jsx(Controls, { children: /* @__PURE__ */ jsxRuntimeExports.jsxs(Group, { className: modalLoadingStatus ? classes.transparent : "", grow: true, children: [
      /* @__PURE__ */ jsxRuntimeExports.jsx(Button, { variant: "default", bg: "brandGray.1", onClick: closeModal, children: t("cancel") }),
      /* @__PURE__ */ jsxRuntimeExports.jsxs(Button, { disabled: !activeCheckboxLength, color: "red", bg: "#C23939", onClick: handleDeleteUser, children: [
        t("delete"),
        " ",
        activeCheckboxLength ? `(${activeCheckboxLength})` : ""
      ] })
    ] }) })
  ] });
};
const useStyles$1 = createStyles((theme) => ({
  modalRoot: modalTheme(theme).root,
  modalContainer: {
    ...modalTheme(theme).container,
    wordBreak: "break-word"
  },
  modalFooter: modalTheme(theme).footer,
  root: {
    width: "100%",
    height: "100%",
    display: "flex",
    flexDirection: "column",
    alignItems: "center",
    justifyContent: "space-between"
  },
  Content: {
    width: "100%"
  },
  title: {
    width: "100%"
  },
  description: {
    width: "100%"
  }
}));
const useLoginAs = () => {
  const {
    t
  } = useTranslation();
  const [loginAsRequest, {
    isFetching: isFetchingLoginAs,
    isSuccess
  }] = useLazyLoginAsQuery();
  const handleLoginAs = reactExports.useCallback(async ({
    Login,
    LoginAs,
    Password,
    handleUpdate
  }) => {
    try {
      const res = await loginAsRequest({
        Login,
        LoginAs,
        Password
      });
      if ("error" in res) {
        const codeError = extractErrorCode(res.error);
        universalNotification({
          error: res.error,
          errorTitle: res.error && "status" in res.error && res.error.status === 401 ? t("login.errors.wrongPassword") : generateErrorMessage(codeError),
          isError: true,
          isSuccess: false
        });
      } else {
        window.location.href = ROUTES.dashboard.fullPath;
        if (handleUpdate) {
          handleUpdate();
        }
      }
    } catch (error) {
      console.error(error);
    }
  }, []);
  return {
    handleLoginAs,
    isFetchingLoginAs,
    isSuccess
  };
};
const LoginAsModalContent = (t0) => {
  const $ = compilerRuntimeExports.c(55);
  const {
    setOpen,
    loginAs,
    login
  } = t0;
  const {
    classes,
    theme
  } = useStyles$1();
  const {
    t
  } = useTranslation();
  const {
    isFetchingLoginAs,
    handleLoginAs,
    isSuccess
  } = useLoginAs();
  let t1;
  if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
    t1 = {
      Password: ""
    };
    $[0] = t1;
  } else {
    t1 = $[0];
  }
  const dataForm = t1;
  let t2;
  if ($[1] !== t) {
    t2 = objectType({
      Password: stringType().min(1, {
        message: t("login.errors.emptyPassword")
      })
    });
    $[1] = t;
    $[2] = t2;
  } else {
    t2 = $[2];
  }
  const validateScheme = t2;
  let t3;
  if ($[3] !== validateScheme) {
    t3 = {
      initialValues: dataForm,
      validateInputOnChange: true,
      validate: (values) => getValidateErrors(validateScheme, values)
    };
    $[3] = validateScheme;
    $[4] = t3;
  } else {
    t3 = $[4];
  }
  const form = useForm(t3);
  let t4;
  if ($[5] !== form) {
    t4 = Object.keys(form.errors).length !== 0 || !form.isDirty();
    $[5] = form;
    $[6] = t4;
  } else {
    t4 = $[6];
  }
  const isDisabled = t4;
  let t5;
  if ($[7] !== setOpen) {
    t5 = () => {
      setOpen(false);
    };
    $[7] = setOpen;
    $[8] = t5;
  } else {
    t5 = $[8];
  }
  const handleUpdate = t5;
  let t6;
  if ($[9] !== form || $[10] !== handleLoginAs || $[11] !== handleUpdate || $[12] !== isSuccess || $[13] !== login || $[14] !== loginAs) {
    t6 = async (values_0) => {
      await handleLoginAs({
        Login: login || "",
        LoginAs: loginAs,
        Password: values_0.Password,
        handleUpdate
      });
      if (!isSuccess) {
        form.resetDirty();
      }
    };
    $[9] = form;
    $[10] = handleLoginAs;
    $[11] = handleUpdate;
    $[12] = isSuccess;
    $[13] = login;
    $[14] = loginAs;
    $[15] = t6;
  } else {
    t6 = $[15];
  }
  const onSubmit = t6;
  let t7;
  if ($[16] !== form || $[17] !== onSubmit) {
    t7 = form.onSubmit(onSubmit);
    $[16] = form;
    $[17] = onSubmit;
    $[18] = t7;
  } else {
    t7 = $[18];
  }
  const t8 = classes.modalRoot;
  const t9 = classes.modalContainer;
  let t10;
  if ($[19] !== loginAs) {
    t10 = /* @__PURE__ */ jsxRuntimeExports.jsx(Trans, { i18nKey: "profile.loginAsHint", values: {
      LoginAs: loginAs
    } });
    $[19] = loginAs;
    $[20] = t10;
  } else {
    t10 = $[20];
  }
  let t11;
  if ($[21] !== t10 || $[22] !== theme.spacing.sm) {
    t11 = /* @__PURE__ */ jsxRuntimeExports.jsx(Text, { mb: theme.spacing.sm, children: t10 });
    $[21] = t10;
    $[22] = theme.spacing.sm;
    $[23] = t11;
  } else {
    t11 = $[23];
  }
  const t12 = classes.title;
  let t13;
  if ($[24] !== t) {
    t13 = t("login.password");
    $[24] = t;
    $[25] = t13;
  } else {
    t13 = $[25];
  }
  let t14;
  if ($[26] !== t) {
    t14 = t("profile.enterPassword");
    $[26] = t;
    $[27] = t14;
  } else {
    t14 = $[27];
  }
  let t15;
  if ($[28] !== form) {
    t15 = form.getInputProps("Password");
    $[28] = form;
    $[29] = t15;
  } else {
    t15 = $[29];
  }
  let t16;
  if ($[30] !== classes.title || $[31] !== t13 || $[32] !== t14 || $[33] !== t15) {
    t16 = /* @__PURE__ */ jsxRuntimeExports.jsx(PasswordInput, { className: t12, required: true, label: t13, placeholder: t14, "data-autofocus": true, ...t15 });
    $[30] = classes.title;
    $[31] = t13;
    $[32] = t14;
    $[33] = t15;
    $[34] = t16;
  } else {
    t16 = $[34];
  }
  let t17;
  if ($[35] !== classes.modalContainer || $[36] !== t11 || $[37] !== t16) {
    t17 = /* @__PURE__ */ jsxRuntimeExports.jsxs(Box, { className: t9, children: [
      t11,
      t16
    ] });
    $[35] = classes.modalContainer;
    $[36] = t11;
    $[37] = t16;
    $[38] = t17;
  } else {
    t17 = $[38];
  }
  const t18 = classes.modalFooter;
  let t19;
  if ($[39] !== t) {
    t19 = t("send");
    $[39] = t;
    $[40] = t19;
  } else {
    t19 = $[40];
  }
  let t20;
  if ($[41] !== isDisabled || $[42] !== isFetchingLoginAs || $[43] !== t19) {
    t20 = /* @__PURE__ */ jsxRuntimeExports.jsx(Button, { loading: isFetchingLoginAs, fullWidth: true, type: "submit", disabled: isDisabled, children: t19 });
    $[41] = isDisabled;
    $[42] = isFetchingLoginAs;
    $[43] = t19;
    $[44] = t20;
  } else {
    t20 = $[44];
  }
  let t21;
  if ($[45] !== classes.modalFooter || $[46] !== t20) {
    t21 = /* @__PURE__ */ jsxRuntimeExports.jsx(Box, { className: t18, children: t20 });
    $[45] = classes.modalFooter;
    $[46] = t20;
    $[47] = t21;
  } else {
    t21 = $[47];
  }
  let t22;
  if ($[48] !== classes.modalRoot || $[49] !== t17 || $[50] !== t21) {
    t22 = /* @__PURE__ */ jsxRuntimeExports.jsxs(Group, { className: t8, justify: "center", children: [
      t17,
      t21
    ] });
    $[48] = classes.modalRoot;
    $[49] = t17;
    $[50] = t21;
    $[51] = t22;
  } else {
    t22 = $[51];
  }
  let t23;
  if ($[52] !== t22 || $[53] !== t7) {
    t23 = /* @__PURE__ */ jsxRuntimeExports.jsx("form", { onSubmit: t7, children: t22 });
    $[52] = t22;
    $[53] = t7;
    $[54] = t23;
  } else {
    t23 = $[54];
  }
  return t23;
};
const useStyles = createStyles((theme) => ({
  modalContainer: modalTheme(theme).container,
  modalFooter: modalTheme(theme).footer,
  modalCancelBtn: modalTheme(theme).cancelBtn,
  root: {
    width: "100%",
    height: "100%",
    display: "flex",
    flexDirection: "column"
  },
  title: {
    width: "100%"
  },
  description: {
    width: "100%"
  }
}));
const SendMailModal = ({
  setOpenModal,
  selection
}) => {
  const {
    classes
  } = useStyles();
  const {
    t
  } = useTranslation();
  const [fetchSendEmail, {
    isLoading
  }] = useLazySendEmailServerQuery();
  const dataForm = {
    Subject: "",
    Body: "",
    UserIds: []
  };
  const validateScheme = objectType({
    Subject: stringType().min(1, {
      message: t("sendLetter.errors.noSubject")
    }),
    Body: stringType().min(1, {
      message: t("sendLetter.errors.noText")
    })
  });
  const form = useForm({
    initialValues: dataForm,
    validateInputOnChange: true,
    validate: (values) => getValidateErrors(validateScheme, values)
  });
  const isDisabled = Object.keys(form.errors).length !== 0 || !form.isDirty();
  const onSubmit = async (values_0) => {
    var _a;
    const data = {
      ...values_0,
      UserIds: selection
    };
    try {
      const res = await fetchSendEmail(data);
      if (res.error) {
        if ("data" in res.error) {
          const data_0 = (_a = res.error) == null ? void 0 : _a.data;
          const errorMessage = generateErrorMessage(data_0.ErrorCode);
          showNotification({
            title: t("sendLetter.errors.notSent"),
            message: errorMessage,
            autoClose: true,
            color: "red"
          });
        }
      } else {
        setOpenModal(false);
        showNotification({
          title: t(`sendLetter.${(selection == null ? void 0 : selection.length) === 1 ? "successOne" : "successMultiple"}`),
          message: "",
          autoClose: true,
          color: "green"
        });
        form.reset();
      }
    } catch (err) {
      console.warn(t("sendLetter.errors.notSent"), err);
    }
  };
  const handleClose = () => {
    setOpenModal(false);
    form.reset();
  };
  return /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
    /* @__PURE__ */ jsxRuntimeExports.jsxs("form", { className: classes.root, onSubmit: form.onSubmit(onSubmit), children: [
      /* @__PURE__ */ jsxRuntimeExports.jsx(Box, { py: "16px", px: "24px", children: /* @__PURE__ */ jsxRuntimeExports.jsxs(Group, { justify: "center", children: [
        /* @__PURE__ */ jsxRuntimeExports.jsx(TextInput, { className: classes.title, label: t("sendLetter.subject"), placeholder: t("sendLetter.subjectPlaceholder"), "data-autofocus": true, ...form.getInputProps("Subject") }),
        /* @__PURE__ */ jsxRuntimeExports.jsx(Textarea, { className: classes.description, autosize: true, minRows: 2, ...form.getInputProps("Body") })
      ] }) }),
      /* @__PURE__ */ jsxRuntimeExports.jsxs(Box, { className: classes.modalFooter, children: [
        /* @__PURE__ */ jsxRuntimeExports.jsx(Button, { w: "49%", type: "submit", disabled: isDisabled, children: t("send") }),
        /* @__PURE__ */ jsxRuntimeExports.jsx(UnstyledButton, { w: "49%", className: classes.modalCancelBtn, onClick: () => handleClose(), children: t("cancel") })
      ] })
    ] }),
    /* @__PURE__ */ jsxRuntimeExports.jsx(LoadingOverlay, { visible: isLoading, overlayProps: {
      blur: 2
    } })
  ] });
};
const Action = ({
  item,
  setRowData,
  hasIconEye = true,
  scrollRef,
  loginAsUser
}) => {
  const navigate = useNavigate();
  const {
    t
  } = useTranslation();
  const User = useAppSelector((state) => {
    var _a;
    return (_a = state == null ? void 0 : state.userInfo) == null ? void 0 : _a.User;
  });
  const {
    users
  } = useAppSelector((state_0) => state_0.users);
  const {
    handleCheckCustomerServerSettings
  } = useVerifyEmailAndOpenModal();
  const [opened, {
    close,
    open
  }] = useDisclosure(false);
  const {
    setSelectedUserId
  } = useActions();
  const [selectOwnerModal, setSelectOwnerModal] = reactExports.useState(false);
  const [selectedUser, setSelectedUser] = reactExports.useState({});
  const [openDeleteUsersModal, setOpenDeleteUsersModal] = reactExports.useState(false);
  const [openAddRolesModal, setOpenAddRolesModal] = reactExports.useState(false);
  const [openSendEmailModal, setOpenSendEmailModal] = reactExports.useState(false);
  const [openConfirmEmailModal, setOpenConfirmEmailModal] = reactExports.useState(false);
  const [openLoginAsModal, setOpenLoginAsModal] = reactExports.useState(false);
  const [selectedRoles, setSelectedRoles] = reactExports.useState({});
  const [groups, setGroups] = reactExports.useState([]);
  const {
    handleAddRoles
  } = useAddRoles([item == null ? void 0 : item.Id], setRowData);
  const {
    changeStatuses
  } = useChangeStatuses(setRowData);
  const {
    closeSessions
  } = useTerminateSessions();
  const closeAddRolesModal = () => {
    setOpenAddRolesModal(false);
  };
  const handleOpenAddRolesModal = () => {
    setOpenAddRolesModal(true);
  };
  const handleOpenDeleteUsersModal = () => {
    setOpenDeleteUsersModal(true);
  };
  const handleCloseDeleteUsersModal = () => {
    setOpenDeleteUsersModal(false);
  };
  const handleAddRole = (roles) => {
    const rolesIds = roles == null ? void 0 : roles.map((role) => role.Id);
    handleAddRoles([item == null ? void 0 : item.Id], rolesIds);
    setOpenAddRolesModal(false);
  };
  const goEditUser = (id, event) => {
    event == null ? void 0 : event.stopPropagation();
    navigate(`/profile/${id}`);
  };
  const handleOpenConfirmModal = () => {
    setOpenConfirmEmailModal(true);
  };
  const handleOpenSendEmailModal = () => {
    setOpenSendEmailModal(true);
  };
  const onClickItem = reactExports.useCallback(async (event_0) => {
    var _a, _b;
    close();
    event_0.preventDefault();
    event_0.stopPropagation();
    const value = event_0.currentTarget.dataset.value ?? "";
    switch (value) {
      case ActionUserMenuEnum.loginAs:
        setOpenLoginAsModal(true);
        break;
      case ActionUserMenuEnum.activateEmail:
        await handleCheckCustomerServerSettings((_a = item == null ? void 0 : item.Customer) == null ? void 0 : _a.Id, handleOpenConfirmModal);
        break;
      case ActionUserMenuEnum.block:
        await changeStatuses([item == null ? void 0 : item.Id], UserStatusEnum.Ban);
        break;
      case ActionUserMenuEnum.addRole:
        handleOpenAddRolesModal();
        break;
      case ActionUserMenuEnum.writeLetter:
        await handleCheckCustomerServerSettings((_b = item == null ? void 0 : item.Customer) == null ? void 0 : _b.Id, handleOpenSendEmailModal);
        break;
      case ActionUserMenuEnum.editUser:
        goEditUser(item == null ? void 0 : item.Id);
        break;
      case ActionUserMenuEnum.unblock:
        await changeStatuses([item == null ? void 0 : item.Id], UserStatusEnum.Active);
        break;
      case ActionUserMenuEnum.terminateAll:
        await closeSessions({
          userId: (item == null ? void 0 : item.Id) || null
        });
        break;
      case ActionUserMenuEnum.deleteUser:
        handleOpenDeleteUsersModal();
        break;
      case ActionUserMenuEnum.deletePersonalData:
        break;
      case ActionUserMenuEnum.transferData:
        break;
    }
  }, [item]);
  const handleClickShowInfo = reactExports.useCallback(async (event_1) => {
    event_1.preventDefault();
    event_1.nativeEvent.stopPropagation();
    setSelectedUserId(item == null ? void 0 : item.Id);
  }, [item]);
  const handleContextMenu = (event_2) => {
    event_2.preventDefault();
    event_2.stopPropagation();
    close();
  };
  const handleClick = (event_3) => {
    event_3.preventDefault();
    event_3.stopPropagation();
    if (opened) {
      close();
      return;
    }
    open();
  };
  const closeSelectOwnerModal = () => {
    setSelectOwnerModal(false);
  };
  const isEmailConfirmed = () => {
    var _a;
    if (hasIconEye) {
      return item == null ? void 0 : item.IsConfirmed;
    } else {
      return (_a = item == null ? void 0 : item.Credentials) == null ? void 0 : _a.IsConfirmed;
    }
  };
  reactExports.useEffect(() => {
    const selectedUser_0 = users.find((user) => (user == null ? void 0 : user.Id) === (item == null ? void 0 : item.Id));
    setGroups((selectedUser_0 == null ? void 0 : selectedUser_0.Roles) || []);
  }, [item == null ? void 0 : item.Id, users]);
  const showLoginAs = () => {
    var _a, _b;
    if (hasIconEye) {
      return (item == null ? void 0 : item.Id) !== (User == null ? void 0 : User.Id) && !((_a = item == null ? void 0 : item.RoleTypes) == null ? void 0 : _a.some((roleType) => roleType === RoleTypesEnum.Admin || roleType === RoleTypesEnum.SuperUser));
    } else {
      return (item == null ? void 0 : item.Id) !== (User == null ? void 0 : User.Id) && !((_b = item == null ? void 0 : item.Roles) == null ? void 0 : _b.some((role_0) => (role_0 == null ? void 0 : role_0.Type) === RoleTypesEnum.Admin || (role_0 == null ? void 0 : role_0.Type) === RoleTypesEnum.SuperUser));
    }
  };
  const showDelete = () => {
    var _a, _b;
    if (hasIconEye) {
      return (item == null ? void 0 : item.Id) !== (User == null ? void 0 : User.Id) && !((_a = item == null ? void 0 : item.RoleTypes) == null ? void 0 : _a.some((roleType_0) => roleType_0 === RoleTypesEnum.SuperUser));
    } else {
      return (item == null ? void 0 : item.Id) !== (User == null ? void 0 : User.Id) && !((_b = item == null ? void 0 : item.Roles) == null ? void 0 : _b.some((role_1) => (role_1 == null ? void 0 : role_1.Type) === RoleTypesEnum.SuperUser));
    }
  };
  const showChangeStatus = () => {
    var _a, _b;
    const isLoggedAsSuperUser = User == null ? void 0 : User.Roles.some((role_2) => role_2.Type === RoleTypesEnum.SuperUser);
    if (hasIconEye) {
      const hasNoSuperUserRole = !((_a = item == null ? void 0 : item.RoleTypes) == null ? void 0 : _a.some((roleType_1) => roleType_1 === RoleTypesEnum.SuperUser));
      return (item == null ? void 0 : item.Id) !== (User == null ? void 0 : User.Id) && (isLoggedAsSuperUser || hasNoSuperUserRole);
    } else {
      const hasNoSuperUserRole_0 = !((_b = item == null ? void 0 : item.Roles) == null ? void 0 : _b.some((role_3) => (role_3 == null ? void 0 : role_3.Type) === RoleTypesEnum.SuperUser));
      return (item == null ? void 0 : item.Id) !== (User == null ? void 0 : User.Id) && (isLoggedAsSuperUser || hasNoSuperUserRole_0);
    }
  };
  let popoverList = actionMenu(item == null ? void 0 : item.Status, {
    showDeleteItem: showDelete(),
    showLoginAsItem: showLoginAs(),
    showChangeStatusItem: showChangeStatus()
  });
  if (hasIconEye) {
    popoverList = popoverList.filter((item_0) => item_0.value !== ActionUserMenuEnum.terminateAll);
  }
  const ref = useClickOutside(() => opened && close());
  return /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
    /* @__PURE__ */ jsxRuntimeExports.jsxs(Group, { gap: 4, justify: "flex-end", wrap: "nowrap", children: [
      /* @__PURE__ */ jsxRuntimeExports.jsx(ActionIcon, { className: "action-icon", "data-action": "action", onClick: (event_4) => goEditUser(item == null ? void 0 : item.Id, event_4), "data-cy": "editProfile", children: /* @__PURE__ */ jsxRuntimeExports.jsx(EditProfileIcon, { size: 24 }) }),
      hasIconEye && /* @__PURE__ */ jsxRuntimeExports.jsx(ActionIcon, { className: "action-icon", onClick: handleClickShowInfo, "data-action": "action", "data-cy": "viewDetails", children: /* @__PURE__ */ jsxRuntimeExports.jsx(_Z, { size: "1.5rem", color: "#667085", stroke: 1.5, style: {
        pointerEvents: "none"
      } }) }),
      /* @__PURE__ */ jsxRuntimeExports.jsx(PopoverMenu, { opened, onClickItem, closeOnClickOutside: true, list: popoverList, position: "left-start", onClose: close, email: item == null ? void 0 : item.Email, isConfirmed: isEmailConfirmed(), children: /* @__PURE__ */ jsxRuntimeExports.jsx(ActionIcon, { ref, className: "action-icon", "data-action": "action", onClick: handleClick, onContextMenu: handleContextMenu, "data-cy": "moreActions", children: /* @__PURE__ */ jsxRuntimeExports.jsx(CX, { color: "#667085", "data-action": "action" }) }) })
    ] }),
    /* @__PURE__ */ jsxRuntimeExports.jsx(SelectUserModal, { multipleUsers: false, isOpened: selectOwnerModal, title: t("users.addGroupOwner"), onClose: closeSelectOwnerModal, setSelectedUsers: setSelectedUser, userId: selectedUser.Id, controlSection: true }),
    openDeleteUsersModal && /* @__PURE__ */ jsxRuntimeExports.jsx(DeleteUser, { isOpened: openDeleteUsersModal, selectedUsers: [item == null ? void 0 : item.Id], handleClose: handleCloseDeleteUsersModal, setRowData, scrollRef }),
    openAddRolesModal && /* @__PURE__ */ jsxRuntimeExports.jsx(SelectGroupModal, { isOpened: openAddRolesModal, title: t("profile.addRole"), onClose: closeAddRolesModal, setSelectedGroup: setSelectedRoles, selectedGroup: selectedRoles, setGroups: handleAddRole, groups }),
    openSendEmailModal && /* @__PURE__ */ jsxRuntimeExports.jsx(Modal, { size: "500px", zIndex: 1400, opened: openSendEmailModal, onClose: () => setOpenSendEmailModal(false), title: t("sendLetter.newLetter"), children: /* @__PURE__ */ jsxRuntimeExports.jsx(SendMailModal, { setOpenModal: setOpenSendEmailModal, selection: [item == null ? void 0 : item.Id] }) }),
    openConfirmEmailModal && /* @__PURE__ */ jsxRuntimeExports.jsx(OneUserActivationModal, { open: openConfirmEmailModal, handleClose: () => setOpenConfirmEmailModal(false), selectedUsers: [item == null ? void 0 : item.Id], email: item == null ? void 0 : item.Email }),
    /* @__PURE__ */ jsxRuntimeExports.jsx(Modal, { withinPortal: true, opened: openLoginAsModal, onClose: () => setOpenLoginAsModal(false), title: /* @__PURE__ */ jsxRuntimeExports.jsx(Text, { fz: "md", children: t("profile.loginAs") }), children: /* @__PURE__ */ jsxRuntimeExports.jsx(LoginAsModalContent, { setOpen: setOpenLoginAsModal, loginAs: loginAsUser ?? (item == null ? void 0 : item.Login), login: User == null ? void 0 : User.Login }) })
  ] });
};
export {
  Action as A,
  DeleteUser as D,
  LoginAsModalContent as L,
  Panels as P,
  SendMailModal as S,
  PopoverMenu as a,
  useChangeStatuses as u
};
//# sourceMappingURL=index-leRPH4yM.js.map
