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

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,73 +1,95 @@
1
- import { createAuthClient as oe } from "better-auth/client";
2
- class H extends Error {
1
+ import { createAuthClient as be } from "better-auth/client";
2
+ class j extends Error {
3
3
  constructor(e, s) {
4
4
  super(s), this.name = "EdgeSparkError", this.code = e;
5
5
  }
6
6
  }
7
- class d extends H {
7
+ class u extends j {
8
8
  constructor(e) {
9
9
  super("CONFIG_ERROR", e), this.name = "EdgeSparkConfigError";
10
10
  }
11
11
  }
12
- class se extends H {
12
+ class de extends j {
13
13
  constructor(e) {
14
14
  super("RUNTIME_ERROR", e), this.name = "EdgeSparkRuntimeError";
15
15
  }
16
16
  }
17
- class m extends H {
17
+ class w extends j {
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 ie() {
22
+ function ce() {
23
23
  if (typeof window > "u" || typeof document > "u")
24
- throw new se(
24
+ throw new de(
25
25
  "@edgespark/web is browser-only. Create the client from a real browser runtime."
26
26
  );
27
27
  }
28
- function D() {
29
- return ie(), window.location.origin;
28
+ function W() {
29
+ return ce(), window.location.origin;
30
30
  }
31
- function ae(t) {
31
+ function ge(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 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()}.`
34
+ function ve(t) {
35
+ if (t.origin !== W())
36
+ throw new u(
37
+ `Cross-origin requests are not supported by this SDK. Received ${t.origin}, expected ${W()}.`
38
38
  );
39
39
  }
40
- function de() {
40
+ function ye() {
41
41
  return {
42
42
  async fetch(t, e) {
43
- const s = ae(t);
44
- return le(s), fetch(t, {
43
+ const s = ge(t);
44
+ return ve(s), fetch(t, {
45
45
  ...e,
46
46
  credentials: "include"
47
47
  });
48
48
  }
49
49
  };
50
50
  }
51
- const ne = "/api/_es/auth";
52
- function re(t) {
53
- return oe({
54
- baseURL: D(),
55
- basePath: ne,
51
+ const ue = "/api/_es/auth", Pe = "edgespark-auth-session", K = "__edgespark_auth_sync__", he = Symbol("edgespark.notifyAuthTabs");
52
+ function me(t) {
53
+ return be({
54
+ baseURL: W(),
55
+ basePath: ue,
56
56
  ...t != null && t.disableDefaultRedirectPlugin ? { disableDefaultFetchPlugins: !0 } : {},
57
57
  fetchOptions: {
58
58
  credentials: "include"
59
59
  }
60
60
  });
61
61
  }
62
- function v(t) {
62
+ function _(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
- function A(t) {
67
- if (t instanceof m)
66
+ function Le(t) {
67
+ return JSON.stringify({
68
+ source: t,
69
+ timestamp: Date.now()
70
+ });
71
+ }
72
+ function Ee(t) {
73
+ if (typeof t != "string")
74
+ return null;
75
+ try {
76
+ const e = JSON.parse(t);
77
+ return e && typeof e == "object" ? e : null;
78
+ } catch {
79
+ return null;
80
+ }
81
+ }
82
+ function Se(t) {
83
+ if (!(t && typeof t == "object") || "error" in t && t.error)
84
+ return !1;
85
+ const e = "data" in t ? t.data : t;
86
+ return e && typeof e == "object" ? "token" in e && typeof e.token == "string" && e.token.length > 0 ? !0 : "session" in e && "user" in e && !!e.session && !!e.user : !1;
87
+ }
88
+ function M(t) {
89
+ if (t instanceof w)
68
90
  return t;
69
91
  const e = t;
70
- return new m(
92
+ return new w(
71
93
  (e == null ? void 0 : e.message) || "Failed to load the current session.",
72
94
  {
73
95
  code: (e == null ? void 0 : e.code) ?? "SESSION_LOOKUP_FAILED",
@@ -76,123 +98,163 @@ function A(t) {
76
98
  }
77
99
  );
78
100
  }
79
- async function ce(t) {
80
- var e;
81
- await ((e = v(t)) == null ? void 0 : e.get().refetch());
101
+ async function _e(t) {
102
+ var e, s;
103
+ await ((e = _(t)) == null ? void 0 : e.get().refetch()), (s = t[he]) == null || s.call(t);
82
104
  }
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;
105
+ function Te() {
106
+ const t = me(), e = `${Date.now()}-${Math.random().toString(36).slice(2)}`, s = typeof BroadcastChannel < "u" ? new BroadcastChannel(Pe) : null, i = 2, r = 500;
107
+ let a = null, c = !1;
108
+ const p = () => {
109
+ var l;
110
+ return c ? Promise.resolve(((l = _(t)) == null ? void 0 : l.get().data) ?? null) : (a || (a = (async () => {
111
+ var m, f, g, v;
112
+ let o = !1, d = null;
91
113
  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));
114
+ for (let L = 0; L <= i; L++) {
115
+ const E = await t.getSession(), y = ((m = _(t)) == null ? void 0 : m.get().data) ?? null;
116
+ if ((f = E.data) != null && f.session && ((g = E.data) != null && g.user))
117
+ return c = !0, E.data;
118
+ if (y != null && y.session && (y != null && y.user))
119
+ return c = !0, y;
120
+ if (E.error ? d = E.error : o = !0, !E.error && L < i) {
121
+ await new Promise((k) => setTimeout(k, r));
100
122
  continue;
101
123
  }
102
- p < e && await new Promise((U) => setTimeout(U, s));
124
+ L < i && await new Promise((k) => setTimeout(k, r));
103
125
  }
104
- if (!a)
105
- throw i = null, new m("Failed to load the current session.", {
126
+ if (!o)
127
+ throw a = null, new w("Failed to load the current session.", {
106
128
  code: "SESSION_LOOKUP_FAILED",
107
- cause: l
129
+ cause: d
108
130
  });
109
- const h = ((S = v(t)) == null ? void 0 : S.get().data) ?? null;
110
- return r = !0, h;
131
+ const h = ((v = _(t)) == null ? void 0 : v.get().data) ?? null;
132
+ return c = !0, h;
111
133
  } catch (h) {
112
- throw i = null, A(h);
134
+ throw a = null, M(h);
113
135
  }
114
- })()), i);
136
+ })()), a);
115
137
  };
116
- o().catch(() => {
138
+ p().catch(() => {
117
139
  });
118
- const u = async () => {
119
- var c, a;
140
+ const T = async () => {
141
+ var l, o;
120
142
  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.", {
143
+ const d = await t.getSession();
144
+ if ((l = d.data) != null && l.session && ((o = d.data) != null && o.user))
145
+ return d.data;
146
+ throw d.error ? M(d.error) : new w("No authenticated session is available.", {
125
147
  code: "UNAUTHENTICATED"
126
148
  });
127
- } catch (l) {
128
- throw A(l);
149
+ } catch (d) {
150
+ throw M(d);
151
+ }
152
+ }, P = async () => {
153
+ var l;
154
+ try {
155
+ await ((l = _(t)) == null ? void 0 : l.get().refetch());
156
+ } catch {
157
+ }
158
+ }, b = () => {
159
+ const l = Le(e);
160
+ try {
161
+ s == null || s.postMessage(l);
162
+ } catch {
163
+ }
164
+ try {
165
+ window.localStorage.setItem(K, l);
166
+ } catch {
129
167
  }
130
- }, w = (c) => {
131
- let a = !1, l = !1, P;
132
- const L = (h) => {
133
- h !== P && (P = h, c(h));
168
+ }, G = (l) => {
169
+ const o = Ee(l);
170
+ !o || o.source === e || P();
171
+ };
172
+ s == null || s.addEventListener("message", (l) => {
173
+ G(l.data);
174
+ }), typeof window < "u" && window.addEventListener("storage", (l) => {
175
+ l.key !== K || l.newValue === null || G(l.newValue);
176
+ });
177
+ const Y = async () => {
178
+ await P(), b();
179
+ }, we = (l) => {
180
+ let o = !1, d = !1, m;
181
+ const f = (h) => {
182
+ h !== m && (m = h, l(h));
134
183
  };
135
- o().then((h) => {
136
- a || (l = !0, L(h));
184
+ p().then((h) => {
185
+ o || (d = !0, f(h));
137
186
  }).catch(() => {
138
- a || (l = !0);
187
+ o || (d = !0);
139
188
  });
140
- const y = v(t);
141
- if (!y)
189
+ const g = _(t);
190
+ if (!g)
142
191
  return () => {
143
- a = !0;
192
+ o = !0;
144
193
  };
145
- const S = y.subscribe((h) => {
146
- if (a || !l || h.error && !h.data)
194
+ const v = g.subscribe((h) => {
195
+ if (o || !d || h.error && !h.data)
147
196
  return;
148
- const p = h.data ?? null;
149
- L(p);
197
+ const L = h.data ?? null;
198
+ f(L);
150
199
  });
151
200
  return () => {
152
- a = !0, S();
201
+ o = !0, v();
153
202
  };
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;
159
- try {
160
- await ((l = v(t)) == null ? void 0 : l.get().refetch());
161
- } catch {
203
+ }, fe = async (...l) => {
204
+ const o = await t.signOut(...l);
205
+ return o && typeof o == "object" && "error" in o && o.error || await Y(), o;
206
+ }, pe = (l) => new Proxy(l, {
207
+ get(o, d, m) {
208
+ const f = Reflect.get(o, d, m);
209
+ return typeof f != "function" ? f : async (...g) => {
210
+ const v = await f.apply(o, g);
211
+ return Se(v) && await Y(), v;
212
+ };
162
213
  }
163
- return a;
164
- };
214
+ });
165
215
  return new Proxy(t, {
166
- get(c, a, l) {
167
- return a === "requireSession" ? u : a === "onSessionChange" ? w : a === "signOut" ? E : Reflect.get(c, a, l);
216
+ get(l, o, d) {
217
+ if (o === "requireSession")
218
+ return T;
219
+ if (o === "onSessionChange")
220
+ return we;
221
+ if (o === "signOut")
222
+ return fe;
223
+ if (o === he)
224
+ return b;
225
+ if (o === "signIn" || o === "signUp") {
226
+ const m = Reflect.get(l, o, d);
227
+ return m && typeof m == "object" ? pe(m) : m;
228
+ }
229
+ return Reflect.get(l, o, d);
168
230
  }
169
231
  });
170
232
  }
171
- function he() {
172
- return re({ disableDefaultRedirectPlugin: !0 });
233
+ function Ce() {
234
+ return me({ disableDefaultRedirectPlugin: !0 });
173
235
  }
174
- function B(t) {
236
+ function O(t) {
175
237
  const e = (() => {
176
238
  if (t instanceof URL)
177
239
  return t;
178
240
  const s = t.trim();
179
241
  if (!s)
180
- throw new d("redirectTo must not be an empty string.");
242
+ throw new u("redirectTo must not be an empty string.");
181
243
  try {
182
244
  return new URL(s, window.location.href);
183
245
  } catch {
184
- throw new d(
246
+ throw new u(
185
247
  `redirectTo must be a valid relative path or URL. Received: ${JSON.stringify(t)}`
186
248
  );
187
249
  }
188
250
  })();
189
251
  if (e.protocol !== "http:" && e.protocol !== "https:")
190
- throw new d(
252
+ throw new u(
191
253
  `redirectTo must resolve to an http(s) URL. Received protocol: ${e.protocol}`
192
254
  );
193
255
  return e;
194
256
  }
195
- function me(t, e) {
257
+ function Ie(t, e) {
196
258
  return e ? {
197
259
  common: { ...t.common, ...e.common },
198
260
  signIn: { ...t.signIn, ...e.signIn },
@@ -204,7 +266,7 @@ function me(t, e) {
204
266
  errors: { ...t.errors, ...e.errors }
205
267
  } : t;
206
268
  }
207
- const $ = {
269
+ const B = {
208
270
  common: {
209
271
  loading: "Loading sign-in…",
210
272
  redirecting: "Redirecting…",
@@ -267,7 +329,7 @@ const $ = {
267
329
  invalidCode: "Enter the 6-digit verification code.",
268
330
  generic: "Something went wrong. Please try again."
269
331
  }
270
- }, k = {
332
+ }, V = {
271
333
  common: {
272
334
  loading: "加载中…",
273
335
  redirecting: "跳转中…",
@@ -330,7 +392,7 @@ const $ = {
330
392
  invalidCode: "请输入 6 位验证码",
331
393
  generic: "出现错误,请稍后重试"
332
394
  }
333
- }, x = {
395
+ }, J = {
334
396
  common: {
335
397
  loading: "サインインを読み込み中…",
336
398
  redirecting: "リダイレクト中…",
@@ -393,7 +455,7 @@ const $ = {
393
455
  invalidCode: "6桁の認証コードを入力してください",
394
456
  generic: "エラーが発生しました。もう一度お試しください"
395
457
  }
396
- }, W = {
458
+ }, Z = {
397
459
  common: {
398
460
  loading: "로그인 로딩 중…",
399
461
  redirecting: "리디렉션 중…",
@@ -456,7 +518,7 @@ const $ = {
456
518
  invalidCode: "6자리 인증 코드를 입력해 주세요",
457
519
  generic: "문제가 발생했습니다. 다시 시도해 주세요"
458
520
  }
459
- }, M = {
521
+ }, F = {
460
522
  common: {
461
523
  loading: "Cargando inicio de sesión…",
462
524
  redirecting: "Redirigiendo…",
@@ -519,7 +581,7 @@ const $ = {
519
581
  invalidCode: "Ingresa el código de verificación de 6 dígitos.",
520
582
  generic: "Algo salió mal. Por favor, inténtalo de nuevo."
521
583
  }
522
- }, j = {
584
+ }, Q = {
523
585
  common: {
524
586
  loading: "Carregando login…",
525
587
  redirecting: "Redirecionando…",
@@ -582,7 +644,7 @@ const $ = {
582
644
  invalidCode: "Insira o código de verificação de 6 dígitos.",
583
645
  generic: "Algo deu errado. Por favor, tente novamente."
584
646
  }
585
- }, G = {
647
+ }, X = {
586
648
  common: {
587
649
  loading: "Chargement de la connexion…",
588
650
  redirecting: "Redirection…",
@@ -645,7 +707,7 @@ const $ = {
645
707
  invalidCode: "Saisissez le code de vérification à 6 chiffres.",
646
708
  generic: "Une erreur est survenue. Veuillez réessayer."
647
709
  }
648
- }, Y = {
710
+ }, ee = {
649
711
  common: {
650
712
  loading: "Anmeldung wird geladen…",
651
713
  redirecting: "Weiterleitung…",
@@ -708,7 +770,7 @@ const $ = {
708
770
  invalidCode: "Geben Sie den 6-stelligen Bestätigungscode ein.",
709
771
  generic: "Etwas ist schiefgelaufen. Bitte versuchen Sie es erneut."
710
772
  }
711
- }, K = {
773
+ }, te = {
712
774
  common: {
713
775
  loading: "Caricamento accesso…",
714
776
  redirecting: "Reindirizzamento…",
@@ -771,7 +833,7 @@ const $ = {
771
833
  invalidCode: "Inserisci il codice di verifica a 6 cifre.",
772
834
  generic: "Qualcosa è andato storto. Riprova."
773
835
  }
774
- }, J = {
836
+ }, se = {
775
837
  common: {
776
838
  loading: "Загрузка входа…",
777
839
  redirecting: "Перенаправление…",
@@ -834,7 +896,7 @@ const $ = {
834
896
  invalidCode: "Введите 6-значный код подтверждения.",
835
897
  generic: "Произошла ошибка. Пожалуйста, попробуйте снова."
836
898
  }
837
- }, Z = {
899
+ }, ie = {
838
900
  common: {
839
901
  loading: "جارٍ تحميل تسجيل الدخول…",
840
902
  redirecting: "جارٍ إعادة التوجيه…",
@@ -897,7 +959,7 @@ const $ = {
897
959
  invalidCode: "يرجى إدخال رمز التحقّق المكوّن من 6 أرقام.",
898
960
  generic: "حدث خطأ. يرجى المحاولة مرة أخرى."
899
961
  }
900
- }, Q = {
962
+ }, ne = {
901
963
  common: {
902
964
  loading: "सधाइन की जुलातीअ लोड हो रही है…",
903
965
  redirecting: "रीडायरेक्ट हो रहا है…",
@@ -960,62 +1022,62 @@ const $ = {
960
1022
  invalidCode: "कृपया 6 अंकों का सत्यापन कोड दर्ज करें।",
961
1023
  generic: "कुछ गलत हो गई। कृपया फिर से प्रयास करें।"
962
1024
  }
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
1025
+ }, re = {
1026
+ en: B,
1027
+ "en-US": B,
1028
+ zh: V,
1029
+ "zh-CN": V,
1030
+ "zh-TW": V,
1031
+ ja: J,
1032
+ "ja-JP": J,
1033
+ ko: Z,
1034
+ "ko-KR": Z,
1035
+ es: F,
1036
+ "es-ES": F,
1037
+ "es-MX": F,
1038
+ pt: Q,
1039
+ "pt-BR": Q,
1040
+ fr: X,
1041
+ "fr-FR": X,
1042
+ de: ee,
1043
+ "de-DE": ee,
1044
+ it: te,
1045
+ "it-IT": te,
1046
+ ru: se,
1047
+ "ru-RU": se,
1048
+ ar: ie,
1049
+ "ar-SA": ie,
1050
+ hi: ne,
1051
+ "hi-IN": ne
990
1052
  };
991
- function we() {
1053
+ function Re() {
992
1054
  if (typeof navigator > "u")
993
- return $;
1055
+ return B;
994
1056
  const t = navigator.languages ?? [navigator.language];
995
1057
  for (const e of t) {
996
- const s = X[e] ?? X[e.split("-")[0]];
1058
+ const s = re[e] ?? re[e.split("-")[0]];
997
1059
  if (s) return s;
998
1060
  }
999
- return $;
1061
+ return B;
1000
1062
  }
1001
- function O(t, e = "Authentication failed.") {
1002
- if (t instanceof m)
1063
+ function N(t, e = "Authentication failed.") {
1064
+ if (t instanceof w)
1003
1065
  return t;
1004
1066
  if (typeof t == "object" && t !== null) {
1005
1067
  const s = t;
1006
- return new m(s.message || e, {
1068
+ return new w(s.message || e, {
1007
1069
  code: s.code,
1008
1070
  status: s.status,
1009
1071
  cause: t
1010
1072
  });
1011
1073
  }
1012
- return typeof t == "string" ? new m(t) : new m(e, { cause: t });
1074
+ return typeof t == "string" ? new w(t) : new w(e, { cause: t });
1013
1075
  }
1014
- async function V(t) {
1076
+ async function C(t) {
1015
1077
  var s, i;
1016
1078
  const e = await t.getSession();
1017
1079
  if (e.error)
1018
- throw new m(
1080
+ throw new w(
1019
1081
  e.error.message || "Failed to load the current session.",
1020
1082
  {
1021
1083
  code: e.error.code ?? "SESSION_LOOKUP_FAILED",
@@ -1031,7 +1093,7 @@ async function V(t) {
1031
1093
  session: null
1032
1094
  };
1033
1095
  }
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 = {
1096
+ const $e = "data-edgespark-auth", n = "edgespark-auth", z = "es_auth_completion", I = "es_auth_email", oe = "oauth", R = "verify-sign-in", S = "verify-sign-up", ae = 200, q = 2, D = {
1035
1097
  google: "Google",
1036
1098
  apple: "Apple",
1037
1099
  microsoft: "Microsoft",
@@ -1039,24 +1101,24 @@ const be = "data-edgespark-auth", n = "edgespark-auth", F = "es_auth_completion"
1039
1101
  gitlab: "GitLab",
1040
1102
  discord: "Discord"
1041
1103
  };
1042
- function T(t) {
1104
+ function $(t) {
1043
1105
  return "redirectTo" in t;
1044
1106
  }
1045
- function N(t) {
1107
+ function H(t) {
1046
1108
  return "onSuccess" in t && !("redirectTo" in t);
1047
1109
  }
1048
- function q(t) {
1110
+ function x(t) {
1049
1111
  return !t || typeof t != "string" ? !1 : /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(t.trim());
1050
1112
  }
1051
- function ge(t) {
1113
+ function Ue(t) {
1052
1114
  return /^\d{6}$/.test(t.trim());
1053
1115
  }
1054
- function ve(t) {
1116
+ function Ae(t) {
1055
1117
  return t === "email" || t === "name" || t === "password" || t === "confirmPassword" || t === "code" || t === "newPassword";
1056
1118
  }
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 = {
1119
+ class Be {
1120
+ constructor(e, s, i, r, a) {
1121
+ if (this.container = e, this.auth = s, this.options = i, this.loadConfig = r, this.runtimeOptions = a, this.state = {
1060
1122
  view: "loading",
1061
1123
  busy: !0,
1062
1124
  busyLabel: void 0,
@@ -1069,8 +1131,8 @@ class Pe {
1069
1131
  code: "",
1070
1132
  newPassword: ""
1071
1133
  }, 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))
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();
1134
+ throw new u("authUI.mount(container, options) requires a real HTMLElement container.");
1135
+ this.labels = Ie(Re(), i.labels), this.root = document.createElement("div"), this.root.setAttribute($e, ""), e.innerHTML = "", e.appendChild(this.root), this.render(), this.initialize();
1074
1136
  }
1075
1137
  destroy() {
1076
1138
  this.destroyed || (this.destroyed = !0, this.clearCountdown(), this.clearFocusRestoreTimer(), this.container.innerHTML = "");
@@ -1079,17 +1141,17 @@ class Pe {
1079
1141
  try {
1080
1142
  const e = this.consumeManagedReturnContext(), [s, i] = await Promise.all([
1081
1143
  this.loadConfig(),
1082
- V(this.auth)
1144
+ this.readMountSession(e)
1083
1145
  ]);
1084
1146
  if (this.destroyed)
1085
1147
  return;
1086
1148
  if (this.config = s, i.user && i.session) {
1087
1149
  switch (e.marker) {
1088
- case ee:
1089
- case C:
1150
+ case oe:
1151
+ case R:
1090
1152
  await this.completeAuth("sign-in", i);
1091
1153
  return;
1092
- case g:
1154
+ case S:
1093
1155
  await this.completeAuth("sign-up", i);
1094
1156
  return;
1095
1157
  default:
@@ -1105,6 +1167,27 @@ class Pe {
1105
1167
  this.handleError(e, "Failed to load the authentication UI.");
1106
1168
  }
1107
1169
  }
1170
+ async readMountSession(e) {
1171
+ if (!e.marker)
1172
+ return C(this.auth);
1173
+ let s = null;
1174
+ for (let i = 0; i <= q; i++) {
1175
+ try {
1176
+ const r = await C(this.auth);
1177
+ if (r.user && r.session)
1178
+ return r;
1179
+ } catch (r) {
1180
+ s = r;
1181
+ }
1182
+ i < q && await new Promise((r) => setTimeout(r, ae));
1183
+ }
1184
+ if (s)
1185
+ throw s;
1186
+ return {
1187
+ user: null,
1188
+ session: null
1189
+ };
1190
+ }
1108
1191
  render() {
1109
1192
  if (this.destroyed)
1110
1193
  return;
@@ -1305,13 +1388,13 @@ class Pe {
1305
1388
  <div class="${n}__stack">
1306
1389
  ${e.map((i) => `
1307
1390
  <button class="${n}__button ${n}__button--secondary" type="button" data-action="oauth" data-provider="${i}" ${this.state.busy ? "disabled" : ""}>
1308
- ${this.escape(`${this.labels.oauth.continueWith} ${z[i]}`)}
1391
+ ${this.escape(`${this.labels.oauth.continueWith} ${D[i]}`)}
1309
1392
  </button>
1310
1393
  `).join("")}
1311
1394
  </div>
1312
1395
  `;
1313
1396
  }
1314
- renderInput(e, s, i, r, o) {
1397
+ renderInput(e, s, i, r, a) {
1315
1398
  return `
1316
1399
  <label class="${n}__field">
1317
1400
  <span class="${n}__label">${this.escape(s)}</span>
@@ -1320,7 +1403,7 @@ class Pe {
1320
1403
  name="${this.escape(e)}"
1321
1404
  type="${this.escape(i)}"
1322
1405
  value="${this.escape(r)}"
1323
- autocomplete="${this.escape(o)}"
1406
+ autocomplete="${this.escape(a)}"
1324
1407
  ${this.state.busy ? "disabled" : ""}
1325
1408
  />
1326
1409
  </label>
@@ -1328,19 +1411,19 @@ class Pe {
1328
1411
  }
1329
1412
  bindDOM() {
1330
1413
  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();
1414
+ r.addEventListener("submit", (a) => {
1415
+ a.preventDefault();
1416
+ const c = r.dataset.view;
1417
+ c === "sign-in" && this.handleSignIn(), c === "sign-up" && this.handleSignUp(), c === "forgot-password" && this.handleForgotPassword(), c === "reset-password" && this.handleResetPassword();
1335
1418
  });
1336
1419
  }), this.root.querySelectorAll("input[name]").forEach((r) => {
1337
1420
  r.addEventListener("input", () => {
1338
- ve(r.name) && (this.state[r.name] = r.value);
1421
+ Ae(r.name) && (this.state[r.name] = r.value);
1339
1422
  });
1340
1423
  }), this.root.querySelectorAll("[data-action]").forEach((r) => {
1341
1424
  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);
1425
+ const a = r.dataset.action;
1426
+ 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(r.dataset.provider);
1344
1427
  });
1345
1428
  });
1346
1429
  }
@@ -1348,7 +1431,7 @@ class Pe {
1348
1431
  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();
1349
1432
  }
1350
1433
  async handleSignIn() {
1351
- if (!q(this.state.email)) {
1434
+ if (!x(this.state.email)) {
1352
1435
  this.failValidation(this.labels.errors.invalidEmail);
1353
1436
  return;
1354
1437
  }
@@ -1360,7 +1443,7 @@ class Pe {
1360
1443
  const e = await this.auth.signIn.email({
1361
1444
  email: this.state.email.trim(),
1362
1445
  password: this.state.password,
1363
- callbackURL: this.getManagedReturnURL(C, this.state.email.trim())
1446
+ callbackURL: this.getManagedReturnURL(R, this.state.email.trim())
1364
1447
  });
1365
1448
  if (e.error)
1366
1449
  throw e.error;
@@ -1373,7 +1456,7 @@ class Pe {
1373
1456
  this.failValidation(this.labels.errors.requiredField);
1374
1457
  return;
1375
1458
  }
1376
- if (!q(this.state.email)) {
1459
+ if (!x(this.state.email)) {
1377
1460
  this.failValidation(this.labels.errors.invalidEmail);
1378
1461
  return;
1379
1462
  }
@@ -1397,7 +1480,7 @@ class Pe {
1397
1480
  name: this.state.name.trim(),
1398
1481
  email: this.state.email.trim(),
1399
1482
  password: this.state.password,
1400
- callbackURL: this.getManagedReturnURL(g, this.state.email.trim())
1483
+ callbackURL: this.getManagedReturnURL(S, this.state.email.trim())
1401
1484
  });
1402
1485
  if (i.error)
1403
1486
  throw i.error;
@@ -1409,7 +1492,7 @@ class Pe {
1409
1492
  });
1410
1493
  }
1411
1494
  async handleOAuthSignIn(e) {
1412
- await this.runAction(`Redirecting to ${z[e]}…`, async () => {
1495
+ await this.runAction(`Redirecting to ${D[e]}…`, async () => {
1413
1496
  const s = await this.auth.signIn.social({
1414
1497
  provider: e,
1415
1498
  callbackURL: this.getManagedReturnURL("oauth"),
@@ -1419,18 +1502,18 @@ class Pe {
1419
1502
  throw s.error;
1420
1503
  const i = this.extractRedirectURL(s.data);
1421
1504
  if (!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);
1505
+ throw new u(`OAuth sign-in did not return a redirect URL for provider "${e}".`);
1506
+ this.terminalActionInProgress = !0, this.state.busy = !0, this.state.busyLabel = `Opening ${D[e]}…`, this.state.error = null, this.state.notice = null, this.render(), window.location.assign(i);
1424
1507
  });
1425
1508
  }
1426
1509
  async handleForgotPassword() {
1427
1510
  if (!this.canUsePasswordResetEmailOtp()) {
1428
1511
  this.handleError(
1429
- new d("Password reset via email OTP is not enabled for this project.")
1512
+ new u("Password reset via email OTP is not enabled for this project.")
1430
1513
  );
1431
1514
  return;
1432
1515
  }
1433
- if (!q(this.state.email)) {
1516
+ if (!x(this.state.email)) {
1434
1517
  this.failValidation(this.labels.errors.invalidEmail);
1435
1518
  return;
1436
1519
  }
@@ -1450,11 +1533,11 @@ class Pe {
1450
1533
  var e, s;
1451
1534
  if (!this.canUsePasswordResetEmailOtp()) {
1452
1535
  this.handleError(
1453
- new d("Password reset via email OTP is not enabled for this project.")
1536
+ new u("Password reset via email OTP is not enabled for this project.")
1454
1537
  );
1455
1538
  return;
1456
1539
  }
1457
- if (!ge(this.state.code)) {
1540
+ if (!Ue(this.state.code)) {
1458
1541
  this.failValidation(this.labels.errors.invalidCode);
1459
1542
  return;
1460
1543
  }
@@ -1491,7 +1574,7 @@ class Pe {
1491
1574
  const s = await this.auth.sendVerificationEmail({
1492
1575
  email: this.state.email.trim(),
1493
1576
  callbackURL: this.getManagedReturnURL(
1494
- this.verificationCompletionAction === "sign-up" ? g : C,
1577
+ this.verificationCompletionAction === "sign-up" ? S : R,
1495
1578
  this.state.email.trim()
1496
1579
  )
1497
1580
  });
@@ -1505,12 +1588,12 @@ class Pe {
1505
1588
  s ?? await this.resolveAuthCompletionData()
1506
1589
  );
1507
1590
  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());
1591
+ if (i.lookupError && $(this.options)) {
1592
+ 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(O(this.options.redirectTo).toString());
1510
1593
  return;
1511
1594
  }
1512
1595
  if (e === "sign-in")
1513
- throw i.lookupError ?? new se(
1596
+ throw i.lookupError ?? new de(
1514
1597
  "Managed sign-in completed without an authenticated session."
1515
1598
  );
1516
1599
  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();
@@ -1521,11 +1604,11 @@ class Pe {
1521
1604
  user: i.user,
1522
1605
  session: i.session
1523
1606
  };
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());
1607
+ if (await this.syncPublicSessionBestEffort(), $(this.options)) {
1608
+ 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(O(this.options.redirectTo).toString());
1526
1609
  return;
1527
1610
  }
1528
- if (N(this.options)) {
1611
+ if (H(this.options)) {
1529
1612
  this.destroy(), this.options.onSuccess(r);
1530
1613
  return;
1531
1614
  }
@@ -1534,10 +1617,10 @@ class Pe {
1534
1617
  if (e.session)
1535
1618
  return e;
1536
1619
  let s = e.lookupError;
1537
- for (let i = 0; i < fe; i++) {
1538
- await new Promise((r) => setTimeout(r, pe));
1620
+ for (let i = 0; i < q; i++) {
1621
+ await new Promise((r) => setTimeout(r, ae));
1539
1622
  try {
1540
- const r = await V(this.auth);
1623
+ const r = await C(this.auth);
1541
1624
  if (r.user && r.session)
1542
1625
  return {
1543
1626
  user: r.user,
@@ -1561,7 +1644,7 @@ class Pe {
1561
1644
  }
1562
1645
  async resolveAuthCompletionData(e) {
1563
1646
  try {
1564
- const s = await V(this.auth), i = this.extractUser(e);
1647
+ const s = await C(this.auth), i = this.extractUser(e);
1565
1648
  return {
1566
1649
  user: s.user ?? i,
1567
1650
  session: s.session
@@ -1580,19 +1663,19 @@ class Pe {
1580
1663
  user: null,
1581
1664
  session: null
1582
1665
  };
1583
- if (N(this.options)) {
1666
+ if (H(this.options)) {
1584
1667
  this.destroy(), this.options.onSuccess(e);
1585
1668
  return;
1586
1669
  }
1587
1670
  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();
1588
1671
  }
1589
1672
  handleExistingSessionOnMount(e) {
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());
1673
+ if ($(this.options)) {
1674
+ 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(O(this.options.redirectTo).toString());
1592
1675
  return;
1593
1676
  }
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(
1677
+ if (H(this.options))
1678
+ throw this.state.view = "sign-in", this.state.busy = !1, this.state.busyLabel = void 0, this.state.notice = null, new u(
1596
1679
  "authUI.mount(container, { onSuccess }) cannot run while a session already exists. Check es.auth.getSession() before mounting controlled auth UI."
1597
1680
  );
1598
1681
  }
@@ -1609,28 +1692,28 @@ class Pe {
1609
1692
  !this.destroyed && !this.terminalActionInProgress && (this.state.busy = !1, this.state.busyLabel = void 0, this.render());
1610
1693
  }
1611
1694
  maybeHandleVerificationRequired(e) {
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);
1695
+ return N(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);
1613
1696
  }
1614
1697
  handleVerificationEmailSent(e, s) {
1615
1698
  this.state.notice = s ? `We sent another verification email to ${e}.` : `We sent a verification email to ${e}.`, this.startCountdown();
1616
1699
  }
1617
1700
  invokeRedirectModeSuccessHook(e) {
1618
1701
  var s, i;
1619
- if (!(!T(this.options) || !this.options.onSuccess))
1702
+ if (!(!$(this.options) || !this.options.onSuccess))
1620
1703
  try {
1621
1704
  this.options.onSuccess(e);
1622
1705
  } catch (r) {
1623
- const o = O(r, "Post-auth callback failed.");
1706
+ const a = N(r, "Post-auth callback failed.");
1624
1707
  try {
1625
- (i = (s = this.options).onError) == null || i.call(s, o);
1708
+ (i = (s = this.options).onError) == null || i.call(s, a);
1626
1709
  } catch {
1627
1710
  }
1628
1711
  }
1629
1712
  }
1630
1713
  handleError(e, s) {
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);
1714
+ var r, a;
1715
+ const i = N(e, s);
1716
+ this.state.busy = !1, this.state.busyLabel = void 0, this.state.error = i.message, this.render(), (a = (r = this.options).onError) == null || a.call(r, i);
1634
1717
  }
1635
1718
  failValidation(e) {
1636
1719
  this.state.error = e, this.state.notice = null, this.render();
@@ -1639,15 +1722,15 @@ class Pe {
1639
1722
  if (!e)
1640
1723
  return window.location.href;
1641
1724
  const i = new URL(window.location.href);
1642
- return i.searchParams.set(F, e), s ? i.searchParams.set(_, s) : i.searchParams.delete(_), i.toString();
1725
+ return i.searchParams.set(z, e), s ? i.searchParams.set(I, s) : i.searchParams.delete(I), i.toString();
1643
1726
  }
1644
1727
  consumeManagedReturnContext() {
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())), {
1728
+ const e = new URL(window.location.href), s = e.searchParams.get(z), i = e.searchParams.get(I), r = s ? e.searchParams.get("error") : null, a = s ? e.searchParams.get("error_description") : null;
1729
+ return (s || i) && (e.searchParams.delete(z), e.searchParams.delete(I), s && (e.searchParams.delete("error"), e.searchParams.delete("error_description")), window.history.replaceState(null, "", e.toString())), {
1647
1730
  marker: s,
1648
1731
  email: i,
1649
1732
  error: r,
1650
- errorDescription: o
1733
+ errorDescription: a
1651
1734
  };
1652
1735
  }
1653
1736
  startCountdown(e = 60) {
@@ -1711,10 +1794,10 @@ class Pe {
1711
1794
  return !!((e = this.config) != null && e.passwordResetEmailOtpEnabled);
1712
1795
  }
1713
1796
  handleSessionlessManagedReturn(e) {
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(
1797
+ return e.email && (this.state.email = e.email), e.marker === S && !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 === R || e.marker === S ? (this.verificationCompletionAction = e.marker === S ? "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(
1715
1798
  e.errorDescription ?? "Verification failed. Request a new verification email and try again.",
1716
1799
  { code: e.error ?? "VERIFY_EMAIL_ERROR" }
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(
1800
+ )) : this.render(), !0) : e.marker === oe && (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(
1718
1801
  e.errorDescription ?? "OAuth sign-in failed.",
1719
1802
  { code: e.error ?? "OAUTH_ERROR" }
1720
1803
  )), !0) : !1;
@@ -1733,103 +1816,103 @@ class Pe {
1733
1816
  return e.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;");
1734
1817
  }
1735
1818
  }
1736
- function Le(t) {
1819
+ function ke(t) {
1737
1820
  return "data" in t && t.data ? t.data : t;
1738
1821
  }
1739
- const ye = [
1822
+ const Me = [
1740
1823
  { id: "google", key: "providerGoogle" },
1741
1824
  { id: "apple", key: "providerApple" },
1742
1825
  { id: "microsoft", key: "providerMicrosoft" },
1743
1826
  { id: "github", key: "providerGithub" },
1744
1827
  { id: "gitlab", key: "providerGitlab" },
1745
1828
  { id: "discord", key: "providerDiscord" }
1746
- ], te = 2, Ee = 500;
1747
- async function Se() {
1748
- const t = `${window.location.origin}${ne}/config`;
1829
+ ], le = 2, Oe = 500;
1830
+ async function Ve() {
1831
+ const t = `${window.location.origin}${ue}/config`;
1749
1832
  let e;
1750
- for (let s = 0; s <= te; s++)
1833
+ for (let s = 0; s <= le; s++)
1751
1834
  try {
1752
1835
  const i = await fetch(t, { method: "GET", credentials: "include" });
1753
1836
  if (!i.ok)
1754
- throw new d(`Failed to load auth config: HTTP ${i.status}`);
1837
+ throw new u(`Failed to load auth config: HTTP ${i.status}`);
1755
1838
  const r = await i.json();
1756
- return Ce(Le(r));
1839
+ return Ne(ke(r));
1757
1840
  } catch (i) {
1758
- e = i, s < te && await new Promise((r) => setTimeout(r, Ee));
1841
+ e = i, s < le && await new Promise((r) => setTimeout(r, Oe));
1759
1842
  }
1760
1843
  throw e;
1761
1844
  }
1762
- let I = null;
1763
- async function _e() {
1764
- return I || (I = Se().catch((t) => {
1765
- throw I = null, t;
1766
- })), I;
1845
+ let U = null;
1846
+ async function Fe() {
1847
+ return U || (U = Ve().catch((t) => {
1848
+ throw U = null, t;
1849
+ })), U;
1767
1850
  }
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);
1851
+ function Ne(t) {
1852
+ var s, i, r, a, c, p, T;
1853
+ const e = Me.filter(({ key: P }) => {
1854
+ const b = t[P];
1855
+ return typeof b == "object" && b !== null && "enabled" in b && !!b.enabled;
1856
+ }).map(({ id: P }) => P);
1774
1857
  return {
1775
1858
  disableSignUp: !!t.disableSignUp,
1776
1859
  emailPasswordEnabled: !!((s = t.providerEmailPassword) != null && s.enabled),
1777
1860
  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),
1861
+ requireEmailVerification: !!((c = (a = t.providerEmailPassword) == null ? void 0 : a.config) != null && c.requireEmailVerification),
1862
+ passwordResetEmailOtpEnabled: !!((T = (p = t.providerEmailPassword) == null ? void 0 : p.config) != null && T.requirePasswordResetEmailVerification),
1780
1863
  oauthProviders: e
1781
1864
  };
1782
1865
  }
1783
- const R = /* @__PURE__ */ new WeakMap();
1784
- function Te(t) {
1866
+ const A = /* @__PURE__ */ new WeakMap();
1867
+ function ze(t) {
1785
1868
  if (!t)
1786
- throw new d(
1869
+ throw new u(
1787
1870
  "authUI.mount(container, options) requires either { redirectTo } or { onSuccess }."
1788
1871
  );
1789
1872
  const e = "redirectTo" in t, s = "onSuccess" in t && typeof t.onSuccess == "function";
1790
1873
  if (!e && !s)
1791
- throw new d(
1874
+ throw new u(
1792
1875
  "authUI.mount(container, options) requires either { redirectTo } or { onSuccess }."
1793
1876
  );
1794
1877
  if ("redirectTo" in t) {
1795
1878
  const i = t.redirectTo;
1796
1879
  if (!(typeof i == "string" || i instanceof URL))
1797
- throw new d(
1880
+ throw new u(
1798
1881
  "authUI.mount(container, options) expected redirectTo to be a string or URL."
1799
1882
  );
1800
1883
  }
1801
1884
  if ("onSuccess" in t && t.onSuccess !== void 0 && typeof t.onSuccess != "function")
1802
- throw new d(
1885
+ throw new u(
1803
1886
  "authUI.mount(container, options) expected onSuccess to be a function."
1804
1887
  );
1805
1888
  if ("onError" in t && t.onError !== void 0 && typeof t.onError != "function")
1806
- throw new d(
1889
+ throw new u(
1807
1890
  "authUI.mount(container, options) expected onError to be a function."
1808
1891
  );
1809
1892
  }
1810
- function Ie(t) {
1893
+ function qe(t) {
1811
1894
  if (!(t instanceof HTMLElement))
1812
- throw new d("authUI.mount(container, options) requires a real HTMLElement container.");
1895
+ throw new u("authUI.mount(container, options) requires a real HTMLElement container.");
1813
1896
  }
1814
- function Re(t, e) {
1897
+ function De(t, e) {
1815
1898
  return {
1816
1899
  mount(s, i) {
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 = {
1900
+ var p;
1901
+ ze(i), qe(s), (p = A.get(s)) == null || p.destroy();
1902
+ const r = new Be(s, t, i, Fe, e), a = r.destroy.bind(r), c = {
1820
1903
  destroy() {
1821
- o(), R.get(s) === u && R.delete(s);
1904
+ a(), A.get(s) === c && A.delete(s);
1822
1905
  }
1823
1906
  };
1824
- return R.set(s, u), u;
1907
+ return A.set(s, c), c;
1825
1908
  }
1826
1909
  };
1827
1910
  }
1828
- function Ue() {
1829
- ie();
1830
- const t = ue(), e = he(), s = de(), i = Re(e, {
1911
+ function xe() {
1912
+ ce();
1913
+ const t = Te(), e = Ce(), s = ye(), i = De(e, {
1831
1914
  syncPublicSession: async () => {
1832
- await ce(t);
1915
+ await _e(t);
1833
1916
  }
1834
1917
  });
1835
1918
  return {
@@ -1839,22 +1922,22 @@ function Ue() {
1839
1922
  };
1840
1923
  }
1841
1924
  export {
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
1925
+ w as EdgeSparkAuthError,
1926
+ u as EdgeSparkConfigError,
1927
+ j as EdgeSparkError,
1928
+ de as EdgeSparkRuntimeError,
1929
+ ie as ar,
1930
+ xe as createEdgeSpark,
1931
+ ee as de,
1932
+ Re as detectLocale,
1933
+ B as enUS,
1934
+ F as es,
1935
+ X as fr,
1936
+ ne as hi,
1937
+ te as it,
1938
+ J as ja,
1939
+ Z as ko,
1940
+ Q as ptBR,
1941
+ se as ru,
1942
+ V as zhCN
1860
1943
  };