@skylabs-digital/react-identity-access 1.4.0 → 1.6.0

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.
Files changed (47) hide show
  1. package/README.md +203 -42
  2. package/dist/components/FeatureFlag.d.ts +1 -0
  3. package/dist/components/LandingRoute.d.ts +2 -1
  4. package/dist/components/LandingRoute.d.ts.map +1 -1
  5. package/dist/components/LoginForm.d.ts +8 -3
  6. package/dist/components/LoginForm.d.ts.map +1 -1
  7. package/dist/components/MagicLinkForm.d.ts +53 -0
  8. package/dist/components/MagicLinkForm.d.ts.map +1 -0
  9. package/dist/components/MagicLinkVerify.d.ts +45 -0
  10. package/dist/components/MagicLinkVerify.d.ts.map +1 -0
  11. package/dist/components/PasswordRecoveryForm.d.ts +1 -0
  12. package/dist/components/Protected.d.ts +1 -0
  13. package/dist/components/ProtectedRoute.d.ts +1 -0
  14. package/dist/components/SignupForm.d.ts +10 -1
  15. package/dist/components/SignupForm.d.ts.map +1 -1
  16. package/dist/components/SubscriptionGuard.d.ts +1 -0
  17. package/dist/components/TenantRoute.d.ts +2 -1
  18. package/dist/components/TenantRoute.d.ts.map +1 -1
  19. package/dist/index.d.ts +5 -1
  20. package/dist/index.d.ts.map +1 -1
  21. package/dist/index.es.js +1565 -865
  22. package/dist/index.es.js.map +1 -1
  23. package/dist/index.js +6 -1
  24. package/dist/index.js.map +1 -1
  25. package/dist/providers/AppProvider.d.ts +1 -0
  26. package/dist/providers/AppProvider.d.ts.map +1 -1
  27. package/dist/providers/AuthProvider.d.ts +6 -3
  28. package/dist/providers/AuthProvider.d.ts.map +1 -1
  29. package/dist/providers/FeatureFlagProvider.d.ts +1 -0
  30. package/dist/providers/SubscriptionProvider.d.ts +1 -0
  31. package/dist/providers/TenantProvider.d.ts +1 -0
  32. package/dist/providers/TenantProvider.d.ts.map +1 -1
  33. package/dist/services/AppApiService.d.ts +1 -0
  34. package/dist/services/AuthApiService.d.ts +8 -3
  35. package/dist/services/AuthApiService.d.ts.map +1 -1
  36. package/dist/services/FeatureFlagApiService.d.ts +1 -0
  37. package/dist/services/HealthApiService.d.ts +1 -0
  38. package/dist/services/PermissionApiService.d.ts +1 -0
  39. package/dist/services/RoleApiService.d.ts +1 -0
  40. package/dist/services/SubscriptionApiService.d.ts +1 -0
  41. package/dist/services/SubscriptionPlanApiService.d.ts +1 -0
  42. package/dist/services/TenantApiService.d.ts +1 -0
  43. package/dist/services/UserApiService.d.ts +1 -0
  44. package/dist/types/api.d.ts +39 -6
  45. package/dist/types/api.d.ts.map +1 -1
  46. package/package.json +26 -25
  47. package/CHANGELOG.md +0 -32
package/dist/index.es.js CHANGED
@@ -1,7 +1,7 @@
1
- import { jsx as s, Fragment as H, jsxs as c } from "react/jsx-runtime";
2
- import { createContext as ee, useState as b, useMemo as z, useCallback as Z, useEffect as Y, useContext as te } from "react";
3
- import { useLocation as ae, Navigate as ne } from "react-router";
4
- class G {
1
+ import { jsx as n, Fragment as D, jsxs as l } from "react/jsx-runtime";
2
+ import { createContext as ae, useState as p, useMemo as _, useCallback as oe, useEffect as Z, useContext as le } from "react";
3
+ import { useLocation as he, Navigate as de } from "react-router-dom";
4
+ class te {
5
5
  // SessionManager instance
6
6
  constructor(e, t = 1e4) {
7
7
  this.baseUrl = e.replace(/\/$/, ""), this.timeout = t;
@@ -12,44 +12,44 @@ class G {
12
12
  getBaseUrl() {
13
13
  return this.baseUrl;
14
14
  }
15
- async request(e, t, r, n) {
16
- return this.executeRequest(e, t, r, n, !1);
15
+ async request(e, t, r, s) {
16
+ return this.executeRequest(e, t, r, s, !1);
17
17
  }
18
- async executeRequest(e, t, r, n, o = !1) {
19
- const m = `${this.baseUrl}${t.startsWith("/") ? t : `/${t}`}`, T = (n == null ? void 0 : n.timeout) || this.timeout;
20
- let M = {
18
+ async executeRequest(e, t, r, s, a = !1) {
19
+ const b = `${this.baseUrl}${t.startsWith("/") ? t : `/${t}`}`, E = (s == null ? void 0 : s.timeout) || this.timeout;
20
+ let L = {
21
21
  "Content-Type": "application/json",
22
- ...n == null ? void 0 : n.headers
22
+ ...s == null ? void 0 : s.headers
23
23
  };
24
- if (!(n != null && n.skipAuth) && this.sessionManager)
24
+ if (!(s != null && s.skipAuth) && this.sessionManager)
25
25
  try {
26
- const h = await this.sessionManager.getAuthHeaders();
27
- M = { ...M, ...h };
28
- } catch (h) {
29
- console.warn("Failed to inject auth headers:", h);
26
+ const m = await this.sessionManager.getAuthHeaders();
27
+ L = { ...L, ...m };
28
+ } catch (m) {
29
+ console.warn("Failed to inject auth headers:", m);
30
30
  }
31
- const P = new AbortController(), g = setTimeout(() => P.abort(), T);
31
+ const P = new AbortController(), f = setTimeout(() => P.abort(), E);
32
32
  try {
33
- const h = await fetch(m, {
33
+ const m = await fetch(b, {
34
34
  method: e,
35
- headers: M,
35
+ headers: L,
36
36
  body: r ? JSON.stringify(r) : void 0,
37
37
  signal: P.signal
38
38
  });
39
- if (clearTimeout(g), h.status === 401 && !(n != null && n.skipRetry) && !o && this.sessionManager)
39
+ if (clearTimeout(f), m.status === 401 && !(s != null && s.skipRetry) && !a && this.sessionManager)
40
40
  try {
41
- const p = this.sessionManager.getTokens();
42
- if (p != null && p.refreshToken)
43
- return await this.sessionManager.getAuthHeaders(), this.executeRequest(e, t, r, n, !0);
41
+ const w = this.sessionManager.getTokens();
42
+ if (w != null && w.refreshToken)
43
+ return await this.sessionManager.getAuthHeaders(), this.executeRequest(e, t, r, s, !0);
44
44
  } catch {
45
- throw new Error(`HTTP ${h.status}: ${h.statusText}`);
45
+ throw new Error(`HTTP ${m.status}: ${m.statusText}`);
46
46
  }
47
- if (!h.ok)
48
- throw new Error(`HTTP ${h.status}: ${h.statusText}`);
49
- const x = h.headers.get("content-type");
50
- return !x || !x.includes("application/json") ? {} : await h.json();
51
- } catch (h) {
52
- throw clearTimeout(g), h instanceof Error && h.name === "AbortError" ? new Error(`Request timeout after ${T}ms`) : h;
47
+ if (!m.ok)
48
+ throw new Error(`HTTP ${m.status}: ${m.statusText}`);
49
+ const M = m.headers.get("content-type");
50
+ return !M || !M.includes("application/json") ? {} : await m.json();
51
+ } catch (m) {
52
+ throw clearTimeout(f), m instanceof Error && m.name === "AbortError" ? new Error(`Request timeout after ${E}ms`) : m;
53
53
  }
54
54
  }
55
55
  async get(e, t) {
@@ -65,7 +65,7 @@ class G {
65
65
  return this.request("DELETE", e, void 0, t);
66
66
  }
67
67
  }
68
- class be {
68
+ class Te {
69
69
  constructor(e, t) {
70
70
  this.httpService = e, this.sessionManager = t;
71
71
  }
@@ -78,12 +78,12 @@ class be {
78
78
  async getApps(e) {
79
79
  const t = await this.sessionManager.getAuthHeaders(), r = new URLSearchParams();
80
80
  e != null && e.page && r.append("page", e.page.toString()), e != null && e.limit && r.append("limit", e.limit.toString()), e != null && e.sortBy && r.append("sortBy", e.sortBy), e != null && e.sortOrder && r.append("sortOrder", e.sortOrder);
81
- const n = `/apps/${r.toString() ? `?${r.toString()}` : ""}`, o = await this.httpService.get(n, {
81
+ const s = `/apps/${r.toString() ? `?${r.toString()}` : ""}`, a = await this.httpService.get(s, {
82
82
  headers: t
83
83
  });
84
84
  return {
85
- apps: o.data,
86
- meta: o.meta
85
+ apps: a.data,
86
+ meta: a.meta
87
87
  };
88
88
  }
89
89
  async getAppById(e) {
@@ -110,11 +110,11 @@ class be {
110
110
  )).data;
111
111
  }
112
112
  async updateSettingsSchema(e, t, r) {
113
- const n = await this.sessionManager.getAuthHeaders();
113
+ const s = await this.sessionManager.getAuthHeaders();
114
114
  return (await this.httpService.put(
115
115
  `/apps/${e}/settings-schema`,
116
116
  { schema: t, defaultSettings: r },
117
- { headers: n }
117
+ { headers: s }
118
118
  )).data;
119
119
  }
120
120
  async exportConfig(e) {
@@ -124,7 +124,7 @@ class be {
124
124
  })).data;
125
125
  }
126
126
  }
127
- const pe = ee(null), Se = () => /* @__PURE__ */ s(
127
+ const we = ae(null), Me = () => /* @__PURE__ */ n(
128
128
  "div",
129
129
  {
130
130
  style: {
@@ -134,9 +134,9 @@ const pe = ee(null), Se = () => /* @__PURE__ */ s(
134
134
  height: "100vh",
135
135
  fontFamily: "system-ui, sans-serif"
136
136
  },
137
- children: /* @__PURE__ */ s("div", { children: "Loading application..." })
137
+ children: /* @__PURE__ */ n("div", { children: "Loading application..." })
138
138
  }
139
- ), ve = ({ error: i, retry: e }) => /* @__PURE__ */ c(
139
+ ), Ee = ({ error: i, retry: e }) => /* @__PURE__ */ l(
140
140
  "div",
141
141
  {
142
142
  style: {
@@ -150,9 +150,9 @@ const pe = ee(null), Se = () => /* @__PURE__ */ s(
150
150
  padding: "20px"
151
151
  },
152
152
  children: [
153
- /* @__PURE__ */ s("h2", { style: { color: "#dc3545", marginBottom: "16px" }, children: "Application Error" }),
154
- /* @__PURE__ */ s("p", { style: { color: "#6c757d", marginBottom: "24px" }, children: i.message || "Unable to load application" }),
155
- /* @__PURE__ */ s(
153
+ /* @__PURE__ */ n("h2", { style: { color: "#dc3545", marginBottom: "16px" }, children: "Application Error" }),
154
+ /* @__PURE__ */ n("p", { style: { color: "#6c757d", marginBottom: "24px" }, children: i.message || "Unable to load application" }),
155
+ /* @__PURE__ */ n(
156
156
  "button",
157
157
  {
158
158
  onClick: e,
@@ -170,9 +170,9 @@ const pe = ee(null), Se = () => /* @__PURE__ */ s(
170
170
  ]
171
171
  }
172
172
  );
173
- function Ze({ config: i, children: e }) {
174
- const [t, r] = b(null), [n, o] = b(!0), [m, T] = b(null), M = z(() => {
175
- const g = () => {
173
+ function ht({ config: i, children: e }) {
174
+ const [t, r] = p(null), [s, a] = p(!0), [b, E] = p(null), L = _(() => {
175
+ const f = () => {
176
176
  P();
177
177
  };
178
178
  return {
@@ -180,40 +180,40 @@ function Ze({ config: i, children: e }) {
180
180
  baseUrl: i.baseUrl,
181
181
  // App info
182
182
  appInfo: t,
183
- isAppLoading: n,
184
- appError: m,
185
- retryApp: g
183
+ isAppLoading: s,
184
+ appError: b,
185
+ retryApp: f
186
186
  };
187
- }, [i, t, n, m]), P = Z(async () => {
187
+ }, [i, t, s, b]), P = oe(async () => {
188
188
  try {
189
- o(!0), T(null);
190
- const g = new G(i.baseUrl), x = await new be(g, {}).getPublicAppInfo(i.appId);
191
- r(x);
192
- } catch (g) {
193
- const h = g instanceof Error ? g : new Error("Failed to load app information");
194
- T(h), r(null);
189
+ a(!0), E(null);
190
+ const f = new te(i.baseUrl), M = await new Te(f, {}).getPublicAppInfo(i.appId);
191
+ r(M);
192
+ } catch (f) {
193
+ const m = f instanceof Error ? f : new Error("Failed to load app information");
194
+ E(m), r(null);
195
195
  } finally {
196
- o(!1);
196
+ a(!1);
197
197
  }
198
198
  }, [i.baseUrl, i.appId]);
199
- if (Y(() => {
199
+ if (Z(() => {
200
200
  P();
201
- }, [P]), n)
202
- return /* @__PURE__ */ s(H, { children: i.loadingFallback || /* @__PURE__ */ s(Se, {}) });
203
- if (m) {
204
- const g = typeof i.errorFallback == "function" ? i.errorFallback(m, () => P()) : i.errorFallback || /* @__PURE__ */ s(ve, { error: m, retry: () => P() });
205
- return /* @__PURE__ */ s(H, { children: g });
201
+ }, [P]), s)
202
+ return /* @__PURE__ */ n(D, { children: i.loadingFallback || /* @__PURE__ */ n(Me, {}) });
203
+ if (b) {
204
+ const f = typeof i.errorFallback == "function" ? i.errorFallback(b, () => P()) : i.errorFallback || /* @__PURE__ */ n(Ee, { error: b, retry: () => P() });
205
+ return /* @__PURE__ */ n(D, { children: f });
206
206
  }
207
- return /* @__PURE__ */ s(pe.Provider, { value: M, children: e });
207
+ return /* @__PURE__ */ n(we.Provider, { value: L, children: e });
208
208
  }
209
- function re() {
210
- const i = te(pe);
209
+ function ne() {
210
+ const i = le(we);
211
211
  if (!i)
212
212
  throw new Error("useApp must be used within an AppProvider");
213
213
  return i;
214
214
  }
215
- const et = re;
216
- class xe {
215
+ const gt = ne;
216
+ class Le {
217
217
  constructor(e = {}) {
218
218
  this.refreshPromise = null, this.refreshQueue = [], this.storageKey = e.storageKey || "auth_tokens", this.autoRefresh = e.autoRefresh ?? !0, this.refreshThreshold = e.refreshThreshold || 3e5, this.onRefreshFailed = e.onRefreshFailed, this.baseUrl = e.baseUrl || "", this.tokenStorage = e.tokenStorage || {
219
219
  get: () => {
@@ -281,10 +281,10 @@ class xe {
281
281
  try {
282
282
  await this.refreshPromise;
283
283
  const t = this.getTokens(), r = t != null && t.accessToken ? { Authorization: `Bearer ${t.accessToken}` } : {};
284
- return this.refreshQueue.forEach(({ resolve: n }) => n(r)), this.refreshQueue = [], r;
284
+ return this.refreshQueue.forEach(({ resolve: s }) => s(r)), this.refreshQueue = [], r;
285
285
  } catch (t) {
286
286
  const r = t instanceof Error ? t : new Error("Token refresh failed");
287
- return this.refreshQueue.forEach(({ reject: n }) => n(r)), this.refreshQueue = [], this.clearSession(), this.onRefreshFailed && this.onRefreshFailed(), {};
287
+ return this.refreshQueue.forEach(({ reject: s }) => s(r)), this.refreshQueue = [], this.clearSession(), this.onRefreshFailed && this.onRefreshFailed(), {};
288
288
  } finally {
289
289
  this.refreshPromise = null;
290
290
  }
@@ -303,11 +303,11 @@ class xe {
303
303
  });
304
304
  if (!r.ok)
305
305
  throw new Error(`Token refresh failed: ${r.status} ${r.statusText}`);
306
- const n = await r.json();
306
+ const s = await r.json();
307
307
  this.setTokens({
308
- accessToken: n.accessToken,
309
- refreshToken: n.refreshToken || e,
310
- expiresIn: n.expiresIn
308
+ accessToken: s.accessToken,
309
+ refreshToken: s.refreshToken || e,
310
+ expiresIn: s.expiresIn
311
311
  });
312
312
  }
313
313
  setUser(e) {
@@ -330,7 +330,7 @@ class xe {
330
330
  return e !== null && !this.isTokenExpired(e);
331
331
  }
332
332
  }
333
- class Ae {
333
+ class Re {
334
334
  constructor(e) {
335
335
  this.httpService = e;
336
336
  }
@@ -354,6 +354,18 @@ class Ae {
354
354
  async requestPasswordReset(e) {
355
355
  await this.httpService.post("/auth/password-reset/request", e);
356
356
  }
357
+ async sendMagicLink(e) {
358
+ return await this.httpService.post(
359
+ "/auth/magic-link/send",
360
+ e
361
+ );
362
+ }
363
+ async verifyMagicLink(e) {
364
+ return await this.httpService.post(
365
+ "/auth/magic-link/verify",
366
+ e
367
+ );
368
+ }
357
369
  async confirmPasswordReset(e) {
358
370
  await this.httpService.post("/auth/password-reset/confirm", e);
359
371
  }
@@ -364,7 +376,7 @@ class Ae {
364
376
  });
365
377
  }
366
378
  }
367
- class ce {
379
+ class pe {
368
380
  constructor(e, t) {
369
381
  this.httpService = e, this.sessionManager = t;
370
382
  }
@@ -404,10 +416,10 @@ class ce {
404
416
  async getRolesByApp(e, t) {
405
417
  const r = new URLSearchParams();
406
418
  t != null && t.page && r.append("page", t.page.toString()), t != null && t.limit && r.append("limit", t.limit.toString()), t != null && t.sortBy && r.append("sortBy", t.sortBy), t != null && t.sortOrder && r.append("sortOrder", t.sortOrder);
407
- const n = `/roles/app/${e}${r.toString() ? `?${r.toString()}` : ""}`, o = await this.httpService.get(n);
419
+ const s = `/roles/app/${e}${r.toString() ? `?${r.toString()}` : ""}`, a = await this.httpService.get(s);
408
420
  return {
409
- roles: o.data,
410
- meta: o.meta
421
+ roles: a.data,
422
+ meta: a.meta
411
423
  };
412
424
  }
413
425
  async assignRole(e, t) {
@@ -429,18 +441,18 @@ class ce {
429
441
  async getUserRoles(e, t) {
430
442
  if (!this.sessionManager)
431
443
  throw new Error("SessionManager is required for private endpoints");
432
- const r = await this.sessionManager.getAuthHeaders(), n = new URLSearchParams();
433
- t != null && t.page && n.append("page", t.page.toString()), t != null && t.limit && n.append("limit", t.limit.toString()), t != null && t.sortBy && n.append("sortBy", t.sortBy), t != null && t.sortOrder && n.append("sortOrder", t.sortOrder);
434
- const o = `/roles/user/${e}${n.toString() ? `?${n.toString()}` : ""}`, m = await this.httpService.get(o, {
444
+ const r = await this.sessionManager.getAuthHeaders(), s = new URLSearchParams();
445
+ t != null && t.page && s.append("page", t.page.toString()), t != null && t.limit && s.append("limit", t.limit.toString()), t != null && t.sortBy && s.append("sortBy", t.sortBy), t != null && t.sortOrder && s.append("sortOrder", t.sortOrder);
446
+ const a = `/roles/user/${e}${s.toString() ? `?${s.toString()}` : ""}`, b = await this.httpService.get(a, {
435
447
  headers: r
436
448
  });
437
449
  return {
438
- roles: m.data,
439
- meta: m.meta
450
+ roles: b.data,
451
+ meta: b.meta
440
452
  };
441
453
  }
442
454
  }
443
- class Pe {
455
+ class Ce {
444
456
  constructor(e, t) {
445
457
  this.httpService = e, this.sessionManager = t;
446
458
  }
@@ -453,12 +465,12 @@ class Pe {
453
465
  async getUsers(e) {
454
466
  const t = await this.sessionManager.getAuthHeaders(), r = new URLSearchParams();
455
467
  e != null && e.page && r.append("page", e.page.toString()), e != null && e.limit && r.append("limit", e.limit.toString()), e != null && e.sortBy && r.append("sortBy", e.sortBy), e != null && e.sortOrder && r.append("sortOrder", e.sortOrder);
456
- const n = `/users/${r.toString() ? `?${r.toString()}` : ""}`, o = await this.httpService.get(n, {
468
+ const s = `/users/${r.toString() ? `?${r.toString()}` : ""}`, a = await this.httpService.get(s, {
457
469
  headers: t
458
470
  });
459
471
  return {
460
- users: o.data,
461
- meta: o.meta
472
+ users: a.data,
473
+ meta: a.meta
462
474
  };
463
475
  }
464
476
  async getUserById(e) {
@@ -480,7 +492,7 @@ class Pe {
480
492
  });
481
493
  }
482
494
  }
483
- class de {
495
+ class fe {
484
496
  constructor(e, t, r) {
485
497
  this.httpService = e, this.appId = t, this.sessionManager = r;
486
498
  }
@@ -497,12 +509,12 @@ class de {
497
509
  throw new Error("SessionManager is required for private endpoints");
498
510
  const t = await this.sessionManager.getAuthHeaders(), r = new URLSearchParams();
499
511
  e != null && e.page && r.append("page", e.page.toString()), e != null && e.limit && r.append("limit", e.limit.toString()), e != null && e.sortBy && r.append("sortBy", e.sortBy), e != null && e.sortOrder && r.append("sortOrder", e.sortOrder);
500
- const n = `/tenants/${r.toString() ? `?${r.toString()}` : ""}`, o = await this.httpService.get(n, {
512
+ const s = `/tenants/${r.toString() ? `?${r.toString()}` : ""}`, a = await this.httpService.get(s, {
501
513
  headers: t
502
514
  });
503
515
  return {
504
- tenants: o.data,
505
- meta: o.meta
516
+ tenants: a.data,
517
+ meta: a.meta
506
518
  };
507
519
  }
508
520
  async getTenantById(e) {
@@ -558,7 +570,7 @@ class de {
558
570
  )).data;
559
571
  }
560
572
  }
561
- const fe = ee(null), ke = () => /* @__PURE__ */ s(
573
+ const ve = ae(null), Ie = () => /* @__PURE__ */ n(
562
574
  "div",
563
575
  {
564
576
  style: {
@@ -568,9 +580,9 @@ const fe = ee(null), ke = () => /* @__PURE__ */ s(
568
580
  height: "100vh",
569
581
  fontFamily: "system-ui, sans-serif"
570
582
  },
571
- children: /* @__PURE__ */ s("div", { children: "Loading tenant..." })
583
+ children: /* @__PURE__ */ n("div", { children: "Loading tenant..." })
572
584
  }
573
- ), Te = ({ error: i, retry: e }) => /* @__PURE__ */ c(
585
+ ), Fe = ({ error: i, retry: e }) => /* @__PURE__ */ l(
574
586
  "div",
575
587
  {
576
588
  style: {
@@ -584,9 +596,9 @@ const fe = ee(null), ke = () => /* @__PURE__ */ s(
584
596
  padding: "20px"
585
597
  },
586
598
  children: [
587
- /* @__PURE__ */ s("h2", { style: { color: "#dc3545", marginBottom: "16px" }, children: "Tenant Error" }),
588
- /* @__PURE__ */ s("p", { style: { color: "#6c757d", marginBottom: "24px" }, children: i.message || "Unable to load tenant" }),
589
- /* @__PURE__ */ s(
599
+ /* @__PURE__ */ n("h2", { style: { color: "#dc3545", marginBottom: "16px" }, children: "Tenant Error" }),
600
+ /* @__PURE__ */ n("p", { style: { color: "#6c757d", marginBottom: "24px" }, children: i.message || "Unable to load tenant" }),
601
+ /* @__PURE__ */ n(
590
602
  "button",
591
603
  {
592
604
  onClick: e,
@@ -604,77 +616,77 @@ const fe = ee(null), ke = () => /* @__PURE__ */ s(
604
616
  ]
605
617
  }
606
618
  );
607
- function tt({ config: i, children: e }) {
608
- const { baseUrl: t, appInfo: r, appId: n } = re(), [o, m] = b(i.initialTenant || null), [T, M] = b(!i.initialTenant), [P, g] = b(null), [h, x] = b(null), [p, A] = b(!1), [F, f] = b(null), L = Z(() => {
609
- const d = i.tenantMode || "selector", w = "tenant";
619
+ function pt({ config: i, children: e }) {
620
+ const { baseUrl: t, appInfo: r, appId: s } = ne(), [a, b] = p(i.initialTenant || null), [E, L] = p(!i.initialTenant), [P, f] = p(null), [m, M] = p(null), [w, v] = p(!1), [I, g] = p(null), U = oe(() => {
621
+ const S = i.tenantMode || "selector", c = "tenant";
610
622
  if (typeof window > "u") return null;
611
- if (d === "subdomain") {
612
- const a = window.location.hostname.split(".");
613
- if (a.length >= 3) {
614
- const l = a[0];
615
- return localStorage.setItem(w, l), l;
623
+ if (S === "subdomain") {
624
+ const o = window.location.hostname.split(".");
625
+ if (o.length >= 3) {
626
+ const d = o[0];
627
+ return localStorage.setItem(c, d), d;
616
628
  }
617
- return localStorage.getItem(w);
618
- } else if (d === "selector") {
619
- const a = new URLSearchParams(window.location.search).get(i.selectorParam || "tenant");
620
- return a ? (localStorage.setItem(w, a), a) : localStorage.getItem(w);
629
+ return localStorage.getItem(c);
630
+ } else if (S === "selector") {
631
+ const o = new URLSearchParams(window.location.search).get(i.selectorParam || "tenant");
632
+ return o ? (localStorage.setItem(c, o), o) : localStorage.getItem(c);
621
633
  }
622
634
  return null;
623
- }, [i.tenantMode, i.selectorParam]), y = z(() => L(), [L]), S = (r == null ? void 0 : r.settingsSchema) || null, k = Z(
624
- async (d) => {
635
+ }, [i.tenantMode, i.selectorParam]), u = _(() => U(), [U]), y = (r == null ? void 0 : r.settingsSchema) || null, x = oe(
636
+ async (S) => {
625
637
  try {
626
- M(!0), g(null);
627
- const w = new G(t), a = await new de(w, n).getPublicTenantInfo(d);
628
- m(a);
629
- } catch (w) {
630
- const u = w instanceof Error ? w : new Error("Failed to load tenant information");
631
- g(u), m(null);
638
+ L(!0), f(null);
639
+ const c = new te(t), o = await new fe(c, s).getPublicTenantInfo(S);
640
+ b(o);
641
+ } catch (c) {
642
+ const h = c instanceof Error ? c : new Error("Failed to load tenant information");
643
+ f(h), b(null);
632
644
  } finally {
633
- M(!1);
645
+ L(!1);
634
646
  }
635
647
  },
636
- [t, n]
637
- ), R = Z(async () => {
638
- if (o != null && o.id)
648
+ [t, s]
649
+ ), F = oe(async () => {
650
+ if (a != null && a.id)
639
651
  try {
640
- A(!0), f(null);
641
- const d = new G(t), u = await new de(d, o.appId).getTenantSettings(o.id);
642
- x(u);
643
- } catch (d) {
644
- const w = d instanceof Error ? d : new Error("Failed to load tenant settings");
645
- f(w), x(null);
652
+ v(!0), g(null);
653
+ const S = new te(t), h = await new fe(S, a.appId).getTenantSettings(a.id);
654
+ M(h);
655
+ } catch (S) {
656
+ const c = S instanceof Error ? S : new Error("Failed to load tenant settings");
657
+ g(c), M(null);
646
658
  } finally {
647
- A(!1);
659
+ v(!1);
648
660
  }
649
- }, [t, o]), D = Z(() => {
650
- R();
651
- }, [R]), E = Z(
652
- (d) => {
653
- if (!S)
661
+ }, [t, a]), B = oe(() => {
662
+ F();
663
+ }, [F]), z = oe(
664
+ (S) => {
665
+ if (!y)
654
666
  return { isValid: !0, errors: [] };
655
- const w = [];
667
+ const c = [];
656
668
  try {
657
- return S.properties && Object.entries(S.properties).forEach(([u, a]) => {
658
- var W;
659
- const l = d[u];
660
- if ((W = S.required) != null && W.includes(u) && l == null) {
661
- w.push(`Field '${u}' is required`);
669
+ return y.properties && Object.entries(y.properties).forEach(([h, o]) => {
670
+ var G;
671
+ const d = S[h];
672
+ if ((G = y.required) != null && G.includes(h) && d == null) {
673
+ c.push(`Field '${h}' is required`);
662
674
  return;
663
675
  }
664
- if (l != null) {
665
- if (a.type) {
666
- const I = a.type, N = typeof l;
667
- I === "string" && N !== "string" ? w.push(`Field '${u}' must be a string`) : (I === "number" || I === "integer") && N !== "number" ? w.push(`Field '${u}' must be a number`) : I === "boolean" && N !== "boolean" ? w.push(`Field '${u}' must be a boolean`) : I === "array" && !Array.isArray(l) && w.push(`Field '${u}' must be an array`);
676
+ if (d != null) {
677
+ if (o.type) {
678
+ const Y = o.type, H = typeof d;
679
+ Y === "string" && H !== "string" ? c.push(`Field '${h}' must be a string`) : (Y === "number" || Y === "integer") && H !== "number" ? c.push(`Field '${h}' must be a number`) : Y === "boolean" && H !== "boolean" ? c.push(`Field '${h}' must be a boolean`) : Y === "array" && !Array.isArray(d) && c.push(`Field '${h}' must be an array`);
668
680
  }
669
- a.minLength !== void 0 && typeof l == "string" && l.length < a.minLength && w.push(
670
- `Field '${u}' must be at least ${a.minLength} characters long`
671
- ), a.maxLength !== void 0 && typeof l == "string" && l.length > a.maxLength && w.push(
672
- `Field '${u}' must be no more than ${a.maxLength} characters long`
673
- ), a.minimum !== void 0 && typeof l == "number" && l < a.minimum && w.push(`Field '${u}' must be at least ${a.minimum}`), a.maximum !== void 0 && typeof l == "number" && l > a.maximum && w.push(`Field '${u}' must be no more than ${a.maximum}`), a.pattern && typeof l == "string" && (new RegExp(a.pattern).test(l) || w.push(`Field '${u}' does not match the required pattern`)), a.enum && !a.enum.includes(l) && w.push(`Field '${u}' must be one of: ${a.enum.join(", ")}`);
681
+ o.minLength !== void 0 && typeof d == "string" && d.length < o.minLength && c.push(
682
+ `Field '${h}' must be at least ${o.minLength} characters long`
683
+ ), o.maxLength !== void 0 && typeof d == "string" && d.length > o.maxLength && c.push(
684
+ `Field '${h}' must be no more than ${o.maxLength} characters long`
685
+ ), o.minimum !== void 0 && typeof d == "number" && d < o.minimum && c.push(`Field '${h}' must be at least ${o.minimum}`), o.maximum !== void 0 && typeof d == "number" && d > o.maximum && c.push(`Field '${h}' must be no more than ${o.maximum}`), o.pattern && typeof d == "string" && (new RegExp(o.pattern).test(d) || c.push(`Field '${h}' does not match the required pattern`)), o.enum && !o.enum.includes(d) && c.push(`Field '${h}' must be one of: ${o.enum.join(", ")}`);
674
686
  }
675
687
  }), {
676
- isValid: w.length === 0,
677
- errors: w
688
+ isValid: c.length === 0,
689
+ errors: c
678
690
  };
679
691
  } catch {
680
692
  return {
@@ -683,275 +695,321 @@ function tt({ config: i, children: e }) {
683
695
  };
684
696
  }
685
697
  },
686
- [S]
698
+ [y]
687
699
  );
688
- Y(() => {
689
- !i.initialTenant && y ? k(y) : !i.initialTenant && !y && (m(null), g(null), M(!1));
690
- }, [i.initialTenant, y, k]), Y(() => {
691
- o != null && o.id ? R() : (x(null), f(null), A(!1));
692
- }, [o == null ? void 0 : o.id, R]);
693
- const B = z(() => ({
700
+ Z(() => {
701
+ !i.initialTenant && u ? x(u) : !i.initialTenant && !u && (b(null), f(null), L(!1));
702
+ }, [i.initialTenant, u, x]), Z(() => {
703
+ a != null && a.id ? F() : (M(null), g(null), v(!1));
704
+ }, [a == null ? void 0 : a.id, F]);
705
+ const q = _(() => ({
694
706
  // Tenant info
695
- tenant: o,
696
- tenantSlug: y,
697
- isTenantLoading: T,
707
+ tenant: a,
708
+ tenantSlug: u,
709
+ isTenantLoading: E,
698
710
  tenantError: P,
699
711
  retryTenant: () => {
700
- y && k(y);
712
+ u && x(u);
701
713
  },
702
714
  // Settings
703
- settings: h,
704
- settingsSchema: S,
705
- isSettingsLoading: p,
706
- settingsError: F,
715
+ settings: m,
716
+ settingsSchema: y,
717
+ isSettingsLoading: w,
718
+ settingsError: I,
707
719
  // Actions
708
- refreshSettings: D,
720
+ refreshSettings: B,
709
721
  // Validation
710
- validateSettings: E
722
+ validateSettings: z
711
723
  }), [
712
- o,
713
- y,
714
- T,
724
+ a,
725
+ u,
726
+ E,
715
727
  P,
716
- h,
717
- S,
718
- p,
719
- F,
720
- D,
721
- E
728
+ m,
729
+ y,
730
+ w,
731
+ I,
732
+ B,
733
+ z
722
734
  ]);
723
- if (T)
724
- return /* @__PURE__ */ s(H, { children: i.loadingFallback || /* @__PURE__ */ s(ke, {}) });
735
+ if (E)
736
+ return /* @__PURE__ */ n(D, { children: i.loadingFallback || /* @__PURE__ */ n(Ie, {}) });
725
737
  if (P) {
726
- const d = typeof i.errorFallback == "function" ? i.errorFallback(P, () => k(y || "")) : i.errorFallback || /* @__PURE__ */ s(Te, { error: P, retry: () => k(y || "") });
727
- return /* @__PURE__ */ s(H, { children: d });
738
+ const S = typeof i.errorFallback == "function" ? i.errorFallback(P, () => x(u || "")) : i.errorFallback || /* @__PURE__ */ n(Fe, { error: P, retry: () => x(u || "") });
739
+ return /* @__PURE__ */ n(D, { children: S });
728
740
  }
729
- return /* @__PURE__ */ s(fe.Provider, { value: B, children: e });
741
+ return /* @__PURE__ */ n(ve.Provider, { value: q, children: e });
730
742
  }
731
- function le() {
732
- const i = te(fe);
743
+ function ge() {
744
+ const i = le(ve);
733
745
  if (!i)
734
746
  throw new Error("useTenant must be used within a TenantProvider");
735
747
  return i;
736
748
  }
737
- const rt = le;
738
- function st() {
739
- const {
740
- settings: i,
741
- settingsSchema: e,
742
- isSettingsLoading: t,
743
- settingsError: r,
744
- validateSettings: n
745
- } = le();
749
+ const ft = ge;
750
+ function mt() {
751
+ const { settings: i, settingsSchema: e, isSettingsLoading: t, settingsError: r, validateSettings: s } = ge();
746
752
  return {
747
753
  settings: i,
748
754
  settingsSchema: e,
749
755
  isLoading: t,
750
756
  error: r,
751
- validateSettings: n
757
+ validateSettings: s
752
758
  };
753
759
  }
754
- function K() {
755
- const { tenant: i, tenantSlug: e, isTenantLoading: t, tenantError: r, retryTenant: n } = le();
760
+ function re() {
761
+ const { tenant: i, tenantSlug: e, isTenantLoading: t, tenantError: r, retryTenant: s } = ge();
756
762
  return {
757
763
  tenant: i,
758
764
  tenantSlug: e,
759
765
  isLoading: t,
760
766
  error: r,
761
- retry: n
767
+ retry: s
762
768
  };
763
769
  }
764
- const ye = ee(null);
765
- function nt({ config: i = {}, children: e }) {
766
- const { appId: t, baseUrl: r } = re(), n = K(), o = (n == null ? void 0 : n.tenantSlug) || null, [m, T] = b(i.initialRoles || []), [M, P] = b(!i.initialRoles), [g, h] = b(null), [x, p] = b(!1), [A, F] = b(null), f = z(() => {
767
- const d = o ? `auth_tokens_${o}` : "auth_tokens", w = {
770
+ const Se = ae(null);
771
+ function yt({ config: i = {}, children: e }) {
772
+ const { appId: t, baseUrl: r } = ne(), s = re(), a = (s == null ? void 0 : s.tenantSlug) || null, [b, E] = p(i.initialRoles || []), [L, P] = p(!i.initialRoles), [f, m] = p(null), [M, w] = p(!1), [v, I] = p(null), g = _(() => {
773
+ const S = a ? `auth_tokens_${a}` : "auth_tokens", c = {
768
774
  get: () => {
769
775
  try {
770
- const u = localStorage.getItem(d);
771
- return u ? JSON.parse(u) : null;
776
+ const h = localStorage.getItem(S);
777
+ return h ? JSON.parse(h) : null;
772
778
  } catch {
773
779
  return null;
774
780
  }
775
781
  },
776
- set: (u) => {
782
+ set: (h) => {
777
783
  try {
778
- localStorage.setItem(d, JSON.stringify(u));
784
+ localStorage.setItem(S, JSON.stringify(h));
779
785
  } catch {
780
786
  }
781
787
  },
782
788
  clear: () => {
783
789
  try {
784
- localStorage.removeItem(d);
790
+ localStorage.removeItem(S);
785
791
  } catch {
786
792
  }
787
793
  }
788
794
  };
789
- return new xe({
795
+ return new Le({
790
796
  onRefreshFailed: i.onRefreshFailed,
791
- tokenStorage: w,
797
+ tokenStorage: c,
792
798
  baseUrl: r
793
799
  });
794
- }, [o, r, i.onRefreshFailed]), L = z(() => {
795
- const d = new G(r);
796
- return d.setSessionManager(f), d;
797
- }, [r, f]), y = z(() => new Ae(new G(r)), [r]), S = z(() => new Pe(L, f), [L, f]), k = z(() => new ce(new G(r)), [r]), R = z(() => g || f.getUser(), [g, f]), D = z(() => R != null && R.roleId && m.find((d) => d.id === R.roleId) || null, [R, m]), E = z(() => (D == null ? void 0 : D.permissions) || [], [D]);
798
- Y(() => {
799
- console.log("AuthProvider - userPermissions changed:", E);
800
- }, [E]);
801
- const B = z(() => {
802
- const d = async () => {
800
+ }, [a, r, i.onRefreshFailed]), U = _(() => {
801
+ const S = new te(r);
802
+ return S.setSessionManager(g), S;
803
+ }, [r, g]), u = _(() => new Re(new te(r)), [r]), y = _(() => new Ce(U, g), [U, g]), x = _(() => new pe(new te(r)), [r]), F = _(() => f || g.getUser(), [f, g]), B = _(() => F != null && F.roleId && b.find((S) => S.id === F.roleId) || null, [F, b]), z = _(() => (B == null ? void 0 : B.permissions) || [], [B]);
804
+ Z(() => {
805
+ console.log("AuthProvider - userPermissions changed:", z);
806
+ }, [z]);
807
+ const q = _(() => {
808
+ const S = async () => {
803
809
  try {
804
- p(!0), F(null);
805
- const v = f.getUser();
806
- if (!(v != null && v.id))
810
+ w(!0), I(null);
811
+ const A = g.getUser();
812
+ if (!(A != null && A.id))
807
813
  throw new Error("No user ID available in session");
808
- const $ = await S.getUserById(v.id);
809
- h($), f.setUser($);
810
- } catch (v) {
811
- const $ = v instanceof Error ? v : new Error("Failed to load user data");
812
- F($), console.error("Failed to load user data:", $);
814
+ const $ = await y.getUserById(A.id);
815
+ m($), g.setUser($);
816
+ } catch (A) {
817
+ const $ = A instanceof Error ? A : new Error("Failed to load user data");
818
+ I($), console.error("Failed to load user data:", $);
813
819
  } finally {
814
- p(!1);
820
+ w(!1);
815
821
  }
816
- }, w = async () => {
817
- await d();
818
- }, u = async (v, $, J) => {
819
- const V = await y.login({
820
- email: v,
822
+ }, c = async () => {
823
+ await S();
824
+ }, h = async (A, $, Q, X) => {
825
+ const W = await u.login({
826
+ username: A,
821
827
  password: $,
822
- tenantId: J
828
+ appId: Q,
829
+ tenantId: X
830
+ });
831
+ if (g.setTokens({
832
+ accessToken: W.accessToken,
833
+ refreshToken: W.refreshToken,
834
+ expiresIn: W.expiresIn
835
+ }), W.user) {
836
+ g.setUser(W.user), m(W.user);
837
+ try {
838
+ await S();
839
+ } catch (ee) {
840
+ console.warn("Failed to load complete user data after login:", ee);
841
+ }
842
+ }
843
+ return W;
844
+ }, o = async (A, $, Q, X, W, ee, ce) => {
845
+ if (!A && !$)
846
+ throw new Error("Either email or phoneNumber is required");
847
+ if (!Q || !X)
848
+ throw new Error("Name and password are required");
849
+ return await u.signup({
850
+ email: A,
851
+ phoneNumber: $,
852
+ name: Q,
853
+ password: X,
854
+ tenantId: W,
855
+ lastName: ee,
856
+ appId: ce
823
857
  });
824
- if (f.setTokens({
825
- accessToken: V.accessToken,
826
- refreshToken: V.refreshToken,
827
- expiresIn: V.expiresIn
828
- }), V.user) {
829
- f.setUser(V.user), h(V.user);
858
+ }, d = async (A, $, Q, X, W, ee, ce) => {
859
+ if (!A && !$)
860
+ throw new Error("Either email or phoneNumber is required");
861
+ if (!Q || !X || !W)
862
+ throw new Error("Name, password, and tenantName are required");
863
+ return await u.signupTenantAdmin({
864
+ email: A,
865
+ phoneNumber: $,
866
+ name: Q,
867
+ password: X,
868
+ tenantName: W,
869
+ appId: ce,
870
+ lastName: ee
871
+ });
872
+ }, G = async (A, $) => {
873
+ const Q = await g.getAuthHeaders();
874
+ await u.changePassword({ currentPassword: A, newPassword: $ }, Q);
875
+ }, Y = async (A, $) => {
876
+ await u.requestPasswordReset({ email: A, tenantId: $ });
877
+ }, H = async (A, $) => {
878
+ await u.confirmPasswordReset({ token: A, newPassword: $ });
879
+ }, C = async (A, $, Q, X, W, ee) => await u.sendMagicLink({
880
+ email: A,
881
+ tenantId: $,
882
+ frontendUrl: Q,
883
+ name: X,
884
+ lastName: W,
885
+ appId: ee
886
+ }), k = async (A, $, Q, X) => {
887
+ const W = await u.verifyMagicLink({
888
+ token: A,
889
+ email: $,
890
+ appId: Q,
891
+ tenantId: X
892
+ });
893
+ if (g.setTokens({
894
+ accessToken: W.accessToken,
895
+ refreshToken: W.refreshToken,
896
+ expiresIn: W.expiresIn
897
+ }), W.user) {
898
+ g.setUser(W.user), m(W.user);
830
899
  try {
831
- await d();
832
- } catch (oe) {
833
- console.warn("Failed to load complete user data after login:", oe);
900
+ await S();
901
+ } catch (ee) {
902
+ console.warn("Failed to load complete user data after magic link login:", ee);
834
903
  }
835
904
  }
836
- return V;
837
- }, a = async (v, $, J, V) => await y.signup({ email: v, name: $, password: J, tenantId: V }), l = async (v, $, J, V) => await y.signupTenantAdmin({
838
- email: v,
839
- name: $,
840
- password: J,
841
- tenantName: V,
842
- appId: t
843
- }), W = async (v, $) => {
844
- const J = await f.getAuthHeaders();
845
- await y.changePassword({ currentPassword: v, newPassword: $ }, J);
846
- }, I = async (v, $) => {
847
- await y.requestPasswordReset({ email: v, tenantId: $ });
848
- }, N = async (v, $) => {
849
- await y.confirmPasswordReset({ token: v, newPassword: $ });
850
- }, _ = async () => {
851
- const v = f.getTokens();
852
- if (!(v != null && v.refreshToken))
905
+ return W;
906
+ }, T = async () => {
907
+ const A = g.getTokens();
908
+ if (!(A != null && A.refreshToken))
853
909
  throw new Error("No refresh token available");
854
- const $ = await y.refreshToken({
855
- refreshToken: v.refreshToken
910
+ const $ = await u.refreshToken({
911
+ refreshToken: A.refreshToken
856
912
  });
857
- f.setTokens({
913
+ g.setTokens({
858
914
  accessToken: $.accessToken,
859
- refreshToken: $.refreshToken || v.refreshToken,
915
+ refreshToken: $.refreshToken || A.refreshToken,
860
916
  expiresIn: $.expiresIn
861
917
  });
862
- }, C = () => {
863
- f.clearSession(), h(null), F(null);
864
- }, U = (v) => {
865
- f.setTokens(v);
866
- }, Q = () => f.hasValidSession(), q = () => {
867
- f.clearSession(), h(null), F(null);
868
- }, O = async () => {
918
+ }, J = () => {
919
+ g.clearSession(), m(null), I(null);
920
+ }, O = (A) => {
921
+ g.setTokens(A);
922
+ }, j = () => g.hasValidSession(), N = () => {
923
+ g.clearSession(), m(null), I(null);
924
+ }, K = async () => {
869
925
  if (t)
870
926
  try {
871
927
  P(!0);
872
- const { roles: v } = await k.getRolesByApp(t);
873
- T(v);
874
- } catch (v) {
875
- console.error("Failed to fetch roles:", v);
928
+ const { roles: A } = await x.getRolesByApp(t);
929
+ E(A);
930
+ } catch (A) {
931
+ console.error("Failed to fetch roles:", A);
876
932
  } finally {
877
933
  P(!1);
878
934
  }
879
- }, j = async () => {
880
- await O();
881
- }, ie = (v) => {
882
- if (!E || E.length === 0)
935
+ }, R = async () => {
936
+ await K();
937
+ }, V = (A) => {
938
+ if (!z || z.length === 0)
883
939
  return !1;
884
- if (typeof v == "string")
885
- return E.includes(v);
886
- const $ = `${v.resource}.${v.action}`;
887
- return E.includes($);
940
+ if (typeof A == "string")
941
+ return z.includes(A);
942
+ const $ = `${A.resource}.${A.action}`;
943
+ return z.includes($);
888
944
  };
889
945
  return {
890
- sessionManager: f,
891
- authenticatedHttpService: L,
892
- login: u,
893
- signup: a,
894
- signupTenantAdmin: l,
895
- changePassword: W,
896
- requestPasswordReset: I,
897
- confirmPasswordReset: N,
898
- refreshToken: _,
899
- logout: C,
900
- setTokens: U,
901
- hasValidSession: Q,
902
- clearSession: q,
903
- currentUser: g,
904
- isUserLoading: x,
905
- userError: A,
906
- refreshUser: w,
907
- userRole: D,
908
- userPermissions: E,
909
- availableRoles: m,
910
- rolesLoading: M,
911
- hasPermission: ie,
912
- hasAnyPermission: (v) => v.some(($) => ie($)),
913
- hasAllPermissions: (v) => v.every(($) => ie($)),
914
- getUserPermissionStrings: () => E || [],
915
- refreshRoles: j
946
+ sessionManager: g,
947
+ authenticatedHttpService: U,
948
+ login: h,
949
+ signup: o,
950
+ signupTenantAdmin: d,
951
+ sendMagicLink: C,
952
+ verifyMagicLink: k,
953
+ changePassword: G,
954
+ requestPasswordReset: Y,
955
+ confirmPasswordReset: H,
956
+ refreshToken: T,
957
+ logout: J,
958
+ setTokens: O,
959
+ hasValidSession: j,
960
+ clearSession: N,
961
+ currentUser: f,
962
+ isUserLoading: M,
963
+ userError: v,
964
+ refreshUser: c,
965
+ userRole: B,
966
+ userPermissions: z,
967
+ availableRoles: b,
968
+ rolesLoading: L,
969
+ hasPermission: V,
970
+ hasAnyPermission: (A) => A.some(($) => V($)),
971
+ hasAllPermissions: (A) => A.every(($) => V($)),
972
+ getUserPermissionStrings: () => z || [],
973
+ refreshRoles: R
916
974
  };
917
975
  }, [
918
- f,
919
- L,
920
- y,
921
- S,
922
- k,
923
- t,
924
- m,
925
976
  g,
977
+ U,
978
+ u,
979
+ y,
926
980
  x,
927
- A,
928
- D,
929
- E
981
+ t,
982
+ b,
983
+ f,
984
+ M,
985
+ v,
986
+ B,
987
+ z
930
988
  ]);
931
- return Y(() => {
989
+ return Z(() => {
932
990
  !i.initialRoles && t && (async () => {
933
991
  try {
934
992
  P(!0);
935
- const w = new G(r), u = new ce(w), { roles: a } = await u.getRolesByApp(t);
936
- T(a);
937
- } catch (w) {
938
- console.error("Failed to fetch roles:", w);
993
+ const c = new te(r), h = new pe(c), { roles: o } = await h.getRolesByApp(t);
994
+ E(o);
995
+ } catch (c) {
996
+ console.error("Failed to fetch roles:", c);
939
997
  } finally {
940
998
  P(!1);
941
999
  }
942
1000
  })();
943
- }, [t, r, i.initialRoles]), Y(() => {
944
- const d = f.getUser();
945
- d && f.hasValidSession() && h(d);
946
- }, [f]), /* @__PURE__ */ s(ye.Provider, { value: B, children: e });
1001
+ }, [t, r, i.initialRoles]), Z(() => {
1002
+ const S = g.getUser();
1003
+ S && g.hasValidSession() && m(S);
1004
+ }, [g]), /* @__PURE__ */ n(Se.Provider, { value: q, children: e });
947
1005
  }
948
- function se() {
949
- const i = te(ye);
1006
+ function ie() {
1007
+ const i = le(Se);
950
1008
  if (!i)
951
1009
  throw new Error("useAuth must be used within an AuthProvider");
952
1010
  return i;
953
1011
  }
954
- class Me {
1012
+ class He {
955
1013
  constructor(e, t) {
956
1014
  this.httpService = e, this.sessionManager = t;
957
1015
  }
@@ -972,12 +1030,12 @@ class Me {
972
1030
  throw new Error("SessionManager is required for private endpoints");
973
1031
  const t = await this.sessionManager.getAuthHeaders(), r = new URLSearchParams();
974
1032
  e != null && e.page && r.append("page", e.page.toString()), e != null && e.limit && r.append("limit", e.limit.toString()), e != null && e.sortBy && r.append("sortBy", e.sortBy), e != null && e.sortOrder && r.append("sortOrder", e.sortOrder);
975
- const n = `/feature-flags/${r.toString() ? `?${r.toString()}` : ""}`, o = await this.httpService.get(n, {
1033
+ const s = `/feature-flags/${r.toString() ? `?${r.toString()}` : ""}`, a = await this.httpService.get(s, {
976
1034
  headers: t
977
1035
  });
978
1036
  return {
979
- featureFlags: o.data,
980
- meta: o.meta
1037
+ featureFlags: a.data,
1038
+ meta: a.meta
981
1039
  };
982
1040
  }
983
1041
  async getFeatureFlagById(e) {
@@ -1014,8 +1072,8 @@ class Me {
1014
1072
  throw new Error("Tenant ID and App ID are required");
1015
1073
  const r = new URLSearchParams();
1016
1074
  r.append("tenantId", e), r.append("appId", t);
1017
- const n = `/tenant-feature-flags${r.toString() ? `?${r.toString()}` : ""}`;
1018
- return (await this.httpService.get(n, {
1075
+ const s = `/tenant-feature-flags${r.toString() ? `?${r.toString()}` : ""}`;
1076
+ return (await this.httpService.get(s, {
1019
1077
  headers: { "X-Tenant-ID": e }
1020
1078
  })).data;
1021
1079
  }
@@ -1023,66 +1081,66 @@ class Me {
1023
1081
  async getTenantFeatureFlag(e, t, r) {
1024
1082
  if (!e || !t || !r)
1025
1083
  throw new Error("Flag Key, Tenant ID and App ID are required");
1026
- const n = new URLSearchParams();
1027
- n.append("tenantId", t), n.append("appId", r);
1028
- const o = `/tenant-feature-flags/${e}${n.toString() ? `?${n.toString()}` : ""}`;
1029
- return (await this.httpService.get(o, {
1084
+ const s = new URLSearchParams();
1085
+ s.append("tenantId", t), s.append("appId", r);
1086
+ const a = `/tenant-feature-flags/${e}${s.toString() ? `?${s.toString()}` : ""}`;
1087
+ return (await this.httpService.get(a, {
1030
1088
  headers: { "X-Tenant-ID": t }
1031
1089
  })).data;
1032
1090
  }
1033
1091
  }
1034
- const we = ee(null);
1035
- function it({ config: i = {}, children: e }) {
1036
- const { baseUrl: t, appId: r } = re(), { tenant: n } = K(), [o, m] = b([]), [T, M] = b(!1), [P, g] = b(null), h = z(() => {
1037
- const A = new G(t);
1038
- return new Me(A);
1039
- }, [t]), x = async () => {
1040
- if (!(n != null && n.id)) {
1041
- m([]);
1092
+ const xe = ae(null);
1093
+ function bt({ config: i = {}, children: e }) {
1094
+ const { baseUrl: t, appId: r } = ne(), { tenant: s } = re(), [a, b] = p([]), [E, L] = p(!1), [P, f] = p(null), m = _(() => {
1095
+ const v = new te(t);
1096
+ return new He(v);
1097
+ }, [t]), M = async () => {
1098
+ if (!(s != null && s.id)) {
1099
+ b([]);
1042
1100
  return;
1043
1101
  }
1044
- M(!0), g(null);
1102
+ L(!0), f(null);
1045
1103
  try {
1046
- const A = await h.getTenantFeatureFlags(n.id, r);
1047
- m(A);
1048
- } catch (A) {
1049
- const F = A instanceof Error ? A.message : "Failed to fetch feature flags";
1050
- g(F), i.onError && i.onError(A instanceof Error ? A : new Error(F));
1104
+ const v = await m.getTenantFeatureFlags(s.id, r);
1105
+ b(v);
1106
+ } catch (v) {
1107
+ const I = v instanceof Error ? v.message : "Failed to fetch feature flags";
1108
+ f(I), i.onError && i.onError(v instanceof Error ? v : new Error(I));
1051
1109
  } finally {
1052
- M(!1);
1110
+ L(!1);
1053
1111
  }
1054
1112
  };
1055
- Y(() => {
1056
- x();
1057
- const A = i.refreshInterval || 5 * 60 * 1e3, F = setInterval(x, A);
1058
- return () => clearInterval(F);
1059
- }, [n == null ? void 0 : n.id, i.refreshInterval]);
1060
- const p = z(() => ({
1061
- featureFlags: o,
1062
- loading: T,
1113
+ Z(() => {
1114
+ M();
1115
+ const v = i.refreshInterval || 5 * 60 * 1e3, I = setInterval(M, v);
1116
+ return () => clearInterval(I);
1117
+ }, [s == null ? void 0 : s.id, i.refreshInterval]);
1118
+ const w = _(() => ({
1119
+ featureFlags: a,
1120
+ loading: E,
1063
1121
  error: P,
1064
- isEnabled: (y) => {
1065
- const S = o.find((k) => k.key === y);
1066
- return (S == null ? void 0 : S.value) === !0;
1122
+ isEnabled: (u) => {
1123
+ const y = a.find((x) => x.key === u);
1124
+ return (y == null ? void 0 : y.value) === !0;
1067
1125
  },
1068
- getFlag: (y) => o.find((S) => S.key === y),
1069
- getFlagState: (y) => {
1070
- const S = o.find((k) => k.key === y);
1071
- return S ? S.value ? "enabled" : "disabled" : "not_found";
1126
+ getFlag: (u) => a.find((y) => y.key === u),
1127
+ getFlagState: (u) => {
1128
+ const y = a.find((x) => x.key === u);
1129
+ return y ? y.value ? "enabled" : "disabled" : "not_found";
1072
1130
  },
1073
1131
  refresh: async () => {
1074
- await x();
1132
+ await M();
1075
1133
  }
1076
- }), [o, T, P]);
1077
- return /* @__PURE__ */ s(we.Provider, { value: p, children: e });
1134
+ }), [a, E, P]);
1135
+ return /* @__PURE__ */ n(xe.Provider, { value: w, children: e });
1078
1136
  }
1079
- function Ee() {
1080
- const i = te(we);
1137
+ function $e() {
1138
+ const i = le(xe);
1081
1139
  if (!i)
1082
1140
  throw new Error("useFeatureFlags must be used within a FeatureFlagProvider");
1083
1141
  return i;
1084
1142
  }
1085
- class Re {
1143
+ class De {
1086
1144
  constructor(e, t) {
1087
1145
  this.httpService = e, this.sessionManager = t;
1088
1146
  }
@@ -1148,64 +1206,64 @@ class Re {
1148
1206
  )).data;
1149
1207
  }
1150
1208
  }
1151
- const me = ee(void 0);
1152
- function ot({ config: i = {}, children: e }) {
1153
- const { baseUrl: t } = re(), { tenant: r } = K(), [n, o] = b(null), [m, T] = b(!1), [M, P] = b(null), g = z(() => {
1154
- const p = new G(t);
1155
- return new Re(p);
1156
- }, [t]), h = async () => {
1209
+ const ke = ae(void 0);
1210
+ function wt({ config: i = {}, children: e }) {
1211
+ const { baseUrl: t } = ne(), { tenant: r } = re(), [s, a] = p(null), [b, E] = p(!1), [L, P] = p(null), f = _(() => {
1212
+ const w = new te(t);
1213
+ return new De(w);
1214
+ }, [t]), m = async () => {
1157
1215
  if (!(r != null && r.id)) {
1158
- o(null);
1216
+ a(null);
1159
1217
  return;
1160
1218
  }
1161
- T(!0), P(null);
1219
+ E(!0), P(null);
1162
1220
  try {
1163
- const p = await g.getTenantSubscriptionFeatures(r.id);
1164
- o(p);
1165
- } catch (p) {
1166
- const A = p instanceof Error ? p.message : "Failed to fetch subscription";
1167
- P(A), i.onError && i.onError(p instanceof Error ? p : new Error(A));
1221
+ const w = await f.getTenantSubscriptionFeatures(r.id);
1222
+ a(w);
1223
+ } catch (w) {
1224
+ const v = w instanceof Error ? w.message : "Failed to fetch subscription";
1225
+ P(v), i.onError && i.onError(w instanceof Error ? w : new Error(v));
1168
1226
  } finally {
1169
- T(!1);
1227
+ E(!1);
1170
1228
  }
1171
1229
  };
1172
- Y(() => {
1173
- if (h(), !i.refreshInterval) return;
1174
- const p = i.refreshInterval || 10 * 60 * 1e3, A = setInterval(h, p);
1175
- return () => clearInterval(A);
1230
+ Z(() => {
1231
+ if (m(), !i.refreshInterval) return;
1232
+ const w = i.refreshInterval || 10 * 60 * 1e3, v = setInterval(m, w);
1233
+ return () => clearInterval(v);
1176
1234
  }, [r == null ? void 0 : r.id, i.refreshInterval]);
1177
- const x = z(() => {
1178
- const p = (n == null ? void 0 : n.features) || [];
1235
+ const M = _(() => {
1236
+ const w = (s == null ? void 0 : s.features) || [];
1179
1237
  return {
1180
- subscription: n,
1181
- features: p,
1182
- loading: m,
1183
- error: M,
1184
- isFeatureEnabled: (S) => {
1185
- const k = p.find((R) => R.key === S);
1186
- return k ? k.type === "BOOLEAN" || k.type === "boolean" ? k.value === !0 : !!k.value : !1;
1238
+ subscription: s,
1239
+ features: w,
1240
+ loading: b,
1241
+ error: L,
1242
+ isFeatureEnabled: (y) => {
1243
+ const x = w.find((F) => F.key === y);
1244
+ return x ? x.type === "BOOLEAN" || x.type === "boolean" ? x.value === !0 : !!x.value : !1;
1187
1245
  },
1188
- getFeature: (S) => p.find((k) => k.key === S),
1189
- getFeatureValue: (S, k) => {
1190
- const R = p.find((D) => D.key === S);
1191
- return R ? R.value : k;
1246
+ getFeature: (y) => w.find((x) => x.key === y),
1247
+ getFeatureValue: (y, x) => {
1248
+ const F = w.find((B) => B.key === y);
1249
+ return F ? F.value : x;
1192
1250
  },
1193
- hasAllowedPlan: (S) => !n || !n.isActive ? !1 : S.includes(n.planId),
1251
+ hasAllowedPlan: (y) => !s || !s.isActive ? !1 : y.includes(s.planId),
1194
1252
  refresh: async () => {
1195
- await h();
1253
+ await m();
1196
1254
  }
1197
1255
  };
1198
- }, [n, m, M]);
1199
- return /* @__PURE__ */ s(me.Provider, { value: x, children: e });
1256
+ }, [s, b, L]);
1257
+ return /* @__PURE__ */ n(ke.Provider, { value: M, children: e });
1200
1258
  }
1201
- function Fe() {
1202
- const i = te(me);
1259
+ function Be() {
1260
+ const i = le(ke);
1203
1261
  if (i === void 0)
1204
1262
  throw new Error("useSubscription must be used within a SubscriptionProvider");
1205
1263
  return i;
1206
1264
  }
1207
- var X = /* @__PURE__ */ ((i) => (i.SUPERUSER = "SUPERUSER", i.TENANT_ADMIN = "TENANT_ADMIN", i.USER = "USER", i))(X || {});
1208
- const ue = () => /* @__PURE__ */ c(
1265
+ var se = /* @__PURE__ */ ((i) => (i.SUPERUSER = "SUPERUSER", i.TENANT_ADMIN = "TENANT_ADMIN", i.USER = "USER", i))(se || {});
1266
+ const me = () => /* @__PURE__ */ l(
1209
1267
  "div",
1210
1268
  {
1211
1269
  style: {
@@ -1221,10 +1279,10 @@ const ue = () => /* @__PURE__ */ c(
1221
1279
  margin: "20px 0"
1222
1280
  },
1223
1281
  children: [
1224
- /* @__PURE__ */ s("div", { style: { fontSize: "2rem", marginBottom: "10px" }, children: "🔒" }),
1225
- /* @__PURE__ */ s("h3", { style: { color: "#495057", marginBottom: "10px" }, children: "Access Required" }),
1226
- /* @__PURE__ */ s("p", { style: { color: "#6c757d", fontSize: "14px", marginBottom: "15px" }, children: "You need to be signed in to view this content." }),
1227
- /* @__PURE__ */ s(
1282
+ /* @__PURE__ */ n("div", { style: { fontSize: "2rem", marginBottom: "10px" }, children: "🔒" }),
1283
+ /* @__PURE__ */ n("h3", { style: { color: "#495057", marginBottom: "10px" }, children: "Access Required" }),
1284
+ /* @__PURE__ */ n("p", { style: { color: "#6c757d", fontSize: "14px", marginBottom: "15px" }, children: "You need to be signed in to view this content." }),
1285
+ /* @__PURE__ */ n(
1228
1286
  "button",
1229
1287
  {
1230
1288
  style: {
@@ -1242,11 +1300,11 @@ const ue = () => /* @__PURE__ */ c(
1242
1300
  )
1243
1301
  ]
1244
1302
  }
1245
- ), he = ({
1303
+ ), ye = ({
1246
1304
  userType: i,
1247
1305
  minUserType: e,
1248
1306
  missingPermissions: t
1249
- }) => /* @__PURE__ */ c(
1307
+ }) => /* @__PURE__ */ l(
1250
1308
  "div",
1251
1309
  {
1252
1310
  style: {
@@ -1262,57 +1320,57 @@ const ue = () => /* @__PURE__ */ c(
1262
1320
  margin: "20px 0"
1263
1321
  },
1264
1322
  children: [
1265
- /* @__PURE__ */ s("div", { style: { fontSize: "2rem", marginBottom: "10px" }, children: "⚠️" }),
1266
- /* @__PURE__ */ s("h3", { style: { color: "#856404", marginBottom: "10px" }, children: "Insufficient Permissions" }),
1267
- e && i ? /* @__PURE__ */ c(H, { children: [
1268
- /* @__PURE__ */ c("p", { style: { color: "#856404", fontSize: "14px", marginBottom: "10px" }, children: [
1323
+ /* @__PURE__ */ n("div", { style: { fontSize: "2rem", marginBottom: "10px" }, children: "⚠️" }),
1324
+ /* @__PURE__ */ n("h3", { style: { color: "#856404", marginBottom: "10px" }, children: "Insufficient Permissions" }),
1325
+ e && i ? /* @__PURE__ */ l(D, { children: [
1326
+ /* @__PURE__ */ l("p", { style: { color: "#856404", fontSize: "14px", marginBottom: "10px" }, children: [
1269
1327
  "This content requires ",
1270
- /* @__PURE__ */ s("strong", { children: e }),
1328
+ /* @__PURE__ */ n("strong", { children: e }),
1271
1329
  " access level or higher."
1272
1330
  ] }),
1273
- /* @__PURE__ */ c("p", { style: { color: "#6c757d", fontSize: "12px" }, children: [
1331
+ /* @__PURE__ */ l("p", { style: { color: "#6c757d", fontSize: "12px" }, children: [
1274
1332
  "Your current access level: ",
1275
- /* @__PURE__ */ s("strong", { children: i })
1333
+ /* @__PURE__ */ n("strong", { children: i })
1276
1334
  ] })
1277
- ] }) : /* @__PURE__ */ c(H, { children: [
1278
- /* @__PURE__ */ s("p", { style: { color: "#856404", fontSize: "14px", marginBottom: "10px" }, children: "You don't have the required permissions to view this content." }),
1279
- t && t.length > 0 && /* @__PURE__ */ c("p", { style: { color: "#6c757d", fontSize: "12px" }, children: [
1335
+ ] }) : /* @__PURE__ */ l(D, { children: [
1336
+ /* @__PURE__ */ n("p", { style: { color: "#856404", fontSize: "14px", marginBottom: "10px" }, children: "You don't have the required permissions to view this content." }),
1337
+ t && t.length > 0 && /* @__PURE__ */ l("p", { style: { color: "#6c757d", fontSize: "12px" }, children: [
1280
1338
  "Required permissions: ",
1281
- /* @__PURE__ */ s("strong", { children: t.join(", ") })
1339
+ /* @__PURE__ */ n("strong", { children: t.join(", ") })
1282
1340
  ] })
1283
1341
  ] })
1284
1342
  ]
1285
1343
  }
1286
- ), Ie = (i, e) => {
1344
+ ), Ne = (i, e) => {
1287
1345
  const t = {
1288
- [X.USER]: 1,
1289
- [X.TENANT_ADMIN]: 2,
1290
- [X.SUPERUSER]: 3
1346
+ [se.USER]: 1,
1347
+ [se.TENANT_ADMIN]: 2,
1348
+ [se.SUPERUSER]: 3
1291
1349
  };
1292
1350
  return t[i] >= t[e];
1293
1351
  };
1294
- function at({
1352
+ function vt({
1295
1353
  children: i,
1296
1354
  fallback: e,
1297
1355
  minUserType: t,
1298
1356
  requiredPermissions: r,
1299
- requireAllPermissions: n = !1
1357
+ requireAllPermissions: s = !1
1300
1358
  }) {
1301
- const { hasValidSession: o, sessionManager: m, hasPermission: T, hasAnyPermission: M, hasAllPermissions: P } = se();
1302
- if (!o())
1303
- return /* @__PURE__ */ s(H, { children: e || /* @__PURE__ */ s(ue, {}) });
1304
- const g = m.getUser();
1305
- if (!g)
1306
- return /* @__PURE__ */ s(H, { children: e || /* @__PURE__ */ s(ue, {}) });
1307
- if (t && !Ie(g.userType, t))
1308
- return /* @__PURE__ */ s(he, { userType: g.userType, minUserType: t });
1309
- if (r && r.length > 0 && !(n ? P(r) : M(r))) {
1310
- const x = r.filter((p) => !T(p)).map((p) => typeof p == "string" ? p : p.name);
1311
- return /* @__PURE__ */ s(he, { missingPermissions: x });
1312
- }
1313
- return /* @__PURE__ */ s(H, { children: i });
1359
+ const { hasValidSession: a, sessionManager: b, hasPermission: E, hasAnyPermission: L, hasAllPermissions: P } = ie();
1360
+ if (!a())
1361
+ return /* @__PURE__ */ n(D, { children: e || /* @__PURE__ */ n(me, {}) });
1362
+ const f = b.getUser();
1363
+ if (!f)
1364
+ return /* @__PURE__ */ n(D, { children: e || /* @__PURE__ */ n(me, {}) });
1365
+ if (t && !Ne(f.userType, t))
1366
+ return /* @__PURE__ */ n(ye, { userType: f.userType, minUserType: t });
1367
+ if (r && r.length > 0 && !(s ? P(r) : L(r))) {
1368
+ const M = r.filter((w) => !E(w)).map((w) => typeof w == "string" ? w : w.name);
1369
+ return /* @__PURE__ */ n(ye, { missingPermissions: M });
1370
+ }
1371
+ return /* @__PURE__ */ n(D, { children: i });
1314
1372
  }
1315
- const He = ({ redirectPath: i }) => /* @__PURE__ */ s(
1373
+ const qe = ({ redirectPath: i }) => /* @__PURE__ */ n(
1316
1374
  "div",
1317
1375
  {
1318
1376
  style: {
@@ -1325,7 +1383,7 @@ const He = ({ redirectPath: i }) => /* @__PURE__ */ s(
1325
1383
  backgroundColor: "#f9fafb",
1326
1384
  textAlign: "center"
1327
1385
  },
1328
- children: /* @__PURE__ */ c(
1386
+ children: /* @__PURE__ */ l(
1329
1387
  "div",
1330
1388
  {
1331
1389
  style: {
@@ -1336,10 +1394,10 @@ const He = ({ redirectPath: i }) => /* @__PURE__ */ s(
1336
1394
  maxWidth: "400px"
1337
1395
  },
1338
1396
  children: [
1339
- /* @__PURE__ */ s("div", { style: { fontSize: "3rem", marginBottom: "1rem" }, children: "🔒" }),
1340
- /* @__PURE__ */ s("h2", { style: { color: "#374151", marginBottom: "1rem" }, children: "Access Required" }),
1341
- /* @__PURE__ */ s("p", { style: { color: "#6b7280", marginBottom: "1.5rem" }, children: "You need to be signed in to access this page." }),
1342
- /* @__PURE__ */ c("p", { style: { fontSize: "0.875rem", color: "#9ca3af" }, children: [
1397
+ /* @__PURE__ */ n("div", { style: { fontSize: "3rem", marginBottom: "1rem" }, children: "🔒" }),
1398
+ /* @__PURE__ */ n("h2", { style: { color: "#374151", marginBottom: "1rem" }, children: "Access Required" }),
1399
+ /* @__PURE__ */ n("p", { style: { color: "#6b7280", marginBottom: "1.5rem" }, children: "You need to be signed in to access this page." }),
1400
+ /* @__PURE__ */ l("p", { style: { fontSize: "0.875rem", color: "#9ca3af" }, children: [
1343
1401
  "Redirecting to ",
1344
1402
  i,
1345
1403
  "..."
@@ -1348,11 +1406,11 @@ const He = ({ redirectPath: i }) => /* @__PURE__ */ s(
1348
1406
  }
1349
1407
  )
1350
1408
  }
1351
- ), ge = ({
1409
+ ), be = ({
1352
1410
  userType: i,
1353
1411
  minUserType: e,
1354
1412
  missingPermissions: t
1355
- }) => /* @__PURE__ */ s(
1413
+ }) => /* @__PURE__ */ n(
1356
1414
  "div",
1357
1415
  {
1358
1416
  style: {
@@ -1365,7 +1423,7 @@ const He = ({ redirectPath: i }) => /* @__PURE__ */ s(
1365
1423
  backgroundColor: "#f9fafb",
1366
1424
  textAlign: "center"
1367
1425
  },
1368
- children: /* @__PURE__ */ c(
1426
+ children: /* @__PURE__ */ l(
1369
1427
  "div",
1370
1428
  {
1371
1429
  style: {
@@ -1376,63 +1434,63 @@ const He = ({ redirectPath: i }) => /* @__PURE__ */ s(
1376
1434
  maxWidth: "400px"
1377
1435
  },
1378
1436
  children: [
1379
- /* @__PURE__ */ s("div", { style: { fontSize: "3rem", marginBottom: "1rem" }, children: "⚠️" }),
1380
- /* @__PURE__ */ s("h2", { style: { color: "#374151", marginBottom: "1rem" }, children: "Insufficient Permissions" }),
1381
- e && i ? /* @__PURE__ */ c(H, { children: [
1382
- /* @__PURE__ */ c("p", { style: { color: "#6b7280", marginBottom: "1rem" }, children: [
1437
+ /* @__PURE__ */ n("div", { style: { fontSize: "3rem", marginBottom: "1rem" }, children: "⚠️" }),
1438
+ /* @__PURE__ */ n("h2", { style: { color: "#374151", marginBottom: "1rem" }, children: "Insufficient Permissions" }),
1439
+ e && i ? /* @__PURE__ */ l(D, { children: [
1440
+ /* @__PURE__ */ l("p", { style: { color: "#6b7280", marginBottom: "1rem" }, children: [
1383
1441
  "This page requires ",
1384
- /* @__PURE__ */ s("strong", { children: e }),
1442
+ /* @__PURE__ */ n("strong", { children: e }),
1385
1443
  " access level or higher."
1386
1444
  ] }),
1387
- /* @__PURE__ */ c("p", { style: { color: "#9ca3af", fontSize: "0.875rem" }, children: [
1445
+ /* @__PURE__ */ l("p", { style: { color: "#9ca3af", fontSize: "0.875rem" }, children: [
1388
1446
  "Your current access level: ",
1389
- /* @__PURE__ */ s("strong", { children: i })
1447
+ /* @__PURE__ */ n("strong", { children: i })
1390
1448
  ] })
1391
- ] }) : /* @__PURE__ */ c(H, { children: [
1392
- /* @__PURE__ */ s("p", { style: { color: "#6b7280", marginBottom: "1rem" }, children: "You don't have the required permissions to access this page." }),
1393
- t && t.length > 0 && /* @__PURE__ */ c("p", { style: { color: "#9ca3af", fontSize: "0.875rem" }, children: [
1449
+ ] }) : /* @__PURE__ */ l(D, { children: [
1450
+ /* @__PURE__ */ n("p", { style: { color: "#6b7280", marginBottom: "1rem" }, children: "You don't have the required permissions to access this page." }),
1451
+ t && t.length > 0 && /* @__PURE__ */ l("p", { style: { color: "#9ca3af", fontSize: "0.875rem" }, children: [
1394
1452
  "Required permissions: ",
1395
- /* @__PURE__ */ s("strong", { children: t.join(", ") })
1453
+ /* @__PURE__ */ n("strong", { children: t.join(", ") })
1396
1454
  ] })
1397
1455
  ] })
1398
1456
  ]
1399
1457
  }
1400
1458
  )
1401
1459
  }
1402
- ), Ce = (i, e) => {
1460
+ ), Ue = (i, e) => {
1403
1461
  const t = {
1404
- [X.USER]: 1,
1405
- [X.TENANT_ADMIN]: 2,
1406
- [X.SUPERUSER]: 3
1462
+ [se.USER]: 1,
1463
+ [se.TENANT_ADMIN]: 2,
1464
+ [se.SUPERUSER]: 3
1407
1465
  };
1408
1466
  return t[i] >= t[e];
1409
1467
  };
1410
- function lt({
1468
+ function St({
1411
1469
  children: i,
1412
1470
  redirectTo: e = "/login",
1413
1471
  minUserType: t,
1414
1472
  requiredPermissions: r,
1415
- requireAllPermissions: n = !1,
1416
- fallback: o
1473
+ requireAllPermissions: s = !1,
1474
+ fallback: a
1417
1475
  }) {
1418
- const { hasValidSession: m, sessionManager: T, hasPermission: M, hasAnyPermission: P, hasAllPermissions: g } = se(), h = ae();
1419
- if (!m())
1420
- return o ? /* @__PURE__ */ s(H, { children: o }) : /* @__PURE__ */ c(H, { children: [
1421
- /* @__PURE__ */ s(He, { redirectPath: e }),
1422
- /* @__PURE__ */ s(ne, { to: e, state: { from: h.pathname }, replace: !0 })
1476
+ const { hasValidSession: b, sessionManager: E, hasPermission: L, hasAnyPermission: P, hasAllPermissions: f } = ie(), m = he();
1477
+ if (!b())
1478
+ return a ? /* @__PURE__ */ n(D, { children: a }) : /* @__PURE__ */ l(D, { children: [
1479
+ /* @__PURE__ */ n(qe, { redirectPath: e }),
1480
+ /* @__PURE__ */ n(de, { to: e, state: { from: m.pathname }, replace: !0 })
1423
1481
  ] });
1424
- const x = T.getUser();
1425
- if (!x)
1426
- return /* @__PURE__ */ s(ne, { to: e, state: { from: h.pathname }, replace: !0 });
1427
- if (t && !Ce(x.userType, t))
1428
- return /* @__PURE__ */ s(ge, { userType: x.userType, minUserType: t });
1429
- if (r && r.length > 0 && !(n ? g(r) : P(r))) {
1430
- const A = r.filter((F) => !M(F)).map((F) => typeof F == "string" ? F : F.name);
1431
- return /* @__PURE__ */ s(ge, { missingPermissions: A });
1432
- }
1433
- return /* @__PURE__ */ s(H, { children: i });
1482
+ const M = E.getUser();
1483
+ if (!M)
1484
+ return /* @__PURE__ */ n(de, { to: e, state: { from: m.pathname }, replace: !0 });
1485
+ if (t && !Ue(M.userType, t))
1486
+ return /* @__PURE__ */ n(be, { userType: M.userType, minUserType: t });
1487
+ if (r && r.length > 0 && !(s ? f(r) : P(r))) {
1488
+ const v = r.filter((I) => !L(I)).map((I) => typeof I == "string" ? I : I.name);
1489
+ return /* @__PURE__ */ n(be, { missingPermissions: v });
1490
+ }
1491
+ return /* @__PURE__ */ n(D, { children: i });
1434
1492
  }
1435
- const $e = ({ redirectPath: i }) => /* @__PURE__ */ s(
1493
+ const ze = ({ redirectPath: i }) => /* @__PURE__ */ n(
1436
1494
  "div",
1437
1495
  {
1438
1496
  style: {
@@ -1445,7 +1503,7 @@ const $e = ({ redirectPath: i }) => /* @__PURE__ */ s(
1445
1503
  backgroundColor: "#f9fafb",
1446
1504
  textAlign: "center"
1447
1505
  },
1448
- children: /* @__PURE__ */ c(
1506
+ children: /* @__PURE__ */ l(
1449
1507
  "div",
1450
1508
  {
1451
1509
  style: {
@@ -1456,10 +1514,10 @@ const $e = ({ redirectPath: i }) => /* @__PURE__ */ s(
1456
1514
  maxWidth: "400px"
1457
1515
  },
1458
1516
  children: [
1459
- /* @__PURE__ */ s("div", { style: { fontSize: "3rem", marginBottom: "1rem" }, children: "🏢" }),
1460
- /* @__PURE__ */ s("h2", { style: { color: "#374151", marginBottom: "1rem" }, children: "Tenant Required" }),
1461
- /* @__PURE__ */ s("p", { style: { color: "#6b7280", marginBottom: "1.5rem" }, children: "This page requires a tenant context to access." }),
1462
- /* @__PURE__ */ c("p", { style: { fontSize: "0.875rem", color: "#9ca3af" }, children: [
1517
+ /* @__PURE__ */ n("div", { style: { fontSize: "3rem", marginBottom: "1rem" }, children: "🏢" }),
1518
+ /* @__PURE__ */ n("h2", { style: { color: "#374151", marginBottom: "1rem" }, children: "Tenant Required" }),
1519
+ /* @__PURE__ */ n("p", { style: { color: "#6b7280", marginBottom: "1.5rem" }, children: "This page requires a tenant context to access." }),
1520
+ /* @__PURE__ */ l("p", { style: { fontSize: "0.875rem", color: "#9ca3af" }, children: [
1463
1521
  "Redirecting to ",
1464
1522
  i,
1465
1523
  "..."
@@ -1469,18 +1527,14 @@ const $e = ({ redirectPath: i }) => /* @__PURE__ */ s(
1469
1527
  )
1470
1528
  }
1471
1529
  );
1472
- function ct({
1473
- children: i,
1474
- redirectTo: e = "/",
1475
- fallback: t
1476
- }) {
1477
- const { tenant: r, isLoading: n, error: o } = K(), m = ae();
1478
- return n || o ? null : r ? /* @__PURE__ */ s(H, { children: i }) : t ? /* @__PURE__ */ s(H, { children: t }) : /* @__PURE__ */ c(H, { children: [
1479
- /* @__PURE__ */ s($e, { redirectPath: e }),
1480
- /* @__PURE__ */ s(ne, { to: e, state: { from: m.pathname }, replace: !0 })
1530
+ function xt({ children: i, redirectTo: e = "/", fallback: t }) {
1531
+ const { tenant: r, isLoading: s, error: a } = re(), b = he();
1532
+ return s || a ? null : r ? /* @__PURE__ */ n(D, { children: i }) : t ? /* @__PURE__ */ n(D, { children: t }) : /* @__PURE__ */ l(D, { children: [
1533
+ /* @__PURE__ */ n(ze, { redirectPath: e }),
1534
+ /* @__PURE__ */ n(de, { to: e, state: { from: b.pathname }, replace: !0 })
1481
1535
  ] });
1482
1536
  }
1483
- const Le = ({ redirectPath: i }) => /* @__PURE__ */ s(
1537
+ const Oe = ({ redirectPath: i }) => /* @__PURE__ */ n(
1484
1538
  "div",
1485
1539
  {
1486
1540
  style: {
@@ -1493,7 +1547,7 @@ const Le = ({ redirectPath: i }) => /* @__PURE__ */ s(
1493
1547
  backgroundColor: "#f9fafb",
1494
1548
  textAlign: "center"
1495
1549
  },
1496
- children: /* @__PURE__ */ c(
1550
+ children: /* @__PURE__ */ l(
1497
1551
  "div",
1498
1552
  {
1499
1553
  style: {
@@ -1504,10 +1558,10 @@ const Le = ({ redirectPath: i }) => /* @__PURE__ */ s(
1504
1558
  maxWidth: "400px"
1505
1559
  },
1506
1560
  children: [
1507
- /* @__PURE__ */ s("div", { style: { fontSize: "3rem", marginBottom: "1rem" }, children: "🚀" }),
1508
- /* @__PURE__ */ s("h2", { style: { color: "#374151", marginBottom: "1rem" }, children: "Tenant Detected" }),
1509
- /* @__PURE__ */ s("p", { style: { color: "#6b7280", marginBottom: "1.5rem" }, children: "You are accessing a tenant-specific context. Redirecting to the appropriate page." }),
1510
- /* @__PURE__ */ c("p", { style: { fontSize: "0.875rem", color: "#9ca3af" }, children: [
1561
+ /* @__PURE__ */ n("div", { style: { fontSize: "3rem", marginBottom: "1rem" }, children: "🚀" }),
1562
+ /* @__PURE__ */ n("h2", { style: { color: "#374151", marginBottom: "1rem" }, children: "Tenant Detected" }),
1563
+ /* @__PURE__ */ n("p", { style: { color: "#6b7280", marginBottom: "1.5rem" }, children: "You are accessing a tenant-specific context. Redirecting to the appropriate page." }),
1564
+ /* @__PURE__ */ l("p", { style: { fontSize: "0.875rem", color: "#9ca3af" }, children: [
1511
1565
  "Redirecting to ",
1512
1566
  i,
1513
1567
  "..."
@@ -1517,18 +1571,14 @@ const Le = ({ redirectPath: i }) => /* @__PURE__ */ s(
1517
1571
  )
1518
1572
  }
1519
1573
  );
1520
- function dt({
1521
- children: i,
1522
- redirectTo: e = "/dashboard",
1523
- fallback: t
1524
- }) {
1525
- const { tenant: r, isLoading: n, error: o } = K(), m = ae();
1526
- return n || o ? null : r ? t ? /* @__PURE__ */ s(H, { children: t }) : /* @__PURE__ */ c(H, { children: [
1527
- /* @__PURE__ */ s(Le, { redirectPath: e }),
1528
- /* @__PURE__ */ s(ne, { to: e, state: { from: m.pathname }, replace: !0 })
1529
- ] }) : /* @__PURE__ */ s(H, { children: i });
1574
+ function kt({ children: i, redirectTo: e = "/dashboard", fallback: t }) {
1575
+ const { tenant: r, isLoading: s, error: a } = re(), b = he();
1576
+ return s || a ? null : r ? t ? /* @__PURE__ */ n(D, { children: t }) : /* @__PURE__ */ l(D, { children: [
1577
+ /* @__PURE__ */ n(Oe, { redirectPath: e }),
1578
+ /* @__PURE__ */ n(de, { to: e, state: { from: b.pathname }, replace: !0 })
1579
+ ] }) : /* @__PURE__ */ n(D, { children: i });
1530
1580
  }
1531
- const De = () => /* @__PURE__ */ c(
1581
+ const je = () => /* @__PURE__ */ l(
1532
1582
  "div",
1533
1583
  {
1534
1584
  style: {
@@ -1540,19 +1590,19 @@ const De = () => /* @__PURE__ */ c(
1540
1590
  color: "#dc2626"
1541
1591
  },
1542
1592
  children: [
1543
- /* @__PURE__ */ s("h3", { style: { margin: "0 0 1rem 0" }, children: "🔒 Subscription Required" }),
1544
- /* @__PURE__ */ s("p", { style: { margin: 0 }, children: "This feature requires a higher subscription plan. Please upgrade your plan to access this content." })
1593
+ /* @__PURE__ */ n("h3", { style: { margin: "0 0 1rem 0" }, children: "🔒 Subscription Required" }),
1594
+ /* @__PURE__ */ n("p", { style: { margin: 0 }, children: "This feature requires a higher subscription plan. Please upgrade your plan to access this content." })
1545
1595
  ]
1546
1596
  }
1547
1597
  );
1548
- function ut({
1598
+ function At({
1549
1599
  children: i,
1550
- fallback: e = /* @__PURE__ */ s(De, {}),
1600
+ fallback: e = /* @__PURE__ */ n(je, {}),
1551
1601
  allowedPlans: t,
1552
1602
  requiredFeature: r
1553
1603
  }) {
1554
- const { subscription: n, hasAllowedPlan: o, isFeatureEnabled: m, loading: T } = Fe();
1555
- return T ? /* @__PURE__ */ s(
1604
+ const { subscription: s, hasAllowedPlan: a, isFeatureEnabled: b, loading: E } = Be();
1605
+ return E ? /* @__PURE__ */ n(
1556
1606
  "div",
1557
1607
  {
1558
1608
  style: {
@@ -1562,9 +1612,9 @@ function ut({
1562
1612
  },
1563
1613
  children: "Loading subscription..."
1564
1614
  }
1565
- ) : n ? n.isActive ? t && t.length > 0 && !o(t) ? /* @__PURE__ */ s(H, { children: e }) : r && !m(r) ? /* @__PURE__ */ s(H, { children: e }) : /* @__PURE__ */ s(H, { children: i }) : /* @__PURE__ */ s(H, { children: e }) : /* @__PURE__ */ s(H, { children: e });
1615
+ ) : s ? s.isActive ? t && t.length > 0 && !a(t) ? /* @__PURE__ */ n(D, { children: e }) : r && !b(r) ? /* @__PURE__ */ n(D, { children: e }) : /* @__PURE__ */ n(D, { children: i }) : /* @__PURE__ */ n(D, { children: e }) : /* @__PURE__ */ n(D, { children: e });
1566
1616
  }
1567
- const Be = ({ flagName: i }) => /* @__PURE__ */ c(
1617
+ const We = ({ flagName: i }) => /* @__PURE__ */ l(
1568
1618
  "div",
1569
1619
  {
1570
1620
  style: {
@@ -1581,9 +1631,9 @@ const Be = ({ flagName: i }) => /* @__PURE__ */ c(
1581
1631
  color: "#6c757d"
1582
1632
  },
1583
1633
  children: [
1584
- /* @__PURE__ */ s("div", { style: { fontSize: "24px", marginBottom: "8px" }, children: "🚧" }),
1585
- /* @__PURE__ */ s("div", { style: { fontSize: "14px", fontWeight: "500", marginBottom: "4px" }, children: "Feature Not Available" }),
1586
- /* @__PURE__ */ c("div", { style: { fontSize: "12px", opacity: 0.7 }, children: [
1634
+ /* @__PURE__ */ n("div", { style: { fontSize: "24px", marginBottom: "8px" }, children: "🚧" }),
1635
+ /* @__PURE__ */ n("div", { style: { fontSize: "14px", fontWeight: "500", marginBottom: "4px" }, children: "Feature Not Available" }),
1636
+ /* @__PURE__ */ l("div", { style: { fontSize: "12px", opacity: 0.7 }, children: [
1587
1637
  'Feature flag "',
1588
1638
  i,
1589
1639
  '" is disabled'
@@ -1591,9 +1641,9 @@ const Be = ({ flagName: i }) => /* @__PURE__ */ c(
1591
1641
  ]
1592
1642
  }
1593
1643
  );
1594
- function ht({ name: i, children: e, fallback: t }) {
1595
- const { isEnabled: r, loading: n } = Ee();
1596
- return n ? /* @__PURE__ */ s(
1644
+ function Pt({ name: i, children: e, fallback: t }) {
1645
+ const { isEnabled: r, loading: s } = $e();
1646
+ return s ? /* @__PURE__ */ n(
1597
1647
  "div",
1598
1648
  {
1599
1649
  style: {
@@ -1606,9 +1656,9 @@ function ht({ name: i, children: e, fallback: t }) {
1606
1656
  },
1607
1657
  children: "Loading feature flags..."
1608
1658
  }
1609
- ) : (console.log(i, r(i)), r(i) ? /* @__PURE__ */ s(H, { children: e }) : /* @__PURE__ */ s(H, { children: t || /* @__PURE__ */ s(Be, { flagName: i }) }));
1659
+ ) : (console.log(i, r(i)), r(i) ? /* @__PURE__ */ n(D, { children: e }) : /* @__PURE__ */ n(D, { children: t || /* @__PURE__ */ n(We, { flagName: i }) }));
1610
1660
  }
1611
- const qe = () => /* @__PURE__ */ c(
1661
+ const Ve = () => /* @__PURE__ */ l(
1612
1662
  "svg",
1613
1663
  {
1614
1664
  width: "16",
@@ -1621,11 +1671,11 @@ const qe = () => /* @__PURE__ */ c(
1621
1671
  strokeLinejoin: "round",
1622
1672
  style: { flexShrink: 0 },
1623
1673
  children: [
1624
- /* @__PURE__ */ s("path", { d: "M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z" }),
1625
- /* @__PURE__ */ s("circle", { cx: "12", cy: "12", r: "3" })
1674
+ /* @__PURE__ */ n("path", { d: "M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z" }),
1675
+ /* @__PURE__ */ n("circle", { cx: "12", cy: "12", r: "3" })
1626
1676
  ]
1627
1677
  }
1628
- ), Ue = () => /* @__PURE__ */ c(
1678
+ ), Ge = () => /* @__PURE__ */ l(
1629
1679
  "svg",
1630
1680
  {
1631
1681
  width: "16",
@@ -1638,26 +1688,28 @@ const qe = () => /* @__PURE__ */ c(
1638
1688
  strokeLinejoin: "round",
1639
1689
  style: { flexShrink: 0 },
1640
1690
  children: [
1641
- /* @__PURE__ */ s("path", { d: "M17.94 17.94A10.07 10.07 0 0 1 12 20c-7 0-11-8-11-8a18.45 18.45 0 0 1 5.06-5.94M9.9 4.24A9.12 9.12 0 0 1 12 4c7 0 11 8 11 8a18.5 18.5 0 0 1-2.16 3.19m-6.72-1.07a3 3 0 1 1-4.24-4.24" }),
1642
- /* @__PURE__ */ s("line", { x1: "1", y1: "1", x2: "23", y2: "23" })
1691
+ /* @__PURE__ */ n("path", { d: "M17.94 17.94A10.07 10.07 0 0 1 12 20c-7 0-11-8-11-8a18.45 18.45 0 0 1 5.06-5.94M9.9 4.24A9.12 9.12 0 0 1 12 4c7 0 11 8 11 8a18.5 18.5 0 0 1-2.16 3.19m-6.72-1.07a3 3 0 1 1-4.24-4.24" }),
1692
+ /* @__PURE__ */ n("line", { x1: "1", y1: "1", x2: "23", y2: "23" })
1643
1693
  ]
1644
1694
  }
1645
- ), Ne = {
1646
- showPassword: /* @__PURE__ */ s(qe, {}),
1647
- hidePassword: /* @__PURE__ */ s(Ue, {})
1648
- }, ze = {
1695
+ ), Ye = {
1696
+ showPassword: /* @__PURE__ */ n(Ve, {}),
1697
+ hidePassword: /* @__PURE__ */ n(Ge, {})
1698
+ }, _e = {
1649
1699
  title: "Sign In",
1650
- emailLabel: "Email",
1651
- emailPlaceholder: "Enter your email",
1700
+ usernameLabel: "Email or Phone",
1701
+ usernamePlaceholder: "Enter your email or phone number",
1652
1702
  passwordLabel: "Password",
1653
1703
  passwordPlaceholder: "Enter your password",
1654
1704
  submitButton: "Sign In",
1655
1705
  forgotPasswordLink: "Forgot your password?",
1656
1706
  signupLink: "Sign up here",
1657
1707
  signupText: "Don't have an account?",
1658
- errorMessage: "Invalid email or password",
1708
+ magicLinkText: "Prefer passwordless?",
1709
+ magicLinkLink: "Use Magic Link",
1710
+ errorMessage: "Invalid credentials",
1659
1711
  loadingText: "Signing in..."
1660
- }, Oe = {
1712
+ }, Ke = {
1661
1713
  container: {
1662
1714
  maxWidth: "400px",
1663
1715
  width: "100%",
@@ -1764,124 +1816,138 @@ const qe = () => /* @__PURE__ */ c(
1764
1816
  fontSize: "0.875rem"
1765
1817
  }
1766
1818
  };
1767
- function gt({
1819
+ function Tt({
1768
1820
  copy: i = {},
1769
1821
  styles: e = {},
1770
1822
  icons: t = {},
1771
1823
  onSuccess: r,
1772
- onError: n,
1773
- onForgotPassword: o,
1774
- onSignupClick: m,
1775
- showForgotPassword: T = !0,
1776
- showSignupLink: M = !0,
1777
- className: P
1824
+ onError: s,
1825
+ onForgotPassword: a,
1826
+ onSignupClick: b,
1827
+ onMagicLinkClick: E,
1828
+ showForgotPassword: L = !0,
1829
+ showSignupLink: P = !0,
1830
+ showMagicLinkOption: f = !0,
1831
+ className: m
1778
1832
  }) {
1779
- const [g, h] = b(""), [x, p] = b(""), [A, F] = b(!1), [f, L] = b(!1), [y, S] = b(""), [k, R] = b({}), { login: D } = se(), { tenant: E } = K(), B = { ...ze, ...i }, d = { ...Oe, ...e }, w = { ...Ne, ...t }, u = () => {
1780
- const I = {};
1781
- return g.trim() || (I.email = !0), x.trim() || (I.password = !0), R(I), Object.keys(I).length === 0;
1782
- }, a = async (I) => {
1783
- if (I.preventDefault(), !!u()) {
1784
- if (!(E != null && E.id)) {
1785
- S("Tenant not found");
1833
+ const [M, w] = p(""), [v, I] = p(""), [g, U] = p(!1), [u, y] = p(!1), [x, F] = p(""), [B, z] = p({}), { login: q } = ie(), { tenant: S } = re(), { appId: c } = ne(), h = { ..._e, ...i }, o = { ...Ke, ...e }, d = { ...Ye, ...t }, G = () => {
1834
+ const k = {};
1835
+ return M.trim() || (k.username = !0), v.trim() || (k.password = !0), z(k), Object.keys(k).length === 0;
1836
+ }, Y = async (k) => {
1837
+ if (k.preventDefault(), !!G()) {
1838
+ if (!(S != null && S.id)) {
1839
+ F("Tenant not found");
1786
1840
  return;
1787
1841
  }
1788
- L(!0), S("");
1842
+ y(!0), F("");
1789
1843
  try {
1790
- const N = await D(g, x, E.id);
1791
- r == null || r(N);
1792
- } catch (N) {
1793
- const _ = N.message || B.errorMessage;
1794
- S(_), n == null || n(_);
1844
+ const T = await q(M, v, c, S.id);
1845
+ r == null || r(T);
1846
+ } catch (T) {
1847
+ const J = T.message || h.errorMessage;
1848
+ F(J), s == null || s(J);
1795
1849
  } finally {
1796
- L(!1);
1850
+ y(!1);
1797
1851
  }
1798
1852
  }
1799
- }, l = (I) => ({
1800
- ...d.input,
1801
- ...k[I] ? d.inputError : {}
1802
- }), W = () => ({
1803
- ...d.button,
1804
- ...f ? d.buttonLoading : {},
1805
- ...!g || !x || f ? d.buttonDisabled : {}
1853
+ }, H = (k) => ({
1854
+ ...o.input,
1855
+ ...B[k] ? o.inputError : {}
1856
+ }), C = () => ({
1857
+ ...o.button,
1858
+ ...u ? o.buttonLoading : {},
1859
+ ...!M || !v || u ? o.buttonDisabled : {}
1806
1860
  });
1807
- return /* @__PURE__ */ c("div", { className: P, style: d.container, children: [
1808
- /* @__PURE__ */ s("h2", { style: d.title, children: B.title }),
1809
- /* @__PURE__ */ c("form", { onSubmit: a, style: d.form, children: [
1810
- /* @__PURE__ */ c("div", { style: d.fieldGroup, children: [
1811
- /* @__PURE__ */ s("label", { style: d.label, children: B.emailLabel }),
1812
- /* @__PURE__ */ s(
1861
+ return /* @__PURE__ */ l("div", { className: m, style: o.container, children: [
1862
+ /* @__PURE__ */ n("h2", { style: o.title, children: h.title }),
1863
+ /* @__PURE__ */ l("form", { onSubmit: Y, style: o.form, children: [
1864
+ /* @__PURE__ */ l("div", { style: o.fieldGroup, children: [
1865
+ /* @__PURE__ */ n("label", { style: o.label, children: h.usernameLabel }),
1866
+ /* @__PURE__ */ n(
1813
1867
  "input",
1814
1868
  {
1815
- id: "email",
1816
- name: "email",
1817
- type: "email",
1818
- value: g,
1819
- onChange: (I) => {
1820
- h(I.target.value), k.email && R((N) => ({ ...N, email: !1 }));
1869
+ id: "username",
1870
+ name: "username",
1871
+ type: "text",
1872
+ value: M,
1873
+ onChange: (k) => {
1874
+ w(k.target.value), B.username && z((T) => ({ ...T, username: !1 }));
1821
1875
  },
1822
- placeholder: B.emailPlaceholder,
1823
- style: l("email"),
1824
- disabled: f
1876
+ placeholder: h.usernamePlaceholder,
1877
+ style: H("username"),
1878
+ disabled: u
1825
1879
  }
1826
1880
  )
1827
1881
  ] }),
1828
- /* @__PURE__ */ c("div", { style: d.fieldGroup, children: [
1829
- /* @__PURE__ */ s("label", { style: d.label, children: B.passwordLabel }),
1830
- /* @__PURE__ */ c("div", { style: d.inputContainer, children: [
1831
- /* @__PURE__ */ s(
1882
+ /* @__PURE__ */ l("div", { style: o.fieldGroup, children: [
1883
+ /* @__PURE__ */ n("label", { style: o.label, children: h.passwordLabel }),
1884
+ /* @__PURE__ */ l("div", { style: o.inputContainer, children: [
1885
+ /* @__PURE__ */ n(
1832
1886
  "input",
1833
1887
  {
1834
1888
  id: "password",
1835
1889
  name: "password",
1836
- type: A ? "text" : "password",
1837
- value: x,
1838
- onChange: (I) => {
1839
- p(I.target.value), k.password && R((N) => ({ ...N, password: !1 }));
1890
+ type: g ? "text" : "password",
1891
+ value: v,
1892
+ onChange: (k) => {
1893
+ I(k.target.value), B.password && z((T) => ({ ...T, password: !1 }));
1840
1894
  },
1841
- placeholder: B.passwordPlaceholder,
1895
+ placeholder: h.passwordPlaceholder,
1842
1896
  style: {
1843
- ...l("password"),
1897
+ ...H("password"),
1844
1898
  paddingRight: "2.5rem"
1845
1899
  // Make room for the icon
1846
1900
  },
1847
- disabled: f
1901
+ disabled: u
1848
1902
  }
1849
1903
  ),
1850
- /* @__PURE__ */ s(
1904
+ /* @__PURE__ */ n(
1851
1905
  "button",
1852
1906
  {
1853
1907
  type: "button",
1854
- onClick: () => F(!A),
1855
- style: d.passwordToggle,
1856
- disabled: f,
1857
- "aria-label": A ? "Hide password" : "Show password",
1858
- children: A ? w.hidePassword : w.showPassword
1908
+ onClick: () => U(!g),
1909
+ style: o.passwordToggle,
1910
+ disabled: u,
1911
+ "aria-label": g ? "Hide password" : "Show password",
1912
+ children: g ? d.hidePassword : d.showPassword
1859
1913
  }
1860
1914
  )
1861
1915
  ] })
1862
1916
  ] }),
1863
- /* @__PURE__ */ s("button", { type: "submit", disabled: !g || !x || f, style: W(), children: f ? B.loadingText : B.submitButton }),
1864
- y && /* @__PURE__ */ s("div", { style: d.errorText, children: y })
1917
+ /* @__PURE__ */ n("button", { type: "submit", disabled: !M || !v || u, style: C(), children: u ? h.loadingText : h.submitButton }),
1918
+ x && /* @__PURE__ */ n("div", { style: o.errorText, children: x })
1865
1919
  ] }),
1866
- (T || M) && /* @__PURE__ */ c("div", { style: d.linkContainer, children: [
1867
- T && /* @__PURE__ */ s("a", { onClick: o, style: d.link, children: B.forgotPasswordLink }),
1868
- T && M && /* @__PURE__ */ s("div", { style: d.divider, children: "•" }),
1869
- M && /* @__PURE__ */ c("div", { children: [
1870
- /* @__PURE__ */ c("span", { style: d.divider, children: [
1871
- B.signupText,
1920
+ (L || P || f) && /* @__PURE__ */ l("div", { style: o.linkContainer, children: [
1921
+ f && /* @__PURE__ */ l("div", { children: [
1922
+ /* @__PURE__ */ l("span", { style: o.divider, children: [
1923
+ h.magicLinkText,
1872
1924
  " "
1873
1925
  ] }),
1874
- /* @__PURE__ */ s("a", { onClick: m, style: d.link, children: B.signupLink })
1926
+ /* @__PURE__ */ n("a", { onClick: E, style: o.link, children: h.magicLinkLink })
1927
+ ] }),
1928
+ f && (L || P) && /* @__PURE__ */ n("div", { style: o.divider, children: "•" }),
1929
+ L && /* @__PURE__ */ n("a", { onClick: a, style: o.link, children: h.forgotPasswordLink }),
1930
+ L && P && /* @__PURE__ */ n("div", { style: o.divider, children: "•" }),
1931
+ P && /* @__PURE__ */ l("div", { children: [
1932
+ /* @__PURE__ */ l("span", { style: o.divider, children: [
1933
+ h.signupText,
1934
+ " "
1935
+ ] }),
1936
+ /* @__PURE__ */ n("a", { onClick: b, style: o.link, children: h.signupLink })
1875
1937
  ] })
1876
1938
  ] })
1877
1939
  ] });
1878
1940
  }
1879
- const je = {
1941
+ const Qe = {
1880
1942
  title: "Create Account",
1881
- nameLabel: "Full Name",
1882
- namePlaceholder: "Enter your full name",
1943
+ nameLabel: "First Name",
1944
+ namePlaceholder: "Enter your first name",
1945
+ lastNameLabel: "Last Name",
1946
+ lastNamePlaceholder: "Enter your last name",
1883
1947
  emailLabel: "Email",
1884
1948
  emailPlaceholder: "Enter your email",
1949
+ phoneNumberLabel: "Phone Number",
1950
+ phoneNumberPlaceholder: "Enter your phone number",
1885
1951
  passwordLabel: "Password",
1886
1952
  passwordPlaceholder: "Enter your password",
1887
1953
  confirmPasswordLabel: "Confirm Password",
@@ -1891,12 +1957,14 @@ const je = {
1891
1957
  submitButton: "Create Account",
1892
1958
  loginLink: "Sign in here",
1893
1959
  loginText: "Already have an account?",
1960
+ magicLinkText: "Prefer passwordless?",
1961
+ magicLinkLink: "Use Magic Link",
1894
1962
  errorMessage: "Failed to create account",
1895
1963
  loadingText: "Creating account...",
1896
1964
  passwordMismatchError: "Passwords do not match",
1897
1965
  isAdminLabel: "Create new organization",
1898
1966
  isAdminDescription: "Check this if you want to create a new organization"
1899
- }, Ve = {
1967
+ }, Je = {
1900
1968
  container: {
1901
1969
  maxWidth: "400px",
1902
1970
  width: "100%",
@@ -1995,154 +2063,784 @@ const je = {
1995
2063
  fontSize: "0.875rem"
1996
2064
  }
1997
2065
  };
1998
- function pt({
2066
+ function Mt({
1999
2067
  copy: i = {},
2000
2068
  styles: e = {},
2001
2069
  signupType: t = "user",
2002
2070
  onSuccess: r,
2003
- onError: n,
2004
- onLoginClick: o,
2005
- showLoginLink: m = !0,
2006
- className: T
2071
+ onError: s,
2072
+ onLoginClick: a,
2073
+ onMagicLinkClick: b,
2074
+ showLoginLink: E = !0,
2075
+ showMagicLinkOption: L = !0,
2076
+ className: P
2007
2077
  }) {
2008
- const [M, P] = b(""), [g, h] = b(""), [x, p] = b(""), [A, F] = b(""), [f, L] = b(""), [y, S] = b(!1), [k, R] = b(""), [D, E] = b({}), { signup: B, signupTenantAdmin: d } = se(), { tenant: w } = K(), u = { ...je, ...i }, a = { ...Ve, ...e }, l = () => {
2009
- const C = {};
2010
- return M.trim() || (C.name = !0), g.trim() || (C.email = !0), x.trim() || (C.password = !0), A.trim() || (C.confirmPassword = !0), t === "tenant" && !f.trim() && (C.tenantName = !0), E(C), Object.keys(C).length === 0;
2011
- }, W = async (C) => {
2012
- if (C.preventDefault(), !!l()) {
2013
- if (x !== A) {
2014
- R(u.passwordMismatchError), E({ confirmPassword: !0 });
2078
+ const [f, m] = p(""), [M, w] = p(""), [v, I] = p(""), [g, U] = p(""), [u, y] = p(""), [x, F] = p(""), [B, z] = p(""), [q, S] = p(!1), [c, h] = p(""), [o, d] = p({}), { signup: G, signupTenantAdmin: Y } = ie(), { tenant: H } = re(), { appId: C } = ne(), k = { ...Qe, ...i }, T = { ...Je, ...e }, J = () => {
2079
+ const R = {};
2080
+ return f.trim() || (R.name = !0), !v.trim() && !g.trim() && (R.email = !0, R.phoneNumber = !0), u.trim() || (R.password = !0), x.trim() || (R.confirmPassword = !0), t === "tenant" && !B.trim() && (R.tenantName = !0), d(R), Object.keys(R).length === 0;
2081
+ }, O = async (R) => {
2082
+ if (R.preventDefault(), !!J()) {
2083
+ if (u !== x) {
2084
+ h(k.passwordMismatchError), d({ confirmPassword: !0 });
2015
2085
  return;
2016
2086
  }
2017
- if (t === "user" && !(w != null && w.id)) {
2018
- R("Tenant not found");
2087
+ if (t === "user" && !(H != null && H.id)) {
2088
+ h("Tenant not found");
2019
2089
  return;
2020
2090
  }
2021
- S(!0), R("");
2091
+ S(!0), h("");
2022
2092
  try {
2023
- let U;
2024
- t === "tenant" ? U = await d(g, M, x, f) : U = await B(g, M, x, w.id), r == null || r(U);
2025
- } catch (U) {
2026
- const Q = U.message || u.errorMessage;
2027
- R(Q), n == null || n(Q);
2093
+ let V;
2094
+ t === "tenant" ? V = await Y(
2095
+ v || void 0,
2096
+ g || void 0,
2097
+ f,
2098
+ u,
2099
+ B,
2100
+ M || void 0,
2101
+ C
2102
+ ) : V = await G(
2103
+ v || void 0,
2104
+ g || void 0,
2105
+ f,
2106
+ u,
2107
+ H.id,
2108
+ M || void 0,
2109
+ C
2110
+ ), r == null || r(V);
2111
+ } catch (V) {
2112
+ const ue = V.message || k.errorMessage;
2113
+ h(ue), s == null || s(ue);
2028
2114
  } finally {
2029
2115
  S(!1);
2030
2116
  }
2031
2117
  }
2032
- }, I = (C) => ({
2033
- ...a.input,
2034
- ...D[C] ? a.inputError : {}
2118
+ }, j = (R) => ({
2119
+ ...T.input,
2120
+ ...o[R] ? T.inputError : {}
2035
2121
  }), N = () => ({
2036
- ...a.button,
2037
- ...y ? a.buttonLoading : {},
2038
- ...!M || !g || !x || !A || y || t === "tenant" && !f ? a.buttonDisabled : {}
2039
- }), _ = M && g && x && A && (t === "user" || f);
2040
- return /* @__PURE__ */ c("div", { className: T, style: a.container, children: [
2041
- /* @__PURE__ */ s("h2", { style: a.title, children: u.title }),
2042
- /* @__PURE__ */ c("form", { onSubmit: W, style: a.form, children: [
2043
- /* @__PURE__ */ c("div", { style: a.fieldGroup, children: [
2044
- /* @__PURE__ */ s("label", { style: a.label, children: u.nameLabel }),
2045
- /* @__PURE__ */ s(
2122
+ ...T.button,
2123
+ ...q ? T.buttonLoading : {},
2124
+ ...!f || !v && !g || !u || !x || q || t === "tenant" && !B ? T.buttonDisabled : {}
2125
+ }), K = f && (v || g) && u && x && (t === "user" || B);
2126
+ return /* @__PURE__ */ l("div", { className: P, style: T.container, children: [
2127
+ /* @__PURE__ */ n("h2", { style: T.title, children: k.title }),
2128
+ /* @__PURE__ */ l("form", { onSubmit: O, style: T.form, children: [
2129
+ /* @__PURE__ */ l("div", { style: T.fieldGroup, children: [
2130
+ /* @__PURE__ */ n("label", { style: T.label, children: k.nameLabel }),
2131
+ /* @__PURE__ */ n(
2046
2132
  "input",
2047
2133
  {
2048
2134
  id: "name",
2049
2135
  name: "name",
2050
2136
  type: "text",
2051
- value: M,
2052
- onChange: (C) => {
2053
- P(C.target.value), D.name && E((U) => ({ ...U, name: !1 }));
2137
+ value: f,
2138
+ onChange: (R) => {
2139
+ m(R.target.value), o.name && d((V) => ({ ...V, name: !1 }));
2054
2140
  },
2055
- placeholder: u.namePlaceholder,
2056
- style: I("name"),
2057
- disabled: y
2141
+ placeholder: k.namePlaceholder,
2142
+ style: j("name"),
2143
+ disabled: q
2144
+ }
2145
+ )
2146
+ ] }),
2147
+ /* @__PURE__ */ l("div", { style: T.fieldGroup, children: [
2148
+ /* @__PURE__ */ n("label", { style: T.label, children: k.lastNameLabel }),
2149
+ /* @__PURE__ */ n(
2150
+ "input",
2151
+ {
2152
+ id: "lastName",
2153
+ name: "lastName",
2154
+ type: "text",
2155
+ value: M,
2156
+ onChange: (R) => w(R.target.value),
2157
+ placeholder: k.lastNamePlaceholder,
2158
+ style: T.input,
2159
+ disabled: q
2058
2160
  }
2059
2161
  )
2060
2162
  ] }),
2061
- /* @__PURE__ */ c("div", { style: a.fieldGroup, children: [
2062
- /* @__PURE__ */ s("label", { style: a.label, children: u.emailLabel }),
2063
- /* @__PURE__ */ s(
2163
+ /* @__PURE__ */ l("div", { style: T.fieldGroup, children: [
2164
+ /* @__PURE__ */ n("label", { style: T.label, children: k.emailLabel }),
2165
+ /* @__PURE__ */ n(
2064
2166
  "input",
2065
2167
  {
2066
2168
  id: "email",
2067
2169
  name: "email",
2068
2170
  type: "email",
2171
+ value: v,
2172
+ onChange: (R) => {
2173
+ I(R.target.value), o.email && d((V) => ({ ...V, email: !1, phoneNumber: !1 }));
2174
+ },
2175
+ placeholder: k.emailPlaceholder,
2176
+ style: j("email"),
2177
+ disabled: q
2178
+ }
2179
+ )
2180
+ ] }),
2181
+ /* @__PURE__ */ l("div", { style: T.fieldGroup, children: [
2182
+ /* @__PURE__ */ n("label", { style: T.label, children: k.phoneNumberLabel }),
2183
+ /* @__PURE__ */ n(
2184
+ "input",
2185
+ {
2186
+ id: "phoneNumber",
2187
+ name: "phoneNumber",
2188
+ type: "tel",
2069
2189
  value: g,
2070
- onChange: (C) => {
2071
- h(C.target.value), D.email && E((U) => ({ ...U, email: !1 }));
2190
+ onChange: (R) => {
2191
+ U(R.target.value), o.phoneNumber && d((V) => ({ ...V, email: !1, phoneNumber: !1 }));
2072
2192
  },
2073
- placeholder: u.emailPlaceholder,
2074
- style: I("email"),
2075
- disabled: y
2193
+ placeholder: k.phoneNumberPlaceholder,
2194
+ style: j("phoneNumber"),
2195
+ disabled: q
2076
2196
  }
2077
2197
  )
2078
2198
  ] }),
2079
- /* @__PURE__ */ c("div", { style: a.fieldGroup, children: [
2080
- /* @__PURE__ */ s("label", { style: a.label, children: u.passwordLabel }),
2081
- /* @__PURE__ */ s(
2199
+ /* @__PURE__ */ n(
2200
+ "div",
2201
+ {
2202
+ style: {
2203
+ fontSize: "0.875rem",
2204
+ color: "#6b7280",
2205
+ textAlign: "center",
2206
+ margin: "0.5rem 0"
2207
+ },
2208
+ children: "At least one contact method (email or phone) is required"
2209
+ }
2210
+ ),
2211
+ /* @__PURE__ */ l("div", { style: T.fieldGroup, children: [
2212
+ /* @__PURE__ */ n("label", { style: T.label, children: k.passwordLabel }),
2213
+ /* @__PURE__ */ n(
2082
2214
  "input",
2083
2215
  {
2084
2216
  id: "password",
2085
2217
  name: "password",
2086
2218
  type: "password",
2087
- value: x,
2088
- onChange: (C) => {
2089
- p(C.target.value), D.password && E((U) => ({ ...U, password: !1 }));
2219
+ value: u,
2220
+ onChange: (R) => {
2221
+ y(R.target.value), o.password && d((V) => ({ ...V, password: !1 }));
2090
2222
  },
2091
- placeholder: u.passwordPlaceholder,
2092
- style: I("password"),
2093
- disabled: y
2223
+ placeholder: k.passwordPlaceholder,
2224
+ style: j("password"),
2225
+ disabled: q
2094
2226
  }
2095
2227
  )
2096
2228
  ] }),
2097
- /* @__PURE__ */ c("div", { style: a.fieldGroup, children: [
2098
- /* @__PURE__ */ s("label", { style: a.label, children: u.confirmPasswordLabel }),
2099
- /* @__PURE__ */ s(
2229
+ /* @__PURE__ */ l("div", { style: T.fieldGroup, children: [
2230
+ /* @__PURE__ */ n("label", { style: T.label, children: k.confirmPasswordLabel }),
2231
+ /* @__PURE__ */ n(
2100
2232
  "input",
2101
2233
  {
2102
2234
  id: "confirmPassword",
2103
2235
  name: "confirmPassword",
2104
2236
  type: "password",
2105
- value: A,
2106
- onChange: (C) => {
2107
- F(C.target.value), D.confirmPassword && E((U) => ({ ...U, confirmPassword: !1 })), k === u.passwordMismatchError && R("");
2237
+ value: x,
2238
+ onChange: (R) => {
2239
+ F(R.target.value), o.confirmPassword && d((V) => ({ ...V, confirmPassword: !1 })), c === k.passwordMismatchError && h("");
2108
2240
  },
2109
- placeholder: u.confirmPasswordPlaceholder,
2110
- style: I("confirmPassword"),
2111
- disabled: y
2241
+ placeholder: k.confirmPasswordPlaceholder,
2242
+ style: j("confirmPassword"),
2243
+ disabled: q
2112
2244
  }
2113
2245
  )
2114
2246
  ] }),
2115
- t === "tenant" && /* @__PURE__ */ c("div", { style: a.fieldGroup, children: [
2116
- /* @__PURE__ */ s("label", { style: a.label, children: u.tenantNameLabel }),
2117
- /* @__PURE__ */ s(
2247
+ t === "tenant" && /* @__PURE__ */ l("div", { style: T.fieldGroup, children: [
2248
+ /* @__PURE__ */ n("label", { style: T.label, children: k.tenantNameLabel }),
2249
+ /* @__PURE__ */ n(
2118
2250
  "input",
2119
2251
  {
2120
2252
  id: "tenantName",
2121
2253
  name: "tenantName",
2122
2254
  type: "text",
2255
+ value: B,
2256
+ onChange: (R) => {
2257
+ z(R.target.value), o.tenantName && d((V) => ({ ...V, tenantName: !1 }));
2258
+ },
2259
+ placeholder: k.tenantNamePlaceholder,
2260
+ style: j("tenantName"),
2261
+ disabled: q
2262
+ }
2263
+ )
2264
+ ] }),
2265
+ /* @__PURE__ */ n("button", { type: "submit", disabled: !K || q, style: N(), children: q ? k.loadingText : k.submitButton }),
2266
+ c && /* @__PURE__ */ n("div", { style: T.errorText, children: c })
2267
+ ] }),
2268
+ (E || L) && /* @__PURE__ */ l("div", { style: T.linkContainer, children: [
2269
+ L && /* @__PURE__ */ l("div", { children: [
2270
+ /* @__PURE__ */ l("span", { style: T.divider, children: [
2271
+ k.magicLinkText,
2272
+ " "
2273
+ ] }),
2274
+ /* @__PURE__ */ n("a", { onClick: b, style: T.link, children: k.magicLinkLink })
2275
+ ] }),
2276
+ L && E && /* @__PURE__ */ n("div", { style: T.divider, children: "•" }),
2277
+ E && /* @__PURE__ */ l("div", { children: [
2278
+ /* @__PURE__ */ l("span", { style: T.divider, children: [
2279
+ k.loginText,
2280
+ " "
2281
+ ] }),
2282
+ /* @__PURE__ */ n("a", { onClick: a, style: T.link, children: k.loginLink })
2283
+ ] })
2284
+ ] })
2285
+ ] });
2286
+ }
2287
+ const Xe = {
2288
+ title: "Sign In with Magic Link",
2289
+ emailLabel: "Email",
2290
+ emailPlaceholder: "Enter your email",
2291
+ nameLabel: "Name",
2292
+ namePlaceholder: "Enter your name",
2293
+ lastNameLabel: "Last Name",
2294
+ lastNamePlaceholder: "Enter your last name",
2295
+ submitButton: "Send Magic Link",
2296
+ loginLink: "Sign in with password",
2297
+ signupLink: "Sign up with password",
2298
+ loginText: "Already have an account?",
2299
+ signupText: "Prefer traditional signup?",
2300
+ successMessage: "Magic link sent! Check your email and click the link to sign in.",
2301
+ errorMessage: "Failed to send magic link. Please try again.",
2302
+ loadingText: "Sending magic link...",
2303
+ verifyingText: "Verifying magic link...",
2304
+ description: "Enter your email to receive a magic link. If you don't have an account, we'll create one for you."
2305
+ }, Ze = {
2306
+ container: {
2307
+ maxWidth: "400px",
2308
+ width: "100%",
2309
+ margin: "0 auto",
2310
+ padding: "2rem",
2311
+ backgroundColor: "#ffffff",
2312
+ borderRadius: "8px",
2313
+ boxShadow: "0 2px 10px rgba(0, 0, 0, 0.1)"
2314
+ },
2315
+ title: {
2316
+ fontSize: "1.5rem",
2317
+ fontWeight: "bold",
2318
+ textAlign: "center",
2319
+ marginBottom: "1rem",
2320
+ color: "#333333"
2321
+ },
2322
+ description: {
2323
+ fontSize: "0.875rem",
2324
+ color: "#6b7280",
2325
+ textAlign: "center",
2326
+ marginBottom: "1.5rem",
2327
+ lineHeight: "1.5"
2328
+ },
2329
+ form: {
2330
+ display: "flex",
2331
+ flexDirection: "column",
2332
+ gap: "1rem"
2333
+ },
2334
+ fieldGroup: {
2335
+ display: "flex",
2336
+ flexDirection: "column",
2337
+ gap: "0.5rem"
2338
+ },
2339
+ label: {
2340
+ fontSize: "0.875rem",
2341
+ fontWeight: "500",
2342
+ color: "#374151"
2343
+ },
2344
+ input: {
2345
+ padding: "0.75rem",
2346
+ border: "1px solid #d1d5db",
2347
+ borderRadius: "6px",
2348
+ fontSize: "1rem",
2349
+ transition: "border-color 0.15s ease-in-out",
2350
+ outline: "none",
2351
+ width: "100%"
2352
+ },
2353
+ inputError: {
2354
+ borderColor: "#ef4444",
2355
+ boxShadow: "0 0 0 3px rgba(239, 68, 68, 0.1)"
2356
+ },
2357
+ button: {
2358
+ padding: "0.75rem 1rem",
2359
+ backgroundColor: "#3b82f6",
2360
+ color: "white",
2361
+ border: "none",
2362
+ borderRadius: "6px",
2363
+ fontSize: "1rem",
2364
+ fontWeight: "500",
2365
+ cursor: "pointer",
2366
+ transition: "background-color 0.15s ease-in-out",
2367
+ marginTop: "0.5rem"
2368
+ },
2369
+ buttonDisabled: {
2370
+ backgroundColor: "#9ca3af",
2371
+ cursor: "not-allowed"
2372
+ },
2373
+ buttonLoading: {
2374
+ backgroundColor: "#6b7280"
2375
+ },
2376
+ errorText: {
2377
+ color: "#ef4444",
2378
+ fontSize: "0.875rem",
2379
+ textAlign: "center",
2380
+ marginTop: "0.5rem"
2381
+ },
2382
+ successText: {
2383
+ color: "#10b981",
2384
+ fontSize: "0.875rem",
2385
+ textAlign: "center",
2386
+ marginTop: "0.5rem",
2387
+ padding: "0.75rem",
2388
+ backgroundColor: "#f0fdf4",
2389
+ borderRadius: "6px",
2390
+ border: "1px solid #bbf7d0"
2391
+ },
2392
+ linkContainer: {
2393
+ textAlign: "center",
2394
+ marginTop: "1rem"
2395
+ },
2396
+ link: {
2397
+ color: "#3b82f6",
2398
+ textDecoration: "none",
2399
+ fontSize: "0.875rem",
2400
+ cursor: "pointer"
2401
+ },
2402
+ divider: {
2403
+ margin: "0.5rem 0",
2404
+ color: "#6b7280",
2405
+ fontSize: "0.875rem"
2406
+ }
2407
+ };
2408
+ function Et({
2409
+ copy: i = {},
2410
+ styles: e = {},
2411
+ onSuccess: t,
2412
+ onError: r,
2413
+ onLoginClick: s,
2414
+ onSignupClick: a,
2415
+ showTraditionalLinks: b = !0,
2416
+ className: E,
2417
+ verifyToken: L,
2418
+ frontendUrl: P
2419
+ }) {
2420
+ const [f, m] = p(""), [M, w] = p(""), [v, I] = p(""), [g, U] = p(!1), [u, y] = p(!1), [x, F] = p(""), [B, z] = p(""), [q, S] = p({}), [c, h] = p(!1), { sendMagicLink: o, verifyMagicLink: d } = ie(), { tenant: G } = re(), { appId: Y } = ne(), H = { ...Xe, ...i }, C = { ...Ze, ...e };
2421
+ Z(() => {
2422
+ L && k(L);
2423
+ }, [L]);
2424
+ const k = async (N) => {
2425
+ y(!0), F("");
2426
+ try {
2427
+ if (!f || !Y)
2428
+ throw new Error("Email and App ID are required for magic link verification");
2429
+ const K = await d(N, f, Y, G == null ? void 0 : G.id);
2430
+ t == null || t(K);
2431
+ } catch (K) {
2432
+ const R = K.message || "Failed to verify magic link";
2433
+ F(R), r == null || r(R);
2434
+ } finally {
2435
+ y(!1);
2436
+ }
2437
+ }, T = () => {
2438
+ const N = {};
2439
+ return f.trim() || (N.email = !0), c && !M.trim() && (N.name = !0), S(N), Object.keys(N).length === 0;
2440
+ }, J = async (N) => {
2441
+ if (N.preventDefault(), !!T()) {
2442
+ if (!(G != null && G.id)) {
2443
+ F("Tenant not found");
2444
+ return;
2445
+ }
2446
+ U(!0), F(""), z("");
2447
+ try {
2448
+ const K = P || (typeof window < "u" ? window.location.origin : ""), R = await o(
2449
+ f,
2450
+ G.id,
2451
+ K,
2452
+ c ? M : void 0,
2453
+ c ? v : void 0,
2454
+ Y
2455
+ );
2456
+ z(H.successMessage), t == null || t(R);
2457
+ } catch (K) {
2458
+ const R = K.message || H.errorMessage;
2459
+ F(R), r == null || r(R);
2460
+ } finally {
2461
+ U(!1);
2462
+ }
2463
+ }
2464
+ }, O = (N) => ({
2465
+ ...C.input,
2466
+ ...q[N] ? C.inputError : {}
2467
+ }), j = () => ({
2468
+ ...C.button,
2469
+ ...g || u ? C.buttonLoading : {},
2470
+ ...!f || g || u ? C.buttonDisabled : {}
2471
+ });
2472
+ return u ? /* @__PURE__ */ l("div", { className: E, style: C.container, children: [
2473
+ /* @__PURE__ */ n("h2", { style: C.title, children: H.verifyingText }),
2474
+ /* @__PURE__ */ n("div", { style: { textAlign: "center", padding: "2rem" }, children: /* @__PURE__ */ n("div", { style: { fontSize: "1rem", color: "#6b7280" }, children: "Please wait while we verify your magic link..." }) })
2475
+ ] }) : /* @__PURE__ */ l("div", { className: E, style: C.container, children: [
2476
+ /* @__PURE__ */ n("h2", { style: C.title, children: H.title }),
2477
+ /* @__PURE__ */ n("p", { style: C.description, children: H.description }),
2478
+ /* @__PURE__ */ l("form", { onSubmit: J, style: C.form, children: [
2479
+ /* @__PURE__ */ l("div", { style: C.fieldGroup, children: [
2480
+ /* @__PURE__ */ n("label", { style: C.label, children: H.emailLabel }),
2481
+ /* @__PURE__ */ n(
2482
+ "input",
2483
+ {
2484
+ id: "email",
2485
+ name: "email",
2486
+ type: "email",
2123
2487
  value: f,
2124
- onChange: (C) => {
2125
- L(C.target.value), D.tenantName && E((U) => ({ ...U, tenantName: !1 }));
2488
+ onChange: (N) => {
2489
+ m(N.target.value), q.email && S((K) => ({ ...K, email: !1 }));
2126
2490
  },
2127
- placeholder: u.tenantNamePlaceholder,
2128
- style: I("tenantName"),
2129
- disabled: y
2491
+ placeholder: H.emailPlaceholder,
2492
+ style: O("email"),
2493
+ disabled: g || u
2130
2494
  }
2131
2495
  )
2132
2496
  ] }),
2133
- /* @__PURE__ */ s("button", { type: "submit", disabled: !_ || y, style: N(), children: y ? u.loadingText : u.submitButton }),
2134
- k && /* @__PURE__ */ s("div", { style: a.errorText, children: k })
2497
+ !c && /* @__PURE__ */ n("div", { style: { textAlign: "center", marginTop: "0.5rem" }, children: /* @__PURE__ */ n(
2498
+ "button",
2499
+ {
2500
+ type: "button",
2501
+ onClick: () => h(!0),
2502
+ style: {
2503
+ background: "none",
2504
+ border: "none",
2505
+ color: "#3b82f6",
2506
+ fontSize: "0.875rem",
2507
+ cursor: "pointer",
2508
+ textDecoration: "underline"
2509
+ },
2510
+ children: "New user? Add your name"
2511
+ }
2512
+ ) }),
2513
+ c && /* @__PURE__ */ l(D, { children: [
2514
+ /* @__PURE__ */ l("div", { style: C.fieldGroup, children: [
2515
+ /* @__PURE__ */ n("label", { style: C.label, children: H.nameLabel }),
2516
+ /* @__PURE__ */ n(
2517
+ "input",
2518
+ {
2519
+ id: "name",
2520
+ name: "name",
2521
+ type: "text",
2522
+ value: M,
2523
+ onChange: (N) => {
2524
+ w(N.target.value), q.name && S((K) => ({ ...K, name: !1 }));
2525
+ },
2526
+ placeholder: H.namePlaceholder,
2527
+ style: O("name"),
2528
+ disabled: g || u
2529
+ }
2530
+ )
2531
+ ] }),
2532
+ /* @__PURE__ */ l("div", { style: C.fieldGroup, children: [
2533
+ /* @__PURE__ */ n("label", { style: C.label, children: H.lastNameLabel }),
2534
+ /* @__PURE__ */ n(
2535
+ "input",
2536
+ {
2537
+ id: "lastName",
2538
+ name: "lastName",
2539
+ type: "text",
2540
+ value: v,
2541
+ onChange: (N) => I(N.target.value),
2542
+ placeholder: H.lastNamePlaceholder,
2543
+ style: C.input,
2544
+ disabled: g || u
2545
+ }
2546
+ )
2547
+ ] }),
2548
+ /* @__PURE__ */ n("div", { style: { textAlign: "center", marginTop: "0.5rem" }, children: /* @__PURE__ */ n(
2549
+ "button",
2550
+ {
2551
+ type: "button",
2552
+ onClick: () => {
2553
+ h(!1), w(""), I("");
2554
+ },
2555
+ style: {
2556
+ background: "none",
2557
+ border: "none",
2558
+ color: "#6b7280",
2559
+ fontSize: "0.875rem",
2560
+ cursor: "pointer",
2561
+ textDecoration: "underline"
2562
+ },
2563
+ children: "Existing user? Hide name fields"
2564
+ }
2565
+ ) })
2566
+ ] }),
2567
+ /* @__PURE__ */ n("button", { type: "submit", disabled: !f || g || u, style: j(), children: g ? H.loadingText : H.submitButton }),
2568
+ x && /* @__PURE__ */ n("div", { style: C.errorText, children: x }),
2569
+ B && /* @__PURE__ */ n("div", { style: C.successText, children: B })
2135
2570
  ] }),
2136
- m && /* @__PURE__ */ c("div", { style: a.linkContainer, children: [
2137
- /* @__PURE__ */ c("span", { style: a.divider, children: [
2138
- u.loginText,
2139
- " "
2571
+ b && /* @__PURE__ */ l("div", { style: C.linkContainer, children: [
2572
+ /* @__PURE__ */ l("div", { children: [
2573
+ /* @__PURE__ */ l("span", { style: C.divider, children: [
2574
+ H.loginText,
2575
+ " "
2576
+ ] }),
2577
+ /* @__PURE__ */ n("a", { onClick: s, style: C.link, children: H.loginLink })
2140
2578
  ] }),
2141
- /* @__PURE__ */ s("a", { onClick: o, style: a.link, children: u.loginLink })
2579
+ /* @__PURE__ */ n("div", { style: C.divider, children: "•" }),
2580
+ /* @__PURE__ */ l("div", { children: [
2581
+ /* @__PURE__ */ l("span", { style: C.divider, children: [
2582
+ H.signupText,
2583
+ " "
2584
+ ] }),
2585
+ /* @__PURE__ */ n("a", { onClick: a, style: C.link, children: H.signupLink })
2586
+ ] })
2142
2587
  ] })
2143
2588
  ] });
2144
2589
  }
2145
- const We = {
2590
+ const et = {
2591
+ title: "Verifying Magic Link",
2592
+ verifyingMessage: "Please wait while we verify your magic link...",
2593
+ successMessage: "Magic link verified successfully! You are now logged in.",
2594
+ errorMessage: "Failed to verify magic link. The link may be expired or invalid.",
2595
+ redirectingMessage: "Redirecting you to the dashboard...",
2596
+ retryButton: "Try Again",
2597
+ backToLoginButton: "Back to Login"
2598
+ }, Ae = {
2599
+ container: {
2600
+ maxWidth: "400px",
2601
+ width: "100%",
2602
+ margin: "0 auto",
2603
+ padding: "2rem",
2604
+ backgroundColor: "#ffffff",
2605
+ borderRadius: "8px",
2606
+ boxShadow: "0 2px 10px rgba(0, 0, 0, 0.1)"
2607
+ },
2608
+ card: {
2609
+ // Not used in new design, keeping for compatibility
2610
+ backgroundColor: "transparent",
2611
+ padding: "0",
2612
+ borderRadius: "0",
2613
+ boxShadow: "none",
2614
+ maxWidth: "100%",
2615
+ width: "100%",
2616
+ textAlign: "center"
2617
+ },
2618
+ title: {
2619
+ fontSize: "1.5rem",
2620
+ fontWeight: "bold",
2621
+ textAlign: "center",
2622
+ marginBottom: "1.5rem",
2623
+ color: "#333333"
2624
+ },
2625
+ message: {
2626
+ fontSize: "1rem",
2627
+ color: "#6b7280",
2628
+ marginBottom: "1.5rem",
2629
+ lineHeight: "1.5",
2630
+ textAlign: "center"
2631
+ },
2632
+ successMessage: {
2633
+ fontSize: "1rem",
2634
+ color: "#059669",
2635
+ marginBottom: "1.5rem",
2636
+ lineHeight: "1.5",
2637
+ textAlign: "center"
2638
+ },
2639
+ errorMessage: {
2640
+ fontSize: "0.875rem",
2641
+ color: "#ef4444",
2642
+ textAlign: "center",
2643
+ marginBottom: "1rem",
2644
+ lineHeight: "1.5"
2645
+ },
2646
+ spinner: {
2647
+ display: "inline-block",
2648
+ width: "20px",
2649
+ height: "20px",
2650
+ border: "2px solid #e5e7eb",
2651
+ borderTop: "2px solid #3b82f6",
2652
+ borderRadius: "50%",
2653
+ animation: "spin 1s linear infinite",
2654
+ marginRight: "0.5rem"
2655
+ },
2656
+ buttonContainer: {
2657
+ display: "flex",
2658
+ gap: "0.75rem",
2659
+ justifyContent: "center",
2660
+ flexWrap: "wrap",
2661
+ marginTop: "1rem"
2662
+ },
2663
+ retryButton: {
2664
+ padding: "0.75rem 1rem",
2665
+ backgroundColor: "#3b82f6",
2666
+ color: "white",
2667
+ border: "none",
2668
+ borderRadius: "6px",
2669
+ fontSize: "1rem",
2670
+ fontWeight: "500",
2671
+ cursor: "pointer",
2672
+ transition: "background-color 0.15s ease-in-out"
2673
+ },
2674
+ backButton: {
2675
+ padding: "0.75rem 1rem",
2676
+ backgroundColor: "#f3f4f6",
2677
+ color: "#374151",
2678
+ border: "1px solid #d1d5db",
2679
+ borderRadius: "6px",
2680
+ fontSize: "1rem",
2681
+ fontWeight: "500",
2682
+ cursor: "pointer",
2683
+ transition: "all 0.15s ease-in-out"
2684
+ }
2685
+ }, tt = () => /* @__PURE__ */ n("div", { style: Ae.spinner }), rt = () => /* @__PURE__ */ l(
2686
+ "svg",
2687
+ {
2688
+ width: "48",
2689
+ height: "48",
2690
+ viewBox: "0 0 24 24",
2691
+ fill: "none",
2692
+ stroke: "#059669",
2693
+ strokeWidth: "2",
2694
+ strokeLinecap: "round",
2695
+ strokeLinejoin: "round",
2696
+ style: { margin: "0 auto 1rem auto", display: "block" },
2697
+ children: [
2698
+ /* @__PURE__ */ n("path", { d: "M22 11.08V12a10 10 0 1 1-5.93-9.14" }),
2699
+ /* @__PURE__ */ n("polyline", { points: "22,4 12,14.01 9,11.01" })
2700
+ ]
2701
+ }
2702
+ ), nt = () => /* @__PURE__ */ l(
2703
+ "svg",
2704
+ {
2705
+ width: "48",
2706
+ height: "48",
2707
+ viewBox: "0 0 24 24",
2708
+ fill: "none",
2709
+ stroke: "#ef4444",
2710
+ strokeWidth: "2",
2711
+ strokeLinecap: "round",
2712
+ strokeLinejoin: "round",
2713
+ style: { margin: "0 auto 1rem auto", display: "block" },
2714
+ children: [
2715
+ /* @__PURE__ */ n("circle", { cx: "12", cy: "12", r: "10" }),
2716
+ /* @__PURE__ */ n("line", { x1: "15", y1: "9", x2: "9", y2: "15" }),
2717
+ /* @__PURE__ */ n("line", { x1: "9", y1: "9", x2: "15", y2: "15" })
2718
+ ]
2719
+ }
2720
+ ), st = {
2721
+ loading: /* @__PURE__ */ n(tt, {}),
2722
+ success: /* @__PURE__ */ n(rt, {}),
2723
+ error: /* @__PURE__ */ n(nt, {})
2724
+ };
2725
+ function Lt({
2726
+ copy: i = {},
2727
+ styles: e = {},
2728
+ icons: t = {},
2729
+ onSuccess: r,
2730
+ onError: s,
2731
+ onRetry: a,
2732
+ onBackToLogin: b,
2733
+ className: E,
2734
+ token: L,
2735
+ email: P,
2736
+ appId: f,
2737
+ tenantId: m,
2738
+ autoRedirectDelay: M = 3e3
2739
+ }) {
2740
+ const [w, v] = p("verifying"), [I, g] = p(""), { verifyMagicLink: U } = ie(), u = { ...et, ...i }, y = { ...Ae, ...e }, x = { ...st, ...t }, F = () => {
2741
+ if (typeof window > "u") return {};
2742
+ const c = new URLSearchParams(window.location.search);
2743
+ return {
2744
+ token: L || c.get("token") || "",
2745
+ email: P || c.get("email") || "",
2746
+ appId: f || c.get("appId") || "",
2747
+ tenantId: m || c.get("tenantId") || void 0
2748
+ };
2749
+ }, B = async () => {
2750
+ v("verifying"), g("");
2751
+ try {
2752
+ const c = F();
2753
+ if (!c.token || !c.email || !c.appId)
2754
+ throw new Error("Missing required parameters: token, email, or appId");
2755
+ const h = await U(
2756
+ c.token,
2757
+ c.email,
2758
+ c.appId,
2759
+ c.tenantId
2760
+ );
2761
+ v("success"), r == null || r(h), M > 0 && setTimeout(() => {
2762
+ v("redirecting");
2763
+ }, M);
2764
+ } catch (c) {
2765
+ const h = c.message || u.errorMessage;
2766
+ g(h), v("error"), s == null || s(h);
2767
+ }
2768
+ }, z = () => {
2769
+ a == null || a(), B();
2770
+ }, q = () => {
2771
+ b == null || b();
2772
+ };
2773
+ Z(() => {
2774
+ B();
2775
+ }, []);
2776
+ const S = () => {
2777
+ switch (w) {
2778
+ case "verifying":
2779
+ return /* @__PURE__ */ l("div", { style: y.message, children: [
2780
+ x.loading,
2781
+ u.verifyingMessage
2782
+ ] });
2783
+ case "success":
2784
+ return /* @__PURE__ */ l(D, { children: [
2785
+ x.success,
2786
+ /* @__PURE__ */ n("div", { style: y.successMessage, children: u.successMessage })
2787
+ ] });
2788
+ case "redirecting":
2789
+ return /* @__PURE__ */ l(D, { children: [
2790
+ x.loading,
2791
+ /* @__PURE__ */ n("div", { style: y.message, children: u.redirectingMessage })
2792
+ ] });
2793
+ case "error":
2794
+ return /* @__PURE__ */ l(D, { children: [
2795
+ x.error,
2796
+ /* @__PURE__ */ n("div", { style: y.errorMessage, children: I || u.errorMessage }),
2797
+ /* @__PURE__ */ l("div", { style: y.buttonContainer, children: [
2798
+ /* @__PURE__ */ n(
2799
+ "button",
2800
+ {
2801
+ onClick: z,
2802
+ style: y.retryButton,
2803
+ onMouseOver: (c) => {
2804
+ c.currentTarget.style.backgroundColor = "#2563eb";
2805
+ },
2806
+ onMouseOut: (c) => {
2807
+ c.currentTarget.style.backgroundColor = "#3b82f6";
2808
+ },
2809
+ children: u.retryButton
2810
+ }
2811
+ ),
2812
+ /* @__PURE__ */ n(
2813
+ "button",
2814
+ {
2815
+ onClick: q,
2816
+ style: y.backButton,
2817
+ onMouseOver: (c) => {
2818
+ c.currentTarget.style.backgroundColor = "#e5e7eb";
2819
+ },
2820
+ onMouseOut: (c) => {
2821
+ c.currentTarget.style.backgroundColor = "#f3f4f6";
2822
+ },
2823
+ children: u.backToLoginButton
2824
+ }
2825
+ )
2826
+ ] })
2827
+ ] });
2828
+ default:
2829
+ return null;
2830
+ }
2831
+ };
2832
+ return /* @__PURE__ */ l("div", { style: y.container, className: E, children: [
2833
+ /* @__PURE__ */ n("style", { children: `
2834
+ @keyframes spin {
2835
+ 0% { transform: rotate(0deg); }
2836
+ 100% { transform: rotate(360deg); }
2837
+ }
2838
+ ` }),
2839
+ /* @__PURE__ */ n("h1", { style: y.title, children: u.title }),
2840
+ S()
2841
+ ] });
2842
+ }
2843
+ const it = {
2146
2844
  title: "Reset Password",
2147
2845
  subtitle: "Enter your email address and we'll send you a link to reset your password.",
2148
2846
  emailLabel: "Email",
@@ -2164,7 +2862,7 @@ const We = {
2164
2862
  resetLoadingText: "Resetting...",
2165
2863
  resetSuccessMessage: "Password reset successfully!",
2166
2864
  passwordMismatchError: "Passwords do not match"
2167
- }, Ge = {
2865
+ }, ot = {
2168
2866
  container: {
2169
2867
  maxWidth: "400px",
2170
2868
  margin: "0 auto",
@@ -2256,186 +2954,186 @@ const We = {
2256
2954
  cursor: "pointer"
2257
2955
  }
2258
2956
  };
2259
- function ft({
2957
+ function Rt({
2260
2958
  copy: i = {},
2261
2959
  styles: e = {},
2262
2960
  mode: t = "request",
2263
2961
  token: r = "",
2264
- onSuccess: n,
2265
- onError: o,
2266
- onBackToLogin: m,
2267
- onModeChange: T,
2268
- className: M
2962
+ onSuccess: s,
2963
+ onError: a,
2964
+ onBackToLogin: b,
2965
+ onModeChange: E,
2966
+ className: L
2269
2967
  }) {
2270
- const [P, g] = b(""), [h, x] = b(r), [p, A] = b(""), [F, f] = b(""), [L, y] = b(!1), [S, k] = b(""), [R, D] = b(""), [E, B] = b({}), { requestPasswordReset: d, confirmPasswordReset: w } = se(), { tenant: u } = K(), a = { ...We, ...i }, l = { ...Ge, ...e }, W = () => {
2271
- const q = {};
2272
- return P.trim() || (q.email = !0), B(q), Object.keys(q).length === 0;
2273
- }, I = () => {
2274
- const q = {};
2275
- return h.trim() || (q.token = !0), p.trim() || (q.newPassword = !0), F.trim() || (q.confirmPassword = !0), B(q), Object.keys(q).length === 0;
2276
- }, N = async (q) => {
2277
- if (q.preventDefault(), !!W()) {
2278
- if (!(u != null && u.id)) {
2279
- k("Tenant not found");
2968
+ const [P, f] = p(""), [m, M] = p(r), [w, v] = p(""), [I, g] = p(""), [U, u] = p(!1), [y, x] = p(""), [F, B] = p(""), [z, q] = p({}), { requestPasswordReset: S, confirmPasswordReset: c } = ie(), { tenant: h } = re(), o = { ...it, ...i }, d = { ...ot, ...e }, G = () => {
2969
+ const O = {};
2970
+ return P.trim() || (O.email = !0), q(O), Object.keys(O).length === 0;
2971
+ }, Y = () => {
2972
+ const O = {};
2973
+ return m.trim() || (O.token = !0), w.trim() || (O.newPassword = !0), I.trim() || (O.confirmPassword = !0), q(O), Object.keys(O).length === 0;
2974
+ }, H = async (O) => {
2975
+ if (O.preventDefault(), !!G()) {
2976
+ if (!(h != null && h.id)) {
2977
+ x("Tenant not found");
2280
2978
  return;
2281
2979
  }
2282
- y(!0), k(""), D("");
2980
+ u(!0), x(""), B("");
2283
2981
  try {
2284
- await d(P, u.id), D(a.successMessage), n == null || n();
2285
- } catch (O) {
2286
- const j = O.message || a.errorMessage;
2287
- k(j), o == null || o(j);
2982
+ await S(P, h.id), B(o.successMessage), s == null || s();
2983
+ } catch (j) {
2984
+ const N = j.message || o.errorMessage;
2985
+ x(N), a == null || a(N);
2288
2986
  } finally {
2289
- y(!1);
2987
+ u(!1);
2290
2988
  }
2291
2989
  }
2292
- }, _ = async (q) => {
2293
- if (q.preventDefault(), !!I()) {
2294
- if (p !== F) {
2295
- k(a.passwordMismatchError), B({ confirmPassword: !0 });
2990
+ }, C = async (O) => {
2991
+ if (O.preventDefault(), !!Y()) {
2992
+ if (w !== I) {
2993
+ x(o.passwordMismatchError), q({ confirmPassword: !0 });
2296
2994
  return;
2297
2995
  }
2298
- y(!0), k(""), D("");
2996
+ u(!0), x(""), B("");
2299
2997
  try {
2300
- await w(h, p), D(a.resetSuccessMessage), n == null || n();
2301
- } catch (O) {
2302
- const j = O.message || a.errorMessage;
2303
- k(j), o == null || o(j);
2998
+ await c(m, w), B(o.resetSuccessMessage), s == null || s();
2999
+ } catch (j) {
3000
+ const N = j.message || o.errorMessage;
3001
+ x(N), a == null || a(N);
2304
3002
  } finally {
2305
- y(!1);
3003
+ u(!1);
2306
3004
  }
2307
3005
  }
2308
- }, C = (q) => ({
2309
- ...l.input,
2310
- ...E[q] ? l.inputError : {}
2311
- }), U = () => ({
2312
- ...l.button,
2313
- ...L ? l.buttonLoading : {}
3006
+ }, k = (O) => ({
3007
+ ...d.input,
3008
+ ...z[O] ? d.inputError : {}
3009
+ }), T = () => ({
3010
+ ...d.button,
3011
+ ...U ? d.buttonLoading : {}
2314
3012
  });
2315
3013
  if (t === "reset") {
2316
- const q = h && p && F;
2317
- return /* @__PURE__ */ c("div", { className: M, style: l.container, children: [
2318
- /* @__PURE__ */ s("h2", { style: l.title, children: a.resetTitle }),
2319
- /* @__PURE__ */ s("p", { style: l.subtitle, children: a.resetSubtitle }),
2320
- /* @__PURE__ */ c("form", { onSubmit: _, style: l.form, children: [
2321
- /* @__PURE__ */ c("div", { style: l.fieldGroup, children: [
2322
- /* @__PURE__ */ s("label", { style: l.label, children: a.tokenLabel }),
2323
- /* @__PURE__ */ s(
3014
+ const O = m && w && I;
3015
+ return /* @__PURE__ */ l("div", { className: L, style: d.container, children: [
3016
+ /* @__PURE__ */ n("h2", { style: d.title, children: o.resetTitle }),
3017
+ /* @__PURE__ */ n("p", { style: d.subtitle, children: o.resetSubtitle }),
3018
+ /* @__PURE__ */ l("form", { onSubmit: C, style: d.form, children: [
3019
+ /* @__PURE__ */ l("div", { style: d.fieldGroup, children: [
3020
+ /* @__PURE__ */ n("label", { style: d.label, children: o.tokenLabel }),
3021
+ /* @__PURE__ */ n(
2324
3022
  "input",
2325
3023
  {
2326
3024
  type: "text",
2327
- value: h,
2328
- onChange: (O) => {
2329
- x(O.target.value), E.token && B((j) => ({ ...j, token: !1 }));
3025
+ value: m,
3026
+ onChange: (j) => {
3027
+ M(j.target.value), z.token && q((N) => ({ ...N, token: !1 }));
2330
3028
  },
2331
- placeholder: a.tokenPlaceholder,
2332
- style: C("token"),
2333
- disabled: L
3029
+ placeholder: o.tokenPlaceholder,
3030
+ style: k("token"),
3031
+ disabled: U
2334
3032
  }
2335
3033
  )
2336
3034
  ] }),
2337
- /* @__PURE__ */ c("div", { style: l.fieldGroup, children: [
2338
- /* @__PURE__ */ s("label", { style: l.label, children: a.newPasswordLabel }),
2339
- /* @__PURE__ */ s(
3035
+ /* @__PURE__ */ l("div", { style: d.fieldGroup, children: [
3036
+ /* @__PURE__ */ n("label", { style: d.label, children: o.newPasswordLabel }),
3037
+ /* @__PURE__ */ n(
2340
3038
  "input",
2341
3039
  {
2342
3040
  type: "password",
2343
- value: p,
2344
- onChange: (O) => {
2345
- A(O.target.value), E.newPassword && B((j) => ({ ...j, newPassword: !1 }));
3041
+ value: w,
3042
+ onChange: (j) => {
3043
+ v(j.target.value), z.newPassword && q((N) => ({ ...N, newPassword: !1 }));
2346
3044
  },
2347
- placeholder: a.newPasswordPlaceholder,
2348
- style: C("newPassword"),
2349
- disabled: L
3045
+ placeholder: o.newPasswordPlaceholder,
3046
+ style: k("newPassword"),
3047
+ disabled: U
2350
3048
  }
2351
3049
  )
2352
3050
  ] }),
2353
- /* @__PURE__ */ c("div", { style: l.fieldGroup, children: [
2354
- /* @__PURE__ */ s("label", { style: l.label, children: a.confirmPasswordLabel }),
2355
- /* @__PURE__ */ s(
3051
+ /* @__PURE__ */ l("div", { style: d.fieldGroup, children: [
3052
+ /* @__PURE__ */ n("label", { style: d.label, children: o.confirmPasswordLabel }),
3053
+ /* @__PURE__ */ n(
2356
3054
  "input",
2357
3055
  {
2358
3056
  type: "password",
2359
- value: F,
2360
- onChange: (O) => {
2361
- f(O.target.value), E.confirmPassword && B((j) => ({ ...j, confirmPassword: !1 })), S === a.passwordMismatchError && k("");
3057
+ value: I,
3058
+ onChange: (j) => {
3059
+ g(j.target.value), z.confirmPassword && q((N) => ({ ...N, confirmPassword: !1 })), y === o.passwordMismatchError && x("");
2362
3060
  },
2363
- placeholder: a.confirmPasswordPlaceholder,
2364
- style: C("confirmPassword"),
2365
- disabled: L
3061
+ placeholder: o.confirmPasswordPlaceholder,
3062
+ style: k("confirmPassword"),
3063
+ disabled: U
2366
3064
  }
2367
3065
  )
2368
3066
  ] }),
2369
- /* @__PURE__ */ s(
3067
+ /* @__PURE__ */ n(
2370
3068
  "button",
2371
3069
  {
2372
3070
  type: "submit",
2373
- disabled: !q || L,
3071
+ disabled: !O || U,
2374
3072
  style: {
2375
- ...U(),
2376
- ...!q || L ? l.buttonDisabled : {}
3073
+ ...T(),
3074
+ ...!O || U ? d.buttonDisabled : {}
2377
3075
  },
2378
- children: L ? a.resetLoadingText : a.resetSubmitButton
3076
+ children: U ? o.resetLoadingText : o.resetSubmitButton
2379
3077
  }
2380
3078
  ),
2381
- S && /* @__PURE__ */ s("div", { style: l.errorText, children: S }),
2382
- R && /* @__PURE__ */ s("div", { style: l.successText, children: R })
3079
+ y && /* @__PURE__ */ n("div", { style: d.errorText, children: y }),
3080
+ F && /* @__PURE__ */ n("div", { style: d.successText, children: F })
2383
3081
  ] }),
2384
- /* @__PURE__ */ c("div", { style: l.linkContainer, children: [
2385
- /* @__PURE__ */ s("a", { onClick: m, style: l.link, children: a.backToLoginLink }),
2386
- T && /* @__PURE__ */ c(H, { children: [
2387
- /* @__PURE__ */ s("span", { style: { margin: "0 0.5rem", color: "#6b7280" }, children: "•" }),
2388
- /* @__PURE__ */ s("a", { onClick: () => T("request"), style: l.link, children: "Request New Link" })
3082
+ /* @__PURE__ */ l("div", { style: d.linkContainer, children: [
3083
+ /* @__PURE__ */ n("a", { onClick: b, style: d.link, children: o.backToLoginLink }),
3084
+ E && /* @__PURE__ */ l(D, { children: [
3085
+ /* @__PURE__ */ n("span", { style: { margin: "0 0.5rem", color: "#6b7280" }, children: "•" }),
3086
+ /* @__PURE__ */ n("a", { onClick: () => E("request"), style: d.link, children: "Request New Link" })
2389
3087
  ] })
2390
3088
  ] })
2391
3089
  ] });
2392
3090
  }
2393
- const Q = P;
2394
- return /* @__PURE__ */ c("div", { className: M, style: l.container, children: [
2395
- /* @__PURE__ */ s("h2", { style: l.title, children: a.title }),
2396
- /* @__PURE__ */ s("p", { style: l.subtitle, children: a.subtitle }),
2397
- /* @__PURE__ */ c("form", { onSubmit: N, style: l.form, children: [
2398
- /* @__PURE__ */ c("div", { style: l.fieldGroup, children: [
2399
- /* @__PURE__ */ s("label", { style: l.label, children: a.emailLabel }),
2400
- /* @__PURE__ */ s(
3091
+ const J = P;
3092
+ return /* @__PURE__ */ l("div", { className: L, style: d.container, children: [
3093
+ /* @__PURE__ */ n("h2", { style: d.title, children: o.title }),
3094
+ /* @__PURE__ */ n("p", { style: d.subtitle, children: o.subtitle }),
3095
+ /* @__PURE__ */ l("form", { onSubmit: H, style: d.form, children: [
3096
+ /* @__PURE__ */ l("div", { style: d.fieldGroup, children: [
3097
+ /* @__PURE__ */ n("label", { style: d.label, children: o.emailLabel }),
3098
+ /* @__PURE__ */ n(
2401
3099
  "input",
2402
3100
  {
2403
3101
  type: "email",
2404
3102
  value: P,
2405
- onChange: (q) => {
2406
- g(q.target.value), E.email && B((O) => ({ ...O, email: !1 }));
3103
+ onChange: (O) => {
3104
+ f(O.target.value), z.email && q((j) => ({ ...j, email: !1 }));
2407
3105
  },
2408
- placeholder: a.emailPlaceholder,
2409
- style: C("email"),
2410
- disabled: L
3106
+ placeholder: o.emailPlaceholder,
3107
+ style: k("email"),
3108
+ disabled: U
2411
3109
  }
2412
3110
  )
2413
3111
  ] }),
2414
- /* @__PURE__ */ s(
3112
+ /* @__PURE__ */ n(
2415
3113
  "button",
2416
3114
  {
2417
3115
  type: "submit",
2418
- disabled: !Q || L,
3116
+ disabled: !J || U,
2419
3117
  style: {
2420
- ...U(),
2421
- ...!Q || L ? l.buttonDisabled : {}
3118
+ ...T(),
3119
+ ...!J || U ? d.buttonDisabled : {}
2422
3120
  },
2423
- children: L ? a.loadingText : a.submitButton
3121
+ children: U ? o.loadingText : o.submitButton
2424
3122
  }
2425
3123
  ),
2426
- S && /* @__PURE__ */ s("div", { style: l.errorText, children: S }),
2427
- R && /* @__PURE__ */ s("div", { style: l.successText, children: R })
3124
+ y && /* @__PURE__ */ n("div", { style: d.errorText, children: y }),
3125
+ F && /* @__PURE__ */ n("div", { style: d.successText, children: F })
2428
3126
  ] }),
2429
- /* @__PURE__ */ c("div", { style: l.linkContainer, children: [
2430
- /* @__PURE__ */ s("a", { onClick: m, style: l.link, children: a.backToLoginLink }),
2431
- T && /* @__PURE__ */ c(H, { children: [
2432
- /* @__PURE__ */ s("span", { style: { margin: "0 0.5rem", color: "#6b7280" }, children: "•" }),
2433
- /* @__PURE__ */ s("a", { onClick: () => T("reset"), style: l.link, children: "I have a token" })
3127
+ /* @__PURE__ */ l("div", { style: d.linkContainer, children: [
3128
+ /* @__PURE__ */ n("a", { onClick: b, style: d.link, children: o.backToLoginLink }),
3129
+ E && /* @__PURE__ */ l(D, { children: [
3130
+ /* @__PURE__ */ n("span", { style: { margin: "0 0.5rem", color: "#6b7280" }, children: "•" }),
3131
+ /* @__PURE__ */ n("a", { onClick: () => E("reset"), style: d.link, children: "I have a token" })
2434
3132
  ] })
2435
3133
  ] })
2436
3134
  ] });
2437
3135
  }
2438
- class yt {
3136
+ class Ct {
2439
3137
  constructor(e, t) {
2440
3138
  this.httpService = e, this.sessionManager = t;
2441
3139
  }
@@ -2456,12 +3154,12 @@ class yt {
2456
3154
  throw new Error("SessionManager is required for private endpoints");
2457
3155
  const t = await this.sessionManager.getAuthHeaders(), r = new URLSearchParams();
2458
3156
  e != null && e.page && r.append("page", e.page.toString()), e != null && e.limit && r.append("limit", e.limit.toString()), e != null && e.sortBy && r.append("sortBy", e.sortBy), e != null && e.sortOrder && r.append("sortOrder", e.sortOrder);
2459
- const n = `/permissions/${r.toString() ? `?${r.toString()}` : ""}`, o = await this.httpService.get(n, {
3157
+ const s = `/permissions/${r.toString() ? `?${r.toString()}` : ""}`, a = await this.httpService.get(s, {
2460
3158
  headers: t
2461
3159
  });
2462
3160
  return {
2463
- permissions: o.data,
2464
- meta: o.meta
3161
+ permissions: a.data,
3162
+ meta: a.meta
2465
3163
  };
2466
3164
  }
2467
3165
  async getPermissionById(e) {
@@ -2496,14 +3194,14 @@ class yt {
2496
3194
  async getAppPermissions(e, t) {
2497
3195
  const r = new URLSearchParams();
2498
3196
  t != null && t.page && r.append("page", t.page.toString()), t != null && t.limit && r.append("limit", t.limit.toString()), t != null && t.sortBy && r.append("sortBy", t.sortBy), t != null && t.sortOrder && r.append("sortOrder", t.sortOrder);
2499
- const n = `/permissions/apps/${e}${r.toString() ? `?${r.toString()}` : ""}`, o = await this.httpService.get(n);
3197
+ const s = `/permissions/apps/${e}${r.toString() ? `?${r.toString()}` : ""}`, a = await this.httpService.get(s);
2500
3198
  return {
2501
- permissions: o.data,
2502
- meta: o.meta
3199
+ permissions: a.data,
3200
+ meta: a.meta
2503
3201
  };
2504
3202
  }
2505
3203
  }
2506
- class wt {
3204
+ class It {
2507
3205
  constructor(e, t) {
2508
3206
  this.httpService = e, this.sessionManager = t;
2509
3207
  }
@@ -2520,12 +3218,12 @@ class wt {
2520
3218
  async getSubscriptionPlans(e) {
2521
3219
  const t = await this.sessionManager.getAuthHeaders(), r = new URLSearchParams();
2522
3220
  e != null && e.page && r.append("page", e.page.toString()), e != null && e.limit && r.append("limit", e.limit.toString()), e != null && e.sortBy && r.append("sortBy", e.sortBy), e != null && e.sortOrder && r.append("sortOrder", e.sortOrder), e != null && e.appId && r.append("appId", e.appId);
2523
- const n = `/subscription-plans/${r.toString() ? `?${r.toString()}` : ""}`, o = await this.httpService.get(n, {
3221
+ const s = `/subscription-plans/${r.toString() ? `?${r.toString()}` : ""}`, a = await this.httpService.get(s, {
2524
3222
  headers: t
2525
3223
  });
2526
3224
  return {
2527
- plans: o.data,
2528
- meta: o.meta
3225
+ plans: a.data,
3226
+ meta: a.meta
2529
3227
  };
2530
3228
  }
2531
3229
  async getSubscriptionPlanById(e) {
@@ -2554,7 +3252,7 @@ class wt {
2554
3252
  });
2555
3253
  }
2556
3254
  }
2557
- class mt {
3255
+ class Ft {
2558
3256
  constructor(e) {
2559
3257
  this.httpService = e;
2560
3258
  }
@@ -2563,7 +3261,7 @@ class mt {
2563
3261
  return await this.httpService.get("/health");
2564
3262
  }
2565
3263
  }
2566
- class bt {
3264
+ class Ht {
2567
3265
  // Date string to Date object
2568
3266
  static toDate(e) {
2569
3267
  return new Date(e);
@@ -2589,7 +3287,7 @@ class bt {
2589
3287
  ...e,
2590
3288
  createdAt: this.toDate(e.createdAt),
2591
3289
  updatedAt: this.toDate(e.updatedAt),
2592
- displayName: e.name,
3290
+ displayName: e.lastName ? `${e.name} ${e.lastName}` : e.name,
2593
3291
  isActiveUser: e.isActive
2594
3292
  };
2595
3293
  }
@@ -2680,48 +3378,50 @@ class bt {
2680
3378
  // Transform query parameters for API calls
2681
3379
  static transformQueryParams(e) {
2682
3380
  const t = new URLSearchParams();
2683
- return Object.entries(e).forEach(([r, n]) => {
2684
- n != null && n !== "" && t.append(r, String(n));
3381
+ return Object.entries(e).forEach(([r, s]) => {
3382
+ s != null && s !== "" && t.append(r, String(s));
2685
3383
  }), t;
2686
3384
  }
2687
3385
  }
2688
3386
  export {
2689
- bt as ApiMappers,
2690
- be as AppApiService,
2691
- Ze as AppProvider,
2692
- Ae as AuthApiService,
2693
- nt as AuthProvider,
2694
- ht as FeatureFlag,
2695
- Me as FeatureFlagApiService,
2696
- it as FeatureFlagProvider,
2697
- mt as HealthApiService,
2698
- G as HttpService,
2699
- dt as LandingRoute,
2700
- gt as LoginForm,
2701
- ft as PasswordRecoveryForm,
2702
- yt as PermissionApiService,
2703
- at as Protected,
2704
- lt as ProtectedRoute,
2705
- ce as RoleApiService,
2706
- xe as SessionManager,
2707
- pt as SignupForm,
2708
- Re as SubscriptionApiService,
2709
- ut as SubscriptionGuard,
2710
- wt as SubscriptionPlanApiService,
2711
- ot as SubscriptionProvider,
2712
- de as TenantApiService,
2713
- tt as TenantProvider,
2714
- ct as TenantRoute,
2715
- Pe as UserApiService,
2716
- X as UserType,
2717
- et as useApi,
2718
- re as useApp,
2719
- se as useAuth,
2720
- Ee as useFeatureFlags,
2721
- st as useSettings,
2722
- Fe as useSubscription,
2723
- le as useTenant,
2724
- K as useTenantInfo,
2725
- rt as useTenantSettings
3387
+ Ht as ApiMappers,
3388
+ Te as AppApiService,
3389
+ ht as AppProvider,
3390
+ Re as AuthApiService,
3391
+ yt as AuthProvider,
3392
+ Pt as FeatureFlag,
3393
+ He as FeatureFlagApiService,
3394
+ bt as FeatureFlagProvider,
3395
+ Ft as HealthApiService,
3396
+ te as HttpService,
3397
+ kt as LandingRoute,
3398
+ Tt as LoginForm,
3399
+ Et as MagicLinkForm,
3400
+ Lt as MagicLinkVerify,
3401
+ Rt as PasswordRecoveryForm,
3402
+ Ct as PermissionApiService,
3403
+ vt as Protected,
3404
+ St as ProtectedRoute,
3405
+ pe as RoleApiService,
3406
+ Le as SessionManager,
3407
+ Mt as SignupForm,
3408
+ De as SubscriptionApiService,
3409
+ At as SubscriptionGuard,
3410
+ It as SubscriptionPlanApiService,
3411
+ wt as SubscriptionProvider,
3412
+ fe as TenantApiService,
3413
+ pt as TenantProvider,
3414
+ xt as TenantRoute,
3415
+ Ce as UserApiService,
3416
+ se as UserType,
3417
+ gt as useApi,
3418
+ ne as useApp,
3419
+ ie as useAuth,
3420
+ $e as useFeatureFlags,
3421
+ mt as useSettings,
3422
+ Be as useSubscription,
3423
+ ge as useTenant,
3424
+ re as useTenantInfo,
3425
+ ft as useTenantSettings
2726
3426
  };
2727
3427
  //# sourceMappingURL=index.es.js.map