@skylabs-digital/react-identity-access 1.1.0 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.es.js CHANGED
@@ -1,7 +1,7 @@
1
- import { jsx as n, Fragment as U, jsxs as u } from "react/jsx-runtime";
2
- import { createContext as te, useState as m, useMemo as z, useCallback as J, useEffect as K, useContext as re } from "react";
3
- import { useLocation as me, Navigate as le } from "react-router";
4
- class _ {
1
+ import { jsx as n, Fragment as B, jsxs as u } from "react/jsx-runtime";
2
+ import { createContext as ee, useState as m, useMemo as O, useCallback as X, useEffect as K, useContext as te } from "react";
3
+ import { useLocation as me, Navigate as ae } from "react-router";
4
+ class G {
5
5
  // SessionManager instance
6
6
  constructor(e, t = 1e4) {
7
7
  this.baseUrl = e.replace(/\/$/, ""), this.timeout = t;
@@ -16,7 +16,7 @@ class _ {
16
16
  return this.executeRequest(e, t, r, s, !1);
17
17
  }
18
18
  async executeRequest(e, t, r, s, a = !1) {
19
- const x = `${this.baseUrl}${t.startsWith("/") ? t : `/${t}`}`, d = (s == null ? void 0 : s.timeout) || this.timeout;
19
+ const v = `${this.baseUrl}${t.startsWith("/") ? t : `/${t}`}`, T = (s == null ? void 0 : s.timeout) || this.timeout;
20
20
  let M = {
21
21
  "Content-Type": "application/json",
22
22
  ...s == null ? void 0 : s.headers
@@ -28,9 +28,9 @@ class _ {
28
28
  } catch (h) {
29
29
  console.warn("Failed to inject auth headers:", h);
30
30
  }
31
- const P = new AbortController(), g = setTimeout(() => P.abort(), d);
31
+ const P = new AbortController(), g = setTimeout(() => P.abort(), T);
32
32
  try {
33
- const h = await fetch(x, {
33
+ const h = await fetch(v, {
34
34
  method: e,
35
35
  headers: M,
36
36
  body: r ? JSON.stringify(r) : void 0,
@@ -38,18 +38,18 @@ class _ {
38
38
  });
39
39
  if (clearTimeout(g), h.status === 401 && !(s != null && s.skipRetry) && !a && this.sessionManager)
40
40
  try {
41
- const y = this.sessionManager.getTokens();
42
- if (y != null && y.refreshToken)
41
+ const p = this.sessionManager.getTokens();
42
+ if (p != null && p.refreshToken)
43
43
  return await this.sessionManager.getAuthHeaders(), this.executeRequest(e, t, r, s, !0);
44
44
  } catch {
45
45
  throw new Error(`HTTP ${h.status}: ${h.statusText}`);
46
46
  }
47
47
  if (!h.ok)
48
48
  throw new Error(`HTTP ${h.status}: ${h.statusText}`);
49
- const b = h.headers.get("content-type");
50
- return !b || !b.includes("application/json") ? {} : await h.json();
49
+ const x = h.headers.get("content-type");
50
+ return !x || !x.includes("application/json") ? {} : await h.json();
51
51
  } catch (h) {
52
- throw clearTimeout(g), h instanceof Error && h.name === "AbortError" ? new Error(`Request timeout after ${d}ms`) : h;
52
+ throw clearTimeout(g), h instanceof Error && h.name === "AbortError" ? new Error(`Request timeout after ${T}ms`) : h;
53
53
  }
54
54
  }
55
55
  async get(e, t) {
@@ -124,7 +124,7 @@ class be {
124
124
  })).data;
125
125
  }
126
126
  }
127
- const ge = te(null), Se = () => /* @__PURE__ */ n(
127
+ const ge = ee(null), Se = () => /* @__PURE__ */ n(
128
128
  "div",
129
129
  {
130
130
  style: {
@@ -171,7 +171,7 @@ const ge = te(null), Se = () => /* @__PURE__ */ n(
171
171
  }
172
172
  );
173
173
  function Je({ config: i, children: e }) {
174
- const [t, r] = m(null), [s, a] = m(!0), [x, d] = m(null), M = z(() => {
174
+ const [t, r] = m(null), [s, a] = m(!0), [v, T] = m(null), M = O(() => {
175
175
  const g = () => {
176
176
  P();
177
177
  };
@@ -181,17 +181,17 @@ function Je({ config: i, children: e }) {
181
181
  // App info
182
182
  appInfo: t,
183
183
  isAppLoading: s,
184
- appError: x,
184
+ appError: v,
185
185
  retryApp: g
186
186
  };
187
- }, [i, t, s, x]), P = J(async () => {
187
+ }, [i, t, s, v]), P = X(async () => {
188
188
  try {
189
- a(!0), d(null);
190
- const g = new _(i.baseUrl), b = await new be(g, {}).getPublicAppInfo(i.appId);
191
- r(b);
189
+ a(!0), T(null);
190
+ const g = new G(i.baseUrl), x = await new be(g, {}).getPublicAppInfo(i.appId);
191
+ r(x);
192
192
  } catch (g) {
193
193
  const h = g instanceof Error ? g : new Error("Failed to load app information");
194
- d(h), r(null);
194
+ T(h), r(null);
195
195
  } finally {
196
196
  a(!1);
197
197
  }
@@ -199,20 +199,20 @@ function Je({ config: i, children: e }) {
199
199
  if (K(() => {
200
200
  P();
201
201
  }, [P]), s)
202
- return /* @__PURE__ */ n(U, { children: i.loadingFallback || /* @__PURE__ */ n(Se, {}) });
203
- if (x) {
204
- const g = typeof i.errorFallback == "function" ? i.errorFallback(x, () => P()) : i.errorFallback || /* @__PURE__ */ n(ve, { error: x, retry: () => P() });
205
- return /* @__PURE__ */ n(U, { children: g });
202
+ return /* @__PURE__ */ n(B, { children: i.loadingFallback || /* @__PURE__ */ n(Se, {}) });
203
+ if (v) {
204
+ const g = typeof i.errorFallback == "function" ? i.errorFallback(v, () => P()) : i.errorFallback || /* @__PURE__ */ n(ve, { error: v, retry: () => P() });
205
+ return /* @__PURE__ */ n(B, { children: g });
206
206
  }
207
207
  return /* @__PURE__ */ n(ge.Provider, { value: M, children: e });
208
208
  }
209
- function se() {
210
- const i = re(ge);
209
+ function re() {
210
+ const i = te(ge);
211
211
  if (!i)
212
212
  throw new Error("useApp must be used within an AppProvider");
213
213
  return i;
214
214
  }
215
- const Xe = se;
215
+ const Xe = re;
216
216
  class xe {
217
217
  constructor(e = {}) {
218
218
  this.refreshPromise = null, this.refreshQueue = [], this.storageKey = e.storageKey || "auth_tokens", this.autoRefresh = e.autoRefresh ?? !0, this.refreshThreshold = e.refreshThreshold || 3e5, this.onRefreshFailed = e.onRefreshFailed, this.baseUrl = e.baseUrl || "", this.tokenStorage = e.tokenStorage || {
@@ -364,7 +364,7 @@ class Ae {
364
364
  });
365
365
  }
366
366
  }
367
- class ce {
367
+ class le {
368
368
  constructor(e, t) {
369
369
  this.httpService = e, this.sessionManager = t;
370
370
  }
@@ -431,12 +431,12 @@ class ce {
431
431
  throw new Error("SessionManager is required for private endpoints");
432
432
  const r = await this.sessionManager.getAuthHeaders(), s = new URLSearchParams();
433
433
  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);
434
- const a = `/roles/user/${e}${s.toString() ? `?${s.toString()}` : ""}`, x = await this.httpService.get(a, {
434
+ const a = `/roles/user/${e}${s.toString() ? `?${s.toString()}` : ""}`, v = await this.httpService.get(a, {
435
435
  headers: r
436
436
  });
437
437
  return {
438
- roles: x.data,
439
- meta: x.meta
438
+ roles: v.data,
439
+ meta: v.meta
440
440
  };
441
441
  }
442
442
  }
@@ -480,7 +480,7 @@ class Pe {
480
480
  });
481
481
  }
482
482
  }
483
- class oe {
483
+ class ce {
484
484
  constructor(e, t, r) {
485
485
  this.httpService = e, this.appId = t, this.sessionManager = r;
486
486
  }
@@ -558,7 +558,7 @@ class oe {
558
558
  )).data;
559
559
  }
560
560
  }
561
- const pe = te(null), Te = () => /* @__PURE__ */ n(
561
+ const pe = ee(null), ke = () => /* @__PURE__ */ n(
562
562
  "div",
563
563
  {
564
564
  style: {
@@ -570,7 +570,7 @@ const pe = te(null), Te = () => /* @__PURE__ */ n(
570
570
  },
571
571
  children: /* @__PURE__ */ n("div", { children: "Loading tenant..." })
572
572
  }
573
- ), ke = ({ error: i, retry: e }) => /* @__PURE__ */ u(
573
+ ), Te = ({ error: i, retry: e }) => /* @__PURE__ */ u(
574
574
  "div",
575
575
  {
576
576
  style: {
@@ -605,94 +605,76 @@ const pe = te(null), Te = () => /* @__PURE__ */ n(
605
605
  }
606
606
  );
607
607
  function Ze({ config: i, children: e }) {
608
- const { baseUrl: t, appInfo: r, appId: s } = se(), a = ee(), x = a == null ? void 0 : a.sessionManager, [d, M] = m(i.initialTenant || null), [P, g] = m(!i.initialTenant), [h, b] = m(null), [y, S] = m(null), [$, p] = m(!1), [D, A] = m(null), E = J(() => {
609
- const o = i.tenantMode || "optional", l = "tenant";
610
- if (o === "fixed")
611
- return i.fixedTenantSlug || null;
608
+ const { baseUrl: t, appInfo: r, appId: s } = re(), [a, v] = m(i.initialTenant || null), [T, M] = m(!i.initialTenant), [P, g] = m(null), [h, x] = m(null), [p, A] = m(!1), [F, f] = m(null), C = X(() => {
609
+ const c = i.tenantMode || "selector", w = "tenant";
612
610
  if (typeof window > "u") return null;
613
- if (o === "subdomain") {
614
- const c = window.location.hostname.split(".");
615
- if (c.length >= 3) {
616
- const k = c[0];
617
- return localStorage.setItem(l, k), k;
611
+ if (c === "subdomain") {
612
+ const o = window.location.hostname.split(".");
613
+ if (o.length >= 3) {
614
+ const l = o[0];
615
+ return localStorage.setItem(w, l), l;
618
616
  }
619
- return localStorage.getItem(l);
620
- } else if (o === "selector") {
621
- const c = new URLSearchParams(window.location.search).get(i.selectorParam || "tenant");
622
- return c ? (localStorage.setItem(l, c), c) : localStorage.getItem(l);
617
+ return localStorage.getItem(w);
618
+ } else if (c === "selector") {
619
+ const o = new URLSearchParams(window.location.search).get(i.selectorParam || "tenant");
620
+ return o ? (localStorage.setItem(w, o), o) : localStorage.getItem(w);
623
621
  }
624
622
  return null;
625
- }, [i.tenantMode, i.fixedTenantSlug, i.selectorParam]), f = z(() => E(), [E]), I = (r == null ? void 0 : r.settingsSchema) || null, C = J(
626
- async (o) => {
623
+ }, [i.tenantMode, i.selectorParam]), y = O(() => C(), [C]), b = (r == null ? void 0 : r.settingsSchema) || null, k = X(
624
+ async (c) => {
627
625
  try {
628
- g(!0), b(null);
629
- const l = new _(t), c = await new oe(l, s).getPublicTenantInfo(o);
630
- M(c);
631
- } catch (l) {
632
- const H = l instanceof Error ? l : new Error("Failed to load tenant information");
633
- b(H), M(null);
626
+ M(!0), g(null);
627
+ const w = new G(t), o = await new ce(w, s).getPublicTenantInfo(c);
628
+ v(o);
629
+ } catch (w) {
630
+ const d = w instanceof Error ? w : new Error("Failed to load tenant information");
631
+ g(d), v(null);
634
632
  } finally {
635
- g(!1);
633
+ M(!1);
636
634
  }
637
635
  },
638
636
  [t, s]
639
- ), F = J(async () => {
640
- if (d != null && d.id)
637
+ ), R = X(async () => {
638
+ if (a != null && a.id)
641
639
  try {
642
- p(!0), A(null);
643
- const o = new _(t), H = await new oe(o, d.appId).getTenantSettings(d.id);
644
- S(H);
645
- } catch (o) {
646
- const l = o instanceof Error ? o : new Error("Failed to load tenant settings");
647
- A(l), S(null);
640
+ A(!0), f(null);
641
+ const c = new G(t), d = await new ce(c, a.appId).getTenantSettings(a.id);
642
+ x(d);
643
+ } catch (c) {
644
+ const w = c instanceof Error ? c : new Error("Failed to load tenant settings");
645
+ f(w), x(null);
648
646
  } finally {
649
- p(!1);
650
- }
651
- }, [t, d]), B = J(
652
- async (o) => {
653
- if (!(d != null && d.id) || !x)
654
- throw new Error("Tenant ID and authentication required to update settings");
655
- try {
656
- p(!0), A(null);
657
- const l = new _(t), H = new oe(l, d.appId, x), c = { settings: o }, k = await H.updateTenantSettings(d.id, c);
658
- S(k);
659
- } catch (l) {
660
- const H = l instanceof Error ? l : new Error("Failed to update tenant settings");
661
- throw A(H), H;
662
- } finally {
663
- p(!1);
647
+ A(!1);
664
648
  }
665
- },
666
- [t, d, x]
667
- ), w = J(() => {
668
- F();
669
- }, [F]), O = J(
670
- (o) => {
671
- if (!I)
649
+ }, [t, a]), L = X(() => {
650
+ R();
651
+ }, [R]), E = X(
652
+ (c) => {
653
+ if (!b)
672
654
  return { isValid: !0, errors: [] };
673
- const l = [];
655
+ const w = [];
674
656
  try {
675
- return I.properties && Object.entries(I.properties).forEach(([H, c]) => {
657
+ return b.properties && Object.entries(b.properties).forEach(([d, o]) => {
676
658
  var W;
677
- const k = o[H];
678
- if ((W = I.required) != null && W.includes(H) && k == null) {
679
- l.push(`Field '${H}' is required`);
659
+ const l = c[d];
660
+ if ((W = b.required) != null && W.includes(d) && l == null) {
661
+ w.push(`Field '${d}' is required`);
680
662
  return;
681
663
  }
682
- if (k != null) {
683
- if (c.type) {
684
- const R = c.type, q = typeof k;
685
- R === "string" && q !== "string" ? l.push(`Field '${H}' must be a string`) : (R === "number" || R === "integer") && q !== "number" ? l.push(`Field '${H}' must be a number`) : R === "boolean" && q !== "boolean" ? l.push(`Field '${H}' must be a boolean`) : R === "array" && !Array.isArray(k) && l.push(`Field '${H}' must be an array`);
664
+ if (l != null) {
665
+ if (o.type) {
666
+ const I = o.type, N = typeof l;
667
+ I === "string" && N !== "string" ? w.push(`Field '${d}' must be a string`) : (I === "number" || I === "integer") && N !== "number" ? w.push(`Field '${d}' must be a number`) : I === "boolean" && N !== "boolean" ? w.push(`Field '${d}' must be a boolean`) : I === "array" && !Array.isArray(l) && w.push(`Field '${d}' must be an array`);
686
668
  }
687
- c.minLength !== void 0 && typeof k == "string" && k.length < c.minLength && l.push(
688
- `Field '${H}' must be at least ${c.minLength} characters long`
689
- ), c.maxLength !== void 0 && typeof k == "string" && k.length > c.maxLength && l.push(
690
- `Field '${H}' must be no more than ${c.maxLength} characters long`
691
- ), c.minimum !== void 0 && typeof k == "number" && k < c.minimum && l.push(`Field '${H}' must be at least ${c.minimum}`), c.maximum !== void 0 && typeof k == "number" && k > c.maximum && l.push(`Field '${H}' must be no more than ${c.maximum}`), c.pattern && typeof k == "string" && (new RegExp(c.pattern).test(k) || l.push(`Field '${H}' does not match the required pattern`)), c.enum && !c.enum.includes(k) && l.push(`Field '${H}' must be one of: ${c.enum.join(", ")}`);
669
+ o.minLength !== void 0 && typeof l == "string" && l.length < o.minLength && w.push(
670
+ `Field '${d}' must be at least ${o.minLength} characters long`
671
+ ), o.maxLength !== void 0 && typeof l == "string" && l.length > o.maxLength && w.push(
672
+ `Field '${d}' must be no more than ${o.maxLength} characters long`
673
+ ), o.minimum !== void 0 && typeof l == "number" && l < o.minimum && w.push(`Field '${d}' must be at least ${o.minimum}`), o.maximum !== void 0 && typeof l == "number" && l > o.maximum && w.push(`Field '${d}' must be no more than ${o.maximum}`), o.pattern && typeof l == "string" && (new RegExp(o.pattern).test(l) || w.push(`Field '${d}' does not match the required pattern`)), o.enum && !o.enum.includes(l) && w.push(`Field '${d}' must be one of: ${o.enum.join(", ")}`);
692
674
  }
693
675
  }), {
694
- isValid: l.length === 0,
695
- errors: l
676
+ isValid: w.length === 0,
677
+ errors: w
696
678
  };
697
679
  } catch {
698
680
  return {
@@ -701,83 +683,76 @@ function Ze({ config: i, children: e }) {
701
683
  };
702
684
  }
703
685
  },
704
- [I]
686
+ [b]
705
687
  );
706
688
  K(() => {
707
- const o = i.tenantMode || "optional";
708
- !i.initialTenant && f ? C(f) : !i.initialTenant && !f && o === "fixed" ? (b(new Error("Fixed tenant mode requires fixedTenantSlug configuration")), g(!1)) : !i.initialTenant && !f && (o === "subdomain" || o === "selector") ? (b(
709
- new Error(`No tenant ${o === "subdomain" ? "subdomain" : "parameter"} found`)
710
- ), g(!1)) : !i.initialTenant && !f && o === "optional" && (M(null), b(null), g(!1));
711
- }, [i.initialTenant, f, C, i.tenantMode, i.fixedTenantSlug]), K(() => {
712
- d != null && d.id ? F() : (S(null), A(null), p(!1));
713
- }, [d == null ? void 0 : d.id, F]);
714
- const T = z(() => ({
689
+ !i.initialTenant && y ? k(y) : !i.initialTenant && !y && (v(null), g(null), M(!1));
690
+ }, [i.initialTenant, y, k]), K(() => {
691
+ a != null && a.id ? R() : (x(null), f(null), A(!1));
692
+ }, [a == null ? void 0 : a.id, R]);
693
+ const D = O(() => ({
715
694
  // Tenant info
716
- tenant: d,
717
- tenantSlug: f,
718
- isTenantLoading: P,
719
- tenantError: h,
695
+ tenant: a,
696
+ tenantSlug: y,
697
+ isTenantLoading: T,
698
+ tenantError: P,
720
699
  retryTenant: () => {
721
- f && C(f);
700
+ y && k(y);
722
701
  },
723
702
  // Settings
724
- settings: y,
725
- settingsSchema: I,
726
- isSettingsLoading: $,
727
- settingsError: D,
703
+ settings: h,
704
+ settingsSchema: b,
705
+ isSettingsLoading: p,
706
+ settingsError: F,
728
707
  // Actions
729
- updateSettings: B,
730
- refreshSettings: w,
708
+ refreshSettings: L,
731
709
  // Validation
732
- validateSettings: O
710
+ validateSettings: E
733
711
  }), [
734
- d,
735
- f,
712
+ a,
713
+ y,
714
+ T,
736
715
  P,
737
716
  h,
738
- y,
739
- I,
740
- $,
741
- D,
742
- B,
743
- w,
744
- O
717
+ b,
718
+ p,
719
+ F,
720
+ L,
721
+ E
745
722
  ]);
746
- if (P)
747
- return /* @__PURE__ */ n(U, { children: i.loadingFallback || /* @__PURE__ */ n(Te, {}) });
748
- if (h && i.tenantMode !== "optional") {
749
- const o = typeof i.errorFallback == "function" ? i.errorFallback(h, () => C(f || "")) : i.errorFallback || /* @__PURE__ */ n(ke, { error: h, retry: () => C(f || "") });
750
- return /* @__PURE__ */ n(U, { children: o });
723
+ if (T)
724
+ return /* @__PURE__ */ n(B, { children: i.loadingFallback || /* @__PURE__ */ n(ke, {}) });
725
+ if (P) {
726
+ const c = typeof i.errorFallback == "function" ? i.errorFallback(P, () => k(y || "")) : i.errorFallback || /* @__PURE__ */ n(Te, { error: P, retry: () => k(y || "") });
727
+ return /* @__PURE__ */ n(B, { children: c });
751
728
  }
752
- return /* @__PURE__ */ n(pe.Provider, { value: T, children: e });
729
+ return /* @__PURE__ */ n(pe.Provider, { value: D, children: e });
753
730
  }
754
- function ae() {
755
- const i = re(pe);
731
+ function oe() {
732
+ const i = te(pe);
756
733
  if (!i)
757
734
  throw new Error("useTenant must be used within a TenantProvider");
758
735
  return i;
759
736
  }
760
- const et = ae;
737
+ const et = oe;
761
738
  function tt() {
762
739
  const {
763
740
  settings: i,
764
741
  settingsSchema: e,
765
742
  isSettingsLoading: t,
766
743
  settingsError: r,
767
- updateSettings: s,
768
- validateSettings: a
769
- } = ae();
744
+ validateSettings: s
745
+ } = oe();
770
746
  return {
771
747
  settings: i,
772
748
  settingsSchema: e,
773
749
  isLoading: t,
774
750
  error: r,
775
- updateSettings: s,
776
- validateSettings: a
751
+ validateSettings: s
777
752
  };
778
753
  }
779
754
  function Z() {
780
- const { tenant: i, tenantSlug: e, isTenantLoading: t, tenantError: r, retryTenant: s } = ae();
755
+ const { tenant: i, tenantSlug: e, isTenantLoading: t, tenantError: r, retryTenant: s } = oe();
781
756
  return {
782
757
  tenant: i,
783
758
  tenantSlug: e,
@@ -786,192 +761,192 @@ function Z() {
786
761
  retry: s
787
762
  };
788
763
  }
789
- const fe = te(null);
764
+ const fe = ee(null);
790
765
  function rt({ config: i = {}, children: e }) {
791
- const { appId: t, baseUrl: r } = se(), s = Z(), a = (s == null ? void 0 : s.tenantSlug) || null, [x, d] = m(i.initialRoles || []), [M, P] = m(!i.initialRoles), [g, h] = m(null), [b, y] = m(!1), [S, $] = m(null), p = z(() => {
792
- const w = a ? `auth_tokens_${a}` : "auth_tokens", O = {
766
+ const { appId: t, baseUrl: r } = re(), s = Z(), a = (s == null ? void 0 : s.tenantSlug) || null, [v, T] = m(i.initialRoles || []), [M, P] = m(!i.initialRoles), [g, h] = m(null), [x, p] = m(!1), [A, F] = m(null), f = O(() => {
767
+ const c = a ? `auth_tokens_${a}` : "auth_tokens", w = {
793
768
  get: () => {
794
769
  try {
795
- const T = localStorage.getItem(w);
796
- return T ? JSON.parse(T) : null;
770
+ const d = localStorage.getItem(c);
771
+ return d ? JSON.parse(d) : null;
797
772
  } catch {
798
773
  return null;
799
774
  }
800
775
  },
801
- set: (T) => {
776
+ set: (d) => {
802
777
  try {
803
- localStorage.setItem(w, JSON.stringify(T));
778
+ localStorage.setItem(c, JSON.stringify(d));
804
779
  } catch {
805
780
  }
806
781
  },
807
782
  clear: () => {
808
783
  try {
809
- localStorage.removeItem(w);
784
+ localStorage.removeItem(c);
810
785
  } catch {
811
786
  }
812
787
  }
813
788
  };
814
789
  return new xe({
815
790
  onRefreshFailed: i.onRefreshFailed,
816
- tokenStorage: O,
791
+ tokenStorage: w,
817
792
  baseUrl: r
818
793
  });
819
- }, [a, r, i.onRefreshFailed]), D = z(() => {
820
- const w = new _(r);
821
- return w.setSessionManager(p), w;
822
- }, [r, p]), A = z(() => new Ae(new _(r)), [r]), E = z(() => new Pe(D, p), [D, p]), f = z(() => new ce(new _(r)), [r]), I = z(() => g || p.getUser(), [g, p]), C = z(() => I != null && I.roleId && x.find((w) => w.id === I.roleId) || null, [I, x]), F = z(() => (C == null ? void 0 : C.permissions) || [], [C]);
794
+ }, [a, r, i.onRefreshFailed]), C = O(() => {
795
+ const c = new G(r);
796
+ return c.setSessionManager(f), c;
797
+ }, [r, f]), y = O(() => new Ae(new G(r)), [r]), b = O(() => new Pe(C, f), [C, f]), k = O(() => new le(new G(r)), [r]), R = O(() => g || f.getUser(), [g, f]), L = O(() => R != null && R.roleId && v.find((c) => c.id === R.roleId) || null, [R, v]), E = O(() => (L == null ? void 0 : L.permissions) || [], [L]);
823
798
  K(() => {
824
- console.log("AuthProvider - userPermissions changed:", F);
825
- }, [F]);
826
- const B = z(() => {
827
- const w = async () => {
799
+ console.log("AuthProvider - userPermissions changed:", E);
800
+ }, [E]);
801
+ const D = O(() => {
802
+ const c = async () => {
828
803
  try {
829
- y(!0), $(null);
830
- const v = p.getUser();
831
- if (!(v != null && v.id))
804
+ p(!0), F(null);
805
+ const S = f.getUser();
806
+ if (!(S != null && S.id))
832
807
  throw new Error("No user ID available in session");
833
- const L = await E.getUserById(v.id);
834
- h(L), p.setUser(L);
835
- } catch (v) {
836
- const L = v instanceof Error ? v : new Error("Failed to load user data");
837
- $(L), console.error("Failed to load user data:", L);
808
+ const $ = await b.getUserById(S.id);
809
+ h($), f.setUser($);
810
+ } catch (S) {
811
+ const $ = S instanceof Error ? S : new Error("Failed to load user data");
812
+ F($), console.error("Failed to load user data:", $);
838
813
  } finally {
839
- y(!1);
814
+ p(!1);
840
815
  }
841
- }, O = async () => {
842
- await w();
843
- }, T = async (v, L, Q) => {
844
- const G = await A.login({
845
- email: v,
846
- password: L,
816
+ }, w = async () => {
817
+ await c();
818
+ }, d = async (S, $, Q) => {
819
+ const V = await y.login({
820
+ email: S,
821
+ password: $,
847
822
  tenantId: Q
848
823
  });
849
- if (p.setTokens({
850
- accessToken: G.accessToken,
851
- refreshToken: G.refreshToken,
852
- expiresIn: G.expiresIn
853
- }), G.user) {
854
- p.setUser(G.user), h(G.user);
824
+ if (f.setTokens({
825
+ accessToken: V.accessToken,
826
+ refreshToken: V.refreshToken,
827
+ expiresIn: V.expiresIn
828
+ }), V.user) {
829
+ f.setUser(V.user), h(V.user);
855
830
  try {
856
- await w();
831
+ await c();
857
832
  } catch (ie) {
858
833
  console.warn("Failed to load complete user data after login:", ie);
859
834
  }
860
835
  }
861
- return G;
862
- }, o = async (v, L, Q, G) => await A.signup({ email: v, name: L, password: Q, tenantId: G }), l = async (v, L, Q, G) => await A.signupTenantAdmin({
863
- email: v,
864
- name: L,
836
+ return V;
837
+ }, o = async (S, $, Q, V) => await y.signup({ email: S, name: $, password: Q, tenantId: V }), l = async (S, $, Q, V) => await y.signupTenantAdmin({
838
+ email: S,
839
+ name: $,
865
840
  password: Q,
866
- tenantName: G,
841
+ tenantName: V,
867
842
  appId: t
868
- }), H = async (v, L) => {
869
- const Q = await p.getAuthHeaders();
870
- await A.changePassword({ currentPassword: v, newPassword: L }, Q);
871
- }, c = async (v, L) => {
872
- await A.requestPasswordReset({ email: v, tenantId: L });
873
- }, k = async (v, L) => {
874
- await A.confirmPasswordReset({ token: v, newPassword: L });
875
- }, W = async () => {
876
- const v = p.getTokens();
877
- if (!(v != null && v.refreshToken))
843
+ }), W = async (S, $) => {
844
+ const Q = await f.getAuthHeaders();
845
+ await y.changePassword({ currentPassword: S, newPassword: $ }, Q);
846
+ }, I = async (S, $) => {
847
+ await y.requestPasswordReset({ email: S, tenantId: $ });
848
+ }, N = async (S, $) => {
849
+ await y.confirmPasswordReset({ token: S, newPassword: $ });
850
+ }, _ = async () => {
851
+ const S = f.getTokens();
852
+ if (!(S != null && S.refreshToken))
878
853
  throw new Error("No refresh token available");
879
- const L = await A.refreshToken({
880
- refreshToken: v.refreshToken
854
+ const $ = await y.refreshToken({
855
+ refreshToken: S.refreshToken
881
856
  });
882
- p.setTokens({
883
- accessToken: L.accessToken,
884
- refreshToken: L.refreshToken || v.refreshToken,
885
- expiresIn: L.expiresIn
857
+ f.setTokens({
858
+ accessToken: $.accessToken,
859
+ refreshToken: $.refreshToken || S.refreshToken,
860
+ expiresIn: $.expiresIn
886
861
  });
887
- }, R = () => {
888
- p.clearSession(), h(null), $(null);
889
- }, q = (v) => {
890
- p.setTokens(v);
891
- }, Y = () => p.hasValidSession(), N = () => {
892
- p.clearSession(), h(null), $(null);
893
- }, j = async () => {
862
+ }, H = () => {
863
+ f.clearSession(), h(null), F(null);
864
+ }, q = (S) => {
865
+ f.setTokens(S);
866
+ }, Y = () => f.hasValidSession(), U = () => {
867
+ f.clearSession(), h(null), F(null);
868
+ }, z = async () => {
894
869
  if (t)
895
870
  try {
896
871
  P(!0);
897
- const { roles: v } = await f.getRolesByApp(t);
898
- d(v);
899
- } catch (v) {
900
- console.error("Failed to fetch roles:", v);
872
+ const { roles: S } = await k.getRolesByApp(t);
873
+ T(S);
874
+ } catch (S) {
875
+ console.error("Failed to fetch roles:", S);
901
876
  } finally {
902
877
  P(!1);
903
878
  }
904
- }, V = async () => {
905
- await j();
906
- }, ne = (v) => {
907
- if (!F || F.length === 0)
879
+ }, j = async () => {
880
+ await z();
881
+ }, ne = (S) => {
882
+ if (!E || E.length === 0)
908
883
  return !1;
909
- if (typeof v == "string")
910
- return F.includes(v);
911
- const L = `${v.resource}.${v.action}`;
912
- return F.includes(L);
884
+ if (typeof S == "string")
885
+ return E.includes(S);
886
+ const $ = `${S.resource}.${S.action}`;
887
+ return E.includes($);
913
888
  };
914
889
  return {
915
- sessionManager: p,
916
- authenticatedHttpService: D,
917
- login: T,
890
+ sessionManager: f,
891
+ authenticatedHttpService: C,
892
+ login: d,
918
893
  signup: o,
919
894
  signupTenantAdmin: l,
920
- changePassword: H,
921
- requestPasswordReset: c,
922
- confirmPasswordReset: k,
923
- refreshToken: W,
924
- logout: R,
895
+ changePassword: W,
896
+ requestPasswordReset: I,
897
+ confirmPasswordReset: N,
898
+ refreshToken: _,
899
+ logout: H,
925
900
  setTokens: q,
926
901
  hasValidSession: Y,
927
- clearSession: N,
902
+ clearSession: U,
928
903
  currentUser: g,
929
- isUserLoading: b,
930
- userError: S,
931
- refreshUser: O,
932
- userRole: C,
933
- userPermissions: F,
934
- availableRoles: x,
904
+ isUserLoading: x,
905
+ userError: A,
906
+ refreshUser: w,
907
+ userRole: L,
908
+ userPermissions: E,
909
+ availableRoles: v,
935
910
  rolesLoading: M,
936
911
  hasPermission: ne,
937
- hasAnyPermission: (v) => v.some((L) => ne(L)),
938
- hasAllPermissions: (v) => v.every((L) => ne(L)),
939
- getUserPermissionStrings: () => F || [],
940
- refreshRoles: V
912
+ hasAnyPermission: (S) => S.some(($) => ne($)),
913
+ hasAllPermissions: (S) => S.every(($) => ne($)),
914
+ getUserPermissionStrings: () => E || [],
915
+ refreshRoles: j
941
916
  };
942
917
  }, [
943
- p,
944
- D,
945
- A,
946
- E,
947
918
  f,
919
+ C,
920
+ y,
921
+ b,
922
+ k,
948
923
  t,
949
- x,
924
+ v,
950
925
  g,
951
- b,
952
- S,
953
- C,
954
- F
926
+ x,
927
+ A,
928
+ L,
929
+ E
955
930
  ]);
956
931
  return K(() => {
957
932
  !i.initialRoles && t && (async () => {
958
933
  try {
959
934
  P(!0);
960
- const O = new _(r), T = new ce(O), { roles: o } = await T.getRolesByApp(t);
961
- d(o);
962
- } catch (O) {
963
- console.error("Failed to fetch roles:", O);
935
+ const w = new G(r), d = new le(w), { roles: o } = await d.getRolesByApp(t);
936
+ T(o);
937
+ } catch (w) {
938
+ console.error("Failed to fetch roles:", w);
964
939
  } finally {
965
940
  P(!1);
966
941
  }
967
942
  })();
968
943
  }, [t, r, i.initialRoles]), K(() => {
969
- const w = p.getUser();
970
- w && p.hasValidSession() && h(w);
971
- }, [p]), /* @__PURE__ */ n(fe.Provider, { value: B, children: e });
944
+ const c = f.getUser();
945
+ c && f.hasValidSession() && h(c);
946
+ }, [f]), /* @__PURE__ */ n(fe.Provider, { value: D, children: e });
972
947
  }
973
- function ee() {
974
- const i = re(fe);
948
+ function se() {
949
+ const i = te(fe);
975
950
  if (!i)
976
951
  throw new Error("useAuth must be used within an AuthProvider");
977
952
  return i;
@@ -1056,53 +1031,53 @@ class Me {
1056
1031
  })).data;
1057
1032
  }
1058
1033
  }
1059
- const ye = te(null);
1034
+ const ye = ee(null);
1060
1035
  function st({ config: i = {}, children: e }) {
1061
- const { baseUrl: t, appId: r } = se(), { tenant: s } = Z(), [a, x] = m([]), [d, M] = m(!1), [P, g] = m(null), h = z(() => {
1062
- const S = new _(t);
1063
- return new Me(S);
1064
- }, [t]), b = async () => {
1036
+ const { baseUrl: t, appId: r } = re(), { tenant: s } = Z(), [a, v] = m([]), [T, M] = m(!1), [P, g] = m(null), h = O(() => {
1037
+ const A = new G(t);
1038
+ return new Me(A);
1039
+ }, [t]), x = async () => {
1065
1040
  if (!(s != null && s.id)) {
1066
- x([]);
1041
+ v([]);
1067
1042
  return;
1068
1043
  }
1069
1044
  M(!0), g(null);
1070
1045
  try {
1071
- const S = await h.getTenantFeatureFlags(s.id, r);
1072
- x(S);
1073
- } catch (S) {
1074
- const $ = S instanceof Error ? S.message : "Failed to fetch feature flags";
1075
- g($), i.onError && i.onError(S instanceof Error ? S : new Error($));
1046
+ const A = await h.getTenantFeatureFlags(s.id, r);
1047
+ v(A);
1048
+ } catch (A) {
1049
+ const F = A instanceof Error ? A.message : "Failed to fetch feature flags";
1050
+ g(F), i.onError && i.onError(A instanceof Error ? A : new Error(F));
1076
1051
  } finally {
1077
1052
  M(!1);
1078
1053
  }
1079
1054
  };
1080
1055
  K(() => {
1081
- b();
1082
- const S = i.refreshInterval || 5 * 60 * 1e3, $ = setInterval(b, S);
1083
- return () => clearInterval($);
1056
+ x();
1057
+ const A = i.refreshInterval || 5 * 60 * 1e3, F = setInterval(x, A);
1058
+ return () => clearInterval(F);
1084
1059
  }, [s == null ? void 0 : s.id, i.refreshInterval]);
1085
- const y = z(() => ({
1060
+ const p = O(() => ({
1086
1061
  featureFlags: a,
1087
- loading: d,
1062
+ loading: T,
1088
1063
  error: P,
1089
- isEnabled: (A) => {
1090
- const E = a.find((f) => f.key === A);
1091
- return (E == null ? void 0 : E.value) === !0;
1064
+ isEnabled: (y) => {
1065
+ const b = a.find((k) => k.key === y);
1066
+ return (b == null ? void 0 : b.value) === !0;
1092
1067
  },
1093
- getFlag: (A) => a.find((E) => E.key === A),
1094
- getFlagState: (A) => {
1095
- const E = a.find((f) => f.key === A);
1096
- return E ? E.value ? "enabled" : "disabled" : "not_found";
1068
+ getFlag: (y) => a.find((b) => b.key === y),
1069
+ getFlagState: (y) => {
1070
+ const b = a.find((k) => k.key === y);
1071
+ return b ? b.value ? "enabled" : "disabled" : "not_found";
1097
1072
  },
1098
1073
  refresh: async () => {
1099
- await b();
1074
+ await x();
1100
1075
  }
1101
- }), [a, d, P]);
1102
- return /* @__PURE__ */ n(ye.Provider, { value: y, children: e });
1076
+ }), [a, T, P]);
1077
+ return /* @__PURE__ */ n(ye.Provider, { value: p, children: e });
1103
1078
  }
1104
1079
  function Ee() {
1105
- const i = re(ye);
1080
+ const i = te(ye);
1106
1081
  if (!i)
1107
1082
  throw new Error("useFeatureFlags must be used within a FeatureFlagProvider");
1108
1083
  return i;
@@ -1173,63 +1148,63 @@ class Re {
1173
1148
  )).data;
1174
1149
  }
1175
1150
  }
1176
- const we = te(void 0);
1151
+ const we = ee(void 0);
1177
1152
  function nt({ config: i = {}, children: e }) {
1178
- const { baseUrl: t } = se(), { tenant: r } = Z(), [s, a] = m(null), [x, d] = m(!1), [M, P] = m(null), g = z(() => {
1179
- const y = new _(t);
1180
- return new Re(y);
1153
+ const { baseUrl: t } = re(), { tenant: r } = Z(), [s, a] = m(null), [v, T] = m(!1), [M, P] = m(null), g = O(() => {
1154
+ const p = new G(t);
1155
+ return new Re(p);
1181
1156
  }, [t]), h = async () => {
1182
1157
  if (!(r != null && r.id)) {
1183
1158
  a(null);
1184
1159
  return;
1185
1160
  }
1186
- d(!0), P(null);
1161
+ T(!0), P(null);
1187
1162
  try {
1188
- const y = await g.getTenantSubscriptionFeatures(r.id);
1189
- a(y);
1190
- } catch (y) {
1191
- const S = y instanceof Error ? y.message : "Failed to fetch subscription";
1192
- P(S), i.onError && i.onError(y instanceof Error ? y : new Error(S));
1163
+ const p = await g.getTenantSubscriptionFeatures(r.id);
1164
+ a(p);
1165
+ } catch (p) {
1166
+ const A = p instanceof Error ? p.message : "Failed to fetch subscription";
1167
+ P(A), i.onError && i.onError(p instanceof Error ? p : new Error(A));
1193
1168
  } finally {
1194
- d(!1);
1169
+ T(!1);
1195
1170
  }
1196
1171
  };
1197
1172
  K(() => {
1198
1173
  if (h(), !i.refreshInterval) return;
1199
- const y = i.refreshInterval || 10 * 60 * 1e3, S = setInterval(h, y);
1200
- return () => clearInterval(S);
1174
+ const p = i.refreshInterval || 10 * 60 * 1e3, A = setInterval(h, p);
1175
+ return () => clearInterval(A);
1201
1176
  }, [r == null ? void 0 : r.id, i.refreshInterval]);
1202
- const b = z(() => {
1203
- const y = (s == null ? void 0 : s.features) || [];
1177
+ const x = O(() => {
1178
+ const p = (s == null ? void 0 : s.features) || [];
1204
1179
  return {
1205
1180
  subscription: s,
1206
- features: y,
1207
- loading: x,
1181
+ features: p,
1182
+ loading: v,
1208
1183
  error: M,
1209
- isFeatureEnabled: (E) => {
1210
- const f = y.find((I) => I.key === E);
1211
- return f ? f.type === "BOOLEAN" || f.type === "boolean" ? f.value === !0 : !!f.value : !1;
1184
+ isFeatureEnabled: (b) => {
1185
+ const k = p.find((R) => R.key === b);
1186
+ return k ? k.type === "BOOLEAN" || k.type === "boolean" ? k.value === !0 : !!k.value : !1;
1212
1187
  },
1213
- getFeature: (E) => y.find((f) => f.key === E),
1214
- getFeatureValue: (E, f) => {
1215
- const I = y.find((C) => C.key === E);
1216
- return I ? I.value : f;
1188
+ getFeature: (b) => p.find((k) => k.key === b),
1189
+ getFeatureValue: (b, k) => {
1190
+ const R = p.find((L) => L.key === b);
1191
+ return R ? R.value : k;
1217
1192
  },
1218
- hasAllowedPlan: (E) => !s || !s.isActive ? !1 : E.includes(s.planId),
1193
+ hasAllowedPlan: (b) => !s || !s.isActive ? !1 : b.includes(s.planId),
1219
1194
  refresh: async () => {
1220
1195
  await h();
1221
1196
  }
1222
1197
  };
1223
- }, [s, x, M]);
1224
- return /* @__PURE__ */ n(we.Provider, { value: b, children: e });
1198
+ }, [s, v, M]);
1199
+ return /* @__PURE__ */ n(we.Provider, { value: x, children: e });
1225
1200
  }
1226
1201
  function Fe() {
1227
- const i = re(we);
1202
+ const i = te(we);
1228
1203
  if (i === void 0)
1229
1204
  throw new Error("useSubscription must be used within a SubscriptionProvider");
1230
1205
  return i;
1231
1206
  }
1232
- var X = /* @__PURE__ */ ((i) => (i.SUPERUSER = "SUPERUSER", i.TENANT_ADMIN = "TENANT_ADMIN", i.USER = "USER", i))(X || {});
1207
+ var J = /* @__PURE__ */ ((i) => (i.SUPERUSER = "SUPERUSER", i.TENANT_ADMIN = "TENANT_ADMIN", i.USER = "USER", i))(J || {});
1233
1208
  const de = () => /* @__PURE__ */ u(
1234
1209
  "div",
1235
1210
  {
@@ -1289,7 +1264,7 @@ const de = () => /* @__PURE__ */ u(
1289
1264
  children: [
1290
1265
  /* @__PURE__ */ n("div", { style: { fontSize: "2rem", marginBottom: "10px" }, children: "⚠️" }),
1291
1266
  /* @__PURE__ */ n("h3", { style: { color: "#856404", marginBottom: "10px" }, children: "Insufficient Permissions" }),
1292
- e && i ? /* @__PURE__ */ u(U, { children: [
1267
+ e && i ? /* @__PURE__ */ u(B, { children: [
1293
1268
  /* @__PURE__ */ u("p", { style: { color: "#856404", fontSize: "14px", marginBottom: "10px" }, children: [
1294
1269
  "This content requires ",
1295
1270
  /* @__PURE__ */ n("strong", { children: e }),
@@ -1299,7 +1274,7 @@ const de = () => /* @__PURE__ */ u(
1299
1274
  "Your current access level: ",
1300
1275
  /* @__PURE__ */ n("strong", { children: i })
1301
1276
  ] })
1302
- ] }) : /* @__PURE__ */ u(U, { children: [
1277
+ ] }) : /* @__PURE__ */ u(B, { children: [
1303
1278
  /* @__PURE__ */ n("p", { style: { color: "#856404", fontSize: "14px", marginBottom: "10px" }, children: "You don't have the required permissions to view this content." }),
1304
1279
  t && t.length > 0 && /* @__PURE__ */ u("p", { style: { color: "#6c757d", fontSize: "12px" }, children: [
1305
1280
  "Required permissions: ",
@@ -1310,9 +1285,9 @@ const de = () => /* @__PURE__ */ u(
1310
1285
  }
1311
1286
  ), Ie = (i, e) => {
1312
1287
  const t = {
1313
- [X.USER]: 1,
1314
- [X.TENANT_ADMIN]: 2,
1315
- [X.SUPERUSER]: 3
1288
+ [J.USER]: 1,
1289
+ [J.TENANT_ADMIN]: 2,
1290
+ [J.SUPERUSER]: 3
1316
1291
  };
1317
1292
  return t[i] >= t[e];
1318
1293
  };
@@ -1323,19 +1298,19 @@ function it({
1323
1298
  requiredPermissions: r,
1324
1299
  requireAllPermissions: s = !1
1325
1300
  }) {
1326
- const { hasValidSession: a, sessionManager: x, hasPermission: d, hasAnyPermission: M, hasAllPermissions: P } = ee();
1301
+ const { hasValidSession: a, sessionManager: v, hasPermission: T, hasAnyPermission: M, hasAllPermissions: P } = se();
1327
1302
  if (!a())
1328
- return /* @__PURE__ */ n(U, { children: e || /* @__PURE__ */ n(de, {}) });
1329
- const g = x.getUser();
1303
+ return /* @__PURE__ */ n(B, { children: e || /* @__PURE__ */ n(de, {}) });
1304
+ const g = v.getUser();
1330
1305
  if (!g)
1331
- return /* @__PURE__ */ n(U, { children: e || /* @__PURE__ */ n(de, {}) });
1306
+ return /* @__PURE__ */ n(B, { children: e || /* @__PURE__ */ n(de, {}) });
1332
1307
  if (t && !Ie(g.userType, t))
1333
1308
  return /* @__PURE__ */ n(ue, { userType: g.userType, minUserType: t });
1334
1309
  if (r && r.length > 0 && !(s ? P(r) : M(r))) {
1335
- const b = r.filter((y) => !d(y)).map((y) => typeof y == "string" ? y : y.name);
1336
- return /* @__PURE__ */ n(ue, { missingPermissions: b });
1310
+ const x = r.filter((p) => !T(p)).map((p) => typeof p == "string" ? p : p.name);
1311
+ return /* @__PURE__ */ n(ue, { missingPermissions: x });
1337
1312
  }
1338
- return /* @__PURE__ */ n(U, { children: i });
1313
+ return /* @__PURE__ */ n(B, { children: i });
1339
1314
  }
1340
1315
  const He = ({ redirectPath: i }) => /* @__PURE__ */ n(
1341
1316
  "div",
@@ -1403,7 +1378,7 @@ const He = ({ redirectPath: i }) => /* @__PURE__ */ n(
1403
1378
  children: [
1404
1379
  /* @__PURE__ */ n("div", { style: { fontSize: "3rem", marginBottom: "1rem" }, children: "⚠️" }),
1405
1380
  /* @__PURE__ */ n("h2", { style: { color: "#374151", marginBottom: "1rem" }, children: "Insufficient Permissions" }),
1406
- e && i ? /* @__PURE__ */ u(U, { children: [
1381
+ e && i ? /* @__PURE__ */ u(B, { children: [
1407
1382
  /* @__PURE__ */ u("p", { style: { color: "#6b7280", marginBottom: "1rem" }, children: [
1408
1383
  "This page requires ",
1409
1384
  /* @__PURE__ */ n("strong", { children: e }),
@@ -1413,7 +1388,7 @@ const He = ({ redirectPath: i }) => /* @__PURE__ */ n(
1413
1388
  "Your current access level: ",
1414
1389
  /* @__PURE__ */ n("strong", { children: i })
1415
1390
  ] })
1416
- ] }) : /* @__PURE__ */ u(U, { children: [
1391
+ ] }) : /* @__PURE__ */ u(B, { children: [
1417
1392
  /* @__PURE__ */ n("p", { style: { color: "#6b7280", marginBottom: "1rem" }, children: "You don't have the required permissions to access this page." }),
1418
1393
  t && t.length > 0 && /* @__PURE__ */ u("p", { style: { color: "#9ca3af", fontSize: "0.875rem" }, children: [
1419
1394
  "Required permissions: ",
@@ -1426,9 +1401,9 @@ const He = ({ redirectPath: i }) => /* @__PURE__ */ n(
1426
1401
  }
1427
1402
  ), $e = (i, e) => {
1428
1403
  const t = {
1429
- [X.USER]: 1,
1430
- [X.TENANT_ADMIN]: 2,
1431
- [X.SUPERUSER]: 3
1404
+ [J.USER]: 1,
1405
+ [J.TENANT_ADMIN]: 2,
1406
+ [J.SUPERUSER]: 3
1432
1407
  };
1433
1408
  return t[i] >= t[e];
1434
1409
  };
@@ -1440,22 +1415,22 @@ function ot({
1440
1415
  requireAllPermissions: s = !1,
1441
1416
  fallback: a
1442
1417
  }) {
1443
- const { hasValidSession: x, sessionManager: d, hasPermission: M, hasAnyPermission: P, hasAllPermissions: g } = ee(), h = me();
1444
- if (!x())
1445
- return a ? /* @__PURE__ */ n(U, { children: a }) : /* @__PURE__ */ u(U, { children: [
1418
+ const { hasValidSession: v, sessionManager: T, hasPermission: M, hasAnyPermission: P, hasAllPermissions: g } = se(), h = me();
1419
+ if (!v())
1420
+ return a ? /* @__PURE__ */ n(B, { children: a }) : /* @__PURE__ */ u(B, { children: [
1446
1421
  /* @__PURE__ */ n(He, { redirectPath: e }),
1447
- /* @__PURE__ */ n(le, { to: e, state: { from: h.pathname }, replace: !0 })
1422
+ /* @__PURE__ */ n(ae, { to: e, state: { from: h.pathname }, replace: !0 })
1448
1423
  ] });
1449
- const b = d.getUser();
1450
- if (!b)
1451
- return /* @__PURE__ */ n(le, { to: e, state: { from: h.pathname }, replace: !0 });
1452
- if (t && !$e(b.userType, t))
1453
- return /* @__PURE__ */ n(he, { userType: b.userType, minUserType: t });
1424
+ const x = T.getUser();
1425
+ if (!x)
1426
+ return /* @__PURE__ */ n(ae, { to: e, state: { from: h.pathname }, replace: !0 });
1427
+ if (t && !$e(x.userType, t))
1428
+ return /* @__PURE__ */ n(he, { userType: x.userType, minUserType: t });
1454
1429
  if (r && r.length > 0 && !(s ? g(r) : P(r))) {
1455
- const S = r.filter(($) => !M($)).map(($) => typeof $ == "string" ? $ : $.name);
1456
- return /* @__PURE__ */ n(he, { missingPermissions: S });
1430
+ const A = r.filter((F) => !M(F)).map((F) => typeof F == "string" ? F : F.name);
1431
+ return /* @__PURE__ */ n(he, { missingPermissions: A });
1457
1432
  }
1458
- return /* @__PURE__ */ n(U, { children: i });
1433
+ return /* @__PURE__ */ n(B, { children: i });
1459
1434
  }
1460
1435
  const Ce = () => /* @__PURE__ */ u(
1461
1436
  "div",
@@ -1480,8 +1455,8 @@ function at({
1480
1455
  allowedPlans: t,
1481
1456
  requiredFeature: r
1482
1457
  }) {
1483
- const { subscription: s, hasAllowedPlan: a, isFeatureEnabled: x, loading: d } = Fe();
1484
- return d ? /* @__PURE__ */ n(
1458
+ const { subscription: s, hasAllowedPlan: a, isFeatureEnabled: v, loading: T } = Fe();
1459
+ return T ? /* @__PURE__ */ n(
1485
1460
  "div",
1486
1461
  {
1487
1462
  style: {
@@ -1491,7 +1466,7 @@ function at({
1491
1466
  },
1492
1467
  children: "Loading subscription..."
1493
1468
  }
1494
- ) : s ? s.isActive ? t && t.length > 0 && !a(t) ? /* @__PURE__ */ n(U, { children: e }) : r && !x(r) ? /* @__PURE__ */ n(U, { children: e }) : /* @__PURE__ */ n(U, { children: i }) : /* @__PURE__ */ n(U, { children: e }) : /* @__PURE__ */ n(U, { children: e });
1469
+ ) : s ? s.isActive ? t && t.length > 0 && !a(t) ? /* @__PURE__ */ n(B, { children: e }) : r && !v(r) ? /* @__PURE__ */ n(B, { children: e }) : /* @__PURE__ */ n(B, { children: i }) : /* @__PURE__ */ n(B, { children: e }) : /* @__PURE__ */ n(B, { children: e });
1495
1470
  }
1496
1471
  const Le = ({ flagName: i }) => /* @__PURE__ */ u(
1497
1472
  "div",
@@ -1535,7 +1510,7 @@ function lt({ name: i, children: e, fallback: t }) {
1535
1510
  },
1536
1511
  children: "Loading feature flags..."
1537
1512
  }
1538
- ) : (console.log(i, r(i)), r(i) ? /* @__PURE__ */ n(U, { children: e }) : /* @__PURE__ */ n(U, { children: t || /* @__PURE__ */ n(Le, { flagName: i }) }));
1513
+ ) : (console.log(i, r(i)), r(i) ? /* @__PURE__ */ n(B, { children: e }) : /* @__PURE__ */ n(B, { children: t || /* @__PURE__ */ n(Le, { flagName: i }) }));
1539
1514
  }
1540
1515
  const De = () => /* @__PURE__ */ u(
1541
1516
  "svg",
@@ -1571,10 +1546,10 @@ const De = () => /* @__PURE__ */ u(
1571
1546
  /* @__PURE__ */ n("line", { x1: "1", y1: "1", x2: "23", y2: "23" })
1572
1547
  ]
1573
1548
  }
1574
- ), qe = {
1549
+ ), Ue = {
1575
1550
  showPassword: /* @__PURE__ */ n(De, {}),
1576
1551
  hidePassword: /* @__PURE__ */ n(Be, {})
1577
- }, Ue = {
1552
+ }, qe = {
1578
1553
  title: "Sign In",
1579
1554
  emailLabel: "Email",
1580
1555
  emailPlaceholder: "Enter your email",
@@ -1700,44 +1675,44 @@ function ct({
1700
1675
  onSuccess: r,
1701
1676
  onError: s,
1702
1677
  onForgotPassword: a,
1703
- onSignupClick: x,
1704
- showForgotPassword: d = !0,
1678
+ onSignupClick: v,
1679
+ showForgotPassword: T = !0,
1705
1680
  showSignupLink: M = !0,
1706
1681
  className: P
1707
1682
  }) {
1708
- const [g, h] = m(""), [b, y] = m(""), [S, $] = m(!1), [p, D] = m(!1), [A, E] = m(""), [f, I] = m({}), { login: C } = ee(), { tenant: F } = Z(), B = { ...Ue, ...i }, w = { ...Ne, ...e }, O = { ...qe, ...t }, T = () => {
1709
- const c = {};
1710
- return g.trim() || (c.email = !0), b.trim() || (c.password = !0), I(c), Object.keys(c).length === 0;
1711
- }, o = async (c) => {
1712
- if (c.preventDefault(), !!T()) {
1713
- if (!(F != null && F.id)) {
1714
- E("Tenant not found");
1683
+ const [g, h] = m(""), [x, p] = m(""), [A, F] = m(!1), [f, C] = m(!1), [y, b] = m(""), [k, R] = m({}), { login: L } = se(), { tenant: E } = Z(), D = { ...qe, ...i }, c = { ...Ne, ...e }, w = { ...Ue, ...t }, d = () => {
1684
+ const I = {};
1685
+ return g.trim() || (I.email = !0), x.trim() || (I.password = !0), R(I), Object.keys(I).length === 0;
1686
+ }, o = async (I) => {
1687
+ if (I.preventDefault(), !!d()) {
1688
+ if (!(E != null && E.id)) {
1689
+ b("Tenant not found");
1715
1690
  return;
1716
1691
  }
1717
- D(!0), E("");
1692
+ C(!0), b("");
1718
1693
  try {
1719
- const k = await C(g, b, F.id);
1720
- r == null || r(k);
1721
- } catch (k) {
1722
- const W = k.message || B.errorMessage;
1723
- E(W), s == null || s(W);
1694
+ const N = await L(g, x, E.id);
1695
+ r == null || r(N);
1696
+ } catch (N) {
1697
+ const _ = N.message || D.errorMessage;
1698
+ b(_), s == null || s(_);
1724
1699
  } finally {
1725
- D(!1);
1700
+ C(!1);
1726
1701
  }
1727
1702
  }
1728
- }, l = (c) => ({
1729
- ...w.input,
1730
- ...f[c] ? w.inputError : {}
1731
- }), H = () => ({
1732
- ...w.button,
1733
- ...p ? w.buttonLoading : {},
1734
- ...!g || !b || p ? w.buttonDisabled : {}
1703
+ }, l = (I) => ({
1704
+ ...c.input,
1705
+ ...k[I] ? c.inputError : {}
1706
+ }), W = () => ({
1707
+ ...c.button,
1708
+ ...f ? c.buttonLoading : {},
1709
+ ...!g || !x || f ? c.buttonDisabled : {}
1735
1710
  });
1736
- return /* @__PURE__ */ u("div", { className: P, style: w.container, children: [
1737
- /* @__PURE__ */ n("h2", { style: w.title, children: B.title }),
1738
- /* @__PURE__ */ u("form", { onSubmit: o, style: w.form, children: [
1739
- /* @__PURE__ */ u("div", { style: w.fieldGroup, children: [
1740
- /* @__PURE__ */ n("label", { style: w.label, children: B.emailLabel }),
1711
+ return /* @__PURE__ */ u("div", { className: P, style: c.container, children: [
1712
+ /* @__PURE__ */ n("h2", { style: c.title, children: D.title }),
1713
+ /* @__PURE__ */ u("form", { onSubmit: o, style: c.form, children: [
1714
+ /* @__PURE__ */ u("div", { style: c.fieldGroup, children: [
1715
+ /* @__PURE__ */ n("label", { style: c.label, children: D.emailLabel }),
1741
1716
  /* @__PURE__ */ n(
1742
1717
  "input",
1743
1718
  {
@@ -1745,62 +1720,62 @@ function ct({
1745
1720
  name: "email",
1746
1721
  type: "email",
1747
1722
  value: g,
1748
- onChange: (c) => {
1749
- h(c.target.value), f.email && I((k) => ({ ...k, email: !1 }));
1723
+ onChange: (I) => {
1724
+ h(I.target.value), k.email && R((N) => ({ ...N, email: !1 }));
1750
1725
  },
1751
- placeholder: B.emailPlaceholder,
1726
+ placeholder: D.emailPlaceholder,
1752
1727
  style: l("email"),
1753
- disabled: p
1728
+ disabled: f
1754
1729
  }
1755
1730
  )
1756
1731
  ] }),
1757
- /* @__PURE__ */ u("div", { style: w.fieldGroup, children: [
1758
- /* @__PURE__ */ n("label", { style: w.label, children: B.passwordLabel }),
1759
- /* @__PURE__ */ u("div", { style: w.inputContainer, children: [
1732
+ /* @__PURE__ */ u("div", { style: c.fieldGroup, children: [
1733
+ /* @__PURE__ */ n("label", { style: c.label, children: D.passwordLabel }),
1734
+ /* @__PURE__ */ u("div", { style: c.inputContainer, children: [
1760
1735
  /* @__PURE__ */ n(
1761
1736
  "input",
1762
1737
  {
1763
1738
  id: "password",
1764
1739
  name: "password",
1765
- type: S ? "text" : "password",
1766
- value: b,
1767
- onChange: (c) => {
1768
- y(c.target.value), f.password && I((k) => ({ ...k, password: !1 }));
1740
+ type: A ? "text" : "password",
1741
+ value: x,
1742
+ onChange: (I) => {
1743
+ p(I.target.value), k.password && R((N) => ({ ...N, password: !1 }));
1769
1744
  },
1770
- placeholder: B.passwordPlaceholder,
1745
+ placeholder: D.passwordPlaceholder,
1771
1746
  style: {
1772
1747
  ...l("password"),
1773
1748
  paddingRight: "2.5rem"
1774
1749
  // Make room for the icon
1775
1750
  },
1776
- disabled: p
1751
+ disabled: f
1777
1752
  }
1778
1753
  ),
1779
1754
  /* @__PURE__ */ n(
1780
1755
  "button",
1781
1756
  {
1782
1757
  type: "button",
1783
- onClick: () => $(!S),
1784
- style: w.passwordToggle,
1785
- disabled: p,
1786
- "aria-label": S ? "Hide password" : "Show password",
1787
- children: S ? O.hidePassword : O.showPassword
1758
+ onClick: () => F(!A),
1759
+ style: c.passwordToggle,
1760
+ disabled: f,
1761
+ "aria-label": A ? "Hide password" : "Show password",
1762
+ children: A ? w.hidePassword : w.showPassword
1788
1763
  }
1789
1764
  )
1790
1765
  ] })
1791
1766
  ] }),
1792
- /* @__PURE__ */ n("button", { type: "submit", disabled: !g || !b || p, style: H(), children: p ? B.loadingText : B.submitButton }),
1793
- A && /* @__PURE__ */ n("div", { style: w.errorText, children: A })
1767
+ /* @__PURE__ */ n("button", { type: "submit", disabled: !g || !x || f, style: W(), children: f ? D.loadingText : D.submitButton }),
1768
+ y && /* @__PURE__ */ n("div", { style: c.errorText, children: y })
1794
1769
  ] }),
1795
- (d || M) && /* @__PURE__ */ u("div", { style: w.linkContainer, children: [
1796
- d && /* @__PURE__ */ n("a", { onClick: a, style: w.link, children: B.forgotPasswordLink }),
1797
- d && M && /* @__PURE__ */ n("div", { style: w.divider, children: "•" }),
1770
+ (T || M) && /* @__PURE__ */ u("div", { style: c.linkContainer, children: [
1771
+ T && /* @__PURE__ */ n("a", { onClick: a, style: c.link, children: D.forgotPasswordLink }),
1772
+ T && M && /* @__PURE__ */ n("div", { style: c.divider, children: "•" }),
1798
1773
  M && /* @__PURE__ */ u("div", { children: [
1799
- /* @__PURE__ */ u("span", { style: w.divider, children: [
1800
- B.signupText,
1774
+ /* @__PURE__ */ u("span", { style: c.divider, children: [
1775
+ D.signupText,
1801
1776
  " "
1802
1777
  ] }),
1803
- /* @__PURE__ */ n("a", { onClick: x, style: w.link, children: B.signupLink })
1778
+ /* @__PURE__ */ n("a", { onClick: v, style: c.link, children: D.signupLink })
1804
1779
  ] })
1805
1780
  ] })
1806
1781
  ] });
@@ -1931,46 +1906,46 @@ function dt({
1931
1906
  onSuccess: r,
1932
1907
  onError: s,
1933
1908
  onLoginClick: a,
1934
- showLoginLink: x = !0,
1935
- className: d
1909
+ showLoginLink: v = !0,
1910
+ className: T
1936
1911
  }) {
1937
- const [M, P] = m(""), [g, h] = m(""), [b, y] = m(""), [S, $] = m(""), [p, D] = m(""), [A, E] = m(!1), [f, I] = m(""), [C, F] = m({}), { signup: B, signupTenantAdmin: w } = ee(), { tenant: O } = Z(), T = { ...Oe, ...i }, o = { ...ze, ...e }, l = () => {
1938
- const R = {};
1939
- return M.trim() || (R.name = !0), g.trim() || (R.email = !0), b.trim() || (R.password = !0), S.trim() || (R.confirmPassword = !0), t === "tenant" && !p.trim() && (R.tenantName = !0), F(R), Object.keys(R).length === 0;
1940
- }, H = async (R) => {
1941
- if (R.preventDefault(), !!l()) {
1942
- if (b !== S) {
1943
- I(T.passwordMismatchError), F({ confirmPassword: !0 });
1912
+ const [M, P] = m(""), [g, h] = m(""), [x, p] = m(""), [A, F] = m(""), [f, C] = m(""), [y, b] = m(!1), [k, R] = m(""), [L, E] = m({}), { signup: D, signupTenantAdmin: c } = se(), { tenant: w } = Z(), d = { ...Oe, ...i }, o = { ...ze, ...e }, l = () => {
1913
+ const H = {};
1914
+ return M.trim() || (H.name = !0), g.trim() || (H.email = !0), x.trim() || (H.password = !0), A.trim() || (H.confirmPassword = !0), t === "tenant" && !f.trim() && (H.tenantName = !0), E(H), Object.keys(H).length === 0;
1915
+ }, W = async (H) => {
1916
+ if (H.preventDefault(), !!l()) {
1917
+ if (x !== A) {
1918
+ R(d.passwordMismatchError), E({ confirmPassword: !0 });
1944
1919
  return;
1945
1920
  }
1946
- if (t === "user" && !(O != null && O.id)) {
1947
- I("Tenant not found");
1921
+ if (t === "user" && !(w != null && w.id)) {
1922
+ R("Tenant not found");
1948
1923
  return;
1949
1924
  }
1950
- E(!0), I("");
1925
+ b(!0), R("");
1951
1926
  try {
1952
1927
  let q;
1953
- t === "tenant" ? q = await w(g, M, b, p) : q = await B(g, M, b, O.id), r == null || r(q);
1928
+ t === "tenant" ? q = await c(g, M, x, f) : q = await D(g, M, x, w.id), r == null || r(q);
1954
1929
  } catch (q) {
1955
- const Y = q.message || T.errorMessage;
1956
- I(Y), s == null || s(Y);
1930
+ const Y = q.message || d.errorMessage;
1931
+ R(Y), s == null || s(Y);
1957
1932
  } finally {
1958
- E(!1);
1933
+ b(!1);
1959
1934
  }
1960
1935
  }
1961
- }, c = (R) => ({
1936
+ }, I = (H) => ({
1962
1937
  ...o.input,
1963
- ...C[R] ? o.inputError : {}
1964
- }), k = () => ({
1938
+ ...L[H] ? o.inputError : {}
1939
+ }), N = () => ({
1965
1940
  ...o.button,
1966
- ...A ? o.buttonLoading : {},
1967
- ...!M || !g || !b || !S || A || t === "tenant" && !p ? o.buttonDisabled : {}
1968
- }), W = M && g && b && S && (t === "user" || p);
1969
- return /* @__PURE__ */ u("div", { className: d, style: o.container, children: [
1970
- /* @__PURE__ */ n("h2", { style: o.title, children: T.title }),
1971
- /* @__PURE__ */ u("form", { onSubmit: H, style: o.form, children: [
1941
+ ...y ? o.buttonLoading : {},
1942
+ ...!M || !g || !x || !A || y || t === "tenant" && !f ? o.buttonDisabled : {}
1943
+ }), _ = M && g && x && A && (t === "user" || f);
1944
+ return /* @__PURE__ */ u("div", { className: T, style: o.container, children: [
1945
+ /* @__PURE__ */ n("h2", { style: o.title, children: d.title }),
1946
+ /* @__PURE__ */ u("form", { onSubmit: W, style: o.form, children: [
1972
1947
  /* @__PURE__ */ u("div", { style: o.fieldGroup, children: [
1973
- /* @__PURE__ */ n("label", { style: o.label, children: T.nameLabel }),
1948
+ /* @__PURE__ */ n("label", { style: o.label, children: d.nameLabel }),
1974
1949
  /* @__PURE__ */ n(
1975
1950
  "input",
1976
1951
  {
@@ -1978,17 +1953,17 @@ function dt({
1978
1953
  name: "name",
1979
1954
  type: "text",
1980
1955
  value: M,
1981
- onChange: (R) => {
1982
- P(R.target.value), C.name && F((q) => ({ ...q, name: !1 }));
1956
+ onChange: (H) => {
1957
+ P(H.target.value), L.name && E((q) => ({ ...q, name: !1 }));
1983
1958
  },
1984
- placeholder: T.namePlaceholder,
1985
- style: c("name"),
1986
- disabled: A
1959
+ placeholder: d.namePlaceholder,
1960
+ style: I("name"),
1961
+ disabled: y
1987
1962
  }
1988
1963
  )
1989
1964
  ] }),
1990
1965
  /* @__PURE__ */ u("div", { style: o.fieldGroup, children: [
1991
- /* @__PURE__ */ n("label", { style: o.label, children: T.emailLabel }),
1966
+ /* @__PURE__ */ n("label", { style: o.label, children: d.emailLabel }),
1992
1967
  /* @__PURE__ */ n(
1993
1968
  "input",
1994
1969
  {
@@ -1996,78 +1971,78 @@ function dt({
1996
1971
  name: "email",
1997
1972
  type: "email",
1998
1973
  value: g,
1999
- onChange: (R) => {
2000
- h(R.target.value), C.email && F((q) => ({ ...q, email: !1 }));
1974
+ onChange: (H) => {
1975
+ h(H.target.value), L.email && E((q) => ({ ...q, email: !1 }));
2001
1976
  },
2002
- placeholder: T.emailPlaceholder,
2003
- style: c("email"),
2004
- disabled: A
1977
+ placeholder: d.emailPlaceholder,
1978
+ style: I("email"),
1979
+ disabled: y
2005
1980
  }
2006
1981
  )
2007
1982
  ] }),
2008
1983
  /* @__PURE__ */ u("div", { style: o.fieldGroup, children: [
2009
- /* @__PURE__ */ n("label", { style: o.label, children: T.passwordLabel }),
1984
+ /* @__PURE__ */ n("label", { style: o.label, children: d.passwordLabel }),
2010
1985
  /* @__PURE__ */ n(
2011
1986
  "input",
2012
1987
  {
2013
1988
  id: "password",
2014
1989
  name: "password",
2015
1990
  type: "password",
2016
- value: b,
2017
- onChange: (R) => {
2018
- y(R.target.value), C.password && F((q) => ({ ...q, password: !1 }));
1991
+ value: x,
1992
+ onChange: (H) => {
1993
+ p(H.target.value), L.password && E((q) => ({ ...q, password: !1 }));
2019
1994
  },
2020
- placeholder: T.passwordPlaceholder,
2021
- style: c("password"),
2022
- disabled: A
1995
+ placeholder: d.passwordPlaceholder,
1996
+ style: I("password"),
1997
+ disabled: y
2023
1998
  }
2024
1999
  )
2025
2000
  ] }),
2026
2001
  /* @__PURE__ */ u("div", { style: o.fieldGroup, children: [
2027
- /* @__PURE__ */ n("label", { style: o.label, children: T.confirmPasswordLabel }),
2002
+ /* @__PURE__ */ n("label", { style: o.label, children: d.confirmPasswordLabel }),
2028
2003
  /* @__PURE__ */ n(
2029
2004
  "input",
2030
2005
  {
2031
2006
  id: "confirmPassword",
2032
2007
  name: "confirmPassword",
2033
2008
  type: "password",
2034
- value: S,
2035
- onChange: (R) => {
2036
- $(R.target.value), C.confirmPassword && F((q) => ({ ...q, confirmPassword: !1 })), f === T.passwordMismatchError && I("");
2009
+ value: A,
2010
+ onChange: (H) => {
2011
+ F(H.target.value), L.confirmPassword && E((q) => ({ ...q, confirmPassword: !1 })), k === d.passwordMismatchError && R("");
2037
2012
  },
2038
- placeholder: T.confirmPasswordPlaceholder,
2039
- style: c("confirmPassword"),
2040
- disabled: A
2013
+ placeholder: d.confirmPasswordPlaceholder,
2014
+ style: I("confirmPassword"),
2015
+ disabled: y
2041
2016
  }
2042
2017
  )
2043
2018
  ] }),
2044
2019
  t === "tenant" && /* @__PURE__ */ u("div", { style: o.fieldGroup, children: [
2045
- /* @__PURE__ */ n("label", { style: o.label, children: T.tenantNameLabel }),
2020
+ /* @__PURE__ */ n("label", { style: o.label, children: d.tenantNameLabel }),
2046
2021
  /* @__PURE__ */ n(
2047
2022
  "input",
2048
2023
  {
2049
2024
  id: "tenantName",
2050
2025
  name: "tenantName",
2051
2026
  type: "text",
2052
- value: p,
2053
- onChange: (R) => {
2054
- D(R.target.value), C.tenantName && F((q) => ({ ...q, tenantName: !1 }));
2027
+ value: f,
2028
+ onChange: (H) => {
2029
+ C(H.target.value), L.tenantName && E((q) => ({ ...q, tenantName: !1 }));
2055
2030
  },
2056
- placeholder: T.tenantNamePlaceholder,
2057
- style: c("tenantName"),
2058
- disabled: A
2031
+ placeholder: d.tenantNamePlaceholder,
2032
+ style: I("tenantName"),
2033
+ disabled: y
2059
2034
  }
2060
2035
  )
2061
2036
  ] }),
2062
- /* @__PURE__ */ n("button", { type: "submit", disabled: !W || A, style: k(), children: A ? T.loadingText : T.submitButton }),
2063
- f && /* @__PURE__ */ n("div", { style: o.errorText, children: f })
2037
+ /* @__PURE__ */ n("button", { type: "submit", disabled: !_ || y, style: N(), children: y ? d.loadingText : d.submitButton }),
2038
+ k && /* @__PURE__ */ n("div", { style: o.errorText, children: k })
2064
2039
  ] }),
2065
- x && /* @__PURE__ */ u("div", { style: o.linkContainer, children: [
2040
+ v && /* @__PURE__ */ u("div", { style: o.linkContainer, children: [
2066
2041
  /* @__PURE__ */ u("span", { style: o.divider, children: [
2067
- T.loginText,
2042
+ d.loginText,
2068
2043
  " "
2069
2044
  ] }),
2070
- /* @__PURE__ */ n("a", { onClick: a, style: o.link, children: T.loginLink })
2045
+ /* @__PURE__ */ n("a", { onClick: a, style: o.link, children: d.loginLink })
2071
2046
  ] })
2072
2047
  ] });
2073
2048
  }
@@ -2192,61 +2167,61 @@ function ut({
2192
2167
  token: r = "",
2193
2168
  onSuccess: s,
2194
2169
  onError: a,
2195
- onBackToLogin: x,
2196
- onModeChange: d,
2170
+ onBackToLogin: v,
2171
+ onModeChange: T,
2197
2172
  className: M
2198
2173
  }) {
2199
- const [P, g] = m(""), [h, b] = m(r), [y, S] = m(""), [$, p] = m(""), [D, A] = m(!1), [E, f] = m(""), [I, C] = m(""), [F, B] = m({}), { requestPasswordReset: w, confirmPasswordReset: O } = ee(), { tenant: T } = Z(), o = { ...je, ...i }, l = { ...Ve, ...e }, H = () => {
2200
- const N = {};
2201
- return P.trim() || (N.email = !0), B(N), Object.keys(N).length === 0;
2202
- }, c = () => {
2203
- const N = {};
2204
- return h.trim() || (N.token = !0), y.trim() || (N.newPassword = !0), $.trim() || (N.confirmPassword = !0), B(N), Object.keys(N).length === 0;
2205
- }, k = async (N) => {
2206
- if (N.preventDefault(), !!H()) {
2207
- if (!(T != null && T.id)) {
2208
- f("Tenant not found");
2174
+ const [P, g] = m(""), [h, x] = m(r), [p, A] = m(""), [F, f] = m(""), [C, y] = m(!1), [b, k] = m(""), [R, L] = m(""), [E, D] = m({}), { requestPasswordReset: c, confirmPasswordReset: w } = se(), { tenant: d } = Z(), o = { ...je, ...i }, l = { ...Ve, ...e }, W = () => {
2175
+ const U = {};
2176
+ return P.trim() || (U.email = !0), D(U), Object.keys(U).length === 0;
2177
+ }, I = () => {
2178
+ const U = {};
2179
+ return h.trim() || (U.token = !0), p.trim() || (U.newPassword = !0), F.trim() || (U.confirmPassword = !0), D(U), Object.keys(U).length === 0;
2180
+ }, N = async (U) => {
2181
+ if (U.preventDefault(), !!W()) {
2182
+ if (!(d != null && d.id)) {
2183
+ k("Tenant not found");
2209
2184
  return;
2210
2185
  }
2211
- A(!0), f(""), C("");
2186
+ y(!0), k(""), L("");
2212
2187
  try {
2213
- await w(P, T.id), C(o.successMessage), s == null || s();
2214
- } catch (j) {
2215
- const V = j.message || o.errorMessage;
2216
- f(V), a == null || a(V);
2188
+ await c(P, d.id), L(o.successMessage), s == null || s();
2189
+ } catch (z) {
2190
+ const j = z.message || o.errorMessage;
2191
+ k(j), a == null || a(j);
2217
2192
  } finally {
2218
- A(!1);
2193
+ y(!1);
2219
2194
  }
2220
2195
  }
2221
- }, W = async (N) => {
2222
- if (N.preventDefault(), !!c()) {
2223
- if (y !== $) {
2224
- f(o.passwordMismatchError), B({ confirmPassword: !0 });
2196
+ }, _ = async (U) => {
2197
+ if (U.preventDefault(), !!I()) {
2198
+ if (p !== F) {
2199
+ k(o.passwordMismatchError), D({ confirmPassword: !0 });
2225
2200
  return;
2226
2201
  }
2227
- A(!0), f(""), C("");
2202
+ y(!0), k(""), L("");
2228
2203
  try {
2229
- await O(h, y), C(o.resetSuccessMessage), s == null || s();
2230
- } catch (j) {
2231
- const V = j.message || o.errorMessage;
2232
- f(V), a == null || a(V);
2204
+ await w(h, p), L(o.resetSuccessMessage), s == null || s();
2205
+ } catch (z) {
2206
+ const j = z.message || o.errorMessage;
2207
+ k(j), a == null || a(j);
2233
2208
  } finally {
2234
- A(!1);
2209
+ y(!1);
2235
2210
  }
2236
2211
  }
2237
- }, R = (N) => ({
2212
+ }, H = (U) => ({
2238
2213
  ...l.input,
2239
- ...F[N] ? l.inputError : {}
2214
+ ...E[U] ? l.inputError : {}
2240
2215
  }), q = () => ({
2241
2216
  ...l.button,
2242
- ...D ? l.buttonLoading : {}
2217
+ ...C ? l.buttonLoading : {}
2243
2218
  });
2244
2219
  if (t === "reset") {
2245
- const N = h && y && $;
2220
+ const U = h && p && F;
2246
2221
  return /* @__PURE__ */ u("div", { className: M, style: l.container, children: [
2247
2222
  /* @__PURE__ */ n("h2", { style: l.title, children: o.resetTitle }),
2248
2223
  /* @__PURE__ */ n("p", { style: l.subtitle, children: o.resetSubtitle }),
2249
- /* @__PURE__ */ u("form", { onSubmit: W, style: l.form, children: [
2224
+ /* @__PURE__ */ u("form", { onSubmit: _, style: l.form, children: [
2250
2225
  /* @__PURE__ */ u("div", { style: l.fieldGroup, children: [
2251
2226
  /* @__PURE__ */ n("label", { style: l.label, children: o.tokenLabel }),
2252
2227
  /* @__PURE__ */ n(
@@ -2254,12 +2229,12 @@ function ut({
2254
2229
  {
2255
2230
  type: "text",
2256
2231
  value: h,
2257
- onChange: (j) => {
2258
- b(j.target.value), F.token && B((V) => ({ ...V, token: !1 }));
2232
+ onChange: (z) => {
2233
+ x(z.target.value), E.token && D((j) => ({ ...j, token: !1 }));
2259
2234
  },
2260
2235
  placeholder: o.tokenPlaceholder,
2261
- style: R("token"),
2262
- disabled: D
2236
+ style: H("token"),
2237
+ disabled: C
2263
2238
  }
2264
2239
  )
2265
2240
  ] }),
@@ -2269,13 +2244,13 @@ function ut({
2269
2244
  "input",
2270
2245
  {
2271
2246
  type: "password",
2272
- value: y,
2273
- onChange: (j) => {
2274
- S(j.target.value), F.newPassword && B((V) => ({ ...V, newPassword: !1 }));
2247
+ value: p,
2248
+ onChange: (z) => {
2249
+ A(z.target.value), E.newPassword && D((j) => ({ ...j, newPassword: !1 }));
2275
2250
  },
2276
2251
  placeholder: o.newPasswordPlaceholder,
2277
- style: R("newPassword"),
2278
- disabled: D
2252
+ style: H("newPassword"),
2253
+ disabled: C
2279
2254
  }
2280
2255
  )
2281
2256
  ] }),
@@ -2285,13 +2260,13 @@ function ut({
2285
2260
  "input",
2286
2261
  {
2287
2262
  type: "password",
2288
- value: $,
2289
- onChange: (j) => {
2290
- p(j.target.value), F.confirmPassword && B((V) => ({ ...V, confirmPassword: !1 })), E === o.passwordMismatchError && f("");
2263
+ value: F,
2264
+ onChange: (z) => {
2265
+ f(z.target.value), E.confirmPassword && D((j) => ({ ...j, confirmPassword: !1 })), b === o.passwordMismatchError && k("");
2291
2266
  },
2292
2267
  placeholder: o.confirmPasswordPlaceholder,
2293
- style: R("confirmPassword"),
2294
- disabled: D
2268
+ style: H("confirmPassword"),
2269
+ disabled: C
2295
2270
  }
2296
2271
  )
2297
2272
  ] }),
@@ -2299,22 +2274,22 @@ function ut({
2299
2274
  "button",
2300
2275
  {
2301
2276
  type: "submit",
2302
- disabled: !N || D,
2277
+ disabled: !U || C,
2303
2278
  style: {
2304
2279
  ...q(),
2305
- ...!N || D ? l.buttonDisabled : {}
2280
+ ...!U || C ? l.buttonDisabled : {}
2306
2281
  },
2307
- children: D ? o.resetLoadingText : o.resetSubmitButton
2282
+ children: C ? o.resetLoadingText : o.resetSubmitButton
2308
2283
  }
2309
2284
  ),
2310
- E && /* @__PURE__ */ n("div", { style: l.errorText, children: E }),
2311
- I && /* @__PURE__ */ n("div", { style: l.successText, children: I })
2285
+ b && /* @__PURE__ */ n("div", { style: l.errorText, children: b }),
2286
+ R && /* @__PURE__ */ n("div", { style: l.successText, children: R })
2312
2287
  ] }),
2313
2288
  /* @__PURE__ */ u("div", { style: l.linkContainer, children: [
2314
- /* @__PURE__ */ n("a", { onClick: x, style: l.link, children: o.backToLoginLink }),
2315
- d && /* @__PURE__ */ u(U, { children: [
2289
+ /* @__PURE__ */ n("a", { onClick: v, style: l.link, children: o.backToLoginLink }),
2290
+ T && /* @__PURE__ */ u(B, { children: [
2316
2291
  /* @__PURE__ */ n("span", { style: { margin: "0 0.5rem", color: "#6b7280" }, children: "•" }),
2317
- /* @__PURE__ */ n("a", { onClick: () => d("request"), style: l.link, children: "Request New Link" })
2292
+ /* @__PURE__ */ n("a", { onClick: () => T("request"), style: l.link, children: "Request New Link" })
2318
2293
  ] })
2319
2294
  ] })
2320
2295
  ] });
@@ -2323,7 +2298,7 @@ function ut({
2323
2298
  return /* @__PURE__ */ u("div", { className: M, style: l.container, children: [
2324
2299
  /* @__PURE__ */ n("h2", { style: l.title, children: o.title }),
2325
2300
  /* @__PURE__ */ n("p", { style: l.subtitle, children: o.subtitle }),
2326
- /* @__PURE__ */ u("form", { onSubmit: k, style: l.form, children: [
2301
+ /* @__PURE__ */ u("form", { onSubmit: N, style: l.form, children: [
2327
2302
  /* @__PURE__ */ u("div", { style: l.fieldGroup, children: [
2328
2303
  /* @__PURE__ */ n("label", { style: l.label, children: o.emailLabel }),
2329
2304
  /* @__PURE__ */ n(
@@ -2331,12 +2306,12 @@ function ut({
2331
2306
  {
2332
2307
  type: "email",
2333
2308
  value: P,
2334
- onChange: (N) => {
2335
- g(N.target.value), F.email && B((j) => ({ ...j, email: !1 }));
2309
+ onChange: (U) => {
2310
+ g(U.target.value), E.email && D((z) => ({ ...z, email: !1 }));
2336
2311
  },
2337
2312
  placeholder: o.emailPlaceholder,
2338
- style: R("email"),
2339
- disabled: D
2313
+ style: H("email"),
2314
+ disabled: C
2340
2315
  }
2341
2316
  )
2342
2317
  ] }),
@@ -2344,22 +2319,22 @@ function ut({
2344
2319
  "button",
2345
2320
  {
2346
2321
  type: "submit",
2347
- disabled: !Y || D,
2322
+ disabled: !Y || C,
2348
2323
  style: {
2349
2324
  ...q(),
2350
- ...!Y || D ? l.buttonDisabled : {}
2325
+ ...!Y || C ? l.buttonDisabled : {}
2351
2326
  },
2352
- children: D ? o.loadingText : o.submitButton
2327
+ children: C ? o.loadingText : o.submitButton
2353
2328
  }
2354
2329
  ),
2355
- E && /* @__PURE__ */ n("div", { style: l.errorText, children: E }),
2356
- I && /* @__PURE__ */ n("div", { style: l.successText, children: I })
2330
+ b && /* @__PURE__ */ n("div", { style: l.errorText, children: b }),
2331
+ R && /* @__PURE__ */ n("div", { style: l.successText, children: R })
2357
2332
  ] }),
2358
2333
  /* @__PURE__ */ u("div", { style: l.linkContainer, children: [
2359
- /* @__PURE__ */ n("a", { onClick: x, style: l.link, children: o.backToLoginLink }),
2360
- d && /* @__PURE__ */ u(U, { children: [
2334
+ /* @__PURE__ */ n("a", { onClick: v, style: l.link, children: o.backToLoginLink }),
2335
+ T && /* @__PURE__ */ u(B, { children: [
2361
2336
  /* @__PURE__ */ n("span", { style: { margin: "0 0.5rem", color: "#6b7280" }, children: "•" }),
2362
- /* @__PURE__ */ n("a", { onClick: () => d("reset"), style: l.link, children: "I have a token" })
2337
+ /* @__PURE__ */ n("a", { onClick: () => T("reset"), style: l.link, children: "I have a token" })
2363
2338
  ] })
2364
2339
  ] })
2365
2340
  ] });
@@ -2624,30 +2599,30 @@ export {
2624
2599
  Me as FeatureFlagApiService,
2625
2600
  st as FeatureFlagProvider,
2626
2601
  pt as HealthApiService,
2627
- _ as HttpService,
2602
+ G as HttpService,
2628
2603
  ct as LoginForm,
2629
2604
  ut as PasswordRecoveryForm,
2630
2605
  ht as PermissionApiService,
2631
2606
  it as Protected,
2632
2607
  ot as ProtectedRoute,
2633
- ce as RoleApiService,
2608
+ le as RoleApiService,
2634
2609
  xe as SessionManager,
2635
2610
  dt as SignupForm,
2636
2611
  Re as SubscriptionApiService,
2637
2612
  at as SubscriptionGuard,
2638
2613
  gt as SubscriptionPlanApiService,
2639
2614
  nt as SubscriptionProvider,
2640
- oe as TenantApiService,
2615
+ ce as TenantApiService,
2641
2616
  Ze as TenantProvider,
2642
2617
  Pe as UserApiService,
2643
- X as UserType,
2618
+ J as UserType,
2644
2619
  Xe as useApi,
2645
- se as useApp,
2646
- ee as useAuth,
2620
+ re as useApp,
2621
+ se as useAuth,
2647
2622
  Ee as useFeatureFlags,
2648
2623
  tt as useSettings,
2649
2624
  Fe as useSubscription,
2650
- ae as useTenant,
2625
+ oe as useTenant,
2651
2626
  Z as useTenantInfo,
2652
2627
  et as useTenantSettings
2653
2628
  };