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