@skylabs-digital/react-identity-access 2.10.0 → 2.10.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4,10 +4,10 @@ import { UserType, Permission } from '../types/api';
4
4
  export interface ProtectedRouteProps {
5
5
  children: ReactNode;
6
6
  redirectTo?: string;
7
- minUserType?: UserType;
7
+ requiredUserType?: UserType;
8
8
  requiredPermissions?: (string | Permission)[];
9
9
  requireAllPermissions?: boolean;
10
10
  fallback?: ReactNode;
11
11
  }
12
- export declare function ProtectedRoute({ children, redirectTo, minUserType, requiredPermissions, requireAllPermissions, fallback, }: ProtectedRouteProps): import("react/jsx-runtime").JSX.Element;
12
+ export declare function ProtectedRoute({ children, redirectTo, requiredUserType, requiredPermissions, requireAllPermissions, fallback, }: ProtectedRouteProps): import("react/jsx-runtime").JSX.Element;
13
13
  //# sourceMappingURL=ProtectedRoute.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ProtectedRoute.d.ts","sourceRoot":"","sources":["../../src/components/ProtectedRoute.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAGlC,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAEpD,MAAM,WAAW,mBAAmB;IAClC,QAAQ,EAAE,SAAS,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,QAAQ,CAAC;IACvB,mBAAmB,CAAC,EAAE,CAAC,MAAM,GAAG,UAAU,CAAC,EAAE,CAAC;IAC9C,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB;AAsGD,wBAAgB,cAAc,CAAC,EAC7B,QAAQ,EACR,UAAqB,EACrB,WAAW,EACX,mBAAmB,EACnB,qBAA6B,EAC7B,QAAQ,GACT,EAAE,mBAAmB,2CAiDrB"}
1
+ {"version":3,"file":"ProtectedRoute.d.ts","sourceRoot":"","sources":["../../src/components/ProtectedRoute.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAGlC,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAEpD,MAAM,WAAW,mBAAmB;IAClC,QAAQ,EAAE,SAAS,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,gBAAgB,CAAC,EAAE,QAAQ,CAAC;IAC5B,mBAAmB,CAAC,EAAE,CAAC,MAAM,GAAG,UAAU,CAAC,EAAE,CAAC;IAC9C,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB;AAgGD,wBAAgB,cAAc,CAAC,EAC7B,QAAQ,EACR,UAAqB,EACrB,gBAAgB,EAChB,mBAAmB,EACnB,qBAA6B,EAC7B,QAAQ,GACT,EAAE,mBAAmB,2CAsDrB"}
package/dist/index.es.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { jsx as n, Fragment as j, jsxs as d } from "react/jsx-runtime";
2
- import { createContext as he, useMemo as te, useState as k, useCallback as ie, useEffect as re, useContext as se, useRef as Ne } from "react";
2
+ import { createContext as ue, useMemo as te, useState as k, useCallback as ie, useEffect as re, useContext as se, useRef as Ne } from "react";
3
3
  import { useLocation as Te, Navigate as fe } from "react-router-dom";
4
4
  class ne {
5
5
  // SessionManager instance
@@ -124,7 +124,7 @@ class Fe {
124
124
  })).data;
125
125
  }
126
126
  }
127
- const xe = he(null);
127
+ const xe = ue(null);
128
128
  function Jt({ config: i, children: e }) {
129
129
  const t = te(
130
130
  () => {
@@ -209,7 +209,7 @@ function Jt({ config: i, children: e }) {
209
209
  r ? S() : g();
210
210
  }, []), /* @__PURE__ */ n(xe.Provider, { value: b, children: e });
211
211
  }
212
- function ge() {
212
+ function he() {
213
213
  const i = se(xe);
214
214
  if (!i)
215
215
  throw new Error("useApp must be used within an AppProvider");
@@ -218,7 +218,7 @@ function ge() {
218
218
  function Ue() {
219
219
  return se(xe);
220
220
  }
221
- const Kt = ge;
221
+ const Kt = he;
222
222
  class ke {
223
223
  constructor(e = {}) {
224
224
  this.refreshPromise = null, this.refreshQueue = [], e.tenantSlug !== void 0 ? this.storageKey = e.tenantSlug ? `auth_tokens_${e.tenantSlug}` : "auth_tokens" : this.storageKey = e.storageKey || "auth_tokens", this.autoRefresh = e.autoRefresh ?? !0, this.refreshThreshold = e.refreshThreshold || 3e5, this.onRefreshFailed = e.onRefreshFailed, this.baseUrl = e.baseUrl || "", this.tokenStorage = e.tokenStorage || this.createTokenStorage(this.storageKey);
@@ -544,7 +544,7 @@ class rt {
544
544
  });
545
545
  }
546
546
  }
547
- class ue {
547
+ class de {
548
548
  constructor(e, t, r) {
549
549
  this.httpService = e, this.appId = t, this.sessionManager = r;
550
550
  }
@@ -693,9 +693,9 @@ function dt() {
693
693
  newUrl: i.toString()
694
694
  }), window.history.replaceState({}, "", i.toString());
695
695
  }
696
- const Ae = he(null);
696
+ const Ae = ue(null);
697
697
  function Yt({ config: i, children: e }) {
698
- const { baseUrl: t, appInfo: r, appId: s } = ge(), o = ie(() => typeof window > "u" ? null : it(
698
+ const { baseUrl: t, appInfo: r, appId: s } = he(), o = ie(() => typeof window > "u" ? null : it(
699
699
  {
700
700
  tenantMode: i.tenantMode || "selector",
701
701
  baseDomain: i.baseDomain,
@@ -738,7 +738,7 @@ function Yt({ config: i, children: e }) {
738
738
  if (!(!H && y.enabled && b && b.domain === l))
739
739
  try {
740
740
  f(!0), I(null);
741
- const M = new ne(t), u = await new ue(M, s).getPublicTenantInfo(l);
741
+ const M = new ne(t), u = await new de(M, s).getPublicTenantInfo(l);
742
742
  if (g(u), y.enabled)
743
743
  try {
744
744
  const w = {
@@ -765,14 +765,14 @@ function Yt({ config: i, children: e }) {
765
765
  if (!l) return;
766
766
  const H = JSON.parse(l);
767
767
  if (Date.now() - H.timestamp > y.ttl * 0.5) {
768
- const p = new ne(t), w = await new ue(p, s).getPublicTenantInfo(a);
768
+ const p = new ne(t), w = await new de(p, s).getPublicTenantInfo(a);
769
769
  g(w);
770
- const G = {
770
+ const _ = {
771
771
  data: w,
772
772
  timestamp: Date.now(),
773
773
  tenantSlug: a
774
774
  };
775
- localStorage.setItem(y.storageKey, JSON.stringify(G));
775
+ localStorage.setItem(y.storageKey, JSON.stringify(_));
776
776
  }
777
777
  } catch (l) {
778
778
  console.warn("Background tenant refresh failed:", l);
@@ -781,7 +781,7 @@ function Yt({ config: i, children: e }) {
781
781
  if (b != null && b.id)
782
782
  try {
783
783
  h(!0), A(null);
784
- const l = new ne(t), M = await new ue(l, b.appId).getTenantSettings(b.id);
784
+ const l = new ne(t), M = await new de(l, b.appId).getTenantSettings(b.id);
785
785
  R(M);
786
786
  } catch (l) {
787
787
  const H = l instanceof Error ? l : new Error("Failed to load tenant settings");
@@ -806,8 +806,8 @@ function Yt({ config: i, children: e }) {
806
806
  }
807
807
  if (u != null) {
808
808
  if (p.type) {
809
- const G = p.type, K = typeof u;
810
- G === "string" && K !== "string" ? H.push(`Field '${M}' must be a string`) : (G === "number" || G === "integer") && K !== "number" ? H.push(`Field '${M}' must be a number`) : G === "boolean" && K !== "boolean" ? H.push(`Field '${M}' must be a boolean`) : G === "array" && !Array.isArray(u) && H.push(`Field '${M}' must be an array`);
809
+ const _ = p.type, K = typeof u;
810
+ _ === "string" && K !== "string" ? H.push(`Field '${M}' must be a string`) : (_ === "number" || _ === "integer") && K !== "number" ? H.push(`Field '${M}' must be a number`) : _ === "boolean" && K !== "boolean" ? H.push(`Field '${M}' must be a boolean`) : _ === "array" && !Array.isArray(u) && H.push(`Field '${M}' must be an array`);
811
811
  }
812
812
  p.minLength !== void 0 && typeof u == "string" && u.length < p.minLength && H.push(
813
813
  `Field '${M}' must be at least ${p.minLength} characters long`
@@ -837,15 +837,15 @@ function Yt({ config: i, children: e }) {
837
837
  (l, H) => {
838
838
  const { mode: M = "reload", tokens: p, redirectPath: u } = H || {}, w = i.tenantMode || "selector";
839
839
  if (localStorage.setItem("tenant", l), w === "subdomain") {
840
- const G = window.location.hostname, K = ot(
840
+ const _ = window.location.hostname, K = ot(
841
841
  l,
842
- G,
842
+ _,
843
843
  i.baseDomain
844
844
  );
845
845
  if (!K) {
846
846
  console.warn(
847
847
  "[TenantProvider] Cannot switch subdomain, invalid hostname:",
848
- G
848
+ _
849
849
  );
850
850
  return;
851
851
  }
@@ -854,12 +854,12 @@ function Yt({ config: i, children: e }) {
854
854
  J !== me && q.searchParams.set(J, v);
855
855
  }), p && q.searchParams.set(me, at(p)), window.location.href = q.toString();
856
856
  } else if (w === "selector") {
857
- const G = u || window.location.pathname, K = new URLSearchParams(window.location.search);
857
+ const _ = u || window.location.pathname, K = new URLSearchParams(window.location.search);
858
858
  if (K.set(i.selectorParam || "tenant", l), M === "reload") {
859
- const U = `${G}?${K.toString()}${window.location.hash}`;
859
+ const U = `${_}?${K.toString()}${window.location.hash}`;
860
860
  window.location.href = U;
861
861
  } else {
862
- const U = `${G}?${K.toString()}${window.location.hash}`;
862
+ const U = `${_}?${K.toString()}${window.location.hash}`;
863
863
  window.history.pushState({}, "", U), m(l), N(l);
864
864
  }
865
865
  }
@@ -919,7 +919,7 @@ function Xt() {
919
919
  validateSettings: s
920
920
  };
921
921
  }
922
- function ce() {
922
+ function le() {
923
923
  const { tenant: i, tenantSlug: e, isTenantLoading: t, tenantError: r, retryTenant: s } = ye();
924
924
  return {
925
925
  tenant: i,
@@ -929,9 +929,9 @@ function ce() {
929
929
  retry: s
930
930
  };
931
931
  }
932
- const Pe = he(null);
932
+ const Pe = ue(null);
933
933
  function Zt({ config: i = {}, children: e }) {
934
- const { appId: t, baseUrl: r } = ge(), { tenant: s, tenantSlug: o, switchTenant: a } = ye(), [m, y] = k(i.initialRoles || []), [b, g] = k(!i.initialRoles), [S, f] = k(null), [T, I] = k(!1), [C, R] = k(null), [x, h] = k(0), [$, A] = k(() => {
934
+ const { appId: t, baseUrl: r } = he(), { tenant: s, tenantSlug: o, switchTenant: a } = ye(), [m, y] = k(i.initialRoles || []), [b, g] = k(!i.initialRoles), [S, f] = k(null), [T, I] = k(!1), [C, R] = k(null), [x, h] = k(0), [$, A] = k(() => {
935
935
  try {
936
936
  const v = localStorage.getItem("userTenants");
937
937
  return v ? JSON.parse(v) : [];
@@ -959,7 +959,7 @@ function Zt({ config: i = {}, children: e }) {
959
959
  }, [o, r, i.onRefreshFailed]), L = D.current.done && !P, F = te(() => {
960
960
  const v = new ne(r);
961
961
  return v.setSessionManager(c), v;
962
- }, [r, c]), l = te(() => new tt(new ne(r)), [r]), H = te(() => new rt(F, c), [F, c]), M = te(() => new Ce(new ne(r)), [r]), p = te(() => S || c.getUser(), [S, c]), u = te(() => p != null && p.roleId && m.find((v) => v.id === p.roleId) || null, [p, m]), w = te(() => (u == null ? void 0 : u.permissions) || [], [u]), G = te(() => c.hasValidSession() && S !== null, [c, S]), K = 5 * 60 * 1e3, U = te(() => {
962
+ }, [r, c]), l = te(() => new tt(new ne(r)), [r]), H = te(() => new rt(F, c), [F, c]), M = te(() => new Ce(new ne(r)), [r]), p = te(() => S || c.getUser(), [S, c]), u = te(() => p != null && p.roleId && m.find((v) => v.id === p.roleId) || null, [p, m]), w = te(() => (u == null ? void 0 : u.permissions) || [], [u]), _ = te(() => c.hasValidSession() && S !== null, [c, S]), K = 5 * 60 * 1e3, U = te(() => {
963
963
  const v = async (B = !1) => {
964
964
  try {
965
965
  if (!c.hasValidSession())
@@ -983,62 +983,62 @@ function Zt({ config: i = {}, children: e }) {
983
983
  }
984
984
  }, J = async () => {
985
985
  await v();
986
- }, le = async (B) => {
986
+ }, ae = async (B) => {
987
987
  var Le;
988
988
  const { username: z, password: Y, tenantSlug: W, redirectPath: Q } = B;
989
989
  let X = s == null ? void 0 : s.id, Z = o, ee = c;
990
- W && (X = (await new ue(F, t).getPublicTenantInfo(W)).id, Z = W);
991
- const _ = await l.login({
990
+ W && (X = (await new de(F, t).getPublicTenantInfo(W)).id, Z = W);
991
+ const G = await l.login({
992
992
  username: z,
993
993
  password: Y,
994
994
  appId: t,
995
995
  tenantId: X
996
- }), de = W && W !== o;
997
- if (de && (ee = new ke({
996
+ }), ce = W && W !== o;
997
+ if (ce && (ee = new ke({
998
998
  tenantSlug: Z,
999
999
  baseUrl: r
1000
1000
  })), ee.setTokens({
1001
- accessToken: _.accessToken,
1002
- refreshToken: _.refreshToken,
1003
- expiresIn: _.expiresIn
1004
- }), _.user) {
1005
- ee.setUser(_.user), f(_.user);
1001
+ accessToken: G.accessToken,
1002
+ refreshToken: G.refreshToken,
1003
+ expiresIn: G.expiresIn
1004
+ }), G.user) {
1005
+ ee.setUser(G.user), f(G.user);
1006
1006
  try {
1007
1007
  await v();
1008
- } catch (pe) {
1009
- console.warn("Failed to load complete user data after login:", pe);
1008
+ } catch (ge) {
1009
+ console.warn("Failed to load complete user data after login:", ge);
1010
1010
  }
1011
1011
  }
1012
- if (_.tenants && _.tenants.length > 0) {
1013
- A(_.tenants);
1012
+ if (G.tenants && G.tenants.length > 0) {
1013
+ A(G.tenants);
1014
1014
  try {
1015
- localStorage.setItem("userTenants", JSON.stringify(_.tenants));
1015
+ localStorage.setItem("userTenants", JSON.stringify(G.tenants));
1016
1016
  } catch {
1017
1017
  }
1018
1018
  }
1019
- const ve = ((Le = _.user) == null ? void 0 : Le.tenantId) !== null;
1020
- if (N(ve), de && Z && Z !== o && a(Z, {
1019
+ const ve = ((Le = G.user) == null ? void 0 : Le.tenantId) !== null;
1020
+ if (N(ve), ce && Z && Z !== o && a(Z, {
1021
1021
  tokens: {
1022
- accessToken: _.accessToken,
1023
- refreshToken: _.refreshToken,
1024
- expiresIn: _.expiresIn
1022
+ accessToken: G.accessToken,
1023
+ refreshToken: G.refreshToken,
1024
+ expiresIn: G.expiresIn
1025
1025
  },
1026
1026
  redirectPath: Q
1027
- }), !ve && _.tenants && _.tenants.length > 0) {
1028
- const pe = i.autoSwitchSingleTenant !== !1;
1029
- if (_.tenants.length === 1 && pe) {
1030
- const Ee = _.tenants[0];
1027
+ }), !ve && G.tenants && G.tenants.length > 0) {
1028
+ const ge = i.autoSwitchSingleTenant !== !1;
1029
+ if (G.tenants.length === 1 && ge) {
1030
+ const Ee = G.tenants[0];
1031
1031
  a(Ee.subdomain, {
1032
1032
  tokens: {
1033
- accessToken: _.accessToken,
1034
- refreshToken: _.refreshToken,
1035
- expiresIn: _.expiresIn
1033
+ accessToken: G.accessToken,
1034
+ refreshToken: G.refreshToken,
1035
+ expiresIn: G.expiresIn
1036
1036
  },
1037
1037
  redirectPath: Q
1038
1038
  });
1039
- } else _.tenants.length > 1 && i.onTenantSelectionRequired && i.onTenantSelectionRequired(_.tenants);
1039
+ } else G.tenants.length > 1 && i.onTenantSelectionRequired && i.onTenantSelectionRequired(G.tenants);
1040
1040
  }
1041
- return _;
1041
+ return G;
1042
1042
  }, be = async (B) => {
1043
1043
  const { email: z, phoneNumber: Y, name: W, password: Q, lastName: X, tenantId: Z } = B;
1044
1044
  if (!z && !Y)
@@ -1081,7 +1081,7 @@ function Zt({ config: i = {}, children: e }) {
1081
1081
  }, Ve = async (B) => {
1082
1082
  const { token: z, newPassword: Y } = B;
1083
1083
  await l.confirmPasswordReset({ token: z, newPassword: Y });
1084
- }, _e = async (B) => {
1084
+ }, Ge = async (B) => {
1085
1085
  const { email: z, frontendUrl: Y, name: W, lastName: Q, tenantId: X } = B, Z = X ?? (s == null ? void 0 : s.id);
1086
1086
  if (!Z)
1087
1087
  throw new Error("tenantId is required for magic link authentication");
@@ -1093,17 +1093,17 @@ function Zt({ config: i = {}, children: e }) {
1093
1093
  lastName: Q,
1094
1094
  appId: t
1095
1095
  });
1096
- }, Ge = async (B) => {
1096
+ }, _e = async (B) => {
1097
1097
  const { token: z, email: Y, tenantSlug: W } = B;
1098
1098
  let Q = s == null ? void 0 : s.id, X = o, Z = c;
1099
- W && (Q = (await new ue(F, t).getPublicTenantInfo(W)).id, X = W);
1099
+ W && (Q = (await new de(F, t).getPublicTenantInfo(W)).id, X = W);
1100
1100
  const ee = await l.verifyMagicLink({
1101
1101
  token: z,
1102
1102
  email: Y,
1103
1103
  appId: t,
1104
1104
  tenantId: Q
1105
- }), _ = W && W !== o;
1106
- if (_ && (Z = new ke({
1105
+ }), G = W && W !== o;
1106
+ if (G && (Z = new ke({
1107
1107
  tenantSlug: X,
1108
1108
  baseUrl: r
1109
1109
  })), Z.setTokens({
@@ -1114,11 +1114,11 @@ function Zt({ config: i = {}, children: e }) {
1114
1114
  Z.setUser(ee.user), f(ee.user);
1115
1115
  try {
1116
1116
  await v();
1117
- } catch (de) {
1118
- console.warn("Failed to load complete user data after magic link login:", de);
1117
+ } catch (ce) {
1118
+ console.warn("Failed to load complete user data after magic link login:", ce);
1119
1119
  }
1120
1120
  }
1121
- return _ && X && X !== o && a(X, {
1121
+ return G && X && X !== o && a(X, {
1122
1122
  tokens: {
1123
1123
  accessToken: ee.accessToken,
1124
1124
  refreshToken: ee.refreshToken,
@@ -1170,14 +1170,14 @@ function Zt({ config: i = {}, children: e }) {
1170
1170
  };
1171
1171
  return {
1172
1172
  // RFC-003: Authentication state
1173
- isAuthenticated: G,
1173
+ isAuthenticated: _,
1174
1174
  sessionManager: c,
1175
1175
  authenticatedHttpService: F,
1176
- login: le,
1176
+ login: ae,
1177
1177
  signup: be,
1178
1178
  signupTenantAdmin: Oe,
1179
- sendMagicLink: _e,
1180
- verifyMagicLink: Ge,
1179
+ sendMagicLink: Ge,
1180
+ verifyMagicLink: _e,
1181
1181
  changePassword: We,
1182
1182
  requestPasswordReset: je,
1183
1183
  confirmPasswordReset: Ve,
@@ -1240,7 +1240,7 @@ function Zt({ config: i = {}, children: e }) {
1240
1240
  }
1241
1241
  };
1242
1242
  }, [
1243
- G,
1243
+ _,
1244
1244
  c,
1245
1245
  F,
1246
1246
  l,
@@ -1266,7 +1266,7 @@ function Zt({ config: i = {}, children: e }) {
1266
1266
  !i.initialRoles && t && (async () => {
1267
1267
  try {
1268
1268
  g(!0);
1269
- const J = new ne(r), le = new Ce(J), { roles: be } = await le.getRolesByApp(t);
1269
+ const J = new ne(r), ae = new Ce(J), { roles: be } = await ae.getRolesByApp(t);
1270
1270
  y(be);
1271
1271
  } catch (J) {
1272
1272
  console.error("Failed to fetch roles:", J);
@@ -1298,7 +1298,7 @@ function Zt({ config: i = {}, children: e }) {
1298
1298
  return () => clearInterval(v);
1299
1299
  }, [c, S, U, K]), /* @__PURE__ */ n(Pe.Provider, { value: U, children: e });
1300
1300
  }
1301
- function ae() {
1301
+ function oe() {
1302
1302
  const i = se(Pe);
1303
1303
  if (!i)
1304
1304
  throw new Error("useAuth must be used within an AuthProvider");
@@ -1387,7 +1387,7 @@ class ut {
1387
1387
  })).data;
1388
1388
  }
1389
1389
  }
1390
- const Ie = he(null);
1390
+ const Ie = ue(null);
1391
1391
  function er({ config: i = {}, children: e }) {
1392
1392
  const t = Ue(), r = we(), s = (t == null ? void 0 : t.baseUrl) ?? "", o = (t == null ? void 0 : t.appId) ?? "", a = (r == null ? void 0 : r.tenant) ?? null, [m, y] = k([]), [b, g] = k(!1), [S, f] = k(null), [T, I] = k(!1), C = te(() => {
1393
1393
  const h = new ne(s);
@@ -1512,7 +1512,7 @@ class gt {
1512
1512
  )).data;
1513
1513
  }
1514
1514
  }
1515
- const Re = he(void 0);
1515
+ const Re = ue(void 0);
1516
1516
  function tr({ config: i = {}, children: e }) {
1517
1517
  const t = Ue(), r = we(), s = (t == null ? void 0 : t.baseUrl) ?? "", o = (r == null ? void 0 : r.tenant) ?? null, [a, m] = k(null), [y, b] = k(!1), [g, S] = k(null), [f, T] = k(!1), I = te(() => {
1518
1518
  const x = new ne(s);
@@ -1572,7 +1572,7 @@ function pt() {
1572
1572
  function qe() {
1573
1573
  return se(Re) ?? null;
1574
1574
  }
1575
- var oe = /* @__PURE__ */ ((i) => (i.SUPERUSER = "SUPERUSER", i.TENANT_ADMIN = "TENANT_ADMIN", i.USER = "USER", i))(oe || {});
1575
+ var pe = /* @__PURE__ */ ((i) => (i.SUPERUSER = "SUPERUSER", i.TENANT_ADMIN = "TENANT_ADMIN", i.USER = "USER", i))(pe || {});
1576
1576
  const De = () => /* @__PURE__ */ d(
1577
1577
  "div",
1578
1578
  {
@@ -1653,9 +1653,9 @@ const De = () => /* @__PURE__ */ d(
1653
1653
  }
1654
1654
  ), ft = (i, e) => {
1655
1655
  const t = {
1656
- [oe.USER]: 1,
1657
- [oe.TENANT_ADMIN]: 2,
1658
- [oe.SUPERUSER]: 3
1656
+ [pe.USER]: 1,
1657
+ [pe.TENANT_ADMIN]: 2,
1658
+ [pe.SUPERUSER]: 3
1659
1659
  };
1660
1660
  return t[i] >= t[e];
1661
1661
  };
@@ -1666,7 +1666,7 @@ function rr({
1666
1666
  requiredPermissions: r,
1667
1667
  requireAllPermissions: s = !1
1668
1668
  }) {
1669
- const { hasValidSession: o, sessionManager: a, hasPermission: m, hasAnyPermission: y, hasAllPermissions: b } = ae();
1669
+ const { hasValidSession: o, sessionManager: a, hasPermission: m, hasAnyPermission: y, hasAllPermissions: b } = oe();
1670
1670
  if (!o())
1671
1671
  return /* @__PURE__ */ n(j, { children: e || /* @__PURE__ */ n(De, {}) });
1672
1672
  const g = a.getUser();
@@ -1718,7 +1718,7 @@ const mt = ({ redirectPath: i }) => /* @__PURE__ */ n(
1718
1718
  }
1719
1719
  ), He = ({
1720
1720
  userType: i,
1721
- minUserType: e,
1721
+ requiredUserType: e,
1722
1722
  missingPermissions: t
1723
1723
  }) => /* @__PURE__ */ n(
1724
1724
  "div",
@@ -1750,10 +1750,10 @@ const mt = ({ redirectPath: i }) => /* @__PURE__ */ n(
1750
1750
  /* @__PURE__ */ d("p", { style: { color: "#6b7280", marginBottom: "1rem" }, children: [
1751
1751
  "This page requires ",
1752
1752
  /* @__PURE__ */ n("strong", { children: e }),
1753
- " access level or higher."
1753
+ " access."
1754
1754
  ] }),
1755
1755
  /* @__PURE__ */ d("p", { style: { color: "#9ca3af", fontSize: "0.875rem" }, children: [
1756
- "Your current access level: ",
1756
+ "Your current user type: ",
1757
1757
  /* @__PURE__ */ n("strong", { children: i })
1758
1758
  ] })
1759
1759
  ] }) : /* @__PURE__ */ d(j, { children: [
@@ -1767,23 +1767,16 @@ const mt = ({ redirectPath: i }) => /* @__PURE__ */ n(
1767
1767
  }
1768
1768
  )
1769
1769
  }
1770
- ), yt = (i, e) => {
1771
- const t = {
1772
- [oe.USER]: 1,
1773
- [oe.TENANT_ADMIN]: 2,
1774
- [oe.SUPERUSER]: 3
1775
- };
1776
- return t[i] >= t[e];
1777
- };
1770
+ ), yt = (i, e) => i === e;
1778
1771
  function nr({
1779
1772
  children: i,
1780
1773
  redirectTo: e = "/login",
1781
- minUserType: t,
1774
+ requiredUserType: t,
1782
1775
  requiredPermissions: r,
1783
1776
  requireAllPermissions: s = !1,
1784
1777
  fallback: o
1785
1778
  }) {
1786
- const { hasValidSession: a, sessionManager: m, hasPermission: y, hasAnyPermission: b, hasAllPermissions: g } = ae(), S = Te();
1779
+ const { hasValidSession: a, sessionManager: m, hasPermission: y, hasAnyPermission: b, hasAllPermissions: g } = oe(), S = Te();
1787
1780
  if (!a())
1788
1781
  return o ? /* @__PURE__ */ n(j, { children: o }) : /* @__PURE__ */ d(j, { children: [
1789
1782
  /* @__PURE__ */ n(mt, { redirectPath: e }),
@@ -1793,7 +1786,13 @@ function nr({
1793
1786
  if (!f)
1794
1787
  return /* @__PURE__ */ n(fe, { to: e, state: { from: S.pathname }, replace: !0 });
1795
1788
  if (t && !yt(f.userType, t))
1796
- return /* @__PURE__ */ n(He, { userType: f.userType, minUserType: t });
1789
+ return /* @__PURE__ */ n(
1790
+ He,
1791
+ {
1792
+ userType: f.userType,
1793
+ requiredUserType: t
1794
+ }
1795
+ );
1797
1796
  if (r && r.length > 0 && !(s ? g(r) : b(r))) {
1798
1797
  const I = r.filter((C) => !y(C)).map((C) => typeof C == "string" ? C : C.name);
1799
1798
  return /* @__PURE__ */ n(He, { missingPermissions: I });
@@ -1838,7 +1837,7 @@ const wt = ({ redirectPath: i }) => /* @__PURE__ */ n(
1838
1837
  }
1839
1838
  );
1840
1839
  function sr({ children: i, redirectTo: e = "/", fallback: t }) {
1841
- const { tenant: r, isLoading: s, error: o } = ce(), a = Te();
1840
+ const { tenant: r, isLoading: s, error: o } = le(), a = Te();
1842
1841
  return s || o ? null : r ? /* @__PURE__ */ n(j, { children: i }) : t ? /* @__PURE__ */ n(j, { children: t }) : /* @__PURE__ */ d(j, { children: [
1843
1842
  /* @__PURE__ */ n(wt, { redirectPath: e }),
1844
1843
  /* @__PURE__ */ n(fe, { to: e, state: { from: a.pathname }, replace: !0 })
@@ -1882,7 +1881,7 @@ const bt = ({ redirectPath: i }) => /* @__PURE__ */ n(
1882
1881
  }
1883
1882
  );
1884
1883
  function ir({ children: i, redirectTo: e = "/dashboard", fallback: t }) {
1885
- const { tenant: r, isLoading: s, error: o } = ce(), a = Te();
1884
+ const { tenant: r, isLoading: s, error: o } = le(), a = Te();
1886
1885
  return s || o ? null : r ? t ? /* @__PURE__ */ n(j, { children: t }) : /* @__PURE__ */ d(j, { children: [
1887
1886
  /* @__PURE__ */ n(bt, { redirectPath: e }),
1888
1887
  /* @__PURE__ */ n(fe, { to: e, state: { from: a.pathname }, replace: !0 })
@@ -2140,7 +2139,7 @@ function lr({
2140
2139
  showMagicLinkOption: g = !0,
2141
2140
  className: S
2142
2141
  }) {
2143
- const [f, T] = k(""), [I, C] = k(""), [R, x] = k(!1), [h, $] = k(!1), [A, E] = k(""), [N, D] = k({}), { login: P } = ae(), { tenant: O } = ce(), c = { ...At, ...i }, L = { ...Pt, ...e }, F = { ...xt, ...t }, l = () => {
2142
+ const [f, T] = k(""), [I, C] = k(""), [R, x] = k(!1), [h, $] = k(!1), [A, E] = k(""), [N, D] = k({}), { login: P } = oe(), { tenant: O } = le(), c = { ...At, ...i }, L = { ...Pt, ...e }, F = { ...xt, ...t }, l = () => {
2144
2143
  const u = {};
2145
2144
  return f.trim() || (u.username = !0), I.trim() || (u.password = !0), D(u), Object.keys(u).length === 0;
2146
2145
  }, H = async (u) => {
@@ -2158,8 +2157,8 @@ function lr({
2158
2157
  });
2159
2158
  r == null || r(w);
2160
2159
  } catch (w) {
2161
- const G = w.message || c.errorMessage;
2162
- E(G), s == null || s(G);
2160
+ const _ = w.message || c.errorMessage;
2161
+ E(_), s == null || s(_);
2163
2162
  } finally {
2164
2163
  $(!1);
2165
2164
  }
@@ -2389,11 +2388,11 @@ function cr({
2389
2388
  showMagicLinkOption: y = !0,
2390
2389
  className: b
2391
2390
  }) {
2392
- const [g, S] = k(""), [f, T] = k(""), [I, C] = k(""), [R, x] = k(""), [h, $] = k(""), [A, E] = k(""), [N, D] = k(""), [P, O] = k(!1), [c, L] = k(""), [F, l] = k({}), { signup: H, signupTenantAdmin: M } = ae(), { tenant: p } = ce(), u = { ...Mt, ...i }, w = { ...It, ...e }, G = () => {
2391
+ const [g, S] = k(""), [f, T] = k(""), [I, C] = k(""), [R, x] = k(""), [h, $] = k(""), [A, E] = k(""), [N, D] = k(""), [P, O] = k(!1), [c, L] = k(""), [F, l] = k({}), { signup: H, signupTenantAdmin: M } = oe(), { tenant: p } = le(), u = { ...Mt, ...i }, w = { ...It, ...e }, _ = () => {
2393
2392
  const v = {};
2394
2393
  return g.trim() || (v.name = !0), !I.trim() && !R.trim() && (v.email = !0, v.phoneNumber = !0), h.trim() || (v.password = !0), A.trim() || (v.confirmPassword = !0), t === "tenant" && !N.trim() && (v.tenantName = !0), l(v), Object.keys(v).length === 0;
2395
2394
  }, K = async (v) => {
2396
- if (v.preventDefault(), !!G()) {
2395
+ if (v.preventDefault(), !!_()) {
2397
2396
  if (h !== A) {
2398
2397
  L(u.passwordMismatchError), l({ confirmPassword: !0 });
2399
2398
  return;
@@ -2421,8 +2420,8 @@ function cr({
2421
2420
  lastName: f || void 0
2422
2421
  }), r == null || r(J);
2423
2422
  } catch (J) {
2424
- const le = J.message || u.errorMessage;
2425
- L(le), s == null || s(le);
2423
+ const ae = J.message || u.errorMessage;
2424
+ L(ae), s == null || s(ae);
2426
2425
  } finally {
2427
2426
  O(!1);
2428
2427
  }
@@ -2729,7 +2728,7 @@ function dr({
2729
2728
  verifyToken: y,
2730
2729
  frontendUrl: b
2731
2730
  }) {
2732
- const [g, S] = k(""), [f, T] = k(""), [I, C] = k(""), [R, x] = k(!1), [h, $] = k(!1), [A, E] = k(""), [N, D] = k(""), [P, O] = k({}), [c, L] = k(!1), { sendMagicLink: F, verifyMagicLink: l } = ae(), { tenant: H } = ce(), M = { ...Rt, ...i }, p = { ...Lt, ...e };
2731
+ const [g, S] = k(""), [f, T] = k(""), [I, C] = k(""), [R, x] = k(!1), [h, $] = k(!1), [A, E] = k(""), [N, D] = k(""), [P, O] = k({}), [c, L] = k(!1), { sendMagicLink: F, verifyMagicLink: l } = oe(), { tenant: H } = le(), M = { ...Rt, ...i }, p = { ...Lt, ...e };
2733
2732
  re(() => {
2734
2733
  y && u(y);
2735
2734
  }, [y]);
@@ -2755,7 +2754,7 @@ function dr({
2755
2754
  }, w = () => {
2756
2755
  const q = {};
2757
2756
  return g.trim() || (q.email = !0), c && !f.trim() && (q.name = !0), O(q), Object.keys(q).length === 0;
2758
- }, G = async (q) => {
2757
+ }, _ = async (q) => {
2759
2758
  if (q.preventDefault(), !!w()) {
2760
2759
  if (!(H != null && H.id)) {
2761
2760
  E("Tenant not found");
@@ -2792,7 +2791,7 @@ function dr({
2792
2791
  ] }) : /* @__PURE__ */ d("div", { className: m, style: p.container, children: [
2793
2792
  /* @__PURE__ */ n("h2", { style: p.title, children: M.title }),
2794
2793
  /* @__PURE__ */ n("p", { style: p.description, children: M.description }),
2795
- /* @__PURE__ */ d("form", { onSubmit: G, style: p.form, children: [
2794
+ /* @__PURE__ */ d("form", { onSubmit: _, style: p.form, children: [
2796
2795
  /* @__PURE__ */ d("div", { style: p.fieldGroup, children: [
2797
2796
  /* @__PURE__ */ n("label", { style: p.label, children: M.emailLabel }),
2798
2797
  /* @__PURE__ */ n(
@@ -3054,7 +3053,7 @@ function ur({
3054
3053
  tenantSlug: S,
3055
3054
  autoRedirectDelay: f = 3e3
3056
3055
  }) {
3057
- const [T, I] = k("verifying"), [C, R] = k(""), { verifyMagicLink: x } = ae(), h = { ...Et, ...i }, $ = { ...ze, ...e }, A = { ...$t, ...t }, E = () => {
3056
+ const [T, I] = k("verifying"), [C, R] = k(""), { verifyMagicLink: x } = oe(), h = { ...Et, ...i }, $ = { ...ze, ...e }, A = { ...$t, ...t }, E = () => {
3058
3057
  if (typeof window > "u") return {};
3059
3058
  const c = new URLSearchParams(window.location.search);
3060
3059
  return {
@@ -3281,7 +3280,7 @@ function hr({
3281
3280
  onModeChange: m,
3282
3281
  className: y
3283
3282
  }) {
3284
- const [b, g] = k(""), [S, f] = k(r), [T, I] = k(""), [C, R] = k(""), [x, h] = k(!1), [$, A] = k(""), [E, N] = k(""), [D, P] = k({}), { requestPasswordReset: O, confirmPasswordReset: c } = ae(), { tenant: L } = ce(), F = { ...Ht, ...i }, l = { ...Nt, ...e }, H = () => {
3283
+ const [b, g] = k(""), [S, f] = k(r), [T, I] = k(""), [C, R] = k(""), [x, h] = k(!1), [$, A] = k(""), [E, N] = k(""), [D, P] = k({}), { requestPasswordReset: O, confirmPasswordReset: c } = oe(), { tenant: L } = le(), F = { ...Ht, ...i }, l = { ...Nt, ...e }, H = () => {
3285
3284
  const U = {};
3286
3285
  return b.trim() || (U.email = !0), P(U), Object.keys(U).length === 0;
3287
3286
  }, M = () => {
@@ -3322,7 +3321,7 @@ function hr({
3322
3321
  }, w = (U) => ({
3323
3322
  ...l.input,
3324
3323
  ...D[U] ? l.inputError : {}
3325
- }), G = () => ({
3324
+ }), _ = () => ({
3326
3325
  ...l.button,
3327
3326
  ...x ? l.buttonLoading : {}
3328
3327
  });
@@ -3386,7 +3385,7 @@ function hr({
3386
3385
  type: "submit",
3387
3386
  disabled: !U || x,
3388
3387
  style: {
3389
- ...G(),
3388
+ ..._(),
3390
3389
  ...!U || x ? l.buttonDisabled : {}
3391
3390
  },
3392
3391
  children: x ? F.resetLoadingText : F.resetSubmitButton
@@ -3431,7 +3430,7 @@ function hr({
3431
3430
  type: "submit",
3432
3431
  disabled: !K || x,
3433
3432
  style: {
3434
- ...G(),
3433
+ ..._(),
3435
3434
  ...!K || x ? l.buttonDisabled : {}
3436
3435
  },
3437
3436
  children: x ? F.loadingText : F.submitButton
@@ -3501,7 +3500,7 @@ function gr({
3501
3500
  errorFallback: t,
3502
3501
  requireTenant: r = !0
3503
3502
  }) {
3504
- const { isAppLoading: s, appError: o, retryApp: a } = ge(), m = we(), y = Me(), b = Be(), g = qe(), S = (m == null ? void 0 : m.isTenantLoading) ?? !1, f = (m == null ? void 0 : m.tenantError) ?? null, T = (m == null ? void 0 : m.tenantSlug) ?? null, I = (m == null ? void 0 : m.retryTenant) ?? (() => {
3503
+ const { isAppLoading: s, appError: o, retryApp: a } = he(), m = we(), y = Me(), b = Be(), g = qe(), S = (m == null ? void 0 : m.isTenantLoading) ?? !1, f = (m == null ? void 0 : m.tenantError) ?? null, T = (m == null ? void 0 : m.tenantSlug) ?? null, I = (m == null ? void 0 : m.retryTenant) ?? (() => {
3505
3504
  }), C = (y == null ? void 0 : y.isAuthReady) ?? !0, R = (b == null ? void 0 : b.isReady) ?? !0, x = (g == null ? void 0 : g.isReady) ?? !0, h = r && m && T, N = s || h && S || y && !C || b && !R || g && !x, D = o || (h ? f : null), P = () => {
3506
3505
  o && a(), f && m && I();
3507
3506
  };
@@ -3514,7 +3513,7 @@ function gr({
3514
3513
  return /* @__PURE__ */ n(j, { children: i });
3515
3514
  }
3516
3515
  function pr(i = !0) {
3517
- const { isAppLoading: e, appError: t, retryApp: r, appInfo: s } = ge(), o = we(), a = Me(), m = Be(), y = qe(), b = (o == null ? void 0 : o.isTenantLoading) ?? !1, g = (o == null ? void 0 : o.tenantError) ?? null, S = (o == null ? void 0 : o.tenant) ?? null, f = (o == null ? void 0 : o.tenantSlug) ?? null, T = (o == null ? void 0 : o.retryTenant) ?? (() => {
3516
+ const { isAppLoading: e, appError: t, retryApp: r, appInfo: s } = he(), o = we(), a = Me(), m = Be(), y = qe(), b = (o == null ? void 0 : o.isTenantLoading) ?? !1, g = (o == null ? void 0 : o.tenantError) ?? null, S = (o == null ? void 0 : o.tenant) ?? null, f = (o == null ? void 0 : o.tenantSlug) ?? null, T = (o == null ? void 0 : o.retryTenant) ?? (() => {
3518
3517
  }), I = (a == null ? void 0 : a.isAuthReady) ?? !0, C = (m == null ? void 0 : m.isReady) ?? !0, R = (y == null ? void 0 : y.isReady) ?? !0, x = i && o && f, E = e || x && b || a && !I || m && !C || y && !R, N = t || (x ? g : null);
3519
3518
  return {
3520
3519
  isLoading: E,
@@ -3904,21 +3903,21 @@ export {
3904
3903
  or as SubscriptionGuard,
3905
3904
  yr as SubscriptionPlanApiService,
3906
3905
  tr as SubscriptionProvider,
3907
- ue as TenantApiService,
3906
+ de as TenantApiService,
3908
3907
  Yt as TenantProvider,
3909
3908
  sr as TenantRoute,
3910
3909
  fr as TenantSelector,
3911
3910
  rt as UserApiService,
3912
- oe as UserType,
3911
+ pe as UserType,
3913
3912
  Kt as useApi,
3914
- ge as useApp,
3913
+ he as useApp,
3915
3914
  pr as useAppLoaderState,
3916
- ae as useAuth,
3915
+ oe as useAuth,
3917
3916
  ht as useFeatureFlags,
3918
3917
  Xt as useSettings,
3919
3918
  pt as useSubscription,
3920
3919
  ye as useTenant,
3921
- ce as useTenantInfo,
3920
+ le as useTenantInfo,
3922
3921
  we as useTenantOptional,
3923
3922
  Qt as useTenantSettings
3924
3923
  };