import { c as R, m as ae, p as F, f as L, v as ie, s as se, b, d as q, u as G, h as Z, i as V, t as J, r as Q, n as le, o as de } from "./AssetItem-ufNA-vj9.js";
import { t as H, w as ee, x as te, y as N, r as K, l as z, p as P, z as C, C as j, E as d, F as ne, m as D, A as W, D as I, I as X, K as ce, bl as ue, O as U, bm as ve, N as pe } from "./index-DRgrWhNH.js";
import { C as fe } from "./App-C7TSmMh1.js";
import { C as me } from "./ContentHeader-B8i-EqEU.js";
import { B as _e } from "./Button-Dvas4qfY.js";
import { B as ge } from "./ButtonLink-Bj4pTcWP.js";
import { L as Y } from "./Label-GNWLBrSk.js";
import { b as he } from "./input-BDcUSgHd.js";
var we = L('<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 M(p, s) {
  if (new.target) return R({ component: M, ...p });
  H(s, !1), ae(p, xe);
  let e = F(s, "value", 12), _ = F(s, "placeholder", 12, "Code");
  var $ = {
    get value() {
      return e();
    },
    set value(n) {
      e(n), z();
    },
    get placeholder() {
      return _();
    },
    set placeholder(n) {
      _(n), z();
    },
    $set: G,
    $on: (n, c) => q(s, n, c)
  }, o = we(), g = ee(o);
  return ie(g), te(o), N(() => se(g, "placeholder", _())), he(g, e), b(p, o), K($);
}
var be = L("<!> <!>", 1), Ce = L("<!> <!>", 1), $e = L("<!> <!> <!>", 1), ye = L('<!> <!> <div class="crtw-mt-4"><!></div>', 1);
function oe(p, s) {
  if (new.target) return R({ component: oe, ...p });
  H(s, !1);
  let e = F(s, "options", 12), { onBackClick: _, onSubmit: $, pending: o, isLoading: g } = e(), n = D(), c = D();
  var y = {
    get options() {
      return e();
    },
    set options(r) {
      e(r), z();
    },
    $set: G,
    $on: (r, l) => q(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 = J();
              N(() => Q(E, `Enter your code sent to ${j(() => o?.phone) ?? ""}`)), b(x, E);
            },
            $$slots: { default: !0 }
          });
          var T = C(k, 2);
          M(T, {
            placeholder: "SMS Code",
            get value() {
              return d(n);
            },
            set value(x) {
              I(n, x);
            },
            $$legacy: !0
          }), b(t, f);
        };
        V(a, (t) => {
          j(() => 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 = J();
              N(() => Q(E, `Enter your code sent to ${j(() => o?.email) ?? ""}`)), b(x, E);
            },
            $$slots: { default: !0 }
          });
          var T = C(k, 2);
          M(T, {
            placeholder: "Email Code",
            get value() {
              return d(c);
            },
            set value(x) {
              I(c, x);
            },
            $$legacy: !0
          }), b(t, f);
        };
        V(i, (t) => {
          j(() => o?.email) && t(w);
        });
      }
      var S = C(i, 2);
      {
        let t = ne(() => (d(n), d(c), j(() => 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), K(y);
}
function Se(p, s) {
  if (new.target) return R({ component: Se, ...p });
  H(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 = D(!1);
  const O = (u) => o(void 0, [u], void 0, function* ({ confirmEmailCode: h, confirmPhoneCode: r }) {
    var l, m, a, v;
    I(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 === U.CONFIRM_ACCOUNT || w === U.LOGOUT) && n(), c("Account has been confirmed successfully.", "success");
    } catch (i) {
      c(i?.message || i, "failure");
    }
    I(y, !1);
  });
  var A = {
    $set: G,
    $on: (u, h) => q(s, u, h)
  };
  Z();
  {
    let u = ne(() => ({
      isLoading: d(y),
      onBackClick: () => ue.set(U.UPDATE_PROFILE),
      onSubmit: O,
      pending: e()?.pending
    }));
    oe(p, {
      get options() {
        return d(u);
      }
    });
  }
  var B = K(A);
  return $(), B;
}
export {
  Se as default
};
//# sourceMappingURL=ConfirmAccount-mcZmaPaS.js.map
