@skylabs-digital/react-identity-access 2.1.0 → 2.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.es.js CHANGED
@@ -125,7 +125,7 @@ class Se {
125
125
  }
126
126
  }
127
127
  const Te = he(null);
128
- function xt({ config: i, children: e }) {
128
+ function kt({ config: i, children: e }) {
129
129
  const t = Q(
130
130
  () => {
131
131
  var p, h, m;
@@ -215,7 +215,7 @@ function oe() {
215
215
  throw new Error("useApp must be used within an AppProvider");
216
216
  return i;
217
217
  }
218
- const kt = oe;
218
+ const At = oe;
219
219
  class ye {
220
220
  constructor(e = {}) {
221
221
  this.refreshPromise = null, this.refreshQueue = [], e.tenantSlug !== void 0 ? this.storageKey = e.tenantSlug ? `auth_tokens_${e.tenantSlug}` : "auth_tokens" : this.storageKey = e.storageKey || "auth_tokens", this.autoRefresh = e.autoRefresh ?? !0, this.refreshThreshold = e.refreshThreshold || 3e5, this.onRefreshFailed = e.onRefreshFailed, this.baseUrl = e.baseUrl || "", this.tokenStorage = e.tokenStorage || this.createTokenStorage(this.storageKey);
@@ -632,8 +632,14 @@ function qe(i, e, t) {
632
632
  const { tenantMode: r, baseDomain: s, selectorParam: o } = i;
633
633
  return r === "subdomain" ? Be(e.hostname, s) : r === "selector" ? Ue(e.search, o, t) : null;
634
634
  }
635
+ function ze(i, e, t) {
636
+ if (t)
637
+ return `${i}.${t}`;
638
+ const r = e.split(".");
639
+ return r.length === 2 ? `${i}.${e}` : r.length >= 3 ? (r[0] = i, r.join(".")) : null;
640
+ }
635
641
  const be = he(null);
636
- function At({ config: i, children: e }) {
642
+ function Tt({ config: i, children: e }) {
637
643
  const { baseUrl: t, appInfo: r, appId: s } = oe(), o = ne(() => typeof window > "u" ? null : qe(
638
644
  {
639
645
  tenantMode: i.tenantMode || "selector",
@@ -706,12 +712,12 @@ function At({ config: i, children: e }) {
706
712
  if (Date.now() - x.timestamp > A.ttl * 0.5) {
707
713
  const d = new re(t), S = await new ue(d, s).getPublicTenantInfo(g);
708
714
  T(S);
709
- const G = {
715
+ const _ = {
710
716
  data: S,
711
717
  timestamp: Date.now(),
712
718
  tenantSlug: g
713
719
  };
714
- localStorage.setItem(A.storageKey, JSON.stringify(G));
720
+ localStorage.setItem(A.storageKey, JSON.stringify(_));
715
721
  }
716
722
  } catch (l) {
717
723
  console.warn("Background tenant refresh failed:", l);
@@ -745,8 +751,8 @@ function At({ config: i, children: e }) {
745
751
  }
746
752
  if (c != null) {
747
753
  if (d.type) {
748
- const G = d.type, ee = typeof c;
749
- G === "string" && ee !== "string" ? x.push(`Field '${b}' must be a string`) : (G === "number" || G === "integer") && ee !== "number" ? x.push(`Field '${b}' must be a number`) : G === "boolean" && ee !== "boolean" ? x.push(`Field '${b}' must be a boolean`) : G === "array" && !Array.isArray(c) && x.push(`Field '${b}' must be an array`);
754
+ const _ = d.type, ee = typeof c;
755
+ _ === "string" && ee !== "string" ? x.push(`Field '${b}' must be a string`) : (_ === "number" || _ === "integer") && ee !== "number" ? x.push(`Field '${b}' must be a number`) : _ === "boolean" && ee !== "boolean" ? x.push(`Field '${b}' must be a boolean`) : _ === "array" && !Array.isArray(c) && x.push(`Field '${b}' must be an array`);
750
756
  }
751
757
  d.minLength !== void 0 && typeof c == "string" && c.length < d.minLength && x.push(
752
758
  `Field '${b}' must be at least ${d.minLength} characters long`
@@ -776,16 +782,20 @@ function At({ config: i, children: e }) {
776
782
  (l, x = "reload") => {
777
783
  const b = i.tenantMode || "selector";
778
784
  if (localStorage.setItem("tenant", l), b === "subdomain") {
779
- const d = window.location.hostname, c = d.split(".");
780
- if (c.length >= 2) {
781
- c[0] = l;
782
- const S = c.join("."), G = `${window.location.protocol}//${S}${window.location.pathname}${window.location.search}`;
783
- window.location.href = G;
784
- } else
785
+ const d = window.location.hostname, c = ze(
786
+ l,
787
+ d,
788
+ i.baseDomain
789
+ );
790
+ if (!c) {
785
791
  console.warn(
786
792
  "[TenantProvider] Cannot switch subdomain, invalid hostname:",
787
793
  d
788
794
  );
795
+ return;
796
+ }
797
+ const S = `${window.location.protocol}//${c}${window.location.pathname}${window.location.search}`;
798
+ window.location.href = S;
789
799
  } else if (b === "selector") {
790
800
  const d = new URLSearchParams(window.location.search);
791
801
  if (d.set(i.selectorParam || "tenant", l), x === "reload") {
@@ -841,8 +851,8 @@ function fe() {
841
851
  function Pe() {
842
852
  return ce(be);
843
853
  }
844
- const Tt = fe;
845
- function Pt() {
854
+ const Pt = fe;
855
+ function Mt() {
846
856
  const { settings: i, settingsSchema: e, isSettingsLoading: t, settingsError: r, validateSettings: s } = fe();
847
857
  return {
848
858
  settings: i,
@@ -863,7 +873,7 @@ function se() {
863
873
  };
864
874
  }
865
875
  const Me = he(null);
866
- function Mt({ config: i = {}, children: e }) {
876
+ function It({ config: i = {}, children: e }) {
867
877
  const { appId: t, baseUrl: r } = oe(), { tenant: s, tenantSlug: o, switchTenant: g } = fe(), [y, A] = k(i.initialRoles || []), [w, T] = k(!i.initialRoles), [f, p] = k(null), [h, m] = k(!1), [R, C] = k(null), [U, P] = k(0), u = Q(() => new ye({
868
878
  tenantSlug: o,
869
879
  // SessionManager will generate storageKey internally
@@ -889,20 +899,20 @@ function Mt({ config: i = {}, children: e }) {
889
899
  const X = await q.getUserById(W);
890
900
  p(X), u.setUser(X), P(Date.now());
891
901
  } catch (N) {
892
- const _ = N instanceof Error ? N : new Error("Failed to load user data");
893
- C(_), console.error("[AuthProvider] Failed to load user data:", _);
902
+ const G = N instanceof Error ? N : new Error("Failed to load user data");
903
+ C(G), console.error("[AuthProvider] Failed to load user data:", G);
894
904
  } finally {
895
905
  m(!1);
896
906
  }
897
907
  }, b = async () => {
898
908
  await x();
899
909
  }, d = async (F) => {
900
- const { username: N, password: _, tenantSlug: W } = F;
910
+ const { username: N, password: G, tenantSlug: W } = F;
901
911
  let X = s == null ? void 0 : s.id, Y = o, Z = u;
902
912
  W && (X = (await new ue(M, t).getPublicTenantInfo(W)).id, Y = W);
903
913
  const J = await E.login({
904
914
  username: N,
905
- password: _,
915
+ password: G,
906
916
  appId: t,
907
917
  tenantId: X
908
918
  }), le = W && W !== o;
@@ -923,15 +933,15 @@ function Mt({ config: i = {}, children: e }) {
923
933
  }
924
934
  return le && Y && Y !== o && g(Y), J;
925
935
  }, c = async (F) => {
926
- const { email: N, phoneNumber: _, name: W, password: X, lastName: Y, tenantId: Z } = F;
927
- if (!N && !_)
936
+ const { email: N, phoneNumber: G, name: W, password: X, lastName: Y, tenantId: Z } = F;
937
+ if (!N && !G)
928
938
  throw new Error("Either email or phoneNumber is required");
929
939
  if (!W || !X)
930
940
  throw new Error("Name and password are required");
931
941
  const J = Z ?? (s == null ? void 0 : s.id);
932
942
  return await E.signup({
933
943
  email: N,
934
- phoneNumber: _,
944
+ phoneNumber: G,
935
945
  name: W,
936
946
  password: X,
937
947
  tenantId: J,
@@ -939,50 +949,50 @@ function Mt({ config: i = {}, children: e }) {
939
949
  appId: t
940
950
  });
941
951
  }, S = async (F) => {
942
- const { email: N, phoneNumber: _, name: W, password: X, tenantName: Y, lastName: Z } = F;
943
- if (!N && !_)
952
+ const { email: N, phoneNumber: G, name: W, password: X, tenantName: Y, lastName: Z } = F;
953
+ if (!N && !G)
944
954
  throw new Error("Either email or phoneNumber is required");
945
955
  if (!W || !X || !Y)
946
956
  throw new Error("Name, password, and tenantName are required");
947
957
  return await E.signupTenantAdmin({
948
958
  email: N,
949
- phoneNumber: _,
959
+ phoneNumber: G,
950
960
  name: W,
951
961
  password: X,
952
962
  tenantName: Y,
953
963
  appId: t,
954
964
  lastName: Z
955
965
  });
956
- }, G = async (F) => {
957
- const { currentPassword: N, newPassword: _ } = F, W = await u.getAuthHeaders();
958
- await E.changePassword({ currentPassword: N, newPassword: _ }, W);
966
+ }, _ = async (F) => {
967
+ const { currentPassword: N, newPassword: G } = F, W = await u.getAuthHeaders();
968
+ await E.changePassword({ currentPassword: N, newPassword: G }, W);
959
969
  }, ee = async (F) => {
960
- const { email: N, tenantId: _ } = F, W = _ ?? (s == null ? void 0 : s.id);
970
+ const { email: N, tenantId: G } = F, W = G ?? (s == null ? void 0 : s.id);
961
971
  if (!W)
962
972
  throw new Error("tenantId is required for password reset");
963
973
  await E.requestPasswordReset({ email: N, tenantId: W });
964
974
  }, z = async (F) => {
965
- const { token: N, newPassword: _ } = F;
966
- await E.confirmPasswordReset({ token: N, newPassword: _ });
975
+ const { token: N, newPassword: G } = F;
976
+ await E.confirmPasswordReset({ token: N, newPassword: G });
967
977
  }, H = async (F) => {
968
- const { email: N, frontendUrl: _, name: W, lastName: X, tenantId: Y } = F, Z = Y ?? (s == null ? void 0 : s.id);
978
+ const { email: N, frontendUrl: G, name: W, lastName: X, tenantId: Y } = F, Z = Y ?? (s == null ? void 0 : s.id);
969
979
  if (!Z)
970
980
  throw new Error("tenantId is required for magic link authentication");
971
981
  return await E.sendMagicLink({
972
982
  email: N,
973
983
  tenantId: Z,
974
- frontendUrl: _,
984
+ frontendUrl: G,
975
985
  name: W,
976
986
  lastName: X,
977
987
  appId: t
978
988
  });
979
989
  }, O = async (F) => {
980
- const { token: N, email: _, tenantSlug: W } = F;
990
+ const { token: N, email: G, tenantSlug: W } = F;
981
991
  let X = s == null ? void 0 : s.id, Y = o, Z = u;
982
992
  W && (X = (await new ue(M, t).getPublicTenantInfo(W)).id, Y = W);
983
993
  const J = await E.verifyMagicLink({
984
994
  token: N,
985
- email: _,
995
+ email: G,
986
996
  appId: t,
987
997
  tenantId: X
988
998
  }), le = W && W !== o;
@@ -1051,7 +1061,7 @@ function Mt({ config: i = {}, children: e }) {
1051
1061
  signupTenantAdmin: S,
1052
1062
  sendMagicLink: H,
1053
1063
  verifyMagicLink: O,
1054
- changePassword: G,
1064
+ changePassword: _,
1055
1065
  requestPasswordReset: ee,
1056
1066
  confirmPasswordReset: z,
1057
1067
  refreshToken: D,
@@ -1128,7 +1138,7 @@ function ae() {
1128
1138
  throw new Error("useAuth must be used within an AuthProvider");
1129
1139
  return i;
1130
1140
  }
1131
- class ze {
1141
+ class Oe {
1132
1142
  constructor(e, t) {
1133
1143
  this.httpService = e, this.sessionManager = t;
1134
1144
  }
@@ -1209,10 +1219,10 @@ class ze {
1209
1219
  }
1210
1220
  }
1211
1221
  const Ie = he(null);
1212
- function It({ config: i = {}, children: e }) {
1222
+ function Lt({ config: i = {}, children: e }) {
1213
1223
  const { baseUrl: t, appId: r } = oe(), { tenant: s } = se(), [o, g] = k([]), [y, A] = k(!1), [w, T] = k(null), f = Q(() => {
1214
1224
  const m = new re(t);
1215
- return new ze(m);
1225
+ return new Oe(m);
1216
1226
  }, [t]), p = async () => {
1217
1227
  if (!(s != null && s.id)) {
1218
1228
  g([]);
@@ -1253,13 +1263,13 @@ function It({ config: i = {}, children: e }) {
1253
1263
  }), [o, y, w]);
1254
1264
  return /* @__PURE__ */ n(Ie.Provider, { value: h, children: e });
1255
1265
  }
1256
- function Oe() {
1266
+ function We() {
1257
1267
  const i = ce(Ie);
1258
1268
  if (!i)
1259
1269
  throw new Error("useFeatureFlags must be used within a FeatureFlagProvider");
1260
1270
  return i;
1261
1271
  }
1262
- class We {
1272
+ class je {
1263
1273
  constructor(e, t) {
1264
1274
  this.httpService = e, this.sessionManager = t;
1265
1275
  }
@@ -1326,10 +1336,10 @@ class We {
1326
1336
  }
1327
1337
  }
1328
1338
  const Le = he(void 0);
1329
- function Lt({ config: i = {}, children: e }) {
1339
+ function Et({ config: i = {}, children: e }) {
1330
1340
  const { baseUrl: t } = oe(), { tenant: r } = se(), [s, o] = k(null), [g, y] = k(!1), [A, w] = k(null), T = Q(() => {
1331
1341
  const h = new re(t);
1332
- return new We(h);
1342
+ return new je(h);
1333
1343
  }, [t]), f = async () => {
1334
1344
  if (!(r != null && r.id)) {
1335
1345
  o(null);
@@ -1375,7 +1385,7 @@ function Lt({ config: i = {}, children: e }) {
1375
1385
  }, [s, g, A]);
1376
1386
  return /* @__PURE__ */ n(Le.Provider, { value: p, children: e });
1377
1387
  }
1378
- function je() {
1388
+ function Ve() {
1379
1389
  const i = ce(Le);
1380
1390
  if (i === void 0)
1381
1391
  throw new Error("useSubscription must be used within a SubscriptionProvider");
@@ -1460,7 +1470,7 @@ const xe = () => /* @__PURE__ */ a(
1460
1470
  ] })
1461
1471
  ]
1462
1472
  }
1463
- ), Ve = (i, e) => {
1473
+ ), Ge = (i, e) => {
1464
1474
  const t = {
1465
1475
  [ie.USER]: 1,
1466
1476
  [ie.TENANT_ADMIN]: 2,
@@ -1468,7 +1478,7 @@ const xe = () => /* @__PURE__ */ a(
1468
1478
  };
1469
1479
  return t[i] >= t[e];
1470
1480
  };
1471
- function Et({
1481
+ function Rt({
1472
1482
  children: i,
1473
1483
  fallback: e,
1474
1484
  minUserType: t,
@@ -1481,7 +1491,7 @@ function Et({
1481
1491
  const T = g.getUser();
1482
1492
  if (!T)
1483
1493
  return /* @__PURE__ */ n(B, { children: e || /* @__PURE__ */ n(xe, {}) });
1484
- if (t && !Ve(T.userType, t))
1494
+ if (t && !Ge(T.userType, t))
1485
1495
  return /* @__PURE__ */ n(ke, { userType: T.userType, minUserType: t });
1486
1496
  if (r && r.length > 0 && !(s ? w(r) : A(r))) {
1487
1497
  const p = r.filter((h) => !y(h)).map((h) => typeof h == "string" ? h : h.name);
@@ -1489,7 +1499,7 @@ function Et({
1489
1499
  }
1490
1500
  return /* @__PURE__ */ n(B, { children: i });
1491
1501
  }
1492
- const Ge = ({ redirectPath: i }) => /* @__PURE__ */ n(
1502
+ const _e = ({ redirectPath: i }) => /* @__PURE__ */ n(
1493
1503
  "div",
1494
1504
  {
1495
1505
  style: {
@@ -1576,7 +1586,7 @@ const Ge = ({ redirectPath: i }) => /* @__PURE__ */ n(
1576
1586
  }
1577
1587
  )
1578
1588
  }
1579
- ), _e = (i, e) => {
1589
+ ), Ke = (i, e) => {
1580
1590
  const t = {
1581
1591
  [ie.USER]: 1,
1582
1592
  [ie.TENANT_ADMIN]: 2,
@@ -1584,7 +1594,7 @@ const Ge = ({ redirectPath: i }) => /* @__PURE__ */ n(
1584
1594
  };
1585
1595
  return t[i] >= t[e];
1586
1596
  };
1587
- function Rt({
1597
+ function Ct({
1588
1598
  children: i,
1589
1599
  redirectTo: e = "/login",
1590
1600
  minUserType: t,
@@ -1595,13 +1605,13 @@ function Rt({
1595
1605
  const { hasValidSession: g, sessionManager: y, hasPermission: A, hasAnyPermission: w, hasAllPermissions: T } = ae(), f = we();
1596
1606
  if (!g())
1597
1607
  return o ? /* @__PURE__ */ n(B, { children: o }) : /* @__PURE__ */ a(B, { children: [
1598
- /* @__PURE__ */ n(Ge, { redirectPath: e }),
1608
+ /* @__PURE__ */ n(_e, { redirectPath: e }),
1599
1609
  /* @__PURE__ */ n(pe, { to: e, state: { from: f.pathname }, replace: !0 })
1600
1610
  ] });
1601
1611
  const p = y.getUser();
1602
1612
  if (!p)
1603
1613
  return /* @__PURE__ */ n(pe, { to: e, state: { from: f.pathname }, replace: !0 });
1604
- if (t && !_e(p.userType, t))
1614
+ if (t && !Ke(p.userType, t))
1605
1615
  return /* @__PURE__ */ n(Ae, { userType: p.userType, minUserType: t });
1606
1616
  if (r && r.length > 0 && !(s ? T(r) : w(r))) {
1607
1617
  const m = r.filter((R) => !A(R)).map((R) => typeof R == "string" ? R : R.name);
@@ -1609,7 +1619,7 @@ function Rt({
1609
1619
  }
1610
1620
  return /* @__PURE__ */ n(B, { children: i });
1611
1621
  }
1612
- const Ke = ({ redirectPath: i }) => /* @__PURE__ */ n(
1622
+ const Je = ({ redirectPath: i }) => /* @__PURE__ */ n(
1613
1623
  "div",
1614
1624
  {
1615
1625
  style: {
@@ -1646,14 +1656,14 @@ const Ke = ({ redirectPath: i }) => /* @__PURE__ */ n(
1646
1656
  )
1647
1657
  }
1648
1658
  );
1649
- function Ct({ children: i, redirectTo: e = "/", fallback: t }) {
1659
+ function $t({ children: i, redirectTo: e = "/", fallback: t }) {
1650
1660
  const { tenant: r, isLoading: s, error: o } = se(), g = we();
1651
1661
  return s || o ? null : r ? /* @__PURE__ */ n(B, { children: i }) : t ? /* @__PURE__ */ n(B, { children: t }) : /* @__PURE__ */ a(B, { children: [
1652
- /* @__PURE__ */ n(Ke, { redirectPath: e }),
1662
+ /* @__PURE__ */ n(Je, { redirectPath: e }),
1653
1663
  /* @__PURE__ */ n(pe, { to: e, state: { from: g.pathname }, replace: !0 })
1654
1664
  ] });
1655
1665
  }
1656
- const Je = ({ redirectPath: i }) => /* @__PURE__ */ n(
1666
+ const Ye = ({ redirectPath: i }) => /* @__PURE__ */ n(
1657
1667
  "div",
1658
1668
  {
1659
1669
  style: {
@@ -1690,14 +1700,14 @@ const Je = ({ redirectPath: i }) => /* @__PURE__ */ n(
1690
1700
  )
1691
1701
  }
1692
1702
  );
1693
- function $t({ children: i, redirectTo: e = "/dashboard", fallback: t }) {
1703
+ function Ft({ children: i, redirectTo: e = "/dashboard", fallback: t }) {
1694
1704
  const { tenant: r, isLoading: s, error: o } = se(), g = we();
1695
1705
  return s || o ? null : r ? t ? /* @__PURE__ */ n(B, { children: t }) : /* @__PURE__ */ a(B, { children: [
1696
- /* @__PURE__ */ n(Je, { redirectPath: e }),
1706
+ /* @__PURE__ */ n(Ye, { redirectPath: e }),
1697
1707
  /* @__PURE__ */ n(pe, { to: e, state: { from: g.pathname }, replace: !0 })
1698
1708
  ] }) : /* @__PURE__ */ n(B, { children: i });
1699
1709
  }
1700
- const Ye = () => /* @__PURE__ */ a(
1710
+ const Qe = () => /* @__PURE__ */ a(
1701
1711
  "div",
1702
1712
  {
1703
1713
  style: {
@@ -1714,13 +1724,13 @@ const Ye = () => /* @__PURE__ */ a(
1714
1724
  ]
1715
1725
  }
1716
1726
  );
1717
- function Ft({
1727
+ function Dt({
1718
1728
  children: i,
1719
- fallback: e = /* @__PURE__ */ n(Ye, {}),
1729
+ fallback: e = /* @__PURE__ */ n(Qe, {}),
1720
1730
  allowedPlans: t,
1721
1731
  requiredFeature: r
1722
1732
  }) {
1723
- const { subscription: s, hasAllowedPlan: o, isFeatureEnabled: g, loading: y } = je();
1733
+ const { subscription: s, hasAllowedPlan: o, isFeatureEnabled: g, loading: y } = Ve();
1724
1734
  return y ? /* @__PURE__ */ n(
1725
1735
  "div",
1726
1736
  {
@@ -1733,7 +1743,7 @@ function Ft({
1733
1743
  }
1734
1744
  ) : s ? s.isActive ? t && t.length > 0 && !o(t) ? /* @__PURE__ */ n(B, { children: e }) : r && !g(r) ? /* @__PURE__ */ n(B, { children: e }) : /* @__PURE__ */ n(B, { children: i }) : /* @__PURE__ */ n(B, { children: e }) : /* @__PURE__ */ n(B, { children: e });
1735
1745
  }
1736
- const Qe = ({ flagName: i }) => /* @__PURE__ */ a(
1746
+ const Xe = ({ flagName: i }) => /* @__PURE__ */ a(
1737
1747
  "div",
1738
1748
  {
1739
1749
  style: {
@@ -1760,8 +1770,8 @@ const Qe = ({ flagName: i }) => /* @__PURE__ */ a(
1760
1770
  ]
1761
1771
  }
1762
1772
  );
1763
- function Dt({ name: i, children: e, fallback: t }) {
1764
- const { isEnabled: r, loading: s } = Oe();
1773
+ function Ht({ name: i, children: e, fallback: t }) {
1774
+ const { isEnabled: r, loading: s } = We();
1765
1775
  return s ? /* @__PURE__ */ n(
1766
1776
  "div",
1767
1777
  {
@@ -1775,9 +1785,9 @@ function Dt({ name: i, children: e, fallback: t }) {
1775
1785
  },
1776
1786
  children: "Loading feature flags..."
1777
1787
  }
1778
- ) : r(i) ? /* @__PURE__ */ n(B, { children: e }) : /* @__PURE__ */ n(B, { children: t || /* @__PURE__ */ n(Qe, { flagName: i }) });
1788
+ ) : r(i) ? /* @__PURE__ */ n(B, { children: e }) : /* @__PURE__ */ n(B, { children: t || /* @__PURE__ */ n(Xe, { flagName: i }) });
1779
1789
  }
1780
- const Xe = () => /* @__PURE__ */ a(
1790
+ const Ze = () => /* @__PURE__ */ a(
1781
1791
  "svg",
1782
1792
  {
1783
1793
  width: "16",
@@ -1794,7 +1804,7 @@ const Xe = () => /* @__PURE__ */ a(
1794
1804
  /* @__PURE__ */ n("circle", { cx: "12", cy: "12", r: "3" })
1795
1805
  ]
1796
1806
  }
1797
- ), Ze = () => /* @__PURE__ */ a(
1807
+ ), et = () => /* @__PURE__ */ a(
1798
1808
  "svg",
1799
1809
  {
1800
1810
  width: "16",
@@ -1811,10 +1821,10 @@ const Xe = () => /* @__PURE__ */ a(
1811
1821
  /* @__PURE__ */ n("line", { x1: "1", y1: "1", x2: "23", y2: "23" })
1812
1822
  ]
1813
1823
  }
1814
- ), et = {
1815
- showPassword: /* @__PURE__ */ n(Xe, {}),
1816
- hidePassword: /* @__PURE__ */ n(Ze, {})
1817
- }, tt = {
1824
+ ), tt = {
1825
+ showPassword: /* @__PURE__ */ n(Ze, {}),
1826
+ hidePassword: /* @__PURE__ */ n(et, {})
1827
+ }, rt = {
1818
1828
  title: "Sign In",
1819
1829
  usernameLabel: "Email or Phone",
1820
1830
  usernamePlaceholder: "Enter your email or phone number",
@@ -1828,7 +1838,7 @@ const Xe = () => /* @__PURE__ */ a(
1828
1838
  magicLinkLink: "Use Magic Link",
1829
1839
  errorMessage: "Invalid credentials",
1830
1840
  loadingText: "Signing in..."
1831
- }, rt = {
1841
+ }, nt = {
1832
1842
  container: {
1833
1843
  maxWidth: "400px",
1834
1844
  width: "100%",
@@ -1935,7 +1945,7 @@ const Xe = () => /* @__PURE__ */ a(
1935
1945
  fontSize: "0.875rem"
1936
1946
  }
1937
1947
  };
1938
- function Ht({
1948
+ function Nt({
1939
1949
  copy: i = {},
1940
1950
  styles: e = {},
1941
1951
  icons: t = {},
@@ -1949,7 +1959,7 @@ function Ht({
1949
1959
  showMagicLinkOption: T = !0,
1950
1960
  className: f
1951
1961
  }) {
1952
- const [p, h] = k(""), [m, R] = k(""), [C, U] = k(!1), [P, u] = k(!1), [M, E] = k(""), [q, V] = k({}), { login: $ } = ae(), { tenant: j } = se(), v = { ...tt, ...i }, I = { ...rt, ...e }, L = { ...et, ...t }, l = () => {
1962
+ const [p, h] = k(""), [m, R] = k(""), [C, U] = k(!1), [P, u] = k(!1), [M, E] = k(""), [q, V] = k({}), { login: $ } = ae(), { tenant: j } = se(), v = { ...rt, ...i }, I = { ...nt, ...e }, L = { ...tt, ...t }, l = () => {
1953
1963
  const c = {};
1954
1964
  return p.trim() || (c.username = !0), m.trim() || (c.password = !0), V(c), Object.keys(c).length === 0;
1955
1965
  }, x = async (c) => {
@@ -1967,8 +1977,8 @@ function Ht({
1967
1977
  });
1968
1978
  r == null || r(S);
1969
1979
  } catch (S) {
1970
- const G = S.message || v.errorMessage;
1971
- E(G), s == null || s(G);
1980
+ const _ = S.message || v.errorMessage;
1981
+ E(_), s == null || s(_);
1972
1982
  } finally {
1973
1983
  u(!1);
1974
1984
  }
@@ -2061,7 +2071,7 @@ function Ht({
2061
2071
  ] })
2062
2072
  ] });
2063
2073
  }
2064
- const nt = {
2074
+ const st = {
2065
2075
  title: "Create Account",
2066
2076
  nameLabel: "First Name",
2067
2077
  namePlaceholder: "Enter your first name",
@@ -2087,7 +2097,7 @@ const nt = {
2087
2097
  passwordMismatchError: "Passwords do not match",
2088
2098
  isAdminLabel: "Create new organization",
2089
2099
  isAdminDescription: "Check this if you want to create a new organization"
2090
- }, st = {
2100
+ }, it = {
2091
2101
  container: {
2092
2102
  maxWidth: "400px",
2093
2103
  width: "100%",
@@ -2186,7 +2196,7 @@ const nt = {
2186
2196
  fontSize: "0.875rem"
2187
2197
  }
2188
2198
  };
2189
- function Nt({
2199
+ function Bt({
2190
2200
  copy: i = {},
2191
2201
  styles: e = {},
2192
2202
  signupType: t = "user",
@@ -2198,11 +2208,11 @@ function Nt({
2198
2208
  showMagicLinkOption: A = !0,
2199
2209
  className: w
2200
2210
  }) {
2201
- const [T, f] = k(""), [p, h] = k(""), [m, R] = k(""), [C, U] = k(""), [P, u] = k(""), [M, E] = k(""), [q, V] = k(""), [$, j] = k(!1), [v, I] = k(""), [L, l] = k({}), { signup: x, signupTenantAdmin: b } = ae(), { tenant: d } = se(), c = { ...nt, ...i }, S = { ...st, ...e }, G = () => {
2211
+ const [T, f] = k(""), [p, h] = k(""), [m, R] = k(""), [C, U] = k(""), [P, u] = k(""), [M, E] = k(""), [q, V] = k(""), [$, j] = k(!1), [v, I] = k(""), [L, l] = k({}), { signup: x, signupTenantAdmin: b } = ae(), { tenant: d } = se(), c = { ...st, ...i }, S = { ...it, ...e }, _ = () => {
2202
2212
  const D = {};
2203
2213
  return T.trim() || (D.name = !0), !m.trim() && !C.trim() && (D.email = !0, D.phoneNumber = !0), P.trim() || (D.password = !0), M.trim() || (D.confirmPassword = !0), t === "tenant" && !q.trim() && (D.tenantName = !0), l(D), Object.keys(D).length === 0;
2204
2214
  }, ee = async (D) => {
2205
- if (D.preventDefault(), !!G()) {
2215
+ if (D.preventDefault(), !!_()) {
2206
2216
  if (P !== M) {
2207
2217
  I(c.passwordMismatchError), l({ confirmPassword: !0 });
2208
2218
  return;
@@ -2405,7 +2415,7 @@ function Nt({
2405
2415
  ] })
2406
2416
  ] });
2407
2417
  }
2408
- const it = {
2418
+ const ot = {
2409
2419
  title: "Sign In with Magic Link",
2410
2420
  emailLabel: "Email",
2411
2421
  emailPlaceholder: "Enter your email",
@@ -2423,7 +2433,7 @@ const it = {
2423
2433
  loadingText: "Sending magic link...",
2424
2434
  verifyingText: "Verifying magic link...",
2425
2435
  description: "Enter your email to receive a magic link. If you don't have an account, we'll create one for you."
2426
- }, ot = {
2436
+ }, at = {
2427
2437
  container: {
2428
2438
  maxWidth: "400px",
2429
2439
  width: "100%",
@@ -2526,7 +2536,7 @@ const it = {
2526
2536
  fontSize: "0.875rem"
2527
2537
  }
2528
2538
  };
2529
- function Bt({
2539
+ function Ut({
2530
2540
  copy: i = {},
2531
2541
  styles: e = {},
2532
2542
  onSuccess: t,
@@ -2538,7 +2548,7 @@ function Bt({
2538
2548
  verifyToken: A,
2539
2549
  frontendUrl: w
2540
2550
  }) {
2541
- const [T, f] = k(""), [p, h] = k(""), [m, R] = k(""), [C, U] = k(!1), [P, u] = k(!1), [M, E] = k(""), [q, V] = k(""), [$, j] = k({}), [v, I] = k(!1), { sendMagicLink: L, verifyMagicLink: l } = ae(), { tenant: x } = se(), b = { ...it, ...i }, d = { ...ot, ...e };
2551
+ const [T, f] = k(""), [p, h] = k(""), [m, R] = k(""), [C, U] = k(!1), [P, u] = k(!1), [M, E] = k(""), [q, V] = k(""), [$, j] = k({}), [v, I] = k(!1), { sendMagicLink: L, verifyMagicLink: l } = ae(), { tenant: x } = se(), b = { ...ot, ...i }, d = { ...at, ...e };
2542
2552
  te(() => {
2543
2553
  A && c(A);
2544
2554
  }, [A]);
@@ -2564,7 +2574,7 @@ function Bt({
2564
2574
  }, S = () => {
2565
2575
  const H = {};
2566
2576
  return T.trim() || (H.email = !0), v && !p.trim() && (H.name = !0), j(H), Object.keys(H).length === 0;
2567
- }, G = async (H) => {
2577
+ }, _ = async (H) => {
2568
2578
  if (H.preventDefault(), !!S()) {
2569
2579
  if (!(x != null && x.id)) {
2570
2580
  E("Tenant not found");
@@ -2601,7 +2611,7 @@ function Bt({
2601
2611
  ] }) : /* @__PURE__ */ a("div", { className: y, style: d.container, children: [
2602
2612
  /* @__PURE__ */ n("h2", { style: d.title, children: b.title }),
2603
2613
  /* @__PURE__ */ n("p", { style: d.description, children: b.description }),
2604
- /* @__PURE__ */ a("form", { onSubmit: G, style: d.form, children: [
2614
+ /* @__PURE__ */ a("form", { onSubmit: _, style: d.form, children: [
2605
2615
  /* @__PURE__ */ a("div", { style: d.fieldGroup, children: [
2606
2616
  /* @__PURE__ */ n("label", { style: d.label, children: b.emailLabel }),
2607
2617
  /* @__PURE__ */ n(
@@ -2713,7 +2723,7 @@ function Bt({
2713
2723
  ] })
2714
2724
  ] });
2715
2725
  }
2716
- const at = {
2726
+ const lt = {
2717
2727
  title: "Verifying Magic Link",
2718
2728
  verifyingMessage: "Please wait while we verify your magic link...",
2719
2729
  successMessage: "Magic link verified successfully! You are now logged in.",
@@ -2808,7 +2818,7 @@ const at = {
2808
2818
  cursor: "pointer",
2809
2819
  transition: "all 0.15s ease-in-out"
2810
2820
  }
2811
- }, lt = () => /* @__PURE__ */ n("div", { style: Ee.spinner }), ct = () => /* @__PURE__ */ a(
2821
+ }, ct = () => /* @__PURE__ */ n("div", { style: Ee.spinner }), dt = () => /* @__PURE__ */ a(
2812
2822
  "svg",
2813
2823
  {
2814
2824
  width: "48",
@@ -2825,7 +2835,7 @@ const at = {
2825
2835
  /* @__PURE__ */ n("polyline", { points: "22,4 12,14.01 9,11.01" })
2826
2836
  ]
2827
2837
  }
2828
- ), dt = () => /* @__PURE__ */ a(
2838
+ ), ut = () => /* @__PURE__ */ a(
2829
2839
  "svg",
2830
2840
  {
2831
2841
  width: "48",
@@ -2843,12 +2853,12 @@ const at = {
2843
2853
  /* @__PURE__ */ n("line", { x1: "9", y1: "9", x2: "15", y2: "15" })
2844
2854
  ]
2845
2855
  }
2846
- ), ut = {
2847
- loading: /* @__PURE__ */ n(lt, {}),
2848
- success: /* @__PURE__ */ n(ct, {}),
2849
- error: /* @__PURE__ */ n(dt, {})
2856
+ ), ht = {
2857
+ loading: /* @__PURE__ */ n(ct, {}),
2858
+ success: /* @__PURE__ */ n(dt, {}),
2859
+ error: /* @__PURE__ */ n(ut, {})
2850
2860
  };
2851
- function Ut({
2861
+ function qt({
2852
2862
  copy: i = {},
2853
2863
  styles: e = {},
2854
2864
  icons: t = {},
@@ -2863,7 +2873,7 @@ function Ut({
2863
2873
  tenantSlug: f,
2864
2874
  autoRedirectDelay: p = 3e3
2865
2875
  }) {
2866
- const [h, m] = k("verifying"), [R, C] = k(""), { verifyMagicLink: U } = ae(), P = { ...at, ...i }, u = { ...Ee, ...e }, M = { ...ut, ...t }, E = () => {
2876
+ const [h, m] = k("verifying"), [R, C] = k(""), { verifyMagicLink: U } = ae(), P = { ...lt, ...i }, u = { ...Ee, ...e }, M = { ...ht, ...t }, E = () => {
2867
2877
  if (typeof window > "u") return {};
2868
2878
  const v = new URLSearchParams(window.location.search);
2869
2879
  return {
@@ -2965,7 +2975,7 @@ function Ut({
2965
2975
  j()
2966
2976
  ] });
2967
2977
  }
2968
- const ht = {
2978
+ const gt = {
2969
2979
  title: "Reset Password",
2970
2980
  subtitle: "Enter your email address and we'll send you a link to reset your password.",
2971
2981
  emailLabel: "Email",
@@ -2987,7 +2997,7 @@ const ht = {
2987
2997
  resetLoadingText: "Resetting...",
2988
2998
  resetSuccessMessage: "Password reset successfully!",
2989
2999
  passwordMismatchError: "Passwords do not match"
2990
- }, gt = {
3000
+ }, pt = {
2991
3001
  container: {
2992
3002
  maxWidth: "400px",
2993
3003
  margin: "0 auto",
@@ -3079,7 +3089,7 @@ const ht = {
3079
3089
  cursor: "pointer"
3080
3090
  }
3081
3091
  };
3082
- function qt({
3092
+ function zt({
3083
3093
  copy: i = {},
3084
3094
  styles: e = {},
3085
3095
  mode: t = "request",
@@ -3090,7 +3100,7 @@ function qt({
3090
3100
  onModeChange: y,
3091
3101
  className: A
3092
3102
  }) {
3093
- const [w, T] = k(""), [f, p] = k(r), [h, m] = k(""), [R, C] = k(""), [U, P] = k(!1), [u, M] = k(""), [E, q] = k(""), [V, $] = k({}), { requestPasswordReset: j, confirmPasswordReset: v } = ae(), { tenant: I } = se(), L = { ...ht, ...i }, l = { ...gt, ...e }, x = () => {
3103
+ const [w, T] = k(""), [f, p] = k(r), [h, m] = k(""), [R, C] = k(""), [U, P] = k(!1), [u, M] = k(""), [E, q] = k(""), [V, $] = k({}), { requestPasswordReset: j, confirmPasswordReset: v } = ae(), { tenant: I } = se(), L = { ...gt, ...i }, l = { ...pt, ...e }, x = () => {
3094
3104
  const z = {};
3095
3105
  return w.trim() || (z.email = !0), $(z), Object.keys(z).length === 0;
3096
3106
  }, b = () => {
@@ -3131,7 +3141,7 @@ function qt({
3131
3141
  }, S = (z) => ({
3132
3142
  ...l.input,
3133
3143
  ...V[z] ? l.inputError : {}
3134
- }), G = () => ({
3144
+ }), _ = () => ({
3135
3145
  ...l.button,
3136
3146
  ...U ? l.buttonLoading : {}
3137
3147
  });
@@ -3195,7 +3205,7 @@ function qt({
3195
3205
  type: "submit",
3196
3206
  disabled: !z || U,
3197
3207
  style: {
3198
- ...G(),
3208
+ ..._(),
3199
3209
  ...!z || U ? l.buttonDisabled : {}
3200
3210
  },
3201
3211
  children: U ? L.resetLoadingText : L.resetSubmitButton
@@ -3240,7 +3250,7 @@ function qt({
3240
3250
  type: "submit",
3241
3251
  disabled: !ee || U,
3242
3252
  style: {
3243
- ...G(),
3253
+ ..._(),
3244
3254
  ...!ee || U ? l.buttonDisabled : {}
3245
3255
  },
3246
3256
  children: U ? L.loadingText : L.submitButton
@@ -3258,7 +3268,7 @@ function qt({
3258
3268
  ] })
3259
3269
  ] });
3260
3270
  }
3261
- const pt = () => /* @__PURE__ */ n(
3271
+ const ft = () => /* @__PURE__ */ n(
3262
3272
  "div",
3263
3273
  {
3264
3274
  style: {
@@ -3270,7 +3280,7 @@ const pt = () => /* @__PURE__ */ n(
3270
3280
  },
3271
3281
  children: /* @__PURE__ */ n("div", { children: "Loading..." })
3272
3282
  }
3273
- ), ft = ({ error: i, retry: e }) => /* @__PURE__ */ a(
3283
+ ), mt = ({ error: i, retry: e }) => /* @__PURE__ */ a(
3274
3284
  "div",
3275
3285
  {
3276
3286
  style: {
@@ -3304,7 +3314,7 @@ const pt = () => /* @__PURE__ */ n(
3304
3314
  ]
3305
3315
  }
3306
3316
  );
3307
- function zt({
3317
+ function Ot({
3308
3318
  children: i,
3309
3319
  loadingFallback: e,
3310
3320
  errorFallback: t,
@@ -3315,14 +3325,14 @@ function zt({
3315
3325
  o && g(), w && y && f();
3316
3326
  };
3317
3327
  if (h)
3318
- return /* @__PURE__ */ n(B, { children: e || /* @__PURE__ */ n(pt, {}) });
3328
+ return /* @__PURE__ */ n(B, { children: e || /* @__PURE__ */ n(ft, {}) });
3319
3329
  if (m) {
3320
- const C = typeof t == "function" ? t(m, R) : t || /* @__PURE__ */ n(ft, { error: m, retry: R });
3330
+ const C = typeof t == "function" ? t(m, R) : t || /* @__PURE__ */ n(mt, { error: m, retry: R });
3321
3331
  return /* @__PURE__ */ n(B, { children: C });
3322
3332
  }
3323
3333
  return /* @__PURE__ */ n(B, { children: i });
3324
3334
  }
3325
- function Ot(i = !0) {
3335
+ function Wt(i = !0) {
3326
3336
  const { isAppLoading: e, appError: t, retryApp: r, appInfo: s } = oe(), o = Pe(), g = (o == null ? void 0 : o.isTenantLoading) ?? !1, y = (o == null ? void 0 : o.tenantError) ?? null, A = (o == null ? void 0 : o.tenant) ?? null, w = (o == null ? void 0 : o.tenantSlug) ?? null, T = (o == null ? void 0 : o.retryTenant) ?? (() => {
3327
3337
  }), f = i && o && w, p = e || f && g, h = t || (f ? y : null);
3328
3338
  return {
@@ -3337,7 +3347,7 @@ function Ot(i = !0) {
3337
3347
  tenant: o ? { isLoading: g, error: y, data: A } : null
3338
3348
  };
3339
3349
  }
3340
- class Wt {
3350
+ class jt {
3341
3351
  constructor(e, t) {
3342
3352
  this.httpService = e, this.sessionManager = t;
3343
3353
  }
@@ -3405,7 +3415,7 @@ class Wt {
3405
3415
  };
3406
3416
  }
3407
3417
  }
3408
- class jt {
3418
+ class Vt {
3409
3419
  constructor(e, t) {
3410
3420
  this.httpService = e, this.sessionManager = t;
3411
3421
  }
@@ -3456,7 +3466,7 @@ class jt {
3456
3466
  });
3457
3467
  }
3458
3468
  }
3459
- class Vt {
3469
+ class Gt {
3460
3470
  constructor(e) {
3461
3471
  this.httpService = e;
3462
3472
  }
@@ -3465,7 +3475,7 @@ class Vt {
3465
3475
  return await this.httpService.get("/health");
3466
3476
  }
3467
3477
  }
3468
- class Gt {
3478
+ class _t {
3469
3479
  // Date string to Date object
3470
3480
  static toDate(e) {
3471
3481
  return new Date(e);
@@ -3588,47 +3598,47 @@ class Gt {
3588
3598
  }
3589
3599
  }
3590
3600
  export {
3591
- Gt as ApiMappers,
3601
+ _t as ApiMappers,
3592
3602
  Se as AppApiService,
3593
- zt as AppLoader,
3594
- xt as AppProvider,
3603
+ Ot as AppLoader,
3604
+ kt as AppProvider,
3595
3605
  He as AuthApiService,
3596
- Mt as AuthProvider,
3597
- Dt as FeatureFlag,
3598
- ze as FeatureFlagApiService,
3599
- It as FeatureFlagProvider,
3600
- Vt as HealthApiService,
3606
+ It as AuthProvider,
3607
+ Ht as FeatureFlag,
3608
+ Oe as FeatureFlagApiService,
3609
+ Lt as FeatureFlagProvider,
3610
+ Gt as HealthApiService,
3601
3611
  re as HttpService,
3602
- $t as LandingRoute,
3603
- Ht as LoginForm,
3604
- Bt as MagicLinkForm,
3605
- Ut as MagicLinkVerify,
3606
- qt as PasswordRecoveryForm,
3607
- Wt as PermissionApiService,
3608
- Et as Protected,
3609
- Rt as ProtectedRoute,
3612
+ Ft as LandingRoute,
3613
+ Nt as LoginForm,
3614
+ Ut as MagicLinkForm,
3615
+ qt as MagicLinkVerify,
3616
+ zt as PasswordRecoveryForm,
3617
+ jt as PermissionApiService,
3618
+ Rt as Protected,
3619
+ Ct as ProtectedRoute,
3610
3620
  ve as RoleApiService,
3611
3621
  ye as SessionManager,
3612
- Nt as SignupForm,
3613
- We as SubscriptionApiService,
3614
- Ft as SubscriptionGuard,
3615
- jt as SubscriptionPlanApiService,
3616
- Lt as SubscriptionProvider,
3622
+ Bt as SignupForm,
3623
+ je as SubscriptionApiService,
3624
+ Dt as SubscriptionGuard,
3625
+ Vt as SubscriptionPlanApiService,
3626
+ Et as SubscriptionProvider,
3617
3627
  ue as TenantApiService,
3618
- At as TenantProvider,
3619
- Ct as TenantRoute,
3628
+ Tt as TenantProvider,
3629
+ $t as TenantRoute,
3620
3630
  Ne as UserApiService,
3621
3631
  ie as UserType,
3622
- kt as useApi,
3632
+ At as useApi,
3623
3633
  oe as useApp,
3624
- Ot as useAppLoaderState,
3634
+ Wt as useAppLoaderState,
3625
3635
  ae as useAuth,
3626
- Oe as useFeatureFlags,
3627
- Pt as useSettings,
3628
- je as useSubscription,
3636
+ We as useFeatureFlags,
3637
+ Mt as useSettings,
3638
+ Ve as useSubscription,
3629
3639
  fe as useTenant,
3630
3640
  se as useTenantInfo,
3631
3641
  Pe as useTenantOptional,
3632
- Tt as useTenantSettings
3642
+ Pt as useTenantSettings
3633
3643
  };
3634
3644
  //# sourceMappingURL=index.es.js.map