import e, { useState as Q, useEffect as $ } from "react";
import { IamHelper as ce, IamUserAuthorizationClient as ie, LoginErrorExpired as We, LoginErrorCancelled as Ze, TWOFA_PAGE as S, Iam as He, EligibleUser as Be } from "@accelbyte/sdk-iam";
import { a as G, c as Le, b as Ke, u as ye } from "./useAppState-80c04995.mjs";
import { a as X, u as R } from "./useUserInfo-ad7006e5.mjs";
import { u as Me, b as ge, E as J, F as w } from "./FetchConfigsUtils-476a602b.mjs";
import { C as V } from "./CommonError-e27d39d7.mjs";
import { L as De, a as Se } from "./Loading-9dff8957.mjs";
import { t as E, g as Ee } from "./i18n-6228a4ed.mjs";
import { Trans as n } from "react-i18next";
import { LegalHelper as se } from "@accelbyte/sdk-legal";
import { A as H } from "./Alert-1fab9453.mjs";
import { H as Je } from "./HeaderAlerts-7d33c741.mjs";
import { l as Xe, A as qe, B as $e, E as et, a as je, b as le, u as he, V as tt, H as Ae, e as it, U as at, I as nt, L as rt } from "./EmailVerificationForm-6a6a28fa.mjs";
import { E as ee } from "./Env-161a418e.mjs";
import { U as ot } from "./UrlUtils-45b0efe7.mjs";
import { UrlHelper as fe, DesktopChecker as ct } from "@accelbyte/sdk";
import { A as L } from "./Alert-1277e378.mjs";
import { z as re } from "zod";
import { B as v, S as st, a as lt, b as xe, c as Pe } from "./Button-c97a7217.mjs";
import { C as Mt } from "./Checkbox-c1d65bdf.mjs";
import me from "react-otp-input";
import { u as pe } from "./useHeaderAlerts-15020c2b.mjs";
import { D as gt, a as ut, b as mt } from "./Dialog-806d50a9.mjs";
import oe from "classnames";
import { F as ke, c as we } from "./FormGroup-bf779d3e.mjs";
import { I as Oe } from "./InputGroup-8377b80f.mjs";
import { V as _e, i as be, v as ve, d as K } from "./validateEmail-03d506e7.mjs";
import { M as Ue } from "./numbers-4344265e.mjs";
import { L as It } from "./LanguageSelector-e5ed6045.mjs";
import { u as dt } from "./useDiscoveryConfigs-cf63cd60.mjs";
import { s as Nt } from "./starBgGradient-589e5185.mjs";
import "./ErrorPage-4ed993c7.mjs";
import "./SSRHelper-8eb361ff.mjs";
import "@accelbyte/sdk-gdpr";
import "@accelbyte/sdk-basic";
import "./RouteUtils-f2d71427.mjs";
import "uuid";
import "axios";
import "flat";
import "i18next";
import "date-fns";
import "./InfoIcon-c86fd057.mjs";
import "react-feather";
import "shortid";
import "./useCompanyLogo-b952c2f7.mjs";
import "./useAppConfigs-0fb5df89.mjs";
import "@zxcvbn-ts/core";
import "./CircleCheckIcon-8f97f219.mjs";
import "react-dom";
import "react-tooltip";
import "./InputLabel-760cfc94.mjs";
import "xregexp";
const yt = "errorContainer _errorContainer_c5dcb", Dt = "sessionExpiredContainer _sessionExpiredContainer_76ac5", Ye = {
  errorContainer: yt,
  sessionExpiredContainer: Dt
}, Et = (i) => {
  const [t, a] = Q(null), [r] = Me(), { state: o } = X(), { state: s } = ge(), { mutations: c } = R(), l = G();
  $(() => {
    g();
  }, []);
  const M = () => {
    var d;
    o.replace(`${(d = o.location) == null ? void 0 : d.pathname}`);
  }, g = async () => {
    try {
      await I(), i.onAuthCodeDone();
    } catch (d) {
      console.error(d), M(), a(d);
    }
  }, I = async () => {
    var N, y;
    if (!((N = o.location) != null && N.search))
      return;
    const { code: d, error: p, state: A } = ce.getAuthorizationCodeParams((y = o.location) == null ? void 0 : y.search);
    try {
      const C = await new ie(r).exchangeAuthorizationCode({
        code: d,
        error: p,
        state: A
      });
      if (!C)
        return;
      M();
      const { mfaData: F, returnPath: D } = C;
      F ? c.updateMFAData(F) : await l.fetchAllUserInformation(), D ? o.replace(D) : D.replace(s.home.link);
    } catch (h) {
      i.onAuthCodeError(h);
    }
  };
  return /* @__PURE__ */ e.createElement(e.Fragment, null, !t && /* @__PURE__ */ e.createElement(De, { className: Se.medium }, /* @__PURE__ */ e.createElement(n, { i18nKey: "InitialUserFetchPage.notice" })), t && /* @__PURE__ */ e.createElement("div", { className: Ye.errorContainer }, /* @__PURE__ */ e.createElement(V, { error: t })), t && /* @__PURE__ */ e.createElement(jt, { error: t }));
}, jt = ({ error: i }) => {
  var o;
  const { state: t } = X(), [a] = Me(), r = () => {
    const s = new ie(a).createLoginURL(t.location.pathname);
    window.location.replace(s);
  };
  if (!i)
    return null;
  if (J.isAxiosError(i) && ((o = i == null ? void 0 : i.response) != null && o.status)) {
    const { status: s } = i.response;
    if (s === 401)
      return /* @__PURE__ */ e.createElement("div", { className: Ye.sessionExpiredContainer }, /* @__PURE__ */ e.createElement(n, { i18nKey: "AuthorizationCodeExchanger.error.sessionExpired" }, "Session Expired"), /* @__PURE__ */ e.createElement("div", { onClick: r }, E("HomePage.login")));
  }
  return /* @__PURE__ */ e.createElement(V, { error: i });
}, pa = ({ children: i }) => {
  var g;
  const [t, a] = Q(!1), { state: r } = X(), { state: o } = ge(), s = G(), l = new URLSearchParams((g = r.location) == null ? void 0 : g.search).get("error"), M = (I) => {
    var d, p;
    return I instanceof We ? (s.logout(), r.replace(o["error.sessionExpired"].link)) : I instanceof Ze ? r.replace(`${(d = r.location) == null ? void 0 : d.pathname}`) : r.replace(`${(p = r.location) == null ? void 0 : p.pathname}`);
  };
  if (l) {
    const I = ie.deduceLoginError(l);
    return M(I), null;
  }
  return t ? i : /* @__PURE__ */ e.createElement(Et, { onAuthCodeDone: () => a(!0), onAuthCodeError: M });
}, Qe = class {
};
let te = Qe;
te.PP_BASE_PATH = fe.trimSlashFromStringEnd(
  ot.makeAbsolutePath(fe.trimSlashFromStringEdges(ee.PLAYER_PORTAL_BASE_URL))
);
te.CACHE_URL = ee.CACHE_URL || `${Qe.PP_BASE_PATH}/cache`;
te.DOCS_FAQ_URL = "https://docs.accelbyte.io/faq/faq.html";
const At = typeof me == "object" ? me.default : me;
class pt extends e.Component {
  constructor(t) {
    super(t), this.onCodeChange = (a) => {
      this.setState({ code: a });
    }, this.onRememberDeviceChange = () => {
      this.setState((a) => ({
        rememberDevice: !a.rememberDevice
      }));
    }, this.submit = () => {
      const { factor: a } = this.props, { code: r, rememberDevice: o } = this.state;
      this.props.onSubmit({ code: r, factor: a, rememberDevice: o });
    }, this.onKeyDown = (a) => {
      a.key !== "Enter" || this.state.code.length < this.props.codeLength || this.submit();
    }, this.state = {
      code: "",
      rememberDevice: !0
    };
  }
  componentDidMount() {
    window.addEventListener("keydown", this.onKeyDown);
  }
  componentWillUnmount() {
    window.removeEventListener("keydown", this.onKeyDown);
  }
  render() {
    const { codeLength: t, isSubmitting: a, onTryAnother: r, helperText: o } = this.props, { code: s, rememberDevice: c } = this.state;
    return /* @__PURE__ */ e.createElement(e.Fragment, null, /* @__PURE__ */ e.createElement(
      At,
      {
        value: s,
        onChange: this.onCodeChange,
        numInputs: t,
        className: "otpInput",
        containerStyle: "otpInputContainer",
        focusStyle: "otpInput__focus",
        shouldAutoFocus: !0,
        isDisabled: a
      }
    ), o, /* @__PURE__ */ e.createElement("div", { className: "rememberDeviceContainer" }, /* @__PURE__ */ e.createElement(Mt, { isChecked: c, onChange: this.onRememberDeviceChange, label: E("twoFAPage.checkbox.rememberDevice") }), !!r && /* @__PURE__ */ e.createElement("span", { className: "tryAnother", onClick: r }, /* @__PURE__ */ e.createElement(n, { i18nKey: "twoFAPage.tryAnother" }, "Try another way"))), /* @__PURE__ */ e.createElement(
      v,
      {
        loadingIndicator: "SPINNER",
        className: "continueButton btn btn-primary",
        onClick: this.submit,
        disabled: s.length < t,
        isLoading: a
      },
      E("UpgradeHeadlessAccountPage.UpgradeHeadlessAccountPage.continue")
    ));
  }
}
const Ie = (i) => {
  const { icon: t, description: a, onClick: r } = i;
  return /* @__PURE__ */ e.createElement("div", { className: "methodOption", onClick: r }, t, /* @__PURE__ */ e.createElement("p", null, a));
}, ae = (i) => {
  const { title: t, alert: a, withAlert: r, description: o, children: s, onDismissAlert: c } = i;
  return /* @__PURE__ */ e.createElement(e.Fragment, null, /* @__PURE__ */ e.createElement("div", { className: "titleWrapper" }, /* @__PURE__ */ e.createElement("p", { className: "title" }, t), !!a && r && /* @__PURE__ */ e.createElement(H, { type: a.type, onDismiss: c, className: "text-left" }, a.element), /* @__PURE__ */ e.createElement("p", { className: "description" }, o)), s);
}, de = "mfaPage", Ct = 6, zt = 8, Tt = 6, ne = re.enum(["invalid_code", "invalid_factor", "invalid_mfa_token", "code_expired"]), ft = re.object({
  error: re.string(),
  error_description: re.string()
}), Lt = (i) => {
  var t;
  try {
    if (J.isAxiosError(i))
      switch (ft.parse((t = i == null ? void 0 : i.response) == null ? void 0 : t.data).error) {
        case ne.Enum.invalid_code:
          return /* @__PURE__ */ e.createElement(n, { i18nKey: "twoFAPage.error.invalidCode" }, "Sorry, the code you entered is invalid. Please try again.");
        case ne.Enum.code_expired:
          return /* @__PURE__ */ e.createElement(n, { i18nKey: "twoFAPage.error.codeExpired" }, "Sorry, the code you entered is expired. Please try again.");
        case ne.Enum.invalid_factor:
        case ne.Enum.invalid_mfa_token:
          return /* @__PURE__ */ e.createElement(n, { i18nKey: "twoFAPage.error.invalidFactor" }, "Failed to complete the request. Please click the back to login button below, and try logging in again.");
      }
    throw i;
  } catch {
    return /* @__PURE__ */ e.createElement(V, { error: i });
  }
}, St = () => {
  var P, _;
  const [i, t] = Q(), [a, r] = Q(!1), [o, s] = Q(), [c] = Me(), { state: l } = X(), { state: M, mutations: g } = R(), { mutations: I } = pe(), d = G(), p = ((P = M.mfaData) == null ? void 0 : P.factors) || [];
  $(() => {
    var U;
    const f = (U = M.mfaData) == null ? void 0 : U.defaultFactor, T = sessionStorage.getItem(de);
    t(T || f || S.enum.options);
  }, []);
  const A = (f) => {
    t(f), sessionStorage.setItem(de, f);
  }, N = () => {
    A(S.enum.options);
  }, y = () => {
    s(null);
  }, h = async (f) => {
    if (!a)
      try {
        r(!0);
        const T = await g.verify2FA(f);
        if (T) {
          if (T.error)
            throw T.error;
          d.refreshSession(T.data.access_token, T.data.refresh_token), await d.refreshUser(), g.removeMFAData(), M.isLinkingAccountRequired2FA && (I.push({
            type: L.success,
            element: /* @__PURE__ */ e.createElement(n, { i18nKey: "LinkPlatformAccountPage.notification.accountLinked" }, "Account linked")
          }), g.clearLinkAccountRequired2FA());
        }
      } catch (T) {
        if (J.isAxiosNetworkError(T)) {
          I.push({
            type: L.danger,
            element: E("CommonError.networkError")
          });
          return;
        }
        const U = Lt(T);
        s({ type: L.danger, element: U });
      } finally {
        r(!1);
      }
  }, C = async (f) => {
    if (!(a || !M.mfaData))
      try {
        r(!0), await He.OAuth20Api(c).postOauthMfaCode({
          mfaToken: M.mfaData.mfaToken,
          factor: "email",
          clientId: c.assembly().clientId
        }), f && s({ type: L.success, element: E("twoFAPage.email.resend.success") }), t(S.enum.email);
      } catch (T) {
        if (J.isAxiosNetworkError(T)) {
          I.push({
            type: L.danger,
            element: E("CommonError.networkError")
          });
          return;
        }
        s({ type: L.danger, element: /* @__PURE__ */ e.createElement(V, { error: T }) });
      } finally {
        r(!1);
      }
  }, F = (f) => {
    switch (f) {
      case S.enum.backupCode:
        return zt;
      case S.enum.authenticator:
        return Ct;
      default:
        return Tt;
    }
  }, D = () => /* @__PURE__ */ e.createElement("div", { className: "mt-3 text-[13px]" }, /* @__PURE__ */ e.createElement("span", null, E("AccountPasswordSecurity.2fa.emailModal.helperText")), /* @__PURE__ */ e.createElement("span", { className: "ml-1 cursor-pointer text-blue-50", onClick: () => C(!0) }, E("AccountPasswordSecurity.2fa.emailModal.resendBtn"))), m = (f, T) => {
    var B;
    const U = ((B = M.mfaData) == null ? void 0 : B.factors) || [];
    return /* @__PURE__ */ e.createElement(
      pt,
      {
        onTryAnother: U.length > 1 ? N : void 0,
        codeLength: F(f),
        factor: f,
        onSubmit: h,
        isSubmitting: a,
        helperText: T
      }
    );
  }, x = () => {
    if (sessionStorage.removeItem(de), g.removeMFAData(), d.logout(), !ct.isDesktopApp()) {
      const f = new ie(c).createLoginURL(l.location.pathname);
      window.location.replace(f);
    }
  };
  return /* @__PURE__ */ e.createElement("div", { className: "twoFAPage" }, /* @__PURE__ */ e.createElement(Je, { className: "twoFAAlert" }), /* @__PURE__ */ e.createElement("div", { className: "twoFAContainer" }, /* @__PURE__ */ e.createElement("div", { className: "flex justify-center" }, /* @__PURE__ */ e.createElement("img", { src: Xe, loading: "lazy" })), /* @__PURE__ */ e.createElement("div", { className: "twoFAForm" }, i === S.enum.authenticator && /* @__PURE__ */ e.createElement(
    ae,
    {
      title: E("twoFAPage.authenticator.title"),
      description: /* @__PURE__ */ e.createElement(n, { i18nKey: "twoFAPage.authenticator.description" }, "Please enter the security code from your authenticator app.", /* @__PURE__ */ e.createElement("a", { href: te.DOCS_FAQ_URL, target: "_blank", rel: "noreferrer" }, "Learn more")),
      withAlert: !0,
      alert: o,
      onDismissAlert: y
    },
    m(S.enum.authenticator)
  ), i === S.enum.backupCode && /* @__PURE__ */ e.createElement(
    ae,
    {
      title: E("twoFAPage.backupCode.title"),
      description: /* @__PURE__ */ e.createElement(n, { i18nKey: "twoFAPage.backupCode.description" }, "Please enter one of your backup codes to continue.", /* @__PURE__ */ e.createElement("a", { href: te.DOCS_FAQ_URL, target: "_blank", rel: "noreferrer" }, "Learn more")),
      withAlert: !0,
      alert: o,
      onDismissAlert: y
    },
    m(S.enum.backupCode)
  ), i === S.enum.email && /* @__PURE__ */ e.createElement(
    ae,
    {
      title: E("twoFAPage.email.title"),
      description: /* @__PURE__ */ e.createElement(n, { i18nKey: "twoFAPage.email.description" }, "To continue, please enter the verification code we’ve sent to your email at", /* @__PURE__ */ e.createElement("strong", null, { email: (_ = M.mfaData) == null ? void 0 : _.email }), ".", /* @__PURE__ */ e.createElement("a", { href: "https://docs.accelbyte.io/faq/faq.html", target: "_blank", rel: "noreferrer" }, "Learn more")),
      withAlert: !0,
      alert: o,
      onDismissAlert: y
    },
    m(S.enum.email, D())
  ), i === S.enum.options && /* @__PURE__ */ e.createElement(ae, { title: E("twoFAPage.verify.title"), description: E("twoFAPage.verify.description") }, !!o && /* @__PURE__ */ e.createElement(H, { type: o.type, onDismiss: y, className: "text-left" }, o.element), p.includes(S.enum.authenticator) && /* @__PURE__ */ e.createElement(
    Ie,
    {
      icon: /* @__PURE__ */ e.createElement(qe, null),
      description: E("twoFAPage.verify.authApp.description"),
      onClick: () => A(S.enum.authenticator)
    }
  ), p.includes(S.enum.backupCode) && /* @__PURE__ */ e.createElement(
    Ie,
    {
      icon: /* @__PURE__ */ e.createElement($e, null),
      description: E("twoFAPage.verify.backupCode.description"),
      onClick: () => A(S.enum.backupCode)
    }
  ), p.includes(S.enum.email) && /* @__PURE__ */ e.createElement(
    Ie,
    {
      icon: /* @__PURE__ */ e.createElement(et, null),
      description: E("twoFAPage.verify.email.description"),
      onClick: () => C(!1)
    }
  ))), /* @__PURE__ */ e.createElement("div", { className: "backContainer" }, /* @__PURE__ */ e.createElement("button", { onClick: x }, /* @__PURE__ */ e.createElement(n, { i18nKey: "twoFAPage.backToLogin" }, "Back to Login")))));
};
const ht = () => {
  var A;
  const [i, t] = Q(null), a = G(), { state: r } = R(), { state: o, mutations: s } = Le(), { mutations: c } = pe(), l = o.requestDeletionFetchStatus === w.CANCELLING, M = (A = o.gdprDeletionStatus) == null ? void 0 : A.DeletionDate, g = async () => {
    c.push({
      type: L.success,
      element: /* @__PURE__ */ e.createElement(n, { i18nKey: "AccountDeletionNoticePage.cancelAccountDeletionSuccess" }, "The account deletion process has been cancelled. Please log in to continue."),
      autoDismiss: !0
    }), a.clear();
  }, I = (N) => {
    t({
      type: L.danger,
      element: /* @__PURE__ */ e.createElement(V, { error: N })
    });
  }, d = async () => {
    const N = r.user;
    if (N)
      try {
        await s.cancelDeleteAccount(N.userId), g(), await a.logout();
      } catch (y) {
        I(y);
      }
  }, p = async () => {
    await a.logout();
  };
  return /* @__PURE__ */ e.createElement("div", { className: "deletionNoticeContainer" }, /* @__PURE__ */ e.createElement("main", null, !!i && !l && /* @__PURE__ */ e.createElement(H, { type: i.type, className: "alert", onDismiss: () => t(null) }, i.element), /* @__PURE__ */ e.createElement("p", { className: "title" }, /* @__PURE__ */ e.createElement(n, { i18nKey: "common.AccountDeletion.title" }, "Account deletion in-progress")), /* @__PURE__ */ e.createElement("div", { className: "content" }, /* @__PURE__ */ e.createElement(n, { i18nKey: "common.AccountDeletion.content" }, "Your account is set to be deleted on ", { deletionDate: M }, ". Please check your email for more information regarding the deletion request.")), /* @__PURE__ */ e.createElement("div", { className: "btnContainer" }, /* @__PURE__ */ e.createElement("button", { className: "btn big btnContinue", onClick: () => p() }, /* @__PURE__ */ e.createElement(n, { i18nKey: "AccountDeletionNoticePage.button.keepDeleting" }, "Continue the Deletion")), /* @__PURE__ */ e.createElement("button", { className: "btn big btn-primary btnCancel", disabled: l, onClick: () => d() }, l && /* @__PURE__ */ e.createElement(e.Fragment, null, /* @__PURE__ */ e.createElement(st, { className: `${lt.inline} spinner` }), /* @__PURE__ */ e.createElement(n, { i18nKey: "AccountDeletionNoticePage.form.processing" }, "Processing...")), !l && /* @__PURE__ */ e.createElement(n, { i18nKey: "AccountDeletionNoticePage.button.cancelDeletion" }, "Cancel Deletion")))));
}, xt = "emailVerificationPage _emailVerificationPage_9e642", Pt = "emailVerificationPageContainer _emailVerificationPageContainer_999eb", kt = "logoContainer _logoContainer_647fc", wt = "emailVerificationPageHeader _emailVerificationPageHeader_0f5ac", Ot = "emailVerificationPageForm _emailVerificationPageForm_9b43d", _t = "title _title_920f7", bt = "description _description_ba969", vt = "input _input_d3f42", O = {
  emailVerificationPage: xt,
  emailVerificationPageContainer: Pt,
  logoContainer: kt,
  emailVerificationPageHeader: wt,
  emailVerificationPageForm: Ot,
  title: _t,
  description: bt,
  input: vt
}, Ut = "logoutConfirmationModal _logoutConfirmationModal_c46af", Yt = {
  logoutConfirmationModal: Ut
}, Qt = ({ onLogout: i, onClose: t, isOpen: a }) => /* @__PURE__ */ e.createElement(gt, { title: E("LogoutConfirmationModal.title"), isOpen: a, className: oe(Yt.logoutConfirmationModal) }, /* @__PURE__ */ e.createElement(ut, null, /* @__PURE__ */ e.createElement("p", null, E("LogoutConfirmationModal.content"))), /* @__PURE__ */ e.createElement(mt, { className: "dialogFooter" }, /* @__PURE__ */ e.createElement(v, { className: "btn big btn-ghost btnClose footer-btn", onClick: t }, E("UserSessionList.dialog.cancel")), /* @__PURE__ */ e.createElement(v, { className: "btn big btn-primary btnLogout footer-btn", onClick: i }, E("UserSessionList.dialog.logout")))), Vt = () => {
  const i = e.useRef(new _e()), [t, a] = Q({
    verificationCode: "",
    alert: null,
    isVerificationSuccess: !1,
    isPasteVerificationCode: !1
  }), { state: r } = R(), { state: o, mutations: s } = je(), c = G(), { mutations: l } = pe(), M = o.fetchVerificationStatus === w.VERIFYING, g = o.fetchVerificationStatus === w.REQUESTING, I = !i.current.isAllValid() || be(t.verificationCode) || M || t.isVerificationSuccess, d = (D, m) => {
    a((x) => ({
      ...x,
      alert: { type: D, element: m }
    }));
  }, p = async () => {
    a((D) => ({
      ...D,
      isVerificationSuccess: !0
    })), l.push({
      type: L.success,
      element: /* @__PURE__ */ e.createElement(n, { i18nKey: "EmailVerificationPage.accountVerified" }, "Congratulations! The registration process is complete."),
      autoDismiss: !0
    }), await c.refreshUser();
  }, A = async (D) => {
    const m = await s.verify(D, Ee());
    if (m.error) {
      d(L.danger, /* @__PURE__ */ e.createElement(V, { error: m.error }));
      return;
    }
    p();
  }, N = () => {
    c.logout();
  }, y = (D) => {
    const { isPasteVerificationCode: m } = t, x = D.target.value.toString().toUpperCase(), P = m ? x.replace(/\s/g, "") : x;
    i.current.set("verificationCode", ve(P)), a((_) => ({
      ..._,
      verificationCode: P,
      isPasteVerificationCode: !1
    }));
  }, h = () => {
    a((D) => ({
      ...D,
      isPasteVerificationCode: !0
    }));
  }, C = (D) => {
    if (!D)
      return null;
    const m = {
      [K.enum.empty]: /* @__PURE__ */ e.createElement(n, { i18nKey: "EmailVerificationPage.verifyCodeForm.verifyCodeError.empty" }, "Please enter your verification code."),
      [K.enum.exceedLengthLimit]: /* @__PURE__ */ e.createElement(n, { i18nKey: "EmailVerificationPage.verifyCodeForm.verifyCodeError.ExceedLimit" }, "Verification code must not exceed ", { MAX_SHORT_TEXT_LENGTH: Ue }, " characters"),
      [K.enum.invalidFormat]: /* @__PURE__ */ e.createElement(n, { i18nKey: "EmailVerificationPage.verifyCodeForm.verifyCodeError.invalidFormat" }, "The verification code must be alphanumeric and cannot contain spaces or special characters.")
    };
    return /* @__PURE__ */ e.createElement(we, null, m[D]);
  }, F = async () => {
    var x;
    const D = ((x = r.user) == null ? void 0 : x.emailAddress) || "", m = await s.sendVerificationCode(D, le.enum.UserAccountRegistration);
    if (m.error) {
      d(L.danger, /* @__PURE__ */ e.createElement(V, { error: m.error }));
      return;
    }
    d(
      L.success,
      /* @__PURE__ */ e.createElement(n, { i18nKey: "ChangeEmailPage.verifyCodeForm.codeSent" }, "A verification code has been sent to your email")
    );
  };
  return /* @__PURE__ */ e.createElement("div", { className: "newEmailVerification" }, /* @__PURE__ */ e.createElement("div", { className: O.title }, /* @__PURE__ */ e.createElement(n, { i18nKey: "EmailVerificationPage.title" }, "Enter the Verification Code")), !!t.alert && /* @__PURE__ */ e.createElement(
    H,
    {
      className: "mb-6",
      type: t.alert.type,
      onDismiss: () => a((D) => ({
        ...D,
        alert: null
      }))
    },
    t.alert.element
  ), /* @__PURE__ */ e.createElement("div", { className: O.description }, /* @__PURE__ */ e.createElement("div", null, /* @__PURE__ */ e.createElement(n, { i18nKey: "EmailVerificationPage.instruction1" }, "A verification code has been sent to your email. Please verify your email address to complete the registration process.")), /* @__PURE__ */ e.createElement("div", null, /* @__PURE__ */ e.createElement(n, { i18nKey: "EmailVerificationPage.instruction2" }, "Please enter the verification code below:"))), /* @__PURE__ */ e.createElement(ke, null, /* @__PURE__ */ e.createElement(
    Oe,
    {
      className: O.input,
      value: t.verificationCode || "",
      placeholder: E("EmailVerificationPage.placeholder.verificationCode"),
      onChange: y,
      onPaste: h
    }
  ), C(i.current.get("verificationCode"))), /* @__PURE__ */ e.createElement("div", { className: O.description }, /* @__PURE__ */ e.createElement(n, { i18nKey: "EmailVerificationPage.sendVerificationCode.didntReceiveEmail" }, "Didn't receive an email?"), g && /* @__PURE__ */ e.createElement("span", { className: "ml-1" }, /* @__PURE__ */ e.createElement(n, { i18nKey: "EmailVerificationPage.sendVerificationCode.requesting" }, "Requesting..")), !g && /* @__PURE__ */ e.createElement("span", { onClick: F }, /* @__PURE__ */ e.createElement(n, { i18nKey: "EmailVerificationPage.sendVerificationCode.click" }, " Click here to resend"))), /* @__PURE__ */ e.createElement("div", { className: "flex flex-row" }, /* @__PURE__ */ e.createElement(
    v,
    {
      loadingIndicator: "SPINNER",
      disabled: I,
      className: "btn big btn-primary mt-6 uppercase",
      onClick: () => A(t.verificationCode),
      isLoading: M
    },
    /* @__PURE__ */ e.createElement(n, { i18nKey: "EmailVerificationPage.submitButton" }, "VERIFY")
  ), /* @__PURE__ */ e.createElement(v, { className: "btn big text-blue-40 mt-6 capitalize", onClick: N, disabled: M || t.isVerificationSuccess }, /* @__PURE__ */ e.createElement(n, { i18nKey: "EmailVerificationPage.notNowBtn" }, "Not Now"))));
};
class Ft extends e.Component {
  constructor(t) {
    super(t), this.onVerificationCodeChange = (a) => {
      const r = a.target.value.toString().toUpperCase();
      this.validation.set("verificationCode", ve(r)), this.setState({
        verificationCode: r
      });
    }, this.state = {
      verificationCode: ""
    }, this.validation = new _e(), this.validation.listen(() => this.setState({}));
  }
  renderVerificationCodeError(t) {
    if (!t)
      return null;
    const a = {
      [K.enum.empty]: /* @__PURE__ */ e.createElement(n, { i18nKey: "EmailVerificationPage.verifyCodeForm.verifyCodeError.empty" }, "Please enter your verification code."),
      [K.enum.exceedLengthLimit]: /* @__PURE__ */ e.createElement(n, { i18nKey: "EmailVerificationPage.verifyCodeForm.verifyCodeError.ExceedLimit" }, "Verification code must not exceed ", { MAX_SHORT_TEXT_LENGTH: Ue }, " characters"),
      [K.enum.invalidFormat]: /* @__PURE__ */ e.createElement(n, { i18nKey: "EmailVerificationPage.verifyCodeForm.verifyCodeError.invalidFormat" }, "The verification code must be alphanumeric and cannot contain spaces or special characters.")
    };
    return /* @__PURE__ */ e.createElement(we, null, a[t]);
  }
  render() {
    const { isRequestingCode: t, isVerifying: a, onChangeEmail: r, onResend: o, onVerify: s, alert: c, onDismissAlert: l, isSuccess: M } = this.props, { verificationCode: g } = this.state, I = be(g) || a || M || !this.validation.isAllValid();
    return /* @__PURE__ */ e.createElement("div", null, /* @__PURE__ */ e.createElement("div", { className: O.title }, /* @__PURE__ */ e.createElement(n, { i18nKey: "NewEmailVerificationPage.title" }, "Verify your new email")), !!c && /* @__PURE__ */ e.createElement(H, { type: c.type, onDismiss: l, className: "mb-6" }, c.element), /* @__PURE__ */ e.createElement("div", { className: O.description }, /* @__PURE__ */ e.createElement("p", null, /* @__PURE__ */ e.createElement(n, { i18nKey: "NewEmailVerificationPage.verificationCodeForm.description" }, "A verification code has been sent to your new email address. Please enter the verification code below."))), /* @__PURE__ */ e.createElement(ke, null, /* @__PURE__ */ e.createElement(
      Oe,
      {
        className: O.input,
        value: g || "",
        placeholder: E("NewEmailVerificationPage.placeholder.verificationCode"),
        onChange: this.onVerificationCodeChange
      }
    ), this.renderVerificationCodeError(this.validation.get("verificationCode"))), /* @__PURE__ */ e.createElement("div", { className: "mt-2 flex flex-row" }, /* @__PURE__ */ e.createElement(
      v,
      {
        loadingIndicator: "SPINNER",
        disabled: I,
        className: oe(O.btnActionVerify, "btn btn-primary"),
        onClick: () => s(g),
        isLoading: a
      },
      /* @__PURE__ */ e.createElement(n, { i18nKey: "NewEmailVerificationPage.submitButton" }, "Verify")
    )), /* @__PURE__ */ e.createElement("div", { className: oe(O.description, "mt-2") }, /* @__PURE__ */ e.createElement(n, { i18nKey: "NewEmailVerificationPage.sendVerificationCode.didntReceiveEmail" }, "Didn't receive the email?"), t && /* @__PURE__ */ e.createElement("span", { className: "ml-1" }, /* @__PURE__ */ e.createElement(n, { i18nKey: "NewEmailVerificationPage.sendVerificationCode.requesting" }, "Requesting...")), !t && /* @__PURE__ */ e.createElement("span", { onClick: () => o() }, /* @__PURE__ */ e.createElement(n, { i18nKey: "NewEmailVerificationPage.sendVerificationCode.click" }, " Click here to resend"))), /* @__PURE__ */ e.createElement("div", { className: oe(O.description, "mt-2") }, /* @__PURE__ */ e.createElement(n, { i18nKey: "NewEmailVerificationPage.changeEmail" }, "Entered the wrong email?", /* @__PURE__ */ e.createElement("span", { onClick: () => r() }, " Click here to change"))));
  }
}
const Gt = (i) => {
  const [t, a] = Q({
    step: "verifyCodeNewEmail",
    verificationCode: "",
    alert: null,
    isVerificationSuccess: !1
  }), { state: r, mutations: o } = R(), { state: s, mutations: c } = je(), { state: l, mutations: M } = he(), { state: g } = X(), { state: I } = ge(), d = G();
  $(() => {
    var j;
    const z = new URLSearchParams((j = g.location) == null ? void 0 : j.search);
    p(), z.get("isChangingEmail") && a((W) => ({ ...W, step: "inputNewEmail" }));
  }, []);
  const p = async () => {
    const z = await M.fetchValidations();
    z.error && y(z.error);
  }, A = (z) => {
    a((j) => ({
      ...j,
      ...z
    }));
  }, N = () => {
    A({
      alert: {
        type: L.success,
        element: /* @__PURE__ */ e.createElement(n, { i18nKey: "ChangeEmailPage.verifyCodeForm.codeSent" }, "A verification code has been sent to your email")
      }
    });
  }, y = async (z) => {
    l.validationsError && await M.refetchIfValidationError(l.validationsError), A({
      alert: {
        type: L.danger,
        element: /* @__PURE__ */ e.createElement(V, { error: z })
      }
    });
  }, h = async (z) => {
    const j = await c.verify(z, Ee());
    if (j.error) {
      A({
        alert: {
          type: L.danger,
          element: /* @__PURE__ */ e.createElement(V, { error: j.error })
        },
        isVerificationSuccess: !1
      });
      return;
    }
    A({ isVerificationSuccess: !0 }), await d.fetchAllUserInformation(), g.push({ pathname: I.account.profile.link, state: { updateEmailStatus: "success" } });
  }, C = () => {
    A({ alert: null });
  }, F = async () => {
    const { setIsLogoutAvailable: z } = i, j = r.user, W = (j == null ? void 0 : j.oldEmailAddress) || (j == null ? void 0 : j.emailAddress) || "", Z = await c.sendVerificationCode(W, le.enum.UpdateEmailAddress);
    Z.error ? await y(Z.error) : N(), A({ step: "inputNewEmail" }), g.push(`${g.location.pathname}?isChangingEmail=true`), z(!1);
  }, D = () => {
    const { setIsLogoutAvailable: z } = i;
    A({ step: "verifyCodeNewEmail" }), C(), g.push(g.location.pathname), z(!0);
  }, m = async (z, j) => {
    const { pathname: W } = g.location, Z = await o.updateEmail(z, j);
    if (Z.error) {
      y(Z.error);
      return;
    }
    window.open(W, "_self");
  }, x = async (z) => {
    const j = await c.sendVerificationCode(z, le.enum.UpdateEmailAddress);
    if (j.error) {
      y(j.error);
      return;
    }
    N();
  }, P = Be.safeParse(r.user);
  if (!P.success)
    return null;
  const _ = P.data.newEmailAddress || P.data.emailAddress, f = P.data.emailVerified, T = P.data.oldEmailAddress || P.data.emailAddress, U = s.fetchVerificationStatus === w.REQUESTING, B = s.fetchVerificationStatus === w.VERIFYING;
  return /* @__PURE__ */ e.createElement("div", { className: "newEmailVerification" }, t.step === "verifyCodeNewEmail" && /* @__PURE__ */ e.createElement(
    Ft,
    {
      isRequestingCode: U,
      isVerifying: B,
      onResend: () => x(_),
      onVerify: async (z) => {
        await h(z);
      },
      onChangeEmail: F,
      alert: t.alert,
      onDismissAlert: C,
      isSuccess: t.isVerificationSuccess
    }
  ), t.step === "inputNewEmail" && /* @__PURE__ */ e.createElement(
    tt,
    {
      isRequestingCode: U,
      onResendCode: () => x(T),
      onUpdateEmail: m,
      alert: t.alert,
      onDismissAlert: C,
      oldEmail: T,
      isUpdatingEmail: r.userFetchStatus === w.UPDATING,
      isFromEmailVerification: !0,
      onCancel: D,
      emailVerified: f,
      newEmail: _
    }
  ));
}, Rt = () => {
  const i = G(), { state: t } = R(), [a, r] = Q({
    isLogoutAvailable: !0,
    isLogoutConfirmationModalOpen: !1,
    isUpdatingEmail: ce.currentUserIsUpdatingEmail(t.user)
  }), o = (l) => {
    r((M) => ({ ...M, isLogoutAvailable: l }));
  }, s = () => {
    r((l) => ({ ...l, isLogoutConfirmationModalOpen: !l.isLogoutConfirmationModalOpen }));
  }, c = () => {
    i.logout();
  };
  return /* @__PURE__ */ e.createElement(e.Fragment, null, /* @__PURE__ */ e.createElement("div", { className: O.emailVerificationPage }, /* @__PURE__ */ e.createElement("div", { className: O.emailVerificationPageContainer }, /* @__PURE__ */ e.createElement(Ae, null), /* @__PURE__ */ e.createElement("div", { className: O.emailVerificationPageForm }, a.isUpdatingEmail && /* @__PURE__ */ e.createElement(Gt, { setIsLogoutAvailable: o }), !a.isUpdatingEmail && /* @__PURE__ */ e.createElement(Vt, null)), a.isUpdatingEmail && a.isLogoutAvailable && /* @__PURE__ */ e.createElement("span", { onClick: s }, /* @__PURE__ */ e.createElement(n, { i18nKey: "UserSessionItem.logout" }, "Logout")))), /* @__PURE__ */ e.createElement(Qt, { isOpen: a.isLogoutConfirmationModalOpen, onLogout: c, onClose: s }));
}, Wt = "logoContainer _logoContainer_79460", Zt = "headlessAccountPage _headlessAccountPage_9d10b", Ht = "headlessAccountPageContainer _headlessAccountPageContainer_3eae6", Bt = "headlessAccountPageContainerForm _headlessAccountPageContainerForm_fc277", Kt = "contentWrapper _contentWrapper_ab231", Jt = "formWrapper _formWrapper_f8b0b", Xt = "alert _alert_31b82", qt = "passwordValidation _passwordValidation_5cf3b", $t = "flexCol _flexCol_34609", ei = "passwordMismatch _passwordMismatch_0d12b", ti = "title _title_38830", ii = "description _description_a9c4b", ai = "resendCode _resendCode_4cad2", ni = "tabs _tabs_b2513", ri = "tab _tab_a1638", oi = "active _active_a34d1", ci = "label _label_c2204", si = "input _input_6de23", li = "select _select_e338f", Mi = "datePicker _datePicker_b5e69", gi = "agreementList _agreementList_0650c", ui = "agreementItem _agreementItem_6bb38", mi = "text _text_164ab", Ii = "optional _optional_d106a", di = "changePage _changePage_481a1", Ni = "backContainer _backContainer_760cd", Y = {
  logoContainer: Wt,
  headlessAccountPage: Zt,
  headlessAccountPageContainer: Ht,
  headlessAccountPageContainerForm: Bt,
  contentWrapper: Kt,
  formWrapper: Jt,
  alert: Xt,
  passwordValidation: qt,
  flexCol: $t,
  passwordMismatch: ei,
  title: ti,
  description: ii,
  resendCode: ai,
  tabs: ni,
  tab: ri,
  active: oi,
  label: ci,
  input: si,
  select: li,
  datePicker: Mi,
  agreementList: gi,
  agreementItem: ui,
  text: mi,
  optional: Ii,
  changePage: di,
  backContainer: Ni
}, Ne = "registration_email", yi = () => {
  var Ce;
  const [i, t] = Q({
    email: "",
    alert: null,
    displayedPolicies: [],
    step: "email"
  }), { displayedPolicies: a, alert: r, step: o, email: s } = i, { state: c, mutations: l } = R(), { state: M, mutations: g } = je(), { state: I, mutations: d } = Ke(), { state: p, mutations: A } = he(), { state: N, mutations: y } = ye(), { state: h } = dt(), C = G(), [F] = Me(), D = ((Ce = h.discoveryConfigData) == null ? void 0 : Ce.brandName.data.value) || "", m = (u) => {
    t((k) => ({
      ...k,
      ...u
    }));
  }, x = async () => {
    const u = await A.fetchValidations(Ee());
    u.error && _(u.error);
  };
  $(() => {
    x();
    const u = sessionStorage.getItem(Ne);
    return m({ email: u || "" }), u && m({ step: "otherData" }), () => {
      j();
    };
  }, []), $(() => {
    var k;
    const u = (k = c.user) == null ? void 0 : k.country;
    u && (async () => {
      const q = await y.fetchPoliciesList(u);
      if (q.error) {
        _(q.error);
        return;
      }
      m({ displayedPolicies: se.convertPoliciesToDisplayedPolicies(q.data || [], ee.NAMESPACE) });
    })();
  }, [c.user, y.fetchPoliciesList]);
  const P = async (u = i.email) => {
    if (!u)
      return;
    const k = await g.sendVerificationCode(u, le.enum.upgradeHeadlessAccount);
    if (k.error) {
      _(k.error);
      return;
    }
    m({ email: u }), T(u);
  }, _ = async (u) => {
    if (await A.refetchIfValidationError(u)) {
      m({ alert: null });
      return;
    }
    const b = J.extractServiceErrorCode(u);
    m({
      alert: {
        type: L.danger,
        element: (() => {
          switch (b) {
            case 10130:
              return /* @__PURE__ */ e.createElement(n, { i18nKey: "UpdateUser.error.updateErrorUnderage" }, "You are below the required age");
            default:
              return /* @__PURE__ */ e.createElement(V, { error: u });
          }
        })()
      }
    });
  }, f = () => {
    m({ alert: null });
  }, T = (u) => {
    sessionStorage.setItem(Ne, u), m({
      step: "otherData",
      alert: {
        type: L.success,
        element: /* @__PURE__ */ e.createElement(n, { i18nKey: "ChangeEmailPage.verifyCodeForm.codeSent" }, "A verification code has been sent to your email")
      }
    });
  }, U = () => {
    m({ alert: null }), x();
  }, B = () => {
    m({ step: "email", email: "" }), j();
  }, z = async ({
    password: u,
    displayName: k,
    username: b,
    reachMinimumAge: q,
    verificationCode: Fe,
    acceptedPolicyIds: Ge
  }) => {
    var Te;
    const Re = ((Te = c.user) == null ? void 0 : Te.country) ?? "", ze = await d.upgradeHeadlessAccount(
      {
        displayName: k,
        password: u,
        username: b,
        country: Re,
        reachMinimumAge: q,
        emailAddress: i.email,
        code: Fe
      },
      ee.IS_DISABLE_USERNAME
    );
    if (ze.error) {
      _(ze.error);
      return;
    }
    await Z(Ge), j();
    const ue = await l.refreshToken();
    ue && C.refreshSession(ue.access_token, ue.refresh_token), await C.refreshUser();
  }, j = () => {
    sessionStorage.removeItem(Ne);
  }, W = (u) => {
    const k = [];
    for (const b of i.displayedPolicies)
      k.push({
        policyId: b.policyId,
        policyVersionId: b.policyVersionId,
        localizedPolicyVersionId: b.localizedPolicyVersionId,
        isAccepted: u.includes(b.policyId)
      });
    return k;
  }, Z = async (u) => {
    const k = c.user, b = W(u);
    b && k && await y.bulkAcceptPolicies(b);
  }, Ve = () => {
    j(), C.logout();
    const u = new ie(F).createLoginURL();
    window.location.replace(u);
  };
  return /* @__PURE__ */ e.createElement("div", { className: Y.headlessAccountPage }, /* @__PURE__ */ e.createElement(It, { className: "fixed top-0 right-0 mt-8 mr-8" }), /* @__PURE__ */ e.createElement("div", { className: Y.headlessAccountPageContainer }, /* @__PURE__ */ e.createElement(Ae, null), /* @__PURE__ */ e.createElement("div", { className: Y.headlessAccountPageContainerForm }, /* @__PURE__ */ e.createElement("div", { className: Y.contentWrapper }, /* @__PURE__ */ e.createElement("div", { className: Y.title }, o === "email" && /* @__PURE__ */ e.createElement(n, { i18nKey: "UpgradeHeadlessAccountPage.UpgradeHeadlessAccountPage.title" }, "Upgrade to Full Account"), o === "otherData" && /* @__PURE__ */ e.createElement(n, { i18nKey: "UpgradeHeadlessAccountPage.UpgradeHeadlessAccountForm.title" }, "Finish Account Setup")), /* @__PURE__ */ e.createElement("div", { className: Y.description }, o === "email" && /* @__PURE__ */ e.createElement(n, { i18nKey: "UpgradeHeadlessAccountPage.UpgradeHeadlessAccountPage.description" }, "Enter your email address below to start creating your ", { publisherName: D }, " account"), o === "otherData" && /* @__PURE__ */ e.createElement(n, { i18nKey: "UpgradeHeadlessAccountPage.UpgradeHeadlessAccountForm.description" }, "Enter the verification code we’ve sent to your email at ", /* @__PURE__ */ e.createElement("strong", null, { email: s }), ", and complete the form below"))), /* @__PURE__ */ e.createElement("div", { className: Y.formWrapper }, !!r && /* @__PURE__ */ e.createElement("div", { className: Y.alert }, /* @__PURE__ */ e.createElement(H, { type: r.type, onDismiss: f }, r.element), !!p.validationsError && /* @__PURE__ */ e.createElement(v, { className: "btn btn-primary mt-4 w-full", onClick: U }, /* @__PURE__ */ e.createElement(n, { i18nKey: "Common.reload" }, "Reload"))), i.step === "email" && /* @__PURE__ */ e.createElement(
    it,
    {
      styles: Y,
      onRequestVerificationCode: P,
      isRequesting: M.fetchVerificationStatus === w.REQUESTING
    }
  ), i.step === "otherData" && /* @__PURE__ */ e.createElement("div", null, p.validations.length <= 0 && p.validationsFetchStatus === w.FETCHING && /* @__PURE__ */ e.createElement(De, { className: Se.medium }), p.validations.length > 0 && !p.validationsError && c.user && /* @__PURE__ */ e.createElement(
    at,
    {
      onChangePage: B,
      onContinue: z,
      onRequestVerificationCode: P,
      policies: a,
      isUpgradingUser: I.upgradeHeadlessAccountFetchStatus === w.FETCHING || N.bulkAcceptPoliciesFetchStatus === w.FETCHING,
      isRequestingVerificationCode: M.fetchVerificationStatus === w.REQUESTING,
      user: c.user,
      styles: Y
    }
  )))), /* @__PURE__ */ e.createElement("div", { className: Y.backContainer }, /* @__PURE__ */ e.createElement("button", { onClick: Ve }, /* @__PURE__ */ e.createElement(n, { i18nKey: "UpgradeHeadlessAccountPage.UpgradeHeadlessAccountPage.logout" }, "Back to Login"))), /* @__PURE__ */ e.createElement(nt, null)));
};
const Di = () => {
  const [i, t] = Q(null), { state: a, mutations: r } = R(), { state: o, mutations: s } = ye(), c = G(), l = o.bulkAcceptPoliciesFetchStatus === w.FETCHING, g = !(o.policiesFetchStatus === w.FETCHING) && o.eligibilities && o.eligibilities.length > 0, I = () => {
    const { eligibilities: N } = o;
    return N || [];
  }, d = (N) => {
    t({
      type: L.danger,
      element: /* @__PURE__ */ e.createElement(V, { error: N })
    });
  }, p = async () => {
    const N = I();
    if (N && a.user) {
      const y = se.getAcceptedPolicies(N), h = await s.bulkAcceptPolicies(y);
      if (h.error) {
        d(h.error);
        return;
      }
      const C = await r.refreshToken();
      C && (c.refreshSession(C.access_token, C.refresh_token), await c.refreshUser());
    }
  }, A = () => {
    const N = I();
    return N ? /* @__PURE__ */ e.createElement("ul", { className: "policies" }, N.map((y) => y.policyVersions && y.policyVersions.map((h) => Array.isArray(h.localizedPolicyVersions) ? h.localizedPolicyVersions.map((C) => /* @__PURE__ */ e.createElement("li", { key: C.id, className: "policyItem" }, y.policyName, /* @__PURE__ */ e.createElement(
      "a",
      {
        href: se.createLegalURL(rt.getLegalUrl(), C.id),
        className: "readMore",
        target: "_blank",
        rel: "noreferrer"
      },
      /* @__PURE__ */ e.createElement(n, { i18nKey: "PromptLegalPage.readMore" }, "Read More")
    ))) : null))) : null;
  };
  return /* @__PURE__ */ e.createElement("div", { className: "promptLegalPage" }, /* @__PURE__ */ e.createElement("div", { className: "promptLegalPageContainer" }, /* @__PURE__ */ e.createElement(Ae, null), /* @__PURE__ */ e.createElement("div", { className: "legalContent" }, o.policiesFetchStatus === w.FETCHING && /* @__PURE__ */ e.createElement(De, null), (g || l) && /* @__PURE__ */ e.createElement(e.Fragment, null, /* @__PURE__ */ e.createElement("div", { className: "legalHeader" }, /* @__PURE__ */ e.createElement("h1", null, /* @__PURE__ */ e.createElement(n, { i18nKey: "PromptLegalPage.title" }, "New Agreement and Policy Terms"))), /* @__PURE__ */ e.createElement("div", { className: "legalBody" }, !l && !!i && /* @__PURE__ */ e.createElement(H, { className: "legalBodyAlert", type: i.type, onDismiss: () => t(null) }, i.element), /* @__PURE__ */ e.createElement(n, { i18nKey: "PromptLegalPage.description" }, /* @__PURE__ */ e.createElement("p", null, "We have updated our user agreement and policy to better explain what data we collect from you, why we collect it, and how it's used."), /* @__PURE__ */ e.createElement("p", null, "The following terms have been updated:")), A(), /* @__PURE__ */ e.createElement("div", { className: "notes" }, /* @__PURE__ */ e.createElement(n, { i18nKey: "PromptLegalPage.notes" }, /* @__PURE__ */ e.createElement("p", null, "Please take a moment to read and understand the updated agreement. By clicking the Accept button, you agree to these changes.")))), /* @__PURE__ */ e.createElement("div", { className: "legalFooter" }, /* @__PURE__ */ e.createElement(
    v,
    {
      loadingIndicator: "SPINNER",
      className: "btn-primary btn-accept",
      isLoading: l,
      disabled: l,
      onClick: p
    },
    /* @__PURE__ */ e.createElement(n, { i18nKey: "PromptLegalPage.accept" }, "Accept")
  ), /* @__PURE__ */ e.createElement(
    v,
    {
      className: "btn-decline",
      buttonType: xe.TEXT,
      buttonStyle: Pe.NONE,
      onClick: () => c.logout(),
      disabled: l
    },
    /* @__PURE__ */ e.createElement(n, { i18nKey: "PromptLegalPage.decline" }, "Decline")
  ))))));
}, Ei = "data:image/svg+xml;base64, ", ji = () => {
  const i = ee.CONTACT_SUPPORT_EMAIL, t = G(), a = () => {
    t.logout();
  }, r = () => window.location.reload();
  return /* @__PURE__ */ e.createElement("div", { className: "mainPageContainer" }, /* @__PURE__ */ e.createElement("div", { className: "errorPage", style: { backgroundImage: `url(${Nt})` } }, /* @__PURE__ */ e.createElement("div", { className: "errorPageContentWrapper errorFetchUser" }, /* @__PURE__ */ e.createElement("div", { className: "errorPageContent" }, /* @__PURE__ */ e.createElement("img", { src: Ei, alt: "space ship alien", loading: "lazy" }), /* @__PURE__ */ e.createElement("div", { className: "errorPageText" }, /* @__PURE__ */ e.createElement("h2", { className: "textHeading" }, /* @__PURE__ */ e.createElement(n, { i18nKey: "FetchUserErrorPage.title" }, "Internal Server Error")), /* @__PURE__ */ e.createElement("div", { className: "textContent" }, !!i && /* @__PURE__ */ e.createElement(n, { i18nKey: "FetchUserErrorPage.textContentWithSupport" }, /* @__PURE__ */ e.createElement("p", null, "Oops.. Something went wrong. Try to refresh this page or log in again. If the problem persists, please contact our support at ", /* @__PURE__ */ e.createElement("a", { href: `mailto:${i}` }, { contactSupportEmail: i }))), !i && /* @__PURE__ */ e.createElement(n, { i18nKey: "FetchUserErrorPage.textContent" }, /* @__PURE__ */ e.createElement("p", null, "Don't worry, our team on Mars is working hard to fix this! For now let's retreat to our home page.")), /* @__PURE__ */ e.createElement("div", { className: "buttonWrapper" }, /* @__PURE__ */ e.createElement(v, { className: "btn btn-primary", onClick: r }, /* @__PURE__ */ e.createElement(n, { i18nKey: "FetchUserErrorPage.refresh" }, "Refresh")), /* @__PURE__ */ e.createElement(v, { className: "btn", onClick: a }, /* @__PURE__ */ e.createElement(n, { i18nKey: "FetchUserErrorPage.logout" }, "Log out")))))))));
};
const Ai = (i) => {
  const { title: t, description: a, message: r, buttonAction: o, buttonText: s, icon: c } = i;
  return /* @__PURE__ */ e.createElement("div", { className: "errorPage" }, /* @__PURE__ */ e.createElement("div", { className: "wrapper" }, typeof c == "string" && /* @__PURE__ */ e.createElement("img", { src: c, className: "icon", loading: "lazy" }), typeof c != "string" && c, /* @__PURE__ */ e.createElement("div", { className: "message" }, /* @__PURE__ */ e.createElement("div", { className: "primary" }, t), /* @__PURE__ */ e.createElement("div", { className: "description" }, a), !!r && /* @__PURE__ */ e.createElement("div", { className: "secondary" }, r)), o && /* @__PURE__ */ e.createElement(v, { className: "button", onClick: o, buttonStyle: Pe.PRIMARY, buttonType: xe.FLAT }, s == null ? void 0 : s.toUpperCase())));
}, pi = ({ message: i, buttonAction: t }) => {
  const a = () => /* @__PURE__ */ e.createElement("svg", { width: "102", height: "93", viewBox: "0 0 102 93", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, /* @__PURE__ */ e.createElement("g", { filter: "url(#filter0_d)" }, /* @__PURE__ */ e.createElement(
    "path",
    {
      fillRule: "evenodd",
      clipRule: "evenodd",
      d: "M34.0187 29.6164C33.9646 29.6429 33.9105 29.6695 33.8565 29.6962L25.0781 20.9178C24.2971 20.1368 23.0307 20.1368 22.2497 20.9178C21.4686 21.6989 21.4686 22.9652 22.2497 23.7462L30.2429 31.7394C26.4552 34.1623 23.1245 37.2358 20.409 40.8014C19.7398 41.6801 19.9096 42.935 20.7883 43.6042C21.6671 44.2735 22.922 44.1036 23.5912 43.2249C26.202 39.7968 29.4453 36.8784 33.1469 34.6434L39.76 41.2566C35.5467 43.0674 31.8694 45.8856 29.0325 49.4062C28.3394 50.2662 28.4748 51.5253 29.3349 52.2184C30.195 52.9114 31.454 52.776 32.1471 51.916C34.9137 48.4826 38.6074 45.8321 42.8474 44.344L50.7546 52.2512C45.5533 52.2545 40.9621 54.8637 38.2154 58.8347C37.587 59.7432 37.8141 60.989 38.7225 61.6173C39.631 62.2457 40.8768 62.0186 41.5051 61.1102C43.5386 58.1703 46.9277 56.2512 50.7646 56.2512C52.6927 56.2512 54.5077 56.7358 56.0944 57.591L70.843 72.3396C71.6241 73.1207 72.8904 73.1207 73.6715 72.3396C74.4525 71.5586 74.4525 70.2922 73.6715 69.5112L63.5962 59.4359C63.5577 59.2978 63.5039 59.1622 63.4341 59.0318L59.1927 54.7903C58.9791 54.6484 58.7618 54.5118 58.5408 54.3805L47.3972 43.2369C47.4681 43.2269 47.5391 43.2172 47.6102 43.2078L44.1847 39.7823C44.1198 39.798 44.0551 39.814 43.9904 39.8301L36.862 32.7017C36.9178 32.6768 36.9737 32.652 37.0297 32.6273L34.0187 29.6164ZM49.1091 39.0499L53.1814 43.1222C59.8306 43.7896 65.6758 47.1819 69.5861 52.1721C70.2674 53.0415 71.5245 53.194 72.3939 52.5128C73.2634 51.8315 73.4159 50.5744 72.7346 49.7049C67.6314 43.1924 59.687 39.0015 50.7648 39.0015C50.209 39.0015 49.6569 39.0178 49.1091 39.0499ZM41.176 31.1168L38.0002 27.941C41.991 26.5237 46.2877 25.7519 50.7646 25.7519C63.3076 25.7519 74.4361 31.8096 81.383 41.1504C82.0422 42.0367 81.858 43.2896 80.9717 43.9488C80.0854 44.608 78.8325 44.4238 78.1733 43.5375C71.9487 35.1678 61.9894 29.7519 50.7646 29.7519C47.4356 29.7519 44.218 30.2283 41.176 31.1168ZM50.7644 72.9198C52.7601 72.9198 54.3779 71.302 54.3779 69.3063C54.3779 67.3107 52.7601 65.6929 50.7644 65.6929C48.7688 65.6929 47.151 67.3107 47.151 69.3063C47.151 71.302 48.7688 72.9198 50.7644 72.9198Z",
      fill: "url(#paint0_linear)"
    }
  )), /* @__PURE__ */ e.createElement("path", { d: "M23.6639 22.332L72.2573 70.9254", stroke: "#FFD80B", strokeWidth: "4", strokeLinecap: "round", strokeLinejoin: "round" }), /* @__PURE__ */ e.createElement("defs", null, /* @__PURE__ */ e.createElement(
    "filter",
    {
      id: "filter0_d",
      x: "0",
      y: "0.332031",
      width: "101.778",
      height: "92.5934",
      filterUnits: "userSpaceOnUse",
      colorInterpolationFilters: "sRGB"
    },
    /* @__PURE__ */ e.createElement("feFlood", { floodOpacity: "0", result: "BackgroundImageFix" }),
    /* @__PURE__ */ e.createElement("feColorMatrix", { in: "SourceAlpha", type: "matrix", values: "0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0" }),
    /* @__PURE__ */ e.createElement("feOffset", null),
    /* @__PURE__ */ e.createElement("feGaussianBlur", { stdDeviation: "10" }),
    /* @__PURE__ */ e.createElement("feColorMatrix", { type: "matrix", values: "0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.25 0" }),
    /* @__PURE__ */ e.createElement("feBlend", { mode: "normal", in2: "BackgroundImageFix", result: "effect1_dropShadow" }),
    /* @__PURE__ */ e.createElement("feBlend", { mode: "normal", in: "SourceGraphic", in2: "effect1_dropShadow", result: "shape" })
  ), /* @__PURE__ */ e.createElement("linearGradient", { id: "paint0_linear", x1: "50.8891", y1: "40.6383", x2: "35.6011", y2: "15.5271", gradientUnits: "userSpaceOnUse" }, /* @__PURE__ */ e.createElement("stop", { stopColor: "#3E5062" }), /* @__PURE__ */ e.createElement("stop", { offset: "1", stopColor: "#222E39" }))));
  return /* @__PURE__ */ e.createElement(
    Ai,
    {
      icon: a(),
      title: E("ErrorPage.networkError.message"),
      description: E("ErrorPage.networkError.description"),
      message: i,
      buttonAction: t,
      buttonText: E("ErrorPage.networkError.button")
    }
  );
};
const Ci = () => /* @__PURE__ */ e.createElement("div", { className: "userInitializationErrorPage" }, /* @__PURE__ */ e.createElement(n, { i18nKey: "UserInitializationErrorPage.unexpectedError" }, "Something went wrong. We're working on getting this fixed as soon as we can.", " ")), Ca = ({ children: i }) => {
  var l, M, g;
  const { state: t } = R(), { state: a } = ye(), { state: r } = Le(), { state: o } = ge(), {
    state: { location: s }
  } = X();
  if (t.userFetchError && J.isAxiosError(t.userFetchError)) {
    const I = ((l = t.userFetchError.response) == null ? void 0 : l.status) || -1;
    if (I >= 500)
      return /* @__PURE__ */ e.createElement(ji, null);
    if (!t.userFetchError.response)
      return /* @__PURE__ */ e.createElement(pi, null);
    if (I !== 401)
      return /* @__PURE__ */ e.createElement(Ci, null);
  }
  return o.linkAccountOneTimeCode.link === s.pathname ? i : ce.currentUserIsHeadlessAccount(t.user) ? /* @__PURE__ */ e.createElement(yi, null) : !t.user && ((M = t.mfaData) != null && M.mfaToken) ? /* @__PURE__ */ e.createElement(St, null) : se.currentUserIsBlockedByLegal(a.eligibilities) ? /* @__PURE__ */ e.createElement(Di, null) : !(o.accountDeletionSuccess.link === s.pathname) && t.user && ((g = r.gdprDeletionStatus) != null && g.DeletionStatus) ? /* @__PURE__ */ e.createElement(ht, null) : ce.currentUserNeedsVerification(t.user) ? /* @__PURE__ */ e.createElement(Rt, null) : i;
};
export {
  Ca as AccountInterceptorsWidget,
  pa as AuthCodeExchangeWidget
};
