@skylabs-digital/react-identity-access 2.6.0 → 2.8.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 W, jsxs as l } from "react/jsx-runtime";
2
- import { createContext as ue, useMemo as X, useState as k, useCallback as se, useEffect as te, useContext as ne, useRef as Ve } from "react";
1
+ import { jsx as n, Fragment as j, jsxs as l } from "react/jsx-runtime";
2
+ import { createContext as ue, useMemo as X, useState as S, useCallback as se, useEffect as te, useContext as ne, useRef as Ge } from "react";
3
3
  import { useLocation as Se, Navigate as pe } from "react-router-dom";
4
4
  class re {
5
5
  // SessionManager instance
@@ -16,7 +16,7 @@ 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 a = `${this.baseUrl}${t.startsWith("/") ? t : `/${t}`}`, p = (s == null ? void 0 : s.timeout) || this.timeout;
19
+ const a = `${this.baseUrl}${t.startsWith("/") ? t : `/${t}`}`, g = (s == null ? void 0 : s.timeout) || this.timeout;
20
20
  let w = {
21
21
  "Content-Type": "application/json",
22
22
  ...s == null ? void 0 : s.headers
@@ -28,15 +28,15 @@ class re {
28
28
  } catch (b) {
29
29
  console.warn("Failed to inject auth headers:", b);
30
30
  }
31
- const y = new AbortController(), x = setTimeout(() => y.abort(), p);
31
+ const m = new AbortController(), k = setTimeout(() => m.abort(), g);
32
32
  try {
33
33
  const b = await fetch(a, {
34
34
  method: e,
35
35
  headers: w,
36
36
  body: r ? JSON.stringify(r) : void 0,
37
- signal: y.signal
37
+ signal: m.signal
38
38
  });
39
- if (clearTimeout(x), b.status === 401 && !(s != null && s.skipRetry) && !o && this.sessionManager)
39
+ if (clearTimeout(k), b.status === 401 && !(s != null && s.skipRetry) && !o && this.sessionManager)
40
40
  try {
41
41
  const A = this.sessionManager.getTokens();
42
42
  if (A != null && A.refreshToken)
@@ -49,7 +49,7 @@ class re {
49
49
  const f = b.headers.get("content-type");
50
50
  return !f || !f.includes("application/json") ? {} : await b.json();
51
51
  } catch (b) {
52
- throw clearTimeout(x), b instanceof Error && b.name === "AbortError" ? new Error(`Request timeout after ${p}ms`) : b;
52
+ throw clearTimeout(k), b instanceof Error && b.name === "AbortError" ? new Error(`Request timeout after ${g}ms`) : b;
53
53
  }
54
54
  }
55
55
  async get(e, t) {
@@ -125,19 +125,19 @@ class Pe {
125
125
  }
126
126
  }
127
127
  const ve = ue(null);
128
- function Nt({ config: i, children: e }) {
128
+ function Bt({ config: i, children: e }) {
129
129
  const t = X(
130
130
  () => {
131
- var f, A, L;
131
+ var f, A, E;
132
132
  return {
133
133
  enabled: ((f = i.cache) == null ? void 0 : f.enabled) ?? !0,
134
134
  ttl: ((A = i.cache) == null ? void 0 : A.ttl) ?? 3e5,
135
135
  // 5 minutes default
136
- storageKey: ((L = i.cache) == null ? void 0 : L.storageKey) ?? `app_cache_${i.appId}`
136
+ storageKey: ((E = i.cache) == null ? void 0 : E.storageKey) ?? `app_cache_${i.appId}`
137
137
  };
138
138
  },
139
139
  [i.cache, i.appId]
140
- ), [r, s] = k(() => {
140
+ ), [r, s] = S(() => {
141
141
  if (!t.enabled) return null;
142
142
  try {
143
143
  const f = localStorage.getItem(t.storageKey);
@@ -147,9 +147,9 @@ function Nt({ config: i, children: e }) {
147
147
  } catch {
148
148
  return null;
149
149
  }
150
- }), [o, a] = k(!r), [p, w] = k(null), y = X(() => {
150
+ }), [o, a] = S(!r), [g, w] = S(null), m = X(() => {
151
151
  const f = () => {
152
- x();
152
+ k();
153
153
  };
154
154
  return {
155
155
  appId: i.appId,
@@ -157,29 +157,29 @@ function Nt({ config: i, children: e }) {
157
157
  // App info
158
158
  appInfo: r,
159
159
  isAppLoading: o,
160
- appError: p,
160
+ appError: g,
161
161
  retryApp: f
162
162
  };
163
- }, [i, r, o, p]), x = se(
163
+ }, [i, r, o, g]), k = se(
164
164
  async (f = !1) => {
165
165
  if (!(!f && t.enabled && r))
166
166
  try {
167
167
  a(!0), w(null);
168
- const A = new re(i.baseUrl), D = await new Pe(A, {}).getPublicAppInfo(i.appId);
169
- if (s(D), t.enabled)
168
+ const A = new re(i.baseUrl), $ = await new Pe(A, {}).getPublicAppInfo(i.appId);
169
+ if (s($), t.enabled)
170
170
  try {
171
- const I = {
172
- data: D,
171
+ const L = {
172
+ data: $,
173
173
  timestamp: Date.now(),
174
174
  appId: i.appId
175
175
  };
176
- localStorage.setItem(t.storageKey, JSON.stringify(I));
177
- } catch (I) {
178
- console.warn("Failed to cache app info:", I);
176
+ localStorage.setItem(t.storageKey, JSON.stringify(L));
177
+ } catch (L) {
178
+ console.warn("Failed to cache app info:", L);
179
179
  }
180
180
  } catch (A) {
181
- const L = A instanceof Error ? A : new Error("Failed to load app information");
182
- w(L), s(null);
181
+ const E = A instanceof Error ? A : new Error("Failed to load app information");
182
+ w(E), s(null);
183
183
  } finally {
184
184
  a(!1);
185
185
  }
@@ -192,10 +192,10 @@ function Nt({ config: i, children: e }) {
192
192
  if (!f) return;
193
193
  const A = JSON.parse(f);
194
194
  if (Date.now() - A.timestamp > t.ttl * 0.5) {
195
- const D = new re(i.baseUrl), M = await new Pe(D, {}).getPublicAppInfo(i.appId);
196
- s(M);
195
+ const $ = new re(i.baseUrl), P = await new Pe($, {}).getPublicAppInfo(i.appId);
196
+ s(P);
197
197
  const u = {
198
- data: M,
198
+ data: P,
199
199
  timestamp: Date.now(),
200
200
  appId: i.appId
201
201
  };
@@ -206,8 +206,8 @@ function Nt({ config: i, children: e }) {
206
206
  }
207
207
  }, [i, t, r]);
208
208
  return te(() => {
209
- r ? b() : x();
210
- }, []), /* @__PURE__ */ n(ve.Provider, { value: y, children: e });
209
+ r ? b() : k();
210
+ }, []), /* @__PURE__ */ n(ve.Provider, { value: m, children: e });
211
211
  }
212
212
  function he() {
213
213
  const i = ne(ve);
@@ -218,7 +218,7 @@ function he() {
218
218
  function Ee() {
219
219
  return ne(ve);
220
220
  }
221
- const Ut = he;
221
+ const qt = he;
222
222
  class be {
223
223
  constructor(e = {}) {
224
224
  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);
@@ -372,7 +372,7 @@ class be {
372
372
  return e !== null && !this.isTokenExpired(e);
373
373
  }
374
374
  }
375
- class _e {
375
+ class Ke {
376
376
  constructor(e) {
377
377
  this.httpService = e;
378
378
  }
@@ -493,7 +493,7 @@ class Me {
493
493
  };
494
494
  }
495
495
  }
496
- class Ge {
496
+ class Je {
497
497
  constructor(e, t) {
498
498
  this.httpService = e, this.sessionManager = t;
499
499
  }
@@ -611,7 +611,7 @@ class de {
611
611
  )).data;
612
612
  }
613
613
  }
614
- function Ke(i, e) {
614
+ function Ye(i, e) {
615
615
  if (i === "localhost" || i.startsWith("127.") || i.startsWith("192.168."))
616
616
  return null;
617
617
  if (e) {
@@ -627,26 +627,26 @@ function Ke(i, e) {
627
627
  const r = i.split(".");
628
628
  return r.length >= 3 && r[0] !== "www" ? r[0] : null;
629
629
  }
630
- function Je(i, e = "tenant", t) {
630
+ function Qe(i, e = "tenant", t) {
631
631
  const s = new URLSearchParams(i).get(e);
632
632
  return s ? (t && t.setItem("tenant", s), s) : t ? t.getItem("tenant") : null;
633
633
  }
634
- function Ye(i, e, t) {
634
+ function Xe(i, e, t) {
635
635
  const { tenantMode: r, baseDomain: s, selectorParam: o } = i;
636
- return r === "subdomain" ? Ke(e.hostname, s) : r === "selector" ? Je(e.search, o, t) : null;
636
+ return r === "subdomain" ? Ye(e.hostname, s) : r === "selector" ? Qe(e.search, o, t) : null;
637
637
  }
638
- function Qe(i, e, t) {
638
+ function Ze(i, e, t) {
639
639
  if (t)
640
640
  return `${i}.${t}`;
641
641
  const r = e.split(".");
642
642
  return r.length === 2 ? `${i}.${e}` : r.length >= 3 ? (r[0] = i, r.join(".")) : null;
643
643
  }
644
644
  const fe = "_auth";
645
- function Xe(i) {
645
+ function et(i) {
646
646
  const e = JSON.stringify(i);
647
647
  return btoa(e).replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, "");
648
648
  }
649
- function Ze(i) {
649
+ function tt(i) {
650
650
  try {
651
651
  let e = i.replace(/-/g, "+").replace(/_/g, "/");
652
652
  for (; e.length % 4; )
@@ -657,7 +657,7 @@ function Ze(i) {
657
657
  return null;
658
658
  }
659
659
  }
660
- function et() {
660
+ function rt() {
661
661
  if (typeof window > "u")
662
662
  return console.log("[CrossDomainAuth] SSR environment, skipping URL token extraction"), null;
663
663
  const e = new URLSearchParams(window.location.search).get(fe);
@@ -666,7 +666,7 @@ function et() {
666
666
  searchParams: window.location.search,
667
667
  encodedLength: e == null ? void 0 : e.length
668
668
  }), !e) return null;
669
- const t = Ze(e);
669
+ const t = tt(e);
670
670
  return console.log("[CrossDomainAuth] Token decode result:", {
671
671
  success: !!t,
672
672
  hasAccessToken: !!(t != null && t.accessToken),
@@ -674,7 +674,7 @@ function et() {
674
674
  expiresIn: t == null ? void 0 : t.expiresIn
675
675
  }), t;
676
676
  }
677
- function tt() {
677
+ function nt() {
678
678
  if (typeof window > "u") return;
679
679
  const i = new URL(window.location.href);
680
680
  i.searchParams.delete(fe), console.log("[CrossDomainAuth] Clearing auth tokens from URL", {
@@ -683,8 +683,8 @@ function tt() {
683
683
  }), window.history.replaceState({}, "", i.toString());
684
684
  }
685
685
  const ke = ue(null);
686
- function Bt({ config: i, children: e }) {
687
- const { baseUrl: t, appInfo: r, appId: s } = he(), o = se(() => typeof window > "u" ? null : Ye(
686
+ function zt({ config: i, children: e }) {
687
+ const { baseUrl: t, appInfo: r, appId: s } = he(), o = se(() => typeof window > "u" ? null : Xe(
688
688
  {
689
689
  tenantMode: i.tenantMode || "selector",
690
690
  baseDomain: i.baseDomain,
@@ -695,118 +695,118 @@ function Bt({ config: i, children: e }) {
695
695
  search: window.location.search
696
696
  },
697
697
  window.localStorage
698
- ), [i.tenantMode, i.baseDomain, i.selectorParam]), [a, p] = k(() => o()), w = X(
698
+ ), [i.tenantMode, i.baseDomain, i.selectorParam]), [a, g] = S(() => o()), w = X(
699
699
  () => {
700
- var d, F, v;
700
+ var c, R, T;
701
701
  return {
702
- enabled: ((d = i.cache) == null ? void 0 : d.enabled) ?? !0,
703
- ttl: ((F = i.cache) == null ? void 0 : F.ttl) ?? 5 * 60 * 1e3,
702
+ enabled: ((c = i.cache) == null ? void 0 : c.enabled) ?? !0,
703
+ ttl: ((R = i.cache) == null ? void 0 : R.ttl) ?? 5 * 60 * 1e3,
704
704
  // 5 minutes default
705
- storageKey: ((v = i.cache) == null ? void 0 : v.storageKey) ?? `tenant_cache_${a || "default"}`
705
+ storageKey: ((T = i.cache) == null ? void 0 : T.storageKey) ?? `tenant_cache_${a || "default"}`
706
706
  };
707
707
  },
708
708
  [i.cache, a]
709
- ), [y, x] = k(() => {
709
+ ), [m, k] = S(() => {
710
710
  if (i.initialTenant) return i.initialTenant;
711
711
  if (!w.enabled || !a) return null;
712
712
  try {
713
- const d = localStorage.getItem(w.storageKey);
714
- if (!d) return null;
715
- const F = JSON.parse(d);
716
- return Date.now() - F.timestamp < w.ttl && F.tenantSlug === a ? F.data : (localStorage.removeItem(w.storageKey), null);
713
+ const c = localStorage.getItem(w.storageKey);
714
+ if (!c) return null;
715
+ const R = JSON.parse(c);
716
+ return Date.now() - R.timestamp < w.ttl && R.tenantSlug === a ? R.data : (localStorage.removeItem(w.storageKey), null);
717
717
  } catch {
718
718
  return null;
719
719
  }
720
- }), [b, f] = k(!y && !i.initialTenant), [A, L] = k(null), [D, I] = k(null), [M, u] = k(!1), [R, m] = k(null);
720
+ }), [b, f] = S(!m && !i.initialTenant), [A, E] = S(null), [$, L] = S(null), [P, u] = S(!1), [M, z] = S(null);
721
721
  te(() => {
722
- const d = o();
723
- p(d);
722
+ const c = o();
723
+ g(c);
724
724
  }, [o]);
725
- const H = (r == null ? void 0 : r.settingsSchema) || null, $ = se(
726
- async (d, F = !1) => {
727
- if (!(!F && w.enabled && y && y.domain === d))
725
+ const N = (r == null ? void 0 : r.settingsSchema) || null, p = se(
726
+ async (c, R = !1) => {
727
+ if (!(!R && w.enabled && m && m.domain === c))
728
728
  try {
729
- f(!0), L(null);
730
- const v = new re(t), g = await new de(v, s).getPublicTenantInfo(d);
731
- if (x(g), w.enabled)
729
+ f(!0), E(null);
730
+ const T = new re(t), d = await new de(T, s).getPublicTenantInfo(c);
731
+ if (k(d), w.enabled)
732
732
  try {
733
- const c = {
734
- data: g,
733
+ const y = {
734
+ data: d,
735
735
  timestamp: Date.now(),
736
- tenantSlug: d
736
+ tenantSlug: c
737
737
  };
738
- localStorage.setItem(w.storageKey, JSON.stringify(c));
739
- } catch (c) {
740
- console.warn("Failed to cache tenant info:", c);
738
+ localStorage.setItem(w.storageKey, JSON.stringify(y));
739
+ } catch (y) {
740
+ console.warn("Failed to cache tenant info:", y);
741
741
  }
742
- } catch (v) {
743
- const h = v instanceof Error ? v : new Error("Failed to load tenant information");
744
- L(h), x(null);
742
+ } catch (T) {
743
+ const h = T instanceof Error ? T : new Error("Failed to load tenant information");
744
+ E(h), k(null);
745
745
  } finally {
746
746
  f(!1);
747
747
  }
748
748
  },
749
- [t, s, w, y]
750
- ), C = se(async () => {
751
- if (!(!w.enabled || !y || !a))
749
+ [t, s, w, m]
750
+ ), O = se(async () => {
751
+ if (!(!w.enabled || !m || !a))
752
752
  try {
753
- const d = localStorage.getItem(w.storageKey);
754
- if (!d) return;
755
- const F = JSON.parse(d);
756
- if (Date.now() - F.timestamp > w.ttl * 0.5) {
757
- const h = new re(t), c = await new de(h, s).getPublicTenantInfo(a);
758
- x(c);
759
- const j = {
760
- data: c,
753
+ const c = localStorage.getItem(w.storageKey);
754
+ if (!c) return;
755
+ const R = JSON.parse(c);
756
+ if (Date.now() - R.timestamp > w.ttl * 0.5) {
757
+ const h = new re(t), y = await new de(h, s).getPublicTenantInfo(a);
758
+ k(y);
759
+ const G = {
760
+ data: y,
761
761
  timestamp: Date.now(),
762
762
  tenantSlug: a
763
763
  };
764
- localStorage.setItem(w.storageKey, JSON.stringify(j));
764
+ localStorage.setItem(w.storageKey, JSON.stringify(G));
765
765
  }
766
- } catch (d) {
767
- console.warn("Background tenant refresh failed:", d);
766
+ } catch (c) {
767
+ console.warn("Background tenant refresh failed:", c);
768
768
  }
769
- }, [t, s, w, y, a]), T = se(async () => {
770
- if (y != null && y.id)
769
+ }, [t, s, w, m, a]), v = se(async () => {
770
+ if (m != null && m.id)
771
771
  try {
772
- u(!0), m(null);
773
- const d = new re(t), v = await new de(d, y.appId).getTenantSettings(y.id);
774
- I(v);
775
- } catch (d) {
776
- const F = d instanceof Error ? d : new Error("Failed to load tenant settings");
777
- m(F), I(null);
772
+ u(!0), z(null);
773
+ const c = new re(t), T = await new de(c, m.appId).getTenantSettings(m.id);
774
+ L(T);
775
+ } catch (c) {
776
+ const R = c instanceof Error ? c : new Error("Failed to load tenant settings");
777
+ z(R), L(null);
778
778
  } finally {
779
779
  u(!1);
780
780
  }
781
- }, [t, y]), q = se(() => {
782
- T();
783
- }, [T]), S = se(
784
- (d) => {
785
- if (!H)
781
+ }, [t, m]), C = se(() => {
782
+ v();
783
+ }, [v]), x = se(
784
+ (c) => {
785
+ if (!N)
786
786
  return { isValid: !0, errors: [] };
787
- const F = [];
787
+ const R = [];
788
788
  try {
789
- return H.properties && Object.entries(H.properties).forEach(([v, h]) => {
790
- var c;
791
- const g = d[v];
792
- if ((c = H.required) != null && c.includes(v) && g == null) {
793
- F.push(`Field '${v}' is required`);
789
+ return N.properties && Object.entries(N.properties).forEach(([T, h]) => {
790
+ var y;
791
+ const d = c[T];
792
+ if ((y = N.required) != null && y.includes(T) && d == null) {
793
+ R.push(`Field '${T}' is required`);
794
794
  return;
795
795
  }
796
- if (g != null) {
796
+ if (d != null) {
797
797
  if (h.type) {
798
- const j = h.type, K = typeof g;
799
- j === "string" && K !== "string" ? F.push(`Field '${v}' must be a string`) : (j === "number" || j === "integer") && K !== "number" ? F.push(`Field '${v}' must be a number`) : j === "boolean" && K !== "boolean" ? F.push(`Field '${v}' must be a boolean`) : j === "array" && !Array.isArray(g) && F.push(`Field '${v}' must be an array`);
798
+ const G = h.type, D = typeof d;
799
+ G === "string" && D !== "string" ? R.push(`Field '${T}' must be a string`) : (G === "number" || G === "integer") && D !== "number" ? R.push(`Field '${T}' must be a number`) : G === "boolean" && D !== "boolean" ? R.push(`Field '${T}' must be a boolean`) : G === "array" && !Array.isArray(d) && R.push(`Field '${T}' must be an array`);
800
800
  }
801
- h.minLength !== void 0 && typeof g == "string" && g.length < h.minLength && F.push(
802
- `Field '${v}' must be at least ${h.minLength} characters long`
803
- ), h.maxLength !== void 0 && typeof g == "string" && g.length > h.maxLength && F.push(
804
- `Field '${v}' must be no more than ${h.maxLength} characters long`
805
- ), h.minimum !== void 0 && typeof g == "number" && g < h.minimum && F.push(`Field '${v}' must be at least ${h.minimum}`), h.maximum !== void 0 && typeof g == "number" && g > h.maximum && F.push(`Field '${v}' must be no more than ${h.maximum}`), h.pattern && typeof g == "string" && (new RegExp(h.pattern).test(g) || F.push(`Field '${v}' does not match the required pattern`)), h.enum && !h.enum.includes(g) && F.push(`Field '${v}' must be one of: ${h.enum.join(", ")}`);
801
+ h.minLength !== void 0 && typeof d == "string" && d.length < h.minLength && R.push(
802
+ `Field '${T}' must be at least ${h.minLength} characters long`
803
+ ), h.maxLength !== void 0 && typeof d == "string" && d.length > h.maxLength && R.push(
804
+ `Field '${T}' must be no more than ${h.maxLength} characters long`
805
+ ), h.minimum !== void 0 && typeof d == "number" && d < h.minimum && R.push(`Field '${T}' must be at least ${h.minimum}`), h.maximum !== void 0 && typeof d == "number" && d > h.maximum && R.push(`Field '${T}' must be no more than ${h.maximum}`), h.pattern && typeof d == "string" && (new RegExp(h.pattern).test(d) || R.push(`Field '${T}' does not match the required pattern`)), h.enum && !h.enum.includes(d) && R.push(`Field '${T}' must be one of: ${h.enum.join(", ")}`);
806
806
  }
807
807
  }), {
808
- isValid: F.length === 0,
809
- errors: F
808
+ isValid: R.length === 0,
809
+ errors: R
810
810
  };
811
811
  } catch {
812
812
  return {
@@ -815,78 +815,78 @@ function Bt({ config: i, children: e }) {
815
815
  };
816
816
  }
817
817
  },
818
- [H]
818
+ [N]
819
819
  );
820
820
  te(() => {
821
- !i.initialTenant && a ? y ? C() : $(a) : !i.initialTenant && !a && (x(null), L(null), f(!1));
822
- }, [i.initialTenant, a, y, $, C]), te(() => {
823
- y != null && y.id ? T() : (I(null), m(null), u(!1));
824
- }, [y == null ? void 0 : y.id, T]);
825
- const P = se(
826
- (d, F) => {
827
- const { mode: v = "reload", tokens: h, redirectPath: g } = F || {}, c = i.tenantMode || "selector";
828
- if (localStorage.setItem("tenant", d), c === "subdomain") {
829
- const j = window.location.hostname, K = Qe(
830
- d,
831
- j,
821
+ !i.initialTenant && a ? m ? O() : p(a) : !i.initialTenant && !a && (k(null), E(null), f(!1));
822
+ }, [i.initialTenant, a, m, p, O]), te(() => {
823
+ m != null && m.id ? v() : (L(null), z(null), u(!1));
824
+ }, [m == null ? void 0 : m.id, v]);
825
+ const I = se(
826
+ (c, R) => {
827
+ const { mode: T = "reload", tokens: h, redirectPath: d } = R || {}, y = i.tenantMode || "selector";
828
+ if (localStorage.setItem("tenant", c), y === "subdomain") {
829
+ const G = window.location.hostname, D = Ze(
830
+ c,
831
+ G,
832
832
  i.baseDomain
833
833
  );
834
- if (!K) {
834
+ if (!D) {
835
835
  console.warn(
836
836
  "[TenantProvider] Cannot switch subdomain, invalid hostname:",
837
- j
837
+ G
838
838
  );
839
839
  return;
840
840
  }
841
- const N = g || window.location.pathname, z = new URL(`${window.location.protocol}//${K}${N}`);
842
- new URLSearchParams(window.location.search).forEach((U, J) => {
843
- J !== fe && z.searchParams.set(J, U);
844
- }), h && z.searchParams.set(fe, Xe(h)), window.location.href = z.toString();
845
- } else if (c === "selector") {
846
- const j = g || window.location.pathname, K = new URLSearchParams(window.location.search);
847
- if (K.set(i.selectorParam || "tenant", d), v === "reload") {
848
- const N = `${j}?${K.toString()}${window.location.hash}`;
849
- window.location.href = N;
841
+ const H = d || window.location.pathname, U = new URL(`${window.location.protocol}//${D}${H}`);
842
+ new URLSearchParams(window.location.search).forEach((B, J) => {
843
+ J !== fe && U.searchParams.set(J, B);
844
+ }), h && U.searchParams.set(fe, et(h)), window.location.href = U.toString();
845
+ } else if (y === "selector") {
846
+ const G = d || window.location.pathname, D = new URLSearchParams(window.location.search);
847
+ if (D.set(i.selectorParam || "tenant", c), T === "reload") {
848
+ const H = `${G}?${D.toString()}${window.location.hash}`;
849
+ window.location.href = H;
850
850
  } else {
851
- const N = `${j}?${K.toString()}${window.location.hash}`;
852
- window.history.pushState({}, "", N), p(d), $(d);
851
+ const H = `${G}?${D.toString()}${window.location.hash}`;
852
+ window.history.pushState({}, "", H), g(c), p(c);
853
853
  }
854
854
  }
855
855
  },
856
- [i.tenantMode, i.selectorParam, i.baseDomain, $]
857
- ), E = X(() => ({
856
+ [i.tenantMode, i.selectorParam, i.baseDomain, p]
857
+ ), F = X(() => ({
858
858
  // Tenant info
859
- tenant: y,
859
+ tenant: m,
860
860
  tenantSlug: a,
861
861
  isTenantLoading: b,
862
862
  tenantError: A,
863
863
  retryTenant: () => {
864
- a && $(a);
864
+ a && p(a);
865
865
  },
866
866
  // Settings
867
- settings: D,
868
- settingsSchema: H,
869
- isSettingsLoading: M,
870
- settingsError: R,
867
+ settings: $,
868
+ settingsSchema: N,
869
+ isSettingsLoading: P,
870
+ settingsError: M,
871
871
  // Actions
872
- refreshSettings: q,
873
- switchTenant: P,
872
+ refreshSettings: C,
873
+ switchTenant: I,
874
874
  // Validation
875
- validateSettings: S
875
+ validateSettings: x
876
876
  }), [
877
- y,
877
+ m,
878
878
  a,
879
879
  b,
880
880
  A,
881
- D,
882
- H,
883
- M,
884
- R,
885
- q,
881
+ $,
882
+ N,
886
883
  P,
887
- S
884
+ M,
885
+ C,
886
+ I,
887
+ x
888
888
  ]);
889
- return /* @__PURE__ */ n(ke.Provider, { value: E, children: e });
889
+ return /* @__PURE__ */ n(ke.Provider, { value: F, children: e });
890
890
  }
891
891
  function me() {
892
892
  const i = ne(ke);
@@ -897,8 +897,8 @@ function me() {
897
897
  function ye() {
898
898
  return ne(ke);
899
899
  }
900
- const qt = me;
901
- function zt() {
900
+ const Ot = me;
901
+ function Wt() {
902
902
  const { settings: i, settingsSchema: e, isSettingsLoading: t, settingsError: r, validateSettings: s } = me();
903
903
  return {
904
904
  settings: i,
@@ -919,53 +919,58 @@ function le() {
919
919
  };
920
920
  }
921
921
  const xe = ue(null);
922
- function Ot({ config: i = {}, children: e }) {
923
- const { appId: t, baseUrl: r } = he(), { tenant: s, tenantSlug: o, switchTenant: a } = me(), [p, w] = k(i.initialRoles || []), [y, x] = k(!i.initialRoles), [b, f] = k(null), [A, L] = k(!1), [D, I] = k(null), [M, u] = k(0), R = Ve({ done: !1, urlTokens: null });
924
- R.current.done || (R.current.done = !0, R.current.urlTokens = et(), R.current.urlTokens && console.log("[AuthProvider] SYNC: URL tokens found"));
925
- const m = X(() => {
926
- const c = new be({
922
+ function jt({ config: i = {}, children: e }) {
923
+ const { appId: t, baseUrl: r } = he(), { tenant: s, tenantSlug: o, switchTenant: a } = me(), [g, w] = S(i.initialRoles || []), [m, k] = S(!i.initialRoles), [b, f] = S(null), [A, E] = S(!1), [$, L] = S(null), [P, u] = S(0), M = Ge({ done: !1, urlTokens: null });
924
+ M.current.done || (M.current.done = !0, M.current.urlTokens = rt(), M.current.urlTokens && console.log(
925
+ "[AuthProvider] SYNC: URL tokens found, will block isAuthReady until user loaded"
926
+ ));
927
+ const [z, N] = S(() => {
928
+ const D = M.current.urlTokens !== null;
929
+ return console.log("[AuthProvider] SYNC: isLoadingAfterUrlTokens initial:", D), D;
930
+ }), p = X(() => {
931
+ const D = new be({
927
932
  tenantSlug: o,
928
933
  onRefreshFailed: i.onRefreshFailed,
929
934
  baseUrl: r
930
935
  });
931
- return R.current.urlTokens && (console.log("[AuthProvider] SYNC: Saving URL tokens to session manager"), c.setTokens({
932
- accessToken: R.current.urlTokens.accessToken,
933
- refreshToken: R.current.urlTokens.refreshToken,
934
- expiresIn: R.current.urlTokens.expiresIn
935
- }), console.log("[AuthProvider] SYNC: Session valid:", c.hasValidSession())), c;
936
- }, [o, r, i.onRefreshFailed]), H = R.current.done, $ = X(() => {
937
- const c = new re(r);
938
- return c.setSessionManager(m), c;
939
- }, [r, m]), C = X(() => new _e(new re(r)), [r]), T = X(() => new Ge($, m), [$, m]), q = X(() => new Me(new re(r)), [r]), S = X(() => b || m.getUser(), [b, m]), P = X(() => S != null && S.roleId && p.find((c) => c.id === S.roleId) || null, [S, p]), E = X(() => (P == null ? void 0 : P.permissions) || [], [P]), d = X(() => m.hasValidSession() && b !== null, [m, b]), F = 5 * 60 * 1e3, v = X(() => {
940
- const c = async (B = !1) => {
936
+ return M.current.urlTokens && (console.log("[AuthProvider] SYNC: Saving URL tokens to session manager"), D.setTokens({
937
+ accessToken: M.current.urlTokens.accessToken,
938
+ refreshToken: M.current.urlTokens.refreshToken,
939
+ expiresIn: M.current.urlTokens.expiresIn
940
+ }), console.log("[AuthProvider] SYNC: Session valid:", D.hasValidSession())), D;
941
+ }, [o, r, i.onRefreshFailed]), O = M.current.done && !z, v = X(() => {
942
+ const D = new re(r);
943
+ return D.setSessionManager(p), D;
944
+ }, [r, p]), C = X(() => new Ke(new re(r)), [r]), x = X(() => new Je(v, p), [v, p]), I = X(() => new Me(new re(r)), [r]), F = X(() => b || p.getUser(), [b, p]), c = X(() => F != null && F.roleId && g.find((D) => D.id === F.roleId) || null, [F, g]), R = X(() => (c == null ? void 0 : c.permissions) || [], [c]), T = X(() => p.hasValidSession() && b !== null, [p, b]), h = 5 * 60 * 1e3, d = X(() => {
945
+ const D = async (q = !1) => {
941
946
  try {
942
- if (!m.hasValidSession())
947
+ if (!p.hasValidSession())
943
948
  return;
944
- const O = Date.now();
945
- if (!B && O - M < F && b)
949
+ const W = Date.now();
950
+ if (!q && W - P < h && b)
946
951
  return;
947
- const _ = m.getUserId();
952
+ const _ = p.getUserId();
948
953
  if (!_) {
949
954
  console.warn("[AuthProvider] No userId available in token or storage");
950
955
  return;
951
956
  }
952
- L(!0), I(null);
953
- const Z = await T.getUserById(_);
954
- f(Z), m.setUser(Z), u(Date.now());
955
- } catch (O) {
956
- const Y = O instanceof Error ? O : new Error("Failed to load user data");
957
- I(Y), console.error("[AuthProvider] Failed to load user data:", Y);
957
+ E(!0), L(null);
958
+ const Z = await x.getUserById(_);
959
+ f(Z), p.setUser(Z), u(Date.now());
960
+ } catch (W) {
961
+ const Y = W instanceof Error ? W : new Error("Failed to load user data");
962
+ L(Y), console.error("[AuthProvider] Failed to load user data:", Y);
958
963
  } finally {
959
- L(!1);
964
+ E(!1);
960
965
  }
961
- }, j = async () => {
962
- await c();
963
- }, K = async (B) => {
964
- const { username: O, password: Y, tenantSlug: _ } = B;
965
- let Z = s == null ? void 0 : s.id, Q = o, ee = m;
966
- _ && (Z = (await new de($, t).getPublicTenantInfo(_)).id, Q = _);
967
- const G = await C.login({
968
- username: O,
966
+ }, H = async () => {
967
+ await D();
968
+ }, U = async (q) => {
969
+ const { username: W, password: Y, tenantSlug: _ } = q;
970
+ let Z = s == null ? void 0 : s.id, Q = o, ee = p;
971
+ _ && (Z = (await new de(v, t).getPublicTenantInfo(_)).id, Q = _);
972
+ const K = await C.login({
973
+ username: W,
969
974
  password: Y,
970
975
  appId: t,
971
976
  tenantId: Z
@@ -974,48 +979,48 @@ function Ot({ config: i = {}, children: e }) {
974
979
  tenantSlug: Q,
975
980
  baseUrl: r
976
981
  })), ee.setTokens({
977
- accessToken: G.accessToken,
978
- refreshToken: G.refreshToken,
979
- expiresIn: G.expiresIn
980
- }), G.user) {
981
- ee.setUser(G.user), f(G.user);
982
+ accessToken: K.accessToken,
983
+ refreshToken: K.refreshToken,
984
+ expiresIn: K.expiresIn
985
+ }), K.user) {
986
+ ee.setUser(K.user), f(K.user);
982
987
  try {
983
- await c();
988
+ await D();
984
989
  } catch (ce) {
985
990
  console.warn("Failed to load complete user data after login:", ce);
986
991
  }
987
992
  }
988
993
  return ae && Q && Q !== o && a(Q, {
989
994
  tokens: {
990
- accessToken: G.accessToken,
991
- refreshToken: G.refreshToken,
992
- expiresIn: G.expiresIn
995
+ accessToken: K.accessToken,
996
+ refreshToken: K.refreshToken,
997
+ expiresIn: K.expiresIn
993
998
  }
994
- }), G;
995
- }, N = async (B) => {
996
- const { email: O, phoneNumber: Y, name: _, password: Z, lastName: Q, tenantId: ee } = B;
997
- if (!O && !Y)
999
+ }), K;
1000
+ }, V = async (q) => {
1001
+ const { email: W, phoneNumber: Y, name: _, password: Z, lastName: Q, tenantId: ee } = q;
1002
+ if (!W && !Y)
998
1003
  throw new Error("Either email or phoneNumber is required");
999
1004
  if (!_ || !Z)
1000
1005
  throw new Error("Name and password are required");
1001
- const G = ee ?? (s == null ? void 0 : s.id);
1006
+ const K = ee ?? (s == null ? void 0 : s.id);
1002
1007
  return await C.signup({
1003
- email: O,
1008
+ email: W,
1004
1009
  phoneNumber: Y,
1005
1010
  name: _,
1006
1011
  password: Z,
1007
- tenantId: G,
1012
+ tenantId: K,
1008
1013
  lastName: Q,
1009
1014
  appId: t
1010
1015
  });
1011
- }, z = async (B) => {
1012
- const { email: O, phoneNumber: Y, name: _, password: Z, tenantName: Q, lastName: ee } = B;
1013
- if (!O && !Y)
1016
+ }, B = async (q) => {
1017
+ const { email: W, phoneNumber: Y, name: _, password: Z, tenantName: Q, lastName: ee } = q;
1018
+ if (!W && !Y)
1014
1019
  throw new Error("Either email or phoneNumber is required");
1015
1020
  if (!_ || !Z || !Q)
1016
1021
  throw new Error("Name, password, and tenantName are required");
1017
1022
  return await C.signupTenantAdmin({
1018
- email: O,
1023
+ email: W,
1019
1024
  phoneNumber: Y,
1020
1025
  name: _,
1021
1026
  password: Z,
@@ -1023,35 +1028,35 @@ function Ot({ config: i = {}, children: e }) {
1023
1028
  appId: t,
1024
1029
  lastName: ee
1025
1030
  });
1026
- }, V = async (B) => {
1027
- const { currentPassword: O, newPassword: Y } = B, _ = await m.getAuthHeaders();
1028
- await C.changePassword({ currentPassword: O, newPassword: Y }, _);
1029
- }, U = async (B) => {
1030
- const { email: O, tenantId: Y } = B, _ = Y ?? (s == null ? void 0 : s.id);
1031
+ }, J = async (q) => {
1032
+ const { currentPassword: W, newPassword: Y } = q, _ = await p.getAuthHeaders();
1033
+ await C.changePassword({ currentPassword: W, newPassword: Y }, _);
1034
+ }, ge = async (q) => {
1035
+ const { email: W, tenantId: Y } = q, _ = Y ?? (s == null ? void 0 : s.id);
1031
1036
  if (!_)
1032
1037
  throw new Error("tenantId is required for password reset");
1033
- await C.requestPasswordReset({ email: O, tenantId: _ });
1034
- }, J = async (B) => {
1035
- const { token: O, newPassword: Y } = B;
1036
- await C.confirmPasswordReset({ token: O, newPassword: Y });
1037
- }, ge = async (B) => {
1038
- const { email: O, frontendUrl: Y, name: _, lastName: Z, tenantId: Q } = B, ee = Q ?? (s == null ? void 0 : s.id);
1038
+ await C.requestPasswordReset({ email: W, tenantId: _ });
1039
+ }, He = async (q) => {
1040
+ const { token: W, newPassword: Y } = q;
1041
+ await C.confirmPasswordReset({ token: W, newPassword: Y });
1042
+ }, Ne = async (q) => {
1043
+ const { email: W, frontendUrl: Y, name: _, lastName: Z, tenantId: Q } = q, ee = Q ?? (s == null ? void 0 : s.id);
1039
1044
  if (!ee)
1040
1045
  throw new Error("tenantId is required for magic link authentication");
1041
1046
  return await C.sendMagicLink({
1042
- email: O,
1047
+ email: W,
1043
1048
  tenantId: ee,
1044
1049
  frontendUrl: Y,
1045
1050
  name: _,
1046
1051
  lastName: Z,
1047
1052
  appId: t
1048
1053
  });
1049
- }, He = async (B) => {
1050
- const { token: O, email: Y, tenantSlug: _ } = B;
1051
- let Z = s == null ? void 0 : s.id, Q = o, ee = m;
1052
- _ && (Z = (await new de($, t).getPublicTenantInfo(_)).id, Q = _);
1053
- const G = await C.verifyMagicLink({
1054
- token: O,
1054
+ }, Ue = async (q) => {
1055
+ const { token: W, email: Y, tenantSlug: _ } = q;
1056
+ let Z = s == null ? void 0 : s.id, Q = o, ee = p;
1057
+ _ && (Z = (await new de(v, t).getPublicTenantInfo(_)).id, Q = _);
1058
+ const K = await C.verifyMagicLink({
1059
+ token: W,
1055
1060
  email: Y,
1056
1061
  appId: t,
1057
1062
  tenantId: Z
@@ -1060,152 +1065,154 @@ function Ot({ config: i = {}, children: e }) {
1060
1065
  tenantSlug: Q,
1061
1066
  baseUrl: r
1062
1067
  })), ee.setTokens({
1063
- accessToken: G.accessToken,
1064
- refreshToken: G.refreshToken,
1065
- expiresIn: G.expiresIn
1066
- }), G.user) {
1067
- ee.setUser(G.user), f(G.user);
1068
+ accessToken: K.accessToken,
1069
+ refreshToken: K.refreshToken,
1070
+ expiresIn: K.expiresIn
1071
+ }), K.user) {
1072
+ ee.setUser(K.user), f(K.user);
1068
1073
  try {
1069
- await c();
1074
+ await D();
1070
1075
  } catch (ce) {
1071
1076
  console.warn("Failed to load complete user data after magic link login:", ce);
1072
1077
  }
1073
1078
  }
1074
1079
  return ae && Q && Q !== o && a(Q, {
1075
1080
  tokens: {
1076
- accessToken: G.accessToken,
1077
- refreshToken: G.refreshToken,
1078
- expiresIn: G.expiresIn
1081
+ accessToken: K.accessToken,
1082
+ refreshToken: K.refreshToken,
1083
+ expiresIn: K.expiresIn
1079
1084
  }
1080
- }), G;
1081
- }, Ne = async () => {
1082
- const B = m.getTokens();
1083
- if (!(B != null && B.refreshToken))
1085
+ }), K;
1086
+ }, Be = async () => {
1087
+ const q = p.getTokens();
1088
+ if (!(q != null && q.refreshToken))
1084
1089
  throw new Error("No refresh token available");
1085
- const O = await C.refreshToken({
1086
- refreshToken: B.refreshToken
1090
+ const W = await C.refreshToken({
1091
+ refreshToken: q.refreshToken
1087
1092
  });
1088
- m.setTokens({
1089
- accessToken: O.accessToken,
1090
- refreshToken: O.refreshToken || B.refreshToken,
1091
- expiresIn: O.expiresIn
1093
+ p.setTokens({
1094
+ accessToken: W.accessToken,
1095
+ refreshToken: W.refreshToken || q.refreshToken,
1096
+ expiresIn: W.expiresIn
1092
1097
  });
1093
- }, Ue = () => {
1094
- m.clearSession(), f(null), I(null);
1095
- }, Be = (B) => {
1096
- m.setTokens(B);
1097
- }, qe = () => m.hasValidSession(), ze = () => {
1098
- m.clearSession(), f(null), I(null);
1099
- }, Oe = async () => {
1098
+ }, qe = () => {
1099
+ p.clearSession(), f(null), L(null);
1100
+ }, ze = (q) => {
1101
+ p.setTokens(q);
1102
+ }, Oe = () => p.hasValidSession(), We = () => {
1103
+ p.clearSession(), f(null), L(null);
1104
+ }, je = async () => {
1100
1105
  if (t)
1101
1106
  try {
1102
- x(!0);
1103
- const { roles: B } = await q.getRolesByApp(t);
1104
- w(B);
1105
- } catch (B) {
1106
- console.error("Failed to fetch roles:", B);
1107
+ k(!0);
1108
+ const { roles: q } = await I.getRolesByApp(t);
1109
+ w(q);
1110
+ } catch (q) {
1111
+ console.error("Failed to fetch roles:", q);
1107
1112
  } finally {
1108
- x(!1);
1113
+ k(!1);
1109
1114
  }
1110
- }, We = async () => {
1111
- await Oe();
1112
- }, we = (B) => {
1113
- if (!E || E.length === 0)
1115
+ }, Ve = async () => {
1116
+ await je();
1117
+ }, we = (q) => {
1118
+ if (!R || R.length === 0)
1114
1119
  return !1;
1115
- if (typeof B == "string")
1116
- return E.includes(B);
1117
- const O = `${B.resource}.${B.action}`;
1118
- return E.includes(O);
1120
+ if (typeof q == "string")
1121
+ return R.includes(q);
1122
+ const W = `${q.resource}.${q.action}`;
1123
+ return R.includes(W);
1119
1124
  };
1120
1125
  return {
1121
1126
  // RFC-003: Authentication state
1122
- isAuthenticated: d,
1123
- sessionManager: m,
1124
- authenticatedHttpService: $,
1125
- login: K,
1126
- signup: N,
1127
- signupTenantAdmin: z,
1128
- sendMagicLink: ge,
1129
- verifyMagicLink: He,
1130
- changePassword: V,
1131
- requestPasswordReset: U,
1132
- confirmPasswordReset: J,
1133
- refreshToken: Ne,
1134
- logout: Ue,
1135
- setTokens: Be,
1136
- hasValidSession: qe,
1137
- clearSession: ze,
1127
+ isAuthenticated: T,
1128
+ sessionManager: p,
1129
+ authenticatedHttpService: v,
1130
+ login: U,
1131
+ signup: V,
1132
+ signupTenantAdmin: B,
1133
+ sendMagicLink: Ne,
1134
+ verifyMagicLink: Ue,
1135
+ changePassword: J,
1136
+ requestPasswordReset: ge,
1137
+ confirmPasswordReset: He,
1138
+ refreshToken: Be,
1139
+ logout: qe,
1140
+ setTokens: ze,
1141
+ hasValidSession: Oe,
1142
+ clearSession: We,
1138
1143
  currentUser: b,
1139
1144
  isUserLoading: A,
1140
- userError: D,
1141
- loadUserData: c,
1142
- refreshUser: j,
1143
- isAuthInitializing: !H,
1144
- isAuthReady: H,
1145
- userRole: P,
1146
- userPermissions: E,
1147
- availableRoles: p,
1148
- rolesLoading: y,
1145
+ userError: $,
1146
+ loadUserData: D,
1147
+ refreshUser: H,
1148
+ isAuthInitializing: !O,
1149
+ isAuthReady: O,
1150
+ userRole: c,
1151
+ userPermissions: R,
1152
+ availableRoles: g,
1153
+ rolesLoading: m,
1149
1154
  hasPermission: we,
1150
- hasAnyPermission: (B) => B.some((O) => we(O)),
1151
- hasAllPermissions: (B) => B.every((O) => we(O)),
1152
- getUserPermissionStrings: () => E || [],
1153
- refreshRoles: We
1155
+ hasAnyPermission: (q) => q.some((W) => we(W)),
1156
+ hasAllPermissions: (q) => q.every((W) => we(W)),
1157
+ getUserPermissionStrings: () => R || [],
1158
+ refreshRoles: Ve
1154
1159
  };
1155
1160
  }, [
1156
- d,
1157
- m,
1158
- $,
1159
- C,
1160
1161
  T,
1161
- q,
1162
+ p,
1163
+ v,
1164
+ C,
1165
+ x,
1166
+ I,
1162
1167
  t,
1163
1168
  s,
1164
1169
  o,
1165
1170
  a,
1166
- p,
1171
+ g,
1167
1172
  b,
1168
1173
  A,
1169
- D,
1170
- H,
1174
+ $,
1175
+ O,
1176
+ c,
1177
+ R,
1171
1178
  P,
1172
- E,
1173
- M,
1174
- F
1179
+ h
1175
1180
  ]);
1176
1181
  te(() => {
1177
1182
  !i.initialRoles && t && (async () => {
1178
1183
  try {
1179
- x(!0);
1180
- const j = new re(r), K = new Me(j), { roles: N } = await K.getRolesByApp(t);
1181
- w(N);
1182
- } catch (j) {
1183
- console.error("Failed to fetch roles:", j);
1184
+ k(!0);
1185
+ const H = new re(r), U = new Me(H), { roles: V } = await U.getRolesByApp(t);
1186
+ w(V);
1187
+ } catch (H) {
1188
+ console.error("Failed to fetch roles:", H);
1184
1189
  } finally {
1185
- x(!1);
1190
+ k(!1);
1186
1191
  }
1187
1192
  })();
1188
1193
  }, [t, r, i.initialRoles]);
1189
- const [h, g] = k(!1);
1194
+ const [y, G] = S(!1);
1190
1195
  return te(() => {
1191
- h || (g(!0), R.current.urlTokens && (console.log("[AuthProvider] EFFECT: Cleaning up URL after sync token processing"), tt(), console.log("[AuthProvider] EFFECT: Loading user data..."), v.loadUserData().catch((c) => {
1192
- console.error("[AuthProvider] Failed to load user data:", c);
1196
+ y || (G(!0), M.current.urlTokens && (console.log("[AuthProvider] EFFECT: Cleaning up URL after sync token processing"), nt(), N(!0), console.log("[AuthProvider] EFFECT: Loading user data (blocking isAuthReady)..."), d.loadUserData().catch((D) => {
1197
+ console.error("[AuthProvider] Failed to load user data:", D);
1198
+ }).finally(() => {
1199
+ console.log("[AuthProvider] EFFECT: User data loaded, releasing isAuthReady"), N(!1);
1193
1200
  })));
1194
- }, [v, h]), te(() => {
1195
- const c = m.getUser();
1196
- c && m.hasValidSession() && f(c);
1197
- }, [m]), te(() => {
1198
- h && (R.current.urlTokens || !b && !A && m.hasValidSession() && (console.log("[AuthProvider] Auto-loading user data..."), v.loadUserData().catch(() => {
1201
+ }, [d, y]), te(() => {
1202
+ const D = p.getUser();
1203
+ D && p.hasValidSession() && f(D);
1204
+ }, [p]), te(() => {
1205
+ y && (M.current.urlTokens || !b && !A && p.hasValidSession() && (console.log("[AuthProvider] Auto-loading user data..."), d.loadUserData().catch(() => {
1199
1206
  })));
1200
- }, [b, A, v, m, h]), te(() => {
1201
- if (!m.hasValidSession() || !b)
1207
+ }, [b, A, d, p, y]), te(() => {
1208
+ if (!p.hasValidSession() || !b)
1202
1209
  return;
1203
- const c = setInterval(() => {
1204
- v.loadUserData().catch(() => {
1210
+ const D = setInterval(() => {
1211
+ d.loadUserData().catch(() => {
1205
1212
  });
1206
- }, F);
1207
- return () => clearInterval(c);
1208
- }, [m, b, v, F]), /* @__PURE__ */ n(xe.Provider, { value: v, children: e });
1213
+ }, h);
1214
+ return () => clearInterval(D);
1215
+ }, [p, b, d, h]), /* @__PURE__ */ n(xe.Provider, { value: d, children: e });
1209
1216
  }
1210
1217
  function oe() {
1211
1218
  const i = ne(xe);
@@ -1216,7 +1223,7 @@ function oe() {
1216
1223
  function Fe() {
1217
1224
  return ne(xe);
1218
1225
  }
1219
- class rt {
1226
+ class st {
1220
1227
  constructor(e, t) {
1221
1228
  this.httpService = e, this.sessionManager = t;
1222
1229
  }
@@ -1297,56 +1304,56 @@ class rt {
1297
1304
  }
1298
1305
  }
1299
1306
  const Ae = ue(null);
1300
- function Wt({ config: i = {}, children: e }) {
1301
- const t = Ee(), r = ye(), s = (t == null ? void 0 : t.baseUrl) ?? "", o = (t == null ? void 0 : t.appId) ?? "", a = (r == null ? void 0 : r.tenant) ?? null, [p, w] = k([]), [y, x] = k(!1), [b, f] = k(null), [A, L] = k(!1), D = X(() => {
1307
+ function Vt({ config: i = {}, children: e }) {
1308
+ const t = Ee(), r = ye(), s = (t == null ? void 0 : t.baseUrl) ?? "", o = (t == null ? void 0 : t.appId) ?? "", a = (r == null ? void 0 : r.tenant) ?? null, [g, w] = S([]), [m, k] = S(!1), [b, f] = S(null), [A, E] = S(!1), $ = X(() => {
1302
1309
  const u = new re(s);
1303
- return new rt(u);
1304
- }, [s]), I = async () => {
1310
+ return new st(u);
1311
+ }, [s]), L = async () => {
1305
1312
  if (!(a != null && a.id)) {
1306
1313
  w([]);
1307
1314
  return;
1308
1315
  }
1309
- x(!0), f(null);
1316
+ k(!0), f(null);
1310
1317
  try {
1311
- const u = await D.getTenantFeatureFlags(a.id, o);
1318
+ const u = await $.getTenantFeatureFlags(a.id, o);
1312
1319
  w(u);
1313
1320
  } catch (u) {
1314
- const R = u instanceof Error ? u.message : "Failed to fetch feature flags";
1315
- f(R), i.onError && i.onError(u instanceof Error ? u : new Error(R));
1321
+ const M = u instanceof Error ? u.message : "Failed to fetch feature flags";
1322
+ f(M), i.onError && i.onError(u instanceof Error ? u : new Error(M));
1316
1323
  } finally {
1317
- x(!1);
1324
+ k(!1);
1318
1325
  }
1319
1326
  };
1320
1327
  te(() => {
1321
1328
  if (!s || !o) return;
1322
- I().finally(() => L(!0));
1323
- const u = i.refreshInterval || 5 * 60 * 1e3, R = setInterval(I, u);
1324
- return () => clearInterval(R);
1329
+ L().finally(() => E(!0));
1330
+ const u = i.refreshInterval || 5 * 60 * 1e3, M = setInterval(L, u);
1331
+ return () => clearInterval(M);
1325
1332
  }, [a == null ? void 0 : a.id, s, o, i.refreshInterval]);
1326
- const M = X(() => {
1327
- const u = (C) => {
1328
- const T = p.find((q) => q.key === C);
1329
- return (T == null ? void 0 : T.value) === !0;
1330
- }, R = (C) => p.find((T) => T.key === C), m = (C) => {
1331
- const T = p.find((q) => q.key === C);
1332
- return T ? T.value ? "enabled" : "disabled" : "not_found";
1333
- }, H = async () => {
1334
- await I();
1335
- }, $ = !!(s && o) && (A || !(a != null && a.id));
1333
+ const P = X(() => {
1334
+ const u = (O) => {
1335
+ const v = g.find((C) => C.key === O);
1336
+ return (v == null ? void 0 : v.value) === !0;
1337
+ }, M = (O) => g.find((v) => v.key === O), z = (O) => {
1338
+ const v = g.find((C) => C.key === O);
1339
+ return v ? v.value ? "enabled" : "disabled" : "not_found";
1340
+ }, N = async () => {
1341
+ await L();
1342
+ }, p = !!(s && o) && (A || !(a != null && a.id));
1336
1343
  return {
1337
- featureFlags: p,
1338
- loading: y,
1344
+ featureFlags: g,
1345
+ loading: m,
1339
1346
  error: b,
1340
- isReady: $,
1347
+ isReady: p,
1341
1348
  isEnabled: u,
1342
- getFlag: R,
1343
- getFlagState: m,
1344
- refresh: H
1349
+ getFlag: M,
1350
+ getFlagState: z,
1351
+ refresh: N
1345
1352
  };
1346
- }, [p, y, b, s, o, a == null ? void 0 : a.id, A]);
1347
- return /* @__PURE__ */ n(Ae.Provider, { value: M, children: e });
1353
+ }, [g, m, b, s, o, a == null ? void 0 : a.id, A]);
1354
+ return /* @__PURE__ */ n(Ae.Provider, { value: P, children: e });
1348
1355
  }
1349
- function nt() {
1356
+ function it() {
1350
1357
  const i = ne(Ae);
1351
1358
  if (!i)
1352
1359
  throw new Error("useFeatureFlags must be used within a FeatureFlagProvider");
@@ -1355,7 +1362,7 @@ function nt() {
1355
1362
  function Ce() {
1356
1363
  return ne(Ae);
1357
1364
  }
1358
- class st {
1365
+ class ot {
1359
1366
  constructor(e, t) {
1360
1367
  this.httpService = e, this.sessionManager = t;
1361
1368
  }
@@ -1422,57 +1429,57 @@ class st {
1422
1429
  }
1423
1430
  }
1424
1431
  const Te = ue(void 0);
1425
- function jt({ config: i = {}, children: e }) {
1426
- const t = Ee(), r = ye(), s = (t == null ? void 0 : t.baseUrl) ?? "", o = (r == null ? void 0 : r.tenant) ?? null, [a, p] = k(null), [w, y] = k(!1), [x, b] = k(null), [f, A] = k(!1), L = X(() => {
1427
- const M = new re(s);
1428
- return new st(M);
1429
- }, [s]), D = async () => {
1432
+ function _t({ config: i = {}, children: e }) {
1433
+ const t = Ee(), r = ye(), s = (t == null ? void 0 : t.baseUrl) ?? "", o = (r == null ? void 0 : r.tenant) ?? null, [a, g] = S(null), [w, m] = S(!1), [k, b] = S(null), [f, A] = S(!1), E = X(() => {
1434
+ const P = new re(s);
1435
+ return new ot(P);
1436
+ }, [s]), $ = async () => {
1430
1437
  if (!(o != null && o.id)) {
1431
- p(null);
1438
+ g(null);
1432
1439
  return;
1433
1440
  }
1434
- y(!0), b(null);
1441
+ m(!0), b(null);
1435
1442
  try {
1436
- const M = await L.getTenantSubscriptionFeatures(o.id);
1437
- p(M);
1438
- } catch (M) {
1439
- const u = M instanceof Error ? M.message : "Failed to fetch subscription";
1440
- b(u), i.onError && i.onError(M instanceof Error ? M : new Error(u));
1443
+ const P = await E.getTenantSubscriptionFeatures(o.id);
1444
+ g(P);
1445
+ } catch (P) {
1446
+ const u = P instanceof Error ? P.message : "Failed to fetch subscription";
1447
+ b(u), i.onError && i.onError(P instanceof Error ? P : new Error(u));
1441
1448
  } finally {
1442
- y(!1);
1449
+ m(!1);
1443
1450
  }
1444
1451
  };
1445
1452
  te(() => {
1446
- if (!s || (D().finally(() => A(!0)), !i.refreshInterval)) return;
1447
- const M = i.refreshInterval || 10 * 60 * 1e3, u = setInterval(D, M);
1453
+ if (!s || ($().finally(() => A(!0)), !i.refreshInterval)) return;
1454
+ const P = i.refreshInterval || 10 * 60 * 1e3, u = setInterval($, P);
1448
1455
  return () => clearInterval(u);
1449
1456
  }, [o == null ? void 0 : o.id, s, i.refreshInterval]);
1450
- const I = X(() => {
1451
- const M = (a == null ? void 0 : a.features) || [], u = (T) => {
1452
- const q = M.find((S) => S.key === T);
1453
- return q ? q.type === "BOOLEAN" || q.type === "boolean" ? q.value === !0 : !!q.value : !1;
1454
- }, R = (T) => M.find((q) => q.key === T), m = (T, q) => {
1455
- const S = M.find((P) => P.key === T);
1456
- return S ? S.value : q;
1457
- }, H = (T) => !a || !a.isActive ? !1 : T.includes(a.planId), $ = async () => {
1458
- await D();
1459
- }, C = !!s && (f || !(o != null && o.id));
1457
+ const L = X(() => {
1458
+ const P = (a == null ? void 0 : a.features) || [], u = (v) => {
1459
+ const C = P.find((x) => x.key === v);
1460
+ return C ? C.type === "BOOLEAN" || C.type === "boolean" ? C.value === !0 : !!C.value : !1;
1461
+ }, M = (v) => P.find((C) => C.key === v), z = (v, C) => {
1462
+ const x = P.find((I) => I.key === v);
1463
+ return x ? x.value : C;
1464
+ }, N = (v) => !a || !a.isActive ? !1 : v.includes(a.planId), p = async () => {
1465
+ await $();
1466
+ }, O = !!s && (f || !(o != null && o.id));
1460
1467
  return {
1461
1468
  subscription: a,
1462
- features: M,
1469
+ features: P,
1463
1470
  loading: w,
1464
- error: x,
1465
- isReady: C,
1471
+ error: k,
1472
+ isReady: O,
1466
1473
  isFeatureEnabled: u,
1467
- getFeature: R,
1468
- getFeatureValue: m,
1469
- hasAllowedPlan: H,
1470
- refresh: $
1474
+ getFeature: M,
1475
+ getFeatureValue: z,
1476
+ hasAllowedPlan: N,
1477
+ refresh: p
1471
1478
  };
1472
- }, [a, w, x, s, o == null ? void 0 : o.id, f]);
1473
- return /* @__PURE__ */ n(Te.Provider, { value: I, children: e });
1479
+ }, [a, w, k, s, o == null ? void 0 : o.id, f]);
1480
+ return /* @__PURE__ */ n(Te.Provider, { value: L, children: e });
1474
1481
  }
1475
- function it() {
1482
+ function at() {
1476
1483
  const i = ne(Te);
1477
1484
  if (i === void 0)
1478
1485
  throw new Error("useSubscription must be used within a SubscriptionProvider");
@@ -1541,7 +1548,7 @@ const Ie = () => /* @__PURE__ */ l(
1541
1548
  children: [
1542
1549
  /* @__PURE__ */ n("div", { style: { fontSize: "2rem", marginBottom: "10px" }, children: "⚠️" }),
1543
1550
  /* @__PURE__ */ n("h3", { style: { color: "#856404", marginBottom: "10px" }, children: "Insufficient Permissions" }),
1544
- e && i ? /* @__PURE__ */ l(W, { children: [
1551
+ e && i ? /* @__PURE__ */ l(j, { children: [
1545
1552
  /* @__PURE__ */ l("p", { style: { color: "#856404", fontSize: "14px", marginBottom: "10px" }, children: [
1546
1553
  "This content requires ",
1547
1554
  /* @__PURE__ */ n("strong", { children: e }),
@@ -1551,7 +1558,7 @@ const Ie = () => /* @__PURE__ */ l(
1551
1558
  "Your current access level: ",
1552
1559
  /* @__PURE__ */ n("strong", { children: i })
1553
1560
  ] })
1554
- ] }) : /* @__PURE__ */ l(W, { children: [
1561
+ ] }) : /* @__PURE__ */ l(j, { children: [
1555
1562
  /* @__PURE__ */ n("p", { style: { color: "#856404", fontSize: "14px", marginBottom: "10px" }, children: "You don't have the required permissions to view this content." }),
1556
1563
  t && t.length > 0 && /* @__PURE__ */ l("p", { style: { color: "#6c757d", fontSize: "12px" }, children: [
1557
1564
  "Required permissions: ",
@@ -1560,7 +1567,7 @@ const Ie = () => /* @__PURE__ */ l(
1560
1567
  ] })
1561
1568
  ]
1562
1569
  }
1563
- ), ot = (i, e) => {
1570
+ ), lt = (i, e) => {
1564
1571
  const t = {
1565
1572
  [ie.USER]: 1,
1566
1573
  [ie.TENANT_ADMIN]: 2,
@@ -1568,28 +1575,28 @@ const Ie = () => /* @__PURE__ */ l(
1568
1575
  };
1569
1576
  return t[i] >= t[e];
1570
1577
  };
1571
- function Vt({
1578
+ function Gt({
1572
1579
  children: i,
1573
1580
  fallback: e,
1574
1581
  minUserType: t,
1575
1582
  requiredPermissions: r,
1576
1583
  requireAllPermissions: s = !1
1577
1584
  }) {
1578
- const { hasValidSession: o, sessionManager: a, hasPermission: p, hasAnyPermission: w, hasAllPermissions: y } = oe();
1585
+ const { hasValidSession: o, sessionManager: a, hasPermission: g, hasAnyPermission: w, hasAllPermissions: m } = oe();
1579
1586
  if (!o())
1580
- return /* @__PURE__ */ n(W, { children: e || /* @__PURE__ */ n(Ie, {}) });
1581
- const x = a.getUser();
1582
- if (!x)
1583
- return /* @__PURE__ */ n(W, { children: e || /* @__PURE__ */ n(Ie, {}) });
1584
- if (t && !ot(x.userType, t))
1585
- return /* @__PURE__ */ n(Re, { userType: x.userType, minUserType: t });
1586
- if (r && r.length > 0 && !(s ? y(r) : w(r))) {
1587
- const f = r.filter((A) => !p(A)).map((A) => typeof A == "string" ? A : A.name);
1587
+ return /* @__PURE__ */ n(j, { children: e || /* @__PURE__ */ n(Ie, {}) });
1588
+ const k = a.getUser();
1589
+ if (!k)
1590
+ return /* @__PURE__ */ n(j, { children: e || /* @__PURE__ */ n(Ie, {}) });
1591
+ if (t && !lt(k.userType, t))
1592
+ return /* @__PURE__ */ n(Re, { userType: k.userType, minUserType: t });
1593
+ if (r && r.length > 0 && !(s ? m(r) : w(r))) {
1594
+ const f = r.filter((A) => !g(A)).map((A) => typeof A == "string" ? A : A.name);
1588
1595
  return /* @__PURE__ */ n(Re, { missingPermissions: f });
1589
1596
  }
1590
- return /* @__PURE__ */ n(W, { children: i });
1597
+ return /* @__PURE__ */ n(j, { children: i });
1591
1598
  }
1592
- const at = ({ redirectPath: i }) => /* @__PURE__ */ n(
1599
+ const ct = ({ redirectPath: i }) => /* @__PURE__ */ n(
1593
1600
  "div",
1594
1601
  {
1595
1602
  style: {
@@ -1655,7 +1662,7 @@ const at = ({ redirectPath: i }) => /* @__PURE__ */ n(
1655
1662
  children: [
1656
1663
  /* @__PURE__ */ n("div", { style: { fontSize: "3rem", marginBottom: "1rem" }, children: "⚠️" }),
1657
1664
  /* @__PURE__ */ n("h2", { style: { color: "#374151", marginBottom: "1rem" }, children: "Insufficient Permissions" }),
1658
- e && i ? /* @__PURE__ */ l(W, { children: [
1665
+ e && i ? /* @__PURE__ */ l(j, { children: [
1659
1666
  /* @__PURE__ */ l("p", { style: { color: "#6b7280", marginBottom: "1rem" }, children: [
1660
1667
  "This page requires ",
1661
1668
  /* @__PURE__ */ n("strong", { children: e }),
@@ -1665,7 +1672,7 @@ const at = ({ redirectPath: i }) => /* @__PURE__ */ n(
1665
1672
  "Your current access level: ",
1666
1673
  /* @__PURE__ */ n("strong", { children: i })
1667
1674
  ] })
1668
- ] }) : /* @__PURE__ */ l(W, { children: [
1675
+ ] }) : /* @__PURE__ */ l(j, { children: [
1669
1676
  /* @__PURE__ */ n("p", { style: { color: "#6b7280", marginBottom: "1rem" }, children: "You don't have the required permissions to access this page." }),
1670
1677
  t && t.length > 0 && /* @__PURE__ */ l("p", { style: { color: "#9ca3af", fontSize: "0.875rem" }, children: [
1671
1678
  "Required permissions: ",
@@ -1676,7 +1683,7 @@ const at = ({ redirectPath: i }) => /* @__PURE__ */ n(
1676
1683
  }
1677
1684
  )
1678
1685
  }
1679
- ), lt = (i, e) => {
1686
+ ), dt = (i, e) => {
1680
1687
  const t = {
1681
1688
  [ie.USER]: 1,
1682
1689
  [ie.TENANT_ADMIN]: 2,
@@ -1684,7 +1691,7 @@ const at = ({ redirectPath: i }) => /* @__PURE__ */ n(
1684
1691
  };
1685
1692
  return t[i] >= t[e];
1686
1693
  };
1687
- function _t({
1694
+ function Kt({
1688
1695
  children: i,
1689
1696
  redirectTo: e = "/login",
1690
1697
  minUserType: t,
@@ -1692,24 +1699,24 @@ function _t({
1692
1699
  requireAllPermissions: s = !1,
1693
1700
  fallback: o
1694
1701
  }) {
1695
- const { hasValidSession: a, sessionManager: p, hasPermission: w, hasAnyPermission: y, hasAllPermissions: x } = oe(), b = Se();
1702
+ const { hasValidSession: a, sessionManager: g, hasPermission: w, hasAnyPermission: m, hasAllPermissions: k } = oe(), b = Se();
1696
1703
  if (!a())
1697
- return o ? /* @__PURE__ */ n(W, { children: o }) : /* @__PURE__ */ l(W, { children: [
1698
- /* @__PURE__ */ n(at, { redirectPath: e }),
1704
+ return o ? /* @__PURE__ */ n(j, { children: o }) : /* @__PURE__ */ l(j, { children: [
1705
+ /* @__PURE__ */ n(ct, { redirectPath: e }),
1699
1706
  /* @__PURE__ */ n(pe, { to: e, state: { from: b.pathname }, replace: !0 })
1700
1707
  ] });
1701
- const f = p.getUser();
1708
+ const f = g.getUser();
1702
1709
  if (!f)
1703
1710
  return /* @__PURE__ */ n(pe, { to: e, state: { from: b.pathname }, replace: !0 });
1704
- if (t && !lt(f.userType, t))
1711
+ if (t && !dt(f.userType, t))
1705
1712
  return /* @__PURE__ */ n(Le, { userType: f.userType, minUserType: t });
1706
- if (r && r.length > 0 && !(s ? x(r) : y(r))) {
1707
- const L = r.filter((D) => !w(D)).map((D) => typeof D == "string" ? D : D.name);
1708
- return /* @__PURE__ */ n(Le, { missingPermissions: L });
1713
+ if (r && r.length > 0 && !(s ? k(r) : m(r))) {
1714
+ const E = r.filter(($) => !w($)).map(($) => typeof $ == "string" ? $ : $.name);
1715
+ return /* @__PURE__ */ n(Le, { missingPermissions: E });
1709
1716
  }
1710
- return /* @__PURE__ */ n(W, { children: i });
1717
+ return /* @__PURE__ */ n(j, { children: i });
1711
1718
  }
1712
- const ct = ({ redirectPath: i }) => /* @__PURE__ */ n(
1719
+ const ut = ({ redirectPath: i }) => /* @__PURE__ */ n(
1713
1720
  "div",
1714
1721
  {
1715
1722
  style: {
@@ -1746,14 +1753,14 @@ const ct = ({ redirectPath: i }) => /* @__PURE__ */ n(
1746
1753
  )
1747
1754
  }
1748
1755
  );
1749
- function Gt({ children: i, redirectTo: e = "/", fallback: t }) {
1756
+ function Jt({ children: i, redirectTo: e = "/", fallback: t }) {
1750
1757
  const { tenant: r, isLoading: s, error: o } = le(), a = Se();
1751
- return s || o ? null : r ? /* @__PURE__ */ n(W, { children: i }) : t ? /* @__PURE__ */ n(W, { children: t }) : /* @__PURE__ */ l(W, { children: [
1752
- /* @__PURE__ */ n(ct, { redirectPath: e }),
1758
+ return s || o ? null : r ? /* @__PURE__ */ n(j, { children: i }) : t ? /* @__PURE__ */ n(j, { children: t }) : /* @__PURE__ */ l(j, { children: [
1759
+ /* @__PURE__ */ n(ut, { redirectPath: e }),
1753
1760
  /* @__PURE__ */ n(pe, { to: e, state: { from: a.pathname }, replace: !0 })
1754
1761
  ] });
1755
1762
  }
1756
- const dt = ({ redirectPath: i }) => /* @__PURE__ */ n(
1763
+ const ht = ({ redirectPath: i }) => /* @__PURE__ */ n(
1757
1764
  "div",
1758
1765
  {
1759
1766
  style: {
@@ -1790,14 +1797,14 @@ const dt = ({ redirectPath: i }) => /* @__PURE__ */ n(
1790
1797
  )
1791
1798
  }
1792
1799
  );
1793
- function Kt({ children: i, redirectTo: e = "/dashboard", fallback: t }) {
1800
+ function Yt({ children: i, redirectTo: e = "/dashboard", fallback: t }) {
1794
1801
  const { tenant: r, isLoading: s, error: o } = le(), a = Se();
1795
- return s || o ? null : r ? t ? /* @__PURE__ */ n(W, { children: t }) : /* @__PURE__ */ l(W, { children: [
1796
- /* @__PURE__ */ n(dt, { redirectPath: e }),
1802
+ return s || o ? null : r ? t ? /* @__PURE__ */ n(j, { children: t }) : /* @__PURE__ */ l(j, { children: [
1803
+ /* @__PURE__ */ n(ht, { redirectPath: e }),
1797
1804
  /* @__PURE__ */ n(pe, { to: e, state: { from: a.pathname }, replace: !0 })
1798
- ] }) : /* @__PURE__ */ n(W, { children: i });
1805
+ ] }) : /* @__PURE__ */ n(j, { children: i });
1799
1806
  }
1800
- const ut = () => /* @__PURE__ */ l(
1807
+ const gt = () => /* @__PURE__ */ l(
1801
1808
  "div",
1802
1809
  {
1803
1810
  style: {
@@ -1814,14 +1821,14 @@ const ut = () => /* @__PURE__ */ l(
1814
1821
  ]
1815
1822
  }
1816
1823
  );
1817
- function Jt({
1824
+ function Qt({
1818
1825
  children: i,
1819
- fallback: e = /* @__PURE__ */ n(ut, {}),
1826
+ fallback: e = /* @__PURE__ */ n(gt, {}),
1820
1827
  allowedPlans: t,
1821
1828
  requiredFeature: r
1822
1829
  }) {
1823
- const { subscription: s, hasAllowedPlan: o, isFeatureEnabled: a, loading: p } = it();
1824
- return p ? /* @__PURE__ */ n(
1830
+ const { subscription: s, hasAllowedPlan: o, isFeatureEnabled: a, loading: g } = at();
1831
+ return g ? /* @__PURE__ */ n(
1825
1832
  "div",
1826
1833
  {
1827
1834
  style: {
@@ -1831,9 +1838,9 @@ function Jt({
1831
1838
  },
1832
1839
  children: "Loading subscription..."
1833
1840
  }
1834
- ) : s ? s.isActive ? t && t.length > 0 && !o(t) ? /* @__PURE__ */ n(W, { children: e }) : r && !a(r) ? /* @__PURE__ */ n(W, { children: e }) : /* @__PURE__ */ n(W, { children: i }) : /* @__PURE__ */ n(W, { children: e }) : /* @__PURE__ */ n(W, { children: e });
1841
+ ) : s ? s.isActive ? t && t.length > 0 && !o(t) ? /* @__PURE__ */ n(j, { children: e }) : r && !a(r) ? /* @__PURE__ */ n(j, { children: e }) : /* @__PURE__ */ n(j, { children: i }) : /* @__PURE__ */ n(j, { children: e }) : /* @__PURE__ */ n(j, { children: e });
1835
1842
  }
1836
- const ht = ({ flagName: i }) => /* @__PURE__ */ l(
1843
+ const pt = ({ flagName: i }) => /* @__PURE__ */ l(
1837
1844
  "div",
1838
1845
  {
1839
1846
  style: {
@@ -1860,8 +1867,8 @@ const ht = ({ flagName: i }) => /* @__PURE__ */ l(
1860
1867
  ]
1861
1868
  }
1862
1869
  );
1863
- function Yt({ name: i, children: e, fallback: t }) {
1864
- const { isEnabled: r, loading: s } = nt();
1870
+ function Xt({ name: i, children: e, fallback: t }) {
1871
+ const { isEnabled: r, loading: s } = it();
1865
1872
  return s ? /* @__PURE__ */ n(
1866
1873
  "div",
1867
1874
  {
@@ -1875,9 +1882,9 @@ function Yt({ name: i, children: e, fallback: t }) {
1875
1882
  },
1876
1883
  children: "Loading feature flags..."
1877
1884
  }
1878
- ) : r(i) ? /* @__PURE__ */ n(W, { children: e }) : /* @__PURE__ */ n(W, { children: t || /* @__PURE__ */ n(ht, { flagName: i }) });
1885
+ ) : r(i) ? /* @__PURE__ */ n(j, { children: e }) : /* @__PURE__ */ n(j, { children: t || /* @__PURE__ */ n(pt, { flagName: i }) });
1879
1886
  }
1880
- const gt = () => /* @__PURE__ */ l(
1887
+ const ft = () => /* @__PURE__ */ l(
1881
1888
  "svg",
1882
1889
  {
1883
1890
  width: "16",
@@ -1894,7 +1901,7 @@ const gt = () => /* @__PURE__ */ l(
1894
1901
  /* @__PURE__ */ n("circle", { cx: "12", cy: "12", r: "3" })
1895
1902
  ]
1896
1903
  }
1897
- ), pt = () => /* @__PURE__ */ l(
1904
+ ), mt = () => /* @__PURE__ */ l(
1898
1905
  "svg",
1899
1906
  {
1900
1907
  width: "16",
@@ -1911,10 +1918,10 @@ const gt = () => /* @__PURE__ */ l(
1911
1918
  /* @__PURE__ */ n("line", { x1: "1", y1: "1", x2: "23", y2: "23" })
1912
1919
  ]
1913
1920
  }
1914
- ), ft = {
1915
- showPassword: /* @__PURE__ */ n(gt, {}),
1916
- hidePassword: /* @__PURE__ */ n(pt, {})
1917
- }, mt = {
1921
+ ), yt = {
1922
+ showPassword: /* @__PURE__ */ n(ft, {}),
1923
+ hidePassword: /* @__PURE__ */ n(mt, {})
1924
+ }, wt = {
1918
1925
  title: "Sign In",
1919
1926
  usernameLabel: "Email or Phone",
1920
1927
  usernamePlaceholder: "Enter your email or phone number",
@@ -1928,7 +1935,7 @@ const gt = () => /* @__PURE__ */ l(
1928
1935
  magicLinkLink: "Use Magic Link",
1929
1936
  errorMessage: "Invalid credentials",
1930
1937
  loadingText: "Signing in..."
1931
- }, yt = {
1938
+ }, bt = {
1932
1939
  container: {
1933
1940
  maxWidth: "400px",
1934
1941
  width: "100%",
@@ -2035,7 +2042,7 @@ const gt = () => /* @__PURE__ */ l(
2035
2042
  fontSize: "0.875rem"
2036
2043
  }
2037
2044
  };
2038
- function Qt({
2045
+ function Zt({
2039
2046
  copy: i = {},
2040
2047
  styles: e = {},
2041
2048
  icons: t = {},
@@ -2043,49 +2050,49 @@ function Qt({
2043
2050
  onError: s,
2044
2051
  onForgotPassword: o,
2045
2052
  onSignupClick: a,
2046
- onMagicLinkClick: p,
2053
+ onMagicLinkClick: g,
2047
2054
  showForgotPassword: w = !0,
2048
- showSignupLink: y = !0,
2049
- showMagicLinkOption: x = !0,
2055
+ showSignupLink: m = !0,
2056
+ showMagicLinkOption: k = !0,
2050
2057
  className: b
2051
2058
  }) {
2052
- const [f, A] = k(""), [L, D] = k(""), [I, M] = k(!1), [u, R] = k(!1), [m, H] = k(""), [$, C] = k({}), { login: T } = oe(), { tenant: q } = le(), S = { ...mt, ...i }, P = { ...yt, ...e }, E = { ...ft, ...t }, d = () => {
2053
- const g = {};
2054
- return f.trim() || (g.username = !0), L.trim() || (g.password = !0), C(g), Object.keys(g).length === 0;
2055
- }, F = async (g) => {
2056
- if (g.preventDefault(), !!d()) {
2057
- if (!(q != null && q.id)) {
2058
- H("Tenant not found");
2059
+ const [f, A] = S(""), [E, $] = S(""), [L, P] = S(!1), [u, M] = S(!1), [z, N] = S(""), [p, O] = S({}), { login: v } = oe(), { tenant: C } = le(), x = { ...wt, ...i }, I = { ...bt, ...e }, F = { ...yt, ...t }, c = () => {
2060
+ const d = {};
2061
+ return f.trim() || (d.username = !0), E.trim() || (d.password = !0), O(d), Object.keys(d).length === 0;
2062
+ }, R = async (d) => {
2063
+ if (d.preventDefault(), !!c()) {
2064
+ if (!(C != null && C.id)) {
2065
+ N("Tenant not found");
2059
2066
  return;
2060
2067
  }
2061
- R(!0), H("");
2068
+ M(!0), N("");
2062
2069
  try {
2063
- const c = await T({
2070
+ const y = await v({
2064
2071
  username: f,
2065
- password: L
2072
+ password: E
2066
2073
  // tenantId inferred from context automatically
2067
2074
  });
2068
- r == null || r(c);
2069
- } catch (c) {
2070
- const j = c.message || S.errorMessage;
2071
- H(j), s == null || s(j);
2075
+ r == null || r(y);
2076
+ } catch (y) {
2077
+ const G = y.message || x.errorMessage;
2078
+ N(G), s == null || s(G);
2072
2079
  } finally {
2073
- R(!1);
2080
+ M(!1);
2074
2081
  }
2075
2082
  }
2076
- }, v = (g) => ({
2077
- ...P.input,
2078
- ...$[g] ? P.inputError : {}
2083
+ }, T = (d) => ({
2084
+ ...I.input,
2085
+ ...p[d] ? I.inputError : {}
2079
2086
  }), h = () => ({
2080
- ...P.button,
2081
- ...u ? P.buttonLoading : {},
2082
- ...!f || !L || u ? P.buttonDisabled : {}
2087
+ ...I.button,
2088
+ ...u ? I.buttonLoading : {},
2089
+ ...!f || !E || u ? I.buttonDisabled : {}
2083
2090
  });
2084
- return /* @__PURE__ */ l("div", { className: b, style: P.container, children: [
2085
- /* @__PURE__ */ n("h2", { style: P.title, children: S.title }),
2086
- /* @__PURE__ */ l("form", { onSubmit: F, style: P.form, children: [
2087
- /* @__PURE__ */ l("div", { style: P.fieldGroup, children: [
2088
- /* @__PURE__ */ n("label", { style: P.label, children: S.usernameLabel }),
2091
+ return /* @__PURE__ */ l("div", { className: b, style: I.container, children: [
2092
+ /* @__PURE__ */ n("h2", { style: I.title, children: x.title }),
2093
+ /* @__PURE__ */ l("form", { onSubmit: R, style: I.form, children: [
2094
+ /* @__PURE__ */ l("div", { style: I.fieldGroup, children: [
2095
+ /* @__PURE__ */ n("label", { style: I.label, children: x.usernameLabel }),
2089
2096
  /* @__PURE__ */ n(
2090
2097
  "input",
2091
2098
  {
@@ -2093,31 +2100,31 @@ function Qt({
2093
2100
  name: "username",
2094
2101
  type: "text",
2095
2102
  value: f,
2096
- onChange: (g) => {
2097
- A(g.target.value), $.username && C((c) => ({ ...c, username: !1 }));
2103
+ onChange: (d) => {
2104
+ A(d.target.value), p.username && O((y) => ({ ...y, username: !1 }));
2098
2105
  },
2099
- placeholder: S.usernamePlaceholder,
2100
- style: v("username"),
2106
+ placeholder: x.usernamePlaceholder,
2107
+ style: T("username"),
2101
2108
  disabled: u
2102
2109
  }
2103
2110
  )
2104
2111
  ] }),
2105
- /* @__PURE__ */ l("div", { style: P.fieldGroup, children: [
2106
- /* @__PURE__ */ n("label", { style: P.label, children: S.passwordLabel }),
2107
- /* @__PURE__ */ l("div", { style: P.inputContainer, children: [
2112
+ /* @__PURE__ */ l("div", { style: I.fieldGroup, children: [
2113
+ /* @__PURE__ */ n("label", { style: I.label, children: x.passwordLabel }),
2114
+ /* @__PURE__ */ l("div", { style: I.inputContainer, children: [
2108
2115
  /* @__PURE__ */ n(
2109
2116
  "input",
2110
2117
  {
2111
2118
  id: "password",
2112
2119
  name: "password",
2113
- type: I ? "text" : "password",
2114
- value: L,
2115
- onChange: (g) => {
2116
- D(g.target.value), $.password && C((c) => ({ ...c, password: !1 }));
2120
+ type: L ? "text" : "password",
2121
+ value: E,
2122
+ onChange: (d) => {
2123
+ $(d.target.value), p.password && O((y) => ({ ...y, password: !1 }));
2117
2124
  },
2118
- placeholder: S.passwordPlaceholder,
2125
+ placeholder: x.passwordPlaceholder,
2119
2126
  style: {
2120
- ...v("password"),
2127
+ ...T("password"),
2121
2128
  paddingRight: "2.5rem"
2122
2129
  // Make room for the icon
2123
2130
  },
@@ -2128,40 +2135,40 @@ function Qt({
2128
2135
  "button",
2129
2136
  {
2130
2137
  type: "button",
2131
- onClick: () => M(!I),
2132
- style: P.passwordToggle,
2138
+ onClick: () => P(!L),
2139
+ style: I.passwordToggle,
2133
2140
  disabled: u,
2134
- "aria-label": I ? "Hide password" : "Show password",
2135
- children: I ? E.hidePassword : E.showPassword
2141
+ "aria-label": L ? "Hide password" : "Show password",
2142
+ children: L ? F.hidePassword : F.showPassword
2136
2143
  }
2137
2144
  )
2138
2145
  ] })
2139
2146
  ] }),
2140
- /* @__PURE__ */ n("button", { type: "submit", disabled: !f || !L || u, style: h(), children: u ? S.loadingText : S.submitButton }),
2141
- m && /* @__PURE__ */ n("div", { style: P.errorText, children: m })
2147
+ /* @__PURE__ */ n("button", { type: "submit", disabled: !f || !E || u, style: h(), children: u ? x.loadingText : x.submitButton }),
2148
+ z && /* @__PURE__ */ n("div", { style: I.errorText, children: z })
2142
2149
  ] }),
2143
- (w || y || x) && /* @__PURE__ */ l("div", { style: P.linkContainer, children: [
2144
- x && /* @__PURE__ */ l("div", { children: [
2145
- /* @__PURE__ */ l("span", { style: P.divider, children: [
2146
- S.magicLinkText,
2150
+ (w || m || k) && /* @__PURE__ */ l("div", { style: I.linkContainer, children: [
2151
+ k && /* @__PURE__ */ l("div", { children: [
2152
+ /* @__PURE__ */ l("span", { style: I.divider, children: [
2153
+ x.magicLinkText,
2147
2154
  " "
2148
2155
  ] }),
2149
- /* @__PURE__ */ n("a", { onClick: p, style: P.link, children: S.magicLinkLink })
2156
+ /* @__PURE__ */ n("a", { onClick: g, style: I.link, children: x.magicLinkLink })
2150
2157
  ] }),
2151
- x && (w || y) && /* @__PURE__ */ n("div", { style: P.divider, children: "•" }),
2152
- w && /* @__PURE__ */ n("a", { onClick: o, style: P.link, children: S.forgotPasswordLink }),
2153
- w && y && /* @__PURE__ */ n("div", { style: P.divider, children: "•" }),
2154
- y && /* @__PURE__ */ l("div", { children: [
2155
- /* @__PURE__ */ l("span", { style: P.divider, children: [
2156
- S.signupText,
2158
+ k && (w || m) && /* @__PURE__ */ n("div", { style: I.divider, children: "•" }),
2159
+ w && /* @__PURE__ */ n("a", { onClick: o, style: I.link, children: x.forgotPasswordLink }),
2160
+ w && m && /* @__PURE__ */ n("div", { style: I.divider, children: "•" }),
2161
+ m && /* @__PURE__ */ l("div", { children: [
2162
+ /* @__PURE__ */ l("span", { style: I.divider, children: [
2163
+ x.signupText,
2157
2164
  " "
2158
2165
  ] }),
2159
- /* @__PURE__ */ n("a", { onClick: a, style: P.link, children: S.signupLink })
2166
+ /* @__PURE__ */ n("a", { onClick: a, style: I.link, children: x.signupLink })
2160
2167
  ] })
2161
2168
  ] })
2162
2169
  ] });
2163
2170
  }
2164
- const wt = {
2171
+ const St = {
2165
2172
  title: "Create Account",
2166
2173
  nameLabel: "First Name",
2167
2174
  namePlaceholder: "Enter your first name",
@@ -2187,7 +2194,7 @@ const wt = {
2187
2194
  passwordMismatchError: "Passwords do not match",
2188
2195
  isAdminLabel: "Create new organization",
2189
2196
  isAdminDescription: "Check this if you want to create a new organization"
2190
- }, bt = {
2197
+ }, vt = {
2191
2198
  container: {
2192
2199
  maxWidth: "400px",
2193
2200
  width: "100%",
@@ -2286,7 +2293,7 @@ const wt = {
2286
2293
  fontSize: "0.875rem"
2287
2294
  }
2288
2295
  };
2289
- function Xt({
2296
+ function er({
2290
2297
  copy: i = {},
2291
2298
  styles: e = {},
2292
2299
  signupType: t = "user",
@@ -2294,79 +2301,79 @@ function Xt({
2294
2301
  onError: s,
2295
2302
  onLoginClick: o,
2296
2303
  onMagicLinkClick: a,
2297
- showLoginLink: p = !0,
2304
+ showLoginLink: g = !0,
2298
2305
  showMagicLinkOption: w = !0,
2299
- className: y
2306
+ className: m
2300
2307
  }) {
2301
- const [x, b] = k(""), [f, A] = k(""), [L, D] = k(""), [I, M] = k(""), [u, R] = k(""), [m, H] = k(""), [$, C] = k(""), [T, q] = k(!1), [S, P] = k(""), [E, d] = k({}), { signup: F, signupTenantAdmin: v } = oe(), { tenant: h } = le(), g = { ...wt, ...i }, c = { ...bt, ...e }, j = () => {
2302
- const U = {};
2303
- return x.trim() || (U.name = !0), !L.trim() && !I.trim() && (U.email = !0, U.phoneNumber = !0), u.trim() || (U.password = !0), m.trim() || (U.confirmPassword = !0), t === "tenant" && !$.trim() && (U.tenantName = !0), d(U), Object.keys(U).length === 0;
2304
- }, K = async (U) => {
2305
- if (U.preventDefault(), !!j()) {
2306
- if (u !== m) {
2307
- P(g.passwordMismatchError), d({ confirmPassword: !0 });
2308
+ const [k, b] = S(""), [f, A] = S(""), [E, $] = S(""), [L, P] = S(""), [u, M] = S(""), [z, N] = S(""), [p, O] = S(""), [v, C] = S(!1), [x, I] = S(""), [F, c] = S({}), { signup: R, signupTenantAdmin: T } = oe(), { tenant: h } = le(), d = { ...St, ...i }, y = { ...vt, ...e }, G = () => {
2309
+ const B = {};
2310
+ return k.trim() || (B.name = !0), !E.trim() && !L.trim() && (B.email = !0, B.phoneNumber = !0), u.trim() || (B.password = !0), z.trim() || (B.confirmPassword = !0), t === "tenant" && !p.trim() && (B.tenantName = !0), c(B), Object.keys(B).length === 0;
2311
+ }, D = async (B) => {
2312
+ if (B.preventDefault(), !!G()) {
2313
+ if (u !== z) {
2314
+ I(d.passwordMismatchError), c({ confirmPassword: !0 });
2308
2315
  return;
2309
2316
  }
2310
2317
  if (t === "user" && !(h != null && h.id)) {
2311
- P("Tenant not found");
2318
+ I("Tenant not found");
2312
2319
  return;
2313
2320
  }
2314
- q(!0), P("");
2321
+ C(!0), I("");
2315
2322
  try {
2316
2323
  let J;
2317
- t === "tenant" ? J = await v({
2318
- email: L || void 0,
2319
- phoneNumber: I || void 0,
2320
- name: x,
2324
+ t === "tenant" ? J = await T({
2325
+ email: E || void 0,
2326
+ phoneNumber: L || void 0,
2327
+ name: k,
2321
2328
  password: u,
2322
- tenantName: $,
2329
+ tenantName: p,
2323
2330
  lastName: f || void 0
2324
- }) : J = await F({
2325
- email: L || void 0,
2326
- phoneNumber: I || void 0,
2327
- name: x,
2331
+ }) : J = await R({
2332
+ email: E || void 0,
2333
+ phoneNumber: L || void 0,
2334
+ name: k,
2328
2335
  password: u,
2329
2336
  tenantId: h.id,
2330
2337
  lastName: f || void 0
2331
2338
  }), r == null || r(J);
2332
2339
  } catch (J) {
2333
- const ge = J.message || g.errorMessage;
2334
- P(ge), s == null || s(ge);
2340
+ const ge = J.message || d.errorMessage;
2341
+ I(ge), s == null || s(ge);
2335
2342
  } finally {
2336
- q(!1);
2343
+ C(!1);
2337
2344
  }
2338
2345
  }
2339
- }, N = (U) => ({
2340
- ...c.input,
2341
- ...E[U] ? c.inputError : {}
2342
- }), z = () => ({
2343
- ...c.button,
2344
- ...T ? c.buttonLoading : {},
2345
- ...!x || !L && !I || !u || !m || T || t === "tenant" && !$ ? c.buttonDisabled : {}
2346
- }), V = x && (L || I) && u && m && (t === "user" || $);
2347
- return /* @__PURE__ */ l("div", { className: y, style: c.container, children: [
2348
- /* @__PURE__ */ n("h2", { style: c.title, children: g.title }),
2349
- /* @__PURE__ */ l("form", { onSubmit: K, style: c.form, children: [
2350
- /* @__PURE__ */ l("div", { style: c.fieldGroup, children: [
2351
- /* @__PURE__ */ n("label", { style: c.label, children: g.nameLabel }),
2346
+ }, H = (B) => ({
2347
+ ...y.input,
2348
+ ...F[B] ? y.inputError : {}
2349
+ }), U = () => ({
2350
+ ...y.button,
2351
+ ...v ? y.buttonLoading : {},
2352
+ ...!k || !E && !L || !u || !z || v || t === "tenant" && !p ? y.buttonDisabled : {}
2353
+ }), V = k && (E || L) && u && z && (t === "user" || p);
2354
+ return /* @__PURE__ */ l("div", { className: m, style: y.container, children: [
2355
+ /* @__PURE__ */ n("h2", { style: y.title, children: d.title }),
2356
+ /* @__PURE__ */ l("form", { onSubmit: D, style: y.form, children: [
2357
+ /* @__PURE__ */ l("div", { style: y.fieldGroup, children: [
2358
+ /* @__PURE__ */ n("label", { style: y.label, children: d.nameLabel }),
2352
2359
  /* @__PURE__ */ n(
2353
2360
  "input",
2354
2361
  {
2355
2362
  id: "name",
2356
2363
  name: "name",
2357
2364
  type: "text",
2358
- value: x,
2359
- onChange: (U) => {
2360
- b(U.target.value), E.name && d((J) => ({ ...J, name: !1 }));
2365
+ value: k,
2366
+ onChange: (B) => {
2367
+ b(B.target.value), F.name && c((J) => ({ ...J, name: !1 }));
2361
2368
  },
2362
- placeholder: g.namePlaceholder,
2363
- style: N("name"),
2364
- disabled: T
2369
+ placeholder: d.namePlaceholder,
2370
+ style: H("name"),
2371
+ disabled: v
2365
2372
  }
2366
2373
  )
2367
2374
  ] }),
2368
- /* @__PURE__ */ l("div", { style: c.fieldGroup, children: [
2369
- /* @__PURE__ */ n("label", { style: c.label, children: g.lastNameLabel }),
2375
+ /* @__PURE__ */ l("div", { style: y.fieldGroup, children: [
2376
+ /* @__PURE__ */ n("label", { style: y.label, children: d.lastNameLabel }),
2370
2377
  /* @__PURE__ */ n(
2371
2378
  "input",
2372
2379
  {
@@ -2374,46 +2381,46 @@ function Xt({
2374
2381
  name: "lastName",
2375
2382
  type: "text",
2376
2383
  value: f,
2377
- onChange: (U) => A(U.target.value),
2378
- placeholder: g.lastNamePlaceholder,
2379
- style: c.input,
2380
- disabled: T
2384
+ onChange: (B) => A(B.target.value),
2385
+ placeholder: d.lastNamePlaceholder,
2386
+ style: y.input,
2387
+ disabled: v
2381
2388
  }
2382
2389
  )
2383
2390
  ] }),
2384
- /* @__PURE__ */ l("div", { style: c.fieldGroup, children: [
2385
- /* @__PURE__ */ n("label", { style: c.label, children: g.emailLabel }),
2391
+ /* @__PURE__ */ l("div", { style: y.fieldGroup, children: [
2392
+ /* @__PURE__ */ n("label", { style: y.label, children: d.emailLabel }),
2386
2393
  /* @__PURE__ */ n(
2387
2394
  "input",
2388
2395
  {
2389
2396
  id: "email",
2390
2397
  name: "email",
2391
2398
  type: "email",
2392
- value: L,
2393
- onChange: (U) => {
2394
- D(U.target.value), E.email && d((J) => ({ ...J, email: !1, phoneNumber: !1 }));
2399
+ value: E,
2400
+ onChange: (B) => {
2401
+ $(B.target.value), F.email && c((J) => ({ ...J, email: !1, phoneNumber: !1 }));
2395
2402
  },
2396
- placeholder: g.emailPlaceholder,
2397
- style: N("email"),
2398
- disabled: T
2403
+ placeholder: d.emailPlaceholder,
2404
+ style: H("email"),
2405
+ disabled: v
2399
2406
  }
2400
2407
  )
2401
2408
  ] }),
2402
- /* @__PURE__ */ l("div", { style: c.fieldGroup, children: [
2403
- /* @__PURE__ */ n("label", { style: c.label, children: g.phoneNumberLabel }),
2409
+ /* @__PURE__ */ l("div", { style: y.fieldGroup, children: [
2410
+ /* @__PURE__ */ n("label", { style: y.label, children: d.phoneNumberLabel }),
2404
2411
  /* @__PURE__ */ n(
2405
2412
  "input",
2406
2413
  {
2407
2414
  id: "phoneNumber",
2408
2415
  name: "phoneNumber",
2409
2416
  type: "tel",
2410
- value: I,
2411
- onChange: (U) => {
2412
- M(U.target.value), E.phoneNumber && d((J) => ({ ...J, email: !1, phoneNumber: !1 }));
2417
+ value: L,
2418
+ onChange: (B) => {
2419
+ P(B.target.value), F.phoneNumber && c((J) => ({ ...J, email: !1, phoneNumber: !1 }));
2413
2420
  },
2414
- placeholder: g.phoneNumberPlaceholder,
2415
- style: N("phoneNumber"),
2416
- disabled: T
2421
+ placeholder: d.phoneNumberPlaceholder,
2422
+ style: H("phoneNumber"),
2423
+ disabled: v
2417
2424
  }
2418
2425
  )
2419
2426
  ] }),
@@ -2429,8 +2436,8 @@ function Xt({
2429
2436
  children: "At least one contact method (email or phone) is required"
2430
2437
  }
2431
2438
  ),
2432
- /* @__PURE__ */ l("div", { style: c.fieldGroup, children: [
2433
- /* @__PURE__ */ n("label", { style: c.label, children: g.passwordLabel }),
2439
+ /* @__PURE__ */ l("div", { style: y.fieldGroup, children: [
2440
+ /* @__PURE__ */ n("label", { style: y.label, children: d.passwordLabel }),
2434
2441
  /* @__PURE__ */ n(
2435
2442
  "input",
2436
2443
  {
@@ -2438,74 +2445,74 @@ function Xt({
2438
2445
  name: "password",
2439
2446
  type: "password",
2440
2447
  value: u,
2441
- onChange: (U) => {
2442
- R(U.target.value), E.password && d((J) => ({ ...J, password: !1 }));
2448
+ onChange: (B) => {
2449
+ M(B.target.value), F.password && c((J) => ({ ...J, password: !1 }));
2443
2450
  },
2444
- placeholder: g.passwordPlaceholder,
2445
- style: N("password"),
2446
- disabled: T
2451
+ placeholder: d.passwordPlaceholder,
2452
+ style: H("password"),
2453
+ disabled: v
2447
2454
  }
2448
2455
  )
2449
2456
  ] }),
2450
- /* @__PURE__ */ l("div", { style: c.fieldGroup, children: [
2451
- /* @__PURE__ */ n("label", { style: c.label, children: g.confirmPasswordLabel }),
2457
+ /* @__PURE__ */ l("div", { style: y.fieldGroup, children: [
2458
+ /* @__PURE__ */ n("label", { style: y.label, children: d.confirmPasswordLabel }),
2452
2459
  /* @__PURE__ */ n(
2453
2460
  "input",
2454
2461
  {
2455
2462
  id: "confirmPassword",
2456
2463
  name: "confirmPassword",
2457
2464
  type: "password",
2458
- value: m,
2459
- onChange: (U) => {
2460
- H(U.target.value), E.confirmPassword && d((J) => ({ ...J, confirmPassword: !1 })), S === g.passwordMismatchError && P("");
2465
+ value: z,
2466
+ onChange: (B) => {
2467
+ N(B.target.value), F.confirmPassword && c((J) => ({ ...J, confirmPassword: !1 })), x === d.passwordMismatchError && I("");
2461
2468
  },
2462
- placeholder: g.confirmPasswordPlaceholder,
2463
- style: N("confirmPassword"),
2464
- disabled: T
2469
+ placeholder: d.confirmPasswordPlaceholder,
2470
+ style: H("confirmPassword"),
2471
+ disabled: v
2465
2472
  }
2466
2473
  )
2467
2474
  ] }),
2468
- t === "tenant" && /* @__PURE__ */ l("div", { style: c.fieldGroup, children: [
2469
- /* @__PURE__ */ n("label", { style: c.label, children: g.tenantNameLabel }),
2475
+ t === "tenant" && /* @__PURE__ */ l("div", { style: y.fieldGroup, children: [
2476
+ /* @__PURE__ */ n("label", { style: y.label, children: d.tenantNameLabel }),
2470
2477
  /* @__PURE__ */ n(
2471
2478
  "input",
2472
2479
  {
2473
2480
  id: "tenantName",
2474
2481
  name: "tenantName",
2475
2482
  type: "text",
2476
- value: $,
2477
- onChange: (U) => {
2478
- C(U.target.value), E.tenantName && d((J) => ({ ...J, tenantName: !1 }));
2483
+ value: p,
2484
+ onChange: (B) => {
2485
+ O(B.target.value), F.tenantName && c((J) => ({ ...J, tenantName: !1 }));
2479
2486
  },
2480
- placeholder: g.tenantNamePlaceholder,
2481
- style: N("tenantName"),
2482
- disabled: T
2487
+ placeholder: d.tenantNamePlaceholder,
2488
+ style: H("tenantName"),
2489
+ disabled: v
2483
2490
  }
2484
2491
  )
2485
2492
  ] }),
2486
- /* @__PURE__ */ n("button", { type: "submit", disabled: !V || T, style: z(), children: T ? g.loadingText : g.submitButton }),
2487
- S && /* @__PURE__ */ n("div", { style: c.errorText, children: S })
2493
+ /* @__PURE__ */ n("button", { type: "submit", disabled: !V || v, style: U(), children: v ? d.loadingText : d.submitButton }),
2494
+ x && /* @__PURE__ */ n("div", { style: y.errorText, children: x })
2488
2495
  ] }),
2489
- (p || w) && /* @__PURE__ */ l("div", { style: c.linkContainer, children: [
2496
+ (g || w) && /* @__PURE__ */ l("div", { style: y.linkContainer, children: [
2490
2497
  w && /* @__PURE__ */ l("div", { children: [
2491
- /* @__PURE__ */ l("span", { style: c.divider, children: [
2492
- g.magicLinkText,
2498
+ /* @__PURE__ */ l("span", { style: y.divider, children: [
2499
+ d.magicLinkText,
2493
2500
  " "
2494
2501
  ] }),
2495
- /* @__PURE__ */ n("a", { onClick: a, style: c.link, children: g.magicLinkLink })
2502
+ /* @__PURE__ */ n("a", { onClick: a, style: y.link, children: d.magicLinkLink })
2496
2503
  ] }),
2497
- w && p && /* @__PURE__ */ n("div", { style: c.divider, children: "•" }),
2498
- p && /* @__PURE__ */ l("div", { children: [
2499
- /* @__PURE__ */ l("span", { style: c.divider, children: [
2500
- g.loginText,
2504
+ w && g && /* @__PURE__ */ n("div", { style: y.divider, children: "•" }),
2505
+ g && /* @__PURE__ */ l("div", { children: [
2506
+ /* @__PURE__ */ l("span", { style: y.divider, children: [
2507
+ d.loginText,
2501
2508
  " "
2502
2509
  ] }),
2503
- /* @__PURE__ */ n("a", { onClick: o, style: c.link, children: g.loginLink })
2510
+ /* @__PURE__ */ n("a", { onClick: o, style: y.link, children: d.loginLink })
2504
2511
  ] })
2505
2512
  ] })
2506
2513
  ] });
2507
2514
  }
2508
- const St = {
2515
+ const kt = {
2509
2516
  title: "Sign In with Magic Link",
2510
2517
  emailLabel: "Email",
2511
2518
  emailPlaceholder: "Enter your email",
@@ -2523,7 +2530,7 @@ const St = {
2523
2530
  loadingText: "Sending magic link...",
2524
2531
  verifyingText: "Verifying magic link...",
2525
2532
  description: "Enter your email to receive a magic link. If you don't have an account, we'll create one for you."
2526
- }, vt = {
2533
+ }, xt = {
2527
2534
  container: {
2528
2535
  maxWidth: "400px",
2529
2536
  width: "100%",
@@ -2626,7 +2633,7 @@ const St = {
2626
2633
  fontSize: "0.875rem"
2627
2634
  }
2628
2635
  };
2629
- function Zt({
2636
+ function tr({
2630
2637
  copy: i = {},
2631
2638
  styles: e = {},
2632
2639
  onSuccess: t,
@@ -2634,97 +2641,97 @@ function Zt({
2634
2641
  onLoginClick: s,
2635
2642
  onSignupClick: o,
2636
2643
  showTraditionalLinks: a = !0,
2637
- className: p,
2644
+ className: g,
2638
2645
  verifyToken: w,
2639
- frontendUrl: y
2646
+ frontendUrl: m
2640
2647
  }) {
2641
- const [x, b] = k(""), [f, A] = k(""), [L, D] = k(""), [I, M] = k(!1), [u, R] = k(!1), [m, H] = k(""), [$, C] = k(""), [T, q] = k({}), [S, P] = k(!1), { sendMagicLink: E, verifyMagicLink: d } = oe(), { tenant: F } = le(), v = { ...St, ...i }, h = { ...vt, ...e };
2648
+ const [k, b] = S(""), [f, A] = S(""), [E, $] = S(""), [L, P] = S(!1), [u, M] = S(!1), [z, N] = S(""), [p, O] = S(""), [v, C] = S({}), [x, I] = S(!1), { sendMagicLink: F, verifyMagicLink: c } = oe(), { tenant: R } = le(), T = { ...kt, ...i }, h = { ...xt, ...e };
2642
2649
  te(() => {
2643
- w && g(w);
2650
+ w && d(w);
2644
2651
  }, [w]);
2645
- const g = async (z) => {
2646
- if (!F || !x) {
2647
- H("Missing tenant or email");
2652
+ const d = async (U) => {
2653
+ if (!R || !k) {
2654
+ N("Missing tenant or email");
2648
2655
  return;
2649
2656
  }
2650
- R(!0), H("");
2657
+ M(!0), N("");
2651
2658
  try {
2652
- const V = await d({
2653
- token: z,
2654
- email: x
2659
+ const V = await c({
2660
+ token: U,
2661
+ email: k
2655
2662
  // tenantId inferred from context automatically
2656
2663
  });
2657
2664
  t == null || t(V);
2658
2665
  } catch (V) {
2659
- const U = V.message || "Failed to verify magic link";
2660
- H(U), r == null || r(U);
2666
+ const B = V.message || "Failed to verify magic link";
2667
+ N(B), r == null || r(B);
2661
2668
  } finally {
2662
- R(!1);
2669
+ M(!1);
2663
2670
  }
2664
- }, c = () => {
2665
- const z = {};
2666
- return x.trim() || (z.email = !0), S && !f.trim() && (z.name = !0), q(z), Object.keys(z).length === 0;
2667
- }, j = async (z) => {
2668
- if (z.preventDefault(), !!c()) {
2669
- if (!(F != null && F.id)) {
2670
- H("Tenant not found");
2671
+ }, y = () => {
2672
+ const U = {};
2673
+ return k.trim() || (U.email = !0), x && !f.trim() && (U.name = !0), C(U), Object.keys(U).length === 0;
2674
+ }, G = async (U) => {
2675
+ if (U.preventDefault(), !!y()) {
2676
+ if (!(R != null && R.id)) {
2677
+ N("Tenant not found");
2671
2678
  return;
2672
2679
  }
2673
- M(!0), H(""), C("");
2680
+ P(!0), N(""), O("");
2674
2681
  try {
2675
- const V = y || (typeof window < "u" ? window.location.origin : ""), U = await E({
2676
- email: x,
2677
- tenantId: F.id,
2682
+ const V = m || (typeof window < "u" ? window.location.origin : ""), B = await F({
2683
+ email: k,
2684
+ tenantId: R.id,
2678
2685
  frontendUrl: V,
2679
- name: S ? f : void 0,
2680
- lastName: S ? L : void 0
2686
+ name: x ? f : void 0,
2687
+ lastName: x ? E : void 0
2681
2688
  });
2682
- C(v.successMessage), t == null || t(U);
2689
+ O(T.successMessage), t == null || t(B);
2683
2690
  } catch (V) {
2684
- const U = V.message || v.errorMessage;
2685
- H(U), r == null || r(U);
2691
+ const B = V.message || T.errorMessage;
2692
+ N(B), r == null || r(B);
2686
2693
  } finally {
2687
- M(!1);
2694
+ P(!1);
2688
2695
  }
2689
2696
  }
2690
- }, K = (z) => ({
2697
+ }, D = (U) => ({
2691
2698
  ...h.input,
2692
- ...T[z] ? h.inputError : {}
2693
- }), N = () => ({
2699
+ ...v[U] ? h.inputError : {}
2700
+ }), H = () => ({
2694
2701
  ...h.button,
2695
- ...I || u ? h.buttonLoading : {},
2696
- ...!x || I || u ? h.buttonDisabled : {}
2702
+ ...L || u ? h.buttonLoading : {},
2703
+ ...!k || L || u ? h.buttonDisabled : {}
2697
2704
  });
2698
- return u ? /* @__PURE__ */ l("div", { className: p, style: h.container, children: [
2699
- /* @__PURE__ */ n("h2", { style: h.title, children: v.verifyingText }),
2705
+ return u ? /* @__PURE__ */ l("div", { className: g, style: h.container, children: [
2706
+ /* @__PURE__ */ n("h2", { style: h.title, children: T.verifyingText }),
2700
2707
  /* @__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..." }) })
2701
- ] }) : /* @__PURE__ */ l("div", { className: p, style: h.container, children: [
2702
- /* @__PURE__ */ n("h2", { style: h.title, children: v.title }),
2703
- /* @__PURE__ */ n("p", { style: h.description, children: v.description }),
2704
- /* @__PURE__ */ l("form", { onSubmit: j, style: h.form, children: [
2708
+ ] }) : /* @__PURE__ */ l("div", { className: g, style: h.container, children: [
2709
+ /* @__PURE__ */ n("h2", { style: h.title, children: T.title }),
2710
+ /* @__PURE__ */ n("p", { style: h.description, children: T.description }),
2711
+ /* @__PURE__ */ l("form", { onSubmit: G, style: h.form, children: [
2705
2712
  /* @__PURE__ */ l("div", { style: h.fieldGroup, children: [
2706
- /* @__PURE__ */ n("label", { style: h.label, children: v.emailLabel }),
2713
+ /* @__PURE__ */ n("label", { style: h.label, children: T.emailLabel }),
2707
2714
  /* @__PURE__ */ n(
2708
2715
  "input",
2709
2716
  {
2710
2717
  id: "email",
2711
2718
  name: "email",
2712
2719
  type: "email",
2713
- value: x,
2714
- onChange: (z) => {
2715
- b(z.target.value), T.email && q((V) => ({ ...V, email: !1 }));
2720
+ value: k,
2721
+ onChange: (U) => {
2722
+ b(U.target.value), v.email && C((V) => ({ ...V, email: !1 }));
2716
2723
  },
2717
- placeholder: v.emailPlaceholder,
2718
- style: K("email"),
2719
- disabled: I || u
2724
+ placeholder: T.emailPlaceholder,
2725
+ style: D("email"),
2726
+ disabled: L || u
2720
2727
  }
2721
2728
  )
2722
2729
  ] }),
2723
- !S && /* @__PURE__ */ n("div", { style: { textAlign: "center", marginTop: "0.5rem" }, children: /* @__PURE__ */ n(
2730
+ !x && /* @__PURE__ */ n("div", { style: { textAlign: "center", marginTop: "0.5rem" }, children: /* @__PURE__ */ n(
2724
2731
  "button",
2725
2732
  {
2726
2733
  type: "button",
2727
- onClick: () => P(!0),
2734
+ onClick: () => I(!0),
2728
2735
  style: {
2729
2736
  background: "none",
2730
2737
  border: "none",
@@ -2736,9 +2743,9 @@ function Zt({
2736
2743
  children: "New user? Add your name"
2737
2744
  }
2738
2745
  ) }),
2739
- S && /* @__PURE__ */ l(W, { children: [
2746
+ x && /* @__PURE__ */ l(j, { children: [
2740
2747
  /* @__PURE__ */ l("div", { style: h.fieldGroup, children: [
2741
- /* @__PURE__ */ n("label", { style: h.label, children: v.nameLabel }),
2748
+ /* @__PURE__ */ n("label", { style: h.label, children: T.nameLabel }),
2742
2749
  /* @__PURE__ */ n(
2743
2750
  "input",
2744
2751
  {
@@ -2746,28 +2753,28 @@ function Zt({
2746
2753
  name: "name",
2747
2754
  type: "text",
2748
2755
  value: f,
2749
- onChange: (z) => {
2750
- A(z.target.value), T.name && q((V) => ({ ...V, name: !1 }));
2756
+ onChange: (U) => {
2757
+ A(U.target.value), v.name && C((V) => ({ ...V, name: !1 }));
2751
2758
  },
2752
- placeholder: v.namePlaceholder,
2753
- style: K("name"),
2754
- disabled: I || u
2759
+ placeholder: T.namePlaceholder,
2760
+ style: D("name"),
2761
+ disabled: L || u
2755
2762
  }
2756
2763
  )
2757
2764
  ] }),
2758
2765
  /* @__PURE__ */ l("div", { style: h.fieldGroup, children: [
2759
- /* @__PURE__ */ n("label", { style: h.label, children: v.lastNameLabel }),
2766
+ /* @__PURE__ */ n("label", { style: h.label, children: T.lastNameLabel }),
2760
2767
  /* @__PURE__ */ n(
2761
2768
  "input",
2762
2769
  {
2763
2770
  id: "lastName",
2764
2771
  name: "lastName",
2765
2772
  type: "text",
2766
- value: L,
2767
- onChange: (z) => D(z.target.value),
2768
- placeholder: v.lastNamePlaceholder,
2773
+ value: E,
2774
+ onChange: (U) => $(U.target.value),
2775
+ placeholder: T.lastNamePlaceholder,
2769
2776
  style: h.input,
2770
- disabled: I || u
2777
+ disabled: L || u
2771
2778
  }
2772
2779
  )
2773
2780
  ] }),
@@ -2776,7 +2783,7 @@ function Zt({
2776
2783
  {
2777
2784
  type: "button",
2778
2785
  onClick: () => {
2779
- P(!1), A(""), D("");
2786
+ I(!1), A(""), $("");
2780
2787
  },
2781
2788
  style: {
2782
2789
  background: "none",
@@ -2790,30 +2797,30 @@ function Zt({
2790
2797
  }
2791
2798
  ) })
2792
2799
  ] }),
2793
- /* @__PURE__ */ n("button", { type: "submit", disabled: !x || I || u, style: N(), children: I ? v.loadingText : v.submitButton }),
2794
- m && /* @__PURE__ */ n("div", { style: h.errorText, children: m }),
2795
- $ && /* @__PURE__ */ n("div", { style: h.successText, children: $ })
2800
+ /* @__PURE__ */ n("button", { type: "submit", disabled: !k || L || u, style: H(), children: L ? T.loadingText : T.submitButton }),
2801
+ z && /* @__PURE__ */ n("div", { style: h.errorText, children: z }),
2802
+ p && /* @__PURE__ */ n("div", { style: h.successText, children: p })
2796
2803
  ] }),
2797
2804
  a && /* @__PURE__ */ l("div", { style: h.linkContainer, children: [
2798
2805
  /* @__PURE__ */ l("div", { children: [
2799
2806
  /* @__PURE__ */ l("span", { style: h.divider, children: [
2800
- v.loginText,
2807
+ T.loginText,
2801
2808
  " "
2802
2809
  ] }),
2803
- /* @__PURE__ */ n("a", { onClick: s, style: h.link, children: v.loginLink })
2810
+ /* @__PURE__ */ n("a", { onClick: s, style: h.link, children: T.loginLink })
2804
2811
  ] }),
2805
2812
  /* @__PURE__ */ n("div", { style: h.divider, children: "•" }),
2806
2813
  /* @__PURE__ */ l("div", { children: [
2807
2814
  /* @__PURE__ */ l("span", { style: h.divider, children: [
2808
- v.signupText,
2815
+ T.signupText,
2809
2816
  " "
2810
2817
  ] }),
2811
- /* @__PURE__ */ n("a", { onClick: o, style: h.link, children: v.signupLink })
2818
+ /* @__PURE__ */ n("a", { onClick: o, style: h.link, children: T.signupLink })
2812
2819
  ] })
2813
2820
  ] })
2814
2821
  ] });
2815
2822
  }
2816
- const kt = {
2823
+ const At = {
2817
2824
  title: "Verifying Magic Link",
2818
2825
  verifyingMessage: "Please wait while we verify your magic link...",
2819
2826
  successMessage: "Magic link verified successfully! You are now logged in.",
@@ -2908,7 +2915,7 @@ const kt = {
2908
2915
  cursor: "pointer",
2909
2916
  transition: "all 0.15s ease-in-out"
2910
2917
  }
2911
- }, xt = () => /* @__PURE__ */ n("div", { style: $e.spinner }), At = () => /* @__PURE__ */ l(
2918
+ }, Tt = () => /* @__PURE__ */ n("div", { style: $e.spinner }), Pt = () => /* @__PURE__ */ l(
2912
2919
  "svg",
2913
2920
  {
2914
2921
  width: "48",
@@ -2925,7 +2932,7 @@ const kt = {
2925
2932
  /* @__PURE__ */ n("polyline", { points: "22,4 12,14.01 9,11.01" })
2926
2933
  ]
2927
2934
  }
2928
- ), Tt = () => /* @__PURE__ */ l(
2935
+ ), Mt = () => /* @__PURE__ */ l(
2929
2936
  "svg",
2930
2937
  {
2931
2938
  width: "48",
@@ -2943,12 +2950,12 @@ const kt = {
2943
2950
  /* @__PURE__ */ n("line", { x1: "9", y1: "9", x2: "15", y2: "15" })
2944
2951
  ]
2945
2952
  }
2946
- ), Pt = {
2947
- loading: /* @__PURE__ */ n(xt, {}),
2948
- success: /* @__PURE__ */ n(At, {}),
2949
- error: /* @__PURE__ */ n(Tt, {})
2953
+ ), It = {
2954
+ loading: /* @__PURE__ */ n(Tt, {}),
2955
+ success: /* @__PURE__ */ n(Pt, {}),
2956
+ error: /* @__PURE__ */ n(Mt, {})
2950
2957
  };
2951
- function er({
2958
+ function rr({
2952
2959
  copy: i = {},
2953
2960
  styles: e = {},
2954
2961
  icons: t = {},
@@ -2956,80 +2963,80 @@ function er({
2956
2963
  onError: s,
2957
2964
  onRetry: o,
2958
2965
  onBackToLogin: a,
2959
- className: p,
2966
+ className: g,
2960
2967
  token: w,
2961
- email: y,
2962
- appId: x,
2968
+ email: m,
2969
+ appId: k,
2963
2970
  tenantSlug: b,
2964
2971
  autoRedirectDelay: f = 3e3
2965
2972
  }) {
2966
- const [A, L] = k("verifying"), [D, I] = k(""), { verifyMagicLink: M } = oe(), u = { ...kt, ...i }, R = { ...$e, ...e }, m = { ...Pt, ...t }, H = () => {
2973
+ const [A, E] = S("verifying"), [$, L] = S(""), { verifyMagicLink: P } = oe(), u = { ...At, ...i }, M = { ...$e, ...e }, z = { ...It, ...t }, N = () => {
2967
2974
  if (typeof window > "u") return {};
2968
- const S = new URLSearchParams(window.location.search);
2975
+ const x = new URLSearchParams(window.location.search);
2969
2976
  return {
2970
- token: w || S.get("token") || "",
2971
- email: y || S.get("email") || "",
2972
- appId: x || S.get("appId") || "",
2973
- tenantSlug: b || S.get("tenantSlug") || void 0
2977
+ token: w || x.get("token") || "",
2978
+ email: m || x.get("email") || "",
2979
+ appId: k || x.get("appId") || "",
2980
+ tenantSlug: b || x.get("tenantSlug") || void 0
2974
2981
  };
2975
- }, $ = async () => {
2976
- L("verifying"), I("");
2982
+ }, p = async () => {
2983
+ E("verifying"), L("");
2977
2984
  try {
2978
- const S = H();
2979
- if (!S.token || !S.email)
2985
+ const x = N();
2986
+ if (!x.token || !x.email)
2980
2987
  throw new Error("Missing required parameters: token or email");
2981
- const P = await M({
2982
- token: S.token,
2983
- email: S.email,
2984
- tenantSlug: S.tenantSlug
2988
+ const I = await P({
2989
+ token: x.token,
2990
+ email: x.email,
2991
+ tenantSlug: x.tenantSlug
2985
2992
  });
2986
- L("success"), r == null || r(P), f > 0 && setTimeout(() => {
2987
- L("redirecting");
2993
+ E("success"), r == null || r(I), f > 0 && setTimeout(() => {
2994
+ E("redirecting");
2988
2995
  }, f);
2989
- } catch (S) {
2990
- const P = S.message || u.errorMessage;
2991
- I(P), L("error"), s == null || s(P);
2996
+ } catch (x) {
2997
+ const I = x.message || u.errorMessage;
2998
+ L(I), E("error"), s == null || s(I);
2992
2999
  }
2993
- }, C = () => {
2994
- o == null || o(), $();
2995
- }, T = () => {
3000
+ }, O = () => {
3001
+ o == null || o(), p();
3002
+ }, v = () => {
2996
3003
  a == null || a();
2997
3004
  };
2998
3005
  te(() => {
2999
- $();
3006
+ p();
3000
3007
  }, []);
3001
- const q = () => {
3008
+ const C = () => {
3002
3009
  switch (A) {
3003
3010
  case "verifying":
3004
- return /* @__PURE__ */ l("div", { style: R.message, children: [
3005
- m.loading,
3011
+ return /* @__PURE__ */ l("div", { style: M.message, children: [
3012
+ z.loading,
3006
3013
  u.verifyingMessage
3007
3014
  ] });
3008
3015
  case "success":
3009
- return /* @__PURE__ */ l(W, { children: [
3010
- m.success,
3011
- /* @__PURE__ */ n("div", { style: R.successMessage, children: u.successMessage })
3016
+ return /* @__PURE__ */ l(j, { children: [
3017
+ z.success,
3018
+ /* @__PURE__ */ n("div", { style: M.successMessage, children: u.successMessage })
3012
3019
  ] });
3013
3020
  case "redirecting":
3014
- return /* @__PURE__ */ l(W, { children: [
3015
- m.loading,
3016
- /* @__PURE__ */ n("div", { style: R.message, children: u.redirectingMessage })
3021
+ return /* @__PURE__ */ l(j, { children: [
3022
+ z.loading,
3023
+ /* @__PURE__ */ n("div", { style: M.message, children: u.redirectingMessage })
3017
3024
  ] });
3018
3025
  case "error":
3019
- return /* @__PURE__ */ l(W, { children: [
3020
- m.error,
3021
- /* @__PURE__ */ n("div", { style: R.errorMessage, children: D || u.errorMessage }),
3022
- /* @__PURE__ */ l("div", { style: R.buttonContainer, children: [
3026
+ return /* @__PURE__ */ l(j, { children: [
3027
+ z.error,
3028
+ /* @__PURE__ */ n("div", { style: M.errorMessage, children: $ || u.errorMessage }),
3029
+ /* @__PURE__ */ l("div", { style: M.buttonContainer, children: [
3023
3030
  /* @__PURE__ */ n(
3024
3031
  "button",
3025
3032
  {
3026
- onClick: C,
3027
- style: R.retryButton,
3028
- onMouseOver: (S) => {
3029
- S.currentTarget.style.backgroundColor = "#2563eb";
3033
+ onClick: O,
3034
+ style: M.retryButton,
3035
+ onMouseOver: (x) => {
3036
+ x.currentTarget.style.backgroundColor = "#2563eb";
3030
3037
  },
3031
- onMouseOut: (S) => {
3032
- S.currentTarget.style.backgroundColor = "#3b82f6";
3038
+ onMouseOut: (x) => {
3039
+ x.currentTarget.style.backgroundColor = "#3b82f6";
3033
3040
  },
3034
3041
  children: u.retryButton
3035
3042
  }
@@ -3037,13 +3044,13 @@ function er({
3037
3044
  /* @__PURE__ */ n(
3038
3045
  "button",
3039
3046
  {
3040
- onClick: T,
3041
- style: R.backButton,
3042
- onMouseOver: (S) => {
3043
- S.currentTarget.style.backgroundColor = "#e5e7eb";
3047
+ onClick: v,
3048
+ style: M.backButton,
3049
+ onMouseOver: (x) => {
3050
+ x.currentTarget.style.backgroundColor = "#e5e7eb";
3044
3051
  },
3045
- onMouseOut: (S) => {
3046
- S.currentTarget.style.backgroundColor = "#f3f4f6";
3052
+ onMouseOut: (x) => {
3053
+ x.currentTarget.style.backgroundColor = "#f3f4f6";
3047
3054
  },
3048
3055
  children: u.backToLoginButton
3049
3056
  }
@@ -3054,18 +3061,18 @@ function er({
3054
3061
  return null;
3055
3062
  }
3056
3063
  };
3057
- return /* @__PURE__ */ l("div", { style: R.container, className: p, children: [
3064
+ return /* @__PURE__ */ l("div", { style: M.container, className: g, children: [
3058
3065
  /* @__PURE__ */ n("style", { children: `
3059
3066
  @keyframes spin {
3060
3067
  0% { transform: rotate(0deg); }
3061
3068
  100% { transform: rotate(360deg); }
3062
3069
  }
3063
3070
  ` }),
3064
- /* @__PURE__ */ n("h1", { style: R.title, children: u.title }),
3065
- q()
3071
+ /* @__PURE__ */ n("h1", { style: M.title, children: u.title }),
3072
+ C()
3066
3073
  ] });
3067
3074
  }
3068
- const Mt = {
3075
+ const Rt = {
3069
3076
  title: "Reset Password",
3070
3077
  subtitle: "Enter your email address and we'll send you a link to reset your password.",
3071
3078
  emailLabel: "Email",
@@ -3087,7 +3094,7 @@ const Mt = {
3087
3094
  resetLoadingText: "Resetting...",
3088
3095
  resetSuccessMessage: "Password reset successfully!",
3089
3096
  passwordMismatchError: "Passwords do not match"
3090
- }, It = {
3097
+ }, Lt = {
3091
3098
  container: {
3092
3099
  maxWidth: "400px",
3093
3100
  margin: "0 auto",
@@ -3179,7 +3186,7 @@ const Mt = {
3179
3186
  cursor: "pointer"
3180
3187
  }
3181
3188
  };
3182
- function tr({
3189
+ function nr({
3183
3190
  copy: i = {},
3184
3191
  styles: e = {},
3185
3192
  mode: t = "request",
@@ -3187,105 +3194,105 @@ function tr({
3187
3194
  onSuccess: s,
3188
3195
  onError: o,
3189
3196
  onBackToLogin: a,
3190
- onModeChange: p,
3197
+ onModeChange: g,
3191
3198
  className: w
3192
3199
  }) {
3193
- const [y, x] = k(""), [b, f] = k(r), [A, L] = k(""), [D, I] = k(""), [M, u] = k(!1), [R, m] = k(""), [H, $] = k(""), [C, T] = k({}), { requestPasswordReset: q, confirmPasswordReset: S } = oe(), { tenant: P } = le(), E = { ...Mt, ...i }, d = { ...It, ...e }, F = () => {
3194
- const N = {};
3195
- return y.trim() || (N.email = !0), T(N), Object.keys(N).length === 0;
3196
- }, v = () => {
3197
- const N = {};
3198
- return b.trim() || (N.token = !0), A.trim() || (N.newPassword = !0), D.trim() || (N.confirmPassword = !0), T(N), Object.keys(N).length === 0;
3199
- }, h = async (N) => {
3200
- if (N.preventDefault(), !!F()) {
3201
- if (!(P != null && P.id)) {
3202
- m("Tenant not found");
3200
+ const [m, k] = S(""), [b, f] = S(r), [A, E] = S(""), [$, L] = S(""), [P, u] = S(!1), [M, z] = S(""), [N, p] = S(""), [O, v] = S({}), { requestPasswordReset: C, confirmPasswordReset: x } = oe(), { tenant: I } = le(), F = { ...Rt, ...i }, c = { ...Lt, ...e }, R = () => {
3201
+ const H = {};
3202
+ return m.trim() || (H.email = !0), v(H), Object.keys(H).length === 0;
3203
+ }, T = () => {
3204
+ const H = {};
3205
+ return b.trim() || (H.token = !0), A.trim() || (H.newPassword = !0), $.trim() || (H.confirmPassword = !0), v(H), Object.keys(H).length === 0;
3206
+ }, h = async (H) => {
3207
+ if (H.preventDefault(), !!R()) {
3208
+ if (!(I != null && I.id)) {
3209
+ z("Tenant not found");
3203
3210
  return;
3204
3211
  }
3205
- u(!0), m(""), $("");
3212
+ u(!0), z(""), p("");
3206
3213
  try {
3207
- await q({ email: y, tenantId: P.id }), $(E.successMessage), s == null || s();
3208
- } catch (z) {
3209
- const V = z.message || E.errorMessage;
3210
- m(V), o == null || o(V);
3214
+ await C({ email: m, tenantId: I.id }), p(F.successMessage), s == null || s();
3215
+ } catch (U) {
3216
+ const V = U.message || F.errorMessage;
3217
+ z(V), o == null || o(V);
3211
3218
  } finally {
3212
3219
  u(!1);
3213
3220
  }
3214
3221
  }
3215
- }, g = async (N) => {
3216
- if (N.preventDefault(), !!v()) {
3217
- if (A !== D) {
3218
- m(E.passwordMismatchError), T({ confirmPassword: !0 });
3222
+ }, d = async (H) => {
3223
+ if (H.preventDefault(), !!T()) {
3224
+ if (A !== $) {
3225
+ z(F.passwordMismatchError), v({ confirmPassword: !0 });
3219
3226
  return;
3220
3227
  }
3221
- u(!0), m(""), $("");
3228
+ u(!0), z(""), p("");
3222
3229
  try {
3223
- await S({ token: b, newPassword: A }), $(E.resetSuccessMessage), s == null || s();
3224
- } catch (z) {
3225
- const V = z.message || E.errorMessage;
3226
- m(V), o == null || o(V);
3230
+ await x({ token: b, newPassword: A }), p(F.resetSuccessMessage), s == null || s();
3231
+ } catch (U) {
3232
+ const V = U.message || F.errorMessage;
3233
+ z(V), o == null || o(V);
3227
3234
  } finally {
3228
3235
  u(!1);
3229
3236
  }
3230
3237
  }
3231
- }, c = (N) => ({
3232
- ...d.input,
3233
- ...C[N] ? d.inputError : {}
3234
- }), j = () => ({
3235
- ...d.button,
3236
- ...M ? d.buttonLoading : {}
3238
+ }, y = (H) => ({
3239
+ ...c.input,
3240
+ ...O[H] ? c.inputError : {}
3241
+ }), G = () => ({
3242
+ ...c.button,
3243
+ ...P ? c.buttonLoading : {}
3237
3244
  });
3238
3245
  if (t === "reset") {
3239
- const N = b && A && D;
3240
- return /* @__PURE__ */ l("div", { className: w, style: d.container, children: [
3241
- /* @__PURE__ */ n("h2", { style: d.title, children: E.resetTitle }),
3242
- /* @__PURE__ */ n("p", { style: d.subtitle, children: E.resetSubtitle }),
3243
- /* @__PURE__ */ l("form", { onSubmit: g, style: d.form, children: [
3244
- /* @__PURE__ */ l("div", { style: d.fieldGroup, children: [
3245
- /* @__PURE__ */ n("label", { style: d.label, children: E.tokenLabel }),
3246
+ const H = b && A && $;
3247
+ return /* @__PURE__ */ l("div", { className: w, style: c.container, children: [
3248
+ /* @__PURE__ */ n("h2", { style: c.title, children: F.resetTitle }),
3249
+ /* @__PURE__ */ n("p", { style: c.subtitle, children: F.resetSubtitle }),
3250
+ /* @__PURE__ */ l("form", { onSubmit: d, style: c.form, children: [
3251
+ /* @__PURE__ */ l("div", { style: c.fieldGroup, children: [
3252
+ /* @__PURE__ */ n("label", { style: c.label, children: F.tokenLabel }),
3246
3253
  /* @__PURE__ */ n(
3247
3254
  "input",
3248
3255
  {
3249
3256
  type: "text",
3250
3257
  value: b,
3251
- onChange: (z) => {
3252
- f(z.target.value), C.token && T((V) => ({ ...V, token: !1 }));
3258
+ onChange: (U) => {
3259
+ f(U.target.value), O.token && v((V) => ({ ...V, token: !1 }));
3253
3260
  },
3254
- placeholder: E.tokenPlaceholder,
3255
- style: c("token"),
3256
- disabled: M
3261
+ placeholder: F.tokenPlaceholder,
3262
+ style: y("token"),
3263
+ disabled: P
3257
3264
  }
3258
3265
  )
3259
3266
  ] }),
3260
- /* @__PURE__ */ l("div", { style: d.fieldGroup, children: [
3261
- /* @__PURE__ */ n("label", { style: d.label, children: E.newPasswordLabel }),
3267
+ /* @__PURE__ */ l("div", { style: c.fieldGroup, children: [
3268
+ /* @__PURE__ */ n("label", { style: c.label, children: F.newPasswordLabel }),
3262
3269
  /* @__PURE__ */ n(
3263
3270
  "input",
3264
3271
  {
3265
3272
  type: "password",
3266
3273
  value: A,
3267
- onChange: (z) => {
3268
- L(z.target.value), C.newPassword && T((V) => ({ ...V, newPassword: !1 }));
3274
+ onChange: (U) => {
3275
+ E(U.target.value), O.newPassword && v((V) => ({ ...V, newPassword: !1 }));
3269
3276
  },
3270
- placeholder: E.newPasswordPlaceholder,
3271
- style: c("newPassword"),
3272
- disabled: M
3277
+ placeholder: F.newPasswordPlaceholder,
3278
+ style: y("newPassword"),
3279
+ disabled: P
3273
3280
  }
3274
3281
  )
3275
3282
  ] }),
3276
- /* @__PURE__ */ l("div", { style: d.fieldGroup, children: [
3277
- /* @__PURE__ */ n("label", { style: d.label, children: E.confirmPasswordLabel }),
3283
+ /* @__PURE__ */ l("div", { style: c.fieldGroup, children: [
3284
+ /* @__PURE__ */ n("label", { style: c.label, children: F.confirmPasswordLabel }),
3278
3285
  /* @__PURE__ */ n(
3279
3286
  "input",
3280
3287
  {
3281
3288
  type: "password",
3282
- value: D,
3283
- onChange: (z) => {
3284
- I(z.target.value), C.confirmPassword && T((V) => ({ ...V, confirmPassword: !1 })), R === E.passwordMismatchError && m("");
3289
+ value: $,
3290
+ onChange: (U) => {
3291
+ L(U.target.value), O.confirmPassword && v((V) => ({ ...V, confirmPassword: !1 })), M === F.passwordMismatchError && z("");
3285
3292
  },
3286
- placeholder: E.confirmPasswordPlaceholder,
3287
- style: c("confirmPassword"),
3288
- disabled: M
3293
+ placeholder: F.confirmPasswordPlaceholder,
3294
+ style: y("confirmPassword"),
3295
+ disabled: P
3289
3296
  }
3290
3297
  )
3291
3298
  ] }),
@@ -3293,44 +3300,44 @@ function tr({
3293
3300
  "button",
3294
3301
  {
3295
3302
  type: "submit",
3296
- disabled: !N || M,
3303
+ disabled: !H || P,
3297
3304
  style: {
3298
- ...j(),
3299
- ...!N || M ? d.buttonDisabled : {}
3305
+ ...G(),
3306
+ ...!H || P ? c.buttonDisabled : {}
3300
3307
  },
3301
- children: M ? E.resetLoadingText : E.resetSubmitButton
3308
+ children: P ? F.resetLoadingText : F.resetSubmitButton
3302
3309
  }
3303
3310
  ),
3304
- R && /* @__PURE__ */ n("div", { style: d.errorText, children: R }),
3305
- H && /* @__PURE__ */ n("div", { style: d.successText, children: H })
3311
+ M && /* @__PURE__ */ n("div", { style: c.errorText, children: M }),
3312
+ N && /* @__PURE__ */ n("div", { style: c.successText, children: N })
3306
3313
  ] }),
3307
- /* @__PURE__ */ l("div", { style: d.linkContainer, children: [
3308
- /* @__PURE__ */ n("a", { onClick: a, style: d.link, children: E.backToLoginLink }),
3309
- p && /* @__PURE__ */ l(W, { children: [
3314
+ /* @__PURE__ */ l("div", { style: c.linkContainer, children: [
3315
+ /* @__PURE__ */ n("a", { onClick: a, style: c.link, children: F.backToLoginLink }),
3316
+ g && /* @__PURE__ */ l(j, { children: [
3310
3317
  /* @__PURE__ */ n("span", { style: { margin: "0 0.5rem", color: "#6b7280" }, children: "•" }),
3311
- /* @__PURE__ */ n("a", { onClick: () => p("request"), style: d.link, children: "Request New Link" })
3318
+ /* @__PURE__ */ n("a", { onClick: () => g("request"), style: c.link, children: "Request New Link" })
3312
3319
  ] })
3313
3320
  ] })
3314
3321
  ] });
3315
3322
  }
3316
- const K = y;
3317
- return /* @__PURE__ */ l("div", { className: w, style: d.container, children: [
3318
- /* @__PURE__ */ n("h2", { style: d.title, children: E.title }),
3319
- /* @__PURE__ */ n("p", { style: d.subtitle, children: E.subtitle }),
3320
- /* @__PURE__ */ l("form", { onSubmit: h, style: d.form, children: [
3321
- /* @__PURE__ */ l("div", { style: d.fieldGroup, children: [
3322
- /* @__PURE__ */ n("label", { style: d.label, children: E.emailLabel }),
3323
+ const D = m;
3324
+ return /* @__PURE__ */ l("div", { className: w, style: c.container, children: [
3325
+ /* @__PURE__ */ n("h2", { style: c.title, children: F.title }),
3326
+ /* @__PURE__ */ n("p", { style: c.subtitle, children: F.subtitle }),
3327
+ /* @__PURE__ */ l("form", { onSubmit: h, style: c.form, children: [
3328
+ /* @__PURE__ */ l("div", { style: c.fieldGroup, children: [
3329
+ /* @__PURE__ */ n("label", { style: c.label, children: F.emailLabel }),
3323
3330
  /* @__PURE__ */ n(
3324
3331
  "input",
3325
3332
  {
3326
3333
  type: "email",
3327
- value: y,
3328
- onChange: (N) => {
3329
- x(N.target.value), C.email && T((z) => ({ ...z, email: !1 }));
3334
+ value: m,
3335
+ onChange: (H) => {
3336
+ k(H.target.value), O.email && v((U) => ({ ...U, email: !1 }));
3330
3337
  },
3331
- placeholder: E.emailPlaceholder,
3332
- style: c("email"),
3333
- disabled: M
3338
+ placeholder: F.emailPlaceholder,
3339
+ style: y("email"),
3340
+ disabled: P
3334
3341
  }
3335
3342
  )
3336
3343
  ] }),
@@ -3338,27 +3345,27 @@ function tr({
3338
3345
  "button",
3339
3346
  {
3340
3347
  type: "submit",
3341
- disabled: !K || M,
3348
+ disabled: !D || P,
3342
3349
  style: {
3343
- ...j(),
3344
- ...!K || M ? d.buttonDisabled : {}
3350
+ ...G(),
3351
+ ...!D || P ? c.buttonDisabled : {}
3345
3352
  },
3346
- children: M ? E.loadingText : E.submitButton
3353
+ children: P ? F.loadingText : F.submitButton
3347
3354
  }
3348
3355
  ),
3349
- R && /* @__PURE__ */ n("div", { style: d.errorText, children: R }),
3350
- H && /* @__PURE__ */ n("div", { style: d.successText, children: H })
3356
+ M && /* @__PURE__ */ n("div", { style: c.errorText, children: M }),
3357
+ N && /* @__PURE__ */ n("div", { style: c.successText, children: N })
3351
3358
  ] }),
3352
- /* @__PURE__ */ l("div", { style: d.linkContainer, children: [
3353
- /* @__PURE__ */ n("a", { onClick: a, style: d.link, children: E.backToLoginLink }),
3354
- p && /* @__PURE__ */ l(W, { children: [
3359
+ /* @__PURE__ */ l("div", { style: c.linkContainer, children: [
3360
+ /* @__PURE__ */ n("a", { onClick: a, style: c.link, children: F.backToLoginLink }),
3361
+ g && /* @__PURE__ */ l(j, { children: [
3355
3362
  /* @__PURE__ */ n("span", { style: { margin: "0 0.5rem", color: "#6b7280" }, children: "•" }),
3356
- /* @__PURE__ */ n("a", { onClick: () => p("reset"), style: d.link, children: "I have a token" })
3363
+ /* @__PURE__ */ n("a", { onClick: () => g("reset"), style: c.link, children: "I have a token" })
3357
3364
  ] })
3358
3365
  ] })
3359
3366
  ] });
3360
3367
  }
3361
- const Rt = () => /* @__PURE__ */ n(
3368
+ const Et = () => /* @__PURE__ */ n(
3362
3369
  "div",
3363
3370
  {
3364
3371
  style: {
@@ -3370,7 +3377,7 @@ const Rt = () => /* @__PURE__ */ n(
3370
3377
  },
3371
3378
  children: /* @__PURE__ */ n("div", { children: "Loading..." })
3372
3379
  }
3373
- ), Lt = ({ error: i, retry: e }) => /* @__PURE__ */ l(
3380
+ ), Ft = ({ error: i, retry: e }) => /* @__PURE__ */ l(
3374
3381
  "div",
3375
3382
  {
3376
3383
  style: {
@@ -3404,43 +3411,43 @@ const Rt = () => /* @__PURE__ */ n(
3404
3411
  ]
3405
3412
  }
3406
3413
  );
3407
- function rr({
3414
+ function sr({
3408
3415
  children: i,
3409
3416
  loadingFallback: e,
3410
3417
  errorFallback: t,
3411
3418
  requireTenant: r = !0
3412
3419
  }) {
3413
- const { isAppLoading: s, appError: o, retryApp: a } = he(), p = ye(), w = Fe(), y = Ce(), x = De(), b = (p == null ? void 0 : p.isTenantLoading) ?? !1, f = (p == null ? void 0 : p.tenantError) ?? null, A = (p == null ? void 0 : p.tenantSlug) ?? null, L = (p == null ? void 0 : p.retryTenant) ?? (() => {
3414
- }), D = (w == null ? void 0 : w.isAuthReady) ?? !0, I = (y == null ? void 0 : y.isReady) ?? !0, M = (x == null ? void 0 : x.isReady) ?? !0, u = r && p && A, $ = s || u && b || w && !D || y && !I || x && !M, C = o || (u ? f : null), T = () => {
3415
- o && a(), f && p && L();
3420
+ const { isAppLoading: s, appError: o, retryApp: a } = he(), g = ye(), w = Fe(), m = Ce(), k = De(), b = (g == null ? void 0 : g.isTenantLoading) ?? !1, f = (g == null ? void 0 : g.tenantError) ?? null, A = (g == null ? void 0 : g.tenantSlug) ?? null, E = (g == null ? void 0 : g.retryTenant) ?? (() => {
3421
+ }), $ = (w == null ? void 0 : w.isAuthReady) ?? !0, L = (m == null ? void 0 : m.isReady) ?? !0, P = (k == null ? void 0 : k.isReady) ?? !0, u = r && g && A, p = s || u && b || w && !$ || m && !L || k && !P, O = o || (u ? f : null), v = () => {
3422
+ o && a(), f && g && E();
3416
3423
  };
3417
- if ($)
3418
- return /* @__PURE__ */ n(W, { children: e || /* @__PURE__ */ n(Rt, {}) });
3419
- if (C) {
3420
- const q = typeof t == "function" ? t(C, T) : t || /* @__PURE__ */ n(Lt, { error: C, retry: T });
3421
- return /* @__PURE__ */ n(W, { children: q });
3424
+ if (p)
3425
+ return /* @__PURE__ */ n(j, { children: e || /* @__PURE__ */ n(Et, {}) });
3426
+ if (O) {
3427
+ const C = typeof t == "function" ? t(O, v) : t || /* @__PURE__ */ n(Ft, { error: O, retry: v });
3428
+ return /* @__PURE__ */ n(j, { children: C });
3422
3429
  }
3423
- return /* @__PURE__ */ n(W, { children: i });
3430
+ return /* @__PURE__ */ n(j, { children: i });
3424
3431
  }
3425
- function nr(i = !0) {
3426
- const { isAppLoading: e, appError: t, retryApp: r, appInfo: s } = he(), o = ye(), a = Fe(), p = Ce(), w = De(), y = (o == null ? void 0 : o.isTenantLoading) ?? !1, x = (o == null ? void 0 : o.tenantError) ?? null, b = (o == null ? void 0 : o.tenant) ?? null, f = (o == null ? void 0 : o.tenantSlug) ?? null, A = (o == null ? void 0 : o.retryTenant) ?? (() => {
3427
- }), L = (a == null ? void 0 : a.isAuthReady) ?? !0, D = (p == null ? void 0 : p.isReady) ?? !0, I = (w == null ? void 0 : w.isReady) ?? !0, M = i && o && f, H = e || M && y || a && !L || p && !D || w && !I, $ = t || (M ? x : null);
3432
+ function ir(i = !0) {
3433
+ const { isAppLoading: e, appError: t, retryApp: r, appInfo: s } = he(), o = ye(), a = Fe(), g = Ce(), w = De(), m = (o == null ? void 0 : o.isTenantLoading) ?? !1, k = (o == null ? void 0 : o.tenantError) ?? null, b = (o == null ? void 0 : o.tenant) ?? null, f = (o == null ? void 0 : o.tenantSlug) ?? null, A = (o == null ? void 0 : o.retryTenant) ?? (() => {
3434
+ }), E = (a == null ? void 0 : a.isAuthReady) ?? !0, $ = (g == null ? void 0 : g.isReady) ?? !0, L = (w == null ? void 0 : w.isReady) ?? !0, P = i && o && f, N = e || P && m || a && !E || g && !$ || w && !L, p = t || (P ? k : null);
3428
3435
  return {
3429
- isLoading: H,
3430
- error: $,
3431
- isReady: !H && !$ && s !== null && (!M || b !== null),
3436
+ isLoading: N,
3437
+ error: p,
3438
+ isReady: !N && !p && s !== null && (!P || b !== null),
3432
3439
  retry: () => {
3433
- t && r(), x && o && A();
3440
+ t && r(), k && o && A();
3434
3441
  },
3435
3442
  // Individual states
3436
3443
  app: { isLoading: e, error: t, data: s },
3437
- tenant: o ? { isLoading: y, error: x, data: b } : null,
3438
- auth: a ? { isReady: L } : null,
3439
- featureFlags: p ? { isReady: D } : null,
3440
- subscription: w ? { isReady: I } : null
3444
+ tenant: o ? { isLoading: m, error: k, data: b } : null,
3445
+ auth: a ? { isReady: E } : null,
3446
+ featureFlags: g ? { isReady: $ } : null,
3447
+ subscription: w ? { isReady: L } : null
3441
3448
  };
3442
3449
  }
3443
- class sr {
3450
+ class or {
3444
3451
  constructor(e, t) {
3445
3452
  this.httpService = e, this.sessionManager = t;
3446
3453
  }
@@ -3508,7 +3515,7 @@ class sr {
3508
3515
  };
3509
3516
  }
3510
3517
  }
3511
- class ir {
3518
+ class ar {
3512
3519
  constructor(e, t) {
3513
3520
  this.httpService = e, this.sessionManager = t;
3514
3521
  }
@@ -3559,7 +3566,7 @@ class ir {
3559
3566
  });
3560
3567
  }
3561
3568
  }
3562
- class or {
3569
+ class lr {
3563
3570
  constructor(e) {
3564
3571
  this.httpService = e;
3565
3572
  }
@@ -3568,7 +3575,7 @@ class or {
3568
3575
  return await this.httpService.get("/health");
3569
3576
  }
3570
3577
  }
3571
- class ar {
3578
+ class cr {
3572
3579
  // Date string to Date object
3573
3580
  static toDate(e) {
3574
3581
  return new Date(e);
@@ -3691,47 +3698,47 @@ class ar {
3691
3698
  }
3692
3699
  }
3693
3700
  export {
3694
- ar as ApiMappers,
3701
+ cr as ApiMappers,
3695
3702
  Pe as AppApiService,
3696
- rr as AppLoader,
3697
- Nt as AppProvider,
3698
- _e as AuthApiService,
3699
- Ot as AuthProvider,
3700
- Yt as FeatureFlag,
3701
- rt as FeatureFlagApiService,
3702
- Wt as FeatureFlagProvider,
3703
- or as HealthApiService,
3703
+ sr as AppLoader,
3704
+ Bt as AppProvider,
3705
+ Ke as AuthApiService,
3706
+ jt as AuthProvider,
3707
+ Xt as FeatureFlag,
3708
+ st as FeatureFlagApiService,
3709
+ Vt as FeatureFlagProvider,
3710
+ lr as HealthApiService,
3704
3711
  re as HttpService,
3705
- Kt as LandingRoute,
3706
- Qt as LoginForm,
3707
- Zt as MagicLinkForm,
3708
- er as MagicLinkVerify,
3709
- tr as PasswordRecoveryForm,
3710
- sr as PermissionApiService,
3711
- Vt as Protected,
3712
- _t as ProtectedRoute,
3712
+ Yt as LandingRoute,
3713
+ Zt as LoginForm,
3714
+ tr as MagicLinkForm,
3715
+ rr as MagicLinkVerify,
3716
+ nr as PasswordRecoveryForm,
3717
+ or as PermissionApiService,
3718
+ Gt as Protected,
3719
+ Kt as ProtectedRoute,
3713
3720
  Me as RoleApiService,
3714
3721
  be as SessionManager,
3715
- Xt as SignupForm,
3716
- st as SubscriptionApiService,
3717
- Jt as SubscriptionGuard,
3718
- ir as SubscriptionPlanApiService,
3719
- jt as SubscriptionProvider,
3722
+ er as SignupForm,
3723
+ ot as SubscriptionApiService,
3724
+ Qt as SubscriptionGuard,
3725
+ ar as SubscriptionPlanApiService,
3726
+ _t as SubscriptionProvider,
3720
3727
  de as TenantApiService,
3721
- Bt as TenantProvider,
3722
- Gt as TenantRoute,
3723
- Ge as UserApiService,
3728
+ zt as TenantProvider,
3729
+ Jt as TenantRoute,
3730
+ Je as UserApiService,
3724
3731
  ie as UserType,
3725
- Ut as useApi,
3732
+ qt as useApi,
3726
3733
  he as useApp,
3727
- nr as useAppLoaderState,
3734
+ ir as useAppLoaderState,
3728
3735
  oe as useAuth,
3729
- nt as useFeatureFlags,
3730
- zt as useSettings,
3731
- it as useSubscription,
3736
+ it as useFeatureFlags,
3737
+ Wt as useSettings,
3738
+ at as useSubscription,
3732
3739
  me as useTenant,
3733
3740
  le as useTenantInfo,
3734
3741
  ye as useTenantOptional,
3735
- qt as useTenantSettings
3742
+ Ot as useTenantSettings
3736
3743
  };
3737
3744
  //# sourceMappingURL=index.es.js.map