@edgespark/web 0.0.1-beta.2 → 0.0.1-beta.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.es.js CHANGED
@@ -1,159 +1,198 @@
1
- import { createAuthClient as te } from "better-auth/client";
2
- class U extends Error {
1
+ import { createAuthClient as oe } from "better-auth/client";
2
+ class H extends Error {
3
3
  constructor(e, s) {
4
4
  super(s), this.name = "EdgeSparkError", this.code = e;
5
5
  }
6
6
  }
7
- class u extends U {
7
+ class d extends H {
8
8
  constructor(e) {
9
9
  super("CONFIG_ERROR", e), this.name = "EdgeSparkConfigError";
10
10
  }
11
11
  }
12
- class K extends U {
12
+ class se extends H {
13
13
  constructor(e) {
14
14
  super("RUNTIME_ERROR", e), this.name = "EdgeSparkRuntimeError";
15
15
  }
16
16
  }
17
- class w extends U {
17
+ class m extends H {
18
18
  constructor(e, s) {
19
19
  super((s == null ? void 0 : s.code) ?? "AUTH_ERROR", e), this.name = "EdgeSparkAuthError", this.cause = s == null ? void 0 : s.cause, this.status = s == null ? void 0 : s.status;
20
20
  }
21
21
  }
22
- function J() {
22
+ function ie() {
23
23
  if (typeof window > "u" || typeof document > "u")
24
- throw new K(
24
+ throw new se(
25
25
  "@edgespark/web is browser-only. Create the client from a real browser runtime."
26
26
  );
27
27
  }
28
- function I() {
29
- return J(), window.location.origin;
28
+ function D() {
29
+ return ie(), window.location.origin;
30
30
  }
31
- function se(t) {
31
+ function ae(t) {
32
32
  return t instanceof URL ? t : typeof t == "string" ? new URL(t, window.location.href) : new URL(t.url, window.location.href);
33
33
  }
34
- function ie(t) {
35
- if (t.origin !== I())
36
- throw new u(
37
- `Cross-origin requests are not supported by this SDK. Received ${t.origin}, expected ${I()}.`
34
+ function le(t) {
35
+ if (t.origin !== D())
36
+ throw new d(
37
+ `Cross-origin requests are not supported by this SDK. Received ${t.origin}, expected ${D()}.`
38
38
  );
39
39
  }
40
- function ne() {
40
+ function de() {
41
41
  return {
42
42
  async fetch(t, e) {
43
- const s = se(t);
44
- return ie(s), fetch(t, {
43
+ const s = ae(t);
44
+ return le(s), fetch(t, {
45
45
  ...e,
46
46
  credentials: "include"
47
47
  });
48
48
  }
49
49
  };
50
50
  }
51
- const Z = "/api/_es/auth";
52
- function Q(t) {
53
- return te({
54
- baseURL: I(),
55
- basePath: Z,
51
+ const ne = "/api/_es/auth";
52
+ function re(t) {
53
+ return oe({
54
+ baseURL: D(),
55
+ basePath: ne,
56
56
  ...t != null && t.disableDefaultRedirectPlugin ? { disableDefaultFetchPlugins: !0 } : {},
57
57
  fetchOptions: {
58
58
  credentials: "include"
59
59
  }
60
60
  });
61
61
  }
62
- function P(t) {
62
+ function v(t) {
63
63
  var e, s;
64
64
  return (s = (e = t.$store) == null ? void 0 : e.atoms) == null ? void 0 : s.session;
65
65
  }
66
- async function oe(t) {
66
+ function A(t) {
67
+ if (t instanceof m)
68
+ return t;
69
+ const e = t;
70
+ return new m(
71
+ (e == null ? void 0 : e.message) || "Failed to load the current session.",
72
+ {
73
+ code: (e == null ? void 0 : e.code) ?? "SESSION_LOOKUP_FAILED",
74
+ cause: t,
75
+ status: e == null ? void 0 : e.status
76
+ }
77
+ );
78
+ }
79
+ async function ce(t) {
67
80
  var e;
68
- await ((e = P(t)) == null ? void 0 : e.get().refetch());
81
+ await ((e = v(t)) == null ? void 0 : e.get().refetch());
69
82
  }
70
- function ae() {
71
- const t = Q(), e = 2, s = 500;
72
- let i = null;
73
- const o = () => (i || (i = (async () => {
74
- for (let l = 0; l <= e; l++) {
75
- if (!(await t.getSession()).error) return;
76
- l < e && await new Promise((d) => setTimeout(d, s));
83
+ function ue() {
84
+ const t = re(), e = 2, s = 500;
85
+ let i = null, r = !1;
86
+ const o = () => {
87
+ var c;
88
+ return r ? Promise.resolve(((c = v(t)) == null ? void 0 : c.get().data) ?? null) : (i || (i = (async () => {
89
+ var P, L, y, S;
90
+ let a = !1, l = null;
91
+ try {
92
+ for (let p = 0; p <= e; p++) {
93
+ const f = await t.getSession(), b = ((P = v(t)) == null ? void 0 : P.get().data) ?? null;
94
+ if ((L = f.data) != null && L.session && ((y = f.data) != null && y.user))
95
+ return r = !0, f.data;
96
+ if (b != null && b.session && (b != null && b.user))
97
+ return r = !0, b;
98
+ if (f.error ? l = f.error : a = !0, !f.error && p < e) {
99
+ await new Promise((U) => setTimeout(U, s));
100
+ continue;
101
+ }
102
+ p < e && await new Promise((U) => setTimeout(U, s));
103
+ }
104
+ if (!a)
105
+ throw i = null, new m("Failed to load the current session.", {
106
+ code: "SESSION_LOOKUP_FAILED",
107
+ cause: l
108
+ });
109
+ const h = ((S = v(t)) == null ? void 0 : S.get().data) ?? null;
110
+ return r = !0, h;
111
+ } catch (h) {
112
+ throw i = null, A(h);
113
+ }
114
+ })()), i);
115
+ };
116
+ o().catch(() => {
117
+ });
118
+ const u = async () => {
119
+ var c, a;
120
+ try {
121
+ const l = await t.getSession();
122
+ if ((c = l.data) != null && c.session && ((a = l.data) != null && a.user))
123
+ return l.data;
124
+ throw l.error ? A(l.error) : new m("No authenticated session is available.", {
125
+ code: "UNAUTHENTICATED"
126
+ });
127
+ } catch (l) {
128
+ throw A(l);
77
129
  }
78
- i = null;
79
- })()), i.then(() => {
80
- var l;
81
- return ((l = P(t)) == null ? void 0 : l.get().data) ?? null;
82
- }));
83
- o();
84
- const a = async () => {
85
- var r, d;
86
- const l = await t.getSession();
87
- if ((r = l.data) != null && r.session && ((d = l.data) != null && d.user))
88
- return l.data;
89
- throw new w("No authenticated session is available.", {
90
- code: "UNAUTHENTICATED",
91
- cause: l.error
92
- });
93
- }, c = (l) => {
94
- let r = !1, d = !1, A;
95
- const B = (m) => {
96
- m !== A && (A = m, l(m));
130
+ }, w = (c) => {
131
+ let a = !1, l = !1, P;
132
+ const L = (h) => {
133
+ h !== P && (P = h, c(h));
97
134
  };
98
- o().then((m) => {
99
- r || (d = !0, B(m));
135
+ o().then((h) => {
136
+ a || (l = !0, L(h));
137
+ }).catch(() => {
138
+ a || (l = !0);
100
139
  });
101
- const M = P(t);
102
- if (!M)
140
+ const y = v(t);
141
+ if (!y)
103
142
  return () => {
104
- r = !0;
143
+ a = !0;
105
144
  };
106
- const X = M.subscribe((m) => {
107
- if (r || !d)
145
+ const S = y.subscribe((h) => {
146
+ if (a || !l || h.error && !h.data)
108
147
  return;
109
- const ee = m.data ?? null;
110
- B(ee);
148
+ const p = h.data ?? null;
149
+ L(p);
111
150
  });
112
151
  return () => {
113
- r = !0, X();
152
+ a = !0, S();
114
153
  };
115
- }, h = async (...l) => {
116
- var d;
117
- const r = await t.signOut(...l);
118
- if (r && typeof r == "object" && "error" in r && r.error)
119
- return r;
154
+ }, E = async (...c) => {
155
+ var l;
156
+ const a = await t.signOut(...c);
157
+ if (a && typeof a == "object" && "error" in a && a.error)
158
+ return a;
120
159
  try {
121
- await ((d = P(t)) == null ? void 0 : d.get().refetch());
160
+ await ((l = v(t)) == null ? void 0 : l.get().refetch());
122
161
  } catch {
123
162
  }
124
- return r;
163
+ return a;
125
164
  };
126
165
  return new Proxy(t, {
127
- get(l, r, d) {
128
- return r === "requireSession" ? a : r === "onSessionChange" ? c : r === "signOut" ? h : Reflect.get(l, r, d);
166
+ get(c, a, l) {
167
+ return a === "requireSession" ? u : a === "onSessionChange" ? w : a === "signOut" ? E : Reflect.get(c, a, l);
129
168
  }
130
169
  });
131
170
  }
132
- function re() {
133
- return Q({ disableDefaultRedirectPlugin: !0 });
171
+ function he() {
172
+ return re({ disableDefaultRedirectPlugin: !0 });
134
173
  }
135
- function k(t) {
174
+ function B(t) {
136
175
  const e = (() => {
137
176
  if (t instanceof URL)
138
177
  return t;
139
178
  const s = t.trim();
140
179
  if (!s)
141
- throw new u("redirectTo must not be an empty string.");
180
+ throw new d("redirectTo must not be an empty string.");
142
181
  try {
143
182
  return new URL(s, window.location.href);
144
183
  } catch {
145
- throw new u(
184
+ throw new d(
146
185
  `redirectTo must be a valid relative path or URL. Received: ${JSON.stringify(t)}`
147
186
  );
148
187
  }
149
188
  })();
150
189
  if (e.protocol !== "http:" && e.protocol !== "https:")
151
- throw new u(
190
+ throw new d(
152
191
  `redirectTo must resolve to an http(s) URL. Received protocol: ${e.protocol}`
153
192
  );
154
193
  return e;
155
194
  }
156
- function le(t, e) {
195
+ function me(t, e) {
157
196
  return e ? {
158
197
  common: { ...t.common, ...e.common },
159
198
  signIn: { ...t.signIn, ...e.signIn },
@@ -165,7 +204,7 @@ function le(t, e) {
165
204
  errors: { ...t.errors, ...e.errors }
166
205
  } : t;
167
206
  }
168
- const y = {
207
+ const $ = {
169
208
  common: {
170
209
  loading: "Loading sign-in…",
171
210
  redirecting: "Redirecting…",
@@ -228,7 +267,7 @@ const y = {
228
267
  invalidCode: "Enter the 6-digit verification code.",
229
268
  generic: "Something went wrong. Please try again."
230
269
  }
231
- }, L = {
270
+ }, k = {
232
271
  common: {
233
272
  loading: "加载中…",
234
273
  redirecting: "跳转中…",
@@ -291,7 +330,7 @@ const y = {
291
330
  invalidCode: "请输入 6 位验证码",
292
331
  generic: "出现错误,请稍后重试"
293
332
  }
294
- }, V = {
333
+ }, x = {
295
334
  common: {
296
335
  loading: "サインインを読み込み中…",
297
336
  redirecting: "リダイレクト中…",
@@ -354,7 +393,7 @@ const y = {
354
393
  invalidCode: "6桁の認証コードを入力してください",
355
394
  generic: "エラーが発生しました。もう一度お試しください"
356
395
  }
357
- }, O = {
396
+ }, W = {
358
397
  common: {
359
398
  loading: "로그인 로딩 중…",
360
399
  redirecting: "리디렉션 중…",
@@ -417,7 +456,7 @@ const y = {
417
456
  invalidCode: "6자리 인증 코드를 입력해 주세요",
418
457
  generic: "문제가 발생했습니다. 다시 시도해 주세요"
419
458
  }
420
- }, E = {
459
+ }, M = {
421
460
  common: {
422
461
  loading: "Cargando inicio de sesión…",
423
462
  redirecting: "Redirigiendo…",
@@ -480,7 +519,7 @@ const y = {
480
519
  invalidCode: "Ingresa el código de verificación de 6 dígitos.",
481
520
  generic: "Algo salió mal. Por favor, inténtalo de nuevo."
482
521
  }
483
- }, z = {
522
+ }, j = {
484
523
  common: {
485
524
  loading: "Carregando login…",
486
525
  redirecting: "Redirecionando…",
@@ -543,7 +582,7 @@ const y = {
543
582
  invalidCode: "Insira o código de verificação de 6 dígitos.",
544
583
  generic: "Algo deu errado. Por favor, tente novamente."
545
584
  }
546
- }, F = {
585
+ }, G = {
547
586
  common: {
548
587
  loading: "Chargement de la connexion…",
549
588
  redirecting: "Redirection…",
@@ -606,7 +645,7 @@ const y = {
606
645
  invalidCode: "Saisissez le code de vérification à 6 chiffres.",
607
646
  generic: "Une erreur est survenue. Veuillez réessayer."
608
647
  }
609
- }, q = {
648
+ }, Y = {
610
649
  common: {
611
650
  loading: "Anmeldung wird geladen…",
612
651
  redirecting: "Weiterleitung…",
@@ -669,7 +708,7 @@ const y = {
669
708
  invalidCode: "Geben Sie den 6-stelligen Bestätigungscode ein.",
670
709
  generic: "Etwas ist schiefgelaufen. Bitte versuchen Sie es erneut."
671
710
  }
672
- }, N = {
711
+ }, K = {
673
712
  common: {
674
713
  loading: "Caricamento accesso…",
675
714
  redirecting: "Reindirizzamento…",
@@ -732,7 +771,7 @@ const y = {
732
771
  invalidCode: "Inserisci il codice di verifica a 6 cifre.",
733
772
  generic: "Qualcosa è andato storto. Riprova."
734
773
  }
735
- }, D = {
774
+ }, J = {
736
775
  common: {
737
776
  loading: "Загрузка входа…",
738
777
  redirecting: "Перенаправление…",
@@ -795,7 +834,7 @@ const y = {
795
834
  invalidCode: "Введите 6-значный код подтверждения.",
796
835
  generic: "Произошла ошибка. Пожалуйста, попробуйте снова."
797
836
  }
798
- }, x = {
837
+ }, Z = {
799
838
  common: {
800
839
  loading: "جارٍ تحميل تسجيل الدخول…",
801
840
  redirecting: "جارٍ إعادة التوجيه…",
@@ -858,7 +897,7 @@ const y = {
858
897
  invalidCode: "يرجى إدخال رمز التحقّق المكوّن من 6 أرقام.",
859
898
  generic: "حدث خطأ. يرجى المحاولة مرة أخرى."
860
899
  }
861
- }, H = {
900
+ }, Q = {
862
901
  common: {
863
902
  loading: "सधाइन की जुलातीअ लोड हो रही है…",
864
903
  redirecting: "रीडायरेक्ट हो रहا है…",
@@ -921,60 +960,69 @@ const y = {
921
960
  invalidCode: "कृपया 6 अंकों का सत्यापन कोड दर्ज करें।",
922
961
  generic: "कुछ गलत हो गई। कृपया फिर से प्रयास करें।"
923
962
  }
924
- }, W = {
925
- en: y,
926
- "en-US": y,
927
- zh: L,
928
- "zh-CN": L,
929
- "zh-TW": L,
930
- ja: V,
931
- "ja-JP": V,
932
- ko: O,
933
- "ko-KR": O,
934
- es: E,
935
- "es-ES": E,
936
- "es-MX": E,
937
- pt: z,
938
- "pt-BR": z,
939
- fr: F,
940
- "fr-FR": F,
941
- de: q,
942
- "de-DE": q,
943
- it: N,
944
- "it-IT": N,
945
- ru: D,
946
- "ru-RU": D,
947
- ar: x,
948
- "ar-SA": x,
949
- hi: H,
950
- "hi-IN": H
963
+ }, X = {
964
+ en: $,
965
+ "en-US": $,
966
+ zh: k,
967
+ "zh-CN": k,
968
+ "zh-TW": k,
969
+ ja: x,
970
+ "ja-JP": x,
971
+ ko: W,
972
+ "ko-KR": W,
973
+ es: M,
974
+ "es-ES": M,
975
+ "es-MX": M,
976
+ pt: j,
977
+ "pt-BR": j,
978
+ fr: G,
979
+ "fr-FR": G,
980
+ de: Y,
981
+ "de-DE": Y,
982
+ it: K,
983
+ "it-IT": K,
984
+ ru: J,
985
+ "ru-RU": J,
986
+ ar: Z,
987
+ "ar-SA": Z,
988
+ hi: Q,
989
+ "hi-IN": Q
951
990
  };
952
- function de() {
991
+ function we() {
953
992
  if (typeof navigator > "u")
954
- return y;
993
+ return $;
955
994
  const t = navigator.languages ?? [navigator.language];
956
995
  for (const e of t) {
957
- const s = W[e] ?? W[e.split("-")[0]];
996
+ const s = X[e] ?? X[e.split("-")[0]];
958
997
  if (s) return s;
959
998
  }
960
- return y;
999
+ return $;
961
1000
  }
962
- function S(t, e = "Authentication failed.") {
963
- if (t instanceof w)
1001
+ function O(t, e = "Authentication failed.") {
1002
+ if (t instanceof m)
964
1003
  return t;
965
1004
  if (typeof t == "object" && t !== null) {
966
1005
  const s = t;
967
- return new w(s.message || e, {
1006
+ return new m(s.message || e, {
968
1007
  code: s.code,
969
1008
  status: s.status,
970
1009
  cause: t
971
1010
  });
972
1011
  }
973
- return typeof t == "string" ? new w(t) : new w(e, { cause: t });
1012
+ return typeof t == "string" ? new m(t) : new m(e, { cause: t });
974
1013
  }
975
- async function j(t) {
1014
+ async function V(t) {
976
1015
  var s, i;
977
1016
  const e = await t.getSession();
1017
+ if (e.error)
1018
+ throw new m(
1019
+ e.error.message || "Failed to load the current session.",
1020
+ {
1021
+ code: e.error.code ?? "SESSION_LOOKUP_FAILED",
1022
+ status: e.error.status,
1023
+ cause: e.error
1024
+ }
1025
+ );
978
1026
  return (s = e.data) != null && s.user && ((i = e.data) != null && i.session) ? {
979
1027
  user: e.data.user,
980
1028
  session: e.data
@@ -983,7 +1031,7 @@ async function j(t) {
983
1031
  session: null
984
1032
  };
985
1033
  }
986
- const ce = "data-edgespark-auth", n = "edgespark-auth", C = "es_auth_completion", p = "es_auth_email", G = "oauth", g = "verify-sign-in", b = "verify-sign-up", _ = {
1034
+ const be = "data-edgespark-auth", n = "edgespark-auth", F = "es_auth_completion", _ = "es_auth_email", ee = "oauth", C = "verify-sign-in", g = "verify-sign-up", pe = 200, fe = 2, z = {
987
1035
  google: "Google",
988
1036
  apple: "Apple",
989
1037
  microsoft: "Microsoft",
@@ -991,24 +1039,24 @@ const ce = "data-edgespark-auth", n = "edgespark-auth", C = "es_auth_completion"
991
1039
  gitlab: "GitLab",
992
1040
  discord: "Discord"
993
1041
  };
994
- function R(t) {
1042
+ function T(t) {
995
1043
  return "redirectTo" in t;
996
1044
  }
997
- function T(t) {
1045
+ function N(t) {
998
1046
  return "onSuccess" in t && !("redirectTo" in t);
999
1047
  }
1000
- function $(t) {
1048
+ function q(t) {
1001
1049
  return !t || typeof t != "string" ? !1 : /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(t.trim());
1002
1050
  }
1003
- function ue(t) {
1051
+ function ge(t) {
1004
1052
  return /^\d{6}$/.test(t.trim());
1005
1053
  }
1006
- function he(t) {
1054
+ function ve(t) {
1007
1055
  return t === "email" || t === "name" || t === "password" || t === "confirmPassword" || t === "code" || t === "newPassword";
1008
1056
  }
1009
- class me {
1010
- constructor(e, s, i, o, a) {
1011
- if (this.container = e, this.auth = s, this.options = i, this.loadConfig = o, this.runtimeOptions = a, this.state = {
1057
+ class Pe {
1058
+ constructor(e, s, i, r, o) {
1059
+ if (this.container = e, this.auth = s, this.options = i, this.loadConfig = r, this.runtimeOptions = o, this.state = {
1012
1060
  view: "loading",
1013
1061
  busy: !0,
1014
1062
  busyLabel: void 0,
@@ -1021,8 +1069,8 @@ class me {
1021
1069
  code: "",
1022
1070
  newPassword: ""
1023
1071
  }, this.destroyed = !1, this.terminalActionInProgress = !1, this.config = null, this.countdownUntil = null, this.countdownTimer = null, this.pendingFocusSnapshot = null, this.focusRestoreTimer = null, this.verificationCompletionAction = null, !(e instanceof HTMLElement))
1024
- throw new u("authUI.mount(container, options) requires a real HTMLElement container.");
1025
- this.labels = le(de(), i.labels), this.root = document.createElement("div"), this.root.setAttribute(ce, ""), e.innerHTML = "", e.appendChild(this.root), this.render(), this.initialize();
1072
+ throw new d("authUI.mount(container, options) requires a real HTMLElement container.");
1073
+ this.labels = me(we(), i.labels), this.root = document.createElement("div"), this.root.setAttribute(be, ""), e.innerHTML = "", e.appendChild(this.root), this.render(), this.initialize();
1026
1074
  }
1027
1075
  destroy() {
1028
1076
  this.destroyed || (this.destroyed = !0, this.clearCountdown(), this.clearFocusRestoreTimer(), this.container.innerHTML = "");
@@ -1031,17 +1079,17 @@ class me {
1031
1079
  try {
1032
1080
  const e = this.consumeManagedReturnContext(), [s, i] = await Promise.all([
1033
1081
  this.loadConfig(),
1034
- j(this.auth)
1082
+ V(this.auth)
1035
1083
  ]);
1036
1084
  if (this.destroyed)
1037
1085
  return;
1038
1086
  if (this.config = s, i.user && i.session) {
1039
1087
  switch (e.marker) {
1040
- case G:
1041
- case g:
1088
+ case ee:
1089
+ case C:
1042
1090
  await this.completeAuth("sign-in", i);
1043
1091
  return;
1044
- case b:
1092
+ case g:
1045
1093
  await this.completeAuth("sign-up", i);
1046
1094
  return;
1047
1095
  default:
@@ -1112,7 +1160,7 @@ class me {
1112
1160
  }
1113
1161
  }
1114
1162
  renderSignInView() {
1115
- var i, o;
1163
+ var i, r;
1116
1164
  const e = this.renderOAuthProviders(), s = ((i = this.config) == null ? void 0 : i.emailPasswordEnabled) ?? !0;
1117
1165
  return `
1118
1166
  <section class="${n}__section">
@@ -1136,7 +1184,7 @@ class me {
1136
1184
  ${this.escape(this.labels.signIn.forgotPassword)}
1137
1185
  </button>
1138
1186
  ` : ""}
1139
- ${(o = this.config) != null && o.disableSignUp ? "" : `
1187
+ ${(r = this.config) != null && r.disableSignUp ? "" : `
1140
1188
  <p class="${n}__meta">
1141
1189
  ${this.escape(this.labels.signIn.signUpPrompt)}
1142
1190
  <button class="${n}__link" type="button" data-action="switch-sign-up" ${this.state.busy ? "disabled" : ""}>
@@ -1257,13 +1305,13 @@ class me {
1257
1305
  <div class="${n}__stack">
1258
1306
  ${e.map((i) => `
1259
1307
  <button class="${n}__button ${n}__button--secondary" type="button" data-action="oauth" data-provider="${i}" ${this.state.busy ? "disabled" : ""}>
1260
- ${this.escape(`${this.labels.oauth.continueWith} ${_[i]}`)}
1308
+ ${this.escape(`${this.labels.oauth.continueWith} ${z[i]}`)}
1261
1309
  </button>
1262
1310
  `).join("")}
1263
1311
  </div>
1264
1312
  `;
1265
1313
  }
1266
- renderInput(e, s, i, o, a) {
1314
+ renderInput(e, s, i, r, o) {
1267
1315
  return `
1268
1316
  <label class="${n}__field">
1269
1317
  <span class="${n}__label">${this.escape(s)}</span>
@@ -1271,28 +1319,28 @@ class me {
1271
1319
  class="${n}__input"
1272
1320
  name="${this.escape(e)}"
1273
1321
  type="${this.escape(i)}"
1274
- value="${this.escape(o)}"
1275
- autocomplete="${this.escape(a)}"
1322
+ value="${this.escape(r)}"
1323
+ autocomplete="${this.escape(o)}"
1276
1324
  ${this.state.busy ? "disabled" : ""}
1277
1325
  />
1278
1326
  </label>
1279
1327
  `;
1280
1328
  }
1281
1329
  bindDOM() {
1282
- this.root.querySelectorAll("form[data-view]").forEach((o) => {
1283
- o.addEventListener("submit", (a) => {
1284
- a.preventDefault();
1285
- const c = o.dataset.view;
1286
- c === "sign-in" && this.handleSignIn(), c === "sign-up" && this.handleSignUp(), c === "forgot-password" && this.handleForgotPassword(), c === "reset-password" && this.handleResetPassword();
1330
+ this.root.querySelectorAll("form[data-view]").forEach((r) => {
1331
+ r.addEventListener("submit", (o) => {
1332
+ o.preventDefault();
1333
+ const u = r.dataset.view;
1334
+ u === "sign-in" && this.handleSignIn(), u === "sign-up" && this.handleSignUp(), u === "forgot-password" && this.handleForgotPassword(), u === "reset-password" && this.handleResetPassword();
1287
1335
  });
1288
- }), this.root.querySelectorAll("input[name]").forEach((o) => {
1289
- o.addEventListener("input", () => {
1290
- he(o.name) && (this.state[o.name] = o.value);
1336
+ }), this.root.querySelectorAll("input[name]").forEach((r) => {
1337
+ r.addEventListener("input", () => {
1338
+ ve(r.name) && (this.state[r.name] = r.value);
1291
1339
  });
1292
- }), this.root.querySelectorAll("[data-action]").forEach((o) => {
1293
- o.addEventListener("click", () => {
1294
- const a = o.dataset.action;
1295
- a === "switch-sign-up" && this.switchView("sign-up"), a === "switch-sign-in" && this.switchView("sign-in"), a === "forgot-password" && this.switchView("forgot-password"), a === "resend-verification" && this.resendVerificationEmail(), a === "use-different-email" && this.switchView(this.verificationCompletionAction === "sign-in" ? "sign-in" : "sign-up"), a === "resend-reset-code" && this.resendResetCode(), a === "oauth" && this.handleOAuthSignIn(o.dataset.provider);
1340
+ }), this.root.querySelectorAll("[data-action]").forEach((r) => {
1341
+ r.addEventListener("click", () => {
1342
+ const o = r.dataset.action;
1343
+ o === "switch-sign-up" && this.switchView("sign-up"), o === "switch-sign-in" && this.switchView("sign-in"), o === "forgot-password" && this.switchView("forgot-password"), o === "resend-verification" && this.resendVerificationEmail(), o === "use-different-email" && this.switchView(this.verificationCompletionAction === "sign-in" ? "sign-in" : "sign-up"), o === "resend-reset-code" && this.resendResetCode(), o === "oauth" && this.handleOAuthSignIn(r.dataset.provider);
1296
1344
  });
1297
1345
  });
1298
1346
  }
@@ -1300,7 +1348,7 @@ class me {
1300
1348
  this.clearCountdown(), e !== "verify-email" && (this.verificationCompletionAction = null), this.state.view = e, this.state.error = null, this.state.notice = null, this.state.busy = !1, this.state.busyLabel = void 0, this.terminalActionInProgress = !1, this.render();
1301
1349
  }
1302
1350
  async handleSignIn() {
1303
- if (!$(this.state.email)) {
1351
+ if (!q(this.state.email)) {
1304
1352
  this.failValidation(this.labels.errors.invalidEmail);
1305
1353
  return;
1306
1354
  }
@@ -1312,7 +1360,7 @@ class me {
1312
1360
  const e = await this.auth.signIn.email({
1313
1361
  email: this.state.email.trim(),
1314
1362
  password: this.state.password,
1315
- callbackURL: this.getManagedReturnURL(g, this.state.email.trim())
1363
+ callbackURL: this.getManagedReturnURL(C, this.state.email.trim())
1316
1364
  });
1317
1365
  if (e.error)
1318
1366
  throw e.error;
@@ -1325,7 +1373,7 @@ class me {
1325
1373
  this.failValidation(this.labels.errors.requiredField);
1326
1374
  return;
1327
1375
  }
1328
- if (!$(this.state.email)) {
1376
+ if (!q(this.state.email)) {
1329
1377
  this.failValidation(this.labels.errors.invalidEmail);
1330
1378
  return;
1331
1379
  }
@@ -1344,16 +1392,16 @@ class me {
1344
1392
  return;
1345
1393
  }
1346
1394
  await this.runAction("Creating account…", async () => {
1347
- var o;
1395
+ var r;
1348
1396
  const i = await this.auth.signUp.email({
1349
1397
  name: this.state.name.trim(),
1350
1398
  email: this.state.email.trim(),
1351
1399
  password: this.state.password,
1352
- callbackURL: this.getManagedReturnURL(b, this.state.email.trim())
1400
+ callbackURL: this.getManagedReturnURL(g, this.state.email.trim())
1353
1401
  });
1354
1402
  if (i.error)
1355
1403
  throw i.error;
1356
- if ((o = this.config) != null && o.requireEmailVerification) {
1404
+ if ((r = this.config) != null && r.requireEmailVerification) {
1357
1405
  this.verificationCompletionAction = "sign-up", this.state.view = "verify-email", this.state.notice = "Check your inbox to verify your email address.", this.startCountdown();
1358
1406
  return;
1359
1407
  }
@@ -1361,7 +1409,7 @@ class me {
1361
1409
  });
1362
1410
  }
1363
1411
  async handleOAuthSignIn(e) {
1364
- await this.runAction(`Redirecting to ${_[e]}…`, async () => {
1412
+ await this.runAction(`Redirecting to ${z[e]}…`, async () => {
1365
1413
  const s = await this.auth.signIn.social({
1366
1414
  provider: e,
1367
1415
  callbackURL: this.getManagedReturnURL("oauth"),
@@ -1371,18 +1419,18 @@ class me {
1371
1419
  throw s.error;
1372
1420
  const i = this.extractRedirectURL(s.data);
1373
1421
  if (!i)
1374
- throw new u(`OAuth sign-in did not return a redirect URL for provider "${e}".`);
1375
- this.terminalActionInProgress = !0, this.state.busy = !0, this.state.busyLabel = `Opening ${_[e]}…`, this.state.error = null, this.state.notice = null, this.render(), window.location.assign(i);
1422
+ throw new d(`OAuth sign-in did not return a redirect URL for provider "${e}".`);
1423
+ this.terminalActionInProgress = !0, this.state.busy = !0, this.state.busyLabel = `Opening ${z[e]}…`, this.state.error = null, this.state.notice = null, this.render(), window.location.assign(i);
1376
1424
  });
1377
1425
  }
1378
1426
  async handleForgotPassword() {
1379
1427
  if (!this.canUsePasswordResetEmailOtp()) {
1380
1428
  this.handleError(
1381
- new u("Password reset via email OTP is not enabled for this project.")
1429
+ new d("Password reset via email OTP is not enabled for this project.")
1382
1430
  );
1383
1431
  return;
1384
1432
  }
1385
- if (!$(this.state.email)) {
1433
+ if (!q(this.state.email)) {
1386
1434
  this.failValidation(this.labels.errors.invalidEmail);
1387
1435
  return;
1388
1436
  }
@@ -1399,13 +1447,14 @@ class me {
1399
1447
  this.isCountdownActive() || await this.handleForgotPassword();
1400
1448
  }
1401
1449
  async handleResetPassword() {
1450
+ var e, s;
1402
1451
  if (!this.canUsePasswordResetEmailOtp()) {
1403
1452
  this.handleError(
1404
- new u("Password reset via email OTP is not enabled for this project.")
1453
+ new d("Password reset via email OTP is not enabled for this project.")
1405
1454
  );
1406
1455
  return;
1407
1456
  }
1408
- if (!ue(this.state.code)) {
1457
+ if (!ge(this.state.code)) {
1409
1458
  this.failValidation(this.labels.errors.invalidCode);
1410
1459
  return;
1411
1460
  }
@@ -1413,18 +1462,24 @@ class me {
1413
1462
  this.failValidation(this.labels.errors.requiredField);
1414
1463
  return;
1415
1464
  }
1465
+ if (this.state.newPassword.length < (((e = this.config) == null ? void 0 : e.minPasswordLength) ?? 8)) {
1466
+ this.failValidation(
1467
+ this.labels.errors.passwordTooShort.replace("{min}", String(((s = this.config) == null ? void 0 : s.minPasswordLength) ?? 8))
1468
+ );
1469
+ return;
1470
+ }
1416
1471
  if (this.state.newPassword !== this.state.confirmPassword) {
1417
1472
  this.failValidation(this.labels.errors.passwordMismatch);
1418
1473
  return;
1419
1474
  }
1420
1475
  await this.runAction("Updating password…", async () => {
1421
- const e = await this.passwordResetEndpoints().emailOtp.resetPassword({
1476
+ const i = await this.passwordResetEndpoints().emailOtp.resetPassword({
1422
1477
  email: this.state.email.trim(),
1423
1478
  otp: this.state.code.trim(),
1424
1479
  password: this.state.newPassword
1425
1480
  });
1426
- if (e.error)
1427
- throw e.error;
1481
+ if (i.error)
1482
+ throw i.error;
1428
1483
  await this.completePasswordReset();
1429
1484
  });
1430
1485
  }
@@ -1436,7 +1491,7 @@ class me {
1436
1491
  const s = await this.auth.sendVerificationEmail({
1437
1492
  email: this.state.email.trim(),
1438
1493
  callbackURL: this.getManagedReturnURL(
1439
- this.verificationCompletionAction === "sign-up" ? b : g,
1494
+ this.verificationCompletionAction === "sign-up" ? g : C,
1440
1495
  this.state.email.trim()
1441
1496
  )
1442
1497
  });
@@ -1446,54 +1501,98 @@ class me {
1446
1501
  });
1447
1502
  }
1448
1503
  async completeAuth(e, s) {
1449
- var a, c;
1450
- const i = s ?? await this.resolveAuthCompletionData();
1504
+ const i = await this.retryAuthCompletionDataIfNeeded(
1505
+ s ?? await this.resolveAuthCompletionData()
1506
+ );
1451
1507
  if (!i.user || !i.session) {
1508
+ if (i.lookupError && T(this.options)) {
1509
+ this.terminalActionInProgress = !0, this.state.busy = !0, this.state.busyLabel = this.labels.common.redirecting, this.state.error = null, this.state.notice = null, this.render(), window.location.assign(B(this.options.redirectTo).toString());
1510
+ return;
1511
+ }
1452
1512
  if (e === "sign-in")
1453
- throw new K("Managed sign-in completed without an authenticated session.");
1513
+ throw i.lookupError ?? new se(
1514
+ "Managed sign-in completed without an authenticated session."
1515
+ );
1454
1516
  this.state.view = "sign-in", this.state.password = "", this.state.confirmPassword = "", this.state.error = null, this.state.busy = !1, this.state.busyLabel = void 0, this.state.notice = "Account created. Sign in to continue.", this.render();
1455
1517
  return;
1456
1518
  }
1457
- const o = {
1519
+ const r = {
1458
1520
  action: e,
1459
1521
  user: i.user,
1460
1522
  session: i.session
1461
1523
  };
1462
- if (await ((c = (a = this.runtimeOptions) == null ? void 0 : a.syncPublicSession) == null ? void 0 : c.call(a)), R(this.options)) {
1463
- this.terminalActionInProgress = !0, this.invokeRedirectModeSuccessHook(o), this.state.busy = !0, this.state.busyLabel = this.labels.common.redirecting, this.state.error = null, this.state.notice = null, this.render(), window.location.assign(k(this.options.redirectTo).toString());
1524
+ if (await this.syncPublicSessionBestEffort(), T(this.options)) {
1525
+ this.terminalActionInProgress = !0, this.invokeRedirectModeSuccessHook(r), this.state.busy = !0, this.state.busyLabel = this.labels.common.redirecting, this.state.error = null, this.state.notice = null, this.render(), window.location.assign(B(this.options.redirectTo).toString());
1464
1526
  return;
1465
1527
  }
1466
- if (T(this.options)) {
1467
- this.destroy(), this.options.onSuccess(o);
1528
+ if (N(this.options)) {
1529
+ this.destroy(), this.options.onSuccess(r);
1468
1530
  return;
1469
1531
  }
1470
1532
  }
1471
- async resolveAuthCompletionData(e) {
1472
- const s = await j(this.auth), i = this.extractUser(e);
1533
+ async retryAuthCompletionDataIfNeeded(e) {
1534
+ if (e.session)
1535
+ return e;
1536
+ let s = e.lookupError;
1537
+ for (let i = 0; i < fe; i++) {
1538
+ await new Promise((r) => setTimeout(r, pe));
1539
+ try {
1540
+ const r = await V(this.auth);
1541
+ if (r.user && r.session)
1542
+ return {
1543
+ user: r.user,
1544
+ session: r.session
1545
+ };
1546
+ } catch (r) {
1547
+ s = r;
1548
+ }
1549
+ }
1473
1550
  return {
1474
- user: s.user ?? i,
1475
- session: s.session
1551
+ ...e,
1552
+ lookupError: s ?? e.lookupError
1476
1553
  };
1477
1554
  }
1555
+ async syncPublicSessionBestEffort() {
1556
+ var e, s;
1557
+ try {
1558
+ await ((s = (e = this.runtimeOptions) == null ? void 0 : e.syncPublicSession) == null ? void 0 : s.call(e));
1559
+ } catch {
1560
+ }
1561
+ }
1562
+ async resolveAuthCompletionData(e) {
1563
+ try {
1564
+ const s = await V(this.auth), i = this.extractUser(e);
1565
+ return {
1566
+ user: s.user ?? i,
1567
+ session: s.session
1568
+ };
1569
+ } catch (s) {
1570
+ return {
1571
+ user: this.extractUser(e),
1572
+ session: null,
1573
+ lookupError: s
1574
+ };
1575
+ }
1576
+ }
1478
1577
  async completePasswordReset() {
1479
1578
  const e = {
1480
1579
  action: "password-reset",
1481
1580
  user: null,
1482
1581
  session: null
1483
1582
  };
1484
- if (T(this.options)) {
1583
+ if (N(this.options)) {
1485
1584
  this.destroy(), this.options.onSuccess(e);
1486
1585
  return;
1487
1586
  }
1488
1587
  this.invokeRedirectModeSuccessHook(e), this.clearCountdown(), this.state.view = "sign-in", this.state.password = "", this.state.confirmPassword = "", this.state.newPassword = "", this.state.code = "", this.state.busy = !1, this.state.busyLabel = void 0, this.state.error = null, this.state.notice = "Password updated. Sign in with your new password.", this.render();
1489
1588
  }
1490
1589
  handleExistingSessionOnMount(e) {
1491
- if (R(this.options)) {
1492
- this.terminalActionInProgress = !0, this.state.busy = !0, this.state.busyLabel = this.labels.common.redirecting, this.state.error = null, this.state.notice = null, this.render(), window.location.assign(k(this.options.redirectTo).toString());
1590
+ if (T(this.options)) {
1591
+ this.terminalActionInProgress = !0, this.state.busy = !0, this.state.busyLabel = this.labels.common.redirecting, this.state.error = null, this.state.notice = null, this.render(), window.location.assign(B(this.options.redirectTo).toString());
1493
1592
  return;
1494
1593
  }
1495
- if (T(this.options))
1496
- throw this.state.view = "sign-in", this.state.busy = !1, this.state.busyLabel = void 0, this.state.notice = null, new u(
1594
+ if (N(this.options))
1595
+ throw this.state.view = "sign-in", this.state.busy = !1, this.state.busyLabel = void 0, this.state.notice = null, new d(
1497
1596
  "authUI.mount(container, { onSuccess }) cannot run while a session already exists. Check es.auth.getSession() before mounting controlled auth UI."
1498
1597
  );
1499
1598
  }
@@ -1510,28 +1609,28 @@ class me {
1510
1609
  !this.destroyed && !this.terminalActionInProgress && (this.state.busy = !1, this.state.busyLabel = void 0, this.render());
1511
1610
  }
1512
1611
  maybeHandleVerificationRequired(e) {
1513
- return S(e).code !== "EMAIL_NOT_VERIFIED" ? !1 : (this.verificationCompletionAction = "sign-in", this.state.view = "verify-email", this.state.busy = !1, this.state.busyLabel = void 0, this.state.error = null, this.state.notice = `Verify your email to finish signing in as ${this.state.email.trim()}.`, this.render(), this.sendVerificationEmail(!0), !0);
1612
+ return O(e).code !== "EMAIL_NOT_VERIFIED" ? !1 : (this.verificationCompletionAction = "sign-in", this.state.view = "verify-email", this.state.busy = !1, this.state.busyLabel = void 0, this.state.error = null, this.state.notice = `Verify your email to finish signing in as ${this.state.email.trim()}.`, this.render(), this.sendVerificationEmail(!0), !0);
1514
1613
  }
1515
1614
  handleVerificationEmailSent(e, s) {
1516
1615
  this.state.notice = s ? `We sent another verification email to ${e}.` : `We sent a verification email to ${e}.`, this.startCountdown();
1517
1616
  }
1518
1617
  invokeRedirectModeSuccessHook(e) {
1519
1618
  var s, i;
1520
- if (!(!R(this.options) || !this.options.onSuccess))
1619
+ if (!(!T(this.options) || !this.options.onSuccess))
1521
1620
  try {
1522
1621
  this.options.onSuccess(e);
1523
- } catch (o) {
1524
- const a = S(o, "Post-auth callback failed.");
1622
+ } catch (r) {
1623
+ const o = O(r, "Post-auth callback failed.");
1525
1624
  try {
1526
- (i = (s = this.options).onError) == null || i.call(s, a);
1625
+ (i = (s = this.options).onError) == null || i.call(s, o);
1527
1626
  } catch {
1528
1627
  }
1529
1628
  }
1530
1629
  }
1531
1630
  handleError(e, s) {
1532
- var o, a;
1533
- const i = S(e, s);
1534
- this.state.busy = !1, this.state.busyLabel = void 0, this.state.error = i.message, this.render(), (a = (o = this.options).onError) == null || a.call(o, i);
1631
+ var r, o;
1632
+ const i = O(e, s);
1633
+ this.state.busy = !1, this.state.busyLabel = void 0, this.state.error = i.message, this.render(), (o = (r = this.options).onError) == null || o.call(r, i);
1535
1634
  }
1536
1635
  failValidation(e) {
1537
1636
  this.state.error = e, this.state.notice = null, this.render();
@@ -1540,15 +1639,15 @@ class me {
1540
1639
  if (!e)
1541
1640
  return window.location.href;
1542
1641
  const i = new URL(window.location.href);
1543
- return i.searchParams.set(C, e), s ? i.searchParams.set(p, s) : i.searchParams.delete(p), i.toString();
1642
+ return i.searchParams.set(F, e), s ? i.searchParams.set(_, s) : i.searchParams.delete(_), i.toString();
1544
1643
  }
1545
1644
  consumeManagedReturnContext() {
1546
- const e = new URL(window.location.href), s = e.searchParams.get(C), i = e.searchParams.get(p), o = s ? e.searchParams.get("error") : null, a = s ? e.searchParams.get("error_description") : null;
1547
- return (s || i) && (e.searchParams.delete(C), e.searchParams.delete(p), s && (e.searchParams.delete("error"), e.searchParams.delete("error_description")), window.history.replaceState(null, "", e.toString())), {
1645
+ const e = new URL(window.location.href), s = e.searchParams.get(F), i = e.searchParams.get(_), r = s ? e.searchParams.get("error") : null, o = s ? e.searchParams.get("error_description") : null;
1646
+ return (s || i) && (e.searchParams.delete(F), e.searchParams.delete(_), s && (e.searchParams.delete("error"), e.searchParams.delete("error_description")), window.history.replaceState(null, "", e.toString())), {
1548
1647
  marker: s,
1549
1648
  email: i,
1550
- error: o,
1551
- errorDescription: a
1649
+ error: r,
1650
+ errorDescription: o
1552
1651
  };
1553
1652
  }
1554
1653
  startCountdown(e = 60) {
@@ -1582,8 +1681,8 @@ class me {
1582
1681
  try {
1583
1682
  i.setSelectionRange(e.selectionStart, e.selectionEnd);
1584
1683
  } catch {
1585
- const o = i.value.length;
1586
- i.setSelectionRange(o, o);
1684
+ const r = i.value.length;
1685
+ i.setSelectionRange(r, r);
1587
1686
  }
1588
1687
  this.pendingFocusSnapshot = null;
1589
1688
  }
@@ -1612,10 +1711,10 @@ class me {
1612
1711
  return !!((e = this.config) != null && e.passwordResetEmailOtpEnabled);
1613
1712
  }
1614
1713
  handleSessionlessManagedReturn(e) {
1615
- return e.email && (this.state.email = e.email), e.marker === b && !e.error ? (this.verificationCompletionAction = null, this.clearCountdown(), this.state.view = "sign-in", this.state.password = "", this.state.confirmPassword = "", this.state.error = null, this.state.busy = !1, this.state.busyLabel = void 0, this.state.notice = "Account created. Sign in to continue.", this.render(), !0) : e.marker === g || e.marker === b ? (this.verificationCompletionAction = e.marker === b ? "sign-up" : "sign-in", this.state.view = "verify-email", this.state.busy = !1, this.state.busyLabel = void 0, this.state.notice = null, e.error || e.errorDescription ? this.handleError(new w(
1714
+ return e.email && (this.state.email = e.email), e.marker === g && !e.error ? (this.verificationCompletionAction = null, this.clearCountdown(), this.state.view = "sign-in", this.state.password = "", this.state.confirmPassword = "", this.state.error = null, this.state.busy = !1, this.state.busyLabel = void 0, this.state.notice = "Account created. Sign in to continue.", this.render(), !0) : e.marker === C || e.marker === g ? (this.verificationCompletionAction = e.marker === g ? "sign-up" : "sign-in", this.state.view = "verify-email", this.state.busy = !1, this.state.busyLabel = void 0, this.state.notice = null, e.error || e.errorDescription ? this.handleError(new m(
1616
1715
  e.errorDescription ?? "Verification failed. Request a new verification email and try again.",
1617
1716
  { code: e.error ?? "VERIFY_EMAIL_ERROR" }
1618
- )) : this.render(), !0) : e.marker === G && (e.error || e.errorDescription) ? (this.state.view = "sign-in", this.state.busy = !1, this.state.busyLabel = void 0, this.state.notice = null, this.handleError(new w(
1717
+ )) : this.render(), !0) : e.marker === ee && (e.error || e.errorDescription) ? (this.state.view = "sign-in", this.state.busy = !1, this.state.busyLabel = void 0, this.state.notice = null, this.handleError(new m(
1619
1718
  e.errorDescription ?? "OAuth sign-in failed.",
1620
1719
  { code: e.error ?? "OAUTH_ERROR" }
1621
1720
  )), !0) : !1;
@@ -1634,103 +1733,103 @@ class me {
1634
1733
  return e.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;");
1635
1734
  }
1636
1735
  }
1637
- function we(t) {
1736
+ function Le(t) {
1638
1737
  return "data" in t && t.data ? t.data : t;
1639
1738
  }
1640
- const be = [
1739
+ const ye = [
1641
1740
  { id: "google", key: "providerGoogle" },
1642
1741
  { id: "apple", key: "providerApple" },
1643
1742
  { id: "microsoft", key: "providerMicrosoft" },
1644
1743
  { id: "github", key: "providerGithub" },
1645
1744
  { id: "gitlab", key: "providerGitlab" },
1646
1745
  { id: "discord", key: "providerDiscord" }
1647
- ], Y = 2, pe = 500;
1648
- async function ge() {
1649
- const t = `${window.location.origin}${Z}/config`;
1746
+ ], te = 2, Ee = 500;
1747
+ async function Se() {
1748
+ const t = `${window.location.origin}${ne}/config`;
1650
1749
  let e;
1651
- for (let s = 0; s <= Y; s++)
1750
+ for (let s = 0; s <= te; s++)
1652
1751
  try {
1653
1752
  const i = await fetch(t, { method: "GET", credentials: "include" });
1654
1753
  if (!i.ok)
1655
- throw new u(`Failed to load auth config: HTTP ${i.status}`);
1656
- const o = await i.json();
1657
- return ve(we(o));
1754
+ throw new d(`Failed to load auth config: HTTP ${i.status}`);
1755
+ const r = await i.json();
1756
+ return Ce(Le(r));
1658
1757
  } catch (i) {
1659
- e = i, s < Y && await new Promise((o) => setTimeout(o, pe));
1758
+ e = i, s < te && await new Promise((r) => setTimeout(r, Ee));
1660
1759
  }
1661
1760
  throw e;
1662
1761
  }
1663
- let f = null;
1664
- async function fe() {
1665
- return f || (f = ge().catch((t) => {
1666
- throw f = null, t;
1667
- })), f;
1762
+ let I = null;
1763
+ async function _e() {
1764
+ return I || (I = Se().catch((t) => {
1765
+ throw I = null, t;
1766
+ })), I;
1668
1767
  }
1669
- function ve(t) {
1670
- var s, i, o, a, c, h, l;
1671
- const e = be.filter(({ key: r }) => {
1672
- const d = t[r];
1673
- return typeof d == "object" && d !== null && "enabled" in d && !!d.enabled;
1674
- }).map(({ id: r }) => r);
1768
+ function Ce(t) {
1769
+ var s, i, r, o, u, w, E;
1770
+ const e = ye.filter(({ key: c }) => {
1771
+ const a = t[c];
1772
+ return typeof a == "object" && a !== null && "enabled" in a && !!a.enabled;
1773
+ }).map(({ id: c }) => c);
1675
1774
  return {
1676
1775
  disableSignUp: !!t.disableSignUp,
1677
1776
  emailPasswordEnabled: !!((s = t.providerEmailPassword) != null && s.enabled),
1678
- minPasswordLength: ((o = (i = t.providerEmailPassword) == null ? void 0 : i.config) == null ? void 0 : o.minPasswordLength) ?? 8,
1679
- requireEmailVerification: !!((c = (a = t.providerEmailPassword) == null ? void 0 : a.config) != null && c.requireEmailVerification),
1680
- passwordResetEmailOtpEnabled: !!((l = (h = t.providerEmailPassword) == null ? void 0 : h.config) != null && l.requirePasswordResetEmailVerification),
1777
+ minPasswordLength: ((r = (i = t.providerEmailPassword) == null ? void 0 : i.config) == null ? void 0 : r.minPasswordLength) ?? 8,
1778
+ requireEmailVerification: !!((u = (o = t.providerEmailPassword) == null ? void 0 : o.config) != null && u.requireEmailVerification),
1779
+ passwordResetEmailOtpEnabled: !!((E = (w = t.providerEmailPassword) == null ? void 0 : w.config) != null && E.requirePasswordResetEmailVerification),
1681
1780
  oauthProviders: e
1682
1781
  };
1683
1782
  }
1684
- const v = /* @__PURE__ */ new WeakMap();
1685
- function Pe(t) {
1783
+ const R = /* @__PURE__ */ new WeakMap();
1784
+ function Te(t) {
1686
1785
  if (!t)
1687
- throw new u(
1786
+ throw new d(
1688
1787
  "authUI.mount(container, options) requires either { redirectTo } or { onSuccess }."
1689
1788
  );
1690
1789
  const e = "redirectTo" in t, s = "onSuccess" in t && typeof t.onSuccess == "function";
1691
1790
  if (!e && !s)
1692
- throw new u(
1791
+ throw new d(
1693
1792
  "authUI.mount(container, options) requires either { redirectTo } or { onSuccess }."
1694
1793
  );
1695
1794
  if ("redirectTo" in t) {
1696
1795
  const i = t.redirectTo;
1697
1796
  if (!(typeof i == "string" || i instanceof URL))
1698
- throw new u(
1797
+ throw new d(
1699
1798
  "authUI.mount(container, options) expected redirectTo to be a string or URL."
1700
1799
  );
1701
1800
  }
1702
1801
  if ("onSuccess" in t && t.onSuccess !== void 0 && typeof t.onSuccess != "function")
1703
- throw new u(
1802
+ throw new d(
1704
1803
  "authUI.mount(container, options) expected onSuccess to be a function."
1705
1804
  );
1706
1805
  if ("onError" in t && t.onError !== void 0 && typeof t.onError != "function")
1707
- throw new u(
1806
+ throw new d(
1708
1807
  "authUI.mount(container, options) expected onError to be a function."
1709
1808
  );
1710
1809
  }
1711
- function ye(t) {
1810
+ function Ie(t) {
1712
1811
  if (!(t instanceof HTMLElement))
1713
- throw new u("authUI.mount(container, options) requires a real HTMLElement container.");
1812
+ throw new d("authUI.mount(container, options) requires a real HTMLElement container.");
1714
1813
  }
1715
- function Le(t, e) {
1814
+ function Re(t, e) {
1716
1815
  return {
1717
1816
  mount(s, i) {
1718
- var h;
1719
- Pe(i), ye(s), (h = v.get(s)) == null || h.destroy();
1720
- const o = new me(s, t, i, fe, e), a = o.destroy.bind(o), c = {
1817
+ var w;
1818
+ Te(i), Ie(s), (w = R.get(s)) == null || w.destroy();
1819
+ const r = new Pe(s, t, i, _e, e), o = r.destroy.bind(r), u = {
1721
1820
  destroy() {
1722
- a(), v.get(s) === c && v.delete(s);
1821
+ o(), R.get(s) === u && R.delete(s);
1723
1822
  }
1724
1823
  };
1725
- return v.set(s, c), c;
1824
+ return R.set(s, u), u;
1726
1825
  }
1727
1826
  };
1728
1827
  }
1729
- function Se() {
1730
- J();
1731
- const t = ae(), e = re(), s = ne(), i = Le(e, {
1828
+ function Ue() {
1829
+ ie();
1830
+ const t = ue(), e = he(), s = de(), i = Re(e, {
1732
1831
  syncPublicSession: async () => {
1733
- await oe(t);
1832
+ await ce(t);
1734
1833
  }
1735
1834
  });
1736
1835
  return {
@@ -1740,22 +1839,22 @@ function Se() {
1740
1839
  };
1741
1840
  }
1742
1841
  export {
1743
- w as EdgeSparkAuthError,
1744
- u as EdgeSparkConfigError,
1745
- U as EdgeSparkError,
1746
- K as EdgeSparkRuntimeError,
1747
- x as ar,
1748
- Se as createEdgeSpark,
1749
- q as de,
1750
- de as detectLocale,
1751
- y as enUS,
1752
- E as es,
1753
- F as fr,
1754
- H as hi,
1755
- N as it,
1756
- V as ja,
1757
- O as ko,
1758
- z as ptBR,
1759
- D as ru,
1760
- L as zhCN
1842
+ m as EdgeSparkAuthError,
1843
+ d as EdgeSparkConfigError,
1844
+ H as EdgeSparkError,
1845
+ se as EdgeSparkRuntimeError,
1846
+ Z as ar,
1847
+ Ue as createEdgeSpark,
1848
+ Y as de,
1849
+ we as detectLocale,
1850
+ $ as enUS,
1851
+ M as es,
1852
+ G as fr,
1853
+ Q as hi,
1854
+ K as it,
1855
+ x as ja,
1856
+ W as ko,
1857
+ j as ptBR,
1858
+ J as ru,
1859
+ k as zhCN
1761
1860
  };