import { E as compilerRuntimeExports, j as jsxRuntimeExports, r as reactExports, L as Link, T as useNavigate, a0 as useParams, V as Outlet } from "./vendor-react-DYNCg6N5.js";
import { n as numberToUserStatus, g as getColorsByRole, f as useGetDefaultUserFiltersQuery, I as IFiltersEnumType, h as filtersLabelsKeys, b as useActions, c as useAppSelector, j as useChangeRolesMutation, l as useLazyGetUsersQuery, m as universalNotification, o as useLazyBulkForgotQuery, S as ScrollContainer, U as UserStatusEnum, p as useBulkChangeFilialMutation, q as useLazyVerifyEmailServersQuery, t as extractErrorCode, v as generateErrorMessage, w as getUsersIdBySelect, x as styleScroll, R as ROUTES, P as PanelsEnum, H as HEADER_HEIGHT, y as SearchIcon, z as transformConditionals, A as useGetUsersQuery, B as convertToFilterConditions, E as ErrorBoundary, L as Layout, C as transformNumberToUsersSortField, D as transformUsersSortFieldToNumber } from "./index-DfebxkL9.js";
import { d as Checkbox, c as createStyles, b as Box, T as Text, F as Flex, k as Tooltip, M as Menu, B as Button, R as Radio, S as Stack, K as Divider, O as Badge, s as showNotification, n as useDisclosure, l as ScrollArea, Q as Collapse, h as ActionIcon, U as UnstyledButton, V as LoadingOverlay, W as useMediaQuery, X as Drawer } from "./vendor-mantine-h0WlM2Mj.js";
import { I as ItemUser, F as FilialsControl, U as UsersFilterList } from "./options-CRIRDAK6.js";
import { A as Action, S as SendMailModal, u as useChangeStatuses, D as DeleteUser, P as Panels } from "./index-leRPH4yM.js";
import { f as formatDate } from "./date-bOIw2uwV.js";
import { E as EllipsisTooltip } from "./index-D4BAIihc.js";
import { f as formatByteToGb, a as formatDataSizeUnits } from "./format-CMT-x-V3.js";
import { E as EmailActivationControl, u as useEmailActivation } from "./useTerminateSessions-Cb3ukMTY.js";
import { u as useTranslation } from "./vendor-i18n-wisIXUFi.js";
import { S as SimpleTable } from "./index-DOqL4InQ.js";
import { b as gq, z as zq, S as Se, X as XMe } from "./vendor-icons-xWhXK_Ui.js";
import { U as UsersActionTableEnum } from "./useUpdateUser-innD962A.js";
import { d as downloadCsv } from "./index-zpOhy7mV.js";
import { G as GroupItem, S as SelectGroupModal } from "./index-Ds4Bnwmy.js";
import { u as useAddRoles } from "./index-woYEqWvh.js";
import { M as Modal } from "./index-DqcA8P_y.js";
import { m as modalTheme } from "./styles-3NoIlzov.js";
import { T as TableColumnsAction } from "./index-lR9_AURi.js";
import { S as Search } from "./index-CcqTjOWY.js";
import { u as useDebounce } from "./useDebounce-DTubzIUC.js";
import { C as CreateUserModal } from "./index-C7llsr9G.js";
import { F as FilterSkeleton } from "./index-DppR1vQX.js";
import "./index-C-CFogWu.js";
import "./index-3c9En-DB.js";
import "./index-CfN7Ll0p.js";
import "./errorIcon-PZO0f1IY.js";
import "./index.es-BTZFX8B-.js";
import "./index-C6QQOvbB.js";
import "./index-C_Fw_IUU.js";
import "./index-_NgMYV3i.js";
import "./index-TL41xEJi.js";
import "./index-B7nmdYVM.js";
import "./utils-D5kCyTRM.js";
import "./types-B9VC9FeZ.js";
import "./index-DFEP7Sv_.js";
import "./index-DMTgSMwy.js";
import "./validation-Ds00Zghx.js";
import "./types-espwwxTQ.js";
import "./useCopyToClipboard-C-S2RacD.js";
import "./styles-BC5VOxAU.js";
import "./index-Zaude47i.js";
import "./papaparse.min-Ds9XhCoe.js";
import "./validate-Bw-sUlFj.js";
import "./useGeneratePolicy-B4rO5xUa.js";
import "./passwordUtils-B3CN2t6O.js";
import "./index-CNv4hlnY.js";
import "./index-B9yUPW9X.js";
import "./ru-Bush41s2.js";
import "./index-CUcivY9l.js";
import "./index-BvQfhnV_.js";
import "./styles-C9HVNQJ0.js";
import "./index-72JBTuLT.js";
import "./index-DnphFLKH.js";
import "./index-CslanKI5.js";
import "./styles-Dnu4P1Zm.js";
import "./index-C2HWmCvh.js";
import "./index-BWhdniX1.js";
import "./index-BoQKW1g7.js";
import "./index-CEv9Eejp.js";
import "./validateTextInput-2E2Z5K9Z.js";
import "./index-DFZKJmic.js";
import "./index-DOixMRp5.js";
import "./passwordOptions-b-kjbiiT.js";
const CustomCheckbox = (t0) => {
  const $ = compilerRuntimeExports.c(8);
  const {
    selection,
    toggleRow,
    item
  } = t0;
  const handleClick = _temp$6;
  const t1 = item == null ? void 0 : item.Id;
  let t2;
  if ($[0] !== (item == null ? void 0 : item.Id) || $[1] !== selection) {
    t2 = selection && selection.includes(item == null ? void 0 : item.Id);
    $[0] = item == null ? void 0 : item.Id;
    $[1] = selection;
    $[2] = t2;
  } else {
    t2 = $[2];
  }
  let t3;
  if ($[3] === Symbol.for("react.memo_cache_sentinel")) {
    t3 = {
      "& input": {
        cursor: "pointer"
      }
    };
    $[3] = t3;
  } else {
    t3 = $[3];
  }
  let t4;
  if ($[4] !== t1 || $[5] !== t2 || $[6] !== toggleRow) {
    t4 = /* @__PURE__ */ jsxRuntimeExports.jsx(Checkbox, { "data-id": t1, checked: t2, onChange: toggleRow, onClick: handleClick, "data-cy": "selectUserCheckbox", sx: t3 });
    $[4] = t1;
    $[5] = t2;
    $[6] = toggleRow;
    $[7] = t4;
  } else {
    t4 = $[7];
  }
  return t4;
};
function _temp$6(event) {
  event.stopPropagation();
}
const useStyles$a = createStyles((theme) => ({
  rounded: {
    fontSize: "14px",
    lineHeight: "125%",
    fontWeight: "normal",
    width: "fit-content",
    border: "none",
    display: "block",
    borderRadius: "34px",
    backgroundColor: theme.colors.backgroundGray[2],
    padding: "8px 12px",
    margin: "4px"
  },
  listGroup: {
    width: "100%",
    display: "flex",
    flexWrap: "wrap",
    backgroundColor: "transparent"
  }
}));
const RolesList = (t0) => {
  const $ = compilerRuntimeExports.c(6);
  const {
    roles
  } = t0;
  const {
    classes
  } = useStyles$a();
  if (!Array.isArray(roles)) {
    return null;
  }
  let t1;
  if ($[0] !== classes.rounded || $[1] !== roles) {
    t1 = roles == null ? void 0 : roles.slice(0, 5).map((role, index) => /* @__PURE__ */ jsxRuntimeExports.jsx(EllipsisTooltip, { "data-text": role == null ? void 0 : role.Name, className: classes.rounded, width: 100, children: role == null ? void 0 : role.Name }, index));
    $[0] = classes.rounded;
    $[1] = roles;
    $[2] = t1;
  } else {
    t1 = $[2];
  }
  let t2;
  if ($[3] !== classes.listGroup || $[4] !== t1) {
    t2 = /* @__PURE__ */ jsxRuntimeExports.jsx(Box, { className: classes.listGroup, children: t1 });
    $[3] = classes.listGroup;
    $[4] = t1;
    $[5] = t2;
  } else {
    t2 = $[5];
  }
  return t2;
};
const useStyles$9 = createStyles(() => ({
  content: {
    height: "100%",
    width: "100%",
    display: "flex",
    alignItems: "flex-start",
    justifyContent: "space-between",
    flexDirection: "column"
  },
  text: {
    wordBreak: "break-word",
    span: {
      display: "block"
    }
  }
}));
const ParentUserNames = (t0) => {
  const $ = compilerRuntimeExports.c(6);
  const {
    item
  } = t0;
  const {
    classes
  } = useStyles$9();
  let t1;
  if ($[0] !== classes.text || $[1] !== item) {
    t1 = (item == null ? void 0 : item.some(_temp$5)) ? item.slice(0, 3).map((position, index) => /* @__PURE__ */ jsxRuntimeExports.jsx(Box, { maw: "200px", children: /* @__PURE__ */ jsxRuntimeExports.jsx(Text, { size: "xs", fw: 400, className: classes.text, children: /* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: position == null ? void 0 : position.ParentUserName }) }) }, index)) : null;
    $[0] = classes.text;
    $[1] = item;
    $[2] = t1;
  } else {
    t1 = $[2];
  }
  let t2;
  if ($[3] !== classes.content || $[4] !== t1) {
    t2 = /* @__PURE__ */ jsxRuntimeExports.jsx(Box, { className: classes.content, children: t1 });
    $[3] = classes.content;
    $[4] = t1;
    $[5] = t2;
  } else {
    t2 = $[5];
  }
  return t2;
};
function _temp$5(position_0) {
  return position_0 == null ? void 0 : position_0.ParentUserName;
}
const useStyles$8 = createStyles(() => ({
  container: {
    width: "100%",
    backgroundColor: "transparent",
    position: "relative",
    display: "flex",
    alignItems: "center",
    gap: 4
  },
  nameWrapper: {
    textOverflow: "ellipsis",
    overflow: "hidden"
  }
}));
const ItemEmail = (t0) => {
  var _a, _b, _c;
  const $ = compilerRuntimeExports.c(11);
  const {
    item
  } = t0;
  const {
    classes
  } = useStyles$8();
  if (!(item == null ? void 0 : item.Email) || !(item == null ? void 0 : item.Id)) {
    return null;
  }
  let t1;
  if ($[0] !== ((_a = item == null ? void 0 : item.Customer) == null ? void 0 : _a.Id) || $[1] !== (item == null ? void 0 : item.Email) || $[2] !== (item == null ? void 0 : item.Id) || $[3] !== (item == null ? void 0 : item.IsConfirmed)) {
    t1 = !(item == null ? void 0 : item.IsConfirmed) && (item == null ? void 0 : item.Email) && /* @__PURE__ */ jsxRuntimeExports.jsx(EmailActivationControl, { Email: item == null ? void 0 : item.Email, Id: item == null ? void 0 : item.Id, customerId: (_b = item == null ? void 0 : item.Customer) == null ? void 0 : _b.Id });
    $[0] = (_c = item == null ? void 0 : item.Customer) == null ? void 0 : _c.Id;
    $[1] = item == null ? void 0 : item.Email;
    $[2] = item == null ? void 0 : item.Id;
    $[3] = item == null ? void 0 : item.IsConfirmed;
    $[4] = t1;
  } else {
    t1 = $[4];
  }
  const t2 = item == null ? void 0 : item.Email;
  let t3;
  if ($[5] !== t2) {
    t3 = /* @__PURE__ */ jsxRuntimeExports.jsx(EllipsisTooltip, { width: 200, children: t2 });
    $[5] = t2;
    $[6] = t3;
  } else {
    t3 = $[6];
  }
  let t4;
  if ($[7] !== classes.container || $[8] !== t1 || $[9] !== t3) {
    t4 = /* @__PURE__ */ jsxRuntimeExports.jsxs(Flex, { className: classes.container, children: [
      t1,
      t3
    ] });
    $[7] = classes.container;
    $[8] = t1;
    $[9] = t3;
    $[10] = t4;
  } else {
    t4 = $[10];
  }
  return t4;
};
const useStyles$7 = createStyles((theme) => ({
  cellContent: {
    position: "relative",
    display: "flex",
    flexDirection: "column",
    gap: "2px",
    cursor: "pointer",
    minWidth: 0
  },
  emailText: {
    fontSize: "14px",
    fontWeight: 400,
    lineHeight: "20px",
    color: theme.colors.dark[9],
    overflow: "hidden",
    textOverflow: "ellipsis",
    whiteSpace: "nowrap"
  },
  serverText: {
    fontSize: "12px",
    fontWeight: 400,
    lineHeight: "16px",
    color: theme.colors.gray[6],
    overflow: "hidden",
    textOverflow: "ellipsis",
    whiteSpace: "nowrap"
  },
  moreIndicator: {
    transform: "translate(-50%, -50%)",
    position: "absolute",
    top: "50%",
    right: -40,
    fontSize: "12px",
    padding: "4px",
    backgroundColor: "#E7F5FF",
    borderRadius: "4px",
    fontWeight: 500,
    lineHeight: "16px",
    color: "#339AF0"
  },
  tooltip: {
    backgroundColor: "rgba(52, 58, 64, 0.8)",
    padding: "12px",
    maxWidth: "320px",
    borderRadius: "8px"
  },
  tooltipContent: {
    display: "flex",
    flexDirection: "column",
    gap: "12px"
  },
  serverBlock: {
    display: "flex",
    flexDirection: "column",
    gap: "4px"
  },
  serverName: {
    fontSize: "12px",
    fontWeight: 500,
    lineHeight: "16px",
    color: theme.white,
    marginBottom: "4px"
  },
  emailItem: {
    fontSize: "12px",
    fontWeight: 400,
    lineHeight: "16px",
    color: theme.colors.gray[4],
    paddingLeft: "8px"
  }
}));
const MailboxesCell = (t0) => {
  var _a, _b;
  const $ = compilerRuntimeExports.c(32);
  const {
    item
  } = t0;
  const {
    classes
  } = useStyles$7();
  const postClientEmails = item == null ? void 0 : item.PostClientEmails;
  if (!postClientEmails || postClientEmails.length === 0) {
    let t12;
    if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
      t12 = /* @__PURE__ */ jsxRuntimeExports.jsx(Text, { c: "dimmed", children: "—" });
      $[0] = t12;
    } else {
      t12 = $[0];
    }
    return t12;
  }
  const firstServer = postClientEmails[0];
  const firstEmail = (_a = firstServer == null ? void 0 : firstServer.Emails) == null ? void 0 : _a[0];
  const hasMoreData = postClientEmails.length > 1 || (((_b = firstServer == null ? void 0 : firstServer.Emails) == null ? void 0 : _b.length) || 0) > 1;
  let t1;
  if ($[1] !== classes.emailItem || $[2] !== classes.serverBlock || $[3] !== classes.serverName || $[4] !== classes.tooltipContent || $[5] !== postClientEmails) {
    t1 = () => /* @__PURE__ */ jsxRuntimeExports.jsx(Box, { className: classes.tooltipContent, children: postClientEmails.map((serverData, serverIndex) => /* @__PURE__ */ jsxRuntimeExports.jsxs(Box, { className: classes.serverBlock, children: [
      /* @__PURE__ */ jsxRuntimeExports.jsx(Text, { className: classes.serverName, children: serverData.Server }),
      serverData.Emails.map((email, emailIndex) => /* @__PURE__ */ jsxRuntimeExports.jsx(Text, { className: classes.emailItem, children: email }, emailIndex))
    ] }, serverIndex)) });
    $[1] = classes.emailItem;
    $[2] = classes.serverBlock;
    $[3] = classes.serverName;
    $[4] = classes.tooltipContent;
    $[5] = postClientEmails;
    $[6] = t1;
  } else {
    t1 = $[6];
  }
  const renderTooltipContent = t1;
  if (!firstEmail) {
    let t22;
    if ($[7] === Symbol.for("react.memo_cache_sentinel")) {
      t22 = /* @__PURE__ */ jsxRuntimeExports.jsx(Text, { c: "dimmed", children: "—" });
      $[7] = t22;
    } else {
      t22 = $[7];
    }
    return t22;
  }
  let t2;
  if ($[8] !== renderTooltipContent) {
    t2 = renderTooltipContent();
    $[8] = renderTooltipContent;
    $[9] = t2;
  } else {
    t2 = $[9];
  }
  const t3 = !hasMoreData;
  let t4;
  if ($[10] !== classes.tooltip) {
    t4 = {
      tooltip: classes.tooltip
    };
    $[10] = classes.tooltip;
    $[11] = t4;
  } else {
    t4 = $[11];
  }
  let t5;
  if ($[12] !== classes.emailText || $[13] !== firstEmail) {
    t5 = /* @__PURE__ */ jsxRuntimeExports.jsx(Text, { className: classes.emailText, lineClamp: 1, children: firstEmail });
    $[12] = classes.emailText;
    $[13] = firstEmail;
    $[14] = t5;
  } else {
    t5 = $[14];
  }
  let t6;
  if ($[15] !== classes.serverText || $[16] !== firstServer.Server) {
    t6 = /* @__PURE__ */ jsxRuntimeExports.jsx(Text, { className: classes.serverText, lineClamp: 1, children: firstServer.Server });
    $[15] = classes.serverText;
    $[16] = firstServer.Server;
    $[17] = t6;
  } else {
    t6 = $[17];
  }
  let t7;
  if ($[18] !== classes.moreIndicator || $[19] !== hasMoreData || $[20] !== postClientEmails) {
    t7 = hasMoreData && /* @__PURE__ */ jsxRuntimeExports.jsxs(Text, { className: classes.moreIndicator, children: [
      "+",
      postClientEmails.reduce(_temp$4, 0) - 1
    ] });
    $[18] = classes.moreIndicator;
    $[19] = hasMoreData;
    $[20] = postClientEmails;
    $[21] = t7;
  } else {
    t7 = $[21];
  }
  let t8;
  if ($[22] !== classes.cellContent || $[23] !== t5 || $[24] !== t6 || $[25] !== t7) {
    t8 = /* @__PURE__ */ jsxRuntimeExports.jsxs(Box, { className: classes.cellContent, children: [
      t5,
      t6,
      t7
    ] });
    $[22] = classes.cellContent;
    $[23] = t5;
    $[24] = t6;
    $[25] = t7;
    $[26] = t8;
  } else {
    t8 = $[26];
  }
  let t9;
  if ($[27] !== t2 || $[28] !== t3 || $[29] !== t4 || $[30] !== t8) {
    t9 = /* @__PURE__ */ jsxRuntimeExports.jsx(Tooltip, { label: t2, position: "bottom-start", withArrow: true, disabled: t3, classNames: t4, children: t8 });
    $[27] = t2;
    $[28] = t3;
    $[29] = t4;
    $[30] = t8;
    $[31] = t9;
  } else {
    t9 = $[31];
  }
  return t9;
};
function _temp$4(total, server) {
  return total + server.Emails.length;
}
const useGetColumns = (toggleRow, setRowData, columnsVisibility, scrollRef) => {
  const $ = compilerRuntimeExports.c(130);
  const {
    t
  } = useTranslation();
  let t0;
  if ($[0] !== toggleRow) {
    t0 = {
      width: "32px",
      dataIndex: "Checkbox",
      title: "",
      hideColumn: false,
      render: (item, selection) => /* @__PURE__ */ jsxRuntimeExports.jsx(CustomCheckbox, { selection, toggleRow, item })
    };
    $[0] = toggleRow;
    $[1] = t0;
  } else {
    t0 = $[1];
  }
  let t1;
  if ($[2] !== t) {
    t1 = t("profile.firstName");
    $[2] = t;
    $[3] = t1;
  } else {
    t1 = $[3];
  }
  let t2;
  if ($[4] !== columnsVisibility.Name || $[5] !== t1) {
    t2 = {
      width: "292px",
      dataIndex: "Name",
      title: t1,
      hideColumn: columnsVisibility.Name,
      hasSort: true,
      render: _temp$3
    };
    $[4] = columnsVisibility.Name;
    $[5] = t1;
    $[6] = t2;
  } else {
    t2 = $[6];
  }
  let t3;
  if ($[7] !== t) {
    t3 = t("profile.login");
    $[7] = t;
    $[8] = t3;
  } else {
    t3 = $[8];
  }
  let t4;
  if ($[9] !== columnsVisibility.Login || $[10] !== t3) {
    t4 = {
      width: "220px",
      dataIndex: "Login",
      title: t3,
      hideColumn: columnsVisibility.Login,
      hasSort: true,
      render: _temp2
    };
    $[9] = columnsVisibility.Login;
    $[10] = t3;
    $[11] = t4;
  } else {
    t4 = $[11];
  }
  let t5;
  if ($[12] !== t) {
    t5 = t("profile.role");
    $[12] = t;
    $[13] = t5;
  } else {
    t5 = $[13];
  }
  let t6;
  if ($[14] !== columnsVisibility.Type || $[15] !== t5) {
    t6 = {
      width: "292px",
      dataIndex: "Type",
      title: t5,
      hideColumn: columnsVisibility.Type,
      render: _temp3
    };
    $[14] = columnsVisibility.Type;
    $[15] = t5;
    $[16] = t6;
  } else {
    t6 = $[16];
  }
  let t7;
  if ($[17] !== t) {
    t7 = t("filials.authorization.mail");
    $[17] = t;
    $[18] = t7;
  } else {
    t7 = $[18];
  }
  let t8;
  if ($[19] !== columnsVisibility.Email || $[20] !== t7) {
    t8 = {
      width: "235px",
      dataIndex: "Email",
      title: t7,
      hideColumn: columnsVisibility.Email,
      hasSort: true,
      render: _temp4
    };
    $[19] = columnsVisibility.Email;
    $[20] = t7;
    $[21] = t8;
  } else {
    t8 = $[21];
  }
  let t9;
  if ($[22] !== t) {
    t9 = t("users.mailboxes");
    $[22] = t;
    $[23] = t9;
  } else {
    t9 = $[23];
  }
  let t10;
  if ($[24] !== columnsVisibility.PostClientEmails || $[25] !== t9) {
    t10 = {
      width: "200px",
      dataIndex: "PostClientEmails",
      title: t9,
      hideColumn: columnsVisibility.PostClientEmails,
      render: _temp5
    };
    $[24] = columnsVisibility.PostClientEmails;
    $[25] = t9;
    $[26] = t10;
  } else {
    t10 = $[26];
  }
  let t11;
  if ($[27] !== t) {
    t11 = t("register.phone");
    $[27] = t;
    $[28] = t11;
  } else {
    t11 = $[28];
  }
  let t12;
  if ($[29] !== columnsVisibility.Phone || $[30] !== t11) {
    t12 = {
      width: "220px",
      dataIndex: "Phone",
      title: t11,
      hideColumn: columnsVisibility.Phone,
      hasSort: true,
      render: _temp6
    };
    $[29] = columnsVisibility.Phone;
    $[30] = t11;
    $[31] = t12;
  } else {
    t12 = $[31];
  }
  let t13;
  if ($[32] !== t) {
    t13 = t("unit");
    $[32] = t;
    $[33] = t13;
  } else {
    t13 = $[33];
  }
  let t14;
  if ($[34] !== columnsVisibility.Customer || $[35] !== t13) {
    t14 = {
      width: "220px",
      dataIndex: "Customer",
      title: t13,
      hideColumn: columnsVisibility.Customer,
      hasSort: true,
      render: _temp7
    };
    $[34] = columnsVisibility.Customer;
    $[35] = t13;
    $[36] = t14;
  } else {
    t14 = $[36];
  }
  let t15;
  if ($[37] !== t) {
    t15 = t("roles.leader");
    $[37] = t;
    $[38] = t15;
  } else {
    t15 = $[38];
  }
  let t16;
  if ($[39] !== columnsVisibility.ParentUserName || $[40] !== t15) {
    t16 = {
      width: "220px",
      dataIndex: "ParentUserName",
      title: t15,
      hideColumn: columnsVisibility.ParentUserName,
      render: _temp8
    };
    $[39] = columnsVisibility.ParentUserName;
    $[40] = t15;
    $[41] = t16;
  } else {
    t16 = $[41];
  }
  let t17;
  if ($[42] !== t) {
    t17 = t("profile.birthDate");
    $[42] = t;
    $[43] = t17;
  } else {
    t17 = $[43];
  }
  let t18;
  if ($[44] !== columnsVisibility.BirthDate || $[45] !== t17) {
    t18 = {
      width: "220px",
      dataIndex: "BirthDate",
      title: t17,
      hideColumn: columnsVisibility.BirthDate,
      hasSort: true,
      render: _temp9
    };
    $[44] = columnsVisibility.BirthDate;
    $[45] = t17;
    $[46] = t18;
  } else {
    t18 = $[46];
  }
  let t19;
  if ($[47] !== t) {
    t19 = t("dateOfCreation");
    $[47] = t;
    $[48] = t19;
  } else {
    t19 = $[48];
  }
  let t20;
  if ($[49] !== columnsVisibility.DateOfCreate || $[50] !== t19) {
    t20 = {
      width: "220px",
      dataIndex: "DateOfCreate",
      title: t19,
      hideColumn: columnsVisibility.DateOfCreate,
      hasSort: true,
      render: _temp0
    };
    $[49] = columnsVisibility.DateOfCreate;
    $[50] = t19;
    $[51] = t20;
  } else {
    t20 = $[51];
  }
  let t21;
  if ($[52] !== t) {
    t21 = t("profile.lastEntryDate");
    $[52] = t;
    $[53] = t21;
  } else {
    t21 = $[53];
  }
  let t22;
  if ($[54] !== columnsVisibility.LastVisitDate || $[55] !== t21) {
    t22 = {
      width: "280px",
      dataIndex: "LastVisitDate",
      title: t21,
      hideColumn: columnsVisibility.LastVisitDate,
      hasSort: true,
      render: _temp1
    };
    $[54] = columnsVisibility.LastVisitDate;
    $[55] = t21;
    $[56] = t22;
  } else {
    t22 = $[56];
  }
  let t23;
  if ($[57] !== t) {
    t23 = t("profile.userStatus");
    $[57] = t;
    $[58] = t23;
  } else {
    t23 = $[58];
  }
  let t24;
  if ($[59] !== t) {
    t24 = (item_11) => numberToUserStatus({
      value: item_11 == null ? void 0 : item_11.Status,
      t
    });
    $[59] = t;
    $[60] = t24;
  } else {
    t24 = $[60];
  }
  let t25;
  if ($[61] !== columnsVisibility.Status || $[62] !== t23 || $[63] !== t24) {
    t25 = {
      width: "280px",
      dataIndex: "Status",
      title: t23,
      hideColumn: columnsVisibility.Status,
      hasSort: true,
      render: t24
    };
    $[61] = columnsVisibility.Status;
    $[62] = t23;
    $[63] = t24;
    $[64] = t25;
  } else {
    t25 = $[64];
  }
  let t26;
  if ($[65] !== t) {
    t26 = t("profile.userQuota");
    $[65] = t;
    $[66] = t26;
  } else {
    t26 = $[66];
  }
  let t27;
  if ($[67] !== columnsVisibility.QuotaName || $[68] !== t26) {
    t27 = {
      width: "220px",
      dataIndex: "QuotaName",
      title: t26,
      hideColumn: columnsVisibility.QuotaName,
      hasSort: true,
      render: _temp10
    };
    $[67] = columnsVisibility.QuotaName;
    $[68] = t26;
    $[69] = t27;
  } else {
    t27 = $[69];
  }
  let t28;
  if ($[70] !== t) {
    t28 = t("quota.size");
    $[70] = t;
    $[71] = t28;
  } else {
    t28 = $[71];
  }
  let t29;
  if ($[72] !== columnsVisibility.QuotaSize || $[73] !== t28) {
    t29 = {
      width: "220px",
      dataIndex: "QuotaSize",
      title: t28,
      hideColumn: columnsVisibility.QuotaSize,
      hasSort: true,
      render: _temp11
    };
    $[72] = columnsVisibility.QuotaSize;
    $[73] = t28;
    $[74] = t29;
  } else {
    t29 = $[74];
  }
  let t30;
  if ($[75] !== t) {
    t30 = t("quota.usedSpace");
    $[75] = t;
    $[76] = t30;
  } else {
    t30 = $[76];
  }
  let t31;
  if ($[77] !== columnsVisibility.UsingQuotaSize || $[78] !== t30) {
    t31 = {
      width: "280px",
      dataIndex: "UsingQuotaSize",
      title: t30,
      hideColumn: columnsVisibility.UsingQuotaSize,
      hasSort: true,
      render: _temp12
    };
    $[77] = columnsVisibility.UsingQuotaSize;
    $[78] = t30;
    $[79] = t31;
  } else {
    t31 = $[79];
  }
  let t32;
  if ($[80] !== scrollRef || $[81] !== setRowData) {
    t32 = (item_15) => /* @__PURE__ */ jsxRuntimeExports.jsx(Action, { scrollRef, item: item_15, setRowData });
    $[80] = scrollRef;
    $[81] = setRowData;
    $[82] = t32;
  } else {
    t32 = $[82];
  }
  let t33;
  if ($[83] !== columnsVisibility.Action || $[84] !== t32) {
    t33 = {
      width: "50px",
      dataIndex: "Action",
      title: "",
      hideColumn: columnsVisibility.Action,
      render: t32
    };
    $[83] = columnsVisibility.Action;
    $[84] = t32;
    $[85] = t33;
  } else {
    t33 = $[85];
  }
  let t34;
  if ($[86] !== t0 || $[87] !== t10 || $[88] !== t12 || $[89] !== t14 || $[90] !== t16 || $[91] !== t18 || $[92] !== t2 || $[93] !== t20 || $[94] !== t22 || $[95] !== t25 || $[96] !== t27 || $[97] !== t29 || $[98] !== t31 || $[99] !== t33 || $[100] !== t4 || $[101] !== t6 || $[102] !== t8) {
    t34 = [t0, t2, t4, t6, t8, t10, t12, t14, t16, t18, t20, t22, t25, t27, t29, t31, t33];
    $[86] = t0;
    $[87] = t10;
    $[88] = t12;
    $[89] = t14;
    $[90] = t16;
    $[91] = t18;
    $[92] = t2;
    $[93] = t20;
    $[94] = t22;
    $[95] = t25;
    $[96] = t27;
    $[97] = t29;
    $[98] = t31;
    $[99] = t33;
    $[100] = t4;
    $[101] = t6;
    $[102] = t8;
    $[103] = t34;
  } else {
    t34 = $[103];
  }
  const columnsData = t34;
  let t35;
  if ($[104] === Symbol.for("react.memo_cache_sentinel")) {
    t35 = {
      width: "32px",
      dataIndex: "Checkbox",
      title: "",
      hideColumn: false,
      render: _temp13
    };
    $[104] = t35;
  } else {
    t35 = $[104];
  }
  let t36;
  if ($[105] !== t) {
    t36 = t("profile.firstName");
    $[105] = t;
    $[106] = t36;
  } else {
    t36 = $[106];
  }
  let t37;
  if ($[107] !== t36) {
    t37 = {
      width: "292px",
      dataIndex: "Name",
      title: t36,
      hideColumn: false,
      render: _temp14
    };
    $[107] = t36;
    $[108] = t37;
  } else {
    t37 = $[108];
  }
  let t38;
  if ($[109] !== t) {
    t38 = t("profile.role");
    $[109] = t;
    $[110] = t38;
  } else {
    t38 = $[110];
  }
  let t39;
  if ($[111] !== t38) {
    t39 = {
      width: "120px",
      dataIndex: "Type",
      title: t38,
      hideColumn: false,
      render: _temp16
    };
    $[111] = t38;
    $[112] = t39;
  } else {
    t39 = $[112];
  }
  let t40;
  if ($[113] !== t) {
    t40 = t("filials.authorization.mail");
    $[113] = t;
    $[114] = t40;
  } else {
    t40 = $[114];
  }
  let t41;
  if ($[115] !== t40) {
    t41 = {
      width: "235px",
      dataIndex: "Email",
      title: t40,
      hideColumn: false,
      render: _temp17
    };
    $[115] = t40;
    $[116] = t41;
  } else {
    t41 = $[116];
  }
  let t42;
  if ($[117] !== t) {
    t42 = t("register.phone");
    $[117] = t;
    $[118] = t42;
  } else {
    t42 = $[118];
  }
  let t43;
  if ($[119] !== t42) {
    t43 = {
      width: "220px",
      dataIndex: "Phone",
      title: t42,
      hideColumn: false,
      render: _temp18
    };
    $[119] = t42;
    $[120] = t43;
  } else {
    t43 = $[120];
  }
  let t44;
  if ($[121] === Symbol.for("react.memo_cache_sentinel")) {
    t44 = {
      width: "50px",
      dataIndex: "Action",
      title: "",
      hideColumn: false,
      render: _temp19
    };
    $[121] = t44;
  } else {
    t44 = $[121];
  }
  let t45;
  if ($[122] !== t37 || $[123] !== t39 || $[124] !== t41 || $[125] !== t43) {
    t45 = [t35, t37, t39, t41, t43, t44];
    $[122] = t37;
    $[123] = t39;
    $[124] = t41;
    $[125] = t43;
    $[126] = t45;
  } else {
    t45 = $[126];
  }
  const simpleColumns = t45;
  const [columns, setColumns] = reactExports.useState(columnsData);
  let t46;
  if ($[127] !== columns || $[128] !== simpleColumns) {
    t46 = {
      columns,
      setColumns,
      simpleColumns
    };
    $[127] = columns;
    $[128] = simpleColumns;
    $[129] = t46;
  } else {
    t46 = $[129];
  }
  return t46;
};
function _temp$3(item_0) {
  return /* @__PURE__ */ jsxRuntimeExports.jsx(ItemUser, { item: item_0 });
}
function _temp2(item_1) {
  return /* @__PURE__ */ jsxRuntimeExports.jsx(EllipsisTooltip, { width: 200, children: item_1 == null ? void 0 : item_1.Login });
}
function _temp3(item_2) {
  return /* @__PURE__ */ jsxRuntimeExports.jsx(RolesList, { roles: (item_2 == null ? void 0 : item_2.Roles) || [] });
}
function _temp4(item_3) {
  return /* @__PURE__ */ jsxRuntimeExports.jsx(ItemEmail, { item: item_3 });
}
function _temp5(item_4) {
  return /* @__PURE__ */ jsxRuntimeExports.jsx(MailboxesCell, { item: item_4 });
}
function _temp6(item_5) {
  return item_5 == null ? void 0 : item_5.PhoneNumber;
}
function _temp7(item_6) {
  var _a;
  return /* @__PURE__ */ jsxRuntimeExports.jsx(EllipsisTooltip, { width: 220, children: (_a = item_6 == null ? void 0 : item_6.Customer) == null ? void 0 : _a.Name });
}
function _temp8(item_7) {
  return /* @__PURE__ */ jsxRuntimeExports.jsx(ParentUserNames, { item: item_7 == null ? void 0 : item_7.Positions });
}
function _temp9(item_8) {
  return formatDate(item_8 == null ? void 0 : item_8.BirthDate);
}
function _temp0(item_9) {
  return formatDate(item_9 == null ? void 0 : item_9.DateOfCreate);
}
function _temp1(item_10) {
  return formatDate(item_10 == null ? void 0 : item_10.LastVisitDate);
}
function _temp10(item_12) {
  var _a;
  return (_a = item_12 == null ? void 0 : item_12.DataStorageQuota) == null ? void 0 : _a.QuotaName;
}
function _temp11(item_13) {
  var _a;
  return formatByteToGb((_a = item_13 == null ? void 0 : item_13.DataStorageQuota) == null ? void 0 : _a.QuotaSize);
}
function _temp12(item_14) {
  var _a;
  return formatDataSizeUnits((_a = item_14 == null ? void 0 : item_14.DataStorageQuota) == null ? void 0 : _a.UsingQuotaSize);
}
function _temp13() {
  return "";
}
function _temp14(item_16) {
  return `${(item_16 == null ? void 0 : item_16.Surname) ?? ""} ${(item_16 == null ? void 0 : item_16.FirstName) ?? ""} ${(item_16 == null ? void 0 : item_16.MiddleName) ?? ""}`;
}
function _temp15(role) {
  const {
    status
  } = getColorsByRole(role);
  return status;
}
function _temp16(item_17) {
  var _a;
  return (_a = item_17 == null ? void 0 : item_17.RoleTypes) == null ? void 0 : _a.map(_temp15).join().trim();
}
function _temp17(item_18) {
  return item_18 == null ? void 0 : item_18.Email;
}
function _temp18(item_19) {
  return item_19 == null ? void 0 : item_19.Phone;
}
function _temp19() {
  return "";
}
const filtersSettings = {
  1: {
    hideSearch: false
  },
  2: {
    hideSearch: true
  },
  3: {
    hideSearch: false
  },
  4: {
    hideSearch: false
  },
  5: {
    hideSearch: false
  },
  6: {
    hideSearch: true
  },
  7: {
    hideSearch: true
  },
  8: {
    hideSearch: true
  },
  9: {
    hideSearch: true
  },
  10: {
    hideSearch: false
  },
  11: {
    hideSearch: false
  },
  12: {
    hideSearch: false
  },
  13: {
    hideSearch: false
  },
  14: {
    hideSearch: false
  },
  15: {
    hideSearch: false
  },
  16: {
    hideSearch: false
  },
  17: {
    hideSearch: false
  }
};
const transformFilters = (data, t) => {
  return data.map((item) => {
    var _a, _b;
    return {
      ...item,
      label: item.Type in IFiltersEnumType ? t(`filters.${filtersLabelsKeys[item.Type]}`) : t("filters.title"),
      Items: (_a = item.Items) == null ? void 0 : _a.map((filterItem) => ({
        ...filterItem,
        checked: false
      })),
      hideSearch: ((_b = filtersSettings[item.Type]) == null ? void 0 : _b.hideSearch) ?? false
    };
  }).sort((a, b) => a.Type - b.Type).filter((item) => item.Type !== 10);
};
const useGetUsersFilters = () => {
  const $ = compilerRuntimeExports.c(7);
  const {
    t
  } = useTranslation();
  const {
    data: defaultFiltersData,
    isSuccess: defaultFiltersSuccess,
    isFetching
  } = useGetDefaultUserFiltersQuery(20);
  let t0;
  if ($[0] !== defaultFiltersData || $[1] !== defaultFiltersSuccess || $[2] !== t) {
    t0 = defaultFiltersSuccess ? transformFilters(defaultFiltersData || [], t) : [];
    $[0] = defaultFiltersData;
    $[1] = defaultFiltersSuccess;
    $[2] = t;
    $[3] = t0;
  } else {
    t0 = $[3];
  }
  const filtersMenuList = t0;
  let t1;
  if ($[4] !== filtersMenuList || $[5] !== isFetching) {
    t1 = {
      filtersMenuList,
      isFetching
    };
    $[4] = filtersMenuList;
    $[5] = isFetching;
    $[6] = t1;
  } else {
    t1 = $[6];
  }
  return t1;
};
const useChangeRoles = (setRowData, selection) => {
  const {
    setUsers
  } = useActions();
  const {
    filters
  } = useAppSelector((state) => state.users);
  const [fetchChangeRoles, resultChangeRoles] = useChangeRolesMutation();
  const [fetchGetUsers] = useLazyGetUsersQuery();
  const changeRoles = reactExports.useCallback(async (selection_0, roleIds) => {
    const numbersSelection = (selection_0 == null ? void 0 : selection_0.map((item) => Number(item))) ?? [];
    const roleIdsUnique = new Set(roleIds);
    try {
      const res = await fetchChangeRoles({
        UserIds: numbersSelection,
        RoleIds: [...roleIdsUnique]
      });
      if (!Object.keys(res).includes("error")) {
        const {
          data
        } = await fetchGetUsers({
          Count: filters.Count,
          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);
    }
  }, [selection]);
  reactExports.useEffect(() => {
    const {
      isSuccess,
      isError,
      error
    } = resultChangeRoles;
    const _errorStatus = error == null ? void 0 : error.data;
    universalNotification({
      isSuccess,
      isError,
      error: _errorStatus,
      successTitle: "Роли пользователей успешно обновлены"
    });
  }, [resultChangeRoles]);
  return {
    changeRoles
  };
};
const useResetPassword = () => {
  const [fetchResetPassword] = useLazyBulkForgotQuery();
  const resetPassword = reactExports.useCallback(async (selection) => {
    const numbersSelection = (selection == null ? void 0 : selection.map((item) => Number(item))) ?? [];
    try {
      const {
        isSuccess,
        isError,
        error
      } = await fetchResetPassword(numbersSelection);
      const _errorStatus = error == null ? void 0 : error.data;
      universalNotification({
        isSuccess,
        isError,
        error: _errorStatus,
        successTitle: "Пароли успешно сброшены"
      });
    } catch (err) {
      console.warn("fetchResetPassword ERROR", err);
    }
  }, []);
  return {
    resetPassword
  };
};
const useStyles$6 = createStyles((theme) => ({
  badge: {
    backgroundColor: theme.colors.backgroundGray[6],
    color: "#344054",
    textTransform: "none",
    fontSize: "12px",
    fontWeight: 400,
    lineHeight: "18px",
    marginRight: theme.spacing.xs,
    borderRadius: "16px",
    cursor: "pointer",
    padding: `0px ${theme.spacing.xs}`,
    "& .mantine-Badge-rightSection": {
      display: "flex"
    }
  },
  disabled: {
    opacity: "0.5",
    pointerEvents: "none"
  }
}));
const useStyles$5 = createStyles((theme, _, utils) => ({
  divider: {
    margin: theme.spacing.sm,
    borderTopColor: theme.colors.brandGray[1]
  },
  checkbox: {
    fontWeight: 500,
    display: "flex",
    alignItems: "center",
    flexDirection: "row",
    justifyContent: "space-between",
    textDecoration: "none",
    padding: `${theme.spacing.xs} ${theme.spacing.sm}`,
    fontSize: theme.fontSizes.sm,
    [utils.dark]: {
      color: theme.colors.dark[0]
    },
    [utils.light]: {
      color: theme.black
    },
    borderRadius: "8px",
    width: "100%",
    cursor: "pointer",
    "& input, label": {
      cursor: "pointer"
    },
    "&:hover": {
      [utils.dark]: {
        backgroundColor: theme.colors.dark[7],
        color: theme.white
      },
      [utils.light]: {
        backgroundColor: theme.colors.gray[2],
        color: theme.black
      }
    }
  },
  checkboxLastItem: {
    marginBottom: theme.spacing.xl
  },
  buttonChange: {
    width: "100%",
    position: "absolute",
    bottom: "0px"
  },
  radio: {
    "& .mantine-Radio-label": {
      fontSize: "14px"
    }
  }
}));
var MenuItemTypeEnum = /* @__PURE__ */ ((MenuItemTypeEnum2) => {
  MenuItemTypeEnum2["item"] = "item";
  MenuItemTypeEnum2["checkbox"] = "checkbox";
  MenuItemTypeEnum2["radio"] = "radio";
  return MenuItemTypeEnum2;
})(MenuItemTypeEnum || {});
const DropdownMenu = (t0) => {
  const $ = compilerRuntimeExports.c(49);
  let classNames;
  let handleChangeCheckbox;
  let handleClick;
  let height;
  let list;
  let position;
  let props;
  let scrollHeight;
  let t1;
  let t2;
  let t3;
  let t4;
  if ($[0] !== t0) {
    ({
      width: t1,
      height,
      scrollHeight,
      list,
      marginLeft: t2,
      marginRight: t3,
      classNames,
      handleClick,
      position,
      menuItemType: t4,
      handleChangeCheckbox,
      ...props
    } = t0);
    $[0] = t0;
    $[1] = classNames;
    $[2] = handleChangeCheckbox;
    $[3] = handleClick;
    $[4] = height;
    $[5] = list;
    $[6] = position;
    $[7] = props;
    $[8] = scrollHeight;
    $[9] = t1;
    $[10] = t2;
    $[11] = t3;
    $[12] = t4;
  } else {
    classNames = $[1];
    handleChangeCheckbox = $[2];
    handleClick = $[3];
    height = $[4];
    list = $[5];
    position = $[6];
    props = $[7];
    scrollHeight = $[8];
    t1 = $[9];
    t2 = $[10];
    t3 = $[11];
    t4 = $[12];
  }
  const width = t1 === void 0 ? 200 : t1;
  const marginLeft = t2 === void 0 ? 0 : t2;
  const marginRight = t3 === void 0 ? 0 : t3;
  const menuItemType = t4 === void 0 ? "item" : t4;
  const {
    classes,
    cx
  } = useStyles$5();
  const widthMenu = typeof width === "string" ? width : `calc(${width}px - (${marginLeft}px + ${marginRight}px))`;
  let t5;
  if ($[13] !== classes || $[14] !== cx || $[15] !== handleChangeCheckbox || $[16] !== handleClick || $[17] !== list.length || $[18] !== menuItemType) {
    t5 = (item, index) => {
      const key = `${menuItemType}-${index}`;
      switch (menuItemType) {
        case "item": {
          return /* @__PURE__ */ jsxRuntimeExports.jsx(Box, { children: /* @__PURE__ */ jsxRuntimeExports.jsx(Menu.Item, { leftSection: item.icon, "data-value": item.value, onClick: handleClick, children: item.label }, index) }, key);
        }
        case "checkbox": {
          return /* @__PURE__ */ jsxRuntimeExports.jsx(Checkbox, { "data-checkbox": item.value, className: cx(classes.checkbox, {
            [classes.checkboxLastItem]: index === list.length - 1
          }), onChange: handleChangeCheckbox, readOnly: true, label: /* @__PURE__ */ jsxRuntimeExports.jsx(Text, { children: item.label }) }, key);
        }
        case "radio": {
          return /* @__PURE__ */ jsxRuntimeExports.jsx(Menu.Item, { "data-value": item.value, onClick: handleClick, children: /* @__PURE__ */ jsxRuntimeExports.jsx(Radio, { size: "xs", defaultChecked: item.checked, label: item.label, className: classes.radio }) }, key);
        }
      }
    };
    $[13] = classes;
    $[14] = cx;
    $[15] = handleChangeCheckbox;
    $[16] = handleClick;
    $[17] = list.length;
    $[18] = menuItemType;
    $[19] = t5;
  } else {
    t5 = $[19];
  }
  const getChildrenItem = t5;
  const t6 = props == null ? void 0 : props.children;
  let t7;
  if ($[20] !== t6) {
    t7 = /* @__PURE__ */ jsxRuntimeExports.jsx(Menu.Target, { children: t6 });
    $[20] = t6;
    $[21] = t7;
  } else {
    t7 = $[21];
  }
  let t8;
  if ($[22] === Symbol.for("react.memo_cache_sentinel")) {
    t8 = /* @__PURE__ */ jsxRuntimeExports.jsx(Stack, {});
    $[22] = t8;
  } else {
    t8 = $[22];
  }
  const t9 = height ?? "auto";
  let t10;
  if ($[23] !== t9) {
    t10 = {
      height: t9
    };
    $[23] = t9;
    $[24] = t10;
  } else {
    t10 = $[24];
  }
  const t11 = scrollHeight ?? "auto";
  let t12;
  if ($[25] !== t11) {
    t12 = {
      height: t11
    };
    $[25] = t11;
    $[26] = t12;
  } else {
    t12 = $[26];
  }
  let t13;
  if ($[27] !== getChildrenItem || $[28] !== list) {
    let t142;
    if ($[30] !== getChildrenItem) {
      t142 = (item_0, index_0) => {
        if (item_0.value === "divider") {
          return /* @__PURE__ */ jsxRuntimeExports.jsx(Divider, { className: item_0.className }, index_0);
        } else {
          return getChildrenItem(item_0, index_0);
        }
      };
      $[30] = getChildrenItem;
      $[31] = t142;
    } else {
      t142 = $[31];
    }
    t13 = list.map(t142);
    $[27] = getChildrenItem;
    $[28] = list;
    $[29] = t13;
  } else {
    t13 = $[29];
  }
  let t14;
  if ($[32] !== classes || $[33] !== handleClick || $[34] !== menuItemType) {
    t14 = menuItemType === "checkbox" && /* @__PURE__ */ jsxRuntimeExports.jsx(Button, { className: classes.buttonChange, size: "xs", onClick: handleClick, children: "Изменить" });
    $[32] = classes;
    $[33] = handleClick;
    $[34] = menuItemType;
    $[35] = t14;
  } else {
    t14 = $[35];
  }
  let t15;
  if ($[36] !== t12 || $[37] !== t13 || $[38] !== t14) {
    t15 = /* @__PURE__ */ jsxRuntimeExports.jsxs(ScrollContainer, { style: t12, children: [
      t13,
      t14
    ] });
    $[36] = t12;
    $[37] = t13;
    $[38] = t14;
    $[39] = t15;
  } else {
    t15 = $[39];
  }
  let t16;
  if ($[40] !== t10 || $[41] !== t15) {
    t16 = /* @__PURE__ */ jsxRuntimeExports.jsx(Menu.Dropdown, { sx: t10, children: t15 });
    $[40] = t10;
    $[41] = t15;
    $[42] = t16;
  } else {
    t16 = $[42];
  }
  let t17;
  if ($[43] !== classNames || $[44] !== position || $[45] !== t16 || $[46] !== t7 || $[47] !== widthMenu) {
    t17 = /* @__PURE__ */ jsxRuntimeExports.jsxs(Menu, { classNames, shadow: "md", width: widthMenu, zIndex: 400, position, children: [
      t7,
      t8,
      t16
    ] });
    $[43] = classNames;
    $[44] = position;
    $[45] = t16;
    $[46] = t7;
    $[47] = widthMenu;
    $[48] = t17;
  } else {
    t17 = $[48];
  }
  return t17;
};
const BadgeMenu = (t0) => {
  const $ = compilerRuntimeExports.c(13);
  const {
    item,
    handleClickListItem,
    handleClick,
    handleChangeCheckbox,
    ddmClassNames,
    ddmWidth,
    disabled
  } = t0;
  const {
    classes
  } = useStyles$6();
  const getAttributeForValue = _temp$2;
  let t1;
  if ($[0] !== classes.badge || $[1] !== classes.disabled || $[2] !== ddmClassNames || $[3] !== ddmWidth || $[4] !== disabled || $[5] !== handleChangeCheckbox || $[6] !== handleClick || $[7] !== handleClickListItem || $[8] !== item.label || $[9] !== item.list || $[10] !== item.menuItemType || $[11] !== item.value) {
    t1 = /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: (item == null ? void 0 : item.list.length) ? /* @__PURE__ */ jsxRuntimeExports.jsx(DropdownMenu, { height: "auto", scrollHeight: "auto", width: ddmWidth, classNames: ddmClassNames, list: item.list, handleClick: handleClickListItem, handleChangeCheckbox, menuItemType: item.menuItemType, position: "bottom-start", children: /* @__PURE__ */ jsxRuntimeExports.jsx(Badge, { "data-type": item.value, onClick: handleClick, variant: "light", size: "md", miw: "fit-content", rightSection: Boolean(item.list.length) && /* @__PURE__ */ jsxRuntimeExports.jsx(gq, { size: "12px" }), className: `${classes.badge} ${disabled ? classes.disabled : ""}`, "data-cy": getAttributeForValue(item.value), children: /* @__PURE__ */ jsxRuntimeExports.jsx(Text, { fz: "inherit", children: item.label }) }) }) : /* @__PURE__ */ jsxRuntimeExports.jsx(Badge, { onClick: handleClick, "data-type": item.value, variant: "light", size: "md", miw: "fit-content", rightSection: Boolean(item.list.length) && /* @__PURE__ */ jsxRuntimeExports.jsx(gq, { size: "12px" }), className: `${classes.badge} ${disabled ? classes.disabled : ""}`, "data-cy": getAttributeForValue(item.value), children: /* @__PURE__ */ jsxRuntimeExports.jsx(Text, { fz: "inherit", children: item.label }) }) });
    $[0] = classes.badge;
    $[1] = classes.disabled;
    $[2] = ddmClassNames;
    $[3] = ddmWidth;
    $[4] = disabled;
    $[5] = handleChangeCheckbox;
    $[6] = handleClick;
    $[7] = handleClickListItem;
    $[8] = item.label;
    $[9] = item.list;
    $[10] = item.menuItemType;
    $[11] = item.value;
    $[12] = t1;
  } else {
    t1 = $[12];
  }
  return t1;
};
function _temp$2(value) {
  return Object.keys(UsersActionTableEnum).find((key) => UsersActionTableEnum[key] === value);
}
const ACTION_PANEL_HEIGHT = 44;
const useStyles$4 = createStyles((theme) => ({
  root: {
    width: `calc(100% - 48px)`,
    height: `${ACTION_PANEL_HEIGHT}px`,
    padding: `0 ${theme.spacing.sm} 0 ${theme.spacing.sm}`,
    display: "flex",
    alignItems: "center",
    flexDirection: "row",
    justifyContent: "space-between",
    borderBottom: `1px solid ${theme.colors.backgroundGray[6]}`,
    borderRadius: "8px 8px 0px 0px",
    backgroundColor: "white",
    overflowX: "scroll",
    msOverflowStyle: "none",
    scrollbarWidth: "none",
    "&::-webkit-scrollbar": {
      display: "none"
    }
  },
  scroll: {
    overflow: "scroll",
    height: "100%",
    width: "100%",
    position: "absolute",
    top: "0",
    left: "0",
    visibility: "hidden"
  },
  checkbox: {
    display: "flex",
    marginRight: theme.spacing.md,
    "& input": {
      cursor: "pointer"
    }
  },
  badge: {
    backgroundColor: theme.colors.backgroundGray[6],
    color: "#344054",
    textTransform: "none",
    fontSize: "12px",
    fontWeight: 400,
    lineHeight: "18px",
    marginRight: theme.spacing.xs,
    borderRadius: "16px",
    cursor: "pointer",
    padding: `0px ${theme.spacing.xs}`,
    "& .mantine-Badge-rightSection": {
      display: "flex"
    }
  },
  leftSection: {
    display: "flex",
    alignItems: "flex-start",
    "& .mantine-Menu-dropdown": {
      padding: theme.spacing.sm
    }
  },
  rightSection: {
    display: "flex",
    alignItems: "flex-end",
    marginRight: theme.spacing.xs
  },
  menu: {
    // height: '180px',
    marginBottom: "10px",
    padding: theme.spacing.sm
  }
}));
const useGetActionList = () => {
  const $ = compilerRuntimeExports.c(48);
  const {
    t
  } = useTranslation();
  let t0;
  if ($[0] !== t) {
    t0 = t("users.actionList.emailConfirmation");
    $[0] = t;
    $[1] = t0;
  } else {
    t0 = $[1];
  }
  let t1;
  if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
    t1 = [];
    $[2] = t1;
  } else {
    t1 = $[2];
  }
  let t2;
  if ($[3] !== t0) {
    t2 = {
      label: t0,
      value: UsersActionTableEnum.sendActivationLinkAgain,
      menuItemType: MenuItemTypeEnum.item,
      list: t1
    };
    $[3] = t0;
    $[4] = t2;
  } else {
    t2 = $[4];
  }
  let t3;
  if ($[5] !== t) {
    t3 = t("users.actionList.changeStatus");
    $[5] = t;
    $[6] = t3;
  } else {
    t3 = $[6];
  }
  let t4;
  if ($[7] !== t) {
    t4 = t("users.actionList.locked");
    $[7] = t;
    $[8] = t4;
  } else {
    t4 = $[8];
  }
  let t5;
  if ($[9] !== t4) {
    t5 = {
      label: t4,
      value: UserStatusEnum.Ban
    };
    $[9] = t4;
    $[10] = t5;
  } else {
    t5 = $[10];
  }
  let t6;
  if ($[11] !== t) {
    t6 = t("users.actionList.active");
    $[11] = t;
    $[12] = t6;
  } else {
    t6 = $[12];
  }
  let t7;
  if ($[13] !== t6) {
    t7 = {
      label: t6,
      value: UserStatusEnum.Active
    };
    $[13] = t6;
    $[14] = t7;
  } else {
    t7 = $[14];
  }
  let t8;
  if ($[15] !== t5 || $[16] !== t7) {
    t8 = [t5, t7];
    $[15] = t5;
    $[16] = t7;
    $[17] = t8;
  } else {
    t8 = $[17];
  }
  let t9;
  if ($[18] !== t3 || $[19] !== t8) {
    t9 = {
      label: t3,
      value: UsersActionTableEnum.status,
      menuItemType: MenuItemTypeEnum.item,
      list: t8
    };
    $[18] = t3;
    $[19] = t8;
    $[20] = t9;
  } else {
    t9 = $[20];
  }
  let t10;
  if ($[21] !== t) {
    t10 = t("users.actionList.writeLetter");
    $[21] = t;
    $[22] = t10;
  } else {
    t10 = $[22];
  }
  let t11;
  if ($[23] === Symbol.for("react.memo_cache_sentinel")) {
    t11 = [];
    $[23] = t11;
  } else {
    t11 = $[23];
  }
  let t12;
  if ($[24] !== t10) {
    t12 = {
      label: t10,
      value: UsersActionTableEnum.writeLetter,
      menuItemType: MenuItemTypeEnum.item,
      list: t11
    };
    $[24] = t10;
    $[25] = t12;
  } else {
    t12 = $[25];
  }
  let t13;
  if ($[26] !== t) {
    t13 = t("users.actionList.changeDepartment");
    $[26] = t;
    $[27] = t13;
  } else {
    t13 = $[27];
  }
  let t14;
  if ($[28] === Symbol.for("react.memo_cache_sentinel")) {
    t14 = [];
    $[28] = t14;
  } else {
    t14 = $[28];
  }
  let t15;
  if ($[29] !== t13) {
    t15 = {
      label: t13,
      value: UsersActionTableEnum.filial,
      menuItemType: MenuItemTypeEnum.item,
      list: t14
    };
    $[29] = t13;
    $[30] = t15;
  } else {
    t15 = $[30];
  }
  let t16;
  if ($[31] !== t) {
    t16 = t("users.actionList.addRole");
    $[31] = t;
    $[32] = t16;
  } else {
    t16 = $[32];
  }
  let t17;
  if ($[33] === Symbol.for("react.memo_cache_sentinel")) {
    t17 = [];
    $[33] = t17;
  } else {
    t17 = $[33];
  }
  let t18;
  if ($[34] !== t16) {
    t18 = {
      label: t16,
      value: UsersActionTableEnum.addRoles,
      menuItemType: MenuItemTypeEnum.item,
      list: t17
    };
    $[34] = t16;
    $[35] = t18;
  } else {
    t18 = $[35];
  }
  let t19;
  if ($[36] !== t) {
    t19 = t("users.actionList.delete");
    $[36] = t;
    $[37] = t19;
  } else {
    t19 = $[37];
  }
  let t20;
  if ($[38] === Symbol.for("react.memo_cache_sentinel")) {
    t20 = [];
    $[38] = t20;
  } else {
    t20 = $[38];
  }
  let t21;
  if ($[39] !== t19) {
    t21 = {
      label: t19,
      value: UsersActionTableEnum.delete,
      menuItemType: MenuItemTypeEnum.item,
      list: t20
    };
    $[39] = t19;
    $[40] = t21;
  } else {
    t21 = $[40];
  }
  let t22;
  if ($[41] !== t12 || $[42] !== t15 || $[43] !== t18 || $[44] !== t2 || $[45] !== t21 || $[46] !== t9) {
    t22 = [t2, t9, t12, t15, t18, t21];
    $[41] = t12;
    $[42] = t15;
    $[43] = t18;
    $[44] = t2;
    $[45] = t21;
    $[46] = t9;
    $[47] = t22;
  } else {
    t22 = $[47];
  }
  const subheaderList = t22;
  return subheaderList;
};
const useChangeFilial = (setRowData, selection) => {
  const [fetchChangeFilial, resultChangeFilial] = useBulkChangeFilialMutation();
  const [fetchGetUsers] = useLazyGetUsersQuery();
  const {
    filters
  } = useAppSelector((state) => state.users);
  const {
    setUsers
  } = useActions();
  const {
    t
  } = useTranslation();
  const changeFilial = reactExports.useCallback(async (selection_0, CustomerId) => {
    const numbersSelection = (selection_0 == null ? void 0 : selection_0.map((item) => Number(item))) ?? [];
    try {
      const res = await fetchChangeFilial({
        UserIds: numbersSelection,
        CustomerId
      });
      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);
    }
  }, [selection]);
  reactExports.useEffect(() => {
    const {
      isSuccess,
      isError,
      error
    } = resultChangeFilial;
    const _errorStatus = error == null ? void 0 : error.data;
    universalNotification({
      isSuccess,
      isError,
      error: _errorStatus,
      successTitle: t("filials.successUpdate")
    });
  }, [resultChangeFilial]);
  return {
    changeFilial
  };
};
const useVerifyUsersEmail = ({
  selectedUsers,
  users,
  isConfirmModal
}) => {
  const [getVerifiedList, {
    data: CustomerEmailData,
    isSuccess,
    isLoading,
    isError
  }] = useLazyVerifyEmailServersQuery();
  const [userList, setUserList] = reactExports.useState([]);
  const [sortedList, setSortedList] = reactExports.useState([]);
  const [verifiedIds, setVerifiedIds] = reactExports.useState([]);
  const getCustomerEmailData = reactExports.useCallback(async (list) => {
    try {
      const res = await getVerifiedList(list);
      if ("error" in res) {
        const codeError = extractErrorCode(res.error);
        showNotification({
          title: generateErrorMessage(codeError),
          message: "",
          autoClose: true,
          color: "red"
        });
      }
    } catch (err) {
      console.warn("Ошибка", err);
    }
  }, []);
  reactExports.useEffect(() => {
    const data = users.filter((user) => selectedUsers == null ? void 0 : selectedUsers.includes(user.Id)).map((filtered) => {
      var _a, _b;
      return {
        isChecked: true,
        isDisabled: false,
        id: filtered.Id,
        firstName: (filtered == null ? void 0 : filtered.FirstName) || "",
        surName: (filtered == null ? void 0 : filtered.Surname) || "",
        email: filtered == null ? void 0 : filtered.Email,
        customerId: (_a = filtered == null ? void 0 : filtered.Customer) == null ? void 0 : _a.Id,
        customerName: (_b = filtered == null ? void 0 : filtered.Customer) == null ? void 0 : _b.Name,
        isConfirmed: filtered == null ? void 0 : filtered.IsConfirmed
      };
    });
    setUserList(data);
    const uniqueCustomerIds = Array.from(new Set(data.map((user_0) => user_0.customerId))).filter((customerId) => customerId !== void 0);
    if (uniqueCustomerIds == null ? void 0 : uniqueCustomerIds.length) {
      verifyCustomers(uniqueCustomerIds);
    }
  }, [selectedUsers]);
  const verifyCustomers = async (filials) => {
    await getCustomerEmailData(filials);
  };
  const isUserChecked = (user_1, isConfirmModal_0) => {
    return isConfirmModal_0 ? user_1.email && !(user_1 == null ? void 0 : user_1.isConfirmed) : user_1.email;
  };
  reactExports.useEffect(() => {
    if (CustomerEmailData == null ? void 0 : CustomerEmailData.Customers) {
      const sortedUsers = CustomerEmailData.Customers.map((customer) => {
        const usersForCustomer = userList.filter((user_2) => (user_2 == null ? void 0 : user_2.customerId) === (customer == null ? void 0 : customer.CustomerId)).map((user_3) => ({
          ...user_3,
          isChecked: isUserChecked(user_3, isConfirmModal) ? customer.HasSettings : false,
          isDisabled: isUserChecked(user_3, isConfirmModal) ? !customer.HasSettings : true
        }));
        return {
          CustomerId: customer.CustomerId,
          CustomerName: usersForCustomer[0].customerName ? usersForCustomer[0].customerName : "",
          HasSettings: customer.HasSettings,
          Users: usersForCustomer
        };
      });
      setSortedList(sortedUsers);
      setVerifiedIds(getUsersIdBySelect(sortedUsers));
    } else {
      setVerifiedIds([]);
    }
  }, [CustomerEmailData]);
  const handleClickUser = (selectedUser) => {
    const newData = sortedList.map((customer_0) => {
      if (customer_0.CustomerId === selectedUser.customerId && customer_0.HasSettings) {
        const newUsers = customer_0.Users.map((user_4) => {
          if (user_4.id === selectedUser.id && !selectedUser.isDisabled) {
            return {
              ...user_4,
              isChecked: !selectedUser.isChecked
            };
          }
          return user_4;
        });
        return {
          ...customer_0,
          Users: newUsers
        };
      }
      return customer_0;
    });
    setSortedList(newData);
    setVerifiedIds(getUsersIdBySelect(newData));
  };
  return {
    isError,
    isSuccess,
    isLoading,
    sortedList,
    handleClickUser,
    verifiedIds
  };
};
const useStyles$3 = createStyles((theme) => ({
  modalContainer: modalTheme(theme).container,
  modalFooter: {
    ...modalTheme(theme).footer,
    position: "sticky",
    bottom: 0,
    zIndex: 1
  },
  modalCancelBtn: modalTheme(theme).cancelBtn,
  link: {
    color: theme.colors.blue[9],
    "&:hover": {
      color: theme.colors.blue[4]
    }
  }
}));
const UsersListByVerifiedFilials = (t0) => {
  const $ = compilerRuntimeExports.c(27);
  const {
    sortedList,
    handleClickUser,
    isLoading
  } = t0;
  const {
    t
  } = useTranslation();
  const {
    classes
  } = useStyles$3();
  const {
    theme
  } = useStyles$3();
  const [opened, t1] = useDisclosure(false);
  const {
    toggle
  } = t1;
  let t2;
  if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
    t2 = [];
    $[0] = t2;
  } else {
    t2 = $[0];
  }
  const [isOpenStates, setIsOpenStates] = reactExports.useState(t2);
  let t3;
  if ($[1] !== isOpenStates) {
    t3 = (index) => {
      const newIsOpenStates = [...isOpenStates];
      newIsOpenStates[index] = !newIsOpenStates[index];
      setIsOpenStates(newIsOpenStates);
    };
    $[1] = isOpenStates;
    $[2] = t3;
  } else {
    t3 = $[2];
  }
  const toggleFilial = t3;
  let t4;
  if ($[3] === Symbol.for("react.memo_cache_sentinel")) {
    t4 = {
      cursor: "pointer"
    };
    $[3] = t4;
  } else {
    t4 = $[3];
  }
  let t5;
  if ($[4] !== t) {
    t5 = t("sendLetter.showUsers");
    $[4] = t;
    $[5] = t5;
  } else {
    t5 = $[5];
  }
  let t6;
  if ($[6] !== t5) {
    t6 = /* @__PURE__ */ jsxRuntimeExports.jsx(Text, { td: "underline", sx: t4, children: t5 });
    $[6] = t5;
    $[7] = t6;
  } else {
    t6 = $[7];
  }
  let t7;
  if ($[8] !== opened) {
    t7 = /* @__PURE__ */ jsxRuntimeExports.jsx(ActionIcon, { ml: "5px", children: opened ? /* @__PURE__ */ jsxRuntimeExports.jsx(gq, { size: 18, color: "#667085" }) : /* @__PURE__ */ jsxRuntimeExports.jsx(zq, { size: 18, color: "#667085" }) });
    $[8] = opened;
    $[9] = t7;
  } else {
    t7 = $[9];
  }
  let t8;
  if ($[10] !== t6 || $[11] !== t7 || $[12] !== toggle) {
    t8 = /* @__PURE__ */ jsxRuntimeExports.jsxs(Flex, { onClick: toggle, align: "center", children: [
      t6,
      t7
    ] });
    $[10] = t6;
    $[11] = t7;
    $[12] = toggle;
    $[13] = t8;
  } else {
    t8 = $[13];
  }
  let t9;
  if ($[14] !== classes || $[15] !== handleClickUser || $[16] !== isLoading || $[17] !== isOpenStates || $[18] !== opened || $[19] !== sortedList || $[20] !== t || $[21] !== theme || $[22] !== toggleFilial) {
    t9 = opened ? /* @__PURE__ */ jsxRuntimeExports.jsx(ScrollArea.Autosize, { sx: {
      maxHeight: "300px"
    }, styles: styleScroll, children: sortedList.length && !isLoading ? sortedList.map((filial, index_0) => /* @__PURE__ */ jsxRuntimeExports.jsxs(Collapse, { in: opened, py: "5px", children: [
      /* @__PURE__ */ jsxRuntimeExports.jsxs(Flex, { align: "center", onClick: () => toggleFilial(index_0), children: [
        /* @__PURE__ */ jsxRuntimeExports.jsx(ActionIcon, { children: isOpenStates[index_0] ? /* @__PURE__ */ jsxRuntimeExports.jsx(gq, { size: 18, color: "#667085" }) : /* @__PURE__ */ jsxRuntimeExports.jsx(zq, { size: 18, color: "#667085" }) }),
        /* @__PURE__ */ jsxRuntimeExports.jsx(Text, { fw: "bold", sx: {
          cursor: "pointer"
        }, ml: "5px", children: filial.CustomerName }),
        " ",
        !filial.HasSettings ? /* @__PURE__ */ jsxRuntimeExports.jsxs(Menu, { trigger: "hover", openDelay: 100, closeDelay: 400, zIndex: "1400", children: [
          /* @__PURE__ */ jsxRuntimeExports.jsx(Menu.Target, { children: /* @__PURE__ */ jsxRuntimeExports.jsx(ActionIcon, { variant: "transparent", ml: "10px", children: /* @__PURE__ */ jsxRuntimeExports.jsx(Se, { size: "20", color: "red", stroke: 1.5, cursor: "pointer" }) }) }),
          /* @__PURE__ */ jsxRuntimeExports.jsx(Menu.Dropdown, { c: "theme.colors.dark", sx: {
            background: theme.colors.brandGray[1],
            borderRadius: theme.spacing.xs,
            padding: "8px"
          }, children: /* @__PURE__ */ jsxRuntimeExports.jsxs(Text, { fz: "sm", children: [
            t("sendLetter.noSettings"),
            " ",
            /* @__PURE__ */ jsxRuntimeExports.jsx(Link, { className: classes.link, target: "_blank", to: `${ROUTES.filials.edit.clearPath}/${filial.CustomerId}/mailing-setup`, children: t("sendLetter.params") })
          ] }) })
        ] }) : null
      ] }),
      isOpenStates[index_0] && /* @__PURE__ */ jsxRuntimeExports.jsx(ScrollArea, { sx: {
        height: filial.Users.length > 4 ? "200px" : "auto",
        width: "98%"
      }, children: filial.Users.map((user, innerIndex) => /* @__PURE__ */ jsxRuntimeExports.jsx(GroupItem, { checked: user.isChecked, disabled: user.isDisabled, label: `${user.surName} ${user.firstName ?? "-"}`, handleChange: () => handleClickUser(user), value: Number(user.id), withCheckbox: true }, innerIndex)) })
    ] }, index_0)) : null }) : null;
    $[14] = classes;
    $[15] = handleClickUser;
    $[16] = isLoading;
    $[17] = isOpenStates;
    $[18] = opened;
    $[19] = sortedList;
    $[20] = t;
    $[21] = theme;
    $[22] = toggleFilial;
    $[23] = t9;
  } else {
    t9 = $[23];
  }
  let t10;
  if ($[24] !== t8 || $[25] !== t9) {
    t10 = /* @__PURE__ */ jsxRuntimeExports.jsxs(Box, { children: [
      t8,
      t9
    ] });
    $[24] = t8;
    $[25] = t9;
    $[26] = t10;
  } else {
    t10 = $[26];
  }
  return t10;
};
const VerifyEmailUsers = (t0) => {
  const $ = compilerRuntimeExports.c(30);
  const {
    open,
    setOpen,
    selectedUsers
  } = t0;
  const {
    t
  } = useTranslation();
  const {
    classes
  } = useStyles$3();
  const {
    users
  } = useAppSelector(_temp$1);
  const [sendMail, setSendMail] = reactExports.useState(false);
  let t1;
  if ($[0] !== selectedUsers || $[1] !== users) {
    t1 = {
      selectedUsers,
      users
    };
    $[0] = selectedUsers;
    $[1] = users;
    $[2] = t1;
  } else {
    t1 = $[2];
  }
  const {
    isLoading,
    sortedList,
    handleClickUser,
    verifiedIds,
    isError
  } = useVerifyUsersEmail(t1);
  let t2;
  if ($[3] === Symbol.for("react.memo_cache_sentinel")) {
    t2 = () => {
      setSendMail(true);
    };
    $[3] = t2;
  } else {
    t2 = $[3];
  }
  const handleContinue = t2;
  let t3;
  if ($[4] === Symbol.for("react.memo_cache_sentinel")) {
    t3 = () => {
      setSendMail(false);
    };
    $[4] = t3;
  } else {
    t3 = $[4];
  }
  const handleBack = t3;
  let t4;
  if ($[5] !== setOpen) {
    t4 = () => setOpen(false);
    $[5] = setOpen;
    $[6] = t4;
  } else {
    t4 = $[6];
  }
  let t5;
  if ($[7] !== sendMail || $[8] !== t) {
    t5 = sendMail ? t("sendLetter.newLetter") : t("sendLetter.writeLetter");
    $[7] = sendMail;
    $[8] = t;
    $[9] = t5;
  } else {
    t5 = $[9];
  }
  const t6 = sendMail && handleBack;
  let t7;
  if ($[10] !== classes || $[11] !== handleClickUser || $[12] !== isError || $[13] !== isLoading || $[14] !== sendMail || $[15] !== setOpen || $[16] !== sortedList || $[17] !== t || $[18] !== verifiedIds) {
    t7 = sendMail ? /* @__PURE__ */ jsxRuntimeExports.jsx(SendMailModal, { selection: verifiedIds, setOpenModal: setOpen }) : /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
      /* @__PURE__ */ jsxRuntimeExports.jsx(Box, { className: classes.modalContainer, children: !isError ? /* @__PURE__ */ jsxRuntimeExports.jsxs(Box, { sx: {
        width: "100%"
      }, children: [
        /* @__PURE__ */ jsxRuntimeExports.jsx(Text, { mb: "25px", children: t("sendLetter.sendWarning") }),
        /* @__PURE__ */ jsxRuntimeExports.jsx(UsersListByVerifiedFilials, { isLoading, sortedList, handleClickUser })
      ] }) : /* @__PURE__ */ jsxRuntimeExports.jsx(Text, { fz: "lg", children: t("requestsErrors.unknownError") }) }),
      /* @__PURE__ */ jsxRuntimeExports.jsxs(Box, { className: classes.modalFooter, children: [
        /* @__PURE__ */ jsxRuntimeExports.jsx(Button, { w: "49%", disabled: !verifiedIds.length, onClick: () => {
          handleContinue();
        }, children: t("continue") }),
        /* @__PURE__ */ jsxRuntimeExports.jsx(UnstyledButton, { w: "49%", className: classes.modalCancelBtn, onClick: () => setOpen(false), children: t("cancel") })
      ] })
    ] });
    $[10] = classes;
    $[11] = handleClickUser;
    $[12] = isError;
    $[13] = isLoading;
    $[14] = sendMail;
    $[15] = setOpen;
    $[16] = sortedList;
    $[17] = t;
    $[18] = verifiedIds;
    $[19] = t7;
  } else {
    t7 = $[19];
  }
  let t8;
  if ($[20] === Symbol.for("react.memo_cache_sentinel")) {
    t8 = {
      blur: 2
    };
    $[20] = t8;
  } else {
    t8 = $[20];
  }
  let t9;
  if ($[21] !== isLoading) {
    t9 = /* @__PURE__ */ jsxRuntimeExports.jsx(LoadingOverlay, { visible: isLoading, overlayProps: t8 });
    $[21] = isLoading;
    $[22] = t9;
  } else {
    t9 = $[22];
  }
  let t10;
  if ($[23] !== open || $[24] !== t4 || $[25] !== t5 || $[26] !== t6 || $[27] !== t7 || $[28] !== t9) {
    t10 = /* @__PURE__ */ jsxRuntimeExports.jsxs(Modal, { size: "500px", zIndex: 1400, opened: open, onClose: t4, title: t5, onBackClick: t6, children: [
      t7,
      t9
    ] });
    $[23] = open;
    $[24] = t4;
    $[25] = t5;
    $[26] = t6;
    $[27] = t7;
    $[28] = t9;
    $[29] = t10;
  } else {
    t10 = $[29];
  }
  return t10;
};
function _temp$1(state) {
  return state.users;
}
const useStyles$2 = createStyles((theme) => ({
  modalContainer: modalTheme(theme).container,
  modalFooter: {
    ...modalTheme(theme).footer,
    position: "sticky",
    bottom: 0,
    zIndex: 1
  },
  modalCancelBtn: modalTheme(theme).cancelBtn,
  root: {
    width: "100%",
    height: "100%",
    display: "flex",
    flexDirection: "column"
  },
  title: {
    width: "100%"
  },
  description: {
    width: "100%"
  }
}));
const SendEmailActivationModal = ({
  open,
  setOpen,
  selectedUsers
}) => {
  const {
    classes
  } = useStyles$2();
  const {
    t
  } = useTranslation();
  const {
    sendEmailActivation,
    isLoading: isSendingActivation
  } = useEmailActivation();
  const {
    users
  } = useAppSelector((state) => state.users);
  const {
    isLoading,
    sortedList,
    handleClickUser,
    verifiedIds,
    isError
  } = useVerifyUsersEmail({
    selectedUsers,
    users,
    isConfirmModal: true
  });
  const handleConfirm = reactExports.useCallback(async () => {
    await sendEmailActivation(verifiedIds);
    setOpen(false);
  }, [verifiedIds.length]);
  return /* @__PURE__ */ jsxRuntimeExports.jsxs(Modal, { size: "500px", zIndex: 1400, opened: open, onClose: () => setOpen(false), title: t("sendLetter.confirmLetter"), children: [
    /* @__PURE__ */ jsxRuntimeExports.jsx(Box, { className: classes.modalContainer, children: !isError ? /* @__PURE__ */ jsxRuntimeExports.jsxs(Box, { sx: {
      width: "100%"
    }, children: [
      /* @__PURE__ */ jsxRuntimeExports.jsx(Text, { mb: "25px", children: t("sendLetter.sendActivationsDescription") }),
      /* @__PURE__ */ jsxRuntimeExports.jsx(UsersListByVerifiedFilials, { isLoading, sortedList, handleClickUser })
    ] }) : /* @__PURE__ */ jsxRuntimeExports.jsx(Text, { fz: "lg", children: t("requestsErrors.unknownError") }) }),
    /* @__PURE__ */ jsxRuntimeExports.jsxs(Box, { className: classes.modalFooter, children: [
      /* @__PURE__ */ jsxRuntimeExports.jsx(Button, { w: "49%", disabled: !verifiedIds.length, onClick: handleConfirm, children: t("send") }),
      /* @__PURE__ */ jsxRuntimeExports.jsx(UnstyledButton, { w: "49%", className: classes.modalCancelBtn, onClick: () => setOpen(false), children: t("cancel") })
    ] }),
    /* @__PURE__ */ jsxRuntimeExports.jsx(LoadingOverlay, { visible: isLoading || isSendingActivation, overlayProps: {
      blur: 2
    } })
  ] });
};
const Control = ({
  selection,
  rowData,
  toggleAll,
  deselectAll,
  columns,
  setColumnsData,
  setRowData,
  simpleColumns,
  scrollRef
}) => {
  const {
    classes
  } = useStyles$4();
  const {
    t
  } = useTranslation();
  const actionList = useGetActionList();
  const {
    users
  } = useAppSelector((state) => state.users);
  const [fetchGetUsers] = useLazyGetUsersQuery();
  const {
    filters: usersFilter,
    total
  } = useAppSelector((state_0) => state_0.users);
  const {
    setColumnVisibility
  } = useActions();
  const [type, setType] = reactExports.useState("");
  const [checkboxValues, setCheckboxValues] = reactExports.useState([]);
  const isMobile = useMediaQuery("(max-width: 576px)");
  const {
    changeStatuses
  } = useChangeStatuses(setRowData);
  const {
    changeRoles
  } = useChangeRoles(setRowData, selection);
  const {
    changeFilial
  } = useChangeFilial(setRowData, selection);
  const {
    handleAddRoles
  } = useAddRoles(selection, setRowData);
  const {
    resetPassword
  } = useResetPassword();
  const [openVerifyEmailModal, setOpenVerifyEmailModal] = reactExports.useState(false);
  const [openSendEmailActivationModal, setOpenSendEmailActivationModal] = reactExports.useState(false);
  const [openAddRolesModal, setOpenAddRolesModal] = reactExports.useState(false);
  const [openDeleteUsersModal, setOpenDeleteUsersModal] = reactExports.useState(false);
  const [selectedRoles, setSelectedRoles] = reactExports.useState({});
  const [groups, setGroups] = reactExports.useState([]);
  const handleAddRole = (roles) => {
    const rolesIds = roles == null ? void 0 : roles.map((role) => role.Id);
    handleAddRoles(selection, rolesIds);
    setOpenAddRolesModal(false);
  };
  const closeAddRolesModal = () => {
    setOpenAddRolesModal(false);
  };
  const handleOpenAddRolesModal = () => {
    setOpenAddRolesModal(true);
  };
  const handleOpenDeleteUsersModal = () => {
    setOpenDeleteUsersModal(true);
  };
  const handleCloseDeleteUsersModal = () => {
    setOpenDeleteUsersModal(false);
  };
  const handleChangeCheckbox = reactExports.useCallback((event) => {
    const value = event.currentTarget.dataset.checkbox ?? "";
    setCheckboxValues((prevState) => [...prevState, Number(value)]);
  }, []);
  const getAllUserByFilters = async () => {
    const {
      data
    } = await fetchGetUsers({
      Count: total,
      Offset: 0,
      SortOrder: 0,
      SortField: 0,
      Query: usersFilter.Query,
      FilterConditions: usersFilter.FilterConditions
    });
    if (data === void 0) {
      return [];
    }
    return data.Users;
  };
  const handleClickListItem = reactExports.useCallback(async (event_0) => {
    const value_0 = event_0.currentTarget.dataset.value ?? "";
    const valueNumber = Number(value_0);
    if (type === UsersActionTableEnum.export) {
      if (value_0 === "export") {
        downloadCsv(rowData, simpleColumns);
      } else if (value_0 === "export-all") {
        const allData = await getAllUserByFilters();
        downloadCsv(allData, simpleColumns);
      }
    } else {
      if (selection.length) {
        switch (type) {
          case UsersActionTableEnum.role:
            await changeRoles(selection, checkboxValues);
            break;
          case UsersActionTableEnum.filial:
            await changeFilial(selection, valueNumber);
            break;
          case UsersActionTableEnum.department:
            break;
          case UsersActionTableEnum.status:
            await changeStatuses(selection, valueNumber);
            break;
        }
      } else {
        showNotification({
          title: t("roles.noSelectedUsers"),
          message: "",
          autoClose: true,
          color: "yellow"
        });
      }
    }
  }, [selection, type, checkboxValues, rowData, simpleColumns]);
  const handleClickBadge = reactExports.useCallback(async (event_1) => {
    const type_0 = event_1.currentTarget.dataset.type ?? "";
    setType(type_0);
    if (selection.length) {
      switch (type_0) {
        case UsersActionTableEnum.sendActivationLinkAgain:
          setOpenSendEmailActivationModal(true);
          break;
        case UsersActionTableEnum.writeLetter:
          setOpenVerifyEmailModal(true);
          break;
        case UsersActionTableEnum.removedUser:
          await changeStatuses(selection, UserStatusEnum.Deleted);
          break;
        case UsersActionTableEnum.resetPassword:
          await resetPassword(selection);
          break;
        case UsersActionTableEnum.addRoles:
          handleOpenAddRolesModal();
          break;
        case UsersActionTableEnum.delete:
          handleOpenDeleteUsersModal();
          break;
      }
    } else {
      if ([UsersActionTableEnum.sendActivationLinkAgain, UsersActionTableEnum.writeLetter, UsersActionTableEnum.removedUser, UsersActionTableEnum.resetPassword, UsersActionTableEnum.addRoles, UsersActionTableEnum.delete].includes(type_0)) showNotification({
        title: t("roles.noSelectedUsers"),
        message: "",
        autoClose: true,
        color: "yellow"
      });
    }
  }, [selection]);
  reactExports.useEffect(() => {
    if (selection.length === 1) {
      const selectedUser = users.find((user) => user.Id === selection[0]);
      setGroups((selectedUser == null ? void 0 : selectedUser.Roles) || []);
    } else {
      setGroups([]);
    }
  }, [selection, users]);
  return /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
    /* @__PURE__ */ jsxRuntimeExports.jsxs(Box, { className: classes.root, children: [
      /* @__PURE__ */ jsxRuntimeExports.jsxs(Box, { className: classes.leftSection, children: [
        selection && /* @__PURE__ */ jsxRuntimeExports.jsx(Checkbox, { size: "sm", className: classes.checkbox, onChange: () => {
          if (selection.length > 0 && selection.length !== rowData.length) {
            deselectAll();
          } else if (rowData.length > 0) {
            toggleAll();
          }
        }, checked: Boolean(rowData.length > 0 && selection.length > 0 && selection.length === rowData.length), indeterminate: selection.length > 0 && selection.length !== rowData.length, "data-cy": "selectAllCheckbox" }),
        isMobile && /* @__PURE__ */ jsxRuntimeExports.jsx(Box, { className: classes.rightSection, children: /* @__PURE__ */ jsxRuntimeExports.jsx(TableColumnsAction, { setColumnsData, list: columns, setColumnVisibility }) }),
        actionList == null ? void 0 : actionList.map((item, index) => {
          return item.value === UsersActionTableEnum.filial ? /* @__PURE__ */ jsxRuntimeExports.jsx(FilialsControl, { handleClickListItem, handleClick: handleClickBadge, disabled: !selection.length, item }, index) : /* @__PURE__ */ jsxRuntimeExports.jsx(BadgeMenu, { item, handleClickListItem, handleClick: handleClickBadge, handleChangeCheckbox, ddmClassNames: {
            dropdown: classes.menu
          }, ddmWidth: "190px", disabled: !selection.length }, index);
        })
      ] }),
      !isMobile && /* @__PURE__ */ jsxRuntimeExports.jsx(Box, { className: classes.rightSection, children: /* @__PURE__ */ jsxRuntimeExports.jsx(TableColumnsAction, { setColumnsData, list: columns, setColumnVisibility }) })
    ] }),
    openVerifyEmailModal && /* @__PURE__ */ jsxRuntimeExports.jsx(VerifyEmailUsers, { open: openVerifyEmailModal, setOpen: setOpenVerifyEmailModal, selectedUsers: selection }),
    openSendEmailActivationModal && /* @__PURE__ */ jsxRuntimeExports.jsx(SendEmailActivationModal, { open: openSendEmailActivationModal, setOpen: setOpenSendEmailActivationModal, openSendEmail: setOpenSendEmailActivationModal, selectedUsers: selection }),
    /* @__PURE__ */ jsxRuntimeExports.jsx(SelectGroupModal, { isOpened: openAddRolesModal, title: t("profile.addRole"), onClose: closeAddRolesModal, setSelectedGroup: setSelectedRoles, selectedGroup: selectedRoles, setGroups: handleAddRole, groups }),
    openDeleteUsersModal && /* @__PURE__ */ jsxRuntimeExports.jsx(DeleteUser, { isOpened: openDeleteUsersModal, selectedUsers: selection, handleClose: handleCloseDeleteUsersModal, setRowData, scrollRef })
  ] });
};
const useStyles$1 = createStyles((theme) => ({
  root: {
    "& .mantine-Drawer-body": {
      height: "100%",
      padding: theme.spacing.sm,
      overflow: "auto"
    },
    "& .mantine-Paper-root": {
      width: "384px"
    }
  }
}));
const UserInfoMain = ({
  setRowData
}) => {
  const {
    classes
  } = useStyles$1();
  const navigate = useNavigate();
  const [isOpened, setIsOpened] = reactExports.useState(false);
  const {
    setSelectedUserId
  } = useActions();
  const {
    selectedUserId
  } = useAppSelector((state) => state.users);
  const {
    id
  } = useParams();
  const toNumberId = reactExports.useMemo(() => Number(id), [id]);
  reactExports.useEffect(() => {
    if (toNumberId) {
      setSelectedUserId(toNumberId);
      setIsOpened(true);
    } else {
      handleClose();
    }
  }, [toNumberId]);
  const [activePanel, setActivePanel] = reactExports.useState(PanelsEnum.generalInformation);
  const handleClose = reactExports.useCallback(() => {
    setIsOpened(false);
    setSelectedUserId(0);
    navigate("/users");
    setActivePanel(PanelsEnum.generalInformation);
  }, []);
  return /* @__PURE__ */ jsxRuntimeExports.jsx(Drawer, { zIndex: 1100, opened: isOpened, onClose: handleClose, position: "right", withCloseButton: false, className: classes.root, lockScroll: true, children: selectedUserId ? /* @__PURE__ */ jsxRuntimeExports.jsx(Panels, { activePanel, setActivePanel, selectedUserId, setRowData, handleClose }) : null });
};
const useStyles = createStyles((theme, _, utils) => ({
  container: {
    height: `calc(100vh - ${HEADER_HEIGHT}px)`,
    width: "100%",
    display: "flex",
    alignItems: "center",
    justifyContent: "flex-start",
    flexDirection: "column",
    backgroundColor: theme.colors.backgroundGray[0]
  },
  list: {
    width: "calc(100vw - 264px)"
  },
  listItem: {
    display: "flex",
    alignItems: "center",
    justifyContent: "center",
    flexDirection: "column"
  },
  searchWrapper: {
    backgroundColor: theme.colors.backgroundGray[0],
    padding: "0 24px 0 24px",
    width: "100%",
    margin: "24px 0 20px 0",
    display: "flex",
    justifyContent: "space-between",
    alignItems: "flex-start",
    [utils.largerThan("xs")]: {
      alignItems: "center"
    }
  },
  filtersListWrapper: {
    width: `calc(100% - 48px)`,
    padding: `${theme.spacing.sm} ${theme.spacing.md} ${theme.spacing.sm} ${theme.spacing.sm}`,
    display: "flex",
    justifyContent: "space-between",
    backgroundColor: "white",
    overflowX: "auto",
    msOverflowStyle: "none",
    scrollbarWidth: "none",
    "&::-webkit-scrollbar": {
      display: "none"
    },
    "& .mantine-Menu-dropdown": {
      padding: theme.spacing.sm
    }
  },
  createButton: {
    display: "flex",
    alignItems: "center",
    justifyContent: "flex-start",
    borderRadius: theme.spacing.xs,
    span: {
      height: "auto",
      marginRight: "8px",
      div: {
        margin: "0"
      }
    },
    [utils.smallerThan("lg")]: {
      padding: "15px",
      justifyContent: "center",
      span: {
        margin: "0"
      }
    }
  },
  search: {
    marginRight: "27px",
    "& input": {
      backgroundColor: theme.colors.backgroundGray[6],
      paddingLeft: "56px",
      height: "45px",
      fontSize: "16px"
    },
    "& .mantine-Input-section": {
      marginLeft: "15px"
    },
    [utils.smallerThan("xs")]: {
      marginBottom: 15
    }
  },
  avatar: {
    cursor: "pointer"
  },
  error: {
    display: "flex",
    alignItems: "center",
    justifyContent: "center",
    flexDirection: "column"
  }
}));
const UsersSearch = () => {
  const $ = compilerRuntimeExports.c(13);
  const {
    classes
  } = useStyles();
  const {
    t
  } = useTranslation();
  const {
    setUsersTableFilters
  } = useActions();
  const {
    filters: usersFilter
  } = useAppSelector(_temp);
  const [text, setText] = reactExports.useState(usersFilter.Query || "");
  const debounced = useDebounce(text, 500);
  let t0;
  if ($[0] !== debounced || $[1] !== setUsersTableFilters || $[2] !== usersFilter) {
    t0 = () => {
      setUsersTableFilters({
        ...usersFilter,
        Offset: 0,
        Query: debounced
      });
    };
    $[0] = debounced;
    $[1] = setUsersTableFilters;
    $[2] = usersFilter;
    $[3] = t0;
  } else {
    t0 = $[3];
  }
  let t1;
  if ($[4] !== debounced) {
    t1 = [debounced];
    $[4] = debounced;
    $[5] = t1;
  } else {
    t1 = $[5];
  }
  reactExports.useEffect(t0, t1);
  let t2;
  if ($[6] === Symbol.for("react.memo_cache_sentinel")) {
    t2 = /* @__PURE__ */ jsxRuntimeExports.jsx(SearchIcon, {});
    $[6] = t2;
  } else {
    t2 = $[6];
  }
  const t3 = classes.search;
  let t4;
  if ($[7] !== t) {
    t4 = t("users.search");
    $[7] = t;
    $[8] = t4;
  } else {
    t4 = $[8];
  }
  let t5;
  if ($[9] !== classes.search || $[10] !== t4 || $[11] !== text) {
    t5 = /* @__PURE__ */ jsxRuntimeExports.jsx(Search, { "data-cy": "searchUserInput", icon: t2, setSearch: setText, className: t3, fullSize: true, value: text, placeholder: t4 });
    $[9] = classes.search;
    $[10] = t4;
    $[11] = text;
    $[12] = t5;
  } else {
    t5 = $[12];
  }
  return t5;
};
function _temp(state) {
  return state.users;
}
const CreateButton = () => {
  const $ = compilerRuntimeExports.c(16);
  const {
    classes
  } = useStyles();
  const {
    t
  } = useTranslation();
  const isMobile = useMediaQuery("(max-width: 1200px)");
  const [opened, t0] = useDisclosure(false);
  const {
    open,
    close
  } = t0;
  let t1;
  if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
    t1 = /* @__PURE__ */ jsxRuntimeExports.jsx(XMe, {});
    $[0] = t1;
  } else {
    t1 = $[0];
  }
  let t2;
  if ($[1] !== isMobile || $[2] !== t) {
    t2 = isMobile ? "" : t("create");
    $[1] = isMobile;
    $[2] = t;
    $[3] = t2;
  } else {
    t2 = $[3];
  }
  let t3;
  if ($[4] !== t2) {
    t3 = /* @__PURE__ */ jsxRuntimeExports.jsx(Text, { fw: "600", children: t2 });
    $[4] = t2;
    $[5] = t3;
  } else {
    t3 = $[5];
  }
  let t4;
  if ($[6] !== classes.createButton || $[7] !== open || $[8] !== t3) {
    t4 = /* @__PURE__ */ jsxRuntimeExports.jsx(Button, { size: "md", leftSection: t1, type: "button", className: classes.createButton, onClick: open, "data-cy": "createNewUserButton", children: t3 });
    $[6] = classes.createButton;
    $[7] = open;
    $[8] = t3;
    $[9] = t4;
  } else {
    t4 = $[9];
  }
  let t5;
  if ($[10] !== close || $[11] !== opened) {
    t5 = opened && /* @__PURE__ */ jsxRuntimeExports.jsx(CreateUserModal, { opened, modalClose: () => {
      close();
    } });
    $[10] = close;
    $[11] = opened;
    $[12] = t5;
  } else {
    t5 = $[12];
  }
  let t6;
  if ($[13] !== t4 || $[14] !== t5) {
    t6 = /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
      t4,
      t5
    ] });
    $[13] = t4;
    $[14] = t5;
    $[15] = t6;
  } else {
    t6 = $[15];
  }
  return t6;
};
const Users = () => {
  const {
    classes
  } = useStyles();
  const {
    filtersMenuList,
    isFetching: isFetchingFilters
  } = useGetUsersFilters();
  const {
    setUsers,
    setUsersTableFilters,
    setSelectedAllUsers,
    setSelectedUsersIds
  } = useActions();
  const {
    users,
    total,
    filters: usersFilter,
    selected: selectedUsers,
    columnVisibility
  } = useAppSelector((state) => state.users);
  const scrollRef = reactExports.useRef(null);
  const isMobile = useMediaQuery("(max-width: 576px)");
  const navigate = useNavigate();
  const [rowData, setRowData] = reactExports.useState(users);
  const [activeFilters, setActiveFilters] = reactExports.useState(() => (usersFilter == null ? void 0 : usersFilter.FilterConditions) ? transformConditionals(usersFilter == null ? void 0 : usersFilter.FilterConditions) : {});
  const [usersFilters, setUsersFilters] = reactExports.useState(filtersMenuList);
  const [sortParams, setSortParams] = reactExports.useState({
    SortOrder: usersFilter.SortOrder,
    SortField: usersFilter.SortField
  });
  reactExports.useEffect(() => {
    if (filtersMenuList.length) {
      setUsersFilters(filtersMenuList);
    }
  }, [filtersMenuList]);
  const {
    data,
    error,
    isLoading,
    isFetching
  } = useGetUsersQuery({
    Count: 20,
    Offset: usersFilter.Offset,
    SortOrder: usersFilter.SortOrder,
    SortField: usersFilter.SortField,
    Filters: {},
    Query: usersFilter.Query,
    FilterConditions: usersFilter.FilterConditions
  });
  const handleSelectedAll = () => setSelectedAllUsers(rowData.map((object) => object.Id));
  const deselectAll = () => setSelectedAllUsers([]);
  const handleSelected = (event) => {
    const id = Number(event.currentTarget.dataset.id);
    if (id) {
      setSelectedUsersIds(id);
    }
  };
  const {
    columns,
    setColumns,
    simpleColumns
  } = useGetColumns(handleSelected, setRowData, columnVisibility, scrollRef);
  const handleRowClick = reactExports.useCallback((id_0) => {
    navigate(`/users/${id_0}`);
  }, []);
  const handleLoadMore = () => {
    setUsersTableFilters({
      ...usersFilter,
      Offset: usersFilter.Offset + 20
    });
  };
  const handleFilterChange = reactExports.useCallback(({
    Type,
    value
  }) => {
    setActiveFilters((PrevFilters) => {
      const updatedData = {
        ...PrevFilters
      };
      if (Array.isArray(value)) {
        updatedData[Type] = value;
      } else {
        if (typeof value === "number") {
          const array = updatedData[Type] || [];
          updatedData[Type] = array.includes(value) ? array.filter((val) => val !== value) : [...array, value];
        }
      }
      const updatedFilters = {
        ...PrevFilters,
        ...updatedData
      };
      setUsersTableFilters({
        ...usersFilter,
        FilterConditions: convertToFilterConditions(updatedFilters),
        Offset: 0
      });
      scrollRef.current.el.scrollTo(0, 0);
      return updatedFilters;
    });
  }, [usersFilter, activeFilters]);
  const resetActiveFilterByType = reactExports.useCallback((type) => {
    setActiveFilters((prevNumbers) => {
      const updatedNumbers = {
        ...prevNumbers
      };
      delete updatedNumbers[type];
      setUsersTableFilters({
        ...usersFilter,
        FilterConditions: convertToFilterConditions(updatedNumbers),
        Offset: 0
      });
      return updatedNumbers;
    });
  }, []);
  const resetAllActiveFilters = reactExports.useCallback(() => {
    setActiveFilters({});
    setUsersTableFilters({
      ...usersFilter,
      FilterConditions: [],
      Offset: 0,
      Query: ""
    });
  }, []);
  const handleSortTable = (payload) => {
    setSortParams({
      SortOrder: payload.SortOrder === true ? 1 : 0,
      SortField: transformUsersSortFieldToNumber(payload.SortField)
    });
  };
  reactExports.useEffect(() => {
    if (data) {
      const usersData = usersFilter.Offset > 0 ? [...users, ...data.Users] : data == null ? void 0 : data.Users;
      setUsers({
        ...data,
        Users: usersData
      });
    }
  }, [data]);
  reactExports.useEffect(() => {
    setRowData(users || []);
  }, [users]);
  reactExports.useEffect(() => {
    return () => {
      resetAllActiveFilters();
    };
  }, []);
  reactExports.useEffect(() => {
    setUsersTableFilters({
      ...usersFilter,
      Offset: 0,
      SortField: sortParams == null ? void 0 : sortParams.SortField,
      SortOrder: sortParams == null ? void 0 : sortParams.SortOrder
    });
  }, [sortParams]);
  return /* @__PURE__ */ jsxRuntimeExports.jsx(ErrorBoundary, { componentTitle: "Users page", children: /* @__PURE__ */ jsxRuntimeExports.jsxs(Layout, { children: [
    /* @__PURE__ */ jsxRuntimeExports.jsxs(Box, { className: classes.container, children: [
      /* @__PURE__ */ jsxRuntimeExports.jsxs(Box, { className: classes.searchWrapper, children: [
        /* @__PURE__ */ jsxRuntimeExports.jsx(UsersSearch, {}),
        /* @__PURE__ */ jsxRuntimeExports.jsx(CreateButton, {})
      ] }),
      /* @__PURE__ */ jsxRuntimeExports.jsxs(Box, { className: classes.filtersListWrapper, children: [
        isFetchingFilters && /* @__PURE__ */ jsxRuntimeExports.jsx(FilterSkeleton, { count: 5 }),
        !isFetchingFilters && /* @__PURE__ */ jsxRuntimeExports.jsx(UsersFilterList, { handleFilterReset: resetActiveFilterByType, handleResetFilters: resetAllActiveFilters, activeFilters, handleFilterChange, filtersMenuList: usersFilters })
      ] }),
      /* @__PURE__ */ jsxRuntimeExports.jsx(Control, { columns, rowData, selection: selectedUsers || [], toggleAll: handleSelectedAll, deselectAll, setColumnsData: setColumns, setRowData, simpleColumns, scrollRef }),
      /* @__PURE__ */ jsxRuntimeExports.jsx(
        SimpleTable,
        {
          dataCy: "userTable",
          sort: {
            SortOrder: sortParams.SortOrder !== 0,
            SortField: transformNumberToUsersSortField(sortParams.SortField)
          },
          setSort: handleSortTable,
          allDataLength: total,
          rowData,
          setRowData,
          columns,
          height: `calc(100vh - ${isMobile ? "320px" : "296px"})`,
          minWidth: 700,
          width: "calc(100vw - 48px)",
          selection: selectedUsers,
          handleRowClick,
          getNextData: handleLoadMore,
          error,
          scrollRef,
          isLoading,
          isFetching
        }
      )
    ] }),
    /* @__PURE__ */ jsxRuntimeExports.jsx(Outlet, {}),
    /* @__PURE__ */ jsxRuntimeExports.jsx(UserInfoMain, { setRowData })
  ] }) });
};
export {
  Users
};
//# sourceMappingURL=index-1TpVQR3a.js.map
