import { E as compilerRuntimeExports, T as useNavigate, j as jsxRuntimeExports, r as reactExports } from "./vendor-react-DYNCg6N5.js";
import { m as modalTheme } from "./styles-3NoIlzov.js";
import { c as createStyles, b as Box, O as Badge, T as Text, F as Flex, h as ActionIcon, J as PasswordInput, B as Button, U as UnstyledButton, a2 as Overlay, a3 as CloseIcon, i as Indicator, S as Stack, a4 as Select, W as useMediaQuery, a0 as SimpleGrid, R as Radio, _ as useDirection, n as useDisclosure, G as Group, Q as Collapse, a5 as openContextModal, z as useForm, l as ScrollArea, V as LoadingOverlay, s as showNotification } from "./vendor-mantine-h0WlM2Mj.js";
import { M as Modal } from "./index-DqcA8P_y.js";
import { i as initForm } from "./index-TL41xEJi.js";
import { c as useAppSelector, i as isSaaS, R as ROUTES, m as universalNotification, a0 as UserAvatar, aa as useLazyEmailServerDomainsQuery, O as themeColors, ab as useLazyCheckCanCreateUserQuery, ac as useLazyGetFilialsInfoCommonQuery, ad as useAddMutation, a6 as clearApiCacheByTags, ae as usersApi } from "./index-DfebxkL9.js";
import { g as getValidateErrors } from "./validation-Ds00Zghx.js";
import { v as validateSchemeStatus, a as validateSchemePositions, b as validateSchemeCustomer, c as validateSchemeCreateCredentials, d as validateSchemeEditUserInfo, e as validateSchemeDataStorageQuota } from "./validate-Bw-sUlFj.js";
import { C as CreateUserContext } from "./options-CRIRDAK6.js";
import { M as MessageContainer } from "./index-CNv4hlnY.js";
import { l as lG, b as gq, m as Dze, n as Bq } from "./vendor-icons-xWhXK_Ui.js";
import { c as copyToClipboard } from "./utils-D5kCyTRM.js";
import { O as OverflowTip } from "./index-C-CFogWu.js";
import { u as useTranslation } from "./vendor-i18n-wisIXUFi.js";
import { A as AvatarEditor, S as StatusSelect, G as Gender, a as Address, V as ValidatePhoneInput, P as Phone } from "./index-B9yUPW9X.js";
import { b as base64ToBlob } from "./index-zpOhy7mV.js";
import { u as uploadFile } from "./index-CEv9Eejp.js";
import { T as TextFieldInput } from "./index-BvQfhnV_.js";
import { V as ValidateTextInput } from "./validateTextInput-2E2Z5K9Z.js";
import { D as DatePicker } from "./index-DFZKJmic.js";
import { S as SelectWithPagination } from "./index-CfN7Ll0p.js";
import { S as SelectQuotas } from "./index-BoQKW1g7.js";
import { R as Roles } from "./index-DOixMRp5.js";
import { P as Positions } from "./index-CUcivY9l.js";
import { u as useGenerateRules, R as RulesConditionList, d as defaultMailServerPasswordOptions } from "./passwordOptions-b-kjbiiT.js";
import { o as objectType } from "./types-espwwxTQ.js";
const useStyles$8 = createStyles((theme) => ({
  modalContainer: modalTheme(theme).container
}));
const iconUser = "data:image/svg+xml,%3csvg%20width='110'%20height='110'%20viewBox='0%200%20110%20110'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3crect%20x='5'%20y='5'%20width='100'%20height='100'%20rx='50'%20fill='%23FFE8CC'/%3e%3crect%20x='5'%20y='5'%20width='100'%20height='100'%20rx='50'%20stroke='%23FFF4E6'%20stroke-width='10'/%3e%3cpath%20d='M40%2077.5V72.5C40%2069.8478%2041.0536%2067.3043%2042.9289%2065.4289C44.8043%2063.5536%2047.3478%2062.5%2050%2062.5H60C60.87%2062.5%2061.715%2062.6125%2062.52%2062.82M72.5%2065V72.5M72.5%2080V80.025M45%2042.5C45%2045.1522%2046.0536%2047.6957%2047.9289%2049.5711C49.8043%2051.4464%2052.3478%2052.5%2055%2052.5C57.6522%2052.5%2060.1957%2051.4464%2062.0711%2049.5711C63.9464%2047.6957%2065%2045.1522%2065%2042.5C65%2039.8478%2063.9464%2037.3043%2062.0711%2035.4289C60.1957%2033.5536%2057.6522%2032.5%2055%2032.5C52.3478%2032.5%2049.8043%2033.5536%2047.9289%2035.4289C46.0536%2037.3043%2045%2039.8478%2045%2042.5Z'%20stroke='%23FD7E14'%20stroke-width='2.33'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3c/svg%3e";
const useStyles$7 = createStyles((theme) => ({
  modalContainer: modalTheme(theme).container,
  modalFooter: modalTheme(theme).footer,
  root: {
    display: "flex",
    flexDirection: "column",
    margin: "auto",
    paddingTop: "20px",
    width: "100%",
    justifyContent: "center",
    alignItems: "center",
    boxSizing: "border-box"
  },
  userContainer: {
    display: "flex",
    justifyContent: "center",
    alignItems: "center",
    flexDirection: "column",
    cursor: "pointer"
  },
  info: {
    display: "flex",
    flexDirection: "column"
  },
  dataContainer: {
    width: "400px",
    flexDirection: "row",
    alignItems: "center",
    justifyContent: "space-between",
    "@media (max-width: 574px)": {
      width: "300px"
    }
  },
  label: {
    textTransform: "uppercase",
    color: "#868E96",
    fontWeight: "500",
    width: "60px"
  },
  tip: {
    fontSize: "14px",
    lineHeight: "204%"
  },
  description: {
    maxWidth: "350px",
    width: "100%",
    fontSize: "14px",
    "@media (max-width: 574px)": {
      maxWidth: "200px"
    }
  },
  passwordInput: {
    width: "100%",
    maxWidth: "350px",
    "@media (max-width: 574px)": {
      maxWidth: "280px"
    },
    "& .mantine-PasswordInput-input": {
      fontSize: "14px",
      border: "none"
    },
    '[type="password"]': {
      letterSpacing: "2px"
    }
  },
  copyIcon: {
    cursor: "pointer"
  },
  cancelBtn: {
    display: "flex",
    alignItems: "center",
    justifyContent: "center",
    height: "36px",
    borderRadius: "8px",
    padding: `8px ${theme.spacing.sm}`,
    backgroundColor: theme.colors.brandGray[1],
    fontSize: "14px",
    color: "#101828",
    fontWeight: 600,
    lineHeight: "17px",
    "&:hover": {
      backgroundColor: "#eff0f4"
    }
  },
  badge: {
    paddingRight: 3,
    backgroundColor: theme.colors.backgroundGray[6],
    color: "black",
    borderRadius: "16px",
    marginRight: theme.spacing.xs,
    marginBottom: theme.spacing.xs,
    border: "none",
    textTransform: "inherit",
    height: "28px",
    fontSize: "14px",
    padding: theme.spacing.xs,
    fontWeight: 400
  },
  roleBox: {
    marginBottom: "20px",
    display: "flex",
    alignItems: "center",
    flexWrap: "wrap",
    justifyContent: "center"
  }
}));
const SuccessUserModal = (t0) => {
  var _a;
  const $ = compilerRuntimeExports.c(91);
  const {
    modalClose,
    createUser,
    userInfo,
    avatar
  } = t0;
  const {
    classes
  } = useStyles$7();
  const {
    t
  } = useTranslation();
  const navigate = useNavigate();
  const {
    Settings
  } = useAppSelector(_temp$2);
  let t1;
  if ($[0] !== modalClose || $[1] !== navigate || $[2] !== userInfo) {
    t1 = () => {
      if (userInfo == null ? void 0 : userInfo.Id) {
        modalClose();
        navigate(`${ROUTES.profile.path}/${userInfo.Id}`);
      }
    };
    $[0] = modalClose;
    $[1] = navigate;
    $[2] = userInfo;
    $[3] = t1;
  } else {
    t1 = $[3];
  }
  const goToUserProfile = t1;
  let t2;
  if ($[4] !== t) {
    t2 = async (textToCopy) => {
      if (textToCopy) {
        try {
          await copyToClipboard(textToCopy);
          universalNotification({
            isError: false,
            error: null,
            isSuccess: true,
            successTitle: t("copied")
          });
        } catch (t33) {
          const e = t33;
          console.error("Failed to copy to clipboard:", e);
        }
      }
    };
    $[4] = t;
    $[5] = t2;
  } else {
    t2 = $[5];
  }
  const copyText = t2;
  let t3;
  if ($[6] === Symbol.for("react.memo_cache_sentinel")) {
    t3 = {
      paddingBottom: "100px"
    };
    $[6] = t3;
  } else {
    t3 = $[6];
  }
  const t4 = userInfo == null ? void 0 : userInfo.Common;
  const t5 = userInfo == null ? void 0 : userInfo.Id;
  let t6;
  if ($[7] !== avatar || $[8] !== t4 || $[9] !== t5) {
    t6 = /* @__PURE__ */ jsxRuntimeExports.jsx(UserAvatar, { size: "126", src: avatar, user: t4, userId: t5 });
    $[7] = avatar;
    $[8] = t4;
    $[9] = t5;
    $[10] = t6;
  } else {
    t6 = $[10];
  }
  let t7;
  if ($[11] === Symbol.for("react.memo_cache_sentinel")) {
    t7 = {
      textAlign: "center"
    };
    $[11] = t7;
  } else {
    t7 = $[11];
  }
  const t8 = userInfo == null ? void 0 : userInfo.Common.SurName;
  const t9 = userInfo == null ? void 0 : userInfo.Common.FirstName;
  const t10 = userInfo == null ? void 0 : userInfo.Common.MiddleName;
  let t11;
  if ($[12] !== t10 || $[13] !== t8 || $[14] !== t9) {
    t11 = /* @__PURE__ */ jsxRuntimeExports.jsxs(Text, { fz: "26", py: "15px", sx: t7, children: [
      t8,
      " ",
      t9,
      " ",
      t10
    ] });
    $[12] = t10;
    $[13] = t8;
    $[14] = t9;
    $[15] = t11;
  } else {
    t11 = $[15];
  }
  let t12;
  if ($[16] !== classes.userContainer || $[17] !== goToUserProfile || $[18] !== t11 || $[19] !== t6) {
    t12 = /* @__PURE__ */ jsxRuntimeExports.jsxs(Box, { onClick: goToUserProfile, className: classes.userContainer, children: [
      t6,
      t11
    ] });
    $[16] = classes.userContainer;
    $[17] = goToUserProfile;
    $[18] = t11;
    $[19] = t6;
    $[20] = t12;
  } else {
    t12 = $[20];
  }
  let t13;
  if ($[21] !== classes.badge || $[22] !== (userInfo == null ? void 0 : userInfo.Roles)) {
    t13 = (_a = userInfo == null ? void 0 : userInfo.Roles) == null ? void 0 : _a.map((item) => /* @__PURE__ */ jsxRuntimeExports.jsx(Badge, { className: classes.badge, variant: "outline", "data-cy": `${item.Name}`, children: item.Name }, item.Id));
    $[21] = classes.badge;
    $[22] = userInfo == null ? void 0 : userInfo.Roles;
    $[23] = t13;
  } else {
    t13 = $[23];
  }
  let t14;
  if ($[24] !== classes.roleBox || $[25] !== t13) {
    t14 = /* @__PURE__ */ jsxRuntimeExports.jsx(Box, { className: classes.roleBox, children: t13 });
    $[24] = classes.roleBox;
    $[25] = t13;
    $[26] = t14;
  } else {
    t14 = $[26];
  }
  let t15;
  if ($[27] !== classes.description || $[28] !== classes.label || $[29] !== classes.tip || $[30] !== copyText || $[31] !== t || $[32] !== (userInfo == null ? void 0 : userInfo.Credentials.Email)) {
    t15 = (userInfo == null ? void 0 : userInfo.Credentials.Email) && /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
      /* @__PURE__ */ jsxRuntimeExports.jsxs(Text, { className: classes.label, fz: "10", children: [
        t("profile.email"),
        ":"
      ] }),
      /* @__PURE__ */ jsxRuntimeExports.jsxs(Flex, { align: "center", className: classes.description, children: [
        /* @__PURE__ */ jsxRuntimeExports.jsx(OverflowTip, { index: 1300, className: classes.tip, children: userInfo == null ? void 0 : userInfo.Credentials.Email }),
        /* @__PURE__ */ jsxRuntimeExports.jsx(ActionIcon, { onClick: () => copyText(userInfo == null ? void 0 : userInfo.Credentials.Email), children: /* @__PURE__ */ jsxRuntimeExports.jsx(lG, { stroke: 1.5, size: 17 }) })
      ] })
    ] });
    $[27] = classes.description;
    $[28] = classes.label;
    $[29] = classes.tip;
    $[30] = copyText;
    $[31] = t;
    $[32] = userInfo == null ? void 0 : userInfo.Credentials.Email;
    $[33] = t15;
  } else {
    t15 = $[33];
  }
  let t16;
  if ($[34] !== classes.dataContainer || $[35] !== t15) {
    t16 = /* @__PURE__ */ jsxRuntimeExports.jsx(Flex, { className: classes.dataContainer, children: t15 });
    $[34] = classes.dataContainer;
    $[35] = t15;
    $[36] = t16;
  } else {
    t16 = $[36];
  }
  let t17;
  if ($[37] !== Settings || $[38] !== classes.dataContainer || $[39] !== classes.description || $[40] !== classes.label || $[41] !== classes.tip || $[42] !== copyText || $[43] !== t || $[44] !== (userInfo == null ? void 0 : userInfo.Credentials.Login)) {
    t17 = isSaaS(Settings) ? null : /* @__PURE__ */ jsxRuntimeExports.jsx(Flex, { className: classes.dataContainer, children: (userInfo == null ? void 0 : userInfo.Credentials.Login) && /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
      /* @__PURE__ */ jsxRuntimeExports.jsxs(Text, { className: classes.label, fz: "10", children: [
        t("profile.login"),
        ":"
      ] }),
      /* @__PURE__ */ jsxRuntimeExports.jsxs(Flex, { align: "center", className: classes.description, children: [
        /* @__PURE__ */ jsxRuntimeExports.jsx(OverflowTip, { index: 1300, className: classes.tip, children: userInfo == null ? void 0 : userInfo.Credentials.Login }),
        /* @__PURE__ */ jsxRuntimeExports.jsx(ActionIcon, { onClick: () => copyText(userInfo == null ? void 0 : userInfo.Credentials.Login), children: /* @__PURE__ */ jsxRuntimeExports.jsx(lG, { stroke: 1.5, size: 17 }) })
      ] })
    ] }) });
    $[37] = Settings;
    $[38] = classes.dataContainer;
    $[39] = classes.description;
    $[40] = classes.label;
    $[41] = classes.tip;
    $[42] = copyText;
    $[43] = t;
    $[44] = userInfo == null ? void 0 : userInfo.Credentials.Login;
    $[45] = t17;
  } else {
    t17 = $[45];
  }
  let t18;
  if ($[46] !== classes.copyIcon || $[47] !== classes.dataContainer || $[48] !== classes.description || $[49] !== classes.label || $[50] !== classes.passwordInput || $[51] !== copyText || $[52] !== t || $[53] !== (userInfo == null ? void 0 : userInfo.Credentials.Password)) {
    t18 = (userInfo == null ? void 0 : userInfo.Credentials.Password) && /* @__PURE__ */ jsxRuntimeExports.jsxs(Flex, { className: classes.dataContainer, children: [
      /* @__PURE__ */ jsxRuntimeExports.jsxs(Text, { className: classes.label, fz: "10", children: [
        t("profile.password"),
        ":"
      ] }),
      /* @__PURE__ */ jsxRuntimeExports.jsxs(Flex, { align: "center", className: classes.description, children: [
        /* @__PURE__ */ jsxRuntimeExports.jsx(PasswordInput, { ml: "-10px", className: classes.passwordInput, value: userInfo == null ? void 0 : userInfo.Credentials.Password, readOnly: true }),
        /* @__PURE__ */ jsxRuntimeExports.jsx(ActionIcon, { onClick: () => copyText(userInfo == null ? void 0 : userInfo.Credentials.Password), children: /* @__PURE__ */ jsxRuntimeExports.jsx(lG, { stroke: 1.5, size: 17, color: "#868e96", className: classes.copyIcon }) })
      ] })
    ] });
    $[46] = classes.copyIcon;
    $[47] = classes.dataContainer;
    $[48] = classes.description;
    $[49] = classes.label;
    $[50] = classes.passwordInput;
    $[51] = copyText;
    $[52] = t;
    $[53] = userInfo == null ? void 0 : userInfo.Credentials.Password;
    $[54] = t18;
  } else {
    t18 = $[54];
  }
  let t19;
  if ($[55] !== classes.info || $[56] !== t16 || $[57] !== t17 || $[58] !== t18) {
    t19 = /* @__PURE__ */ jsxRuntimeExports.jsxs(Flex, { className: classes.info, children: [
      t16,
      t17,
      t18
    ] });
    $[55] = classes.info;
    $[56] = t16;
    $[57] = t17;
    $[58] = t18;
    $[59] = t19;
  } else {
    t19 = $[59];
  }
  let t20;
  if ($[60] !== classes.root || $[61] !== t12 || $[62] !== t14 || $[63] !== t19) {
    t20 = /* @__PURE__ */ jsxRuntimeExports.jsxs(Box, { className: classes.root, children: [
      t12,
      t14,
      t19
    ] });
    $[60] = classes.root;
    $[61] = t12;
    $[62] = t14;
    $[63] = t19;
    $[64] = t20;
  } else {
    t20 = $[64];
  }
  let t21;
  if ($[65] !== classes.modalContainer || $[66] !== t20) {
    t21 = /* @__PURE__ */ jsxRuntimeExports.jsx(Box, { className: classes.modalContainer, sx: t3, children: t20 });
    $[65] = classes.modalContainer;
    $[66] = t20;
    $[67] = t21;
  } else {
    t21 = $[67];
  }
  const t22 = classes.modalFooter;
  let t23;
  if ($[68] === Symbol.for("react.memo_cache_sentinel")) {
    t23 = {
      position: "fixed",
      bottom: "0",
      zIndex: 1,
      borderBottomLeftRadius: "10px",
      borderBottomRightRadius: "10px"
    };
    $[68] = t23;
  } else {
    t23 = $[68];
  }
  let t24;
  if ($[69] !== modalClose) {
    t24 = () => {
      modalClose();
    };
    $[69] = modalClose;
    $[70] = t24;
  } else {
    t24 = $[70];
  }
  let t25;
  if ($[71] !== t) {
    t25 = t("requestResetPassword.ready");
    $[71] = t;
    $[72] = t25;
  } else {
    t25 = $[72];
  }
  let t26;
  if ($[73] !== t24 || $[74] !== t25) {
    t26 = /* @__PURE__ */ jsxRuntimeExports.jsx(Button, { size: "sm", radius: 8, w: "49%", onClick: t24, children: t25 });
    $[73] = t24;
    $[74] = t25;
    $[75] = t26;
  } else {
    t26 = $[75];
  }
  const t27 = classes.cancelBtn;
  let t28;
  if ($[76] !== createUser) {
    t28 = () => {
      createUser();
    };
    $[76] = createUser;
    $[77] = t28;
  } else {
    t28 = $[77];
  }
  let t29;
  if ($[78] !== t) {
    t29 = t("profile.createMore");
    $[78] = t;
    $[79] = t29;
  } else {
    t29 = $[79];
  }
  let t30;
  if ($[80] !== classes.cancelBtn || $[81] !== t28 || $[82] !== t29) {
    t30 = /* @__PURE__ */ jsxRuntimeExports.jsx(UnstyledButton, { ml: 8, className: t27, w: "49%", onClick: t28, children: t29 });
    $[80] = classes.cancelBtn;
    $[81] = t28;
    $[82] = t29;
    $[83] = t30;
  } else {
    t30 = $[83];
  }
  let t31;
  if ($[84] !== classes.modalFooter || $[85] !== t26 || $[86] !== t30) {
    t31 = /* @__PURE__ */ jsxRuntimeExports.jsxs(Box, { className: t22, sx: t23, children: [
      t26,
      t30
    ] });
    $[84] = classes.modalFooter;
    $[85] = t26;
    $[86] = t30;
    $[87] = t31;
  } else {
    t31 = $[87];
  }
  let t32;
  if ($[88] !== t21 || $[89] !== t31) {
    t32 = /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
      t21,
      t31
    ] });
    $[88] = t21;
    $[89] = t31;
    $[90] = t32;
  } else {
    t32 = $[90];
  }
  return t32;
};
function _temp$2(state) {
  return state.userInfo;
}
const useStyles$6 = createStyles((theme) => ({
  avatarBox: {
    position: "relative",
    width: "100px",
    height: "100px",
    // [utils.largerThan('xs')]: {
    //   width: '124px',
    //   height: '124px'
    // }
    "&:hover": {
      "& .mantine-Overlay-root": {
        display: "flex"
      }
    }
  },
  avatarOverlay: {
    display: "none",
    backgroundColor: "#000000",
    opacity: 0.6,
    borderRadius: "50%",
    cursor: "pointer",
    zIndex: 1
  },
  overlayText: {
    whiteSpace: "pre-wrap",
    fontSize: "12px",
    color: "#ffffff",
    textAlign: "center",
    position: "absolute",
    top: "50%",
    left: "50%",
    transform: "translate(-50%, -50%)"
  },
  headerInput: {
    "& .mantine-TextInput-input": {
      padding: "0",
      border: "none",
      borderRadius: "0px",
      borderBottom: `1px solid ${theme.colors.backgroundGray[5]}`
    }
  }
}));
const useStyles$5 = createStyles((theme) => ({
  root: {
    width: "100%",
    height: "100%",
    display: "flex",
    flexDirection: "column",
    alignItems: "center",
    justifyContent: "space-between"
  },
  container: {
    display: "flex",
    flexDirection: "column",
    alignItems: "center",
    justifyContent: "flex-start",
    width: "100%",
    overflowX: "hidden",
    padding: theme.spacing.md
  },
  control: {
    display: "flex",
    flexDirection: "row",
    alignItems: "center",
    justifyContent: "flex-start",
    width: "100%",
    marginTop: theme.spacing.sm
  },
  controlTextInfo: {
    color: theme.colors.brandGray[0],
    fontSize: "12px",
    lineHeight: "15px",
    marginTop: theme.spacing.md
  },
  footer: {
    display: "flex",
    flexDirection: "row",
    alignItems: "center",
    justifyContent: "space-between",
    width: "100%",
    backgroundColor: "#F9FAFB",
    height: "63px",
    padding: `0px ${theme.spacing.md}`,
    borderTop: "1px solid #F2F4F7"
  },
  cancelBtn: {
    display: "flex",
    alignItems: "center",
    justifyContent: "center",
    height: "36px",
    borderRadius: "8px",
    padding: `8px ${theme.spacing.sm}`,
    backgroundColor: theme.colors.brandGray[1],
    fontSize: "14px",
    color: "#101828",
    fontWeight: 600,
    lineHeight: "17px",
    "&:hover": {
      backgroundColor: "#eff0f4"
    },
    "&:active": {
      transform: `translateY(1px)`
    }
  }
}));
const AvatarEditModal = (t0) => {
  const $ = compilerRuntimeExports.c(47);
  const {
    isOpened,
    title,
    onClose,
    setPreview
  } = t0;
  const {
    classes
  } = useStyles$5();
  const {
    t
  } = useTranslation();
  const {
    form
  } = reactExports.useContext(CreateUserContext);
  const [avatar, setAvatar] = reactExports.useState("");
  const openRef = reactExports.useRef(null);
  const avatarRef = reactExports.useRef(null);
  const [isLoading, setIsLoading] = reactExports.useState(false);
  let t1;
  if ($[0] !== avatar || $[1] !== form || $[2] !== onClose || $[3] !== setPreview || $[4] !== t) {
    t1 = async () => {
      var _a;
      const img = (_a = avatarRef == null ? void 0 : avatarRef.current) == null ? void 0 : _a.getImageScaledToCanvas().toDataURL();
      if (img) {
        setPreview(img);
        const file = await base64ToBlob(avatar);
        const formData = new FormData();
        formData.append("File", file);
        try {
          setIsLoading(true);
          const res = await uploadFile(formData);
          form.setFieldValue("AvatarId", res.data.Id);
          if (res.status === 200) {
            onClose();
            setIsLoading(false);
          } else {
            setIsLoading(false);
            universalNotification({
              error: null,
              errorTitle: t("requestResetPassword.errorText"),
              isError: true,
              isSuccess: false
            });
          }
        } catch (t22) {
          setIsLoading(false);
        }
        setAvatar("");
      }
    };
    $[0] = avatar;
    $[1] = form;
    $[2] = onClose;
    $[3] = setPreview;
    $[4] = t;
    $[5] = t1;
  } else {
    t1 = $[5];
  }
  const saveAvatar = t1;
  let t2;
  if ($[6] === Symbol.for("react.memo_cache_sentinel")) {
    t2 = async () => {
      if (openRef.current) {
        openRef.current();
      }
    };
    $[6] = t2;
  } else {
    t2 = $[6];
  }
  const clickInAvatar = t2;
  let t3;
  if ($[7] !== onClose) {
    t3 = () => {
      onClose();
      setAvatar("");
    };
    $[7] = onClose;
    $[8] = t3;
  } else {
    t3 = $[8];
  }
  const close = t3;
  const t4 = classes.root;
  const t5 = classes.container;
  let t6;
  if ($[9] !== avatar || $[10] !== isLoading) {
    t6 = /* @__PURE__ */ jsxRuntimeExports.jsx(AvatarEditor, { openRef, avatarRef, avatar, setAvatar, isLoading });
    $[9] = avatar;
    $[10] = isLoading;
    $[11] = t6;
  } else {
    t6 = $[11];
  }
  const t7 = classes.control;
  let t8;
  if ($[12] !== t) {
    t8 = t("avatar.conditions");
    $[12] = t;
    $[13] = t8;
  } else {
    t8 = $[13];
  }
  let t9;
  if ($[14] !== t8) {
    t9 = /* @__PURE__ */ jsxRuntimeExports.jsx(Text, { size: "sm", children: t8 });
    $[14] = t8;
    $[15] = t9;
  } else {
    t9 = $[15];
  }
  let t10;
  if ($[16] !== classes.control || $[17] !== t9) {
    t10 = /* @__PURE__ */ jsxRuntimeExports.jsx(Box, { className: t7, children: t9 });
    $[16] = classes.control;
    $[17] = t9;
    $[18] = t10;
  } else {
    t10 = $[18];
  }
  let t11;
  if ($[19] !== classes.container || $[20] !== t10 || $[21] !== t6) {
    t11 = /* @__PURE__ */ jsxRuntimeExports.jsxs(Box, { className: t5, children: [
      t6,
      t10
    ] });
    $[19] = classes.container;
    $[20] = t10;
    $[21] = t6;
    $[22] = t11;
  } else {
    t11 = $[22];
  }
  const t12 = classes.footer;
  const t13 = !avatar || isLoading;
  let t14;
  if ($[23] !== t) {
    t14 = t("save");
    $[23] = t;
    $[24] = t14;
  } else {
    t14 = $[24];
  }
  let t15;
  if ($[25] !== saveAvatar || $[26] !== t13 || $[27] !== t14) {
    t15 = /* @__PURE__ */ jsxRuntimeExports.jsx(Button, { size: "sm", radius: 8, w: "49%", onClick: saveAvatar, disabled: t13, children: t14 });
    $[25] = saveAvatar;
    $[26] = t13;
    $[27] = t14;
    $[28] = t15;
  } else {
    t15 = $[28];
  }
  let t16;
  if ($[29] !== avatar || $[30] !== classes.cancelBtn || $[31] !== close || $[32] !== t) {
    t16 = avatar ? /* @__PURE__ */ jsxRuntimeExports.jsx(UnstyledButton, { ml: 8, w: "49%", onClick: clickInAvatar, className: classes.cancelBtn, children: t("avatar.changePhoto") }) : /* @__PURE__ */ jsxRuntimeExports.jsx(UnstyledButton, { ml: 8, w: "49%", onClick: close, className: classes.cancelBtn, children: t("cancel") });
    $[29] = avatar;
    $[30] = classes.cancelBtn;
    $[31] = close;
    $[32] = t;
    $[33] = t16;
  } else {
    t16 = $[33];
  }
  let t17;
  if ($[34] !== classes.footer || $[35] !== t15 || $[36] !== t16) {
    t17 = /* @__PURE__ */ jsxRuntimeExports.jsxs(Box, { className: t12, children: [
      t15,
      t16
    ] });
    $[34] = classes.footer;
    $[35] = t15;
    $[36] = t16;
    $[37] = t17;
  } else {
    t17 = $[37];
  }
  let t18;
  if ($[38] !== classes.root || $[39] !== t11 || $[40] !== t17) {
    t18 = /* @__PURE__ */ jsxRuntimeExports.jsxs(Box, { className: t4, children: [
      t11,
      t17
    ] });
    $[38] = classes.root;
    $[39] = t11;
    $[40] = t17;
    $[41] = t18;
  } else {
    t18 = $[41];
  }
  let t19;
  if ($[42] !== close || $[43] !== isOpened || $[44] !== t18 || $[45] !== title) {
    t19 = /* @__PURE__ */ jsxRuntimeExports.jsx(Modal, { opened: isOpened, title, onClose: close, children: t18 });
    $[42] = close;
    $[43] = isOpened;
    $[44] = t18;
    $[45] = title;
    $[46] = t19;
  } else {
    t19 = $[46];
  }
  return t19;
};
const AvatarFio = (t0) => {
  const $ = compilerRuntimeExports.c(70);
  const {
    preview,
    setPreview,
    disabled
  } = t0;
  const {
    classes
  } = useStyles$6();
  const {
    t
  } = useTranslation();
  const {
    form
  } = reactExports.useContext(CreateUserContext);
  const {
    Common
  } = form.values;
  const [editAvatar, setEditAvatar] = reactExports.useState(false);
  let t1;
  if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
    t1 = {
      FirstName: "",
      SurName: ""
    };
    $[0] = t1;
  } else {
    t1 = $[0];
  }
  const [user, setUser] = reactExports.useState(t1);
  let t2;
  let t3;
  if ($[1] !== Common.FirstName || $[2] !== Common.SurName) {
    t2 = () => {
      setUser({
        FirstName: Common.FirstName || null,
        SurName: Common.SurName || null
      });
    };
    t3 = [Common.FirstName, Common.SurName];
    $[1] = Common.FirstName;
    $[2] = Common.SurName;
    $[3] = t2;
    $[4] = t3;
  } else {
    t2 = $[3];
    t3 = $[4];
  }
  reactExports.useEffect(t2, t3);
  let t4;
  if ($[5] === Symbol.for("react.memo_cache_sentinel")) {
    t4 = () => {
      setEditAvatar(false);
    };
    $[5] = t4;
  } else {
    t4 = $[5];
  }
  const handleCloseModalEditAvatar = t4;
  let t5;
  if ($[6] !== form || $[7] !== setPreview) {
    t5 = () => {
      setPreview("");
      form.setFieldValue("AvatarId", null);
    };
    $[6] = form;
    $[7] = setPreview;
    $[8] = t5;
  } else {
    t5 = $[8];
  }
  const handleDeleteAvatar = t5;
  let t6;
  if ($[9] !== handleDeleteAvatar || $[10] !== preview) {
    t6 = preview ? /* @__PURE__ */ jsxRuntimeExports.jsx(ActionIcon, { size: "md", variant: "transparent", onClick: () => handleDeleteAvatar(), children: /* @__PURE__ */ jsxRuntimeExports.jsx(CloseIcon, { fill: "#667085" }) }) : null;
    $[9] = handleDeleteAvatar;
    $[10] = preview;
    $[11] = t6;
  } else {
    t6 = $[11];
  }
  const label = t6;
  let t7;
  if ($[12] === Symbol.for("react.memo_cache_sentinel")) {
    t7 = () => {
      setEditAvatar(true);
    };
    $[12] = t7;
  } else {
    t7 = $[12];
  }
  const t8 = user.FirstName || user.SurName ? user : void 0;
  let t9;
  if ($[13] !== preview || $[14] !== t8) {
    t9 = /* @__PURE__ */ jsxRuntimeExports.jsx(UserAvatar, { size: "100", src: preview, user: t8 });
    $[13] = preview;
    $[14] = t8;
    $[15] = t9;
  } else {
    t9 = $[15];
  }
  let t10;
  if ($[16] !== preview || $[17] !== t) {
    t10 = preview ? t("avatar.changeAvatar") : t("avatar.uploadPhoto");
    $[16] = preview;
    $[17] = t;
    $[18] = t10;
  } else {
    t10 = $[18];
  }
  let t11;
  if ($[19] !== classes.overlayText || $[20] !== t10) {
    t11 = /* @__PURE__ */ jsxRuntimeExports.jsx(Text, { className: classes.overlayText, children: t10 });
    $[19] = classes.overlayText;
    $[20] = t10;
    $[21] = t11;
  } else {
    t11 = $[21];
  }
  let t12;
  if ($[22] !== classes.avatarOverlay || $[23] !== t11) {
    t12 = /* @__PURE__ */ jsxRuntimeExports.jsx(Overlay, { className: classes.avatarOverlay, children: t11 });
    $[22] = classes.avatarOverlay;
    $[23] = t11;
    $[24] = t12;
  } else {
    t12 = $[24];
  }
  let t13;
  if ($[25] !== t12 || $[26] !== t9) {
    t13 = /* @__PURE__ */ jsxRuntimeExports.jsxs(Box, { onClick: t7, children: [
      t9,
      t12
    ] });
    $[25] = t12;
    $[26] = t9;
    $[27] = t13;
  } else {
    t13 = $[27];
  }
  let t14;
  if ($[28] !== label || $[29] !== t13) {
    t14 = /* @__PURE__ */ jsxRuntimeExports.jsx(Indicator, { label, size: 13, offset: 10, position: "top-end", color: "transparent", children: t13 });
    $[28] = label;
    $[29] = t13;
    $[30] = t14;
  } else {
    t14 = $[30];
  }
  let t15;
  if ($[31] !== classes.avatarBox || $[32] !== t14) {
    t15 = /* @__PURE__ */ jsxRuntimeExports.jsx(Box, { className: classes.avatarBox, children: t14 });
    $[31] = classes.avatarBox;
    $[32] = t14;
    $[33] = t15;
  } else {
    t15 = $[33];
  }
  let t16;
  if ($[34] !== t) {
    t16 = t("profile.profilePhoto");
    $[34] = t;
    $[35] = t16;
  } else {
    t16 = $[35];
  }
  let t17;
  if ($[36] !== editAvatar || $[37] !== preview || $[38] !== setPreview || $[39] !== t16) {
    t17 = /* @__PURE__ */ jsxRuntimeExports.jsx(AvatarEditModal, { isOpened: editAvatar, title: t16, onClose: handleCloseModalEditAvatar, preview, setPreview });
    $[36] = editAvatar;
    $[37] = preview;
    $[38] = setPreview;
    $[39] = t16;
    $[40] = t17;
  } else {
    t17 = $[40];
  }
  let t18;
  if ($[41] !== t) {
    t18 = t("profile.surName");
    $[41] = t;
    $[42] = t18;
  } else {
    t18 = $[42];
  }
  let t19;
  if ($[43] !== classes.headerInput || $[44] !== disabled || $[45] !== form || $[46] !== t18) {
    t19 = /* @__PURE__ */ jsxRuntimeExports.jsx(TextFieldInput, { fieldName: "Common.SurName", placeholder: t18, form, className: classes.headerInput, disabled });
    $[43] = classes.headerInput;
    $[44] = disabled;
    $[45] = form;
    $[46] = t18;
    $[47] = t19;
  } else {
    t19 = $[47];
  }
  let t20;
  if ($[48] !== t) {
    t20 = t("profile.firstName");
    $[48] = t;
    $[49] = t20;
  } else {
    t20 = $[49];
  }
  let t21;
  if ($[50] !== classes.headerInput || $[51] !== disabled || $[52] !== form || $[53] !== t20) {
    t21 = /* @__PURE__ */ jsxRuntimeExports.jsx(TextFieldInput, { fieldName: "Common.FirstName", placeholder: t20, form, className: classes.headerInput, disabled });
    $[50] = classes.headerInput;
    $[51] = disabled;
    $[52] = form;
    $[53] = t20;
    $[54] = t21;
  } else {
    t21 = $[54];
  }
  let t22;
  if ($[55] !== t) {
    t22 = t("profile.middleName");
    $[55] = t;
    $[56] = t22;
  } else {
    t22 = $[56];
  }
  let t23;
  if ($[57] !== classes.headerInput || $[58] !== disabled || $[59] !== form || $[60] !== t22) {
    t23 = /* @__PURE__ */ jsxRuntimeExports.jsx(TextFieldInput, { fieldName: "Common.MiddleName", placeholder: t22, form, className: classes.headerInput, disabled });
    $[57] = classes.headerInput;
    $[58] = disabled;
    $[59] = form;
    $[60] = t22;
    $[61] = t23;
  } else {
    t23 = $[61];
  }
  let t24;
  if ($[62] !== t19 || $[63] !== t21 || $[64] !== t23) {
    t24 = /* @__PURE__ */ jsxRuntimeExports.jsxs(Stack, { w: "100%", gap: "0", children: [
      t19,
      t21,
      t23
    ] });
    $[62] = t19;
    $[63] = t21;
    $[64] = t23;
    $[65] = t24;
  } else {
    t24 = $[65];
  }
  let t25;
  if ($[66] !== t15 || $[67] !== t17 || $[68] !== t24) {
    t25 = /* @__PURE__ */ jsxRuntimeExports.jsxs(Flex, { w: "100%", gap: "md", align: "center", children: [
      t15,
      t17,
      t24
    ] });
    $[66] = t15;
    $[67] = t17;
    $[68] = t24;
    $[69] = t25;
  } else {
    t25 = $[69];
  }
  return t25;
};
const useStyles$4 = createStyles((theme) => ({
  input: {
    "& .mantine-TextInput-input": {
      borderBottomRightRadius: "10px",
      borderTopRightRadius: "10px"
    },
    "& .mantine-TextInput-wrapper": {
      "&[data-error=true]": {
        "& .mantine-Select-section": {
          color: "#868e96"
        }
      }
    },
    "& .mantine-InputWrapper-label": {
      color: "#4B4B4B",
      fontSize: theme.fontSizes.sm,
      fontWeight: 500
    }
  },
  rightBox: {
    fontSize: "14px",
    color: "black"
  },
  disabledBox: {
    color: "#868e96",
    cursor: "not-allowed"
  },
  domainSelect: {
    "& .mantine-Select-wrapper": {
      borderWidth: 0,
      margin: 0
    },
    "& .mantine-Select-section": {
      marginRight: "4px"
    },
    "& .mantine-Select-input": {
      borderRight: "none",
      cursor: "pointer",
      borderLeft: "none",
      borderRadius: "8px",
      borderBottomLeftRadius: "0px",
      borderTopLeftRadius: "0px",
      "&:focus": {
        borderColor: "#d0d5dd",
        outline: "none"
      },
      '&[data-disabled="true"]': {
        cursor: "not-allowed",
        backgroundColor: "transparent"
      }
    }
  },
  changeInputContainer: {
    alignItems: "center",
    justifyContent: "flex-end",
    marginTop: "5px",
    cursor: "pointer"
  },
  changeInput: {
    fontSize: 12,
    color: theme.colors.blue[6]
  },
  refreshIcon: {
    color: theme.colors.blue[6],
    marginRight: "5px"
  },
  inputLabel: {
    "& .mantine-InputWrapper-label": {
      color: "#4B4B4B",
      fontSize: theme.fontSizes.sm,
      fontWeight: 500
    }
  },
  statusSelect: {
    "& .mantine-Select-root, & .mantine-Select-input": {
      borderRadius: "8px"
    },
    "& .mantine-InputWrapper-label": {
      color: "#4B4B4B",
      fontSize: theme.fontSizes.sm,
      fontWeight: 500
    }
  }
}));
const CreateEmail = (t0) => {
  const $ = compilerRuntimeExports.c(35);
  const {
    domains,
    setIsValidEmail,
    disabled
  } = t0;
  const {
    classes,
    cx
  } = useStyles$4();
  const {
    t
  } = useTranslation();
  const {
    form
  } = reactExports.useContext(CreateUserContext);
  const [selectedDomain, setSelectedDomain] = reactExports.useState(domains.length > 0 ? domains[0].value : "");
  let t1;
  if ($[0] !== domains[0] || $[1] !== domains.length) {
    t1 = () => {
      if (domains.length > 0) {
        setSelectedDomain(domains[0].value);
      }
    };
    $[0] = domains[0];
    $[1] = domains.length;
    $[2] = t1;
  } else {
    t1 = $[2];
  }
  let t2;
  if ($[3] !== domains) {
    t2 = [domains];
    $[3] = domains;
    $[4] = t2;
  } else {
    t2 = $[4];
  }
  reactExports.useEffect(t1, t2);
  let t3;
  if ($[5] !== form || $[6] !== selectedDomain || $[7] !== setIsValidEmail) {
    t3 = (event) => {
      const emailPrefix = event.target.value;
      if (emailPrefix.length === 0) {
        form.setFieldValue("Credentials.Email", "");
        setIsValidEmail(true);
      } else {
        if (!emailPrefix.includes("@")) {
          form.setFieldValue("Credentials.Email", `${emailPrefix}${selectedDomain}`);
        }
      }
    };
    $[5] = form;
    $[6] = selectedDomain;
    $[7] = setIsValidEmail;
    $[8] = t3;
  } else {
    t3 = $[8];
  }
  const handleInputChange = t3;
  let t4;
  if ($[9] !== form) {
    t4 = (value) => {
      if (value) {
        setSelectedDomain(value);
        const emailPrefix_0 = form.getInputProps("Credentials.Email").value.split("@")[0];
        if (emailPrefix_0) {
          form.setFieldValue("Credentials.Email", `${emailPrefix_0}${value}`);
        }
      }
    };
    $[9] = form;
    $[10] = t4;
  } else {
    t4 = $[10];
  }
  const handleDomainChange = t4;
  let t5;
  if ($[11] !== classes.disabledBox || $[12] !== classes.domainSelect || $[13] !== classes.rightBox || $[14] !== cx || $[15] !== disabled || $[16] !== domains || $[17] !== handleDomainChange || $[18] !== selectedDomain) {
    t5 = domains.length <= 1 ? /* @__PURE__ */ jsxRuntimeExports.jsx(Box, { className: cx(classes.rightBox, {
      [classes.disabledBox]: disabled
    }), children: selectedDomain }) : /* @__PURE__ */ jsxRuntimeExports.jsx(Select, { data: domains, w: "100%", rightSectionWidth: 20, comboboxProps: {
      zIndex: 1300
    }, rightSection: /* @__PURE__ */ jsxRuntimeExports.jsx(gq, { size: "1rem" }), styles: {
      rightSection: {
        pointerEvents: "none"
      }
    }, maxDropdownHeight: 150, allowDeselect: false, "data-cy": "selectDomain", disabled, className: classes.domainSelect, value: selectedDomain, onChange: handleDomainChange, px: 0 });
    $[11] = classes.disabledBox;
    $[12] = classes.domainSelect;
    $[13] = classes.rightBox;
    $[14] = cx;
    $[15] = disabled;
    $[16] = domains;
    $[17] = handleDomainChange;
    $[18] = selectedDomain;
    $[19] = t5;
  } else {
    t5 = $[19];
  }
  const rightSection = t5;
  let t6;
  if ($[20] !== t) {
    t6 = t("profile.email");
    $[20] = t;
    $[21] = t6;
  } else {
    t6 = $[21];
  }
  const t7 = classes.input;
  let t8;
  if ($[22] !== t) {
    t8 = t("profile.createEmailDescription");
    $[22] = t;
    $[23] = t8;
  } else {
    t8 = $[23];
  }
  const t9 = domains.length <= 1 ? selectedDomain.length * 8 + 10 : 120;
  let t10;
  if ($[24] !== classes.input || $[25] !== disabled || $[26] !== form || $[27] !== handleInputChange || $[28] !== rightSection || $[29] !== selectedDomain || $[30] !== setIsValidEmail || $[31] !== t6 || $[32] !== t8 || $[33] !== t9) {
    t10 = /* @__PURE__ */ jsxRuntimeExports.jsx(ValidateTextInput, { fieldName: "Credentials.Email", label: t6, form, className: t7, setIsValidEmail, description: t8, rightSection, rightSectionWidth: t9, onChange: handleInputChange, createEmail: true, selectedDomain, dataAttribute: "createEmail", isRequired: form.values.Credentials.isSaas, disabled });
    $[24] = classes.input;
    $[25] = disabled;
    $[26] = form;
    $[27] = handleInputChange;
    $[28] = rightSection;
    $[29] = selectedDomain;
    $[30] = setIsValidEmail;
    $[31] = t6;
    $[32] = t8;
    $[33] = t9;
    $[34] = t10;
  } else {
    t10 = $[34];
  }
  return t10;
};
const LoginInfo = (t0) => {
  const $ = compilerRuntimeExports.c(65);
  const {
    disabled
  } = t0;
  const {
    classes
  } = useStyles$4();
  const {
    t
  } = useTranslation();
  const {
    Settings
  } = useAppSelector(_temp$1);
  const {
    form
  } = reactExports.useContext(CreateUserContext);
  const {
    isCreateEmail
  } = form.values.Credentials;
  const {
    Customer,
    Status,
    Credentials
  } = form.values;
  const isMobile = useMediaQuery("(max-width: 576px)");
  let t1;
  if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
    t1 = [];
    $[0] = t1;
  } else {
    t1 = $[0];
  }
  const [servers, setServers] = reactExports.useState(t1);
  const [getDomainsData, t2] = useLazyEmailServerDomainsQuery();
  const {
    data: domainsData
  } = t2;
  const [isLoginTouched, setIsLoginTouched] = reactExports.useState(false);
  const [isValidEmail, setIsValidEmail] = reactExports.useState(false);
  let t3;
  if ($[1] !== Customer || $[2] !== getDomainsData) {
    t3 = () => {
      if (Customer == null ? void 0 : Customer.Id) {
        getDomainsData(Customer.Id);
      }
    };
    $[1] = Customer;
    $[2] = getDomainsData;
    $[3] = t3;
  } else {
    t3 = $[3];
  }
  const t4 = Customer == null ? void 0 : Customer.Id;
  let t5;
  if ($[4] !== t4) {
    t5 = [t4];
    $[4] = t4;
    $[5] = t5;
  } else {
    t5 = $[5];
  }
  reactExports.useEffect(t3, t5);
  let t6;
  let t7;
  if ($[6] !== domainsData) {
    t6 = () => {
      if (domainsData) {
        setServers(domainsData);
      }
    };
    t7 = [domainsData];
    $[6] = domainsData;
    $[7] = t6;
    $[8] = t7;
  } else {
    t6 = $[7];
    t7 = $[8];
  }
  reactExports.useEffect(t6, t7);
  let t8;
  bb0: {
    if (!Array.isArray(servers)) {
      let t93;
      if ($[9] === Symbol.for("react.memo_cache_sentinel")) {
        t93 = [];
        $[9] = t93;
      } else {
        t93 = $[9];
      }
      t8 = t93;
      break bb0;
    }
    let t92;
    if ($[10] !== servers) {
      const seen = /* @__PURE__ */ new Set();
      t92 = servers.reduce((acc, Item, index) => {
        const domain = `@${String(Item == null ? void 0 : Item.Domain)}`;
        if (!seen.has(domain)) {
          seen.add(domain);
          acc.push({
            key: index,
            label: domain,
            value: domain
          });
        }
        return acc;
      }, []);
      $[10] = servers;
      $[11] = t92;
    } else {
      t92 = $[11];
    }
    t8 = t92;
  }
  const list = t8;
  let t9;
  if ($[12] !== form || $[13] !== isCreateEmail) {
    t9 = () => {
      form.setFieldValue("Credentials.isCreateEmail", !isCreateEmail);
      form.setFieldValue("Credentials.Email", "");
      form.clearFieldError("Credentials.Email");
    };
    $[12] = form;
    $[13] = isCreateEmail;
    $[14] = t9;
  } else {
    t9 = $[14];
  }
  const handleToggle = t9;
  let t10;
  if ($[15] !== Credentials.Email || $[16] !== form || $[17] !== isLoginTouched || $[18] !== isValidEmail) {
    t10 = () => {
      if (isValidEmail && !isLoginTouched) {
        form.setFieldValue("Credentials.Login", Credentials.Email);
      }
      if ((!isValidEmail || !form.isValid("Credentials.Email")) && !isLoginTouched) {
        form.setFieldValue("Credentials.Login", "");
        setIsValidEmail(false);
      }
    };
    $[15] = Credentials.Email;
    $[16] = form;
    $[17] = isLoginTouched;
    $[18] = isValidEmail;
    $[19] = t10;
  } else {
    t10 = $[19];
  }
  let t11;
  if ($[20] !== Credentials.Email || $[21] !== isValidEmail) {
    t11 = [isValidEmail, Credentials.Email];
    $[20] = Credentials.Email;
    $[21] = isValidEmail;
    $[22] = t11;
  } else {
    t11 = $[22];
  }
  reactExports.useEffect(t10, t11);
  let t12;
  if ($[23] === Symbol.for("react.memo_cache_sentinel")) {
    t12 = () => {
      setIsLoginTouched(true);
    };
    $[23] = t12;
  } else {
    t12 = $[23];
  }
  const handleLoginChange = t12;
  let t13;
  if ($[24] !== domainsData || $[25] !== form || $[26] !== servers) {
    t13 = () => {
      if (domainsData) {
        if (form.values.Credentials.isCreateEmail && !servers.length) {
          form.setFieldValue("Credentials.isCreateEmail", false);
          form.setFieldValue("Credentials.Email", "");
        }
      }
    };
    $[24] = domainsData;
    $[25] = form;
    $[26] = servers;
    $[27] = t13;
  } else {
    t13 = $[27];
  }
  let t14;
  if ($[28] !== servers) {
    t14 = [servers];
    $[28] = servers;
    $[29] = t14;
  } else {
    t14 = $[29];
  }
  reactExports.useEffect(t13, t14);
  let t15;
  if ($[30] === Symbol.for("react.memo_cache_sentinel")) {
    t15 = {
      base: 1,
      xs: 2
    };
    $[30] = t15;
  } else {
    t15 = $[30];
  }
  const t16 = isMobile ? 0 : "md";
  let t17;
  if ($[31] !== classes.changeInput || $[32] !== classes.changeInputContainer || $[33] !== classes.inputLabel || $[34] !== classes.refreshIcon || $[35] !== disabled || $[36] !== form || $[37] !== handleToggle || $[38] !== isCreateEmail || $[39] !== list || $[40] !== servers || $[41] !== t) {
    t17 = /* @__PURE__ */ jsxRuntimeExports.jsx(Flex, { direction: "column", children: isCreateEmail ? /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
      /* @__PURE__ */ jsxRuntimeExports.jsx(CreateEmail, { domains: list, setIsValidEmail, disabled }),
      /* @__PURE__ */ jsxRuntimeExports.jsxs(Flex, { className: classes.changeInputContainer, children: [
        /* @__PURE__ */ jsxRuntimeExports.jsx(Dze, { size: 11, className: classes.refreshIcon }),
        /* @__PURE__ */ jsxRuntimeExports.jsx(Text, { onClick: handleToggle, className: classes.changeInput, children: t("profile.useExistingEmail") })
      ] })
    ] }) : /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
      /* @__PURE__ */ jsxRuntimeExports.jsx(ValidateTextInput, { rightSectionWidth: 30, fieldName: "Credentials.Email", label: t("login.login"), form, description: t("profile.emailExistsDescription"), className: classes.inputLabel, setIsValidEmail, isRequired: form.values.Credentials.isSaas, disabled }),
      servers.length > 0 ? /* @__PURE__ */ jsxRuntimeExports.jsxs(Flex, { className: classes.changeInputContainer, children: [
        /* @__PURE__ */ jsxRuntimeExports.jsx(Dze, { size: 11, className: classes.refreshIcon }),
        /* @__PURE__ */ jsxRuntimeExports.jsx(Text, { onClick: handleToggle, className: classes.changeInput, children: t("profile.createNewEmail") })
      ] }) : null
    ] }) });
    $[31] = classes.changeInput;
    $[32] = classes.changeInputContainer;
    $[33] = classes.inputLabel;
    $[34] = classes.refreshIcon;
    $[35] = disabled;
    $[36] = form;
    $[37] = handleToggle;
    $[38] = isCreateEmail;
    $[39] = list;
    $[40] = servers;
    $[41] = t;
    $[42] = t17;
  } else {
    t17 = $[42];
  }
  let t18;
  if ($[43] !== Settings || $[44] !== classes.inputLabel || $[45] !== disabled || $[46] !== form || $[47] !== t) {
    t18 = isSaaS(Settings) ? /* @__PURE__ */ jsxRuntimeExports.jsx(TextFieldInput, { form, fieldName: "Credentials.AdditionalEmail", label: t("profile.backupEmail"), className: classes.inputLabel, description: t("profile.backupEmailDescription"), disabled }) : /* @__PURE__ */ jsxRuntimeExports.jsx(ValidateTextInput, { fieldName: "Credentials.Login", label: t("profile.login"), form, description: t("profile.loginDescription"), className: classes.inputLabel, handleLoginChange, withAsterisk: true, disabled });
    $[43] = Settings;
    $[44] = classes.inputLabel;
    $[45] = disabled;
    $[46] = form;
    $[47] = t;
    $[48] = t18;
  } else {
    t18 = $[48];
  }
  let t19;
  if ($[49] !== t16 || $[50] !== t17 || $[51] !== t18) {
    t19 = /* @__PURE__ */ jsxRuntimeExports.jsxs(SimpleGrid, { cols: t15, w: "100%", spacing: t16, children: [
      t17,
      t18
    ] });
    $[49] = t16;
    $[50] = t17;
    $[51] = t18;
    $[52] = t19;
  } else {
    t19 = $[52];
  }
  let t20;
  if ($[53] !== Settings || $[54] !== Status || $[55] !== classes.inputLabel || $[56] !== classes.statusSelect || $[57] !== disabled || $[58] !== form || $[59] !== isMobile || $[60] !== t) {
    t20 = !isSaaS(Settings) && /* @__PURE__ */ jsxRuntimeExports.jsx(SimpleGrid, { mt: "10px", cols: {
      base: 1,
      xs: 2
    }, w: "100%", spacing: isMobile ? 0 : "md", children: /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
      /* @__PURE__ */ jsxRuntimeExports.jsx(TextFieldInput, { form, fieldName: "Credentials.AdditionalEmail", label: t("profile.backupEmail"), className: classes.inputLabel, description: t("profile.backupEmailDescription"), disabled }),
      /* @__PURE__ */ jsxRuntimeExports.jsx(StatusSelect, { label: t("users.status"), placeholder: t("profile.chooseStatus"), fieldName: "Status", form, value: Status, className: classes.statusSelect, description: t("profile.statusDescription"), disabled })
    ] }) });
    $[53] = Settings;
    $[54] = Status;
    $[55] = classes.inputLabel;
    $[56] = classes.statusSelect;
    $[57] = disabled;
    $[58] = form;
    $[59] = isMobile;
    $[60] = t;
    $[61] = t20;
  } else {
    t20 = $[61];
  }
  let t21;
  if ($[62] !== t19 || $[63] !== t20) {
    t21 = /* @__PURE__ */ jsxRuntimeExports.jsxs(Flex, { direction: "column", w: "100%", children: [
      t19,
      t20
    ] });
    $[62] = t19;
    $[63] = t20;
    $[64] = t21;
  } else {
    t21 = $[64];
  }
  return t21;
};
function _temp$1(state) {
  return state.userInfo;
}
const useStyles$3 = createStyles((theme) => ({
  group: {
    cursor: "pointer"
  },
  groupTitle: {
    fontSize: "12px",
    color: theme.colors.blue[6]
  },
  chevron: {
    transition: "transform 200ms ease",
    color: theme.colors.blue[6]
  },
  sectionTitle: {
    fontSize: "18px",
    fontWeight: 500,
    color: "#4B4B4B"
  },
  selectLabel: {
    "& .mantine-InputWrapper-label": {
      color: "#667085",
      fontSize: "12px",
      fontWeight: 100
    }
  }
}));
const MoreInfo = (t0) => {
  const $ = compilerRuntimeExports.c(60);
  const {
    disabled
  } = t0;
  const {
    classes
  } = useStyles$3();
  const {
    t
  } = useTranslation();
  const {
    form
  } = reactExports.useContext(CreateUserContext);
  const {
    Customer,
    Quota,
    Roles: userRoles,
    Positions: userPositions
  } = form.values;
  const t1 = classes.sectionTitle;
  let t2;
  if ($[0] !== t) {
    t2 = t("profile.company");
    $[0] = t;
    $[1] = t2;
  } else {
    t2 = $[1];
  }
  let t3;
  if ($[2] !== classes.sectionTitle || $[3] !== t2) {
    t3 = /* @__PURE__ */ jsxRuntimeExports.jsx(Text, { mb: "16px", className: t1, children: t2 });
    $[2] = classes.sectionTitle;
    $[3] = t2;
    $[4] = t3;
  } else {
    t3 = $[4];
  }
  let t4;
  if ($[5] === Symbol.for("react.memo_cache_sentinel")) {
    t4 = {
      base: 1,
      xs: 2
    };
    $[5] = t4;
  } else {
    t4 = $[5];
  }
  let t5;
  if ($[6] !== t) {
    t5 = t("unit");
    $[6] = t;
    $[7] = t5;
  } else {
    t5 = $[7];
  }
  let t6;
  if ($[8] !== t) {
    t6 = t("choose");
    $[8] = t;
    $[9] = t6;
  } else {
    t6 = $[9];
  }
  const t7 = (Customer == null ? void 0 : Customer.Id) || null;
  const t8 = Customer == null ? void 0 : Customer.Id;
  const t9 = Customer == null ? void 0 : Customer.Name;
  let t10;
  if ($[10] !== classes.selectLabel || $[11] !== disabled || $[12] !== form || $[13] !== t5 || $[14] !== t6 || $[15] !== t7 || $[16] !== t8 || $[17] !== t9) {
    t10 = /* @__PURE__ */ jsxRuntimeExports.jsx(SelectWithPagination, { label: t5, placeholder: t6, fieldName: "Customer.Id", form, defaultValue: t7, value: t8, isCreateUser: true, className: classes.selectLabel, customerField: "Customer.Name", filialName: t9, disabled });
    $[10] = classes.selectLabel;
    $[11] = disabled;
    $[12] = form;
    $[13] = t5;
    $[14] = t6;
    $[15] = t7;
    $[16] = t8;
    $[17] = t9;
    $[18] = t10;
  } else {
    t10 = $[18];
  }
  const t11 = Customer == null ? void 0 : Customer.Id;
  const t12 = Quota == null ? void 0 : Quota.Id;
  const t13 = Quota == null ? void 0 : Quota.Name;
  let t14;
  if ($[19] !== classes.selectLabel || $[20] !== disabled || $[21] !== form || $[22] !== t11 || $[23] !== t12 || $[24] !== t13) {
    t14 = /* @__PURE__ */ jsxRuntimeExports.jsx(SelectQuotas, { form, fieldName: "Quota.Id", quotaField: "Quota.Name", Customer: t11, value: t12, QuotaName: t13, className: classes.selectLabel, createUser: true, disabled });
    $[19] = classes.selectLabel;
    $[20] = disabled;
    $[21] = form;
    $[22] = t11;
    $[23] = t12;
    $[24] = t13;
    $[25] = t14;
  } else {
    t14 = $[25];
  }
  let t15;
  if ($[26] !== t10 || $[27] !== t14) {
    t15 = /* @__PURE__ */ jsxRuntimeExports.jsxs(SimpleGrid, { cols: t4, w: "100%", children: [
      t10,
      t14
    ] });
    $[26] = t10;
    $[27] = t14;
    $[28] = t15;
  } else {
    t15 = $[28];
  }
  let t16;
  if ($[29] !== t15 || $[30] !== t3) {
    t16 = /* @__PURE__ */ jsxRuntimeExports.jsxs(Box, { mb: "30px", children: [
      t3,
      t15
    ] });
    $[29] = t15;
    $[30] = t3;
    $[31] = t16;
  } else {
    t16 = $[31];
  }
  const t17 = classes.sectionTitle;
  let t18;
  if ($[32] !== t) {
    t18 = t("profile.roles");
    $[32] = t;
    $[33] = t18;
  } else {
    t18 = $[33];
  }
  let t19;
  if ($[34] !== classes.sectionTitle || $[35] !== t18) {
    t19 = /* @__PURE__ */ jsxRuntimeExports.jsx(Text, { mb: "16px", className: t17, children: t18 });
    $[34] = classes.sectionTitle;
    $[35] = t18;
    $[36] = t19;
  } else {
    t19 = $[36];
  }
  let t20;
  if ($[37] !== disabled || $[38] !== form || $[39] !== userRoles) {
    t20 = /* @__PURE__ */ jsxRuntimeExports.jsx(Roles, { Roles: userRoles, fieldName: "Roles", form, disabled });
    $[37] = disabled;
    $[38] = form;
    $[39] = userRoles;
    $[40] = t20;
  } else {
    t20 = $[40];
  }
  let t21;
  if ($[41] !== t19 || $[42] !== t20) {
    t21 = /* @__PURE__ */ jsxRuntimeExports.jsxs(Box, { mb: "30px", children: [
      t19,
      t20
    ] });
    $[41] = t19;
    $[42] = t20;
    $[43] = t21;
  } else {
    t21 = $[43];
  }
  const t22 = classes.sectionTitle;
  let t23;
  if ($[44] !== t) {
    t23 = t("profile.position");
    $[44] = t;
    $[45] = t23;
  } else {
    t23 = $[45];
  }
  let t24;
  if ($[46] !== classes.sectionTitle || $[47] !== t23) {
    t24 = /* @__PURE__ */ jsxRuntimeExports.jsx(Text, { className: t22, children: t23 });
    $[46] = classes.sectionTitle;
    $[47] = t23;
    $[48] = t24;
  } else {
    t24 = $[48];
  }
  let t25;
  if ($[49] !== disabled || $[50] !== form || $[51] !== userPositions) {
    t25 = /* @__PURE__ */ jsxRuntimeExports.jsx(Positions, { Positions: userPositions, form, sectionFormKey: "Positions", disabled });
    $[49] = disabled;
    $[50] = form;
    $[51] = userPositions;
    $[52] = t25;
  } else {
    t25 = $[52];
  }
  let t26;
  if ($[53] !== t24 || $[54] !== t25) {
    t26 = /* @__PURE__ */ jsxRuntimeExports.jsxs(Box, { children: [
      t24,
      t25
    ] });
    $[53] = t24;
    $[54] = t25;
    $[55] = t26;
  } else {
    t26 = $[55];
  }
  let t27;
  if ($[56] !== t16 || $[57] !== t21 || $[58] !== t26) {
    t27 = /* @__PURE__ */ jsxRuntimeExports.jsxs(Flex, { direction: "column", w: "100%", children: [
      t16,
      t21,
      t26
    ] });
    $[56] = t16;
    $[57] = t21;
    $[58] = t26;
    $[59] = t27;
  } else {
    t27 = $[59];
  }
  return t27;
};
const useStyles$2 = createStyles((theme) => ({
  radio: {
    padding: "5px 0",
    "& .mantine-Radio-inner": {
      alignSelf: "center"
    },
    "& .mantine-Radio-label": {
      fontSize: "14px",
      paddingLeft: theme.spacing.xs
    }
  },
  textFieldInput: {
    "& .mantine-TextInput-label, .mantine-InputWrapper-label": {
      color: theme.colors.brandGray[0],
      fontSize: "12px",
      fontWeight: 400
    },
    "& .mantine-TextInput-input": {
      borderRadius: "4px",
      border: "1px solid #D0D5DD"
    }
  }
}));
const CreatePassword = (t0) => {
  var _a;
  const $ = compilerRuntimeExports.c(49);
  const {
    isPasswordEnabled,
    setIsPasswordEnabled,
    passwordStrengthOptions,
    disabled
  } = t0;
  const {
    classes
  } = useStyles$2();
  const {
    t
  } = useTranslation();
  const isMobile = useMediaQuery("(max-width: 576px)");
  const {
    form
  } = reactExports.useContext(CreateUserContext);
  let t1;
  if ($[0] !== form || $[1] !== isPasswordEnabled) {
    t1 = () => {
      if (!isPasswordEnabled) {
        form.clearFieldError("Credentials.Password");
        form.setFieldValue("Credentials.Password", "");
      }
    };
    $[0] = form;
    $[1] = isPasswordEnabled;
    $[2] = t1;
  } else {
    t1 = $[2];
  }
  let t2;
  if ($[3] !== isPasswordEnabled) {
    t2 = [isPasswordEnabled];
    $[3] = isPasswordEnabled;
    $[4] = t2;
  } else {
    t2 = $[4];
  }
  reactExports.useEffect(t1, t2);
  let t3;
  if ($[5] !== form) {
    t3 = ((_a = form.getInputProps("Credentials.Password")) == null ? void 0 : _a.value) || "";
    $[5] = form;
    $[6] = t3;
  } else {
    t3 = $[6];
  }
  const password = t3;
  const rules = useGenerateRules(password, passwordStrengthOptions);
  let t4;
  if ($[7] !== form || $[8] !== password) {
    t4 = () => {
      if (!password) {
        form.getInputProps("Credentials.Password").onChange("");
      }
    };
    $[7] = form;
    $[8] = password;
    $[9] = t4;
  } else {
    t4 = $[9];
  }
  const onBlur = t4;
  let t5;
  if ($[10] !== t) {
    t5 = t("login.password");
    $[10] = t;
    $[11] = t5;
  } else {
    t5 = $[11];
  }
  let t6;
  if ($[12] !== t5) {
    t6 = /* @__PURE__ */ jsxRuntimeExports.jsx(Text, { fz: "14", fw: "500", c: "#4B4B4B", children: t5 });
    $[12] = t5;
    $[13] = t6;
  } else {
    t6 = $[13];
  }
  const t7 = !isPasswordEnabled;
  let t8;
  if ($[14] !== setIsPasswordEnabled) {
    t8 = () => setIsPasswordEnabled(false);
    $[14] = setIsPasswordEnabled;
    $[15] = t8;
  } else {
    t8 = $[15];
  }
  const t9 = classes.radio;
  let t10;
  if ($[16] !== t) {
    t10 = t("profile.generatePassword");
    $[16] = t;
    $[17] = t10;
  } else {
    t10 = $[17];
  }
  let t11;
  if ($[18] !== classes.radio || $[19] !== t10 || $[20] !== t7 || $[21] !== t8) {
    t11 = /* @__PURE__ */ jsxRuntimeExports.jsx(Radio, { checked: t7, onChange: t8, className: t9, label: t10, "data-cy": "enableGeneratePassword" });
    $[18] = classes.radio;
    $[19] = t10;
    $[20] = t7;
    $[21] = t8;
    $[22] = t11;
  } else {
    t11 = $[22];
  }
  let t12;
  if ($[23] !== setIsPasswordEnabled) {
    t12 = () => setIsPasswordEnabled(true);
    $[23] = setIsPasswordEnabled;
    $[24] = t12;
  } else {
    t12 = $[24];
  }
  const t13 = classes.radio;
  let t14;
  if ($[25] !== t) {
    t14 = t("profile.createPassword");
    $[25] = t;
    $[26] = t14;
  } else {
    t14 = $[26];
  }
  let t15;
  if ($[27] !== classes.radio || $[28] !== isPasswordEnabled || $[29] !== t12 || $[30] !== t14) {
    t15 = /* @__PURE__ */ jsxRuntimeExports.jsx(Radio, { checked: isPasswordEnabled, onChange: t12, className: t13, label: t14, "data-cy": "enableCreatePassword" });
    $[27] = classes.radio;
    $[28] = isPasswordEnabled;
    $[29] = t12;
    $[30] = t14;
    $[31] = t15;
  } else {
    t15 = $[31];
  }
  const t16 = isMobile ? 1 : 2;
  let t17;
  if ($[32] !== classes.textFieldInput || $[33] !== disabled || $[34] !== form || $[35] !== isPasswordEnabled || $[36] !== onBlur || $[37] !== password || $[38] !== rules || $[39] !== t) {
    t17 = isPasswordEnabled && /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
      /* @__PURE__ */ jsxRuntimeExports.jsx(PasswordInput, { ...form.getInputProps("Credentials.Password"), radius: "md", className: classes.textFieldInput, placeholder: t("profile.password"), value: password || "", onBlur, withAsterisk: true, "data-cy": "passwordInput", disabled }),
      /* @__PURE__ */ jsxRuntimeExports.jsx(RulesConditionList, { rules, check: (password == null ? void 0 : password.length) > 0 })
    ] });
    $[32] = classes.textFieldInput;
    $[33] = disabled;
    $[34] = form;
    $[35] = isPasswordEnabled;
    $[36] = onBlur;
    $[37] = password;
    $[38] = rules;
    $[39] = t;
    $[40] = t17;
  } else {
    t17 = $[40];
  }
  let t18;
  if ($[41] !== t16 || $[42] !== t17) {
    t18 = /* @__PURE__ */ jsxRuntimeExports.jsx(SimpleGrid, { cols: t16, w: "100%", children: t17 });
    $[41] = t16;
    $[42] = t17;
    $[43] = t18;
  } else {
    t18 = $[43];
  }
  let t19;
  if ($[44] !== t11 || $[45] !== t15 || $[46] !== t18 || $[47] !== t6) {
    t19 = /* @__PURE__ */ jsxRuntimeExports.jsxs(Flex, { direction: "column", mt: "20px", gap: 10, children: [
      t6,
      t11,
      t15,
      t18
    ] });
    $[44] = t11;
    $[45] = t15;
    $[46] = t18;
    $[47] = t6;
    $[48] = t19;
  } else {
    t19 = $[48];
  }
  return t19;
};
const AdditionalInfo = (t0) => {
  const $ = compilerRuntimeExports.c(94);
  const {
    isPasswordEnabled,
    setIsPasswordEnabled,
    passwordStrengthOptions,
    disabled
  } = t0;
  const {
    classes
  } = useStyles$3();
  const {
    t
  } = useTranslation();
  const {
    form
  } = reactExports.useContext(CreateUserContext);
  const {
    dir
  } = useDirection();
  const {
    Settings
  } = useAppSelector(_temp);
  const {
    Common
  } = form.values;
  const isMobile = useMediaQuery("(max-width: 576px)");
  const [opened, t1] = useDisclosure(false);
  const {
    toggle
  } = t1;
  let t2;
  if ($[0] !== form || $[1] !== isPasswordEnabled || $[2] !== opened || $[3] !== toggle) {
    t2 = () => {
      const nextValue = !opened;
      toggle();
      if (!nextValue && isPasswordEnabled) {
        form.validate();
      }
    };
    $[0] = form;
    $[1] = isPasswordEnabled;
    $[2] = opened;
    $[3] = toggle;
    $[4] = t2;
  } else {
    t2 = $[4];
  }
  const handleToggle = t2;
  const t3 = classes.group;
  const t4 = classes.groupTitle;
  let t5;
  if ($[5] !== t) {
    t5 = t("profile.additional");
    $[5] = t;
    $[6] = t5;
  } else {
    t5 = $[6];
  }
  let t6;
  if ($[7] !== classes.groupTitle || $[8] !== t5) {
    t6 = /* @__PURE__ */ jsxRuntimeExports.jsx(Text, { className: t4, children: t5 });
    $[7] = classes.groupTitle;
    $[8] = t5;
    $[9] = t6;
  } else {
    t6 = $[9];
  }
  const t7 = !opened ? `rotate(${dir === "rtl" ? -180 : 180}deg)` : "none";
  let t8;
  if ($[10] !== t7) {
    t8 = {
      transform: t7
    };
    $[10] = t7;
    $[11] = t8;
  } else {
    t8 = $[11];
  }
  let t9;
  if ($[12] !== classes.chevron || $[13] !== t8) {
    t9 = /* @__PURE__ */ jsxRuntimeExports.jsx(Bq, { className: classes.chevron, size: 16, stroke: 1.5, style: t8 });
    $[12] = classes.chevron;
    $[13] = t8;
    $[14] = t9;
  } else {
    t9 = $[14];
  }
  let t10;
  if ($[15] !== classes.group || $[16] !== handleToggle || $[17] !== t6 || $[18] !== t9) {
    t10 = /* @__PURE__ */ jsxRuntimeExports.jsxs(Group, { className: t3, onClick: handleToggle, gap: "5px", children: [
      t6,
      t9
    ] });
    $[15] = classes.group;
    $[16] = handleToggle;
    $[17] = t6;
    $[18] = t9;
    $[19] = t10;
  } else {
    t10 = $[19];
  }
  let t11;
  if ($[20] !== disabled || $[21] !== isPasswordEnabled || $[22] !== passwordStrengthOptions || $[23] !== setIsPasswordEnabled) {
    t11 = /* @__PURE__ */ jsxRuntimeExports.jsx(CreatePassword, { isPasswordEnabled, passwordStrengthOptions, setIsPasswordEnabled, disabled });
    $[20] = disabled;
    $[21] = isPasswordEnabled;
    $[22] = passwordStrengthOptions;
    $[23] = setIsPasswordEnabled;
    $[24] = t11;
  } else {
    t11 = $[24];
  }
  const t12 = classes.sectionTitle;
  let t13;
  if ($[25] !== t) {
    t13 = t("profile.commonInfo");
    $[25] = t;
    $[26] = t13;
  } else {
    t13 = $[26];
  }
  let t14;
  if ($[27] !== classes.sectionTitle || $[28] !== t13) {
    t14 = /* @__PURE__ */ jsxRuntimeExports.jsx(Text, { className: t12, children: t13 });
    $[27] = classes.sectionTitle;
    $[28] = t13;
    $[29] = t14;
  } else {
    t14 = $[29];
  }
  let t15;
  if ($[30] === Symbol.for("react.memo_cache_sentinel")) {
    t15 = {
      base: 1,
      xs: 2
    };
    $[30] = t15;
  } else {
    t15 = $[30];
  }
  const t16 = isMobile ? 0 : "md";
  let t17;
  if ($[31] !== t) {
    t17 = t("profile.chooseBirthDate");
    $[31] = t;
    $[32] = t17;
  } else {
    t17 = $[32];
  }
  let t18;
  if ($[33] !== t) {
    t18 = t("profile.birthDate");
    $[33] = t;
    $[34] = t18;
  } else {
    t18 = $[34];
  }
  let t19;
  if ($[35] !== disabled || $[36] !== form || $[37] !== t17 || $[38] !== t18) {
    t19 = /* @__PURE__ */ jsxRuntimeExports.jsx(DatePicker, { fieldName: "Common.BirthDate", placeholder: t17, label: t18, form, clearable: true, disabled });
    $[35] = disabled;
    $[36] = form;
    $[37] = t17;
    $[38] = t18;
    $[39] = t19;
  } else {
    t19 = $[39];
  }
  const t20 = String(Common.Gender);
  let t21;
  if ($[40] !== disabled || $[41] !== form || $[42] !== t20) {
    t21 = /* @__PURE__ */ jsxRuntimeExports.jsx(Gender, { fieldName: "Common.Gender", form, defaultValue: t20, clearable: true, disabled });
    $[40] = disabled;
    $[41] = form;
    $[42] = t20;
    $[43] = t21;
  } else {
    t21 = $[43];
  }
  let t22;
  if ($[44] !== t16 || $[45] !== t19 || $[46] !== t21) {
    t22 = /* @__PURE__ */ jsxRuntimeExports.jsxs(SimpleGrid, { cols: t15, w: "100%", spacing: t16, children: [
      t19,
      t21
    ] });
    $[44] = t16;
    $[45] = t19;
    $[46] = t21;
    $[47] = t22;
  } else {
    t22 = $[47];
  }
  let t23;
  if ($[48] === Symbol.for("react.memo_cache_sentinel")) {
    t23 = {
      base: 1,
      xs: 2
    };
    $[48] = t23;
  } else {
    t23 = $[48];
  }
  const t24 = isMobile ? 0 : "md";
  let t25;
  if ($[49] !== t) {
    t25 = t("profile.address");
    $[49] = t;
    $[50] = t25;
  } else {
    t25 = $[50];
  }
  let t26;
  if ($[51] !== t) {
    t26 = t("profile.addAddress");
    $[51] = t;
    $[52] = t26;
  } else {
    t26 = $[52];
  }
  let t27;
  if ($[53] !== disabled || $[54] !== form || $[55] !== t25 || $[56] !== t26) {
    t27 = /* @__PURE__ */ jsxRuntimeExports.jsx(Address, { fieldName: "Common.Address", label: t25, placeholder: t26, form, disabled });
    $[53] = disabled;
    $[54] = form;
    $[55] = t25;
    $[56] = t26;
    $[57] = t27;
  } else {
    t27 = $[57];
  }
  let t28;
  if ($[58] !== t) {
    t28 = t("profile.phone");
    $[58] = t;
    $[59] = t28;
  } else {
    t28 = $[59];
  }
  let t29;
  if ($[60] !== disabled || $[61] !== form || $[62] !== t28) {
    t29 = /* @__PURE__ */ jsxRuntimeExports.jsx(ValidatePhoneInput, { form, mask: "+7 (___) ___-__-__", label: t28, fieldName: "Common.Phone", disabled });
    $[60] = disabled;
    $[61] = form;
    $[62] = t28;
    $[63] = t29;
  } else {
    t29 = $[63];
  }
  let t30;
  if ($[64] !== t24 || $[65] !== t27 || $[66] !== t29) {
    t30 = /* @__PURE__ */ jsxRuntimeExports.jsxs(SimpleGrid, { cols: t23, w: "100%", spacing: t24, children: [
      t27,
      t29
    ] });
    $[64] = t24;
    $[65] = t27;
    $[66] = t29;
    $[67] = t30;
  } else {
    t30 = $[67];
  }
  let t31;
  if ($[68] === Symbol.for("react.memo_cache_sentinel")) {
    t31 = {
      base: 1,
      xs: 2
    };
    $[68] = t31;
  } else {
    t31 = $[68];
  }
  let t32;
  if ($[69] !== t) {
    t32 = t("profile.additionalPhone");
    $[69] = t;
    $[70] = t32;
  } else {
    t32 = $[70];
  }
  let t33;
  if ($[71] !== form) {
    t33 = form.getInputProps("Common.AdditionalPhone");
    $[71] = form;
    $[72] = t33;
  } else {
    t33 = $[72];
  }
  const t34 = t33;
  let t35;
  if ($[73] !== disabled || $[74] !== form || $[75] !== t32 || $[76] !== t34) {
    t35 = /* @__PURE__ */ jsxRuntimeExports.jsx(SimpleGrid, { cols: t31, w: "100%", children: /* @__PURE__ */ jsxRuntimeExports.jsx(Phone, { label: t32, inputProps: t34, form, fieldName: "Common.AdditionalPhone", disabled }) });
    $[73] = disabled;
    $[74] = form;
    $[75] = t32;
    $[76] = t34;
    $[77] = t35;
  } else {
    t35 = $[77];
  }
  let t36;
  if ($[78] !== t14 || $[79] !== t22 || $[80] !== t30 || $[81] !== t35) {
    t36 = /* @__PURE__ */ jsxRuntimeExports.jsxs(Flex, { mb: "30px", mt: "20px", direction: "column", gap: "xs", children: [
      t14,
      t22,
      t30,
      t35
    ] });
    $[78] = t14;
    $[79] = t22;
    $[80] = t30;
    $[81] = t35;
    $[82] = t36;
  } else {
    t36 = $[82];
  }
  let t37;
  if ($[83] !== Settings || $[84] !== disabled) {
    t37 = !isSaaS(Settings) && /* @__PURE__ */ jsxRuntimeExports.jsx(MoreInfo, { disabled });
    $[83] = Settings;
    $[84] = disabled;
    $[85] = t37;
  } else {
    t37 = $[85];
  }
  let t38;
  if ($[86] !== opened || $[87] !== t11 || $[88] !== t36 || $[89] !== t37) {
    t38 = /* @__PURE__ */ jsxRuntimeExports.jsxs(Collapse, { in: opened, children: [
      t11,
      t36,
      t37
    ] });
    $[86] = opened;
    $[87] = t11;
    $[88] = t36;
    $[89] = t37;
    $[90] = t38;
  } else {
    t38 = $[90];
  }
  let t39;
  if ($[91] !== t10 || $[92] !== t38) {
    t39 = /* @__PURE__ */ jsxRuntimeExports.jsxs(Flex, { direction: "column", w: "100%", children: [
      t10,
      t38
    ] });
    $[91] = t10;
    $[92] = t38;
    $[93] = t39;
  } else {
    t39 = $[93];
  }
  return t39;
};
function _temp(state) {
  return state.userInfo;
}
const useStyles$1 = createStyles((theme) => ({
  groupButton: {
    display: "flex",
    alignItems: "center",
    justifyContent: "center",
    height: "36px",
    borderRadius: "8px",
    padding: `8px ${theme.spacing.sm}`,
    backgroundColor: theme.colors.brandGray[1],
    fontSize: "14px",
    color: "#101828",
    fontWeight: 600,
    lineHeight: "17px",
    "&:hover": {
      backgroundColor: "#eff0f4"
    },
    "&:active": {
      transform: `translateY(1px)`
    }
  },
  textField: {
    "& .mantine-TextInput-label, .mantine-InputWrapper-label": {
      color: theme.colors.brandGray[0],
      fontSize: "12px"
    }
  }
}));
const useConfirmCancelForm = (modalClose) => {
  const $ = compilerRuntimeExports.c(5);
  const {
    t
  } = useTranslation();
  let t0;
  if ($[0] !== modalClose) {
    t0 = () => {
      modalClose();
    };
    $[0] = modalClose;
    $[1] = t0;
  } else {
    t0 = $[1];
  }
  const handleConfirm = t0;
  let t1;
  if ($[2] !== handleConfirm || $[3] !== t) {
    t1 = () => {
      openContextModal({
        modal: "context",
        centered: true,
        innerProps: {
          title: t("warning"),
          modalBody: /* @__PURE__ */ jsxRuntimeExports.jsx(Box, { mb: 24, children: t("profile.cancelWarning") }),
          confirmProps: {
            "data-cy": "continue",
            color: "brandRed.1",
            sx: {
              backgroundColor: themeColors.brandRed[1],
              color: "white",
              width: "49%"
            }
          },
          cancelProps: {
            "data-cy": "cancel",
            sx: {
              backgroundColor: themeColors.brandGray[1],
              color: "black",
              width: "49%",
              "& .mantine-Button-label": {
                color: "black"
              }
            }
          },
          labels: {
            confirm: t("continue"),
            cancel: t("cancel")
          },
          onConfirm: () => handleConfirm()
        }
      });
    };
    $[2] = handleConfirm;
    $[3] = t;
    $[4] = t1;
  } else {
    t1 = $[4];
  }
  const openCancelCreateUser = t1;
  return openCancelCreateUser;
};
const Control = (t0) => {
  const $ = compilerRuntimeExports.c(17);
  const {
    form,
    isLoading,
    modalClose
  } = t0;
  const {
    t
  } = useTranslation();
  const {
    classes
  } = useStyles$1();
  const errors = form.errors;
  let t1;
  if ($[0] !== errors) {
    t1 = Object.keys(errors);
    $[0] = errors;
    $[1] = t1;
  } else {
    t1 = $[1];
  }
  const isDisabled = t1.length !== 0;
  const handleCancelForm = useConfirmCancelForm(modalClose);
  let t2;
  if ($[2] !== t) {
    t2 = t("create");
    $[2] = t;
    $[3] = t2;
  } else {
    t2 = $[3];
  }
  let t3;
  if ($[4] !== isDisabled || $[5] !== isLoading || $[6] !== t2) {
    t3 = /* @__PURE__ */ jsxRuntimeExports.jsx(Button, { size: "sm", radius: 8, type: "submit", mr: 16, disabled: isDisabled, loading: isLoading, "data-cy": "createUser", w: "49%", children: t2 });
    $[4] = isDisabled;
    $[5] = isLoading;
    $[6] = t2;
    $[7] = t3;
  } else {
    t3 = $[7];
  }
  const t4 = classes.groupButton;
  let t5;
  if ($[8] !== t) {
    t5 = t("cancel");
    $[8] = t;
    $[9] = t5;
  } else {
    t5 = $[9];
  }
  let t6;
  if ($[10] !== classes.groupButton || $[11] !== handleCancelForm || $[12] !== t5) {
    t6 = /* @__PURE__ */ jsxRuntimeExports.jsx(UnstyledButton, { onClick: handleCancelForm, "data-cy": "cancelCreateUser", className: t4, w: "49%", children: t5 });
    $[10] = classes.groupButton;
    $[11] = handleCancelForm;
    $[12] = t5;
    $[13] = t6;
  } else {
    t6 = $[13];
  }
  let t7;
  if ($[14] !== t3 || $[15] !== t6) {
    t7 = /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
      t3,
      t6
    ] });
    $[14] = t3;
    $[15] = t6;
    $[16] = t7;
  } else {
    t7 = $[16];
  }
  return t7;
};
const useStyles = createStyles((theme) => ({
  modalContainer: modalTheme(theme).container,
  modalFooter: modalTheme(theme).footer
}));
const Sections = (t0) => {
  const $ = compilerRuntimeExports.c(30);
  const {
    isLoading,
    modalClose,
    isPasswordEnabled,
    setIsPasswordEnabled,
    passwordStrengthOptions,
    previewAvatar,
    setPreviewAvatar
  } = t0;
  const {
    form
  } = reactExports.useContext(CreateUserContext);
  const {
    classes
  } = useStyles();
  let t1;
  if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
    t1 = {
      paddingBottom: "100px"
    };
    $[0] = t1;
  } else {
    t1 = $[0];
  }
  let t2;
  if ($[1] !== isLoading || $[2] !== previewAvatar || $[3] !== setPreviewAvatar) {
    t2 = /* @__PURE__ */ jsxRuntimeExports.jsx(AvatarFio, { preview: previewAvatar, setPreview: setPreviewAvatar, disabled: isLoading });
    $[1] = isLoading;
    $[2] = previewAvatar;
    $[3] = setPreviewAvatar;
    $[4] = t2;
  } else {
    t2 = $[4];
  }
  let t3;
  if ($[5] !== isLoading) {
    t3 = /* @__PURE__ */ jsxRuntimeExports.jsx(LoginInfo, { disabled: isLoading });
    $[5] = isLoading;
    $[6] = t3;
  } else {
    t3 = $[6];
  }
  let t4;
  if ($[7] !== isLoading || $[8] !== isPasswordEnabled || $[9] !== passwordStrengthOptions || $[10] !== setIsPasswordEnabled) {
    t4 = /* @__PURE__ */ jsxRuntimeExports.jsx(AdditionalInfo, { disabled: isLoading, passwordStrengthOptions, isPasswordEnabled, setIsPasswordEnabled });
    $[7] = isLoading;
    $[8] = isPasswordEnabled;
    $[9] = passwordStrengthOptions;
    $[10] = setIsPasswordEnabled;
    $[11] = t4;
  } else {
    t4 = $[11];
  }
  let t5;
  if ($[12] !== t2 || $[13] !== t3 || $[14] !== t4) {
    t5 = /* @__PURE__ */ jsxRuntimeExports.jsxs(Flex, { direction: "column", gap: "20px", w: "100%", children: [
      t2,
      t3,
      t4
    ] });
    $[12] = t2;
    $[13] = t3;
    $[14] = t4;
    $[15] = t5;
  } else {
    t5 = $[15];
  }
  let t6;
  if ($[16] !== classes.modalContainer || $[17] !== t5) {
    t6 = /* @__PURE__ */ jsxRuntimeExports.jsx(Box, { className: classes.modalContainer, sx: t1, children: t5 });
    $[16] = classes.modalContainer;
    $[17] = t5;
    $[18] = t6;
  } else {
    t6 = $[18];
  }
  let t7;
  if ($[19] === Symbol.for("react.memo_cache_sentinel")) {
    t7 = {
      position: "fixed",
      bottom: "0",
      zIndex: 1,
      borderBottomLeftRadius: "10px",
      borderBottomRightRadius: "10px"
    };
    $[19] = t7;
  } else {
    t7 = $[19];
  }
  let t8;
  if ($[20] !== form || $[21] !== isLoading || $[22] !== modalClose) {
    t8 = /* @__PURE__ */ jsxRuntimeExports.jsx(Control, { form, isLoading, modalClose });
    $[20] = form;
    $[21] = isLoading;
    $[22] = modalClose;
    $[23] = t8;
  } else {
    t8 = $[23];
  }
  let t9;
  if ($[24] !== classes.modalFooter || $[25] !== t8) {
    t9 = /* @__PURE__ */ jsxRuntimeExports.jsx(Box, { className: classes.modalFooter, sx: t7, children: t8 });
    $[24] = classes.modalFooter;
    $[25] = t8;
    $[26] = t9;
  } else {
    t9 = $[26];
  }
  let t10;
  if ($[27] !== t6 || $[28] !== t9) {
    t10 = /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
      t6,
      t9
    ] });
    $[27] = t6;
    $[28] = t9;
    $[29] = t10;
  } else {
    t10 = $[29];
  }
  return t10;
};
const CreateUserModal = ({
  opened,
  modalClose,
  onSuccess
}) => {
  var _a, _b, _c, _d;
  const {
    classes
  } = useStyles$8();
  const {
    t
  } = useTranslation();
  const [isCreateModal, setIsCreateModal] = reactExports.useState(true);
  const {
    Settings
  } = useAppSelector((state) => state.userInfo);
  const currentUser = useAppSelector((state_0) => state_0.userInfo.User);
  const [isRequestCompleted, setIsRequestCompleted] = reactExports.useState(false);
  const [preview, setPreview] = reactExports.useState("");
  const [checkCanCreate, {
    data: canCreateUserData,
    isSuccess: SuccessCheckCreateUser
  }] = useLazyCheckCanCreateUserQuery();
  const [isPasswordEnabled, setIsPasswordEnabled] = reactExports.useState(false);
  const [passwordRules, setPasswordRules] = reactExports.useState({});
  const [getFilialData, {
    isSuccess: filialDataSuccess,
    data: filialData
  }] = useLazyGetFilialsInfoCommonQuery();
  const [fetchAddUser, {
    data,
    error,
    isError,
    isSuccess,
    isLoading
  }] = useAddMutation();
  reactExports.useEffect(() => {
    if (currentUser && isSaaS(Settings)) {
      checkCanCreate({
        Customerid: currentUser == null ? void 0 : currentUser.Customer.Id
      }).then(() => {
        setIsRequestCompleted(true);
      });
    }
  }, [currentUser]);
  const modules = useAppSelector((state_1) => {
    var _a2, _b2;
    return (_b2 = (_a2 = state_1.userInfo.Settings) == null ? void 0 : _a2.ModuleSettings) == null ? void 0 : _b2.ModuleUrls;
  });
  const paymentModule = Array.isArray(modules) ? modules.find((module) => module.Name === "Payments") : void 0;
  const allValidateScheme = objectType({
    Common: validateSchemeEditUserInfo(t),
    Credentials: validateSchemeCreateCredentials(t, passwordRules, isPasswordEnabled),
    Customer: validateSchemeCustomer(t),
    Positions: validateSchemePositions(t),
    Status: validateSchemeStatus(t)
  });
  const quotaValidationScheme = objectType({
    Quota: validateSchemeDataStorageQuota(t)
  });
  const form = useForm({
    initialValues: {
      ...initForm,
      Customer: {
        Id: ((_a = currentUser == null ? void 0 : currentUser.Customer) == null ? void 0 : _a.Id) ?? null,
        Name: ((_b = currentUser == null ? void 0 : currentUser.Customer) == null ? void 0 : _b.Title) ?? null
      },
      Credentials: {
        ...initForm.Credentials,
        Password: "",
        isSaas: isSaaS(Settings)
      }
    },
    validateInputOnBlur: true,
    validate: (values) => getValidateErrors(allValidateScheme, values)
  });
  reactExports.useEffect(() => {
    var _a2, _b2;
    if ((_a2 = form.values.Customer) == null ? void 0 : _a2.Id) {
      getFilialData({
        id: (_b2 = form.values.Customer) == null ? void 0 : _b2.Id,
        extended: true
      });
    }
  }, [(_c = form.values.Customer) == null ? void 0 : _c.Id, getFilialData]);
  reactExports.useEffect(() => {
    var _a2, _b2;
    if ((_a2 = form.values.Credentials) == null ? void 0 : _a2.isCreateEmail) {
      if (filialDataSuccess && filialData) {
        setPasswordRules(((_b2 = filialData.Settings) == null ? void 0 : _b2.PasswordSecurity) || {});
      } else {
        setPasswordRules(defaultMailServerPasswordOptions);
      }
    }
  }, [filialDataSuccess, filialData, (_d = form.values.Credentials) == null ? void 0 : _d.isCreateEmail]);
  const handleSubmit = async (values_0) => {
    var _a2;
    const quotaErrors = getValidateErrors(quotaValidationScheme, values_0);
    const isValidQuota = !Object.keys(quotaErrors).length;
    if (isValidQuota) {
      try {
        await fetchAddUser({
          ...values_0,
          Credentials: {
            ...values_0.Credentials,
            isCreateEmail: values_0.Credentials.Email && values_0.Credentials.isCreateEmail && !isSaaS(Settings) ? values_0.Credentials.isCreateEmail : false
          },
          Quota: !((_a2 = values_0 == null ? void 0 : values_0.Quota) == null ? void 0 : _a2.Id) ? null : values_0.Quota
        });
        onSuccess && onSuccess();
      } catch (e) {
        showNotification({
          message: "e" + e,
          autoClose: true,
          color: "red"
        });
      }
    } else {
      form.setErrors(quotaErrors);
    }
  };
  reactExports.useEffect(() => {
    var _a2, _b2;
    universalNotification({
      error,
      isError,
      isSuccess,
      successTitle: t("profile.success.userLogin", {
        login: isSaaS(Settings) ? (_a2 = data == null ? void 0 : data.Credentials) == null ? void 0 : _a2.Email : (_b2 = data == null ? void 0 : data.Credentials) == null ? void 0 : _b2.Login
      }),
      successMessage: t("profile.success.successCreated")
    });
    if (isSuccess && data) {
      setIsCreateModal(false);
      clearApiCacheByTags(usersApi, ["Users"]);
    }
  }, [data, error, isError, isSuccess]);
  const initialValues = {
    form,
    handleSubmit
  };
  const closeSuccessModal = () => {
    setIsCreateModal(false);
    modalClose();
    form.reset();
  };
  const createAnotherUser = () => {
    form.reset();
    setIsCreateModal(true);
    setIsPasswordEnabled(false);
    setPreview("");
  };
  return /* @__PURE__ */ jsxRuntimeExports.jsx(Modal, { size: "900px", opened, onClose: modalClose, title: isCreateModal ? t("profile.createUser") : t("profile.successCreated"), scrollAreaComponent: ScrollArea.Autosize, zIndex: 1300, children: isCreateModal ? /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: !isRequestCompleted && isSaaS(Settings) ? /* @__PURE__ */ jsxRuntimeExports.jsx(LoadingOverlay, { visible: true, overlayProps: {
    blur: 10
  } }) : (canCreateUserData == null ? void 0 : canCreateUserData.IsCanAddUser) && SuccessCheckCreateUser || !isSaaS(Settings) ? /* @__PURE__ */ jsxRuntimeExports.jsx(CreateUserContext.Provider, { value: initialValues, children: /* @__PURE__ */ jsxRuntimeExports.jsx("form", { onSubmit: form.onSubmit(handleSubmit), children: /* @__PURE__ */ jsxRuntimeExports.jsx(Sections, { isLoading, modalClose, passwordStrengthOptions: passwordRules, isPasswordEnabled, setIsPasswordEnabled, previewAvatar: preview, setPreviewAvatar: setPreview }) }) }) : /* @__PURE__ */ jsxRuntimeExports.jsx(Box, { className: classes.modalContainer, children: /* @__PURE__ */ jsxRuntimeExports.jsx(MessageContainer, { icon: iconUser, description: t("profile.error.createLimit"), buttonText: t("profile.error.createLimitButton"), redirect: paymentModule == null ? void 0 : paymentModule.Url }) }) }) : /* @__PURE__ */ jsxRuntimeExports.jsx(SuccessUserModal, { userInfo: data, avatar: preview, modalClose: closeSuccessModal, createUser: createAnotherUser }) });
};
export {
  CreateUserModal as C
};
//# sourceMappingURL=index-C7llsr9G.js.map
