import { Alert as l } from "./accelbyte-widgets123.mjs";
import { CommonError as s } from "./accelbyte-widgets124.mjs";
import { Spinner as r, SpinnerStyle as m } from "./accelbyte-widgets154.mjs";
import { headerAlertsQueue as u } from "./accelbyte-widgets155.mjs";
import { AlertType as i } from "./accelbyte-widgets128.mjs";
import e from "react";
import { Trans as n } from "react-i18next";
import "./accelbyte-widgets156.mjs";
class A extends e.Component {
  constructor(o) {
    super(o), this.notifyCancelAccountDeletionSuccess = async () => {
      u.push({
        type: i.success,
        element: /* @__PURE__ */ e.createElement(n, { i18nKey: "AccountDeletionNoticePage.cancelAccountDeletionSuccess" }, "The account deletion process has been cancelled. Please log in to continue."),
        autoDismiss: !0
      }), this.props.appState.clear();
    }, this.notifyCancelAccountDeletionError = (t) => {
      this.setState({
        alert: {
          type: i.danger,
          element: /* @__PURE__ */ e.createElement(s, { error: t })
        }
      });
    }, this.cancelDeletion = async () => {
      const { user: t } = this.props.appState.getUserManager().state;
      if (t)
        try {
          await this.logic.cancelDeleteAccount(t.userId), this.notifyCancelAccountDeletionSuccess(), await this.props.appState.logout();
        } catch (c) {
          this.notifyCancelAccountDeletionError(c);
        }
    }, this.continueDeletion = async () => {
      await this.props.appState.logout();
    }, this.logic = this.props.appState.getGdprManager(), this.logic.subscribe(() => this.setState({})), this.state = {
      alert: null
    };
  }
  render() {
    const { alert: o } = this.state, { isRequestingDeletion: t, gdprDeletionStatus: c } = this.logic.state, a = c == null ? void 0 : c.DeletionDate;
    return /* @__PURE__ */ e.createElement("div", { className: "deletionNoticeContainer" }, /* @__PURE__ */ e.createElement("main", null, !!o && !t && /* @__PURE__ */ e.createElement(l, { type: o.type, className: "alert", onDismiss: () => this.setState({ alert: null }) }, o.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: a }, ". 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: () => this.continueDeletion() }, /* @__PURE__ */ e.createElement(n, { i18nKey: "AccountDeletionNoticePage.button.keepDeleting" }, "Continue the Deletion")), /* @__PURE__ */ e.createElement("button", { className: "btn big btn-primary btnCancel", disabled: t, onClick: () => this.cancelDeletion() }, t && /* @__PURE__ */ e.createElement(e.Fragment, null, /* @__PURE__ */ e.createElement(r, { className: `${m.inline} spinner` }), /* @__PURE__ */ e.createElement(n, { i18nKey: "AccountDeletionNoticePage.form.processing" }, "Processing...")), !t && /* @__PURE__ */ e.createElement(n, { i18nKey: "AccountDeletionNoticePage.button.cancelDeletion" }, "Cancel Deletion")))));
  }
}
export {
  A as default
};
