@skylabs-digital/react-identity-access 2.7.0 → 2.8.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 +260 -255
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/providers/AuthProvider.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.es.js
CHANGED
|
@@ -128,12 +128,12 @@ const ve = ue(null);
|
|
|
128
128
|
function Bt({ config: i, children: e }) {
|
|
129
129
|
const t = X(
|
|
130
130
|
() => {
|
|
131
|
-
var f, A,
|
|
131
|
+
var f, A, E;
|
|
132
132
|
return {
|
|
133
133
|
enabled: ((f = i.cache) == null ? void 0 : f.enabled) ?? !0,
|
|
134
134
|
ttl: ((A = i.cache) == null ? void 0 : A.ttl) ?? 3e5,
|
|
135
135
|
// 5 minutes default
|
|
136
|
-
storageKey: ((
|
|
136
|
+
storageKey: ((E = i.cache) == null ? void 0 : E.storageKey) ?? `app_cache_${i.appId}`
|
|
137
137
|
};
|
|
138
138
|
},
|
|
139
139
|
[i.cache, i.appId]
|
|
@@ -165,21 +165,21 @@ function Bt({ config: i, children: e }) {
|
|
|
165
165
|
if (!(!f && t.enabled && r))
|
|
166
166
|
try {
|
|
167
167
|
a(!0), w(null);
|
|
168
|
-
const A = new re(i.baseUrl),
|
|
169
|
-
if (s(
|
|
168
|
+
const A = new re(i.baseUrl), $ = await new Pe(A, {}).getPublicAppInfo(i.appId);
|
|
169
|
+
if (s($), t.enabled)
|
|
170
170
|
try {
|
|
171
|
-
const
|
|
172
|
-
data:
|
|
171
|
+
const L = {
|
|
172
|
+
data: $,
|
|
173
173
|
timestamp: Date.now(),
|
|
174
174
|
appId: i.appId
|
|
175
175
|
};
|
|
176
|
-
localStorage.setItem(t.storageKey, JSON.stringify(
|
|
177
|
-
} catch (
|
|
178
|
-
console.warn("Failed to cache app info:",
|
|
176
|
+
localStorage.setItem(t.storageKey, JSON.stringify(L));
|
|
177
|
+
} catch (L) {
|
|
178
|
+
console.warn("Failed to cache app info:", L);
|
|
179
179
|
}
|
|
180
180
|
} catch (A) {
|
|
181
|
-
const
|
|
182
|
-
w(
|
|
181
|
+
const E = A instanceof Error ? A : new Error("Failed to load app information");
|
|
182
|
+
w(E), s(null);
|
|
183
183
|
} finally {
|
|
184
184
|
a(!1);
|
|
185
185
|
}
|
|
@@ -192,7 +192,7 @@ function Bt({ config: i, children: e }) {
|
|
|
192
192
|
if (!f) return;
|
|
193
193
|
const A = JSON.parse(f);
|
|
194
194
|
if (Date.now() - A.timestamp > t.ttl * 0.5) {
|
|
195
|
-
const
|
|
195
|
+
const $ = new re(i.baseUrl), P = await new Pe($, {}).getPublicAppInfo(i.appId);
|
|
196
196
|
s(P);
|
|
197
197
|
const u = {
|
|
198
198
|
data: P,
|
|
@@ -697,10 +697,10 @@ function zt({ config: i, children: e }) {
|
|
|
697
697
|
window.localStorage
|
|
698
698
|
), [i.tenantMode, i.baseDomain, i.selectorParam]), [a, g] = S(() => o()), w = X(
|
|
699
699
|
() => {
|
|
700
|
-
var c,
|
|
700
|
+
var c, R, T;
|
|
701
701
|
return {
|
|
702
702
|
enabled: ((c = i.cache) == null ? void 0 : c.enabled) ?? !0,
|
|
703
|
-
ttl: ((
|
|
703
|
+
ttl: ((R = i.cache) == null ? void 0 : R.ttl) ?? 5 * 60 * 1e3,
|
|
704
704
|
// 5 minutes default
|
|
705
705
|
storageKey: ((T = i.cache) == null ? void 0 : T.storageKey) ?? `tenant_cache_${a || "default"}`
|
|
706
706
|
};
|
|
@@ -712,21 +712,21 @@ function zt({ config: i, children: e }) {
|
|
|
712
712
|
try {
|
|
713
713
|
const c = localStorage.getItem(w.storageKey);
|
|
714
714
|
if (!c) return null;
|
|
715
|
-
const
|
|
716
|
-
return Date.now() -
|
|
715
|
+
const R = JSON.parse(c);
|
|
716
|
+
return Date.now() - R.timestamp < w.ttl && R.tenantSlug === a ? R.data : (localStorage.removeItem(w.storageKey), null);
|
|
717
717
|
} catch {
|
|
718
718
|
return null;
|
|
719
719
|
}
|
|
720
|
-
}), [b, f] = S(!m && !i.initialTenant), [A,
|
|
720
|
+
}), [b, f] = S(!m && !i.initialTenant), [A, E] = S(null), [$, L] = S(null), [P, u] = S(!1), [M, z] = S(null);
|
|
721
721
|
te(() => {
|
|
722
722
|
const c = o();
|
|
723
723
|
g(c);
|
|
724
724
|
}, [o]);
|
|
725
|
-
const
|
|
726
|
-
async (c,
|
|
727
|
-
if (!(!
|
|
725
|
+
const N = (r == null ? void 0 : r.settingsSchema) || null, p = se(
|
|
726
|
+
async (c, R = !1) => {
|
|
727
|
+
if (!(!R && w.enabled && m && m.domain === c))
|
|
728
728
|
try {
|
|
729
|
-
f(!0),
|
|
729
|
+
f(!0), E(null);
|
|
730
730
|
const T = new re(t), d = await new de(T, s).getPublicTenantInfo(c);
|
|
731
731
|
if (k(d), w.enabled)
|
|
732
732
|
try {
|
|
@@ -741,7 +741,7 @@ function zt({ config: i, children: e }) {
|
|
|
741
741
|
}
|
|
742
742
|
} catch (T) {
|
|
743
743
|
const h = T instanceof Error ? T : new Error("Failed to load tenant information");
|
|
744
|
-
|
|
744
|
+
E(h), k(null);
|
|
745
745
|
} finally {
|
|
746
746
|
f(!1);
|
|
747
747
|
}
|
|
@@ -752,8 +752,8 @@ function zt({ config: i, children: e }) {
|
|
|
752
752
|
try {
|
|
753
753
|
const c = localStorage.getItem(w.storageKey);
|
|
754
754
|
if (!c) return;
|
|
755
|
-
const
|
|
756
|
-
if (Date.now() -
|
|
755
|
+
const R = JSON.parse(c);
|
|
756
|
+
if (Date.now() - R.timestamp > w.ttl * 0.5) {
|
|
757
757
|
const h = new re(t), y = await new de(h, s).getPublicTenantInfo(a);
|
|
758
758
|
k(y);
|
|
759
759
|
const G = {
|
|
@@ -771,10 +771,10 @@ function zt({ config: i, children: e }) {
|
|
|
771
771
|
try {
|
|
772
772
|
u(!0), z(null);
|
|
773
773
|
const c = new re(t), T = await new de(c, m.appId).getTenantSettings(m.id);
|
|
774
|
-
|
|
774
|
+
L(T);
|
|
775
775
|
} catch (c) {
|
|
776
|
-
const
|
|
777
|
-
z(
|
|
776
|
+
const R = c instanceof Error ? c : new Error("Failed to load tenant settings");
|
|
777
|
+
z(R), L(null);
|
|
778
778
|
} finally {
|
|
779
779
|
u(!1);
|
|
780
780
|
}
|
|
@@ -782,31 +782,31 @@ function zt({ config: i, children: e }) {
|
|
|
782
782
|
v();
|
|
783
783
|
}, [v]), x = se(
|
|
784
784
|
(c) => {
|
|
785
|
-
if (!
|
|
785
|
+
if (!N)
|
|
786
786
|
return { isValid: !0, errors: [] };
|
|
787
|
-
const
|
|
787
|
+
const R = [];
|
|
788
788
|
try {
|
|
789
|
-
return
|
|
789
|
+
return N.properties && Object.entries(N.properties).forEach(([T, h]) => {
|
|
790
790
|
var y;
|
|
791
791
|
const d = c[T];
|
|
792
|
-
if ((y =
|
|
793
|
-
|
|
792
|
+
if ((y = N.required) != null && y.includes(T) && d == null) {
|
|
793
|
+
R.push(`Field '${T}' is required`);
|
|
794
794
|
return;
|
|
795
795
|
}
|
|
796
796
|
if (d != null) {
|
|
797
797
|
if (h.type) {
|
|
798
|
-
const G = h.type,
|
|
799
|
-
G === "string" &&
|
|
798
|
+
const G = h.type, D = typeof d;
|
|
799
|
+
G === "string" && D !== "string" ? R.push(`Field '${T}' must be a string`) : (G === "number" || G === "integer") && D !== "number" ? R.push(`Field '${T}' must be a number`) : G === "boolean" && D !== "boolean" ? R.push(`Field '${T}' must be a boolean`) : G === "array" && !Array.isArray(d) && R.push(`Field '${T}' must be an array`);
|
|
800
800
|
}
|
|
801
|
-
h.minLength !== void 0 && typeof d == "string" && d.length < h.minLength &&
|
|
801
|
+
h.minLength !== void 0 && typeof d == "string" && d.length < h.minLength && R.push(
|
|
802
802
|
`Field '${T}' must be at least ${h.minLength} characters long`
|
|
803
|
-
), h.maxLength !== void 0 && typeof d == "string" && d.length > h.maxLength &&
|
|
803
|
+
), h.maxLength !== void 0 && typeof d == "string" && d.length > h.maxLength && R.push(
|
|
804
804
|
`Field '${T}' must be no more than ${h.maxLength} characters long`
|
|
805
|
-
), h.minimum !== void 0 && typeof d == "number" && d < h.minimum &&
|
|
805
|
+
), h.minimum !== void 0 && typeof d == "number" && d < h.minimum && R.push(`Field '${T}' must be at least ${h.minimum}`), h.maximum !== void 0 && typeof d == "number" && d > h.maximum && R.push(`Field '${T}' must be no more than ${h.maximum}`), h.pattern && typeof d == "string" && (new RegExp(h.pattern).test(d) || R.push(`Field '${T}' does not match the required pattern`)), h.enum && !h.enum.includes(d) && R.push(`Field '${T}' must be one of: ${h.enum.join(", ")}`);
|
|
806
806
|
}
|
|
807
807
|
}), {
|
|
808
|
-
isValid:
|
|
809
|
-
errors:
|
|
808
|
+
isValid: R.length === 0,
|
|
809
|
+
errors: R
|
|
810
810
|
};
|
|
811
811
|
} catch {
|
|
812
812
|
return {
|
|
@@ -815,40 +815,40 @@ function zt({ config: i, children: e }) {
|
|
|
815
815
|
};
|
|
816
816
|
}
|
|
817
817
|
},
|
|
818
|
-
[
|
|
818
|
+
[N]
|
|
819
819
|
);
|
|
820
820
|
te(() => {
|
|
821
|
-
!i.initialTenant && a ? m ? O() : p(a) : !i.initialTenant && !a && (k(null),
|
|
821
|
+
!i.initialTenant && a ? m ? O() : p(a) : !i.initialTenant && !a && (k(null), E(null), f(!1));
|
|
822
822
|
}, [i.initialTenant, a, m, p, O]), te(() => {
|
|
823
|
-
m != null && m.id ? v() : (
|
|
823
|
+
m != null && m.id ? v() : (L(null), z(null), u(!1));
|
|
824
824
|
}, [m == null ? void 0 : m.id, v]);
|
|
825
|
-
const
|
|
826
|
-
(c,
|
|
827
|
-
const { mode: T = "reload", tokens: h, redirectPath: d } =
|
|
825
|
+
const I = se(
|
|
826
|
+
(c, R) => {
|
|
827
|
+
const { mode: T = "reload", tokens: h, redirectPath: d } = R || {}, y = i.tenantMode || "selector";
|
|
828
828
|
if (localStorage.setItem("tenant", c), y === "subdomain") {
|
|
829
|
-
const G = window.location.hostname,
|
|
829
|
+
const G = window.location.hostname, D = Ze(
|
|
830
830
|
c,
|
|
831
831
|
G,
|
|
832
832
|
i.baseDomain
|
|
833
833
|
);
|
|
834
|
-
if (
|
|
834
|
+
if (!D) {
|
|
835
835
|
console.warn(
|
|
836
836
|
"[TenantProvider] Cannot switch subdomain, invalid hostname:",
|
|
837
837
|
G
|
|
838
838
|
);
|
|
839
839
|
return;
|
|
840
840
|
}
|
|
841
|
-
const H = d || window.location.pathname, U = new URL(`${window.location.protocol}//${
|
|
841
|
+
const H = d || window.location.pathname, U = new URL(`${window.location.protocol}//${D}${H}`);
|
|
842
842
|
new URLSearchParams(window.location.search).forEach((B, J) => {
|
|
843
843
|
J !== fe && U.searchParams.set(J, B);
|
|
844
844
|
}), h && U.searchParams.set(fe, et(h)), window.location.href = U.toString();
|
|
845
845
|
} else if (y === "selector") {
|
|
846
|
-
const G = d || window.location.pathname,
|
|
847
|
-
if (
|
|
848
|
-
const H = `${G}?${
|
|
846
|
+
const G = d || window.location.pathname, D = new URLSearchParams(window.location.search);
|
|
847
|
+
if (D.set(i.selectorParam || "tenant", c), T === "reload") {
|
|
848
|
+
const H = `${G}?${D.toString()}${window.location.hash}`;
|
|
849
849
|
window.location.href = H;
|
|
850
850
|
} else {
|
|
851
|
-
const H = `${G}?${
|
|
851
|
+
const H = `${G}?${D.toString()}${window.location.hash}`;
|
|
852
852
|
window.history.pushState({}, "", H), g(c), p(c);
|
|
853
853
|
}
|
|
854
854
|
}
|
|
@@ -864,13 +864,13 @@ function zt({ config: i, children: e }) {
|
|
|
864
864
|
a && p(a);
|
|
865
865
|
},
|
|
866
866
|
// Settings
|
|
867
|
-
settings:
|
|
868
|
-
settingsSchema:
|
|
867
|
+
settings: $,
|
|
868
|
+
settingsSchema: N,
|
|
869
869
|
isSettingsLoading: P,
|
|
870
|
-
settingsError:
|
|
870
|
+
settingsError: M,
|
|
871
871
|
// Actions
|
|
872
872
|
refreshSettings: C,
|
|
873
|
-
switchTenant:
|
|
873
|
+
switchTenant: I,
|
|
874
874
|
// Validation
|
|
875
875
|
validateSettings: x
|
|
876
876
|
}), [
|
|
@@ -878,12 +878,12 @@ function zt({ config: i, children: e }) {
|
|
|
878
878
|
a,
|
|
879
879
|
b,
|
|
880
880
|
A,
|
|
881
|
-
|
|
882
|
-
E,
|
|
883
|
-
P,
|
|
881
|
+
$,
|
|
884
882
|
N,
|
|
885
|
-
|
|
883
|
+
P,
|
|
886
884
|
M,
|
|
885
|
+
C,
|
|
886
|
+
I,
|
|
887
887
|
x
|
|
888
888
|
]);
|
|
889
889
|
return /* @__PURE__ */ n(ke.Provider, { value: F, children: e });
|
|
@@ -920,24 +920,29 @@ function le() {
|
|
|
920
920
|
}
|
|
921
921
|
const xe = ue(null);
|
|
922
922
|
function jt({ config: i = {}, children: e }) {
|
|
923
|
-
const { appId: t, baseUrl: r } = he(), { tenant: s, tenantSlug: o, switchTenant: a } = me(), [g, w] = S(i.initialRoles || []), [m, k] = S(!i.initialRoles), [b, f] = S(null), [A,
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
923
|
+
const { appId: t, baseUrl: r } = he(), { tenant: s, tenantSlug: o, switchTenant: a } = me(), [g, w] = S(i.initialRoles || []), [m, k] = S(!i.initialRoles), [b, f] = S(null), [A, E] = S(!1), [$, L] = S(null), [P, u] = S(0), M = Ge({ done: !1, urlTokens: null });
|
|
924
|
+
M.current.done || (M.current.done = !0, M.current.urlTokens = rt(), M.current.urlTokens && console.log(
|
|
925
|
+
"[AuthProvider] SYNC: URL tokens found, will block isAuthReady until user loaded"
|
|
926
|
+
));
|
|
927
|
+
const [z, N] = S(() => {
|
|
928
|
+
const D = M.current.urlTokens !== null;
|
|
929
|
+
return console.log("[AuthProvider] SYNC: isLoadingAfterUrlTokens initial:", D), D;
|
|
930
|
+
}), p = X(() => {
|
|
931
|
+
const D = new be({
|
|
927
932
|
tenantSlug: o,
|
|
928
933
|
onRefreshFailed: i.onRefreshFailed,
|
|
929
934
|
baseUrl: r
|
|
930
935
|
});
|
|
931
|
-
return
|
|
932
|
-
accessToken:
|
|
933
|
-
refreshToken:
|
|
934
|
-
expiresIn:
|
|
935
|
-
}), console.log("[AuthProvider] SYNC: Session valid:",
|
|
936
|
-
}, [o, r, i.onRefreshFailed]), O =
|
|
937
|
-
const
|
|
938
|
-
return
|
|
939
|
-
}, [r, p]), C = X(() => new Ke(new re(r)), [r]), x = X(() => new Je(v, p), [v, p]),
|
|
940
|
-
const
|
|
936
|
+
return M.current.urlTokens && (console.log("[AuthProvider] SYNC: Saving URL tokens to session manager"), D.setTokens({
|
|
937
|
+
accessToken: M.current.urlTokens.accessToken,
|
|
938
|
+
refreshToken: M.current.urlTokens.refreshToken,
|
|
939
|
+
expiresIn: M.current.urlTokens.expiresIn
|
|
940
|
+
}), console.log("[AuthProvider] SYNC: Session valid:", D.hasValidSession())), D;
|
|
941
|
+
}, [o, r, i.onRefreshFailed]), O = M.current.done && !z, v = X(() => {
|
|
942
|
+
const D = new re(r);
|
|
943
|
+
return D.setSessionManager(p), D;
|
|
944
|
+
}, [r, p]), C = X(() => new Ke(new re(r)), [r]), x = X(() => new Je(v, p), [v, p]), I = X(() => new Me(new re(r)), [r]), F = X(() => b || p.getUser(), [b, p]), c = X(() => F != null && F.roleId && g.find((D) => D.id === F.roleId) || null, [F, g]), R = X(() => (c == null ? void 0 : c.permissions) || [], [c]), T = X(() => p.hasValidSession() && b !== null, [p, b]), h = 5 * 60 * 1e3, d = X(() => {
|
|
945
|
+
const D = async (q = !1) => {
|
|
941
946
|
try {
|
|
942
947
|
if (!p.hasValidSession())
|
|
943
948
|
return;
|
|
@@ -949,17 +954,17 @@ function jt({ config: i = {}, children: e }) {
|
|
|
949
954
|
console.warn("[AuthProvider] No userId available in token or storage");
|
|
950
955
|
return;
|
|
951
956
|
}
|
|
952
|
-
|
|
957
|
+
E(!0), L(null);
|
|
953
958
|
const Z = await x.getUserById(_);
|
|
954
959
|
f(Z), p.setUser(Z), u(Date.now());
|
|
955
960
|
} catch (W) {
|
|
956
961
|
const Y = W instanceof Error ? W : new Error("Failed to load user data");
|
|
957
|
-
|
|
962
|
+
L(Y), console.error("[AuthProvider] Failed to load user data:", Y);
|
|
958
963
|
} finally {
|
|
959
|
-
|
|
964
|
+
E(!1);
|
|
960
965
|
}
|
|
961
966
|
}, H = async () => {
|
|
962
|
-
await
|
|
967
|
+
await D();
|
|
963
968
|
}, U = async (q) => {
|
|
964
969
|
const { username: W, password: Y, tenantSlug: _ } = q;
|
|
965
970
|
let Z = s == null ? void 0 : s.id, Q = o, ee = p;
|
|
@@ -980,7 +985,7 @@ function jt({ config: i = {}, children: e }) {
|
|
|
980
985
|
}), K.user) {
|
|
981
986
|
ee.setUser(K.user), f(K.user);
|
|
982
987
|
try {
|
|
983
|
-
await
|
|
988
|
+
await D();
|
|
984
989
|
} catch (ce) {
|
|
985
990
|
console.warn("Failed to load complete user data after login:", ce);
|
|
986
991
|
}
|
|
@@ -1066,7 +1071,7 @@ function jt({ config: i = {}, children: e }) {
|
|
|
1066
1071
|
}), K.user) {
|
|
1067
1072
|
ee.setUser(K.user), f(K.user);
|
|
1068
1073
|
try {
|
|
1069
|
-
await
|
|
1074
|
+
await D();
|
|
1070
1075
|
} catch (ce) {
|
|
1071
1076
|
console.warn("Failed to load complete user data after magic link login:", ce);
|
|
1072
1077
|
}
|
|
@@ -1091,16 +1096,16 @@ function jt({ config: i = {}, children: e }) {
|
|
|
1091
1096
|
expiresIn: W.expiresIn
|
|
1092
1097
|
});
|
|
1093
1098
|
}, qe = () => {
|
|
1094
|
-
p.clearSession(), f(null),
|
|
1099
|
+
p.clearSession(), f(null), L(null);
|
|
1095
1100
|
}, ze = (q) => {
|
|
1096
1101
|
p.setTokens(q);
|
|
1097
1102
|
}, Oe = () => p.hasValidSession(), We = () => {
|
|
1098
|
-
p.clearSession(), f(null),
|
|
1103
|
+
p.clearSession(), f(null), L(null);
|
|
1099
1104
|
}, je = async () => {
|
|
1100
1105
|
if (t)
|
|
1101
1106
|
try {
|
|
1102
1107
|
k(!0);
|
|
1103
|
-
const { roles: q } = await
|
|
1108
|
+
const { roles: q } = await I.getRolesByApp(t);
|
|
1104
1109
|
w(q);
|
|
1105
1110
|
} catch (q) {
|
|
1106
1111
|
console.error("Failed to fetch roles:", q);
|
|
@@ -1110,12 +1115,12 @@ function jt({ config: i = {}, children: e }) {
|
|
|
1110
1115
|
}, Ve = async () => {
|
|
1111
1116
|
await je();
|
|
1112
1117
|
}, we = (q) => {
|
|
1113
|
-
if (!
|
|
1118
|
+
if (!R || R.length === 0)
|
|
1114
1119
|
return !1;
|
|
1115
1120
|
if (typeof q == "string")
|
|
1116
|
-
return
|
|
1121
|
+
return R.includes(q);
|
|
1117
1122
|
const W = `${q.resource}.${q.action}`;
|
|
1118
|
-
return
|
|
1123
|
+
return R.includes(W);
|
|
1119
1124
|
};
|
|
1120
1125
|
return {
|
|
1121
1126
|
// RFC-003: Authentication state
|
|
@@ -1137,19 +1142,19 @@ function jt({ config: i = {}, children: e }) {
|
|
|
1137
1142
|
clearSession: We,
|
|
1138
1143
|
currentUser: b,
|
|
1139
1144
|
isUserLoading: A,
|
|
1140
|
-
userError:
|
|
1141
|
-
loadUserData:
|
|
1145
|
+
userError: $,
|
|
1146
|
+
loadUserData: D,
|
|
1142
1147
|
refreshUser: H,
|
|
1143
1148
|
isAuthInitializing: !O,
|
|
1144
1149
|
isAuthReady: O,
|
|
1145
1150
|
userRole: c,
|
|
1146
|
-
userPermissions:
|
|
1151
|
+
userPermissions: R,
|
|
1147
1152
|
availableRoles: g,
|
|
1148
1153
|
rolesLoading: m,
|
|
1149
1154
|
hasPermission: we,
|
|
1150
1155
|
hasAnyPermission: (q) => q.some((W) => we(W)),
|
|
1151
1156
|
hasAllPermissions: (q) => q.every((W) => we(W)),
|
|
1152
|
-
getUserPermissionStrings: () =>
|
|
1157
|
+
getUserPermissionStrings: () => R || [],
|
|
1153
1158
|
refreshRoles: Ve
|
|
1154
1159
|
};
|
|
1155
1160
|
}, [
|
|
@@ -1158,7 +1163,7 @@ function jt({ config: i = {}, children: e }) {
|
|
|
1158
1163
|
v,
|
|
1159
1164
|
C,
|
|
1160
1165
|
x,
|
|
1161
|
-
|
|
1166
|
+
I,
|
|
1162
1167
|
t,
|
|
1163
1168
|
s,
|
|
1164
1169
|
o,
|
|
@@ -1166,10 +1171,10 @@ function jt({ config: i = {}, children: e }) {
|
|
|
1166
1171
|
g,
|
|
1167
1172
|
b,
|
|
1168
1173
|
A,
|
|
1169
|
-
|
|
1174
|
+
$,
|
|
1170
1175
|
O,
|
|
1171
1176
|
c,
|
|
1172
|
-
|
|
1177
|
+
R,
|
|
1173
1178
|
P,
|
|
1174
1179
|
h
|
|
1175
1180
|
]);
|
|
@@ -1188,25 +1193,25 @@ function jt({ config: i = {}, children: e }) {
|
|
|
1188
1193
|
}, [t, r, i.initialRoles]);
|
|
1189
1194
|
const [y, G] = S(!1);
|
|
1190
1195
|
return te(() => {
|
|
1191
|
-
y || (G(!0),
|
|
1192
|
-
console.error("[AuthProvider] Failed to load user data:",
|
|
1196
|
+
y || (G(!0), M.current.urlTokens && (console.log("[AuthProvider] EFFECT: Cleaning up URL after sync token processing"), nt(), N(!0), console.log("[AuthProvider] EFFECT: Loading user data (blocking isAuthReady)..."), d.loadUserData().catch((D) => {
|
|
1197
|
+
console.error("[AuthProvider] Failed to load user data:", D);
|
|
1193
1198
|
}).finally(() => {
|
|
1194
|
-
console.log("[AuthProvider] EFFECT: User data loaded, releasing isAuthReady"),
|
|
1199
|
+
console.log("[AuthProvider] EFFECT: User data loaded, releasing isAuthReady"), N(!1);
|
|
1195
1200
|
})));
|
|
1196
1201
|
}, [d, y]), te(() => {
|
|
1197
|
-
const
|
|
1198
|
-
|
|
1202
|
+
const D = p.getUser();
|
|
1203
|
+
D && p.hasValidSession() && f(D);
|
|
1199
1204
|
}, [p]), te(() => {
|
|
1200
|
-
y && (
|
|
1205
|
+
y && (M.current.urlTokens || !b && !A && p.hasValidSession() && (console.log("[AuthProvider] Auto-loading user data..."), d.loadUserData().catch(() => {
|
|
1201
1206
|
})));
|
|
1202
1207
|
}, [b, A, d, p, y]), te(() => {
|
|
1203
1208
|
if (!p.hasValidSession() || !b)
|
|
1204
1209
|
return;
|
|
1205
|
-
const
|
|
1210
|
+
const D = setInterval(() => {
|
|
1206
1211
|
d.loadUserData().catch(() => {
|
|
1207
1212
|
});
|
|
1208
1213
|
}, h);
|
|
1209
|
-
return () => clearInterval(
|
|
1214
|
+
return () => clearInterval(D);
|
|
1210
1215
|
}, [p, b, d, h]), /* @__PURE__ */ n(xe.Provider, { value: d, children: e });
|
|
1211
1216
|
}
|
|
1212
1217
|
function oe() {
|
|
@@ -1300,40 +1305,40 @@ class st {
|
|
|
1300
1305
|
}
|
|
1301
1306
|
const Ae = ue(null);
|
|
1302
1307
|
function Vt({ config: i = {}, children: e }) {
|
|
1303
|
-
const t = Ee(), r = ye(), s = (t == null ? void 0 : t.baseUrl) ?? "", o = (t == null ? void 0 : t.appId) ?? "", a = (r == null ? void 0 : r.tenant) ?? null, [g, w] = S([]), [m, k] = S(!1), [b, f] = S(null), [A,
|
|
1308
|
+
const t = Ee(), r = ye(), s = (t == null ? void 0 : t.baseUrl) ?? "", o = (t == null ? void 0 : t.appId) ?? "", a = (r == null ? void 0 : r.tenant) ?? null, [g, w] = S([]), [m, k] = S(!1), [b, f] = S(null), [A, E] = S(!1), $ = X(() => {
|
|
1304
1309
|
const u = new re(s);
|
|
1305
1310
|
return new st(u);
|
|
1306
|
-
}, [s]),
|
|
1311
|
+
}, [s]), L = async () => {
|
|
1307
1312
|
if (!(a != null && a.id)) {
|
|
1308
1313
|
w([]);
|
|
1309
1314
|
return;
|
|
1310
1315
|
}
|
|
1311
1316
|
k(!0), f(null);
|
|
1312
1317
|
try {
|
|
1313
|
-
const u = await
|
|
1318
|
+
const u = await $.getTenantFeatureFlags(a.id, o);
|
|
1314
1319
|
w(u);
|
|
1315
1320
|
} catch (u) {
|
|
1316
|
-
const
|
|
1317
|
-
f(
|
|
1321
|
+
const M = u instanceof Error ? u.message : "Failed to fetch feature flags";
|
|
1322
|
+
f(M), i.onError && i.onError(u instanceof Error ? u : new Error(M));
|
|
1318
1323
|
} finally {
|
|
1319
1324
|
k(!1);
|
|
1320
1325
|
}
|
|
1321
1326
|
};
|
|
1322
1327
|
te(() => {
|
|
1323
1328
|
if (!s || !o) return;
|
|
1324
|
-
|
|
1325
|
-
const u = i.refreshInterval || 5 * 60 * 1e3,
|
|
1326
|
-
return () => clearInterval(
|
|
1329
|
+
L().finally(() => E(!0));
|
|
1330
|
+
const u = i.refreshInterval || 5 * 60 * 1e3, M = setInterval(L, u);
|
|
1331
|
+
return () => clearInterval(M);
|
|
1327
1332
|
}, [a == null ? void 0 : a.id, s, o, i.refreshInterval]);
|
|
1328
1333
|
const P = X(() => {
|
|
1329
1334
|
const u = (O) => {
|
|
1330
1335
|
const v = g.find((C) => C.key === O);
|
|
1331
1336
|
return (v == null ? void 0 : v.value) === !0;
|
|
1332
|
-
},
|
|
1337
|
+
}, M = (O) => g.find((v) => v.key === O), z = (O) => {
|
|
1333
1338
|
const v = g.find((C) => C.key === O);
|
|
1334
1339
|
return v ? v.value ? "enabled" : "disabled" : "not_found";
|
|
1335
|
-
},
|
|
1336
|
-
await
|
|
1340
|
+
}, N = async () => {
|
|
1341
|
+
await L();
|
|
1337
1342
|
}, p = !!(s && o) && (A || !(a != null && a.id));
|
|
1338
1343
|
return {
|
|
1339
1344
|
featureFlags: g,
|
|
@@ -1341,9 +1346,9 @@ function Vt({ config: i = {}, children: e }) {
|
|
|
1341
1346
|
error: b,
|
|
1342
1347
|
isReady: p,
|
|
1343
1348
|
isEnabled: u,
|
|
1344
|
-
getFlag:
|
|
1349
|
+
getFlag: M,
|
|
1345
1350
|
getFlagState: z,
|
|
1346
|
-
refresh:
|
|
1351
|
+
refresh: N
|
|
1347
1352
|
};
|
|
1348
1353
|
}, [g, m, b, s, o, a == null ? void 0 : a.id, A]);
|
|
1349
1354
|
return /* @__PURE__ */ n(Ae.Provider, { value: P, children: e });
|
|
@@ -1425,17 +1430,17 @@ class ot {
|
|
|
1425
1430
|
}
|
|
1426
1431
|
const Te = ue(void 0);
|
|
1427
1432
|
function _t({ config: i = {}, children: e }) {
|
|
1428
|
-
const t = Ee(), r = ye(), s = (t == null ? void 0 : t.baseUrl) ?? "", o = (r == null ? void 0 : r.tenant) ?? null, [a, g] = S(null), [w, m] = S(!1), [k, b] = S(null), [f, A] = S(!1),
|
|
1433
|
+
const t = Ee(), r = ye(), s = (t == null ? void 0 : t.baseUrl) ?? "", o = (r == null ? void 0 : r.tenant) ?? null, [a, g] = S(null), [w, m] = S(!1), [k, b] = S(null), [f, A] = S(!1), E = X(() => {
|
|
1429
1434
|
const P = new re(s);
|
|
1430
1435
|
return new ot(P);
|
|
1431
|
-
}, [s]),
|
|
1436
|
+
}, [s]), $ = async () => {
|
|
1432
1437
|
if (!(o != null && o.id)) {
|
|
1433
1438
|
g(null);
|
|
1434
1439
|
return;
|
|
1435
1440
|
}
|
|
1436
1441
|
m(!0), b(null);
|
|
1437
1442
|
try {
|
|
1438
|
-
const P = await
|
|
1443
|
+
const P = await E.getTenantSubscriptionFeatures(o.id);
|
|
1439
1444
|
g(P);
|
|
1440
1445
|
} catch (P) {
|
|
1441
1446
|
const u = P instanceof Error ? P.message : "Failed to fetch subscription";
|
|
@@ -1445,19 +1450,19 @@ function _t({ config: i = {}, children: e }) {
|
|
|
1445
1450
|
}
|
|
1446
1451
|
};
|
|
1447
1452
|
te(() => {
|
|
1448
|
-
if (!s || (
|
|
1449
|
-
const P = i.refreshInterval || 10 * 60 * 1e3, u = setInterval(
|
|
1453
|
+
if (!s || ($().finally(() => A(!0)), !i.refreshInterval)) return;
|
|
1454
|
+
const P = i.refreshInterval || 10 * 60 * 1e3, u = setInterval($, P);
|
|
1450
1455
|
return () => clearInterval(u);
|
|
1451
1456
|
}, [o == null ? void 0 : o.id, s, i.refreshInterval]);
|
|
1452
|
-
const
|
|
1457
|
+
const L = X(() => {
|
|
1453
1458
|
const P = (a == null ? void 0 : a.features) || [], u = (v) => {
|
|
1454
1459
|
const C = P.find((x) => x.key === v);
|
|
1455
1460
|
return C ? C.type === "BOOLEAN" || C.type === "boolean" ? C.value === !0 : !!C.value : !1;
|
|
1456
|
-
},
|
|
1457
|
-
const x = P.find((
|
|
1461
|
+
}, M = (v) => P.find((C) => C.key === v), z = (v, C) => {
|
|
1462
|
+
const x = P.find((I) => I.key === v);
|
|
1458
1463
|
return x ? x.value : C;
|
|
1459
|
-
},
|
|
1460
|
-
await
|
|
1464
|
+
}, N = (v) => !a || !a.isActive ? !1 : v.includes(a.planId), p = async () => {
|
|
1465
|
+
await $();
|
|
1461
1466
|
}, O = !!s && (f || !(o != null && o.id));
|
|
1462
1467
|
return {
|
|
1463
1468
|
subscription: a,
|
|
@@ -1466,13 +1471,13 @@ function _t({ config: i = {}, children: e }) {
|
|
|
1466
1471
|
error: k,
|
|
1467
1472
|
isReady: O,
|
|
1468
1473
|
isFeatureEnabled: u,
|
|
1469
|
-
getFeature:
|
|
1474
|
+
getFeature: M,
|
|
1470
1475
|
getFeatureValue: z,
|
|
1471
|
-
hasAllowedPlan:
|
|
1476
|
+
hasAllowedPlan: N,
|
|
1472
1477
|
refresh: p
|
|
1473
1478
|
};
|
|
1474
1479
|
}, [a, w, k, s, o == null ? void 0 : o.id, f]);
|
|
1475
|
-
return /* @__PURE__ */ n(Te.Provider, { value:
|
|
1480
|
+
return /* @__PURE__ */ n(Te.Provider, { value: L, children: e });
|
|
1476
1481
|
}
|
|
1477
1482
|
function at() {
|
|
1478
1483
|
const i = ne(Te);
|
|
@@ -1706,8 +1711,8 @@ function Kt({
|
|
|
1706
1711
|
if (t && !dt(f.userType, t))
|
|
1707
1712
|
return /* @__PURE__ */ n(Le, { userType: f.userType, minUserType: t });
|
|
1708
1713
|
if (r && r.length > 0 && !(s ? k(r) : m(r))) {
|
|
1709
|
-
const
|
|
1710
|
-
return /* @__PURE__ */ n(Le, { missingPermissions:
|
|
1714
|
+
const E = r.filter(($) => !w($)).map(($) => typeof $ == "string" ? $ : $.name);
|
|
1715
|
+
return /* @__PURE__ */ n(Le, { missingPermissions: E });
|
|
1711
1716
|
}
|
|
1712
1717
|
return /* @__PURE__ */ n(j, { children: i });
|
|
1713
1718
|
}
|
|
@@ -2051,43 +2056,43 @@ function Zt({
|
|
|
2051
2056
|
showMagicLinkOption: k = !0,
|
|
2052
2057
|
className: b
|
|
2053
2058
|
}) {
|
|
2054
|
-
const [f, A] = S(""), [
|
|
2059
|
+
const [f, A] = S(""), [E, $] = S(""), [L, P] = S(!1), [u, M] = S(!1), [z, N] = S(""), [p, O] = S({}), { login: v } = oe(), { tenant: C } = le(), x = { ...wt, ...i }, I = { ...bt, ...e }, F = { ...yt, ...t }, c = () => {
|
|
2055
2060
|
const d = {};
|
|
2056
|
-
return f.trim() || (d.username = !0),
|
|
2057
|
-
},
|
|
2061
|
+
return f.trim() || (d.username = !0), E.trim() || (d.password = !0), O(d), Object.keys(d).length === 0;
|
|
2062
|
+
}, R = async (d) => {
|
|
2058
2063
|
if (d.preventDefault(), !!c()) {
|
|
2059
2064
|
if (!(C != null && C.id)) {
|
|
2060
|
-
|
|
2065
|
+
N("Tenant not found");
|
|
2061
2066
|
return;
|
|
2062
2067
|
}
|
|
2063
|
-
|
|
2068
|
+
M(!0), N("");
|
|
2064
2069
|
try {
|
|
2065
2070
|
const y = await v({
|
|
2066
2071
|
username: f,
|
|
2067
|
-
password:
|
|
2072
|
+
password: E
|
|
2068
2073
|
// tenantId inferred from context automatically
|
|
2069
2074
|
});
|
|
2070
2075
|
r == null || r(y);
|
|
2071
2076
|
} catch (y) {
|
|
2072
2077
|
const G = y.message || x.errorMessage;
|
|
2073
|
-
|
|
2078
|
+
N(G), s == null || s(G);
|
|
2074
2079
|
} finally {
|
|
2075
|
-
|
|
2080
|
+
M(!1);
|
|
2076
2081
|
}
|
|
2077
2082
|
}
|
|
2078
2083
|
}, T = (d) => ({
|
|
2079
|
-
...
|
|
2080
|
-
...p[d] ?
|
|
2084
|
+
...I.input,
|
|
2085
|
+
...p[d] ? I.inputError : {}
|
|
2081
2086
|
}), h = () => ({
|
|
2082
|
-
...
|
|
2083
|
-
...u ?
|
|
2084
|
-
...!f || !
|
|
2087
|
+
...I.button,
|
|
2088
|
+
...u ? I.buttonLoading : {},
|
|
2089
|
+
...!f || !E || u ? I.buttonDisabled : {}
|
|
2085
2090
|
});
|
|
2086
|
-
return /* @__PURE__ */ l("div", { className: b, style:
|
|
2087
|
-
/* @__PURE__ */ n("h2", { style:
|
|
2088
|
-
/* @__PURE__ */ l("form", { onSubmit:
|
|
2089
|
-
/* @__PURE__ */ l("div", { style:
|
|
2090
|
-
/* @__PURE__ */ n("label", { style:
|
|
2091
|
+
return /* @__PURE__ */ l("div", { className: b, style: I.container, children: [
|
|
2092
|
+
/* @__PURE__ */ n("h2", { style: I.title, children: x.title }),
|
|
2093
|
+
/* @__PURE__ */ l("form", { onSubmit: R, style: I.form, children: [
|
|
2094
|
+
/* @__PURE__ */ l("div", { style: I.fieldGroup, children: [
|
|
2095
|
+
/* @__PURE__ */ n("label", { style: I.label, children: x.usernameLabel }),
|
|
2091
2096
|
/* @__PURE__ */ n(
|
|
2092
2097
|
"input",
|
|
2093
2098
|
{
|
|
@@ -2104,18 +2109,18 @@ function Zt({
|
|
|
2104
2109
|
}
|
|
2105
2110
|
)
|
|
2106
2111
|
] }),
|
|
2107
|
-
/* @__PURE__ */ l("div", { style:
|
|
2108
|
-
/* @__PURE__ */ n("label", { style:
|
|
2109
|
-
/* @__PURE__ */ l("div", { style:
|
|
2112
|
+
/* @__PURE__ */ l("div", { style: I.fieldGroup, children: [
|
|
2113
|
+
/* @__PURE__ */ n("label", { style: I.label, children: x.passwordLabel }),
|
|
2114
|
+
/* @__PURE__ */ l("div", { style: I.inputContainer, children: [
|
|
2110
2115
|
/* @__PURE__ */ n(
|
|
2111
2116
|
"input",
|
|
2112
2117
|
{
|
|
2113
2118
|
id: "password",
|
|
2114
2119
|
name: "password",
|
|
2115
|
-
type:
|
|
2116
|
-
value:
|
|
2120
|
+
type: L ? "text" : "password",
|
|
2121
|
+
value: E,
|
|
2117
2122
|
onChange: (d) => {
|
|
2118
|
-
|
|
2123
|
+
$(d.target.value), p.password && O((y) => ({ ...y, password: !1 }));
|
|
2119
2124
|
},
|
|
2120
2125
|
placeholder: x.passwordPlaceholder,
|
|
2121
2126
|
style: {
|
|
@@ -2130,35 +2135,35 @@ function Zt({
|
|
|
2130
2135
|
"button",
|
|
2131
2136
|
{
|
|
2132
2137
|
type: "button",
|
|
2133
|
-
onClick: () => P(!
|
|
2134
|
-
style:
|
|
2138
|
+
onClick: () => P(!L),
|
|
2139
|
+
style: I.passwordToggle,
|
|
2135
2140
|
disabled: u,
|
|
2136
|
-
"aria-label":
|
|
2137
|
-
children:
|
|
2141
|
+
"aria-label": L ? "Hide password" : "Show password",
|
|
2142
|
+
children: L ? F.hidePassword : F.showPassword
|
|
2138
2143
|
}
|
|
2139
2144
|
)
|
|
2140
2145
|
] })
|
|
2141
2146
|
] }),
|
|
2142
|
-
/* @__PURE__ */ n("button", { type: "submit", disabled: !f || !
|
|
2143
|
-
z && /* @__PURE__ */ n("div", { style:
|
|
2147
|
+
/* @__PURE__ */ n("button", { type: "submit", disabled: !f || !E || u, style: h(), children: u ? x.loadingText : x.submitButton }),
|
|
2148
|
+
z && /* @__PURE__ */ n("div", { style: I.errorText, children: z })
|
|
2144
2149
|
] }),
|
|
2145
|
-
(w || m || k) && /* @__PURE__ */ l("div", { style:
|
|
2150
|
+
(w || m || k) && /* @__PURE__ */ l("div", { style: I.linkContainer, children: [
|
|
2146
2151
|
k && /* @__PURE__ */ l("div", { children: [
|
|
2147
|
-
/* @__PURE__ */ l("span", { style:
|
|
2152
|
+
/* @__PURE__ */ l("span", { style: I.divider, children: [
|
|
2148
2153
|
x.magicLinkText,
|
|
2149
2154
|
" "
|
|
2150
2155
|
] }),
|
|
2151
|
-
/* @__PURE__ */ n("a", { onClick: g, style:
|
|
2156
|
+
/* @__PURE__ */ n("a", { onClick: g, style: I.link, children: x.magicLinkLink })
|
|
2152
2157
|
] }),
|
|
2153
|
-
k && (w || m) && /* @__PURE__ */ n("div", { style:
|
|
2154
|
-
w && /* @__PURE__ */ n("a", { onClick: o, style:
|
|
2155
|
-
w && m && /* @__PURE__ */ n("div", { style:
|
|
2158
|
+
k && (w || m) && /* @__PURE__ */ n("div", { style: I.divider, children: "•" }),
|
|
2159
|
+
w && /* @__PURE__ */ n("a", { onClick: o, style: I.link, children: x.forgotPasswordLink }),
|
|
2160
|
+
w && m && /* @__PURE__ */ n("div", { style: I.divider, children: "•" }),
|
|
2156
2161
|
m && /* @__PURE__ */ l("div", { children: [
|
|
2157
|
-
/* @__PURE__ */ l("span", { style:
|
|
2162
|
+
/* @__PURE__ */ l("span", { style: I.divider, children: [
|
|
2158
2163
|
x.signupText,
|
|
2159
2164
|
" "
|
|
2160
2165
|
] }),
|
|
2161
|
-
/* @__PURE__ */ n("a", { onClick: a, style:
|
|
2166
|
+
/* @__PURE__ */ n("a", { onClick: a, style: I.link, children: x.signupLink })
|
|
2162
2167
|
] })
|
|
2163
2168
|
] })
|
|
2164
2169
|
] });
|
|
@@ -2300,32 +2305,32 @@ function er({
|
|
|
2300
2305
|
showMagicLinkOption: w = !0,
|
|
2301
2306
|
className: m
|
|
2302
2307
|
}) {
|
|
2303
|
-
const [k, b] = S(""), [f, A] = S(""), [
|
|
2308
|
+
const [k, b] = S(""), [f, A] = S(""), [E, $] = S(""), [L, P] = S(""), [u, M] = S(""), [z, N] = S(""), [p, O] = S(""), [v, C] = S(!1), [x, I] = S(""), [F, c] = S({}), { signup: R, signupTenantAdmin: T } = oe(), { tenant: h } = le(), d = { ...St, ...i }, y = { ...vt, ...e }, G = () => {
|
|
2304
2309
|
const B = {};
|
|
2305
|
-
return k.trim() || (B.name = !0), !
|
|
2306
|
-
},
|
|
2310
|
+
return k.trim() || (B.name = !0), !E.trim() && !L.trim() && (B.email = !0, B.phoneNumber = !0), u.trim() || (B.password = !0), z.trim() || (B.confirmPassword = !0), t === "tenant" && !p.trim() && (B.tenantName = !0), c(B), Object.keys(B).length === 0;
|
|
2311
|
+
}, D = async (B) => {
|
|
2307
2312
|
if (B.preventDefault(), !!G()) {
|
|
2308
2313
|
if (u !== z) {
|
|
2309
|
-
|
|
2314
|
+
I(d.passwordMismatchError), c({ confirmPassword: !0 });
|
|
2310
2315
|
return;
|
|
2311
2316
|
}
|
|
2312
2317
|
if (t === "user" && !(h != null && h.id)) {
|
|
2313
|
-
|
|
2318
|
+
I("Tenant not found");
|
|
2314
2319
|
return;
|
|
2315
2320
|
}
|
|
2316
|
-
C(!0),
|
|
2321
|
+
C(!0), I("");
|
|
2317
2322
|
try {
|
|
2318
2323
|
let J;
|
|
2319
2324
|
t === "tenant" ? J = await T({
|
|
2320
|
-
email:
|
|
2321
|
-
phoneNumber:
|
|
2325
|
+
email: E || void 0,
|
|
2326
|
+
phoneNumber: L || void 0,
|
|
2322
2327
|
name: k,
|
|
2323
2328
|
password: u,
|
|
2324
2329
|
tenantName: p,
|
|
2325
2330
|
lastName: f || void 0
|
|
2326
|
-
}) : J = await
|
|
2327
|
-
email:
|
|
2328
|
-
phoneNumber:
|
|
2331
|
+
}) : J = await R({
|
|
2332
|
+
email: E || void 0,
|
|
2333
|
+
phoneNumber: L || void 0,
|
|
2329
2334
|
name: k,
|
|
2330
2335
|
password: u,
|
|
2331
2336
|
tenantId: h.id,
|
|
@@ -2333,7 +2338,7 @@ function er({
|
|
|
2333
2338
|
}), r == null || r(J);
|
|
2334
2339
|
} catch (J) {
|
|
2335
2340
|
const ge = J.message || d.errorMessage;
|
|
2336
|
-
|
|
2341
|
+
I(ge), s == null || s(ge);
|
|
2337
2342
|
} finally {
|
|
2338
2343
|
C(!1);
|
|
2339
2344
|
}
|
|
@@ -2344,11 +2349,11 @@ function er({
|
|
|
2344
2349
|
}), U = () => ({
|
|
2345
2350
|
...y.button,
|
|
2346
2351
|
...v ? y.buttonLoading : {},
|
|
2347
|
-
...!k || !
|
|
2348
|
-
}), V = k && (
|
|
2352
|
+
...!k || !E && !L || !u || !z || v || t === "tenant" && !p ? y.buttonDisabled : {}
|
|
2353
|
+
}), V = k && (E || L) && u && z && (t === "user" || p);
|
|
2349
2354
|
return /* @__PURE__ */ l("div", { className: m, style: y.container, children: [
|
|
2350
2355
|
/* @__PURE__ */ n("h2", { style: y.title, children: d.title }),
|
|
2351
|
-
/* @__PURE__ */ l("form", { onSubmit:
|
|
2356
|
+
/* @__PURE__ */ l("form", { onSubmit: D, style: y.form, children: [
|
|
2352
2357
|
/* @__PURE__ */ l("div", { style: y.fieldGroup, children: [
|
|
2353
2358
|
/* @__PURE__ */ n("label", { style: y.label, children: d.nameLabel }),
|
|
2354
2359
|
/* @__PURE__ */ n(
|
|
@@ -2391,9 +2396,9 @@ function er({
|
|
|
2391
2396
|
id: "email",
|
|
2392
2397
|
name: "email",
|
|
2393
2398
|
type: "email",
|
|
2394
|
-
value:
|
|
2399
|
+
value: E,
|
|
2395
2400
|
onChange: (B) => {
|
|
2396
|
-
|
|
2401
|
+
$(B.target.value), F.email && c((J) => ({ ...J, email: !1, phoneNumber: !1 }));
|
|
2397
2402
|
},
|
|
2398
2403
|
placeholder: d.emailPlaceholder,
|
|
2399
2404
|
style: H("email"),
|
|
@@ -2409,7 +2414,7 @@ function er({
|
|
|
2409
2414
|
id: "phoneNumber",
|
|
2410
2415
|
name: "phoneNumber",
|
|
2411
2416
|
type: "tel",
|
|
2412
|
-
value:
|
|
2417
|
+
value: L,
|
|
2413
2418
|
onChange: (B) => {
|
|
2414
2419
|
P(B.target.value), F.phoneNumber && c((J) => ({ ...J, email: !1, phoneNumber: !1 }));
|
|
2415
2420
|
},
|
|
@@ -2441,7 +2446,7 @@ function er({
|
|
|
2441
2446
|
type: "password",
|
|
2442
2447
|
value: u,
|
|
2443
2448
|
onChange: (B) => {
|
|
2444
|
-
|
|
2449
|
+
M(B.target.value), F.password && c((J) => ({ ...J, password: !1 }));
|
|
2445
2450
|
},
|
|
2446
2451
|
placeholder: d.passwordPlaceholder,
|
|
2447
2452
|
style: H("password"),
|
|
@@ -2459,7 +2464,7 @@ function er({
|
|
|
2459
2464
|
type: "password",
|
|
2460
2465
|
value: z,
|
|
2461
2466
|
onChange: (B) => {
|
|
2462
|
-
|
|
2467
|
+
N(B.target.value), F.confirmPassword && c((J) => ({ ...J, confirmPassword: !1 })), x === d.passwordMismatchError && I("");
|
|
2463
2468
|
},
|
|
2464
2469
|
placeholder: d.confirmPasswordPlaceholder,
|
|
2465
2470
|
style: H("confirmPassword"),
|
|
@@ -2640,16 +2645,16 @@ function tr({
|
|
|
2640
2645
|
verifyToken: w,
|
|
2641
2646
|
frontendUrl: m
|
|
2642
2647
|
}) {
|
|
2643
|
-
const [k, b] = S(""), [f, A] = S(""), [
|
|
2648
|
+
const [k, b] = S(""), [f, A] = S(""), [E, $] = S(""), [L, P] = S(!1), [u, M] = S(!1), [z, N] = S(""), [p, O] = S(""), [v, C] = S({}), [x, I] = S(!1), { sendMagicLink: F, verifyMagicLink: c } = oe(), { tenant: R } = le(), T = { ...kt, ...i }, h = { ...xt, ...e };
|
|
2644
2649
|
te(() => {
|
|
2645
2650
|
w && d(w);
|
|
2646
2651
|
}, [w]);
|
|
2647
2652
|
const d = async (U) => {
|
|
2648
|
-
if (!
|
|
2649
|
-
|
|
2653
|
+
if (!R || !k) {
|
|
2654
|
+
N("Missing tenant or email");
|
|
2650
2655
|
return;
|
|
2651
2656
|
}
|
|
2652
|
-
|
|
2657
|
+
M(!0), N("");
|
|
2653
2658
|
try {
|
|
2654
2659
|
const V = await c({
|
|
2655
2660
|
token: U,
|
|
@@ -2659,43 +2664,43 @@ function tr({
|
|
|
2659
2664
|
t == null || t(V);
|
|
2660
2665
|
} catch (V) {
|
|
2661
2666
|
const B = V.message || "Failed to verify magic link";
|
|
2662
|
-
|
|
2667
|
+
N(B), r == null || r(B);
|
|
2663
2668
|
} finally {
|
|
2664
|
-
|
|
2669
|
+
M(!1);
|
|
2665
2670
|
}
|
|
2666
2671
|
}, y = () => {
|
|
2667
2672
|
const U = {};
|
|
2668
2673
|
return k.trim() || (U.email = !0), x && !f.trim() && (U.name = !0), C(U), Object.keys(U).length === 0;
|
|
2669
2674
|
}, G = async (U) => {
|
|
2670
2675
|
if (U.preventDefault(), !!y()) {
|
|
2671
|
-
if (!(
|
|
2672
|
-
|
|
2676
|
+
if (!(R != null && R.id)) {
|
|
2677
|
+
N("Tenant not found");
|
|
2673
2678
|
return;
|
|
2674
2679
|
}
|
|
2675
|
-
P(!0),
|
|
2680
|
+
P(!0), N(""), O("");
|
|
2676
2681
|
try {
|
|
2677
2682
|
const V = m || (typeof window < "u" ? window.location.origin : ""), B = await F({
|
|
2678
2683
|
email: k,
|
|
2679
|
-
tenantId:
|
|
2684
|
+
tenantId: R.id,
|
|
2680
2685
|
frontendUrl: V,
|
|
2681
2686
|
name: x ? f : void 0,
|
|
2682
|
-
lastName: x ?
|
|
2687
|
+
lastName: x ? E : void 0
|
|
2683
2688
|
});
|
|
2684
2689
|
O(T.successMessage), t == null || t(B);
|
|
2685
2690
|
} catch (V) {
|
|
2686
2691
|
const B = V.message || T.errorMessage;
|
|
2687
|
-
|
|
2692
|
+
N(B), r == null || r(B);
|
|
2688
2693
|
} finally {
|
|
2689
2694
|
P(!1);
|
|
2690
2695
|
}
|
|
2691
2696
|
}
|
|
2692
|
-
},
|
|
2697
|
+
}, D = (U) => ({
|
|
2693
2698
|
...h.input,
|
|
2694
2699
|
...v[U] ? h.inputError : {}
|
|
2695
2700
|
}), H = () => ({
|
|
2696
2701
|
...h.button,
|
|
2697
|
-
...
|
|
2698
|
-
...!k ||
|
|
2702
|
+
...L || u ? h.buttonLoading : {},
|
|
2703
|
+
...!k || L || u ? h.buttonDisabled : {}
|
|
2699
2704
|
});
|
|
2700
2705
|
return u ? /* @__PURE__ */ l("div", { className: g, style: h.container, children: [
|
|
2701
2706
|
/* @__PURE__ */ n("h2", { style: h.title, children: T.verifyingText }),
|
|
@@ -2717,8 +2722,8 @@ function tr({
|
|
|
2717
2722
|
b(U.target.value), v.email && C((V) => ({ ...V, email: !1 }));
|
|
2718
2723
|
},
|
|
2719
2724
|
placeholder: T.emailPlaceholder,
|
|
2720
|
-
style:
|
|
2721
|
-
disabled:
|
|
2725
|
+
style: D("email"),
|
|
2726
|
+
disabled: L || u
|
|
2722
2727
|
}
|
|
2723
2728
|
)
|
|
2724
2729
|
] }),
|
|
@@ -2726,7 +2731,7 @@ function tr({
|
|
|
2726
2731
|
"button",
|
|
2727
2732
|
{
|
|
2728
2733
|
type: "button",
|
|
2729
|
-
onClick: () =>
|
|
2734
|
+
onClick: () => I(!0),
|
|
2730
2735
|
style: {
|
|
2731
2736
|
background: "none",
|
|
2732
2737
|
border: "none",
|
|
@@ -2752,8 +2757,8 @@ function tr({
|
|
|
2752
2757
|
A(U.target.value), v.name && C((V) => ({ ...V, name: !1 }));
|
|
2753
2758
|
},
|
|
2754
2759
|
placeholder: T.namePlaceholder,
|
|
2755
|
-
style:
|
|
2756
|
-
disabled:
|
|
2760
|
+
style: D("name"),
|
|
2761
|
+
disabled: L || u
|
|
2757
2762
|
}
|
|
2758
2763
|
)
|
|
2759
2764
|
] }),
|
|
@@ -2765,11 +2770,11 @@ function tr({
|
|
|
2765
2770
|
id: "lastName",
|
|
2766
2771
|
name: "lastName",
|
|
2767
2772
|
type: "text",
|
|
2768
|
-
value:
|
|
2769
|
-
onChange: (U) =>
|
|
2773
|
+
value: E,
|
|
2774
|
+
onChange: (U) => $(U.target.value),
|
|
2770
2775
|
placeholder: T.lastNamePlaceholder,
|
|
2771
2776
|
style: h.input,
|
|
2772
|
-
disabled:
|
|
2777
|
+
disabled: L || u
|
|
2773
2778
|
}
|
|
2774
2779
|
)
|
|
2775
2780
|
] }),
|
|
@@ -2778,7 +2783,7 @@ function tr({
|
|
|
2778
2783
|
{
|
|
2779
2784
|
type: "button",
|
|
2780
2785
|
onClick: () => {
|
|
2781
|
-
|
|
2786
|
+
I(!1), A(""), $("");
|
|
2782
2787
|
},
|
|
2783
2788
|
style: {
|
|
2784
2789
|
background: "none",
|
|
@@ -2792,7 +2797,7 @@ function tr({
|
|
|
2792
2797
|
}
|
|
2793
2798
|
) })
|
|
2794
2799
|
] }),
|
|
2795
|
-
/* @__PURE__ */ n("button", { type: "submit", disabled: !k ||
|
|
2800
|
+
/* @__PURE__ */ n("button", { type: "submit", disabled: !k || L || u, style: H(), children: L ? T.loadingText : T.submitButton }),
|
|
2796
2801
|
z && /* @__PURE__ */ n("div", { style: h.errorText, children: z }),
|
|
2797
2802
|
p && /* @__PURE__ */ n("div", { style: h.successText, children: p })
|
|
2798
2803
|
] }),
|
|
@@ -2965,7 +2970,7 @@ function rr({
|
|
|
2965
2970
|
tenantSlug: b,
|
|
2966
2971
|
autoRedirectDelay: f = 3e3
|
|
2967
2972
|
}) {
|
|
2968
|
-
const [A,
|
|
2973
|
+
const [A, E] = S("verifying"), [$, L] = S(""), { verifyMagicLink: P } = oe(), u = { ...At, ...i }, M = { ...$e, ...e }, z = { ...It, ...t }, N = () => {
|
|
2969
2974
|
if (typeof window > "u") return {};
|
|
2970
2975
|
const x = new URLSearchParams(window.location.search);
|
|
2971
2976
|
return {
|
|
@@ -2975,22 +2980,22 @@ function rr({
|
|
|
2975
2980
|
tenantSlug: b || x.get("tenantSlug") || void 0
|
|
2976
2981
|
};
|
|
2977
2982
|
}, p = async () => {
|
|
2978
|
-
|
|
2983
|
+
E("verifying"), L("");
|
|
2979
2984
|
try {
|
|
2980
|
-
const x =
|
|
2985
|
+
const x = N();
|
|
2981
2986
|
if (!x.token || !x.email)
|
|
2982
2987
|
throw new Error("Missing required parameters: token or email");
|
|
2983
|
-
const
|
|
2988
|
+
const I = await P({
|
|
2984
2989
|
token: x.token,
|
|
2985
2990
|
email: x.email,
|
|
2986
2991
|
tenantSlug: x.tenantSlug
|
|
2987
2992
|
});
|
|
2988
|
-
|
|
2989
|
-
|
|
2993
|
+
E("success"), r == null || r(I), f > 0 && setTimeout(() => {
|
|
2994
|
+
E("redirecting");
|
|
2990
2995
|
}, f);
|
|
2991
2996
|
} catch (x) {
|
|
2992
|
-
const
|
|
2993
|
-
|
|
2997
|
+
const I = x.message || u.errorMessage;
|
|
2998
|
+
L(I), E("error"), s == null || s(I);
|
|
2994
2999
|
}
|
|
2995
3000
|
}, O = () => {
|
|
2996
3001
|
o == null || o(), p();
|
|
@@ -3003,30 +3008,30 @@ function rr({
|
|
|
3003
3008
|
const C = () => {
|
|
3004
3009
|
switch (A) {
|
|
3005
3010
|
case "verifying":
|
|
3006
|
-
return /* @__PURE__ */ l("div", { style:
|
|
3011
|
+
return /* @__PURE__ */ l("div", { style: M.message, children: [
|
|
3007
3012
|
z.loading,
|
|
3008
3013
|
u.verifyingMessage
|
|
3009
3014
|
] });
|
|
3010
3015
|
case "success":
|
|
3011
3016
|
return /* @__PURE__ */ l(j, { children: [
|
|
3012
3017
|
z.success,
|
|
3013
|
-
/* @__PURE__ */ n("div", { style:
|
|
3018
|
+
/* @__PURE__ */ n("div", { style: M.successMessage, children: u.successMessage })
|
|
3014
3019
|
] });
|
|
3015
3020
|
case "redirecting":
|
|
3016
3021
|
return /* @__PURE__ */ l(j, { children: [
|
|
3017
3022
|
z.loading,
|
|
3018
|
-
/* @__PURE__ */ n("div", { style:
|
|
3023
|
+
/* @__PURE__ */ n("div", { style: M.message, children: u.redirectingMessage })
|
|
3019
3024
|
] });
|
|
3020
3025
|
case "error":
|
|
3021
3026
|
return /* @__PURE__ */ l(j, { children: [
|
|
3022
3027
|
z.error,
|
|
3023
|
-
/* @__PURE__ */ n("div", { style:
|
|
3024
|
-
/* @__PURE__ */ l("div", { style:
|
|
3028
|
+
/* @__PURE__ */ n("div", { style: M.errorMessage, children: $ || u.errorMessage }),
|
|
3029
|
+
/* @__PURE__ */ l("div", { style: M.buttonContainer, children: [
|
|
3025
3030
|
/* @__PURE__ */ n(
|
|
3026
3031
|
"button",
|
|
3027
3032
|
{
|
|
3028
3033
|
onClick: O,
|
|
3029
|
-
style:
|
|
3034
|
+
style: M.retryButton,
|
|
3030
3035
|
onMouseOver: (x) => {
|
|
3031
3036
|
x.currentTarget.style.backgroundColor = "#2563eb";
|
|
3032
3037
|
},
|
|
@@ -3040,7 +3045,7 @@ function rr({
|
|
|
3040
3045
|
"button",
|
|
3041
3046
|
{
|
|
3042
3047
|
onClick: v,
|
|
3043
|
-
style:
|
|
3048
|
+
style: M.backButton,
|
|
3044
3049
|
onMouseOver: (x) => {
|
|
3045
3050
|
x.currentTarget.style.backgroundColor = "#e5e7eb";
|
|
3046
3051
|
},
|
|
@@ -3056,14 +3061,14 @@ function rr({
|
|
|
3056
3061
|
return null;
|
|
3057
3062
|
}
|
|
3058
3063
|
};
|
|
3059
|
-
return /* @__PURE__ */ l("div", { style:
|
|
3064
|
+
return /* @__PURE__ */ l("div", { style: M.container, className: g, children: [
|
|
3060
3065
|
/* @__PURE__ */ n("style", { children: `
|
|
3061
3066
|
@keyframes spin {
|
|
3062
3067
|
0% { transform: rotate(0deg); }
|
|
3063
3068
|
100% { transform: rotate(360deg); }
|
|
3064
3069
|
}
|
|
3065
3070
|
` }),
|
|
3066
|
-
/* @__PURE__ */ n("h1", { style:
|
|
3071
|
+
/* @__PURE__ */ n("h1", { style: M.title, children: u.title }),
|
|
3067
3072
|
C()
|
|
3068
3073
|
] });
|
|
3069
3074
|
}
|
|
@@ -3192,21 +3197,21 @@ function nr({
|
|
|
3192
3197
|
onModeChange: g,
|
|
3193
3198
|
className: w
|
|
3194
3199
|
}) {
|
|
3195
|
-
const [m, k] = S(""), [b, f] = S(r), [A,
|
|
3200
|
+
const [m, k] = S(""), [b, f] = S(r), [A, E] = S(""), [$, L] = S(""), [P, u] = S(!1), [M, z] = S(""), [N, p] = S(""), [O, v] = S({}), { requestPasswordReset: C, confirmPasswordReset: x } = oe(), { tenant: I } = le(), F = { ...Rt, ...i }, c = { ...Lt, ...e }, R = () => {
|
|
3196
3201
|
const H = {};
|
|
3197
3202
|
return m.trim() || (H.email = !0), v(H), Object.keys(H).length === 0;
|
|
3198
3203
|
}, T = () => {
|
|
3199
3204
|
const H = {};
|
|
3200
|
-
return b.trim() || (H.token = !0), A.trim() || (H.newPassword = !0),
|
|
3205
|
+
return b.trim() || (H.token = !0), A.trim() || (H.newPassword = !0), $.trim() || (H.confirmPassword = !0), v(H), Object.keys(H).length === 0;
|
|
3201
3206
|
}, h = async (H) => {
|
|
3202
|
-
if (H.preventDefault(), !!
|
|
3203
|
-
if (!(
|
|
3207
|
+
if (H.preventDefault(), !!R()) {
|
|
3208
|
+
if (!(I != null && I.id)) {
|
|
3204
3209
|
z("Tenant not found");
|
|
3205
3210
|
return;
|
|
3206
3211
|
}
|
|
3207
3212
|
u(!0), z(""), p("");
|
|
3208
3213
|
try {
|
|
3209
|
-
await C({ email: m, tenantId:
|
|
3214
|
+
await C({ email: m, tenantId: I.id }), p(F.successMessage), s == null || s();
|
|
3210
3215
|
} catch (U) {
|
|
3211
3216
|
const V = U.message || F.errorMessage;
|
|
3212
3217
|
z(V), o == null || o(V);
|
|
@@ -3216,7 +3221,7 @@ function nr({
|
|
|
3216
3221
|
}
|
|
3217
3222
|
}, d = async (H) => {
|
|
3218
3223
|
if (H.preventDefault(), !!T()) {
|
|
3219
|
-
if (A !==
|
|
3224
|
+
if (A !== $) {
|
|
3220
3225
|
z(F.passwordMismatchError), v({ confirmPassword: !0 });
|
|
3221
3226
|
return;
|
|
3222
3227
|
}
|
|
@@ -3238,7 +3243,7 @@ function nr({
|
|
|
3238
3243
|
...P ? c.buttonLoading : {}
|
|
3239
3244
|
});
|
|
3240
3245
|
if (t === "reset") {
|
|
3241
|
-
const H = b && A &&
|
|
3246
|
+
const H = b && A && $;
|
|
3242
3247
|
return /* @__PURE__ */ l("div", { className: w, style: c.container, children: [
|
|
3243
3248
|
/* @__PURE__ */ n("h2", { style: c.title, children: F.resetTitle }),
|
|
3244
3249
|
/* @__PURE__ */ n("p", { style: c.subtitle, children: F.resetSubtitle }),
|
|
@@ -3267,7 +3272,7 @@ function nr({
|
|
|
3267
3272
|
type: "password",
|
|
3268
3273
|
value: A,
|
|
3269
3274
|
onChange: (U) => {
|
|
3270
|
-
|
|
3275
|
+
E(U.target.value), O.newPassword && v((V) => ({ ...V, newPassword: !1 }));
|
|
3271
3276
|
},
|
|
3272
3277
|
placeholder: F.newPasswordPlaceholder,
|
|
3273
3278
|
style: y("newPassword"),
|
|
@@ -3281,9 +3286,9 @@ function nr({
|
|
|
3281
3286
|
"input",
|
|
3282
3287
|
{
|
|
3283
3288
|
type: "password",
|
|
3284
|
-
value:
|
|
3289
|
+
value: $,
|
|
3285
3290
|
onChange: (U) => {
|
|
3286
|
-
|
|
3291
|
+
L(U.target.value), O.confirmPassword && v((V) => ({ ...V, confirmPassword: !1 })), M === F.passwordMismatchError && z("");
|
|
3287
3292
|
},
|
|
3288
3293
|
placeholder: F.confirmPasswordPlaceholder,
|
|
3289
3294
|
style: y("confirmPassword"),
|
|
@@ -3303,8 +3308,8 @@ function nr({
|
|
|
3303
3308
|
children: P ? F.resetLoadingText : F.resetSubmitButton
|
|
3304
3309
|
}
|
|
3305
3310
|
),
|
|
3306
|
-
|
|
3307
|
-
|
|
3311
|
+
M && /* @__PURE__ */ n("div", { style: c.errorText, children: M }),
|
|
3312
|
+
N && /* @__PURE__ */ n("div", { style: c.successText, children: N })
|
|
3308
3313
|
] }),
|
|
3309
3314
|
/* @__PURE__ */ l("div", { style: c.linkContainer, children: [
|
|
3310
3315
|
/* @__PURE__ */ n("a", { onClick: a, style: c.link, children: F.backToLoginLink }),
|
|
@@ -3315,7 +3320,7 @@ function nr({
|
|
|
3315
3320
|
] })
|
|
3316
3321
|
] });
|
|
3317
3322
|
}
|
|
3318
|
-
const
|
|
3323
|
+
const D = m;
|
|
3319
3324
|
return /* @__PURE__ */ l("div", { className: w, style: c.container, children: [
|
|
3320
3325
|
/* @__PURE__ */ n("h2", { style: c.title, children: F.title }),
|
|
3321
3326
|
/* @__PURE__ */ n("p", { style: c.subtitle, children: F.subtitle }),
|
|
@@ -3340,16 +3345,16 @@ function nr({
|
|
|
3340
3345
|
"button",
|
|
3341
3346
|
{
|
|
3342
3347
|
type: "submit",
|
|
3343
|
-
disabled:
|
|
3348
|
+
disabled: !D || P,
|
|
3344
3349
|
style: {
|
|
3345
3350
|
...G(),
|
|
3346
|
-
|
|
3351
|
+
...!D || P ? c.buttonDisabled : {}
|
|
3347
3352
|
},
|
|
3348
3353
|
children: P ? F.loadingText : F.submitButton
|
|
3349
3354
|
}
|
|
3350
3355
|
),
|
|
3351
|
-
|
|
3352
|
-
|
|
3356
|
+
M && /* @__PURE__ */ n("div", { style: c.errorText, children: M }),
|
|
3357
|
+
N && /* @__PURE__ */ n("div", { style: c.successText, children: N })
|
|
3353
3358
|
] }),
|
|
3354
3359
|
/* @__PURE__ */ l("div", { style: c.linkContainer, children: [
|
|
3355
3360
|
/* @__PURE__ */ n("a", { onClick: a, style: c.link, children: F.backToLoginLink }),
|
|
@@ -3412,9 +3417,9 @@ function sr({
|
|
|
3412
3417
|
errorFallback: t,
|
|
3413
3418
|
requireTenant: r = !0
|
|
3414
3419
|
}) {
|
|
3415
|
-
const { isAppLoading: s, appError: o, retryApp: a } = he(), g = ye(), w = Fe(), m = Ce(), k = De(), b = (g == null ? void 0 : g.isTenantLoading) ?? !1, f = (g == null ? void 0 : g.tenantError) ?? null, A = (g == null ? void 0 : g.tenantSlug) ?? null,
|
|
3416
|
-
}),
|
|
3417
|
-
o && a(), f && g &&
|
|
3420
|
+
const { isAppLoading: s, appError: o, retryApp: a } = he(), g = ye(), w = Fe(), m = Ce(), k = De(), b = (g == null ? void 0 : g.isTenantLoading) ?? !1, f = (g == null ? void 0 : g.tenantError) ?? null, A = (g == null ? void 0 : g.tenantSlug) ?? null, E = (g == null ? void 0 : g.retryTenant) ?? (() => {
|
|
3421
|
+
}), $ = (w == null ? void 0 : w.isAuthReady) ?? !0, L = (m == null ? void 0 : m.isReady) ?? !0, P = (k == null ? void 0 : k.isReady) ?? !0, u = r && g && A, p = s || u && b || w && !$ || m && !L || k && !P, O = o || (u ? f : null), v = () => {
|
|
3422
|
+
o && a(), f && g && E();
|
|
3418
3423
|
};
|
|
3419
3424
|
if (p)
|
|
3420
3425
|
return /* @__PURE__ */ n(j, { children: e || /* @__PURE__ */ n(Et, {}) });
|
|
@@ -3426,20 +3431,20 @@ function sr({
|
|
|
3426
3431
|
}
|
|
3427
3432
|
function ir(i = !0) {
|
|
3428
3433
|
const { isAppLoading: e, appError: t, retryApp: r, appInfo: s } = he(), o = ye(), a = Fe(), g = Ce(), w = De(), m = (o == null ? void 0 : o.isTenantLoading) ?? !1, k = (o == null ? void 0 : o.tenantError) ?? null, b = (o == null ? void 0 : o.tenant) ?? null, f = (o == null ? void 0 : o.tenantSlug) ?? null, A = (o == null ? void 0 : o.retryTenant) ?? (() => {
|
|
3429
|
-
}),
|
|
3434
|
+
}), E = (a == null ? void 0 : a.isAuthReady) ?? !0, $ = (g == null ? void 0 : g.isReady) ?? !0, L = (w == null ? void 0 : w.isReady) ?? !0, P = i && o && f, N = e || P && m || a && !E || g && !$ || w && !L, p = t || (P ? k : null);
|
|
3430
3435
|
return {
|
|
3431
|
-
isLoading:
|
|
3436
|
+
isLoading: N,
|
|
3432
3437
|
error: p,
|
|
3433
|
-
isReady: !
|
|
3438
|
+
isReady: !N && !p && s !== null && (!P || b !== null),
|
|
3434
3439
|
retry: () => {
|
|
3435
3440
|
t && r(), k && o && A();
|
|
3436
3441
|
},
|
|
3437
3442
|
// Individual states
|
|
3438
3443
|
app: { isLoading: e, error: t, data: s },
|
|
3439
3444
|
tenant: o ? { isLoading: m, error: k, data: b } : null,
|
|
3440
|
-
auth: a ? { isReady:
|
|
3441
|
-
featureFlags: g ? { isReady:
|
|
3442
|
-
subscription: w ? { isReady:
|
|
3445
|
+
auth: a ? { isReady: E } : null,
|
|
3446
|
+
featureFlags: g ? { isReady: $ } : null,
|
|
3447
|
+
subscription: w ? { isReady: L } : null
|
|
3443
3448
|
};
|
|
3444
3449
|
}
|
|
3445
3450
|
class or {
|