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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.es.js CHANGED
@@ -1,5 +1,5 @@
1
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,
@@ -733,12 +733,12 @@ function Yt({ config: i, children: e }) {
733
733
  const l = o();
734
734
  m(l);
735
735
  }, [o]);
736
- const E = (r == null ? void 0 : r.settingsSchema) || null, N = ie(
736
+ const E = (r == null ? void 0 : r.settingsSchema) || null, U = ie(
737
737
  async (l, H = !1) => {
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`
@@ -829,42 +829,42 @@ function Yt({ config: i, children: e }) {
829
829
  [E]
830
830
  );
831
831
  re(() => {
832
- !i.initialTenant && a ? b ? D() : N(a) : !i.initialTenant && !a && (g(null), I(null), f(!1));
833
- }, [i.initialTenant, a, b, N, D]), re(() => {
832
+ !i.initialTenant && a ? b ? D() : U(a) : !i.initialTenant && !a && (g(null), I(null), f(!1));
833
+ }, [i.initialTenant, a, b, U, D]), re(() => {
834
834
  b != null && b.id ? P() : (R(null), A(null), h(!1));
835
835
  }, [b == null ? void 0 : b.id, P]);
836
836
  const L = ie(
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
  }
852
- const U = u || window.location.pathname, q = new URL(`${window.location.protocol}//${K}${U}`);
852
+ const B = u || window.location.pathname, q = new URL(`${window.location.protocol}//${K}${B}`);
853
853
  new URLSearchParams(window.location.search).forEach((v, J) => {
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}`;
860
- window.location.href = U;
859
+ const B = `${_}?${K.toString()}${window.location.hash}`;
860
+ window.location.href = B;
861
861
  } else {
862
- const U = `${G}?${K.toString()}${window.location.hash}`;
863
- window.history.pushState({}, "", U), m(l), N(l);
862
+ const B = `${_}?${K.toString()}${window.location.hash}`;
863
+ window.history.pushState({}, "", B), m(l), U(l);
864
864
  }
865
865
  }
866
866
  },
867
- [i.tenantMode, i.selectorParam, i.baseDomain, N]
867
+ [i.tenantMode, i.selectorParam, i.baseDomain, U]
868
868
  ), F = te(() => ({
869
869
  // Tenant info
870
870
  tenant: b,
@@ -872,7 +872,7 @@ function Yt({ config: i, children: e }) {
872
872
  isTenantLoading: S,
873
873
  tenantError: T,
874
874
  retryTenant: () => {
875
- a && N(a);
875
+ a && U(a);
876
876
  },
877
877
  // Settings
878
878
  settings: C,
@@ -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,16 +929,16 @@ 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) : [];
938
938
  } catch {
939
939
  return [];
940
940
  }
941
- }), [E, N] = k(!1), D = Ne({ done: !1, urlTokens: null });
941
+ }), [E, U] = k(!1), D = Ne({ done: !1, urlTokens: null });
942
942
  D.current.done || (D.current.done = !0, D.current.urlTokens = ct(), D.current.urlTokens && console.log(
943
943
  "[AuthProvider] SYNC: URL tokens found, will block isAuthReady until user loaded"
944
944
  ));
@@ -959,13 +959,13 @@ 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(() => {
963
- const v = async (B = !1) => {
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, B = te(() => {
963
+ const v = async (N = !1) => {
964
964
  try {
965
965
  if (!c.hasValidSession())
966
966
  return;
967
967
  const z = Date.now();
968
- if (!B && z - x < K && S)
968
+ if (!N && z - x < K && S)
969
969
  return;
970
970
  const W = c.getUserId();
971
971
  if (!W) {
@@ -983,64 +983,64 @@ function Zt({ config: i = {}, children: e }) {
983
983
  }
984
984
  }, J = async () => {
985
985
  await v();
986
- }, le = async (B) => {
986
+ }, ae = async (N) => {
987
987
  var Le;
988
- const { username: z, password: Y, tenantSlug: W, redirectPath: Q } = B;
988
+ const { username: z, password: Y, tenantSlug: W, redirectPath: Q } = N;
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 (U(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 = N.autoSwitch !== !1 && 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 _;
1042
- }, be = async (B) => {
1043
- const { email: z, phoneNumber: Y, name: W, password: Q, lastName: X, tenantId: Z } = B;
1041
+ return G;
1042
+ }, be = async (N) => {
1043
+ const { email: z, phoneNumber: Y, name: W, password: Q, lastName: X, tenantId: Z } = N;
1044
1044
  if (!z && !Y)
1045
1045
  throw new Error("Either email or phoneNumber is required");
1046
1046
  if (!W || !Q)
@@ -1055,8 +1055,8 @@ function Zt({ config: i = {}, children: e }) {
1055
1055
  lastName: X,
1056
1056
  appId: t
1057
1057
  });
1058
- }, Oe = async (B) => {
1059
- const { email: z, phoneNumber: Y, name: W, password: Q, tenantName: X, lastName: Z } = B;
1058
+ }, Oe = async (N) => {
1059
+ const { email: z, phoneNumber: Y, name: W, password: Q, tenantName: X, lastName: Z } = N;
1060
1060
  if (!z && !Y)
1061
1061
  throw new Error("Either email or phoneNumber is required");
1062
1062
  if (!W || !Q || !X)
@@ -1070,19 +1070,19 @@ function Zt({ config: i = {}, children: e }) {
1070
1070
  appId: t,
1071
1071
  lastName: Z
1072
1072
  });
1073
- }, We = async (B) => {
1074
- const { currentPassword: z, newPassword: Y } = B, W = await c.getAuthHeaders();
1073
+ }, We = async (N) => {
1074
+ const { currentPassword: z, newPassword: Y } = N, W = await c.getAuthHeaders();
1075
1075
  await l.changePassword({ currentPassword: z, newPassword: Y }, W);
1076
- }, je = async (B) => {
1077
- const { email: z, tenantId: Y } = B, W = Y ?? (s == null ? void 0 : s.id);
1076
+ }, je = async (N) => {
1077
+ const { email: z, tenantId: Y } = N, W = Y ?? (s == null ? void 0 : s.id);
1078
1078
  if (!W)
1079
1079
  throw new Error("tenantId is required for password reset");
1080
1080
  await l.requestPasswordReset({ email: z, tenantId: W });
1081
- }, Ve = async (B) => {
1082
- const { token: z, newPassword: Y } = B;
1081
+ }, Ve = async (N) => {
1082
+ const { token: z, newPassword: Y } = N;
1083
1083
  await l.confirmPasswordReset({ token: z, newPassword: Y });
1084
- }, _e = async (B) => {
1085
- const { email: z, frontendUrl: Y, name: W, lastName: Q, tenantId: X } = B, Z = X ?? (s == null ? void 0 : s.id);
1084
+ }, Ge = async (N) => {
1085
+ const { email: z, frontendUrl: Y, name: W, lastName: Q, tenantId: X } = N, Z = X ?? (s == null ? void 0 : s.id);
1086
1086
  if (!Z)
1087
1087
  throw new Error("tenantId is required for magic link authentication");
1088
1088
  return await l.sendMagicLink({
@@ -1093,17 +1093,17 @@ function Zt({ config: i = {}, children: e }) {
1093
1093
  lastName: Q,
1094
1094
  appId: t
1095
1095
  });
1096
- }, Ge = async (B) => {
1097
- const { token: z, email: Y, tenantSlug: W } = B;
1096
+ }, _e = async (N) => {
1097
+ const { token: z, email: Y, tenantSlug: W } = N;
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,
@@ -1126,58 +1126,58 @@ function Zt({ config: i = {}, children: e }) {
1126
1126
  }
1127
1127
  }), ee;
1128
1128
  }, Je = async () => {
1129
- const B = c.getTokens();
1130
- if (!(B != null && B.refreshToken))
1129
+ const N = c.getTokens();
1130
+ if (!(N != null && N.refreshToken))
1131
1131
  throw new Error("No refresh token available");
1132
1132
  const z = await l.refreshToken({
1133
- refreshToken: B.refreshToken
1133
+ refreshToken: N.refreshToken
1134
1134
  });
1135
1135
  c.setTokens({
1136
1136
  accessToken: z.accessToken,
1137
- refreshToken: z.refreshToken || B.refreshToken,
1137
+ refreshToken: z.refreshToken || N.refreshToken,
1138
1138
  expiresIn: z.expiresIn
1139
1139
  });
1140
1140
  }, Ke = () => {
1141
- c.clearSession(), f(null), R(null), A([]), N(!1);
1141
+ c.clearSession(), f(null), R(null), A([]), U(!1);
1142
1142
  try {
1143
1143
  localStorage.removeItem("userTenants");
1144
1144
  } catch {
1145
1145
  }
1146
- }, Ye = (B) => {
1147
- c.setTokens(B);
1146
+ }, Ye = (N) => {
1147
+ c.setTokens(N);
1148
1148
  }, Qe = () => c.hasValidSession(), Xe = () => {
1149
1149
  c.clearSession(), f(null), R(null);
1150
1150
  }, Ze = async () => {
1151
1151
  if (t)
1152
1152
  try {
1153
1153
  g(!0);
1154
- const { roles: B } = await M.getRolesByApp(t);
1155
- y(B);
1156
- } catch (B) {
1157
- console.error("Failed to fetch roles:", B);
1154
+ const { roles: N } = await M.getRolesByApp(t);
1155
+ y(N);
1156
+ } catch (N) {
1157
+ console.error("Failed to fetch roles:", N);
1158
1158
  } finally {
1159
1159
  g(!1);
1160
1160
  }
1161
1161
  }, et = async () => {
1162
1162
  await Ze();
1163
- }, Se = (B) => {
1163
+ }, Se = (N) => {
1164
1164
  if (!w || w.length === 0)
1165
1165
  return !1;
1166
- if (typeof B == "string")
1167
- return w.includes(B);
1168
- const z = `${B.resource}.${B.action}`;
1166
+ if (typeof N == "string")
1167
+ return w.includes(N);
1168
+ const z = `${N.resource}.${N.action}`;
1169
1169
  return w.includes(z);
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,
@@ -1198,28 +1198,28 @@ function Zt({ config: i = {}, children: e }) {
1198
1198
  availableRoles: m,
1199
1199
  rolesLoading: b,
1200
1200
  hasPermission: Se,
1201
- hasAnyPermission: (B) => B.some((z) => Se(z)),
1202
- hasAllPermissions: (B) => B.every((z) => Se(z)),
1201
+ hasAnyPermission: (N) => N.some((z) => Se(z)),
1202
+ hasAllPermissions: (N) => N.every((z) => Se(z)),
1203
1203
  getUserPermissionStrings: () => w || [],
1204
1204
  refreshRoles: et,
1205
1205
  // RFC-004: Multi-tenant user membership
1206
1206
  userTenants: $,
1207
1207
  hasTenantContext: E,
1208
- switchToTenant: async (B, z) => {
1208
+ switchToTenant: async (N, z) => {
1209
1209
  const { redirectPath: Y } = z || {}, W = c.getTokens();
1210
1210
  if (!(W != null && W.refreshToken))
1211
1211
  throw new Error("No refresh token available for tenant switch");
1212
1212
  const Q = await l.switchTenant({
1213
1213
  refreshToken: W.refreshToken,
1214
- tenantId: B
1214
+ tenantId: N
1215
1215
  });
1216
1216
  c.setTokens({
1217
1217
  accessToken: Q.accessToken,
1218
1218
  refreshToken: W.refreshToken,
1219
1219
  // Keep the same refresh token
1220
1220
  expiresIn: Q.expiresIn
1221
- }), f(Q.user), c.setUser(Q.user), N(!0);
1222
- const X = $.find((Z) => Z.id === B);
1221
+ }), f(Q.user), c.setUser(Q.user), U(!0);
1222
+ const X = $.find((Z) => Z.id === N);
1223
1223
  X && a(X.subdomain, {
1224
1224
  tokens: {
1225
1225
  accessToken: Q.accessToken,
@@ -1230,7 +1230,7 @@ function Zt({ config: i = {}, children: e }) {
1230
1230
  });
1231
1231
  },
1232
1232
  refreshUserTenants: async () => {
1233
- const B = await c.getAuthHeaders(), z = await l.getUserTenants(B);
1233
+ const N = await c.getAuthHeaders(), z = await l.getUserTenants(N);
1234
1234
  A(z);
1235
1235
  try {
1236
1236
  localStorage.setItem("userTenants", JSON.stringify(z));
@@ -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);
@@ -1277,28 +1277,28 @@ function Zt({ config: i = {}, children: e }) {
1277
1277
  }, [t, r, i.initialRoles]);
1278
1278
  const [q, V] = k(!1);
1279
1279
  return re(() => {
1280
- q || (V(!0), D.current.urlTokens && (console.log("[AuthProvider] EFFECT: Cleaning up URL after sync token processing"), dt(), O(!0), console.log("[AuthProvider] EFFECT: Loading user data (blocking isAuthReady)..."), U.loadUserData().catch((v) => {
1280
+ q || (V(!0), D.current.urlTokens && (console.log("[AuthProvider] EFFECT: Cleaning up URL after sync token processing"), dt(), O(!0), console.log("[AuthProvider] EFFECT: Loading user data (blocking isAuthReady)..."), B.loadUserData().catch((v) => {
1281
1281
  console.error("[AuthProvider] Failed to load user data:", v);
1282
1282
  }).finally(() => {
1283
1283
  console.log("[AuthProvider] EFFECT: User data loaded, releasing isAuthReady"), O(!1);
1284
1284
  })));
1285
- }, [U, q]), re(() => {
1285
+ }, [B, q]), re(() => {
1286
1286
  const v = c.getUser();
1287
1287
  v && c.hasValidSession() && f(v);
1288
1288
  }, [c]), re(() => {
1289
- q && (D.current.urlTokens || !S && !T && c.hasValidSession() && (console.log("[AuthProvider] Auto-loading user data..."), U.loadUserData().catch(() => {
1289
+ q && (D.current.urlTokens || !S && !T && c.hasValidSession() && (console.log("[AuthProvider] Auto-loading user data..."), B.loadUserData().catch(() => {
1290
1290
  })));
1291
- }, [S, T, U, c, q]), re(() => {
1291
+ }, [S, T, B, c, q]), re(() => {
1292
1292
  if (!c.hasValidSession() || !S)
1293
1293
  return;
1294
1294
  const v = setInterval(() => {
1295
- U.loadUserData().catch(() => {
1295
+ B.loadUserData().catch(() => {
1296
1296
  });
1297
1297
  }, K);
1298
1298
  return () => clearInterval(v);
1299
- }, [c, S, U, K]), /* @__PURE__ */ n(Pe.Provider, { value: U, children: e });
1299
+ }, [c, S, B, K]), /* @__PURE__ */ n(Pe.Provider, { value: B, 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);
@@ -1423,12 +1423,12 @@ function er({ config: i = {}, children: e }) {
1423
1423
  return P ? P.value ? "enabled" : "disabled" : "not_found";
1424
1424
  }, E = async () => {
1425
1425
  await R();
1426
- }, N = !!(s && o) && (T || !(a != null && a.id));
1426
+ }, U = !!(s && o) && (T || !(a != null && a.id));
1427
1427
  return {
1428
1428
  featureFlags: m,
1429
1429
  loading: b,
1430
1430
  error: S,
1431
- isReady: N,
1431
+ isReady: U,
1432
1432
  isEnabled: h,
1433
1433
  getFlag: $,
1434
1434
  getFlagState: A,
@@ -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);
@@ -1545,7 +1545,7 @@ function tr({ config: i = {}, children: e }) {
1545
1545
  }, $ = (P) => x.find((O) => O.key === P), A = (P, O) => {
1546
1546
  const c = x.find((L) => L.key === P);
1547
1547
  return c ? c.value : O;
1548
- }, E = (P) => !a || !a.isActive ? !1 : P.includes(a.planId), N = async () => {
1548
+ }, E = (P) => !a || !a.isActive ? !1 : P.includes(a.planId), U = async () => {
1549
1549
  await C();
1550
1550
  }, D = !!s && (f || !(o != null && o.id));
1551
1551
  return {
@@ -1558,7 +1558,7 @@ function tr({ config: i = {}, children: e }) {
1558
1558
  getFeature: $,
1559
1559
  getFeatureValue: A,
1560
1560
  hasAllowedPlan: E,
1561
- refresh: N
1561
+ refresh: U
1562
1562
  };
1563
1563
  }, [a, y, g, s, o == null ? void 0 : o.id, f]);
1564
1564
  return /* @__PURE__ */ n(Re.Provider, { value: R, children: e });
@@ -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(""), [U, 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,15 +2157,15 @@ 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
  }
2166
2165
  }
2167
2166
  }, M = (u) => ({
2168
2167
  ...L.input,
2169
- ...N[u] ? L.inputError : {}
2168
+ ...U[u] ? L.inputError : {}
2170
2169
  }), p = () => ({
2171
2170
  ...L.button,
2172
2171
  ...h ? L.buttonLoading : {},
@@ -2185,7 +2184,7 @@ function lr({
2185
2184
  type: "text",
2186
2185
  value: f,
2187
2186
  onChange: (u) => {
2188
- T(u.target.value), N.username && D((w) => ({ ...w, username: !1 }));
2187
+ T(u.target.value), U.username && D((w) => ({ ...w, username: !1 }));
2189
2188
  },
2190
2189
  placeholder: c.usernamePlaceholder,
2191
2190
  style: M("username"),
@@ -2204,7 +2203,7 @@ function lr({
2204
2203
  type: R ? "text" : "password",
2205
2204
  value: I,
2206
2205
  onChange: (u) => {
2207
- C(u.target.value), N.password && D((w) => ({ ...w, password: !1 }));
2206
+ C(u.target.value), U.password && D((w) => ({ ...w, password: !1 }));
2208
2207
  },
2209
2208
  placeholder: c.passwordPlaceholder,
2210
2209
  style: {
@@ -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(""), [U, 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
- 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;
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" && !U.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;
@@ -2410,7 +2409,7 @@ function cr({
2410
2409
  phoneNumber: R || void 0,
2411
2410
  name: g,
2412
2411
  password: h,
2413
- tenantName: N,
2412
+ tenantName: U,
2414
2413
  lastName: f || void 0
2415
2414
  }) : J = await H({
2416
2415
  email: I || void 0,
@@ -2421,20 +2420,20 @@ 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
  }
2429
2428
  }
2430
- }, U = (v) => ({
2429
+ }, B = (v) => ({
2431
2430
  ...w.input,
2432
2431
  ...F[v] ? w.inputError : {}
2433
2432
  }), q = () => ({
2434
2433
  ...w.button,
2435
2434
  ...P ? w.buttonLoading : {},
2436
- ...!g || !I && !R || !h || !A || P || t === "tenant" && !N ? w.buttonDisabled : {}
2437
- }), V = g && (I || R) && h && A && (t === "user" || N);
2435
+ ...!g || !I && !R || !h || !A || P || t === "tenant" && !U ? w.buttonDisabled : {}
2436
+ }), V = g && (I || R) && h && A && (t === "user" || U);
2438
2437
  return /* @__PURE__ */ d("div", { className: b, style: w.container, children: [
2439
2438
  /* @__PURE__ */ n("h2", { style: w.title, children: u.title }),
2440
2439
  /* @__PURE__ */ d("form", { onSubmit: K, style: w.form, children: [
@@ -2451,7 +2450,7 @@ function cr({
2451
2450
  S(v.target.value), F.name && l((J) => ({ ...J, name: !1 }));
2452
2451
  },
2453
2452
  placeholder: u.namePlaceholder,
2454
- style: U("name"),
2453
+ style: B("name"),
2455
2454
  disabled: P
2456
2455
  }
2457
2456
  )
@@ -2485,7 +2484,7 @@ function cr({
2485
2484
  C(v.target.value), F.email && l((J) => ({ ...J, email: !1, phoneNumber: !1 }));
2486
2485
  },
2487
2486
  placeholder: u.emailPlaceholder,
2488
- style: U("email"),
2487
+ style: B("email"),
2489
2488
  disabled: P
2490
2489
  }
2491
2490
  )
@@ -2503,7 +2502,7 @@ function cr({
2503
2502
  x(v.target.value), F.phoneNumber && l((J) => ({ ...J, email: !1, phoneNumber: !1 }));
2504
2503
  },
2505
2504
  placeholder: u.phoneNumberPlaceholder,
2506
- style: U("phoneNumber"),
2505
+ style: B("phoneNumber"),
2507
2506
  disabled: P
2508
2507
  }
2509
2508
  )
@@ -2533,7 +2532,7 @@ function cr({
2533
2532
  $(v.target.value), F.password && l((J) => ({ ...J, password: !1 }));
2534
2533
  },
2535
2534
  placeholder: u.passwordPlaceholder,
2536
- style: U("password"),
2535
+ style: B("password"),
2537
2536
  disabled: P
2538
2537
  }
2539
2538
  )
@@ -2551,7 +2550,7 @@ function cr({
2551
2550
  E(v.target.value), F.confirmPassword && l((J) => ({ ...J, confirmPassword: !1 })), c === u.passwordMismatchError && L("");
2552
2551
  },
2553
2552
  placeholder: u.confirmPasswordPlaceholder,
2554
- style: U("confirmPassword"),
2553
+ style: B("confirmPassword"),
2555
2554
  disabled: P
2556
2555
  }
2557
2556
  )
@@ -2564,12 +2563,12 @@ function cr({
2564
2563
  id: "tenantName",
2565
2564
  name: "tenantName",
2566
2565
  type: "text",
2567
- value: N,
2566
+ value: U,
2568
2567
  onChange: (v) => {
2569
2568
  D(v.target.value), F.tenantName && l((J) => ({ ...J, tenantName: !1 }));
2570
2569
  },
2571
2570
  placeholder: u.tenantNamePlaceholder,
2572
- style: U("tenantName"),
2571
+ style: B("tenantName"),
2573
2572
  disabled: P
2574
2573
  }
2575
2574
  )
@@ -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(""), [U, 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");
@@ -2781,7 +2780,7 @@ function dr({
2781
2780
  }, K = (q) => ({
2782
2781
  ...p.input,
2783
2782
  ...P[q] ? p.inputError : {}
2784
- }), U = () => ({
2783
+ }), B = () => ({
2785
2784
  ...p.button,
2786
2785
  ...R || h ? p.buttonLoading : {},
2787
2786
  ...!g || R || h ? p.buttonDisabled : {}
@@ -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(
@@ -2881,9 +2880,9 @@ function dr({
2881
2880
  }
2882
2881
  ) })
2883
2882
  ] }),
2884
- /* @__PURE__ */ n("button", { type: "submit", disabled: !g || R || h, style: U(), children: R ? M.loadingText : M.submitButton }),
2883
+ /* @__PURE__ */ n("button", { type: "submit", disabled: !g || R || h, style: B(), children: R ? M.loadingText : M.submitButton }),
2885
2884
  A && /* @__PURE__ */ n("div", { style: p.errorText, children: A }),
2886
- N && /* @__PURE__ */ n("div", { style: p.successText, children: N })
2885
+ U && /* @__PURE__ */ n("div", { style: p.successText, children: U })
2887
2886
  ] }),
2888
2887
  a && /* @__PURE__ */ d("div", { style: p.linkContainer, children: [
2889
2888
  /* @__PURE__ */ d("div", { children: [
@@ -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 {
@@ -3063,7 +3062,7 @@ function ur({
3063
3062
  appId: g || c.get("appId") || "",
3064
3063
  tenantSlug: S || c.get("tenantSlug") || void 0
3065
3064
  };
3066
- }, N = async () => {
3065
+ }, U = async () => {
3067
3066
  I("verifying"), R("");
3068
3067
  try {
3069
3068
  const c = E();
@@ -3082,12 +3081,12 @@ function ur({
3082
3081
  R(L), I("error"), s == null || s(L);
3083
3082
  }
3084
3083
  }, D = () => {
3085
- o == null || o(), N();
3084
+ o == null || o(), U();
3086
3085
  }, P = () => {
3087
3086
  a == null || a();
3088
3087
  };
3089
3088
  re(() => {
3090
- N();
3089
+ U();
3091
3090
  }, []);
3092
3091
  const O = () => {
3093
3092
  switch (T) {
@@ -3281,21 +3280,21 @@ 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 = () => {
3285
- const U = {};
3286
- return b.trim() || (U.email = !0), P(U), Object.keys(U).length === 0;
3283
+ const [b, g] = k(""), [S, f] = k(r), [T, I] = k(""), [C, R] = k(""), [x, h] = k(!1), [$, A] = k(""), [E, U] = k(""), [D, P] = k({}), { requestPasswordReset: O, confirmPasswordReset: c } = oe(), { tenant: L } = le(), F = { ...Ht, ...i }, l = { ...Nt, ...e }, H = () => {
3284
+ const B = {};
3285
+ return b.trim() || (B.email = !0), P(B), Object.keys(B).length === 0;
3287
3286
  }, M = () => {
3288
- const U = {};
3289
- return S.trim() || (U.token = !0), T.trim() || (U.newPassword = !0), C.trim() || (U.confirmPassword = !0), P(U), Object.keys(U).length === 0;
3290
- }, p = async (U) => {
3291
- if (U.preventDefault(), !!H()) {
3287
+ const B = {};
3288
+ return S.trim() || (B.token = !0), T.trim() || (B.newPassword = !0), C.trim() || (B.confirmPassword = !0), P(B), Object.keys(B).length === 0;
3289
+ }, p = async (B) => {
3290
+ if (B.preventDefault(), !!H()) {
3292
3291
  if (!(L != null && L.id)) {
3293
3292
  A("Tenant not found");
3294
3293
  return;
3295
3294
  }
3296
- h(!0), A(""), N("");
3295
+ h(!0), A(""), U("");
3297
3296
  try {
3298
- await O({ email: b, tenantId: L.id }), N(F.successMessage), s == null || s();
3297
+ await O({ email: b, tenantId: L.id }), U(F.successMessage), s == null || s();
3299
3298
  } catch (q) {
3300
3299
  const V = q.message || F.errorMessage;
3301
3300
  A(V), o == null || o(V);
@@ -3303,15 +3302,15 @@ function hr({
3303
3302
  h(!1);
3304
3303
  }
3305
3304
  }
3306
- }, u = async (U) => {
3307
- if (U.preventDefault(), !!M()) {
3305
+ }, u = async (B) => {
3306
+ if (B.preventDefault(), !!M()) {
3308
3307
  if (T !== C) {
3309
3308
  A(F.passwordMismatchError), P({ confirmPassword: !0 });
3310
3309
  return;
3311
3310
  }
3312
- h(!0), A(""), N("");
3311
+ h(!0), A(""), U("");
3313
3312
  try {
3314
- await c({ token: S, newPassword: T }), N(F.resetSuccessMessage), s == null || s();
3313
+ await c({ token: S, newPassword: T }), U(F.resetSuccessMessage), s == null || s();
3315
3314
  } catch (q) {
3316
3315
  const V = q.message || F.errorMessage;
3317
3316
  A(V), o == null || o(V);
@@ -3319,15 +3318,15 @@ function hr({
3319
3318
  h(!1);
3320
3319
  }
3321
3320
  }
3322
- }, w = (U) => ({
3321
+ }, w = (B) => ({
3323
3322
  ...l.input,
3324
- ...D[U] ? l.inputError : {}
3325
- }), G = () => ({
3323
+ ...D[B] ? l.inputError : {}
3324
+ }), _ = () => ({
3326
3325
  ...l.button,
3327
3326
  ...x ? l.buttonLoading : {}
3328
3327
  });
3329
3328
  if (t === "reset") {
3330
- const U = S && T && C;
3329
+ const B = S && T && C;
3331
3330
  return /* @__PURE__ */ d("div", { className: y, style: l.container, children: [
3332
3331
  /* @__PURE__ */ n("h2", { style: l.title, children: F.resetTitle }),
3333
3332
  /* @__PURE__ */ n("p", { style: l.subtitle, children: F.resetSubtitle }),
@@ -3384,10 +3383,10 @@ function hr({
3384
3383
  "button",
3385
3384
  {
3386
3385
  type: "submit",
3387
- disabled: !U || x,
3386
+ disabled: !B || x,
3388
3387
  style: {
3389
- ...G(),
3390
- ...!U || x ? l.buttonDisabled : {}
3388
+ ..._(),
3389
+ ...!B || x ? l.buttonDisabled : {}
3391
3390
  },
3392
3391
  children: x ? F.resetLoadingText : F.resetSubmitButton
3393
3392
  }
@@ -3416,8 +3415,8 @@ function hr({
3416
3415
  {
3417
3416
  type: "email",
3418
3417
  value: b,
3419
- onChange: (U) => {
3420
- g(U.target.value), D.email && P((q) => ({ ...q, email: !1 }));
3418
+ onChange: (B) => {
3419
+ g(B.target.value), D.email && P((q) => ({ ...q, email: !1 }));
3421
3420
  },
3422
3421
  placeholder: F.emailPlaceholder,
3423
3422
  style: w("email"),
@@ -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,11 +3500,11 @@ 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) ?? (() => {
3505
- }), 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 = () => {
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) ?? (() => {
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, U = s || h && S || y && !C || b && !R || g && !x, D = o || (h ? f : null), P = () => {
3506
3505
  o && a(), f && m && I();
3507
3506
  };
3508
- if (N)
3507
+ if (U)
3509
3508
  return /* @__PURE__ */ n(j, { children: e || /* @__PURE__ */ n(Ut, {}) });
3510
3509
  if (D) {
3511
3510
  const O = typeof t == "function" ? t(D, P) : t || /* @__PURE__ */ n(Bt, { error: D, retry: P });
@@ -3514,12 +3513,12 @@ 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) ?? (() => {
3518
- }), 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);
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) ?? (() => {
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, U = t || (x ? g : null);
3519
3518
  return {
3520
3519
  isLoading: E,
3521
- error: N,
3522
- isReady: !E && !N && s !== null && (!x || S !== null),
3520
+ error: U,
3521
+ isReady: !E && !U && s !== null && (!x || S !== null),
3523
3522
  retry: () => {
3524
3523
  t && r(), g && o && T();
3525
3524
  },
@@ -3612,11 +3611,11 @@ function fr({
3612
3611
  cursor: "pointer",
3613
3612
  backgroundColor: E ? "#f0f0f0" : "transparent"
3614
3613
  },
3615
- onMouseEnter: (N) => {
3616
- E || (N.target.style.backgroundColor = "#f5f5f5");
3614
+ onMouseEnter: (U) => {
3615
+ E || (U.target.style.backgroundColor = "#f5f5f5");
3617
3616
  },
3618
- onMouseLeave: (N) => {
3619
- E || (N.target.style.backgroundColor = "transparent");
3617
+ onMouseLeave: (U) => {
3618
+ E || (U.target.style.backgroundColor = "transparent");
3620
3619
  },
3621
3620
  children: a ? a(A, E) : h(A, E)
3622
3621
  },
@@ -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
  };