@edgespark/web 0.0.5 → 0.0.7

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,67 +1,67 @@
1
- import { createAuthClient as He } from "better-auth/client";
2
- class le extends Error {
3
- constructor(e, s) {
4
- super(s), this.name = "EdgeSparkError", this.code = e;
1
+ import { createAuthClient as ze } from "better-auth/client";
2
+ class ae extends Error {
3
+ constructor(e, i) {
4
+ super(i), this.name = "EdgeSparkError", this.code = e;
5
5
  }
6
6
  }
7
- class b extends le {
7
+ class b extends ae {
8
8
  constructor(e) {
9
9
  super("CONFIG_ERROR", e), this.name = "EdgeSparkConfigError";
10
10
  }
11
11
  }
12
- class Ue extends le {
12
+ class $e extends ae {
13
13
  constructor(e) {
14
14
  super("RUNTIME_ERROR", e), this.name = "EdgeSparkRuntimeError";
15
15
  }
16
16
  }
17
- class L extends le {
18
- constructor(e, s) {
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;
17
+ class L extends ae {
18
+ constructor(e, i) {
19
+ super((i == null ? void 0 : i.code) ?? "AUTH_ERROR", e), this.name = "EdgeSparkAuthError", this.cause = i == null ? void 0 : i.cause, this.status = i == null ? void 0 : i.status;
20
20
  }
21
21
  }
22
- function de(t, e = "Authentication failed.", s) {
22
+ function le(t, e = "Authentication failed.", i) {
23
23
  if (t instanceof L)
24
24
  return t;
25
25
  if (typeof t == "object" && t !== null) {
26
- const i = t;
27
- return new L(i.message || e, {
28
- code: i.code ?? s,
29
- status: i.status,
26
+ const s = t;
27
+ return new L(s.message || e, {
28
+ code: s.code ?? i,
29
+ status: s.status,
30
30
  cause: t
31
31
  });
32
32
  }
33
- return typeof t == "string" ? new L(t, { code: s }) : new L(e, { code: s, cause: t });
33
+ return typeof t == "string" ? new L(t, { code: i }) : new L(e, { code: i, cause: t });
34
34
  }
35
- function $e() {
35
+ function Ue() {
36
36
  if (typeof window > "u" || typeof document > "u")
37
- throw new Ue(
37
+ throw new $e(
38
38
  "@edgespark/web is browser-only. Create the client from a real browser runtime."
39
39
  );
40
40
  }
41
- function oe() {
42
- return $e(), window.location.origin;
41
+ function re() {
42
+ return Ue(), window.location.origin;
43
43
  }
44
- function ze(t) {
44
+ function Ge(t) {
45
45
  return t instanceof URL ? t : typeof t == "string" ? new URL(t, window.location.href) : new URL(t.url, window.location.href);
46
46
  }
47
- function xe(t) {
48
- if (t.origin !== oe())
47
+ function He(t) {
48
+ if (t.origin !== re())
49
49
  throw new b(
50
- `Cross-origin requests are not supported by this SDK. Received ${t.origin}, expected ${oe()}.`
50
+ `Cross-origin requests are not supported by this SDK. Received ${t.origin}, expected ${re()}.`
51
51
  );
52
52
  }
53
53
  function je() {
54
54
  return {
55
55
  async fetch(t, e) {
56
- const s = ze(t);
57
- return xe(s), fetch(t, {
56
+ const i = Ge(t);
57
+ return He(i), fetch(t, {
58
58
  ...e,
59
59
  credentials: "include"
60
60
  });
61
61
  }
62
62
  };
63
63
  }
64
- const ke = "/api/_es/auth", qe = "edgespark-auth-session", Oe = "__edgespark_auth_sync__", q = "__edgespark_auth_pending_sign_in__", Be = Symbol("edgespark.notifyAuthTabs"), We = 10 * 60 * 1e3, Ke = /* @__PURE__ */ new Set([
64
+ const ke = "/api/_es/auth", qe = "edgespark-auth-session", Oe = "__edgespark_auth_sync__", q = "__edgespark_auth_pending_sign_in__", Be = Symbol("edgespark.notifyAuthTabs"), Ke = 10 * 60 * 1e3, We = /* @__PURE__ */ new Set([
65
65
  "signOut",
66
66
  "revokeSession",
67
67
  "revokeSessions",
@@ -88,14 +88,14 @@ class Je {
88
88
  return this.value;
89
89
  }
90
90
  }
91
- const ue = globalThis.WeakRef, he = globalThis.FinalizationRegistry;
92
- let W, me = !1;
93
- const M = /* @__PURE__ */ new Map(), K = he ? new he((t) => {
91
+ const ce = globalThis.WeakRef, ue = globalThis.FinalizationRegistry;
92
+ let K, he = !1;
93
+ const M = /* @__PURE__ */ new Map(), W = ue ? new ue((t) => {
94
94
  M.delete(t);
95
95
  }) : null;
96
96
  function Me(t) {
97
- return He({
98
- baseURL: oe(),
97
+ return ze({
98
+ baseURL: re(),
99
99
  basePath: ke,
100
100
  ...t != null && t.disableDefaultRedirectPlugin ? { disableDefaultFetchPlugins: !0 } : {},
101
101
  fetchOptions: {
@@ -104,8 +104,8 @@ function Me(t) {
104
104
  });
105
105
  }
106
106
  function B(t) {
107
- var e, s;
108
- return (s = (e = t.$store) == null ? void 0 : e.atoms) == null ? void 0 : s.session;
107
+ var e, i;
108
+ return (i = (e = t.$store) == null ? void 0 : e.atoms) == null ? void 0 : i.session;
109
109
  }
110
110
  function Xe(t) {
111
111
  return JSON.stringify({
@@ -127,12 +127,12 @@ function Qe(t) {
127
127
  return t.join(".");
128
128
  }
129
129
  function et(t) {
130
- const e = Qe(t), s = Ye.get(e);
131
- return s ? new L(s, {
130
+ const e = Qe(t), i = Ye.get(e);
131
+ return i ? new L(i, {
132
132
  code: "UNSUPPORTED_AUTH_METHOD"
133
133
  }) : null;
134
134
  }
135
- async function ae(t) {
135
+ async function oe(t) {
136
136
  var e;
137
137
  try {
138
138
  return await ((e = B(t)) == null ? void 0 : e.get().refetch()), !0;
@@ -141,42 +141,42 @@ async function ae(t) {
141
141
  }
142
142
  }
143
143
  function De() {
144
- return W === void 0 && (W = typeof BroadcastChannel < "u" ? new BroadcastChannel(qe) : null), W;
144
+ return K === void 0 && (K = typeof BroadcastChannel < "u" ? new BroadcastChannel(qe) : null), K;
145
145
  }
146
- function fe(t) {
146
+ function me(t) {
147
147
  const e = Ze(t);
148
148
  if (e)
149
- for (const [s, i] of M) {
150
- if (s === e.source)
149
+ for (const [i, s] of M) {
150
+ if (i === e.source)
151
151
  continue;
152
- const n = i.deref();
152
+ const n = s.deref();
153
153
  if (!n) {
154
- M.delete(s);
154
+ M.delete(i);
155
155
  continue;
156
156
  }
157
- ae(n);
157
+ oe(n);
158
158
  }
159
159
  }
160
160
  function tt() {
161
161
  var t;
162
- me || (me = !0, (t = De()) == null || t.addEventListener("message", (e) => {
163
- fe(e.data);
162
+ he || (he = !0, (t = De()) == null || t.addEventListener("message", (e) => {
163
+ me(e.data);
164
164
  }), typeof window < "u" && window.addEventListener("storage", (e) => {
165
- e.key !== Oe || e.newValue === null || fe(e.newValue);
165
+ e.key !== Oe || e.newValue === null || me(e.newValue);
166
166
  }));
167
167
  }
168
- function st(t, e) {
169
- ue ? M.set(t, new ue(e)) : (M.clear(), M.set(t, new Je(e))), K == null || K.register(e, t), tt();
168
+ function it(t, e) {
169
+ ce ? M.set(t, new ce(e)) : (M.clear(), M.set(t, new Je(e))), W == null || W.register(e, t), tt();
170
170
  }
171
171
  function k(t) {
172
- const e = Xe(t), s = De();
173
- let i = !1;
174
- if (s)
172
+ const e = Xe(t), i = De();
173
+ let s = !1;
174
+ if (i)
175
175
  try {
176
- s.postMessage(e), i = !0;
176
+ i.postMessage(e), s = !0;
177
177
  } catch {
178
178
  }
179
- if (!i)
179
+ if (!s)
180
180
  try {
181
181
  window.localStorage.setItem(Oe, e);
182
182
  } catch {
@@ -202,38 +202,38 @@ function O() {
202
202
  } catch {
203
203
  }
204
204
  }
205
- function it(t) {
205
+ function st(t) {
206
206
  return !!(t != null && t.session && (t != null && t.user));
207
207
  }
208
- function v(t) {
208
+ function y(t) {
209
209
  return t instanceof Date ? t.toISOString() : t === null || typeof t == "string" || typeof t == "number" || typeof t == "boolean" ? t : t == null ? null : String(t);
210
210
  }
211
211
  function nt(t) {
212
212
  return t ? JSON.stringify({
213
213
  session: {
214
- createdAt: v(t.session.createdAt),
215
- expiresAt: v(t.session.expiresAt),
216
- id: v(t.session.id),
217
- impersonatedBy: v(t.session.impersonatedBy),
218
- ipAddress: v(t.session.ipAddress),
219
- token: v(t.session.token),
220
- updatedAt: v(t.session.updatedAt),
221
- userAgent: v(t.session.userAgent),
222
- userId: v(t.session.userId)
214
+ createdAt: y(t.session.createdAt),
215
+ expiresAt: y(t.session.expiresAt),
216
+ id: y(t.session.id),
217
+ impersonatedBy: y(t.session.impersonatedBy),
218
+ ipAddress: y(t.session.ipAddress),
219
+ token: y(t.session.token),
220
+ updatedAt: y(t.session.updatedAt),
221
+ userAgent: y(t.session.userAgent),
222
+ userId: y(t.session.userId)
223
223
  },
224
224
  user: {
225
- banExpires: v(t.user.banExpires),
226
- banReason: v(t.user.banReason),
227
- banned: v(t.user.banned),
228
- createdAt: v(t.user.createdAt),
229
- email: v(t.user.email),
230
- emailVerified: v(t.user.emailVerified),
231
- id: v(t.user.id),
232
- image: v(t.user.image),
233
- lastLoginAt: v(t.user.lastLoginAt),
234
- name: v(t.user.name),
235
- role: v(t.user.role),
236
- updatedAt: v(t.user.updatedAt)
225
+ banExpires: y(t.user.banExpires),
226
+ banReason: y(t.user.banReason),
227
+ banned: y(t.user.banned),
228
+ createdAt: y(t.user.createdAt),
229
+ email: y(t.user.email),
230
+ emailVerified: y(t.user.emailVerified),
231
+ id: y(t.user.id),
232
+ image: y(t.user.image),
233
+ lastLoginAt: y(t.user.lastLoginAt),
234
+ name: y(t.user.name),
235
+ role: y(t.user.role),
236
+ updatedAt: y(t.user.updatedAt)
237
237
  }
238
238
  }) : "__null__";
239
239
  }
@@ -245,12 +245,12 @@ function Ne() {
245
245
  if (!t)
246
246
  return null;
247
247
  const e = JSON.parse(t);
248
- return !e || typeof e != "object" || typeof e.createdAt != "number" || Date.now() - e.createdAt > We ? null : { createdAt: e.createdAt };
248
+ return !e || typeof e != "object" || typeof e.createdAt != "number" || Date.now() - e.createdAt > Ke ? null : { createdAt: e.createdAt };
249
249
  } catch {
250
250
  return null;
251
251
  }
252
252
  }
253
- function ge() {
253
+ function fe() {
254
254
  if (!Ne())
255
255
  return !1;
256
256
  try {
@@ -275,7 +275,7 @@ function at(t) {
275
275
  return e && typeof e == "object" ? "url" in e && typeof e.url == "string" : !1;
276
276
  }
277
277
  function lt(t) {
278
- if ($(t) || !(t && typeof t == "object"))
278
+ if (U(t) || !(t && typeof t == "object"))
279
279
  return !1;
280
280
  const e = "data" in t ? t.data : t;
281
281
  return e && typeof e == "object" ? "user" in e && !!e.user && "token" in e && e.token === null && !("url" in e) : !1;
@@ -283,14 +283,14 @@ function lt(t) {
283
283
  function dt(t, e) {
284
284
  if (t.length !== 1 || t[0] !== "changePassword")
285
285
  return !1;
286
- const [s] = e;
287
- return !!(s && typeof s == "object" && "revokeOtherSessions" in s && s.revokeOtherSessions === !0);
286
+ const [i] = e;
287
+ return !!(i && typeof i == "object" && "revokeOtherSessions" in i && i.revokeOtherSessions === !0);
288
288
  }
289
- function $(t) {
289
+ function U(t) {
290
290
  return !!(t && typeof t == "object" && "error" in t && t.error);
291
291
  }
292
292
  function ct(t) {
293
- if ($(t) || !(t && typeof t == "object"))
293
+ if (U(t) || !(t && typeof t == "object"))
294
294
  return !1;
295
295
  const e = "data" in t ? t.data : t;
296
296
  return e && typeof e == "object" ? "message" in e && e.message === "User deleted" : !1;
@@ -299,58 +299,58 @@ function ut(t) {
299
299
  return !!(t && (typeof t == "object" || typeof t == "function") && "then" in t && typeof t.then == "function");
300
300
  }
301
301
  function J(t) {
302
- return de(t, "Failed to load the current session.", "SESSION_LOOKUP_FAILED");
302
+ return le(t, "Failed to load the current session.", "SESSION_LOOKUP_FAILED");
303
303
  }
304
304
  async function ht(t) {
305
- var s, i;
305
+ var i, s;
306
306
  let e = null;
307
307
  try {
308
- await ((s = B(t)) == null ? void 0 : s.get().refetch());
308
+ await ((i = B(t)) == null ? void 0 : i.get().refetch());
309
309
  } catch (n) {
310
310
  e = n;
311
311
  } finally {
312
- (i = t[Be]) == null || i.call(t);
312
+ (s = t[Be]) == null || s.call(t);
313
313
  }
314
314
  if (e)
315
315
  throw e;
316
316
  }
317
317
  function mt() {
318
318
  const t = Me(), e = `${Date.now()}-${Math.random().toString(36).slice(2)}`;
319
- st(e, t);
320
- const s = 2, i = 500;
321
- let n = null, o = !1, c;
322
- const h = (a) => (c = a, a), p = () => {
319
+ it(e, t);
320
+ const i = 2, s = 500;
321
+ let n = null, o = !1, l;
322
+ const h = (a) => (l = a, a), f = () => {
323
323
  var m;
324
324
  const a = (m = B(t)) == null ? void 0 : m.get();
325
- return a != null && a.error && !a.data && c !== void 0 ? c : (a == null ? void 0 : a.data) ?? c ?? null;
326
- }, P = () => o ? Promise.resolve(p()) : (n || (n = (async () => {
327
- var d, f, T;
325
+ return a != null && a.error && !a.data && l !== void 0 ? l : (a == null ? void 0 : a.data) ?? l ?? null;
326
+ }, P = () => o ? Promise.resolve(f()) : (n || (n = (async () => {
327
+ var c, g, C;
328
328
  let a = !1, m = null;
329
329
  try {
330
- for (let I = 0; I <= s; I++) {
330
+ for (let _ = 0; _ <= i; _++) {
331
331
  let u = null;
332
332
  try {
333
333
  u = await t.getSession();
334
- } catch (C) {
335
- m = C;
334
+ } catch (T) {
335
+ m = T;
336
336
  }
337
- const E = ((d = B(t)) == null ? void 0 : d.get().data) ?? null;
338
- if ((f = u == null ? void 0 : u.data) != null && f.session && ((T = u.data) != null && T.user))
339
- return o = !0, ge() && k(e), h(u.data);
337
+ const E = ((c = B(t)) == null ? void 0 : c.get().data) ?? null;
338
+ if ((g = u == null ? void 0 : u.data) != null && g.session && ((C = u.data) != null && C.user))
339
+ return o = !0, fe() && k(e), h(u.data);
340
340
  if (E != null && E.session && (E != null && E.user))
341
- return o = !0, ge() && k(e), h(E);
342
- if (u != null && u.error ? m = u.error : u && (a = !0), u && !u.error && rt() && I < s) {
341
+ return o = !0, fe() && k(e), h(E);
342
+ if (u != null && u.error ? m = u.error : u && (a = !0), u && !u.error && rt() && _ < i) {
343
343
  await new Promise(
344
- (C) => setTimeout(C, i)
344
+ (T) => setTimeout(T, s)
345
345
  );
346
346
  continue;
347
347
  }
348
348
  if (u && !u.error) {
349
- const C = p();
350
- return o = !0, h(C);
349
+ const T = f();
350
+ return o = !0, h(T);
351
351
  }
352
- I < s && await new Promise(
353
- (C) => setTimeout(C, i)
352
+ _ < i && await new Promise(
353
+ (T) => setTimeout(T, s)
354
354
  );
355
355
  }
356
356
  if (!a)
@@ -358,10 +358,10 @@ function mt() {
358
358
  code: "SESSION_LOOKUP_FAILED",
359
359
  cause: m
360
360
  });
361
- const y = p();
362
- return o = !0, h(y);
363
- } catch (y) {
364
- throw n = null, J(y);
361
+ const v = f();
362
+ return o = !0, h(v);
363
+ } catch (v) {
364
+ throw n = null, J(v);
365
365
  }
366
366
  })()), n);
367
367
  P().catch(() => {
@@ -369,92 +369,92 @@ function mt() {
369
369
  const w = async () => {
370
370
  var a, m;
371
371
  try {
372
- const d = await t.getSession();
373
- if ((a = d.data) != null && a.session && ((m = d.data) != null && m.user))
374
- return d.data;
375
- throw d.error ? J(d.error) : new L("No authenticated session is available.", {
372
+ const c = await t.getSession();
373
+ if ((a = c.data) != null && a.session && ((m = c.data) != null && m.user))
374
+ return c.data;
375
+ throw c.error ? J(c.error) : new L("No authenticated session is available.", {
376
376
  code: "UNAUTHENTICATED"
377
377
  });
378
- } catch (d) {
379
- throw J(d);
378
+ } catch (c) {
379
+ throw J(c);
380
380
  }
381
- }, g = async () => {
382
- await ae(t), k(e);
381
+ }, p = async () => {
382
+ await oe(t), k(e);
383
383
  }, S = async () => {
384
- var d;
385
- const a = await ae(t), m = ((d = B(t)) == null ? void 0 : d.get().data) ?? null;
386
- it(m) ? (O(), k(e)) : a || k(e);
387
- }, l = (a) => {
388
- let m = !1, d = !1, f;
389
- const T = (u) => {
384
+ var c;
385
+ const a = await oe(t), m = ((c = B(t)) == null ? void 0 : c.get().data) ?? null;
386
+ st(m) ? (O(), k(e)) : a || k(e);
387
+ }, d = (a) => {
388
+ let m = !1, c = !1, g;
389
+ const C = (u) => {
390
390
  const E = nt(u);
391
- E !== f && (f = E, a(u));
391
+ E !== g && (g = E, a(u));
392
392
  };
393
393
  P().then((u) => {
394
- m || (d = !0, T(h(u)));
394
+ m || (c = !0, C(h(u)));
395
395
  }).catch(() => {
396
- m || (d = !0);
396
+ m || (c = !0);
397
397
  });
398
- const y = B(t);
399
- if (!y)
398
+ const v = B(t);
399
+ if (!v)
400
400
  return () => {
401
401
  m = !0;
402
402
  };
403
- const I = y.subscribe((u) => {
404
- if (m || !d || u.error && !u.data)
403
+ const _ = v.subscribe((u) => {
404
+ if (m || !c || u.error && !u.data)
405
405
  return;
406
406
  const E = u.data ?? null;
407
- T(h(E));
407
+ C(h(E));
408
408
  });
409
409
  return () => {
410
- m = !0, I();
410
+ m = !0, _();
411
411
  };
412
- }, _ = async (a, m, d) => {
413
- const f = a[0], T = a.length >= 2 && f === "emailOtp" && a[1] === "verifyEmail", y = a.length >= 2 && f === "emailOtp" && a[1] === "resetPassword", I = a.length >= 2 && f === "resetPassword" && a[1] === "emailOtp", u = a.length >= 2 && f === "oneTap" && a[1] === "callback";
414
- return a.length === 1 && (f === "deleteUser" || f === "deleteUserCallback") ? (O(), ct(d) && await g(), d) : a.length === 1 && f && Ke.has(f) ? (O(), $(d) || await g(), d) : dt(a, m) && !$(d) ? (O(), await g(), d) : (y || I) && !$(d) ? (O(), await g(), d) : a.length === 1 && f === "changeEmail" && !$(d) ? (await g(), d) : ((f === "signIn" || f === "signUp" || T || u) && ot(d) ? (O(), await g()) : (f === "signIn" || f === "signUp") && at(d) || f === "signUp" && lt(d) ? Y(a) : f === "verifyEmail" && !$(d) && (Y(a), await S()), d);
412
+ }, I = async (a, m, c) => {
413
+ const g = a[0], C = a.length >= 2 && g === "emailOtp" && a[1] === "verifyEmail", v = a.length >= 2 && g === "emailOtp" && a[1] === "resetPassword", _ = a.length >= 2 && g === "resetPassword" && a[1] === "emailOtp", u = a.length >= 2 && g === "oneTap" && a[1] === "callback";
414
+ return a.length === 1 && (g === "deleteUser" || g === "deleteUserCallback") ? (O(), ct(c) && await p(), c) : a.length === 1 && g && We.has(g) ? (O(), U(c) || await p(), c) : dt(a, m) && !U(c) ? (O(), await p(), c) : (v || _) && !U(c) ? (O(), await p(), c) : a.length === 1 && g === "changeEmail" && !U(c) ? (await p(), c) : ((g === "signIn" || g === "signUp" || C || u) && ot(c) ? (O(), await p()) : (g === "signIn" || g === "signUp") && at(c) || g === "signUp" && lt(c) ? Y(a) : g === "verifyEmail" && !U(c) && (Y(a), await S()), c);
415
415
  }, A = /* @__PURE__ */ new WeakMap(), D = (a, m) => {
416
416
  if (!a || typeof a != "object" && typeof a != "function")
417
417
  return a;
418
- const d = A.get(a);
419
- if (d)
420
- return d;
421
- const f = new Proxy(a, {
422
- get(T, y, I) {
418
+ const c = A.get(a);
419
+ if (c)
420
+ return c;
421
+ const g = new Proxy(a, {
422
+ get(C, v, _) {
423
423
  if (m.length === 0) {
424
- if (y === "requireSession")
424
+ if (v === "requireSession")
425
425
  return w;
426
- if (y === "onSessionChange")
427
- return l;
428
- if (y === Be)
426
+ if (v === "onSessionChange")
427
+ return d;
428
+ if (v === Be)
429
429
  return () => {
430
430
  k(e);
431
431
  };
432
432
  }
433
- const u = Reflect.get(T, y, I);
434
- return typeof y != "string" ? u : D(u, [...m, y]);
433
+ const u = Reflect.get(C, v, _);
434
+ return typeof v != "string" ? u : D(u, [...m, v]);
435
435
  },
436
- apply(T, y, I) {
436
+ apply(C, v, _) {
437
437
  const u = et(m);
438
438
  if (u)
439
439
  throw u;
440
440
  const E = Reflect.apply(
441
- T,
442
- y,
443
- I
441
+ C,
442
+ v,
443
+ _
444
444
  );
445
445
  return ut(E) ? Promise.resolve(E).then(
446
- (C) => _(m, I, C)
446
+ (T) => I(m, _, T)
447
447
  ) : E;
448
448
  }
449
449
  });
450
- return A.set(a, f), f;
450
+ return A.set(a, g), g;
451
451
  };
452
452
  return D(t, []);
453
453
  }
454
454
  function ft() {
455
455
  return Me({ disableDefaultRedirectPlugin: !0 });
456
456
  }
457
- const ce = "/api/_es/dev";
457
+ const de = "/api/_es/dev";
458
458
  function gt() {
459
459
  if (typeof document > "u") return !1;
460
460
  const t = document.querySelector('meta[name="edgespark-local-dev"]');
@@ -463,21 +463,21 @@ function gt() {
463
463
  async function pt(t) {
464
464
  const e = typeof window < "u" ? window.location.origin : "";
465
465
  if (!e) return !1;
466
- const s = await fetch(
467
- `${e}${ce}/auto-verify?email=${encodeURIComponent(t)}`,
466
+ const i = await fetch(
467
+ `${e}${de}/auto-verify?email=${encodeURIComponent(t)}`,
468
468
  { credentials: "include" }
469
469
  );
470
- return s.ok ? (await s.json()).verified === !0 : !1;
470
+ return i.ok ? (await i.json()).verified === !0 : !1;
471
471
  }
472
472
  async function wt(t) {
473
473
  const e = typeof window < "u" ? window.location.origin : "";
474
474
  if (!e) return null;
475
475
  try {
476
- const s = await fetch(
477
- `${e}${ce}/pending-otp?email=${encodeURIComponent(t)}`,
476
+ const i = await fetch(
477
+ `${e}${de}/pending-otp?email=${encodeURIComponent(t)}`,
478
478
  { credentials: "include" }
479
479
  );
480
- return s.ok ? (await s.json()).otp ?? null : null;
480
+ return i.ok ? (await i.json()).otp ?? null : null;
481
481
  } catch {
482
482
  return null;
483
483
  }
@@ -486,24 +486,24 @@ async function bt(t) {
486
486
  const e = typeof window < "u" ? window.location.origin : "";
487
487
  if (!e) return null;
488
488
  try {
489
- const s = await fetch(
490
- `${e}${ce}/pending-sign-in-otp?email=${encodeURIComponent(t)}`,
489
+ const i = await fetch(
490
+ `${e}${de}/pending-sign-in-otp?email=${encodeURIComponent(t)}`,
491
491
  { credentials: "include" }
492
492
  );
493
- return s.ok ? (await s.json()).otp ?? null : null;
493
+ return i.ok ? (await i.json()).otp ?? null : null;
494
494
  } catch {
495
495
  return null;
496
496
  }
497
497
  }
498
- function vt(t) {
498
+ function yt(t) {
499
499
  const e = (() => {
500
500
  if (t instanceof URL)
501
501
  return t;
502
- const s = t.trim();
503
- if (!s)
502
+ const i = t.trim();
503
+ if (!i)
504
504
  throw new b("redirectTo must not be an empty string.");
505
505
  try {
506
- return new URL(s, window.location.href);
506
+ return new URL(i, window.location.href);
507
507
  } catch {
508
508
  throw new b(
509
509
  `redirectTo must be a valid relative path or URL. Received: ${JSON.stringify(t)}`
@@ -516,7 +516,7 @@ function vt(t) {
516
516
  );
517
517
  return e;
518
518
  }
519
- function yt(t, e) {
519
+ function vt(t, e) {
520
520
  return e ? {
521
521
  common: { ...t.common, ...e.common },
522
522
  signIn: { ...t.signIn, ...e.signIn },
@@ -535,6 +535,10 @@ const j = {
535
535
  backToSignIn: "Back to sign in"
536
536
  },
537
537
  signIn: {
538
+ emailPlaceholder: "you@mail.com",
539
+ codePlaceholder: "Sign-in code sent to your email",
540
+ sendingCode: "Sending sign-in code…",
541
+ signingIn: "Signing in…",
538
542
  title: "Welcome back",
539
543
  subtitle: "Sign in to continue",
540
544
  emailLabel: "Email",
@@ -582,6 +586,7 @@ const j = {
582
586
  resendCountdown: "Resend in {seconds}s"
583
587
  },
584
588
  oauth: {
589
+ redirecting: "Redirecting to {provider}…",
585
590
  dividerText: "or",
586
591
  continueWith: "Continue with"
587
592
  },
@@ -600,6 +605,10 @@ const j = {
600
605
  backToSignIn: "返回登录"
601
606
  },
602
607
  signIn: {
608
+ emailPlaceholder: "you@mail.com",
609
+ codePlaceholder: "登录验证码已发送至你的邮箱",
610
+ sendingCode: "正在发送登录验证码…",
611
+ signingIn: "正在登录…",
603
612
  title: "欢迎回来",
604
613
  subtitle: "登录以继续",
605
614
  emailLabel: "邮箱",
@@ -645,6 +654,7 @@ const j = {
645
654
  resendCountdown: "{seconds}秒后可重发"
646
655
  },
647
656
  oauth: {
657
+ redirecting: "正在跳转至 {provider}…",
648
658
  dividerText: "或",
649
659
  continueWith: "使用"
650
660
  },
@@ -656,13 +666,17 @@ const j = {
656
666
  invalidCode: "请输入 6 位验证码",
657
667
  generic: "出现错误,请稍后重试"
658
668
  }
659
- }, pe = {
669
+ }, ge = {
660
670
  common: {
661
671
  loading: "サインインを読み込み中…",
662
672
  redirecting: "リダイレクト中…",
663
673
  backToSignIn: "サインインに戻る"
664
674
  },
665
675
  signIn: {
676
+ emailPlaceholder: "you@mail.com",
677
+ codePlaceholder: "ログインコードをメールに送信しました",
678
+ sendingCode: "ログインコードを送信中…",
679
+ signingIn: "ログイン中…",
666
680
  title: "おかえりなさい",
667
681
  subtitle: "サインインして続行",
668
682
  emailLabel: "メールアドレス",
@@ -708,6 +722,7 @@ const j = {
708
722
  resendCountdown: "{seconds}秒後に再送信可能"
709
723
  },
710
724
  oauth: {
725
+ redirecting: "{provider} に移動中…",
711
726
  dividerText: "または",
712
727
  continueWith: "で続行"
713
728
  },
@@ -719,13 +734,17 @@ const j = {
719
734
  invalidCode: "6桁の認証コードを入力してください",
720
735
  generic: "エラーが発生しました。もう一度お試しください"
721
736
  }
722
- }, we = {
737
+ }, pe = {
723
738
  common: {
724
739
  loading: "로그인 로딩 중…",
725
740
  redirecting: "리디렉션 중…",
726
741
  backToSignIn: "로그인으로 돌아가기"
727
742
  },
728
743
  signIn: {
744
+ emailPlaceholder: "you@mail.com",
745
+ codePlaceholder: "로그인 코드를 이메일로 보냈습니다",
746
+ sendingCode: "로그인 코드 전송 중…",
747
+ signingIn: "로그인 중…",
729
748
  title: "다시 오신 것을 환영합니다",
730
749
  subtitle: "로그인하여 계속하기",
731
750
  emailLabel: "이메일",
@@ -771,6 +790,7 @@ const j = {
771
790
  resendCountdown: "{seconds}초 후 재발송 가능"
772
791
  },
773
792
  oauth: {
793
+ redirecting: "{provider}(으)로 이동 중…",
774
794
  dividerText: "또는",
775
795
  continueWith: "으로 계속"
776
796
  },
@@ -789,6 +809,10 @@ const j = {
789
809
  backToSignIn: "Volver a iniciar sesión"
790
810
  },
791
811
  signIn: {
812
+ emailPlaceholder: "you@mail.com",
813
+ codePlaceholder: "Código de acceso enviado a tu correo",
814
+ sendingCode: "Enviando código de acceso…",
815
+ signingIn: "Iniciando sesión…",
792
816
  title: "Bienvenido de nuevo",
793
817
  subtitle: "Inicia sesión para continuar",
794
818
  emailLabel: "Correo electrónico",
@@ -834,6 +858,7 @@ const j = {
834
858
  resendCountdown: "Reenviar en {seconds}s"
835
859
  },
836
860
  oauth: {
861
+ redirecting: "Redirigiendo a {provider}…",
837
862
  dividerText: "o",
838
863
  continueWith: "Continuar con"
839
864
  },
@@ -845,13 +870,17 @@ const j = {
845
870
  invalidCode: "Ingresa el código de verificación de 6 dígitos.",
846
871
  generic: "Algo salió mal. Por favor, inténtalo de nuevo."
847
872
  }
848
- }, be = {
873
+ }, we = {
849
874
  common: {
850
875
  loading: "Carregando login…",
851
876
  redirecting: "Redirecionando…",
852
877
  backToSignIn: "Voltar para o login"
853
878
  },
854
879
  signIn: {
880
+ emailPlaceholder: "you@mail.com",
881
+ codePlaceholder: "Código de acesso enviado por e-mail",
882
+ sendingCode: "Enviando código de acesso…",
883
+ signingIn: "Entrando…",
855
884
  title: "Bem-vindo de volta",
856
885
  subtitle: "Faça login para continuar",
857
886
  emailLabel: "E-mail",
@@ -897,6 +926,7 @@ const j = {
897
926
  resendCountdown: "Reenviar em {seconds}s"
898
927
  },
899
928
  oauth: {
929
+ redirecting: "Redirecionando para {provider}…",
900
930
  dividerText: "ou",
901
931
  continueWith: "Continuar com"
902
932
  },
@@ -908,13 +938,17 @@ const j = {
908
938
  invalidCode: "Insira o código de verificação de 6 dígitos.",
909
939
  generic: "Algo deu errado. Por favor, tente novamente."
910
940
  }
911
- }, ve = {
941
+ }, be = {
912
942
  common: {
913
943
  loading: "Chargement de la connexion…",
914
944
  redirecting: "Redirection…",
915
945
  backToSignIn: "Retour à la connexion"
916
946
  },
917
947
  signIn: {
948
+ emailPlaceholder: "you@mail.com",
949
+ codePlaceholder: "Code de connexion envoyé par e-mail",
950
+ sendingCode: "Envoi du code de connexion…",
951
+ signingIn: "Connexion en cours…",
918
952
  title: "Bon retour",
919
953
  subtitle: "Connectez-vous pour continuer",
920
954
  emailLabel: "Adresse e-mail",
@@ -960,6 +994,7 @@ const j = {
960
994
  resendCountdown: "Renvoyer dans {seconds}s"
961
995
  },
962
996
  oauth: {
997
+ redirecting: "Redirection vers {provider}…",
963
998
  dividerText: "ou",
964
999
  continueWith: "Continuer avec"
965
1000
  },
@@ -978,6 +1013,10 @@ const j = {
978
1013
  backToSignIn: "Zurück zur Anmeldung"
979
1014
  },
980
1015
  signIn: {
1016
+ emailPlaceholder: "you@mail.com",
1017
+ codePlaceholder: "Anmeldecode wurde per E-Mail gesendet",
1018
+ sendingCode: "Anmeldecode wird gesendet…",
1019
+ signingIn: "Anmeldung läuft…",
981
1020
  title: "Willkommen zurück",
982
1021
  subtitle: "Melden Sie sich an, um fortzufahren",
983
1022
  emailLabel: "E-Mail-Adresse",
@@ -1023,6 +1062,7 @@ const j = {
1023
1062
  resendCountdown: "Erneut senden in {seconds}s"
1024
1063
  },
1025
1064
  oauth: {
1065
+ redirecting: "Weiterleitung zu {provider}…",
1026
1066
  dividerText: "oder",
1027
1067
  continueWith: "Weiter mit"
1028
1068
  },
@@ -1034,13 +1074,17 @@ const j = {
1034
1074
  invalidCode: "Geben Sie den 6-stelligen Bestätigungscode ein.",
1035
1075
  generic: "Etwas ist schiefgelaufen. Bitte versuchen Sie es erneut."
1036
1076
  }
1037
- }, Se = {
1077
+ }, ve = {
1038
1078
  common: {
1039
1079
  loading: "Caricamento accesso…",
1040
1080
  redirecting: "Reindirizzamento…",
1041
1081
  backToSignIn: "Torna all’accesso"
1042
1082
  },
1043
1083
  signIn: {
1084
+ emailPlaceholder: "you@mail.com",
1085
+ codePlaceholder: "Codice di accesso inviato alla tua e-mail",
1086
+ sendingCode: "Invio del codice di accesso…",
1087
+ signingIn: "Accesso in corso…",
1044
1088
  title: "Bentornato",
1045
1089
  subtitle: "Accedi per continuare",
1046
1090
  emailLabel: "Indirizzo e-mail",
@@ -1086,6 +1130,7 @@ const j = {
1086
1130
  resendCountdown: "Reinvia tra {seconds}s"
1087
1131
  },
1088
1132
  oauth: {
1133
+ redirecting: "Reindirizzamento a {provider}…",
1089
1134
  dividerText: "oppure",
1090
1135
  continueWith: "Continua con"
1091
1136
  },
@@ -1097,13 +1142,17 @@ const j = {
1097
1142
  invalidCode: "Inserisci il codice di verifica a 6 cifre.",
1098
1143
  generic: "Qualcosa è andato storto. Riprova."
1099
1144
  }
1100
- }, Ee = {
1145
+ }, Se = {
1101
1146
  common: {
1102
1147
  loading: "Загрузка входа…",
1103
1148
  redirecting: "Перенаправление…",
1104
1149
  backToSignIn: "Вернуться ко входу"
1105
1150
  },
1106
1151
  signIn: {
1152
+ emailPlaceholder: "you@mail.com",
1153
+ codePlaceholder: "Код входа отправлен на вашу почту",
1154
+ sendingCode: "Отправка кода входа…",
1155
+ signingIn: "Вход…",
1107
1156
  title: "С возвращением",
1108
1157
  subtitle: "Войдите, чтобы продолжить",
1109
1158
  emailLabel: "Электронная почта",
@@ -1149,6 +1198,7 @@ const j = {
1149
1198
  resendCountdown: "Повторная отправка через {seconds}с"
1150
1199
  },
1151
1200
  oauth: {
1201
+ redirecting: "Переход в {provider}…",
1152
1202
  dividerText: "или",
1153
1203
  continueWith: "Продолжить через"
1154
1204
  },
@@ -1160,13 +1210,17 @@ const j = {
1160
1210
  invalidCode: "Введите 6-значный код подтверждения.",
1161
1211
  generic: "Произошла ошибка. Пожалуйста, попробуйте снова."
1162
1212
  }
1163
- }, Pe = {
1213
+ }, Ee = {
1164
1214
  common: {
1165
1215
  loading: "جارٍ تحميل تسجيل الدخول…",
1166
1216
  redirecting: "جارٍ إعادة التوجيه…",
1167
1217
  backToSignIn: "العودة إلى تسجيل الدخول"
1168
1218
  },
1169
1219
  signIn: {
1220
+ emailPlaceholder: "you@mail.com",
1221
+ codePlaceholder: "تم إرسال رمز تسجيل الدخول إلى بريدك الإلكتروني",
1222
+ sendingCode: "جارٍ إرسال رمز تسجيل الدخول…",
1223
+ signingIn: "جارٍ تسجيل الدخول…",
1170
1224
  title: "مرحبًا بعودتك",
1171
1225
  subtitle: "سجّل الدخول للمتابعة",
1172
1226
  emailLabel: "البريد الإلكتروني",
@@ -1212,6 +1266,7 @@ const j = {
1212
1266
  resendCountdown: "إعادة الإرسال خلال {seconds} ثانية"
1213
1267
  },
1214
1268
  oauth: {
1269
+ redirecting: "جارٍ الانتقال إلى {provider}…",
1215
1270
  dividerText: "أو",
1216
1271
  continueWith: "المتابعة باستخدام"
1217
1272
  },
@@ -1223,13 +1278,17 @@ const j = {
1223
1278
  invalidCode: "يرجى إدخال رمز التحقّق المكوّن من 6 أرقام.",
1224
1279
  generic: "حدث خطأ. يرجى المحاولة مرة أخرى."
1225
1280
  }
1226
- }, _e = {
1281
+ }, Pe = {
1227
1282
  common: {
1228
1283
  loading: "सधाइन की जुलातीअ लोड हो रही है…",
1229
1284
  redirecting: "रीडायरेक्ट हो रहا है…",
1230
1285
  backToSignIn: "साइन इन पर वापस जाएँ"
1231
1286
  },
1232
1287
  signIn: {
1288
+ emailPlaceholder: "you@mail.com",
1289
+ codePlaceholder: "साइन-इन कोड आपके ईमेल पर भेज दिया गया है",
1290
+ sendingCode: "साइन-इन कोड भेजा जा रहा है…",
1291
+ signingIn: "साइन इन हो रहा है…",
1233
1292
  title: "वापसी आपका स्वागत है",
1234
1293
  subtitle: "जारी रखने के लिए साइन इन करें",
1235
1294
  emailLabel: "ईमेल",
@@ -1275,6 +1334,7 @@ const j = {
1275
1334
  resendCountdown: "{seconds} सेकंड में फिर से भेजें"
1276
1335
  },
1277
1336
  oauth: {
1337
+ redirecting: "{provider} पर भेजा जा रहा है…",
1278
1338
  dividerText: "या",
1279
1339
  continueWith: "से जारी रखें"
1280
1340
  },
@@ -1292,42 +1352,42 @@ const j = {
1292
1352
  zh: X,
1293
1353
  "zh-CN": X,
1294
1354
  "zh-TW": X,
1295
- ja: pe,
1296
- "ja-JP": pe,
1297
- ko: we,
1298
- "ko-KR": we,
1355
+ ja: ge,
1356
+ "ja-JP": ge,
1357
+ ko: pe,
1358
+ "ko-KR": pe,
1299
1359
  es: Z,
1300
1360
  "es-ES": Z,
1301
1361
  "es-MX": Z,
1302
- pt: be,
1303
- "pt-BR": be,
1304
- fr: ve,
1305
- "fr-FR": ve,
1362
+ pt: we,
1363
+ "pt-BR": we,
1364
+ fr: be,
1365
+ "fr-FR": be,
1306
1366
  de: ye,
1307
1367
  "de-DE": ye,
1308
- it: Se,
1309
- "it-IT": Se,
1310
- ru: Ee,
1311
- "ru-RU": Ee,
1312
- ar: Pe,
1313
- "ar-SA": Pe,
1314
- hi: _e,
1315
- "hi-IN": _e
1368
+ it: ve,
1369
+ "it-IT": ve,
1370
+ ru: Se,
1371
+ "ru-RU": Se,
1372
+ ar: Ee,
1373
+ "ar-SA": Ee,
1374
+ hi: Pe,
1375
+ "hi-IN": Pe
1316
1376
  };
1317
1377
  function St() {
1318
1378
  if (typeof navigator > "u")
1319
1379
  return j;
1320
1380
  const t = navigator.languages ?? [navigator.language];
1321
1381
  for (const e of t) {
1322
- const s = Ie[e] ?? Ie[e.split("-")[0]];
1323
- if (s) return s;
1382
+ const i = Ie[e] ?? Ie[e.split("-")[0]];
1383
+ if (i) return i;
1324
1384
  }
1325
1385
  return j;
1326
1386
  }
1327
1387
  const Ve = {
1328
1388
  LIGHT: "light",
1329
1389
  DARK: "dark"
1330
- }, Fe = Ve.LIGHT, Et = Ve.DARK, Ge = [Fe, Et], Pt = Fe, _t = {
1390
+ }, Fe = Ve.LIGHT, Et = Ve.DARK, xe = [Fe, Et], Pt = Fe, It = {
1331
1391
  BACKGROUND: "--edgespark-auth-bg",
1332
1392
  BACKGROUND_MUTED: "--edgespark-auth-bg-muted",
1333
1393
  CARD_BACKGROUND: "--edgespark-auth-card-bg",
@@ -1347,16 +1407,16 @@ const Ve = {
1347
1407
  MODAL_BACKDROP: "--edgespark-auth-modal-backdrop",
1348
1408
  MODAL_CARD_BACKGROUND: "--edgespark-auth-modal-card-bg",
1349
1409
  MODAL_SHADOW: "--edgespark-auth-modal-shadow"
1350
- }, It = Object.values(
1351
- _t
1410
+ }, _t = Object.values(
1411
+ It
1352
1412
  );
1353
1413
  function Lt(t) {
1354
- return typeof t == "string" && Ge.includes(t);
1414
+ return typeof t == "string" && xe.includes(t);
1355
1415
  }
1356
1416
  function At(t) {
1357
- return It.includes(t);
1417
+ return _t.includes(t);
1358
1418
  }
1359
- function Tt(t) {
1419
+ function Ct(t) {
1360
1420
  var e;
1361
1421
  return {
1362
1422
  theme: (t == null ? void 0 : t.theme) ?? Pt,
@@ -1365,10 +1425,10 @@ function Tt(t) {
1365
1425
  };
1366
1426
  }
1367
1427
  function Q(t, e = "Authentication failed.") {
1368
- return de(t, e);
1428
+ return le(t, e);
1369
1429
  }
1370
1430
  async function V(t) {
1371
- var s, i;
1431
+ var i, s;
1372
1432
  const e = await t.getSession();
1373
1433
  if (e.error)
1374
1434
  throw new L(
@@ -1379,7 +1439,7 @@ async function V(t) {
1379
1439
  cause: e.error
1380
1440
  }
1381
1441
  );
1382
- return (s = e.data) != null && s.user && ((i = e.data) != null && i.session) ? {
1442
+ return (i = e.data) != null && i.user && ((s = e.data) != null && s.session) ? {
1383
1443
  user: e.data.user,
1384
1444
  session: e.data
1385
1445
  } : {
@@ -1387,13 +1447,14 @@ async function V(t) {
1387
1447
  session: null
1388
1448
  };
1389
1449
  }
1390
- const Ct = "data-edgespark-auth", Rt = "data-edgespark-auth-theme", r = "edgespark-auth", ee = "es_auth_completion", F = "es_auth_email", te = "oauth", N = "verify-sign-in", R = "verify-sign-up", Le = 200, se = 2, Ut = {
1450
+ let Tt = 0;
1451
+ const Rt = "data-edgespark-auth", $t = "data-edgespark-auth-theme", r = "edgespark-auth", ee = "es_auth_completion", F = "es_auth_email", te = "oauth", N = "verify-sign-in", R = "verify-sign-up", _e = 200, ie = 2, Ut = {
1391
1452
  "&": "&amp;",
1392
1453
  "<": "&lt;",
1393
1454
  ">": "&gt;",
1394
1455
  '"': "&quot;",
1395
1456
  "'": "&#39;"
1396
- }, ie = {
1457
+ }, Le = {
1397
1458
  google: "Google",
1398
1459
  apple: "Apple",
1399
1460
  microsoft: "Microsoft",
@@ -1401,27 +1462,27 @@ const Ct = "data-edgespark-auth", Rt = "data-edgespark-auth-theme", r = "edgespa
1401
1462
  gitlab: "GitLab",
1402
1463
  discord: "Discord"
1403
1464
  };
1404
- function U(t) {
1465
+ function $(t) {
1405
1466
  return "redirectTo" in t;
1406
1467
  }
1407
- function ne(t) {
1468
+ function se(t) {
1408
1469
  return "onSuccess" in t && !("redirectTo" in t);
1409
1470
  }
1410
- function G(t) {
1471
+ function x(t) {
1411
1472
  return !t || typeof t != "string" ? !1 : /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(t.trim());
1412
1473
  }
1413
1474
  function Ae(t) {
1414
1475
  return /^\d{6}$/.test(t.trim());
1415
1476
  }
1416
- function $t(t) {
1477
+ function kt(t) {
1417
1478
  return t === "email" || t === "name" || t === "password" || t === "confirmPassword" || t === "code" || t === "newPassword";
1418
1479
  }
1419
- function kt(t) {
1480
+ function Ot(t) {
1420
1481
  return !!(t.error || t.errorDescription);
1421
1482
  }
1422
- class Ot {
1423
- constructor(e, s, i, n, o) {
1424
- this.container = e, this.auth = s, this.options = i, this.loadConfig = n, this.runtimeOptions = o, this.state = {
1483
+ class Bt {
1484
+ constructor(e, i, s, n, o) {
1485
+ this.container = e, this.auth = i, this.options = s, this.loadConfig = n, this.runtimeOptions = o, this.fieldIdPrefix = `edgespark-auth-${++Tt}`, this.state = {
1425
1486
  view: "loading",
1426
1487
  busy: !0,
1427
1488
  busyLabel: void 0,
@@ -1436,10 +1497,10 @@ class Ot {
1436
1497
  signInMethod: "password",
1437
1498
  signInOtpSent: !1
1438
1499
  }, this.destroyed = !1, this.terminalActionInProgress = !1, this.config = null, this.countdownUntil = null, this.countdownTimer = null, this.pendingFocusSnapshot = null, this.focusRestoreTimer = null, this.verificationCompletionAction = null;
1439
- const c = Tt(i.appearance);
1440
- this.labels = yt(St(), i.labels), this.root = document.createElement("div"), this.root.className = c.className ? `${r} ${c.className}` : r, this.root.setAttribute(Ct, ""), this.root.setAttribute(Rt, c.theme);
1441
- for (const [h, p] of Object.entries(c.variables))
1442
- p !== void 0 && this.root.style.setProperty(h, p);
1500
+ const l = Ct(s.appearance);
1501
+ this.labels = vt(St(), s.labels), this.root = document.createElement("div"), this.root.className = l.className ? `${r} ${l.className}` : r, this.root.setAttribute(Rt, ""), this.root.setAttribute($t, l.theme);
1502
+ for (const [h, f] of Object.entries(l.variables))
1503
+ f !== void 0 && this.root.style.setProperty(h, f);
1443
1504
  e.appendChild(this.root), this.render(), this.initialize();
1444
1505
  }
1445
1506
  destroy() {
@@ -1448,19 +1509,19 @@ class Ot {
1448
1509
  async initialize() {
1449
1510
  const e = this.consumeManagedReturnContext();
1450
1511
  try {
1451
- const [s, i] = await Promise.allSettled([
1512
+ const [i, s] = await Promise.allSettled([
1452
1513
  this.loadConfig(),
1453
1514
  this.readMountSession(e)
1454
1515
  ]);
1455
1516
  if (this.destroyed)
1456
1517
  return;
1457
- if (i.status === "rejected") {
1458
- if (e.marker && !kt(e) && U(this.options)) {
1518
+ if (s.status === "rejected") {
1519
+ if (e.marker && !Ot(e) && $(this.options)) {
1459
1520
  this.redirectAfterManagedReturnLookupFailure();
1460
1521
  return;
1461
1522
  }
1462
1523
  } else {
1463
- const o = i.value;
1524
+ const o = s.value;
1464
1525
  if (o.user && o.session) {
1465
1526
  switch (e.marker) {
1466
1527
  case te:
@@ -1477,40 +1538,40 @@ class Ot {
1477
1538
  return;
1478
1539
  }
1479
1540
  }
1480
- if (s.status === "rejected")
1481
- throw i.status === "rejected" ? i.reason : s.reason;
1482
- if (this.config = s.value, this.state.signInMethod = this.resolveInitialSignInMethod(), this.handleSessionlessManagedReturn(e))
1483
- return;
1484
1541
  if (i.status === "rejected")
1485
- throw i.reason;
1486
- const n = i.value;
1542
+ throw s.status === "rejected" ? s.reason : i.reason;
1543
+ if (this.config = i.value, this.state.signInMethod = this.resolveInitialSignInMethod(), this.handleSessionlessManagedReturn(e))
1544
+ return;
1545
+ if (s.status === "rejected")
1546
+ throw s.reason;
1547
+ const n = s.value;
1487
1548
  this.state.view = "sign-in", this.state.busy = !1, this.state.busyLabel = void 0, this.render();
1488
- } catch (s) {
1489
- this.handleError(s, "Failed to load the authentication UI.");
1549
+ } catch (i) {
1550
+ this.handleError(i, "Failed to load the authentication UI.");
1490
1551
  }
1491
1552
  }
1492
1553
  redirectAfterManagedReturnLookupFailure() {
1493
- U(this.options) && this.navigateToRedirect();
1554
+ $(this.options) && this.navigateToRedirect();
1494
1555
  }
1495
1556
  navigateToRedirect() {
1496
- U(this.options) && (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(vt(this.options.redirectTo).toString()));
1557
+ $(this.options) && (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(yt(this.options.redirectTo).toString()));
1497
1558
  }
1498
1559
  async readMountSession(e) {
1499
1560
  if (!e.marker)
1500
1561
  return V(this.auth);
1501
- let s = null;
1502
- for (let i = 0; i <= se; i++) {
1562
+ let i = null;
1563
+ for (let s = 0; s <= ie; s++) {
1503
1564
  try {
1504
1565
  const n = await V(this.auth);
1505
1566
  if (n.user && n.session)
1506
1567
  return n;
1507
1568
  } catch (n) {
1508
- s = n;
1569
+ i = n;
1509
1570
  }
1510
- i < se && await new Promise((n) => setTimeout(n, Le));
1571
+ s < ie && await new Promise((n) => setTimeout(n, _e));
1511
1572
  }
1512
- if (s)
1513
- throw s;
1573
+ if (i)
1574
+ throw i;
1514
1575
  return {
1515
1576
  user: null,
1516
1577
  session: null
@@ -1520,7 +1581,7 @@ class Ot {
1520
1581
  if (this.destroyed)
1521
1582
  return;
1522
1583
  const e = this.captureFocusSnapshot();
1523
- if (e && (this.pendingFocusSnapshot = e), !this.config) {
1584
+ if (e && (this.pendingFocusSnapshot = e), this.root.dataset.authAction = this.state.busy ? this.state.busyAction ?? "loading" : "idle", !this.config) {
1524
1585
  this.root.innerHTML = this.renderLoading();
1525
1586
  return;
1526
1587
  }
@@ -1535,11 +1596,20 @@ class Ot {
1535
1596
  `, this.bindDOM(), this.scheduleFocusRestore();
1536
1597
  }
1537
1598
  renderLoading() {
1538
- const e = this.renderStatus();
1539
1599
  return `
1540
1600
  <div class="${r}__shell">
1541
- <div class="${r}__card">
1542
- ${e || `<div class="${r}__status ${r}__status--info">${this.escape(this.labels.common.loading)}</div>`}
1601
+ <div class="${r}__card" aria-busy="${!this.state.error}">
1602
+ ${this.renderStatus()}
1603
+ ${this.state.error ? "" : `
1604
+ <p class="${r}__sr-only" role="status">${this.escape(this.labels.common.loading)}</p>
1605
+ <div class="${r}__section ${r}__skeleton" aria-hidden="true">
1606
+ <div class="${r}__skeleton-label"></div>
1607
+ <div class="${r}__skeleton-input"></div>
1608
+ <div class="${r}__skeleton-button"></div>
1609
+ <div class="${r}__divider"><span>${this.escape(this.labels.oauth.dividerText)}</span></div>
1610
+ <div class="${r}__skeleton-button ${r}__skeleton-button--secondary"></div>
1611
+ </div>
1612
+ `}
1543
1613
  </div>
1544
1614
  </div>
1545
1615
  `;
@@ -1549,12 +1619,13 @@ class Ot {
1549
1619
  return (e = this.config) != null && e.isLocalDev ? `<div class="${r}__dev-banner">Local dev mode — emails are mocked, OAuth uses test identities</div>` : "";
1550
1620
  }
1551
1621
  renderStatus() {
1622
+ var i;
1552
1623
  const e = [];
1553
1624
  return this.state.error && e.push(
1554
- `<div class="${r}__status ${r}__status--error">${this.escape(this.state.error)}</div>`
1625
+ `<div role="alert" class="${r}__status ${r}__status--error">${this.escape(this.state.error)}</div>`
1555
1626
  ), this.state.notice && e.push(
1556
- `<div class="${r}__status ${r}__status--info">${this.escape(this.state.notice)}</div>`
1557
- ), this.state.busy && this.state.busyLabel && e.push(
1627
+ `<div role="status" class="${this.state.view === "sign-in" && this.state.signInOtpSent && !((i = this.config) != null && i.isLocalDev) ? `${r}__sr-only` : `${r}__status ${r}__status--info`}">${this.escape(this.state.notice)}</div>`
1628
+ ), this.state.busy && this.state.busyLabel && !this.state.busyAction && e.push(
1558
1629
  `<div class="${r}__status ${r}__status--muted">${this.escape(this.state.busyLabel)}</div>`
1559
1630
  ), e.join("");
1560
1631
  }
@@ -1576,8 +1647,8 @@ class Ot {
1576
1647
  }
1577
1648
  }
1578
1649
  renderSignInView() {
1579
- var w, g, S, l;
1580
- const e = this.renderOAuthProviders(), s = !!((w = this.config) != null && w.emailPasswordEnabled), i = !!((g = this.config) != null && g.emailOtpSignInEnabled), n = s || i, o = s && i, c = i && !s ? "otp" : this.state.signInMethod, h = c === "otp", p = h ? this.state.signInOtpSent ? this.labels.signIn.verifyCodeButton ?? "Verify code" : this.labels.signIn.sendCodeButton ?? "Send code" : this.labels.signIn.submitButton, P = this.countdownText(
1650
+ var w, p, S, d;
1651
+ const e = this.renderOAuthProviders(), i = !!((w = this.config) != null && w.emailPasswordEnabled), s = !!((p = this.config) != null && p.emailOtpSignInEnabled), n = i || s, o = i && s, l = s && !i ? "otp" : this.state.signInMethod, h = l === "otp", f = h ? this.state.signInOtpSent ? this.labels.signIn.verifyCodeButton ?? "Verify code" : this.labels.signIn.sendCodeButton ?? "Send code" : this.labels.signIn.submitButton, P = this.countdownText(
1581
1652
  this.labels.signIn.resendCodeButton ?? "Resend code",
1582
1653
  this.labels.signIn.resendCountdown ?? "Resend in {seconds}s"
1583
1654
  );
@@ -1592,33 +1663,32 @@ class Ot {
1592
1663
  ${n ? `
1593
1664
  ${o ? `
1594
1665
  <div class="${r}__tabs" role="tablist" aria-label="Sign-in method">
1595
- <button class="${r}__tab ${c === "password" ? `${r}__tab--active` : ""}" type="button" data-action="sign-in-method" data-method="password" ${this.state.busy ? "disabled" : ""}>
1666
+ <button class="${r}__tab ${l === "password" ? `${r}__tab--active` : ""}" type="button" data-action="sign-in-method" data-method="password" ${this.state.busy ? "disabled" : ""}>
1596
1667
  ${this.escape(this.labels.signIn.passwordTab ?? "Password")}
1597
1668
  </button>
1598
- <button class="${r}__tab ${c === "otp" ? `${r}__tab--active` : ""}" type="button" data-action="sign-in-method" data-method="otp" ${this.state.busy ? "disabled" : ""}>
1669
+ <button class="${r}__tab ${l === "otp" ? `${r}__tab--active` : ""}" type="button" data-action="sign-in-method" data-method="otp" ${this.state.busy ? "disabled" : ""}>
1599
1670
  ${this.escape(this.labels.signIn.codeTab ?? "Code")}
1600
1671
  </button>
1601
1672
  </div>
1602
1673
  ` : ""}
1603
1674
  <form class="${r}__form" data-view="sign-in" novalidate>
1604
- ${this.renderInput("email", this.labels.signIn.emailLabel, "email", this.state.email, "email")}
1605
- ${h ? this.state.signInOtpSent ? this.renderInput("code", this.labels.signIn.codeLabel ?? "Code", "text", this.state.code, "one-time-code") : "" : this.renderInput("password", this.labels.signIn.passwordLabel, "password", this.state.password, "current-password")}
1606
- <button class="${r}__button ${r}__button--primary" type="submit" ${this.state.busy ? "disabled" : ""}>
1607
- ${this.escape(p)}
1675
+ ${this.renderInput("email", this.labels.signIn.emailLabel, "email", this.state.email, "email", this.labels.signIn.emailPlaceholder)}
1676
+ ${h ? this.state.signInOtpSent ? this.renderInput("code", this.labels.signIn.codeLabel ?? "Code", "text", this.state.code, "one-time-code", this.labels.signIn.codePlaceholder, `
1677
+ <button class="${r}__text-action" type="button" data-action="resend-sign-in-code" aria-busy="${this.state.busy && this.state.busyAction === "resend-code"}" ${this.state.busy || this.isCountdownActive() ? "disabled" : ""}>
1678
+ ${this.escape(this.state.busy && this.state.busyAction === "resend-code" ? this.state.busyLabel ?? P : P)}
1679
+ </button>
1680
+ `) : "" : this.renderInput("password", this.labels.signIn.passwordLabel, "password", this.state.password, "current-password")}
1681
+ <button class="${r}__button ${r}__button--primary" type="submit" aria-busy="${this.state.busy && (this.state.busyAction === "sign-in" || this.state.busyAction === "send-code")}" ${this.state.busy ? "disabled" : ""}>
1682
+ ${this.escape(this.state.busy && (this.state.busyAction === "sign-in" || this.state.busyAction === "send-code") ? this.state.busyLabel ?? f : f)}
1608
1683
  </button>
1609
1684
  </form>
1610
- ${h && this.state.signInOtpSent ? `
1611
- <button class="${r}__text-action" type="button" data-action="resend-sign-in-code" ${this.state.busy || this.isCountdownActive() ? "disabled" : ""}>
1612
- ${this.escape(P)}
1613
- </button>
1614
- ` : ""}
1615
1685
  <div class="${r}__actions">
1616
1686
  ${!h && this.canUsePasswordResetEmailOtp() ? `
1617
1687
  <button class="${r}__link" type="button" data-action="forgot-password" ${this.state.busy ? "disabled" : ""}>
1618
1688
  ${this.escape(this.labels.signIn.forgotPassword)}
1619
1689
  </button>
1620
1690
  ` : ""}
1621
- ${!((S = this.config) != null && S.disableSignUp) && ((l = this.config) != null && l.emailPasswordEnabled) ? `
1691
+ ${!((S = this.config) != null && S.disableSignUp) && ((d = this.config) != null && d.emailPasswordEnabled) ? `
1622
1692
  <p class="${r}__meta">
1623
1693
  ${this.escape(this.labels.signIn.signUpPrompt)}
1624
1694
  <button class="${r}__link" type="button" data-action="switch-sign-up" ${this.state.busy ? "disabled" : ""}>
@@ -1733,43 +1803,49 @@ class Ot {
1733
1803
  `;
1734
1804
  }
1735
1805
  renderOAuthProviders() {
1736
- var s;
1737
- const e = ((s = this.config) == null ? void 0 : s.oauthProviders) ?? [];
1806
+ var i;
1807
+ const e = ((i = this.config) == null ? void 0 : i.oauthProviders) ?? [];
1738
1808
  return e.length === 0 ? "" : `
1739
1809
  <div class="${r}__stack">
1740
- ${e.map((i) => `
1741
- <button class="${r}__button ${r}__button--secondary" type="button" data-action="oauth" data-provider="${i}" ${this.state.busy ? "disabled" : ""}>
1742
- ${this.escape(`${this.labels.oauth.continueWith} ${ie[i]}`)}
1810
+ ${e.map((s) => `
1811
+ <button class="${r}__button ${r}__button--secondary" type="button" data-action="oauth" data-provider="${s}" aria-busy="${this.state.busy && this.state.busyAction === `oauth:${s}`}" ${this.state.busy ? "disabled" : ""}>
1812
+ ${this.escape(this.state.busy && this.state.busyAction === `oauth:${s}` ? this.state.busyLabel ?? this.labels.common.redirecting : `${this.labels.oauth.continueWith} ${Le[s]}`)}
1743
1813
  </button>
1744
1814
  `).join("")}
1745
1815
  </div>
1746
1816
  `;
1747
1817
  }
1748
- renderInput(e, s, i, n, o) {
1818
+ renderInput(e, i, s, n, o, l = "", h = "") {
1819
+ const f = `${this.fieldIdPrefix}-${e}`;
1749
1820
  return `
1750
- <label class="${r}__field">
1751
- <span class="${r}__label">${this.escape(s)}</span>
1821
+ <div class="${r}__field">
1822
+ <div class="${r}__field-heading">
1823
+ <label class="${r}__label" for="${f}">${this.escape(i)}</label>
1824
+ ${h}
1825
+ </div>
1752
1826
  <input
1827
+ id="${f}"
1828
+ placeholder="${this.escape(l)}"
1753
1829
  class="${r}__input"
1754
1830
  name="${this.escape(e)}"
1755
- type="${this.escape(i)}"
1831
+ type="${this.escape(s)}"
1756
1832
  value="${this.escape(n)}"
1757
1833
  autocomplete="${this.escape(o)}"
1758
1834
  ${this.state.busy ? "disabled" : ""}
1759
1835
  />
1760
- </label>
1836
+ </div>
1761
1837
  `;
1762
1838
  }
1763
1839
  bindDOM() {
1764
1840
  this.root.querySelectorAll("form[data-view]").forEach((n) => {
1765
1841
  n.addEventListener("submit", (o) => {
1766
1842
  o.preventDefault();
1767
- const c = n.dataset.view;
1768
- c === "sign-in" && this.handleSignIn(), c === "sign-up" && this.handleSignUp(), c === "forgot-password" && this.handleForgotPassword(), c === "reset-password" && this.handleResetPassword();
1843
+ const l = n.dataset.view;
1844
+ l === "sign-in" && this.handleSignIn(), l === "sign-up" && this.handleSignUp(), l === "forgot-password" && this.handleForgotPassword(), l === "reset-password" && this.handleResetPassword();
1769
1845
  });
1770
1846
  }), this.root.querySelectorAll("input[name]").forEach((n) => {
1771
1847
  n.addEventListener("input", () => {
1772
- $t(n.name) && (this.state[n.name] = n.value, n.name === "email" && this.state.signInOtpSent && (this.state.signInOtpSent = !1, this.state.code = "", this.clearCountdown()));
1848
+ kt(n.name) && (this.state[n.name] = n.value, n.name === "email" && this.state.signInOtpSent && (this.state.signInOtpSent = !1, this.state.code = "", this.clearCountdown(), this.state.notice = null, this.state.error = null, this.render()));
1773
1849
  });
1774
1850
  }), this.root.querySelectorAll("[data-action]").forEach((n) => {
1775
1851
  n.addEventListener("click", () => {
@@ -1782,12 +1858,12 @@ class Ot {
1782
1858
  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();
1783
1859
  }
1784
1860
  async handleSignIn() {
1785
- var s, i;
1786
- if (((s = this.config) != null && s.emailOtpSignInEnabled && !((i = this.config) != null && i.emailPasswordEnabled) ? "otp" : this.state.signInMethod) === "otp") {
1861
+ var i, s;
1862
+ if (((i = this.config) != null && i.emailOtpSignInEnabled && !((s = this.config) != null && s.emailPasswordEnabled) ? "otp" : this.state.signInMethod) === "otp") {
1787
1863
  await this.handleEmailOtpSignIn();
1788
1864
  return;
1789
1865
  }
1790
- if (!G(this.state.email)) {
1866
+ if (!x(this.state.email)) {
1791
1867
  this.failValidation(this.labels.errors.invalidEmail);
1792
1868
  return;
1793
1869
  }
@@ -1795,7 +1871,7 @@ class Ot {
1795
1871
  this.failValidation(this.labels.errors.requiredField);
1796
1872
  return;
1797
1873
  }
1798
- await this.runAction("Signing in…", async () => {
1874
+ await this.runAction(this.labels.signIn.signingIn ?? this.labels.common.loading, async () => {
1799
1875
  const n = await this.auth.signIn.email({
1800
1876
  email: this.state.email.trim(),
1801
1877
  password: this.state.password,
@@ -1804,7 +1880,7 @@ class Ot {
1804
1880
  if (n.error)
1805
1881
  throw n.error;
1806
1882
  await this.completeAuth("sign-in");
1807
- });
1883
+ }, "sign-in");
1808
1884
  }
1809
1885
  async handleEmailOtpSignIn() {
1810
1886
  if (!this.canUseEmailOtpSignIn()) {
@@ -1813,7 +1889,7 @@ class Ot {
1813
1889
  );
1814
1890
  return;
1815
1891
  }
1816
- if (!G(this.state.email)) {
1892
+ if (!x(this.state.email)) {
1817
1893
  this.failValidation(this.labels.errors.invalidEmail);
1818
1894
  return;
1819
1895
  }
@@ -1825,7 +1901,7 @@ class Ot {
1825
1901
  this.failValidation(this.labels.errors.invalidCode);
1826
1902
  return;
1827
1903
  }
1828
- await this.runAction("Signing in...", async () => {
1904
+ await this.runAction(this.labels.signIn.signingIn ?? this.labels.common.loading, async () => {
1829
1905
  const e = await this.emailOtpSignInEndpoints().signIn.emailOtp({
1830
1906
  email: this.state.email.trim(),
1831
1907
  otp: this.state.code.trim()
@@ -1833,36 +1909,36 @@ class Ot {
1833
1909
  if (e.error)
1834
1910
  throw e.error;
1835
1911
  await this.completeAuth("sign-in", await this.resolveAuthCompletionData(e.data));
1836
- });
1912
+ }, "sign-in");
1837
1913
  }
1838
1914
  async sendSignInOtp(e = !1) {
1839
- await this.runAction("Sending sign-in code...", async () => {
1840
- var i;
1841
- const s = await this.emailOtpSignInEndpoints().emailOtp.sendVerificationOtp({
1915
+ await this.runAction(this.labels.signIn.sendingCode ?? this.labels.common.loading, async () => {
1916
+ var s;
1917
+ const i = await this.emailOtpSignInEndpoints().emailOtp.sendVerificationOtp({
1842
1918
  email: this.state.email.trim(),
1843
1919
  type: "sign-in"
1844
1920
  });
1845
- if (s.error)
1846
- throw s.error;
1847
- if (this.state.signInOtpSent = !0, this.state.code = "", (i = this.config) != null && i.isLocalDev) {
1921
+ if (i.error)
1922
+ throw i.error;
1923
+ if (this.state.signInOtpSent = !0, this.state.code = "", (s = this.config) != null && s.isLocalDev) {
1848
1924
  this.state.busyLabel = "Dev mode: fetching sign-in code...", this.render();
1849
1925
  const n = await bt(this.state.email.trim());
1850
1926
  n ? (this.state.code = n, this.state.notice = `Dev mode: sign-in code auto-filled (${n})`) : this.state.notice = "Dev mode: could not retrieve sign-in code — check server logs";
1851
1927
  } else
1852
- this.state.notice = e ? `We sent another sign-in code to ${this.state.email.trim()}.` : `We sent a sign-in code to ${this.state.email.trim()}.`;
1928
+ this.state.notice = this.labels.signIn.codePlaceholder ?? this.labels.signIn.codeLabel ?? "Code";
1853
1929
  this.startCountdown();
1854
- });
1930
+ }, e ? "resend-code" : "send-code");
1855
1931
  }
1856
1932
  async resendSignInCode() {
1857
1933
  this.isCountdownActive() || await this.sendSignInOtp(!0);
1858
1934
  }
1859
1935
  async handleSignUp() {
1860
- var e, s;
1936
+ var e, i;
1861
1937
  if (!this.state.name.trim()) {
1862
1938
  this.failValidation(this.labels.errors.requiredField);
1863
1939
  return;
1864
1940
  }
1865
- if (!G(this.state.email)) {
1941
+ if (!x(this.state.email)) {
1866
1942
  this.failValidation(this.labels.errors.invalidEmail);
1867
1943
  return;
1868
1944
  }
@@ -1872,7 +1948,7 @@ class Ot {
1872
1948
  }
1873
1949
  if (this.state.password.length < (((e = this.config) == null ? void 0 : e.minPasswordLength) ?? 8)) {
1874
1950
  this.failValidation(
1875
- this.labels.errors.passwordTooShort.replace("{min}", String(((s = this.config) == null ? void 0 : s.minPasswordLength) ?? 8))
1951
+ this.labels.errors.passwordTooShort.replace("{min}", String(((i = this.config) == null ? void 0 : i.minPasswordLength) ?? 8))
1876
1952
  );
1877
1953
  return;
1878
1954
  }
@@ -1882,25 +1958,26 @@ class Ot {
1882
1958
  }
1883
1959
  await this.runAction("Creating account…", async () => {
1884
1960
  var n;
1885
- const i = await this.auth.signUp.email({
1961
+ const s = await this.auth.signUp.email({
1886
1962
  name: this.state.name.trim(),
1887
1963
  email: this.state.email.trim(),
1888
1964
  password: this.state.password,
1889
1965
  callbackURL: this.getManagedReturnURL(R, this.state.email.trim())
1890
1966
  });
1891
- if (i.error)
1892
- throw i.error;
1967
+ if (s.error)
1968
+ throw s.error;
1893
1969
  if ((n = this.config) != null && n.requireEmailVerification) {
1894
- if (this.config.isLocalDev && await this.tryDevAutoVerify("sign-up", i.data))
1970
+ if (this.config.isLocalDev && await this.tryDevAutoVerify("sign-up", s.data))
1895
1971
  return;
1896
1972
  this.verificationCompletionAction = "sign-up", this.state.view = "verify-email", this.state.notice = this.config.isLocalDev ? "Dev mode: auto-verify didn’t complete. Click resend to retry." : "Check your inbox to verify your email address.", this.startCountdown();
1897
1973
  return;
1898
1974
  }
1899
- await this.completeAuth("sign-up", await this.resolveAuthCompletionData(i.data));
1975
+ await this.completeAuth("sign-up", await this.resolveAuthCompletionData(s.data));
1900
1976
  });
1901
1977
  }
1902
1978
  async handleOAuthSignIn(e) {
1903
- await this.runAction(`Redirecting to ${ie[e]}…`, async () => {
1979
+ const i = (this.labels.oauth.redirecting ?? this.labels.common.redirecting).replace("{provider}", Le[e]);
1980
+ await this.runAction(i, async () => {
1904
1981
  const s = await this.auth.signIn.social({
1905
1982
  provider: e,
1906
1983
  callbackURL: this.getManagedReturnURL("oauth"),
@@ -1908,11 +1985,11 @@ class Ot {
1908
1985
  });
1909
1986
  if (s.error)
1910
1987
  throw s.error;
1911
- const i = this.extractRedirectURL(s.data);
1912
- if (!i)
1988
+ const n = this.extractRedirectURL(s.data);
1989
+ if (!n)
1913
1990
  throw new b(`OAuth sign-in did not return a redirect URL for provider "${e}".`);
1914
- this.terminalActionInProgress = !0, this.state.busy = !0, this.state.busyLabel = `Opening ${ie[e]}…`, this.state.error = null, this.state.notice = null, this.render(), window.location.assign(i);
1915
- });
1991
+ this.terminalActionInProgress = !0, this.state.busy = !0, this.state.busyLabel = i, this.state.error = null, this.state.notice = null, this.render(), window.location.assign(n);
1992
+ }, `oauth:${e}`);
1916
1993
  }
1917
1994
  async handleForgotPassword() {
1918
1995
  if (!this.canUsePasswordResetEmailOtp()) {
@@ -1921,21 +1998,21 @@ class Ot {
1921
1998
  );
1922
1999
  return;
1923
2000
  }
1924
- if (!G(this.state.email)) {
2001
+ if (!x(this.state.email)) {
1925
2002
  this.failValidation(this.labels.errors.invalidEmail);
1926
2003
  return;
1927
2004
  }
1928
2005
  await this.runAction("Sending reset code…", async () => {
1929
- var s;
2006
+ var i;
1930
2007
  const e = await this.passwordResetEndpoints().forgetPassword.emailOtp({
1931
2008
  email: this.state.email.trim()
1932
2009
  });
1933
2010
  if (e.error)
1934
2011
  throw e.error;
1935
- if (this.state.view = "reset-password", (s = this.config) != null && s.isLocalDev) {
2012
+ if (this.state.view = "reset-password", (i = this.config) != null && i.isLocalDev) {
1936
2013
  this.state.busyLabel = "Dev mode: fetching reset code…", this.render();
1937
- const i = await wt(this.state.email.trim());
1938
- i ? (this.state.code = i, this.state.notice = `Dev mode: reset code auto-filled (${i})`) : this.state.notice = "Dev mode: could not retrieve reset code — check server logs";
2014
+ const s = await wt(this.state.email.trim());
2015
+ s ? (this.state.code = s, this.state.notice = `Dev mode: reset code auto-filled (${s})`) : this.state.notice = "Dev mode: could not retrieve reset code — check server logs";
1939
2016
  } else
1940
2017
  this.state.notice = `We sent a reset code to ${this.state.email.trim()}.`;
1941
2018
  this.startCountdown();
@@ -1945,7 +2022,7 @@ class Ot {
1945
2022
  this.isCountdownActive() || await this.handleForgotPassword();
1946
2023
  }
1947
2024
  async handleResetPassword() {
1948
- var e, s;
2025
+ var e, i;
1949
2026
  if (!this.canUsePasswordResetEmailOtp()) {
1950
2027
  this.handleError(
1951
2028
  new b("Password reset via email OTP is not enabled for this project.")
@@ -1962,7 +2039,7 @@ class Ot {
1962
2039
  }
1963
2040
  if (this.state.newPassword.length < (((e = this.config) == null ? void 0 : e.minPasswordLength) ?? 8)) {
1964
2041
  this.failValidation(
1965
- this.labels.errors.passwordTooShort.replace("{min}", String(((s = this.config) == null ? void 0 : s.minPasswordLength) ?? 8))
2042
+ this.labels.errors.passwordTooShort.replace("{min}", String(((i = this.config) == null ? void 0 : i.minPasswordLength) ?? 8))
1966
2043
  );
1967
2044
  return;
1968
2045
  }
@@ -1971,13 +2048,13 @@ class Ot {
1971
2048
  return;
1972
2049
  }
1973
2050
  await this.runAction("Updating password…", async () => {
1974
- const i = await this.passwordResetEndpoints().emailOtp.resetPassword({
2051
+ const s = await this.passwordResetEndpoints().emailOtp.resetPassword({
1975
2052
  email: this.state.email.trim(),
1976
2053
  otp: this.state.code.trim(),
1977
2054
  password: this.state.newPassword
1978
2055
  });
1979
- if (i.error)
1980
- throw i.error;
2056
+ if (s.error)
2057
+ throw s.error;
1981
2058
  await this.completePasswordReset();
1982
2059
  });
1983
2060
  }
@@ -1986,8 +2063,8 @@ class Ot {
1986
2063
  if ((e = this.config) != null && e.isLocalDev) {
1987
2064
  if (this.isCountdownActive()) return;
1988
2065
  await this.runAction("Dev mode: retrying auto-verify…", async () => {
1989
- const s = this.verificationCompletionAction ?? "sign-in";
1990
- if (!await this.tryDevAutoVerify(s))
2066
+ const i = this.verificationCompletionAction ?? "sign-in";
2067
+ if (!await this.tryDevAutoVerify(i))
1991
2068
  throw new Error(
1992
2069
  "Dev auto-verify did not complete. Check the edgespark dev logs and try again."
1993
2070
  );
@@ -2001,43 +2078,43 @@ class Ot {
2001
2078
  * auth flow. Returns whether auto-verify completed — callers decide what
2002
2079
  * to do on `false` (sign-up falls through to a retry UI; resend throws).
2003
2080
  */
2004
- async tryDevAutoVerify(e, s) {
2005
- const i = this.state.email.trim();
2081
+ async tryDevAutoVerify(e, i) {
2082
+ const s = this.state.email.trim();
2006
2083
  try {
2007
- return this.state.busyLabel = "Dev mode: auto-verifying email…", this.render(), await pt(i) ? (this.state.notice = "Dev mode: email verification auto-completed", await this.completeAuth(e, await this.resolveAuthCompletionData(s)), !0) : (console.warn("[edgespark] Dev auto-verify returned false — falling through"), !1);
2084
+ return this.state.busyLabel = "Dev mode: auto-verifying email…", this.render(), await pt(s) ? (this.state.notice = "Dev mode: email verification auto-completed", await this.completeAuth(e, await this.resolveAuthCompletionData(i)), !0) : (console.warn("[edgespark] Dev auto-verify returned false — falling through"), !1);
2008
2085
  } catch (n) {
2009
2086
  return console.warn("[edgespark] Dev auto-verify failed:", n), !1;
2010
2087
  }
2011
2088
  }
2012
2089
  async sendVerificationEmail(e) {
2013
2090
  !e && this.isCountdownActive() || await this.runAction("Sending verification email…", async () => {
2014
- const s = await this.auth.sendVerificationEmail({
2091
+ const i = await this.auth.sendVerificationEmail({
2015
2092
  email: this.state.email.trim(),
2016
2093
  callbackURL: this.getManagedReturnURL(
2017
2094
  this.verificationCompletionAction === "sign-up" ? R : N,
2018
2095
  this.state.email.trim()
2019
2096
  )
2020
2097
  });
2021
- if (s.error)
2022
- throw s.error;
2098
+ if (i.error)
2099
+ throw i.error;
2023
2100
  this.handleVerificationEmailSent(this.state.email.trim(), !0);
2024
2101
  });
2025
2102
  }
2026
- async completeAuth(e, s) {
2027
- const i = await this.retryAuthCompletionDataIfNeeded(
2028
- s ?? await this.resolveAuthCompletionData()
2103
+ async completeAuth(e, i) {
2104
+ const s = await this.retryAuthCompletionDataIfNeeded(
2105
+ i ?? await this.resolveAuthCompletionData()
2029
2106
  );
2030
2107
  if (this.destroyed)
2031
2108
  return;
2032
- if (!i.user || !i.session) {
2109
+ if (!s.user || !s.session) {
2033
2110
  if (this.destroyed)
2034
2111
  return;
2035
- if (i.lookupError && U(this.options)) {
2112
+ if (s.lookupError && $(this.options)) {
2036
2113
  this.navigateToRedirect();
2037
2114
  return;
2038
2115
  }
2039
2116
  if (e === "sign-in")
2040
- throw i.lookupError ?? new Ue(
2117
+ throw s.lookupError ?? new $e(
2041
2118
  "Managed sign-in completed without an authenticated session."
2042
2119
  );
2043
2120
  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();
@@ -2045,15 +2122,15 @@ class Ot {
2045
2122
  }
2046
2123
  const n = {
2047
2124
  action: e,
2048
- user: i.user,
2049
- session: i.session
2125
+ user: s.user,
2126
+ session: s.session
2050
2127
  };
2051
2128
  if (await this.syncPublicSessionBestEffort(), !this.destroyed) {
2052
- if (U(this.options)) {
2129
+ if ($(this.options)) {
2053
2130
  this.invokeRedirectModeSuccessHook(n), this.navigateToRedirect();
2054
2131
  return;
2055
2132
  }
2056
- if (ne(this.options)) {
2133
+ if (se(this.options)) {
2057
2134
  this.options.onSuccess(n), this.terminalActionInProgress = !0;
2058
2135
  return;
2059
2136
  }
@@ -2062,9 +2139,9 @@ class Ot {
2062
2139
  async retryAuthCompletionDataIfNeeded(e) {
2063
2140
  if (e.session)
2064
2141
  return e;
2065
- let s = e.lookupError;
2066
- for (let i = 0; i < se; i++) {
2067
- await new Promise((n) => setTimeout(n, Le));
2142
+ let i = e.lookupError;
2143
+ for (let s = 0; s < ie; s++) {
2144
+ await new Promise((n) => setTimeout(n, _e));
2068
2145
  try {
2069
2146
  const n = await V(this.auth);
2070
2147
  if (n.user && n.session)
@@ -2073,33 +2150,33 @@ class Ot {
2073
2150
  session: n.session
2074
2151
  };
2075
2152
  } catch (n) {
2076
- s = n;
2153
+ i = n;
2077
2154
  }
2078
2155
  }
2079
2156
  return {
2080
2157
  ...e,
2081
- lookupError: s ?? e.lookupError
2158
+ lookupError: i ?? e.lookupError
2082
2159
  };
2083
2160
  }
2084
2161
  async syncPublicSessionBestEffort() {
2085
- var e, s;
2162
+ var e, i;
2086
2163
  try {
2087
- await ((s = (e = this.runtimeOptions) == null ? void 0 : e.syncPublicSession) == null ? void 0 : s.call(e));
2164
+ await ((i = (e = this.runtimeOptions) == null ? void 0 : e.syncPublicSession) == null ? void 0 : i.call(e));
2088
2165
  } catch {
2089
2166
  }
2090
2167
  }
2091
2168
  async resolveAuthCompletionData(e) {
2092
2169
  try {
2093
- const s = await V(this.auth), i = this.extractUser(e);
2170
+ const i = await V(this.auth), s = this.extractUser(e);
2094
2171
  return {
2095
- user: s.user ?? i,
2096
- session: s.session
2172
+ user: i.user ?? s,
2173
+ session: i.session
2097
2174
  };
2098
- } catch (s) {
2175
+ } catch (i) {
2099
2176
  return {
2100
2177
  user: this.extractUser(e),
2101
2178
  session: null,
2102
- lookupError: s
2179
+ lookupError: i
2103
2180
  };
2104
2181
  }
2105
2182
  }
@@ -2110,7 +2187,7 @@ class Ot {
2110
2187
  session: null
2111
2188
  };
2112
2189
  if (await this.syncPublicSessionBestEffort(), !this.destroyed) {
2113
- if (ne(this.options)) {
2190
+ if (se(this.options)) {
2114
2191
  this.clearCountdown(), this.options.onSuccess(e), this.terminalActionInProgress = !0;
2115
2192
  return;
2116
2193
  }
@@ -2118,23 +2195,23 @@ class Ot {
2118
2195
  }
2119
2196
  }
2120
2197
  handleExistingSessionOnMount() {
2121
- if (U(this.options)) {
2198
+ if ($(this.options)) {
2122
2199
  this.navigateToRedirect();
2123
2200
  return;
2124
2201
  }
2125
- if (ne(this.options))
2202
+ if (se(this.options))
2126
2203
  throw this.state.view = "sign-in", this.state.busy = !1, this.state.busyLabel = void 0, this.state.notice = null, new b(
2127
2204
  "authUI.mount(container, { onSuccess }) cannot run while a session already exists. Check es.auth.getSession() before mounting controlled auth UI."
2128
2205
  );
2129
2206
  }
2130
- async runAction(e, s) {
2131
- this.state.busy = !0, this.state.busyLabel = e, this.state.error = null, this.state.notice = null, this.render();
2207
+ async runAction(e, i, s) {
2208
+ this.state.busyAction = s, this.state.busy = !0, this.state.busyLabel = e, this.state.error = null, this.state.notice = null, this.render();
2132
2209
  try {
2133
- await s();
2134
- } catch (i) {
2135
- if (this.maybeHandleVerificationRequired(i))
2210
+ await i();
2211
+ } catch (n) {
2212
+ if (this.maybeHandleVerificationRequired(n))
2136
2213
  return;
2137
- this.handleError(i);
2214
+ this.handleError(n);
2138
2215
  return;
2139
2216
  }
2140
2217
  !this.destroyed && !this.terminalActionInProgress && (this.state.busy = !1, this.state.busyLabel = void 0, this.render());
@@ -2142,54 +2219,79 @@ class Ot {
2142
2219
  maybeHandleVerificationRequired(e) {
2143
2220
  return Q(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);
2144
2221
  }
2145
- handleVerificationEmailSent(e, s) {
2146
- this.state.notice = s ? `We sent another verification email to ${e}.` : `We sent a verification email to ${e}.`, this.startCountdown();
2222
+ handleVerificationEmailSent(e, i) {
2223
+ this.state.notice = i ? `We sent another verification email to ${e}.` : `We sent a verification email to ${e}.`, this.startCountdown();
2147
2224
  }
2148
2225
  invokeRedirectModeSuccessHook(e) {
2149
- var s, i;
2150
- if (!(!U(this.options) || !this.options.onSuccess))
2226
+ var i, s;
2227
+ if (!(!$(this.options) || !this.options.onSuccess))
2151
2228
  try {
2152
2229
  this.options.onSuccess(e);
2153
2230
  } catch (n) {
2154
2231
  const o = Q(n, "Post-auth callback failed.");
2155
2232
  try {
2156
- (i = (s = this.options).onError) == null || i.call(s, o);
2233
+ (s = (i = this.options).onError) == null || s.call(i, o);
2157
2234
  } catch {
2158
2235
  }
2159
2236
  }
2160
2237
  }
2161
- handleError(e, s) {
2238
+ handleError(e, i) {
2162
2239
  var n, o;
2163
- const i = Q(e, s);
2164
- this.state.busy = !1, this.state.busyLabel = void 0, this.state.error = i.message, this.render(), (o = (n = this.options).onError) == null || o.call(n, i);
2240
+ const s = Q(e, i);
2241
+ this.state.busy = !1, this.state.busyLabel = void 0, this.state.error = s.message, this.render(), (o = (n = this.options).onError) == null || o.call(n, s);
2165
2242
  }
2166
2243
  failValidation(e) {
2167
2244
  this.state.error = e, this.state.notice = null, this.render();
2168
2245
  }
2169
- getManagedReturnURL(e, s) {
2246
+ getManagedReturnURL(e, i) {
2170
2247
  if (!e)
2171
2248
  return window.location.href;
2172
- const i = new URL(window.location.href);
2173
- return i.searchParams.set(ee, e), s ? i.searchParams.set(F, s) : i.searchParams.delete(F), i.toString();
2249
+ const s = new URL(window.location.href);
2250
+ return s.searchParams.set(ee, e), i ? s.searchParams.set(F, i) : s.searchParams.delete(F), s.toString();
2174
2251
  }
2175
2252
  consumeManagedReturnContext() {
2176
- const e = new URL(window.location.href), s = e.searchParams.get(ee), i = s === te || s === N || s === R ? s : null, n = e.searchParams.get(F), o = i ? e.searchParams.get("error") : null, c = i ? e.searchParams.get("error_description") : null;
2177
- return (i || n) && (e.searchParams.delete(ee), e.searchParams.delete(F), i && (e.searchParams.delete("error"), e.searchParams.delete("error_description")), window.history.replaceState(null, "", e.toString())), {
2178
- marker: i,
2253
+ const e = new URL(window.location.href), i = e.searchParams.get(ee), s = i === te || i === N || i === R ? i : null, n = e.searchParams.get(F), o = s ? e.searchParams.get("error") : null, l = s ? e.searchParams.get("error_description") : null;
2254
+ return (s || n) && (e.searchParams.delete(ee), e.searchParams.delete(F), s && (e.searchParams.delete("error"), e.searchParams.delete("error_description")), window.history.replaceState(null, "", e.toString())), {
2255
+ marker: s,
2179
2256
  email: n,
2180
2257
  error: o,
2181
- errorDescription: c
2258
+ errorDescription: l
2182
2259
  };
2183
2260
  }
2184
2261
  startCountdown(e = 60) {
2185
2262
  this.countdownUntil = Date.now() + e * 1e3, this.countdownTimer && window.clearInterval(this.countdownTimer), this.countdownTimer = window.setInterval(() => {
2186
2263
  if (!this.isCountdownActive()) {
2187
- this.countdownTimer && (window.clearInterval(this.countdownTimer), this.countdownTimer = null), this.render();
2264
+ this.countdownTimer && (window.clearInterval(this.countdownTimer), this.countdownTimer = null), this.updateCountdownControls();
2188
2265
  return;
2189
2266
  }
2190
- this.render();
2267
+ this.updateCountdownControls();
2191
2268
  }, 1e3);
2192
2269
  }
2270
+ updateCountdownControls() {
2271
+ const e = [
2272
+ {
2273
+ action: "resend-sign-in-code",
2274
+ base: this.labels.signIn.resendCodeButton ?? "Resend code",
2275
+ template: this.labels.signIn.resendCountdown ?? "Resend in {seconds}s"
2276
+ },
2277
+ {
2278
+ action: "resend-verification",
2279
+ base: this.labels.verifyEmail.resendButton,
2280
+ template: this.labels.verifyEmail.resendCountdown
2281
+ },
2282
+ {
2283
+ action: "resend-reset-code",
2284
+ base: this.labels.resetPassword.resendCodeButton,
2285
+ template: this.labels.resetPassword.resendCountdown
2286
+ }
2287
+ ];
2288
+ for (const i of e) {
2289
+ const s = this.root.querySelector(
2290
+ `[data-action="${i.action}"]`
2291
+ );
2292
+ s && (i.action === "resend-sign-in-code" && this.state.busy && this.state.busyAction === "resend-code" || (s.textContent = this.countdownText(i.base, i.template), s.disabled = this.state.busy || this.isCountdownActive()));
2293
+ }
2294
+ }
2193
2295
  clearCountdown() {
2194
2296
  this.countdownUntil = null, this.countdownTimer && (window.clearInterval(this.countdownTimer), this.countdownTimer = null);
2195
2297
  }
@@ -2206,14 +2308,14 @@ class Ot {
2206
2308
  this.pendingFocusSnapshot && (this.clearFocusRestoreTimer(), this.focusRestoreTimer = window.setTimeout(() => {
2207
2309
  if (this.focusRestoreTimer = null, this.destroyed || !this.pendingFocusSnapshot)
2208
2310
  return;
2209
- const e = this.pendingFocusSnapshot, s = `input[name="${this.escape(e.name)}"][type="${this.escape(e.type)}"]`, i = this.root.querySelector(s);
2210
- if (!(!i || i.disabled)) {
2211
- if (i.focus(), e.selectionStart !== null && e.selectionEnd !== null)
2311
+ const e = this.pendingFocusSnapshot, i = `input[name="${this.escape(e.name)}"][type="${this.escape(e.type)}"]`, s = this.root.querySelector(i);
2312
+ if (!(!s || s.disabled)) {
2313
+ if (s.focus(), e.selectionStart !== null && e.selectionEnd !== null)
2212
2314
  try {
2213
- i.setSelectionRange(e.selectionStart, e.selectionEnd);
2315
+ s.setSelectionRange(e.selectionStart, e.selectionEnd);
2214
2316
  } catch {
2215
- const n = i.value.length;
2216
- i.setSelectionRange(n, n);
2317
+ const n = s.value.length;
2318
+ s.setSelectionRange(n, n);
2217
2319
  }
2218
2320
  this.pendingFocusSnapshot = null;
2219
2321
  }
@@ -2229,8 +2331,8 @@ class Ot {
2229
2331
  return this.auth;
2230
2332
  }
2231
2333
  resolveInitialSignInMethod() {
2232
- var e, s;
2233
- return (e = this.config) != null && e.emailPasswordEnabled ? "password" : (s = this.config) != null && s.emailOtpSignInEnabled ? "otp" : "password";
2334
+ var e, i;
2335
+ return (e = this.config) != null && e.emailPasswordEnabled ? "password" : (i = this.config) != null && i.emailOtpSignInEnabled ? "otp" : "password";
2234
2336
  }
2235
2337
  setSignInMethod(e) {
2236
2338
  this.state.signInMethod !== e && (this.state.signInMethod = e, this.state.signInOtpSent = !1, this.state.code = "", this.state.error = null, this.state.notice = null, this.render());
@@ -2242,14 +2344,14 @@ class Ot {
2242
2344
  extractRedirectURL(e) {
2243
2345
  if (!e || typeof e != "object")
2244
2346
  return null;
2245
- const s = e;
2246
- return s.redirect && typeof s.url == "string" && s.url.length > 0 ? s.url : null;
2347
+ const i = e;
2348
+ return i.redirect && typeof i.url == "string" && i.url.length > 0 ? i.url : null;
2247
2349
  }
2248
2350
  extractUser(e) {
2249
2351
  if (!e || typeof e != "object")
2250
2352
  return null;
2251
- const s = e;
2252
- return s.user && typeof s.user == "object" ? s.user : null;
2353
+ const i = e;
2354
+ return i.user && typeof i.user == "object" ? i.user : null;
2253
2355
  }
2254
2356
  canUsePasswordResetEmailOtp() {
2255
2357
  var e;
@@ -2270,198 +2372,198 @@ class Ot {
2270
2372
  getCountdownSecondsRemaining() {
2271
2373
  return this.countdownUntil ? Math.max(0, Math.ceil((this.countdownUntil - Date.now()) / 1e3)) : 0;
2272
2374
  }
2273
- countdownText(e, s) {
2274
- const i = this.getCountdownSecondsRemaining();
2275
- return i <= 0 ? e : s.replace("{seconds}", String(i));
2375
+ countdownText(e, i) {
2376
+ const s = this.getCountdownSecondsRemaining();
2377
+ return s <= 0 ? e : i.replace("{seconds}", String(s));
2276
2378
  }
2277
2379
  escape(e) {
2278
- return e.replace(/[&<>"']/g, (s) => Ut[s]);
2380
+ return e.replace(/[&<>"']/g, (i) => Ut[i]);
2279
2381
  }
2280
2382
  }
2281
- function Bt(t) {
2383
+ function Mt(t) {
2282
2384
  return "data" in t && t.data ? t.data : t;
2283
2385
  }
2284
- const Mt = [
2386
+ const Dt = [
2285
2387
  { id: "google", key: "providerGoogle" },
2286
2388
  { id: "apple", key: "providerApple" },
2287
2389
  { id: "microsoft", key: "providerMicrosoft" },
2288
2390
  { id: "github", key: "providerGithub" },
2289
2391
  { id: "gitlab", key: "providerGitlab" },
2290
2392
  { id: "discord", key: "providerDiscord" }
2291
- ], Te = 2, Dt = 500;
2292
- async function Nt() {
2393
+ ], Ce = 2, Nt = 500;
2394
+ async function Vt() {
2293
2395
  const t = `${window.location.origin}${ke}/config`;
2294
2396
  let e;
2295
- for (let s = 0; s <= Te; s++)
2397
+ for (let i = 0; i <= Ce; i++)
2296
2398
  try {
2297
- const i = await fetch(t, { method: "GET", credentials: "include" });
2298
- if (!i.ok)
2299
- throw new b(`Failed to load auth config: HTTP ${i.status}`);
2300
- const n = await i.json(), o = Bt(n);
2301
- return Vt(o, gt());
2302
- } catch (i) {
2303
- e = i, s < Te && await new Promise((n) => setTimeout(n, Dt));
2399
+ const s = await fetch(t, { method: "GET", credentials: "include" });
2400
+ if (!s.ok)
2401
+ throw new b(`Failed to load auth config: HTTP ${s.status}`);
2402
+ const n = await s.json(), o = Mt(n);
2403
+ return Ft(o, gt());
2404
+ } catch (s) {
2405
+ e = s, i < Ce && await new Promise((n) => setTimeout(n, Nt));
2304
2406
  }
2305
2407
  throw e;
2306
2408
  }
2307
- let H = null;
2308
- async function Ce() {
2309
- return H || (H = Nt().catch((t) => {
2310
- throw H = null, t;
2311
- })), H;
2312
- }
2313
- function Vt(t, e = !1) {
2314
- var o, c, h, p, P, w, g, S, l;
2315
- const s = Mt.filter(({ key: _ }) => {
2316
- const A = t[_];
2409
+ let z = null;
2410
+ async function Te() {
2411
+ return z || (z = Vt().catch((t) => {
2412
+ throw z = null, t;
2413
+ })), z;
2414
+ }
2415
+ function Ft(t, e = !1) {
2416
+ var o, l, h, f, P, w, p, S, d;
2417
+ const i = Dt.filter(({ key: I }) => {
2418
+ const A = t[I];
2317
2419
  return typeof A == "object" && A !== null && "enabled" in A && !!A.enabled;
2318
- }).map(({ id: _ }) => _), i = t.providerGoogle, n = i != null && i.enabled && typeof ((o = i.config) == null ? void 0 : o.clientId) == "string" ? i.config.clientId : null;
2420
+ }).map(({ id: I }) => I), s = t.providerGoogle, n = s != null && s.enabled && typeof ((o = s.config) == null ? void 0 : o.clientId) == "string" ? s.config.clientId : null;
2319
2421
  return {
2320
2422
  disableSignUp: !!t.disableSignUp,
2321
- emailPasswordEnabled: !!((c = t.providerEmailPassword) != null && c.enabled),
2423
+ emailPasswordEnabled: !!((l = t.providerEmailPassword) != null && l.enabled),
2322
2424
  emailOtpSignInEnabled: !!((h = t.providerEmailOtp) != null && h.enabled),
2323
- minPasswordLength: ((P = (p = t.providerEmailPassword) == null ? void 0 : p.config) == null ? void 0 : P.minPasswordLength) ?? 8,
2324
- requireEmailVerification: !!((g = (w = t.providerEmailPassword) == null ? void 0 : w.config) != null && g.requireEmailVerification),
2325
- passwordResetEmailOtpEnabled: !!((l = (S = t.providerEmailPassword) == null ? void 0 : S.config) != null && l.requirePasswordResetEmailVerification),
2326
- oauthProviders: s,
2425
+ minPasswordLength: ((P = (f = t.providerEmailPassword) == null ? void 0 : f.config) == null ? void 0 : P.minPasswordLength) ?? 8,
2426
+ requireEmailVerification: !!((p = (w = t.providerEmailPassword) == null ? void 0 : w.config) != null && p.requireEmailVerification),
2427
+ passwordResetEmailOtpEnabled: !!((d = (S = t.providerEmailPassword) == null ? void 0 : S.config) != null && d.requirePasswordResetEmailVerification),
2428
+ oauthProviders: i,
2327
2429
  googleClientId: n,
2328
2430
  isLocalDev: e
2329
2431
  };
2330
2432
  }
2331
- const Ft = "https://accounts.google.com/gsi/client", Re = "data-edgespark-gsi";
2332
- let z = null;
2333
- function re() {
2433
+ const xt = "https://accounts.google.com/gsi/client", Re = "data-edgespark-gsi";
2434
+ let G = null;
2435
+ function ne() {
2334
2436
  var t, e;
2335
2437
  return (e = (t = window.google) == null ? void 0 : t.accounts) == null ? void 0 : e.id;
2336
2438
  }
2337
- function Gt() {
2439
+ function zt() {
2338
2440
  if (typeof window > "u")
2339
2441
  return Promise.reject(new Error("Google Identity Services is unavailable outside the browser."));
2340
- const t = re();
2341
- return t ? Promise.resolve(t) : (z || (z = new Promise((e, s) => {
2342
- const i = document.querySelector(
2442
+ const t = ne();
2443
+ return t ? Promise.resolve(t) : (G || (G = new Promise((e, i) => {
2444
+ const s = document.querySelector(
2343
2445
  `script[${Re}]`
2344
2446
  );
2345
- if (i) {
2346
- const o = re();
2447
+ if (s) {
2448
+ const o = ne();
2347
2449
  if (o) {
2348
2450
  e(o);
2349
2451
  return;
2350
2452
  }
2351
- i.remove();
2453
+ s.remove();
2352
2454
  }
2353
2455
  const n = document.createElement("script");
2354
- n.src = Ft, n.async = !0, n.defer = !0, n.setAttribute(Re, ""), n.addEventListener(
2456
+ n.src = xt, n.async = !0, n.defer = !0, n.setAttribute(Re, ""), n.addEventListener(
2355
2457
  "load",
2356
2458
  () => {
2357
- const o = re();
2358
- o ? e(o) : (n.remove(), s(new Error("Google Identity Services loaded but did not expose google.accounts.id.")));
2459
+ const o = ne();
2460
+ o ? e(o) : (n.remove(), i(new Error("Google Identity Services loaded but did not expose google.accounts.id.")));
2359
2461
  },
2360
2462
  { once: !0 }
2361
2463
  ), n.addEventListener(
2362
2464
  "error",
2363
2465
  () => {
2364
- n.remove(), s(new Error("Failed to load Google Identity Services."));
2466
+ n.remove(), i(new Error("Failed to load Google Identity Services."));
2365
2467
  },
2366
2468
  { once: !0 }
2367
2469
  ), document.head.appendChild(n);
2368
2470
  }).catch((e) => {
2369
- throw z = null, e;
2370
- })), z);
2471
+ throw G = null, e;
2472
+ })), G);
2371
2473
  }
2372
- function Ht() {
2474
+ function Gt() {
2373
2475
  return { cancel: () => {
2374
2476
  } };
2375
2477
  }
2376
- function zt(t) {
2478
+ function Ht(t) {
2377
2479
  let e = null;
2378
- return function(i) {
2480
+ return function(s) {
2379
2481
  if (typeof window > "u")
2380
2482
  return console.error(
2381
2483
  "[edgespark] promptGoogleOneTap() requires a browser environment."
2382
- ), Ht();
2484
+ ), Gt();
2383
2485
  if (e)
2384
2486
  return console.warn(
2385
2487
  "[edgespark] promptGoogleOneTap() is already in flight; returning the existing handle. Call cancel() on the original before re-prompting."
2386
2488
  ), e;
2387
2489
  let n = !1, o = null;
2388
- const c = () => {
2490
+ const l = () => {
2389
2491
  n || (n = !0, e === h && (e = null));
2390
2492
  }, h = {
2391
2493
  cancel() {
2392
- if (!n && (c(), o))
2494
+ if (!n && (l(), o))
2393
2495
  try {
2394
2496
  o.cancel();
2395
2497
  } catch {
2396
2498
  }
2397
2499
  }
2398
- }, p = () => {
2399
- var g;
2500
+ }, f = () => {
2501
+ var p;
2400
2502
  if (!n) {
2401
- c();
2503
+ l();
2402
2504
  try {
2403
- (g = i == null ? void 0 : i.onUnavailable) == null || g.call(i);
2505
+ (p = s == null ? void 0 : s.onUnavailable) == null || p.call(s);
2404
2506
  } catch (S) {
2405
2507
  console.error("[edgespark] onUnavailable threw:", S);
2406
2508
  }
2407
2509
  }
2408
- }, P = (g, S) => {
2409
- var _;
2510
+ }, P = (p, S) => {
2511
+ var I;
2410
2512
  if (n) return;
2411
- c();
2412
- const l = de(g, S);
2513
+ l();
2514
+ const d = le(p, S);
2413
2515
  try {
2414
- (_ = i == null ? void 0 : i.onError) == null || _.call(i, l);
2516
+ (I = s == null ? void 0 : s.onError) == null || I.call(s, d);
2415
2517
  } catch (A) {
2416
2518
  console.error("[edgespark] onError threw:", A);
2417
2519
  }
2418
- }, w = (g, S) => {
2419
- var l;
2520
+ }, w = (p, S) => {
2521
+ var d;
2420
2522
  if (!n) {
2421
- c();
2523
+ l();
2422
2524
  try {
2423
- (l = i == null ? void 0 : i.onSuccess) == null || l.call(i, { action: "sign-in", user: g, session: S });
2424
- } catch (_) {
2425
- console.error("[edgespark] onSuccess threw:", _);
2525
+ (d = s == null ? void 0 : s.onSuccess) == null || d.call(s, { action: "sign-in", user: p, session: S });
2526
+ } catch (I) {
2527
+ console.error("[edgespark] onSuccess threw:", I);
2426
2528
  }
2427
2529
  }
2428
2530
  };
2429
2531
  return e = h, (async () => {
2430
- let g;
2532
+ let p;
2431
2533
  try {
2432
- g = await t.loadConfig();
2433
- } catch (l) {
2434
- P(l, "Failed to load auth config for Google One Tap.");
2534
+ p = await t.loadConfig();
2535
+ } catch (d) {
2536
+ P(d, "Failed to load auth config for Google One Tap.");
2435
2537
  return;
2436
2538
  }
2437
2539
  if (n) return;
2438
- if (g.isLocalDev) {
2540
+ if (p.isLocalDev) {
2439
2541
  console.error(
2440
2542
  "[edgespark] promptGoogleOneTap() is disabled in local dev mode — Google Identity Services cannot run against mock OAuth."
2441
- ), c();
2543
+ ), l();
2442
2544
  return;
2443
2545
  }
2444
- const S = g.googleClientId;
2546
+ const S = p.googleClientId;
2445
2547
  if (!S) {
2446
2548
  console.error(
2447
2549
  "[edgespark] promptGoogleOneTap() called but Google is not configured. Set `providerGoogle` in `auth-config.yaml` with resolvable credentials."
2448
- ), c();
2550
+ ), l();
2449
2551
  return;
2450
2552
  }
2451
2553
  try {
2452
- o = await Gt();
2453
- } catch (l) {
2554
+ o = await zt();
2555
+ } catch (d) {
2454
2556
  console.warn(
2455
2557
  "[edgespark] Google Identity Services failed to load; treating as unavailable.",
2456
- l
2457
- ), p();
2558
+ d
2559
+ ), f();
2458
2560
  return;
2459
2561
  }
2460
2562
  if (!n) {
2461
2563
  o.initialize({
2462
2564
  client_id: S,
2463
- callback: (l) => {
2464
- n || typeof (l == null ? void 0 : l.credential) != "string" || l.credential.length === 0 || xt(l.credential, t, {
2565
+ callback: (d) => {
2566
+ n || typeof (d == null ? void 0 : d.credential) != "string" || d.credential.length === 0 || jt(d.credential, t, {
2465
2567
  emitSuccess: w,
2466
2568
  emitError: P,
2467
2569
  isDone: () => n
@@ -2472,29 +2574,29 @@ function zt(t) {
2472
2574
  context: "signin"
2473
2575
  });
2474
2576
  try {
2475
- o.prompt((l) => {
2476
- var _, A, D, a;
2577
+ o.prompt((d) => {
2578
+ var I, A, D, a;
2477
2579
  if (!n) {
2478
- if ((_ = l.isDismissedMoment) != null && _.call(l)) {
2479
- const m = (A = l.getDismissedReason) == null ? void 0 : A.call(l);
2580
+ if ((I = d.isDismissedMoment) != null && I.call(d)) {
2581
+ const m = (A = d.getDismissedReason) == null ? void 0 : A.call(d);
2480
2582
  if (m === "credential_returned" || m === "cancel_called") return;
2481
- p();
2583
+ f();
2482
2584
  return;
2483
2585
  }
2484
- ((D = l.isNotDisplayed) != null && D.call(l) || (a = l.isSkippedMoment) != null && a.call(l)) && p();
2586
+ ((D = d.isNotDisplayed) != null && D.call(d) || (a = d.isSkippedMoment) != null && a.call(d)) && f();
2485
2587
  }
2486
2588
  });
2487
- } catch (l) {
2488
- P(l, "Failed to prompt Google One Tap.");
2589
+ } catch (d) {
2590
+ P(d, "Failed to prompt Google One Tap.");
2489
2591
  }
2490
2592
  }
2491
2593
  })(), h;
2492
2594
  };
2493
2595
  }
2494
- async function xt(t, e, s) {
2596
+ async function jt(t, e, i) {
2495
2597
  var P;
2496
- const { emitSuccess: i, emitError: n, isDone: o } = s, c = e.authClient;
2497
- if (!((P = c.oneTap) != null && P.callback)) {
2598
+ const { emitSuccess: s, emitError: n, isDone: o } = i, l = e.authClient;
2599
+ if (!((P = l.oneTap) != null && P.callback)) {
2498
2600
  n(
2499
2601
  new L(
2500
2602
  "Google One Tap endpoint not registered. Update the EdgeSpark sidecar.",
@@ -2505,7 +2607,7 @@ async function xt(t, e, s) {
2505
2607
  return;
2506
2608
  }
2507
2609
  try {
2508
- const w = await c.oneTap.callback({ idToken: t });
2610
+ const w = await l.oneTap.callback({ idToken: t });
2509
2611
  if (o()) return;
2510
2612
  if (w.error) {
2511
2613
  n(
@@ -2526,17 +2628,17 @@ async function xt(t, e, s) {
2526
2628
  n(w, "Google One Tap sign-in failed.");
2527
2629
  return;
2528
2630
  }
2529
- let h = null, p = null;
2631
+ let h = null, f = null;
2530
2632
  try {
2531
2633
  const w = await V(e.authClient);
2532
2634
  if (o()) return;
2533
- h = w.user, p = w.session;
2635
+ h = w.user, f = w.session;
2534
2636
  } catch (w) {
2535
2637
  if (o()) return;
2536
2638
  n(w, "Sign-in succeeded but session lookup failed.");
2537
2639
  return;
2538
2640
  }
2539
- if (!h || !p) {
2641
+ if (!h || !f) {
2540
2642
  n(
2541
2643
  new L(
2542
2644
  "Google One Tap completed without an authenticated session.",
@@ -2546,22 +2648,22 @@ async function xt(t, e, s) {
2546
2648
  );
2547
2649
  return;
2548
2650
  }
2549
- i(h, p);
2651
+ s(h, f);
2550
2652
  }
2551
- const x = /* @__PURE__ */ new WeakMap();
2552
- function jt(t) {
2653
+ const H = /* @__PURE__ */ new WeakMap();
2654
+ function qt(t) {
2553
2655
  if (!t)
2554
2656
  throw new b(
2555
2657
  "authUI.mount(container, options) requires either { redirectTo } or { onSuccess }."
2556
2658
  );
2557
- const e = "redirectTo" in t, s = "onSuccess" in t && typeof t.onSuccess == "function";
2558
- if (!e && !s)
2659
+ const e = "redirectTo" in t, i = "onSuccess" in t && typeof t.onSuccess == "function";
2660
+ if (!e && !i)
2559
2661
  throw new b(
2560
2662
  "authUI.mount(container, options) requires either { redirectTo } or { onSuccess }."
2561
2663
  );
2562
2664
  if ("redirectTo" in t) {
2563
- const i = t.redirectTo;
2564
- if (!(typeof i == "string" || i instanceof URL))
2665
+ const s = t.redirectTo;
2666
+ if (!(typeof s == "string" || s instanceof URL))
2565
2667
  throw new b(
2566
2668
  "authUI.mount(container, options) expected redirectTo to be a string or URL."
2567
2669
  );
@@ -2575,25 +2677,25 @@ function jt(t) {
2575
2677
  "authUI.mount(container, options) expected onError to be a function."
2576
2678
  );
2577
2679
  if ("appearance" in t && t.appearance !== void 0) {
2578
- const i = t.appearance;
2579
- if (!i || typeof i != "object" || Array.isArray(i))
2680
+ const s = t.appearance;
2681
+ if (!s || typeof s != "object" || Array.isArray(s))
2580
2682
  throw new b(
2581
2683
  "authUI.mount(container, options) expected appearance to be an object."
2582
2684
  );
2583
- if ("theme" in i && i.theme !== void 0 && !Lt(i.theme))
2685
+ if ("theme" in s && s.theme !== void 0 && !Lt(s.theme))
2584
2686
  throw new b(
2585
- `authUI.mount(container, options) expected appearance.theme to be one of: ${Ge.join(", ")}.`
2687
+ `authUI.mount(container, options) expected appearance.theme to be one of: ${xe.join(", ")}.`
2586
2688
  );
2587
- if ("className" in i && i.className !== void 0 && typeof i.className != "string")
2689
+ if ("className" in s && s.className !== void 0 && typeof s.className != "string")
2588
2690
  throw new b(
2589
2691
  "authUI.mount(container, options) expected appearance.className to be a string."
2590
2692
  );
2591
- if ("variables" in i && i.variables !== void 0) {
2592
- if (!i.variables || typeof i.variables != "object" || Array.isArray(i.variables))
2693
+ if ("variables" in s && s.variables !== void 0) {
2694
+ if (!s.variables || typeof s.variables != "object" || Array.isArray(s.variables))
2593
2695
  throw new b(
2594
2696
  "authUI.mount(container, options) expected appearance.variables to be an object."
2595
2697
  );
2596
- for (const [n, o] of Object.entries(i.variables)) {
2698
+ for (const [n, o] of Object.entries(s.variables)) {
2597
2699
  if (!At(n))
2598
2700
  throw new b(
2599
2701
  `authUI.mount(container, options) received unsupported appearance.variables key "${n}".`
@@ -2606,32 +2708,32 @@ function jt(t) {
2606
2708
  }
2607
2709
  }
2608
2710
  }
2609
- function qt(t) {
2711
+ function Kt(t) {
2610
2712
  if (!(t instanceof HTMLElement))
2611
2713
  throw new b("authUI.mount(container, options) requires a real HTMLElement container.");
2612
2714
  }
2613
2715
  function Wt(t, e) {
2614
- const s = zt({
2716
+ const i = Ht({
2615
2717
  authClient: e.publicAuthClient,
2616
- loadConfig: Ce
2718
+ loadConfig: Te
2617
2719
  });
2618
2720
  return {
2619
- mount(i, n) {
2620
- var p;
2621
- jt(n), qt(i), (p = x.get(i)) == null || p.destroy();
2622
- const o = new Ot(i, t, n, Ce, e), c = o.destroy.bind(o), h = {
2721
+ mount(s, n) {
2722
+ var f;
2723
+ qt(n), Kt(s), (f = H.get(s)) == null || f.destroy();
2724
+ const o = new Bt(s, t, n, Te, e), l = o.destroy.bind(o), h = {
2623
2725
  destroy() {
2624
- c(), x.get(i) === h && x.delete(i);
2726
+ l(), H.get(s) === h && H.delete(s);
2625
2727
  }
2626
2728
  };
2627
- return x.set(i, h), h;
2729
+ return H.set(s, h), h;
2628
2730
  },
2629
- promptGoogleOneTap: s
2731
+ promptGoogleOneTap: i
2630
2732
  };
2631
2733
  }
2632
- function Yt() {
2633
- $e();
2634
- const t = mt(), e = ft(), s = je(), i = Wt(e, {
2734
+ function Jt() {
2735
+ Ue();
2736
+ const t = mt(), e = ft(), i = je(), s = Wt(e, {
2635
2737
  syncPublicSession: async () => {
2636
2738
  await ht(t);
2637
2739
  },
@@ -2639,34 +2741,34 @@ function Yt() {
2639
2741
  });
2640
2742
  return {
2641
2743
  auth: t,
2642
- api: s,
2643
- authUI: i
2744
+ api: i,
2745
+ authUI: s
2644
2746
  };
2645
2747
  }
2646
2748
  export {
2647
- _t as AUTH_UI_APPEARANCE_VARIABLE,
2648
- It as AUTH_UI_APPEARANCE_VARIABLE_NAMES,
2749
+ It as AUTH_UI_APPEARANCE_VARIABLE,
2750
+ _t as AUTH_UI_APPEARANCE_VARIABLE_NAMES,
2649
2751
  Pt as AUTH_UI_DEFAULT_THEME,
2650
2752
  Ve as AUTH_UI_THEME,
2651
- Ge as AUTH_UI_THEMES,
2753
+ xe as AUTH_UI_THEMES,
2652
2754
  Et as AUTH_UI_THEME_DARK,
2653
2755
  Fe as AUTH_UI_THEME_LIGHT,
2654
2756
  L as EdgeSparkAuthError,
2655
2757
  b as EdgeSparkConfigError,
2656
- le as EdgeSparkError,
2657
- Ue as EdgeSparkRuntimeError,
2658
- Pe as ar,
2659
- Yt as createEdgeSpark,
2758
+ ae as EdgeSparkError,
2759
+ $e as EdgeSparkRuntimeError,
2760
+ Ee as ar,
2761
+ Jt as createEdgeSpark,
2660
2762
  ye as de,
2661
2763
  St as detectLocale,
2662
2764
  j as enUS,
2663
2765
  Z as es,
2664
- ve as fr,
2665
- _e as hi,
2666
- Se as it,
2667
- pe as ja,
2668
- we as ko,
2669
- be as ptBR,
2670
- Ee as ru,
2766
+ be as fr,
2767
+ Pe as hi,
2768
+ ve as it,
2769
+ ge as ja,
2770
+ pe as ko,
2771
+ we as ptBR,
2772
+ Se as ru,
2671
2773
  X as zhCN
2672
2774
  };