import { c as R, m as ae, p as z, f as j, v as ie, s as se, b, d as V, u as q, h as Z, i as J, t as Q, r as K, n as le, o as de } from "./AssetItem-BxjLUzNd.js";
import { t as G, w as ee, x as te, y as D, r as H, l as F, p as P, z as C, C as L, E as d, V as ne, m as M, A as W, D as T, J as X, L as ce, bt as ue, Q as I, bu as ve, O as pe } from "./index-BBXAtvZr.js";
import { C as fe } from "./App-BwT5MYkN.js";
import { C as me } from "./ContentHeader-CNIXuMji.js";
import { B as _e } from "./Button-CqLZSfSk.js";
import { B as ge } from "./ButtonLink-BnG9q4HI.js";
import { L as Y } from "./Label-zekiKFxP.js";
import { b as he } from "./input-c8sTQ2Qk.js";
var we = j('<div class="crtw-flex crtw-justify-center"><input type="number" min="0" max="99999" class="crtw-w-full crtw-mb-1.5 phone crtw-border crtw-rounded crtw-px-2 crtw-outline-none crtw-mt-2.5 crtw-h-[50px] crtw-text-xs svelte-10xd7vj" name="code"/></div>');
const xe = {
  hash: "svelte-10xd7vj",
  code: `input.svelte-10xd7vj::-webkit-outer-spin-button,
  input.svelte-10xd7vj::-webkit-inner-spin-button {-webkit-appearance:none;margin:0;}input[type="number"].svelte-10xd7vj {appearance:textfield;-moz-appearance:textfield;}`
};
function N(p, s) {
  if (new.target) return R({ component: N, ...p });
  G(s, !1), ae(p, xe);
  let e = z(s, "value", 12), _ = z(s, "placeholder", 12, "Code");
  var $ = {
    get value() {
      return e();
    },
    set value(n) {
      e(n), F();
    },
    get placeholder() {
      return _();
    },
    set placeholder(n) {
      _(n), F();
    },
    $set: q,
    $on: (n, c) => V(s, n, c)
  }, o = we(), g = ee(o);
  return ie(g), te(o), D(() => se(g, "placeholder", _())), he(g, e), b(p, o), H($);
}
var be = j("<!> <!>", 1), Ce = j("<!> <!>", 1), $e = j("<!> <!> <!>", 1), ye = j('<!> <!> <div class="crtw-mt-4"><!></div>', 1);
function oe(p, s) {
  if (new.target) return R({ component: oe, ...p });
  G(s, !1);
  let e = z(s, "options", 12), { onBackClick: _, onSubmit: $, pending: o, isLoading: g } = e(), n = M(), c = M();
  var y = {
    get options() {
      return e();
    },
    set options(r) {
      e(r), F();
    },
    $set: q,
    $on: (r, l) => V(s, r, l)
  };
  Z();
  var O = ye(), A = P(O);
  me(A, { text: "Before we start please verify your personal data" });
  var B = C(A, 2);
  fe(B, {
    children: (r, l) => {
      var m = $e(), a = P(m);
      {
        var v = (t) => {
          var f = be(), k = P(f);
          Y(k, {
            for: "code",
            children: (x, re) => {
              W();
              var E = Q();
              D(() => K(E, `Enter your code sent to ${L(() => o?.phone) ?? ""}`)), b(x, E);
            },
            $$slots: { default: !0 }
          });
          var U = C(k, 2);
          N(U, {
            placeholder: "SMS Code",
            get value() {
              return d(n);
            },
            set value(x) {
              T(n, x);
            },
            $$legacy: !0
          }), b(t, f);
        };
        J(a, (t) => {
          L(() => o?.phone) && t(v);
        });
      }
      var i = C(a, 2);
      {
        var w = (t) => {
          var f = Ce(), k = P(f);
          Y(k, {
            for: "code",
            children: (x, re) => {
              W();
              var E = Q();
              D(() => K(E, `Enter your code sent to ${L(() => o?.email) ?? ""}`)), b(x, E);
            },
            $$slots: { default: !0 }
          });
          var U = C(k, 2);
          N(U, {
            placeholder: "Email Code",
            get value() {
              return d(c);
            },
            set value(x) {
              T(c, x);
            },
            $$legacy: !0
          }), b(t, f);
        };
        J(i, (t) => {
          L(() => o?.email) && t(w);
        });
      }
      var S = C(i, 2);
      {
        let t = ne(() => (d(n), d(c), L(() => g || !!(o?.phone && String(d(n)).length !== 6) || !!(o?.email && String(d(c)).length !== 6))));
        _e(S, {
          text: "Verify",
          onClick: () => $({
            confirmPhoneCode: d(n),
            confirmEmailCode: d(c)
          }),
          get disabled() {
            return d(t);
          }
        });
      }
      b(r, m);
    },
    $$slots: { default: !0 }
  });
  var u = C(B, 2), h = ee(u);
  return ge(h, {
    text: "Update your account details",
    get onClick() {
      return _;
    }
  }), te(u), b(p, O), H(y);
}
function Se(p, s) {
  if (new.target) return R({ component: Se, ...p });
  G(s, !1);
  const e = () => de(ve, "$userStore", _), [_, $] = le();
  var o = this && this.__awaiter || function(u, h, r, l) {
    function m(a) {
      return a instanceof r ? a : new r(function(v) {
        v(a);
      });
    }
    return new (r || (r = Promise))(function(a, v) {
      function i(t) {
        try {
          S(l.next(t));
        } catch (f) {
          v(f);
        }
      }
      function w(t) {
        try {
          S(l.throw(t));
        } catch (f) {
          v(f);
        }
      }
      function S(t) {
        t.done ? a(t.value) : m(t.value).then(i, w);
      }
      S((l = l.apply(u, h || [])).next());
    });
  };
  const { confirmAccount: g, close: n, toastAlert: c } = X(ce);
  let y = M(!1);
  const O = (u) => o(void 0, [u], void 0, function* ({ confirmEmailCode: h, confirmPhoneCode: r }) {
    var l, m, a, v;
    T(y, !0);
    try {
      const i = yield g(Object.assign(Object.assign({}, !((l = e() === null || e() === void 0 ? void 0 : e().pending) === null || l === void 0) && l.email ? { emailCode: String(h) } : {}), !((m = e() === null || e() === void 0 ? void 0 : e().pending) === null || m === void 0) && m.phone ? { phoneCode: String(r) } : {}));
      if (!((a = e() === null || e() === void 0 ? void 0 : e().pending) === null || a === void 0) && a.phone && !i.phone || !((v = e() === null || e() === void 0 ? void 0 : e().pending) === null || v === void 0) && v.email && !i.email) throw new Error("The code is invalid.");
      const w = X(pe);
      (!w || w === I.CONFIRM_ACCOUNT || w === I.LOGOUT) && n(), c("Account has been confirmed successfully.", "success");
    } catch (i) {
      c(i?.message || i, "failure");
    }
    T(y, !1);
  });
  var A = {
    $set: q,
    $on: (u, h) => V(s, u, h)
  };
  Z();
  {
    let u = ne(() => ({
      isLoading: d(y),
      onBackClick: () => ue.set(I.UPDATE_PROFILE),
      onSubmit: O,
      pending: e()?.pending
    }));
    oe(p, {
      get options() {
        return d(u);
      }
    });
  }
  var B = H(A);
  return $(), B;
}
export {
  Se as default
};
//# sourceMappingURL=ConfirmAccount-DawI5_rf.js.map
