@skylabs-digital/react-identity-access 3.2.1 → 3.2.2

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,6 +1,6 @@
1
- import { jsx as s, Fragment as B, jsxs as f } from "react/jsx-runtime";
2
- import me, { createContext as fe, useState as N, useRef as Ee, useCallback as te, useMemo as V, useEffect as re, useContext as ne } from "react";
3
- import { useLocation as xe, Navigate as be, useNavigate as wt, useSearchParams as vt } from "react-router-dom";
1
+ import { jsx as s, Fragment as U, jsxs as f } from "react/jsx-runtime";
2
+ import me, { createContext as fe, useState as N, useRef as ye, useCallback as te, useMemo as V, useEffect as re, useContext as ne } from "react";
3
+ import { useLocation as xe, Navigate as we, useNavigate as vt, useSearchParams as Tt } from "react-router-dom";
4
4
  class he {
5
5
  constructor(e, t = 1e4) {
6
6
  this.baseUrl = e.replace(/\/$/, ""), this.timeout = t;
@@ -98,10 +98,10 @@ class Je {
98
98
  return (await this.httpService.get(`/apps/${e}/export-config`)).data;
99
99
  }
100
100
  }
101
- const $e = fe(null), Tt = 5 * 60 * 1e3;
102
- function Sr({ config: r, children: e }) {
101
+ const $e = fe(null), St = 5 * 60 * 1e3;
102
+ function kr({ config: r, children: e }) {
103
103
  var k, m, g;
104
- const { appId: t, baseUrl: n } = r, i = (((k = r.cache) == null ? void 0 : k.enabled) ?? !0) && !!t, a = ((m = r.cache) == null ? void 0 : m.ttl) ?? Tt, l = ((g = r.cache) == null ? void 0 : g.storageKey) ?? (t ? `app_cache_${t}` : ""), [d, T] = N(() => {
104
+ const { appId: t, baseUrl: n } = r, i = (((k = r.cache) == null ? void 0 : k.enabled) ?? !0) && !!t, a = ((m = r.cache) == null ? void 0 : m.ttl) ?? St, l = ((g = r.cache) == null ? void 0 : g.storageKey) ?? (t ? `app_cache_${t}` : ""), [d, T] = N(() => {
105
105
  if (!i) return null;
106
106
  try {
107
107
  const b = localStorage.getItem(l);
@@ -111,7 +111,7 @@ function Sr({ config: r, children: e }) {
111
111
  } catch {
112
112
  return null;
113
113
  }
114
- }), [A, c] = N(!!t && !d), [S, h] = N(null), x = Ee(d);
114
+ }), [A, c] = N(!!t && !d), [S, h] = N(null), x = ye(d);
115
115
  x.current = d;
116
116
  const P = te(
117
117
  async (b = !1) => {
@@ -182,7 +182,7 @@ function Ae() {
182
182
  function Ue() {
183
183
  return ne($e);
184
184
  }
185
- const kr = Ae;
185
+ const Er = Ae;
186
186
  class ee extends Error {
187
187
  constructor(e, t) {
188
188
  const n = {
@@ -193,12 +193,12 @@ class ee extends Error {
193
193
  super(t || n[e]), this.name = "SessionExpiredError", this.reason = e;
194
194
  }
195
195
  }
196
- class St extends Error {
196
+ class kt extends Error {
197
197
  constructor(e) {
198
198
  super(`Token refresh timed out after ${e}ms`), this.name = "TokenRefreshTimeoutError", this.timeoutMs = e;
199
199
  }
200
200
  }
201
- class kt extends Error {
201
+ class Et extends Error {
202
202
  constructor(e, t) {
203
203
  super(
204
204
  `Token refresh failed after ${e} attempts: ${(t == null ? void 0 : t.message) || "Unknown error"}`
@@ -207,10 +207,10 @@ class kt extends Error {
207
207
  }
208
208
  class oe extends Error {
209
209
  constructor(e, t, n) {
210
- super(`Invalid configuration "${e}": ${n} (received: ${Et(t)})`), this.name = "ConfigurationError", this.field = e, this.received = t;
210
+ super(`Invalid configuration "${e}": ${n} (received: ${xt(t)})`), this.name = "ConfigurationError", this.field = e, this.received = t;
211
211
  }
212
212
  }
213
- function Et(r) {
213
+ function xt(r) {
214
214
  if (r === void 0) return "undefined";
215
215
  try {
216
216
  const e = JSON.stringify(r);
@@ -235,19 +235,19 @@ function Ke(r) {
235
235
  const e = Re(r), t = e == null ? void 0 : e.payload.exp;
236
236
  return typeof t == "number" ? t * 1e3 : void 0;
237
237
  }
238
- function xt(r, e) {
238
+ function At(r, e) {
239
239
  var n;
240
240
  const t = (n = Re(r)) == null ? void 0 : n.payload[e];
241
241
  return typeof t == "string" ? t : void 0;
242
242
  }
243
- const At = /^(javascript|data|vbscript|file):/i, Rt = /^https?:\/\//i;
244
- function Pt(r, e = "baseUrl") {
243
+ const Rt = /^(javascript|data|vbscript|file):/i, Pt = /^https?:\/\//i;
244
+ function It(r, e = "baseUrl") {
245
245
  if (!(r == null || r === "")) {
246
246
  if (typeof r != "string")
247
247
  throw new oe(e, r, "must be a string");
248
- if (At.test(r))
248
+ if (Rt.test(r))
249
249
  throw new oe(e, r, "dangerous URL scheme is not allowed");
250
- if (!Rt.test(r))
250
+ if (!Pt.test(r))
251
251
  throw new oe(e, r, "must start with http:// or https://");
252
252
  }
253
253
  }
@@ -265,7 +265,7 @@ function Ye(r, e) {
265
265
  if (e !== void 0 && typeof e != "boolean")
266
266
  throw new oe(r, e, "must be a boolean");
267
267
  }
268
- function It(r, e = "accessToken") {
268
+ function Lt(r, e = "accessToken") {
269
269
  if (typeof r != "string" || r.length === 0)
270
270
  throw new oe(e, r, "must be a non-empty string");
271
271
  if (!r.includes(".")) return;
@@ -283,11 +283,11 @@ function It(r, e = "accessToken") {
283
283
  "JWT header or payload is not valid base64url-encoded JSON"
284
284
  );
285
285
  }
286
- function Lt(r) {
286
+ function Ft(r) {
287
287
  if (r !== void 0 && (typeof r != "number" || !Number.isFinite(r) || r <= 0))
288
288
  throw new oe("expiresIn", r, "must be a finite positive number (seconds)");
289
289
  }
290
- function Ft(r) {
290
+ function Nt(r) {
291
291
  if (r !== void 0 && (typeof r != "number" || !Number.isFinite(r) || r <= 0))
292
292
  throw new oe(
293
293
  "expiresAt",
@@ -321,7 +321,7 @@ const ie = class ie {
321
321
  return e.storageKey || "auth_tokens";
322
322
  }
323
323
  static validateConfig(e) {
324
- Pt(e.baseUrl), Ye("enableCookieSession", e.enableCookieSession), Ye("autoRefresh", e.autoRefresh), ge("refreshThreshold", e.refreshThreshold, { min: 0 }), ge("proactiveRefreshMargin", e.proactiveRefreshMargin, { min: 0 }), ge("refreshQueueTimeout", e.refreshQueueTimeout, { min: 1 }), ge("maxRefreshRetries", e.maxRefreshRetries, { min: 0 }), ge("retryBackoffBase", e.retryBackoffBase, { min: 1 });
324
+ It(e.baseUrl), Ye("enableCookieSession", e.enableCookieSession), Ye("autoRefresh", e.autoRefresh), ge("refreshThreshold", e.refreshThreshold, { min: 0 }), ge("proactiveRefreshMargin", e.proactiveRefreshMargin, { min: 0 }), ge("refreshQueueTimeout", e.refreshQueueTimeout, { min: 1 }), ge("maxRefreshRetries", e.maxRefreshRetries, { min: 0 }), ge("retryBackoffBase", e.retryBackoffBase, { min: 1 });
325
325
  }
326
326
  /** Update mutable config (callbacks, baseUrl) on an existing instance. */
327
327
  updateConfig(e) {
@@ -390,9 +390,9 @@ const ie = class ie {
390
390
  }
391
391
  // --- Token CRUD ---
392
392
  setTokens(e) {
393
- if (It(e.accessToken, "accessToken"), e.refreshToken !== void 0 && typeof e.refreshToken != "string")
393
+ if (Lt(e.accessToken, "accessToken"), e.refreshToken !== void 0 && typeof e.refreshToken != "string")
394
394
  throw new oe("refreshToken", e.refreshToken, "must be a string");
395
- Lt(e.expiresIn), Ft(e.expiresAt);
395
+ Ft(e.expiresIn), Nt(e.expiresAt);
396
396
  const t = e.expiresAt || (e.expiresIn ? Date.now() + e.expiresIn * 1e3 : void 0) || Ke(e.accessToken), n = {
397
397
  ...e,
398
398
  expiresAt: t
@@ -570,7 +570,7 @@ const ie = class ie {
570
570
  return new Promise((e, t) => {
571
571
  const n = setTimeout(() => {
572
572
  const i = this.refreshQueue.findIndex((a) => a.timeoutId === n);
573
- i !== -1 && this.refreshQueue.splice(i, 1), t(new St(this.refreshQueueTimeout));
573
+ i !== -1 && this.refreshQueue.splice(i, 1), t(new kt(this.refreshQueueTimeout));
574
574
  }, this.refreshQueueTimeout);
575
575
  this.refreshQueue.push({ resolve: e, reject: t, timeoutId: n });
576
576
  });
@@ -620,7 +620,7 @@ const ie = class ie {
620
620
  }
621
621
  }
622
622
  }
623
- throw new kt(this.maxRefreshRetries + 1, t);
623
+ throw new Et(this.maxRefreshRetries + 1, t);
624
624
  }
625
625
  /**
626
626
  * Single refresh attempt with error classification.
@@ -639,7 +639,7 @@ const ie = class ie {
639
639
  const n = this.getTokens();
640
640
  if (n != null && n.accessToken && !this.isTokenExpired(n) && !this.shouldRefreshToken(n))
641
641
  return;
642
- const i = (n == null ? void 0 : n.refreshToken) || e, a = `${this.baseUrl}/auth/refresh`, l = xt(i, "deviceId"), d = { refreshToken: i };
642
+ const i = (n == null ? void 0 : n.refreshToken) || e, a = `${this.baseUrl}/auth/refresh`, l = At(i, "deviceId"), d = { refreshToken: i };
643
643
  l && (d.deviceId = l);
644
644
  let T;
645
645
  try {
@@ -729,9 +729,9 @@ const ie = class ie {
729
729
  };
730
730
  ie.instances = /* @__PURE__ */ new Map(), ie.MAX_BACKGROUND_FAILURES = 3;
731
731
  let Me = ie;
732
- class Nt {
732
+ class Ct {
733
733
  constructor(e) {
734
- this.httpService = e, this.pendingVerifications = /* @__PURE__ */ new Map(), this.pendingMagicLinks = /* @__PURE__ */ new Map();
734
+ this.httpService = e, this.verificationCache = /* @__PURE__ */ new Map(), this.VERIFY_CACHE_TTL_MS = 6e4, this.pendingMagicLinks = /* @__PURE__ */ new Map();
735
735
  }
736
736
  // Public endpoints - no auth required.
737
737
  // Must pass `{ skipAuth: true }` so HttpService does NOT call
@@ -780,12 +780,24 @@ class Nt {
780
780
  return this.pendingMagicLinks.set(t, i), i;
781
781
  }
782
782
  async verifyMagicLink(e) {
783
- const t = e.token, n = this.pendingVerifications.get(t);
784
- if (n) return n;
785
- const i = this.httpService.post("/auth/magic-link/verify", e, { skipAuth: !0 }).finally(() => {
786
- this.pendingVerifications.delete(t);
787
- });
788
- return this.pendingVerifications.set(t, i), i;
783
+ const t = e.token, n = this.verificationCache.get(t);
784
+ if (n) return n.promise;
785
+ const i = this.httpService.post(
786
+ "/auth/magic-link/verify",
787
+ e,
788
+ { skipAuth: !0 }
789
+ ), a = { promise: i };
790
+ return this.verificationCache.set(t, a), i.then(
791
+ () => {
792
+ a.timer = setTimeout(
793
+ () => this.verificationCache.delete(t),
794
+ this.VERIFY_CACHE_TTL_MS
795
+ );
796
+ },
797
+ () => {
798
+ this.verificationCache.delete(t);
799
+ }
800
+ ), i;
789
801
  }
790
802
  async confirmPasswordReset(e) {
791
803
  await this.httpService.post("/auth/password-reset/confirm", e, { skipAuth: !0 });
@@ -794,7 +806,7 @@ class Nt {
794
806
  await this.httpService.post("/auth/change-password", e);
795
807
  }
796
808
  }
797
- class Ct {
809
+ class Dt {
798
810
  constructor(e) {
799
811
  this.httpService = e;
800
812
  }
@@ -830,7 +842,7 @@ class Ct {
830
842
  return { roles: n.data, meta: n.meta };
831
843
  }
832
844
  }
833
- class Dt {
845
+ class Mt {
834
846
  constructor(e) {
835
847
  this.httpService = e;
836
848
  }
@@ -853,7 +865,7 @@ class Dt {
853
865
  await this.httpService.delete(`/users/${e}`);
854
866
  }
855
867
  }
856
- class ye {
868
+ class be {
857
869
  constructor(e, t) {
858
870
  this.httpService = e, this.appId = t;
859
871
  }
@@ -897,7 +909,7 @@ class ye {
897
909
  )).data;
898
910
  }
899
911
  }
900
- function Mt(r, e) {
912
+ function $t(r, e) {
901
913
  if (r === "localhost" || r.startsWith("127.") || r.startsWith("192.168."))
902
914
  return null;
903
915
  if (e) {
@@ -913,24 +925,24 @@ function Mt(r, e) {
913
925
  const n = r.split(".");
914
926
  return n.length >= 3 && n[0] !== "www" ? n[0] : null;
915
927
  }
916
- function $t(r, e = "tenant", t) {
928
+ function Ut(r, e = "tenant", t) {
917
929
  const i = new URLSearchParams(r).get(e);
918
930
  return i ? (t && t.setItem("tenant", i), i) : t ? t.getItem("tenant") : null;
919
931
  }
920
- function Ut(r, e, t) {
932
+ function Bt(r, e, t) {
921
933
  const { tenantMode: n, baseDomain: i, selectorParam: a, fixedTenantSlug: l } = r;
922
- return n === "fixed" ? l || null : n === "subdomain" ? Mt(e.hostname, i) : n === "selector" ? $t(e.search, a, t) : null;
934
+ return n === "fixed" ? l || null : n === "subdomain" ? $t(e.hostname, i) : n === "selector" ? Ut(e.search, a, t) : null;
923
935
  }
924
- function Bt(r, e, t) {
936
+ function _t(r, e, t) {
925
937
  if (t)
926
938
  return `${r}.${t}`;
927
939
  const n = e.split(".");
928
940
  return n.length === 2 ? `${r}.${e}` : n.length >= 3 ? (n[0] = r, n.join(".")) : null;
929
941
  }
930
942
  const Be = fe(null);
931
- function Er({ config: r, children: e }) {
943
+ function xr({ config: r, children: e }) {
932
944
  var j, Z, $;
933
- const { baseUrl: t, appInfo: n, appId: i } = Ae(), a = te(() => typeof window > "u" ? null : Ut(
945
+ const { baseUrl: t, appInfo: n, appId: i } = Ae(), a = te(() => typeof window > "u" ? null : Bt(
934
946
  {
935
947
  tenantMode: r.tenantMode || "selector",
936
948
  baseDomain: r.baseDomain,
@@ -949,9 +961,9 @@ function Er({ config: r, children: e }) {
949
961
  if (r.initialTenant) return r.initialTenant;
950
962
  if (!S.enabled || !l) return null;
951
963
  try {
952
- const U = localStorage.getItem(S.storageKey);
953
- if (!U) return null;
954
- const L = JSON.parse(U);
964
+ const B = localStorage.getItem(S.storageKey);
965
+ if (!B) return null;
966
+ const L = JSON.parse(B);
955
967
  return Date.now() - L.timestamp < S.ttl && L.tenantSlug === l ? L.data : (localStorage.removeItem(S.storageKey), null);
956
968
  } catch {
957
969
  return null;
@@ -959,21 +971,21 @@ function Er({ config: r, children: e }) {
959
971
  }), [P, I] = N(!h && !r.initialTenant), [R, k] = N(null), [m, g] = N(null), [b, C] = N(!1), [o, p] = N(null);
960
972
  re(() => {
961
973
  if (r.tenantMode === "fixed") return;
962
- const U = a();
963
- d(U);
974
+ const B = a();
975
+ d(B);
964
976
  }, [a, r.tenantMode]);
965
977
  const E = (n == null ? void 0 : n.settingsSchema) || null, y = te(
966
- async (U, L = !1) => {
967
- if (!(!L && S.enabled && h && h.subdomain === U))
978
+ async (B, L = !1) => {
979
+ if (!(!L && S.enabled && h && h.subdomain === B))
968
980
  try {
969
981
  I(!0), k(null);
970
- const q = new he(t), W = await new ye(q, i).getPublicTenantInfo(U);
982
+ const q = new he(t), W = await new be(q, i).getPublicTenantInfo(B);
971
983
  if (x(W), S.enabled)
972
984
  try {
973
985
  const K = {
974
986
  data: W,
975
987
  timestamp: Date.now(),
976
- tenantSlug: U
988
+ tenantSlug: B
977
989
  };
978
990
  localStorage.setItem(S.storageKey, JSON.stringify(K));
979
991
  } catch (K) {
@@ -990,11 +1002,11 @@ function Er({ config: r, children: e }) {
990
1002
  ), u = te(async () => {
991
1003
  if (!(!S.enabled || !h || !l))
992
1004
  try {
993
- const U = localStorage.getItem(S.storageKey);
994
- if (!U) return;
995
- const L = JSON.parse(U);
1005
+ const B = localStorage.getItem(S.storageKey);
1006
+ if (!B) return;
1007
+ const L = JSON.parse(B);
996
1008
  if (Date.now() - L.timestamp > S.ttl * 0.5) {
997
- const _ = new he(t), K = await new ye(_, i).getPublicTenantInfo(l);
1009
+ const _ = new he(t), K = await new be(_, i).getPublicTenantInfo(l);
998
1010
  x(K);
999
1011
  const Y = {
1000
1012
  data: K,
@@ -1003,17 +1015,17 @@ function Er({ config: r, children: e }) {
1003
1015
  };
1004
1016
  localStorage.setItem(S.storageKey, JSON.stringify(Y));
1005
1017
  }
1006
- } catch (U) {
1007
- process.env.NODE_ENV === "development" && console.warn("[TenantProvider] Background tenant refresh failed:", U);
1018
+ } catch (B) {
1019
+ process.env.NODE_ENV === "development" && console.warn("[TenantProvider] Background tenant refresh failed:", B);
1008
1020
  }
1009
1021
  }, [t, i, S, h, l]), v = te(async () => {
1010
1022
  if (h != null && h.id)
1011
1023
  try {
1012
1024
  C(!0), p(null);
1013
- const U = new he(t), q = await new ye(U, h.appId).getTenantSettings(h.id);
1025
+ const B = new he(t), q = await new be(B, h.appId).getTenantSettings(h.id);
1014
1026
  g(q);
1015
- } catch (U) {
1016
- const L = U instanceof Error ? U : new Error("Failed to load tenant settings");
1027
+ } catch (B) {
1028
+ const L = B instanceof Error ? B : new Error("Failed to load tenant settings");
1017
1029
  p(L), g(null);
1018
1030
  } finally {
1019
1031
  C(!1);
@@ -1021,14 +1033,14 @@ function Er({ config: r, children: e }) {
1021
1033
  }, [t, h]), D = te(() => {
1022
1034
  v();
1023
1035
  }, [v]), se = te(
1024
- (U) => {
1036
+ (B) => {
1025
1037
  if (!E)
1026
1038
  return { isValid: !0, errors: [] };
1027
1039
  const L = [];
1028
1040
  try {
1029
1041
  return E.properties && Object.entries(E.properties).forEach(([q, _]) => {
1030
1042
  var K;
1031
- const W = U[q];
1043
+ const W = B[q];
1032
1044
  if ((K = E.required) != null && K.includes(q) && W == null) {
1033
1045
  L.push(`Field '${q}' is required`);
1034
1046
  return;
@@ -1063,7 +1075,7 @@ function Er({ config: r, children: e }) {
1063
1075
  h != null && h.id ? v() : (g(null), p(null), C(!1));
1064
1076
  }, [h == null ? void 0 : h.id, v]);
1065
1077
  const F = te(
1066
- (U, L) => {
1078
+ (B, L) => {
1067
1079
  const { mode: q = "reload", redirectPath: _ } = L || {}, W = r.tenantMode || "selector";
1068
1080
  if (W === "fixed") {
1069
1081
  process.env.NODE_ENV === "development" && console.warn(
@@ -1072,9 +1084,9 @@ function Er({ config: r, children: e }) {
1072
1084
  ), _ && (window.location.href = _);
1073
1085
  return;
1074
1086
  }
1075
- if (localStorage.setItem("tenant", U), W === "subdomain") {
1076
- const K = window.location.hostname, Y = Bt(
1077
- U,
1087
+ if (localStorage.setItem("tenant", B), W === "subdomain") {
1088
+ const K = window.location.hostname, Y = _t(
1089
+ B,
1078
1090
  K,
1079
1091
  r.baseDomain
1080
1092
  );
@@ -1085,18 +1097,18 @@ function Er({ config: r, children: e }) {
1085
1097
  );
1086
1098
  return;
1087
1099
  }
1088
- const le = _ || window.location.pathname, Te = new URL(`${window.location.protocol}//${Y}${le}`);
1100
+ const le = _ || window.location.pathname, Se = new URL(`${window.location.protocol}//${Y}${le}`);
1089
1101
  new URLSearchParams(window.location.search).forEach((Fe, Ne) => {
1090
- Te.searchParams.set(Ne, Fe);
1091
- }), window.location.href = Te.toString();
1102
+ Se.searchParams.set(Ne, Fe);
1103
+ }), window.location.href = Se.toString();
1092
1104
  } else if (W === "selector") {
1093
1105
  const K = _ || window.location.pathname, Y = new URLSearchParams(window.location.search);
1094
- if (Y.set(r.selectorParam || "tenant", U), q === "reload") {
1106
+ if (Y.set(r.selectorParam || "tenant", B), q === "reload") {
1095
1107
  const le = `${K}?${Y.toString()}${window.location.hash}`;
1096
1108
  window.location.href = le;
1097
1109
  } else {
1098
1110
  const le = `${K}?${Y.toString()}${window.location.hash}`;
1099
- window.history.pushState({}, "", le), d(U), y(U);
1111
+ window.history.pushState({}, "", le), d(B), y(B);
1100
1112
  }
1101
1113
  }
1102
1114
  },
@@ -1135,7 +1147,7 @@ function Er({ config: r, children: e }) {
1135
1147
  ]);
1136
1148
  return /* @__PURE__ */ s(Be.Provider, { value: H, children: e });
1137
1149
  }
1138
- function ve() {
1150
+ function Te() {
1139
1151
  const r = ne(Be);
1140
1152
  if (!r)
1141
1153
  throw new Error("useTenant must be used within a TenantProvider");
@@ -1144,9 +1156,9 @@ function ve() {
1144
1156
  function pe() {
1145
1157
  return ne(Be);
1146
1158
  }
1147
- const xr = ve;
1148
- function Ar() {
1149
- const { settings: r, settingsSchema: e, isSettingsLoading: t, settingsError: n, validateSettings: i } = ve();
1159
+ const Ar = Te;
1160
+ function Rr() {
1161
+ const { settings: r, settingsSchema: e, isSettingsLoading: t, settingsError: n, validateSettings: i } = Te();
1150
1162
  return {
1151
1163
  settings: r,
1152
1164
  settingsSchema: e,
@@ -1156,7 +1168,7 @@ function Ar() {
1156
1168
  };
1157
1169
  }
1158
1170
  function ot() {
1159
- const { tenant: r, tenantSlug: e, isTenantLoading: t, tenantError: n, retryTenant: i } = ve();
1171
+ const { tenant: r, tenantSlug: e, isTenantLoading: t, tenantError: n, retryTenant: i } = Te();
1160
1172
  return {
1161
1173
  tenant: r,
1162
1174
  tenantSlug: e,
@@ -1166,7 +1178,7 @@ function ot() {
1166
1178
  };
1167
1179
  }
1168
1180
  const _e = "userTenants";
1169
- function _t() {
1181
+ function Ot() {
1170
1182
  try {
1171
1183
  const r = localStorage.getItem(_e);
1172
1184
  return r ? JSON.parse(r) : [];
@@ -1187,14 +1199,14 @@ function et() {
1187
1199
  }
1188
1200
  }
1189
1201
  const Pe = fe(null), Ie = fe(null);
1190
- function Rr({ config: r = {}, children: e }) {
1202
+ function Pr({ config: r = {}, children: e }) {
1191
1203
  const t = Ue(), n = pe(), i = (t == null ? void 0 : t.baseUrl) ?? r.baseUrl ?? "", a = (t == null ? void 0 : t.appId) ?? r.appId, l = (n == null ? void 0 : n.tenant) ?? null, d = (n == null ? void 0 : n.tenantSlug) ?? null, T = (n == null ? void 0 : n.switchTenant) ?? (() => {
1192
1204
  });
1193
1205
  if (!i)
1194
1206
  throw new Error(
1195
1207
  "[AuthProvider] baseUrl is required. Provide it via AppProvider or AuthConfig.baseUrl."
1196
1208
  );
1197
- const [A, c] = N(r.initialRoles || []), [S, h] = N(!r.initialRoles), [x, P] = N(null), [I, R] = N(!1), [k, m] = N(null), [g, b] = N(() => _t()), C = Ee({ done: !1 });
1209
+ const [A, c] = N(r.initialRoles || []), [S, h] = N(!r.initialRoles), [x, P] = N(null), [I, R] = N(!1), [k, m] = N(null), [g, b] = N(() => Ot()), C = ye({ done: !1 });
1198
1210
  C.current.done || (C.current.done = !0);
1199
1211
  const o = V(() => Me.getInstance({
1200
1212
  baseUrl: i,
@@ -1216,18 +1228,18 @@ function Rr({ config: r = {}, children: e }) {
1216
1228
  const w = new he(i);
1217
1229
  return w.setSessionManager(o), w;
1218
1230
  }, [i, o]), v = V(
1219
- () => new Nt(u),
1231
+ () => new Ct(u),
1220
1232
  [u]
1221
1233
  ), D = V(
1222
- () => new Dt(u),
1234
+ () => new Mt(u),
1223
1235
  [u]
1224
1236
  ), se = V(
1225
- () => new Ct(u),
1237
+ () => new Dt(u),
1226
1238
  [u]
1227
1239
  ), F = V(() => x != null && x.roleId && A.find((w) => w.id === x.roleId) || null, [x, A]), H = V(() => (F == null ? void 0 : F.permissions) || [], [F]), j = V(
1228
1240
  () => o.hasValidSession() && x !== null,
1229
1241
  [o, x]
1230
- ), Z = V(() => (x == null ? void 0 : x.tenantId) != null, [x]), $ = Ee(null), U = async (w = !1) => {
1242
+ ), Z = V(() => (x == null ? void 0 : x.tenantId) != null, [x]), $ = ye(null), B = ye(/* @__PURE__ */ new Set()), L = async (w = !1) => {
1231
1243
  try {
1232
1244
  if (!o.hasValidSession() || !w && x) return;
1233
1245
  const M = o.getUserId();
@@ -1244,17 +1256,17 @@ function Rr({ config: r = {}, children: e }) {
1244
1256
  } finally {
1245
1257
  R(!1);
1246
1258
  }
1247
- }, L = async (w) => {
1259
+ }, q = async (w) => {
1248
1260
  var He;
1249
- const { username: M, password: z, tenantSlug: O, redirectPath: Q } = w;
1250
- let X = l == null ? void 0 : l.id, J = d;
1251
- O && (X = (await new ye(u, a).getPublicTenantInfo(O)).id, J = O);
1261
+ const { username: M, password: z, tenantSlug: O, redirectPath: J } = w;
1262
+ let X = l == null ? void 0 : l.id, Q = d;
1263
+ O && (X = (await new be(u, a).getPublicTenantInfo(O)).id, Q = O);
1252
1264
  const G = await v.login({
1253
1265
  username: M,
1254
1266
  password: z,
1255
1267
  appId: a,
1256
1268
  tenantId: X
1257
- }), Se = O && O !== d;
1269
+ }), ke = O && O !== d;
1258
1270
  if (o.setTokens({
1259
1271
  accessToken: G.accessToken,
1260
1272
  refreshToken: G.refreshToken,
@@ -1262,100 +1274,104 @@ function Rr({ config: r = {}, children: e }) {
1262
1274
  }), G.user) {
1263
1275
  o.setUser(G.user), P(G.user);
1264
1276
  try {
1265
- await U();
1266
- } catch (ke) {
1267
- process.env.NODE_ENV === "development" && console.warn("[AuthProvider] Failed to load complete user data after login:", ke);
1277
+ await L();
1278
+ } catch (Ee) {
1279
+ process.env.NODE_ENV === "development" && console.warn("[AuthProvider] Failed to load complete user data after login:", Ee);
1268
1280
  }
1269
1281
  }
1270
1282
  G.tenants && G.tenants.length > 0 && (b(G.tenants), Xe(G.tenants));
1271
1283
  const Ge = ((He = G.user) == null ? void 0 : He.tenantId) !== null;
1272
- if (Se && J)
1273
- return T(J, { redirectPath: Q }), G;
1274
- if (Q && Q !== window.location.pathname)
1275
- return T(J || d || "", { redirectPath: Q }), G;
1284
+ if (ke && Q)
1285
+ return T(Q, { redirectPath: J }), G;
1286
+ if (J && J !== window.location.pathname)
1287
+ return T(Q || d || "", { redirectPath: J }), G;
1276
1288
  if (!Ge && G.tenants && G.tenants.length > 0) {
1277
- const ke = w.autoSwitch !== !1 && r.autoSwitchSingleTenant !== !1;
1278
- if (G.tenants.length === 1 && ke) {
1289
+ const Ee = w.autoSwitch !== !1 && r.autoSwitchSingleTenant !== !1;
1290
+ if (G.tenants.length === 1 && Ee) {
1279
1291
  const Qe = G.tenants[0];
1280
- return T(Qe.subdomain, { redirectPath: Q }), G;
1292
+ return T(Qe.subdomain, { redirectPath: J }), G;
1281
1293
  } else G.tenants.length > 1 && r.onTenantSelectionRequired && r.onTenantSelectionRequired(G.tenants);
1282
1294
  }
1283
1295
  return G;
1284
- }, q = async (w) => {
1285
- const { email: M, phoneNumber: z, name: O, password: Q, lastName: X, tenantId: J } = w;
1296
+ }, _ = async (w) => {
1297
+ const { email: M, phoneNumber: z, name: O, password: J, lastName: X, tenantId: Q } = w;
1286
1298
  if (!M && !z)
1287
1299
  throw new Error("Either email or phoneNumber is required");
1288
- if (!O || !Q)
1300
+ if (!O || !J)
1289
1301
  throw new Error("Name and password are required");
1290
1302
  return v.signup({
1291
1303
  email: M,
1292
1304
  phoneNumber: z,
1293
1305
  name: O,
1294
- password: Q,
1295
- tenantId: J ?? (l == null ? void 0 : l.id),
1306
+ password: J,
1307
+ tenantId: Q ?? (l == null ? void 0 : l.id),
1296
1308
  lastName: X,
1297
1309
  appId: a
1298
1310
  });
1299
- }, _ = async (w) => {
1300
- const { email: M, phoneNumber: z, name: O, password: Q, tenantName: X, lastName: J } = w;
1311
+ }, W = async (w) => {
1312
+ const { email: M, phoneNumber: z, name: O, password: J, tenantName: X, lastName: Q } = w;
1301
1313
  if (!M && !z)
1302
1314
  throw new Error("Either email or phoneNumber is required");
1303
- if (!O || !Q || !X)
1315
+ if (!O || !J || !X)
1304
1316
  throw new Error("Name, password, and tenantName are required");
1305
1317
  return v.signupTenantAdmin({
1306
1318
  email: M,
1307
1319
  phoneNumber: z,
1308
1320
  name: O,
1309
- password: Q,
1321
+ password: J,
1310
1322
  tenantName: X,
1311
1323
  appId: a,
1312
- lastName: J
1324
+ lastName: Q
1313
1325
  });
1314
- }, W = async (w) => {
1315
- await v.changePassword(w);
1316
1326
  }, K = async (w) => {
1327
+ await v.changePassword(w);
1328
+ }, Y = async (w) => {
1317
1329
  const { email: M, tenantId: z } = w, O = z ?? (l == null ? void 0 : l.id);
1318
1330
  if (!O)
1319
1331
  throw new Error("tenantId is required for password reset");
1320
1332
  await v.requestPasswordReset({ email: M, tenantId: O });
1321
- }, Y = async (w) => {
1322
- await v.confirmPasswordReset(w);
1323
1333
  }, le = async (w) => {
1324
- const { email: M, frontendUrl: z, name: O, lastName: Q, tenantId: X } = w, J = X ?? (l == null ? void 0 : l.id);
1325
- if (!J)
1334
+ await v.confirmPasswordReset(w);
1335
+ }, Se = async (w) => {
1336
+ const { email: M, frontendUrl: z, name: O, lastName: J, tenantId: X } = w, Q = X ?? (l == null ? void 0 : l.id);
1337
+ if (!Q)
1326
1338
  throw new Error("tenantId is required for magic link authentication");
1327
1339
  return v.sendMagicLink({
1328
1340
  email: M,
1329
- tenantId: J,
1341
+ tenantId: Q,
1330
1342
  frontendUrl: z,
1331
1343
  name: O,
1332
- lastName: Q,
1344
+ lastName: J,
1333
1345
  appId: a
1334
1346
  });
1335
- }, Te = async (w) => {
1347
+ }, We = async (w) => {
1336
1348
  const { token: M, email: z, tenantSlug: O } = w;
1337
- let Q = l == null ? void 0 : l.id, X = d;
1338
- O && (Q = (await new ye(u, a).getPublicTenantInfo(O)).id, X = O);
1339
- const J = await v.verifyMagicLink({
1349
+ let J = l == null ? void 0 : l.id, X = d;
1350
+ O && (J = (await new be(u, a).getPublicTenantInfo(O)).id, X = O);
1351
+ const Q = await v.verifyMagicLink({
1340
1352
  token: M,
1341
1353
  email: z,
1342
1354
  appId: a,
1343
- tenantId: Q
1344
- }), G = O && O !== d;
1355
+ tenantId: J
1356
+ });
1357
+ if (B.current.has(M))
1358
+ return Q;
1359
+ B.current.add(M);
1360
+ const G = O && O !== d;
1345
1361
  if (o.setTokens({
1346
- accessToken: J.accessToken,
1347
- refreshToken: J.refreshToken,
1348
- expiresIn: J.expiresIn
1349
- }), J.user) {
1350
- o.setUser(J.user), P(J.user);
1362
+ accessToken: Q.accessToken,
1363
+ refreshToken: Q.refreshToken,
1364
+ expiresIn: Q.expiresIn
1365
+ }), Q.user) {
1366
+ o.setUser(Q.user), P(Q.user);
1351
1367
  try {
1352
- await U();
1353
- } catch (Se) {
1354
- process.env.NODE_ENV === "development" && console.warn("[AuthProvider] Failed to load complete user data after magic link:", Se);
1368
+ await L();
1369
+ } catch (ke) {
1370
+ process.env.NODE_ENV === "development" && console.warn("[AuthProvider] Failed to load complete user data after magic link:", ke);
1355
1371
  }
1356
1372
  }
1357
- return G && X && X !== d && T(X), J;
1358
- }, We = async () => {
1373
+ return G && X && X !== d && T(X), Q;
1374
+ }, Fe = async () => {
1359
1375
  const w = o.getTokens();
1360
1376
  if (!(w != null && w.refreshToken))
1361
1377
  throw new Error("No refresh token available");
@@ -1367,13 +1383,13 @@ function Rr({ config: r = {}, children: e }) {
1367
1383
  refreshToken: M.refreshToken || w.refreshToken,
1368
1384
  expiresIn: M.expiresIn
1369
1385
  });
1370
- }, Fe = () => {
1386
+ }, Ne = () => {
1371
1387
  o.clearSession(), P(null), m(null), b([]), et();
1372
- }, Ne = (w) => {
1388
+ }, ht = (w) => {
1373
1389
  o.setTokens(w);
1374
- }, ht = () => o.hasValidSession(), pt = () => {
1390
+ }, pt = () => o.hasValidSession(), ft = () => {
1375
1391
  o.clearSession(), P(null), m(null);
1376
- }, ft = async () => {
1392
+ }, mt = async () => {
1377
1393
  if (a)
1378
1394
  try {
1379
1395
  h(!0);
@@ -1384,46 +1400,46 @@ function Rr({ config: r = {}, children: e }) {
1384
1400
  } finally {
1385
1401
  h(!1);
1386
1402
  }
1387
- }, mt = async (w, M) => {
1403
+ }, gt = async (w, M) => {
1388
1404
  const { redirectPath: z } = M || {}, O = o.getTokens();
1389
1405
  if (!(O != null && O.refreshToken))
1390
1406
  throw new Error("No refresh token available for tenant switch");
1391
- const Q = await v.switchTenant({
1407
+ const J = await v.switchTenant({
1392
1408
  refreshToken: O.refreshToken,
1393
1409
  tenantId: w
1394
1410
  });
1395
1411
  o.setTokens({
1396
- accessToken: Q.accessToken,
1412
+ accessToken: J.accessToken,
1397
1413
  refreshToken: O.refreshToken,
1398
- expiresIn: Q.expiresIn
1399
- }), P(Q.user), o.setUser(Q.user);
1400
- const X = g.find((J) => J.id === w);
1414
+ expiresIn: J.expiresIn
1415
+ }), P(J.user), o.setUser(J.user);
1416
+ const X = g.find((Q) => Q.id === w);
1401
1417
  X && T(X.subdomain, { redirectPath: z });
1402
- }, gt = async () => {
1418
+ }, yt = async () => {
1403
1419
  const w = await v.getUserTenants();
1404
1420
  return b(w), Xe(w), w;
1405
1421
  };
1406
1422
  $.current = {
1407
- login: L,
1408
- signup: q,
1409
- signupTenantAdmin: _,
1410
- sendMagicLink: le,
1411
- verifyMagicLink: Te,
1412
- changePassword: W,
1413
- requestPasswordReset: K,
1414
- confirmPasswordReset: Y,
1415
- refreshToken: We,
1416
- logout: Fe,
1417
- setTokens: Ne,
1418
- hasValidSession: ht,
1419
- clearSession: pt,
1420
- loadUserData: U,
1421
- refreshUser: () => U(),
1422
- refreshRoles: ft,
1423
- switchToTenant: mt,
1424
- refreshUserTenants: gt
1423
+ login: q,
1424
+ signup: _,
1425
+ signupTenantAdmin: W,
1426
+ sendMagicLink: Se,
1427
+ verifyMagicLink: We,
1428
+ changePassword: K,
1429
+ requestPasswordReset: Y,
1430
+ confirmPasswordReset: le,
1431
+ refreshToken: Fe,
1432
+ logout: Ne,
1433
+ setTokens: ht,
1434
+ hasValidSession: pt,
1435
+ clearSession: ft,
1436
+ loadUserData: L,
1437
+ refreshUser: () => L(),
1438
+ refreshRoles: mt,
1439
+ switchToTenant: gt,
1440
+ refreshUserTenants: yt
1425
1441
  };
1426
- const yt = V(
1442
+ const bt = V(
1427
1443
  () => ({
1428
1444
  login: (w) => $.current.login(w),
1429
1445
  signup: (w) => $.current.signup(w),
@@ -1445,7 +1461,7 @@ function Rr({ config: r = {}, children: e }) {
1445
1461
  refreshUserTenants: () => $.current.refreshUserTenants()
1446
1462
  }),
1447
1463
  []
1448
- ), bt = V(() => {
1464
+ ), wt = V(() => {
1449
1465
  const w = (M) => !H || H.length === 0 ? !1 : typeof M == "string" ? H.includes(M) : H.includes(`${M.resource}.${M.action}`);
1450
1466
  return {
1451
1467
  isAuthenticated: j,
@@ -1510,15 +1526,15 @@ function Rr({ config: r = {}, children: e }) {
1510
1526
  }).finally(() => {
1511
1527
  E(!1);
1512
1528
  }) : E(!1);
1513
- }, [x, I, k, o]), /* @__PURE__ */ s(Ie.Provider, { value: yt, children: /* @__PURE__ */ s(Pe.Provider, { value: bt, children: e }) });
1529
+ }, [x, I, k, o]), /* @__PURE__ */ s(Ie.Provider, { value: bt, children: /* @__PURE__ */ s(Pe.Provider, { value: wt, children: e }) });
1514
1530
  }
1515
- function Pr() {
1531
+ function Ir() {
1516
1532
  const r = ne(Pe);
1517
1533
  if (!r)
1518
1534
  throw new Error("useAuthState must be used within an AuthProvider");
1519
1535
  return r;
1520
1536
  }
1521
- function Ir() {
1537
+ function Lr() {
1522
1538
  const r = ne(Ie);
1523
1539
  if (!r)
1524
1540
  throw new Error("useAuthActions must be used within an AuthProvider");
@@ -1534,7 +1550,7 @@ function Oe() {
1534
1550
  const r = ne(Pe), e = ne(Ie);
1535
1551
  return V(() => !r || !e ? null : { ...r, ...e }, [r, e]);
1536
1552
  }
1537
- class Ot {
1553
+ class Vt {
1538
1554
  constructor(e) {
1539
1555
  this.httpService = e;
1540
1556
  }
@@ -1582,10 +1598,10 @@ class Ot {
1582
1598
  }
1583
1599
  }
1584
1600
  const Ve = fe(null);
1585
- function Lr({ config: r = {}, children: e }) {
1601
+ function Fr({ config: r = {}, children: e }) {
1586
1602
  const t = Ue(), n = pe(), i = (t == null ? void 0 : t.baseUrl) ?? "", a = (t == null ? void 0 : t.appId) ?? "", l = (n == null ? void 0 : n.tenant) ?? null, [d, T] = N([]), [A, c] = N(!1), [S, h] = N(null), [x, P] = N(!1), I = V(() => {
1587
1603
  const m = new he(i);
1588
- return new Ot(m);
1604
+ return new Vt(m);
1589
1605
  }, [i]), R = async () => {
1590
1606
  if (!(l != null && l.id)) {
1591
1607
  T([]);
@@ -1631,7 +1647,7 @@ function Lr({ config: r = {}, children: e }) {
1631
1647
  }, [d, A, S, i, a, l == null ? void 0 : l.id, x]);
1632
1648
  return /* @__PURE__ */ s(Ve.Provider, { value: k, children: e });
1633
1649
  }
1634
- function Vt() {
1650
+ function qt() {
1635
1651
  const r = ne(Ve);
1636
1652
  if (!r)
1637
1653
  throw new Error("useFeatureFlags must be used within a FeatureFlagProvider");
@@ -1640,7 +1656,7 @@ function Vt() {
1640
1656
  function at() {
1641
1657
  return ne(Ve);
1642
1658
  }
1643
- class qt {
1659
+ class zt {
1644
1660
  constructor(e) {
1645
1661
  this.httpService = e;
1646
1662
  }
@@ -1681,10 +1697,10 @@ class qt {
1681
1697
  }
1682
1698
  }
1683
1699
  const qe = fe(void 0);
1684
- function Fr({ config: r = {}, children: e }) {
1700
+ function Nr({ config: r = {}, children: e }) {
1685
1701
  const t = Ue(), n = pe(), i = (t == null ? void 0 : t.baseUrl) ?? "", a = (n == null ? void 0 : n.tenant) ?? null, [l, d] = N(null), [T, A] = N(!1), [c, S] = N(null), [h, x] = N(!1), P = V(() => {
1686
1702
  const k = new he(i);
1687
- return new qt(k);
1703
+ return new zt(k);
1688
1704
  }, [i]), I = async () => {
1689
1705
  if (!(a != null && a.id)) {
1690
1706
  d(null);
@@ -1731,7 +1747,7 @@ function Fr({ config: r = {}, children: e }) {
1731
1747
  }, [l, T, c, i, a == null ? void 0 : a.id, h]);
1732
1748
  return /* @__PURE__ */ s(qe.Provider, { value: R, children: e });
1733
1749
  }
1734
- function zt() {
1750
+ function jt() {
1735
1751
  const r = ne(qe);
1736
1752
  if (r === void 0)
1737
1753
  throw new Error("useSubscription must be used within a SubscriptionProvider");
@@ -1766,7 +1782,7 @@ const ze = {
1766
1782
  admin: { tenant: "required", auth: "required", userType: ae.TENANT_ADMIN },
1767
1783
  // Fully open
1768
1784
  open: { tenant: "optional", auth: "optional" }
1769
- }, je = fe(null), jt = {
1785
+ }, je = fe(null), Wt = {
1770
1786
  zoneRoots: ze,
1771
1787
  presets: ct,
1772
1788
  loadingFallback: null,
@@ -1775,7 +1791,7 @@ const ze = {
1775
1791
  returnToParam: "returnTo",
1776
1792
  returnToStorage: "url"
1777
1793
  };
1778
- function Nr({ config: r = {}, children: e }) {
1794
+ function Cr({ config: r = {}, children: e }) {
1779
1795
  const t = V(() => {
1780
1796
  const n = {
1781
1797
  ...ze,
@@ -1796,14 +1812,14 @@ function Nr({ config: r = {}, children: e }) {
1796
1812
  }, [r]);
1797
1813
  return /* @__PURE__ */ s(je.Provider, { value: t, children: e });
1798
1814
  }
1799
- function Cr() {
1815
+ function Dr() {
1800
1816
  const r = ne(je);
1801
1817
  if (!r)
1802
1818
  throw new Error("useRouting must be used within a RoutingProvider");
1803
1819
  return r;
1804
1820
  }
1805
- function Wt() {
1806
- return ne(je) ?? jt;
1821
+ function Gt() {
1822
+ return ne(je) ?? Wt;
1807
1823
  }
1808
1824
  const tt = () => /* @__PURE__ */ f(
1809
1825
  "div",
@@ -1864,7 +1880,7 @@ const tt = () => /* @__PURE__ */ f(
1864
1880
  children: [
1865
1881
  /* @__PURE__ */ s("div", { style: { fontSize: "2rem", marginBottom: "10px" }, children: "⚠️" }),
1866
1882
  /* @__PURE__ */ s("h3", { style: { color: "#856404", marginBottom: "10px" }, children: "Insufficient Permissions" }),
1867
- e && r ? /* @__PURE__ */ f(B, { children: [
1883
+ e && r ? /* @__PURE__ */ f(U, { children: [
1868
1884
  /* @__PURE__ */ f("p", { style: { color: "#856404", fontSize: "14px", marginBottom: "10px" }, children: [
1869
1885
  "This content requires ",
1870
1886
  /* @__PURE__ */ s("strong", { children: e }),
@@ -1874,7 +1890,7 @@ const tt = () => /* @__PURE__ */ f(
1874
1890
  "Your current access level: ",
1875
1891
  /* @__PURE__ */ s("strong", { children: r })
1876
1892
  ] })
1877
- ] }) : /* @__PURE__ */ f(B, { children: [
1893
+ ] }) : /* @__PURE__ */ f(U, { children: [
1878
1894
  /* @__PURE__ */ s("p", { style: { color: "#856404", fontSize: "14px", marginBottom: "10px" }, children: "You don't have the required permissions to view this content." }),
1879
1895
  t && t.length > 0 && /* @__PURE__ */ f("p", { style: { color: "#6c757d", fontSize: "12px" }, children: [
1880
1896
  "Required permissions: ",
@@ -1883,7 +1899,7 @@ const tt = () => /* @__PURE__ */ f(
1883
1899
  ] })
1884
1900
  ]
1885
1901
  }
1886
- ), Gt = (r, e) => {
1902
+ ), Ht = (r, e) => {
1887
1903
  const t = {
1888
1904
  [ae.USER]: 1,
1889
1905
  [ae.TENANT_ADMIN]: 2,
@@ -1891,7 +1907,7 @@ const tt = () => /* @__PURE__ */ f(
1891
1907
  };
1892
1908
  return t[r] >= t[e];
1893
1909
  };
1894
- function Dr({
1910
+ function Mr({
1895
1911
  children: r,
1896
1912
  fallback: e,
1897
1913
  minUserType: t,
@@ -1900,19 +1916,19 @@ function Dr({
1900
1916
  }) {
1901
1917
  const { hasValidSession: a, sessionManager: l, hasPermission: d, hasAnyPermission: T, hasAllPermissions: A } = de();
1902
1918
  if (!a())
1903
- return /* @__PURE__ */ s(B, { children: e || /* @__PURE__ */ s(tt, {}) });
1919
+ return /* @__PURE__ */ s(U, { children: e || /* @__PURE__ */ s(tt, {}) });
1904
1920
  const c = l.getUser();
1905
1921
  if (!c)
1906
- return /* @__PURE__ */ s(B, { children: e || /* @__PURE__ */ s(tt, {}) });
1907
- if (t && !Gt(c.userType, t))
1922
+ return /* @__PURE__ */ s(U, { children: e || /* @__PURE__ */ s(tt, {}) });
1923
+ if (t && !Ht(c.userType, t))
1908
1924
  return /* @__PURE__ */ s(rt, { userType: c.userType, minUserType: t });
1909
1925
  if (n && n.length > 0 && !(i ? A(n) : T(n))) {
1910
1926
  const h = n.filter((x) => !d(x)).map((x) => typeof x == "string" ? x : x.name);
1911
1927
  return /* @__PURE__ */ s(rt, { missingPermissions: h });
1912
1928
  }
1913
- return /* @__PURE__ */ s(B, { children: r });
1929
+ return /* @__PURE__ */ s(U, { children: r });
1914
1930
  }
1915
- const Ht = ({ redirectPath: r }) => /* @__PURE__ */ s(
1931
+ const Qt = ({ redirectPath: r }) => /* @__PURE__ */ s(
1916
1932
  "div",
1917
1933
  {
1918
1934
  style: {
@@ -1978,7 +1994,7 @@ const Ht = ({ redirectPath: r }) => /* @__PURE__ */ s(
1978
1994
  children: [
1979
1995
  /* @__PURE__ */ s("div", { style: { fontSize: "3rem", marginBottom: "1rem" }, children: "⚠️" }),
1980
1996
  /* @__PURE__ */ s("h2", { style: { color: "#374151", marginBottom: "1rem" }, children: "Insufficient Permissions" }),
1981
- e && r ? /* @__PURE__ */ f(B, { children: [
1997
+ e && r ? /* @__PURE__ */ f(U, { children: [
1982
1998
  /* @__PURE__ */ f("p", { style: { color: "#6b7280", marginBottom: "1rem" }, children: [
1983
1999
  "This page requires ",
1984
2000
  /* @__PURE__ */ s("strong", { children: e }),
@@ -1988,7 +2004,7 @@ const Ht = ({ redirectPath: r }) => /* @__PURE__ */ s(
1988
2004
  "Your current user type: ",
1989
2005
  /* @__PURE__ */ s("strong", { children: r })
1990
2006
  ] })
1991
- ] }) : /* @__PURE__ */ f(B, { children: [
2007
+ ] }) : /* @__PURE__ */ f(U, { children: [
1992
2008
  /* @__PURE__ */ s("p", { style: { color: "#6b7280", marginBottom: "1rem" }, children: "You don't have the required permissions to access this page." }),
1993
2009
  t && t.length > 0 && /* @__PURE__ */ f("p", { style: { color: "#9ca3af", fontSize: "0.875rem" }, children: [
1994
2010
  "Required permissions: ",
@@ -1999,8 +2015,8 @@ const Ht = ({ redirectPath: r }) => /* @__PURE__ */ s(
1999
2015
  }
2000
2016
  )
2001
2017
  }
2002
- ), Qt = (r, e) => r === e;
2003
- function Mr({
2018
+ ), Jt = (r, e) => r === e;
2019
+ function $r({
2004
2020
  children: r,
2005
2021
  redirectTo: e = "/login",
2006
2022
  requiredUserType: t,
@@ -2014,14 +2030,14 @@ function Mr({
2014
2030
  "[react-identity-access] ProtectedRoute is deprecated. Use AuthenticatedZone or AdminZone from ZoneRoute instead."
2015
2031
  );
2016
2032
  }, []), !l())
2017
- return a ? /* @__PURE__ */ s(B, { children: a }) : /* @__PURE__ */ f(B, { children: [
2018
- /* @__PURE__ */ s(Ht, { redirectPath: e }),
2019
- /* @__PURE__ */ s(be, { to: e, state: { from: S.pathname }, replace: !0 })
2033
+ return a ? /* @__PURE__ */ s(U, { children: a }) : /* @__PURE__ */ f(U, { children: [
2034
+ /* @__PURE__ */ s(Qt, { redirectPath: e }),
2035
+ /* @__PURE__ */ s(we, { to: e, state: { from: S.pathname }, replace: !0 })
2020
2036
  ] });
2021
2037
  const h = d.getUser();
2022
2038
  if (!h)
2023
- return /* @__PURE__ */ s(be, { to: e, state: { from: S.pathname }, replace: !0 });
2024
- if (t && !Qt(h.userType, t))
2039
+ return /* @__PURE__ */ s(we, { to: e, state: { from: S.pathname }, replace: !0 });
2040
+ if (t && !Jt(h.userType, t))
2025
2041
  return /* @__PURE__ */ s(
2026
2042
  nt,
2027
2043
  {
@@ -2033,9 +2049,9 @@ function Mr({
2033
2049
  const P = n.filter((I) => !T(I)).map((I) => typeof I == "string" ? I : I.name);
2034
2050
  return /* @__PURE__ */ s(nt, { missingPermissions: P });
2035
2051
  }
2036
- return /* @__PURE__ */ s(B, { children: r });
2052
+ return /* @__PURE__ */ s(U, { children: r });
2037
2053
  }
2038
- const Jt = ({ redirectPath: r }) => /* @__PURE__ */ s(
2054
+ const Zt = ({ redirectPath: r }) => /* @__PURE__ */ s(
2039
2055
  "div",
2040
2056
  {
2041
2057
  style: {
@@ -2072,18 +2088,18 @@ const Jt = ({ redirectPath: r }) => /* @__PURE__ */ s(
2072
2088
  )
2073
2089
  }
2074
2090
  );
2075
- function $r({ children: r, redirectTo: e = "/", fallback: t }) {
2091
+ function Ur({ children: r, redirectTo: e = "/", fallback: t }) {
2076
2092
  const { tenant: n, isLoading: i, error: a } = ot(), l = xe();
2077
2093
  return re(() => {
2078
2094
  process.env.NODE_ENV === "development" && console.warn(
2079
2095
  "[react-identity-access] TenantRoute is deprecated. Use TenantZone from ZoneRoute instead."
2080
2096
  );
2081
- }, []), i || a ? null : n ? /* @__PURE__ */ s(B, { children: r }) : t ? /* @__PURE__ */ s(B, { children: t }) : /* @__PURE__ */ f(B, { children: [
2082
- /* @__PURE__ */ s(Jt, { redirectPath: e }),
2083
- /* @__PURE__ */ s(be, { to: e, state: { from: l.pathname }, replace: !0 })
2097
+ }, []), i || a ? null : n ? /* @__PURE__ */ s(U, { children: r }) : t ? /* @__PURE__ */ s(U, { children: t }) : /* @__PURE__ */ f(U, { children: [
2098
+ /* @__PURE__ */ s(Zt, { redirectPath: e }),
2099
+ /* @__PURE__ */ s(we, { to: e, state: { from: l.pathname }, replace: !0 })
2084
2100
  ] });
2085
2101
  }
2086
- const Zt = ({ redirectPath: r }) => /* @__PURE__ */ s(
2102
+ const Kt = ({ redirectPath: r }) => /* @__PURE__ */ s(
2087
2103
  "div",
2088
2104
  {
2089
2105
  style: {
@@ -2120,36 +2136,36 @@ const Zt = ({ redirectPath: r }) => /* @__PURE__ */ s(
2120
2136
  )
2121
2137
  }
2122
2138
  );
2123
- function Ur({ children: r, redirectTo: e = "/dashboard", fallback: t }) {
2139
+ function Br({ children: r, redirectTo: e = "/dashboard", fallback: t }) {
2124
2140
  const { tenant: n, isLoading: i, error: a } = ot(), l = xe();
2125
2141
  return re(() => {
2126
2142
  process.env.NODE_ENV === "development" && console.warn(
2127
2143
  "[react-identity-access] LandingRoute is deprecated. Use PublicZone from ZoneRoute instead."
2128
2144
  );
2129
- }, []), i || a ? null : n ? t ? /* @__PURE__ */ s(B, { children: t }) : /* @__PURE__ */ f(B, { children: [
2130
- /* @__PURE__ */ s(Zt, { redirectPath: e }),
2131
- /* @__PURE__ */ s(be, { to: e, state: { from: l.pathname }, replace: !0 })
2132
- ] }) : /* @__PURE__ */ s(B, { children: r });
2145
+ }, []), i || a ? null : n ? t ? /* @__PURE__ */ s(U, { children: t }) : /* @__PURE__ */ f(U, { children: [
2146
+ /* @__PURE__ */ s(Kt, { redirectPath: e }),
2147
+ /* @__PURE__ */ s(we, { to: e, state: { from: l.pathname }, replace: !0 })
2148
+ ] }) : /* @__PURE__ */ s(U, { children: r });
2133
2149
  }
2134
- function Kt(r, e) {
2150
+ function Yt(r, e) {
2135
2151
  return e ? r ? Array.isArray(e) ? e.includes(r) : r === e : !1 : !0;
2136
2152
  }
2137
2153
  function st(r, e) {
2138
2154
  return !r || r === "optional" ? "skip" : r === "required" ? e ? "pass" : "fail" : r === "forbidden" ? e ? "fail" : "pass" : "skip";
2139
2155
  }
2140
- function Yt(r, e) {
2141
- return st(r.tenant, e.hasTenant) === "fail" ? e.hasTenant ? "has_tenant" : "no_tenant" : st(r.auth, e.isAuthenticated) === "fail" ? e.isAuthenticated ? "already_authenticated" : "not_authenticated" : r.userType && e.isAuthenticated && !Kt(e.userType, r.userType) ? "wrong_user_type" : r.permissions && r.permissions.length > 0 && !(r.requireAllPermissions !== !1 ? (a) => a.every((l) => e.permissions.includes(l)) : (a) => a.some((l) => e.permissions.includes(l)))(r.permissions) ? "missing_permissions" : null;
2142
- }
2143
2156
  function Xt(r, e) {
2157
+ return st(r.tenant, e.hasTenant) === "fail" ? e.hasTenant ? "has_tenant" : "no_tenant" : st(r.auth, e.isAuthenticated) === "fail" ? e.isAuthenticated ? "already_authenticated" : "not_authenticated" : r.userType && e.isAuthenticated && !Yt(e.userType, r.userType) ? "wrong_user_type" : r.permissions && r.permissions.length > 0 && !(r.requireAllPermissions !== !1 ? (a) => a.every((l) => e.permissions.includes(l)) : (a) => a.some((l) => e.permissions.includes(l)))(r.permissions) ? "missing_permissions" : null;
2158
+ }
2159
+ function er(r, e) {
2144
2160
  return r.hasTenant ? r.isAuthenticated ? r.userType === ae.TENANT_ADMIN ? e.tenantAdmin : e.tenantUser : e.tenantGuest : r.isAuthenticated ? r.userType === ae.TENANT_ADMIN ? e.publicAdmin : e.publicUser : e.publicGuest;
2145
2161
  }
2146
- function er(r, e, t, n, i) {
2162
+ function tr(r, e, t, n, i) {
2147
2163
  if (!e || i !== "url")
2148
2164
  return r;
2149
2165
  const a = typeof e == "string" ? e : t, l = r.includes("?") ? "&" : "?";
2150
2166
  return `${r}${l}${n}=${encodeURIComponent(a)}`;
2151
2167
  }
2152
- function tr(r, e, t) {
2168
+ function rr(r, e, t) {
2153
2169
  if (!r || t === "url") return;
2154
2170
  const n = typeof r == "string" ? r : e, i = "zone_return_to";
2155
2171
  t === "session" ? sessionStorage.setItem(i, n) : t === "local" && localStorage.setItem(i, n);
@@ -2168,7 +2184,7 @@ const ue = ({
2168
2184
  loadingFallback: c,
2169
2185
  accessDeniedFallback: S
2170
2186
  }) => {
2171
- const h = xe(), { isAuthenticated: x, isAuthInitializing: P, currentUser: I, userPermissions: R } = de(), { tenant: k, isTenantLoading: m } = ve(), g = Wt(), b = V(() => {
2187
+ const h = xe(), { isAuthenticated: x, isAuthInitializing: P, currentUser: I, userPermissions: R } = de(), { tenant: k, isTenantLoading: m } = Te(), g = Gt(), b = V(() => {
2172
2188
  if (e)
2173
2189
  return g.presets[e];
2174
2190
  }, [e, g.presets]), C = V(
@@ -2196,7 +2212,7 @@ const ue = ({
2196
2212
  P,
2197
2213
  m
2198
2214
  ]
2199
- ), p = V(() => o.isLoading ? null : Yt(C, o), [C, o]), E = V(() => p ? A || Xt(o, g.zoneRoots) : null, [p, A, o, g.zoneRoots]), y = V(() => !p || !E ? null : {
2215
+ ), p = V(() => o.isLoading ? null : Xt(C, o), [C, o]), E = V(() => p ? A || er(o, g.zoneRoots) : null, [p, A, o, g.zoneRoots]), y = V(() => !p || !E ? null : {
2200
2216
  type: p,
2201
2217
  required: {
2202
2218
  tenant: C.tenant,
@@ -2215,7 +2231,7 @@ const ue = ({
2215
2231
  if (re(() => {
2216
2232
  y && (T ? T(y) : g.onAccessDenied && g.onAccessDenied(y));
2217
2233
  }, [y, T, g]), re(() => {
2218
- y && d && tr(d, h.pathname + h.search, g.returnToStorage);
2234
+ y && d && rr(d, h.pathname + h.search, g.returnToStorage);
2219
2235
  }, [
2220
2236
  y,
2221
2237
  d,
@@ -2223,22 +2239,22 @@ const ue = ({
2223
2239
  h.search,
2224
2240
  g.returnToStorage
2225
2241
  ]), o.isLoading)
2226
- return /* @__PURE__ */ s(B, { children: c ?? g.loadingFallback ?? null });
2242
+ return /* @__PURE__ */ s(U, { children: c ?? g.loadingFallback ?? null });
2227
2243
  if (y && E) {
2228
2244
  const u = S ?? g.accessDeniedFallback;
2229
2245
  if (u)
2230
- return /* @__PURE__ */ s(B, { children: u });
2231
- const v = er(
2246
+ return /* @__PURE__ */ s(U, { children: u });
2247
+ const v = tr(
2232
2248
  E,
2233
2249
  d,
2234
2250
  h.pathname + h.search,
2235
2251
  g.returnToParam,
2236
2252
  g.returnToStorage
2237
2253
  );
2238
- return /* @__PURE__ */ s(be, { to: v, replace: !0 });
2254
+ return /* @__PURE__ */ s(we, { to: v, replace: !0 });
2239
2255
  }
2240
- return /* @__PURE__ */ s(B, { children: r });
2241
- }, Br = (r) => /* @__PURE__ */ s(ue, { tenant: "required", ...r }), _r = (r) => /* @__PURE__ */ s(ue, { tenant: "forbidden", ...r }), Or = (r) => /* @__PURE__ */ s(ue, { auth: "required", ...r }), Vr = (r) => /* @__PURE__ */ s(ue, { auth: "forbidden", ...r }), qr = (r) => /* @__PURE__ */ s(ue, { auth: "required", userType: ae.TENANT_ADMIN, ...r }), zr = (r) => /* @__PURE__ */ s(ue, { auth: "required", userType: ae.USER, ...r }), jr = (r) => /* @__PURE__ */ s(ue, { tenant: "optional", auth: "optional", ...r }), Wr = (r) => /* @__PURE__ */ s(ue, { tenant: "required", auth: "required", ...r }), Gr = (r) => /* @__PURE__ */ s(ue, { tenant: "required", auth: "optional", ...r }), Hr = (r) => /* @__PURE__ */ s(ue, { tenant: "required", auth: "forbidden", ...r }), rr = () => /* @__PURE__ */ f(
2256
+ return /* @__PURE__ */ s(U, { children: r });
2257
+ }, _r = (r) => /* @__PURE__ */ s(ue, { tenant: "required", ...r }), Or = (r) => /* @__PURE__ */ s(ue, { tenant: "forbidden", ...r }), Vr = (r) => /* @__PURE__ */ s(ue, { auth: "required", ...r }), qr = (r) => /* @__PURE__ */ s(ue, { auth: "forbidden", ...r }), zr = (r) => /* @__PURE__ */ s(ue, { auth: "required", userType: ae.TENANT_ADMIN, ...r }), jr = (r) => /* @__PURE__ */ s(ue, { auth: "required", userType: ae.USER, ...r }), Wr = (r) => /* @__PURE__ */ s(ue, { tenant: "optional", auth: "optional", ...r }), Gr = (r) => /* @__PURE__ */ s(ue, { tenant: "required", auth: "required", ...r }), Hr = (r) => /* @__PURE__ */ s(ue, { tenant: "required", auth: "optional", ...r }), Qr = (r) => /* @__PURE__ */ s(ue, { tenant: "required", auth: "forbidden", ...r }), nr = () => /* @__PURE__ */ f(
2242
2258
  "div",
2243
2259
  {
2244
2260
  style: {
@@ -2255,13 +2271,13 @@ const ue = ({
2255
2271
  ]
2256
2272
  }
2257
2273
  );
2258
- function Qr({
2274
+ function Jr({
2259
2275
  children: r,
2260
- fallback: e = /* @__PURE__ */ s(rr, {}),
2276
+ fallback: e = /* @__PURE__ */ s(nr, {}),
2261
2277
  allowedPlans: t,
2262
2278
  requiredFeature: n
2263
2279
  }) {
2264
- const { subscription: i, hasAllowedPlan: a, isFeatureEnabled: l, loading: d } = zt();
2280
+ const { subscription: i, hasAllowedPlan: a, isFeatureEnabled: l, loading: d } = jt();
2265
2281
  return d ? /* @__PURE__ */ s(
2266
2282
  "div",
2267
2283
  {
@@ -2272,9 +2288,9 @@ function Qr({
2272
2288
  },
2273
2289
  children: "Loading subscription..."
2274
2290
  }
2275
- ) : i ? i.isActive ? t && t.length > 0 && !a(t) ? /* @__PURE__ */ s(B, { children: e }) : n && !l(n) ? /* @__PURE__ */ s(B, { children: e }) : /* @__PURE__ */ s(B, { children: r }) : /* @__PURE__ */ s(B, { children: e }) : /* @__PURE__ */ s(B, { children: e });
2291
+ ) : i ? i.isActive ? t && t.length > 0 && !a(t) ? /* @__PURE__ */ s(U, { children: e }) : n && !l(n) ? /* @__PURE__ */ s(U, { children: e }) : /* @__PURE__ */ s(U, { children: r }) : /* @__PURE__ */ s(U, { children: e }) : /* @__PURE__ */ s(U, { children: e });
2276
2292
  }
2277
- const nr = ({ flagName: r }) => /* @__PURE__ */ f(
2293
+ const sr = ({ flagName: r }) => /* @__PURE__ */ f(
2278
2294
  "div",
2279
2295
  {
2280
2296
  style: {
@@ -2301,8 +2317,8 @@ const nr = ({ flagName: r }) => /* @__PURE__ */ f(
2301
2317
  ]
2302
2318
  }
2303
2319
  );
2304
- function Jr({ name: r, children: e, fallback: t }) {
2305
- const { isEnabled: n, loading: i } = Vt();
2320
+ function Zr({ name: r, children: e, fallback: t }) {
2321
+ const { isEnabled: n, loading: i } = qt();
2306
2322
  return i ? /* @__PURE__ */ s(
2307
2323
  "div",
2308
2324
  {
@@ -2316,9 +2332,9 @@ function Jr({ name: r, children: e, fallback: t }) {
2316
2332
  },
2317
2333
  children: "Loading feature flags..."
2318
2334
  }
2319
- ) : n(r) ? /* @__PURE__ */ s(B, { children: e }) : /* @__PURE__ */ s(B, { children: t || /* @__PURE__ */ s(nr, { flagName: r }) });
2335
+ ) : n(r) ? /* @__PURE__ */ s(U, { children: e }) : /* @__PURE__ */ s(U, { children: t || /* @__PURE__ */ s(sr, { flagName: r }) });
2320
2336
  }
2321
- function we(r) {
2337
+ function ve(r) {
2322
2338
  const { submit: e, defaultErrorMessage: t, validate: n, onSuccess: i, onError: a } = r, [l, d] = N(!1), [T, A] = N(""), [c, S] = N({}), h = te((R, k) => {
2323
2339
  S((m) => ({ ...m, [R]: k }));
2324
2340
  }, []), x = te((R) => {
@@ -2533,7 +2549,7 @@ function Le(r, e) {
2533
2549
  }
2534
2550
  };
2535
2551
  }
2536
- const sr = () => me.createElement(
2552
+ const ir = () => me.createElement(
2537
2553
  "svg",
2538
2554
  {
2539
2555
  width: "16",
@@ -2548,7 +2564,7 @@ const sr = () => me.createElement(
2548
2564
  },
2549
2565
  me.createElement("path", { d: "M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z" }),
2550
2566
  me.createElement("circle", { cx: "12", cy: "12", r: "3" })
2551
- ), ir = () => me.createElement(
2567
+ ), or = () => me.createElement(
2552
2568
  "svg",
2553
2569
  {
2554
2570
  width: "16",
@@ -2565,10 +2581,10 @@ const sr = () => me.createElement(
2565
2581
  d: "M17.94 17.94A10.07 10.07 0 0 1 12 20c-7 0-11-8-11-8a18.45 18.45 0 0 1 5.06-5.94M9.9 4.24A9.12 9.12 0 0 1 12 4c7 0 11 8 11 8a18.5 18.5 0 0 1-2.16 3.19m-6.72-1.07a3 3 0 1 1-4.24-4.24"
2566
2582
  }),
2567
2583
  me.createElement("line", { x1: "1", y1: "1", x2: "23", y2: "23" })
2568
- ), or = {
2569
- showPassword: /* @__PURE__ */ s(sr, {}),
2570
- hidePassword: /* @__PURE__ */ s(ir, {})
2571
- }, ar = {
2584
+ ), ar = {
2585
+ showPassword: /* @__PURE__ */ s(ir, {}),
2586
+ hidePassword: /* @__PURE__ */ s(or, {})
2587
+ }, lr = {
2572
2588
  title: "Sign In",
2573
2589
  usernameLabel: "Email or Phone",
2574
2590
  usernamePlaceholder: "Enter your email or phone number",
@@ -2587,7 +2603,7 @@ const sr = () => me.createElement(
2587
2603
  showPasswordAriaLabel: "Show password",
2588
2604
  hidePasswordAriaLabel: "Hide password"
2589
2605
  };
2590
- function Zr({
2606
+ function Kr({
2591
2607
  copy: r = {},
2592
2608
  styles: e = {},
2593
2609
  icons: t = {},
@@ -2601,7 +2617,7 @@ function Zr({
2601
2617
  showMagicLinkOption: c = !0,
2602
2618
  className: S
2603
2619
  }) {
2604
- const [h, x] = N(""), [P, I] = N(""), [R, k] = N(!1), { login: m } = de(), g = { ...ar, ...r }, b = Le("#3b82f6", e), C = { ...or, ...t }, o = we({
2620
+ const [h, x] = N(""), [P, I] = N(""), [R, k] = N(!1), { login: m } = de(), g = { ...lr, ...r }, b = Le("#3b82f6", e), C = { ...ar, ...t }, o = ve({
2605
2621
  defaultErrorMessage: g.errorMessage,
2606
2622
  validate: () => {
2607
2623
  const u = [];
@@ -2694,7 +2710,7 @@ function Zr({
2694
2710
  ] })
2695
2711
  ] });
2696
2712
  }
2697
- const lr = {
2713
+ const cr = {
2698
2714
  title: "Create Account",
2699
2715
  nameLabel: "First Name",
2700
2716
  namePlaceholder: "Enter your first name",
@@ -2724,7 +2740,7 @@ const lr = {
2724
2740
  tenantNotFoundError: "Tenant not found",
2725
2741
  dividerBullet: "•"
2726
2742
  };
2727
- function Kr({
2743
+ function Yr({
2728
2744
  copy: r = {},
2729
2745
  styles: e = {},
2730
2746
  signupType: t = "user",
@@ -2736,8 +2752,8 @@ function Kr({
2736
2752
  showMagicLinkOption: T = !0,
2737
2753
  className: A
2738
2754
  }) {
2739
- var U;
2740
- const [c, S] = N(""), [h, x] = N(""), [P, I] = N(""), [R, k] = N(""), [m, g] = N(""), [b, C] = N(""), [o, p] = N(""), { signup: E, signupTenantAdmin: y } = de(), u = ((U = pe()) == null ? void 0 : U.tenant) ?? null, v = { ...lr, ...r }, D = Le("#10b981", e), se = !!c && (!!P || !!R) && !!m && !!b && (t === "user" || !!o), F = we({
2755
+ var B;
2756
+ const [c, S] = N(""), [h, x] = N(""), [P, I] = N(""), [R, k] = N(""), [m, g] = N(""), [b, C] = N(""), [o, p] = N(""), { signup: E, signupTenantAdmin: y } = de(), u = ((B = pe()) == null ? void 0 : B.tenant) ?? null, v = { ...cr, ...r }, D = Le("#10b981", e), se = !!c && (!!P || !!R) && !!m && !!b && (t === "user" || !!o), F = ve({
2741
2757
  defaultErrorMessage: v.errorMessage,
2742
2758
  validate: () => {
2743
2759
  const L = [];
@@ -2920,7 +2936,7 @@ function Kr({
2920
2936
  ] })
2921
2937
  ] });
2922
2938
  }
2923
- const cr = {
2939
+ const ur = {
2924
2940
  title: "Sign In with Magic Link",
2925
2941
  emailLabel: "Email",
2926
2942
  emailPlaceholder: "Enter your email",
@@ -2945,7 +2961,7 @@ const cr = {
2945
2961
  missingTenantOrEmailError: "Missing tenant or email",
2946
2962
  dividerBullet: "•"
2947
2963
  };
2948
- function Yr({
2964
+ function Xr({
2949
2965
  copy: r = {},
2950
2966
  styles: e = {},
2951
2967
  onSuccess: t,
@@ -2958,7 +2974,7 @@ function Yr({
2958
2974
  frontendUrl: A
2959
2975
  }) {
2960
2976
  var H;
2961
- const [c, S] = N(""), [h, x] = N(""), [P, I] = N(""), [R, k] = N(!1), [m, g] = N(""), [b, C] = N(!1), { sendMagicLink: o, verifyMagicLink: p } = de(), E = ((H = pe()) == null ? void 0 : H.tenant) ?? null, y = { ...cr, ...r }, u = Le("#3b82f6", e), v = we({
2977
+ const [c, S] = N(""), [h, x] = N(""), [P, I] = N(""), [R, k] = N(!1), [m, g] = N(""), [b, C] = N(!1), { sendMagicLink: o, verifyMagicLink: p } = de(), E = ((H = pe()) == null ? void 0 : H.tenant) ?? null, y = { ...ur, ...r }, u = Le("#3b82f6", e), v = ve({
2962
2978
  defaultErrorMessage: y.errorMessage,
2963
2979
  validate: () => {
2964
2980
  const j = [];
@@ -3039,7 +3055,7 @@ function Yr({
3039
3055
  children: y.showNameToggle
3040
3056
  }
3041
3057
  ) }),
3042
- b && /* @__PURE__ */ f(B, { children: [
3058
+ b && /* @__PURE__ */ f(U, { children: [
3043
3059
  /* @__PURE__ */ f("div", { style: u.fieldGroup, children: [
3044
3060
  /* @__PURE__ */ s("label", { style: u.label, children: y.nameLabel }),
3045
3061
  /* @__PURE__ */ s(
@@ -3109,7 +3125,7 @@ function Yr({
3109
3125
  ] })
3110
3126
  ] });
3111
3127
  }
3112
- const ur = {
3128
+ const dr = {
3113
3129
  title: "Verifying Magic Link",
3114
3130
  verifyingMessage: "Please wait while we verify your magic link...",
3115
3131
  successMessage: "Magic link verified successfully! You are now logged in.",
@@ -3211,7 +3227,7 @@ const ur = {
3211
3227
  backButtonHover: {
3212
3228
  backgroundColor: "#e5e7eb"
3213
3229
  }
3214
- }, dr = () => /* @__PURE__ */ s("div", { style: ut.spinner }), hr = () => /* @__PURE__ */ f(
3230
+ }, hr = () => /* @__PURE__ */ s("div", { style: ut.spinner }), pr = () => /* @__PURE__ */ f(
3215
3231
  "svg",
3216
3232
  {
3217
3233
  width: "48",
@@ -3228,7 +3244,7 @@ const ur = {
3228
3244
  /* @__PURE__ */ s("polyline", { points: "22,4 12,14.01 9,11.01" })
3229
3245
  ]
3230
3246
  }
3231
- ), pr = () => /* @__PURE__ */ f(
3247
+ ), fr = () => /* @__PURE__ */ f(
3232
3248
  "svg",
3233
3249
  {
3234
3250
  width: "48",
@@ -3246,12 +3262,12 @@ const ur = {
3246
3262
  /* @__PURE__ */ s("line", { x1: "9", y1: "9", x2: "15", y2: "15" })
3247
3263
  ]
3248
3264
  }
3249
- ), fr = {
3250
- loading: /* @__PURE__ */ s(dr, {}),
3251
- success: /* @__PURE__ */ s(hr, {}),
3252
- error: /* @__PURE__ */ s(pr, {})
3265
+ ), mr = {
3266
+ loading: /* @__PURE__ */ s(hr, {}),
3267
+ success: /* @__PURE__ */ s(pr, {}),
3268
+ error: /* @__PURE__ */ s(fr, {})
3253
3269
  };
3254
- function Xr({
3270
+ function en({
3255
3271
  copy: r = {},
3256
3272
  styles: e = {},
3257
3273
  icons: t = {},
@@ -3266,7 +3282,7 @@ function Xr({
3266
3282
  tenantSlug: S,
3267
3283
  autoRedirectDelay: h = 3e3
3268
3284
  }) {
3269
- const [x, P] = N("verifying"), [I, R] = N(""), { verifyMagicLink: k } = de(), m = { ...ur, ...r }, g = { ...ut, ...e }, b = { ...fr, ...t }, C = () => {
3285
+ const [x, P] = N("verifying"), [I, R] = N(""), { verifyMagicLink: k } = de(), m = { ...dr, ...r }, g = { ...ut, ...e }, b = { ...mr, ...t }, C = () => {
3270
3286
  if (typeof window > "u") return {};
3271
3287
  const u = new URLSearchParams(window.location.search);
3272
3288
  return {
@@ -3309,17 +3325,17 @@ function Xr({
3309
3325
  m.verifyingMessage
3310
3326
  ] });
3311
3327
  case "success":
3312
- return /* @__PURE__ */ f(B, { children: [
3328
+ return /* @__PURE__ */ f(U, { children: [
3313
3329
  b.success,
3314
3330
  /* @__PURE__ */ s("div", { style: g.successMessage, children: m.successMessage })
3315
3331
  ] });
3316
3332
  case "redirecting":
3317
- return /* @__PURE__ */ f(B, { children: [
3333
+ return /* @__PURE__ */ f(U, { children: [
3318
3334
  b.loading,
3319
3335
  /* @__PURE__ */ s("div", { style: g.message, children: m.redirectingMessage })
3320
3336
  ] });
3321
3337
  case "error":
3322
- return /* @__PURE__ */ f(B, { children: [
3338
+ return /* @__PURE__ */ f(U, { children: [
3323
3339
  b.error,
3324
3340
  /* @__PURE__ */ s("div", { style: g.errorMessage, children: I || m.errorMessage }),
3325
3341
  /* @__PURE__ */ f("div", { style: g.buttonContainer, children: [
@@ -3374,7 +3390,7 @@ function Xr({
3374
3390
  y()
3375
3391
  ] });
3376
3392
  }
3377
- const mr = {
3393
+ const gr = {
3378
3394
  title: "Reset Password",
3379
3395
  subtitle: "Enter your email address and we'll send you a link to reset your password.",
3380
3396
  emailLabel: "Email",
@@ -3401,7 +3417,7 @@ const mr = {
3401
3417
  tenantNotFoundError: "Tenant not found",
3402
3418
  dividerBullet: "•"
3403
3419
  };
3404
- function en({
3420
+ function tn({
3405
3421
  copy: r = {},
3406
3422
  styles: e = {},
3407
3423
  mode: t = "request",
@@ -3413,7 +3429,7 @@ function en({
3413
3429
  className: T
3414
3430
  }) {
3415
3431
  var se;
3416
- const [A, c] = N(""), [S, h] = N(n), [x, P] = N(""), [I, R] = N(""), [k, m] = N(""), { requestPasswordReset: g, confirmPasswordReset: b } = de(), C = ((se = pe()) == null ? void 0 : se.tenant) ?? null, o = { ...mr, ...r }, p = Le("#f59e0b", e), E = we({
3432
+ const [A, c] = N(""), [S, h] = N(n), [x, P] = N(""), [I, R] = N(""), [k, m] = N(""), { requestPasswordReset: g, confirmPasswordReset: b } = de(), C = ((se = pe()) == null ? void 0 : se.tenant) ?? null, o = { ...gr, ...r }, p = Le("#f59e0b", e), E = ve({
3417
3433
  defaultErrorMessage: o.errorMessage,
3418
3434
  validate: () => A.trim() ? C != null && C.id ? !0 : (E.setError(o.tenantNotFoundError), !1) : (E.setFieldError("email", !0), !1),
3419
3435
  submit: async () => {
@@ -3421,7 +3437,7 @@ function en({
3421
3437
  },
3422
3438
  onSuccess: () => i == null ? void 0 : i(),
3423
3439
  onError: a
3424
- }), y = we({
3440
+ }), y = ve({
3425
3441
  defaultErrorMessage: o.errorMessage,
3426
3442
  validate: () => {
3427
3443
  const F = [];
@@ -3500,7 +3516,7 @@ function en({
3500
3516
  ] }),
3501
3517
  /* @__PURE__ */ f("div", { style: p.linkContainer, children: [
3502
3518
  /* @__PURE__ */ s("a", { onClick: l, style: p.link, children: o.backToLoginLink }),
3503
- d && /* @__PURE__ */ f(B, { children: [
3519
+ d && /* @__PURE__ */ f(U, { children: [
3504
3520
  /* @__PURE__ */ s("span", { style: p.modeSwitchDivider, children: o.dividerBullet }),
3505
3521
  /* @__PURE__ */ s("a", { onClick: () => d("request"), style: p.link, children: o.requestNewLinkLink })
3506
3522
  ] })
@@ -3541,14 +3557,14 @@ function en({
3541
3557
  ] }),
3542
3558
  /* @__PURE__ */ f("div", { style: p.linkContainer, children: [
3543
3559
  /* @__PURE__ */ s("a", { onClick: l, style: p.link, children: o.backToLoginLink }),
3544
- d && /* @__PURE__ */ f(B, { children: [
3560
+ d && /* @__PURE__ */ f(U, { children: [
3545
3561
  /* @__PURE__ */ s("span", { style: p.modeSwitchDivider, children: o.dividerBullet }),
3546
3562
  /* @__PURE__ */ s("a", { onClick: () => d("reset"), style: p.link, children: o.haveTokenLink })
3547
3563
  ] })
3548
3564
  ] })
3549
3565
  ] });
3550
3566
  }
3551
- const gr = () => /* @__PURE__ */ s(
3567
+ const yr = () => /* @__PURE__ */ s(
3552
3568
  "div",
3553
3569
  {
3554
3570
  style: {
@@ -3560,7 +3576,7 @@ const gr = () => /* @__PURE__ */ s(
3560
3576
  },
3561
3577
  children: /* @__PURE__ */ s("div", { children: "Loading..." })
3562
3578
  }
3563
- ), yr = ({ error: r, retry: e }) => /* @__PURE__ */ f(
3579
+ ), br = ({ error: r, retry: e }) => /* @__PURE__ */ f(
3564
3580
  "div",
3565
3581
  {
3566
3582
  style: {
@@ -3594,7 +3610,7 @@ const gr = () => /* @__PURE__ */ s(
3594
3610
  ]
3595
3611
  }
3596
3612
  );
3597
- function tn({
3613
+ function rn({
3598
3614
  children: r,
3599
3615
  loadingFallback: e,
3600
3616
  errorFallback: t,
@@ -3605,14 +3621,14 @@ function tn({
3605
3621
  a && l(), h && d && P();
3606
3622
  };
3607
3623
  if (o)
3608
- return /* @__PURE__ */ s(B, { children: e || /* @__PURE__ */ s(gr, {}) });
3624
+ return /* @__PURE__ */ s(U, { children: e || /* @__PURE__ */ s(yr, {}) });
3609
3625
  if (p) {
3610
- const y = typeof t == "function" ? t(p, E) : t || /* @__PURE__ */ s(yr, { error: p, retry: E });
3611
- return /* @__PURE__ */ s(B, { children: y });
3626
+ const y = typeof t == "function" ? t(p, E) : t || /* @__PURE__ */ s(br, { error: p, retry: E });
3627
+ return /* @__PURE__ */ s(U, { children: y });
3612
3628
  }
3613
- return /* @__PURE__ */ s(B, { children: r });
3629
+ return /* @__PURE__ */ s(U, { children: r });
3614
3630
  }
3615
- function rn(r = !0) {
3631
+ function nn(r = !0) {
3616
3632
  const { isAppLoading: e, appError: t, retryApp: n, appInfo: i } = Ae(), a = pe(), l = Oe(), d = at(), T = lt(), A = (a == null ? void 0 : a.isTenantLoading) ?? !1, c = (a == null ? void 0 : a.tenantError) ?? null, S = (a == null ? void 0 : a.tenant) ?? null, h = (a == null ? void 0 : a.tenantSlug) ?? null, x = (a == null ? void 0 : a.retryTenant) ?? (() => {
3617
3633
  }), P = (l == null ? void 0 : l.isAuthReady) ?? !0, I = (d == null ? void 0 : d.isReady) ?? !0, R = (T == null ? void 0 : T.isReady) ?? !0, k = r && a && h, C = e || k && A || l && !P || d && !I || T && !R, o = t || (k ? c : null);
3618
3634
  return {
@@ -3630,7 +3646,7 @@ function rn(r = !0) {
3630
3646
  subscription: T ? { isReady: R } : null
3631
3647
  };
3632
3648
  }
3633
- const br = {
3649
+ const wr = {
3634
3650
  wrapper: {
3635
3651
  position: "relative"
3636
3652
  },
@@ -3674,7 +3690,7 @@ const br = {
3674
3690
  marginLeft: 8
3675
3691
  }
3676
3692
  };
3677
- function nn({
3693
+ function sn({
3678
3694
  tenants: r,
3679
3695
  currentTenantId: e,
3680
3696
  onSelect: t,
@@ -3688,7 +3704,7 @@ function nn({
3688
3704
  showCurrentTenant: c = !0
3689
3705
  }) {
3690
3706
  var C;
3691
- const S = { ...br, ...n }, h = Oe(), [x, P] = N(!1), I = Ee(null), R = r ?? (h == null ? void 0 : h.userTenants) ?? [], k = e ?? ((C = h == null ? void 0 : h.currentUser) == null ? void 0 : C.tenantId) ?? null, m = async (o) => {
3707
+ const S = { ...wr, ...n }, h = Oe(), [x, P] = N(!1), I = ye(null), R = r ?? (h == null ? void 0 : h.userTenants) ?? [], k = e ?? ((C = h == null ? void 0 : h.currentUser) == null ? void 0 : C.tenantId) ?? null, m = async (o) => {
3692
3708
  P(!1), t ? t(o) : h != null && h.switchToTenant && await h.switchToTenant(o);
3693
3709
  };
3694
3710
  re(() => {
@@ -3756,7 +3772,7 @@ function nn({
3756
3772
  }) })
3757
3773
  ] });
3758
3774
  }
3759
- class sn {
3775
+ class on {
3760
3776
  constructor(e) {
3761
3777
  this.httpService = e;
3762
3778
  }
@@ -3789,7 +3805,7 @@ class sn {
3789
3805
  return { permissions: n.data, meta: n.meta };
3790
3806
  }
3791
3807
  }
3792
- class on {
3808
+ class an {
3793
3809
  constructor(e) {
3794
3810
  this.httpService = e;
3795
3811
  }
@@ -3820,7 +3836,7 @@ class on {
3820
3836
  await this.httpService.delete(`/subscription-plans/${e}`);
3821
3837
  }
3822
3838
  }
3823
- class an {
3839
+ class ln {
3824
3840
  constructor(e) {
3825
3841
  this.httpService = e;
3826
3842
  }
@@ -3830,12 +3846,12 @@ class an {
3830
3846
  }
3831
3847
  }
3832
3848
  const dt = "returnTo", Ce = "zone_return_to", De = "zone_return_to";
3833
- function ln(r = {}) {
3849
+ function cn(r = {}) {
3834
3850
  const {
3835
3851
  zoneRoots: e = {},
3836
3852
  returnToParam: t = dt,
3837
3853
  returnToStorage: n = "url"
3838
- } = r, i = wt(), [a, l] = vt(), { isAuthenticated: d, currentUser: T } = de(), { tenant: A } = ve(), c = V(() => ({ ...ze, ...e }), [e]), S = !!A, h = T == null ? void 0 : T.userType, x = V(() => {
3854
+ } = r, i = vt(), [a, l] = Tt(), { isAuthenticated: d, currentUser: T } = de(), { tenant: A } = Te(), c = V(() => ({ ...ze, ...e }), [e]), S = !!A, h = T == null ? void 0 : T.userType, x = V(() => {
3839
3855
  switch (n) {
3840
3856
  case "url":
3841
3857
  return a.get(t);
@@ -3892,79 +3908,79 @@ function ln(r = {}) {
3892
3908
  getSmartRedirect: k
3893
3909
  };
3894
3910
  }
3895
- function cn(r, e, t = dt, n = "url") {
3911
+ function un(r, e, t = dt, n = "url") {
3896
3912
  if (!e || n !== "url")
3897
3913
  return r;
3898
3914
  const i = new URL(r, window.location.origin);
3899
3915
  return i.searchParams.set(t, e), i.pathname + i.search;
3900
3916
  }
3901
3917
  export {
3902
- qr as AdminZone,
3918
+ zr as AdminZone,
3903
3919
  Je as AppApiService,
3904
- tn as AppLoader,
3905
- Sr as AppProvider,
3906
- Nt as AuthApiService,
3907
- Rr as AuthProvider,
3908
- Or as AuthenticatedZone,
3920
+ rn as AppLoader,
3921
+ kr as AppProvider,
3922
+ Ct as AuthApiService,
3923
+ Pr as AuthProvider,
3924
+ Vr as AuthenticatedZone,
3909
3925
  oe as ConfigurationError,
3910
3926
  ct as DEFAULT_ZONE_PRESETS,
3911
3927
  ze as DEFAULT_ZONE_ROOTS,
3912
- Jr as FeatureFlag,
3913
- Ot as FeatureFlagApiService,
3914
- Lr as FeatureFlagProvider,
3915
- Vr as GuestZone,
3916
- an as HealthApiService,
3928
+ Zr as FeatureFlag,
3929
+ Vt as FeatureFlagApiService,
3930
+ Fr as FeatureFlagProvider,
3931
+ qr as GuestZone,
3932
+ ln as HealthApiService,
3917
3933
  he as HttpService,
3918
- Ur as LandingRoute,
3919
- Zr as LoginForm,
3920
- Yr as MagicLinkForm,
3921
- Xr as MagicLinkVerify,
3922
- jr as OpenZone,
3923
- en as PasswordRecoveryForm,
3924
- sn as PermissionApiService,
3925
- Dr as Protected,
3926
- Mr as ProtectedRoute,
3927
- _r as PublicZone,
3928
- Ct as RoleApiService,
3929
- Nr as RoutingProvider,
3934
+ Br as LandingRoute,
3935
+ Kr as LoginForm,
3936
+ Xr as MagicLinkForm,
3937
+ en as MagicLinkVerify,
3938
+ Wr as OpenZone,
3939
+ tn as PasswordRecoveryForm,
3940
+ on as PermissionApiService,
3941
+ Mr as Protected,
3942
+ $r as ProtectedRoute,
3943
+ Or as PublicZone,
3944
+ Dt as RoleApiService,
3945
+ Cr as RoutingProvider,
3930
3946
  ee as SessionExpiredError,
3931
3947
  Me as SessionManager,
3932
- Kr as SignupForm,
3933
- qt as SubscriptionApiService,
3934
- Qr as SubscriptionGuard,
3935
- on as SubscriptionPlanApiService,
3936
- Fr as SubscriptionProvider,
3937
- ye as TenantApiService,
3938
- Wr as TenantAuthenticatedZone,
3939
- Hr as TenantGuestZone,
3940
- Gr as TenantOpenZone,
3941
- Er as TenantProvider,
3942
- $r as TenantRoute,
3943
- nn as TenantSelector,
3944
- Br as TenantZone,
3945
- kt as TokenRefreshError,
3946
- St as TokenRefreshTimeoutError,
3947
- Dt as UserApiService,
3948
+ Yr as SignupForm,
3949
+ zt as SubscriptionApiService,
3950
+ Jr as SubscriptionGuard,
3951
+ an as SubscriptionPlanApiService,
3952
+ Nr as SubscriptionProvider,
3953
+ be as TenantApiService,
3954
+ Gr as TenantAuthenticatedZone,
3955
+ Qr as TenantGuestZone,
3956
+ Hr as TenantOpenZone,
3957
+ xr as TenantProvider,
3958
+ Ur as TenantRoute,
3959
+ sn as TenantSelector,
3960
+ _r as TenantZone,
3961
+ Et as TokenRefreshError,
3962
+ kt as TokenRefreshTimeoutError,
3963
+ Mt as UserApiService,
3948
3964
  ae as UserType,
3949
- zr as UserZone,
3965
+ jr as UserZone,
3950
3966
  ue as ZoneRoute,
3951
- cn as buildRedirectUrl,
3952
- kr as useApi,
3967
+ un as buildRedirectUrl,
3968
+ Er as useApi,
3953
3969
  Ae as useApp,
3954
- rn as useAppLoaderState,
3970
+ nn as useAppLoaderState,
3955
3971
  de as useAuth,
3956
- Ir as useAuthActions,
3972
+ Lr as useAuthActions,
3957
3973
  Oe as useAuthOptional,
3958
- Pr as useAuthState,
3959
- Vt as useFeatureFlags,
3960
- Cr as useRouting,
3961
- Wt as useRoutingOptional,
3962
- Ar as useSettings,
3963
- zt as useSubscription,
3964
- ve as useTenant,
3974
+ Ir as useAuthState,
3975
+ qt as useFeatureFlags,
3976
+ Dr as useRouting,
3977
+ Gt as useRoutingOptional,
3978
+ Rr as useSettings,
3979
+ jt as useSubscription,
3980
+ Te as useTenant,
3965
3981
  ot as useTenantInfo,
3966
3982
  pe as useTenantOptional,
3967
- xr as useTenantSettings,
3968
- ln as useZoneNavigation
3983
+ Ar as useTenantSettings,
3984
+ cn as useZoneNavigation
3969
3985
  };
3970
3986
  //# sourceMappingURL=index.es.js.map