import { Alert as p } from "./accelbyte-widgets123.mjs";
import { Button as r, ButtonType as d, ButtonStyle as u } from "./accelbyte-widgets107.mjs";
import { Dialog as h, DialogBody as f, DialogFooter as E } from "./accelbyte-widgets235.mjs";
import { FormGroup as y } from "./accelbyte-widgets263.mjs";
import { InputGroup as C } from "./accelbyte-widgets229.mjs";
import { InputLabel as b } from "./accelbyte-widgets435.mjs";
import { t as a } from "./accelbyte-widgets58.mjs";
import { Ctx as S } from "./accelbyte-widgets33.mjs";
import e from "react";
import { Trans as w } from "react-i18next";
class L extends e.Component {
  constructor(s) {
    super(s), this.submitCode = () => {
      const { enableEmail: o } = this.props, { code: t } = this.state;
      o(t, () => this.setState({ code: "" }));
    }, this.onCodeChange = (o) => {
      const t = o.target.value;
      this.setState({ code: t });
    }, this.onCloseModal = () => {
      const { onClose: o, closeAlert: t } = this.props;
      this.setState({ code: "" }, o), t();
    }, this.appState = S.getAppState(), this.state = {
      code: ""
    };
  }
  render() {
    var n;
    const { isOpen: s, onResendCode: o, alert: t, closeAlert: c, isLoading: i } = this.props, { code: l } = this.state, m = (n = this.appState.getUser()) == null ? void 0 : n.emailAddress;
    return /* @__PURE__ */ e.createElement(h, { isOpen: s, title: a("AccountPasswordSecurity.2fa.emailModal.title"), className: "w-[450px]", onClose: this.onCloseModal }, /* @__PURE__ */ e.createElement(f, null, /* @__PURE__ */ e.createElement("div", { className: "mb-3 text-sm" }, /* @__PURE__ */ e.createElement(w, { i18nKey: "AccountPasswordSecurity.2fa.emailModal.desc" }, "To continue, please enter the verification code we’ve sent to your email at ", /* @__PURE__ */ e.createElement("strong", null, { email: m }), ".")), t && /* @__PURE__ */ e.createElement(p, { type: t.type, onDismiss: c, className: "mb-3" }, t.element), /* @__PURE__ */ e.createElement(y, null, /* @__PURE__ */ e.createElement(b, null, a("AccountPasswordSecurity.2fa.emailModal.inputLabel")), /* @__PURE__ */ e.createElement(C, { placeholder: a("AccountPasswordSecurity.2fa.emailModal.placeHolder"), value: l, onChange: this.onCodeChange }), /* @__PURE__ */ e.createElement("div", { className: "text-[13px]" }, /* @__PURE__ */ e.createElement("span", null, a("AccountPasswordSecurity.2fa.emailModal.helperText")), /* @__PURE__ */ e.createElement("span", { className: "ml-1 cursor-pointer text-blue-50", onClick: o }, a("AccountPasswordSecurity.2fa.emailModal.resendBtn"))))), /* @__PURE__ */ e.createElement(E, null, /* @__PURE__ */ e.createElement("div", { className: "justify-end sm:flex" }, /* @__PURE__ */ e.createElement(
      r,
      {
        className: "btn btn-ghost mr-5 w-full w-[87px] text-sm",
        buttonType: d.TEXT,
        buttonStyle: u.NONE,
        onClick: this.onCloseModal
      },
      a("AccountPasswordSecurity.2fa.cancelBtn")
    ), /* @__PURE__ */ e.createElement(
      r,
      {
        className: "btn btn-primary mt-3 w-full w-[102px] text-sm sm:mt-0",
        onClick: this.submitCode,
        disabled: i || !l
      },
      a("AccountPasswordSecurity.2fa.btnEnable").toUpperCase()
    ))));
  }
}
export {
  L as EmailAuthModal
};
