import { c as E, p as U, f as q, g as St, e as it, b as f, d as H, u as j, a as M, i as $, t as Lt, r as rt, h as ct, o as Z, n as Ct } from "./AssetItem-DSqy7mUZ.js";
import { o as Qt } from "./index-client-C6CzifWu.js";
import { t as z, w as S, x as L, r as B, l as W, p as N, C as R, A as Pt, y as ot, E as x, z as J, n as $t, D as P, m as et, v as tt, o as qt, V as lt, bq as Ot, J as st, I as Dt, L as kt, br as Tt, a1 as At, N as It, O as Mt } from "./index-CoRcfuX4.js";
import { L as at } from "./Loader-fbImczWc.js";
import { C as Nt } from "./ContentHeader-BkaWhy8n.js";
import { e as Rt, i as Jt } from "./each-BbpL54E9.js";
import { C as Et } from "./App-fY_cbS1F.js";
import { h as Ht } from "./html-CLv01M-_.js";
import { P as jt, s as zt } from "./svg-D5FtkcEe.js";
import { g as Bt } from "./authMethods.helper-DPXygidY.js";
var Vt = q(`<button class="crtw-w-full crtw-text-center crtw-h-11 crtw-font-medium
   crtw-rounded-sm crtw-text-[13px] sm:crtw-text-sm crtw-items-center crtw-bg-black
crtw-text-white crtw-mt-[5px] crtw-justify-center crtw-flex"><!></button>`);
function dt(l, r) {
  if (new.target) return E({ component: dt, ...l });
  z(r, !1);
  let o = U(r, "handler", 12);
  var e = {
    get handler() {
      return o();
    },
    set handler(d) {
      o(d), W();
    },
    $set: j,
    $on: (d, p) => H(r, d, p)
  }, u = Vt(), w = S(u);
  return St(w, r, "default", {}), L(u), it("click", u, function(...d) {
    o()?.apply(this, d);
  }), f(l, u), B(e);
}
var Ft = q('<div class="crtw-text-center crtw-text-gray-500 crtw-text-sm">No login methods available for this client.</div>'), Gt = q('<div class="crtw-m-5"><!></div>');
function vt(l, r) {
  if (new.target) return E({ component: vt, ...l });
  z(r, !1);
  let o = U(r, "options", 12), { loginMethods: e, handleLogin: u, isLoading: w } = o();
  var d = {
    get options() {
      return o();
    },
    set options(a) {
      o(a), W();
    },
    $set: j,
    $on: (a, i) => H(r, a, i)
  }, p = M(), m = N(p);
  {
    var g = (a) => {
      Et(a, {
        children: (i, t) => {
          var n = M(), _ = N(n);
          {
            var O = (h) => {
              var v = Ft();
              f(h, v);
            }, D = (h) => {
              var v = M(), k = N(v);
              Rt(k, 1, () => e, Jt, (T, c) => {
                dt(T, {
                  handler: () => u(x(c)),
                  children: (C, V) => {
                    Pt();
                    var F = Lt();
                    ot(() => rt(F, `Continue with ${x(c), R(() => x(c).text) ?? ""}`)), f(C, F);
                  },
                  $$slots: { default: !0 }
                });
              }), f(h, v);
            };
            $(_, (h) => {
              R(() => e.length === 0) ? h(O) : h(D, !1);
            });
          }
          f(i, n);
        },
        $$slots: { default: !0 }
      });
    }, b = (a) => {
      var i = Gt(), t = S(i);
      at(t, {}), L(i), f(a, i);
    };
    $(m, (a) => {
      w ? a(b, !1) : a(g);
    });
  }
  return f(l, p), B(d);
}
var Kt = q("<div><!></div>"), Ut = q('<div class="crtw-mt-4"><span class="crtw-text-sm">Cached QR is available. <span class="crtw-cursor-pointer crtw-text-warningTextColor" role="button" tabindex="0"> </span></span> <!></div>');
function ft(l, r) {
  if (new.target) return E({ component: ft, ...l });
  z(r, !1);
  let o = U(r, "options", 12), { qrCodeSvg: e, showQr: u, hideQr: w } = o();
  var d = {
    get options() {
      return o();
    },
    set options(t) {
      o(t), W();
    },
    $set: j,
    $on: (t, n) => H(r, t, n)
  }, p = Ut(), m = S(p), g = J(S(m)), b = S(g, !0);
  L(g), L(m);
  var a = J(m, 2);
  {
    var i = (t) => {
      var n = Kt(), _ = S(n);
      Ht(_, () => e), L(n), f(t, n);
    };
    $(a, (t) => {
      e && t(i);
    });
  }
  return L(p), ot(() => rt(b, e ? "Hide QR!" : "Show QR!")), it("click", g, function(...t) {
    (e ? w : u)?.apply(this, t);
  }), f(l, p), B(d);
}
var Wt = q('<p class="crtw-text-center crtw-text-xs crtw-text-gray-700"> </p>'), Xt = q('<div class="crtw-flex crtw-flex-col crtw-gap-14 crtw-items-center crtw-w-full"><div class="crtw-flex crtw-flex-col crtw-gap-3 crtw-items-center crtw-w-full"><!> <!></div> <!> <!></div>');
function ut(l, r) {
  if (new.target) return E({ component: ut, ...l });
  z(r, !1);
  const o = et();
  let e = U(r, "options", 12), { authTitle: u, authDescription: w, qrOptions: d, authOptions: p } = e();
  $t(() => tt(e()), () => {
    P(o, e().isLoading);
  }), qt();
  var m = {
    get options() {
      return e();
    },
    set options(t) {
      e(t), W();
    },
    $set: j,
    $on: (t, n) => H(r, t, n)
  };
  ct();
  var g = M(), b = N(g);
  {
    var a = (t) => {
      at(t, {});
    }, i = (t) => {
      var n = Xt(), _ = S(n), O = S(_);
      Nt(O, {
        get text() {
          return u;
        },
        get description() {
          return w;
        }
      });
      var D = J(O, 2);
      {
        var h = (c) => {
          var C = Wt(), V = S(C, !0);
          L(C), ot(() => rt(V, (tt(e()), R(() => e().infoText)))), f(c, C);
        };
        $(D, (c) => {
          tt(e()), R(() => e().infoText) && c(h);
        });
      }
      L(_);
      var v = J(_, 2);
      {
        let c = lt(() => (x(o), R(() => ({ ...p, isLoading: x(o) }))));
        vt(v, {
          get options() {
            return x(c);
          }
        });
      }
      var k = J(v, 2);
      {
        var T = (c) => {
          ft(c, {
            get options() {
              return d;
            }
          });
        };
        $(k, (c) => {
          d && c(T);
        });
      }
      L(n), f(t, n);
    };
    $(b, (t) => {
      x(o) ? t(a) : t(i, !1);
    });
  }
  return f(l, g), B(m);
}
function Yt(l, r) {
  if (new.target) return E({ component: Yt, ...l });
  z(r, !1);
  const o = () => Z(It, "$forcedPage", w), e = () => Z(Mt, "$pageStore", w), u = () => Z(At, "$clientPublicStore", w), [w, d] = Ct();
  var p = this && this.__awaiter || function(s, y, A, G) {
    function xt(I) {
      return I instanceof A ? I : new A(function(K) {
        K(I);
      });
    }
    return new (A || (A = Promise))(function(I, K) {
      function bt(Q) {
        try {
          X(G.next(Q));
        } catch (Y) {
          K(Y);
        }
      }
      function yt(Q) {
        try {
          X(G.throw(Q));
        } catch (Y) {
          K(Y);
        }
      }
      function X(Q) {
        Q.done ? I(Q.value) : xt(Q.value).then(bt, yt);
      }
      X((G = G.apply(s, y || [])).next());
    });
  }, m, g, b, a, i, t;
  const n = localStorage.getItem(Ot.QR_CODE);
  let _ = et();
  const O = () => {
    if (!n) return;
    const s = JSON.parse(n), y = jt(JSON.stringify(s));
    P(_, zt(y, { width: 250, height: 250 }));
  }, D = () => P(_, "");
  let h = st(Dt), v = et(!1);
  const { login: k, close: T } = st(kt), c = (s) => p(void 0, [s], void 0, function* ({ provider: y }) {
    try {
      P(v, !0), yield k(y), P(v, !1), !o() && !e() && T();
    } catch {
      P(v, !1);
    }
  }), C = (b = (g = (m = h.content) === null || m === void 0 ? void 0 : m.auth) === null || g === void 0 ? void 0 : g.title) !== null && b !== void 0 ? b : "Let’s get started", V = (t = (i = (a = h.content) === null || a === void 0 ? void 0 : a.auth) === null || i === void 0 ? void 0 : i.description) !== null && t !== void 0 ? t : "Confirm your account to connect.", F = Tt.subscribe((s) => P(v, s));
  Qt(F);
  const pt = Bt();
  var gt = {
    $set: j,
    $on: (s, y) => H(r, s, y)
  };
  ct();
  var nt = M(), wt = N(nt);
  {
    var mt = (s) => {
      {
        let y = lt(() => ({
          isLoading: x(v),
          authTitle: C,
          authDescription: V,
          qrOptions: { qrCodeSvg: x(_), showQr: O, hideQr: D },
          authOptions: { loginMethods: pt, handleLogin: c }
        }));
        ut(s, {
          get options() {
            return x(y);
          }
        });
      }
    }, _t = (s) => {
      at(s, {});
    };
    $(wt, (s) => {
      u() ? s(mt) : s(_t, !1);
    });
  }
  f(l, nt);
  var ht = B(gt);
  return d(), ht;
}
export {
  Yt as default
};
//# sourceMappingURL=Login-Bg8Ni3Hy.js.map
