import { a0 as useParams, r as reactExports, j as jsxRuntimeExports, E as compilerRuntimeExports } from "./vendor-react-DYNCg6N5.js";
import { c as createStyles, b as Box, T as Text, B as Button, U as UnstyledButton, A as Avatar, a2 as Overlay, a5 as openContextModal, W as useMediaQuery, h as ActionIcon, s as showNotification, i as Indicator, F as Flex, G as Group, z as useForm, a0 as SimpleGrid, V as LoadingOverlay } from "./vendor-mantine-h0WlM2Mj.js";
import { M as Modal } from "./index-DqcA8P_y.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 { aU as axiosInstance, cy as useLazyCurrentUserQuery, cz as useLazyGetUserInfoQuery, b as useActions, c as useAppSelector, cA as generateUUID, m as universalNotification, a6 as clearApiCacheByTags, ae as usersApi, cB as useDeleteAvatarMutation, O as themeColors, K as IUsersSortField, bz as LoginAsIcon, U as UserStatusEnum, bP as RoleTypesEnum, i as isSaaS, P as PanelsEnum } from "./index-DfebxkL9.js";
import { E as EditUserInfoContext } from "./index-TL41xEJi.js";
import { u as useTranslation } from "./vendor-i18n-wisIXUFi.js";
import { C as ES } from "./vendor-icons-xWhXK_Ui.js";
import { S as SectionTemplate } from "./index-CbTPqI7c.js";
import { L as LoginAsModalContent } from "./index-leRPH4yM.js";
import { D as DatePicker } from "./index-DFZKJmic.js";
import { T as TextFieldInput } from "./index-BvQfhnV_.js";
import { g as getValidateErrors } from "./validation-Ds00Zghx.js";
import { d as validateSchemeEditUserInfo, i as isSaasScheme, n as noSaasScheme, f as validateLoginScheme, g as validateAdditionalEmailScheme } from "./validate-Bw-sUlFj.js";
import { u as useUpdateInfo, a as ProfileUpdateTypeEnum, P as ProfileSectionEnum } from "./useUpdateUser-innD962A.js";
import { V as ValidateTextInput } from "./validateTextInput-2E2Z5K9Z.js";
import { u as unionType } from "./types-espwwxTQ.js";
import "./styles-3NoIlzov.js";
import "./options-CRIRDAK6.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-CcqTjOWY.js";
import "./useDebounce-DTubzIUC.js";
import "./index-C_Fw_IUU.js";
import "./index-_NgMYV3i.js";
import "./utils-D5kCyTRM.js";
import "./types-B9VC9FeZ.js";
import "./date-bOIw2uwV.js";
import "./papaparse.min-Ds9XhCoe.js";
import "./passwordUtils-B3CN2t6O.js";
import "./ru-Bush41s2.js";
import "./index-CUcivY9l.js";
import "./index-72JBTuLT.js";
import "./index-DFEP7Sv_.js";
import "./index-DnphFLKH.js";
import "./index-D4BAIihc.js";
import "./useCopyToClipboard-C-S2RacD.js";
import "./index-CslanKI5.js";
import "./styles-Dnu4P1Zm.js";
import "./index-C2HWmCvh.js";
import "./index-BWhdniX1.js";
import "./index-woYEqWvh.js";
import "./index-Ds4Bnwmy.js";
import "./index-BoQKW1g7.js";
import "./format-CMT-x-V3.js";
import "./index-B7nmdYVM.js";
import "./useTerminateSessions-Cb3ukMTY.js";
import "./index-DMTgSMwy.js";
import "./styles-C9HVNQJ0.js";
import "./useGeneratePolicy-B4rO5xUa.js";
const useStyles$2 = createStyles((theme, _, utils) => ({
  root: {
    height: "100%",
    width: "100%"
  },
  photo: {
    display: "flex",
    alignItems: "center",
    flexDirection: "row"
  },
  mainInfo: {
    display: "flex",
    flexDirection: "column",
    alignItems: "flex-start",
    justifyContent: "center",
    marginLeft: theme.spacing.md,
    width: "100%"
  },
  name: {
    color: theme.black,
    fontSize: "13px",
    fontWeight: 600,
    marginBottom: theme.spacing.xs,
    wordBreak: "break-all",
    lineHeight: "22px",
    [utils.largerThan("xs")]: {
      fontSize: "18px"
    }
  },
  email: {
    color: theme.colors.brandGray[0],
    fontSize: "14px",
    lineHeight: "17px",
    marginBottom: theme.spacing.xs
  },
  group: {
    display: "flex",
    flexDirection: "column",
    alignItems: "flex-start",
    justifyContent: "flex-end"
  },
  groupTitle: {
    color: theme.colors.brandGray[0],
    fontSize: "12px"
  },
  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)`
    }
  },
  loginAs: {
    width: "100%"
  },
  ldapLabel: {
    backgroundColor: "rgba(51, 154, 240, 1)",
    color: "#EFF8FF",
    fontSize: "12px",
    fontWeight: 500,
    lineHeight: "18px",
    padding: "2px 8px",
    borderRadius: "16px",
    flexShrink: 0
  },
  loginButton: {
    backgroundColor: theme.colors.brandGray[1],
    color: "#000000",
    fontWeight: 400,
    "&:hover": {
      backgroundColor: theme.colors.dark[1],
      color: "#000000"
    },
    svg: {
      marginRight: "10px"
    }
  }
}));
const useStyles$1 = 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 userUploadAvatar = async (formData) => await axiosInstance.post(`/v2/Profile/UploadAvatar`, formData);
const userTask = async (id) => await axiosInstance.get(`/v1/UserTask?Id=${id}`);
var UserTask = /* @__PURE__ */ ((UserTask2) => {
  UserTask2[UserTask2["Error"] = -1] = "Error";
  UserTask2[UserTask2["Unknown"] = 0] = "Unknown";
  UserTask2[UserTask2["Register"] = 1] = "Register";
  UserTask2[UserTask2["Start"] = 2] = "Start";
  UserTask2[UserTask2["Done"] = 3] = "Done";
  return UserTask2;
})(UserTask || {});
const useUserTask = () => {
  const {
    t
  } = useTranslation();
  const [fetchUser] = useLazyCurrentUserQuery();
  const [fetchUserInfo] = useLazyGetUserInfoQuery();
  const params = useParams();
  const {
    setUserInfo
  } = useActions();
  const {
    currentId,
    setAvatarKey
  } = reactExports.useContext(EditUserInfoContext);
  const {
    User
  } = useAppSelector((state) => state.userInfo);
  const handleTaskCompletion = (setIsLoading, setAvatar, onClose) => {
    const userId = Number(params.id);
    const uuid = generateUUID();
    if ((User == null ? void 0 : User.Id) === currentId) {
      setUserInfo({
        ...User,
        HasAvatar: true,
        AvatarKey: uuid
      });
    } else {
      setAvatarKey(uuid);
    }
    setIsLoading(false);
    setAvatar("");
    onClose();
    universalNotification({
      error: null,
      successTitle: t("profile.avatarEditSuccess"),
      isError: false,
      isSuccess: true
    });
    clearApiCacheByTags(usersApi, ["Users"]);
    fetchUser();
    fetchUserInfo(userId);
  };
  const handleTaskFailure = (setIsLoading_0, setAvatar_0) => {
    setIsLoading_0(false);
    setAvatar_0("");
    universalNotification({
      error: null,
      errorTitle: t("avatar.error"),
      isError: true,
      isSuccess: false
    });
  };
  return async (taskId, setIsLoading_1, onClose_0, setAvatar_1) => {
    if (taskId) {
      const result = await userTask(taskId);
      if (UserTask.Done === result.data.Status) {
        handleTaskCompletion(setIsLoading_1, setAvatar_1, onClose_0);
      } else {
        let count = 0;
        const intervalID = setInterval(async () => {
          const repeatRequest = await userTask(taskId);
          count++;
          if (count >= 8) {
            clearInterval(intervalID);
            handleTaskFailure(setIsLoading_1, setAvatar_1);
          }
          if (UserTask.Done === repeatRequest.data.Status) {
            clearInterval(intervalID);
            handleTaskCompletion(setIsLoading_1, setAvatar_1, onClose_0);
          }
        }, 800);
      }
    }
  };
};
const AvatarEditModal = ({
  isOpened,
  title,
  onClose,
  id
}) => {
  const {
    classes
  } = useStyles$1();
  const {
    t
  } = useTranslation();
  const [avatar, setAvatar] = reactExports.useState("");
  const openRef = reactExports.useRef(null);
  const avatarRef = reactExports.useRef(null);
  const userTask2 = useUserTask();
  const [isLoading, setIsLoading] = reactExports.useState(false);
  const handleUploadError = () => {
    setIsLoading(false);
    setAvatar("");
    universalNotification({
      error: null,
      errorTitle: t("avatar.error"),
      isError: true,
      isSuccess: false
    });
  };
  const saveAvatar = async () => {
    var _a, _b, _c, _d;
    const img = (_a = avatarRef == null ? void 0 : avatarRef.current) == null ? void 0 : _a.getImageScaledToCanvas().toDataURL();
    if (img) {
      const file = await base64ToBlob(img);
      const formData = new FormData();
      formData.append("fileName", "avatar");
      formData.append("formFile", file);
      formData.append("userId", String(id));
      try {
        setIsLoading(true);
        const res = await userUploadAvatar(formData);
        if ((res == null ? void 0 : res.status) === 200) {
          const taskId = (_d = (_c = (_b = res == null ? void 0 : res.data) == null ? void 0 : _b.Response) == null ? void 0 : _c.Data) == null ? void 0 : _d.Id;
          userTask2(taskId, setIsLoading, onClose, setAvatar);
        } else {
          handleUploadError();
        }
      } catch (e) {
        handleUploadError();
      }
    }
  };
  const clickInAvatar = async () => {
    if (openRef.current) {
      openRef.current();
    }
  };
  const close = () => {
    onClose();
    setAvatar("");
  };
  return /* @__PURE__ */ jsxRuntimeExports.jsx(Modal, { size: "450px", opened: isOpened, title, onClose: close, children: /* @__PURE__ */ jsxRuntimeExports.jsxs(Box, { className: classes.root, children: [
    /* @__PURE__ */ jsxRuntimeExports.jsxs(Box, { className: classes.container, children: [
      /* @__PURE__ */ jsxRuntimeExports.jsx(AvatarEditor, { openRef, avatarRef, avatar, setAvatar, isLoading }),
      /* @__PURE__ */ jsxRuntimeExports.jsx(Box, { className: classes.control, children: /* @__PURE__ */ jsxRuntimeExports.jsx(Text, { size: "sm", children: t("avatar.conditions") }) })
    ] }),
    /* @__PURE__ */ jsxRuntimeExports.jsxs(Box, { className: classes.footer, children: [
      /* @__PURE__ */ jsxRuntimeExports.jsx(Button, { size: "sm", radius: 8, w: "49%", onClick: saveAvatar, disabled: !avatar, children: t("save") }),
      avatar ? /* @__PURE__ */ jsxRuntimeExports.jsx(UnstyledButton, { ml: 8, w: "49%", onClick: clickInAvatar, className: classes.cancelBtn, children: t("avatar.changePhoto") }) : /* @__PURE__ */ jsxRuntimeExports.jsx(UnstyledButton, { ml: 8, className: classes.cancelBtn, w: "49%", onClick: close, children: t("cancel") })
    ] })
  ] }) });
};
const useStyles = createStyles((_, __, utils) => ({
  container: {
    position: "relative",
    width: "90px",
    height: "90px",
    [utils.largerThan("xs")]: {
      width: "124px",
      height: "124px"
    }
  },
  avatar: {
    cursor: "pointer",
    width: "90px",
    height: "90px",
    [utils.largerThan("xs")]: {
      width: "124px",
      height: "124px"
    },
    img: {
      width: "90px",
      height: "90px",
      borderRadius: "50%",
      [utils.largerThan("xs")]: {
        width: "124px",
        height: "124px"
      }
    },
    svg: {
      display: "none"
    }
  },
  overlay: {
    backgroundColor: "#000000",
    opacity: 0.6,
    borderRadius: 62,
    cursor: "pointer",
    zIndex: 1,
    width: "90px"
  },
  text: {
    whiteSpace: "pre-wrap",
    fontSize: "12px",
    color: "#ffffff",
    textAlign: "center",
    position: "absolute",
    top: "50%",
    left: "50%",
    transform: "translate(-50%, -50%)"
  }
}));
const AvatarWithOverlay = (t0) => {
  const $ = compilerRuntimeExports.c(31);
  let className;
  let handleClick;
  let overlayStyles;
  let props;
  let src;
  if ($[0] !== t0) {
    ({
      src,
      handleClick,
      className,
      overlayStyles,
      ...props
    } = t0);
    $[0] = t0;
    $[1] = className;
    $[2] = handleClick;
    $[3] = overlayStyles;
    $[4] = props;
    $[5] = src;
  } else {
    className = $[1];
    handleClick = $[2];
    overlayStyles = $[3];
    props = $[4];
    src = $[5];
  }
  const {
    classes,
    cx
  } = useStyles();
  const {
    t
  } = useTranslation();
  let t1;
  if ($[6] === Symbol.for("react.memo_cache_sentinel")) {
    t1 = {
      backgroundColor: "#000000",
      opacity: 0.6,
      borderRadius: 62,
      cursor: "pointer",
      zIndex: 1
    };
    $[6] = t1;
  } else {
    t1 = $[6];
  }
  const defaultOverlayStyles = t1;
  const t2 = classes.container;
  let t3;
  if ($[7] === Symbol.for("react.memo_cache_sentinel")) {
    t3 = {};
    $[7] = t3;
  } else {
    t3 = $[7];
  }
  let t4;
  if ($[8] !== className || $[9] !== classes.avatar || $[10] !== cx) {
    t4 = cx(classes.avatar, className);
    $[8] = className;
    $[9] = classes.avatar;
    $[10] = cx;
    $[11] = t4;
  } else {
    t4 = $[11];
  }
  let t5;
  if ($[12] !== handleClick || $[13] !== props || $[14] !== src || $[15] !== t4) {
    t5 = /* @__PURE__ */ jsxRuntimeExports.jsx(Avatar, { "data-cy": "avatar", src, className: t4, onClick: handleClick, ...props });
    $[12] = handleClick;
    $[13] = props;
    $[14] = src;
    $[15] = t4;
    $[16] = t5;
  } else {
    t5 = $[16];
  }
  const t6 = overlayStyles || defaultOverlayStyles;
  let t7;
  if ($[17] !== src || $[18] !== t) {
    t7 = src ? t("avatar.changeAvatar") : t("avatar.uploadPhoto");
    $[17] = src;
    $[18] = t;
    $[19] = t7;
  } else {
    t7 = $[19];
  }
  let t8;
  if ($[20] !== classes.text || $[21] !== t7) {
    t8 = /* @__PURE__ */ jsxRuntimeExports.jsx(Text, { className: classes.text, children: t7 });
    $[20] = classes.text;
    $[21] = t7;
    $[22] = t8;
  } else {
    t8 = $[22];
  }
  let t9;
  if ($[23] !== handleClick || $[24] !== t6 || $[25] !== t8) {
    t9 = /* @__PURE__ */ jsxRuntimeExports.jsx(Overlay, { style: t6, onClick: handleClick, children: t8 });
    $[23] = handleClick;
    $[24] = t6;
    $[25] = t8;
    $[26] = t9;
  } else {
    t9 = $[26];
  }
  let t10;
  if ($[27] !== classes.container || $[28] !== t5 || $[29] !== t9) {
    t10 = /* @__PURE__ */ jsxRuntimeExports.jsxs(Box, { className: t2, sx: t3, children: [
      t5,
      t9
    ] });
    $[27] = classes.container;
    $[28] = t5;
    $[29] = t9;
    $[30] = t10;
  } else {
    t10 = $[30];
  }
  return t10;
};
const useDeleteAvatarModal = (id) => {
  const {
    t
  } = useTranslation();
  const [deleteAvatar, {
    isSuccess,
    data
  }] = useDeleteAvatarMutation();
  const [fetchUserInfo] = useLazyGetUserInfoQuery();
  const {
    setUserInfo
  } = useActions();
  const {
    User
  } = useAppSelector((state) => state.userInfo);
  const {
    setAvatarKey
  } = reactExports.useContext(EditUserInfoContext);
  const params = useParams();
  const handleDeleteAvatar = async (id_0) => {
    try {
      await deleteAvatar(Number(id_0));
      if (params.id) {
        if (params.id === (User == null ? void 0 : User.Id.toString())) {
          setUserInfo({
            ...User,
            HasAvatar: false,
            AvatarKey: ""
          });
        }
        setAvatarKey("");
        fetchUserInfo(Number(params.id));
      }
    } catch (e) {
      console.error("Failed to delete avatar:", e);
    }
  };
  const openDeleteAvatar = () => {
    openContextModal({
      modal: "context",
      centered: true,
      innerProps: {
        title: t("warning"),
        modalBody: /* @__PURE__ */ jsxRuntimeExports.jsx(Box, { mb: 24, children: t("avatar.confirmDelete") }),
        confirmProps: {
          color: "brandRed.1",
          sx: {
            backgroundColor: themeColors.brandRed[1],
            color: "white",
            width: "49%"
          }
        },
        cancelProps: {
          sx: {
            backgroundColor: themeColors.brandGray[1],
            color: "black",
            width: "49%",
            "& .mantine-Button-label": {
              color: "black"
            }
          }
        },
        labels: {
          confirm: t("delete"),
          cancel: t("cancel")
        },
        onConfirm: () => handleDeleteAvatar(id)
      }
    });
  };
  return {
    openDeleteAvatar,
    data,
    isSuccess
  };
};
const ProfileHeader = () => {
  const $ = compilerRuntimeExports.c(89);
  const {
    classes
  } = useStyles$2();
  const {
    t
  } = useTranslation();
  const {
    currentId,
    userInfoCommon,
    isLimitedAccess,
    avatarKey
  } = reactExports.useContext(EditUserInfoContext);
  const User = useAppSelector(_temp$2);
  const {
    Avatar: Avatar2,
    Status,
    Common,
    Credentials
  } = userInfoCommon;
  const isMobile = useMediaQuery("(max-width: 576px)");
  const {
    openDeleteAvatar,
    isSuccess
  } = useDeleteAvatarModal(currentId);
  const [editAvatar, setEditAvatar] = reactExports.useState(false);
  const [openLoginAsModal, setOpenLoginAsModal] = reactExports.useState(false);
  const fullName = `${(Common == null ? void 0 : Common.SurName) ?? ""} ${(Common == null ? void 0 : Common.FirstName) ?? ""} ${(Common == null ? void 0 : Common.MiddleName) ?? ""} `;
  User == null ? void 0 : User.AvatarKey;
  User == null ? void 0 : User.HasAvatar;
  let t0;
  if ((User == null ? void 0 : User.Id) === currentId) {
    t0 = (User == null ? void 0 : User.AvatarKey) ? `/api/v2/profile/getAvatar?id=${User.Id}&key=${User.AvatarKey}` : Avatar2 || "";
  } else {
    t0 = avatarKey ? `/api/v2/profile/getavatar?id=${currentId}&key=${avatarKey}` : Avatar2 || "";
  }
  const avatarSrc = t0;
  let t1;
  if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
    t1 = () => {
      setEditAvatar(false);
    };
    $[0] = t1;
  } else {
    t1 = $[0];
  }
  const handleCloseModalEditAvatar = t1;
  let t2;
  if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
    t2 = () => {
      setEditAvatar(true);
    };
    $[1] = t2;
  } else {
    t2 = $[1];
  }
  const openAvatarModal = t2;
  let t3;
  if ($[2] !== openDeleteAvatar) {
    t3 = () => {
      openDeleteAvatar();
    };
    $[2] = openDeleteAvatar;
    $[3] = t3;
  } else {
    t3 = $[3];
  }
  const handleDeleteAvatar = t3;
  let t4;
  if ($[4] === Symbol.for("react.memo_cache_sentinel")) {
    t4 = () => {
      setOpenLoginAsModal(true);
    };
    $[4] = t4;
  } else {
    t4 = $[4];
  }
  const handleLoginAs = t4;
  let t5;
  if ($[5] !== isSuccess || $[6] !== t) {
    t5 = () => {
      if (isSuccess) {
        showNotification({
          title: t("profile.avatarDeletedSuccessMessage"),
          message: "",
          autoClose: true,
          color: "green"
        });
      }
    };
    $[5] = isSuccess;
    $[6] = t;
    $[7] = t5;
  } else {
    t5 = $[7];
  }
  let t6;
  if ($[8] !== isSuccess) {
    t6 = [isSuccess];
    $[8] = isSuccess;
    $[9] = t6;
  } else {
    t6 = $[9];
  }
  reactExports.useEffect(t5, t6);
  let t7;
  if ($[10] !== (User == null ? void 0 : User.Id) || $[11] !== (User == null ? void 0 : User.Roles) || $[12] !== currentId || $[13] !== isLimitedAccess || $[14] !== userInfoCommon.Roles) {
    t7 = () => {
      var _a;
      const isLoggedAsSuperUser = User == null ? void 0 : User.Roles.some(_temp2);
      const hasNoSuperUserRole = !((_a = userInfoCommon.Roles) == null ? void 0 : _a.some(_temp3));
      return !isLimitedAccess && (User == null ? void 0 : User.Id) !== currentId && (isLoggedAsSuperUser || hasNoSuperUserRole);
    };
    $[10] = User == null ? void 0 : User.Id;
    $[11] = User == null ? void 0 : User.Roles;
    $[12] = currentId;
    $[13] = isLimitedAccess;
    $[14] = userInfoCommon.Roles;
    $[15] = t7;
  } else {
    t7 = $[15];
  }
  const canChangeStatus = t7;
  let t8;
  if ($[16] !== Status || $[17] !== (User == null ? void 0 : User.Id) || $[18] !== currentId || $[19] !== userInfoCommon.Roles) {
    t8 = () => {
      var _a;
      return (User == null ? void 0 : User.Id) !== currentId && Status === UserStatusEnum.Active && !((_a = userInfoCommon.Roles) == null ? void 0 : _a.some(_temp4));
    };
    $[16] = Status;
    $[17] = User == null ? void 0 : User.Id;
    $[18] = currentId;
    $[19] = userInfoCommon.Roles;
    $[20] = t8;
  } else {
    t8 = $[20];
  }
  const showLoginAsButton = t8;
  const isLdapUser = (userInfoCommon == null ? void 0 : userInfoCommon.UserType) === IUsersSortField.LDAP;
  const t9 = classes.root;
  const t10 = classes.photo;
  let t11;
  if ($[21] !== (Avatar2 == null ? void 0 : Avatar2.length) || $[22] !== handleDeleteAvatar) {
    t11 = (Avatar2 == null ? void 0 : Avatar2.length) ? /* @__PURE__ */ jsxRuntimeExports.jsx(ActionIcon, { size: "md", variant: "transparent", onClick: () => handleDeleteAvatar(), children: /* @__PURE__ */ jsxRuntimeExports.jsx(ES, { color: "#667085" }) }) : null;
    $[21] = Avatar2 == null ? void 0 : Avatar2.length;
    $[22] = handleDeleteAvatar;
    $[23] = t11;
  } else {
    t11 = $[23];
  }
  const t12 = isMobile ? 5 : 10;
  const t13 = isMobile ? 90 : 124;
  let t14;
  if ($[24] !== avatarSrc || $[25] !== t13) {
    t14 = /* @__PURE__ */ jsxRuntimeExports.jsx(AvatarWithOverlay, { size: t13, radius: 62, src: avatarSrc, handleClick: openAvatarModal });
    $[24] = avatarSrc;
    $[25] = t13;
    $[26] = t14;
  } else {
    t14 = $[26];
  }
  let t15;
  if ($[27] !== t11 || $[28] !== t12 || $[29] !== t14) {
    t15 = /* @__PURE__ */ jsxRuntimeExports.jsx(Indicator, { label: t11, size: 13, offset: t12, position: "top-end", color: "transparent", children: t14 });
    $[27] = t11;
    $[28] = t12;
    $[29] = t14;
    $[30] = t15;
  } else {
    t15 = $[30];
  }
  const t16 = classes.mainInfo;
  let t17;
  if ($[31] !== classes.name || $[32] !== fullName) {
    t17 = /* @__PURE__ */ jsxRuntimeExports.jsx(Text, { className: classes.name, children: fullName });
    $[31] = classes.name;
    $[32] = fullName;
    $[33] = t17;
  } else {
    t17 = $[33];
  }
  const t18 = classes.loginAs;
  let t19;
  if ($[34] !== t) {
    t19 = t("profile.chooseStatus");
    $[34] = t;
    $[35] = t19;
  } else {
    t19 = $[35];
  }
  let t20;
  if ($[36] !== canChangeStatus) {
    t20 = canChangeStatus();
    $[36] = canChangeStatus;
    $[37] = t20;
  } else {
    t20 = $[37];
  }
  const t21 = !t20;
  let t22;
  if ($[38] !== Status || $[39] !== t19 || $[40] !== t21) {
    t22 = /* @__PURE__ */ jsxRuntimeExports.jsx(StatusSelect, { editUser: true, placeholder: t19, fieldName: "Status", value: Status, disabled: t21 });
    $[38] = Status;
    $[39] = t19;
    $[40] = t21;
    $[41] = t22;
  } else {
    t22 = $[41];
  }
  let t23;
  if ($[42] !== classes.ldapLabel || $[43] !== isLdapUser) {
    t23 = isLdapUser && /* @__PURE__ */ jsxRuntimeExports.jsx(Box, { className: classes.ldapLabel, children: "LDAP" });
    $[42] = classes.ldapLabel;
    $[43] = isLdapUser;
    $[44] = t23;
  } else {
    t23 = $[44];
  }
  let t24;
  if ($[45] !== t22 || $[46] !== t23) {
    t24 = /* @__PURE__ */ jsxRuntimeExports.jsxs(Flex, { direction: "column", align: "flex-start", gap: 12, children: [
      t22,
      t23
    ] });
    $[45] = t22;
    $[46] = t23;
    $[47] = t24;
  } else {
    t24 = $[47];
  }
  let t25;
  if ($[48] !== classes.loginButton || $[49] !== showLoginAsButton || $[50] !== t) {
    t25 = showLoginAsButton() ? /* @__PURE__ */ jsxRuntimeExports.jsxs(Button, { radius: "md", className: classes.loginButton, onClick: handleLoginAs, children: [
      /* @__PURE__ */ jsxRuntimeExports.jsx(LoginAsIcon, { stroke: "#000000" }),
      t("profile.loginAs")
    ] }) : null;
    $[48] = classes.loginButton;
    $[49] = showLoginAsButton;
    $[50] = t;
    $[51] = t25;
  } else {
    t25 = $[51];
  }
  let t26;
  if ($[52] !== classes.loginAs || $[53] !== t24 || $[54] !== t25) {
    t26 = /* @__PURE__ */ jsxRuntimeExports.jsxs(Group, { justify: "space-between", className: t18, children: [
      t24,
      t25
    ] });
    $[52] = classes.loginAs;
    $[53] = t24;
    $[54] = t25;
    $[55] = t26;
  } else {
    t26 = $[55];
  }
  let t27;
  if ($[56] !== classes.mainInfo || $[57] !== t17 || $[58] !== t26) {
    t27 = /* @__PURE__ */ jsxRuntimeExports.jsxs(Box, { className: t16, children: [
      t17,
      t26
    ] });
    $[56] = classes.mainInfo;
    $[57] = t17;
    $[58] = t26;
    $[59] = t27;
  } else {
    t27 = $[59];
  }
  let t28;
  if ($[60] !== classes.photo || $[61] !== t15 || $[62] !== t27) {
    t28 = /* @__PURE__ */ jsxRuntimeExports.jsxs(Box, { className: t10, children: [
      t15,
      t27
    ] });
    $[60] = classes.photo;
    $[61] = t15;
    $[62] = t27;
    $[63] = t28;
  } else {
    t28 = $[63];
  }
  let t29;
  if ($[64] !== t) {
    t29 = t("profile.profilePhoto");
    $[64] = t;
    $[65] = t29;
  } else {
    t29 = $[65];
  }
  let t30;
  if ($[66] !== currentId || $[67] !== editAvatar || $[68] !== t29) {
    t30 = /* @__PURE__ */ jsxRuntimeExports.jsx(AvatarEditModal, { isOpened: editAvatar, title: t29, onClose: handleCloseModalEditAvatar, id: currentId });
    $[66] = currentId;
    $[67] = editAvatar;
    $[68] = t29;
    $[69] = t30;
  } else {
    t30 = $[69];
  }
  let t31;
  if ($[70] !== classes.root || $[71] !== t28 || $[72] !== t30) {
    t31 = /* @__PURE__ */ jsxRuntimeExports.jsxs(Box, { className: t9, children: [
      t28,
      t30
    ] });
    $[70] = classes.root;
    $[71] = t28;
    $[72] = t30;
    $[73] = t31;
  } else {
    t31 = $[73];
  }
  let t32;
  if ($[74] === Symbol.for("react.memo_cache_sentinel")) {
    t32 = () => setOpenLoginAsModal(false);
    $[74] = t32;
  } else {
    t32 = $[74];
  }
  let t33;
  if ($[75] !== t) {
    t33 = t("profile.loginAs");
    $[75] = t;
    $[76] = t33;
  } else {
    t33 = $[76];
  }
  let t34;
  if ($[77] !== t33) {
    t34 = /* @__PURE__ */ jsxRuntimeExports.jsx(Text, { fz: "md", children: t33 });
    $[77] = t33;
    $[78] = t34;
  } else {
    t34 = $[78];
  }
  const t35 = (Credentials == null ? void 0 : Credentials.Login) || "";
  const t36 = User == null ? void 0 : User.Login;
  let t37;
  if ($[79] !== t35 || $[80] !== t36) {
    t37 = /* @__PURE__ */ jsxRuntimeExports.jsx(LoginAsModalContent, { setOpen: setOpenLoginAsModal, loginAs: t35, login: t36 });
    $[79] = t35;
    $[80] = t36;
    $[81] = t37;
  } else {
    t37 = $[81];
  }
  let t38;
  if ($[82] !== openLoginAsModal || $[83] !== t34 || $[84] !== t37) {
    t38 = /* @__PURE__ */ jsxRuntimeExports.jsx(Modal, { withinPortal: true, opened: openLoginAsModal, onClose: t32, title: t34, children: t37 });
    $[82] = openLoginAsModal;
    $[83] = t34;
    $[84] = t37;
    $[85] = t38;
  } else {
    t38 = $[85];
  }
  let t39;
  if ($[86] !== t31 || $[87] !== t38) {
    t39 = /* @__PURE__ */ jsxRuntimeExports.jsxs(SectionTemplate, { children: [
      t31,
      t38
    ] });
    $[86] = t31;
    $[87] = t38;
    $[88] = t39;
  } else {
    t39 = $[88];
  }
  return t39;
};
function _temp$2(state) {
  var _a;
  return (_a = state == null ? void 0 : state.userInfo) == null ? void 0 : _a.User;
}
function _temp2(role) {
  return role.Type === RoleTypesEnum.SuperUser;
}
function _temp3(role_0) {
  return (role_0 == null ? void 0 : role_0.Type) === RoleTypesEnum.SuperUser;
}
function _temp4(role_1) {
  return (role_1 == null ? void 0 : role_1.Type) === RoleTypesEnum.SuperUser || (role_1 == null ? void 0 : role_1.Type) === RoleTypesEnum.Admin;
}
const GeneralInformation = () => {
  var _a;
  const $ = compilerRuntimeExports.c(137);
  const {
    t
  } = useTranslation();
  const {
    userInfoCommon,
    currentId,
    isLdapUser
  } = reactExports.useContext(EditUserInfoContext);
  const {
    Common
  } = userInfoCommon;
  const {
    saveUpdate,
    isLoading
  } = useUpdateInfo();
  let t0;
  if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
    t0 = {
      FirstName: "",
      SurName: "",
      MiddleName: "",
      Gender: 0,
      BirthDate: null,
      Address: "",
      Phone: "",
      AdditionalPhone: "",
      LastEntryDate: "",
      DateOfCreate: ""
    };
    $[0] = t0;
  } else {
    t0 = $[0];
  }
  let t1;
  if ($[1] !== t) {
    t1 = {
      initialValues: t0,
      validateInputOnChange: true,
      validate: (values) => getValidateErrors(validateSchemeEditUserInfo(t), values)
    };
    $[1] = t;
    $[2] = t1;
  } else {
    t1 = $[2];
  }
  const userGeneralInfoForm = useForm(t1);
  const errors = userGeneralInfoForm.errors;
  let t2;
  if ($[3] !== userGeneralInfoForm) {
    t2 = userGeneralInfoForm.isDirty();
    $[3] = userGeneralInfoForm;
    $[4] = t2;
  } else {
    t2 = $[4];
  }
  const isDirtyForm = t2;
  let t3;
  if ($[5] !== errors || $[6] !== isDirtyForm) {
    t3 = Object.keys(errors).length !== 0 || !isDirtyForm;
    $[5] = errors;
    $[6] = isDirtyForm;
    $[7] = t3;
  } else {
    t3 = $[7];
  }
  const isDisabled = t3;
  const isMobile = useMediaQuery("(max-width: 576px)");
  const t4 = (Common == null ? void 0 : Common.FirstName) || "";
  const t5 = (Common == null ? void 0 : Common.SurName) || "";
  const t6 = Common.MiddleName || "";
  const t7 = Common.Gender || 0;
  const t8 = Common.BirthDate || null;
  const t9 = Common.Address || "";
  const t10 = Common.Phone || "";
  const t11 = Common.AdditionalPhone || "";
  const t12 = Common.LastEntryDate || "";
  const t13 = Common.DateOfCreate || "";
  let t14;
  if ($[8] !== t10 || $[9] !== t11 || $[10] !== t12 || $[11] !== t13 || $[12] !== t4 || $[13] !== t5 || $[14] !== t6 || $[15] !== t7 || $[16] !== t8 || $[17] !== t9) {
    t14 = {
      FirstName: t4,
      SurName: t5,
      MiddleName: t6,
      Gender: t7,
      BirthDate: t8,
      Address: t9,
      Phone: t10,
      AdditionalPhone: t11,
      LastEntryDate: t12,
      DateOfCreate: t13
    };
    $[8] = t10;
    $[9] = t11;
    $[10] = t12;
    $[11] = t13;
    $[12] = t4;
    $[13] = t5;
    $[14] = t6;
    $[15] = t7;
    $[16] = t8;
    $[17] = t9;
    $[18] = t14;
  } else {
    t14 = $[18];
  }
  const fromData = t14;
  let t15;
  if ($[19] !== fromData || $[20] !== userGeneralInfoForm) {
    t15 = () => {
      userGeneralInfoForm.setValues(fromData);
      userGeneralInfoForm.resetDirty(fromData);
    };
    $[19] = fromData;
    $[20] = userGeneralInfoForm;
    $[21] = t15;
  } else {
    t15 = $[21];
  }
  let t16;
  if ($[22] !== Common) {
    t16 = [Common];
    $[22] = Common;
    $[23] = t16;
  } else {
    t16 = $[23];
  }
  reactExports.useEffect(t15, t16);
  let t17;
  if ($[24] !== currentId || $[25] !== fromData || $[26] !== saveUpdate || $[27] !== userGeneralInfoForm) {
    t17 = async (values_0) => {
      await saveUpdate({
        Type: ProfileUpdateTypeEnum.Common,
        Data: {
          [ProfileSectionEnum.Common]: values_0,
          Id: currentId
        }
      });
      userGeneralInfoForm.setValues(fromData);
      userGeneralInfoForm.resetDirty(fromData);
    };
    $[24] = currentId;
    $[25] = fromData;
    $[26] = saveUpdate;
    $[27] = userGeneralInfoForm;
    $[28] = t17;
  } else {
    t17 = $[28];
  }
  const handleSubmit = t17;
  let t18;
  if ($[29] !== handleSubmit || $[30] !== userGeneralInfoForm) {
    t18 = userGeneralInfoForm.onSubmit(handleSubmit);
    $[29] = handleSubmit;
    $[30] = userGeneralInfoForm;
    $[31] = t18;
  } else {
    t18 = $[31];
  }
  let t19;
  if ($[32] !== t) {
    t19 = t("profile.generalInformation");
    $[32] = t;
    $[33] = t19;
  } else {
    t19 = $[33];
  }
  const t20 = isMobile ? 1 : 2;
  let t21;
  if ($[34] !== t) {
    t21 = t("profile.surName");
    $[34] = t;
    $[35] = t21;
  } else {
    t21 = $[35];
  }
  let t22;
  if ($[36] !== isLdapUser || $[37] !== t21 || $[38] !== userGeneralInfoForm) {
    t22 = /* @__PURE__ */ jsxRuntimeExports.jsx(TextFieldInput, { fieldName: "SurName", label: t21, form: userGeneralInfoForm, isRequired: true, disabled: isLdapUser });
    $[36] = isLdapUser;
    $[37] = t21;
    $[38] = userGeneralInfoForm;
    $[39] = t22;
  } else {
    t22 = $[39];
  }
  let t23;
  if ($[40] !== t) {
    t23 = t("profile.firstName");
    $[40] = t;
    $[41] = t23;
  } else {
    t23 = $[41];
  }
  let t24;
  if ($[42] !== isLdapUser || $[43] !== t23 || $[44] !== userGeneralInfoForm) {
    t24 = /* @__PURE__ */ jsxRuntimeExports.jsx(TextFieldInput, { isRequired: true, fieldName: "FirstName", label: t23, form: userGeneralInfoForm, disabled: isLdapUser });
    $[42] = isLdapUser;
    $[43] = t23;
    $[44] = userGeneralInfoForm;
    $[45] = t24;
  } else {
    t24 = $[45];
  }
  let t25;
  if ($[46] !== t20 || $[47] !== t22 || $[48] !== t24) {
    t25 = /* @__PURE__ */ jsxRuntimeExports.jsxs(SimpleGrid, { cols: t20, w: "100%", children: [
      t22,
      t24
    ] });
    $[46] = t20;
    $[47] = t22;
    $[48] = t24;
    $[49] = t25;
  } else {
    t25 = $[49];
  }
  const t26 = isMobile ? 1 : 2;
  let t27;
  if ($[50] !== t) {
    t27 = t("profile.middleName");
    $[50] = t;
    $[51] = t27;
  } else {
    t27 = $[51];
  }
  let t28;
  if ($[52] !== isLdapUser || $[53] !== t27 || $[54] !== userGeneralInfoForm) {
    t28 = /* @__PURE__ */ jsxRuntimeExports.jsx(TextFieldInput, { fieldName: "MiddleName", label: t27, form: userGeneralInfoForm, disabled: isLdapUser });
    $[52] = isLdapUser;
    $[53] = t27;
    $[54] = userGeneralInfoForm;
    $[55] = t28;
  } else {
    t28 = $[55];
  }
  const t29 = String((_a = userGeneralInfoForm.values) == null ? void 0 : _a.Gender);
  let t30;
  if ($[56] !== isLdapUser || $[57] !== t29 || $[58] !== userGeneralInfoForm) {
    t30 = /* @__PURE__ */ jsxRuntimeExports.jsx(Gender, { fieldName: "Gender", form: userGeneralInfoForm, defaultValue: t29, clearable: true, disabled: isLdapUser });
    $[56] = isLdapUser;
    $[57] = t29;
    $[58] = userGeneralInfoForm;
    $[59] = t30;
  } else {
    t30 = $[59];
  }
  let t31;
  if ($[60] !== t26 || $[61] !== t28 || $[62] !== t30) {
    t31 = /* @__PURE__ */ jsxRuntimeExports.jsxs(SimpleGrid, { cols: t26, mt: 16, w: "100%", children: [
      t28,
      t30
    ] });
    $[60] = t26;
    $[61] = t28;
    $[62] = t30;
    $[63] = t31;
  } else {
    t31 = $[63];
  }
  const t32 = isMobile ? 1 : 2;
  let t33;
  if ($[64] !== t) {
    t33 = t("profile.chooseBirthDate");
    $[64] = t;
    $[65] = t33;
  } else {
    t33 = $[65];
  }
  let t34;
  if ($[66] !== t) {
    t34 = t("profile.birthDate");
    $[66] = t;
    $[67] = t34;
  } else {
    t34 = $[67];
  }
  let t35;
  if ($[68] !== isLdapUser || $[69] !== t33 || $[70] !== t34 || $[71] !== userGeneralInfoForm) {
    t35 = /* @__PURE__ */ jsxRuntimeExports.jsx(DatePicker, { fieldName: "BirthDate", placeholder: t33, label: t34, form: userGeneralInfoForm, clearable: true, disabled: isLdapUser });
    $[68] = isLdapUser;
    $[69] = t33;
    $[70] = t34;
    $[71] = userGeneralInfoForm;
    $[72] = t35;
  } else {
    t35 = $[72];
  }
  let t36;
  if ($[73] !== t) {
    t36 = t("profile.address");
    $[73] = t;
    $[74] = t36;
  } else {
    t36 = $[74];
  }
  const t37 = userGeneralInfoForm.values.Address ? userGeneralInfoForm.values.Address : "";
  let t38;
  if ($[75] !== isLdapUser || $[76] !== t36 || $[77] !== t37 || $[78] !== userGeneralInfoForm) {
    t38 = /* @__PURE__ */ jsxRuntimeExports.jsx(Address, { fieldName: "Address", label: t36, form: userGeneralInfoForm, defaultValue: t37, disabled: isLdapUser });
    $[75] = isLdapUser;
    $[76] = t36;
    $[77] = t37;
    $[78] = userGeneralInfoForm;
    $[79] = t38;
  } else {
    t38 = $[79];
  }
  let t39;
  if ($[80] !== t32 || $[81] !== t35 || $[82] !== t38) {
    t39 = /* @__PURE__ */ jsxRuntimeExports.jsxs(SimpleGrid, { cols: t32, mt: 16, w: "100%", children: [
      t35,
      t38
    ] });
    $[80] = t32;
    $[81] = t35;
    $[82] = t38;
    $[83] = t39;
  } else {
    t39 = $[83];
  }
  const t40 = isMobile ? 1 : 2;
  let t41;
  if ($[84] !== t) {
    t41 = t("profile.phone");
    $[84] = t;
    $[85] = t41;
  } else {
    t41 = $[85];
  }
  let t42;
  if ($[86] !== isLdapUser || $[87] !== t41 || $[88] !== userGeneralInfoForm) {
    t42 = /* @__PURE__ */ jsxRuntimeExports.jsx(ValidatePhoneInput, { form: userGeneralInfoForm, mask: "+7 (___) ___-__-__", label: t41, fieldName: "Phone", disabled: isLdapUser });
    $[86] = isLdapUser;
    $[87] = t41;
    $[88] = userGeneralInfoForm;
    $[89] = t42;
  } else {
    t42 = $[89];
  }
  let t43;
  if ($[90] !== t) {
    t43 = t("profile.additionalPhone");
    $[90] = t;
    $[91] = t43;
  } else {
    t43 = $[91];
  }
  let t44;
  if ($[92] !== userGeneralInfoForm) {
    t44 = userGeneralInfoForm.getInputProps("AdditionalPhone");
    $[92] = userGeneralInfoForm;
    $[93] = t44;
  } else {
    t44 = $[93];
  }
  const t45 = t44;
  let t46;
  if ($[94] !== isLdapUser || $[95] !== t43 || $[96] !== t45 || $[97] !== userGeneralInfoForm) {
    t46 = /* @__PURE__ */ jsxRuntimeExports.jsx(Phone, { label: t43, inputProps: t45, form: userGeneralInfoForm, fieldName: "AdditionalPhone", disabled: isLdapUser });
    $[94] = isLdapUser;
    $[95] = t43;
    $[96] = t45;
    $[97] = userGeneralInfoForm;
    $[98] = t46;
  } else {
    t46 = $[98];
  }
  let t47;
  if ($[99] !== t40 || $[100] !== t42 || $[101] !== t46) {
    t47 = /* @__PURE__ */ jsxRuntimeExports.jsxs(SimpleGrid, { cols: t40, mt: 16, w: "100%", children: [
      t42,
      t46
    ] });
    $[99] = t40;
    $[100] = t42;
    $[101] = t46;
    $[102] = t47;
  } else {
    t47 = $[102];
  }
  const t48 = isMobile ? 1 : 2;
  let t49;
  if ($[103] !== t) {
    t49 = t("profile.dateOfCreateProfile");
    $[103] = t;
    $[104] = t49;
  } else {
    t49 = $[104];
  }
  let t50;
  if ($[105] !== t49 || $[106] !== userGeneralInfoForm) {
    t50 = /* @__PURE__ */ jsxRuntimeExports.jsx(DatePicker, { fieldName: "DateOfCreate", label: t49, form: userGeneralInfoForm, disabled: true });
    $[105] = t49;
    $[106] = userGeneralInfoForm;
    $[107] = t50;
  } else {
    t50 = $[107];
  }
  let t51;
  if ($[108] !== t) {
    t51 = t("profile.lastEntryDate");
    $[108] = t;
    $[109] = t51;
  } else {
    t51 = $[109];
  }
  let t52;
  if ($[110] !== t51 || $[111] !== userGeneralInfoForm) {
    t52 = /* @__PURE__ */ jsxRuntimeExports.jsx(DatePicker, { fieldName: "LastEntryDate", label: t51, form: userGeneralInfoForm, disabled: true });
    $[110] = t51;
    $[111] = userGeneralInfoForm;
    $[112] = t52;
  } else {
    t52 = $[112];
  }
  let t53;
  if ($[113] !== t48 || $[114] !== t50 || $[115] !== t52) {
    t53 = /* @__PURE__ */ jsxRuntimeExports.jsxs(SimpleGrid, { cols: t48, mt: 16, w: "100%", children: [
      t50,
      t52
    ] });
    $[113] = t48;
    $[114] = t50;
    $[115] = t52;
    $[116] = t53;
  } else {
    t53 = $[116];
  }
  const t54 = isDisabled || isLdapUser;
  let t55;
  if ($[117] === Symbol.for("react.memo_cache_sentinel")) {
    t55 = {
      padding: "0 20px"
    };
    $[117] = t55;
  } else {
    t55 = $[117];
  }
  let t56;
  if ($[118] !== t) {
    t56 = t("profile.save");
    $[118] = t;
    $[119] = t56;
  } else {
    t56 = $[119];
  }
  let t57;
  if ($[120] !== t54 || $[121] !== t56) {
    t57 = /* @__PURE__ */ jsxRuntimeExports.jsx(Button, { type: "submit", size: "sm", radius: 8, disabled: t54, mt: "md", style: t55, children: t56 });
    $[120] = t54;
    $[121] = t56;
    $[122] = t57;
  } else {
    t57 = $[122];
  }
  let t58;
  if ($[123] !== isLoading) {
    t58 = /* @__PURE__ */ jsxRuntimeExports.jsx(LoadingOverlay, { visible: isLoading });
    $[123] = isLoading;
    $[124] = t58;
  } else {
    t58 = $[124];
  }
  let t59;
  if ($[125] !== t19 || $[126] !== t25 || $[127] !== t31 || $[128] !== t39 || $[129] !== t47 || $[130] !== t53 || $[131] !== t57 || $[132] !== t58) {
    t59 = /* @__PURE__ */ jsxRuntimeExports.jsxs(SectionTemplate, { title: t19, children: [
      t25,
      t31,
      t39,
      t47,
      t53,
      t57,
      t58
    ] });
    $[125] = t19;
    $[126] = t25;
    $[127] = t31;
    $[128] = t39;
    $[129] = t47;
    $[130] = t53;
    $[131] = t57;
    $[132] = t58;
    $[133] = t59;
  } else {
    t59 = $[133];
  }
  let t60;
  if ($[134] !== t18 || $[135] !== t59) {
    t60 = /* @__PURE__ */ jsxRuntimeExports.jsx("form", { onSubmit: t18, children: t59 });
    $[134] = t18;
    $[135] = t59;
    $[136] = t60;
  } else {
    t60 = $[136];
  }
  return t60;
};
const EmailCredentials = () => {
  var _a;
  const $ = compilerRuntimeExports.c(58);
  const {
    t
  } = useTranslation();
  const {
    currentId,
    userInfoCommon,
    isLdapUser
  } = reactExports.useContext(EditUserInfoContext);
  const {
    Credentials,
    Customer
  } = userInfoCommon;
  const {
    Settings
  } = useAppSelector(_temp$1);
  const {
    saveUpdate,
    isLoading
  } = useUpdateInfo();
  let t0;
  if ($[0] !== t) {
    t0 = unionType([isSaasScheme(t), noSaasScheme(t)]);
    $[0] = t;
    $[1] = t0;
  } else {
    t0 = $[1];
  }
  const validateScheme = t0;
  let t1;
  if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
    t1 = {
      isSaaS: false,
      Email: ""
    };
    $[2] = t1;
  } else {
    t1 = $[2];
  }
  let t2;
  if ($[3] !== validateScheme) {
    t2 = {
      initialValues: t1,
      validateInputOnChange: true,
      validate: (values) => getValidateErrors(validateScheme, values)
    };
    $[3] = validateScheme;
    $[4] = t2;
  } else {
    t2 = $[4];
  }
  const emailCredentialsForm = useForm(t2);
  const errors = emailCredentialsForm.errors;
  let t3;
  if ($[5] !== emailCredentialsForm) {
    t3 = emailCredentialsForm.isDirty();
    $[5] = emailCredentialsForm;
    $[6] = t3;
  } else {
    t3 = $[6];
  }
  const isDirtyForm = t3;
  let t4;
  if ($[7] !== errors || $[8] !== isDirtyForm) {
    t4 = Object.keys(errors).length !== 0 || !isDirtyForm;
    $[7] = errors;
    $[8] = isDirtyForm;
    $[9] = t4;
  } else {
    t4 = $[9];
  }
  const isDisabled = t4;
  let t5;
  if ($[10] !== Settings) {
    t5 = isSaaS(Settings);
    $[10] = Settings;
    $[11] = t5;
  } else {
    t5 = $[11];
  }
  const t6 = (Credentials == null ? void 0 : Credentials.Email) || "";
  const t7 = Credentials == null ? void 0 : Credentials.IsConfirmed;
  let t8;
  if ($[12] !== t5 || $[13] !== t6 || $[14] !== t7) {
    t8 = {
      isSaaS: t5,
      Email: t6,
      IsConfirmed: t7
    };
    $[12] = t5;
    $[13] = t6;
    $[14] = t7;
    $[15] = t8;
  } else {
    t8 = $[15];
  }
  const fromData = t8;
  let t9;
  if ($[16] !== emailCredentialsForm || $[17] !== fromData) {
    t9 = () => {
      emailCredentialsForm.setValues(fromData);
      emailCredentialsForm.resetDirty(fromData);
    };
    $[16] = emailCredentialsForm;
    $[17] = fromData;
    $[18] = t9;
  } else {
    t9 = $[18];
  }
  let t10;
  if ($[19] !== Credentials.Email || $[20] !== Credentials.IsConfirmed) {
    t10 = [Credentials.Email, Credentials.IsConfirmed];
    $[19] = Credentials.Email;
    $[20] = Credentials.IsConfirmed;
    $[21] = t10;
  } else {
    t10 = $[21];
  }
  reactExports.useEffect(t9, t10);
  let t11;
  if ($[22] !== currentId || $[23] !== emailCredentialsForm || $[24] !== fromData || $[25] !== saveUpdate) {
    t11 = async (values_0) => {
      await saveUpdate({
        Type: ProfileUpdateTypeEnum.CredentialEmail,
        Data: {
          [ProfileSectionEnum.Credentials]: {
            Email: values_0.Email,
            IsConfirmed: values_0.IsConfirmed
          },
          Id: currentId
        }
      });
      emailCredentialsForm.setValues(fromData);
      emailCredentialsForm.resetDirty(fromData);
    };
    $[22] = currentId;
    $[23] = emailCredentialsForm;
    $[24] = fromData;
    $[25] = saveUpdate;
    $[26] = t11;
  } else {
    t11 = $[26];
  }
  const handleSubmit = t11;
  let t12;
  if ($[27] !== emailCredentialsForm || $[28] !== handleSubmit) {
    t12 = emailCredentialsForm.onSubmit(handleSubmit);
    $[27] = emailCredentialsForm;
    $[28] = handleSubmit;
    $[29] = t12;
  } else {
    t12 = $[29];
  }
  let t13;
  if ($[30] !== Settings) {
    t13 = isSaaS(Settings);
    $[30] = Settings;
    $[31] = t13;
  } else {
    t13 = $[31];
  }
  let t14;
  if ($[32] !== t) {
    t14 = t("profile.email");
    $[32] = t;
    $[33] = t14;
  } else {
    t14 = $[33];
  }
  const t15 = (_a = emailCredentialsForm == null ? void 0 : emailCredentialsForm.values) == null ? void 0 : _a.IsConfirmed;
  const t16 = Customer == null ? void 0 : Customer.Id;
  let t17;
  if ($[34] !== Settings) {
    t17 = isSaaS(Settings);
    $[34] = Settings;
    $[35] = t17;
  } else {
    t17 = $[35];
  }
  let t18;
  if ($[36] !== currentId || $[37] !== emailCredentialsForm || $[38] !== isLdapUser || $[39] !== t13 || $[40] !== t14 || $[41] !== t15 || $[42] !== t16 || $[43] !== t17) {
    t18 = /* @__PURE__ */ jsxRuntimeExports.jsx(ValidateTextInput, { fieldName: "Email", isSaasEmail: t13, currentId, label: t14, form: emailCredentialsForm, isConfirmed: t15, userId: currentId, customerId: t16, withAsterisk: t17, disabled: isLdapUser });
    $[36] = currentId;
    $[37] = emailCredentialsForm;
    $[38] = isLdapUser;
    $[39] = t13;
    $[40] = t14;
    $[41] = t15;
    $[42] = t16;
    $[43] = t17;
    $[44] = t18;
  } else {
    t18 = $[44];
  }
  const t19 = isDisabled || isLdapUser;
  let t20;
  if ($[45] === Symbol.for("react.memo_cache_sentinel")) {
    t20 = {
      padding: "0 20px"
    };
    $[45] = t20;
  } else {
    t20 = $[45];
  }
  let t21;
  if ($[46] !== t) {
    t21 = t("profile.save");
    $[46] = t;
    $[47] = t21;
  } else {
    t21 = $[47];
  }
  let t22;
  if ($[48] !== t19 || $[49] !== t21) {
    t22 = /* @__PURE__ */ jsxRuntimeExports.jsx(Button, { type: "submit", size: "sm", radius: 8, disabled: t19, mt: "md", style: t20, children: t21 });
    $[48] = t19;
    $[49] = t21;
    $[50] = t22;
  } else {
    t22 = $[50];
  }
  let t23;
  if ($[51] !== isLoading) {
    t23 = /* @__PURE__ */ jsxRuntimeExports.jsx(LoadingOverlay, { visible: isLoading });
    $[51] = isLoading;
    $[52] = t23;
  } else {
    t23 = $[52];
  }
  let t24;
  if ($[53] !== t12 || $[54] !== t18 || $[55] !== t22 || $[56] !== t23) {
    t24 = /* @__PURE__ */ jsxRuntimeExports.jsxs("form", { onSubmit: t12, children: [
      t18,
      t22,
      t23
    ] });
    $[53] = t12;
    $[54] = t18;
    $[55] = t22;
    $[56] = t23;
    $[57] = t24;
  } else {
    t24 = $[57];
  }
  return t24;
};
function _temp$1(state) {
  return state.userInfo;
}
const LoginCredentials = () => {
  const $ = compilerRuntimeExports.c(42);
  const {
    t
  } = useTranslation();
  const {
    currentId,
    userInfoCommon,
    isLdapUser
  } = reactExports.useContext(EditUserInfoContext);
  const {
    Credentials
  } = userInfoCommon;
  const {
    saveUpdate,
    isLoading
  } = useUpdateInfo();
  let t0;
  if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
    t0 = {
      Login: ""
    };
    $[0] = t0;
  } else {
    t0 = $[0];
  }
  let t1;
  if ($[1] !== t) {
    t1 = {
      initialValues: t0,
      validateInputOnChange: true,
      validate: (values) => getValidateErrors(validateLoginScheme(t), values)
    };
    $[1] = t;
    $[2] = t1;
  } else {
    t1 = $[2];
  }
  const loginCredentialsForm = useForm(t1);
  const errors = loginCredentialsForm.errors;
  let t2;
  if ($[3] !== loginCredentialsForm) {
    t2 = loginCredentialsForm.isDirty();
    $[3] = loginCredentialsForm;
    $[4] = t2;
  } else {
    t2 = $[4];
  }
  const isDirtyForm = t2;
  let t3;
  if ($[5] !== errors || $[6] !== isDirtyForm) {
    t3 = Object.keys(errors).length !== 0 || !isDirtyForm;
    $[5] = errors;
    $[6] = isDirtyForm;
    $[7] = t3;
  } else {
    t3 = $[7];
  }
  const isDisabled = t3;
  const t4 = (Credentials == null ? void 0 : Credentials.Login) || "";
  let t5;
  if ($[8] !== t4) {
    t5 = {
      Login: t4
    };
    $[8] = t4;
    $[9] = t5;
  } else {
    t5 = $[9];
  }
  const fromData = t5;
  let t6;
  if ($[10] !== fromData || $[11] !== loginCredentialsForm) {
    t6 = () => {
      loginCredentialsForm.setValues(fromData);
      loginCredentialsForm.resetDirty(fromData);
    };
    $[10] = fromData;
    $[11] = loginCredentialsForm;
    $[12] = t6;
  } else {
    t6 = $[12];
  }
  let t7;
  if ($[13] !== Credentials) {
    t7 = [Credentials];
    $[13] = Credentials;
    $[14] = t7;
  } else {
    t7 = $[14];
  }
  reactExports.useEffect(t6, t7);
  let t8;
  if ($[15] !== currentId || $[16] !== fromData || $[17] !== loginCredentialsForm || $[18] !== saveUpdate) {
    t8 = async (values_0) => {
      await saveUpdate({
        Type: ProfileUpdateTypeEnum.Credentials,
        Data: {
          [ProfileSectionEnum.Credentials]: values_0,
          Id: currentId
        }
      });
      loginCredentialsForm.setValues(fromData);
      loginCredentialsForm.resetDirty(fromData);
    };
    $[15] = currentId;
    $[16] = fromData;
    $[17] = loginCredentialsForm;
    $[18] = saveUpdate;
    $[19] = t8;
  } else {
    t8 = $[19];
  }
  const handleSubmit = t8;
  let t9;
  if ($[20] !== handleSubmit || $[21] !== loginCredentialsForm) {
    t9 = loginCredentialsForm.onSubmit(handleSubmit);
    $[20] = handleSubmit;
    $[21] = loginCredentialsForm;
    $[22] = t9;
  } else {
    t9 = $[22];
  }
  let t10;
  if ($[23] !== t) {
    t10 = t("profile.login");
    $[23] = t;
    $[24] = t10;
  } else {
    t10 = $[24];
  }
  let t11;
  if ($[25] !== isLdapUser || $[26] !== loginCredentialsForm || $[27] !== t10) {
    t11 = /* @__PURE__ */ jsxRuntimeExports.jsx(ValidateTextInput, { fieldName: "Login", label: t10, form: loginCredentialsForm, isRequired: true, disabled: isLdapUser });
    $[25] = isLdapUser;
    $[26] = loginCredentialsForm;
    $[27] = t10;
    $[28] = t11;
  } else {
    t11 = $[28];
  }
  const t12 = isDisabled || isLdapUser;
  let t13;
  if ($[29] === Symbol.for("react.memo_cache_sentinel")) {
    t13 = {
      padding: "0 20px"
    };
    $[29] = t13;
  } else {
    t13 = $[29];
  }
  let t14;
  if ($[30] !== t) {
    t14 = t("profile.save");
    $[30] = t;
    $[31] = t14;
  } else {
    t14 = $[31];
  }
  let t15;
  if ($[32] !== t12 || $[33] !== t14) {
    t15 = /* @__PURE__ */ jsxRuntimeExports.jsx(Button, { type: "submit", size: "sm", radius: 8, disabled: t12, mt: "md", style: t13, children: t14 });
    $[32] = t12;
    $[33] = t14;
    $[34] = t15;
  } else {
    t15 = $[34];
  }
  let t16;
  if ($[35] !== isLoading) {
    t16 = /* @__PURE__ */ jsxRuntimeExports.jsx(LoadingOverlay, { visible: isLoading });
    $[35] = isLoading;
    $[36] = t16;
  } else {
    t16 = $[36];
  }
  let t17;
  if ($[37] !== t11 || $[38] !== t15 || $[39] !== t16 || $[40] !== t9) {
    t17 = /* @__PURE__ */ jsxRuntimeExports.jsxs("form", { onSubmit: t9, children: [
      t11,
      t15,
      t16
    ] });
    $[37] = t11;
    $[38] = t15;
    $[39] = t16;
    $[40] = t9;
    $[41] = t17;
  } else {
    t17 = $[41];
  }
  return t17;
};
const AdditionalEmailCredentials = () => {
  const $ = compilerRuntimeExports.c(43);
  const {
    t
  } = useTranslation();
  const {
    currentId,
    userInfoCommon
  } = reactExports.useContext(EditUserInfoContext);
  const {
    Credentials
  } = userInfoCommon;
  const {
    saveUpdate,
    isLoading
  } = useUpdateInfo();
  let t0;
  if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
    t0 = {
      AdditionalEmail: "",
      Email: ""
    };
    $[0] = t0;
  } else {
    t0 = $[0];
  }
  let t1;
  if ($[1] !== t) {
    t1 = {
      initialValues: t0,
      validateInputOnChange: true,
      validate: (values) => getValidateErrors(validateAdditionalEmailScheme(t), values)
    };
    $[1] = t;
    $[2] = t1;
  } else {
    t1 = $[2];
  }
  const additionalEmailCredentialsForm = useForm(t1);
  const errors = additionalEmailCredentialsForm.errors;
  let t2;
  if ($[3] !== additionalEmailCredentialsForm) {
    t2 = additionalEmailCredentialsForm.isDirty();
    $[3] = additionalEmailCredentialsForm;
    $[4] = t2;
  } else {
    t2 = $[4];
  }
  const isDirtyForm = t2;
  let t3;
  if ($[5] !== errors || $[6] !== isDirtyForm) {
    t3 = Object.keys(errors).length !== 0 || !isDirtyForm;
    $[5] = errors;
    $[6] = isDirtyForm;
    $[7] = t3;
  } else {
    t3 = $[7];
  }
  const isDisabled = t3;
  const t4 = (Credentials == null ? void 0 : Credentials.AdditionalEmail) || "";
  const t5 = (Credentials == null ? void 0 : Credentials.Email) || "";
  let t6;
  if ($[8] !== t4 || $[9] !== t5) {
    t6 = {
      AdditionalEmail: t4,
      Email: t5
    };
    $[8] = t4;
    $[9] = t5;
    $[10] = t6;
  } else {
    t6 = $[10];
  }
  const fromData = t6;
  let t7;
  if ($[11] !== additionalEmailCredentialsForm || $[12] !== fromData) {
    t7 = () => {
      additionalEmailCredentialsForm.setValues(fromData);
      additionalEmailCredentialsForm.resetDirty(fromData);
    };
    $[11] = additionalEmailCredentialsForm;
    $[12] = fromData;
    $[13] = t7;
  } else {
    t7 = $[13];
  }
  let t8;
  if ($[14] !== Credentials.AdditionalEmail || $[15] !== Credentials.Email) {
    t8 = [Credentials.AdditionalEmail, Credentials.Email];
    $[14] = Credentials.AdditionalEmail;
    $[15] = Credentials.Email;
    $[16] = t8;
  } else {
    t8 = $[16];
  }
  reactExports.useEffect(t7, t8);
  let t9;
  if ($[17] !== additionalEmailCredentialsForm || $[18] !== currentId || $[19] !== fromData || $[20] !== saveUpdate) {
    t9 = async (values_0) => {
      await saveUpdate({
        Type: ProfileUpdateTypeEnum.AdditionalEmail,
        Data: {
          [ProfileSectionEnum.Credentials]: {
            AdditionalEmail: values_0.AdditionalEmail
          },
          Id: currentId
        }
      });
      additionalEmailCredentialsForm.setValues(fromData);
      additionalEmailCredentialsForm.resetDirty(fromData);
    };
    $[17] = additionalEmailCredentialsForm;
    $[18] = currentId;
    $[19] = fromData;
    $[20] = saveUpdate;
    $[21] = t9;
  } else {
    t9 = $[21];
  }
  const handleSubmit = t9;
  let t10;
  if ($[22] !== additionalEmailCredentialsForm || $[23] !== handleSubmit) {
    t10 = additionalEmailCredentialsForm.onSubmit(handleSubmit);
    $[22] = additionalEmailCredentialsForm;
    $[23] = handleSubmit;
    $[24] = t10;
  } else {
    t10 = $[24];
  }
  let t11;
  if ($[25] !== t) {
    t11 = t("profile.backupEmail");
    $[25] = t;
    $[26] = t11;
  } else {
    t11 = $[26];
  }
  let t12;
  if ($[27] !== additionalEmailCredentialsForm || $[28] !== t11) {
    t12 = /* @__PURE__ */ jsxRuntimeExports.jsx(TextFieldInput, { form: additionalEmailCredentialsForm, fieldName: "AdditionalEmail", label: t11 });
    $[27] = additionalEmailCredentialsForm;
    $[28] = t11;
    $[29] = t12;
  } else {
    t12 = $[29];
  }
  let t13;
  if ($[30] === Symbol.for("react.memo_cache_sentinel")) {
    t13 = {
      padding: "0 20px"
    };
    $[30] = t13;
  } else {
    t13 = $[30];
  }
  let t14;
  if ($[31] !== t) {
    t14 = t("profile.save");
    $[31] = t;
    $[32] = t14;
  } else {
    t14 = $[32];
  }
  let t15;
  if ($[33] !== isDisabled || $[34] !== t14) {
    t15 = /* @__PURE__ */ jsxRuntimeExports.jsx(Button, { type: "submit", size: "sm", radius: 8, disabled: isDisabled, mt: "md", style: t13, children: t14 });
    $[33] = isDisabled;
    $[34] = t14;
    $[35] = t15;
  } else {
    t15 = $[35];
  }
  let t16;
  if ($[36] !== isLoading) {
    t16 = /* @__PURE__ */ jsxRuntimeExports.jsx(LoadingOverlay, { visible: isLoading });
    $[36] = isLoading;
    $[37] = t16;
  } else {
    t16 = $[37];
  }
  let t17;
  if ($[38] !== t10 || $[39] !== t12 || $[40] !== t15 || $[41] !== t16) {
    t17 = /* @__PURE__ */ jsxRuntimeExports.jsxs("form", { onSubmit: t10, children: [
      t12,
      t15,
      t16
    ] });
    $[38] = t10;
    $[39] = t12;
    $[40] = t15;
    $[41] = t16;
    $[42] = t17;
  } else {
    t17 = $[42];
  }
  return t17;
};
const UserCredentials = () => {
  const $ = compilerRuntimeExports.c(12);
  const {
    t
  } = useTranslation();
  const isMobile = useMediaQuery("(max-width: 576px)");
  const {
    Settings
  } = useAppSelector(_temp);
  let t0;
  if ($[0] !== t) {
    t0 = t("profile.credentials");
    $[0] = t;
    $[1] = t0;
  } else {
    t0 = $[1];
  }
  const t1 = isMobile ? 1 : 2;
  let t2;
  if ($[2] !== Settings) {
    t2 = !isSaaS(Settings) ? /* @__PURE__ */ jsxRuntimeExports.jsx(LoginCredentials, {}) : null;
    $[2] = Settings;
    $[3] = t2;
  } else {
    t2 = $[3];
  }
  let t3;
  let t4;
  if ($[4] === Symbol.for("react.memo_cache_sentinel")) {
    t3 = /* @__PURE__ */ jsxRuntimeExports.jsx(EmailCredentials, {});
    t4 = /* @__PURE__ */ jsxRuntimeExports.jsx(AdditionalEmailCredentials, {});
    $[4] = t3;
    $[5] = t4;
  } else {
    t3 = $[4];
    t4 = $[5];
  }
  let t5;
  if ($[6] !== t1 || $[7] !== t2) {
    t5 = /* @__PURE__ */ jsxRuntimeExports.jsxs(SimpleGrid, { cols: t1, w: "100%", children: [
      t2,
      t3,
      t4
    ] });
    $[6] = t1;
    $[7] = t2;
    $[8] = t5;
  } else {
    t5 = $[8];
  }
  let t6;
  if ($[9] !== t0 || $[10] !== t5) {
    t6 = /* @__PURE__ */ jsxRuntimeExports.jsx(SectionTemplate, { dataSection: PanelsEnum.credentials, title: t0, children: t5 });
    $[9] = t0;
    $[10] = t5;
    $[11] = t6;
  } else {
    t6 = $[11];
  }
  return t6;
};
function _temp(state) {
  return state.userInfo;
}
const PersonalData = () => {
  const $ = compilerRuntimeExports.c(1);
  let t0;
  if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
    t0 = /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
      /* @__PURE__ */ jsxRuntimeExports.jsx(ProfileHeader, {}),
      /* @__PURE__ */ jsxRuntimeExports.jsx(UserCredentials, {}),
      /* @__PURE__ */ jsxRuntimeExports.jsx(GeneralInformation, {})
    ] });
    $[0] = t0;
  } else {
    t0 = $[0];
  }
  return t0;
};
export {
  PersonalData as default
};
//# sourceMappingURL=index-CQqoUH6l.js.map
