@skylabs-digital/react-identity-access 2.22.0 → 2.23.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
@@ -13,19 +13,19 @@ class ce {
13
13
  }
14
14
  async executeRequest(e, t, r, i) {
15
15
  const o = `${this.baseUrl}${t.startsWith("/") ? t : `/${t}`}`, a = (i == null ? void 0 : i.timeout) || this.timeout;
16
- let f = {
16
+ let h = {
17
17
  "Content-Type": "application/json",
18
18
  ...i == null ? void 0 : i.headers
19
19
  };
20
20
  if (!(i != null && i.skipAuth) && this.sessionManager) {
21
21
  const c = await this.sessionManager.getValidAccessToken();
22
- f = { ...f, Authorization: `Bearer ${c}` };
22
+ h = { ...h, Authorization: `Bearer ${c}` };
23
23
  }
24
24
  const g = new AbortController(), w = setTimeout(() => g.abort(), a);
25
25
  try {
26
26
  const c = await fetch(o, {
27
27
  method: e,
28
- headers: f,
28
+ headers: h,
29
29
  body: r ? JSON.stringify(r) : void 0,
30
30
  signal: g.signal
31
31
  });
@@ -132,7 +132,7 @@ function yr({ config: n, children: e }) {
132
132
  } catch {
133
133
  return null;
134
134
  }
135
- }), [o, a] = T(!r), [f, g] = T(null), w = Z(() => {
135
+ }), [o, a] = T(!r), [h, g] = T(null), w = Z(() => {
136
136
  const p = () => {
137
137
  c();
138
138
  };
@@ -142,10 +142,10 @@ function yr({ config: n, children: e }) {
142
142
  // App info
143
143
  appInfo: r,
144
144
  isAppLoading: o,
145
- appError: f,
145
+ appError: h,
146
146
  retryApp: p
147
147
  };
148
- }, [n, r, o, f]), c = ie(
148
+ }, [n, r, o, h]), c = ie(
149
149
  async (p = !1) => {
150
150
  if (!(!p && t.enabled && r))
151
151
  try {
@@ -299,8 +299,8 @@ const oe = class oe {
299
299
  const t = e.expiresAt || (e.expiresIn ? Date.now() + e.expiresIn * 1e3 : void 0) || oe.extractJwtExpiry(e.accessToken), r = {
300
300
  ...e,
301
301
  expiresAt: t
302
- };
303
- this.tokenStorage.set(r), this.scheduleProactiveRefresh();
302
+ }, i = this.tokenStorage.get() || {};
303
+ this.tokenStorage.set({ ...i, ...r }), this.scheduleProactiveRefresh();
304
304
  }
305
305
  getTokens() {
306
306
  const { accessToken: e, refreshToken: t, expiresAt: r, expiresIn: i, tokenType: o } = this.tokenStorage.get() || {};
@@ -449,15 +449,15 @@ const oe = class oe {
449
449
  if (this.sessionGeneration !== r)
450
450
  throw new se("token_invalid", "Session cleared during refresh");
451
451
  try {
452
- await this.performTokenRefresh(e);
452
+ await this.performTokenRefresh(e, r);
453
453
  return;
454
454
  } catch (o) {
455
455
  const a = o instanceof Error ? o : new Error(String(o));
456
456
  if (a instanceof se)
457
457
  throw a;
458
458
  if (t = a, i < this.maxRefreshRetries) {
459
- const f = this.retryBackoffBase * Math.pow(2, i);
460
- await this.sleep(f);
459
+ const h = this.retryBackoffBase * Math.pow(2, i);
460
+ await this.sleep(h);
461
461
  }
462
462
  }
463
463
  }
@@ -468,35 +468,37 @@ const oe = class oe {
468
468
  * Throws SessionExpiredError for fatal errors (no retry).
469
469
  * Throws generic Error for transient errors (will be retried).
470
470
  */
471
- async performTokenRefresh(e) {
471
+ async performTokenRefresh(e, t) {
472
472
  if (!this.baseUrl)
473
473
  throw new Error("Base URL not configured for token refresh");
474
- const t = `${this.baseUrl}/auth/refresh`;
475
- let r;
474
+ const r = `${this.baseUrl}/auth/refresh`;
475
+ let i;
476
476
  try {
477
- r = await fetch(t, {
477
+ i = await fetch(r, {
478
478
  method: "POST",
479
479
  headers: { "Content-Type": "application/json" },
480
480
  body: JSON.stringify({ refreshToken: e })
481
481
  });
482
- } catch (o) {
483
- throw o instanceof Error ? o : new Error("Network error during token refresh");
482
+ } catch (a) {
483
+ throw a instanceof Error ? a : new Error("Network error during token refresh");
484
484
  }
485
- if (!r.ok) {
486
- let o = "";
485
+ if (!i.ok) {
486
+ let a = "";
487
487
  try {
488
- const a = await r.json();
489
- o = (a.message || a.error || "").toLowerCase();
488
+ const h = await i.json();
489
+ a = (h.message || h.error || "").toLowerCase();
490
490
  } catch {
491
- o = r.statusText.toLowerCase();
491
+ a = i.statusText.toLowerCase();
492
492
  }
493
- throw r.status === 401 ? o.includes("expired") ? new se("token_expired") : o.includes("invalid") ? new se("token_invalid") : new se("token_invalid", `Unauthorized: ${o}`) : r.status === 400 ? o.includes("inactive") ? new se("user_inactive") : new Error(`Token refresh failed (400): ${o}`) : new Error(`Token refresh failed: ${r.status} ${o}`);
493
+ throw i.status === 401 ? a.includes("expired") ? new se("token_expired") : a.includes("invalid") ? new se("token_invalid") : new se("token_invalid", `Unauthorized: ${a}`) : i.status === 400 ? a.includes("inactive") ? new se("user_inactive") : a.includes("expired") || a.includes("invalid") ? new se("token_invalid", a) : new Error(`Token refresh failed (400): ${a}`) : new Error(`Token refresh failed: ${i.status} ${a}`);
494
494
  }
495
- const i = await r.json();
495
+ if (this.sessionGeneration !== t)
496
+ throw new se("token_invalid", "Session cleared during refresh");
497
+ const o = await i.json();
496
498
  this.setTokens({
497
- accessToken: i.accessToken,
498
- refreshToken: i.refreshToken || e,
499
- expiresIn: i.expiresIn
499
+ accessToken: o.accessToken,
500
+ refreshToken: o.refreshToken || e,
501
+ expiresIn: o.expiresIn
500
502
  });
501
503
  }
502
504
  // --- Session expiry handler ---
@@ -518,7 +520,7 @@ const oe = class oe {
518
520
  }
519
521
  // --- Session lifecycle ---
520
522
  clearSession() {
521
- this.sessionGeneration++, this.cancelProactiveTimer(), this.clearTokens(), this.clearUser();
523
+ this.sessionGeneration++, this.cancelProactiveTimer(), this.clearTokens();
522
524
  const e = new se("token_invalid", "Session cleared");
523
525
  this.rejectQueue(e);
524
526
  }
@@ -903,11 +905,11 @@ function br({ config: n, children: e }) {
903
905
  search: window.location.search
904
906
  },
905
907
  window.localStorage
906
- ), [n.tenantMode, n.baseDomain, n.selectorParam, n.fixedTenantSlug]), [a, f] = T(() => o()), g = Z(
908
+ ), [n.tenantMode, n.baseDomain, n.selectorParam, n.fixedTenantSlug]), [a, h] = T(() => o()), g = Z(
907
909
  () => {
908
- var h, C, S;
910
+ var f, C, S;
909
911
  return {
910
- enabled: ((h = n.cache) == null ? void 0 : h.enabled) ?? !0,
912
+ enabled: ((f = n.cache) == null ? void 0 : f.enabled) ?? !0,
911
913
  ttl: ((C = n.cache) == null ? void 0 : C.ttl) ?? 5 * 60 * 1e3,
912
914
  // 5 minutes default
913
915
  storageKey: ((S = n.cache) == null ? void 0 : S.storageKey) ?? `tenant_cache_${a || "default"}`
@@ -918,9 +920,9 @@ function br({ config: n, children: e }) {
918
920
  if (n.initialTenant) return n.initialTenant;
919
921
  if (!g.enabled || !a) return null;
920
922
  try {
921
- const h = localStorage.getItem(g.storageKey);
922
- if (!h) return null;
923
- const C = JSON.parse(h);
923
+ const f = localStorage.getItem(g.storageKey);
924
+ if (!f) return null;
925
+ const C = JSON.parse(f);
924
926
  return Date.now() - C.timestamp < g.ttl && C.tenantSlug === a ? C.data : (localStorage.removeItem(g.storageKey), null);
925
927
  } catch {
926
928
  return null;
@@ -928,21 +930,21 @@ function br({ config: n, children: e }) {
928
930
  }), [I, p] = T(!w && !n.initialTenant), [x, R] = T(null), [F, E] = T(null), [A, u] = T(!1), [k, m] = T(null);
929
931
  ee(() => {
930
932
  if (n.tenantMode === "fixed") return;
931
- const h = o();
932
- f(h);
933
+ const f = o();
934
+ h(f);
933
935
  }, [o, n.tenantMode]);
934
936
  const M = (r == null ? void 0 : r.settingsSchema) || null, L = ie(
935
- async (h, C = !1) => {
936
- if (!(!C && g.enabled && w && w.domain === h))
937
+ async (f, C = !1) => {
938
+ if (!(!C && g.enabled && w && w.domain === f))
937
939
  try {
938
940
  p(!0), R(null);
939
- const S = new ce(t), y = await new ve(S, i).getPublicTenantInfo(h);
941
+ const S = new ce(t), y = await new ve(S, i).getPublicTenantInfo(f);
940
942
  if (c(y), g.enabled)
941
943
  try {
942
944
  const v = {
943
945
  data: y,
944
946
  timestamp: Date.now(),
945
- tenantSlug: h
947
+ tenantSlug: f
946
948
  };
947
949
  localStorage.setItem(g.storageKey, JSON.stringify(v));
948
950
  } catch (v) {
@@ -959,9 +961,9 @@ function br({ config: n, children: e }) {
959
961
  ), D = ie(async () => {
960
962
  if (!(!g.enabled || !w || !a))
961
963
  try {
962
- const h = localStorage.getItem(g.storageKey);
963
- if (!h) return;
964
- const C = JSON.parse(h);
964
+ const f = localStorage.getItem(g.storageKey);
965
+ if (!f) return;
966
+ const C = JSON.parse(f);
965
967
  if (Date.now() - C.timestamp > g.ttl * 0.5) {
966
968
  const b = new ce(t), v = await new ve(b, i).getPublicTenantInfo(a);
967
969
  c(v);
@@ -972,17 +974,17 @@ function br({ config: n, children: e }) {
972
974
  };
973
975
  localStorage.setItem(g.storageKey, JSON.stringify(G));
974
976
  }
975
- } catch (h) {
976
- console.warn("Background tenant refresh failed:", h);
977
+ } catch (f) {
978
+ console.warn("Background tenant refresh failed:", f);
977
979
  }
978
980
  }, [t, i, g, w, a]), P = ie(async () => {
979
981
  if (w != null && w.id)
980
982
  try {
981
983
  u(!0), m(null);
982
- const h = new ce(t), S = await new ve(h, w.appId).getTenantSettings(w.id);
984
+ const f = new ce(t), S = await new ve(f, w.appId).getTenantSettings(w.id);
983
985
  E(S);
984
- } catch (h) {
985
- const C = h instanceof Error ? h : new Error("Failed to load tenant settings");
986
+ } catch (f) {
987
+ const C = f instanceof Error ? f : new Error("Failed to load tenant settings");
986
988
  m(C), E(null);
987
989
  } finally {
988
990
  u(!1);
@@ -990,14 +992,14 @@ function br({ config: n, children: e }) {
990
992
  }, [t, w]), U = ie(() => {
991
993
  P();
992
994
  }, [P]), l = ie(
993
- (h) => {
995
+ (f) => {
994
996
  if (!M)
995
997
  return { isValid: !0, errors: [] };
996
998
  const C = [];
997
999
  try {
998
1000
  return M.properties && Object.entries(M.properties).forEach(([S, b]) => {
999
1001
  var v;
1000
- const y = h[S];
1002
+ const y = f[S];
1001
1003
  if ((v = M.required) != null && v.includes(S) && y == null) {
1002
1004
  C.push(`Field '${S}' is required`);
1003
1005
  return;
@@ -1032,7 +1034,7 @@ function br({ config: n, children: e }) {
1032
1034
  w != null && w.id ? P() : (E(null), m(null), u(!1));
1033
1035
  }, [w == null ? void 0 : w.id, P]);
1034
1036
  const N = ie(
1035
- (h, C) => {
1037
+ (f, C) => {
1036
1038
  const { mode: S = "reload", tokens: b, redirectPath: y } = C || {}, v = n.tenantMode || "selector";
1037
1039
  if (v === "fixed") {
1038
1040
  console.warn(
@@ -1041,9 +1043,9 @@ function br({ config: n, children: e }) {
1041
1043
  ), y && (window.location.href = y);
1042
1044
  return;
1043
1045
  }
1044
- if (localStorage.setItem("tenant", h), v === "subdomain") {
1046
+ if (localStorage.setItem("tenant", f), v === "subdomain") {
1045
1047
  const G = window.location.hostname, Q = xt(
1046
- h,
1048
+ f,
1047
1049
  G,
1048
1050
  n.baseDomain
1049
1051
  );
@@ -1060,17 +1062,17 @@ function br({ config: n, children: e }) {
1060
1062
  }), b && q.searchParams.set(ge, We(b)), window.location.href = q.toString();
1061
1063
  } else if (v === "selector") {
1062
1064
  const G = y || window.location.pathname, Q = new URLSearchParams(window.location.search);
1063
- if (Q.set(n.selectorParam || "tenant", h), Q.delete(ge), b && Q.set(ge, We(b)), S === "reload") {
1065
+ if (Q.set(n.selectorParam || "tenant", f), Q.delete(ge), b && Q.set(ge, We(b)), S === "reload") {
1064
1066
  const O = `${G}?${Q.toString()}${window.location.hash}`;
1065
1067
  window.location.href = O;
1066
1068
  } else {
1067
1069
  const O = `${G}?${Q.toString()}${window.location.hash}`;
1068
- window.history.pushState({}, "", O), f(h), L(h);
1070
+ window.history.pushState({}, "", O), h(f), L(f);
1069
1071
  }
1070
1072
  }
1071
1073
  },
1072
1074
  [n.tenantMode, n.selectorParam, n.baseDomain, L]
1073
- ), $ = Z(() => ({
1075
+ ), H = Z(() => ({
1074
1076
  // Tenant info
1075
1077
  tenant: w,
1076
1078
  tenantSlug: a,
@@ -1102,7 +1104,7 @@ function br({ config: n, children: e }) {
1102
1104
  N,
1103
1105
  l
1104
1106
  ]);
1105
- return /* @__PURE__ */ s(De.Provider, { value: $, children: e });
1107
+ return /* @__PURE__ */ s(De.Provider, { value: H, children: e });
1106
1108
  }
1107
1109
  function ye() {
1108
1110
  const n = le(De);
@@ -1136,7 +1138,7 @@ function we() {
1136
1138
  }
1137
1139
  const Ne = me(null);
1138
1140
  function Tr({ config: n = {}, children: e }) {
1139
- const { appId: t, baseUrl: r } = ke(), { tenant: i, tenantSlug: o, switchTenant: a } = ye(), [f, g] = T(n.initialRoles || []), [w, c] = T(!n.initialRoles), [I, p] = T(null), [x, R] = T(!1), [F, E] = T(null), [A, u] = T(0), [k, m] = T(() => {
1141
+ const { appId: t, baseUrl: r } = ke(), { tenant: i, tenantSlug: o, switchTenant: a } = ye(), [h, g] = T(n.initialRoles || []), [w, c] = T(!n.initialRoles), [I, p] = T(null), [x, R] = T(!1), [F, E] = T(null), [A, u] = T(0), [k, m] = T(() => {
1140
1142
  try {
1141
1143
  const V = localStorage.getItem("userTenants");
1142
1144
  return V ? JSON.parse(V) : [];
@@ -1170,20 +1172,20 @@ function Tr({ config: n = {}, children: e }) {
1170
1172
  refreshToken: D.current.urlTokens.refreshToken,
1171
1173
  expiresIn: D.current.urlTokens.expiresIn
1172
1174
  }), console.log("[AuthProvider] SYNC: Session valid:", V.hasValidSession())), V;
1173
- }, [o, r, n.refreshQueueTimeout, n.proactiveRefreshMargin]), [N, $] = T(() => {
1175
+ }, [o, r, n.refreshQueueTimeout, n.proactiveRefreshMargin]), [N, H] = T(() => {
1174
1176
  if (D.current.urlTokens) return !1;
1175
1177
  const V = l.getTokens();
1176
1178
  return V ? l.hasValidSession() || !!V.refreshToken : !1;
1177
- }), h = D.current.done && !P && !N, C = Z(() => {
1179
+ }), f = D.current.done && !P && !N, C = Z(() => {
1178
1180
  const V = new ce(r);
1179
1181
  return V.setSessionManager(l), V;
1180
- }, [r, l]), S = Z(() => new bt(new ce(r)), [r]), b = Z(() => new St(C, l), [C, l]), y = Z(() => new _e(new ce(r)), [r]), v = Z(() => I || l.getUser(), [I, l]), G = Z(() => v != null && v.roleId && f.find((V) => V.id === v.roleId) || null, [v, f]), Q = Z(() => (G == null ? void 0 : G.permissions) || [], [G]), O = Z(() => l.hasValidSession() && I !== null, [l, I]), q = 5 * 60 * 1e3, W = Z(() => {
1181
- const V = async (H = !1) => {
1182
+ }, [r, l]), S = Z(() => new bt(new ce(r)), [r]), b = Z(() => new St(C, l), [C, l]), y = Z(() => new _e(new ce(r)), [r]), v = Z(() => I || l.getUser(), [I, l]), G = Z(() => v != null && v.roleId && h.find((V) => V.id === v.roleId) || null, [v, h]), Q = Z(() => (G == null ? void 0 : G.permissions) || [], [G]), O = Z(() => l.hasValidSession() && I !== null, [l, I]), q = 5 * 60 * 1e3, W = Z(() => {
1183
+ const V = async ($ = !1) => {
1182
1184
  try {
1183
1185
  if (!l.hasValidSession())
1184
1186
  return;
1185
1187
  const z = Date.now();
1186
- if (!H && z - A < q && I)
1188
+ if (!$ && z - A < q && I)
1187
1189
  return;
1188
1190
  const j = l.getUserId();
1189
1191
  if (!j) {
@@ -1201,9 +1203,9 @@ function Tr({ config: n = {}, children: e }) {
1201
1203
  }
1202
1204
  }, he = async () => {
1203
1205
  await V();
1204
- }, fe = async (H) => {
1206
+ }, fe = async ($) => {
1205
1207
  var qe;
1206
- const { username: z, password: Y, tenantSlug: j, redirectPath: J } = H;
1208
+ const { username: z, password: Y, tenantSlug: j, redirectPath: J } = $;
1207
1209
  let te = i == null ? void 0 : i.id, re = o, ne = l;
1208
1210
  j && (te = (await new ve(C, t).getPublicTenantInfo(j)).id, re = j);
1209
1211
  const K = await S.login({
@@ -1246,15 +1248,15 @@ function Tr({ config: n = {}, children: e }) {
1246
1248
  if (J && J !== window.location.pathname)
1247
1249
  return a(re || o || "", { tokens: Ee, redirectPath: J }), K;
1248
1250
  if (!Ie && K.tenants && K.tenants.length > 0) {
1249
- const xe = H.autoSwitch !== !1 && n.autoSwitchSingleTenant !== !1;
1251
+ const xe = $.autoSwitch !== !1 && n.autoSwitchSingleTenant !== !1;
1250
1252
  if (K.tenants.length === 1 && xe) {
1251
1253
  const Oe = K.tenants[0];
1252
1254
  return a(Oe.subdomain, { tokens: Ee, redirectPath: J }), K;
1253
1255
  } else K.tenants.length > 1 && n.onTenantSelectionRequired && n.onTenantSelectionRequired(K.tenants);
1254
1256
  }
1255
1257
  return K;
1256
- }, pe = async (H) => {
1257
- const { email: z, phoneNumber: Y, name: j, password: J, lastName: te, tenantId: re } = H;
1258
+ }, pe = async ($) => {
1259
+ const { email: z, phoneNumber: Y, name: j, password: J, lastName: te, tenantId: re } = $;
1258
1260
  if (!z && !Y)
1259
1261
  throw new Error("Either email or phoneNumber is required");
1260
1262
  if (!j || !J)
@@ -1269,8 +1271,8 @@ function Tr({ config: n = {}, children: e }) {
1269
1271
  lastName: te,
1270
1272
  appId: t
1271
1273
  });
1272
- }, rt = async (H) => {
1273
- const { email: z, phoneNumber: Y, name: j, password: J, tenantName: te, lastName: re } = H;
1274
+ }, rt = async ($) => {
1275
+ const { email: z, phoneNumber: Y, name: j, password: J, tenantName: te, lastName: re } = $;
1274
1276
  if (!z && !Y)
1275
1277
  throw new Error("Either email or phoneNumber is required");
1276
1278
  if (!j || !J || !te)
@@ -1284,19 +1286,19 @@ function Tr({ config: n = {}, children: e }) {
1284
1286
  appId: t,
1285
1287
  lastName: re
1286
1288
  });
1287
- }, nt = async (H) => {
1288
- const { currentPassword: z, newPassword: Y } = H, j = await l.getAuthHeaders();
1289
+ }, nt = async ($) => {
1290
+ const { currentPassword: z, newPassword: Y } = $, j = await l.getAuthHeaders();
1289
1291
  await S.changePassword({ currentPassword: z, newPassword: Y }, j);
1290
- }, st = async (H) => {
1291
- const { email: z, tenantId: Y } = H, j = Y ?? (i == null ? void 0 : i.id);
1292
+ }, st = async ($) => {
1293
+ const { email: z, tenantId: Y } = $, j = Y ?? (i == null ? void 0 : i.id);
1292
1294
  if (!j)
1293
1295
  throw new Error("tenantId is required for password reset");
1294
1296
  await S.requestPasswordReset({ email: z, tenantId: j });
1295
- }, it = async (H) => {
1296
- const { token: z, newPassword: Y } = H;
1297
+ }, it = async ($) => {
1298
+ const { token: z, newPassword: Y } = $;
1297
1299
  await S.confirmPasswordReset({ token: z, newPassword: Y });
1298
- }, ot = async (H) => {
1299
- const { email: z, frontendUrl: Y, name: j, lastName: J, tenantId: te } = H, re = te ?? (i == null ? void 0 : i.id);
1300
+ }, ot = async ($) => {
1301
+ const { email: z, frontendUrl: Y, name: j, lastName: J, tenantId: te } = $, re = te ?? (i == null ? void 0 : i.id);
1300
1302
  if (!re)
1301
1303
  throw new Error("tenantId is required for magic link authentication");
1302
1304
  return await S.sendMagicLink({
@@ -1307,8 +1309,8 @@ function Tr({ config: n = {}, children: e }) {
1307
1309
  lastName: J,
1308
1310
  appId: t
1309
1311
  });
1310
- }, at = async (H) => {
1311
- const { token: z, email: Y, tenantSlug: j } = H;
1312
+ }, at = async ($) => {
1313
+ const { token: z, email: Y, tenantSlug: j } = $;
1312
1314
  let J = i == null ? void 0 : i.id, te = o, re = l;
1313
1315
  j && (J = (await new ve(C, t).getPublicTenantInfo(j)).id, te = j);
1314
1316
  const ne = await S.verifyMagicLink({
@@ -1340,15 +1342,15 @@ function Tr({ config: n = {}, children: e }) {
1340
1342
  }
1341
1343
  }), ne;
1342
1344
  }, lt = async () => {
1343
- const H = l.getTokens();
1344
- if (!(H != null && H.refreshToken))
1345
+ const $ = l.getTokens();
1346
+ if (!($ != null && $.refreshToken))
1345
1347
  throw new Error("No refresh token available");
1346
1348
  const z = await S.refreshToken({
1347
- refreshToken: H.refreshToken
1349
+ refreshToken: $.refreshToken
1348
1350
  });
1349
1351
  l.setTokens({
1350
1352
  accessToken: z.accessToken,
1351
- refreshToken: z.refreshToken || H.refreshToken,
1353
+ refreshToken: z.refreshToken || $.refreshToken,
1352
1354
  expiresIn: z.expiresIn
1353
1355
  });
1354
1356
  }, ct = () => {
@@ -1357,29 +1359,29 @@ function Tr({ config: n = {}, children: e }) {
1357
1359
  localStorage.removeItem("userTenants");
1358
1360
  } catch {
1359
1361
  }
1360
- }, dt = (H) => {
1361
- l.setTokens(H);
1362
+ }, dt = ($) => {
1363
+ l.setTokens($);
1362
1364
  }, ut = () => l.hasValidSession(), ht = () => {
1363
1365
  l.clearSession(), p(null), E(null);
1364
1366
  }, ft = async () => {
1365
1367
  if (t)
1366
1368
  try {
1367
1369
  c(!0);
1368
- const { roles: H } = await y.getRolesByApp(t);
1369
- g(H);
1370
- } catch (H) {
1371
- console.error("Failed to fetch roles:", H);
1370
+ const { roles: $ } = await y.getRolesByApp(t);
1371
+ g($);
1372
+ } catch ($) {
1373
+ console.error("Failed to fetch roles:", $);
1372
1374
  } finally {
1373
1375
  c(!1);
1374
1376
  }
1375
1377
  }, pt = async () => {
1376
1378
  await ft();
1377
- }, Re = (H) => {
1379
+ }, Re = ($) => {
1378
1380
  if (!Q || Q.length === 0)
1379
1381
  return !1;
1380
- if (typeof H == "string")
1381
- return Q.includes(H);
1382
- const z = `${H.resource}.${H.action}`;
1382
+ if (typeof $ == "string")
1383
+ return Q.includes($);
1384
+ const z = `${$.resource}.${$.action}`;
1383
1385
  return Q.includes(z);
1384
1386
  };
1385
1387
  return {
@@ -1405,27 +1407,27 @@ function Tr({ config: n = {}, children: e }) {
1405
1407
  userError: F,
1406
1408
  loadUserData: V,
1407
1409
  refreshUser: he,
1408
- isAuthInitializing: !h,
1409
- isAuthReady: h,
1410
+ isAuthInitializing: !f,
1411
+ isAuthReady: f,
1410
1412
  userRole: G,
1411
1413
  userPermissions: Q,
1412
- availableRoles: f,
1414
+ availableRoles: h,
1413
1415
  rolesLoading: w,
1414
1416
  hasPermission: Re,
1415
- hasAnyPermission: (H) => H.some((z) => Re(z)),
1416
- hasAllPermissions: (H) => H.every((z) => Re(z)),
1417
+ hasAnyPermission: ($) => $.some((z) => Re(z)),
1418
+ hasAllPermissions: ($) => $.every((z) => Re(z)),
1417
1419
  getUserPermissionStrings: () => Q || [],
1418
1420
  refreshRoles: pt,
1419
1421
  // RFC-004: Multi-tenant user membership
1420
1422
  userTenants: k,
1421
1423
  hasTenantContext: M,
1422
- switchToTenant: async (H, z) => {
1424
+ switchToTenant: async ($, z) => {
1423
1425
  const { redirectPath: Y } = z || {}, j = l.getTokens();
1424
1426
  if (!(j != null && j.refreshToken))
1425
1427
  throw new Error("No refresh token available for tenant switch");
1426
1428
  const J = await S.switchTenant({
1427
1429
  refreshToken: j.refreshToken,
1428
- tenantId: H
1430
+ tenantId: $
1429
1431
  });
1430
1432
  l.setTokens({
1431
1433
  accessToken: J.accessToken,
@@ -1433,7 +1435,7 @@ function Tr({ config: n = {}, children: e }) {
1433
1435
  // Keep the same refresh token
1434
1436
  expiresIn: J.expiresIn
1435
1437
  }), p(J.user), l.setUser(J.user), L(!0);
1436
- const te = k.find((re) => re.id === H);
1438
+ const te = k.find((re) => re.id === $);
1437
1439
  te && a(te.subdomain, {
1438
1440
  tokens: {
1439
1441
  accessToken: J.accessToken,
@@ -1444,7 +1446,7 @@ function Tr({ config: n = {}, children: e }) {
1444
1446
  });
1445
1447
  },
1446
1448
  refreshUserTenants: async () => {
1447
- const H = await l.getAuthHeaders(), z = await S.getUserTenants(H);
1449
+ const $ = await l.getAuthHeaders(), z = await S.getUserTenants($);
1448
1450
  m(z);
1449
1451
  try {
1450
1452
  localStorage.setItem("userTenants", JSON.stringify(z));
@@ -1464,13 +1466,13 @@ function Tr({ config: n = {}, children: e }) {
1464
1466
  i,
1465
1467
  o,
1466
1468
  a,
1467
- f,
1469
+ h,
1468
1470
  I,
1469
1471
  x,
1470
1472
  F,
1471
1473
  k,
1472
1474
  M,
1473
- h,
1475
+ f,
1474
1476
  G,
1475
1477
  Q,
1476
1478
  A,
@@ -1502,15 +1504,15 @@ function Tr({ config: n = {}, children: e }) {
1502
1504
  var pe;
1503
1505
  if (!l.hasValidSession() && ((pe = l.getTokens()) != null && pe.refreshToken) && await l.waitForPendingRefresh(), V) return;
1504
1506
  const fe = l.getUser();
1505
- fe && l.hasValidSession() ? (p(fe), $(!1)) : l.hasValidSession() || $(!1);
1507
+ fe && l.hasValidSession() && p(fe), H(!1);
1506
1508
  })(), () => {
1507
1509
  V = !0;
1508
1510
  };
1509
1511
  }, [l]), ee(() => {
1510
1512
  B && (D.current.urlTokens || (!I && !x && l.hasValidSession() ? (console.log("[AuthProvider] Auto-loading user data..."), W.loadUserData().catch(() => {
1511
1513
  }).finally(() => {
1512
- $(!1);
1513
- })) : I && $(!1)));
1514
+ H(!1);
1515
+ })) : I && H(!1)));
1514
1516
  }, [I, x, W, l, B]), ee(() => {
1515
1517
  if (!l.hasValidSession() || !I)
1516
1518
  return;
@@ -1612,7 +1614,7 @@ class It {
1612
1614
  }
1613
1615
  const Ue = me(null);
1614
1616
  function kr({ config: n = {}, children: e }) {
1615
- const t = Ze(), r = Pe(), i = (t == null ? void 0 : t.baseUrl) ?? "", o = (t == null ? void 0 : t.appId) ?? "", a = (r == null ? void 0 : r.tenant) ?? null, [f, g] = T([]), [w, c] = T(!1), [I, p] = T(null), [x, R] = T(!1), F = Z(() => {
1617
+ const t = Ze(), r = Pe(), i = (t == null ? void 0 : t.baseUrl) ?? "", o = (t == null ? void 0 : t.appId) ?? "", a = (r == null ? void 0 : r.tenant) ?? null, [h, g] = T([]), [w, c] = T(!1), [I, p] = T(null), [x, R] = T(!1), F = Z(() => {
1616
1618
  const u = new ce(i);
1617
1619
  return new It(u);
1618
1620
  }, [i]), E = async () => {
@@ -1639,16 +1641,16 @@ function kr({ config: n = {}, children: e }) {
1639
1641
  }, [a == null ? void 0 : a.id, i, o, n.refreshInterval]);
1640
1642
  const A = Z(() => {
1641
1643
  const u = (D) => {
1642
- const P = f.find((U) => U.key === D);
1644
+ const P = h.find((U) => U.key === D);
1643
1645
  return (P == null ? void 0 : P.value) === !0;
1644
- }, k = (D) => f.find((P) => P.key === D), m = (D) => {
1645
- const P = f.find((U) => U.key === D);
1646
+ }, k = (D) => h.find((P) => P.key === D), m = (D) => {
1647
+ const P = h.find((U) => U.key === D);
1646
1648
  return P ? P.value ? "enabled" : "disabled" : "not_found";
1647
1649
  }, M = async () => {
1648
1650
  await E();
1649
1651
  }, L = !!(i && o) && (x || !(a != null && a.id));
1650
1652
  return {
1651
- featureFlags: f,
1653
+ featureFlags: h,
1652
1654
  loading: w,
1653
1655
  error: I,
1654
1656
  isReady: L,
@@ -1657,7 +1659,7 @@ function kr({ config: n = {}, children: e }) {
1657
1659
  getFlagState: m,
1658
1660
  refresh: M
1659
1661
  };
1660
- }, [f, w, I, i, o, a == null ? void 0 : a.id, x]);
1662
+ }, [h, w, I, i, o, a == null ? void 0 : a.id, x]);
1661
1663
  return /* @__PURE__ */ s(Ue.Provider, { value: A, children: e });
1662
1664
  }
1663
1665
  function Et() {
@@ -1737,18 +1739,18 @@ class Mt {
1737
1739
  }
1738
1740
  const $e = me(void 0);
1739
1741
  function xr({ config: n = {}, children: e }) {
1740
- const t = Ze(), r = Pe(), i = (t == null ? void 0 : t.baseUrl) ?? "", o = (r == null ? void 0 : r.tenant) ?? null, [a, f] = T(null), [g, w] = T(!1), [c, I] = T(null), [p, x] = T(!1), R = Z(() => {
1742
+ const t = Ze(), r = Pe(), i = (t == null ? void 0 : t.baseUrl) ?? "", o = (r == null ? void 0 : r.tenant) ?? null, [a, h] = T(null), [g, w] = T(!1), [c, I] = T(null), [p, x] = T(!1), R = Z(() => {
1741
1743
  const A = new ce(i);
1742
1744
  return new Mt(A);
1743
1745
  }, [i]), F = async () => {
1744
1746
  if (!(o != null && o.id)) {
1745
- f(null);
1747
+ h(null);
1746
1748
  return;
1747
1749
  }
1748
1750
  w(!0), I(null);
1749
1751
  try {
1750
1752
  const A = await R.getTenantSubscriptionFeatures(o.id);
1751
- f(A);
1753
+ h(A);
1752
1754
  } catch (A) {
1753
1755
  const u = A instanceof Error ? A.message : "Failed to fetch subscription";
1754
1756
  I(u), n.onError && n.onError(A instanceof Error ? A : new Error(u));
@@ -1954,7 +1956,7 @@ function Rr({
1954
1956
  requiredPermissions: r,
1955
1957
  requireAllPermissions: i = !1
1956
1958
  }) {
1957
- const { hasValidSession: o, sessionManager: a, hasPermission: f, hasAnyPermission: g, hasAllPermissions: w } = ue();
1959
+ const { hasValidSession: o, sessionManager: a, hasPermission: h, hasAnyPermission: g, hasAllPermissions: w } = ue();
1958
1960
  if (!o())
1959
1961
  return /* @__PURE__ */ s(_, { children: e || /* @__PURE__ */ s(Ve, {}) });
1960
1962
  const c = a.getUser();
@@ -1963,7 +1965,7 @@ function Rr({
1963
1965
  if (t && !Dt(c.userType, t))
1964
1966
  return /* @__PURE__ */ s(je, { userType: c.userType, minUserType: t });
1965
1967
  if (r && r.length > 0 && !(i ? w(r) : g(r))) {
1966
- const p = r.filter((x) => !f(x)).map((x) => typeof x == "string" ? x : x.name);
1968
+ const p = r.filter((x) => !h(x)).map((x) => typeof x == "string" ? x : x.name);
1967
1969
  return /* @__PURE__ */ s(je, { missingPermissions: p });
1968
1970
  }
1969
1971
  return /* @__PURE__ */ s(_, { children: n });
@@ -2064,7 +2066,7 @@ function Ir({
2064
2066
  requireAllPermissions: i = !1,
2065
2067
  fallback: o
2066
2068
  }) {
2067
- const { hasValidSession: a, sessionManager: f, hasPermission: g, hasAnyPermission: w, hasAllPermissions: c } = ue(), I = Ae();
2069
+ const { hasValidSession: a, sessionManager: h, hasPermission: g, hasAnyPermission: w, hasAllPermissions: c } = ue(), I = Ae();
2068
2070
  if (ee(() => {
2069
2071
  process.env.NODE_ENV === "development" && console.warn(
2070
2072
  "[react-identity-access] ProtectedRoute is deprecated. Use AuthenticatedZone or AdminZone from ZoneRoute instead."
@@ -2074,7 +2076,7 @@ function Ir({
2074
2076
  /* @__PURE__ */ s(Nt, { redirectPath: e }),
2075
2077
  /* @__PURE__ */ s(Te, { to: e, state: { from: I.pathname }, replace: !0 })
2076
2078
  ] });
2077
- const p = f.getUser();
2079
+ const p = h.getUser();
2078
2080
  if (!p)
2079
2081
  return /* @__PURE__ */ s(Te, { to: e, state: { from: I.pathname }, replace: !0 });
2080
2082
  if (t && !Ct(p.userType, t))
@@ -2218,7 +2220,7 @@ const de = ({
2218
2220
  userType: i,
2219
2221
  requiredPermissions: o,
2220
2222
  requireAllPermissions: a = !0,
2221
- returnTo: f,
2223
+ returnTo: h,
2222
2224
  onAccessDenied: g,
2223
2225
  redirectTo: w,
2224
2226
  loadingFallback: c,
@@ -2271,10 +2273,10 @@ const de = ({
2271
2273
  if (ee(() => {
2272
2274
  U && (g ? g(U) : k.onAccessDenied && k.onAccessDenied(U));
2273
2275
  }, [U, g, k]), ee(() => {
2274
- U && f && zt(f, p.pathname + p.search, k.returnToStorage);
2276
+ U && h && zt(h, p.pathname + p.search, k.returnToStorage);
2275
2277
  }, [
2276
2278
  U,
2277
- f,
2279
+ h,
2278
2280
  p.pathname,
2279
2281
  p.search,
2280
2282
  k.returnToStorage
@@ -2286,7 +2288,7 @@ const de = ({
2286
2288
  return /* @__PURE__ */ s(_, { children: l });
2287
2289
  const N = Ot(
2288
2290
  P,
2289
- f,
2291
+ h,
2290
2292
  p.pathname + p.search,
2291
2293
  k.returnToParam,
2292
2294
  k.returnToStorage
@@ -2317,8 +2319,8 @@ function Or({
2317
2319
  allowedPlans: t,
2318
2320
  requiredFeature: r
2319
2321
  }) {
2320
- const { subscription: i, hasAllowedPlan: o, isFeatureEnabled: a, loading: f } = Lt();
2321
- return f ? /* @__PURE__ */ s(
2322
+ const { subscription: i, hasAllowedPlan: o, isFeatureEnabled: a, loading: h } = Lt();
2323
+ return h ? /* @__PURE__ */ s(
2322
2324
  "div",
2323
2325
  {
2324
2326
  style: {
@@ -2540,17 +2542,17 @@ function _r({
2540
2542
  onError: i,
2541
2543
  onForgotPassword: o,
2542
2544
  onSignupClick: a,
2543
- onMagicLinkClick: f,
2545
+ onMagicLinkClick: h,
2544
2546
  showForgotPassword: g = !0,
2545
2547
  showSignupLink: w = !0,
2546
2548
  showMagicLinkOption: c = !0,
2547
2549
  className: I
2548
2550
  }) {
2549
- const [p, x] = T(""), [R, F] = T(""), [E, A] = T(!1), [u, k] = T(!1), [m, M] = T(""), [L, D] = T({}), { login: P } = ue(), { tenant: U } = we(), l = { ...Qt, ...n }, N = { ...Kt, ...e }, $ = { ...Gt, ...t }, h = () => {
2551
+ const [p, x] = T(""), [R, F] = T(""), [E, A] = T(!1), [u, k] = T(!1), [m, M] = T(""), [L, D] = T({}), { login: P } = ue(), { tenant: U } = we(), l = { ...Qt, ...n }, N = { ...Kt, ...e }, H = { ...Gt, ...t }, f = () => {
2550
2552
  const y = {};
2551
2553
  return p.trim() || (y.username = !0), R.trim() || (y.password = !0), D(y), Object.keys(y).length === 0;
2552
2554
  }, C = async (y) => {
2553
- if (y.preventDefault(), !!h()) {
2555
+ if (y.preventDefault(), !!f()) {
2554
2556
  if (!(U != null && U.id)) {
2555
2557
  M("Tenant not found");
2556
2558
  return;
@@ -2629,7 +2631,7 @@ function _r({
2629
2631
  style: N.passwordToggle,
2630
2632
  disabled: u,
2631
2633
  "aria-label": E ? "Hide password" : "Show password",
2632
- children: E ? $.hidePassword : $.showPassword
2634
+ children: E ? H.hidePassword : H.showPassword
2633
2635
  }
2634
2636
  )
2635
2637
  ] })
@@ -2643,7 +2645,7 @@ function _r({
2643
2645
  l.magicLinkText,
2644
2646
  " "
2645
2647
  ] }),
2646
- /* @__PURE__ */ s("a", { onClick: f, style: N.link, children: l.magicLinkLink })
2648
+ /* @__PURE__ */ s("a", { onClick: h, style: N.link, children: l.magicLinkLink })
2647
2649
  ] }),
2648
2650
  c && (g || w) && /* @__PURE__ */ s("div", { style: N.divider, children: "•" }),
2649
2651
  g && /* @__PURE__ */ s("a", { onClick: o, style: N.link, children: l.forgotPasswordLink }),
@@ -2791,17 +2793,17 @@ function Wr({
2791
2793
  onError: i,
2792
2794
  onLoginClick: o,
2793
2795
  onMagicLinkClick: a,
2794
- showLoginLink: f = !0,
2796
+ showLoginLink: h = !0,
2795
2797
  showMagicLinkOption: g = !0,
2796
2798
  className: w
2797
2799
  }) {
2798
- const [c, I] = T(""), [p, x] = T(""), [R, F] = T(""), [E, A] = T(""), [u, k] = T(""), [m, M] = T(""), [L, D] = T(""), [P, U] = T(!1), [l, N] = T(""), [$, h] = T({}), { signup: C, signupTenantAdmin: S } = ue(), { tenant: b } = we(), y = { ...Zt, ...n }, v = { ...Jt, ...e }, G = () => {
2800
+ const [c, I] = T(""), [p, x] = T(""), [R, F] = T(""), [E, A] = T(""), [u, k] = T(""), [m, M] = T(""), [L, D] = T(""), [P, U] = T(!1), [l, N] = T(""), [H, f] = T({}), { signup: C, signupTenantAdmin: S } = ue(), { tenant: b } = we(), y = { ...Zt, ...n }, v = { ...Jt, ...e }, G = () => {
2799
2801
  const B = {};
2800
- return c.trim() || (B.name = !0), !R.trim() && !E.trim() && (B.email = !0, B.phoneNumber = !0), u.trim() || (B.password = !0), m.trim() || (B.confirmPassword = !0), t === "tenant" && !L.trim() && (B.tenantName = !0), h(B), Object.keys(B).length === 0;
2802
+ return c.trim() || (B.name = !0), !R.trim() && !E.trim() && (B.email = !0, B.phoneNumber = !0), u.trim() || (B.password = !0), m.trim() || (B.confirmPassword = !0), t === "tenant" && !L.trim() && (B.tenantName = !0), f(B), Object.keys(B).length === 0;
2801
2803
  }, Q = async (B) => {
2802
2804
  if (B.preventDefault(), !!G()) {
2803
2805
  if (u !== m) {
2804
- N(y.passwordMismatchError), h({ confirmPassword: !0 });
2806
+ N(y.passwordMismatchError), f({ confirmPassword: !0 });
2805
2807
  return;
2806
2808
  }
2807
2809
  if (t === "user" && !(b != null && b.id)) {
@@ -2835,7 +2837,7 @@ function Wr({
2835
2837
  }
2836
2838
  }, O = (B) => ({
2837
2839
  ...v.input,
2838
- ...$[B] ? v.inputError : {}
2840
+ ...H[B] ? v.inputError : {}
2839
2841
  }), q = () => ({
2840
2842
  ...v.button,
2841
2843
  ...P ? v.buttonLoading : {},
@@ -2854,7 +2856,7 @@ function Wr({
2854
2856
  type: "text",
2855
2857
  value: c,
2856
2858
  onChange: (B) => {
2857
- I(B.target.value), $.name && h((X) => ({ ...X, name: !1 }));
2859
+ I(B.target.value), H.name && f((X) => ({ ...X, name: !1 }));
2858
2860
  },
2859
2861
  placeholder: y.namePlaceholder,
2860
2862
  style: O("name"),
@@ -2888,7 +2890,7 @@ function Wr({
2888
2890
  type: "email",
2889
2891
  value: R,
2890
2892
  onChange: (B) => {
2891
- F(B.target.value), $.email && h((X) => ({ ...X, email: !1, phoneNumber: !1 }));
2893
+ F(B.target.value), H.email && f((X) => ({ ...X, email: !1, phoneNumber: !1 }));
2892
2894
  },
2893
2895
  placeholder: y.emailPlaceholder,
2894
2896
  style: O("email"),
@@ -2906,7 +2908,7 @@ function Wr({
2906
2908
  type: "tel",
2907
2909
  value: E,
2908
2910
  onChange: (B) => {
2909
- A(B.target.value), $.phoneNumber && h((X) => ({ ...X, email: !1, phoneNumber: !1 }));
2911
+ A(B.target.value), H.phoneNumber && f((X) => ({ ...X, email: !1, phoneNumber: !1 }));
2910
2912
  },
2911
2913
  placeholder: y.phoneNumberPlaceholder,
2912
2914
  style: O("phoneNumber"),
@@ -2936,7 +2938,7 @@ function Wr({
2936
2938
  type: "password",
2937
2939
  value: u,
2938
2940
  onChange: (B) => {
2939
- k(B.target.value), $.password && h((X) => ({ ...X, password: !1 }));
2941
+ k(B.target.value), H.password && f((X) => ({ ...X, password: !1 }));
2940
2942
  },
2941
2943
  placeholder: y.passwordPlaceholder,
2942
2944
  style: O("password"),
@@ -2954,7 +2956,7 @@ function Wr({
2954
2956
  type: "password",
2955
2957
  value: m,
2956
2958
  onChange: (B) => {
2957
- M(B.target.value), $.confirmPassword && h((X) => ({ ...X, confirmPassword: !1 })), l === y.passwordMismatchError && N("");
2959
+ M(B.target.value), H.confirmPassword && f((X) => ({ ...X, confirmPassword: !1 })), l === y.passwordMismatchError && N("");
2958
2960
  },
2959
2961
  placeholder: y.confirmPasswordPlaceholder,
2960
2962
  style: O("confirmPassword"),
@@ -2972,7 +2974,7 @@ function Wr({
2972
2974
  type: "text",
2973
2975
  value: L,
2974
2976
  onChange: (B) => {
2975
- D(B.target.value), $.tenantName && h((X) => ({ ...X, tenantName: !1 }));
2977
+ D(B.target.value), H.tenantName && f((X) => ({ ...X, tenantName: !1 }));
2976
2978
  },
2977
2979
  placeholder: y.tenantNamePlaceholder,
2978
2980
  style: O("tenantName"),
@@ -2983,7 +2985,7 @@ function Wr({
2983
2985
  /* @__PURE__ */ s("button", { type: "submit", disabled: !W || P, style: q(), children: P ? y.loadingText : y.submitButton }),
2984
2986
  l && /* @__PURE__ */ s("div", { style: v.errorText, children: l })
2985
2987
  ] }),
2986
- (f || g) && /* @__PURE__ */ d("div", { style: v.linkContainer, children: [
2988
+ (h || g) && /* @__PURE__ */ d("div", { style: v.linkContainer, children: [
2987
2989
  g && /* @__PURE__ */ d("div", { children: [
2988
2990
  /* @__PURE__ */ d("span", { style: v.divider, children: [
2989
2991
  y.magicLinkText,
@@ -2991,8 +2993,8 @@ function Wr({
2991
2993
  ] }),
2992
2994
  /* @__PURE__ */ s("a", { onClick: a, style: v.link, children: y.magicLinkLink })
2993
2995
  ] }),
2994
- g && f && /* @__PURE__ */ s("div", { style: v.divider, children: "•" }),
2995
- f && /* @__PURE__ */ d("div", { children: [
2996
+ g && h && /* @__PURE__ */ s("div", { style: v.divider, children: "•" }),
2997
+ h && /* @__PURE__ */ d("div", { children: [
2996
2998
  /* @__PURE__ */ d("span", { style: v.divider, children: [
2997
2999
  y.loginText,
2998
3000
  " "
@@ -3131,11 +3133,11 @@ function Vr({
3131
3133
  onLoginClick: i,
3132
3134
  onSignupClick: o,
3133
3135
  showTraditionalLinks: a = !0,
3134
- className: f,
3136
+ className: h,
3135
3137
  verifyToken: g,
3136
3138
  frontendUrl: w
3137
3139
  }) {
3138
- const [c, I] = T(""), [p, x] = T(""), [R, F] = T(""), [E, A] = T(!1), [u, k] = T(!1), [m, M] = T(""), [L, D] = T(""), [P, U] = T({}), [l, N] = T(!1), { sendMagicLink: $, verifyMagicLink: h } = ue(), { tenant: C } = we(), S = { ...Yt, ...n }, b = { ...Xt, ...e };
3140
+ const [c, I] = T(""), [p, x] = T(""), [R, F] = T(""), [E, A] = T(!1), [u, k] = T(!1), [m, M] = T(""), [L, D] = T(""), [P, U] = T({}), [l, N] = T(!1), { sendMagicLink: H, verifyMagicLink: f } = ue(), { tenant: C } = we(), S = { ...Yt, ...n }, b = { ...Xt, ...e };
3139
3141
  ee(() => {
3140
3142
  g && y(g);
3141
3143
  }, [g]);
@@ -3146,7 +3148,7 @@ function Vr({
3146
3148
  }
3147
3149
  k(!0), M("");
3148
3150
  try {
3149
- const W = await h({
3151
+ const W = await f({
3150
3152
  token: q,
3151
3153
  email: c
3152
3154
  // tenantId inferred from context automatically
@@ -3169,7 +3171,7 @@ function Vr({
3169
3171
  }
3170
3172
  A(!0), M(""), D("");
3171
3173
  try {
3172
- const W = w || (typeof window < "u" ? window.location.origin : ""), B = await $({
3174
+ const W = w || (typeof window < "u" ? window.location.origin : ""), B = await H({
3173
3175
  email: c,
3174
3176
  tenantId: C.id,
3175
3177
  frontendUrl: W,
@@ -3192,10 +3194,10 @@ function Vr({
3192
3194
  ...E || u ? b.buttonLoading : {},
3193
3195
  ...!c || E || u ? b.buttonDisabled : {}
3194
3196
  });
3195
- return u ? /* @__PURE__ */ d("div", { className: f, style: b.container, children: [
3197
+ return u ? /* @__PURE__ */ d("div", { className: h, style: b.container, children: [
3196
3198
  /* @__PURE__ */ s("h2", { style: b.title, children: S.verifyingText }),
3197
3199
  /* @__PURE__ */ s("div", { style: { textAlign: "center", padding: "2rem" }, children: /* @__PURE__ */ s("div", { style: { fontSize: "1rem", color: "#6b7280" }, children: "Please wait while we verify your magic link..." }) })
3198
- ] }) : /* @__PURE__ */ d("div", { className: f, style: b.container, children: [
3200
+ ] }) : /* @__PURE__ */ d("div", { className: h, style: b.container, children: [
3199
3201
  /* @__PURE__ */ s("h2", { style: b.title, children: S.title }),
3200
3202
  /* @__PURE__ */ s("p", { style: b.description, children: S.description }),
3201
3203
  /* @__PURE__ */ d("form", { onSubmit: G, style: b.form, children: [
@@ -3453,7 +3455,7 @@ function jr({
3453
3455
  onError: i,
3454
3456
  onRetry: o,
3455
3457
  onBackToLogin: a,
3456
- className: f,
3458
+ className: h,
3457
3459
  token: g,
3458
3460
  email: w,
3459
3461
  appId: c,
@@ -3551,7 +3553,7 @@ function jr({
3551
3553
  return null;
3552
3554
  }
3553
3555
  };
3554
- return /* @__PURE__ */ d("div", { style: k.container, className: f, children: [
3556
+ return /* @__PURE__ */ d("div", { style: k.container, className: h, children: [
3555
3557
  /* @__PURE__ */ s("style", { children: `
3556
3558
  @keyframes spin {
3557
3559
  0% { transform: rotate(0deg); }
@@ -3684,10 +3686,10 @@ function Gr({
3684
3686
  onSuccess: i,
3685
3687
  onError: o,
3686
3688
  onBackToLogin: a,
3687
- onModeChange: f,
3689
+ onModeChange: h,
3688
3690
  className: g
3689
3691
  }) {
3690
- const [w, c] = T(""), [I, p] = T(r), [x, R] = T(""), [F, E] = T(""), [A, u] = T(!1), [k, m] = T(""), [M, L] = T(""), [D, P] = T({}), { requestPasswordReset: U, confirmPasswordReset: l } = ue(), { tenant: N } = we(), $ = { ...ir, ...n }, h = { ...or, ...e }, C = () => {
3692
+ const [w, c] = T(""), [I, p] = T(r), [x, R] = T(""), [F, E] = T(""), [A, u] = T(!1), [k, m] = T(""), [M, L] = T(""), [D, P] = T({}), { requestPasswordReset: U, confirmPasswordReset: l } = ue(), { tenant: N } = we(), H = { ...ir, ...n }, f = { ...or, ...e }, C = () => {
3691
3693
  const O = {};
3692
3694
  return w.trim() || (O.email = !0), P(O), Object.keys(O).length === 0;
3693
3695
  }, S = () => {
@@ -3701,9 +3703,9 @@ function Gr({
3701
3703
  }
3702
3704
  u(!0), m(""), L("");
3703
3705
  try {
3704
- await U({ email: w, tenantId: N.id }), L($.successMessage), i == null || i();
3706
+ await U({ email: w, tenantId: N.id }), L(H.successMessage), i == null || i();
3705
3707
  } catch (q) {
3706
- const W = q.message || $.errorMessage;
3708
+ const W = q.message || H.errorMessage;
3707
3709
  m(W), o == null || o(W);
3708
3710
  } finally {
3709
3711
  u(!1);
@@ -3712,34 +3714,34 @@ function Gr({
3712
3714
  }, y = async (O) => {
3713
3715
  if (O.preventDefault(), !!S()) {
3714
3716
  if (x !== F) {
3715
- m($.passwordMismatchError), P({ confirmPassword: !0 });
3717
+ m(H.passwordMismatchError), P({ confirmPassword: !0 });
3716
3718
  return;
3717
3719
  }
3718
3720
  u(!0), m(""), L("");
3719
3721
  try {
3720
- await l({ token: I, newPassword: x }), L($.resetSuccessMessage), i == null || i();
3722
+ await l({ token: I, newPassword: x }), L(H.resetSuccessMessage), i == null || i();
3721
3723
  } catch (q) {
3722
- const W = q.message || $.errorMessage;
3724
+ const W = q.message || H.errorMessage;
3723
3725
  m(W), o == null || o(W);
3724
3726
  } finally {
3725
3727
  u(!1);
3726
3728
  }
3727
3729
  }
3728
3730
  }, v = (O) => ({
3729
- ...h.input,
3730
- ...D[O] ? h.inputError : {}
3731
+ ...f.input,
3732
+ ...D[O] ? f.inputError : {}
3731
3733
  }), G = () => ({
3732
- ...h.button,
3733
- ...A ? h.buttonLoading : {}
3734
+ ...f.button,
3735
+ ...A ? f.buttonLoading : {}
3734
3736
  });
3735
3737
  if (t === "reset") {
3736
3738
  const O = I && x && F;
3737
- return /* @__PURE__ */ d("div", { className: g, style: h.container, children: [
3738
- /* @__PURE__ */ s("h2", { style: h.title, children: $.resetTitle }),
3739
- /* @__PURE__ */ s("p", { style: h.subtitle, children: $.resetSubtitle }),
3740
- /* @__PURE__ */ d("form", { onSubmit: y, style: h.form, children: [
3741
- /* @__PURE__ */ d("div", { style: h.fieldGroup, children: [
3742
- /* @__PURE__ */ s("label", { style: h.label, children: $.tokenLabel }),
3739
+ return /* @__PURE__ */ d("div", { className: g, style: f.container, children: [
3740
+ /* @__PURE__ */ s("h2", { style: f.title, children: H.resetTitle }),
3741
+ /* @__PURE__ */ s("p", { style: f.subtitle, children: H.resetSubtitle }),
3742
+ /* @__PURE__ */ d("form", { onSubmit: y, style: f.form, children: [
3743
+ /* @__PURE__ */ d("div", { style: f.fieldGroup, children: [
3744
+ /* @__PURE__ */ s("label", { style: f.label, children: H.tokenLabel }),
3743
3745
  /* @__PURE__ */ s(
3744
3746
  "input",
3745
3747
  {
@@ -3748,14 +3750,14 @@ function Gr({
3748
3750
  onChange: (q) => {
3749
3751
  p(q.target.value), D.token && P((W) => ({ ...W, token: !1 }));
3750
3752
  },
3751
- placeholder: $.tokenPlaceholder,
3753
+ placeholder: H.tokenPlaceholder,
3752
3754
  style: v("token"),
3753
3755
  disabled: A
3754
3756
  }
3755
3757
  )
3756
3758
  ] }),
3757
- /* @__PURE__ */ d("div", { style: h.fieldGroup, children: [
3758
- /* @__PURE__ */ s("label", { style: h.label, children: $.newPasswordLabel }),
3759
+ /* @__PURE__ */ d("div", { style: f.fieldGroup, children: [
3760
+ /* @__PURE__ */ s("label", { style: f.label, children: H.newPasswordLabel }),
3759
3761
  /* @__PURE__ */ s(
3760
3762
  "input",
3761
3763
  {
@@ -3764,23 +3766,23 @@ function Gr({
3764
3766
  onChange: (q) => {
3765
3767
  R(q.target.value), D.newPassword && P((W) => ({ ...W, newPassword: !1 }));
3766
3768
  },
3767
- placeholder: $.newPasswordPlaceholder,
3769
+ placeholder: H.newPasswordPlaceholder,
3768
3770
  style: v("newPassword"),
3769
3771
  disabled: A
3770
3772
  }
3771
3773
  )
3772
3774
  ] }),
3773
- /* @__PURE__ */ d("div", { style: h.fieldGroup, children: [
3774
- /* @__PURE__ */ s("label", { style: h.label, children: $.confirmPasswordLabel }),
3775
+ /* @__PURE__ */ d("div", { style: f.fieldGroup, children: [
3776
+ /* @__PURE__ */ s("label", { style: f.label, children: H.confirmPasswordLabel }),
3775
3777
  /* @__PURE__ */ s(
3776
3778
  "input",
3777
3779
  {
3778
3780
  type: "password",
3779
3781
  value: F,
3780
3782
  onChange: (q) => {
3781
- E(q.target.value), D.confirmPassword && P((W) => ({ ...W, confirmPassword: !1 })), k === $.passwordMismatchError && m("");
3783
+ E(q.target.value), D.confirmPassword && P((W) => ({ ...W, confirmPassword: !1 })), k === H.passwordMismatchError && m("");
3782
3784
  },
3783
- placeholder: $.confirmPasswordPlaceholder,
3785
+ placeholder: H.confirmPasswordPlaceholder,
3784
3786
  style: v("confirmPassword"),
3785
3787
  disabled: A
3786
3788
  }
@@ -3793,30 +3795,30 @@ function Gr({
3793
3795
  disabled: !O || A,
3794
3796
  style: {
3795
3797
  ...G(),
3796
- ...!O || A ? h.buttonDisabled : {}
3798
+ ...!O || A ? f.buttonDisabled : {}
3797
3799
  },
3798
- children: A ? $.resetLoadingText : $.resetSubmitButton
3800
+ children: A ? H.resetLoadingText : H.resetSubmitButton
3799
3801
  }
3800
3802
  ),
3801
- k && /* @__PURE__ */ s("div", { style: h.errorText, children: k }),
3802
- M && /* @__PURE__ */ s("div", { style: h.successText, children: M })
3803
+ k && /* @__PURE__ */ s("div", { style: f.errorText, children: k }),
3804
+ M && /* @__PURE__ */ s("div", { style: f.successText, children: M })
3803
3805
  ] }),
3804
- /* @__PURE__ */ d("div", { style: h.linkContainer, children: [
3805
- /* @__PURE__ */ s("a", { onClick: a, style: h.link, children: $.backToLoginLink }),
3806
- f && /* @__PURE__ */ d(_, { children: [
3806
+ /* @__PURE__ */ d("div", { style: f.linkContainer, children: [
3807
+ /* @__PURE__ */ s("a", { onClick: a, style: f.link, children: H.backToLoginLink }),
3808
+ h && /* @__PURE__ */ d(_, { children: [
3807
3809
  /* @__PURE__ */ s("span", { style: { margin: "0 0.5rem", color: "#6b7280" }, children: "•" }),
3808
- /* @__PURE__ */ s("a", { onClick: () => f("request"), style: h.link, children: "Request New Link" })
3810
+ /* @__PURE__ */ s("a", { onClick: () => h("request"), style: f.link, children: "Request New Link" })
3809
3811
  ] })
3810
3812
  ] })
3811
3813
  ] });
3812
3814
  }
3813
3815
  const Q = w;
3814
- return /* @__PURE__ */ d("div", { className: g, style: h.container, children: [
3815
- /* @__PURE__ */ s("h2", { style: h.title, children: $.title }),
3816
- /* @__PURE__ */ s("p", { style: h.subtitle, children: $.subtitle }),
3817
- /* @__PURE__ */ d("form", { onSubmit: b, style: h.form, children: [
3818
- /* @__PURE__ */ d("div", { style: h.fieldGroup, children: [
3819
- /* @__PURE__ */ s("label", { style: h.label, children: $.emailLabel }),
3816
+ return /* @__PURE__ */ d("div", { className: g, style: f.container, children: [
3817
+ /* @__PURE__ */ s("h2", { style: f.title, children: H.title }),
3818
+ /* @__PURE__ */ s("p", { style: f.subtitle, children: H.subtitle }),
3819
+ /* @__PURE__ */ d("form", { onSubmit: b, style: f.form, children: [
3820
+ /* @__PURE__ */ d("div", { style: f.fieldGroup, children: [
3821
+ /* @__PURE__ */ s("label", { style: f.label, children: H.emailLabel }),
3820
3822
  /* @__PURE__ */ s(
3821
3823
  "input",
3822
3824
  {
@@ -3825,7 +3827,7 @@ function Gr({
3825
3827
  onChange: (O) => {
3826
3828
  c(O.target.value), D.email && P((q) => ({ ...q, email: !1 }));
3827
3829
  },
3828
- placeholder: $.emailPlaceholder,
3830
+ placeholder: H.emailPlaceholder,
3829
3831
  style: v("email"),
3830
3832
  disabled: A
3831
3833
  }
@@ -3838,19 +3840,19 @@ function Gr({
3838
3840
  disabled: !Q || A,
3839
3841
  style: {
3840
3842
  ...G(),
3841
- ...!Q || A ? h.buttonDisabled : {}
3843
+ ...!Q || A ? f.buttonDisabled : {}
3842
3844
  },
3843
- children: A ? $.loadingText : $.submitButton
3845
+ children: A ? H.loadingText : H.submitButton
3844
3846
  }
3845
3847
  ),
3846
- k && /* @__PURE__ */ s("div", { style: h.errorText, children: k }),
3847
- M && /* @__PURE__ */ s("div", { style: h.successText, children: M })
3848
+ k && /* @__PURE__ */ s("div", { style: f.errorText, children: k }),
3849
+ M && /* @__PURE__ */ s("div", { style: f.successText, children: M })
3848
3850
  ] }),
3849
- /* @__PURE__ */ d("div", { style: h.linkContainer, children: [
3850
- /* @__PURE__ */ s("a", { onClick: a, style: h.link, children: $.backToLoginLink }),
3851
- f && /* @__PURE__ */ d(_, { children: [
3851
+ /* @__PURE__ */ d("div", { style: f.linkContainer, children: [
3852
+ /* @__PURE__ */ s("a", { onClick: a, style: f.link, children: H.backToLoginLink }),
3853
+ h && /* @__PURE__ */ d(_, { children: [
3852
3854
  /* @__PURE__ */ s("span", { style: { margin: "0 0.5rem", color: "#6b7280" }, children: "•" }),
3853
- /* @__PURE__ */ s("a", { onClick: () => f("reset"), style: h.link, children: "I have a token" })
3855
+ /* @__PURE__ */ s("a", { onClick: () => h("reset"), style: f.link, children: "I have a token" })
3854
3856
  ] })
3855
3857
  ] })
3856
3858
  ] });
@@ -3907,9 +3909,9 @@ function Qr({
3907
3909
  errorFallback: t,
3908
3910
  requireTenant: r = !0
3909
3911
  }) {
3910
- const { isAppLoading: i, appError: o, retryApp: a } = ke(), f = Pe(), g = Ce(), w = Je(), c = Ye(), I = (f == null ? void 0 : f.isTenantLoading) ?? !1, p = (f == null ? void 0 : f.tenantError) ?? null, x = (f == null ? void 0 : f.tenantSlug) ?? null, R = (f == null ? void 0 : f.retryTenant) ?? (() => {
3911
- }), F = (g == null ? void 0 : g.isAuthReady) ?? !0, E = (w == null ? void 0 : w.isReady) ?? !0, A = (c == null ? void 0 : c.isReady) ?? !0, u = r && f && x, L = i || u && I || g && !F || w && !E || c && !A, D = o || (u ? p : null), P = () => {
3912
- o && a(), p && f && R();
3912
+ const { isAppLoading: i, appError: o, retryApp: a } = ke(), h = Pe(), g = Ce(), w = Je(), c = Ye(), I = (h == null ? void 0 : h.isTenantLoading) ?? !1, p = (h == null ? void 0 : h.tenantError) ?? null, x = (h == null ? void 0 : h.tenantSlug) ?? null, R = (h == null ? void 0 : h.retryTenant) ?? (() => {
3913
+ }), F = (g == null ? void 0 : g.isAuthReady) ?? !0, E = (w == null ? void 0 : w.isReady) ?? !0, A = (c == null ? void 0 : c.isReady) ?? !0, u = r && h && x, L = i || u && I || g && !F || w && !E || c && !A, D = o || (u ? p : null), P = () => {
3914
+ o && a(), p && h && R();
3913
3915
  };
3914
3916
  if (L)
3915
3917
  return /* @__PURE__ */ s(_, { children: e || /* @__PURE__ */ s(ar, {}) });
@@ -3920,8 +3922,8 @@ function Qr({
3920
3922
  return /* @__PURE__ */ s(_, { children: n });
3921
3923
  }
3922
3924
  function Kr(n = !0) {
3923
- const { isAppLoading: e, appError: t, retryApp: r, appInfo: i } = ke(), o = Pe(), a = Ce(), f = Je(), g = Ye(), w = (o == null ? void 0 : o.isTenantLoading) ?? !1, c = (o == null ? void 0 : o.tenantError) ?? null, I = (o == null ? void 0 : o.tenant) ?? null, p = (o == null ? void 0 : o.tenantSlug) ?? null, x = (o == null ? void 0 : o.retryTenant) ?? (() => {
3924
- }), R = (a == null ? void 0 : a.isAuthReady) ?? !0, F = (f == null ? void 0 : f.isReady) ?? !0, E = (g == null ? void 0 : g.isReady) ?? !0, A = n && o && p, M = e || A && w || a && !R || f && !F || g && !E, L = t || (A ? c : null);
3925
+ const { isAppLoading: e, appError: t, retryApp: r, appInfo: i } = ke(), o = Pe(), a = Ce(), h = Je(), g = Ye(), w = (o == null ? void 0 : o.isTenantLoading) ?? !1, c = (o == null ? void 0 : o.tenantError) ?? null, I = (o == null ? void 0 : o.tenant) ?? null, p = (o == null ? void 0 : o.tenantSlug) ?? null, x = (o == null ? void 0 : o.retryTenant) ?? (() => {
3926
+ }), R = (a == null ? void 0 : a.isAuthReady) ?? !0, F = (h == null ? void 0 : h.isReady) ?? !0, E = (g == null ? void 0 : g.isReady) ?? !0, A = n && o && p, M = e || A && w || a && !R || h && !F || g && !E, L = t || (A ? c : null);
3925
3927
  return {
3926
3928
  isLoading: M,
3927
3929
  error: L,
@@ -3933,7 +3935,7 @@ function Kr(n = !0) {
3933
3935
  app: { isLoading: e, error: t, data: i },
3934
3936
  tenant: o ? { isLoading: w, error: c, data: I } : null,
3935
3937
  auth: a ? { isReady: R } : null,
3936
- featureFlags: f ? { isReady: F } : null,
3938
+ featureFlags: h ? { isReady: F } : null,
3937
3939
  subscription: g ? { isReady: E } : null
3938
3940
  };
3939
3941
  }
@@ -3945,7 +3947,7 @@ function Zr({
3945
3947
  dropdownClassName: i = "",
3946
3948
  itemClassName: o = "",
3947
3949
  renderItem: a,
3948
- placeholder: f = "Select tenant",
3950
+ placeholder: h = "Select tenant",
3949
3951
  disabled: g = !1,
3950
3952
  showCurrentTenant: w = !0
3951
3953
  }) {
@@ -3984,7 +3986,7 @@ function Zr({
3984
3986
  opacity: g ? 0.6 : 1
3985
3987
  },
3986
3988
  children: [
3987
- A ? A.name : f,
3989
+ A ? A.name : h,
3988
3990
  /* @__PURE__ */ s("span", { style: { marginLeft: 8 }, children: I ? "▲" : "▼" })
3989
3991
  ]
3990
3992
  }
@@ -4289,7 +4291,7 @@ function tn(n = {}) {
4289
4291
  zoneRoots: e = {},
4290
4292
  returnToParam: t = tt,
4291
4293
  returnToStorage: r = "url"
4292
- } = n, i = gt(), [o, a] = mt(), { isAuthenticated: f, currentUser: g } = ue(), { tenant: w } = ye(), c = Z(() => ({ ...He, ...e }), [e]), I = !!w, p = g == null ? void 0 : g.userType, x = Z(() => {
4294
+ } = n, i = gt(), [o, a] = mt(), { isAuthenticated: h, currentUser: g } = ue(), { tenant: w } = ye(), c = Z(() => ({ ...He, ...e }), [e]), I = !!w, p = g == null ? void 0 : g.userType, x = Z(() => {
4293
4295
  switch (r) {
4294
4296
  case "url":
4295
4297
  return o.get(t);
@@ -4337,7 +4339,7 @@ function tn(n = {}) {
4337
4339
  i(k);
4338
4340
  },
4339
4341
  [i, c]
4340
- ), A = ie(() => I ? f ? p === ae.TENANT_ADMIN ? c.tenantAdmin : c.tenantUser : c.tenantGuest : f ? p === ae.TENANT_ADMIN ? c.publicAdmin : c.publicUser : c.publicGuest, [I, f, p, c]);
4342
+ ), A = ie(() => I ? h ? p === ae.TENANT_ADMIN ? c.tenantAdmin : c.tenantUser : c.tenantGuest : h ? p === ae.TENANT_ADMIN ? c.publicAdmin : c.publicUser : c.publicGuest, [I, h, p, c]);
4341
4343
  return {
4342
4344
  returnToUrl: x,
4343
4345
  clearReturnTo: R,