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