import { c as H, p as U, f as $, g as St, e as it, b as f, d as J, u as j, a as A, i as O, t as Lt, o as rt, h as ct } from "./AssetItem-CFsdMEwW.js";
import { o as Ct } from "./index-client-DJaMHbvZ.js";
import { v as z, x as L, y as S, t as B, n as V, r as I, D as N, C as Qt, z as ot, I as h, A as E, o as Pt, G as P, m as et, w as Z, p as Ot, Y as lt, bv as $t, M as st, L as qt, O as Dt, bw as kt, F as tt, E as Mt, a4 as Rt, R as Tt, S as At } from "./index-BxjwuJ6T.js";
import { L as at } from "./Loader-BMEbL3GG.js";
import { C as It } from "./ContentHeader-IUWmor6Y.js";
import { e as Nt, i as Et } from "./each-BgMcYdMq.js";
import { C as Ht } from "./App-pmcYlKkW.js";
import { h as Jt } from "./html-DarouBbC.js";
import { P as jt, s as zt } from "./svg-D5FtkcEe.js";
import { g as Bt } from "./authMethods.helper-DBzGGN4n.js";
var Ft = $(`<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 H({ component: dt, ...l });
  z(r, !1);
  let o = U(r, "handler", 12);
  var e = {
    get handler() {
      return o();
    },
    set handler(d) {
      o(d), V();
    },
    $set: j,
    $on: (d, p) => J(r, d, p)
  }, u = Ft(), w = L(u);
  return St(w, r, "default", {}), S(u), it("click", u, function(...d) {
    o()?.apply(this, d);
  }), f(l, u), B(e);
}
var Gt = $('<div class="crtw-text-center crtw-text-gray-500 crtw-text-sm">No login methods available for this client.</div>'), Yt = $('<div class="crtw-m-5"><!></div>');
function vt(l, r) {
  if (new.target) return H({ 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), V();
    },
    $set: j,
    $on: (a, i) => J(r, a, i)
  }, p = A(), m = I(p);
  {
    var g = (a) => {
      Ht(a, {
        children: (i, t) => {
          var n = A(), b = I(n);
          {
            var q = (_) => {
              var v = Gt();
              f(_, v);
            }, D = (_) => {
              var v = A(), k = I(v);
              Nt(k, 1, () => e, Et, (M, c) => {
                dt(M, {
                  handler: () => u(h(c)),
                  children: (C, F) => {
                    Qt();
                    var G = Lt();
                    ot(() => rt(G, (h(c), N(() => h(c).text)))), f(C, G);
                  },
                  $$slots: { default: !0 }
                });
              }), f(_, v);
            };
            O(b, (_) => {
              N(() => e.length === 0) ? _(q) : _(D, -1);
            });
          }
          f(i, n);
        },
        $$slots: { default: !0 }
      });
    }, x = (a) => {
      var i = Yt(), t = L(i);
      at(t, {}), S(i), f(a, i);
    };
    O(m, (a) => {
      w ? a(x, -1) : a(g);
    });
  }
  return f(l, p), B(d);
}
var Kt = $("<div></div>"), Ut = $('<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 H({ 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), V();
    },
    $set: j,
    $on: (t, n) => J(r, t, n)
  }, p = Ut(), m = L(p), g = E(L(m)), x = L(g, !0);
  S(g), S(m);
  var a = E(m, 2);
  {
    var i = (t) => {
      var n = Kt();
      Jt(n, () => e, !0), S(n), f(t, n);
    };
    O(a, (t) => {
      e && t(i);
    });
  }
  return S(p), ot(() => rt(x, e ? "Hide QR!" : "Show QR!")), it("click", g, function(...t) {
    (e ? w : u)?.apply(this, t);
  }), f(l, p), B(d);
}
var Vt = $('<p class="crtw-text-center crtw-text-xs crtw-text-gray-700"> </p>'), Wt = $('<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 H({ component: ut, ...l });
  z(r, !1);
  const o = et();
  let e = U(r, "options", 12), { authTitle: u, authDescription: w, qrOptions: d, authOptions: p } = e();
  Pt(() => Z(e()), () => {
    P(o, e().isLoading);
  }), Ot();
  var m = {
    get options() {
      return e();
    },
    set options(t) {
      e(t), V();
    },
    $set: j,
    $on: (t, n) => J(r, t, n)
  };
  ct();
  var g = A(), x = I(g);
  {
    var a = (t) => {
      at(t, {});
    }, i = (t) => {
      var n = Wt(), b = L(n), q = L(b);
      It(q, {
        get text() {
          return u;
        },
        get description() {
          return w;
        }
      });
      var D = E(q, 2);
      {
        var _ = (c) => {
          var C = Vt(), F = L(C, !0);
          S(C), ot(() => rt(F, (Z(e()), N(() => e().infoText)))), f(c, C);
        };
        O(D, (c) => {
          Z(e()), N(() => e().infoText) && c(_);
        });
      }
      S(b);
      var v = E(b, 2);
      {
        let c = lt(() => (h(o), N(() => ({ ...p, isLoading: h(o) }))));
        vt(v, {
          get options() {
            return h(c);
          }
        });
      }
      var k = E(v, 2);
      {
        var M = (c) => {
          ft(c, {
            get options() {
              return d;
            }
          });
        };
        O(k, (c) => {
          d && c(M);
        });
      }
      S(n), f(t, n);
    };
    O(x, (t) => {
      h(o) ? t(a) : t(i, -1);
    });
  }
  return f(l, g), B(m);
}
function Xt(l, r) {
  if (new.target) return H({ component: Xt, ...l });
  z(r, !1);
  const o = () => tt(Tt, "$forcedPage", w), e = () => tt(At, "$pageStore", w), u = () => tt(Rt, "$clientPublicStore", w), [w, d] = Mt();
  var p = this && this.__awaiter || function(s, y, R, Y) {
    function xt(T) {
      return T instanceof R ? T : new R(function(K) {
        K(T);
      });
    }
    return new (R || (R = Promise))(function(T, K) {
      function bt(Q) {
        try {
          W(Y.next(Q));
        } catch (X) {
          K(X);
        }
      }
      function yt(Q) {
        try {
          W(Y.throw(Q));
        } catch (X) {
          K(X);
        }
      }
      function W(Q) {
        Q.done ? T(Q.value) : xt(Q.value).then(bt, yt);
      }
      W((Y = Y.apply(s, y || [])).next());
    });
  }, m, g, x, a, i, t;
  const n = localStorage.getItem($t.QR_CODE);
  let b = et();
  const q = () => {
    if (!n) return;
    const s = JSON.parse(n), y = jt(JSON.stringify(s));
    P(b, zt(y, { width: 250, height: 250 }));
  }, D = () => P(b, "");
  let _ = st(qt), v = et(!1);
  const { login: k, close: M } = st(Dt), c = (s) => p(void 0, [s], void 0, function* ({ provider: y }) {
    try {
      P(v, !0), yield k(y), P(v, !1), !o() && !e() && M();
    } catch {
      P(v, !1);
    }
  }), C = (x = (g = (m = _.content) === null || m === void 0 ? void 0 : m.auth) === null || g === void 0 ? void 0 : g.title) !== null && x !== void 0 ? x : "Let’s get started", F = (t = (i = (a = _.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.", G = kt.subscribe((s) => P(v, s));
  Ct(G);
  const pt = Bt();
  var gt = {
    $set: j,
    $on: (s, y) => J(r, s, y)
  };
  ct();
  var nt = A(), wt = I(nt);
  {
    var mt = (s) => {
      {
        let y = lt(() => ({
          isLoading: h(v),
          authTitle: C,
          authDescription: F,
          qrOptions: { qrCodeSvg: h(b), showQr: q, hideQr: D },
          authOptions: { loginMethods: pt, handleLogin: c }
        }));
        ut(s, {
          get options() {
            return h(y);
          }
        });
      }
    }, _t = (s) => {
      at(s, {});
    };
    O(wt, (s) => {
      u() ? s(mt) : s(_t, -1);
    });
  }
  f(l, nt);
  var ht = B(gt);
  return d(), ht;
}
export {
  Xt as default
};
//# sourceMappingURL=Login-WlwpyGqC.js.map
