import { E as compilerRuntimeExports, a0 as useParams, r as reactExports, j as jsxRuntimeExports } from "./vendor-react-DYNCg6N5.js";
import { L as LoginWraper } from "./index-q4s1wmSu.js";
import { c as createStyles, V as LoadingOverlay, b as Box } from "./vendor-mantine-h0WlM2Mj.js";
import { c as useAppSelector, aq as useLazyCheckInvitationLinkCodeQuery, ab as useLazyCheckCanCreateUserQuery, i as isSaaS } from "./index-DfebxkL9.js";
import { I as InvalidLinkContent } from "./InvalidLinkContent-CWLs7Xhy.js";
import { R as RegistrationForm } from "./RegistrationForm-CuW4XnXz.js";
import { M as MessageContainer } from "./index-CNv4hlnY.js";
import { u as useTranslation, i as instance } from "./vendor-i18n-wisIXUFi.js";
import "./vendor-icons-xWhXK_Ui.js";
import "./passwordOptions-b-kjbiiT.js";
import "./passwordUtils-B3CN2t6O.js";
import "./useGeneratePolicy-B4rO5xUa.js";
import "./types-espwwxTQ.js";
import "./validation-Ds00Zghx.js";
const useStyles = createStyles((theme) => ({
  wrapper: {
    display: "flex",
    alignItems: "center",
    marginBottom: "20px",
    marginTop: "-15px"
  },
  subtitle: {
    color: theme.colors.gray[6]
  },
  link: {
    padding: 0,
    fontWeight: 400,
    marginLeft: "5px",
    fontSize: "16px",
    height: "auto",
    "&:hover": {
      textDecoration: "underline",
      backgroundColor: "transparent"
    }
  },
  checkbox: {
    label: {
      color: theme.colors.gray[8],
      paddingLeft: "7px",
      lineHeight: "18px"
    }
  },
  checkboxLink: {
    fontSize: "14px",
    padding: 0,
    fontWeight: 400,
    height: "auto",
    lineHeight: "18px",
    "&:hover": {
      textDecoration: "underline",
      backgroundColor: "transparent"
    }
  },
  controls: {
    "& .mantine-InputWrapper-error": {
      marginBottom: "10px",
      marginTop: "10px",
      fontSize: "14px",
      position: "relative"
    },
    "& .mantine-Checkbox-error": {
      paddingLeft: "8px"
    }
  }
}));
const iconError = "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='M35%2045V40C35%2038.6739%2035.5268%2037.4021%2036.4645%2036.4645C37.4021%2035.5268%2038.6739%2035%2040%2035H45M35%2065V70C35%2071.3261%2035.5268%2072.5979%2036.4645%2073.5355C37.4021%2074.4732%2038.6739%2075%2040%2075H45M65%2035H70C71.3261%2035%2072.5979%2035.5268%2073.5355%2036.4645C74.4732%2037.4021%2075%2038.6739%2075%2040V45M65%2075H70C71.3261%2075%2072.5979%2074.4732%2073.5355%2073.5355C74.4732%2072.5979%2075%2071.3261%2075%2070V65M47.5%2050H47.525M62.5%2050H62.525M48.75%2062.625C49.5647%2061.7935%2050.5371%2061.1329%2051.6103%2060.6819C52.6835%2060.231%2053.8359%2059.9987%2055%2059.9987C56.1641%2059.9987%2057.3165%2060.231%2058.3897%2060.6819C59.4629%2061.1329%2060.4353%2061.7935%2061.25%2062.625'%20stroke='%23FD7E14'%20stroke-width='2.33'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3c/svg%3e";
const InviteRegister = () => {
  const $ = compilerRuntimeExports.c(42);
  const {
    t
  } = useTranslation();
  const {
    code: t0
  } = useParams();
  const code = t0 === void 0 ? "" : t0;
  const {
    classes
  } = useStyles();
  const {
    Settings
  } = useAppSelector(_temp);
  const [isCodeValid, setIsCodeValid] = reactExports.useState(null);
  const [isRequestCompleted, setIsRequestCompleted] = reactExports.useState(false);
  let t1;
  if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
    t1 = {};
    $[0] = t1;
  } else {
    t1 = $[0];
  }
  const [passwordStrengthOptions, setPasswordStrengthOptions] = reactExports.useState(t1);
  const [checkInvitationLinkCode, t2] = useLazyCheckInvitationLinkCodeQuery();
  const {
    data: checkInvitationLinkData
  } = t2;
  const [checkCanCreateUser, t3] = useLazyCheckCanCreateUserQuery();
  const {
    data: canCreateUserData,
    isLoading
  } = t3;
  let t4;
  if ($[1] !== Settings || $[2] !== checkCanCreateUser || $[3] !== checkInvitationLinkData) {
    t4 = () => {
      if (checkInvitationLinkData && isSaaS(Settings)) {
        checkCanCreateUser({
          Customerid: checkInvitationLinkData.CustomerId
        });
      }
    };
    $[1] = Settings;
    $[2] = checkCanCreateUser;
    $[3] = checkInvitationLinkData;
    $[4] = t4;
  } else {
    t4 = $[4];
  }
  let t5;
  if ($[5] !== checkInvitationLinkData) {
    t5 = [checkInvitationLinkData];
    $[5] = checkInvitationLinkData;
    $[6] = t5;
  } else {
    t5 = $[6];
  }
  reactExports.useEffect(t4, t5);
  let t6;
  let t7;
  if ($[7] !== checkInvitationLinkCode || $[8] !== code) {
    t6 = () => {
      checkInvitationLinkCode({
        Code: code
      }).then(() => {
        setIsRequestCompleted(true);
      });
    };
    t7 = [code, checkInvitationLinkCode];
    $[7] = checkInvitationLinkCode;
    $[8] = code;
    $[9] = t6;
    $[10] = t7;
  } else {
    t6 = $[9];
    t7 = $[10];
  }
  reactExports.useEffect(t6, t7);
  let t8;
  let t9;
  if ($[11] !== checkInvitationLinkData) {
    t8 = () => {
      if (checkInvitationLinkData) {
        setIsCodeValid(checkInvitationLinkData == null ? void 0 : checkInvitationLinkData.IsActive);
        setPasswordStrengthOptions(checkInvitationLinkData);
      }
    };
    t9 = [checkInvitationLinkData];
    $[11] = checkInvitationLinkData;
    $[12] = t8;
    $[13] = t9;
  } else {
    t8 = $[12];
    t9 = $[13];
  }
  reactExports.useEffect(t8, t9);
  let t10;
  if ($[14] !== Settings) {
    t10 = () => {
      const localLanguage = localStorage.getItem("lng");
      if ((Settings == null ? void 0 : Settings.Culture) && Settings.Culture !== localLanguage) {
        localStorage.setItem("lng", Settings.Culture);
        instance.changeLanguage(Settings.Culture);
      }
    };
    $[14] = Settings;
    $[15] = t10;
  } else {
    t10 = $[15];
  }
  const t11 = Settings == null ? void 0 : Settings.Culture;
  let t12;
  if ($[16] !== t11) {
    t12 = [t11];
    $[16] = t11;
    $[17] = t12;
  } else {
    t12 = $[17];
  }
  reactExports.useEffect(t10, t12);
  let t13;
  if ($[18] !== canCreateUserData || $[19] !== isCodeValid || $[20] !== isRequestCompleted || $[21] !== t) {
    t13 = !isRequestCompleted || !isCodeValid || canCreateUserData ? "" : t("register.title");
    $[18] = canCreateUserData;
    $[19] = isCodeValid;
    $[20] = isRequestCompleted;
    $[21] = t;
    $[22] = t13;
  } else {
    t13 = $[22];
  }
  let t14;
  if ($[23] !== t) {
    t14 = t("");
    $[23] = t;
    $[24] = t14;
  } else {
    t14 = $[24];
  }
  let t15;
  if ($[25] !== Settings || $[26] !== (canCreateUserData == null ? void 0 : canCreateUserData.IsCanAddUser) || $[27] !== checkInvitationLinkData || $[28] !== code || $[29] !== isCodeValid || $[30] !== isLoading || $[31] !== isRequestCompleted || $[32] !== passwordStrengthOptions || $[33] !== t) {
    t15 = !isRequestCompleted || isLoading ? /* @__PURE__ */ jsxRuntimeExports.jsx(LoadingOverlay, { visible: true, overlayProps: {
      blur: 10
    } }) : !isCodeValid ? /* @__PURE__ */ jsxRuntimeExports.jsx(InvalidLinkContent, {}) : !(canCreateUserData == null ? void 0 : canCreateUserData.IsCanAddUser) && isSaaS(Settings) ? /* @__PURE__ */ jsxRuntimeExports.jsx(MessageContainer, { icon: iconError, description: t("register.cantRegister"), buttonText: t("backMain"), redirect: "/login" }) : /* @__PURE__ */ jsxRuntimeExports.jsx(RegistrationForm, { passwordStrengthOptions, invitationData: checkInvitationLinkData, invitationCode: code });
    $[25] = Settings;
    $[26] = canCreateUserData == null ? void 0 : canCreateUserData.IsCanAddUser;
    $[27] = checkInvitationLinkData;
    $[28] = code;
    $[29] = isCodeValid;
    $[30] = isLoading;
    $[31] = isRequestCompleted;
    $[32] = passwordStrengthOptions;
    $[33] = t;
    $[34] = t15;
  } else {
    t15 = $[34];
  }
  let t16;
  if ($[35] !== classes.controls || $[36] !== t15) {
    t16 = /* @__PURE__ */ jsxRuntimeExports.jsx(Box, { className: classes.controls, children: t15 });
    $[35] = classes.controls;
    $[36] = t15;
    $[37] = t16;
  } else {
    t16 = $[37];
  }
  let t17;
  if ($[38] !== t13 || $[39] !== t14 || $[40] !== t16) {
    t17 = /* @__PURE__ */ jsxRuntimeExports.jsx(LoginWraper, { title: t13, text: t14, children: t16 });
    $[38] = t13;
    $[39] = t14;
    $[40] = t16;
    $[41] = t17;
  } else {
    t17 = $[41];
  }
  return t17;
};
function _temp(state) {
  return state.userInfo;
}
export {
  InviteRegister
};
//# sourceMappingURL=index-BIIcHhad.js.map
