@skylabs-digital/react-identity-access 2.0.0 → 2.0.1

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
@@ -15,7 +15,7 @@ class re {
15
15
  async request(e, t, r, s) {
16
16
  return this.executeRequest(e, t, r, s, !1);
17
17
  }
18
- async executeRequest(e, t, r, s, a = !1) {
18
+ async executeRequest(e, t, r, s, o = !1) {
19
19
  const p = `${this.baseUrl}${t.startsWith("/") ? t : `/${t}`}`, I = (s == null ? void 0 : s.timeout) || this.timeout;
20
20
  let A = {
21
21
  "Content-Type": "application/json",
@@ -28,7 +28,7 @@ class re {
28
28
  } catch (b) {
29
29
  console.warn("Failed to inject auth headers:", b);
30
30
  }
31
- const x = new AbortController(), P = setTimeout(() => x.abort(), I);
31
+ const x = new AbortController(), T = setTimeout(() => x.abort(), I);
32
32
  try {
33
33
  const b = await fetch(p, {
34
34
  method: e,
@@ -36,7 +36,7 @@ class re {
36
36
  body: r ? JSON.stringify(r) : void 0,
37
37
  signal: x.signal
38
38
  });
39
- if (clearTimeout(P), b.status === 401 && !(s != null && s.skipRetry) && !a && this.sessionManager)
39
+ if (clearTimeout(T), b.status === 401 && !(s != null && s.skipRetry) && !o && this.sessionManager)
40
40
  try {
41
41
  const h = this.sessionManager.getTokens();
42
42
  if (h != null && h.refreshToken)
@@ -46,10 +46,10 @@ class re {
46
46
  }
47
47
  if (!b.ok)
48
48
  throw new Error(`HTTP ${b.status}: ${b.statusText}`);
49
- const m = b.headers.get("content-type");
50
- return !m || !m.includes("application/json") ? {} : await b.json();
49
+ const f = b.headers.get("content-type");
50
+ return !f || !f.includes("application/json") ? {} : await b.json();
51
51
  } catch (b) {
52
- throw clearTimeout(P), b instanceof Error && b.name === "AbortError" ? new Error(`Request timeout after ${I}ms`) : b;
52
+ throw clearTimeout(T), b instanceof Error && b.name === "AbortError" ? new Error(`Request timeout after ${I}ms`) : b;
53
53
  }
54
54
  }
55
55
  async get(e, t) {
@@ -78,12 +78,12 @@ class be {
78
78
  async getApps(e) {
79
79
  const t = await this.sessionManager.getAuthHeaders(), r = new URLSearchParams();
80
80
  e != null && e.page && r.append("page", e.page.toString()), e != null && e.limit && r.append("limit", e.limit.toString()), e != null && e.sortBy && r.append("sortBy", e.sortBy), e != null && e.sortOrder && r.append("sortOrder", e.sortOrder);
81
- const s = `/apps/${r.toString() ? `?${r.toString()}` : ""}`, a = await this.httpService.get(s, {
81
+ const s = `/apps/${r.toString() ? `?${r.toString()}` : ""}`, o = await this.httpService.get(s, {
82
82
  headers: t
83
83
  });
84
84
  return {
85
- apps: a.data,
86
- meta: a.meta
85
+ apps: o.data,
86
+ meta: o.meta
87
87
  };
88
88
  }
89
89
  async getAppById(e) {
@@ -173,9 +173,9 @@ const Ae = de(null), De = () => /* @__PURE__ */ n(
173
173
  function St({ config: i, children: e }) {
174
174
  const t = Q(
175
175
  () => {
176
- var m, h, S;
176
+ var f, h, S;
177
177
  return {
178
- enabled: ((m = i.cache) == null ? void 0 : m.enabled) ?? !0,
178
+ enabled: ((f = i.cache) == null ? void 0 : f.enabled) ?? !0,
179
179
  ttl: ((h = i.cache) == null ? void 0 : h.ttl) ?? 3e5,
180
180
  // 5 minutes default
181
181
  storageKey: ((S = i.cache) == null ? void 0 : S.storageKey) ?? `app_cache_${i.appId}`
@@ -185,42 +185,42 @@ function St({ config: i, children: e }) {
185
185
  ), [r, s] = v(() => {
186
186
  if (!t.enabled) return null;
187
187
  try {
188
- const m = localStorage.getItem(t.storageKey);
189
- if (!m) return null;
190
- const h = JSON.parse(m);
188
+ const f = localStorage.getItem(t.storageKey);
189
+ if (!f) return null;
190
+ const h = JSON.parse(f);
191
191
  return Date.now() - h.timestamp < t.ttl && h.appId === i.appId ? h.data : (localStorage.removeItem(t.storageKey), null);
192
192
  } catch {
193
193
  return null;
194
194
  }
195
- }), [a, p] = v(!r), [I, A] = v(null), x = Q(() => {
196
- const m = () => {
197
- P();
195
+ }), [o, p] = v(!r), [I, A] = v(null), x = Q(() => {
196
+ const f = () => {
197
+ T();
198
198
  };
199
199
  return {
200
200
  appId: i.appId,
201
201
  baseUrl: i.baseUrl,
202
202
  // App info
203
203
  appInfo: r,
204
- isAppLoading: a,
204
+ isAppLoading: o,
205
205
  appError: I,
206
- retryApp: m
206
+ retryApp: f
207
207
  };
208
- }, [i, r, a, I]), P = ne(
209
- async (m = !1) => {
210
- if (!(!m && t.enabled && r))
208
+ }, [i, r, o, I]), T = ne(
209
+ async (f = !1) => {
210
+ if (!(!f && t.enabled && r))
211
211
  try {
212
212
  p(!0), A(null);
213
213
  const h = new re(i.baseUrl), L = await new be(h, {}).getPublicAppInfo(i.appId);
214
214
  if (s(L), t.enabled)
215
215
  try {
216
- const C = {
216
+ const R = {
217
217
  data: L,
218
218
  timestamp: Date.now(),
219
219
  appId: i.appId
220
220
  };
221
- localStorage.setItem(t.storageKey, JSON.stringify(C));
222
- } catch (C) {
223
- console.warn("Failed to cache app info:", C);
221
+ localStorage.setItem(t.storageKey, JSON.stringify(R));
222
+ } catch (R) {
223
+ console.warn("Failed to cache app info:", R);
224
224
  }
225
225
  } catch (h) {
226
226
  const S = h instanceof Error ? h : new Error("Failed to load app information");
@@ -233,9 +233,9 @@ function St({ config: i, children: e }) {
233
233
  ), b = ne(async () => {
234
234
  if (!(!t.enabled || !r))
235
235
  try {
236
- const m = localStorage.getItem(t.storageKey);
237
- if (!m) return;
238
- const h = JSON.parse(m);
236
+ const f = localStorage.getItem(t.storageKey);
237
+ if (!f) return;
238
+ const h = JSON.parse(f);
239
239
  if (Date.now() - h.timestamp > t.ttl * 0.5) {
240
240
  const L = new re(i.baseUrl), q = await new be(L, {}).getPublicAppInfo(i.appId);
241
241
  s(q);
@@ -246,17 +246,17 @@ function St({ config: i, children: e }) {
246
246
  };
247
247
  localStorage.setItem(t.storageKey, JSON.stringify(k));
248
248
  }
249
- } catch (m) {
250
- console.warn("Background app refresh failed:", m);
249
+ } catch (f) {
250
+ console.warn("Background app refresh failed:", f);
251
251
  }
252
252
  }, [i, t, r]);
253
253
  if (te(() => {
254
- r ? b() : P();
255
- }, []), a)
254
+ r ? b() : T();
255
+ }, []), o)
256
256
  return /* @__PURE__ */ n(N, { children: i.loadingFallback || /* @__PURE__ */ n(De, {}) });
257
257
  if (I) {
258
- const m = typeof i.errorFallback == "function" ? i.errorFallback(I, () => P()) : i.errorFallback || /* @__PURE__ */ n(He, { error: I, retry: () => P() });
259
- return /* @__PURE__ */ n(N, { children: m });
258
+ const f = typeof i.errorFallback == "function" ? i.errorFallback(I, () => T()) : i.errorFallback || /* @__PURE__ */ n(He, { error: I, retry: () => T() });
259
+ return /* @__PURE__ */ n(N, { children: f });
260
260
  }
261
261
  return /* @__PURE__ */ n(Ae.Provider, { value: x, children: e });
262
262
  }
@@ -304,7 +304,14 @@ class ye {
304
304
  this.tokenStorage.set(t);
305
305
  }
306
306
  getTokens() {
307
- return this.tokenStorage.get();
307
+ const { accessToken: e, refreshToken: t, expiresAt: r, expiresIn: s, tokenType: o } = this.tokenStorage.get() || {};
308
+ return e ? {
309
+ accessToken: e,
310
+ refreshToken: t,
311
+ expiresAt: r,
312
+ expiresIn: s,
313
+ tokenType: o
314
+ } : null;
308
315
  }
309
316
  clearTokens() {
310
317
  this.tokenStorage.clear();
@@ -419,8 +426,7 @@ class Ne {
419
426
  }
420
427
  // Public endpoints - no auth required
421
428
  async login(e) {
422
- const t = await this.httpService.post("/auth/login", e);
423
- return console.log(t), t;
429
+ return await this.httpService.post("/auth/login", e);
424
430
  }
425
431
  async signup(e) {
426
432
  return await this.httpService.post("/auth/signup", e);
@@ -499,10 +505,10 @@ class Se {
499
505
  async getRolesByApp(e, t) {
500
506
  const r = new URLSearchParams();
501
507
  t != null && t.page && r.append("page", t.page.toString()), t != null && t.limit && r.append("limit", t.limit.toString()), t != null && t.sortBy && r.append("sortBy", t.sortBy), t != null && t.sortOrder && r.append("sortOrder", t.sortOrder);
502
- const s = `/roles/app/${e}${r.toString() ? `?${r.toString()}` : ""}`, a = await this.httpService.get(s);
508
+ const s = `/roles/app/${e}${r.toString() ? `?${r.toString()}` : ""}`, o = await this.httpService.get(s);
503
509
  return {
504
- roles: a.data,
505
- meta: a.meta
510
+ roles: o.data,
511
+ meta: o.meta
506
512
  };
507
513
  }
508
514
  async assignRole(e, t) {
@@ -526,7 +532,7 @@ class Se {
526
532
  throw new Error("SessionManager is required for private endpoints");
527
533
  const r = await this.sessionManager.getAuthHeaders(), s = new URLSearchParams();
528
534
  t != null && t.page && s.append("page", t.page.toString()), t != null && t.limit && s.append("limit", t.limit.toString()), t != null && t.sortBy && s.append("sortBy", t.sortBy), t != null && t.sortOrder && s.append("sortOrder", t.sortOrder);
529
- const a = `/roles/user/${e}${s.toString() ? `?${s.toString()}` : ""}`, p = await this.httpService.get(a, {
535
+ const o = `/roles/user/${e}${s.toString() ? `?${s.toString()}` : ""}`, p = await this.httpService.get(o, {
530
536
  headers: r
531
537
  });
532
538
  return {
@@ -548,12 +554,12 @@ class Be {
548
554
  async getUsers(e) {
549
555
  const t = await this.sessionManager.getAuthHeaders(), r = new URLSearchParams();
550
556
  e != null && e.page && r.append("page", e.page.toString()), e != null && e.limit && r.append("limit", e.limit.toString()), e != null && e.sortBy && r.append("sortBy", e.sortBy), e != null && e.sortOrder && r.append("sortOrder", e.sortOrder);
551
- const s = `/users/${r.toString() ? `?${r.toString()}` : ""}`, a = await this.httpService.get(s, {
557
+ const s = `/users/${r.toString() ? `?${r.toString()}` : ""}`, o = await this.httpService.get(s, {
552
558
  headers: t
553
559
  });
554
560
  return {
555
- users: a.data,
556
- meta: a.meta
561
+ users: o.data,
562
+ meta: o.meta
557
563
  };
558
564
  }
559
565
  async getUserById(e) {
@@ -592,12 +598,12 @@ class ce {
592
598
  throw new Error("SessionManager is required for private endpoints");
593
599
  const t = await this.sessionManager.getAuthHeaders(), r = new URLSearchParams();
594
600
  e != null && e.page && r.append("page", e.page.toString()), e != null && e.limit && r.append("limit", e.limit.toString()), e != null && e.sortBy && r.append("sortBy", e.sortBy), e != null && e.sortOrder && r.append("sortOrder", e.sortOrder);
595
- const s = `/tenants/${r.toString() ? `?${r.toString()}` : ""}`, a = await this.httpService.get(s, {
601
+ const s = `/tenants/${r.toString() ? `?${r.toString()}` : ""}`, o = await this.httpService.get(s, {
596
602
  headers: t
597
603
  });
598
604
  return {
599
- tenants: a.data,
600
- meta: a.meta
605
+ tenants: o.data,
606
+ meta: o.meta
601
607
  };
602
608
  }
603
609
  async getTenantById(e) {
@@ -653,7 +659,7 @@ class ce {
653
659
  )).data;
654
660
  }
655
661
  }
656
- const Pe = de(null), Ue = () => /* @__PURE__ */ n(
662
+ const Te = de(null), Ue = () => /* @__PURE__ */ n(
657
663
  "div",
658
664
  {
659
665
  style: {
@@ -700,129 +706,129 @@ const Pe = de(null), Ue = () => /* @__PURE__ */ n(
700
706
  }
701
707
  );
702
708
  function xt({ config: i, children: e }) {
703
- const { baseUrl: t, appInfo: r, appId: s } = he(), a = ne(() => {
704
- const o = i.tenantMode || "selector", g = "tenant";
709
+ const { baseUrl: t, appInfo: r, appId: s } = he(), o = ne(() => {
710
+ const a = i.tenantMode || "selector", g = "tenant";
705
711
  if (typeof window > "u") return null;
706
- if (o === "subdomain") {
707
- const d = window.location.hostname.split(".");
708
- if (d.length >= 3) {
709
- const c = d[0];
710
- return localStorage.setItem(g, c), c;
712
+ if (a === "subdomain") {
713
+ const c = window.location.hostname.split(".");
714
+ if (c.length >= 3) {
715
+ const d = c[0];
716
+ return localStorage.setItem(g, d), d;
711
717
  }
712
718
  return localStorage.getItem(g);
713
- } else if (o === "selector") {
714
- const d = new URLSearchParams(window.location.search).get(i.selectorParam || "tenant");
715
- return d ? (localStorage.setItem(g, d), d) : localStorage.getItem(g);
719
+ } else if (a === "selector") {
720
+ const c = new URLSearchParams(window.location.search).get(i.selectorParam || "tenant");
721
+ return c ? (localStorage.setItem(g, c), c) : localStorage.getItem(g);
716
722
  }
717
723
  return null;
718
- }, [i.tenantMode, i.selectorParam]), [p, I] = v(() => a()), A = Q(
724
+ }, [i.tenantMode, i.selectorParam]), [p, I] = v(() => o()), A = Q(
719
725
  () => {
720
- var o, g, f;
726
+ var a, g, m;
721
727
  return {
722
- enabled: ((o = i.cache) == null ? void 0 : o.enabled) ?? !0,
728
+ enabled: ((a = i.cache) == null ? void 0 : a.enabled) ?? !0,
723
729
  ttl: ((g = i.cache) == null ? void 0 : g.ttl) ?? 5 * 60 * 1e3,
724
730
  // 5 minutes default
725
- storageKey: ((f = i.cache) == null ? void 0 : f.storageKey) ?? `tenant_cache_${p || "default"}`
731
+ storageKey: ((m = i.cache) == null ? void 0 : m.storageKey) ?? `tenant_cache_${p || "default"}`
726
732
  };
727
733
  },
728
734
  [i.cache, p]
729
- ), [x, P] = v(() => {
735
+ ), [x, T] = v(() => {
730
736
  if (i.initialTenant) return i.initialTenant;
731
737
  if (!A.enabled || !p) return null;
732
738
  try {
733
- const o = localStorage.getItem(A.storageKey);
734
- if (!o) return null;
735
- const g = JSON.parse(o);
739
+ const a = localStorage.getItem(A.storageKey);
740
+ if (!a) return null;
741
+ const g = JSON.parse(a);
736
742
  return Date.now() - g.timestamp < A.ttl && g.tenantSlug === p ? g.data : (localStorage.removeItem(A.storageKey), null);
737
743
  } catch {
738
744
  return null;
739
745
  }
740
- }), [b, m] = v(!x && !i.initialTenant), [h, S] = v(null), [L, C] = v(null), [q, k] = v(!1), [u, T] = v(null);
746
+ }), [b, f] = v(!x && !i.initialTenant), [h, S] = v(null), [L, R] = v(null), [q, k] = v(!1), [u, P] = v(null);
741
747
  te(() => {
742
- const o = a();
743
- I(o);
744
- }, [a]);
745
- const R = (r == null ? void 0 : r.settingsSchema) || null, H = ne(
746
- async (o, g = !1) => {
747
- if (!(!g && A.enabled && x && x.domain === o))
748
+ const a = o();
749
+ I(a);
750
+ }, [o]);
751
+ const C = (r == null ? void 0 : r.settingsSchema) || null, H = ne(
752
+ async (a, g = !1) => {
753
+ if (!(!g && A.enabled && x && x.domain === a))
748
754
  try {
749
- m(!0), S(null);
750
- const f = new re(t), c = await new ce(f, s).getPublicTenantInfo(o);
751
- if (P(c), A.enabled)
755
+ f(!0), S(null);
756
+ const m = new re(t), d = await new ce(m, s).getPublicTenantInfo(a);
757
+ if (T(d), A.enabled)
752
758
  try {
753
759
  const y = {
754
- data: c,
760
+ data: d,
755
761
  timestamp: Date.now(),
756
- tenantSlug: o
762
+ tenantSlug: a
757
763
  };
758
764
  localStorage.setItem(A.storageKey, JSON.stringify(y));
759
765
  } catch (y) {
760
766
  console.warn("Failed to cache tenant info:", y);
761
767
  }
762
- } catch (f) {
763
- const d = f instanceof Error ? f : new Error("Failed to load tenant information");
764
- S(d), P(null);
768
+ } catch (m) {
769
+ const c = m instanceof Error ? m : new Error("Failed to load tenant information");
770
+ S(c), T(null);
765
771
  } finally {
766
- m(!1);
772
+ f(!1);
767
773
  }
768
774
  },
769
775
  [t, s, A, x]
770
- ), G = ne(async () => {
776
+ ), W = ne(async () => {
771
777
  if (!(!A.enabled || !x || !p))
772
778
  try {
773
- const o = localStorage.getItem(A.storageKey);
774
- if (!o) return;
775
- const g = JSON.parse(o);
779
+ const a = localStorage.getItem(A.storageKey);
780
+ if (!a) return;
781
+ const g = JSON.parse(a);
776
782
  if (Date.now() - g.timestamp > A.ttl * 0.5) {
777
- const d = new re(t), y = await new ce(d, s).getPublicTenantInfo(p);
778
- P(y);
779
- const W = {
783
+ const c = new re(t), y = await new ce(c, s).getPublicTenantInfo(p);
784
+ T(y);
785
+ const G = {
780
786
  data: y,
781
787
  timestamp: Date.now(),
782
788
  tenantSlug: p
783
789
  };
784
- localStorage.setItem(A.storageKey, JSON.stringify(W));
790
+ localStorage.setItem(A.storageKey, JSON.stringify(G));
785
791
  }
786
- } catch (o) {
787
- console.warn("Background tenant refresh failed:", o);
792
+ } catch (a) {
793
+ console.warn("Background tenant refresh failed:", a);
788
794
  }
789
795
  }, [t, s, A, x, p]), F = ne(async () => {
790
796
  if (x != null && x.id)
791
797
  try {
792
- k(!0), T(null);
793
- const o = new re(t), f = await new ce(o, x.appId).getTenantSettings(x.id);
794
- C(f);
795
- } catch (o) {
796
- const g = o instanceof Error ? o : new Error("Failed to load tenant settings");
797
- T(g), C(null);
798
+ k(!0), P(null);
799
+ const a = new re(t), m = await new ce(a, x.appId).getTenantSettings(x.id);
800
+ R(m);
801
+ } catch (a) {
802
+ const g = a instanceof Error ? a : new Error("Failed to load tenant settings");
803
+ P(g), R(null);
798
804
  } finally {
799
805
  k(!1);
800
806
  }
801
807
  }, [t, x]), V = ne(() => {
802
808
  F();
803
809
  }, [F]), w = ne(
804
- (o) => {
805
- if (!R)
810
+ (a) => {
811
+ if (!C)
806
812
  return { isValid: !0, errors: [] };
807
813
  const g = [];
808
814
  try {
809
- return R.properties && Object.entries(R.properties).forEach(([f, d]) => {
815
+ return C.properties && Object.entries(C.properties).forEach(([m, c]) => {
810
816
  var y;
811
- const c = o[f];
812
- if ((y = R.required) != null && y.includes(f) && c == null) {
813
- g.push(`Field '${f}' is required`);
817
+ const d = a[m];
818
+ if ((y = C.required) != null && y.includes(m) && d == null) {
819
+ g.push(`Field '${m}' is required`);
814
820
  return;
815
821
  }
816
- if (c != null) {
817
- if (d.type) {
818
- const W = d.type, ee = typeof c;
819
- W === "string" && ee !== "string" ? g.push(`Field '${f}' must be a string`) : (W === "number" || W === "integer") && ee !== "number" ? g.push(`Field '${f}' must be a number`) : W === "boolean" && ee !== "boolean" ? g.push(`Field '${f}' must be a boolean`) : W === "array" && !Array.isArray(c) && g.push(`Field '${f}' must be an array`);
822
+ if (d != null) {
823
+ if (c.type) {
824
+ const G = c.type, ee = typeof d;
825
+ G === "string" && ee !== "string" ? g.push(`Field '${m}' must be a string`) : (G === "number" || G === "integer") && ee !== "number" ? g.push(`Field '${m}' must be a number`) : G === "boolean" && ee !== "boolean" ? g.push(`Field '${m}' must be a boolean`) : G === "array" && !Array.isArray(d) && g.push(`Field '${m}' must be an array`);
820
826
  }
821
- d.minLength !== void 0 && typeof c == "string" && c.length < d.minLength && g.push(
822
- `Field '${f}' must be at least ${d.minLength} characters long`
823
- ), d.maxLength !== void 0 && typeof c == "string" && c.length > d.maxLength && g.push(
824
- `Field '${f}' must be no more than ${d.maxLength} characters long`
825
- ), d.minimum !== void 0 && typeof c == "number" && c < d.minimum && g.push(`Field '${f}' must be at least ${d.minimum}`), d.maximum !== void 0 && typeof c == "number" && c > d.maximum && g.push(`Field '${f}' must be no more than ${d.maximum}`), d.pattern && typeof c == "string" && (new RegExp(d.pattern).test(c) || g.push(`Field '${f}' does not match the required pattern`)), d.enum && !d.enum.includes(c) && g.push(`Field '${f}' must be one of: ${d.enum.join(", ")}`);
827
+ c.minLength !== void 0 && typeof d == "string" && d.length < c.minLength && g.push(
828
+ `Field '${m}' must be at least ${c.minLength} characters long`
829
+ ), c.maxLength !== void 0 && typeof d == "string" && d.length > c.maxLength && g.push(
830
+ `Field '${m}' must be no more than ${c.maxLength} characters long`
831
+ ), c.minimum !== void 0 && typeof d == "number" && d < c.minimum && g.push(`Field '${m}' must be at least ${c.minimum}`), c.maximum !== void 0 && typeof d == "number" && d > c.maximum && g.push(`Field '${m}' must be no more than ${c.maximum}`), c.pattern && typeof d == "string" && (new RegExp(c.pattern).test(d) || g.push(`Field '${m}' does not match the required pattern`)), c.enum && !c.enum.includes(d) && g.push(`Field '${m}' must be one of: ${c.enum.join(", ")}`);
826
832
  }
827
833
  }), {
828
834
  isValid: g.length === 0,
@@ -835,40 +841,35 @@ function xt({ config: i, children: e }) {
835
841
  };
836
842
  }
837
843
  },
838
- [R]
844
+ [C]
839
845
  );
840
846
  te(() => {
841
- !i.initialTenant && p ? x ? G() : H(p) : !i.initialTenant && !p && (P(null), S(null), m(!1));
842
- }, [i.initialTenant, p, x, H, G]), te(() => {
843
- x != null && x.id ? F() : (C(null), T(null), k(!1));
847
+ !i.initialTenant && p ? x ? W() : H(p) : !i.initialTenant && !p && (T(null), S(null), f(!1));
848
+ }, [i.initialTenant, p, x, H, W]), te(() => {
849
+ x != null && x.id ? F() : (R(null), P(null), k(!1));
844
850
  }, [x == null ? void 0 : x.id, F]);
845
851
  const M = ne(
846
- (o, g = "reload") => {
847
- const f = i.tenantMode || "selector";
848
- if (console.log("[TenantProvider] Switching tenant:", {
849
- targetTenantSlug: o,
850
- currentTenantSlug: p,
851
- tenantMode: f,
852
- mode: g
853
- }), localStorage.setItem("tenant", o), f === "subdomain") {
854
- const d = window.location.hostname, c = d.split(".");
855
- if (c.length >= 2) {
856
- c[0] = o;
857
- const y = c.join("."), W = `${window.location.protocol}//${y}${window.location.pathname}${window.location.search}`;
858
- console.log("[TenantProvider] Redirecting to:", W), window.location.href = W;
852
+ (a, g = "reload") => {
853
+ const m = i.tenantMode || "selector";
854
+ if (localStorage.setItem("tenant", a), m === "subdomain") {
855
+ const c = window.location.hostname, d = c.split(".");
856
+ if (d.length >= 2) {
857
+ d[0] = a;
858
+ const y = d.join("."), G = `${window.location.protocol}//${y}${window.location.pathname}${window.location.search}`;
859
+ window.location.href = G;
859
860
  } else
860
861
  console.warn(
861
862
  "[TenantProvider] Cannot switch subdomain, invalid hostname:",
862
- d
863
+ c
863
864
  );
864
- } else if (f === "selector") {
865
- const d = new URLSearchParams(window.location.search);
866
- if (d.set(i.selectorParam || "tenant", o), g === "reload") {
867
- const c = `${window.location.pathname}?${d.toString()}${window.location.hash}`;
868
- console.log("[TenantProvider] Reloading with new tenant:", c), window.location.href = c;
865
+ } else if (m === "selector") {
866
+ const c = new URLSearchParams(window.location.search);
867
+ if (c.set(i.selectorParam || "tenant", a), g === "reload") {
868
+ const d = `${window.location.pathname}?${c.toString()}${window.location.hash}`;
869
+ window.location.href = d;
869
870
  } else {
870
- const c = `${window.location.pathname}?${d.toString()}${window.location.hash}`;
871
- console.log("[TenantProvider] Navigating without reload:", c), window.history.pushState({}, "", c), I(o), H(o);
871
+ const d = `${window.location.pathname}?${c.toString()}${window.location.hash}`;
872
+ window.history.pushState({}, "", d), I(a), H(a);
872
873
  }
873
874
  }
874
875
  },
@@ -884,7 +885,7 @@ function xt({ config: i, children: e }) {
884
885
  },
885
886
  // Settings
886
887
  settings: L,
887
- settingsSchema: R,
888
+ settingsSchema: C,
888
889
  isSettingsLoading: q,
889
890
  settingsError: u,
890
891
  // Actions
@@ -898,7 +899,7 @@ function xt({ config: i, children: e }) {
898
899
  b,
899
900
  h,
900
901
  L,
901
- R,
902
+ C,
902
903
  q,
903
904
  u,
904
905
  V,
@@ -908,13 +909,13 @@ function xt({ config: i, children: e }) {
908
909
  if (b)
909
910
  return /* @__PURE__ */ n(N, { children: i.loadingFallback || /* @__PURE__ */ n(Ue, {}) });
910
911
  if (h) {
911
- const o = typeof i.errorFallback == "function" ? i.errorFallback(h, () => H(p || "")) : i.errorFallback || /* @__PURE__ */ n(qe, { error: h, retry: () => H(p || "") });
912
- return /* @__PURE__ */ n(N, { children: o });
912
+ const a = typeof i.errorFallback == "function" ? i.errorFallback(h, () => H(p || "")) : i.errorFallback || /* @__PURE__ */ n(qe, { error: h, retry: () => H(p || "") });
913
+ return /* @__PURE__ */ n(N, { children: a });
913
914
  }
914
- return /* @__PURE__ */ n(Pe.Provider, { value: E, children: e });
915
+ return /* @__PURE__ */ n(Te.Provider, { value: E, children: e });
915
916
  }
916
917
  function fe() {
917
- const i = ue(Pe);
918
+ const i = ue(Te);
918
919
  if (!i)
919
920
  throw new Error("useTenant must be used within a TenantProvider");
920
921
  return i;
@@ -940,17 +941,17 @@ function se() {
940
941
  retry: s
941
942
  };
942
943
  }
943
- const Te = de(null);
944
- function Pt({ config: i = {}, children: e }) {
945
- const { appId: t, baseUrl: r } = he(), { tenant: s, tenantSlug: a, switchTenant: p } = fe(), [I, A] = v(i.initialRoles || []), [x, P] = v(!i.initialRoles), [b, m] = v(null), [h, S] = v(!1), [L, C] = v(null), [q, k] = v(0), u = Q(() => new ye({
946
- tenantSlug: a,
944
+ const Pe = de(null);
945
+ function Tt({ config: i = {}, children: e }) {
946
+ const { appId: t, baseUrl: r } = he(), { tenant: s, tenantSlug: o, switchTenant: p } = fe(), [I, A] = v(i.initialRoles || []), [x, T] = v(!i.initialRoles), [b, f] = v(null), [h, S] = v(!1), [L, R] = v(null), [q, k] = v(0), u = Q(() => new ye({
947
+ tenantSlug: o,
947
948
  // SessionManager will generate storageKey internally
948
949
  onRefreshFailed: i.onRefreshFailed,
949
950
  baseUrl: r
950
- }), [a, r, i.onRefreshFailed]), T = Q(() => {
951
+ }), [o, r, i.onRefreshFailed]), P = Q(() => {
951
952
  const g = new re(r);
952
953
  return g.setSessionManager(u), g;
953
- }, [r, u]), R = Q(() => new Ne(new re(r)), [r]), H = Q(() => new Be(T, u), [T, u]), G = Q(() => new Se(new re(r)), [r]), F = Q(() => b || u.getUser(), [b, u]), V = Q(() => F != null && F.roleId && I.find((g) => g.id === F.roleId) || null, [F, I]), w = Q(() => (V == null ? void 0 : V.permissions) || [], [V]), M = Q(() => u.hasValidSession() && b !== null, [u, b]), E = 5 * 60 * 1e3, o = Q(() => {
954
+ }, [r, u]), C = Q(() => new Ne(new re(r)), [r]), H = Q(() => new Be(P, u), [P, u]), W = Q(() => new Se(new re(r)), [r]), F = Q(() => b || u.getUser(), [b, u]), V = Q(() => F != null && F.roleId && I.find((g) => g.id === F.roleId) || null, [F, I]), w = Q(() => (V == null ? void 0 : V.permissions) || [], [V]), M = Q(() => u.hasValidSession() && b !== null, [u, b]), E = 5 * 60 * 1e3, a = Q(() => {
954
955
  const g = async ($ = !1) => {
955
956
  try {
956
957
  if (!u.hasValidSession())
@@ -963,27 +964,27 @@ function Pt({ config: i = {}, children: e }) {
963
964
  console.warn("[AuthProvider] No userId available in token or storage");
964
965
  return;
965
966
  }
966
- S(!0), C(null);
967
+ S(!0), R(null);
967
968
  const X = await H.getUserById(j);
968
- m(X), u.setUser(X), k(Date.now());
969
+ f(X), u.setUser(X), k(Date.now());
969
970
  } catch (U) {
970
971
  const K = U instanceof Error ? U : new Error("Failed to load user data");
971
- C(K), console.error("[AuthProvider] Failed to load user data:", K);
972
+ R(K), console.error("[AuthProvider] Failed to load user data:", K);
972
973
  } finally {
973
974
  S(!1);
974
975
  }
975
- }, f = async () => {
976
+ }, m = async () => {
976
977
  await g();
977
- }, d = async ($) => {
978
+ }, c = async ($) => {
978
979
  const { username: U, password: K, tenantSlug: j } = $;
979
- let X = s == null ? void 0 : s.id, Y = a, Z = u;
980
- j && (X = (await new ce(T, t).getPublicTenantInfo(j)).id, Y = j);
981
- const J = await R.login({
980
+ let X = s == null ? void 0 : s.id, Y = o, Z = u;
981
+ j && (X = (await new ce(P, t).getPublicTenantInfo(j)).id, Y = j);
982
+ const J = await C.login({
982
983
  username: U,
983
984
  password: K,
984
985
  appId: t,
985
986
  tenantId: X
986
- }), ae = j && j !== a;
987
+ }), ae = j && j !== o;
987
988
  if (ae && (Z = new ye({
988
989
  tenantSlug: Y,
989
990
  baseUrl: r
@@ -992,22 +993,22 @@ function Pt({ config: i = {}, children: e }) {
992
993
  refreshToken: J.refreshToken,
993
994
  expiresIn: J.expiresIn
994
995
  }), J.user) {
995
- Z.setUser(J.user), m(J.user);
996
+ Z.setUser(J.user), f(J.user);
996
997
  try {
997
998
  await g();
998
999
  } catch (le) {
999
1000
  console.warn("Failed to load complete user data after login:", le);
1000
1001
  }
1001
1002
  }
1002
- return ae && Y && Y !== a && p(Y), J;
1003
- }, c = async ($) => {
1003
+ return ae && Y && Y !== o && p(Y), J;
1004
+ }, d = async ($) => {
1004
1005
  const { email: U, phoneNumber: K, name: j, password: X, lastName: Y, tenantId: Z } = $;
1005
1006
  if (!U && !K)
1006
1007
  throw new Error("Either email or phoneNumber is required");
1007
1008
  if (!j || !X)
1008
1009
  throw new Error("Name and password are required");
1009
1010
  const J = Z ?? (s == null ? void 0 : s.id);
1010
- return await R.signup({
1011
+ return await C.signup({
1011
1012
  email: U,
1012
1013
  phoneNumber: K,
1013
1014
  name: j,
@@ -1022,7 +1023,7 @@ function Pt({ config: i = {}, children: e }) {
1022
1023
  throw new Error("Either email or phoneNumber is required");
1023
1024
  if (!j || !X || !Y)
1024
1025
  throw new Error("Name, password, and tenantName are required");
1025
- return await R.signupTenantAdmin({
1026
+ return await C.signupTenantAdmin({
1026
1027
  email: U,
1027
1028
  phoneNumber: K,
1028
1029
  name: j,
@@ -1031,22 +1032,22 @@ function Pt({ config: i = {}, children: e }) {
1031
1032
  appId: t,
1032
1033
  lastName: Z
1033
1034
  });
1034
- }, W = async ($) => {
1035
+ }, G = async ($) => {
1035
1036
  const { currentPassword: U, newPassword: K } = $, j = await u.getAuthHeaders();
1036
- await R.changePassword({ currentPassword: U, newPassword: K }, j);
1037
+ await C.changePassword({ currentPassword: U, newPassword: K }, j);
1037
1038
  }, ee = async ($) => {
1038
1039
  const { email: U, tenantId: K } = $, j = K ?? (s == null ? void 0 : s.id);
1039
1040
  if (!j)
1040
1041
  throw new Error("tenantId is required for password reset");
1041
- await R.requestPasswordReset({ email: U, tenantId: j });
1042
+ await C.requestPasswordReset({ email: U, tenantId: j });
1042
1043
  }, z = async ($) => {
1043
1044
  const { token: U, newPassword: K } = $;
1044
- await R.confirmPasswordReset({ token: U, newPassword: K });
1045
+ await C.confirmPasswordReset({ token: U, newPassword: K });
1045
1046
  }, B = async ($) => {
1046
1047
  const { email: U, frontendUrl: K, name: j, lastName: X, tenantId: Y } = $, Z = Y ?? (s == null ? void 0 : s.id);
1047
1048
  if (!Z)
1048
1049
  throw new Error("tenantId is required for magic link authentication");
1049
- return await R.sendMagicLink({
1050
+ return await C.sendMagicLink({
1050
1051
  email: U,
1051
1052
  tenantId: Z,
1052
1053
  frontendUrl: K,
@@ -1056,14 +1057,14 @@ function Pt({ config: i = {}, children: e }) {
1056
1057
  });
1057
1058
  }, O = async ($) => {
1058
1059
  const { token: U, email: K, tenantSlug: j } = $;
1059
- let X = s == null ? void 0 : s.id, Y = a, Z = u;
1060
- j && (X = (await new ce(T, t).getPublicTenantInfo(j)).id, Y = j);
1061
- const J = await R.verifyMagicLink({
1060
+ let X = s == null ? void 0 : s.id, Y = o, Z = u;
1061
+ j && (X = (await new ce(P, t).getPublicTenantInfo(j)).id, Y = j);
1062
+ const J = await C.verifyMagicLink({
1062
1063
  token: U,
1063
1064
  email: K,
1064
1065
  appId: t,
1065
1066
  tenantId: X
1066
- }), ae = j && j !== a;
1067
+ }), ae = j && j !== o;
1067
1068
  if (ae && (Z = new ye({
1068
1069
  tenantSlug: Y,
1069
1070
  baseUrl: r
@@ -1072,19 +1073,19 @@ function Pt({ config: i = {}, children: e }) {
1072
1073
  refreshToken: J.refreshToken,
1073
1074
  expiresIn: J.expiresIn
1074
1075
  }), J.user) {
1075
- Z.setUser(J.user), m(J.user);
1076
+ Z.setUser(J.user), f(J.user);
1076
1077
  try {
1077
1078
  await g();
1078
1079
  } catch (le) {
1079
1080
  console.warn("Failed to load complete user data after magic link login:", le);
1080
1081
  }
1081
1082
  }
1082
- return ae && Y && Y !== a && p(Y), J;
1083
+ return ae && Y && Y !== o && p(Y), J;
1083
1084
  }, D = async () => {
1084
1085
  const $ = u.getTokens();
1085
1086
  if (!($ != null && $.refreshToken))
1086
1087
  throw new Error("No refresh token available");
1087
- const U = await R.refreshToken({
1088
+ const U = await C.refreshToken({
1088
1089
  refreshToken: $.refreshToken
1089
1090
  });
1090
1091
  u.setTokens({
@@ -1093,21 +1094,21 @@ function Pt({ config: i = {}, children: e }) {
1093
1094
  expiresIn: U.expiresIn
1094
1095
  });
1095
1096
  }, _ = () => {
1096
- u.clearSession(), m(null), C(null);
1097
+ u.clearSession(), f(null), R(null);
1097
1098
  }, ge = ($) => {
1098
1099
  u.setTokens($);
1099
- }, Re = () => u.hasValidSession(), Ce = () => {
1100
- u.clearSession(), m(null), C(null);
1100
+ }, Ce = () => u.hasValidSession(), Re = () => {
1101
+ u.clearSession(), f(null), R(null);
1101
1102
  }, Le = async () => {
1102
1103
  if (t)
1103
1104
  try {
1104
- P(!0);
1105
- const { roles: $ } = await G.getRolesByApp(t);
1105
+ T(!0);
1106
+ const { roles: $ } = await W.getRolesByApp(t);
1106
1107
  A($);
1107
1108
  } catch ($) {
1108
1109
  console.error("Failed to fetch roles:", $);
1109
1110
  } finally {
1110
- P(!1);
1111
+ T(!1);
1111
1112
  }
1112
1113
  }, Fe = async () => {
1113
1114
  await Le();
@@ -1123,25 +1124,25 @@ function Pt({ config: i = {}, children: e }) {
1123
1124
  // RFC-003: Authentication state
1124
1125
  isAuthenticated: M,
1125
1126
  sessionManager: u,
1126
- authenticatedHttpService: T,
1127
- login: d,
1128
- signup: c,
1127
+ authenticatedHttpService: P,
1128
+ login: c,
1129
+ signup: d,
1129
1130
  signupTenantAdmin: y,
1130
1131
  sendMagicLink: B,
1131
1132
  verifyMagicLink: O,
1132
- changePassword: W,
1133
+ changePassword: G,
1133
1134
  requestPasswordReset: ee,
1134
1135
  confirmPasswordReset: z,
1135
1136
  refreshToken: D,
1136
1137
  logout: _,
1137
1138
  setTokens: ge,
1138
- hasValidSession: Re,
1139
- clearSession: Ce,
1139
+ hasValidSession: Ce,
1140
+ clearSession: Re,
1140
1141
  currentUser: b,
1141
1142
  isUserLoading: h,
1142
1143
  userError: L,
1143
1144
  loadUserData: g,
1144
- refreshUser: f,
1145
+ refreshUser: m,
1145
1146
  userRole: V,
1146
1147
  userPermissions: w,
1147
1148
  availableRoles: I,
@@ -1155,13 +1156,13 @@ function Pt({ config: i = {}, children: e }) {
1155
1156
  }, [
1156
1157
  M,
1157
1158
  u,
1158
- T,
1159
- R,
1159
+ P,
1160
+ C,
1160
1161
  H,
1161
- G,
1162
+ W,
1162
1163
  t,
1163
1164
  s,
1164
- a,
1165
+ o,
1165
1166
  p,
1166
1167
  I,
1167
1168
  b,
@@ -1175,33 +1176,33 @@ function Pt({ config: i = {}, children: e }) {
1175
1176
  return te(() => {
1176
1177
  !i.initialRoles && t && (async () => {
1177
1178
  try {
1178
- P(!0);
1179
- const f = new re(r), d = new Se(f), { roles: c } = await d.getRolesByApp(t);
1180
- A(c);
1181
- } catch (f) {
1182
- console.error("Failed to fetch roles:", f);
1179
+ T(!0);
1180
+ const m = new re(r), c = new Se(m), { roles: d } = await c.getRolesByApp(t);
1181
+ A(d);
1182
+ } catch (m) {
1183
+ console.error("Failed to fetch roles:", m);
1183
1184
  } finally {
1184
- P(!1);
1185
+ T(!1);
1185
1186
  }
1186
1187
  })();
1187
1188
  }, [t, r, i.initialRoles]), te(() => {
1188
1189
  const g = u.getUser();
1189
- g && u.hasValidSession() && m(g);
1190
+ g && u.hasValidSession() && f(g);
1190
1191
  }, [u]), te(() => {
1191
- !b && !h && o.loadUserData().catch(() => {
1192
+ !b && !h && a.loadUserData().catch(() => {
1192
1193
  });
1193
- }, [b, h, o]), te(() => {
1194
+ }, [b, h, a]), te(() => {
1194
1195
  if (!u.hasValidSession() || !b)
1195
1196
  return;
1196
1197
  const g = setInterval(() => {
1197
- o.loadUserData().catch(() => {
1198
+ a.loadUserData().catch(() => {
1198
1199
  });
1199
1200
  }, E);
1200
1201
  return () => clearInterval(g);
1201
- }, [u, b, o, E]), /* @__PURE__ */ n(Te.Provider, { value: o, children: e });
1202
+ }, [u, b, a, E]), /* @__PURE__ */ n(Pe.Provider, { value: a, children: e });
1202
1203
  }
1203
1204
  function oe() {
1204
- const i = ue(Te);
1205
+ const i = ue(Pe);
1205
1206
  if (!i)
1206
1207
  throw new Error("useAuth must be used within an AuthProvider");
1207
1208
  return i;
@@ -1227,12 +1228,12 @@ class ze {
1227
1228
  throw new Error("SessionManager is required for private endpoints");
1228
1229
  const t = await this.sessionManager.getAuthHeaders(), r = new URLSearchParams();
1229
1230
  e != null && e.page && r.append("page", e.page.toString()), e != null && e.limit && r.append("limit", e.limit.toString()), e != null && e.sortBy && r.append("sortBy", e.sortBy), e != null && e.sortOrder && r.append("sortOrder", e.sortOrder);
1230
- const s = `/feature-flags/${r.toString() ? `?${r.toString()}` : ""}`, a = await this.httpService.get(s, {
1231
+ const s = `/feature-flags/${r.toString() ? `?${r.toString()}` : ""}`, o = await this.httpService.get(s, {
1231
1232
  headers: t
1232
1233
  });
1233
1234
  return {
1234
- featureFlags: a.data,
1235
- meta: a.meta
1235
+ featureFlags: o.data,
1236
+ meta: o.meta
1236
1237
  };
1237
1238
  }
1238
1239
  async getFeatureFlagById(e) {
@@ -1280,55 +1281,55 @@ class ze {
1280
1281
  throw new Error("Flag Key, Tenant ID and App ID are required");
1281
1282
  const s = new URLSearchParams();
1282
1283
  s.append("tenantId", t), s.append("appId", r);
1283
- const a = `/tenant-feature-flags/${e}${s.toString() ? `?${s.toString()}` : ""}`;
1284
- return (await this.httpService.get(a, {
1284
+ const o = `/tenant-feature-flags/${e}${s.toString() ? `?${s.toString()}` : ""}`;
1285
+ return (await this.httpService.get(o, {
1285
1286
  headers: { "X-Tenant-ID": t }
1286
1287
  })).data;
1287
1288
  }
1288
1289
  }
1289
1290
  const Me = de(null);
1290
- function Tt({ config: i = {}, children: e }) {
1291
- const { baseUrl: t, appId: r } = he(), { tenant: s } = se(), [a, p] = v([]), [I, A] = v(!1), [x, P] = v(null), b = Q(() => {
1291
+ function Pt({ config: i = {}, children: e }) {
1292
+ const { baseUrl: t, appId: r } = he(), { tenant: s } = se(), [o, p] = v([]), [I, A] = v(!1), [x, T] = v(null), b = Q(() => {
1292
1293
  const S = new re(t);
1293
1294
  return new ze(S);
1294
- }, [t]), m = async () => {
1295
+ }, [t]), f = async () => {
1295
1296
  if (!(s != null && s.id)) {
1296
1297
  p([]);
1297
1298
  return;
1298
1299
  }
1299
- A(!0), P(null);
1300
+ A(!0), T(null);
1300
1301
  try {
1301
1302
  const S = await b.getTenantFeatureFlags(s.id, r);
1302
1303
  p(S);
1303
1304
  } catch (S) {
1304
1305
  const L = S instanceof Error ? S.message : "Failed to fetch feature flags";
1305
- P(L), i.onError && i.onError(S instanceof Error ? S : new Error(L));
1306
+ T(L), i.onError && i.onError(S instanceof Error ? S : new Error(L));
1306
1307
  } finally {
1307
1308
  A(!1);
1308
1309
  }
1309
1310
  };
1310
1311
  te(() => {
1311
- m();
1312
- const S = i.refreshInterval || 5 * 60 * 1e3, L = setInterval(m, S);
1312
+ f();
1313
+ const S = i.refreshInterval || 5 * 60 * 1e3, L = setInterval(f, S);
1313
1314
  return () => clearInterval(L);
1314
1315
  }, [s == null ? void 0 : s.id, i.refreshInterval]);
1315
1316
  const h = Q(() => ({
1316
- featureFlags: a,
1317
+ featureFlags: o,
1317
1318
  loading: I,
1318
1319
  error: x,
1319
1320
  isEnabled: (k) => {
1320
- const u = a.find((T) => T.key === k);
1321
+ const u = o.find((P) => P.key === k);
1321
1322
  return (u == null ? void 0 : u.value) === !0;
1322
1323
  },
1323
- getFlag: (k) => a.find((u) => u.key === k),
1324
+ getFlag: (k) => o.find((u) => u.key === k),
1324
1325
  getFlagState: (k) => {
1325
- const u = a.find((T) => T.key === k);
1326
+ const u = o.find((P) => P.key === k);
1326
1327
  return u ? u.value ? "enabled" : "disabled" : "not_found";
1327
1328
  },
1328
1329
  refresh: async () => {
1329
- await m();
1330
+ await f();
1330
1331
  }
1331
- }), [a, I, x]);
1332
+ }), [o, I, x]);
1332
1333
  return /* @__PURE__ */ n(Me.Provider, { value: h, children: e });
1333
1334
  }
1334
1335
  function Oe() {
@@ -1405,18 +1406,18 @@ class je {
1405
1406
  }
1406
1407
  const Ie = de(void 0);
1407
1408
  function Mt({ config: i = {}, children: e }) {
1408
- const { baseUrl: t } = he(), { tenant: r } = se(), [s, a] = v(null), [p, I] = v(!1), [A, x] = v(null), P = Q(() => {
1409
+ const { baseUrl: t } = he(), { tenant: r } = se(), [s, o] = v(null), [p, I] = v(!1), [A, x] = v(null), T = Q(() => {
1409
1410
  const h = new re(t);
1410
1411
  return new je(h);
1411
1412
  }, [t]), b = async () => {
1412
1413
  if (!(r != null && r.id)) {
1413
- a(null);
1414
+ o(null);
1414
1415
  return;
1415
1416
  }
1416
1417
  I(!0), x(null);
1417
1418
  try {
1418
- const h = await P.getTenantSubscriptionFeatures(r.id);
1419
- a(h);
1419
+ const h = await T.getTenantSubscriptionFeatures(r.id);
1420
+ o(h);
1420
1421
  } catch (h) {
1421
1422
  const S = h instanceof Error ? h.message : "Failed to fetch subscription";
1422
1423
  x(S), i.onError && i.onError(h instanceof Error ? h : new Error(S));
@@ -1429,7 +1430,7 @@ function Mt({ config: i = {}, children: e }) {
1429
1430
  const h = i.refreshInterval || 10 * 60 * 1e3, S = setInterval(b, h);
1430
1431
  return () => clearInterval(S);
1431
1432
  }, [r == null ? void 0 : r.id, i.refreshInterval]);
1432
- const m = Q(() => {
1433
+ const f = Q(() => {
1433
1434
  const h = (s == null ? void 0 : s.features) || [];
1434
1435
  return {
1435
1436
  subscription: s,
@@ -1437,13 +1438,13 @@ function Mt({ config: i = {}, children: e }) {
1437
1438
  loading: p,
1438
1439
  error: A,
1439
1440
  isFeatureEnabled: (u) => {
1440
- const T = h.find((R) => R.key === u);
1441
- return T ? T.type === "BOOLEAN" || T.type === "boolean" ? T.value === !0 : !!T.value : !1;
1441
+ const P = h.find((C) => C.key === u);
1442
+ return P ? P.type === "BOOLEAN" || P.type === "boolean" ? P.value === !0 : !!P.value : !1;
1442
1443
  },
1443
- getFeature: (u) => h.find((T) => T.key === u),
1444
- getFeatureValue: (u, T) => {
1445
- const R = h.find((H) => H.key === u);
1446
- return R ? R.value : T;
1444
+ getFeature: (u) => h.find((P) => P.key === u),
1445
+ getFeatureValue: (u, P) => {
1446
+ const C = h.find((H) => H.key === u);
1447
+ return C ? C.value : P;
1447
1448
  },
1448
1449
  hasAllowedPlan: (u) => !s || !s.isActive ? !1 : u.includes(s.planId),
1449
1450
  refresh: async () => {
@@ -1451,7 +1452,7 @@ function Mt({ config: i = {}, children: e }) {
1451
1452
  }
1452
1453
  };
1453
1454
  }, [s, p, A]);
1454
- return /* @__PURE__ */ n(Ie.Provider, { value: m, children: e });
1455
+ return /* @__PURE__ */ n(Ie.Provider, { value: f, children: e });
1455
1456
  }
1456
1457
  function Ve() {
1457
1458
  const i = ue(Ie);
@@ -1553,17 +1554,17 @@ function It({
1553
1554
  requiredPermissions: r,
1554
1555
  requireAllPermissions: s = !1
1555
1556
  }) {
1556
- const { hasValidSession: a, sessionManager: p, hasPermission: I, hasAnyPermission: A, hasAllPermissions: x } = oe();
1557
- if (!a())
1557
+ const { hasValidSession: o, sessionManager: p, hasPermission: I, hasAnyPermission: A, hasAllPermissions: x } = oe();
1558
+ if (!o())
1558
1559
  return /* @__PURE__ */ n(N, { children: e || /* @__PURE__ */ n(ve, {}) });
1559
- const P = p.getUser();
1560
- if (!P)
1560
+ const T = p.getUser();
1561
+ if (!T)
1561
1562
  return /* @__PURE__ */ n(N, { children: e || /* @__PURE__ */ n(ve, {}) });
1562
- if (t && !We(P.userType, t))
1563
- return /* @__PURE__ */ n(xe, { userType: P.userType, minUserType: t });
1563
+ if (t && !We(T.userType, t))
1564
+ return /* @__PURE__ */ n(xe, { userType: T.userType, minUserType: t });
1564
1565
  if (r && r.length > 0 && !(s ? x(r) : A(r))) {
1565
- const m = r.filter((h) => !I(h)).map((h) => typeof h == "string" ? h : h.name);
1566
- return /* @__PURE__ */ n(xe, { missingPermissions: m });
1566
+ const f = r.filter((h) => !I(h)).map((h) => typeof h == "string" ? h : h.name);
1567
+ return /* @__PURE__ */ n(xe, { missingPermissions: f });
1567
1568
  }
1568
1569
  return /* @__PURE__ */ n(N, { children: i });
1569
1570
  }
@@ -1668,20 +1669,20 @@ function Et({
1668
1669
  minUserType: t,
1669
1670
  requiredPermissions: r,
1670
1671
  requireAllPermissions: s = !1,
1671
- fallback: a
1672
+ fallback: o
1672
1673
  }) {
1673
- const { hasValidSession: p, sessionManager: I, hasPermission: A, hasAnyPermission: x, hasAllPermissions: P } = oe(), b = we();
1674
+ const { hasValidSession: p, sessionManager: I, hasPermission: A, hasAnyPermission: x, hasAllPermissions: T } = oe(), b = we();
1674
1675
  if (!p())
1675
- return a ? /* @__PURE__ */ n(N, { children: a }) : /* @__PURE__ */ l(N, { children: [
1676
+ return o ? /* @__PURE__ */ n(N, { children: o }) : /* @__PURE__ */ l(N, { children: [
1676
1677
  /* @__PURE__ */ n(Ge, { redirectPath: e }),
1677
1678
  /* @__PURE__ */ n(pe, { to: e, state: { from: b.pathname }, replace: !0 })
1678
1679
  ] });
1679
- const m = I.getUser();
1680
- if (!m)
1680
+ const f = I.getUser();
1681
+ if (!f)
1681
1682
  return /* @__PURE__ */ n(pe, { to: e, state: { from: b.pathname }, replace: !0 });
1682
- if (t && !Ke(m.userType, t))
1683
- return /* @__PURE__ */ n(ke, { userType: m.userType, minUserType: t });
1684
- if (r && r.length > 0 && !(s ? P(r) : x(r))) {
1683
+ if (t && !Ke(f.userType, t))
1684
+ return /* @__PURE__ */ n(ke, { userType: f.userType, minUserType: t });
1685
+ if (r && r.length > 0 && !(s ? T(r) : x(r))) {
1685
1686
  const S = r.filter((L) => !A(L)).map((L) => typeof L == "string" ? L : L.name);
1686
1687
  return /* @__PURE__ */ n(ke, { missingPermissions: S });
1687
1688
  }
@@ -1724,9 +1725,9 @@ const _e = ({ redirectPath: i }) => /* @__PURE__ */ n(
1724
1725
  )
1725
1726
  }
1726
1727
  );
1727
- function Rt({ children: i, redirectTo: e = "/", fallback: t }) {
1728
- const { tenant: r, isLoading: s, error: a } = se(), p = we();
1729
- return s || a ? null : r ? /* @__PURE__ */ n(N, { children: i }) : t ? /* @__PURE__ */ n(N, { children: t }) : /* @__PURE__ */ l(N, { children: [
1728
+ function Ct({ children: i, redirectTo: e = "/", fallback: t }) {
1729
+ const { tenant: r, isLoading: s, error: o } = se(), p = we();
1730
+ return s || o ? null : r ? /* @__PURE__ */ n(N, { children: i }) : t ? /* @__PURE__ */ n(N, { children: t }) : /* @__PURE__ */ l(N, { children: [
1730
1731
  /* @__PURE__ */ n(_e, { redirectPath: e }),
1731
1732
  /* @__PURE__ */ n(pe, { to: e, state: { from: p.pathname }, replace: !0 })
1732
1733
  ] });
@@ -1768,9 +1769,9 @@ const Je = ({ redirectPath: i }) => /* @__PURE__ */ n(
1768
1769
  )
1769
1770
  }
1770
1771
  );
1771
- function Ct({ children: i, redirectTo: e = "/dashboard", fallback: t }) {
1772
- const { tenant: r, isLoading: s, error: a } = se(), p = we();
1773
- return s || a ? null : r ? t ? /* @__PURE__ */ n(N, { children: t }) : /* @__PURE__ */ l(N, { children: [
1772
+ function Rt({ children: i, redirectTo: e = "/dashboard", fallback: t }) {
1773
+ const { tenant: r, isLoading: s, error: o } = se(), p = we();
1774
+ return s || o ? null : r ? t ? /* @__PURE__ */ n(N, { children: t }) : /* @__PURE__ */ l(N, { children: [
1774
1775
  /* @__PURE__ */ n(Je, { redirectPath: e }),
1775
1776
  /* @__PURE__ */ n(pe, { to: e, state: { from: p.pathname }, replace: !0 })
1776
1777
  ] }) : /* @__PURE__ */ n(N, { children: i });
@@ -1798,7 +1799,7 @@ function Lt({
1798
1799
  allowedPlans: t,
1799
1800
  requiredFeature: r
1800
1801
  }) {
1801
- const { subscription: s, hasAllowedPlan: a, isFeatureEnabled: p, loading: I } = Ve();
1802
+ const { subscription: s, hasAllowedPlan: o, isFeatureEnabled: p, loading: I } = Ve();
1802
1803
  return I ? /* @__PURE__ */ n(
1803
1804
  "div",
1804
1805
  {
@@ -1809,7 +1810,7 @@ function Lt({
1809
1810
  },
1810
1811
  children: "Loading subscription..."
1811
1812
  }
1812
- ) : s ? s.isActive ? t && t.length > 0 && !a(t) ? /* @__PURE__ */ n(N, { children: e }) : r && !p(r) ? /* @__PURE__ */ n(N, { children: e }) : /* @__PURE__ */ n(N, { children: i }) : /* @__PURE__ */ n(N, { children: e }) : /* @__PURE__ */ n(N, { children: e });
1813
+ ) : s ? s.isActive ? t && t.length > 0 && !o(t) ? /* @__PURE__ */ n(N, { children: e }) : r && !p(r) ? /* @__PURE__ */ n(N, { children: e }) : /* @__PURE__ */ n(N, { children: i }) : /* @__PURE__ */ n(N, { children: e }) : /* @__PURE__ */ n(N, { children: e });
1813
1814
  }
1814
1815
  const Qe = ({ flagName: i }) => /* @__PURE__ */ l(
1815
1816
  "div",
@@ -1853,7 +1854,7 @@ function Ft({ name: i, children: e, fallback: t }) {
1853
1854
  },
1854
1855
  children: "Loading feature flags..."
1855
1856
  }
1856
- ) : (console.log(i, r(i)), r(i) ? /* @__PURE__ */ n(N, { children: e }) : /* @__PURE__ */ n(N, { children: t || /* @__PURE__ */ n(Qe, { flagName: i }) }));
1857
+ ) : r(i) ? /* @__PURE__ */ n(N, { children: e }) : /* @__PURE__ */ n(N, { children: t || /* @__PURE__ */ n(Qe, { flagName: i }) });
1857
1858
  }
1858
1859
  const Xe = () => /* @__PURE__ */ l(
1859
1860
  "svg",
@@ -2019,45 +2020,45 @@ function $t({
2019
2020
  icons: t = {},
2020
2021
  onSuccess: r,
2021
2022
  onError: s,
2022
- onForgotPassword: a,
2023
+ onForgotPassword: o,
2023
2024
  onSignupClick: p,
2024
2025
  onMagicLinkClick: I,
2025
2026
  showForgotPassword: A = !0,
2026
2027
  showSignupLink: x = !0,
2027
- showMagicLinkOption: P = !0,
2028
+ showMagicLinkOption: T = !0,
2028
2029
  className: b
2029
2030
  }) {
2030
- const [m, h] = v(""), [S, L] = v(""), [C, q] = v(!1), [k, u] = v(!1), [T, R] = v(""), [H, G] = v({}), { login: F } = oe(), { tenant: V } = se(), w = { ...tt, ...i }, M = { ...rt, ...e }, E = { ...et, ...t }, o = () => {
2031
- const c = {};
2032
- return m.trim() || (c.username = !0), S.trim() || (c.password = !0), G(c), Object.keys(c).length === 0;
2033
- }, g = async (c) => {
2034
- if (c.preventDefault(), !!o()) {
2031
+ const [f, h] = v(""), [S, L] = v(""), [R, q] = v(!1), [k, u] = v(!1), [P, C] = v(""), [H, W] = v({}), { login: F } = oe(), { tenant: V } = se(), w = { ...tt, ...i }, M = { ...rt, ...e }, E = { ...et, ...t }, a = () => {
2032
+ const d = {};
2033
+ return f.trim() || (d.username = !0), S.trim() || (d.password = !0), W(d), Object.keys(d).length === 0;
2034
+ }, g = async (d) => {
2035
+ if (d.preventDefault(), !!a()) {
2035
2036
  if (!(V != null && V.id)) {
2036
- R("Tenant not found");
2037
+ C("Tenant not found");
2037
2038
  return;
2038
2039
  }
2039
- u(!0), R("");
2040
+ u(!0), C("");
2040
2041
  try {
2041
2042
  const y = await F({
2042
- username: m,
2043
+ username: f,
2043
2044
  password: S
2044
2045
  // tenantId inferred from context automatically
2045
2046
  });
2046
2047
  r == null || r(y);
2047
2048
  } catch (y) {
2048
- const W = y.message || w.errorMessage;
2049
- R(W), s == null || s(W);
2049
+ const G = y.message || w.errorMessage;
2050
+ C(G), s == null || s(G);
2050
2051
  } finally {
2051
2052
  u(!1);
2052
2053
  }
2053
2054
  }
2054
- }, f = (c) => ({
2055
+ }, m = (d) => ({
2055
2056
  ...M.input,
2056
- ...H[c] ? M.inputError : {}
2057
- }), d = () => ({
2057
+ ...H[d] ? M.inputError : {}
2058
+ }), c = () => ({
2058
2059
  ...M.button,
2059
2060
  ...k ? M.buttonLoading : {},
2060
- ...!m || !S || k ? M.buttonDisabled : {}
2061
+ ...!f || !S || k ? M.buttonDisabled : {}
2061
2062
  });
2062
2063
  return /* @__PURE__ */ l("div", { className: b, style: M.container, children: [
2063
2064
  /* @__PURE__ */ n("h2", { style: M.title, children: w.title }),
@@ -2070,12 +2071,12 @@ function $t({
2070
2071
  id: "username",
2071
2072
  name: "username",
2072
2073
  type: "text",
2073
- value: m,
2074
- onChange: (c) => {
2075
- h(c.target.value), H.username && G((y) => ({ ...y, username: !1 }));
2074
+ value: f,
2075
+ onChange: (d) => {
2076
+ h(d.target.value), H.username && W((y) => ({ ...y, username: !1 }));
2076
2077
  },
2077
2078
  placeholder: w.usernamePlaceholder,
2078
- style: f("username"),
2079
+ style: m("username"),
2079
2080
  disabled: k
2080
2081
  }
2081
2082
  )
@@ -2088,14 +2089,14 @@ function $t({
2088
2089
  {
2089
2090
  id: "password",
2090
2091
  name: "password",
2091
- type: C ? "text" : "password",
2092
+ type: R ? "text" : "password",
2092
2093
  value: S,
2093
- onChange: (c) => {
2094
- L(c.target.value), H.password && G((y) => ({ ...y, password: !1 }));
2094
+ onChange: (d) => {
2095
+ L(d.target.value), H.password && W((y) => ({ ...y, password: !1 }));
2095
2096
  },
2096
2097
  placeholder: w.passwordPlaceholder,
2097
2098
  style: {
2098
- ...f("password"),
2099
+ ...m("password"),
2099
2100
  paddingRight: "2.5rem"
2100
2101
  // Make room for the icon
2101
2102
  },
@@ -2106,28 +2107,28 @@ function $t({
2106
2107
  "button",
2107
2108
  {
2108
2109
  type: "button",
2109
- onClick: () => q(!C),
2110
+ onClick: () => q(!R),
2110
2111
  style: M.passwordToggle,
2111
2112
  disabled: k,
2112
- "aria-label": C ? "Hide password" : "Show password",
2113
- children: C ? E.hidePassword : E.showPassword
2113
+ "aria-label": R ? "Hide password" : "Show password",
2114
+ children: R ? E.hidePassword : E.showPassword
2114
2115
  }
2115
2116
  )
2116
2117
  ] })
2117
2118
  ] }),
2118
- /* @__PURE__ */ n("button", { type: "submit", disabled: !m || !S || k, style: d(), children: k ? w.loadingText : w.submitButton }),
2119
- T && /* @__PURE__ */ n("div", { style: M.errorText, children: T })
2119
+ /* @__PURE__ */ n("button", { type: "submit", disabled: !f || !S || k, style: c(), children: k ? w.loadingText : w.submitButton }),
2120
+ P && /* @__PURE__ */ n("div", { style: M.errorText, children: P })
2120
2121
  ] }),
2121
- (A || x || P) && /* @__PURE__ */ l("div", { style: M.linkContainer, children: [
2122
- P && /* @__PURE__ */ l("div", { children: [
2122
+ (A || x || T) && /* @__PURE__ */ l("div", { style: M.linkContainer, children: [
2123
+ T && /* @__PURE__ */ l("div", { children: [
2123
2124
  /* @__PURE__ */ l("span", { style: M.divider, children: [
2124
2125
  w.magicLinkText,
2125
2126
  " "
2126
2127
  ] }),
2127
2128
  /* @__PURE__ */ n("a", { onClick: I, style: M.link, children: w.magicLinkLink })
2128
2129
  ] }),
2129
- P && (A || x) && /* @__PURE__ */ n("div", { style: M.divider, children: "•" }),
2130
- A && /* @__PURE__ */ n("a", { onClick: a, style: M.link, children: w.forgotPasswordLink }),
2130
+ T && (A || x) && /* @__PURE__ */ n("div", { style: M.divider, children: "•" }),
2131
+ A && /* @__PURE__ */ n("a", { onClick: o, style: M.link, children: w.forgotPasswordLink }),
2131
2132
  A && x && /* @__PURE__ */ n("div", { style: M.divider, children: "•" }),
2132
2133
  x && /* @__PURE__ */ l("div", { children: [
2133
2134
  /* @__PURE__ */ l("span", { style: M.divider, children: [
@@ -2270,45 +2271,45 @@ function Dt({
2270
2271
  signupType: t = "user",
2271
2272
  onSuccess: r,
2272
2273
  onError: s,
2273
- onLoginClick: a,
2274
+ onLoginClick: o,
2274
2275
  onMagicLinkClick: p,
2275
2276
  showLoginLink: I = !0,
2276
2277
  showMagicLinkOption: A = !0,
2277
2278
  className: x
2278
2279
  }) {
2279
- const [P, b] = v(""), [m, h] = v(""), [S, L] = v(""), [C, q] = v(""), [k, u] = v(""), [T, R] = v(""), [H, G] = v(""), [F, V] = v(!1), [w, M] = v(""), [E, o] = v({}), { signup: g, signupTenantAdmin: f } = oe(), { tenant: d } = se(), c = { ...nt, ...i }, y = { ...st, ...e }, W = () => {
2280
+ const [T, b] = v(""), [f, h] = v(""), [S, L] = v(""), [R, q] = v(""), [k, u] = v(""), [P, C] = v(""), [H, W] = v(""), [F, V] = v(!1), [w, M] = v(""), [E, a] = v({}), { signup: g, signupTenantAdmin: m } = oe(), { tenant: c } = se(), d = { ...nt, ...i }, y = { ...st, ...e }, G = () => {
2280
2281
  const D = {};
2281
- return P.trim() || (D.name = !0), !S.trim() && !C.trim() && (D.email = !0, D.phoneNumber = !0), k.trim() || (D.password = !0), T.trim() || (D.confirmPassword = !0), t === "tenant" && !H.trim() && (D.tenantName = !0), o(D), Object.keys(D).length === 0;
2282
+ return T.trim() || (D.name = !0), !S.trim() && !R.trim() && (D.email = !0, D.phoneNumber = !0), k.trim() || (D.password = !0), P.trim() || (D.confirmPassword = !0), t === "tenant" && !H.trim() && (D.tenantName = !0), a(D), Object.keys(D).length === 0;
2282
2283
  }, ee = async (D) => {
2283
- if (D.preventDefault(), !!W()) {
2284
- if (k !== T) {
2285
- M(c.passwordMismatchError), o({ confirmPassword: !0 });
2284
+ if (D.preventDefault(), !!G()) {
2285
+ if (k !== P) {
2286
+ M(d.passwordMismatchError), a({ confirmPassword: !0 });
2286
2287
  return;
2287
2288
  }
2288
- if (t === "user" && !(d != null && d.id)) {
2289
+ if (t === "user" && !(c != null && c.id)) {
2289
2290
  M("Tenant not found");
2290
2291
  return;
2291
2292
  }
2292
2293
  V(!0), M("");
2293
2294
  try {
2294
2295
  let _;
2295
- t === "tenant" ? _ = await f({
2296
+ t === "tenant" ? _ = await m({
2296
2297
  email: S || void 0,
2297
- phoneNumber: C || void 0,
2298
- name: P,
2298
+ phoneNumber: R || void 0,
2299
+ name: T,
2299
2300
  password: k,
2300
2301
  tenantName: H,
2301
- lastName: m || void 0
2302
+ lastName: f || void 0
2302
2303
  }) : _ = await g({
2303
2304
  email: S || void 0,
2304
- phoneNumber: C || void 0,
2305
- name: P,
2305
+ phoneNumber: R || void 0,
2306
+ name: T,
2306
2307
  password: k,
2307
- tenantId: d.id,
2308
- lastName: m || void 0
2308
+ tenantId: c.id,
2309
+ lastName: f || void 0
2309
2310
  }), r == null || r(_);
2310
2311
  } catch (_) {
2311
- const ge = _.message || c.errorMessage;
2312
+ const ge = _.message || d.errorMessage;
2312
2313
  M(ge), s == null || s(ge);
2313
2314
  } finally {
2314
2315
  V(!1);
@@ -2320,47 +2321,47 @@ function Dt({
2320
2321
  }), B = () => ({
2321
2322
  ...y.button,
2322
2323
  ...F ? y.buttonLoading : {},
2323
- ...!P || !S && !C || !k || !T || F || t === "tenant" && !H ? y.buttonDisabled : {}
2324
- }), O = P && (S || C) && k && T && (t === "user" || H);
2324
+ ...!T || !S && !R || !k || !P || F || t === "tenant" && !H ? y.buttonDisabled : {}
2325
+ }), O = T && (S || R) && k && P && (t === "user" || H);
2325
2326
  return /* @__PURE__ */ l("div", { className: x, style: y.container, children: [
2326
- /* @__PURE__ */ n("h2", { style: y.title, children: c.title }),
2327
+ /* @__PURE__ */ n("h2", { style: y.title, children: d.title }),
2327
2328
  /* @__PURE__ */ l("form", { onSubmit: ee, style: y.form, children: [
2328
2329
  /* @__PURE__ */ l("div", { style: y.fieldGroup, children: [
2329
- /* @__PURE__ */ n("label", { style: y.label, children: c.nameLabel }),
2330
+ /* @__PURE__ */ n("label", { style: y.label, children: d.nameLabel }),
2330
2331
  /* @__PURE__ */ n(
2331
2332
  "input",
2332
2333
  {
2333
2334
  id: "name",
2334
2335
  name: "name",
2335
2336
  type: "text",
2336
- value: P,
2337
+ value: T,
2337
2338
  onChange: (D) => {
2338
- b(D.target.value), E.name && o((_) => ({ ..._, name: !1 }));
2339
+ b(D.target.value), E.name && a((_) => ({ ..._, name: !1 }));
2339
2340
  },
2340
- placeholder: c.namePlaceholder,
2341
+ placeholder: d.namePlaceholder,
2341
2342
  style: z("name"),
2342
2343
  disabled: F
2343
2344
  }
2344
2345
  )
2345
2346
  ] }),
2346
2347
  /* @__PURE__ */ l("div", { style: y.fieldGroup, children: [
2347
- /* @__PURE__ */ n("label", { style: y.label, children: c.lastNameLabel }),
2348
+ /* @__PURE__ */ n("label", { style: y.label, children: d.lastNameLabel }),
2348
2349
  /* @__PURE__ */ n(
2349
2350
  "input",
2350
2351
  {
2351
2352
  id: "lastName",
2352
2353
  name: "lastName",
2353
2354
  type: "text",
2354
- value: m,
2355
+ value: f,
2355
2356
  onChange: (D) => h(D.target.value),
2356
- placeholder: c.lastNamePlaceholder,
2357
+ placeholder: d.lastNamePlaceholder,
2357
2358
  style: y.input,
2358
2359
  disabled: F
2359
2360
  }
2360
2361
  )
2361
2362
  ] }),
2362
2363
  /* @__PURE__ */ l("div", { style: y.fieldGroup, children: [
2363
- /* @__PURE__ */ n("label", { style: y.label, children: c.emailLabel }),
2364
+ /* @__PURE__ */ n("label", { style: y.label, children: d.emailLabel }),
2364
2365
  /* @__PURE__ */ n(
2365
2366
  "input",
2366
2367
  {
@@ -2369,27 +2370,27 @@ function Dt({
2369
2370
  type: "email",
2370
2371
  value: S,
2371
2372
  onChange: (D) => {
2372
- L(D.target.value), E.email && o((_) => ({ ..._, email: !1, phoneNumber: !1 }));
2373
+ L(D.target.value), E.email && a((_) => ({ ..._, email: !1, phoneNumber: !1 }));
2373
2374
  },
2374
- placeholder: c.emailPlaceholder,
2375
+ placeholder: d.emailPlaceholder,
2375
2376
  style: z("email"),
2376
2377
  disabled: F
2377
2378
  }
2378
2379
  )
2379
2380
  ] }),
2380
2381
  /* @__PURE__ */ l("div", { style: y.fieldGroup, children: [
2381
- /* @__PURE__ */ n("label", { style: y.label, children: c.phoneNumberLabel }),
2382
+ /* @__PURE__ */ n("label", { style: y.label, children: d.phoneNumberLabel }),
2382
2383
  /* @__PURE__ */ n(
2383
2384
  "input",
2384
2385
  {
2385
2386
  id: "phoneNumber",
2386
2387
  name: "phoneNumber",
2387
2388
  type: "tel",
2388
- value: C,
2389
+ value: R,
2389
2390
  onChange: (D) => {
2390
- q(D.target.value), E.phoneNumber && o((_) => ({ ..._, email: !1, phoneNumber: !1 }));
2391
+ q(D.target.value), E.phoneNumber && a((_) => ({ ..._, email: !1, phoneNumber: !1 }));
2391
2392
  },
2392
- placeholder: c.phoneNumberPlaceholder,
2393
+ placeholder: d.phoneNumberPlaceholder,
2393
2394
  style: z("phoneNumber"),
2394
2395
  disabled: F
2395
2396
  }
@@ -2408,7 +2409,7 @@ function Dt({
2408
2409
  }
2409
2410
  ),
2410
2411
  /* @__PURE__ */ l("div", { style: y.fieldGroup, children: [
2411
- /* @__PURE__ */ n("label", { style: y.label, children: c.passwordLabel }),
2412
+ /* @__PURE__ */ n("label", { style: y.label, children: d.passwordLabel }),
2412
2413
  /* @__PURE__ */ n(
2413
2414
  "input",
2414
2415
  {
@@ -2417,34 +2418,34 @@ function Dt({
2417
2418
  type: "password",
2418
2419
  value: k,
2419
2420
  onChange: (D) => {
2420
- u(D.target.value), E.password && o((_) => ({ ..._, password: !1 }));
2421
+ u(D.target.value), E.password && a((_) => ({ ..._, password: !1 }));
2421
2422
  },
2422
- placeholder: c.passwordPlaceholder,
2423
+ placeholder: d.passwordPlaceholder,
2423
2424
  style: z("password"),
2424
2425
  disabled: F
2425
2426
  }
2426
2427
  )
2427
2428
  ] }),
2428
2429
  /* @__PURE__ */ l("div", { style: y.fieldGroup, children: [
2429
- /* @__PURE__ */ n("label", { style: y.label, children: c.confirmPasswordLabel }),
2430
+ /* @__PURE__ */ n("label", { style: y.label, children: d.confirmPasswordLabel }),
2430
2431
  /* @__PURE__ */ n(
2431
2432
  "input",
2432
2433
  {
2433
2434
  id: "confirmPassword",
2434
2435
  name: "confirmPassword",
2435
2436
  type: "password",
2436
- value: T,
2437
+ value: P,
2437
2438
  onChange: (D) => {
2438
- R(D.target.value), E.confirmPassword && o((_) => ({ ..._, confirmPassword: !1 })), w === c.passwordMismatchError && M("");
2439
+ C(D.target.value), E.confirmPassword && a((_) => ({ ..._, confirmPassword: !1 })), w === d.passwordMismatchError && M("");
2439
2440
  },
2440
- placeholder: c.confirmPasswordPlaceholder,
2441
+ placeholder: d.confirmPasswordPlaceholder,
2441
2442
  style: z("confirmPassword"),
2442
2443
  disabled: F
2443
2444
  }
2444
2445
  )
2445
2446
  ] }),
2446
2447
  t === "tenant" && /* @__PURE__ */ l("div", { style: y.fieldGroup, children: [
2447
- /* @__PURE__ */ n("label", { style: y.label, children: c.tenantNameLabel }),
2448
+ /* @__PURE__ */ n("label", { style: y.label, children: d.tenantNameLabel }),
2448
2449
  /* @__PURE__ */ n(
2449
2450
  "input",
2450
2451
  {
@@ -2453,32 +2454,32 @@ function Dt({
2453
2454
  type: "text",
2454
2455
  value: H,
2455
2456
  onChange: (D) => {
2456
- G(D.target.value), E.tenantName && o((_) => ({ ..._, tenantName: !1 }));
2457
+ W(D.target.value), E.tenantName && a((_) => ({ ..._, tenantName: !1 }));
2457
2458
  },
2458
- placeholder: c.tenantNamePlaceholder,
2459
+ placeholder: d.tenantNamePlaceholder,
2459
2460
  style: z("tenantName"),
2460
2461
  disabled: F
2461
2462
  }
2462
2463
  )
2463
2464
  ] }),
2464
- /* @__PURE__ */ n("button", { type: "submit", disabled: !O || F, style: B(), children: F ? c.loadingText : c.submitButton }),
2465
+ /* @__PURE__ */ n("button", { type: "submit", disabled: !O || F, style: B(), children: F ? d.loadingText : d.submitButton }),
2465
2466
  w && /* @__PURE__ */ n("div", { style: y.errorText, children: w })
2466
2467
  ] }),
2467
2468
  (I || A) && /* @__PURE__ */ l("div", { style: y.linkContainer, children: [
2468
2469
  A && /* @__PURE__ */ l("div", { children: [
2469
2470
  /* @__PURE__ */ l("span", { style: y.divider, children: [
2470
- c.magicLinkText,
2471
+ d.magicLinkText,
2471
2472
  " "
2472
2473
  ] }),
2473
- /* @__PURE__ */ n("a", { onClick: p, style: y.link, children: c.magicLinkLink })
2474
+ /* @__PURE__ */ n("a", { onClick: p, style: y.link, children: d.magicLinkLink })
2474
2475
  ] }),
2475
2476
  A && I && /* @__PURE__ */ n("div", { style: y.divider, children: "•" }),
2476
2477
  I && /* @__PURE__ */ l("div", { children: [
2477
2478
  /* @__PURE__ */ l("span", { style: y.divider, children: [
2478
- c.loginText,
2479
+ d.loginText,
2479
2480
  " "
2480
2481
  ] }),
2481
- /* @__PURE__ */ n("a", { onClick: a, style: y.link, children: c.loginLink })
2482
+ /* @__PURE__ */ n("a", { onClick: o, style: y.link, children: d.loginLink })
2482
2483
  ] })
2483
2484
  ] })
2484
2485
  ] });
@@ -2610,91 +2611,91 @@ function Ht({
2610
2611
  onSuccess: t,
2611
2612
  onError: r,
2612
2613
  onLoginClick: s,
2613
- onSignupClick: a,
2614
+ onSignupClick: o,
2614
2615
  showTraditionalLinks: p = !0,
2615
2616
  className: I,
2616
2617
  verifyToken: A,
2617
2618
  frontendUrl: x
2618
2619
  }) {
2619
- const [P, b] = v(""), [m, h] = v(""), [S, L] = v(""), [C, q] = v(!1), [k, u] = v(!1), [T, R] = v(""), [H, G] = v(""), [F, V] = v({}), [w, M] = v(!1), { sendMagicLink: E, verifyMagicLink: o } = oe(), { tenant: g } = se(), f = { ...it, ...i }, d = { ...ot, ...e };
2620
+ const [T, b] = v(""), [f, h] = v(""), [S, L] = v(""), [R, q] = v(!1), [k, u] = v(!1), [P, C] = v(""), [H, W] = v(""), [F, V] = v({}), [w, M] = v(!1), { sendMagicLink: E, verifyMagicLink: a } = oe(), { tenant: g } = se(), m = { ...it, ...i }, c = { ...ot, ...e };
2620
2621
  te(() => {
2621
- A && c(A);
2622
+ A && d(A);
2622
2623
  }, [A]);
2623
- const c = async (B) => {
2624
- if (!g || !P) {
2625
- R("Missing tenant or email");
2624
+ const d = async (B) => {
2625
+ if (!g || !T) {
2626
+ C("Missing tenant or email");
2626
2627
  return;
2627
2628
  }
2628
- u(!0), R("");
2629
+ u(!0), C("");
2629
2630
  try {
2630
- const O = await o({
2631
+ const O = await a({
2631
2632
  token: B,
2632
- email: P
2633
+ email: T
2633
2634
  // tenantId inferred from context automatically
2634
2635
  });
2635
2636
  t == null || t(O);
2636
2637
  } catch (O) {
2637
2638
  const D = O.message || "Failed to verify magic link";
2638
- R(D), r == null || r(D);
2639
+ C(D), r == null || r(D);
2639
2640
  } finally {
2640
2641
  u(!1);
2641
2642
  }
2642
2643
  }, y = () => {
2643
2644
  const B = {};
2644
- return P.trim() || (B.email = !0), w && !m.trim() && (B.name = !0), V(B), Object.keys(B).length === 0;
2645
- }, W = async (B) => {
2645
+ return T.trim() || (B.email = !0), w && !f.trim() && (B.name = !0), V(B), Object.keys(B).length === 0;
2646
+ }, G = async (B) => {
2646
2647
  if (B.preventDefault(), !!y()) {
2647
2648
  if (!(g != null && g.id)) {
2648
- R("Tenant not found");
2649
+ C("Tenant not found");
2649
2650
  return;
2650
2651
  }
2651
- q(!0), R(""), G("");
2652
+ q(!0), C(""), W("");
2652
2653
  try {
2653
2654
  const O = x || (typeof window < "u" ? window.location.origin : ""), D = await E({
2654
- email: P,
2655
+ email: T,
2655
2656
  tenantId: g.id,
2656
2657
  frontendUrl: O,
2657
- name: w ? m : void 0,
2658
+ name: w ? f : void 0,
2658
2659
  lastName: w ? S : void 0
2659
2660
  });
2660
- G(f.successMessage), t == null || t(D);
2661
+ W(m.successMessage), t == null || t(D);
2661
2662
  } catch (O) {
2662
- const D = O.message || f.errorMessage;
2663
- R(D), r == null || r(D);
2663
+ const D = O.message || m.errorMessage;
2664
+ C(D), r == null || r(D);
2664
2665
  } finally {
2665
2666
  q(!1);
2666
2667
  }
2667
2668
  }
2668
2669
  }, ee = (B) => ({
2669
- ...d.input,
2670
- ...F[B] ? d.inputError : {}
2670
+ ...c.input,
2671
+ ...F[B] ? c.inputError : {}
2671
2672
  }), z = () => ({
2672
- ...d.button,
2673
- ...C || k ? d.buttonLoading : {},
2674
- ...!P || C || k ? d.buttonDisabled : {}
2673
+ ...c.button,
2674
+ ...R || k ? c.buttonLoading : {},
2675
+ ...!T || R || k ? c.buttonDisabled : {}
2675
2676
  });
2676
- return k ? /* @__PURE__ */ l("div", { className: I, style: d.container, children: [
2677
- /* @__PURE__ */ n("h2", { style: d.title, children: f.verifyingText }),
2677
+ return k ? /* @__PURE__ */ l("div", { className: I, style: c.container, children: [
2678
+ /* @__PURE__ */ n("h2", { style: c.title, children: m.verifyingText }),
2678
2679
  /* @__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..." }) })
2679
- ] }) : /* @__PURE__ */ l("div", { className: I, style: d.container, children: [
2680
- /* @__PURE__ */ n("h2", { style: d.title, children: f.title }),
2681
- /* @__PURE__ */ n("p", { style: d.description, children: f.description }),
2682
- /* @__PURE__ */ l("form", { onSubmit: W, style: d.form, children: [
2683
- /* @__PURE__ */ l("div", { style: d.fieldGroup, children: [
2684
- /* @__PURE__ */ n("label", { style: d.label, children: f.emailLabel }),
2680
+ ] }) : /* @__PURE__ */ l("div", { className: I, style: c.container, children: [
2681
+ /* @__PURE__ */ n("h2", { style: c.title, children: m.title }),
2682
+ /* @__PURE__ */ n("p", { style: c.description, children: m.description }),
2683
+ /* @__PURE__ */ l("form", { onSubmit: G, style: c.form, children: [
2684
+ /* @__PURE__ */ l("div", { style: c.fieldGroup, children: [
2685
+ /* @__PURE__ */ n("label", { style: c.label, children: m.emailLabel }),
2685
2686
  /* @__PURE__ */ n(
2686
2687
  "input",
2687
2688
  {
2688
2689
  id: "email",
2689
2690
  name: "email",
2690
2691
  type: "email",
2691
- value: P,
2692
+ value: T,
2692
2693
  onChange: (B) => {
2693
2694
  b(B.target.value), F.email && V((O) => ({ ...O, email: !1 }));
2694
2695
  },
2695
- placeholder: f.emailPlaceholder,
2696
+ placeholder: m.emailPlaceholder,
2696
2697
  style: ee("email"),
2697
- disabled: C || k
2698
+ disabled: R || k
2698
2699
  }
2699
2700
  )
2700
2701
  ] }),
@@ -2715,26 +2716,26 @@ function Ht({
2715
2716
  }
2716
2717
  ) }),
2717
2718
  w && /* @__PURE__ */ l(N, { children: [
2718
- /* @__PURE__ */ l("div", { style: d.fieldGroup, children: [
2719
- /* @__PURE__ */ n("label", { style: d.label, children: f.nameLabel }),
2719
+ /* @__PURE__ */ l("div", { style: c.fieldGroup, children: [
2720
+ /* @__PURE__ */ n("label", { style: c.label, children: m.nameLabel }),
2720
2721
  /* @__PURE__ */ n(
2721
2722
  "input",
2722
2723
  {
2723
2724
  id: "name",
2724
2725
  name: "name",
2725
2726
  type: "text",
2726
- value: m,
2727
+ value: f,
2727
2728
  onChange: (B) => {
2728
2729
  h(B.target.value), F.name && V((O) => ({ ...O, name: !1 }));
2729
2730
  },
2730
- placeholder: f.namePlaceholder,
2731
+ placeholder: m.namePlaceholder,
2731
2732
  style: ee("name"),
2732
- disabled: C || k
2733
+ disabled: R || k
2733
2734
  }
2734
2735
  )
2735
2736
  ] }),
2736
- /* @__PURE__ */ l("div", { style: d.fieldGroup, children: [
2737
- /* @__PURE__ */ n("label", { style: d.label, children: f.lastNameLabel }),
2737
+ /* @__PURE__ */ l("div", { style: c.fieldGroup, children: [
2738
+ /* @__PURE__ */ n("label", { style: c.label, children: m.lastNameLabel }),
2738
2739
  /* @__PURE__ */ n(
2739
2740
  "input",
2740
2741
  {
@@ -2743,9 +2744,9 @@ function Ht({
2743
2744
  type: "text",
2744
2745
  value: S,
2745
2746
  onChange: (B) => L(B.target.value),
2746
- placeholder: f.lastNamePlaceholder,
2747
- style: d.input,
2748
- disabled: C || k
2747
+ placeholder: m.lastNamePlaceholder,
2748
+ style: c.input,
2749
+ disabled: R || k
2749
2750
  }
2750
2751
  )
2751
2752
  ] }),
@@ -2768,25 +2769,25 @@ function Ht({
2768
2769
  }
2769
2770
  ) })
2770
2771
  ] }),
2771
- /* @__PURE__ */ n("button", { type: "submit", disabled: !P || C || k, style: z(), children: C ? f.loadingText : f.submitButton }),
2772
- T && /* @__PURE__ */ n("div", { style: d.errorText, children: T }),
2773
- H && /* @__PURE__ */ n("div", { style: d.successText, children: H })
2772
+ /* @__PURE__ */ n("button", { type: "submit", disabled: !T || R || k, style: z(), children: R ? m.loadingText : m.submitButton }),
2773
+ P && /* @__PURE__ */ n("div", { style: c.errorText, children: P }),
2774
+ H && /* @__PURE__ */ n("div", { style: c.successText, children: H })
2774
2775
  ] }),
2775
- p && /* @__PURE__ */ l("div", { style: d.linkContainer, children: [
2776
+ p && /* @__PURE__ */ l("div", { style: c.linkContainer, children: [
2776
2777
  /* @__PURE__ */ l("div", { children: [
2777
- /* @__PURE__ */ l("span", { style: d.divider, children: [
2778
- f.loginText,
2778
+ /* @__PURE__ */ l("span", { style: c.divider, children: [
2779
+ m.loginText,
2779
2780
  " "
2780
2781
  ] }),
2781
- /* @__PURE__ */ n("a", { onClick: s, style: d.link, children: f.loginLink })
2782
+ /* @__PURE__ */ n("a", { onClick: s, style: c.link, children: m.loginLink })
2782
2783
  ] }),
2783
- /* @__PURE__ */ n("div", { style: d.divider, children: "•" }),
2784
+ /* @__PURE__ */ n("div", { style: c.divider, children: "•" }),
2784
2785
  /* @__PURE__ */ l("div", { children: [
2785
- /* @__PURE__ */ l("span", { style: d.divider, children: [
2786
- f.signupText,
2786
+ /* @__PURE__ */ l("span", { style: c.divider, children: [
2787
+ m.signupText,
2787
2788
  " "
2788
2789
  ] }),
2789
- /* @__PURE__ */ n("a", { onClick: a, style: d.link, children: f.signupLink })
2790
+ /* @__PURE__ */ n("a", { onClick: o, style: c.link, children: m.signupLink })
2790
2791
  ] })
2791
2792
  ] })
2792
2793
  ] });
@@ -2932,28 +2933,28 @@ function Nt({
2932
2933
  icons: t = {},
2933
2934
  onSuccess: r,
2934
2935
  onError: s,
2935
- onRetry: a,
2936
+ onRetry: o,
2936
2937
  onBackToLogin: p,
2937
2938
  className: I,
2938
2939
  token: A,
2939
2940
  email: x,
2940
- appId: P,
2941
+ appId: T,
2941
2942
  tenantSlug: b,
2942
- autoRedirectDelay: m = 3e3
2943
+ autoRedirectDelay: f = 3e3
2943
2944
  }) {
2944
- const [h, S] = v("verifying"), [L, C] = v(""), { verifyMagicLink: q } = oe(), k = { ...at, ...i }, u = { ...Ee, ...e }, T = { ...ut, ...t }, R = () => {
2945
+ const [h, S] = v("verifying"), [L, R] = v(""), { verifyMagicLink: q } = oe(), k = { ...at, ...i }, u = { ...Ee, ...e }, P = { ...ut, ...t }, C = () => {
2945
2946
  if (typeof window > "u") return {};
2946
2947
  const w = new URLSearchParams(window.location.search);
2947
2948
  return {
2948
2949
  token: A || w.get("token") || "",
2949
2950
  email: x || w.get("email") || "",
2950
- appId: P || w.get("appId") || "",
2951
+ appId: T || w.get("appId") || "",
2951
2952
  tenantSlug: b || w.get("tenantSlug") || void 0
2952
2953
  };
2953
2954
  }, H = async () => {
2954
- S("verifying"), C("");
2955
+ S("verifying"), R("");
2955
2956
  try {
2956
- const w = R();
2957
+ const w = C();
2957
2958
  if (!w.token || !w.email)
2958
2959
  throw new Error("Missing required parameters: token or email");
2959
2960
  const M = await q({
@@ -2961,15 +2962,15 @@ function Nt({
2961
2962
  email: w.email,
2962
2963
  tenantSlug: w.tenantSlug
2963
2964
  });
2964
- S("success"), r == null || r(M), m > 0 && setTimeout(() => {
2965
+ S("success"), r == null || r(M), f > 0 && setTimeout(() => {
2965
2966
  S("redirecting");
2966
- }, m);
2967
+ }, f);
2967
2968
  } catch (w) {
2968
2969
  const M = w.message || k.errorMessage;
2969
- C(M), S("error"), s == null || s(M);
2970
+ R(M), S("error"), s == null || s(M);
2970
2971
  }
2971
- }, G = () => {
2972
- a == null || a(), H();
2972
+ }, W = () => {
2973
+ o == null || o(), H();
2973
2974
  }, F = () => {
2974
2975
  p == null || p();
2975
2976
  };
@@ -2980,28 +2981,28 @@ function Nt({
2980
2981
  switch (h) {
2981
2982
  case "verifying":
2982
2983
  return /* @__PURE__ */ l("div", { style: u.message, children: [
2983
- T.loading,
2984
+ P.loading,
2984
2985
  k.verifyingMessage
2985
2986
  ] });
2986
2987
  case "success":
2987
2988
  return /* @__PURE__ */ l(N, { children: [
2988
- T.success,
2989
+ P.success,
2989
2990
  /* @__PURE__ */ n("div", { style: u.successMessage, children: k.successMessage })
2990
2991
  ] });
2991
2992
  case "redirecting":
2992
2993
  return /* @__PURE__ */ l(N, { children: [
2993
- T.loading,
2994
+ P.loading,
2994
2995
  /* @__PURE__ */ n("div", { style: u.message, children: k.redirectingMessage })
2995
2996
  ] });
2996
2997
  case "error":
2997
2998
  return /* @__PURE__ */ l(N, { children: [
2998
- T.error,
2999
+ P.error,
2999
3000
  /* @__PURE__ */ n("div", { style: u.errorMessage, children: L || k.errorMessage }),
3000
3001
  /* @__PURE__ */ l("div", { style: u.buttonContainer, children: [
3001
3002
  /* @__PURE__ */ n(
3002
3003
  "button",
3003
3004
  {
3004
- onClick: G,
3005
+ onClick: W,
3005
3006
  style: u.retryButton,
3006
3007
  onMouseOver: (w) => {
3007
3008
  w.currentTarget.style.backgroundColor = "#2563eb";
@@ -3163,71 +3164,71 @@ function Bt({
3163
3164
  mode: t = "request",
3164
3165
  token: r = "",
3165
3166
  onSuccess: s,
3166
- onError: a,
3167
+ onError: o,
3167
3168
  onBackToLogin: p,
3168
3169
  onModeChange: I,
3169
3170
  className: A
3170
3171
  }) {
3171
- const [x, P] = v(""), [b, m] = v(r), [h, S] = v(""), [L, C] = v(""), [q, k] = v(!1), [u, T] = v(""), [R, H] = v(""), [G, F] = v({}), { requestPasswordReset: V, confirmPasswordReset: w } = oe(), { tenant: M } = se(), E = { ...ht, ...i }, o = { ...gt, ...e }, g = () => {
3172
+ const [x, T] = v(""), [b, f] = v(r), [h, S] = v(""), [L, R] = v(""), [q, k] = v(!1), [u, P] = v(""), [C, H] = v(""), [W, F] = v({}), { requestPasswordReset: V, confirmPasswordReset: w } = oe(), { tenant: M } = se(), E = { ...ht, ...i }, a = { ...gt, ...e }, g = () => {
3172
3173
  const z = {};
3173
3174
  return x.trim() || (z.email = !0), F(z), Object.keys(z).length === 0;
3174
- }, f = () => {
3175
+ }, m = () => {
3175
3176
  const z = {};
3176
3177
  return b.trim() || (z.token = !0), h.trim() || (z.newPassword = !0), L.trim() || (z.confirmPassword = !0), F(z), Object.keys(z).length === 0;
3177
- }, d = async (z) => {
3178
+ }, c = async (z) => {
3178
3179
  if (z.preventDefault(), !!g()) {
3179
3180
  if (!(M != null && M.id)) {
3180
- T("Tenant not found");
3181
+ P("Tenant not found");
3181
3182
  return;
3182
3183
  }
3183
- k(!0), T(""), H("");
3184
+ k(!0), P(""), H("");
3184
3185
  try {
3185
3186
  await V({ email: x, tenantId: M.id }), H(E.successMessage), s == null || s();
3186
3187
  } catch (B) {
3187
3188
  const O = B.message || E.errorMessage;
3188
- T(O), a == null || a(O);
3189
+ P(O), o == null || o(O);
3189
3190
  } finally {
3190
3191
  k(!1);
3191
3192
  }
3192
3193
  }
3193
- }, c = async (z) => {
3194
- if (z.preventDefault(), !!f()) {
3194
+ }, d = async (z) => {
3195
+ if (z.preventDefault(), !!m()) {
3195
3196
  if (h !== L) {
3196
- T(E.passwordMismatchError), F({ confirmPassword: !0 });
3197
+ P(E.passwordMismatchError), F({ confirmPassword: !0 });
3197
3198
  return;
3198
3199
  }
3199
- k(!0), T(""), H("");
3200
+ k(!0), P(""), H("");
3200
3201
  try {
3201
3202
  await w({ token: b, newPassword: h }), H(E.resetSuccessMessage), s == null || s();
3202
3203
  } catch (B) {
3203
3204
  const O = B.message || E.errorMessage;
3204
- T(O), a == null || a(O);
3205
+ P(O), o == null || o(O);
3205
3206
  } finally {
3206
3207
  k(!1);
3207
3208
  }
3208
3209
  }
3209
3210
  }, y = (z) => ({
3210
- ...o.input,
3211
- ...G[z] ? o.inputError : {}
3212
- }), W = () => ({
3213
- ...o.button,
3214
- ...q ? o.buttonLoading : {}
3211
+ ...a.input,
3212
+ ...W[z] ? a.inputError : {}
3213
+ }), G = () => ({
3214
+ ...a.button,
3215
+ ...q ? a.buttonLoading : {}
3215
3216
  });
3216
3217
  if (t === "reset") {
3217
3218
  const z = b && h && L;
3218
- return /* @__PURE__ */ l("div", { className: A, style: o.container, children: [
3219
- /* @__PURE__ */ n("h2", { style: o.title, children: E.resetTitle }),
3220
- /* @__PURE__ */ n("p", { style: o.subtitle, children: E.resetSubtitle }),
3221
- /* @__PURE__ */ l("form", { onSubmit: c, style: o.form, children: [
3222
- /* @__PURE__ */ l("div", { style: o.fieldGroup, children: [
3223
- /* @__PURE__ */ n("label", { style: o.label, children: E.tokenLabel }),
3219
+ return /* @__PURE__ */ l("div", { className: A, style: a.container, children: [
3220
+ /* @__PURE__ */ n("h2", { style: a.title, children: E.resetTitle }),
3221
+ /* @__PURE__ */ n("p", { style: a.subtitle, children: E.resetSubtitle }),
3222
+ /* @__PURE__ */ l("form", { onSubmit: d, style: a.form, children: [
3223
+ /* @__PURE__ */ l("div", { style: a.fieldGroup, children: [
3224
+ /* @__PURE__ */ n("label", { style: a.label, children: E.tokenLabel }),
3224
3225
  /* @__PURE__ */ n(
3225
3226
  "input",
3226
3227
  {
3227
3228
  type: "text",
3228
3229
  value: b,
3229
3230
  onChange: (B) => {
3230
- m(B.target.value), G.token && F((O) => ({ ...O, token: !1 }));
3231
+ f(B.target.value), W.token && F((O) => ({ ...O, token: !1 }));
3231
3232
  },
3232
3233
  placeholder: E.tokenPlaceholder,
3233
3234
  style: y("token"),
@@ -3235,15 +3236,15 @@ function Bt({
3235
3236
  }
3236
3237
  )
3237
3238
  ] }),
3238
- /* @__PURE__ */ l("div", { style: o.fieldGroup, children: [
3239
- /* @__PURE__ */ n("label", { style: o.label, children: E.newPasswordLabel }),
3239
+ /* @__PURE__ */ l("div", { style: a.fieldGroup, children: [
3240
+ /* @__PURE__ */ n("label", { style: a.label, children: E.newPasswordLabel }),
3240
3241
  /* @__PURE__ */ n(
3241
3242
  "input",
3242
3243
  {
3243
3244
  type: "password",
3244
3245
  value: h,
3245
3246
  onChange: (B) => {
3246
- S(B.target.value), G.newPassword && F((O) => ({ ...O, newPassword: !1 }));
3247
+ S(B.target.value), W.newPassword && F((O) => ({ ...O, newPassword: !1 }));
3247
3248
  },
3248
3249
  placeholder: E.newPasswordPlaceholder,
3249
3250
  style: y("newPassword"),
@@ -3251,15 +3252,15 @@ function Bt({
3251
3252
  }
3252
3253
  )
3253
3254
  ] }),
3254
- /* @__PURE__ */ l("div", { style: o.fieldGroup, children: [
3255
- /* @__PURE__ */ n("label", { style: o.label, children: E.confirmPasswordLabel }),
3255
+ /* @__PURE__ */ l("div", { style: a.fieldGroup, children: [
3256
+ /* @__PURE__ */ n("label", { style: a.label, children: E.confirmPasswordLabel }),
3256
3257
  /* @__PURE__ */ n(
3257
3258
  "input",
3258
3259
  {
3259
3260
  type: "password",
3260
3261
  value: L,
3261
3262
  onChange: (B) => {
3262
- C(B.target.value), G.confirmPassword && F((O) => ({ ...O, confirmPassword: !1 })), u === E.passwordMismatchError && T("");
3263
+ R(B.target.value), W.confirmPassword && F((O) => ({ ...O, confirmPassword: !1 })), u === E.passwordMismatchError && P("");
3263
3264
  },
3264
3265
  placeholder: E.confirmPasswordPlaceholder,
3265
3266
  style: y("confirmPassword"),
@@ -3273,38 +3274,38 @@ function Bt({
3273
3274
  type: "submit",
3274
3275
  disabled: !z || q,
3275
3276
  style: {
3276
- ...W(),
3277
- ...!z || q ? o.buttonDisabled : {}
3277
+ ...G(),
3278
+ ...!z || q ? a.buttonDisabled : {}
3278
3279
  },
3279
3280
  children: q ? E.resetLoadingText : E.resetSubmitButton
3280
3281
  }
3281
3282
  ),
3282
- u && /* @__PURE__ */ n("div", { style: o.errorText, children: u }),
3283
- R && /* @__PURE__ */ n("div", { style: o.successText, children: R })
3283
+ u && /* @__PURE__ */ n("div", { style: a.errorText, children: u }),
3284
+ C && /* @__PURE__ */ n("div", { style: a.successText, children: C })
3284
3285
  ] }),
3285
- /* @__PURE__ */ l("div", { style: o.linkContainer, children: [
3286
- /* @__PURE__ */ n("a", { onClick: p, style: o.link, children: E.backToLoginLink }),
3286
+ /* @__PURE__ */ l("div", { style: a.linkContainer, children: [
3287
+ /* @__PURE__ */ n("a", { onClick: p, style: a.link, children: E.backToLoginLink }),
3287
3288
  I && /* @__PURE__ */ l(N, { children: [
3288
3289
  /* @__PURE__ */ n("span", { style: { margin: "0 0.5rem", color: "#6b7280" }, children: "•" }),
3289
- /* @__PURE__ */ n("a", { onClick: () => I("request"), style: o.link, children: "Request New Link" })
3290
+ /* @__PURE__ */ n("a", { onClick: () => I("request"), style: a.link, children: "Request New Link" })
3290
3291
  ] })
3291
3292
  ] })
3292
3293
  ] });
3293
3294
  }
3294
3295
  const ee = x;
3295
- return /* @__PURE__ */ l("div", { className: A, style: o.container, children: [
3296
- /* @__PURE__ */ n("h2", { style: o.title, children: E.title }),
3297
- /* @__PURE__ */ n("p", { style: o.subtitle, children: E.subtitle }),
3298
- /* @__PURE__ */ l("form", { onSubmit: d, style: o.form, children: [
3299
- /* @__PURE__ */ l("div", { style: o.fieldGroup, children: [
3300
- /* @__PURE__ */ n("label", { style: o.label, children: E.emailLabel }),
3296
+ return /* @__PURE__ */ l("div", { className: A, style: a.container, children: [
3297
+ /* @__PURE__ */ n("h2", { style: a.title, children: E.title }),
3298
+ /* @__PURE__ */ n("p", { style: a.subtitle, children: E.subtitle }),
3299
+ /* @__PURE__ */ l("form", { onSubmit: c, style: a.form, children: [
3300
+ /* @__PURE__ */ l("div", { style: a.fieldGroup, children: [
3301
+ /* @__PURE__ */ n("label", { style: a.label, children: E.emailLabel }),
3301
3302
  /* @__PURE__ */ n(
3302
3303
  "input",
3303
3304
  {
3304
3305
  type: "email",
3305
3306
  value: x,
3306
3307
  onChange: (z) => {
3307
- P(z.target.value), G.email && F((B) => ({ ...B, email: !1 }));
3308
+ T(z.target.value), W.email && F((B) => ({ ...B, email: !1 }));
3308
3309
  },
3309
3310
  placeholder: E.emailPlaceholder,
3310
3311
  style: y("email"),
@@ -3318,20 +3319,20 @@ function Bt({
3318
3319
  type: "submit",
3319
3320
  disabled: !ee || q,
3320
3321
  style: {
3321
- ...W(),
3322
- ...!ee || q ? o.buttonDisabled : {}
3322
+ ...G(),
3323
+ ...!ee || q ? a.buttonDisabled : {}
3323
3324
  },
3324
3325
  children: q ? E.loadingText : E.submitButton
3325
3326
  }
3326
3327
  ),
3327
- u && /* @__PURE__ */ n("div", { style: o.errorText, children: u }),
3328
- R && /* @__PURE__ */ n("div", { style: o.successText, children: R })
3328
+ u && /* @__PURE__ */ n("div", { style: a.errorText, children: u }),
3329
+ C && /* @__PURE__ */ n("div", { style: a.successText, children: C })
3329
3330
  ] }),
3330
- /* @__PURE__ */ l("div", { style: o.linkContainer, children: [
3331
- /* @__PURE__ */ n("a", { onClick: p, style: o.link, children: E.backToLoginLink }),
3331
+ /* @__PURE__ */ l("div", { style: a.linkContainer, children: [
3332
+ /* @__PURE__ */ n("a", { onClick: p, style: a.link, children: E.backToLoginLink }),
3332
3333
  I && /* @__PURE__ */ l(N, { children: [
3333
3334
  /* @__PURE__ */ n("span", { style: { margin: "0 0.5rem", color: "#6b7280" }, children: "•" }),
3334
- /* @__PURE__ */ n("a", { onClick: () => I("reset"), style: o.link, children: "I have a token" })
3335
+ /* @__PURE__ */ n("a", { onClick: () => I("reset"), style: a.link, children: "I have a token" })
3335
3336
  ] })
3336
3337
  ] })
3337
3338
  ] });
@@ -3357,12 +3358,12 @@ class Ut {
3357
3358
  throw new Error("SessionManager is required for private endpoints");
3358
3359
  const t = await this.sessionManager.getAuthHeaders(), r = new URLSearchParams();
3359
3360
  e != null && e.page && r.append("page", e.page.toString()), e != null && e.limit && r.append("limit", e.limit.toString()), e != null && e.sortBy && r.append("sortBy", e.sortBy), e != null && e.sortOrder && r.append("sortOrder", e.sortOrder);
3360
- const s = `/permissions/${r.toString() ? `?${r.toString()}` : ""}`, a = await this.httpService.get(s, {
3361
+ const s = `/permissions/${r.toString() ? `?${r.toString()}` : ""}`, o = await this.httpService.get(s, {
3361
3362
  headers: t
3362
3363
  });
3363
3364
  return {
3364
- permissions: a.data,
3365
- meta: a.meta
3365
+ permissions: o.data,
3366
+ meta: o.meta
3366
3367
  };
3367
3368
  }
3368
3369
  async getPermissionById(e) {
@@ -3397,10 +3398,10 @@ class Ut {
3397
3398
  async getAppPermissions(e, t) {
3398
3399
  const r = new URLSearchParams();
3399
3400
  t != null && t.page && r.append("page", t.page.toString()), t != null && t.limit && r.append("limit", t.limit.toString()), t != null && t.sortBy && r.append("sortBy", t.sortBy), t != null && t.sortOrder && r.append("sortOrder", t.sortOrder);
3400
- const s = `/permissions/apps/${e}${r.toString() ? `?${r.toString()}` : ""}`, a = await this.httpService.get(s);
3401
+ const s = `/permissions/apps/${e}${r.toString() ? `?${r.toString()}` : ""}`, o = await this.httpService.get(s);
3401
3402
  return {
3402
- permissions: a.data,
3403
- meta: a.meta
3403
+ permissions: o.data,
3404
+ meta: o.meta
3404
3405
  };
3405
3406
  }
3406
3407
  }
@@ -3421,12 +3422,12 @@ class qt {
3421
3422
  async getSubscriptionPlans(e) {
3422
3423
  const t = await this.sessionManager.getAuthHeaders(), r = new URLSearchParams();
3423
3424
  e != null && e.page && r.append("page", e.page.toString()), e != null && e.limit && r.append("limit", e.limit.toString()), e != null && e.sortBy && r.append("sortBy", e.sortBy), e != null && e.sortOrder && r.append("sortOrder", e.sortOrder), e != null && e.appId && r.append("appId", e.appId);
3424
- const s = `/subscription-plans/${r.toString() ? `?${r.toString()}` : ""}`, a = await this.httpService.get(s, {
3425
+ const s = `/subscription-plans/${r.toString() ? `?${r.toString()}` : ""}`, o = await this.httpService.get(s, {
3425
3426
  headers: t
3426
3427
  });
3427
3428
  return {
3428
- plans: a.data,
3429
- meta: a.meta
3429
+ plans: o.data,
3430
+ meta: o.meta
3430
3431
  };
3431
3432
  }
3432
3433
  async getSubscriptionPlanById(e) {
@@ -3591,13 +3592,13 @@ export {
3591
3592
  be as AppApiService,
3592
3593
  St as AppProvider,
3593
3594
  Ne as AuthApiService,
3594
- Pt as AuthProvider,
3595
+ Tt as AuthProvider,
3595
3596
  Ft as FeatureFlag,
3596
3597
  ze as FeatureFlagApiService,
3597
- Tt as FeatureFlagProvider,
3598
+ Pt as FeatureFlagProvider,
3598
3599
  zt as HealthApiService,
3599
3600
  re as HttpService,
3600
- Ct as LandingRoute,
3601
+ Rt as LandingRoute,
3601
3602
  $t as LoginForm,
3602
3603
  Ht as MagicLinkForm,
3603
3604
  Nt as MagicLinkVerify,
@@ -3614,7 +3615,7 @@ export {
3614
3615
  Mt as SubscriptionProvider,
3615
3616
  ce as TenantApiService,
3616
3617
  xt as TenantProvider,
3617
- Rt as TenantRoute,
3618
+ Ct as TenantRoute,
3618
3619
  Be as UserApiService,
3619
3620
  ie as UserType,
3620
3621
  vt as useApi,