@edgespark/web 0.0.1-beta.7 → 0.0.1

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,25 +1,25 @@
1
- import { createAuthClient as Ue } from "better-auth/client";
2
- class ee extends Error {
1
+ import { createAuthClient as Be } from "better-auth/client";
2
+ class te extends Error {
3
3
  constructor(e, s) {
4
4
  super(s), this.name = "EdgeSparkError", this.code = e;
5
5
  }
6
6
  }
7
- class f extends ee {
7
+ class p extends te {
8
8
  constructor(e) {
9
9
  super("CONFIG_ERROR", e), this.name = "EdgeSparkConfigError";
10
10
  }
11
11
  }
12
- class ye extends ee {
12
+ class Se extends te {
13
13
  constructor(e) {
14
14
  super("RUNTIME_ERROR", e), this.name = "EdgeSparkRuntimeError";
15
15
  }
16
16
  }
17
- class v extends ee {
17
+ class v extends te {
18
18
  constructor(e, s) {
19
19
  super((s == null ? void 0 : s.code) ?? "AUTH_ERROR", e), this.name = "EdgeSparkAuthError", this.cause = s == null ? void 0 : s.cause, this.status = s == null ? void 0 : s.status;
20
20
  }
21
21
  }
22
- function Se(t, e = "Authentication failed.", s) {
22
+ function Pe(t, e = "Authentication failed.", s) {
23
23
  if (t instanceof v)
24
24
  return t;
25
25
  if (typeof t == "object" && t !== null) {
@@ -32,42 +32,46 @@ function Se(t, e = "Authentication failed.", s) {
32
32
  }
33
33
  return typeof t == "string" ? new v(t, { code: s }) : new v(e, { code: s, cause: t });
34
34
  }
35
- function Pe() {
35
+ function Ee() {
36
36
  if (typeof window > "u" || typeof document > "u")
37
- throw new ye(
37
+ throw new Se(
38
38
  "@edgespark/web is browser-only. Create the client from a real browser runtime."
39
39
  );
40
40
  }
41
- function Q() {
42
- return Pe(), window.location.origin;
41
+ function X() {
42
+ return Ee(), window.location.origin;
43
43
  }
44
- function Be(t) {
44
+ function ke(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 ke(t) {
48
- if (t.origin !== Q())
49
- throw new f(
50
- `Cross-origin requests are not supported by this SDK. Received ${t.origin}, expected ${Q()}.`
47
+ function Me(t) {
48
+ if (t.origin !== X())
49
+ throw new p(
50
+ `Cross-origin requests are not supported by this SDK. Received ${t.origin}, expected ${X()}.`
51
51
  );
52
52
  }
53
- function Me() {
53
+ function Oe() {
54
54
  return {
55
55
  async fetch(t, e) {
56
- const s = Be(t);
57
- return ke(s), fetch(t, {
56
+ const s = ke(t);
57
+ return Me(s), fetch(t, {
58
58
  ...e,
59
59
  credentials: "include"
60
60
  });
61
61
  }
62
62
  };
63
63
  }
64
- const Ee = "/api/_es/auth", Oe = "edgespark-auth-session", Le = "__edgespark_auth_sync__", N = "__edgespark_auth_pending_sign_in__", _e = Symbol("edgespark.notifyAuthTabs"), Ve = 10 * 60 * 1e3, Ne = /* @__PURE__ */ new Set([
64
+ const Le = "/api/_es/auth", Ve = "edgespark-auth-session", _e = "__edgespark_auth_sync__", F = "__edgespark_auth_pending_sign_in__", Re = Symbol("edgespark.notifyAuthTabs"), Ne = 10 * 60 * 1e3, Fe = /* @__PURE__ */ new Set([
65
65
  "signOut",
66
66
  "revokeSession",
67
67
  "revokeSessions",
68
68
  "revokeOtherSessions"
69
+ ]), ze = /* @__PURE__ */ new Map([
70
+ ["changeEmail", "changeEmail() is not currently supported by EdgeSpark platform auth."],
71
+ ["deleteUser", "deleteUser() is not currently supported by EdgeSpark platform auth."],
72
+ ["deleteUserCallback", "deleteUserCallback() is not currently supported by EdgeSpark platform auth."]
69
73
  ]);
70
- class Fe {
74
+ class De {
71
75
  constructor(e) {
72
76
  this.value = e;
73
77
  }
@@ -75,32 +79,32 @@ class Fe {
75
79
  return this.value;
76
80
  }
77
81
  }
78
- const ie = globalThis.WeakRef, ne = globalThis.FinalizationRegistry;
79
- let F, re = !1;
80
- const C = /* @__PURE__ */ new Map(), z = ne ? new ne((t) => {
81
- C.delete(t);
82
+ const ne = globalThis.WeakRef, re = globalThis.FinalizationRegistry;
83
+ let z, oe = !1;
84
+ const $ = /* @__PURE__ */ new Map(), D = re ? new re((t) => {
85
+ $.delete(t);
82
86
  }) : null;
83
- function Ie(t) {
84
- return Ue({
85
- baseURL: Q(),
86
- basePath: Ee,
87
+ function Te(t) {
88
+ return Be({
89
+ baseURL: X(),
90
+ basePath: Le,
87
91
  ...t != null && t.disableDefaultRedirectPlugin ? { disableDefaultFetchPlugins: !0 } : {},
88
92
  fetchOptions: {
89
93
  credentials: "include"
90
94
  }
91
95
  });
92
96
  }
93
- function R(t) {
97
+ function U(t) {
94
98
  var e, s;
95
99
  return (s = (e = t.$store) == null ? void 0 : e.atoms) == null ? void 0 : s.session;
96
100
  }
97
- function ze(t) {
101
+ function qe(t) {
98
102
  return JSON.stringify({
99
103
  source: t,
100
104
  timestamp: Date.now()
101
105
  });
102
106
  }
103
- function De(t) {
107
+ function He(t) {
104
108
  if (typeof t != "string")
105
109
  return null;
106
110
  try {
@@ -110,44 +114,53 @@ function De(t) {
110
114
  return null;
111
115
  }
112
116
  }
113
- async function X(t) {
117
+ function je(t) {
118
+ return t.join(".");
119
+ }
120
+ function xe(t) {
121
+ const e = je(t), s = ze.get(e);
122
+ return s ? new v(s, {
123
+ code: "UNSUPPORTED_AUTH_METHOD"
124
+ }) : null;
125
+ }
126
+ async function ee(t) {
114
127
  var e;
115
128
  try {
116
- return await ((e = R(t)) == null ? void 0 : e.get().refetch()), !0;
129
+ return await ((e = U(t)) == null ? void 0 : e.get().refetch()), !0;
117
130
  } catch {
118
131
  return !1;
119
132
  }
120
133
  }
121
- function Re() {
122
- return F === void 0 && (F = typeof BroadcastChannel < "u" ? new BroadcastChannel(Oe) : null), F;
134
+ function Ie() {
135
+ return z === void 0 && (z = typeof BroadcastChannel < "u" ? new BroadcastChannel(Ve) : null), z;
123
136
  }
124
- function oe(t) {
125
- const e = De(t);
137
+ function ae(t) {
138
+ const e = He(t);
126
139
  if (e)
127
- for (const [s, i] of C) {
140
+ for (const [s, i] of $) {
128
141
  if (s === e.source)
129
142
  continue;
130
143
  const n = i.deref();
131
144
  if (!n) {
132
- C.delete(s);
145
+ $.delete(s);
133
146
  continue;
134
147
  }
135
- X(n);
148
+ ee(n);
136
149
  }
137
150
  }
138
- function qe() {
151
+ function We() {
139
152
  var t;
140
- re || (re = !0, (t = Re()) == null || t.addEventListener("message", (e) => {
141
- oe(e.data);
153
+ oe || (oe = !0, (t = Ie()) == null || t.addEventListener("message", (e) => {
154
+ ae(e.data);
142
155
  }), typeof window < "u" && window.addEventListener("storage", (e) => {
143
- e.key !== Le || e.newValue === null || oe(e.newValue);
156
+ e.key !== _e || e.newValue === null || ae(e.newValue);
144
157
  }));
145
158
  }
146
- function je(t, e) {
147
- ie ? C.set(t, new ie(e)) : (C.clear(), C.set(t, new Fe(e))), z == null || z.register(e, t), qe();
159
+ function Ge(t, e) {
160
+ ne ? $.set(t, new ne(e)) : ($.clear(), $.set(t, new De(e))), D == null || D.register(e, t), We();
148
161
  }
149
- function I(t) {
150
- const e = ze(t), s = Re();
162
+ function C(t) {
163
+ const e = qe(t), s = Ie();
151
164
  let i = !1;
152
165
  if (s)
153
166
  try {
@@ -156,15 +169,15 @@ function I(t) {
156
169
  }
157
170
  if (!i)
158
171
  try {
159
- window.localStorage.setItem(Le, e);
172
+ window.localStorage.setItem(_e, e);
160
173
  } catch {
161
174
  }
162
175
  }
163
- function D(t) {
176
+ function q(t) {
164
177
  if (!(typeof window > "u"))
165
178
  try {
166
179
  window.sessionStorage.setItem(
167
- N,
180
+ F,
168
181
  JSON.stringify({
169
182
  path: t,
170
183
  createdAt: Date.now()
@@ -173,130 +186,162 @@ function D(t) {
173
186
  } catch {
174
187
  }
175
188
  }
176
- function $() {
189
+ function A() {
177
190
  if (!(typeof window > "u"))
178
191
  try {
179
- window.sessionStorage.removeItem(N);
192
+ window.sessionStorage.removeItem(F);
180
193
  } catch {
181
194
  }
182
195
  }
183
- function He(t) {
196
+ function Ke(t) {
184
197
  return !!(t != null && t.session && (t != null && t.user));
185
198
  }
186
- function Te() {
199
+ function h(t) {
200
+ return t instanceof Date ? t.toISOString() : t === null || typeof t == "string" || typeof t == "number" || typeof t == "boolean" ? t : t == null ? null : String(t);
201
+ }
202
+ function Ye(t) {
203
+ return t ? JSON.stringify({
204
+ session: {
205
+ createdAt: h(t.session.createdAt),
206
+ expiresAt: h(t.session.expiresAt),
207
+ id: h(t.session.id),
208
+ impersonatedBy: h(t.session.impersonatedBy),
209
+ ipAddress: h(t.session.ipAddress),
210
+ token: h(t.session.token),
211
+ updatedAt: h(t.session.updatedAt),
212
+ userAgent: h(t.session.userAgent),
213
+ userId: h(t.session.userId)
214
+ },
215
+ user: {
216
+ banExpires: h(t.user.banExpires),
217
+ banReason: h(t.user.banReason),
218
+ banned: h(t.user.banned),
219
+ createdAt: h(t.user.createdAt),
220
+ email: h(t.user.email),
221
+ emailVerified: h(t.user.emailVerified),
222
+ id: h(t.user.id),
223
+ image: h(t.user.image),
224
+ lastLoginAt: h(t.user.lastLoginAt),
225
+ name: h(t.user.name),
226
+ role: h(t.user.role),
227
+ updatedAt: h(t.user.updatedAt)
228
+ }
229
+ }) : "__null__";
230
+ }
231
+ function Ce() {
187
232
  if (typeof window > "u")
188
233
  return null;
189
234
  try {
190
- const t = window.sessionStorage.getItem(N);
235
+ const t = window.sessionStorage.getItem(F);
191
236
  if (!t)
192
237
  return null;
193
238
  const e = JSON.parse(t);
194
- return !e || typeof e != "object" || typeof e.createdAt != "number" || Date.now() - e.createdAt > Ve ? null : { createdAt: e.createdAt };
239
+ return !e || typeof e != "object" || typeof e.createdAt != "number" || Date.now() - e.createdAt > Ne ? null : { createdAt: e.createdAt };
195
240
  } catch {
196
241
  return null;
197
242
  }
198
243
  }
199
- function ae() {
200
- if (!Te())
244
+ function le() {
245
+ if (!Ce())
201
246
  return !1;
202
247
  try {
203
- window.sessionStorage.removeItem(N);
248
+ window.sessionStorage.removeItem(F);
204
249
  } catch {
205
250
  }
206
251
  return !0;
207
252
  }
208
- function xe() {
209
- return Te() !== null;
253
+ function Je() {
254
+ return Ce() !== null;
210
255
  }
211
- function We(t) {
256
+ function Ze(t) {
212
257
  if (!(t && typeof t == "object") || "error" in t && t.error)
213
258
  return !1;
214
259
  const e = "data" in t ? t.data : t;
215
260
  return e && typeof e == "object" ? "token" in e && typeof e.token == "string" && e.token.length > 0 ? !0 : "session" in e && "user" in e && !!e.session && !!e.user : !1;
216
261
  }
217
- function Ge(t) {
262
+ function Qe(t) {
218
263
  if (!(t && typeof t == "object") || "error" in t && t.error)
219
264
  return !1;
220
265
  const e = "data" in t ? t.data : t;
221
266
  return e && typeof e == "object" ? "url" in e && typeof e.url == "string" : !1;
222
267
  }
223
- function Ye(t) {
224
- if (T(t) || !(t && typeof t == "object"))
268
+ function Xe(t) {
269
+ if (L(t) || !(t && typeof t == "object"))
225
270
  return !1;
226
271
  const e = "data" in t ? t.data : t;
227
272
  return e && typeof e == "object" ? "user" in e && !!e.user && "token" in e && e.token === null && !("url" in e) : !1;
228
273
  }
229
- function Ke(t, e) {
274
+ function et(t, e) {
230
275
  if (t.length !== 1 || t[0] !== "changePassword")
231
276
  return !1;
232
277
  const [s] = e;
233
278
  return !!(s && typeof s == "object" && "revokeOtherSessions" in s && s.revokeOtherSessions === !0);
234
279
  }
235
- function T(t) {
280
+ function L(t) {
236
281
  return !!(t && typeof t == "object" && "error" in t && t.error);
237
282
  }
238
- function Je(t) {
239
- if (T(t) || !(t && typeof t == "object"))
283
+ function tt(t) {
284
+ if (L(t) || !(t && typeof t == "object"))
240
285
  return !1;
241
286
  const e = "data" in t ? t.data : t;
242
287
  return e && typeof e == "object" ? "message" in e && e.message === "User deleted" : !1;
243
288
  }
244
- function Ze(t) {
289
+ function st(t) {
245
290
  return !!(t && (typeof t == "object" || typeof t == "function") && "then" in t && typeof t.then == "function");
246
291
  }
247
- function q(t) {
248
- return Se(t, "Failed to load the current session.", "SESSION_LOOKUP_FAILED");
292
+ function H(t) {
293
+ return Pe(t, "Failed to load the current session.", "SESSION_LOOKUP_FAILED");
249
294
  }
250
- async function Qe(t) {
295
+ async function it(t) {
251
296
  var s, i;
252
297
  let e = null;
253
298
  try {
254
- await ((s = R(t)) == null ? void 0 : s.get().refetch());
299
+ await ((s = U(t)) == null ? void 0 : s.get().refetch());
255
300
  } catch (n) {
256
301
  e = n;
257
302
  } finally {
258
- (i = t[_e]) == null || i.call(t);
303
+ (i = t[Re]) == null || i.call(t);
259
304
  }
260
305
  if (e)
261
306
  throw e;
262
307
  }
263
- function Xe() {
264
- const t = Ie(), e = `${Date.now()}-${Math.random().toString(36).slice(2)}`;
265
- je(e, t);
308
+ function nt() {
309
+ const t = Te(), e = `${Date.now()}-${Math.random().toString(36).slice(2)}`;
310
+ Ge(e, t);
266
311
  const s = 2, i = 500;
267
- let n = null, a = !1, h;
268
- const w = (o) => (h = o, o), E = () => {
312
+ let n = null, a = !1, m;
313
+ const b = (o) => (m = o, o), _ = () => {
269
314
  var c;
270
- const o = (c = R(t)) == null ? void 0 : c.get();
271
- return o != null && o.error && !o.data && h !== void 0 ? h : (o == null ? void 0 : o.data) ?? h ?? null;
272
- }, L = () => a ? Promise.resolve(E()) : (n || (n = (async () => {
273
- var l, u, g;
315
+ const o = (c = U(t)) == null ? void 0 : c.get();
316
+ return o != null && o.error && !o.data && m !== void 0 ? m : (o == null ? void 0 : o.data) ?? m ?? null;
317
+ }, R = () => a ? Promise.resolve(_()) : (n || (n = (async () => {
318
+ var l, u, y;
274
319
  let o = !1, c = null;
275
320
  try {
276
- for (let p = 0; p <= s; p++) {
321
+ for (let g = 0; g <= s; g++) {
277
322
  let d = null;
278
323
  try {
279
324
  d = await t.getSession();
280
- } catch (y) {
281
- c = y;
325
+ } catch (S) {
326
+ c = S;
282
327
  }
283
- const b = ((l = R(t)) == null ? void 0 : l.get().data) ?? null;
284
- if ((u = d == null ? void 0 : d.data) != null && u.session && ((g = d.data) != null && g.user))
285
- return a = !0, ae() && I(e), w(d.data);
286
- if (b != null && b.session && (b != null && b.user))
287
- return a = !0, ae() && I(e), w(b);
288
- if (d != null && d.error ? c = d.error : d && (o = !0), d && !d.error && xe() && p < s) {
328
+ const w = ((l = U(t)) == null ? void 0 : l.get().data) ?? null;
329
+ if ((u = d == null ? void 0 : d.data) != null && u.session && ((y = d.data) != null && y.user))
330
+ return a = !0, le() && C(e), b(d.data);
331
+ if (w != null && w.session && (w != null && w.user))
332
+ return a = !0, le() && C(e), b(w);
333
+ if (d != null && d.error ? c = d.error : d && (o = !0), d && !d.error && Je() && g < s) {
289
334
  await new Promise(
290
- (y) => setTimeout(y, i)
335
+ (S) => setTimeout(S, i)
291
336
  );
292
337
  continue;
293
338
  }
294
339
  if (d && !d.error) {
295
- const y = E();
296
- return a = !0, w(y);
340
+ const S = _();
341
+ return a = !0, b(S);
297
342
  }
298
- p < s && await new Promise(
299
- (y) => setTimeout(y, i)
343
+ g < s && await new Promise(
344
+ (S) => setTimeout(S, i)
300
345
  );
301
346
  }
302
347
  if (!o)
@@ -304,120 +349,124 @@ function Xe() {
304
349
  code: "SESSION_LOOKUP_FAILED",
305
350
  cause: c
306
351
  });
307
- const m = E();
308
- return a = !0, w(m);
309
- } catch (m) {
310
- throw n = null, q(m);
352
+ const f = _();
353
+ return a = !0, b(f);
354
+ } catch (f) {
355
+ throw n = null, H(f);
311
356
  }
312
357
  })()), n);
313
- L().catch(() => {
358
+ R().catch(() => {
314
359
  });
315
- const _ = async () => {
360
+ const T = async () => {
316
361
  var o, c;
317
362
  try {
318
363
  const l = await t.getSession();
319
364
  if ((o = l.data) != null && o.session && ((c = l.data) != null && c.user))
320
365
  return l.data;
321
- throw l.error ? q(l.error) : new v("No authenticated session is available.", {
366
+ throw l.error ? H(l.error) : new v("No authenticated session is available.", {
322
367
  code: "UNAUTHENTICATED"
323
368
  });
324
369
  } catch (l) {
325
- throw q(l);
370
+ throw H(l);
326
371
  }
327
- }, A = async () => {
328
- await X(t), I(e);
329
- }, Ce = async () => {
372
+ }, I = async () => {
373
+ await ee(t), C(e);
374
+ }, Ae = async () => {
330
375
  var l;
331
- const o = await X(t), c = ((l = R(t)) == null ? void 0 : l.get().data) ?? null;
332
- He(c) ? ($(), I(e)) : o || I(e);
333
- }, Ae = (o) => {
376
+ const o = await ee(t), c = ((l = U(t)) == null ? void 0 : l.get().data) ?? null;
377
+ Ke(c) ? (A(), C(e)) : o || C(e);
378
+ }, Ue = (o) => {
334
379
  let c = !1, l = !1, u;
335
- const g = (d) => {
336
- d !== u && (u = d, o(d));
380
+ const y = (d) => {
381
+ const w = Ye(d);
382
+ w !== u && (u = w, o(d));
337
383
  };
338
- L().then((d) => {
339
- c || (l = !0, g(w(d)));
384
+ R().then((d) => {
385
+ c || (l = !0, y(b(d)));
340
386
  }).catch(() => {
341
387
  c || (l = !0);
342
388
  });
343
- const m = R(t);
344
- if (!m)
389
+ const f = U(t);
390
+ if (!f)
345
391
  return () => {
346
392
  c = !0;
347
393
  };
348
- const p = m.subscribe((d) => {
394
+ const g = f.subscribe((d) => {
349
395
  if (c || !l || d.error && !d.data)
350
396
  return;
351
- const b = d.data ?? null;
352
- g(w(b));
397
+ const w = d.data ?? null;
398
+ y(b(w));
353
399
  });
354
400
  return () => {
355
- c = !0, p();
401
+ c = !0, g();
356
402
  };
357
403
  }, $e = async (o, c, l) => {
358
- const u = o[0], g = o.length >= 2 && u === "emailOtp" && o[1] === "verifyEmail";
359
- return o.length === 1 && (u === "deleteUser" || u === "deleteUserCallback") ? ($(), Je(l) && await A(), l) : o.length === 1 && u && Ne.has(u) ? ($(), T(l) || await A(), l) : Ke(o, c) && !T(l) ? ($(), await A(), l) : o.length === 1 && u === "changeEmail" && !T(l) ? (await A(), l) : ((u === "signIn" || u === "signUp" || g) && We(l) ? ($(), await A()) : (u === "signIn" || u === "signUp") && Ge(l) || u === "signUp" && Ye(l) ? D(o) : u === "verifyEmail" && !T(l) && (D(o), await Ce()), l);
360
- }, te = /* @__PURE__ */ new WeakMap(), se = (o, c) => {
404
+ const u = o[0], y = o.length >= 2 && u === "emailOtp" && o[1] === "verifyEmail", f = o.length >= 2 && u === "emailOtp" && o[1] === "resetPassword", g = o.length >= 2 && u === "resetPassword" && o[1] === "emailOtp";
405
+ return o.length === 1 && (u === "deleteUser" || u === "deleteUserCallback") ? (A(), tt(l) && await I(), l) : o.length === 1 && u && Fe.has(u) ? (A(), L(l) || await I(), l) : et(o, c) && !L(l) ? (A(), await I(), l) : (f || g) && !L(l) ? (A(), await I(), l) : o.length === 1 && u === "changeEmail" && !L(l) ? (await I(), l) : ((u === "signIn" || u === "signUp" || y) && Ze(l) ? (A(), await I()) : (u === "signIn" || u === "signUp") && Qe(l) || u === "signUp" && Xe(l) ? q(o) : u === "verifyEmail" && !L(l) && (q(o), await Ae()), l);
406
+ }, se = /* @__PURE__ */ new WeakMap(), ie = (o, c) => {
361
407
  if (!o || typeof o != "object" && typeof o != "function")
362
408
  return o;
363
- const l = te.get(o);
409
+ const l = se.get(o);
364
410
  if (l)
365
411
  return l;
366
412
  const u = new Proxy(o, {
367
- get(g, m, p) {
413
+ get(y, f, g) {
368
414
  if (c.length === 0) {
369
- if (m === "requireSession")
370
- return _;
371
- if (m === "onSessionChange")
372
- return Ae;
373
- if (m === _e)
415
+ if (f === "requireSession")
416
+ return T;
417
+ if (f === "onSessionChange")
418
+ return Ue;
419
+ if (f === Re)
374
420
  return () => {
375
- I(e);
421
+ C(e);
376
422
  };
377
423
  }
378
- const d = Reflect.get(g, m, p);
379
- return typeof m != "string" ? d : se(d, [...c, m]);
424
+ const d = Reflect.get(y, f, g);
425
+ return typeof f != "string" ? d : ie(d, [...c, f]);
380
426
  },
381
- apply(g, m, p) {
382
- const d = Reflect.apply(
383
- g,
384
- m,
385
- p
427
+ apply(y, f, g) {
428
+ const d = xe(c);
429
+ if (d)
430
+ throw d;
431
+ const w = Reflect.apply(
432
+ y,
433
+ f,
434
+ g
386
435
  );
387
- return Ze(d) ? Promise.resolve(d).then(
388
- (b) => $e(c, p, b)
389
- ) : d;
436
+ return st(w) ? Promise.resolve(w).then(
437
+ (S) => $e(c, g, S)
438
+ ) : w;
390
439
  }
391
440
  });
392
- return te.set(o, u), u;
441
+ return se.set(o, u), u;
393
442
  };
394
- return se(t, []);
443
+ return ie(t, []);
395
444
  }
396
- function et() {
397
- return Ie({ disableDefaultRedirectPlugin: !0 });
445
+ function rt() {
446
+ return Te({ disableDefaultRedirectPlugin: !0 });
398
447
  }
399
- function tt(t) {
448
+ function ot(t) {
400
449
  const e = (() => {
401
450
  if (t instanceof URL)
402
451
  return t;
403
452
  const s = t.trim();
404
453
  if (!s)
405
- throw new f("redirectTo must not be an empty string.");
454
+ throw new p("redirectTo must not be an empty string.");
406
455
  try {
407
456
  return new URL(s, window.location.href);
408
457
  } catch {
409
- throw new f(
458
+ throw new p(
410
459
  `redirectTo must be a valid relative path or URL. Received: ${JSON.stringify(t)}`
411
460
  );
412
461
  }
413
462
  })();
414
463
  if (e.protocol !== "http:" && e.protocol !== "https:")
415
- throw new f(
464
+ throw new p(
416
465
  `redirectTo must resolve to an http(s) URL. Received protocol: ${e.protocol}`
417
466
  );
418
467
  return e;
419
468
  }
420
- function st(t, e) {
469
+ function at(t, e) {
421
470
  return e ? {
422
471
  common: { ...t.common, ...e.common },
423
472
  signIn: { ...t.signIn, ...e.signIn },
@@ -429,7 +478,7 @@ function st(t, e) {
429
478
  errors: { ...t.errors, ...e.errors }
430
479
  } : t;
431
480
  }
432
- const V = {
481
+ const N = {
433
482
  common: {
434
483
  loading: "Loading sign-in…",
435
484
  redirecting: "Redirecting…",
@@ -555,7 +604,7 @@ const V = {
555
604
  invalidCode: "请输入 6 位验证码",
556
605
  generic: "出现错误,请稍后重试"
557
606
  }
558
- }, le = {
607
+ }, de = {
559
608
  common: {
560
609
  loading: "サインインを読み込み中…",
561
610
  redirecting: "リダイレクト中…",
@@ -618,7 +667,7 @@ const V = {
618
667
  invalidCode: "6桁の認証コードを入力してください",
619
668
  generic: "エラーが発生しました。もう一度お試しください"
620
669
  }
621
- }, de = {
670
+ }, ce = {
622
671
  common: {
623
672
  loading: "로그인 로딩 중…",
624
673
  redirecting: "리디렉션 중…",
@@ -681,7 +730,7 @@ const V = {
681
730
  invalidCode: "6자리 인증 코드를 입력해 주세요",
682
731
  generic: "문제가 발생했습니다. 다시 시도해 주세요"
683
732
  }
684
- }, H = {
733
+ }, x = {
685
734
  common: {
686
735
  loading: "Cargando inicio de sesión…",
687
736
  redirecting: "Redirigiendo…",
@@ -744,7 +793,7 @@ const V = {
744
793
  invalidCode: "Ingresa el código de verificación de 6 dígitos.",
745
794
  generic: "Algo salió mal. Por favor, inténtalo de nuevo."
746
795
  }
747
- }, ce = {
796
+ }, ue = {
748
797
  common: {
749
798
  loading: "Carregando login…",
750
799
  redirecting: "Redirecionando…",
@@ -807,7 +856,7 @@ const V = {
807
856
  invalidCode: "Insira o código de verificação de 6 dígitos.",
808
857
  generic: "Algo deu errado. Por favor, tente novamente."
809
858
  }
810
- }, ue = {
859
+ }, he = {
811
860
  common: {
812
861
  loading: "Chargement de la connexion…",
813
862
  redirecting: "Redirection…",
@@ -870,7 +919,7 @@ const V = {
870
919
  invalidCode: "Saisissez le code de vérification à 6 chiffres.",
871
920
  generic: "Une erreur est survenue. Veuillez réessayer."
872
921
  }
873
- }, he = {
922
+ }, me = {
874
923
  common: {
875
924
  loading: "Anmeldung wird geladen…",
876
925
  redirecting: "Weiterleitung…",
@@ -933,7 +982,7 @@ const V = {
933
982
  invalidCode: "Geben Sie den 6-stelligen Bestätigungscode ein.",
934
983
  generic: "Etwas ist schiefgelaufen. Bitte versuchen Sie es erneut."
935
984
  }
936
- }, me = {
985
+ }, fe = {
937
986
  common: {
938
987
  loading: "Caricamento accesso…",
939
988
  redirecting: "Reindirizzamento…",
@@ -996,7 +1045,7 @@ const V = {
996
1045
  invalidCode: "Inserisci il codice di verifica a 6 cifre.",
997
1046
  generic: "Qualcosa è andato storto. Riprova."
998
1047
  }
999
- }, fe = {
1048
+ }, we = {
1000
1049
  common: {
1001
1050
  loading: "Загрузка входа…",
1002
1051
  redirecting: "Перенаправление…",
@@ -1059,7 +1108,7 @@ const V = {
1059
1108
  invalidCode: "Введите 6-значный код подтверждения.",
1060
1109
  generic: "Произошла ошибка. Пожалуйста, попробуйте снова."
1061
1110
  }
1062
- }, we = {
1111
+ }, pe = {
1063
1112
  common: {
1064
1113
  loading: "جارٍ تحميل تسجيل الدخول…",
1065
1114
  redirecting: "جارٍ إعادة التوجيه…",
@@ -1185,48 +1234,48 @@ const V = {
1185
1234
  invalidCode: "कृपया 6 अंकों का सत्यापन कोड दर्ज करें।",
1186
1235
  generic: "कुछ गलत हो गई। कृपया फिर से प्रयास करें।"
1187
1236
  }
1188
- }, pe = {
1189
- en: V,
1190
- "en-US": V,
1237
+ }, be = {
1238
+ en: N,
1239
+ "en-US": N,
1191
1240
  zh: j,
1192
1241
  "zh-CN": j,
1193
1242
  "zh-TW": j,
1194
- ja: le,
1195
- "ja-JP": le,
1196
- ko: de,
1197
- "ko-KR": de,
1198
- es: H,
1199
- "es-ES": H,
1200
- "es-MX": H,
1201
- pt: ce,
1202
- "pt-BR": ce,
1203
- fr: ue,
1204
- "fr-FR": ue,
1205
- de: he,
1206
- "de-DE": he,
1207
- it: me,
1208
- "it-IT": me,
1209
- ru: fe,
1210
- "ru-RU": fe,
1211
- ar: we,
1212
- "ar-SA": we,
1243
+ ja: de,
1244
+ "ja-JP": de,
1245
+ ko: ce,
1246
+ "ko-KR": ce,
1247
+ es: x,
1248
+ "es-ES": x,
1249
+ "es-MX": x,
1250
+ pt: ue,
1251
+ "pt-BR": ue,
1252
+ fr: he,
1253
+ "fr-FR": he,
1254
+ de: me,
1255
+ "de-DE": me,
1256
+ it: fe,
1257
+ "it-IT": fe,
1258
+ ru: we,
1259
+ "ru-RU": we,
1260
+ ar: pe,
1261
+ "ar-SA": pe,
1213
1262
  hi: ge,
1214
1263
  "hi-IN": ge
1215
1264
  };
1216
- function it() {
1265
+ function lt() {
1217
1266
  if (typeof navigator > "u")
1218
- return V;
1267
+ return N;
1219
1268
  const t = navigator.languages ?? [navigator.language];
1220
1269
  for (const e of t) {
1221
- const s = pe[e] ?? pe[e.split("-")[0]];
1270
+ const s = be[e] ?? be[e.split("-")[0]];
1222
1271
  if (s) return s;
1223
1272
  }
1224
- return V;
1273
+ return N;
1225
1274
  }
1226
- function x(t, e = "Authentication failed.") {
1227
- return Se(t, e);
1275
+ function W(t, e = "Authentication failed.") {
1276
+ return Pe(t, e);
1228
1277
  }
1229
- async function B(t) {
1278
+ async function k(t) {
1230
1279
  var s, i;
1231
1280
  const e = await t.getSession();
1232
1281
  if (e.error)
@@ -1246,13 +1295,13 @@ async function B(t) {
1246
1295
  session: null
1247
1296
  };
1248
1297
  }
1249
- const nt = "data-edgespark-auth", r = "edgespark-auth", W = "es_auth_completion", k = "es_auth_email", G = "oauth", U = "verify-sign-in", S = "verify-sign-up", be = 200, Y = 2, rt = {
1298
+ const dt = "data-edgespark-auth", r = "edgespark-auth", G = "es_auth_completion", M = "es_auth_email", K = "oauth", B = "verify-sign-in", P = "verify-sign-up", ye = 200, Y = 2, ct = {
1250
1299
  "&": "&amp;",
1251
1300
  "<": "&lt;",
1252
1301
  ">": "&gt;",
1253
1302
  '"': "&quot;",
1254
1303
  "'": "&#39;"
1255
- }, K = {
1304
+ }, J = {
1256
1305
  google: "Google",
1257
1306
  apple: "Apple",
1258
1307
  microsoft: "Microsoft",
@@ -1260,25 +1309,25 @@ const nt = "data-edgespark-auth", r = "edgespark-auth", W = "es_auth_completion"
1260
1309
  gitlab: "GitLab",
1261
1310
  discord: "Discord"
1262
1311
  };
1263
- function P(t) {
1312
+ function E(t) {
1264
1313
  return "redirectTo" in t;
1265
1314
  }
1266
- function J(t) {
1315
+ function Z(t) {
1267
1316
  return "onSuccess" in t && !("redirectTo" in t);
1268
1317
  }
1269
- function Z(t) {
1318
+ function Q(t) {
1270
1319
  return !t || typeof t != "string" ? !1 : /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(t.trim());
1271
1320
  }
1272
- function ot(t) {
1321
+ function ut(t) {
1273
1322
  return /^\d{6}$/.test(t.trim());
1274
1323
  }
1275
- function at(t) {
1324
+ function ht(t) {
1276
1325
  return t === "email" || t === "name" || t === "password" || t === "confirmPassword" || t === "code" || t === "newPassword";
1277
1326
  }
1278
- function lt(t) {
1327
+ function mt(t) {
1279
1328
  return !!(t.error || t.errorDescription);
1280
1329
  }
1281
- class dt {
1330
+ class ft {
1282
1331
  constructor(e, s, i, n, a) {
1283
1332
  this.container = e, this.auth = s, this.options = i, this.loadConfig = n, this.runtimeOptions = a, this.state = {
1284
1333
  view: "loading",
@@ -1292,7 +1341,7 @@ class dt {
1292
1341
  confirmPassword: "",
1293
1342
  code: "",
1294
1343
  newPassword: ""
1295
- }, this.destroyed = !1, this.terminalActionInProgress = !1, this.config = null, this.countdownUntil = null, this.countdownTimer = null, this.pendingFocusSnapshot = null, this.focusRestoreTimer = null, this.verificationCompletionAction = null, this.labels = st(it(), i.labels), this.root = document.createElement("div"), this.root.setAttribute(nt, ""), e.innerHTML = "", e.appendChild(this.root), this.render(), this.initialize();
1344
+ }, this.destroyed = !1, this.terminalActionInProgress = !1, this.config = null, this.countdownUntil = null, this.countdownTimer = null, this.pendingFocusSnapshot = null, this.focusRestoreTimer = null, this.verificationCompletionAction = null, this.labels = at(lt(), i.labels), this.root = document.createElement("div"), this.root.setAttribute(dt, ""), e.innerHTML = "", e.appendChild(this.root), this.render(), this.initialize();
1296
1345
  }
1297
1346
  destroy() {
1298
1347
  this.destroyed || (this.destroyed = !0, this.clearCountdown(), this.clearFocusRestoreTimer(), this.container.innerHTML = "");
@@ -1307,7 +1356,7 @@ class dt {
1307
1356
  if (this.destroyed)
1308
1357
  return;
1309
1358
  if (i.status === "rejected") {
1310
- if (e.marker && !lt(e) && P(this.options)) {
1359
+ if (e.marker && !mt(e) && E(this.options)) {
1311
1360
  this.redirectAfterManagedReturnLookupFailure();
1312
1361
  return;
1313
1362
  }
@@ -1315,11 +1364,11 @@ class dt {
1315
1364
  const a = i.value;
1316
1365
  if (a.user && a.session) {
1317
1366
  switch (e.marker) {
1318
- case G:
1319
- case U:
1367
+ case K:
1368
+ case B:
1320
1369
  await this.completeAuth("sign-in", a);
1321
1370
  return;
1322
- case S:
1371
+ case P:
1323
1372
  await this.completeAuth("sign-up", a);
1324
1373
  return;
1325
1374
  default:
@@ -1342,24 +1391,24 @@ class dt {
1342
1391
  }
1343
1392
  }
1344
1393
  redirectAfterManagedReturnLookupFailure() {
1345
- P(this.options) && this.navigateToRedirect();
1394
+ E(this.options) && this.navigateToRedirect();
1346
1395
  }
1347
1396
  navigateToRedirect() {
1348
- P(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(tt(this.options.redirectTo).toString()));
1397
+ E(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(ot(this.options.redirectTo).toString()));
1349
1398
  }
1350
1399
  async readMountSession(e) {
1351
1400
  if (!e.marker)
1352
- return B(this.auth);
1401
+ return k(this.auth);
1353
1402
  let s = null;
1354
1403
  for (let i = 0; i <= Y; i++) {
1355
1404
  try {
1356
- const n = await B(this.auth);
1405
+ const n = await k(this.auth);
1357
1406
  if (n.user && n.session)
1358
1407
  return n;
1359
1408
  } catch (n) {
1360
1409
  s = n;
1361
1410
  }
1362
- i < Y && await new Promise((n) => setTimeout(n, be));
1411
+ i < Y && await new Promise((n) => setTimeout(n, ye));
1363
1412
  }
1364
1413
  if (s)
1365
1414
  throw s;
@@ -1568,7 +1617,7 @@ class dt {
1568
1617
  <div class="${r}__stack">
1569
1618
  ${e.map((i) => `
1570
1619
  <button class="${r}__button ${r}__button--secondary" type="button" data-action="oauth" data-provider="${i}" ${this.state.busy ? "disabled" : ""}>
1571
- ${this.escape(`${this.labels.oauth.continueWith} ${K[i]}`)}
1620
+ ${this.escape(`${this.labels.oauth.continueWith} ${J[i]}`)}
1572
1621
  </button>
1573
1622
  `).join("")}
1574
1623
  </div>
@@ -1593,12 +1642,12 @@ class dt {
1593
1642
  this.root.querySelectorAll("form[data-view]").forEach((n) => {
1594
1643
  n.addEventListener("submit", (a) => {
1595
1644
  a.preventDefault();
1596
- const h = n.dataset.view;
1597
- h === "sign-in" && this.handleSignIn(), h === "sign-up" && this.handleSignUp(), h === "forgot-password" && this.handleForgotPassword(), h === "reset-password" && this.handleResetPassword();
1645
+ const m = n.dataset.view;
1646
+ m === "sign-in" && this.handleSignIn(), m === "sign-up" && this.handleSignUp(), m === "forgot-password" && this.handleForgotPassword(), m === "reset-password" && this.handleResetPassword();
1598
1647
  });
1599
1648
  }), this.root.querySelectorAll("input[name]").forEach((n) => {
1600
1649
  n.addEventListener("input", () => {
1601
- at(n.name) && (this.state[n.name] = n.value);
1650
+ ht(n.name) && (this.state[n.name] = n.value);
1602
1651
  });
1603
1652
  }), this.root.querySelectorAll("[data-action]").forEach((n) => {
1604
1653
  n.addEventListener("click", () => {
@@ -1611,7 +1660,7 @@ class dt {
1611
1660
  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();
1612
1661
  }
1613
1662
  async handleSignIn() {
1614
- if (!Z(this.state.email)) {
1663
+ if (!Q(this.state.email)) {
1615
1664
  this.failValidation(this.labels.errors.invalidEmail);
1616
1665
  return;
1617
1666
  }
@@ -1623,7 +1672,7 @@ class dt {
1623
1672
  const e = await this.auth.signIn.email({
1624
1673
  email: this.state.email.trim(),
1625
1674
  password: this.state.password,
1626
- callbackURL: this.getManagedReturnURL(U, this.state.email.trim())
1675
+ callbackURL: this.getManagedReturnURL(B, this.state.email.trim())
1627
1676
  });
1628
1677
  if (e.error)
1629
1678
  throw e.error;
@@ -1636,7 +1685,7 @@ class dt {
1636
1685
  this.failValidation(this.labels.errors.requiredField);
1637
1686
  return;
1638
1687
  }
1639
- if (!Z(this.state.email)) {
1688
+ if (!Q(this.state.email)) {
1640
1689
  this.failValidation(this.labels.errors.invalidEmail);
1641
1690
  return;
1642
1691
  }
@@ -1660,7 +1709,7 @@ class dt {
1660
1709
  name: this.state.name.trim(),
1661
1710
  email: this.state.email.trim(),
1662
1711
  password: this.state.password,
1663
- callbackURL: this.getManagedReturnURL(S, this.state.email.trim())
1712
+ callbackURL: this.getManagedReturnURL(P, this.state.email.trim())
1664
1713
  });
1665
1714
  if (i.error)
1666
1715
  throw i.error;
@@ -1672,7 +1721,7 @@ class dt {
1672
1721
  });
1673
1722
  }
1674
1723
  async handleOAuthSignIn(e) {
1675
- await this.runAction(`Redirecting to ${K[e]}…`, async () => {
1724
+ await this.runAction(`Redirecting to ${J[e]}…`, async () => {
1676
1725
  const s = await this.auth.signIn.social({
1677
1726
  provider: e,
1678
1727
  callbackURL: this.getManagedReturnURL("oauth"),
@@ -1682,18 +1731,18 @@ class dt {
1682
1731
  throw s.error;
1683
1732
  const i = this.extractRedirectURL(s.data);
1684
1733
  if (!i)
1685
- throw new f(`OAuth sign-in did not return a redirect URL for provider "${e}".`);
1686
- this.terminalActionInProgress = !0, this.state.busy = !0, this.state.busyLabel = `Opening ${K[e]}…`, this.state.error = null, this.state.notice = null, this.render(), window.location.assign(i);
1734
+ throw new p(`OAuth sign-in did not return a redirect URL for provider "${e}".`);
1735
+ this.terminalActionInProgress = !0, this.state.busy = !0, this.state.busyLabel = `Opening ${J[e]}…`, this.state.error = null, this.state.notice = null, this.render(), window.location.assign(i);
1687
1736
  });
1688
1737
  }
1689
1738
  async handleForgotPassword() {
1690
1739
  if (!this.canUsePasswordResetEmailOtp()) {
1691
1740
  this.handleError(
1692
- new f("Password reset via email OTP is not enabled for this project.")
1741
+ new p("Password reset via email OTP is not enabled for this project.")
1693
1742
  );
1694
1743
  return;
1695
1744
  }
1696
- if (!Z(this.state.email)) {
1745
+ if (!Q(this.state.email)) {
1697
1746
  this.failValidation(this.labels.errors.invalidEmail);
1698
1747
  return;
1699
1748
  }
@@ -1713,11 +1762,11 @@ class dt {
1713
1762
  var e, s;
1714
1763
  if (!this.canUsePasswordResetEmailOtp()) {
1715
1764
  this.handleError(
1716
- new f("Password reset via email OTP is not enabled for this project.")
1765
+ new p("Password reset via email OTP is not enabled for this project.")
1717
1766
  );
1718
1767
  return;
1719
1768
  }
1720
- if (!ot(this.state.code)) {
1769
+ if (!ut(this.state.code)) {
1721
1770
  this.failValidation(this.labels.errors.invalidCode);
1722
1771
  return;
1723
1772
  }
@@ -1754,7 +1803,7 @@ class dt {
1754
1803
  const s = await this.auth.sendVerificationEmail({
1755
1804
  email: this.state.email.trim(),
1756
1805
  callbackURL: this.getManagedReturnURL(
1757
- this.verificationCompletionAction === "sign-up" ? S : U,
1806
+ this.verificationCompletionAction === "sign-up" ? P : B,
1758
1807
  this.state.email.trim()
1759
1808
  )
1760
1809
  });
@@ -1772,12 +1821,12 @@ class dt {
1772
1821
  if (!i.user || !i.session) {
1773
1822
  if (this.destroyed)
1774
1823
  return;
1775
- if (i.lookupError && P(this.options)) {
1824
+ if (i.lookupError && E(this.options)) {
1776
1825
  this.navigateToRedirect();
1777
1826
  return;
1778
1827
  }
1779
1828
  if (e === "sign-in")
1780
- throw i.lookupError ?? new ye(
1829
+ throw i.lookupError ?? new Se(
1781
1830
  "Managed sign-in completed without an authenticated session."
1782
1831
  );
1783
1832
  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();
@@ -1789,11 +1838,11 @@ class dt {
1789
1838
  session: i.session
1790
1839
  };
1791
1840
  if (await this.syncPublicSessionBestEffort(), !this.destroyed) {
1792
- if (P(this.options)) {
1841
+ if (E(this.options)) {
1793
1842
  this.invokeRedirectModeSuccessHook(n), this.navigateToRedirect();
1794
1843
  return;
1795
1844
  }
1796
- if (J(this.options)) {
1845
+ if (Z(this.options)) {
1797
1846
  this.options.onSuccess(n), this.terminalActionInProgress = !0;
1798
1847
  return;
1799
1848
  }
@@ -1804,9 +1853,9 @@ class dt {
1804
1853
  return e;
1805
1854
  let s = e.lookupError;
1806
1855
  for (let i = 0; i < Y; i++) {
1807
- await new Promise((n) => setTimeout(n, be));
1856
+ await new Promise((n) => setTimeout(n, ye));
1808
1857
  try {
1809
- const n = await B(this.auth);
1858
+ const n = await k(this.auth);
1810
1859
  if (n.user && n.session)
1811
1860
  return {
1812
1861
  user: n.user,
@@ -1830,7 +1879,7 @@ class dt {
1830
1879
  }
1831
1880
  async resolveAuthCompletionData(e) {
1832
1881
  try {
1833
- const s = await B(this.auth), i = this.extractUser(e);
1882
+ const s = await k(this.auth), i = this.extractUser(e);
1834
1883
  return {
1835
1884
  user: s.user ?? i,
1836
1885
  session: s.session
@@ -1850,7 +1899,7 @@ class dt {
1850
1899
  session: null
1851
1900
  };
1852
1901
  if (await this.syncPublicSessionBestEffort(), !this.destroyed) {
1853
- if (J(this.options)) {
1902
+ if (Z(this.options)) {
1854
1903
  this.clearCountdown(), this.options.onSuccess(e), this.terminalActionInProgress = !0;
1855
1904
  return;
1856
1905
  }
@@ -1858,12 +1907,12 @@ class dt {
1858
1907
  }
1859
1908
  }
1860
1909
  handleExistingSessionOnMount() {
1861
- if (P(this.options)) {
1910
+ if (E(this.options)) {
1862
1911
  this.navigateToRedirect();
1863
1912
  return;
1864
1913
  }
1865
- if (J(this.options))
1866
- throw this.state.view = "sign-in", this.state.busy = !1, this.state.busyLabel = void 0, this.state.notice = null, new f(
1914
+ if (Z(this.options))
1915
+ throw this.state.view = "sign-in", this.state.busy = !1, this.state.busyLabel = void 0, this.state.notice = null, new p(
1867
1916
  "authUI.mount(container, { onSuccess }) cannot run while a session already exists. Check es.auth.getSession() before mounting controlled auth UI."
1868
1917
  );
1869
1918
  }
@@ -1880,18 +1929,18 @@ class dt {
1880
1929
  !this.destroyed && !this.terminalActionInProgress && (this.state.busy = !1, this.state.busyLabel = void 0, this.render());
1881
1930
  }
1882
1931
  maybeHandleVerificationRequired(e) {
1883
- return x(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);
1932
+ return W(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);
1884
1933
  }
1885
1934
  handleVerificationEmailSent(e, s) {
1886
1935
  this.state.notice = s ? `We sent another verification email to ${e}.` : `We sent a verification email to ${e}.`, this.startCountdown();
1887
1936
  }
1888
1937
  invokeRedirectModeSuccessHook(e) {
1889
1938
  var s, i;
1890
- if (!(!P(this.options) || !this.options.onSuccess))
1939
+ if (!(!E(this.options) || !this.options.onSuccess))
1891
1940
  try {
1892
1941
  this.options.onSuccess(e);
1893
1942
  } catch (n) {
1894
- const a = x(n, "Post-auth callback failed.");
1943
+ const a = W(n, "Post-auth callback failed.");
1895
1944
  try {
1896
1945
  (i = (s = this.options).onError) == null || i.call(s, a);
1897
1946
  } catch {
@@ -1900,7 +1949,7 @@ class dt {
1900
1949
  }
1901
1950
  handleError(e, s) {
1902
1951
  var n, a;
1903
- const i = x(e, s);
1952
+ const i = W(e, s);
1904
1953
  this.state.busy = !1, this.state.busyLabel = void 0, this.state.error = i.message, this.render(), (a = (n = this.options).onError) == null || a.call(n, i);
1905
1954
  }
1906
1955
  failValidation(e) {
@@ -1910,15 +1959,15 @@ class dt {
1910
1959
  if (!e)
1911
1960
  return window.location.href;
1912
1961
  const i = new URL(window.location.href);
1913
- return i.searchParams.set(W, e), s ? i.searchParams.set(k, s) : i.searchParams.delete(k), i.toString();
1962
+ return i.searchParams.set(G, e), s ? i.searchParams.set(M, s) : i.searchParams.delete(M), i.toString();
1914
1963
  }
1915
1964
  consumeManagedReturnContext() {
1916
- const e = new URL(window.location.href), s = e.searchParams.get(W), i = s === G || s === U || s === S ? s : null, n = e.searchParams.get(k), a = i ? e.searchParams.get("error") : null, h = i ? e.searchParams.get("error_description") : null;
1917
- return (i || n) && (e.searchParams.delete(W), e.searchParams.delete(k), i && (e.searchParams.delete("error"), e.searchParams.delete("error_description")), window.history.replaceState(null, "", e.toString())), {
1965
+ const e = new URL(window.location.href), s = e.searchParams.get(G), i = s === K || s === B || s === P ? s : null, n = e.searchParams.get(M), a = i ? e.searchParams.get("error") : null, m = i ? e.searchParams.get("error_description") : null;
1966
+ return (i || n) && (e.searchParams.delete(G), e.searchParams.delete(M), i && (e.searchParams.delete("error"), e.searchParams.delete("error_description")), window.history.replaceState(null, "", e.toString())), {
1918
1967
  marker: i,
1919
1968
  email: n,
1920
1969
  error: a,
1921
- errorDescription: h
1970
+ errorDescription: m
1922
1971
  };
1923
1972
  }
1924
1973
  startCountdown(e = 60) {
@@ -1982,10 +2031,10 @@ class dt {
1982
2031
  return !!((e = this.config) != null && e.passwordResetEmailOtpEnabled);
1983
2032
  }
1984
2033
  handleSessionlessManagedReturn(e) {
1985
- return e.email && (this.state.email = e.email), e.marker === S && !e.error ? (this.verificationCompletionAction = null, this.clearCountdown(), this.state.view = "sign-in", this.state.password = "", this.state.confirmPassword = "", this.state.error = null, this.state.busy = !1, this.state.busyLabel = void 0, this.state.notice = "Account created. Sign in to continue.", this.render(), !0) : e.marker === U || e.marker === S ? (this.verificationCompletionAction = e.marker === S ? "sign-up" : "sign-in", this.state.view = "verify-email", this.state.busy = !1, this.state.busyLabel = void 0, this.state.notice = null, e.error || e.errorDescription ? this.handleError(new v(
2034
+ return e.email && (this.state.email = e.email), e.marker === P && !e.error ? (this.verificationCompletionAction = null, this.clearCountdown(), this.state.view = "sign-in", this.state.password = "", this.state.confirmPassword = "", this.state.error = null, this.state.busy = !1, this.state.busyLabel = void 0, this.state.notice = "Account created. Sign in to continue.", this.render(), !0) : e.marker === B || e.marker === P ? (this.verificationCompletionAction = e.marker === P ? "sign-up" : "sign-in", this.state.view = "verify-email", this.state.busy = !1, this.state.busyLabel = void 0, this.state.notice = null, e.error || e.errorDescription ? this.handleError(new v(
1986
2035
  e.errorDescription ?? "Verification failed. Request a new verification email and try again.",
1987
2036
  { code: e.error ?? "VERIFY_EMAIL_ERROR" }
1988
- )) : this.render(), !0) : e.marker === G && (e.error || e.errorDescription) ? (this.state.view = "sign-in", this.state.busy = !1, this.state.busyLabel = void 0, this.state.notice = null, this.handleError(new v(
2037
+ )) : this.render(), !0) : e.marker === K && (e.error || e.errorDescription) ? (this.state.view = "sign-in", this.state.busy = !1, this.state.busyLabel = void 0, this.state.notice = null, this.handleError(new v(
1989
2038
  e.errorDescription ?? "OAuth sign-in failed.",
1990
2039
  { code: e.error ?? "OAUTH_ERROR" }
1991
2040
  )), !0) : !1;
@@ -2001,106 +2050,106 @@ class dt {
2001
2050
  return i <= 0 ? e : s.replace("{seconds}", String(i));
2002
2051
  }
2003
2052
  escape(e) {
2004
- return e.replace(/[&<>"']/g, (s) => rt[s]);
2053
+ return e.replace(/[&<>"']/g, (s) => ct[s]);
2005
2054
  }
2006
2055
  }
2007
- function ct(t) {
2056
+ function wt(t) {
2008
2057
  return "data" in t && t.data ? t.data : t;
2009
2058
  }
2010
- const ut = [
2059
+ const pt = [
2011
2060
  { id: "google", key: "providerGoogle" },
2012
2061
  { id: "apple", key: "providerApple" },
2013
2062
  { id: "microsoft", key: "providerMicrosoft" },
2014
2063
  { id: "github", key: "providerGithub" },
2015
2064
  { id: "gitlab", key: "providerGitlab" },
2016
2065
  { id: "discord", key: "providerDiscord" }
2017
- ], ve = 2, ht = 500;
2018
- async function mt() {
2019
- const t = `${window.location.origin}${Ee}/config`;
2066
+ ], ve = 2, gt = 500;
2067
+ async function bt() {
2068
+ const t = `${window.location.origin}${Le}/config`;
2020
2069
  let e;
2021
2070
  for (let s = 0; s <= ve; s++)
2022
2071
  try {
2023
2072
  const i = await fetch(t, { method: "GET", credentials: "include" });
2024
2073
  if (!i.ok)
2025
- throw new f(`Failed to load auth config: HTTP ${i.status}`);
2074
+ throw new p(`Failed to load auth config: HTTP ${i.status}`);
2026
2075
  const n = await i.json();
2027
- return wt(ct(n));
2076
+ return vt(wt(n));
2028
2077
  } catch (i) {
2029
- e = i, s < ve && await new Promise((n) => setTimeout(n, ht));
2078
+ e = i, s < ve && await new Promise((n) => setTimeout(n, gt));
2030
2079
  }
2031
2080
  throw e;
2032
2081
  }
2033
- let M = null;
2034
- async function ft() {
2035
- return M || (M = mt().catch((t) => {
2036
- throw M = null, t;
2037
- })), M;
2082
+ let O = null;
2083
+ async function yt() {
2084
+ return O || (O = bt().catch((t) => {
2085
+ throw O = null, t;
2086
+ })), O;
2038
2087
  }
2039
- function wt(t) {
2040
- var s, i, n, a, h, w, E;
2041
- const e = ut.filter(({ key: L }) => {
2042
- const _ = t[L];
2043
- return typeof _ == "object" && _ !== null && "enabled" in _ && !!_.enabled;
2044
- }).map(({ id: L }) => L);
2088
+ function vt(t) {
2089
+ var s, i, n, a, m, b, _;
2090
+ const e = pt.filter(({ key: R }) => {
2091
+ const T = t[R];
2092
+ return typeof T == "object" && T !== null && "enabled" in T && !!T.enabled;
2093
+ }).map(({ id: R }) => R);
2045
2094
  return {
2046
2095
  disableSignUp: !!t.disableSignUp,
2047
2096
  emailPasswordEnabled: !!((s = t.providerEmailPassword) != null && s.enabled),
2048
2097
  minPasswordLength: ((n = (i = t.providerEmailPassword) == null ? void 0 : i.config) == null ? void 0 : n.minPasswordLength) ?? 8,
2049
- requireEmailVerification: !!((h = (a = t.providerEmailPassword) == null ? void 0 : a.config) != null && h.requireEmailVerification),
2050
- passwordResetEmailOtpEnabled: !!((E = (w = t.providerEmailPassword) == null ? void 0 : w.config) != null && E.requirePasswordResetEmailVerification),
2098
+ requireEmailVerification: !!((m = (a = t.providerEmailPassword) == null ? void 0 : a.config) != null && m.requireEmailVerification),
2099
+ passwordResetEmailOtpEnabled: !!((_ = (b = t.providerEmailPassword) == null ? void 0 : b.config) != null && _.requirePasswordResetEmailVerification),
2051
2100
  oauthProviders: e
2052
2101
  };
2053
2102
  }
2054
- const O = /* @__PURE__ */ new WeakMap();
2055
- function gt(t) {
2103
+ const V = /* @__PURE__ */ new WeakMap();
2104
+ function St(t) {
2056
2105
  if (!t)
2057
- throw new f(
2106
+ throw new p(
2058
2107
  "authUI.mount(container, options) requires either { redirectTo } or { onSuccess }."
2059
2108
  );
2060
2109
  const e = "redirectTo" in t, s = "onSuccess" in t && typeof t.onSuccess == "function";
2061
2110
  if (!e && !s)
2062
- throw new f(
2111
+ throw new p(
2063
2112
  "authUI.mount(container, options) requires either { redirectTo } or { onSuccess }."
2064
2113
  );
2065
2114
  if ("redirectTo" in t) {
2066
2115
  const i = t.redirectTo;
2067
2116
  if (!(typeof i == "string" || i instanceof URL))
2068
- throw new f(
2117
+ throw new p(
2069
2118
  "authUI.mount(container, options) expected redirectTo to be a string or URL."
2070
2119
  );
2071
2120
  }
2072
2121
  if ("onSuccess" in t && t.onSuccess !== void 0 && typeof t.onSuccess != "function")
2073
- throw new f(
2122
+ throw new p(
2074
2123
  "authUI.mount(container, options) expected onSuccess to be a function."
2075
2124
  );
2076
2125
  if ("onError" in t && t.onError !== void 0 && typeof t.onError != "function")
2077
- throw new f(
2126
+ throw new p(
2078
2127
  "authUI.mount(container, options) expected onError to be a function."
2079
2128
  );
2080
2129
  }
2081
- function pt(t) {
2130
+ function Pt(t) {
2082
2131
  if (!(t instanceof HTMLElement))
2083
- throw new f("authUI.mount(container, options) requires a real HTMLElement container.");
2132
+ throw new p("authUI.mount(container, options) requires a real HTMLElement container.");
2084
2133
  }
2085
- function bt(t, e) {
2134
+ function Et(t, e) {
2086
2135
  return {
2087
2136
  mount(s, i) {
2088
- var w;
2089
- gt(i), pt(s), (w = O.get(s)) == null || w.destroy();
2090
- const n = new dt(s, t, i, ft, e), a = n.destroy.bind(n), h = {
2137
+ var b;
2138
+ St(i), Pt(s), (b = V.get(s)) == null || b.destroy();
2139
+ const n = new ft(s, t, i, yt, e), a = n.destroy.bind(n), m = {
2091
2140
  destroy() {
2092
- a(), O.get(s) === h && O.delete(s);
2141
+ a(), V.get(s) === m && V.delete(s);
2093
2142
  }
2094
2143
  };
2095
- return O.set(s, h), h;
2144
+ return V.set(s, m), m;
2096
2145
  }
2097
2146
  };
2098
2147
  }
2099
- function yt() {
2100
- Pe();
2101
- const t = Xe(), e = et(), s = Me(), i = bt(e, {
2148
+ function _t() {
2149
+ Ee();
2150
+ const t = nt(), e = rt(), s = Oe(), i = Et(e, {
2102
2151
  syncPublicSession: async () => {
2103
- await Qe(t);
2152
+ await it(t);
2104
2153
  }
2105
2154
  });
2106
2155
  return {
@@ -2111,21 +2160,21 @@ function yt() {
2111
2160
  }
2112
2161
  export {
2113
2162
  v as EdgeSparkAuthError,
2114
- f as EdgeSparkConfigError,
2115
- ee as EdgeSparkError,
2116
- ye as EdgeSparkRuntimeError,
2117
- we as ar,
2118
- yt as createEdgeSpark,
2119
- he as de,
2120
- it as detectLocale,
2121
- V as enUS,
2122
- H as es,
2123
- ue as fr,
2163
+ p as EdgeSparkConfigError,
2164
+ te as EdgeSparkError,
2165
+ Se as EdgeSparkRuntimeError,
2166
+ pe as ar,
2167
+ _t as createEdgeSpark,
2168
+ me as de,
2169
+ lt as detectLocale,
2170
+ N as enUS,
2171
+ x as es,
2172
+ he as fr,
2124
2173
  ge as hi,
2125
- me as it,
2126
- le as ja,
2127
- de as ko,
2128
- ce as ptBR,
2129
- fe as ru,
2174
+ fe as it,
2175
+ de as ja,
2176
+ ce as ko,
2177
+ ue as ptBR,
2178
+ we as ru,
2130
2179
  j as zhCN
2131
2180
  };