@skylabs-digital/react-identity-access 2.2.0 → 2.3.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.
package/dist/index.es.js CHANGED
@@ -1,6 +1,6 @@
1
- import { jsx as n, Fragment as B, jsxs as a } from "react/jsx-runtime";
2
- import { createContext as he, useMemo as Q, useState as k, useCallback as ne, useEffect as te, useContext as ce } from "react";
3
- import { useLocation as we, Navigate as pe } from "react-router-dom";
1
+ import { jsx as n, Fragment as U, jsxs as l } from "react/jsx-runtime";
2
+ import { createContext as he, useMemo as X, useState as x, useCallback as ne, useEffect as te, useContext as ce, useRef as Be } from "react";
3
+ import { useLocation as be, Navigate as pe } from "react-router-dom";
4
4
  class re {
5
5
  // SessionManager instance
6
6
  constructor(e, t = 1e4) {
@@ -16,40 +16,40 @@ class re {
16
16
  return this.executeRequest(e, t, r, s, !1);
17
17
  }
18
18
  async executeRequest(e, t, r, s, o = !1) {
19
- const g = `${this.baseUrl}${t.startsWith("/") ? t : `/${t}`}`, y = (s == null ? void 0 : s.timeout) || this.timeout;
20
- let A = {
19
+ const p = `${this.baseUrl}${t.startsWith("/") ? t : `/${t}`}`, b = (s == null ? void 0 : s.timeout) || this.timeout;
20
+ let k = {
21
21
  "Content-Type": "application/json",
22
22
  ...s == null ? void 0 : s.headers
23
23
  };
24
24
  if (!(s != null && s.skipAuth) && this.sessionManager)
25
25
  try {
26
- const f = await this.sessionManager.getAuthHeaders();
27
- A = { ...A, ...f };
28
- } catch (f) {
29
- console.warn("Failed to inject auth headers:", f);
26
+ const m = await this.sessionManager.getAuthHeaders();
27
+ k = { ...k, ...m };
28
+ } catch (m) {
29
+ console.warn("Failed to inject auth headers:", m);
30
30
  }
31
- const w = new AbortController(), T = setTimeout(() => w.abort(), y);
31
+ const S = new AbortController(), T = setTimeout(() => S.abort(), b);
32
32
  try {
33
- const f = await fetch(g, {
33
+ const m = await fetch(p, {
34
34
  method: e,
35
- headers: A,
35
+ headers: k,
36
36
  body: r ? JSON.stringify(r) : void 0,
37
- signal: w.signal
37
+ signal: S.signal
38
38
  });
39
- if (clearTimeout(T), f.status === 401 && !(s != null && s.skipRetry) && !o && this.sessionManager)
39
+ if (clearTimeout(T), m.status === 401 && !(s != null && s.skipRetry) && !o && this.sessionManager)
40
40
  try {
41
- const h = this.sessionManager.getTokens();
42
- if (h != null && h.refreshToken)
41
+ const u = this.sessionManager.getTokens();
42
+ if (u != null && u.refreshToken)
43
43
  return await this.sessionManager.getAuthHeaders(), this.executeRequest(e, t, r, s, !0);
44
44
  } catch {
45
- throw new Error(`HTTP ${f.status}: ${f.statusText}`);
45
+ throw new Error(`HTTP ${m.status}: ${m.statusText}`);
46
46
  }
47
- if (!f.ok)
48
- throw new Error(`HTTP ${f.status}: ${f.statusText}`);
49
- const p = f.headers.get("content-type");
50
- return !p || !p.includes("application/json") ? {} : await f.json();
51
- } catch (f) {
52
- throw clearTimeout(T), f instanceof Error && f.name === "AbortError" ? new Error(`Request timeout after ${y}ms`) : f;
47
+ if (!m.ok)
48
+ throw new Error(`HTTP ${m.status}: ${m.statusText}`);
49
+ const f = m.headers.get("content-type");
50
+ return !f || !f.includes("application/json") ? {} : await m.json();
51
+ } catch (m) {
52
+ throw clearTimeout(T), m instanceof Error && m.name === "AbortError" ? new Error(`Request timeout after ${b}ms`) : m;
53
53
  }
54
54
  }
55
55
  async get(e, t) {
@@ -65,7 +65,7 @@ class re {
65
65
  return this.request("DELETE", e, void 0, t);
66
66
  }
67
67
  }
68
- class Se {
68
+ class ve {
69
69
  constructor(e, t) {
70
70
  this.httpService = e, this.sessionManager = t;
71
71
  }
@@ -124,31 +124,31 @@ class Se {
124
124
  })).data;
125
125
  }
126
126
  }
127
- const Te = he(null);
128
- function kt({ config: i, children: e }) {
129
- const t = Q(
127
+ const Pe = he(null);
128
+ function Et({ config: i, children: e }) {
129
+ const t = X(
130
130
  () => {
131
- var p, h, m;
131
+ var f, u, y;
132
132
  return {
133
- enabled: ((p = i.cache) == null ? void 0 : p.enabled) ?? !0,
134
- ttl: ((h = i.cache) == null ? void 0 : h.ttl) ?? 3e5,
133
+ enabled: ((f = i.cache) == null ? void 0 : f.enabled) ?? !0,
134
+ ttl: ((u = i.cache) == null ? void 0 : u.ttl) ?? 3e5,
135
135
  // 5 minutes default
136
- storageKey: ((m = i.cache) == null ? void 0 : m.storageKey) ?? `app_cache_${i.appId}`
136
+ storageKey: ((y = i.cache) == null ? void 0 : y.storageKey) ?? `app_cache_${i.appId}`
137
137
  };
138
138
  },
139
139
  [i.cache, i.appId]
140
- ), [r, s] = k(() => {
140
+ ), [r, s] = x(() => {
141
141
  if (!t.enabled) return null;
142
142
  try {
143
- const p = localStorage.getItem(t.storageKey);
144
- if (!p) return null;
145
- const h = JSON.parse(p);
146
- return Date.now() - h.timestamp < t.ttl && h.appId === i.appId ? h.data : (localStorage.removeItem(t.storageKey), null);
143
+ const f = localStorage.getItem(t.storageKey);
144
+ if (!f) return null;
145
+ const u = JSON.parse(f);
146
+ return Date.now() - u.timestamp < t.ttl && u.appId === i.appId ? u.data : (localStorage.removeItem(t.storageKey), null);
147
147
  } catch {
148
148
  return null;
149
149
  }
150
- }), [o, g] = k(!r), [y, A] = k(null), w = Q(() => {
151
- const p = () => {
150
+ }), [o, p] = x(!r), [b, k] = x(null), S = X(() => {
151
+ const f = () => {
152
152
  T();
153
153
  };
154
154
  return {
@@ -157,15 +157,15 @@ function kt({ config: i, children: e }) {
157
157
  // App info
158
158
  appInfo: r,
159
159
  isAppLoading: o,
160
- appError: y,
161
- retryApp: p
160
+ appError: b,
161
+ retryApp: f
162
162
  };
163
- }, [i, r, o, y]), T = ne(
164
- async (p = !1) => {
165
- if (!(!p && t.enabled && r))
163
+ }, [i, r, o, b]), T = ne(
164
+ async (f = !1) => {
165
+ if (!(!f && t.enabled && r))
166
166
  try {
167
- g(!0), A(null);
168
- const h = new re(i.baseUrl), R = await new Se(h, {}).getPublicAppInfo(i.appId);
167
+ p(!0), k(null);
168
+ const u = new re(i.baseUrl), R = await new ve(u, {}).getPublicAppInfo(i.appId);
169
169
  if (s(R), t.enabled)
170
170
  try {
171
171
  const C = {
@@ -177,46 +177,46 @@ function kt({ config: i, children: e }) {
177
177
  } catch (C) {
178
178
  console.warn("Failed to cache app info:", C);
179
179
  }
180
- } catch (h) {
181
- const m = h instanceof Error ? h : new Error("Failed to load app information");
182
- A(m), s(null);
180
+ } catch (u) {
181
+ const y = u instanceof Error ? u : new Error("Failed to load app information");
182
+ k(y), s(null);
183
183
  } finally {
184
- g(!1);
184
+ p(!1);
185
185
  }
186
186
  },
187
187
  [i.baseUrl, i.appId, t, r]
188
- ), f = ne(async () => {
188
+ ), m = ne(async () => {
189
189
  if (!(!t.enabled || !r))
190
190
  try {
191
- const p = localStorage.getItem(t.storageKey);
192
- if (!p) return;
193
- const h = JSON.parse(p);
194
- if (Date.now() - h.timestamp > t.ttl * 0.5) {
195
- const R = new re(i.baseUrl), U = await new Se(R, {}).getPublicAppInfo(i.appId);
196
- s(U);
197
- const P = {
198
- data: U,
191
+ const f = localStorage.getItem(t.storageKey);
192
+ if (!f) return;
193
+ const u = JSON.parse(f);
194
+ if (Date.now() - u.timestamp > t.ttl * 0.5) {
195
+ const R = new re(i.baseUrl), q = await new ve(R, {}).getPublicAppInfo(i.appId);
196
+ s(q);
197
+ const A = {
198
+ data: q,
199
199
  timestamp: Date.now(),
200
200
  appId: i.appId
201
201
  };
202
- localStorage.setItem(t.storageKey, JSON.stringify(P));
202
+ localStorage.setItem(t.storageKey, JSON.stringify(A));
203
203
  }
204
- } catch (p) {
205
- console.warn("Background app refresh failed:", p);
204
+ } catch (f) {
205
+ console.warn("Background app refresh failed:", f);
206
206
  }
207
207
  }, [i, t, r]);
208
208
  return te(() => {
209
- r ? f() : T();
210
- }, []), /* @__PURE__ */ n(Te.Provider, { value: w, children: e });
209
+ r ? m() : T();
210
+ }, []), /* @__PURE__ */ n(Pe.Provider, { value: S, children: e });
211
211
  }
212
212
  function oe() {
213
- const i = ce(Te);
213
+ const i = ce(Pe);
214
214
  if (!i)
215
215
  throw new Error("useApp must be used within an AppProvider");
216
216
  return i;
217
217
  }
218
- const At = oe;
219
- class ye {
218
+ const Rt = oe;
219
+ class we {
220
220
  constructor(e = {}) {
221
221
  this.refreshPromise = null, this.refreshQueue = [], e.tenantSlug !== void 0 ? this.storageKey = e.tenantSlug ? `auth_tokens_${e.tenantSlug}` : "auth_tokens" : 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 || this.createTokenStorage(this.storageKey);
222
222
  }
@@ -369,7 +369,7 @@ class ye {
369
369
  return e !== null && !this.isTokenExpired(e);
370
370
  }
371
371
  }
372
- class He {
372
+ class Ue {
373
373
  constructor(e) {
374
374
  this.httpService = e;
375
375
  }
@@ -414,7 +414,7 @@ class He {
414
414
  });
415
415
  }
416
416
  }
417
- class ve {
417
+ class xe {
418
418
  constructor(e, t) {
419
419
  this.httpService = e, this.sessionManager = t;
420
420
  }
@@ -481,16 +481,16 @@ class ve {
481
481
  throw new Error("SessionManager is required for private endpoints");
482
482
  const r = await this.sessionManager.getAuthHeaders(), s = new URLSearchParams();
483
483
  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);
484
- const o = `/roles/user/${e}${s.toString() ? `?${s.toString()}` : ""}`, g = await this.httpService.get(o, {
484
+ const o = `/roles/user/${e}${s.toString() ? `?${s.toString()}` : ""}`, p = await this.httpService.get(o, {
485
485
  headers: r
486
486
  });
487
487
  return {
488
- roles: g.data,
489
- meta: g.meta
488
+ roles: p.data,
489
+ meta: p.meta
490
490
  };
491
491
  }
492
492
  }
493
- class Ne {
493
+ class qe {
494
494
  constructor(e, t) {
495
495
  this.httpService = e, this.sessionManager = t;
496
496
  }
@@ -608,7 +608,7 @@ class ue {
608
608
  )).data;
609
609
  }
610
610
  }
611
- function Be(i, e) {
611
+ function ze(i, e) {
612
612
  if (i === "localhost" || i.startsWith("127.") || i.startsWith("192.168."))
613
613
  return null;
614
614
  if (e) {
@@ -616,31 +616,57 @@ function Be(i, e) {
616
616
  if (o === s || o === `www.${s}`)
617
617
  return null;
618
618
  if (o.endsWith(`.${s}`)) {
619
- const g = o.slice(0, -(s.length + 1));
620
- return g === "www" ? null : g;
619
+ const p = o.slice(0, -(s.length + 1));
620
+ return p === "www" ? null : p;
621
621
  }
622
622
  return null;
623
623
  }
624
624
  const r = i.split(".");
625
625
  return r.length >= 3 && r[0] !== "www" ? r[0] : null;
626
626
  }
627
- function Ue(i, e = "tenant", t) {
627
+ function Oe(i, e = "tenant", t) {
628
628
  const s = new URLSearchParams(i).get(e);
629
629
  return s ? (t && t.setItem("tenant", s), s) : t ? t.getItem("tenant") : null;
630
630
  }
631
- function qe(i, e, t) {
631
+ function We(i, e, t) {
632
632
  const { tenantMode: r, baseDomain: s, selectorParam: o } = i;
633
- return r === "subdomain" ? Be(e.hostname, s) : r === "selector" ? Ue(e.search, o, t) : null;
633
+ return r === "subdomain" ? ze(e.hostname, s) : r === "selector" ? Oe(e.search, o, t) : null;
634
634
  }
635
- function ze(i, e, t) {
635
+ function je(i, e, t) {
636
636
  if (t)
637
637
  return `${i}.${t}`;
638
638
  const r = e.split(".");
639
639
  return r.length === 2 ? `${i}.${e}` : r.length >= 3 ? (r[0] = i, r.join(".")) : null;
640
640
  }
641
- const be = he(null);
642
- function Tt({ config: i, children: e }) {
643
- const { baseUrl: t, appInfo: r, appId: s } = oe(), o = ne(() => typeof window > "u" ? null : qe(
641
+ const fe = "_auth";
642
+ function Ve(i) {
643
+ const e = JSON.stringify(i);
644
+ return btoa(e).replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, "");
645
+ }
646
+ function _e(i) {
647
+ try {
648
+ let e = i.replace(/-/g, "+").replace(/_/g, "/");
649
+ for (; e.length % 4; )
650
+ e += "=";
651
+ const t = atob(e), r = JSON.parse(t);
652
+ return typeof r.accessToken == "string" && typeof r.refreshToken == "string" && typeof r.expiresIn == "number" ? r : null;
653
+ } catch {
654
+ return null;
655
+ }
656
+ }
657
+ function Ge() {
658
+ if (typeof window > "u") return null;
659
+ const e = new URLSearchParams(window.location.search).get(fe);
660
+ return e ? _e(e) : null;
661
+ }
662
+ function Ke() {
663
+ if (typeof window > "u") return;
664
+ const i = new URL(window.location.href);
665
+ i.searchParams.delete(fe), window.history.replaceState({}, "", i.toString());
666
+ }
667
+ const Se = he(null);
668
+ function Ct({ config: i, children: e }) {
669
+ const { baseUrl: t, appInfo: r, appId: s } = oe(), o = ne(() => typeof window > "u" ? null : We(
644
670
  {
645
671
  tenantMode: i.tenantMode || "selector",
646
672
  baseDomain: i.baseDomain,
@@ -651,118 +677,118 @@ function Tt({ config: i, children: e }) {
651
677
  search: window.location.search
652
678
  },
653
679
  window.localStorage
654
- ), [i.tenantMode, i.baseDomain, i.selectorParam]), [g, y] = k(() => o()), A = Q(
680
+ ), [i.tenantMode, i.baseDomain, i.selectorParam]), [p, b] = x(() => o()), k = X(
655
681
  () => {
656
- var l, x, b;
682
+ var a, L, c;
657
683
  return {
658
- enabled: ((l = i.cache) == null ? void 0 : l.enabled) ?? !0,
659
- ttl: ((x = i.cache) == null ? void 0 : x.ttl) ?? 5 * 60 * 1e3,
684
+ enabled: ((a = i.cache) == null ? void 0 : a.enabled) ?? !0,
685
+ ttl: ((L = i.cache) == null ? void 0 : L.ttl) ?? 5 * 60 * 1e3,
660
686
  // 5 minutes default
661
- storageKey: ((b = i.cache) == null ? void 0 : b.storageKey) ?? `tenant_cache_${g || "default"}`
687
+ storageKey: ((c = i.cache) == null ? void 0 : c.storageKey) ?? `tenant_cache_${p || "default"}`
662
688
  };
663
689
  },
664
- [i.cache, g]
665
- ), [w, T] = k(() => {
690
+ [i.cache, p]
691
+ ), [S, T] = x(() => {
666
692
  if (i.initialTenant) return i.initialTenant;
667
- if (!A.enabled || !g) return null;
693
+ if (!k.enabled || !p) return null;
668
694
  try {
669
- const l = localStorage.getItem(A.storageKey);
670
- if (!l) return null;
671
- const x = JSON.parse(l);
672
- return Date.now() - x.timestamp < A.ttl && x.tenantSlug === g ? x.data : (localStorage.removeItem(A.storageKey), null);
695
+ const a = localStorage.getItem(k.storageKey);
696
+ if (!a) return null;
697
+ const L = JSON.parse(a);
698
+ return Date.now() - L.timestamp < k.ttl && L.tenantSlug === p ? L.data : (localStorage.removeItem(k.storageKey), null);
673
699
  } catch {
674
700
  return null;
675
701
  }
676
- }), [f, p] = k(!w && !i.initialTenant), [h, m] = k(null), [R, C] = k(null), [U, P] = k(!1), [u, M] = k(null);
702
+ }), [m, f] = x(!S && !i.initialTenant), [u, y] = x(null), [R, C] = x(null), [q, A] = x(!1), [d, P] = x(null);
677
703
  te(() => {
678
- const l = o();
679
- y(l);
704
+ const a = o();
705
+ b(a);
680
706
  }, [o]);
681
- const E = (r == null ? void 0 : r.settingsSchema) || null, q = ne(
682
- async (l, x = !1) => {
683
- if (!(!x && A.enabled && w && w.domain === l))
707
+ const E = (r == null ? void 0 : r.settingsSchema) || null, z = ne(
708
+ async (a, L = !1) => {
709
+ if (!(!L && k.enabled && S && S.domain === a))
684
710
  try {
685
- p(!0), m(null);
686
- const b = new re(t), c = await new ue(b, s).getPublicTenantInfo(l);
687
- if (T(c), A.enabled)
711
+ f(!0), y(null);
712
+ const c = new re(t), g = await new ue(c, s).getPublicTenantInfo(a);
713
+ if (T(g), k.enabled)
688
714
  try {
689
- const S = {
690
- data: c,
715
+ const w = {
716
+ data: g,
691
717
  timestamp: Date.now(),
692
- tenantSlug: l
718
+ tenantSlug: a
693
719
  };
694
- localStorage.setItem(A.storageKey, JSON.stringify(S));
695
- } catch (S) {
696
- console.warn("Failed to cache tenant info:", S);
720
+ localStorage.setItem(k.storageKey, JSON.stringify(w));
721
+ } catch (w) {
722
+ console.warn("Failed to cache tenant info:", w);
697
723
  }
698
- } catch (b) {
699
- const d = b instanceof Error ? b : new Error("Failed to load tenant information");
700
- m(d), T(null);
724
+ } catch (c) {
725
+ const h = c instanceof Error ? c : new Error("Failed to load tenant information");
726
+ y(h), T(null);
701
727
  } finally {
702
- p(!1);
728
+ f(!1);
703
729
  }
704
730
  },
705
- [t, s, A, w]
706
- ), V = ne(async () => {
707
- if (!(!A.enabled || !w || !g))
731
+ [t, s, k, S]
732
+ ), G = ne(async () => {
733
+ if (!(!k.enabled || !S || !p))
708
734
  try {
709
- const l = localStorage.getItem(A.storageKey);
710
- if (!l) return;
711
- const x = JSON.parse(l);
712
- if (Date.now() - x.timestamp > A.ttl * 0.5) {
713
- const d = new re(t), S = await new ue(d, s).getPublicTenantInfo(g);
714
- T(S);
715
- const _ = {
716
- data: S,
735
+ const a = localStorage.getItem(k.storageKey);
736
+ if (!a) return;
737
+ const L = JSON.parse(a);
738
+ if (Date.now() - L.timestamp > k.ttl * 0.5) {
739
+ const h = new re(t), w = await new ue(h, s).getPublicTenantInfo(p);
740
+ T(w);
741
+ const j = {
742
+ data: w,
717
743
  timestamp: Date.now(),
718
- tenantSlug: g
744
+ tenantSlug: p
719
745
  };
720
- localStorage.setItem(A.storageKey, JSON.stringify(_));
746
+ localStorage.setItem(k.storageKey, JSON.stringify(j));
721
747
  }
722
- } catch (l) {
723
- console.warn("Background tenant refresh failed:", l);
748
+ } catch (a) {
749
+ console.warn("Background tenant refresh failed:", a);
724
750
  }
725
- }, [t, s, A, w, g]), $ = ne(async () => {
726
- if (w != null && w.id)
751
+ }, [t, s, k, S, p]), $ = ne(async () => {
752
+ if (S != null && S.id)
727
753
  try {
728
- P(!0), M(null);
729
- const l = new re(t), b = await new ue(l, w.appId).getTenantSettings(w.id);
730
- C(b);
731
- } catch (l) {
732
- const x = l instanceof Error ? l : new Error("Failed to load tenant settings");
733
- M(x), C(null);
754
+ A(!0), P(null);
755
+ const a = new re(t), c = await new ue(a, S.appId).getTenantSettings(S.id);
756
+ C(c);
757
+ } catch (a) {
758
+ const L = a instanceof Error ? a : new Error("Failed to load tenant settings");
759
+ P(L), C(null);
734
760
  } finally {
735
- P(!1);
761
+ A(!1);
736
762
  }
737
- }, [t, w]), j = ne(() => {
763
+ }, [t, S]), _ = ne(() => {
738
764
  $();
739
765
  }, [$]), v = ne(
740
- (l) => {
766
+ (a) => {
741
767
  if (!E)
742
768
  return { isValid: !0, errors: [] };
743
- const x = [];
769
+ const L = [];
744
770
  try {
745
- return E.properties && Object.entries(E.properties).forEach(([b, d]) => {
746
- var S;
747
- const c = l[b];
748
- if ((S = E.required) != null && S.includes(b) && c == null) {
749
- x.push(`Field '${b}' is required`);
771
+ return E.properties && Object.entries(E.properties).forEach(([c, h]) => {
772
+ var w;
773
+ const g = a[c];
774
+ if ((w = E.required) != null && w.includes(c) && g == null) {
775
+ L.push(`Field '${c}' is required`);
750
776
  return;
751
777
  }
752
- if (c != null) {
753
- if (d.type) {
754
- const _ = d.type, ee = typeof c;
755
- _ === "string" && ee !== "string" ? x.push(`Field '${b}' must be a string`) : (_ === "number" || _ === "integer") && ee !== "number" ? x.push(`Field '${b}' must be a number`) : _ === "boolean" && ee !== "boolean" ? x.push(`Field '${b}' must be a boolean`) : _ === "array" && !Array.isArray(c) && x.push(`Field '${b}' must be an array`);
778
+ if (g != null) {
779
+ if (h.type) {
780
+ const j = h.type, Y = typeof g;
781
+ j === "string" && Y !== "string" ? L.push(`Field '${c}' must be a string`) : (j === "number" || j === "integer") && Y !== "number" ? L.push(`Field '${c}' must be a number`) : j === "boolean" && Y !== "boolean" ? L.push(`Field '${c}' must be a boolean`) : j === "array" && !Array.isArray(g) && L.push(`Field '${c}' must be an array`);
756
782
  }
757
- d.minLength !== void 0 && typeof c == "string" && c.length < d.minLength && x.push(
758
- `Field '${b}' must be at least ${d.minLength} characters long`
759
- ), d.maxLength !== void 0 && typeof c == "string" && c.length > d.maxLength && x.push(
760
- `Field '${b}' must be no more than ${d.maxLength} characters long`
761
- ), d.minimum !== void 0 && typeof c == "number" && c < d.minimum && x.push(`Field '${b}' must be at least ${d.minimum}`), d.maximum !== void 0 && typeof c == "number" && c > d.maximum && x.push(`Field '${b}' must be no more than ${d.maximum}`), d.pattern && typeof c == "string" && (new RegExp(d.pattern).test(c) || x.push(`Field '${b}' does not match the required pattern`)), d.enum && !d.enum.includes(c) && x.push(`Field '${b}' must be one of: ${d.enum.join(", ")}`);
783
+ h.minLength !== void 0 && typeof g == "string" && g.length < h.minLength && L.push(
784
+ `Field '${c}' must be at least ${h.minLength} characters long`
785
+ ), h.maxLength !== void 0 && typeof g == "string" && g.length > h.maxLength && L.push(
786
+ `Field '${c}' must be no more than ${h.maxLength} characters long`
787
+ ), h.minimum !== void 0 && typeof g == "number" && g < h.minimum && L.push(`Field '${c}' must be at least ${h.minimum}`), h.maximum !== void 0 && typeof g == "number" && g > h.maximum && L.push(`Field '${c}' must be no more than ${h.maximum}`), h.pattern && typeof g == "string" && (new RegExp(h.pattern).test(g) || L.push(`Field '${c}' does not match the required pattern`)), h.enum && !h.enum.includes(g) && L.push(`Field '${c}' must be one of: ${h.enum.join(", ")}`);
762
788
  }
763
789
  }), {
764
- isValid: x.length === 0,
765
- errors: x
790
+ isValid: L.length === 0,
791
+ errors: L
766
792
  };
767
793
  } catch {
768
794
  return {
@@ -774,86 +800,88 @@ function Tt({ config: i, children: e }) {
774
800
  [E]
775
801
  );
776
802
  te(() => {
777
- !i.initialTenant && g ? w ? V() : q(g) : !i.initialTenant && !g && (T(null), m(null), p(!1));
778
- }, [i.initialTenant, g, w, q, V]), te(() => {
779
- w != null && w.id ? $() : (C(null), M(null), P(!1));
780
- }, [w == null ? void 0 : w.id, $]);
781
- const I = ne(
782
- (l, x = "reload") => {
783
- const b = i.tenantMode || "selector";
784
- if (localStorage.setItem("tenant", l), b === "subdomain") {
785
- const d = window.location.hostname, c = ze(
786
- l,
787
- d,
803
+ !i.initialTenant && p ? S ? G() : z(p) : !i.initialTenant && !p && (T(null), y(null), f(!1));
804
+ }, [i.initialTenant, p, S, z, G]), te(() => {
805
+ S != null && S.id ? $() : (C(null), P(null), A(!1));
806
+ }, [S == null ? void 0 : S.id, $]);
807
+ const M = ne(
808
+ (a, L) => {
809
+ const { mode: c = "reload", tokens: h, redirectPath: g } = L || {}, w = i.tenantMode || "selector";
810
+ if (localStorage.setItem("tenant", a), w === "subdomain") {
811
+ const j = window.location.hostname, Y = je(
812
+ a,
813
+ j,
788
814
  i.baseDomain
789
815
  );
790
- if (!c) {
816
+ if (!Y) {
791
817
  console.warn(
792
818
  "[TenantProvider] Cannot switch subdomain, invalid hostname:",
793
- d
819
+ j
794
820
  );
795
821
  return;
796
822
  }
797
- const S = `${window.location.protocol}//${c}${window.location.pathname}${window.location.search}`;
798
- window.location.href = S;
799
- } else if (b === "selector") {
800
- const d = new URLSearchParams(window.location.search);
801
- if (d.set(i.selectorParam || "tenant", l), x === "reload") {
802
- const c = `${window.location.pathname}?${d.toString()}${window.location.hash}`;
803
- window.location.href = c;
823
+ const H = g || window.location.pathname, N = new URL(`${window.location.protocol}//${Y}${H}`);
824
+ new URLSearchParams(window.location.search).forEach((F, K) => {
825
+ K !== fe && N.searchParams.set(K, F);
826
+ }), h && N.searchParams.set(fe, Ve(h)), window.location.href = N.toString();
827
+ } else if (w === "selector") {
828
+ const j = g || window.location.pathname, Y = new URLSearchParams(window.location.search);
829
+ if (Y.set(i.selectorParam || "tenant", a), c === "reload") {
830
+ const H = `${j}?${Y.toString()}${window.location.hash}`;
831
+ window.location.href = H;
804
832
  } else {
805
- const c = `${window.location.pathname}?${d.toString()}${window.location.hash}`;
806
- window.history.pushState({}, "", c), y(l), q(l);
833
+ const H = `${j}?${Y.toString()}${window.location.hash}`;
834
+ window.history.pushState({}, "", H), b(a), z(a);
807
835
  }
808
836
  }
809
837
  },
810
- [i.tenantMode, i.selectorParam, q, g]
811
- ), L = Q(() => ({
838
+ [i.tenantMode, i.selectorParam, i.baseDomain, z]
839
+ ), I = X(() => ({
812
840
  // Tenant info
813
- tenant: w,
814
- tenantSlug: g,
815
- isTenantLoading: f,
816
- tenantError: h,
841
+ tenant: S,
842
+ tenantSlug: p,
843
+ isTenantLoading: m,
844
+ tenantError: u,
817
845
  retryTenant: () => {
818
- g && q(g);
846
+ p && z(p);
819
847
  },
820
848
  // Settings
821
849
  settings: R,
822
850
  settingsSchema: E,
823
- isSettingsLoading: U,
824
- settingsError: u,
851
+ isSettingsLoading: q,
852
+ settingsError: d,
825
853
  // Actions
826
- refreshSettings: j,
827
- switchTenant: I,
854
+ refreshSettings: _,
855
+ switchTenant: M,
828
856
  // Validation
829
857
  validateSettings: v
830
858
  }), [
831
- w,
832
- g,
833
- f,
834
- h,
859
+ S,
860
+ p,
861
+ m,
862
+ u,
835
863
  R,
836
864
  E,
837
- U,
838
- u,
839
- j,
840
- I,
865
+ q,
866
+ d,
867
+ _,
868
+ M,
841
869
  v
842
870
  ]);
843
- return /* @__PURE__ */ n(be.Provider, { value: L, children: e });
871
+ return /* @__PURE__ */ n(Se.Provider, { value: I, children: e });
844
872
  }
845
- function fe() {
846
- const i = ce(be);
873
+ function me() {
874
+ const i = ce(Se);
847
875
  if (!i)
848
876
  throw new Error("useTenant must be used within a TenantProvider");
849
877
  return i;
850
878
  }
851
- function Pe() {
852
- return ce(be);
879
+ function Me() {
880
+ return ce(Se);
853
881
  }
854
- const Pt = fe;
855
- function Mt() {
856
- const { settings: i, settingsSchema: e, isSettingsLoading: t, settingsError: r, validateSettings: s } = fe();
882
+ const $t = me;
883
+ function Ft() {
884
+ const { settings: i, settingsSchema: e, isSettingsLoading: t, settingsError: r, validateSettings: s } = me();
857
885
  return {
858
886
  settings: i,
859
887
  settingsSchema: e,
@@ -863,7 +891,7 @@ function Mt() {
863
891
  };
864
892
  }
865
893
  function se() {
866
- const { tenant: i, tenantSlug: e, isTenantLoading: t, tenantError: r, retryTenant: s } = fe();
894
+ const { tenant: i, tenantSlug: e, isTenantLoading: t, tenantError: r, retryTenant: s } = me();
867
895
  return {
868
896
  tenant: i,
869
897
  tenantSlug: e,
@@ -872,273 +900,296 @@ function se() {
872
900
  retry: s
873
901
  };
874
902
  }
875
- const Me = he(null);
876
- function It({ config: i = {}, children: e }) {
877
- const { appId: t, baseUrl: r } = oe(), { tenant: s, tenantSlug: o, switchTenant: g } = fe(), [y, A] = k(i.initialRoles || []), [w, T] = k(!i.initialRoles), [f, p] = k(null), [h, m] = k(!1), [R, C] = k(null), [U, P] = k(0), u = Q(() => new ye({
903
+ const Ie = he(null);
904
+ function Dt({ config: i = {}, children: e }) {
905
+ const { appId: t, baseUrl: r } = oe(), { tenant: s, tenantSlug: o, switchTenant: p } = me(), [b, k] = x(i.initialRoles || []), [S, T] = x(!i.initialRoles), [m, f] = x(null), [u, y] = x(!1), [R, C] = x(null), [q, A] = x(0), d = X(() => new we({
878
906
  tenantSlug: o,
879
907
  // SessionManager will generate storageKey internally
880
908
  onRefreshFailed: i.onRefreshFailed,
881
909
  baseUrl: r
882
- }), [o, r, i.onRefreshFailed]), M = Q(() => {
883
- const x = new re(r);
884
- return x.setSessionManager(u), x;
885
- }, [r, u]), E = Q(() => new He(new re(r)), [r]), q = Q(() => new Ne(M, u), [M, u]), V = Q(() => new ve(new re(r)), [r]), $ = Q(() => f || u.getUser(), [f, u]), j = Q(() => $ != null && $.roleId && y.find((x) => x.id === $.roleId) || null, [$, y]), v = Q(() => (j == null ? void 0 : j.permissions) || [], [j]), I = Q(() => u.hasValidSession() && f !== null, [u, f]), L = 5 * 60 * 1e3, l = Q(() => {
886
- const x = async (F = !1) => {
910
+ }), [o, r, i.onRefreshFailed]), P = X(() => {
911
+ const c = new re(r);
912
+ return c.setSessionManager(d), c;
913
+ }, [r, d]), E = X(() => new Ue(new re(r)), [r]), z = X(() => new qe(P, d), [P, d]), G = X(() => new xe(new re(r)), [r]), $ = X(() => m || d.getUser(), [m, d]), _ = X(() => $ != null && $.roleId && b.find((c) => c.id === $.roleId) || null, [$, b]), v = X(() => (_ == null ? void 0 : _.permissions) || [], [_]), M = X(() => d.hasValidSession() && m !== null, [d, m]), I = 5 * 60 * 1e3, a = X(() => {
914
+ const c = async (D = !1) => {
887
915
  try {
888
- if (!u.hasValidSession())
916
+ if (!d.hasValidSession())
889
917
  return;
890
- const N = Date.now();
891
- if (!F && N - U < L && f)
918
+ const B = Date.now();
919
+ if (!D && B - q < I && m)
892
920
  return;
893
- const W = u.getUserId();
921
+ const W = d.getUserId();
894
922
  if (!W) {
895
923
  console.warn("[AuthProvider] No userId available in token or storage");
896
924
  return;
897
925
  }
898
- m(!0), C(null);
899
- const X = await q.getUserById(W);
900
- p(X), u.setUser(X), P(Date.now());
901
- } catch (N) {
902
- const G = N instanceof Error ? N : new Error("Failed to load user data");
903
- C(G), console.error("[AuthProvider] Failed to load user data:", G);
926
+ y(!0), C(null);
927
+ const Z = await z.getUserById(W);
928
+ f(Z), d.setUser(Z), A(Date.now());
929
+ } catch (B) {
930
+ const J = B instanceof Error ? B : new Error("Failed to load user data");
931
+ C(J), console.error("[AuthProvider] Failed to load user data:", J);
904
932
  } finally {
905
- m(!1);
933
+ y(!1);
906
934
  }
907
- }, b = async () => {
908
- await x();
909
- }, d = async (F) => {
910
- const { username: N, password: G, tenantSlug: W } = F;
911
- let X = s == null ? void 0 : s.id, Y = o, Z = u;
912
- W && (X = (await new ue(M, t).getPublicTenantInfo(W)).id, Y = W);
913
- const J = await E.login({
914
- username: N,
915
- password: G,
935
+ }, h = async () => {
936
+ await c();
937
+ }, g = async (D) => {
938
+ const { username: B, password: J, tenantSlug: W } = D;
939
+ let Z = s == null ? void 0 : s.id, Q = o, ee = d;
940
+ W && (Z = (await new ue(P, t).getPublicTenantInfo(W)).id, Q = W);
941
+ const V = await E.login({
942
+ username: B,
943
+ password: J,
916
944
  appId: t,
917
- tenantId: X
945
+ tenantId: Z
918
946
  }), le = W && W !== o;
919
- if (le && (Z = new ye({
920
- tenantSlug: Y,
947
+ if (le && (ee = new we({
948
+ tenantSlug: Q,
921
949
  baseUrl: r
922
- })), Z.setTokens({
923
- accessToken: J.accessToken,
924
- refreshToken: J.refreshToken,
925
- expiresIn: J.expiresIn
926
- }), J.user) {
927
- Z.setUser(J.user), p(J.user);
950
+ })), ee.setTokens({
951
+ accessToken: V.accessToken,
952
+ refreshToken: V.refreshToken,
953
+ expiresIn: V.expiresIn
954
+ }), V.user) {
955
+ ee.setUser(V.user), f(V.user);
928
956
  try {
929
- await x();
957
+ await c();
930
958
  } catch (de) {
931
959
  console.warn("Failed to load complete user data after login:", de);
932
960
  }
933
961
  }
934
- return le && Y && Y !== o && g(Y), J;
935
- }, c = async (F) => {
936
- const { email: N, phoneNumber: G, name: W, password: X, lastName: Y, tenantId: Z } = F;
937
- if (!N && !G)
962
+ return le && Q && Q !== o && p(Q, {
963
+ tokens: {
964
+ accessToken: V.accessToken,
965
+ refreshToken: V.refreshToken,
966
+ expiresIn: V.expiresIn
967
+ }
968
+ }), V;
969
+ }, w = async (D) => {
970
+ const { email: B, phoneNumber: J, name: W, password: Z, lastName: Q, tenantId: ee } = D;
971
+ if (!B && !J)
938
972
  throw new Error("Either email or phoneNumber is required");
939
- if (!W || !X)
973
+ if (!W || !Z)
940
974
  throw new Error("Name and password are required");
941
- const J = Z ?? (s == null ? void 0 : s.id);
975
+ const V = ee ?? (s == null ? void 0 : s.id);
942
976
  return await E.signup({
943
- email: N,
944
- phoneNumber: G,
977
+ email: B,
978
+ phoneNumber: J,
945
979
  name: W,
946
- password: X,
947
- tenantId: J,
948
- lastName: Y,
980
+ password: Z,
981
+ tenantId: V,
982
+ lastName: Q,
949
983
  appId: t
950
984
  });
951
- }, S = async (F) => {
952
- const { email: N, phoneNumber: G, name: W, password: X, tenantName: Y, lastName: Z } = F;
953
- if (!N && !G)
985
+ }, j = async (D) => {
986
+ const { email: B, phoneNumber: J, name: W, password: Z, tenantName: Q, lastName: ee } = D;
987
+ if (!B && !J)
954
988
  throw new Error("Either email or phoneNumber is required");
955
- if (!W || !X || !Y)
989
+ if (!W || !Z || !Q)
956
990
  throw new Error("Name, password, and tenantName are required");
957
991
  return await E.signupTenantAdmin({
958
- email: N,
959
- phoneNumber: G,
992
+ email: B,
993
+ phoneNumber: J,
960
994
  name: W,
961
- password: X,
962
- tenantName: Y,
995
+ password: Z,
996
+ tenantName: Q,
963
997
  appId: t,
964
- lastName: Z
998
+ lastName: ee
965
999
  });
966
- }, _ = async (F) => {
967
- const { currentPassword: N, newPassword: G } = F, W = await u.getAuthHeaders();
968
- await E.changePassword({ currentPassword: N, newPassword: G }, W);
969
- }, ee = async (F) => {
970
- const { email: N, tenantId: G } = F, W = G ?? (s == null ? void 0 : s.id);
1000
+ }, Y = async (D) => {
1001
+ const { currentPassword: B, newPassword: J } = D, W = await d.getAuthHeaders();
1002
+ await E.changePassword({ currentPassword: B, newPassword: J }, W);
1003
+ }, H = async (D) => {
1004
+ const { email: B, tenantId: J } = D, W = J ?? (s == null ? void 0 : s.id);
971
1005
  if (!W)
972
1006
  throw new Error("tenantId is required for password reset");
973
- await E.requestPasswordReset({ email: N, tenantId: W });
974
- }, z = async (F) => {
975
- const { token: N, newPassword: G } = F;
976
- await E.confirmPasswordReset({ token: N, newPassword: G });
977
- }, H = async (F) => {
978
- const { email: N, frontendUrl: G, name: W, lastName: X, tenantId: Y } = F, Z = Y ?? (s == null ? void 0 : s.id);
979
- if (!Z)
1007
+ await E.requestPasswordReset({ email: B, tenantId: W });
1008
+ }, N = async (D) => {
1009
+ const { token: B, newPassword: J } = D;
1010
+ await E.confirmPasswordReset({ token: B, newPassword: J });
1011
+ }, O = async (D) => {
1012
+ const { email: B, frontendUrl: J, name: W, lastName: Z, tenantId: Q } = D, ee = Q ?? (s == null ? void 0 : s.id);
1013
+ if (!ee)
980
1014
  throw new Error("tenantId is required for magic link authentication");
981
1015
  return await E.sendMagicLink({
982
- email: N,
983
- tenantId: Z,
984
- frontendUrl: G,
1016
+ email: B,
1017
+ tenantId: ee,
1018
+ frontendUrl: J,
985
1019
  name: W,
986
- lastName: X,
1020
+ lastName: Z,
987
1021
  appId: t
988
1022
  });
989
- }, O = async (F) => {
990
- const { token: N, email: G, tenantSlug: W } = F;
991
- let X = s == null ? void 0 : s.id, Y = o, Z = u;
992
- W && (X = (await new ue(M, t).getPublicTenantInfo(W)).id, Y = W);
993
- const J = await E.verifyMagicLink({
994
- token: N,
995
- email: G,
1023
+ }, F = async (D) => {
1024
+ const { token: B, email: J, tenantSlug: W } = D;
1025
+ let Z = s == null ? void 0 : s.id, Q = o, ee = d;
1026
+ W && (Z = (await new ue(P, t).getPublicTenantInfo(W)).id, Q = W);
1027
+ const V = await E.verifyMagicLink({
1028
+ token: B,
1029
+ email: J,
996
1030
  appId: t,
997
- tenantId: X
1031
+ tenantId: Z
998
1032
  }), le = W && W !== o;
999
- if (le && (Z = new ye({
1000
- tenantSlug: Y,
1033
+ if (le && (ee = new we({
1034
+ tenantSlug: Q,
1001
1035
  baseUrl: r
1002
- })), Z.setTokens({
1003
- accessToken: J.accessToken,
1004
- refreshToken: J.refreshToken,
1005
- expiresIn: J.expiresIn
1006
- }), J.user) {
1007
- Z.setUser(J.user), p(J.user);
1036
+ })), ee.setTokens({
1037
+ accessToken: V.accessToken,
1038
+ refreshToken: V.refreshToken,
1039
+ expiresIn: V.expiresIn
1040
+ }), V.user) {
1041
+ ee.setUser(V.user), f(V.user);
1008
1042
  try {
1009
- await x();
1043
+ await c();
1010
1044
  } catch (de) {
1011
1045
  console.warn("Failed to load complete user data after magic link login:", de);
1012
1046
  }
1013
1047
  }
1014
- return le && Y && Y !== o && g(Y), J;
1015
- }, D = async () => {
1016
- const F = u.getTokens();
1017
- if (!(F != null && F.refreshToken))
1048
+ return le && Q && Q !== o && p(Q, {
1049
+ tokens: {
1050
+ accessToken: V.accessToken,
1051
+ refreshToken: V.refreshToken,
1052
+ expiresIn: V.expiresIn
1053
+ }
1054
+ }), V;
1055
+ }, K = async () => {
1056
+ const D = d.getTokens();
1057
+ if (!(D != null && D.refreshToken))
1018
1058
  throw new Error("No refresh token available");
1019
- const N = await E.refreshToken({
1020
- refreshToken: F.refreshToken
1059
+ const B = await E.refreshToken({
1060
+ refreshToken: D.refreshToken
1021
1061
  });
1022
- u.setTokens({
1023
- accessToken: N.accessToken,
1024
- refreshToken: N.refreshToken || F.refreshToken,
1025
- expiresIn: N.expiresIn
1062
+ d.setTokens({
1063
+ accessToken: B.accessToken,
1064
+ refreshToken: B.refreshToken || D.refreshToken,
1065
+ expiresIn: B.expiresIn
1026
1066
  });
1027
- }, K = () => {
1028
- u.clearSession(), p(null), C(null);
1029
- }, ge = (F) => {
1030
- u.setTokens(F);
1031
- }, Re = () => u.hasValidSession(), Ce = () => {
1032
- u.clearSession(), p(null), C(null);
1033
- }, $e = async () => {
1067
+ }, ge = () => {
1068
+ d.clearSession(), f(null), C(null);
1069
+ }, Ce = (D) => {
1070
+ d.setTokens(D);
1071
+ }, $e = () => d.hasValidSession(), Fe = () => {
1072
+ d.clearSession(), f(null), C(null);
1073
+ }, De = async () => {
1034
1074
  if (t)
1035
1075
  try {
1036
1076
  T(!0);
1037
- const { roles: F } = await V.getRolesByApp(t);
1038
- A(F);
1039
- } catch (F) {
1040
- console.error("Failed to fetch roles:", F);
1077
+ const { roles: D } = await G.getRolesByApp(t);
1078
+ k(D);
1079
+ } catch (D) {
1080
+ console.error("Failed to fetch roles:", D);
1041
1081
  } finally {
1042
1082
  T(!1);
1043
1083
  }
1044
- }, Fe = async () => {
1045
- await $e();
1046
- }, me = (F) => {
1084
+ }, He = async () => {
1085
+ await De();
1086
+ }, ye = (D) => {
1047
1087
  if (!v || v.length === 0)
1048
1088
  return !1;
1049
- if (typeof F == "string")
1050
- return v.includes(F);
1051
- const N = `${F.resource}.${F.action}`;
1052
- return v.includes(N);
1089
+ if (typeof D == "string")
1090
+ return v.includes(D);
1091
+ const B = `${D.resource}.${D.action}`;
1092
+ return v.includes(B);
1053
1093
  };
1054
1094
  return {
1055
1095
  // RFC-003: Authentication state
1056
- isAuthenticated: I,
1057
- sessionManager: u,
1058
- authenticatedHttpService: M,
1059
- login: d,
1060
- signup: c,
1061
- signupTenantAdmin: S,
1062
- sendMagicLink: H,
1063
- verifyMagicLink: O,
1064
- changePassword: _,
1065
- requestPasswordReset: ee,
1066
- confirmPasswordReset: z,
1067
- refreshToken: D,
1068
- logout: K,
1069
- setTokens: ge,
1070
- hasValidSession: Re,
1071
- clearSession: Ce,
1072
- currentUser: f,
1073
- isUserLoading: h,
1096
+ isAuthenticated: M,
1097
+ sessionManager: d,
1098
+ authenticatedHttpService: P,
1099
+ login: g,
1100
+ signup: w,
1101
+ signupTenantAdmin: j,
1102
+ sendMagicLink: O,
1103
+ verifyMagicLink: F,
1104
+ changePassword: Y,
1105
+ requestPasswordReset: H,
1106
+ confirmPasswordReset: N,
1107
+ refreshToken: K,
1108
+ logout: ge,
1109
+ setTokens: Ce,
1110
+ hasValidSession: $e,
1111
+ clearSession: Fe,
1112
+ currentUser: m,
1113
+ isUserLoading: u,
1074
1114
  userError: R,
1075
- loadUserData: x,
1076
- refreshUser: b,
1077
- userRole: j,
1115
+ loadUserData: c,
1116
+ refreshUser: h,
1117
+ userRole: _,
1078
1118
  userPermissions: v,
1079
- availableRoles: y,
1080
- rolesLoading: w,
1081
- hasPermission: me,
1082
- hasAnyPermission: (F) => F.some((N) => me(N)),
1083
- hasAllPermissions: (F) => F.every((N) => me(N)),
1119
+ availableRoles: b,
1120
+ rolesLoading: S,
1121
+ hasPermission: ye,
1122
+ hasAnyPermission: (D) => D.some((B) => ye(B)),
1123
+ hasAllPermissions: (D) => D.every((B) => ye(B)),
1084
1124
  getUserPermissionStrings: () => v || [],
1085
- refreshRoles: Fe
1125
+ refreshRoles: He
1086
1126
  };
1087
1127
  }, [
1088
- I,
1089
- u,
1090
1128
  M,
1129
+ d,
1130
+ P,
1091
1131
  E,
1092
- q,
1093
- V,
1132
+ z,
1133
+ G,
1094
1134
  t,
1095
1135
  s,
1096
1136
  o,
1097
- g,
1098
- y,
1099
- f,
1100
- h,
1137
+ p,
1138
+ b,
1139
+ m,
1140
+ u,
1101
1141
  R,
1102
- j,
1142
+ _,
1103
1143
  v,
1104
- U,
1105
- L
1144
+ q,
1145
+ I
1106
1146
  ]);
1107
- return te(() => {
1147
+ te(() => {
1108
1148
  !i.initialRoles && t && (async () => {
1109
1149
  try {
1110
1150
  T(!0);
1111
- const b = new re(r), d = new ve(b), { roles: c } = await d.getRolesByApp(t);
1112
- A(c);
1113
- } catch (b) {
1114
- console.error("Failed to fetch roles:", b);
1151
+ const h = new re(r), g = new xe(h), { roles: w } = await g.getRolesByApp(t);
1152
+ k(w);
1153
+ } catch (h) {
1154
+ console.error("Failed to fetch roles:", h);
1115
1155
  } finally {
1116
1156
  T(!1);
1117
1157
  }
1118
1158
  })();
1119
- }, [t, r, i.initialRoles]), te(() => {
1120
- const x = u.getUser();
1121
- x && u.hasValidSession() && p(x);
1122
- }, [u]), te(() => {
1123
- !f && !h && l.loadUserData().catch(() => {
1159
+ }, [t, r, i.initialRoles]);
1160
+ const L = Be(!1);
1161
+ return te(() => {
1162
+ if (L.current) return;
1163
+ const c = Ge();
1164
+ c && (L.current = !0, d.setTokens({
1165
+ accessToken: c.accessToken,
1166
+ refreshToken: c.refreshToken,
1167
+ expiresIn: c.expiresIn
1168
+ }), Ke(), a.loadUserData().catch(() => {
1169
+ }));
1170
+ }, [d, a]), te(() => {
1171
+ const c = d.getUser();
1172
+ c && d.hasValidSession() && f(c);
1173
+ }, [d]), te(() => {
1174
+ !m && !u && a.loadUserData().catch(() => {
1124
1175
  });
1125
- }, [f, h, l]), te(() => {
1126
- if (!u.hasValidSession() || !f)
1176
+ }, [m, u, a]), te(() => {
1177
+ if (!d.hasValidSession() || !m)
1127
1178
  return;
1128
- const x = setInterval(() => {
1129
- l.loadUserData().catch(() => {
1179
+ const c = setInterval(() => {
1180
+ a.loadUserData().catch(() => {
1130
1181
  });
1131
- }, L);
1132
- return () => clearInterval(x);
1133
- }, [u, f, l, L]), /* @__PURE__ */ n(Me.Provider, { value: l, children: e });
1182
+ }, I);
1183
+ return () => clearInterval(c);
1184
+ }, [d, m, a, I]), /* @__PURE__ */ n(Ie.Provider, { value: a, children: e });
1134
1185
  }
1135
1186
  function ae() {
1136
- const i = ce(Me);
1187
+ const i = ce(Ie);
1137
1188
  if (!i)
1138
1189
  throw new Error("useAuth must be used within an AuthProvider");
1139
1190
  return i;
1140
1191
  }
1141
- class Oe {
1192
+ class Je {
1142
1193
  constructor(e, t) {
1143
1194
  this.httpService = e, this.sessionManager = t;
1144
1195
  }
@@ -1218,58 +1269,58 @@ class Oe {
1218
1269
  })).data;
1219
1270
  }
1220
1271
  }
1221
- const Ie = he(null);
1222
- function Lt({ config: i = {}, children: e }) {
1223
- const { baseUrl: t, appId: r } = oe(), { tenant: s } = se(), [o, g] = k([]), [y, A] = k(!1), [w, T] = k(null), f = Q(() => {
1224
- const m = new re(t);
1225
- return new Oe(m);
1226
- }, [t]), p = async () => {
1272
+ const Le = he(null);
1273
+ function Ht({ config: i = {}, children: e }) {
1274
+ const { baseUrl: t, appId: r } = oe(), { tenant: s } = se(), [o, p] = x([]), [b, k] = x(!1), [S, T] = x(null), m = X(() => {
1275
+ const y = new re(t);
1276
+ return new Je(y);
1277
+ }, [t]), f = async () => {
1227
1278
  if (!(s != null && s.id)) {
1228
- g([]);
1279
+ p([]);
1229
1280
  return;
1230
1281
  }
1231
- A(!0), T(null);
1282
+ k(!0), T(null);
1232
1283
  try {
1233
- const m = await f.getTenantFeatureFlags(s.id, r);
1234
- g(m);
1235
- } catch (m) {
1236
- const R = m instanceof Error ? m.message : "Failed to fetch feature flags";
1237
- T(R), i.onError && i.onError(m instanceof Error ? m : new Error(R));
1284
+ const y = await m.getTenantFeatureFlags(s.id, r);
1285
+ p(y);
1286
+ } catch (y) {
1287
+ const R = y instanceof Error ? y.message : "Failed to fetch feature flags";
1288
+ T(R), i.onError && i.onError(y instanceof Error ? y : new Error(R));
1238
1289
  } finally {
1239
- A(!1);
1290
+ k(!1);
1240
1291
  }
1241
1292
  };
1242
1293
  te(() => {
1243
- p();
1244
- const m = i.refreshInterval || 5 * 60 * 1e3, R = setInterval(p, m);
1294
+ f();
1295
+ const y = i.refreshInterval || 5 * 60 * 1e3, R = setInterval(f, y);
1245
1296
  return () => clearInterval(R);
1246
1297
  }, [s == null ? void 0 : s.id, i.refreshInterval]);
1247
- const h = Q(() => ({
1298
+ const u = X(() => ({
1248
1299
  featureFlags: o,
1249
- loading: y,
1250
- error: w,
1251
- isEnabled: (P) => {
1252
- const u = o.find((M) => M.key === P);
1253
- return (u == null ? void 0 : u.value) === !0;
1300
+ loading: b,
1301
+ error: S,
1302
+ isEnabled: (A) => {
1303
+ const d = o.find((P) => P.key === A);
1304
+ return (d == null ? void 0 : d.value) === !0;
1254
1305
  },
1255
- getFlag: (P) => o.find((u) => u.key === P),
1256
- getFlagState: (P) => {
1257
- const u = o.find((M) => M.key === P);
1258
- return u ? u.value ? "enabled" : "disabled" : "not_found";
1306
+ getFlag: (A) => o.find((d) => d.key === A),
1307
+ getFlagState: (A) => {
1308
+ const d = o.find((P) => P.key === A);
1309
+ return d ? d.value ? "enabled" : "disabled" : "not_found";
1259
1310
  },
1260
1311
  refresh: async () => {
1261
- await p();
1312
+ await f();
1262
1313
  }
1263
- }), [o, y, w]);
1264
- return /* @__PURE__ */ n(Ie.Provider, { value: h, children: e });
1314
+ }), [o, b, S]);
1315
+ return /* @__PURE__ */ n(Le.Provider, { value: u, children: e });
1265
1316
  }
1266
- function We() {
1267
- const i = ce(Ie);
1317
+ function Ye() {
1318
+ const i = ce(Le);
1268
1319
  if (!i)
1269
1320
  throw new Error("useFeatureFlags must be used within a FeatureFlagProvider");
1270
1321
  return i;
1271
1322
  }
1272
- class je {
1323
+ class Qe {
1273
1324
  constructor(e, t) {
1274
1325
  this.httpService = e, this.sessionManager = t;
1275
1326
  }
@@ -1335,64 +1386,64 @@ class je {
1335
1386
  )).data;
1336
1387
  }
1337
1388
  }
1338
- const Le = he(void 0);
1339
- function Et({ config: i = {}, children: e }) {
1340
- const { baseUrl: t } = oe(), { tenant: r } = se(), [s, o] = k(null), [g, y] = k(!1), [A, w] = k(null), T = Q(() => {
1341
- const h = new re(t);
1342
- return new je(h);
1343
- }, [t]), f = async () => {
1389
+ const Ee = he(void 0);
1390
+ function Nt({ config: i = {}, children: e }) {
1391
+ const { baseUrl: t } = oe(), { tenant: r } = se(), [s, o] = x(null), [p, b] = x(!1), [k, S] = x(null), T = X(() => {
1392
+ const u = new re(t);
1393
+ return new Qe(u);
1394
+ }, [t]), m = async () => {
1344
1395
  if (!(r != null && r.id)) {
1345
1396
  o(null);
1346
1397
  return;
1347
1398
  }
1348
- y(!0), w(null);
1399
+ b(!0), S(null);
1349
1400
  try {
1350
- const h = await T.getTenantSubscriptionFeatures(r.id);
1351
- o(h);
1352
- } catch (h) {
1353
- const m = h instanceof Error ? h.message : "Failed to fetch subscription";
1354
- w(m), i.onError && i.onError(h instanceof Error ? h : new Error(m));
1401
+ const u = await T.getTenantSubscriptionFeatures(r.id);
1402
+ o(u);
1403
+ } catch (u) {
1404
+ const y = u instanceof Error ? u.message : "Failed to fetch subscription";
1405
+ S(y), i.onError && i.onError(u instanceof Error ? u : new Error(y));
1355
1406
  } finally {
1356
- y(!1);
1407
+ b(!1);
1357
1408
  }
1358
1409
  };
1359
1410
  te(() => {
1360
- if (f(), !i.refreshInterval) return;
1361
- const h = i.refreshInterval || 10 * 60 * 1e3, m = setInterval(f, h);
1362
- return () => clearInterval(m);
1411
+ if (m(), !i.refreshInterval) return;
1412
+ const u = i.refreshInterval || 10 * 60 * 1e3, y = setInterval(m, u);
1413
+ return () => clearInterval(y);
1363
1414
  }, [r == null ? void 0 : r.id, i.refreshInterval]);
1364
- const p = Q(() => {
1365
- const h = (s == null ? void 0 : s.features) || [];
1415
+ const f = X(() => {
1416
+ const u = (s == null ? void 0 : s.features) || [];
1366
1417
  return {
1367
1418
  subscription: s,
1368
- features: h,
1369
- loading: g,
1370
- error: A,
1371
- isFeatureEnabled: (u) => {
1372
- const M = h.find((E) => E.key === u);
1373
- return M ? M.type === "BOOLEAN" || M.type === "boolean" ? M.value === !0 : !!M.value : !1;
1419
+ features: u,
1420
+ loading: p,
1421
+ error: k,
1422
+ isFeatureEnabled: (d) => {
1423
+ const P = u.find((E) => E.key === d);
1424
+ return P ? P.type === "BOOLEAN" || P.type === "boolean" ? P.value === !0 : !!P.value : !1;
1374
1425
  },
1375
- getFeature: (u) => h.find((M) => M.key === u),
1376
- getFeatureValue: (u, M) => {
1377
- const E = h.find((q) => q.key === u);
1378
- return E ? E.value : M;
1426
+ getFeature: (d) => u.find((P) => P.key === d),
1427
+ getFeatureValue: (d, P) => {
1428
+ const E = u.find((z) => z.key === d);
1429
+ return E ? E.value : P;
1379
1430
  },
1380
- hasAllowedPlan: (u) => !s || !s.isActive ? !1 : u.includes(s.planId),
1431
+ hasAllowedPlan: (d) => !s || !s.isActive ? !1 : d.includes(s.planId),
1381
1432
  refresh: async () => {
1382
- await f();
1433
+ await m();
1383
1434
  }
1384
1435
  };
1385
- }, [s, g, A]);
1386
- return /* @__PURE__ */ n(Le.Provider, { value: p, children: e });
1436
+ }, [s, p, k]);
1437
+ return /* @__PURE__ */ n(Ee.Provider, { value: f, children: e });
1387
1438
  }
1388
- function Ve() {
1389
- const i = ce(Le);
1439
+ function Xe() {
1440
+ const i = ce(Ee);
1390
1441
  if (i === void 0)
1391
1442
  throw new Error("useSubscription must be used within a SubscriptionProvider");
1392
1443
  return i;
1393
1444
  }
1394
1445
  var ie = /* @__PURE__ */ ((i) => (i.SUPERUSER = "SUPERUSER", i.TENANT_ADMIN = "TENANT_ADMIN", i.USER = "USER", i))(ie || {});
1395
- const xe = () => /* @__PURE__ */ a(
1446
+ const ke = () => /* @__PURE__ */ l(
1396
1447
  "div",
1397
1448
  {
1398
1449
  style: {
@@ -1429,11 +1480,11 @@ const xe = () => /* @__PURE__ */ a(
1429
1480
  )
1430
1481
  ]
1431
1482
  }
1432
- ), ke = ({
1483
+ ), Te = ({
1433
1484
  userType: i,
1434
1485
  minUserType: e,
1435
1486
  missingPermissions: t
1436
- }) => /* @__PURE__ */ a(
1487
+ }) => /* @__PURE__ */ l(
1437
1488
  "div",
1438
1489
  {
1439
1490
  style: {
@@ -1451,26 +1502,26 @@ const xe = () => /* @__PURE__ */ a(
1451
1502
  children: [
1452
1503
  /* @__PURE__ */ n("div", { style: { fontSize: "2rem", marginBottom: "10px" }, children: "⚠️" }),
1453
1504
  /* @__PURE__ */ n("h3", { style: { color: "#856404", marginBottom: "10px" }, children: "Insufficient Permissions" }),
1454
- e && i ? /* @__PURE__ */ a(B, { children: [
1455
- /* @__PURE__ */ a("p", { style: { color: "#856404", fontSize: "14px", marginBottom: "10px" }, children: [
1505
+ e && i ? /* @__PURE__ */ l(U, { children: [
1506
+ /* @__PURE__ */ l("p", { style: { color: "#856404", fontSize: "14px", marginBottom: "10px" }, children: [
1456
1507
  "This content requires ",
1457
1508
  /* @__PURE__ */ n("strong", { children: e }),
1458
1509
  " access level or higher."
1459
1510
  ] }),
1460
- /* @__PURE__ */ a("p", { style: { color: "#6c757d", fontSize: "12px" }, children: [
1511
+ /* @__PURE__ */ l("p", { style: { color: "#6c757d", fontSize: "12px" }, children: [
1461
1512
  "Your current access level: ",
1462
1513
  /* @__PURE__ */ n("strong", { children: i })
1463
1514
  ] })
1464
- ] }) : /* @__PURE__ */ a(B, { children: [
1515
+ ] }) : /* @__PURE__ */ l(U, { children: [
1465
1516
  /* @__PURE__ */ n("p", { style: { color: "#856404", fontSize: "14px", marginBottom: "10px" }, children: "You don't have the required permissions to view this content." }),
1466
- t && t.length > 0 && /* @__PURE__ */ a("p", { style: { color: "#6c757d", fontSize: "12px" }, children: [
1517
+ t && t.length > 0 && /* @__PURE__ */ l("p", { style: { color: "#6c757d", fontSize: "12px" }, children: [
1467
1518
  "Required permissions: ",
1468
1519
  /* @__PURE__ */ n("strong", { children: t.join(", ") })
1469
1520
  ] })
1470
1521
  ] })
1471
1522
  ]
1472
1523
  }
1473
- ), Ge = (i, e) => {
1524
+ ), Ze = (i, e) => {
1474
1525
  const t = {
1475
1526
  [ie.USER]: 1,
1476
1527
  [ie.TENANT_ADMIN]: 2,
@@ -1478,28 +1529,28 @@ const xe = () => /* @__PURE__ */ a(
1478
1529
  };
1479
1530
  return t[i] >= t[e];
1480
1531
  };
1481
- function Rt({
1532
+ function Bt({
1482
1533
  children: i,
1483
1534
  fallback: e,
1484
1535
  minUserType: t,
1485
1536
  requiredPermissions: r,
1486
1537
  requireAllPermissions: s = !1
1487
1538
  }) {
1488
- const { hasValidSession: o, sessionManager: g, hasPermission: y, hasAnyPermission: A, hasAllPermissions: w } = ae();
1539
+ const { hasValidSession: o, sessionManager: p, hasPermission: b, hasAnyPermission: k, hasAllPermissions: S } = ae();
1489
1540
  if (!o())
1490
- return /* @__PURE__ */ n(B, { children: e || /* @__PURE__ */ n(xe, {}) });
1491
- const T = g.getUser();
1541
+ return /* @__PURE__ */ n(U, { children: e || /* @__PURE__ */ n(ke, {}) });
1542
+ const T = p.getUser();
1492
1543
  if (!T)
1493
- return /* @__PURE__ */ n(B, { children: e || /* @__PURE__ */ n(xe, {}) });
1494
- if (t && !Ge(T.userType, t))
1495
- return /* @__PURE__ */ n(ke, { userType: T.userType, minUserType: t });
1496
- if (r && r.length > 0 && !(s ? w(r) : A(r))) {
1497
- const p = r.filter((h) => !y(h)).map((h) => typeof h == "string" ? h : h.name);
1498
- return /* @__PURE__ */ n(ke, { missingPermissions: p });
1499
- }
1500
- return /* @__PURE__ */ n(B, { children: i });
1544
+ return /* @__PURE__ */ n(U, { children: e || /* @__PURE__ */ n(ke, {}) });
1545
+ if (t && !Ze(T.userType, t))
1546
+ return /* @__PURE__ */ n(Te, { userType: T.userType, minUserType: t });
1547
+ if (r && r.length > 0 && !(s ? S(r) : k(r))) {
1548
+ const f = r.filter((u) => !b(u)).map((u) => typeof u == "string" ? u : u.name);
1549
+ return /* @__PURE__ */ n(Te, { missingPermissions: f });
1550
+ }
1551
+ return /* @__PURE__ */ n(U, { children: i });
1501
1552
  }
1502
- const _e = ({ redirectPath: i }) => /* @__PURE__ */ n(
1553
+ const et = ({ redirectPath: i }) => /* @__PURE__ */ n(
1503
1554
  "div",
1504
1555
  {
1505
1556
  style: {
@@ -1512,7 +1563,7 @@ const _e = ({ redirectPath: i }) => /* @__PURE__ */ n(
1512
1563
  backgroundColor: "#f9fafb",
1513
1564
  textAlign: "center"
1514
1565
  },
1515
- children: /* @__PURE__ */ a(
1566
+ children: /* @__PURE__ */ l(
1516
1567
  "div",
1517
1568
  {
1518
1569
  style: {
@@ -1526,7 +1577,7 @@ const _e = ({ redirectPath: i }) => /* @__PURE__ */ n(
1526
1577
  /* @__PURE__ */ n("div", { style: { fontSize: "3rem", marginBottom: "1rem" }, children: "🔒" }),
1527
1578
  /* @__PURE__ */ n("h2", { style: { color: "#374151", marginBottom: "1rem" }, children: "Access Required" }),
1528
1579
  /* @__PURE__ */ n("p", { style: { color: "#6b7280", marginBottom: "1.5rem" }, children: "You need to be signed in to access this page." }),
1529
- /* @__PURE__ */ a("p", { style: { fontSize: "0.875rem", color: "#9ca3af" }, children: [
1580
+ /* @__PURE__ */ l("p", { style: { fontSize: "0.875rem", color: "#9ca3af" }, children: [
1530
1581
  "Redirecting to ",
1531
1582
  i,
1532
1583
  "..."
@@ -1552,7 +1603,7 @@ const _e = ({ redirectPath: i }) => /* @__PURE__ */ n(
1552
1603
  backgroundColor: "#f9fafb",
1553
1604
  textAlign: "center"
1554
1605
  },
1555
- children: /* @__PURE__ */ a(
1606
+ children: /* @__PURE__ */ l(
1556
1607
  "div",
1557
1608
  {
1558
1609
  style: {
@@ -1565,19 +1616,19 @@ const _e = ({ redirectPath: i }) => /* @__PURE__ */ n(
1565
1616
  children: [
1566
1617
  /* @__PURE__ */ n("div", { style: { fontSize: "3rem", marginBottom: "1rem" }, children: "⚠️" }),
1567
1618
  /* @__PURE__ */ n("h2", { style: { color: "#374151", marginBottom: "1rem" }, children: "Insufficient Permissions" }),
1568
- e && i ? /* @__PURE__ */ a(B, { children: [
1569
- /* @__PURE__ */ a("p", { style: { color: "#6b7280", marginBottom: "1rem" }, children: [
1619
+ e && i ? /* @__PURE__ */ l(U, { children: [
1620
+ /* @__PURE__ */ l("p", { style: { color: "#6b7280", marginBottom: "1rem" }, children: [
1570
1621
  "This page requires ",
1571
1622
  /* @__PURE__ */ n("strong", { children: e }),
1572
1623
  " access level or higher."
1573
1624
  ] }),
1574
- /* @__PURE__ */ a("p", { style: { color: "#9ca3af", fontSize: "0.875rem" }, children: [
1625
+ /* @__PURE__ */ l("p", { style: { color: "#9ca3af", fontSize: "0.875rem" }, children: [
1575
1626
  "Your current access level: ",
1576
1627
  /* @__PURE__ */ n("strong", { children: i })
1577
1628
  ] })
1578
- ] }) : /* @__PURE__ */ a(B, { children: [
1629
+ ] }) : /* @__PURE__ */ l(U, { children: [
1579
1630
  /* @__PURE__ */ n("p", { style: { color: "#6b7280", marginBottom: "1rem" }, children: "You don't have the required permissions to access this page." }),
1580
- t && t.length > 0 && /* @__PURE__ */ a("p", { style: { color: "#9ca3af", fontSize: "0.875rem" }, children: [
1631
+ t && t.length > 0 && /* @__PURE__ */ l("p", { style: { color: "#9ca3af", fontSize: "0.875rem" }, children: [
1581
1632
  "Required permissions: ",
1582
1633
  /* @__PURE__ */ n("strong", { children: t.join(", ") })
1583
1634
  ] })
@@ -1586,7 +1637,7 @@ const _e = ({ redirectPath: i }) => /* @__PURE__ */ n(
1586
1637
  }
1587
1638
  )
1588
1639
  }
1589
- ), Ke = (i, e) => {
1640
+ ), tt = (i, e) => {
1590
1641
  const t = {
1591
1642
  [ie.USER]: 1,
1592
1643
  [ie.TENANT_ADMIN]: 2,
@@ -1594,7 +1645,7 @@ const _e = ({ redirectPath: i }) => /* @__PURE__ */ n(
1594
1645
  };
1595
1646
  return t[i] >= t[e];
1596
1647
  };
1597
- function Ct({
1648
+ function Ut({
1598
1649
  children: i,
1599
1650
  redirectTo: e = "/login",
1600
1651
  minUserType: t,
@@ -1602,24 +1653,24 @@ function Ct({
1602
1653
  requireAllPermissions: s = !1,
1603
1654
  fallback: o
1604
1655
  }) {
1605
- const { hasValidSession: g, sessionManager: y, hasPermission: A, hasAnyPermission: w, hasAllPermissions: T } = ae(), f = we();
1606
- if (!g())
1607
- return o ? /* @__PURE__ */ n(B, { children: o }) : /* @__PURE__ */ a(B, { children: [
1608
- /* @__PURE__ */ n(_e, { redirectPath: e }),
1609
- /* @__PURE__ */ n(pe, { to: e, state: { from: f.pathname }, replace: !0 })
1656
+ const { hasValidSession: p, sessionManager: b, hasPermission: k, hasAnyPermission: S, hasAllPermissions: T } = ae(), m = be();
1657
+ if (!p())
1658
+ return o ? /* @__PURE__ */ n(U, { children: o }) : /* @__PURE__ */ l(U, { children: [
1659
+ /* @__PURE__ */ n(et, { redirectPath: e }),
1660
+ /* @__PURE__ */ n(pe, { to: e, state: { from: m.pathname }, replace: !0 })
1610
1661
  ] });
1611
- const p = y.getUser();
1612
- if (!p)
1613
- return /* @__PURE__ */ n(pe, { to: e, state: { from: f.pathname }, replace: !0 });
1614
- if (t && !Ke(p.userType, t))
1615
- return /* @__PURE__ */ n(Ae, { userType: p.userType, minUserType: t });
1616
- if (r && r.length > 0 && !(s ? T(r) : w(r))) {
1617
- const m = r.filter((R) => !A(R)).map((R) => typeof R == "string" ? R : R.name);
1618
- return /* @__PURE__ */ n(Ae, { missingPermissions: m });
1619
- }
1620
- return /* @__PURE__ */ n(B, { children: i });
1662
+ const f = b.getUser();
1663
+ if (!f)
1664
+ return /* @__PURE__ */ n(pe, { to: e, state: { from: m.pathname }, replace: !0 });
1665
+ if (t && !tt(f.userType, t))
1666
+ return /* @__PURE__ */ n(Ae, { userType: f.userType, minUserType: t });
1667
+ if (r && r.length > 0 && !(s ? T(r) : S(r))) {
1668
+ const y = r.filter((R) => !k(R)).map((R) => typeof R == "string" ? R : R.name);
1669
+ return /* @__PURE__ */ n(Ae, { missingPermissions: y });
1670
+ }
1671
+ return /* @__PURE__ */ n(U, { children: i });
1621
1672
  }
1622
- const Je = ({ redirectPath: i }) => /* @__PURE__ */ n(
1673
+ const rt = ({ redirectPath: i }) => /* @__PURE__ */ n(
1623
1674
  "div",
1624
1675
  {
1625
1676
  style: {
@@ -1632,7 +1683,7 @@ const Je = ({ redirectPath: i }) => /* @__PURE__ */ n(
1632
1683
  backgroundColor: "#f9fafb",
1633
1684
  textAlign: "center"
1634
1685
  },
1635
- children: /* @__PURE__ */ a(
1686
+ children: /* @__PURE__ */ l(
1636
1687
  "div",
1637
1688
  {
1638
1689
  style: {
@@ -1646,7 +1697,7 @@ const Je = ({ redirectPath: i }) => /* @__PURE__ */ n(
1646
1697
  /* @__PURE__ */ n("div", { style: { fontSize: "3rem", marginBottom: "1rem" }, children: "🏢" }),
1647
1698
  /* @__PURE__ */ n("h2", { style: { color: "#374151", marginBottom: "1rem" }, children: "Tenant Required" }),
1648
1699
  /* @__PURE__ */ n("p", { style: { color: "#6b7280", marginBottom: "1.5rem" }, children: "This page requires a tenant context to access." }),
1649
- /* @__PURE__ */ a("p", { style: { fontSize: "0.875rem", color: "#9ca3af" }, children: [
1700
+ /* @__PURE__ */ l("p", { style: { fontSize: "0.875rem", color: "#9ca3af" }, children: [
1650
1701
  "Redirecting to ",
1651
1702
  i,
1652
1703
  "..."
@@ -1656,14 +1707,14 @@ const Je = ({ redirectPath: i }) => /* @__PURE__ */ n(
1656
1707
  )
1657
1708
  }
1658
1709
  );
1659
- function $t({ children: i, redirectTo: e = "/", fallback: t }) {
1660
- const { tenant: r, isLoading: s, error: o } = se(), g = we();
1661
- return s || o ? null : r ? /* @__PURE__ */ n(B, { children: i }) : t ? /* @__PURE__ */ n(B, { children: t }) : /* @__PURE__ */ a(B, { children: [
1662
- /* @__PURE__ */ n(Je, { redirectPath: e }),
1663
- /* @__PURE__ */ n(pe, { to: e, state: { from: g.pathname }, replace: !0 })
1710
+ function qt({ children: i, redirectTo: e = "/", fallback: t }) {
1711
+ const { tenant: r, isLoading: s, error: o } = se(), p = be();
1712
+ return s || o ? null : r ? /* @__PURE__ */ n(U, { children: i }) : t ? /* @__PURE__ */ n(U, { children: t }) : /* @__PURE__ */ l(U, { children: [
1713
+ /* @__PURE__ */ n(rt, { redirectPath: e }),
1714
+ /* @__PURE__ */ n(pe, { to: e, state: { from: p.pathname }, replace: !0 })
1664
1715
  ] });
1665
1716
  }
1666
- const Ye = ({ redirectPath: i }) => /* @__PURE__ */ n(
1717
+ const nt = ({ redirectPath: i }) => /* @__PURE__ */ n(
1667
1718
  "div",
1668
1719
  {
1669
1720
  style: {
@@ -1676,7 +1727,7 @@ const Ye = ({ redirectPath: i }) => /* @__PURE__ */ n(
1676
1727
  backgroundColor: "#f9fafb",
1677
1728
  textAlign: "center"
1678
1729
  },
1679
- children: /* @__PURE__ */ a(
1730
+ children: /* @__PURE__ */ l(
1680
1731
  "div",
1681
1732
  {
1682
1733
  style: {
@@ -1690,7 +1741,7 @@ const Ye = ({ redirectPath: i }) => /* @__PURE__ */ n(
1690
1741
  /* @__PURE__ */ n("div", { style: { fontSize: "3rem", marginBottom: "1rem" }, children: "🚀" }),
1691
1742
  /* @__PURE__ */ n("h2", { style: { color: "#374151", marginBottom: "1rem" }, children: "Tenant Detected" }),
1692
1743
  /* @__PURE__ */ n("p", { style: { color: "#6b7280", marginBottom: "1.5rem" }, children: "You are accessing a tenant-specific context. Redirecting to the appropriate page." }),
1693
- /* @__PURE__ */ a("p", { style: { fontSize: "0.875rem", color: "#9ca3af" }, children: [
1744
+ /* @__PURE__ */ l("p", { style: { fontSize: "0.875rem", color: "#9ca3af" }, children: [
1694
1745
  "Redirecting to ",
1695
1746
  i,
1696
1747
  "..."
@@ -1700,14 +1751,14 @@ const Ye = ({ redirectPath: i }) => /* @__PURE__ */ n(
1700
1751
  )
1701
1752
  }
1702
1753
  );
1703
- function Ft({ children: i, redirectTo: e = "/dashboard", fallback: t }) {
1704
- const { tenant: r, isLoading: s, error: o } = se(), g = we();
1705
- return s || o ? null : r ? t ? /* @__PURE__ */ n(B, { children: t }) : /* @__PURE__ */ a(B, { children: [
1706
- /* @__PURE__ */ n(Ye, { redirectPath: e }),
1707
- /* @__PURE__ */ n(pe, { to: e, state: { from: g.pathname }, replace: !0 })
1708
- ] }) : /* @__PURE__ */ n(B, { children: i });
1754
+ function zt({ children: i, redirectTo: e = "/dashboard", fallback: t }) {
1755
+ const { tenant: r, isLoading: s, error: o } = se(), p = be();
1756
+ return s || o ? null : r ? t ? /* @__PURE__ */ n(U, { children: t }) : /* @__PURE__ */ l(U, { children: [
1757
+ /* @__PURE__ */ n(nt, { redirectPath: e }),
1758
+ /* @__PURE__ */ n(pe, { to: e, state: { from: p.pathname }, replace: !0 })
1759
+ ] }) : /* @__PURE__ */ n(U, { children: i });
1709
1760
  }
1710
- const Qe = () => /* @__PURE__ */ a(
1761
+ const st = () => /* @__PURE__ */ l(
1711
1762
  "div",
1712
1763
  {
1713
1764
  style: {
@@ -1724,14 +1775,14 @@ const Qe = () => /* @__PURE__ */ a(
1724
1775
  ]
1725
1776
  }
1726
1777
  );
1727
- function Dt({
1778
+ function Ot({
1728
1779
  children: i,
1729
- fallback: e = /* @__PURE__ */ n(Qe, {}),
1780
+ fallback: e = /* @__PURE__ */ n(st, {}),
1730
1781
  allowedPlans: t,
1731
1782
  requiredFeature: r
1732
1783
  }) {
1733
- const { subscription: s, hasAllowedPlan: o, isFeatureEnabled: g, loading: y } = Ve();
1734
- return y ? /* @__PURE__ */ n(
1784
+ const { subscription: s, hasAllowedPlan: o, isFeatureEnabled: p, loading: b } = Xe();
1785
+ return b ? /* @__PURE__ */ n(
1735
1786
  "div",
1736
1787
  {
1737
1788
  style: {
@@ -1741,9 +1792,9 @@ function Dt({
1741
1792
  },
1742
1793
  children: "Loading subscription..."
1743
1794
  }
1744
- ) : s ? s.isActive ? t && t.length > 0 && !o(t) ? /* @__PURE__ */ n(B, { children: e }) : r && !g(r) ? /* @__PURE__ */ n(B, { children: e }) : /* @__PURE__ */ n(B, { children: i }) : /* @__PURE__ */ n(B, { children: e }) : /* @__PURE__ */ n(B, { children: e });
1795
+ ) : s ? s.isActive ? t && t.length > 0 && !o(t) ? /* @__PURE__ */ n(U, { children: e }) : r && !p(r) ? /* @__PURE__ */ n(U, { children: e }) : /* @__PURE__ */ n(U, { children: i }) : /* @__PURE__ */ n(U, { children: e }) : /* @__PURE__ */ n(U, { children: e });
1745
1796
  }
1746
- const Xe = ({ flagName: i }) => /* @__PURE__ */ a(
1797
+ const it = ({ flagName: i }) => /* @__PURE__ */ l(
1747
1798
  "div",
1748
1799
  {
1749
1800
  style: {
@@ -1762,7 +1813,7 @@ const Xe = ({ flagName: i }) => /* @__PURE__ */ a(
1762
1813
  children: [
1763
1814
  /* @__PURE__ */ n("div", { style: { fontSize: "24px", marginBottom: "8px" }, children: "🚧" }),
1764
1815
  /* @__PURE__ */ n("div", { style: { fontSize: "14px", fontWeight: "500", marginBottom: "4px" }, children: "Feature Not Available" }),
1765
- /* @__PURE__ */ a("div", { style: { fontSize: "12px", opacity: 0.7 }, children: [
1816
+ /* @__PURE__ */ l("div", { style: { fontSize: "12px", opacity: 0.7 }, children: [
1766
1817
  'Feature flag "',
1767
1818
  i,
1768
1819
  '" is disabled'
@@ -1770,8 +1821,8 @@ const Xe = ({ flagName: i }) => /* @__PURE__ */ a(
1770
1821
  ]
1771
1822
  }
1772
1823
  );
1773
- function Ht({ name: i, children: e, fallback: t }) {
1774
- const { isEnabled: r, loading: s } = We();
1824
+ function Wt({ name: i, children: e, fallback: t }) {
1825
+ const { isEnabled: r, loading: s } = Ye();
1775
1826
  return s ? /* @__PURE__ */ n(
1776
1827
  "div",
1777
1828
  {
@@ -1785,9 +1836,9 @@ function Ht({ name: i, children: e, fallback: t }) {
1785
1836
  },
1786
1837
  children: "Loading feature flags..."
1787
1838
  }
1788
- ) : r(i) ? /* @__PURE__ */ n(B, { children: e }) : /* @__PURE__ */ n(B, { children: t || /* @__PURE__ */ n(Xe, { flagName: i }) });
1839
+ ) : r(i) ? /* @__PURE__ */ n(U, { children: e }) : /* @__PURE__ */ n(U, { children: t || /* @__PURE__ */ n(it, { flagName: i }) });
1789
1840
  }
1790
- const Ze = () => /* @__PURE__ */ a(
1841
+ const ot = () => /* @__PURE__ */ l(
1791
1842
  "svg",
1792
1843
  {
1793
1844
  width: "16",
@@ -1804,7 +1855,7 @@ const Ze = () => /* @__PURE__ */ a(
1804
1855
  /* @__PURE__ */ n("circle", { cx: "12", cy: "12", r: "3" })
1805
1856
  ]
1806
1857
  }
1807
- ), et = () => /* @__PURE__ */ a(
1858
+ ), at = () => /* @__PURE__ */ l(
1808
1859
  "svg",
1809
1860
  {
1810
1861
  width: "16",
@@ -1821,10 +1872,10 @@ const Ze = () => /* @__PURE__ */ a(
1821
1872
  /* @__PURE__ */ n("line", { x1: "1", y1: "1", x2: "23", y2: "23" })
1822
1873
  ]
1823
1874
  }
1824
- ), tt = {
1825
- showPassword: /* @__PURE__ */ n(Ze, {}),
1826
- hidePassword: /* @__PURE__ */ n(et, {})
1827
- }, rt = {
1875
+ ), lt = {
1876
+ showPassword: /* @__PURE__ */ n(ot, {}),
1877
+ hidePassword: /* @__PURE__ */ n(at, {})
1878
+ }, ct = {
1828
1879
  title: "Sign In",
1829
1880
  usernameLabel: "Email or Phone",
1830
1881
  usernamePlaceholder: "Enter your email or phone number",
@@ -1838,7 +1889,7 @@ const Ze = () => /* @__PURE__ */ a(
1838
1889
  magicLinkLink: "Use Magic Link",
1839
1890
  errorMessage: "Invalid credentials",
1840
1891
  loadingText: "Signing in..."
1841
- }, nt = {
1892
+ }, dt = {
1842
1893
  container: {
1843
1894
  maxWidth: "400px",
1844
1895
  width: "100%",
@@ -1945,133 +1996,133 @@ const Ze = () => /* @__PURE__ */ a(
1945
1996
  fontSize: "0.875rem"
1946
1997
  }
1947
1998
  };
1948
- function Nt({
1999
+ function jt({
1949
2000
  copy: i = {},
1950
2001
  styles: e = {},
1951
2002
  icons: t = {},
1952
2003
  onSuccess: r,
1953
2004
  onError: s,
1954
2005
  onForgotPassword: o,
1955
- onSignupClick: g,
1956
- onMagicLinkClick: y,
1957
- showForgotPassword: A = !0,
1958
- showSignupLink: w = !0,
2006
+ onSignupClick: p,
2007
+ onMagicLinkClick: b,
2008
+ showForgotPassword: k = !0,
2009
+ showSignupLink: S = !0,
1959
2010
  showMagicLinkOption: T = !0,
1960
- className: f
2011
+ className: m
1961
2012
  }) {
1962
- const [p, h] = k(""), [m, R] = k(""), [C, U] = k(!1), [P, u] = k(!1), [M, E] = k(""), [q, V] = k({}), { login: $ } = ae(), { tenant: j } = se(), v = { ...rt, ...i }, I = { ...nt, ...e }, L = { ...tt, ...t }, l = () => {
1963
- const c = {};
1964
- return p.trim() || (c.username = !0), m.trim() || (c.password = !0), V(c), Object.keys(c).length === 0;
1965
- }, x = async (c) => {
1966
- if (c.preventDefault(), !!l()) {
1967
- if (!(j != null && j.id)) {
2013
+ const [f, u] = x(""), [y, R] = x(""), [C, q] = x(!1), [A, d] = x(!1), [P, E] = x(""), [z, G] = x({}), { login: $ } = ae(), { tenant: _ } = se(), v = { ...ct, ...i }, M = { ...dt, ...e }, I = { ...lt, ...t }, a = () => {
2014
+ const g = {};
2015
+ return f.trim() || (g.username = !0), y.trim() || (g.password = !0), G(g), Object.keys(g).length === 0;
2016
+ }, L = async (g) => {
2017
+ if (g.preventDefault(), !!a()) {
2018
+ if (!(_ != null && _.id)) {
1968
2019
  E("Tenant not found");
1969
2020
  return;
1970
2021
  }
1971
- u(!0), E("");
2022
+ d(!0), E("");
1972
2023
  try {
1973
- const S = await $({
1974
- username: p,
1975
- password: m
2024
+ const w = await $({
2025
+ username: f,
2026
+ password: y
1976
2027
  // tenantId inferred from context automatically
1977
2028
  });
1978
- r == null || r(S);
1979
- } catch (S) {
1980
- const _ = S.message || v.errorMessage;
1981
- E(_), s == null || s(_);
2029
+ r == null || r(w);
2030
+ } catch (w) {
2031
+ const j = w.message || v.errorMessage;
2032
+ E(j), s == null || s(j);
1982
2033
  } finally {
1983
- u(!1);
2034
+ d(!1);
1984
2035
  }
1985
2036
  }
1986
- }, b = (c) => ({
1987
- ...I.input,
1988
- ...q[c] ? I.inputError : {}
1989
- }), d = () => ({
1990
- ...I.button,
1991
- ...P ? I.buttonLoading : {},
1992
- ...!p || !m || P ? I.buttonDisabled : {}
2037
+ }, c = (g) => ({
2038
+ ...M.input,
2039
+ ...z[g] ? M.inputError : {}
2040
+ }), h = () => ({
2041
+ ...M.button,
2042
+ ...A ? M.buttonLoading : {},
2043
+ ...!f || !y || A ? M.buttonDisabled : {}
1993
2044
  });
1994
- return /* @__PURE__ */ a("div", { className: f, style: I.container, children: [
1995
- /* @__PURE__ */ n("h2", { style: I.title, children: v.title }),
1996
- /* @__PURE__ */ a("form", { onSubmit: x, style: I.form, children: [
1997
- /* @__PURE__ */ a("div", { style: I.fieldGroup, children: [
1998
- /* @__PURE__ */ n("label", { style: I.label, children: v.usernameLabel }),
2045
+ return /* @__PURE__ */ l("div", { className: m, style: M.container, children: [
2046
+ /* @__PURE__ */ n("h2", { style: M.title, children: v.title }),
2047
+ /* @__PURE__ */ l("form", { onSubmit: L, style: M.form, children: [
2048
+ /* @__PURE__ */ l("div", { style: M.fieldGroup, children: [
2049
+ /* @__PURE__ */ n("label", { style: M.label, children: v.usernameLabel }),
1999
2050
  /* @__PURE__ */ n(
2000
2051
  "input",
2001
2052
  {
2002
2053
  id: "username",
2003
2054
  name: "username",
2004
2055
  type: "text",
2005
- value: p,
2006
- onChange: (c) => {
2007
- h(c.target.value), q.username && V((S) => ({ ...S, username: !1 }));
2056
+ value: f,
2057
+ onChange: (g) => {
2058
+ u(g.target.value), z.username && G((w) => ({ ...w, username: !1 }));
2008
2059
  },
2009
2060
  placeholder: v.usernamePlaceholder,
2010
- style: b("username"),
2011
- disabled: P
2061
+ style: c("username"),
2062
+ disabled: A
2012
2063
  }
2013
2064
  )
2014
2065
  ] }),
2015
- /* @__PURE__ */ a("div", { style: I.fieldGroup, children: [
2016
- /* @__PURE__ */ n("label", { style: I.label, children: v.passwordLabel }),
2017
- /* @__PURE__ */ a("div", { style: I.inputContainer, children: [
2066
+ /* @__PURE__ */ l("div", { style: M.fieldGroup, children: [
2067
+ /* @__PURE__ */ n("label", { style: M.label, children: v.passwordLabel }),
2068
+ /* @__PURE__ */ l("div", { style: M.inputContainer, children: [
2018
2069
  /* @__PURE__ */ n(
2019
2070
  "input",
2020
2071
  {
2021
2072
  id: "password",
2022
2073
  name: "password",
2023
2074
  type: C ? "text" : "password",
2024
- value: m,
2025
- onChange: (c) => {
2026
- R(c.target.value), q.password && V((S) => ({ ...S, password: !1 }));
2075
+ value: y,
2076
+ onChange: (g) => {
2077
+ R(g.target.value), z.password && G((w) => ({ ...w, password: !1 }));
2027
2078
  },
2028
2079
  placeholder: v.passwordPlaceholder,
2029
2080
  style: {
2030
- ...b("password"),
2081
+ ...c("password"),
2031
2082
  paddingRight: "2.5rem"
2032
2083
  // Make room for the icon
2033
2084
  },
2034
- disabled: P
2085
+ disabled: A
2035
2086
  }
2036
2087
  ),
2037
2088
  /* @__PURE__ */ n(
2038
2089
  "button",
2039
2090
  {
2040
2091
  type: "button",
2041
- onClick: () => U(!C),
2042
- style: I.passwordToggle,
2043
- disabled: P,
2092
+ onClick: () => q(!C),
2093
+ style: M.passwordToggle,
2094
+ disabled: A,
2044
2095
  "aria-label": C ? "Hide password" : "Show password",
2045
- children: C ? L.hidePassword : L.showPassword
2096
+ children: C ? I.hidePassword : I.showPassword
2046
2097
  }
2047
2098
  )
2048
2099
  ] })
2049
2100
  ] }),
2050
- /* @__PURE__ */ n("button", { type: "submit", disabled: !p || !m || P, style: d(), children: P ? v.loadingText : v.submitButton }),
2051
- M && /* @__PURE__ */ n("div", { style: I.errorText, children: M })
2101
+ /* @__PURE__ */ n("button", { type: "submit", disabled: !f || !y || A, style: h(), children: A ? v.loadingText : v.submitButton }),
2102
+ P && /* @__PURE__ */ n("div", { style: M.errorText, children: P })
2052
2103
  ] }),
2053
- (A || w || T) && /* @__PURE__ */ a("div", { style: I.linkContainer, children: [
2054
- T && /* @__PURE__ */ a("div", { children: [
2055
- /* @__PURE__ */ a("span", { style: I.divider, children: [
2104
+ (k || S || T) && /* @__PURE__ */ l("div", { style: M.linkContainer, children: [
2105
+ T && /* @__PURE__ */ l("div", { children: [
2106
+ /* @__PURE__ */ l("span", { style: M.divider, children: [
2056
2107
  v.magicLinkText,
2057
2108
  " "
2058
2109
  ] }),
2059
- /* @__PURE__ */ n("a", { onClick: y, style: I.link, children: v.magicLinkLink })
2110
+ /* @__PURE__ */ n("a", { onClick: b, style: M.link, children: v.magicLinkLink })
2060
2111
  ] }),
2061
- T && (A || w) && /* @__PURE__ */ n("div", { style: I.divider, children: "•" }),
2062
- A && /* @__PURE__ */ n("a", { onClick: o, style: I.link, children: v.forgotPasswordLink }),
2063
- A && w && /* @__PURE__ */ n("div", { style: I.divider, children: "•" }),
2064
- w && /* @__PURE__ */ a("div", { children: [
2065
- /* @__PURE__ */ a("span", { style: I.divider, children: [
2112
+ T && (k || S) && /* @__PURE__ */ n("div", { style: M.divider, children: "•" }),
2113
+ k && /* @__PURE__ */ n("a", { onClick: o, style: M.link, children: v.forgotPasswordLink }),
2114
+ k && S && /* @__PURE__ */ n("div", { style: M.divider, children: "•" }),
2115
+ S && /* @__PURE__ */ l("div", { children: [
2116
+ /* @__PURE__ */ l("span", { style: M.divider, children: [
2066
2117
  v.signupText,
2067
2118
  " "
2068
2119
  ] }),
2069
- /* @__PURE__ */ n("a", { onClick: g, style: I.link, children: v.signupLink })
2120
+ /* @__PURE__ */ n("a", { onClick: p, style: M.link, children: v.signupLink })
2070
2121
  ] })
2071
2122
  ] })
2072
2123
  ] });
2073
2124
  }
2074
- const st = {
2125
+ const ut = {
2075
2126
  title: "Create Account",
2076
2127
  nameLabel: "First Name",
2077
2128
  namePlaceholder: "Enter your first name",
@@ -2097,7 +2148,7 @@ const st = {
2097
2148
  passwordMismatchError: "Passwords do not match",
2098
2149
  isAdminLabel: "Create new organization",
2099
2150
  isAdminDescription: "Check this if you want to create a new organization"
2100
- }, it = {
2151
+ }, ht = {
2101
2152
  container: {
2102
2153
  maxWidth: "400px",
2103
2154
  width: "100%",
@@ -2196,69 +2247,69 @@ const st = {
2196
2247
  fontSize: "0.875rem"
2197
2248
  }
2198
2249
  };
2199
- function Bt({
2250
+ function Vt({
2200
2251
  copy: i = {},
2201
2252
  styles: e = {},
2202
2253
  signupType: t = "user",
2203
2254
  onSuccess: r,
2204
2255
  onError: s,
2205
2256
  onLoginClick: o,
2206
- onMagicLinkClick: g,
2207
- showLoginLink: y = !0,
2208
- showMagicLinkOption: A = !0,
2209
- className: w
2257
+ onMagicLinkClick: p,
2258
+ showLoginLink: b = !0,
2259
+ showMagicLinkOption: k = !0,
2260
+ className: S
2210
2261
  }) {
2211
- const [T, f] = k(""), [p, h] = k(""), [m, R] = k(""), [C, U] = k(""), [P, u] = k(""), [M, E] = k(""), [q, V] = k(""), [$, j] = k(!1), [v, I] = k(""), [L, l] = k({}), { signup: x, signupTenantAdmin: b } = ae(), { tenant: d } = se(), c = { ...st, ...i }, S = { ...it, ...e }, _ = () => {
2212
- const D = {};
2213
- return T.trim() || (D.name = !0), !m.trim() && !C.trim() && (D.email = !0, D.phoneNumber = !0), P.trim() || (D.password = !0), M.trim() || (D.confirmPassword = !0), t === "tenant" && !q.trim() && (D.tenantName = !0), l(D), Object.keys(D).length === 0;
2214
- }, ee = async (D) => {
2215
- if (D.preventDefault(), !!_()) {
2216
- if (P !== M) {
2217
- I(c.passwordMismatchError), l({ confirmPassword: !0 });
2262
+ const [T, m] = x(""), [f, u] = x(""), [y, R] = x(""), [C, q] = x(""), [A, d] = x(""), [P, E] = x(""), [z, G] = x(""), [$, _] = x(!1), [v, M] = x(""), [I, a] = x({}), { signup: L, signupTenantAdmin: c } = ae(), { tenant: h } = se(), g = { ...ut, ...i }, w = { ...ht, ...e }, j = () => {
2263
+ const F = {};
2264
+ return T.trim() || (F.name = !0), !y.trim() && !C.trim() && (F.email = !0, F.phoneNumber = !0), A.trim() || (F.password = !0), P.trim() || (F.confirmPassword = !0), t === "tenant" && !z.trim() && (F.tenantName = !0), a(F), Object.keys(F).length === 0;
2265
+ }, Y = async (F) => {
2266
+ if (F.preventDefault(), !!j()) {
2267
+ if (A !== P) {
2268
+ M(g.passwordMismatchError), a({ confirmPassword: !0 });
2218
2269
  return;
2219
2270
  }
2220
- if (t === "user" && !(d != null && d.id)) {
2221
- I("Tenant not found");
2271
+ if (t === "user" && !(h != null && h.id)) {
2272
+ M("Tenant not found");
2222
2273
  return;
2223
2274
  }
2224
- j(!0), I("");
2275
+ _(!0), M("");
2225
2276
  try {
2226
2277
  let K;
2227
- t === "tenant" ? K = await b({
2228
- email: m || void 0,
2278
+ t === "tenant" ? K = await c({
2279
+ email: y || void 0,
2229
2280
  phoneNumber: C || void 0,
2230
2281
  name: T,
2231
- password: P,
2232
- tenantName: q,
2233
- lastName: p || void 0
2234
- }) : K = await x({
2235
- email: m || void 0,
2282
+ password: A,
2283
+ tenantName: z,
2284
+ lastName: f || void 0
2285
+ }) : K = await L({
2286
+ email: y || void 0,
2236
2287
  phoneNumber: C || void 0,
2237
2288
  name: T,
2238
- password: P,
2239
- tenantId: d.id,
2240
- lastName: p || void 0
2289
+ password: A,
2290
+ tenantId: h.id,
2291
+ lastName: f || void 0
2241
2292
  }), r == null || r(K);
2242
2293
  } catch (K) {
2243
- const ge = K.message || c.errorMessage;
2244
- I(ge), s == null || s(ge);
2294
+ const ge = K.message || g.errorMessage;
2295
+ M(ge), s == null || s(ge);
2245
2296
  } finally {
2246
- j(!1);
2297
+ _(!1);
2247
2298
  }
2248
2299
  }
2249
- }, z = (D) => ({
2250
- ...S.input,
2251
- ...L[D] ? S.inputError : {}
2252
- }), H = () => ({
2253
- ...S.button,
2254
- ...$ ? S.buttonLoading : {},
2255
- ...!T || !m && !C || !P || !M || $ || t === "tenant" && !q ? S.buttonDisabled : {}
2256
- }), O = T && (m || C) && P && M && (t === "user" || q);
2257
- return /* @__PURE__ */ a("div", { className: w, style: S.container, children: [
2258
- /* @__PURE__ */ n("h2", { style: S.title, children: c.title }),
2259
- /* @__PURE__ */ a("form", { onSubmit: ee, style: S.form, children: [
2260
- /* @__PURE__ */ a("div", { style: S.fieldGroup, children: [
2261
- /* @__PURE__ */ n("label", { style: S.label, children: c.nameLabel }),
2300
+ }, H = (F) => ({
2301
+ ...w.input,
2302
+ ...I[F] ? w.inputError : {}
2303
+ }), N = () => ({
2304
+ ...w.button,
2305
+ ...$ ? w.buttonLoading : {},
2306
+ ...!T || !y && !C || !A || !P || $ || t === "tenant" && !z ? w.buttonDisabled : {}
2307
+ }), O = T && (y || C) && A && P && (t === "user" || z);
2308
+ return /* @__PURE__ */ l("div", { className: S, style: w.container, children: [
2309
+ /* @__PURE__ */ n("h2", { style: w.title, children: g.title }),
2310
+ /* @__PURE__ */ l("form", { onSubmit: Y, style: w.form, children: [
2311
+ /* @__PURE__ */ l("div", { style: w.fieldGroup, children: [
2312
+ /* @__PURE__ */ n("label", { style: w.label, children: g.nameLabel }),
2262
2313
  /* @__PURE__ */ n(
2263
2314
  "input",
2264
2315
  {
@@ -2266,51 +2317,51 @@ function Bt({
2266
2317
  name: "name",
2267
2318
  type: "text",
2268
2319
  value: T,
2269
- onChange: (D) => {
2270
- f(D.target.value), L.name && l((K) => ({ ...K, name: !1 }));
2320
+ onChange: (F) => {
2321
+ m(F.target.value), I.name && a((K) => ({ ...K, name: !1 }));
2271
2322
  },
2272
- placeholder: c.namePlaceholder,
2273
- style: z("name"),
2323
+ placeholder: g.namePlaceholder,
2324
+ style: H("name"),
2274
2325
  disabled: $
2275
2326
  }
2276
2327
  )
2277
2328
  ] }),
2278
- /* @__PURE__ */ a("div", { style: S.fieldGroup, children: [
2279
- /* @__PURE__ */ n("label", { style: S.label, children: c.lastNameLabel }),
2329
+ /* @__PURE__ */ l("div", { style: w.fieldGroup, children: [
2330
+ /* @__PURE__ */ n("label", { style: w.label, children: g.lastNameLabel }),
2280
2331
  /* @__PURE__ */ n(
2281
2332
  "input",
2282
2333
  {
2283
2334
  id: "lastName",
2284
2335
  name: "lastName",
2285
2336
  type: "text",
2286
- value: p,
2287
- onChange: (D) => h(D.target.value),
2288
- placeholder: c.lastNamePlaceholder,
2289
- style: S.input,
2337
+ value: f,
2338
+ onChange: (F) => u(F.target.value),
2339
+ placeholder: g.lastNamePlaceholder,
2340
+ style: w.input,
2290
2341
  disabled: $
2291
2342
  }
2292
2343
  )
2293
2344
  ] }),
2294
- /* @__PURE__ */ a("div", { style: S.fieldGroup, children: [
2295
- /* @__PURE__ */ n("label", { style: S.label, children: c.emailLabel }),
2345
+ /* @__PURE__ */ l("div", { style: w.fieldGroup, children: [
2346
+ /* @__PURE__ */ n("label", { style: w.label, children: g.emailLabel }),
2296
2347
  /* @__PURE__ */ n(
2297
2348
  "input",
2298
2349
  {
2299
2350
  id: "email",
2300
2351
  name: "email",
2301
2352
  type: "email",
2302
- value: m,
2303
- onChange: (D) => {
2304
- R(D.target.value), L.email && l((K) => ({ ...K, email: !1, phoneNumber: !1 }));
2353
+ value: y,
2354
+ onChange: (F) => {
2355
+ R(F.target.value), I.email && a((K) => ({ ...K, email: !1, phoneNumber: !1 }));
2305
2356
  },
2306
- placeholder: c.emailPlaceholder,
2307
- style: z("email"),
2357
+ placeholder: g.emailPlaceholder,
2358
+ style: H("email"),
2308
2359
  disabled: $
2309
2360
  }
2310
2361
  )
2311
2362
  ] }),
2312
- /* @__PURE__ */ a("div", { style: S.fieldGroup, children: [
2313
- /* @__PURE__ */ n("label", { style: S.label, children: c.phoneNumberLabel }),
2363
+ /* @__PURE__ */ l("div", { style: w.fieldGroup, children: [
2364
+ /* @__PURE__ */ n("label", { style: w.label, children: g.phoneNumberLabel }),
2314
2365
  /* @__PURE__ */ n(
2315
2366
  "input",
2316
2367
  {
@@ -2318,11 +2369,11 @@ function Bt({
2318
2369
  name: "phoneNumber",
2319
2370
  type: "tel",
2320
2371
  value: C,
2321
- onChange: (D) => {
2322
- U(D.target.value), L.phoneNumber && l((K) => ({ ...K, email: !1, phoneNumber: !1 }));
2372
+ onChange: (F) => {
2373
+ q(F.target.value), I.phoneNumber && a((K) => ({ ...K, email: !1, phoneNumber: !1 }));
2323
2374
  },
2324
- placeholder: c.phoneNumberPlaceholder,
2325
- style: z("phoneNumber"),
2375
+ placeholder: g.phoneNumberPlaceholder,
2376
+ style: H("phoneNumber"),
2326
2377
  disabled: $
2327
2378
  }
2328
2379
  )
@@ -2339,83 +2390,83 @@ function Bt({
2339
2390
  children: "At least one contact method (email or phone) is required"
2340
2391
  }
2341
2392
  ),
2342
- /* @__PURE__ */ a("div", { style: S.fieldGroup, children: [
2343
- /* @__PURE__ */ n("label", { style: S.label, children: c.passwordLabel }),
2393
+ /* @__PURE__ */ l("div", { style: w.fieldGroup, children: [
2394
+ /* @__PURE__ */ n("label", { style: w.label, children: g.passwordLabel }),
2344
2395
  /* @__PURE__ */ n(
2345
2396
  "input",
2346
2397
  {
2347
2398
  id: "password",
2348
2399
  name: "password",
2349
2400
  type: "password",
2350
- value: P,
2351
- onChange: (D) => {
2352
- u(D.target.value), L.password && l((K) => ({ ...K, password: !1 }));
2401
+ value: A,
2402
+ onChange: (F) => {
2403
+ d(F.target.value), I.password && a((K) => ({ ...K, password: !1 }));
2353
2404
  },
2354
- placeholder: c.passwordPlaceholder,
2355
- style: z("password"),
2405
+ placeholder: g.passwordPlaceholder,
2406
+ style: H("password"),
2356
2407
  disabled: $
2357
2408
  }
2358
2409
  )
2359
2410
  ] }),
2360
- /* @__PURE__ */ a("div", { style: S.fieldGroup, children: [
2361
- /* @__PURE__ */ n("label", { style: S.label, children: c.confirmPasswordLabel }),
2411
+ /* @__PURE__ */ l("div", { style: w.fieldGroup, children: [
2412
+ /* @__PURE__ */ n("label", { style: w.label, children: g.confirmPasswordLabel }),
2362
2413
  /* @__PURE__ */ n(
2363
2414
  "input",
2364
2415
  {
2365
2416
  id: "confirmPassword",
2366
2417
  name: "confirmPassword",
2367
2418
  type: "password",
2368
- value: M,
2369
- onChange: (D) => {
2370
- E(D.target.value), L.confirmPassword && l((K) => ({ ...K, confirmPassword: !1 })), v === c.passwordMismatchError && I("");
2419
+ value: P,
2420
+ onChange: (F) => {
2421
+ E(F.target.value), I.confirmPassword && a((K) => ({ ...K, confirmPassword: !1 })), v === g.passwordMismatchError && M("");
2371
2422
  },
2372
- placeholder: c.confirmPasswordPlaceholder,
2373
- style: z("confirmPassword"),
2423
+ placeholder: g.confirmPasswordPlaceholder,
2424
+ style: H("confirmPassword"),
2374
2425
  disabled: $
2375
2426
  }
2376
2427
  )
2377
2428
  ] }),
2378
- t === "tenant" && /* @__PURE__ */ a("div", { style: S.fieldGroup, children: [
2379
- /* @__PURE__ */ n("label", { style: S.label, children: c.tenantNameLabel }),
2429
+ t === "tenant" && /* @__PURE__ */ l("div", { style: w.fieldGroup, children: [
2430
+ /* @__PURE__ */ n("label", { style: w.label, children: g.tenantNameLabel }),
2380
2431
  /* @__PURE__ */ n(
2381
2432
  "input",
2382
2433
  {
2383
2434
  id: "tenantName",
2384
2435
  name: "tenantName",
2385
2436
  type: "text",
2386
- value: q,
2387
- onChange: (D) => {
2388
- V(D.target.value), L.tenantName && l((K) => ({ ...K, tenantName: !1 }));
2437
+ value: z,
2438
+ onChange: (F) => {
2439
+ G(F.target.value), I.tenantName && a((K) => ({ ...K, tenantName: !1 }));
2389
2440
  },
2390
- placeholder: c.tenantNamePlaceholder,
2391
- style: z("tenantName"),
2441
+ placeholder: g.tenantNamePlaceholder,
2442
+ style: H("tenantName"),
2392
2443
  disabled: $
2393
2444
  }
2394
2445
  )
2395
2446
  ] }),
2396
- /* @__PURE__ */ n("button", { type: "submit", disabled: !O || $, style: H(), children: $ ? c.loadingText : c.submitButton }),
2397
- v && /* @__PURE__ */ n("div", { style: S.errorText, children: v })
2447
+ /* @__PURE__ */ n("button", { type: "submit", disabled: !O || $, style: N(), children: $ ? g.loadingText : g.submitButton }),
2448
+ v && /* @__PURE__ */ n("div", { style: w.errorText, children: v })
2398
2449
  ] }),
2399
- (y || A) && /* @__PURE__ */ a("div", { style: S.linkContainer, children: [
2400
- A && /* @__PURE__ */ a("div", { children: [
2401
- /* @__PURE__ */ a("span", { style: S.divider, children: [
2402
- c.magicLinkText,
2450
+ (b || k) && /* @__PURE__ */ l("div", { style: w.linkContainer, children: [
2451
+ k && /* @__PURE__ */ l("div", { children: [
2452
+ /* @__PURE__ */ l("span", { style: w.divider, children: [
2453
+ g.magicLinkText,
2403
2454
  " "
2404
2455
  ] }),
2405
- /* @__PURE__ */ n("a", { onClick: g, style: S.link, children: c.magicLinkLink })
2456
+ /* @__PURE__ */ n("a", { onClick: p, style: w.link, children: g.magicLinkLink })
2406
2457
  ] }),
2407
- A && y && /* @__PURE__ */ n("div", { style: S.divider, children: "•" }),
2408
- y && /* @__PURE__ */ a("div", { children: [
2409
- /* @__PURE__ */ a("span", { style: S.divider, children: [
2410
- c.loginText,
2458
+ k && b && /* @__PURE__ */ n("div", { style: w.divider, children: "•" }),
2459
+ b && /* @__PURE__ */ l("div", { children: [
2460
+ /* @__PURE__ */ l("span", { style: w.divider, children: [
2461
+ g.loginText,
2411
2462
  " "
2412
2463
  ] }),
2413
- /* @__PURE__ */ n("a", { onClick: o, style: S.link, children: c.loginLink })
2464
+ /* @__PURE__ */ n("a", { onClick: o, style: w.link, children: g.loginLink })
2414
2465
  ] })
2415
2466
  ] })
2416
2467
  ] });
2417
2468
  }
2418
- const ot = {
2469
+ const gt = {
2419
2470
  title: "Sign In with Magic Link",
2420
2471
  emailLabel: "Email",
2421
2472
  emailPlaceholder: "Enter your email",
@@ -2433,7 +2484,7 @@ const ot = {
2433
2484
  loadingText: "Sending magic link...",
2434
2485
  verifyingText: "Verifying magic link...",
2435
2486
  description: "Enter your email to receive a magic link. If you don't have an account, we'll create one for you."
2436
- }, at = {
2487
+ }, pt = {
2437
2488
  container: {
2438
2489
  maxWidth: "400px",
2439
2490
  width: "100%",
@@ -2536,84 +2587,84 @@ const ot = {
2536
2587
  fontSize: "0.875rem"
2537
2588
  }
2538
2589
  };
2539
- function Ut({
2590
+ function _t({
2540
2591
  copy: i = {},
2541
2592
  styles: e = {},
2542
2593
  onSuccess: t,
2543
2594
  onError: r,
2544
2595
  onLoginClick: s,
2545
2596
  onSignupClick: o,
2546
- showTraditionalLinks: g = !0,
2547
- className: y,
2548
- verifyToken: A,
2549
- frontendUrl: w
2597
+ showTraditionalLinks: p = !0,
2598
+ className: b,
2599
+ verifyToken: k,
2600
+ frontendUrl: S
2550
2601
  }) {
2551
- const [T, f] = k(""), [p, h] = k(""), [m, R] = k(""), [C, U] = k(!1), [P, u] = k(!1), [M, E] = k(""), [q, V] = k(""), [$, j] = k({}), [v, I] = k(!1), { sendMagicLink: L, verifyMagicLink: l } = ae(), { tenant: x } = se(), b = { ...ot, ...i }, d = { ...at, ...e };
2602
+ const [T, m] = x(""), [f, u] = x(""), [y, R] = x(""), [C, q] = x(!1), [A, d] = x(!1), [P, E] = x(""), [z, G] = x(""), [$, _] = x({}), [v, M] = x(!1), { sendMagicLink: I, verifyMagicLink: a } = ae(), { tenant: L } = se(), c = { ...gt, ...i }, h = { ...pt, ...e };
2552
2603
  te(() => {
2553
- A && c(A);
2554
- }, [A]);
2555
- const c = async (H) => {
2556
- if (!x || !T) {
2604
+ k && g(k);
2605
+ }, [k]);
2606
+ const g = async (N) => {
2607
+ if (!L || !T) {
2557
2608
  E("Missing tenant or email");
2558
2609
  return;
2559
2610
  }
2560
- u(!0), E("");
2611
+ d(!0), E("");
2561
2612
  try {
2562
- const O = await l({
2563
- token: H,
2613
+ const O = await a({
2614
+ token: N,
2564
2615
  email: T
2565
2616
  // tenantId inferred from context automatically
2566
2617
  });
2567
2618
  t == null || t(O);
2568
2619
  } catch (O) {
2569
- const D = O.message || "Failed to verify magic link";
2570
- E(D), r == null || r(D);
2620
+ const F = O.message || "Failed to verify magic link";
2621
+ E(F), r == null || r(F);
2571
2622
  } finally {
2572
- u(!1);
2623
+ d(!1);
2573
2624
  }
2574
- }, S = () => {
2575
- const H = {};
2576
- return T.trim() || (H.email = !0), v && !p.trim() && (H.name = !0), j(H), Object.keys(H).length === 0;
2577
- }, _ = async (H) => {
2578
- if (H.preventDefault(), !!S()) {
2579
- if (!(x != null && x.id)) {
2625
+ }, w = () => {
2626
+ const N = {};
2627
+ return T.trim() || (N.email = !0), v && !f.trim() && (N.name = !0), _(N), Object.keys(N).length === 0;
2628
+ }, j = async (N) => {
2629
+ if (N.preventDefault(), !!w()) {
2630
+ if (!(L != null && L.id)) {
2580
2631
  E("Tenant not found");
2581
2632
  return;
2582
2633
  }
2583
- U(!0), E(""), V("");
2634
+ q(!0), E(""), G("");
2584
2635
  try {
2585
- const O = w || (typeof window < "u" ? window.location.origin : ""), D = await L({
2636
+ const O = S || (typeof window < "u" ? window.location.origin : ""), F = await I({
2586
2637
  email: T,
2587
- tenantId: x.id,
2638
+ tenantId: L.id,
2588
2639
  frontendUrl: O,
2589
- name: v ? p : void 0,
2590
- lastName: v ? m : void 0
2640
+ name: v ? f : void 0,
2641
+ lastName: v ? y : void 0
2591
2642
  });
2592
- V(b.successMessage), t == null || t(D);
2643
+ G(c.successMessage), t == null || t(F);
2593
2644
  } catch (O) {
2594
- const D = O.message || b.errorMessage;
2595
- E(D), r == null || r(D);
2645
+ const F = O.message || c.errorMessage;
2646
+ E(F), r == null || r(F);
2596
2647
  } finally {
2597
- U(!1);
2648
+ q(!1);
2598
2649
  }
2599
2650
  }
2600
- }, ee = (H) => ({
2601
- ...d.input,
2602
- ...$[H] ? d.inputError : {}
2603
- }), z = () => ({
2604
- ...d.button,
2605
- ...C || P ? d.buttonLoading : {},
2606
- ...!T || C || P ? d.buttonDisabled : {}
2651
+ }, Y = (N) => ({
2652
+ ...h.input,
2653
+ ...$[N] ? h.inputError : {}
2654
+ }), H = () => ({
2655
+ ...h.button,
2656
+ ...C || A ? h.buttonLoading : {},
2657
+ ...!T || C || A ? h.buttonDisabled : {}
2607
2658
  });
2608
- return P ? /* @__PURE__ */ a("div", { className: y, style: d.container, children: [
2609
- /* @__PURE__ */ n("h2", { style: d.title, children: b.verifyingText }),
2659
+ return A ? /* @__PURE__ */ l("div", { className: b, style: h.container, children: [
2660
+ /* @__PURE__ */ n("h2", { style: h.title, children: c.verifyingText }),
2610
2661
  /* @__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..." }) })
2611
- ] }) : /* @__PURE__ */ a("div", { className: y, style: d.container, children: [
2612
- /* @__PURE__ */ n("h2", { style: d.title, children: b.title }),
2613
- /* @__PURE__ */ n("p", { style: d.description, children: b.description }),
2614
- /* @__PURE__ */ a("form", { onSubmit: _, style: d.form, children: [
2615
- /* @__PURE__ */ a("div", { style: d.fieldGroup, children: [
2616
- /* @__PURE__ */ n("label", { style: d.label, children: b.emailLabel }),
2662
+ ] }) : /* @__PURE__ */ l("div", { className: b, style: h.container, children: [
2663
+ /* @__PURE__ */ n("h2", { style: h.title, children: c.title }),
2664
+ /* @__PURE__ */ n("p", { style: h.description, children: c.description }),
2665
+ /* @__PURE__ */ l("form", { onSubmit: j, style: h.form, children: [
2666
+ /* @__PURE__ */ l("div", { style: h.fieldGroup, children: [
2667
+ /* @__PURE__ */ n("label", { style: h.label, children: c.emailLabel }),
2617
2668
  /* @__PURE__ */ n(
2618
2669
  "input",
2619
2670
  {
@@ -2621,12 +2672,12 @@ function Ut({
2621
2672
  name: "email",
2622
2673
  type: "email",
2623
2674
  value: T,
2624
- onChange: (H) => {
2625
- f(H.target.value), $.email && j((O) => ({ ...O, email: !1 }));
2675
+ onChange: (N) => {
2676
+ m(N.target.value), $.email && _((O) => ({ ...O, email: !1 }));
2626
2677
  },
2627
- placeholder: b.emailPlaceholder,
2628
- style: ee("email"),
2629
- disabled: C || P
2678
+ placeholder: c.emailPlaceholder,
2679
+ style: Y("email"),
2680
+ disabled: C || A
2630
2681
  }
2631
2682
  )
2632
2683
  ] }),
@@ -2634,7 +2685,7 @@ function Ut({
2634
2685
  "button",
2635
2686
  {
2636
2687
  type: "button",
2637
- onClick: () => I(!0),
2688
+ onClick: () => M(!0),
2638
2689
  style: {
2639
2690
  background: "none",
2640
2691
  border: "none",
@@ -2646,38 +2697,38 @@ function Ut({
2646
2697
  children: "New user? Add your name"
2647
2698
  }
2648
2699
  ) }),
2649
- v && /* @__PURE__ */ a(B, { children: [
2650
- /* @__PURE__ */ a("div", { style: d.fieldGroup, children: [
2651
- /* @__PURE__ */ n("label", { style: d.label, children: b.nameLabel }),
2700
+ v && /* @__PURE__ */ l(U, { children: [
2701
+ /* @__PURE__ */ l("div", { style: h.fieldGroup, children: [
2702
+ /* @__PURE__ */ n("label", { style: h.label, children: c.nameLabel }),
2652
2703
  /* @__PURE__ */ n(
2653
2704
  "input",
2654
2705
  {
2655
2706
  id: "name",
2656
2707
  name: "name",
2657
2708
  type: "text",
2658
- value: p,
2659
- onChange: (H) => {
2660
- h(H.target.value), $.name && j((O) => ({ ...O, name: !1 }));
2709
+ value: f,
2710
+ onChange: (N) => {
2711
+ u(N.target.value), $.name && _((O) => ({ ...O, name: !1 }));
2661
2712
  },
2662
- placeholder: b.namePlaceholder,
2663
- style: ee("name"),
2664
- disabled: C || P
2713
+ placeholder: c.namePlaceholder,
2714
+ style: Y("name"),
2715
+ disabled: C || A
2665
2716
  }
2666
2717
  )
2667
2718
  ] }),
2668
- /* @__PURE__ */ a("div", { style: d.fieldGroup, children: [
2669
- /* @__PURE__ */ n("label", { style: d.label, children: b.lastNameLabel }),
2719
+ /* @__PURE__ */ l("div", { style: h.fieldGroup, children: [
2720
+ /* @__PURE__ */ n("label", { style: h.label, children: c.lastNameLabel }),
2670
2721
  /* @__PURE__ */ n(
2671
2722
  "input",
2672
2723
  {
2673
2724
  id: "lastName",
2674
2725
  name: "lastName",
2675
2726
  type: "text",
2676
- value: m,
2677
- onChange: (H) => R(H.target.value),
2678
- placeholder: b.lastNamePlaceholder,
2679
- style: d.input,
2680
- disabled: C || P
2727
+ value: y,
2728
+ onChange: (N) => R(N.target.value),
2729
+ placeholder: c.lastNamePlaceholder,
2730
+ style: h.input,
2731
+ disabled: C || A
2681
2732
  }
2682
2733
  )
2683
2734
  ] }),
@@ -2686,7 +2737,7 @@ function Ut({
2686
2737
  {
2687
2738
  type: "button",
2688
2739
  onClick: () => {
2689
- I(!1), h(""), R("");
2740
+ M(!1), u(""), R("");
2690
2741
  },
2691
2742
  style: {
2692
2743
  background: "none",
@@ -2700,30 +2751,30 @@ function Ut({
2700
2751
  }
2701
2752
  ) })
2702
2753
  ] }),
2703
- /* @__PURE__ */ n("button", { type: "submit", disabled: !T || C || P, style: z(), children: C ? b.loadingText : b.submitButton }),
2704
- M && /* @__PURE__ */ n("div", { style: d.errorText, children: M }),
2705
- q && /* @__PURE__ */ n("div", { style: d.successText, children: q })
2754
+ /* @__PURE__ */ n("button", { type: "submit", disabled: !T || C || A, style: H(), children: C ? c.loadingText : c.submitButton }),
2755
+ P && /* @__PURE__ */ n("div", { style: h.errorText, children: P }),
2756
+ z && /* @__PURE__ */ n("div", { style: h.successText, children: z })
2706
2757
  ] }),
2707
- g && /* @__PURE__ */ a("div", { style: d.linkContainer, children: [
2708
- /* @__PURE__ */ a("div", { children: [
2709
- /* @__PURE__ */ a("span", { style: d.divider, children: [
2710
- b.loginText,
2758
+ p && /* @__PURE__ */ l("div", { style: h.linkContainer, children: [
2759
+ /* @__PURE__ */ l("div", { children: [
2760
+ /* @__PURE__ */ l("span", { style: h.divider, children: [
2761
+ c.loginText,
2711
2762
  " "
2712
2763
  ] }),
2713
- /* @__PURE__ */ n("a", { onClick: s, style: d.link, children: b.loginLink })
2764
+ /* @__PURE__ */ n("a", { onClick: s, style: h.link, children: c.loginLink })
2714
2765
  ] }),
2715
- /* @__PURE__ */ n("div", { style: d.divider, children: "•" }),
2716
- /* @__PURE__ */ a("div", { children: [
2717
- /* @__PURE__ */ a("span", { style: d.divider, children: [
2718
- b.signupText,
2766
+ /* @__PURE__ */ n("div", { style: h.divider, children: "•" }),
2767
+ /* @__PURE__ */ l("div", { children: [
2768
+ /* @__PURE__ */ l("span", { style: h.divider, children: [
2769
+ c.signupText,
2719
2770
  " "
2720
2771
  ] }),
2721
- /* @__PURE__ */ n("a", { onClick: o, style: d.link, children: b.signupLink })
2772
+ /* @__PURE__ */ n("a", { onClick: o, style: h.link, children: c.signupLink })
2722
2773
  ] })
2723
2774
  ] })
2724
2775
  ] });
2725
2776
  }
2726
- const lt = {
2777
+ const ft = {
2727
2778
  title: "Verifying Magic Link",
2728
2779
  verifyingMessage: "Please wait while we verify your magic link...",
2729
2780
  successMessage: "Magic link verified successfully! You are now logged in.",
@@ -2731,7 +2782,7 @@ const lt = {
2731
2782
  redirectingMessage: "Redirecting you to the dashboard...",
2732
2783
  retryButton: "Try Again",
2733
2784
  backToLoginButton: "Back to Login"
2734
- }, Ee = {
2785
+ }, Re = {
2735
2786
  container: {
2736
2787
  maxWidth: "400px",
2737
2788
  width: "100%",
@@ -2818,7 +2869,7 @@ const lt = {
2818
2869
  cursor: "pointer",
2819
2870
  transition: "all 0.15s ease-in-out"
2820
2871
  }
2821
- }, ct = () => /* @__PURE__ */ n("div", { style: Ee.spinner }), dt = () => /* @__PURE__ */ a(
2872
+ }, mt = () => /* @__PURE__ */ n("div", { style: Re.spinner }), yt = () => /* @__PURE__ */ l(
2822
2873
  "svg",
2823
2874
  {
2824
2875
  width: "48",
@@ -2835,7 +2886,7 @@ const lt = {
2835
2886
  /* @__PURE__ */ n("polyline", { points: "22,4 12,14.01 9,11.01" })
2836
2887
  ]
2837
2888
  }
2838
- ), ut = () => /* @__PURE__ */ a(
2889
+ ), wt = () => /* @__PURE__ */ l(
2839
2890
  "svg",
2840
2891
  {
2841
2892
  width: "48",
@@ -2853,109 +2904,109 @@ const lt = {
2853
2904
  /* @__PURE__ */ n("line", { x1: "9", y1: "9", x2: "15", y2: "15" })
2854
2905
  ]
2855
2906
  }
2856
- ), ht = {
2857
- loading: /* @__PURE__ */ n(ct, {}),
2858
- success: /* @__PURE__ */ n(dt, {}),
2859
- error: /* @__PURE__ */ n(ut, {})
2907
+ ), bt = {
2908
+ loading: /* @__PURE__ */ n(mt, {}),
2909
+ success: /* @__PURE__ */ n(yt, {}),
2910
+ error: /* @__PURE__ */ n(wt, {})
2860
2911
  };
2861
- function qt({
2912
+ function Gt({
2862
2913
  copy: i = {},
2863
2914
  styles: e = {},
2864
2915
  icons: t = {},
2865
2916
  onSuccess: r,
2866
2917
  onError: s,
2867
2918
  onRetry: o,
2868
- onBackToLogin: g,
2869
- className: y,
2870
- token: A,
2871
- email: w,
2919
+ onBackToLogin: p,
2920
+ className: b,
2921
+ token: k,
2922
+ email: S,
2872
2923
  appId: T,
2873
- tenantSlug: f,
2874
- autoRedirectDelay: p = 3e3
2924
+ tenantSlug: m,
2925
+ autoRedirectDelay: f = 3e3
2875
2926
  }) {
2876
- const [h, m] = k("verifying"), [R, C] = k(""), { verifyMagicLink: U } = ae(), P = { ...lt, ...i }, u = { ...Ee, ...e }, M = { ...ht, ...t }, E = () => {
2927
+ const [u, y] = x("verifying"), [R, C] = x(""), { verifyMagicLink: q } = ae(), A = { ...ft, ...i }, d = { ...Re, ...e }, P = { ...bt, ...t }, E = () => {
2877
2928
  if (typeof window > "u") return {};
2878
2929
  const v = new URLSearchParams(window.location.search);
2879
2930
  return {
2880
- token: A || v.get("token") || "",
2881
- email: w || v.get("email") || "",
2931
+ token: k || v.get("token") || "",
2932
+ email: S || v.get("email") || "",
2882
2933
  appId: T || v.get("appId") || "",
2883
- tenantSlug: f || v.get("tenantSlug") || void 0
2934
+ tenantSlug: m || v.get("tenantSlug") || void 0
2884
2935
  };
2885
- }, q = async () => {
2886
- m("verifying"), C("");
2936
+ }, z = async () => {
2937
+ y("verifying"), C("");
2887
2938
  try {
2888
2939
  const v = E();
2889
2940
  if (!v.token || !v.email)
2890
2941
  throw new Error("Missing required parameters: token or email");
2891
- const I = await U({
2942
+ const M = await q({
2892
2943
  token: v.token,
2893
2944
  email: v.email,
2894
2945
  tenantSlug: v.tenantSlug
2895
2946
  });
2896
- m("success"), r == null || r(I), p > 0 && setTimeout(() => {
2897
- m("redirecting");
2898
- }, p);
2947
+ y("success"), r == null || r(M), f > 0 && setTimeout(() => {
2948
+ y("redirecting");
2949
+ }, f);
2899
2950
  } catch (v) {
2900
- const I = v.message || P.errorMessage;
2901
- C(I), m("error"), s == null || s(I);
2951
+ const M = v.message || A.errorMessage;
2952
+ C(M), y("error"), s == null || s(M);
2902
2953
  }
2903
- }, V = () => {
2904
- o == null || o(), q();
2954
+ }, G = () => {
2955
+ o == null || o(), z();
2905
2956
  }, $ = () => {
2906
- g == null || g();
2957
+ p == null || p();
2907
2958
  };
2908
2959
  te(() => {
2909
- q();
2960
+ z();
2910
2961
  }, []);
2911
- const j = () => {
2912
- switch (h) {
2962
+ const _ = () => {
2963
+ switch (u) {
2913
2964
  case "verifying":
2914
- return /* @__PURE__ */ a("div", { style: u.message, children: [
2915
- M.loading,
2916
- P.verifyingMessage
2965
+ return /* @__PURE__ */ l("div", { style: d.message, children: [
2966
+ P.loading,
2967
+ A.verifyingMessage
2917
2968
  ] });
2918
2969
  case "success":
2919
- return /* @__PURE__ */ a(B, { children: [
2920
- M.success,
2921
- /* @__PURE__ */ n("div", { style: u.successMessage, children: P.successMessage })
2970
+ return /* @__PURE__ */ l(U, { children: [
2971
+ P.success,
2972
+ /* @__PURE__ */ n("div", { style: d.successMessage, children: A.successMessage })
2922
2973
  ] });
2923
2974
  case "redirecting":
2924
- return /* @__PURE__ */ a(B, { children: [
2925
- M.loading,
2926
- /* @__PURE__ */ n("div", { style: u.message, children: P.redirectingMessage })
2975
+ return /* @__PURE__ */ l(U, { children: [
2976
+ P.loading,
2977
+ /* @__PURE__ */ n("div", { style: d.message, children: A.redirectingMessage })
2927
2978
  ] });
2928
2979
  case "error":
2929
- return /* @__PURE__ */ a(B, { children: [
2930
- M.error,
2931
- /* @__PURE__ */ n("div", { style: u.errorMessage, children: R || P.errorMessage }),
2932
- /* @__PURE__ */ a("div", { style: u.buttonContainer, children: [
2980
+ return /* @__PURE__ */ l(U, { children: [
2981
+ P.error,
2982
+ /* @__PURE__ */ n("div", { style: d.errorMessage, children: R || A.errorMessage }),
2983
+ /* @__PURE__ */ l("div", { style: d.buttonContainer, children: [
2933
2984
  /* @__PURE__ */ n(
2934
2985
  "button",
2935
2986
  {
2936
- onClick: V,
2937
- style: u.retryButton,
2987
+ onClick: G,
2988
+ style: d.retryButton,
2938
2989
  onMouseOver: (v) => {
2939
2990
  v.currentTarget.style.backgroundColor = "#2563eb";
2940
2991
  },
2941
2992
  onMouseOut: (v) => {
2942
2993
  v.currentTarget.style.backgroundColor = "#3b82f6";
2943
2994
  },
2944
- children: P.retryButton
2995
+ children: A.retryButton
2945
2996
  }
2946
2997
  ),
2947
2998
  /* @__PURE__ */ n(
2948
2999
  "button",
2949
3000
  {
2950
3001
  onClick: $,
2951
- style: u.backButton,
3002
+ style: d.backButton,
2952
3003
  onMouseOver: (v) => {
2953
3004
  v.currentTarget.style.backgroundColor = "#e5e7eb";
2954
3005
  },
2955
3006
  onMouseOut: (v) => {
2956
3007
  v.currentTarget.style.backgroundColor = "#f3f4f6";
2957
3008
  },
2958
- children: P.backToLoginButton
3009
+ children: A.backToLoginButton
2959
3010
  }
2960
3011
  )
2961
3012
  ] })
@@ -2964,18 +3015,18 @@ function qt({
2964
3015
  return null;
2965
3016
  }
2966
3017
  };
2967
- return /* @__PURE__ */ a("div", { style: u.container, className: y, children: [
3018
+ return /* @__PURE__ */ l("div", { style: d.container, className: b, children: [
2968
3019
  /* @__PURE__ */ n("style", { children: `
2969
3020
  @keyframes spin {
2970
3021
  0% { transform: rotate(0deg); }
2971
3022
  100% { transform: rotate(360deg); }
2972
3023
  }
2973
3024
  ` }),
2974
- /* @__PURE__ */ n("h1", { style: u.title, children: P.title }),
2975
- j()
3025
+ /* @__PURE__ */ n("h1", { style: d.title, children: A.title }),
3026
+ _()
2976
3027
  ] });
2977
3028
  }
2978
- const gt = {
3029
+ const St = {
2979
3030
  title: "Reset Password",
2980
3031
  subtitle: "Enter your email address and we'll send you a link to reset your password.",
2981
3032
  emailLabel: "Email",
@@ -2997,7 +3048,7 @@ const gt = {
2997
3048
  resetLoadingText: "Resetting...",
2998
3049
  resetSuccessMessage: "Password reset successfully!",
2999
3050
  passwordMismatchError: "Passwords do not match"
3000
- }, pt = {
3051
+ }, vt = {
3001
3052
  container: {
3002
3053
  maxWidth: "400px",
3003
3054
  margin: "0 auto",
@@ -3089,113 +3140,113 @@ const gt = {
3089
3140
  cursor: "pointer"
3090
3141
  }
3091
3142
  };
3092
- function zt({
3143
+ function Kt({
3093
3144
  copy: i = {},
3094
3145
  styles: e = {},
3095
3146
  mode: t = "request",
3096
3147
  token: r = "",
3097
3148
  onSuccess: s,
3098
3149
  onError: o,
3099
- onBackToLogin: g,
3100
- onModeChange: y,
3101
- className: A
3150
+ onBackToLogin: p,
3151
+ onModeChange: b,
3152
+ className: k
3102
3153
  }) {
3103
- const [w, T] = k(""), [f, p] = k(r), [h, m] = k(""), [R, C] = k(""), [U, P] = k(!1), [u, M] = k(""), [E, q] = k(""), [V, $] = k({}), { requestPasswordReset: j, confirmPasswordReset: v } = ae(), { tenant: I } = se(), L = { ...gt, ...i }, l = { ...pt, ...e }, x = () => {
3104
- const z = {};
3105
- return w.trim() || (z.email = !0), $(z), Object.keys(z).length === 0;
3106
- }, b = () => {
3107
- const z = {};
3108
- return f.trim() || (z.token = !0), h.trim() || (z.newPassword = !0), R.trim() || (z.confirmPassword = !0), $(z), Object.keys(z).length === 0;
3109
- }, d = async (z) => {
3110
- if (z.preventDefault(), !!x()) {
3111
- if (!(I != null && I.id)) {
3112
- M("Tenant not found");
3154
+ const [S, T] = x(""), [m, f] = x(r), [u, y] = x(""), [R, C] = x(""), [q, A] = x(!1), [d, P] = x(""), [E, z] = x(""), [G, $] = x({}), { requestPasswordReset: _, confirmPasswordReset: v } = ae(), { tenant: M } = se(), I = { ...St, ...i }, a = { ...vt, ...e }, L = () => {
3155
+ const H = {};
3156
+ return S.trim() || (H.email = !0), $(H), Object.keys(H).length === 0;
3157
+ }, c = () => {
3158
+ const H = {};
3159
+ return m.trim() || (H.token = !0), u.trim() || (H.newPassword = !0), R.trim() || (H.confirmPassword = !0), $(H), Object.keys(H).length === 0;
3160
+ }, h = async (H) => {
3161
+ if (H.preventDefault(), !!L()) {
3162
+ if (!(M != null && M.id)) {
3163
+ P("Tenant not found");
3113
3164
  return;
3114
3165
  }
3115
- P(!0), M(""), q("");
3166
+ A(!0), P(""), z("");
3116
3167
  try {
3117
- await j({ email: w, tenantId: I.id }), q(L.successMessage), s == null || s();
3118
- } catch (H) {
3119
- const O = H.message || L.errorMessage;
3120
- M(O), o == null || o(O);
3168
+ await _({ email: S, tenantId: M.id }), z(I.successMessage), s == null || s();
3169
+ } catch (N) {
3170
+ const O = N.message || I.errorMessage;
3171
+ P(O), o == null || o(O);
3121
3172
  } finally {
3122
- P(!1);
3173
+ A(!1);
3123
3174
  }
3124
3175
  }
3125
- }, c = async (z) => {
3126
- if (z.preventDefault(), !!b()) {
3127
- if (h !== R) {
3128
- M(L.passwordMismatchError), $({ confirmPassword: !0 });
3176
+ }, g = async (H) => {
3177
+ if (H.preventDefault(), !!c()) {
3178
+ if (u !== R) {
3179
+ P(I.passwordMismatchError), $({ confirmPassword: !0 });
3129
3180
  return;
3130
3181
  }
3131
- P(!0), M(""), q("");
3182
+ A(!0), P(""), z("");
3132
3183
  try {
3133
- await v({ token: f, newPassword: h }), q(L.resetSuccessMessage), s == null || s();
3134
- } catch (H) {
3135
- const O = H.message || L.errorMessage;
3136
- M(O), o == null || o(O);
3184
+ await v({ token: m, newPassword: u }), z(I.resetSuccessMessage), s == null || s();
3185
+ } catch (N) {
3186
+ const O = N.message || I.errorMessage;
3187
+ P(O), o == null || o(O);
3137
3188
  } finally {
3138
- P(!1);
3189
+ A(!1);
3139
3190
  }
3140
3191
  }
3141
- }, S = (z) => ({
3142
- ...l.input,
3143
- ...V[z] ? l.inputError : {}
3144
- }), _ = () => ({
3145
- ...l.button,
3146
- ...U ? l.buttonLoading : {}
3192
+ }, w = (H) => ({
3193
+ ...a.input,
3194
+ ...G[H] ? a.inputError : {}
3195
+ }), j = () => ({
3196
+ ...a.button,
3197
+ ...q ? a.buttonLoading : {}
3147
3198
  });
3148
3199
  if (t === "reset") {
3149
- const z = f && h && R;
3150
- return /* @__PURE__ */ a("div", { className: A, style: l.container, children: [
3151
- /* @__PURE__ */ n("h2", { style: l.title, children: L.resetTitle }),
3152
- /* @__PURE__ */ n("p", { style: l.subtitle, children: L.resetSubtitle }),
3153
- /* @__PURE__ */ a("form", { onSubmit: c, style: l.form, children: [
3154
- /* @__PURE__ */ a("div", { style: l.fieldGroup, children: [
3155
- /* @__PURE__ */ n("label", { style: l.label, children: L.tokenLabel }),
3200
+ const H = m && u && R;
3201
+ return /* @__PURE__ */ l("div", { className: k, style: a.container, children: [
3202
+ /* @__PURE__ */ n("h2", { style: a.title, children: I.resetTitle }),
3203
+ /* @__PURE__ */ n("p", { style: a.subtitle, children: I.resetSubtitle }),
3204
+ /* @__PURE__ */ l("form", { onSubmit: g, style: a.form, children: [
3205
+ /* @__PURE__ */ l("div", { style: a.fieldGroup, children: [
3206
+ /* @__PURE__ */ n("label", { style: a.label, children: I.tokenLabel }),
3156
3207
  /* @__PURE__ */ n(
3157
3208
  "input",
3158
3209
  {
3159
3210
  type: "text",
3160
- value: f,
3161
- onChange: (H) => {
3162
- p(H.target.value), V.token && $((O) => ({ ...O, token: !1 }));
3211
+ value: m,
3212
+ onChange: (N) => {
3213
+ f(N.target.value), G.token && $((O) => ({ ...O, token: !1 }));
3163
3214
  },
3164
- placeholder: L.tokenPlaceholder,
3165
- style: S("token"),
3166
- disabled: U
3215
+ placeholder: I.tokenPlaceholder,
3216
+ style: w("token"),
3217
+ disabled: q
3167
3218
  }
3168
3219
  )
3169
3220
  ] }),
3170
- /* @__PURE__ */ a("div", { style: l.fieldGroup, children: [
3171
- /* @__PURE__ */ n("label", { style: l.label, children: L.newPasswordLabel }),
3221
+ /* @__PURE__ */ l("div", { style: a.fieldGroup, children: [
3222
+ /* @__PURE__ */ n("label", { style: a.label, children: I.newPasswordLabel }),
3172
3223
  /* @__PURE__ */ n(
3173
3224
  "input",
3174
3225
  {
3175
3226
  type: "password",
3176
- value: h,
3177
- onChange: (H) => {
3178
- m(H.target.value), V.newPassword && $((O) => ({ ...O, newPassword: !1 }));
3227
+ value: u,
3228
+ onChange: (N) => {
3229
+ y(N.target.value), G.newPassword && $((O) => ({ ...O, newPassword: !1 }));
3179
3230
  },
3180
- placeholder: L.newPasswordPlaceholder,
3181
- style: S("newPassword"),
3182
- disabled: U
3231
+ placeholder: I.newPasswordPlaceholder,
3232
+ style: w("newPassword"),
3233
+ disabled: q
3183
3234
  }
3184
3235
  )
3185
3236
  ] }),
3186
- /* @__PURE__ */ a("div", { style: l.fieldGroup, children: [
3187
- /* @__PURE__ */ n("label", { style: l.label, children: L.confirmPasswordLabel }),
3237
+ /* @__PURE__ */ l("div", { style: a.fieldGroup, children: [
3238
+ /* @__PURE__ */ n("label", { style: a.label, children: I.confirmPasswordLabel }),
3188
3239
  /* @__PURE__ */ n(
3189
3240
  "input",
3190
3241
  {
3191
3242
  type: "password",
3192
3243
  value: R,
3193
- onChange: (H) => {
3194
- C(H.target.value), V.confirmPassword && $((O) => ({ ...O, confirmPassword: !1 })), u === L.passwordMismatchError && M("");
3244
+ onChange: (N) => {
3245
+ C(N.target.value), G.confirmPassword && $((O) => ({ ...O, confirmPassword: !1 })), d === I.passwordMismatchError && P("");
3195
3246
  },
3196
- placeholder: L.confirmPasswordPlaceholder,
3197
- style: S("confirmPassword"),
3198
- disabled: U
3247
+ placeholder: I.confirmPasswordPlaceholder,
3248
+ style: w("confirmPassword"),
3249
+ disabled: q
3199
3250
  }
3200
3251
  )
3201
3252
  ] }),
@@ -3203,44 +3254,44 @@ function zt({
3203
3254
  "button",
3204
3255
  {
3205
3256
  type: "submit",
3206
- disabled: !z || U,
3257
+ disabled: !H || q,
3207
3258
  style: {
3208
- ..._(),
3209
- ...!z || U ? l.buttonDisabled : {}
3259
+ ...j(),
3260
+ ...!H || q ? a.buttonDisabled : {}
3210
3261
  },
3211
- children: U ? L.resetLoadingText : L.resetSubmitButton
3262
+ children: q ? I.resetLoadingText : I.resetSubmitButton
3212
3263
  }
3213
3264
  ),
3214
- u && /* @__PURE__ */ n("div", { style: l.errorText, children: u }),
3215
- E && /* @__PURE__ */ n("div", { style: l.successText, children: E })
3265
+ d && /* @__PURE__ */ n("div", { style: a.errorText, children: d }),
3266
+ E && /* @__PURE__ */ n("div", { style: a.successText, children: E })
3216
3267
  ] }),
3217
- /* @__PURE__ */ a("div", { style: l.linkContainer, children: [
3218
- /* @__PURE__ */ n("a", { onClick: g, style: l.link, children: L.backToLoginLink }),
3219
- y && /* @__PURE__ */ a(B, { children: [
3268
+ /* @__PURE__ */ l("div", { style: a.linkContainer, children: [
3269
+ /* @__PURE__ */ n("a", { onClick: p, style: a.link, children: I.backToLoginLink }),
3270
+ b && /* @__PURE__ */ l(U, { children: [
3220
3271
  /* @__PURE__ */ n("span", { style: { margin: "0 0.5rem", color: "#6b7280" }, children: "•" }),
3221
- /* @__PURE__ */ n("a", { onClick: () => y("request"), style: l.link, children: "Request New Link" })
3272
+ /* @__PURE__ */ n("a", { onClick: () => b("request"), style: a.link, children: "Request New Link" })
3222
3273
  ] })
3223
3274
  ] })
3224
3275
  ] });
3225
3276
  }
3226
- const ee = w;
3227
- return /* @__PURE__ */ a("div", { className: A, style: l.container, children: [
3228
- /* @__PURE__ */ n("h2", { style: l.title, children: L.title }),
3229
- /* @__PURE__ */ n("p", { style: l.subtitle, children: L.subtitle }),
3230
- /* @__PURE__ */ a("form", { onSubmit: d, style: l.form, children: [
3231
- /* @__PURE__ */ a("div", { style: l.fieldGroup, children: [
3232
- /* @__PURE__ */ n("label", { style: l.label, children: L.emailLabel }),
3277
+ const Y = S;
3278
+ return /* @__PURE__ */ l("div", { className: k, style: a.container, children: [
3279
+ /* @__PURE__ */ n("h2", { style: a.title, children: I.title }),
3280
+ /* @__PURE__ */ n("p", { style: a.subtitle, children: I.subtitle }),
3281
+ /* @__PURE__ */ l("form", { onSubmit: h, style: a.form, children: [
3282
+ /* @__PURE__ */ l("div", { style: a.fieldGroup, children: [
3283
+ /* @__PURE__ */ n("label", { style: a.label, children: I.emailLabel }),
3233
3284
  /* @__PURE__ */ n(
3234
3285
  "input",
3235
3286
  {
3236
3287
  type: "email",
3237
- value: w,
3238
- onChange: (z) => {
3239
- T(z.target.value), V.email && $((H) => ({ ...H, email: !1 }));
3288
+ value: S,
3289
+ onChange: (H) => {
3290
+ T(H.target.value), G.email && $((N) => ({ ...N, email: !1 }));
3240
3291
  },
3241
- placeholder: L.emailPlaceholder,
3242
- style: S("email"),
3243
- disabled: U
3292
+ placeholder: I.emailPlaceholder,
3293
+ style: w("email"),
3294
+ disabled: q
3244
3295
  }
3245
3296
  )
3246
3297
  ] }),
@@ -3248,27 +3299,27 @@ function zt({
3248
3299
  "button",
3249
3300
  {
3250
3301
  type: "submit",
3251
- disabled: !ee || U,
3302
+ disabled: !Y || q,
3252
3303
  style: {
3253
- ..._(),
3254
- ...!ee || U ? l.buttonDisabled : {}
3304
+ ...j(),
3305
+ ...!Y || q ? a.buttonDisabled : {}
3255
3306
  },
3256
- children: U ? L.loadingText : L.submitButton
3307
+ children: q ? I.loadingText : I.submitButton
3257
3308
  }
3258
3309
  ),
3259
- u && /* @__PURE__ */ n("div", { style: l.errorText, children: u }),
3260
- E && /* @__PURE__ */ n("div", { style: l.successText, children: E })
3310
+ d && /* @__PURE__ */ n("div", { style: a.errorText, children: d }),
3311
+ E && /* @__PURE__ */ n("div", { style: a.successText, children: E })
3261
3312
  ] }),
3262
- /* @__PURE__ */ a("div", { style: l.linkContainer, children: [
3263
- /* @__PURE__ */ n("a", { onClick: g, style: l.link, children: L.backToLoginLink }),
3264
- y && /* @__PURE__ */ a(B, { children: [
3313
+ /* @__PURE__ */ l("div", { style: a.linkContainer, children: [
3314
+ /* @__PURE__ */ n("a", { onClick: p, style: a.link, children: I.backToLoginLink }),
3315
+ b && /* @__PURE__ */ l(U, { children: [
3265
3316
  /* @__PURE__ */ n("span", { style: { margin: "0 0.5rem", color: "#6b7280" }, children: "•" }),
3266
- /* @__PURE__ */ n("a", { onClick: () => y("reset"), style: l.link, children: "I have a token" })
3317
+ /* @__PURE__ */ n("a", { onClick: () => b("reset"), style: a.link, children: "I have a token" })
3267
3318
  ] })
3268
3319
  ] })
3269
3320
  ] });
3270
3321
  }
3271
- const ft = () => /* @__PURE__ */ n(
3322
+ const xt = () => /* @__PURE__ */ n(
3272
3323
  "div",
3273
3324
  {
3274
3325
  style: {
@@ -3280,7 +3331,7 @@ const ft = () => /* @__PURE__ */ n(
3280
3331
  },
3281
3332
  children: /* @__PURE__ */ n("div", { children: "Loading..." })
3282
3333
  }
3283
- ), mt = ({ error: i, retry: e }) => /* @__PURE__ */ a(
3334
+ ), kt = ({ error: i, retry: e }) => /* @__PURE__ */ l(
3284
3335
  "div",
3285
3336
  {
3286
3337
  style: {
@@ -3314,40 +3365,40 @@ const ft = () => /* @__PURE__ */ n(
3314
3365
  ]
3315
3366
  }
3316
3367
  );
3317
- function Ot({
3368
+ function Jt({
3318
3369
  children: i,
3319
3370
  loadingFallback: e,
3320
3371
  errorFallback: t,
3321
3372
  requireTenant: r = !0
3322
3373
  }) {
3323
- const { isAppLoading: s, appError: o, retryApp: g } = oe(), y = Pe(), A = (y == null ? void 0 : y.isTenantLoading) ?? !1, w = (y == null ? void 0 : y.tenantError) ?? null, T = (y == null ? void 0 : y.tenantSlug) ?? null, f = (y == null ? void 0 : y.retryTenant) ?? (() => {
3324
- }), p = r && y && T, h = s || p && A, m = o || (p ? w : null), R = () => {
3325
- o && g(), w && y && f();
3374
+ const { isAppLoading: s, appError: o, retryApp: p } = oe(), b = Me(), k = (b == null ? void 0 : b.isTenantLoading) ?? !1, S = (b == null ? void 0 : b.tenantError) ?? null, T = (b == null ? void 0 : b.tenantSlug) ?? null, m = (b == null ? void 0 : b.retryTenant) ?? (() => {
3375
+ }), f = r && b && T, u = s || f && k, y = o || (f ? S : null), R = () => {
3376
+ o && p(), S && b && m();
3326
3377
  };
3327
- if (h)
3328
- return /* @__PURE__ */ n(B, { children: e || /* @__PURE__ */ n(ft, {}) });
3329
- if (m) {
3330
- const C = typeof t == "function" ? t(m, R) : t || /* @__PURE__ */ n(mt, { error: m, retry: R });
3331
- return /* @__PURE__ */ n(B, { children: C });
3378
+ if (u)
3379
+ return /* @__PURE__ */ n(U, { children: e || /* @__PURE__ */ n(xt, {}) });
3380
+ if (y) {
3381
+ const C = typeof t == "function" ? t(y, R) : t || /* @__PURE__ */ n(kt, { error: y, retry: R });
3382
+ return /* @__PURE__ */ n(U, { children: C });
3332
3383
  }
3333
- return /* @__PURE__ */ n(B, { children: i });
3384
+ return /* @__PURE__ */ n(U, { children: i });
3334
3385
  }
3335
- function Wt(i = !0) {
3336
- const { isAppLoading: e, appError: t, retryApp: r, appInfo: s } = oe(), o = Pe(), g = (o == null ? void 0 : o.isTenantLoading) ?? !1, y = (o == null ? void 0 : o.tenantError) ?? null, A = (o == null ? void 0 : o.tenant) ?? null, w = (o == null ? void 0 : o.tenantSlug) ?? null, T = (o == null ? void 0 : o.retryTenant) ?? (() => {
3337
- }), f = i && o && w, p = e || f && g, h = t || (f ? y : null);
3386
+ function Yt(i = !0) {
3387
+ const { isAppLoading: e, appError: t, retryApp: r, appInfo: s } = oe(), o = Me(), p = (o == null ? void 0 : o.isTenantLoading) ?? !1, b = (o == null ? void 0 : o.tenantError) ?? null, k = (o == null ? void 0 : o.tenant) ?? null, S = (o == null ? void 0 : o.tenantSlug) ?? null, T = (o == null ? void 0 : o.retryTenant) ?? (() => {
3388
+ }), m = i && o && S, f = e || m && p, u = t || (m ? b : null);
3338
3389
  return {
3339
- isLoading: p,
3340
- error: h,
3341
- isReady: !p && !h && s !== null && (!f || A !== null),
3390
+ isLoading: f,
3391
+ error: u,
3392
+ isReady: !f && !u && s !== null && (!m || k !== null),
3342
3393
  retry: () => {
3343
- t && r(), y && o && T();
3394
+ t && r(), b && o && T();
3344
3395
  },
3345
3396
  // Individual states
3346
3397
  app: { isLoading: e, error: t, data: s },
3347
- tenant: o ? { isLoading: g, error: y, data: A } : null
3398
+ tenant: o ? { isLoading: p, error: b, data: k } : null
3348
3399
  };
3349
3400
  }
3350
- class jt {
3401
+ class Qt {
3351
3402
  constructor(e, t) {
3352
3403
  this.httpService = e, this.sessionManager = t;
3353
3404
  }
@@ -3415,7 +3466,7 @@ class jt {
3415
3466
  };
3416
3467
  }
3417
3468
  }
3418
- class Vt {
3469
+ class Xt {
3419
3470
  constructor(e, t) {
3420
3471
  this.httpService = e, this.sessionManager = t;
3421
3472
  }
@@ -3466,7 +3517,7 @@ class Vt {
3466
3517
  });
3467
3518
  }
3468
3519
  }
3469
- class Gt {
3520
+ class Zt {
3470
3521
  constructor(e) {
3471
3522
  this.httpService = e;
3472
3523
  }
@@ -3475,7 +3526,7 @@ class Gt {
3475
3526
  return await this.httpService.get("/health");
3476
3527
  }
3477
3528
  }
3478
- class _t {
3529
+ class er {
3479
3530
  // Date string to Date object
3480
3531
  static toDate(e) {
3481
3532
  return new Date(e);
@@ -3598,47 +3649,47 @@ class _t {
3598
3649
  }
3599
3650
  }
3600
3651
  export {
3601
- _t as ApiMappers,
3602
- Se as AppApiService,
3603
- Ot as AppLoader,
3604
- kt as AppProvider,
3605
- He as AuthApiService,
3606
- It as AuthProvider,
3607
- Ht as FeatureFlag,
3608
- Oe as FeatureFlagApiService,
3609
- Lt as FeatureFlagProvider,
3610
- Gt as HealthApiService,
3652
+ er as ApiMappers,
3653
+ ve as AppApiService,
3654
+ Jt as AppLoader,
3655
+ Et as AppProvider,
3656
+ Ue as AuthApiService,
3657
+ Dt as AuthProvider,
3658
+ Wt as FeatureFlag,
3659
+ Je as FeatureFlagApiService,
3660
+ Ht as FeatureFlagProvider,
3661
+ Zt as HealthApiService,
3611
3662
  re as HttpService,
3612
- Ft as LandingRoute,
3613
- Nt as LoginForm,
3614
- Ut as MagicLinkForm,
3615
- qt as MagicLinkVerify,
3616
- zt as PasswordRecoveryForm,
3617
- jt as PermissionApiService,
3618
- Rt as Protected,
3619
- Ct as ProtectedRoute,
3620
- ve as RoleApiService,
3621
- ye as SessionManager,
3622
- Bt as SignupForm,
3623
- je as SubscriptionApiService,
3624
- Dt as SubscriptionGuard,
3625
- Vt as SubscriptionPlanApiService,
3626
- Et as SubscriptionProvider,
3663
+ zt as LandingRoute,
3664
+ jt as LoginForm,
3665
+ _t as MagicLinkForm,
3666
+ Gt as MagicLinkVerify,
3667
+ Kt as PasswordRecoveryForm,
3668
+ Qt as PermissionApiService,
3669
+ Bt as Protected,
3670
+ Ut as ProtectedRoute,
3671
+ xe as RoleApiService,
3672
+ we as SessionManager,
3673
+ Vt as SignupForm,
3674
+ Qe as SubscriptionApiService,
3675
+ Ot as SubscriptionGuard,
3676
+ Xt as SubscriptionPlanApiService,
3677
+ Nt as SubscriptionProvider,
3627
3678
  ue as TenantApiService,
3628
- Tt as TenantProvider,
3629
- $t as TenantRoute,
3630
- Ne as UserApiService,
3679
+ Ct as TenantProvider,
3680
+ qt as TenantRoute,
3681
+ qe as UserApiService,
3631
3682
  ie as UserType,
3632
- At as useApi,
3683
+ Rt as useApi,
3633
3684
  oe as useApp,
3634
- Wt as useAppLoaderState,
3685
+ Yt as useAppLoaderState,
3635
3686
  ae as useAuth,
3636
- We as useFeatureFlags,
3637
- Mt as useSettings,
3638
- Ve as useSubscription,
3639
- fe as useTenant,
3687
+ Ye as useFeatureFlags,
3688
+ Ft as useSettings,
3689
+ Xe as useSubscription,
3690
+ me as useTenant,
3640
3691
  se as useTenantInfo,
3641
- Pe as useTenantOptional,
3642
- Pt as useTenantSettings
3692
+ Me as useTenantOptional,
3693
+ $t as useTenantSettings
3643
3694
  };
3644
3695
  //# sourceMappingURL=index.es.js.map