@edgespark/web 0.0.1 → 0.0.2

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,15 +1,15 @@
1
- import { createAuthClient as Be } from "better-auth/client";
1
+ import { createAuthClient as Oe } from "better-auth/client";
2
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 p extends te {
7
+ class f extends te {
8
8
  constructor(e) {
9
9
  super("CONFIG_ERROR", e), this.name = "EdgeSparkConfigError";
10
10
  }
11
11
  }
12
- class Se extends te {
12
+ class Ee extends te {
13
13
  constructor(e) {
14
14
  super("RUNTIME_ERROR", e), this.name = "EdgeSparkRuntimeError";
15
15
  }
@@ -19,7 +19,7 @@ class v extends te {
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 Pe(t, e = "Authentication failed.", s) {
22
+ function Se(t, e = "Authentication failed.", s) {
23
23
  if (t instanceof v)
24
24
  return t;
25
25
  if (typeof t == "object" && t !== null) {
@@ -32,46 +32,55 @@ function Pe(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 Ee() {
35
+ function Pe() {
36
36
  if (typeof window > "u" || typeof document > "u")
37
- throw new Se(
37
+ throw new Ee(
38
38
  "@edgespark/web is browser-only. Create the client from a real browser runtime."
39
39
  );
40
40
  }
41
- function X() {
42
- return Ee(), window.location.origin;
41
+ function Q() {
42
+ return Pe(), window.location.origin;
43
43
  }
44
- function ke(t) {
44
+ function Ne(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 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()}.`
47
+ function Ve(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()}.`
51
51
  );
52
52
  }
53
- function Oe() {
53
+ function De() {
54
54
  return {
55
55
  async fetch(t, e) {
56
- const s = ke(t);
57
- return Me(s), fetch(t, {
56
+ const s = Ne(t);
57
+ return Ve(s), fetch(t, {
58
58
  ...e,
59
59
  credentials: "include"
60
60
  });
61
61
  }
62
62
  };
63
63
  }
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([
64
+ const _e = "/api/_es/auth", Fe = "edgespark-auth-session", Le = "__edgespark_auth_sync__", D = "__edgespark_auth_pending_sign_in__", Ae = Symbol("edgespark.notifyAuthTabs"), He = 10 * 60 * 1e3, ze = /* @__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
+ ]), je = /* @__PURE__ */ new Map([
70
+ [
71
+ "changeEmail",
72
+ "changeEmail() is not currently supported by EdgeSpark platform auth. Use authUI.mount() or other supported client.auth flows instead of wiring raw /api/_es/auth/* routes manually."
73
+ ],
74
+ [
75
+ "deleteUser",
76
+ "deleteUser() is not currently supported by EdgeSpark platform auth. Handle account removal through your own app flow until the platform enables this capability."
77
+ ],
78
+ [
79
+ "deleteUserCallback",
80
+ "deleteUserCallback() is not currently supported by EdgeSpark platform auth. Handle account removal through your own app flow until the platform enables this capability."
81
+ ]
73
82
  ]);
74
- class De {
83
+ class xe {
75
84
  constructor(e) {
76
85
  this.value = e;
77
86
  }
@@ -80,14 +89,14 @@ class De {
80
89
  }
81
90
  }
82
91
  const ne = globalThis.WeakRef, re = globalThis.FinalizationRegistry;
83
- let z, oe = !1;
84
- const $ = /* @__PURE__ */ new Map(), D = re ? new re((t) => {
92
+ let F, oe = !1;
93
+ const $ = /* @__PURE__ */ new Map(), H = re ? new re((t) => {
85
94
  $.delete(t);
86
95
  }) : null;
87
- function Te(t) {
88
- return Be({
89
- baseURL: X(),
90
- basePath: Le,
96
+ function Re(t) {
97
+ return Oe({
98
+ baseURL: Q(),
99
+ basePath: _e,
91
100
  ...t != null && t.disableDefaultRedirectPlugin ? { disableDefaultFetchPlugins: !0 } : {},
92
101
  fetchOptions: {
93
102
  credentials: "include"
@@ -104,7 +113,7 @@ function qe(t) {
104
113
  timestamp: Date.now()
105
114
  });
106
115
  }
107
- function He(t) {
116
+ function Ge(t) {
108
117
  if (typeof t != "string")
109
118
  return null;
110
119
  try {
@@ -114,11 +123,11 @@ function He(t) {
114
123
  return null;
115
124
  }
116
125
  }
117
- function je(t) {
126
+ function Ke(t) {
118
127
  return t.join(".");
119
128
  }
120
- function xe(t) {
121
- const e = je(t), s = ze.get(e);
129
+ function We(t) {
130
+ const e = Ke(t), s = je.get(e);
122
131
  return s ? new v(s, {
123
132
  code: "UNSUPPORTED_AUTH_METHOD"
124
133
  }) : null;
@@ -131,11 +140,11 @@ async function ee(t) {
131
140
  return !1;
132
141
  }
133
142
  }
134
- function Ie() {
135
- return z === void 0 && (z = typeof BroadcastChannel < "u" ? new BroadcastChannel(Ve) : null), z;
143
+ function Te() {
144
+ return F === void 0 && (F = typeof BroadcastChannel < "u" ? new BroadcastChannel(Fe) : null), F;
136
145
  }
137
146
  function ae(t) {
138
- const e = He(t);
147
+ const e = Ge(t);
139
148
  if (e)
140
149
  for (const [s, i] of $) {
141
150
  if (s === e.source)
@@ -148,19 +157,19 @@ function ae(t) {
148
157
  ee(n);
149
158
  }
150
159
  }
151
- function We() {
160
+ function Ye() {
152
161
  var t;
153
- oe || (oe = !0, (t = Ie()) == null || t.addEventListener("message", (e) => {
162
+ oe || (oe = !0, (t = Te()) == null || t.addEventListener("message", (e) => {
154
163
  ae(e.data);
155
164
  }), typeof window < "u" && window.addEventListener("storage", (e) => {
156
- e.key !== _e || e.newValue === null || ae(e.newValue);
165
+ e.key !== Le || e.newValue === null || ae(e.newValue);
157
166
  }));
158
167
  }
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();
168
+ function Je(t, e) {
169
+ ne ? $.set(t, new ne(e)) : ($.clear(), $.set(t, new xe(e))), H == null || H.register(e, t), Ye();
161
170
  }
162
- function C(t) {
163
- const e = qe(t), s = Ie();
171
+ function I(t) {
172
+ const e = qe(t), s = Te();
164
173
  let i = !1;
165
174
  if (s)
166
175
  try {
@@ -169,15 +178,15 @@ function C(t) {
169
178
  }
170
179
  if (!i)
171
180
  try {
172
- window.localStorage.setItem(_e, e);
181
+ window.localStorage.setItem(Le, e);
173
182
  } catch {
174
183
  }
175
184
  }
176
- function q(t) {
185
+ function z(t) {
177
186
  if (!(typeof window > "u"))
178
187
  try {
179
188
  window.sessionStorage.setItem(
180
- F,
189
+ D,
181
190
  JSON.stringify({
182
191
  path: t,
183
192
  createdAt: Date.now()
@@ -186,92 +195,92 @@ function q(t) {
186
195
  } catch {
187
196
  }
188
197
  }
189
- function A() {
198
+ function C() {
190
199
  if (!(typeof window > "u"))
191
200
  try {
192
- window.sessionStorage.removeItem(F);
201
+ window.sessionStorage.removeItem(D);
193
202
  } catch {
194
203
  }
195
204
  }
196
- function Ke(t) {
205
+ function Xe(t) {
197
206
  return !!(t != null && t.session && (t != null && t.user));
198
207
  }
199
- function h(t) {
208
+ function m(t) {
200
209
  return t instanceof Date ? t.toISOString() : t === null || typeof t == "string" || typeof t == "number" || typeof t == "boolean" ? t : t == null ? null : String(t);
201
210
  }
202
- function Ye(t) {
211
+ function Ze(t) {
203
212
  return t ? JSON.stringify({
204
213
  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
+ createdAt: m(t.session.createdAt),
215
+ expiresAt: m(t.session.expiresAt),
216
+ id: m(t.session.id),
217
+ impersonatedBy: m(t.session.impersonatedBy),
218
+ ipAddress: m(t.session.ipAddress),
219
+ token: m(t.session.token),
220
+ updatedAt: m(t.session.updatedAt),
221
+ userAgent: m(t.session.userAgent),
222
+ userId: m(t.session.userId)
214
223
  },
215
224
  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)
225
+ banExpires: m(t.user.banExpires),
226
+ banReason: m(t.user.banReason),
227
+ banned: m(t.user.banned),
228
+ createdAt: m(t.user.createdAt),
229
+ email: m(t.user.email),
230
+ emailVerified: m(t.user.emailVerified),
231
+ id: m(t.user.id),
232
+ image: m(t.user.image),
233
+ lastLoginAt: m(t.user.lastLoginAt),
234
+ name: m(t.user.name),
235
+ role: m(t.user.role),
236
+ updatedAt: m(t.user.updatedAt)
228
237
  }
229
238
  }) : "__null__";
230
239
  }
231
- function Ce() {
240
+ function Ie() {
232
241
  if (typeof window > "u")
233
242
  return null;
234
243
  try {
235
- const t = window.sessionStorage.getItem(F);
244
+ const t = window.sessionStorage.getItem(D);
236
245
  if (!t)
237
246
  return null;
238
247
  const e = JSON.parse(t);
239
- return !e || typeof e != "object" || typeof e.createdAt != "number" || Date.now() - e.createdAt > Ne ? null : { createdAt: e.createdAt };
248
+ return !e || typeof e != "object" || typeof e.createdAt != "number" || Date.now() - e.createdAt > He ? null : { createdAt: e.createdAt };
240
249
  } catch {
241
250
  return null;
242
251
  }
243
252
  }
244
253
  function le() {
245
- if (!Ce())
254
+ if (!Ie())
246
255
  return !1;
247
256
  try {
248
- window.sessionStorage.removeItem(F);
257
+ window.sessionStorage.removeItem(D);
249
258
  } catch {
250
259
  }
251
260
  return !0;
252
261
  }
253
- function Je() {
254
- return Ce() !== null;
262
+ function Qe() {
263
+ return Ie() !== null;
255
264
  }
256
- function Ze(t) {
265
+ function et(t) {
257
266
  if (!(t && typeof t == "object") || "error" in t && t.error)
258
267
  return !1;
259
268
  const e = "data" in t ? t.data : t;
260
269
  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;
261
270
  }
262
- function Qe(t) {
271
+ function tt(t) {
263
272
  if (!(t && typeof t == "object") || "error" in t && t.error)
264
273
  return !1;
265
274
  const e = "data" in t ? t.data : t;
266
275
  return e && typeof e == "object" ? "url" in e && typeof e.url == "string" : !1;
267
276
  }
268
- function Xe(t) {
277
+ function st(t) {
269
278
  if (L(t) || !(t && typeof t == "object"))
270
279
  return !1;
271
280
  const e = "data" in t ? t.data : t;
272
281
  return e && typeof e == "object" ? "user" in e && !!e.user && "token" in e && e.token === null && !("url" in e) : !1;
273
282
  }
274
- function et(t, e) {
283
+ function it(t, e) {
275
284
  if (t.length !== 1 || t[0] !== "changePassword")
276
285
  return !1;
277
286
  const [s] = e;
@@ -280,19 +289,19 @@ function et(t, e) {
280
289
  function L(t) {
281
290
  return !!(t && typeof t == "object" && "error" in t && t.error);
282
291
  }
283
- function tt(t) {
292
+ function nt(t) {
284
293
  if (L(t) || !(t && typeof t == "object"))
285
294
  return !1;
286
295
  const e = "data" in t ? t.data : t;
287
296
  return e && typeof e == "object" ? "message" in e && e.message === "User deleted" : !1;
288
297
  }
289
- function st(t) {
298
+ function rt(t) {
290
299
  return !!(t && (typeof t == "object" || typeof t == "function") && "then" in t && typeof t.then == "function");
291
300
  }
292
- function H(t) {
293
- return Pe(t, "Failed to load the current session.", "SESSION_LOOKUP_FAILED");
301
+ function j(t) {
302
+ return Se(t, "Failed to load the current session.", "SESSION_LOOKUP_FAILED");
294
303
  }
295
- async function it(t) {
304
+ async function ot(t) {
296
305
  var s, i;
297
306
  let e = null;
298
307
  try {
@@ -300,47 +309,47 @@ async function it(t) {
300
309
  } catch (n) {
301
310
  e = n;
302
311
  } finally {
303
- (i = t[Re]) == null || i.call(t);
312
+ (i = t[Ae]) == null || i.call(t);
304
313
  }
305
314
  if (e)
306
315
  throw e;
307
316
  }
308
- function nt() {
309
- const t = Te(), e = `${Date.now()}-${Math.random().toString(36).slice(2)}`;
310
- Ge(e, t);
317
+ function at() {
318
+ const t = Re(), e = `${Date.now()}-${Math.random().toString(36).slice(2)}`;
319
+ Je(e, t);
311
320
  const s = 2, i = 500;
312
- let n = null, a = !1, m;
313
- const b = (o) => (m = o, o), _ = () => {
321
+ let n = null, a = !1, u;
322
+ const g = (o) => (u = o, o), E = () => {
314
323
  var c;
315
324
  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;
325
+ return o != null && o.error && !o.data && u !== void 0 ? u : (o == null ? void 0 : o.data) ?? u ?? null;
326
+ }, A = () => a ? Promise.resolve(E()) : (n || (n = (async () => {
327
+ var l, h, y;
319
328
  let o = !1, c = null;
320
329
  try {
321
- for (let g = 0; g <= s; g++) {
330
+ for (let b = 0; b <= s; b++) {
322
331
  let d = null;
323
332
  try {
324
333
  d = await t.getSession();
325
334
  } catch (S) {
326
335
  c = S;
327
336
  }
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) {
337
+ const p = ((l = U(t)) == null ? void 0 : l.get().data) ?? null;
338
+ if ((h = d == null ? void 0 : d.data) != null && h.session && ((y = d.data) != null && y.user))
339
+ return a = !0, le() && I(e), g(d.data);
340
+ if (p != null && p.session && (p != null && p.user))
341
+ return a = !0, le() && I(e), g(p);
342
+ if (d != null && d.error ? c = d.error : d && (o = !0), d && !d.error && Qe() && b < s) {
334
343
  await new Promise(
335
344
  (S) => setTimeout(S, i)
336
345
  );
337
346
  continue;
338
347
  }
339
348
  if (d && !d.error) {
340
- const S = _();
341
- return a = !0, b(S);
349
+ const S = E();
350
+ return a = !0, g(S);
342
351
  }
343
- g < s && await new Promise(
352
+ b < s && await new Promise(
344
353
  (S) => setTimeout(S, i)
345
354
  );
346
355
  }
@@ -349,124 +358,124 @@ function nt() {
349
358
  code: "SESSION_LOOKUP_FAILED",
350
359
  cause: c
351
360
  });
352
- const f = _();
353
- return a = !0, b(f);
354
- } catch (f) {
355
- throw n = null, H(f);
361
+ const w = E();
362
+ return a = !0, g(w);
363
+ } catch (w) {
364
+ throw n = null, j(w);
356
365
  }
357
366
  })()), n);
358
- R().catch(() => {
367
+ A().catch(() => {
359
368
  });
360
- const T = async () => {
369
+ const R = async () => {
361
370
  var o, c;
362
371
  try {
363
372
  const l = await t.getSession();
364
373
  if ((o = l.data) != null && o.session && ((c = l.data) != null && c.user))
365
374
  return l.data;
366
- throw l.error ? H(l.error) : new v("No authenticated session is available.", {
375
+ throw l.error ? j(l.error) : new v("No authenticated session is available.", {
367
376
  code: "UNAUTHENTICATED"
368
377
  });
369
378
  } catch (l) {
370
- throw H(l);
379
+ throw j(l);
371
380
  }
372
- }, I = async () => {
373
- await ee(t), C(e);
374
- }, Ae = async () => {
381
+ }, T = async () => {
382
+ await ee(t), I(e);
383
+ }, Be = async () => {
375
384
  var l;
376
385
  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) => {
379
- let c = !1, l = !1, u;
386
+ Xe(c) ? (C(), I(e)) : o || I(e);
387
+ }, ke = (o) => {
388
+ let c = !1, l = !1, h;
380
389
  const y = (d) => {
381
- const w = Ye(d);
382
- w !== u && (u = w, o(d));
390
+ const p = Ze(d);
391
+ p !== h && (h = p, o(d));
383
392
  };
384
- R().then((d) => {
385
- c || (l = !0, y(b(d)));
393
+ A().then((d) => {
394
+ c || (l = !0, y(g(d)));
386
395
  }).catch(() => {
387
396
  c || (l = !0);
388
397
  });
389
- const f = U(t);
390
- if (!f)
398
+ const w = U(t);
399
+ if (!w)
391
400
  return () => {
392
401
  c = !0;
393
402
  };
394
- const g = f.subscribe((d) => {
403
+ const b = w.subscribe((d) => {
395
404
  if (c || !l || d.error && !d.data)
396
405
  return;
397
- const w = d.data ?? null;
398
- y(b(w));
406
+ const p = d.data ?? null;
407
+ y(g(p));
399
408
  });
400
409
  return () => {
401
- c = !0, g();
410
+ c = !0, b();
402
411
  };
403
- }, $e = async (o, c, l) => {
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);
412
+ }, Me = async (o, c, l) => {
413
+ const h = o[0], y = o.length >= 2 && h === "emailOtp" && o[1] === "verifyEmail", w = o.length >= 2 && h === "emailOtp" && o[1] === "resetPassword", b = o.length >= 2 && h === "resetPassword" && o[1] === "emailOtp";
414
+ return o.length === 1 && (h === "deleteUser" || h === "deleteUserCallback") ? (C(), nt(l) && await T(), l) : o.length === 1 && h && ze.has(h) ? (C(), L(l) || await T(), l) : it(o, c) && !L(l) ? (C(), await T(), l) : (w || b) && !L(l) ? (C(), await T(), l) : o.length === 1 && h === "changeEmail" && !L(l) ? (await T(), l) : ((h === "signIn" || h === "signUp" || y) && et(l) ? (C(), await T()) : (h === "signIn" || h === "signUp") && tt(l) || h === "signUp" && st(l) ? z(o) : h === "verifyEmail" && !L(l) && (z(o), await Be()), l);
406
415
  }, se = /* @__PURE__ */ new WeakMap(), ie = (o, c) => {
407
416
  if (!o || typeof o != "object" && typeof o != "function")
408
417
  return o;
409
418
  const l = se.get(o);
410
419
  if (l)
411
420
  return l;
412
- const u = new Proxy(o, {
413
- get(y, f, g) {
421
+ const h = new Proxy(o, {
422
+ get(y, w, b) {
414
423
  if (c.length === 0) {
415
- if (f === "requireSession")
416
- return T;
417
- if (f === "onSessionChange")
418
- return Ue;
419
- if (f === Re)
424
+ if (w === "requireSession")
425
+ return R;
426
+ if (w === "onSessionChange")
427
+ return ke;
428
+ if (w === Ae)
420
429
  return () => {
421
- C(e);
430
+ I(e);
422
431
  };
423
432
  }
424
- const d = Reflect.get(y, f, g);
425
- return typeof f != "string" ? d : ie(d, [...c, f]);
433
+ const d = Reflect.get(y, w, b);
434
+ return typeof w != "string" ? d : ie(d, [...c, w]);
426
435
  },
427
- apply(y, f, g) {
428
- const d = xe(c);
436
+ apply(y, w, b) {
437
+ const d = We(c);
429
438
  if (d)
430
439
  throw d;
431
- const w = Reflect.apply(
440
+ const p = Reflect.apply(
432
441
  y,
433
- f,
434
- g
442
+ w,
443
+ b
435
444
  );
436
- return st(w) ? Promise.resolve(w).then(
437
- (S) => $e(c, g, S)
438
- ) : w;
445
+ return rt(p) ? Promise.resolve(p).then(
446
+ (S) => Me(c, b, S)
447
+ ) : p;
439
448
  }
440
449
  });
441
- return se.set(o, u), u;
450
+ return se.set(o, h), h;
442
451
  };
443
452
  return ie(t, []);
444
453
  }
445
- function rt() {
446
- return Te({ disableDefaultRedirectPlugin: !0 });
454
+ function lt() {
455
+ return Re({ disableDefaultRedirectPlugin: !0 });
447
456
  }
448
- function ot(t) {
457
+ function dt(t) {
449
458
  const e = (() => {
450
459
  if (t instanceof URL)
451
460
  return t;
452
461
  const s = t.trim();
453
462
  if (!s)
454
- throw new p("redirectTo must not be an empty string.");
463
+ throw new f("redirectTo must not be an empty string.");
455
464
  try {
456
465
  return new URL(s, window.location.href);
457
466
  } catch {
458
- throw new p(
467
+ throw new f(
459
468
  `redirectTo must be a valid relative path or URL. Received: ${JSON.stringify(t)}`
460
469
  );
461
470
  }
462
471
  })();
463
472
  if (e.protocol !== "http:" && e.protocol !== "https:")
464
- throw new p(
473
+ throw new f(
465
474
  `redirectTo must resolve to an http(s) URL. Received protocol: ${e.protocol}`
466
475
  );
467
476
  return e;
468
477
  }
469
- function at(t, e) {
478
+ function ct(t, e) {
470
479
  return e ? {
471
480
  common: { ...t.common, ...e.common },
472
481
  signIn: { ...t.signIn, ...e.signIn },
@@ -478,7 +487,7 @@ function at(t, e) {
478
487
  errors: { ...t.errors, ...e.errors }
479
488
  } : t;
480
489
  }
481
- const N = {
490
+ const V = {
482
491
  common: {
483
492
  loading: "Loading sign-in…",
484
493
  redirecting: "Redirecting…",
@@ -541,7 +550,7 @@ const N = {
541
550
  invalidCode: "Enter the 6-digit verification code.",
542
551
  generic: "Something went wrong. Please try again."
543
552
  }
544
- }, j = {
553
+ }, x = {
545
554
  common: {
546
555
  loading: "加载中…",
547
556
  redirecting: "跳转中…",
@@ -730,7 +739,7 @@ const N = {
730
739
  invalidCode: "6자리 인증 코드를 입력해 주세요",
731
740
  generic: "문제가 발생했습니다. 다시 시도해 주세요"
732
741
  }
733
- }, x = {
742
+ }, q = {
734
743
  common: {
735
744
  loading: "Cargando inicio de sesión…",
736
745
  redirecting: "Redirigiendo…",
@@ -1235,18 +1244,18 @@ const N = {
1235
1244
  generic: "कुछ गलत हो गई। कृपया फिर से प्रयास करें।"
1236
1245
  }
1237
1246
  }, be = {
1238
- en: N,
1239
- "en-US": N,
1240
- zh: j,
1241
- "zh-CN": j,
1242
- "zh-TW": j,
1247
+ en: V,
1248
+ "en-US": V,
1249
+ zh: x,
1250
+ "zh-CN": x,
1251
+ "zh-TW": x,
1243
1252
  ja: de,
1244
1253
  "ja-JP": de,
1245
1254
  ko: ce,
1246
1255
  "ko-KR": ce,
1247
- es: x,
1248
- "es-ES": x,
1249
- "es-MX": x,
1256
+ es: q,
1257
+ "es-ES": q,
1258
+ "es-MX": q,
1250
1259
  pt: ue,
1251
1260
  "pt-BR": ue,
1252
1261
  fr: he,
@@ -1262,18 +1271,58 @@ const N = {
1262
1271
  hi: ge,
1263
1272
  "hi-IN": ge
1264
1273
  };
1265
- function lt() {
1274
+ function ut() {
1266
1275
  if (typeof navigator > "u")
1267
- return N;
1276
+ return V;
1268
1277
  const t = navigator.languages ?? [navigator.language];
1269
1278
  for (const e of t) {
1270
1279
  const s = be[e] ?? be[e.split("-")[0]];
1271
1280
  if (s) return s;
1272
1281
  }
1273
- return N;
1282
+ return V;
1283
+ }
1284
+ const Ce = {
1285
+ LIGHT: "light",
1286
+ DARK: "dark"
1287
+ }, Ue = Ce.LIGHT, ht = Ce.DARK, $e = [Ue, ht], mt = Ue, ft = {
1288
+ BACKGROUND: "--edgespark-auth-bg",
1289
+ BACKGROUND_MUTED: "--edgespark-auth-bg-muted",
1290
+ CARD_BACKGROUND: "--edgespark-auth-card-bg",
1291
+ BORDER: "--edgespark-auth-border",
1292
+ TEXT: "--edgespark-auth-text",
1293
+ TEXT_MUTED: "--edgespark-auth-text-muted",
1294
+ DIVIDER_BACKGROUND: "--edgespark-auth-divider-bg",
1295
+ PRIMARY: "--edgespark-auth-primary",
1296
+ PRIMARY_HOVER: "--edgespark-auth-primary-hover",
1297
+ PRIMARY_CONTRAST: "--edgespark-auth-primary-contrast",
1298
+ ERROR: "--edgespark-auth-error",
1299
+ INFO: "--edgespark-auth-info",
1300
+ CARD_RADIUS: "--edgespark-auth-radius-card",
1301
+ CONTROL_RADIUS: "--edgespark-auth-radius-control",
1302
+ SHADOW: "--edgespark-auth-shadow",
1303
+ FONT: "--edgespark-auth-font",
1304
+ MODAL_BACKDROP: "--edgespark-auth-modal-backdrop",
1305
+ MODAL_CARD_BACKGROUND: "--edgespark-auth-modal-card-bg",
1306
+ MODAL_SHADOW: "--edgespark-auth-modal-shadow"
1307
+ }, wt = Object.values(
1308
+ ft
1309
+ );
1310
+ function pt(t) {
1311
+ return typeof t == "string" && $e.includes(t);
1274
1312
  }
1275
- function W(t, e = "Authentication failed.") {
1276
- return Pe(t, e);
1313
+ function gt(t) {
1314
+ return wt.includes(t);
1315
+ }
1316
+ function bt(t) {
1317
+ var e;
1318
+ return {
1319
+ theme: (t == null ? void 0 : t.theme) ?? mt,
1320
+ className: ((e = t == null ? void 0 : t.className) == null ? void 0 : e.trim()) ?? "",
1321
+ variables: { ...(t == null ? void 0 : t.variables) ?? {} }
1322
+ };
1323
+ }
1324
+ function G(t, e = "Authentication failed.") {
1325
+ return Se(t, e);
1277
1326
  }
1278
1327
  async function k(t) {
1279
1328
  var s, i;
@@ -1295,7 +1344,7 @@ async function k(t) {
1295
1344
  session: null
1296
1345
  };
1297
1346
  }
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 = {
1347
+ const yt = "data-edgespark-auth", vt = "data-edgespark-auth-theme", r = "edgespark-auth", K = "es_auth_completion", M = "es_auth_email", W = "oauth", B = "verify-sign-in", P = "verify-sign-up", ye = 200, Y = 2, Et = {
1299
1348
  "&": "&amp;",
1300
1349
  "<": "&lt;",
1301
1350
  ">": "&gt;",
@@ -1309,25 +1358,25 @@ const dt = "data-edgespark-auth", r = "edgespark-auth", G = "es_auth_completion"
1309
1358
  gitlab: "GitLab",
1310
1359
  discord: "Discord"
1311
1360
  };
1312
- function E(t) {
1361
+ function _(t) {
1313
1362
  return "redirectTo" in t;
1314
1363
  }
1315
- function Z(t) {
1364
+ function X(t) {
1316
1365
  return "onSuccess" in t && !("redirectTo" in t);
1317
1366
  }
1318
- function Q(t) {
1367
+ function Z(t) {
1319
1368
  return !t || typeof t != "string" ? !1 : /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(t.trim());
1320
1369
  }
1321
- function ut(t) {
1370
+ function St(t) {
1322
1371
  return /^\d{6}$/.test(t.trim());
1323
1372
  }
1324
- function ht(t) {
1373
+ function Pt(t) {
1325
1374
  return t === "email" || t === "name" || t === "password" || t === "confirmPassword" || t === "code" || t === "newPassword";
1326
1375
  }
1327
- function mt(t) {
1376
+ function _t(t) {
1328
1377
  return !!(t.error || t.errorDescription);
1329
1378
  }
1330
- class ft {
1379
+ class Lt {
1331
1380
  constructor(e, s, i, n, a) {
1332
1381
  this.container = e, this.auth = s, this.options = i, this.loadConfig = n, this.runtimeOptions = a, this.state = {
1333
1382
  view: "loading",
@@ -1341,7 +1390,12 @@ class ft {
1341
1390
  confirmPassword: "",
1342
1391
  code: "",
1343
1392
  newPassword: ""
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();
1393
+ }, this.destroyed = !1, this.terminalActionInProgress = !1, this.config = null, this.countdownUntil = null, this.countdownTimer = null, this.pendingFocusSnapshot = null, this.focusRestoreTimer = null, this.verificationCompletionAction = null;
1394
+ const u = bt(i.appearance);
1395
+ this.labels = ct(ut(), i.labels), this.root = document.createElement("div"), this.root.className = u.className ? `${r} ${u.className}` : r, this.root.setAttribute(yt, ""), this.root.setAttribute(vt, u.theme);
1396
+ for (const [g, E] of Object.entries(u.variables))
1397
+ E !== void 0 && this.root.style.setProperty(g, E);
1398
+ e.innerHTML = "", e.appendChild(this.root), this.render(), this.initialize();
1345
1399
  }
1346
1400
  destroy() {
1347
1401
  this.destroyed || (this.destroyed = !0, this.clearCountdown(), this.clearFocusRestoreTimer(), this.container.innerHTML = "");
@@ -1356,7 +1410,7 @@ class ft {
1356
1410
  if (this.destroyed)
1357
1411
  return;
1358
1412
  if (i.status === "rejected") {
1359
- if (e.marker && !mt(e) && E(this.options)) {
1413
+ if (e.marker && !_t(e) && _(this.options)) {
1360
1414
  this.redirectAfterManagedReturnLookupFailure();
1361
1415
  return;
1362
1416
  }
@@ -1364,7 +1418,7 @@ class ft {
1364
1418
  const a = i.value;
1365
1419
  if (a.user && a.session) {
1366
1420
  switch (e.marker) {
1367
- case K:
1421
+ case W:
1368
1422
  case B:
1369
1423
  await this.completeAuth("sign-in", a);
1370
1424
  return;
@@ -1391,10 +1445,10 @@ class ft {
1391
1445
  }
1392
1446
  }
1393
1447
  redirectAfterManagedReturnLookupFailure() {
1394
- E(this.options) && this.navigateToRedirect();
1448
+ _(this.options) && this.navigateToRedirect();
1395
1449
  }
1396
1450
  navigateToRedirect() {
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()));
1451
+ _(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(dt(this.options.redirectTo).toString()));
1398
1452
  }
1399
1453
  async readMountSession(e) {
1400
1454
  if (!e.marker)
@@ -1642,12 +1696,12 @@ class ft {
1642
1696
  this.root.querySelectorAll("form[data-view]").forEach((n) => {
1643
1697
  n.addEventListener("submit", (a) => {
1644
1698
  a.preventDefault();
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();
1699
+ const u = n.dataset.view;
1700
+ u === "sign-in" && this.handleSignIn(), u === "sign-up" && this.handleSignUp(), u === "forgot-password" && this.handleForgotPassword(), u === "reset-password" && this.handleResetPassword();
1647
1701
  });
1648
1702
  }), this.root.querySelectorAll("input[name]").forEach((n) => {
1649
1703
  n.addEventListener("input", () => {
1650
- ht(n.name) && (this.state[n.name] = n.value);
1704
+ Pt(n.name) && (this.state[n.name] = n.value);
1651
1705
  });
1652
1706
  }), this.root.querySelectorAll("[data-action]").forEach((n) => {
1653
1707
  n.addEventListener("click", () => {
@@ -1660,7 +1714,7 @@ class ft {
1660
1714
  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();
1661
1715
  }
1662
1716
  async handleSignIn() {
1663
- if (!Q(this.state.email)) {
1717
+ if (!Z(this.state.email)) {
1664
1718
  this.failValidation(this.labels.errors.invalidEmail);
1665
1719
  return;
1666
1720
  }
@@ -1685,7 +1739,7 @@ class ft {
1685
1739
  this.failValidation(this.labels.errors.requiredField);
1686
1740
  return;
1687
1741
  }
1688
- if (!Q(this.state.email)) {
1742
+ if (!Z(this.state.email)) {
1689
1743
  this.failValidation(this.labels.errors.invalidEmail);
1690
1744
  return;
1691
1745
  }
@@ -1731,18 +1785,18 @@ class ft {
1731
1785
  throw s.error;
1732
1786
  const i = this.extractRedirectURL(s.data);
1733
1787
  if (!i)
1734
- throw new p(`OAuth sign-in did not return a redirect URL for provider "${e}".`);
1788
+ throw new f(`OAuth sign-in did not return a redirect URL for provider "${e}".`);
1735
1789
  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);
1736
1790
  });
1737
1791
  }
1738
1792
  async handleForgotPassword() {
1739
1793
  if (!this.canUsePasswordResetEmailOtp()) {
1740
1794
  this.handleError(
1741
- new p("Password reset via email OTP is not enabled for this project.")
1795
+ new f("Password reset via email OTP is not enabled for this project.")
1742
1796
  );
1743
1797
  return;
1744
1798
  }
1745
- if (!Q(this.state.email)) {
1799
+ if (!Z(this.state.email)) {
1746
1800
  this.failValidation(this.labels.errors.invalidEmail);
1747
1801
  return;
1748
1802
  }
@@ -1762,11 +1816,11 @@ class ft {
1762
1816
  var e, s;
1763
1817
  if (!this.canUsePasswordResetEmailOtp()) {
1764
1818
  this.handleError(
1765
- new p("Password reset via email OTP is not enabled for this project.")
1819
+ new f("Password reset via email OTP is not enabled for this project.")
1766
1820
  );
1767
1821
  return;
1768
1822
  }
1769
- if (!ut(this.state.code)) {
1823
+ if (!St(this.state.code)) {
1770
1824
  this.failValidation(this.labels.errors.invalidCode);
1771
1825
  return;
1772
1826
  }
@@ -1821,12 +1875,12 @@ class ft {
1821
1875
  if (!i.user || !i.session) {
1822
1876
  if (this.destroyed)
1823
1877
  return;
1824
- if (i.lookupError && E(this.options)) {
1878
+ if (i.lookupError && _(this.options)) {
1825
1879
  this.navigateToRedirect();
1826
1880
  return;
1827
1881
  }
1828
1882
  if (e === "sign-in")
1829
- throw i.lookupError ?? new Se(
1883
+ throw i.lookupError ?? new Ee(
1830
1884
  "Managed sign-in completed without an authenticated session."
1831
1885
  );
1832
1886
  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();
@@ -1838,11 +1892,11 @@ class ft {
1838
1892
  session: i.session
1839
1893
  };
1840
1894
  if (await this.syncPublicSessionBestEffort(), !this.destroyed) {
1841
- if (E(this.options)) {
1895
+ if (_(this.options)) {
1842
1896
  this.invokeRedirectModeSuccessHook(n), this.navigateToRedirect();
1843
1897
  return;
1844
1898
  }
1845
- if (Z(this.options)) {
1899
+ if (X(this.options)) {
1846
1900
  this.options.onSuccess(n), this.terminalActionInProgress = !0;
1847
1901
  return;
1848
1902
  }
@@ -1899,7 +1953,7 @@ class ft {
1899
1953
  session: null
1900
1954
  };
1901
1955
  if (await this.syncPublicSessionBestEffort(), !this.destroyed) {
1902
- if (Z(this.options)) {
1956
+ if (X(this.options)) {
1903
1957
  this.clearCountdown(), this.options.onSuccess(e), this.terminalActionInProgress = !0;
1904
1958
  return;
1905
1959
  }
@@ -1907,12 +1961,12 @@ class ft {
1907
1961
  }
1908
1962
  }
1909
1963
  handleExistingSessionOnMount() {
1910
- if (E(this.options)) {
1964
+ if (_(this.options)) {
1911
1965
  this.navigateToRedirect();
1912
1966
  return;
1913
1967
  }
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(
1968
+ if (X(this.options))
1969
+ throw this.state.view = "sign-in", this.state.busy = !1, this.state.busyLabel = void 0, this.state.notice = null, new f(
1916
1970
  "authUI.mount(container, { onSuccess }) cannot run while a session already exists. Check es.auth.getSession() before mounting controlled auth UI."
1917
1971
  );
1918
1972
  }
@@ -1929,18 +1983,18 @@ class ft {
1929
1983
  !this.destroyed && !this.terminalActionInProgress && (this.state.busy = !1, this.state.busyLabel = void 0, this.render());
1930
1984
  }
1931
1985
  maybeHandleVerificationRequired(e) {
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);
1986
+ return G(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);
1933
1987
  }
1934
1988
  handleVerificationEmailSent(e, s) {
1935
1989
  this.state.notice = s ? `We sent another verification email to ${e}.` : `We sent a verification email to ${e}.`, this.startCountdown();
1936
1990
  }
1937
1991
  invokeRedirectModeSuccessHook(e) {
1938
1992
  var s, i;
1939
- if (!(!E(this.options) || !this.options.onSuccess))
1993
+ if (!(!_(this.options) || !this.options.onSuccess))
1940
1994
  try {
1941
1995
  this.options.onSuccess(e);
1942
1996
  } catch (n) {
1943
- const a = W(n, "Post-auth callback failed.");
1997
+ const a = G(n, "Post-auth callback failed.");
1944
1998
  try {
1945
1999
  (i = (s = this.options).onError) == null || i.call(s, a);
1946
2000
  } catch {
@@ -1949,7 +2003,7 @@ class ft {
1949
2003
  }
1950
2004
  handleError(e, s) {
1951
2005
  var n, a;
1952
- const i = W(e, s);
2006
+ const i = G(e, s);
1953
2007
  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);
1954
2008
  }
1955
2009
  failValidation(e) {
@@ -1959,15 +2013,15 @@ class ft {
1959
2013
  if (!e)
1960
2014
  return window.location.href;
1961
2015
  const i = new URL(window.location.href);
1962
- return i.searchParams.set(G, e), s ? i.searchParams.set(M, s) : i.searchParams.delete(M), i.toString();
2016
+ return i.searchParams.set(K, e), s ? i.searchParams.set(M, s) : i.searchParams.delete(M), i.toString();
1963
2017
  }
1964
2018
  consumeManagedReturnContext() {
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())), {
2019
+ const e = new URL(window.location.href), s = e.searchParams.get(K), i = s === W || s === B || s === P ? s : null, n = e.searchParams.get(M), a = i ? e.searchParams.get("error") : null, u = i ? e.searchParams.get("error_description") : null;
2020
+ return (i || n) && (e.searchParams.delete(K), e.searchParams.delete(M), i && (e.searchParams.delete("error"), e.searchParams.delete("error_description")), window.history.replaceState(null, "", e.toString())), {
1967
2021
  marker: i,
1968
2022
  email: n,
1969
2023
  error: a,
1970
- errorDescription: m
2024
+ errorDescription: u
1971
2025
  };
1972
2026
  }
1973
2027
  startCountdown(e = 60) {
@@ -2034,7 +2088,7 @@ class ft {
2034
2088
  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(
2035
2089
  e.errorDescription ?? "Verification failed. Request a new verification email and try again.",
2036
2090
  { code: e.error ?? "VERIFY_EMAIL_ERROR" }
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(
2091
+ )) : this.render(), !0) : e.marker === W && (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(
2038
2092
  e.errorDescription ?? "OAuth sign-in failed.",
2039
2093
  { code: e.error ?? "OAUTH_ERROR" }
2040
2094
  )), !0) : !1;
@@ -2050,106 +2104,137 @@ class ft {
2050
2104
  return i <= 0 ? e : s.replace("{seconds}", String(i));
2051
2105
  }
2052
2106
  escape(e) {
2053
- return e.replace(/[&<>"']/g, (s) => ct[s]);
2107
+ return e.replace(/[&<>"']/g, (s) => Et[s]);
2054
2108
  }
2055
2109
  }
2056
- function wt(t) {
2110
+ function At(t) {
2057
2111
  return "data" in t && t.data ? t.data : t;
2058
2112
  }
2059
- const pt = [
2113
+ const Rt = [
2060
2114
  { id: "google", key: "providerGoogle" },
2061
2115
  { id: "apple", key: "providerApple" },
2062
2116
  { id: "microsoft", key: "providerMicrosoft" },
2063
2117
  { id: "github", key: "providerGithub" },
2064
2118
  { id: "gitlab", key: "providerGitlab" },
2065
2119
  { id: "discord", key: "providerDiscord" }
2066
- ], ve = 2, gt = 500;
2067
- async function bt() {
2068
- const t = `${window.location.origin}${Le}/config`;
2120
+ ], ve = 2, Tt = 500;
2121
+ async function It() {
2122
+ const t = `${window.location.origin}${_e}/config`;
2069
2123
  let e;
2070
2124
  for (let s = 0; s <= ve; s++)
2071
2125
  try {
2072
2126
  const i = await fetch(t, { method: "GET", credentials: "include" });
2073
2127
  if (!i.ok)
2074
- throw new p(`Failed to load auth config: HTTP ${i.status}`);
2128
+ throw new f(`Failed to load auth config: HTTP ${i.status}`);
2075
2129
  const n = await i.json();
2076
- return vt(wt(n));
2130
+ return Ut(At(n));
2077
2131
  } catch (i) {
2078
- e = i, s < ve && await new Promise((n) => setTimeout(n, gt));
2132
+ e = i, s < ve && await new Promise((n) => setTimeout(n, Tt));
2079
2133
  }
2080
2134
  throw e;
2081
2135
  }
2082
2136
  let O = null;
2083
- async function yt() {
2084
- return O || (O = bt().catch((t) => {
2137
+ async function Ct() {
2138
+ return O || (O = It().catch((t) => {
2085
2139
  throw O = null, t;
2086
2140
  })), O;
2087
2141
  }
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);
2142
+ function Ut(t) {
2143
+ var s, i, n, a, u, g, E;
2144
+ const e = Rt.filter(({ key: A }) => {
2145
+ const R = t[A];
2146
+ return typeof R == "object" && R !== null && "enabled" in R && !!R.enabled;
2147
+ }).map(({ id: A }) => A);
2094
2148
  return {
2095
2149
  disableSignUp: !!t.disableSignUp,
2096
2150
  emailPasswordEnabled: !!((s = t.providerEmailPassword) != null && s.enabled),
2097
2151
  minPasswordLength: ((n = (i = t.providerEmailPassword) == null ? void 0 : i.config) == null ? void 0 : n.minPasswordLength) ?? 8,
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),
2152
+ requireEmailVerification: !!((u = (a = t.providerEmailPassword) == null ? void 0 : a.config) != null && u.requireEmailVerification),
2153
+ passwordResetEmailOtpEnabled: !!((E = (g = t.providerEmailPassword) == null ? void 0 : g.config) != null && E.requirePasswordResetEmailVerification),
2100
2154
  oauthProviders: e
2101
2155
  };
2102
2156
  }
2103
- const V = /* @__PURE__ */ new WeakMap();
2104
- function St(t) {
2157
+ const N = /* @__PURE__ */ new WeakMap();
2158
+ function $t(t) {
2105
2159
  if (!t)
2106
- throw new p(
2160
+ throw new f(
2107
2161
  "authUI.mount(container, options) requires either { redirectTo } or { onSuccess }."
2108
2162
  );
2109
2163
  const e = "redirectTo" in t, s = "onSuccess" in t && typeof t.onSuccess == "function";
2110
2164
  if (!e && !s)
2111
- throw new p(
2165
+ throw new f(
2112
2166
  "authUI.mount(container, options) requires either { redirectTo } or { onSuccess }."
2113
2167
  );
2114
2168
  if ("redirectTo" in t) {
2115
2169
  const i = t.redirectTo;
2116
2170
  if (!(typeof i == "string" || i instanceof URL))
2117
- throw new p(
2171
+ throw new f(
2118
2172
  "authUI.mount(container, options) expected redirectTo to be a string or URL."
2119
2173
  );
2120
2174
  }
2121
2175
  if ("onSuccess" in t && t.onSuccess !== void 0 && typeof t.onSuccess != "function")
2122
- throw new p(
2176
+ throw new f(
2123
2177
  "authUI.mount(container, options) expected onSuccess to be a function."
2124
2178
  );
2125
2179
  if ("onError" in t && t.onError !== void 0 && typeof t.onError != "function")
2126
- throw new p(
2180
+ throw new f(
2127
2181
  "authUI.mount(container, options) expected onError to be a function."
2128
2182
  );
2183
+ if ("appearance" in t && t.appearance !== void 0) {
2184
+ const i = t.appearance;
2185
+ if (!i || typeof i != "object" || Array.isArray(i))
2186
+ throw new f(
2187
+ "authUI.mount(container, options) expected appearance to be an object."
2188
+ );
2189
+ if ("theme" in i && i.theme !== void 0 && !pt(i.theme))
2190
+ throw new f(
2191
+ `authUI.mount(container, options) expected appearance.theme to be one of: ${$e.join(", ")}.`
2192
+ );
2193
+ if ("className" in i && i.className !== void 0 && typeof i.className != "string")
2194
+ throw new f(
2195
+ "authUI.mount(container, options) expected appearance.className to be a string."
2196
+ );
2197
+ if ("variables" in i && i.variables !== void 0) {
2198
+ if (!i.variables || typeof i.variables != "object" || Array.isArray(i.variables))
2199
+ throw new f(
2200
+ "authUI.mount(container, options) expected appearance.variables to be an object."
2201
+ );
2202
+ for (const [n, a] of Object.entries(i.variables)) {
2203
+ if (!gt(n))
2204
+ throw new f(
2205
+ `authUI.mount(container, options) received unsupported appearance.variables key "${n}".`
2206
+ );
2207
+ if (a !== void 0 && typeof a != "string")
2208
+ throw new f(
2209
+ `authUI.mount(container, options) expected appearance.variables["${n}"] to be a string.`
2210
+ );
2211
+ }
2212
+ }
2213
+ }
2129
2214
  }
2130
- function Pt(t) {
2215
+ function Bt(t) {
2131
2216
  if (!(t instanceof HTMLElement))
2132
- throw new p("authUI.mount(container, options) requires a real HTMLElement container.");
2217
+ throw new f("authUI.mount(container, options) requires a real HTMLElement container.");
2133
2218
  }
2134
- function Et(t, e) {
2219
+ function kt(t, e) {
2135
2220
  return {
2136
2221
  mount(s, i) {
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 = {
2222
+ var g;
2223
+ $t(i), Bt(s), (g = N.get(s)) == null || g.destroy();
2224
+ const n = new Lt(s, t, i, Ct, e), a = n.destroy.bind(n), u = {
2140
2225
  destroy() {
2141
- a(), V.get(s) === m && V.delete(s);
2226
+ a(), N.get(s) === u && N.delete(s);
2142
2227
  }
2143
2228
  };
2144
- return V.set(s, m), m;
2229
+ return N.set(s, u), u;
2145
2230
  }
2146
2231
  };
2147
2232
  }
2148
- function _t() {
2149
- Ee();
2150
- const t = nt(), e = rt(), s = Oe(), i = Et(e, {
2233
+ function Ot() {
2234
+ Pe();
2235
+ const t = at(), e = lt(), s = De(), i = kt(e, {
2151
2236
  syncPublicSession: async () => {
2152
- await it(t);
2237
+ await ot(t);
2153
2238
  }
2154
2239
  });
2155
2240
  return {
@@ -2159,16 +2244,23 @@ function _t() {
2159
2244
  };
2160
2245
  }
2161
2246
  export {
2247
+ ft as AUTH_UI_APPEARANCE_VARIABLE,
2248
+ wt as AUTH_UI_APPEARANCE_VARIABLE_NAMES,
2249
+ mt as AUTH_UI_DEFAULT_THEME,
2250
+ Ce as AUTH_UI_THEME,
2251
+ $e as AUTH_UI_THEMES,
2252
+ ht as AUTH_UI_THEME_DARK,
2253
+ Ue as AUTH_UI_THEME_LIGHT,
2162
2254
  v as EdgeSparkAuthError,
2163
- p as EdgeSparkConfigError,
2255
+ f as EdgeSparkConfigError,
2164
2256
  te as EdgeSparkError,
2165
- Se as EdgeSparkRuntimeError,
2257
+ Ee as EdgeSparkRuntimeError,
2166
2258
  pe as ar,
2167
- _t as createEdgeSpark,
2259
+ Ot as createEdgeSpark,
2168
2260
  me as de,
2169
- lt as detectLocale,
2170
- N as enUS,
2171
- x as es,
2261
+ ut as detectLocale,
2262
+ V as enUS,
2263
+ q as es,
2172
2264
  he as fr,
2173
2265
  ge as hi,
2174
2266
  fe as it,
@@ -2176,5 +2268,5 @@ export {
2176
2268
  ce as ko,
2177
2269
  ue as ptBR,
2178
2270
  we as ru,
2179
- j as zhCN
2271
+ x as zhCN
2180
2272
  };