@skylabs-digital/react-identity-access 2.0.0 → 2.1.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/components/AppLoader.d.ts +56 -0
- package/dist/components/AppLoader.d.ts.map +1 -0
- package/dist/components/FeatureFlag.d.ts.map +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.es.js +1042 -1038
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/providers/AppProvider.d.ts +0 -2
- package/dist/providers/AppProvider.d.ts.map +1 -1
- package/dist/providers/TenantProvider.d.ts +2 -2
- package/dist/providers/TenantProvider.d.ts.map +1 -1
- package/dist/services/AuthApiService.d.ts.map +1 -1
- package/dist/services/SessionManager.d.ts.map +1 -1
- package/dist/utils/tenantDetection.d.ts +26 -0
- package/dist/utils/tenantDetection.d.ts.map +1 -0
- package/package.json +1 -1
package/dist/index.es.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { jsx as n, Fragment as
|
|
2
|
-
import { createContext as
|
|
1
|
+
import { jsx as n, Fragment as B, jsxs as a } from "react/jsx-runtime";
|
|
2
|
+
import { createContext as he, useMemo as Q, useState as k, useCallback as ne, useEffect as te, useContext as ce } from "react";
|
|
3
3
|
import { useLocation as we, Navigate as pe } from "react-router-dom";
|
|
4
4
|
class re {
|
|
5
5
|
// SessionManager instance
|
|
@@ -15,41 +15,41 @@ class re {
|
|
|
15
15
|
async request(e, t, r, s) {
|
|
16
16
|
return this.executeRequest(e, t, r, s, !1);
|
|
17
17
|
}
|
|
18
|
-
async executeRequest(e, t, r, s,
|
|
19
|
-
const
|
|
18
|
+
async executeRequest(e, t, r, s, o = !1) {
|
|
19
|
+
const g = `${this.baseUrl}${t.startsWith("/") ? t : `/${t}`}`, y = (s == null ? void 0 : s.timeout) || this.timeout;
|
|
20
20
|
let A = {
|
|
21
21
|
"Content-Type": "application/json",
|
|
22
22
|
...s == null ? void 0 : s.headers
|
|
23
23
|
};
|
|
24
24
|
if (!(s != null && s.skipAuth) && this.sessionManager)
|
|
25
25
|
try {
|
|
26
|
-
const
|
|
27
|
-
A = { ...A, ...
|
|
28
|
-
} catch (
|
|
29
|
-
console.warn("Failed to inject auth headers:",
|
|
26
|
+
const f = await this.sessionManager.getAuthHeaders();
|
|
27
|
+
A = { ...A, ...f };
|
|
28
|
+
} catch (f) {
|
|
29
|
+
console.warn("Failed to inject auth headers:", f);
|
|
30
30
|
}
|
|
31
|
-
const
|
|
31
|
+
const w = new AbortController(), T = setTimeout(() => w.abort(), y);
|
|
32
32
|
try {
|
|
33
|
-
const
|
|
33
|
+
const f = await fetch(g, {
|
|
34
34
|
method: e,
|
|
35
35
|
headers: A,
|
|
36
36
|
body: r ? JSON.stringify(r) : void 0,
|
|
37
|
-
signal:
|
|
37
|
+
signal: w.signal
|
|
38
38
|
});
|
|
39
|
-
if (clearTimeout(
|
|
39
|
+
if (clearTimeout(T), f.status === 401 && !(s != null && s.skipRetry) && !o && this.sessionManager)
|
|
40
40
|
try {
|
|
41
41
|
const h = this.sessionManager.getTokens();
|
|
42
42
|
if (h != null && h.refreshToken)
|
|
43
43
|
return await this.sessionManager.getAuthHeaders(), this.executeRequest(e, t, r, s, !0);
|
|
44
44
|
} catch {
|
|
45
|
-
throw new Error(`HTTP ${
|
|
45
|
+
throw new Error(`HTTP ${f.status}: ${f.statusText}`);
|
|
46
46
|
}
|
|
47
|
-
if (!
|
|
48
|
-
throw new Error(`HTTP ${
|
|
49
|
-
const
|
|
50
|
-
return !
|
|
51
|
-
} catch (
|
|
52
|
-
throw clearTimeout(
|
|
47
|
+
if (!f.ok)
|
|
48
|
+
throw new Error(`HTTP ${f.status}: ${f.statusText}`);
|
|
49
|
+
const p = f.headers.get("content-type");
|
|
50
|
+
return !p || !p.includes("application/json") ? {} : await f.json();
|
|
51
|
+
} catch (f) {
|
|
52
|
+
throw clearTimeout(T), f instanceof Error && f.name === "AbortError" ? new Error(`Request timeout after ${y}ms`) : f;
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
55
|
async get(e, t) {
|
|
@@ -65,7 +65,7 @@ class re {
|
|
|
65
65
|
return this.request("DELETE", e, void 0, t);
|
|
66
66
|
}
|
|
67
67
|
}
|
|
68
|
-
class
|
|
68
|
+
class Se {
|
|
69
69
|
constructor(e, t) {
|
|
70
70
|
this.httpService = e, this.sessionManager = t;
|
|
71
71
|
}
|
|
@@ -78,12 +78,12 @@ class be {
|
|
|
78
78
|
async getApps(e) {
|
|
79
79
|
const t = await this.sessionManager.getAuthHeaders(), r = new URLSearchParams();
|
|
80
80
|
e != null && e.page && r.append("page", e.page.toString()), e != null && e.limit && r.append("limit", e.limit.toString()), e != null && e.sortBy && r.append("sortBy", e.sortBy), e != null && e.sortOrder && r.append("sortOrder", e.sortOrder);
|
|
81
|
-
const s = `/apps/${r.toString() ? `?${r.toString()}` : ""}`,
|
|
81
|
+
const s = `/apps/${r.toString() ? `?${r.toString()}` : ""}`, o = await this.httpService.get(s, {
|
|
82
82
|
headers: t
|
|
83
83
|
});
|
|
84
84
|
return {
|
|
85
|
-
apps:
|
|
86
|
-
meta:
|
|
85
|
+
apps: o.data,
|
|
86
|
+
meta: o.meta
|
|
87
87
|
};
|
|
88
88
|
}
|
|
89
89
|
async getAppById(e) {
|
|
@@ -124,97 +124,52 @@ class be {
|
|
|
124
124
|
})).data;
|
|
125
125
|
}
|
|
126
126
|
}
|
|
127
|
-
const
|
|
128
|
-
|
|
129
|
-
{
|
|
130
|
-
style: {
|
|
131
|
-
display: "flex",
|
|
132
|
-
justifyContent: "center",
|
|
133
|
-
alignItems: "center",
|
|
134
|
-
height: "100vh",
|
|
135
|
-
fontFamily: "system-ui, sans-serif"
|
|
136
|
-
},
|
|
137
|
-
children: /* @__PURE__ */ n("div", { children: "Loading application..." })
|
|
138
|
-
}
|
|
139
|
-
), He = ({ error: i, retry: e }) => /* @__PURE__ */ l(
|
|
140
|
-
"div",
|
|
141
|
-
{
|
|
142
|
-
style: {
|
|
143
|
-
display: "flex",
|
|
144
|
-
flexDirection: "column",
|
|
145
|
-
justifyContent: "center",
|
|
146
|
-
alignItems: "center",
|
|
147
|
-
height: "100vh",
|
|
148
|
-
fontFamily: "system-ui, sans-serif",
|
|
149
|
-
textAlign: "center",
|
|
150
|
-
padding: "20px"
|
|
151
|
-
},
|
|
152
|
-
children: [
|
|
153
|
-
/* @__PURE__ */ n("h2", { style: { color: "#dc3545", marginBottom: "16px" }, children: "Application Error" }),
|
|
154
|
-
/* @__PURE__ */ n("p", { style: { color: "#6c757d", marginBottom: "24px" }, children: i.message || "Unable to load application" }),
|
|
155
|
-
/* @__PURE__ */ n(
|
|
156
|
-
"button",
|
|
157
|
-
{
|
|
158
|
-
onClick: e,
|
|
159
|
-
style: {
|
|
160
|
-
padding: "8px 16px",
|
|
161
|
-
backgroundColor: "#007bff",
|
|
162
|
-
color: "white",
|
|
163
|
-
border: "none",
|
|
164
|
-
borderRadius: "4px",
|
|
165
|
-
cursor: "pointer"
|
|
166
|
-
},
|
|
167
|
-
children: "Retry"
|
|
168
|
-
}
|
|
169
|
-
)
|
|
170
|
-
]
|
|
171
|
-
}
|
|
172
|
-
);
|
|
173
|
-
function St({ config: i, children: e }) {
|
|
127
|
+
const Te = he(null);
|
|
128
|
+
function xt({ config: i, children: e }) {
|
|
174
129
|
const t = Q(
|
|
175
130
|
() => {
|
|
176
|
-
var
|
|
131
|
+
var p, h, m;
|
|
177
132
|
return {
|
|
178
|
-
enabled: ((
|
|
133
|
+
enabled: ((p = i.cache) == null ? void 0 : p.enabled) ?? !0,
|
|
179
134
|
ttl: ((h = i.cache) == null ? void 0 : h.ttl) ?? 3e5,
|
|
180
135
|
// 5 minutes default
|
|
181
|
-
storageKey: ((
|
|
136
|
+
storageKey: ((m = i.cache) == null ? void 0 : m.storageKey) ?? `app_cache_${i.appId}`
|
|
182
137
|
};
|
|
183
138
|
},
|
|
184
139
|
[i.cache, i.appId]
|
|
185
|
-
), [r, s] =
|
|
140
|
+
), [r, s] = k(() => {
|
|
186
141
|
if (!t.enabled) return null;
|
|
187
142
|
try {
|
|
188
|
-
const
|
|
189
|
-
if (!
|
|
190
|
-
const h = JSON.parse(
|
|
143
|
+
const p = localStorage.getItem(t.storageKey);
|
|
144
|
+
if (!p) return null;
|
|
145
|
+
const h = JSON.parse(p);
|
|
191
146
|
return Date.now() - h.timestamp < t.ttl && h.appId === i.appId ? h.data : (localStorage.removeItem(t.storageKey), null);
|
|
192
147
|
} catch {
|
|
193
148
|
return null;
|
|
194
149
|
}
|
|
195
|
-
}), [
|
|
196
|
-
const
|
|
197
|
-
|
|
150
|
+
}), [o, g] = k(!r), [y, A] = k(null), w = Q(() => {
|
|
151
|
+
const p = () => {
|
|
152
|
+
T();
|
|
198
153
|
};
|
|
199
154
|
return {
|
|
200
155
|
appId: i.appId,
|
|
201
156
|
baseUrl: i.baseUrl,
|
|
202
157
|
// App info
|
|
203
158
|
appInfo: r,
|
|
204
|
-
isAppLoading:
|
|
205
|
-
appError:
|
|
206
|
-
retryApp:
|
|
159
|
+
isAppLoading: o,
|
|
160
|
+
appError: y,
|
|
161
|
+
retryApp: p
|
|
207
162
|
};
|
|
208
|
-
}, [i, r,
|
|
209
|
-
async (
|
|
210
|
-
if (!(!
|
|
163
|
+
}, [i, r, o, y]), T = ne(
|
|
164
|
+
async (p = !1) => {
|
|
165
|
+
if (!(!p && t.enabled && r))
|
|
211
166
|
try {
|
|
212
|
-
|
|
213
|
-
const h = new re(i.baseUrl),
|
|
214
|
-
if (s(
|
|
167
|
+
g(!0), A(null);
|
|
168
|
+
const h = new re(i.baseUrl), R = await new Se(h, {}).getPublicAppInfo(i.appId);
|
|
169
|
+
if (s(R), t.enabled)
|
|
215
170
|
try {
|
|
216
171
|
const C = {
|
|
217
|
-
data:
|
|
172
|
+
data: R,
|
|
218
173
|
timestamp: Date.now(),
|
|
219
174
|
appId: i.appId
|
|
220
175
|
};
|
|
@@ -223,50 +178,44 @@ function St({ config: i, children: e }) {
|
|
|
223
178
|
console.warn("Failed to cache app info:", C);
|
|
224
179
|
}
|
|
225
180
|
} catch (h) {
|
|
226
|
-
const
|
|
227
|
-
A(
|
|
181
|
+
const m = h instanceof Error ? h : new Error("Failed to load app information");
|
|
182
|
+
A(m), s(null);
|
|
228
183
|
} finally {
|
|
229
|
-
|
|
184
|
+
g(!1);
|
|
230
185
|
}
|
|
231
186
|
},
|
|
232
187
|
[i.baseUrl, i.appId, t, r]
|
|
233
|
-
),
|
|
188
|
+
), f = ne(async () => {
|
|
234
189
|
if (!(!t.enabled || !r))
|
|
235
190
|
try {
|
|
236
|
-
const
|
|
237
|
-
if (!
|
|
238
|
-
const h = JSON.parse(
|
|
191
|
+
const p = localStorage.getItem(t.storageKey);
|
|
192
|
+
if (!p) return;
|
|
193
|
+
const h = JSON.parse(p);
|
|
239
194
|
if (Date.now() - h.timestamp > t.ttl * 0.5) {
|
|
240
|
-
const
|
|
241
|
-
s(
|
|
242
|
-
const
|
|
243
|
-
data:
|
|
195
|
+
const R = new re(i.baseUrl), U = await new Se(R, {}).getPublicAppInfo(i.appId);
|
|
196
|
+
s(U);
|
|
197
|
+
const P = {
|
|
198
|
+
data: U,
|
|
244
199
|
timestamp: Date.now(),
|
|
245
200
|
appId: i.appId
|
|
246
201
|
};
|
|
247
|
-
localStorage.setItem(t.storageKey, JSON.stringify(
|
|
202
|
+
localStorage.setItem(t.storageKey, JSON.stringify(P));
|
|
248
203
|
}
|
|
249
|
-
} catch (
|
|
250
|
-
console.warn("Background app refresh failed:",
|
|
204
|
+
} catch (p) {
|
|
205
|
+
console.warn("Background app refresh failed:", p);
|
|
251
206
|
}
|
|
252
207
|
}, [i, t, r]);
|
|
253
|
-
|
|
254
|
-
r ?
|
|
255
|
-
}, []),
|
|
256
|
-
return /* @__PURE__ */ n(N, { children: i.loadingFallback || /* @__PURE__ */ n(De, {}) });
|
|
257
|
-
if (I) {
|
|
258
|
-
const m = typeof i.errorFallback == "function" ? i.errorFallback(I, () => P()) : i.errorFallback || /* @__PURE__ */ n(He, { error: I, retry: () => P() });
|
|
259
|
-
return /* @__PURE__ */ n(N, { children: m });
|
|
260
|
-
}
|
|
261
|
-
return /* @__PURE__ */ n(Ae.Provider, { value: x, children: e });
|
|
208
|
+
return te(() => {
|
|
209
|
+
r ? f() : T();
|
|
210
|
+
}, []), /* @__PURE__ */ n(Te.Provider, { value: w, children: e });
|
|
262
211
|
}
|
|
263
|
-
function
|
|
264
|
-
const i =
|
|
212
|
+
function oe() {
|
|
213
|
+
const i = ce(Te);
|
|
265
214
|
if (!i)
|
|
266
215
|
throw new Error("useApp must be used within an AppProvider");
|
|
267
216
|
return i;
|
|
268
217
|
}
|
|
269
|
-
const
|
|
218
|
+
const kt = oe;
|
|
270
219
|
class ye {
|
|
271
220
|
constructor(e = {}) {
|
|
272
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);
|
|
@@ -304,7 +253,14 @@ class ye {
|
|
|
304
253
|
this.tokenStorage.set(t);
|
|
305
254
|
}
|
|
306
255
|
getTokens() {
|
|
307
|
-
|
|
256
|
+
const { accessToken: e, refreshToken: t, expiresAt: r, expiresIn: s, tokenType: o } = this.tokenStorage.get() || {};
|
|
257
|
+
return e ? {
|
|
258
|
+
accessToken: e,
|
|
259
|
+
refreshToken: t,
|
|
260
|
+
expiresAt: r,
|
|
261
|
+
expiresIn: s,
|
|
262
|
+
tokenType: o
|
|
263
|
+
} : null;
|
|
308
264
|
}
|
|
309
265
|
clearTokens() {
|
|
310
266
|
this.tokenStorage.clear();
|
|
@@ -413,14 +369,13 @@ class ye {
|
|
|
413
369
|
return e !== null && !this.isTokenExpired(e);
|
|
414
370
|
}
|
|
415
371
|
}
|
|
416
|
-
class
|
|
372
|
+
class He {
|
|
417
373
|
constructor(e) {
|
|
418
374
|
this.httpService = e;
|
|
419
375
|
}
|
|
420
376
|
// Public endpoints - no auth required
|
|
421
377
|
async login(e) {
|
|
422
|
-
|
|
423
|
-
return console.log(t), t;
|
|
378
|
+
return await this.httpService.post("/auth/login", e);
|
|
424
379
|
}
|
|
425
380
|
async signup(e) {
|
|
426
381
|
return await this.httpService.post("/auth/signup", e);
|
|
@@ -459,7 +414,7 @@ class Ne {
|
|
|
459
414
|
});
|
|
460
415
|
}
|
|
461
416
|
}
|
|
462
|
-
class
|
|
417
|
+
class ve {
|
|
463
418
|
constructor(e, t) {
|
|
464
419
|
this.httpService = e, this.sessionManager = t;
|
|
465
420
|
}
|
|
@@ -499,10 +454,10 @@ class Se {
|
|
|
499
454
|
async getRolesByApp(e, t) {
|
|
500
455
|
const r = new URLSearchParams();
|
|
501
456
|
t != null && t.page && r.append("page", t.page.toString()), t != null && t.limit && r.append("limit", t.limit.toString()), t != null && t.sortBy && r.append("sortBy", t.sortBy), t != null && t.sortOrder && r.append("sortOrder", t.sortOrder);
|
|
502
|
-
const s = `/roles/app/${e}${r.toString() ? `?${r.toString()}` : ""}`,
|
|
457
|
+
const s = `/roles/app/${e}${r.toString() ? `?${r.toString()}` : ""}`, o = await this.httpService.get(s);
|
|
503
458
|
return {
|
|
504
|
-
roles:
|
|
505
|
-
meta:
|
|
459
|
+
roles: o.data,
|
|
460
|
+
meta: o.meta
|
|
506
461
|
};
|
|
507
462
|
}
|
|
508
463
|
async assignRole(e, t) {
|
|
@@ -526,16 +481,16 @@ class Se {
|
|
|
526
481
|
throw new Error("SessionManager is required for private endpoints");
|
|
527
482
|
const r = await this.sessionManager.getAuthHeaders(), s = new URLSearchParams();
|
|
528
483
|
t != null && t.page && s.append("page", t.page.toString()), t != null && t.limit && s.append("limit", t.limit.toString()), t != null && t.sortBy && s.append("sortBy", t.sortBy), t != null && t.sortOrder && s.append("sortOrder", t.sortOrder);
|
|
529
|
-
const
|
|
484
|
+
const o = `/roles/user/${e}${s.toString() ? `?${s.toString()}` : ""}`, g = await this.httpService.get(o, {
|
|
530
485
|
headers: r
|
|
531
486
|
});
|
|
532
487
|
return {
|
|
533
|
-
roles:
|
|
534
|
-
meta:
|
|
488
|
+
roles: g.data,
|
|
489
|
+
meta: g.meta
|
|
535
490
|
};
|
|
536
491
|
}
|
|
537
492
|
}
|
|
538
|
-
class
|
|
493
|
+
class Ne {
|
|
539
494
|
constructor(e, t) {
|
|
540
495
|
this.httpService = e, this.sessionManager = t;
|
|
541
496
|
}
|
|
@@ -548,12 +503,12 @@ class Be {
|
|
|
548
503
|
async getUsers(e) {
|
|
549
504
|
const t = await this.sessionManager.getAuthHeaders(), r = new URLSearchParams();
|
|
550
505
|
e != null && e.page && r.append("page", e.page.toString()), e != null && e.limit && r.append("limit", e.limit.toString()), e != null && e.sortBy && r.append("sortBy", e.sortBy), e != null && e.sortOrder && r.append("sortOrder", e.sortOrder);
|
|
551
|
-
const s = `/users/${r.toString() ? `?${r.toString()}` : ""}`,
|
|
506
|
+
const s = `/users/${r.toString() ? `?${r.toString()}` : ""}`, o = await this.httpService.get(s, {
|
|
552
507
|
headers: t
|
|
553
508
|
});
|
|
554
509
|
return {
|
|
555
|
-
users:
|
|
556
|
-
meta:
|
|
510
|
+
users: o.data,
|
|
511
|
+
meta: o.meta
|
|
557
512
|
};
|
|
558
513
|
}
|
|
559
514
|
async getUserById(e) {
|
|
@@ -575,7 +530,7 @@ class Be {
|
|
|
575
530
|
});
|
|
576
531
|
}
|
|
577
532
|
}
|
|
578
|
-
class
|
|
533
|
+
class ue {
|
|
579
534
|
constructor(e, t, r) {
|
|
580
535
|
this.httpService = e, this.appId = t, this.sessionManager = r;
|
|
581
536
|
}
|
|
@@ -592,12 +547,12 @@ class ce {
|
|
|
592
547
|
throw new Error("SessionManager is required for private endpoints");
|
|
593
548
|
const t = await this.sessionManager.getAuthHeaders(), r = new URLSearchParams();
|
|
594
549
|
e != null && e.page && r.append("page", e.page.toString()), e != null && e.limit && r.append("limit", e.limit.toString()), e != null && e.sortBy && r.append("sortBy", e.sortBy), e != null && e.sortOrder && r.append("sortOrder", e.sortOrder);
|
|
595
|
-
const s = `/tenants/${r.toString() ? `?${r.toString()}` : ""}`,
|
|
550
|
+
const s = `/tenants/${r.toString() ? `?${r.toString()}` : ""}`, o = await this.httpService.get(s, {
|
|
596
551
|
headers: t
|
|
597
552
|
});
|
|
598
553
|
return {
|
|
599
|
-
tenants:
|
|
600
|
-
meta:
|
|
554
|
+
tenants: o.data,
|
|
555
|
+
meta: o.meta
|
|
601
556
|
};
|
|
602
557
|
}
|
|
603
558
|
async getTenantById(e) {
|
|
@@ -653,180 +608,155 @@ class ce {
|
|
|
653
608
|
)).data;
|
|
654
609
|
}
|
|
655
610
|
}
|
|
656
|
-
|
|
657
|
-
"
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
children: /* @__PURE__ */ n("div", { children: "Loading tenant..." })
|
|
667
|
-
}
|
|
668
|
-
), qe = ({ error: i, retry: e }) => /* @__PURE__ */ l(
|
|
669
|
-
"div",
|
|
670
|
-
{
|
|
671
|
-
style: {
|
|
672
|
-
display: "flex",
|
|
673
|
-
flexDirection: "column",
|
|
674
|
-
justifyContent: "center",
|
|
675
|
-
alignItems: "center",
|
|
676
|
-
height: "100vh",
|
|
677
|
-
fontFamily: "system-ui, sans-serif",
|
|
678
|
-
textAlign: "center",
|
|
679
|
-
padding: "20px"
|
|
680
|
-
},
|
|
681
|
-
children: [
|
|
682
|
-
/* @__PURE__ */ n("h2", { style: { color: "#dc3545", marginBottom: "16px" }, children: "Tenant Error" }),
|
|
683
|
-
/* @__PURE__ */ n("p", { style: { color: "#6c757d", marginBottom: "24px" }, children: i.message || "Unable to load tenant" }),
|
|
684
|
-
/* @__PURE__ */ n(
|
|
685
|
-
"button",
|
|
686
|
-
{
|
|
687
|
-
onClick: e,
|
|
688
|
-
style: {
|
|
689
|
-
padding: "8px 16px",
|
|
690
|
-
backgroundColor: "#007bff",
|
|
691
|
-
color: "white",
|
|
692
|
-
border: "none",
|
|
693
|
-
borderRadius: "4px",
|
|
694
|
-
cursor: "pointer"
|
|
695
|
-
},
|
|
696
|
-
children: "Retry"
|
|
697
|
-
}
|
|
698
|
-
)
|
|
699
|
-
]
|
|
700
|
-
}
|
|
701
|
-
);
|
|
702
|
-
function xt({ config: i, children: e }) {
|
|
703
|
-
const { baseUrl: t, appInfo: r, appId: s } = he(), a = ne(() => {
|
|
704
|
-
const o = i.tenantMode || "selector", g = "tenant";
|
|
705
|
-
if (typeof window > "u") return null;
|
|
706
|
-
if (o === "subdomain") {
|
|
707
|
-
const d = window.location.hostname.split(".");
|
|
708
|
-
if (d.length >= 3) {
|
|
709
|
-
const c = d[0];
|
|
710
|
-
return localStorage.setItem(g, c), c;
|
|
711
|
-
}
|
|
712
|
-
return localStorage.getItem(g);
|
|
713
|
-
} else if (o === "selector") {
|
|
714
|
-
const d = new URLSearchParams(window.location.search).get(i.selectorParam || "tenant");
|
|
715
|
-
return d ? (localStorage.setItem(g, d), d) : localStorage.getItem(g);
|
|
611
|
+
function Be(i, e) {
|
|
612
|
+
if (i === "localhost" || i.startsWith("127.") || i.startsWith("192.168."))
|
|
613
|
+
return null;
|
|
614
|
+
if (e) {
|
|
615
|
+
const s = e.toLowerCase(), o = i.toLowerCase();
|
|
616
|
+
if (o === s || o === `www.${s}`)
|
|
617
|
+
return null;
|
|
618
|
+
if (o.endsWith(`.${s}`)) {
|
|
619
|
+
const g = o.slice(0, -(s.length + 1));
|
|
620
|
+
return g === "www" ? null : g;
|
|
716
621
|
}
|
|
717
622
|
return null;
|
|
718
|
-
}
|
|
623
|
+
}
|
|
624
|
+
const r = i.split(".");
|
|
625
|
+
return r.length >= 3 && r[0] !== "www" ? r[0] : null;
|
|
626
|
+
}
|
|
627
|
+
function Ue(i, e = "tenant", t) {
|
|
628
|
+
const s = new URLSearchParams(i).get(e);
|
|
629
|
+
return s ? (t && t.setItem("tenant", s), s) : t ? t.getItem("tenant") : null;
|
|
630
|
+
}
|
|
631
|
+
function qe(i, e, t) {
|
|
632
|
+
const { tenantMode: r, baseDomain: s, selectorParam: o } = i;
|
|
633
|
+
return r === "subdomain" ? Be(e.hostname, s) : r === "selector" ? Ue(e.search, o, t) : null;
|
|
634
|
+
}
|
|
635
|
+
const be = he(null);
|
|
636
|
+
function At({ config: i, children: e }) {
|
|
637
|
+
const { baseUrl: t, appInfo: r, appId: s } = oe(), o = ne(() => typeof window > "u" ? null : qe(
|
|
638
|
+
{
|
|
639
|
+
tenantMode: i.tenantMode || "selector",
|
|
640
|
+
baseDomain: i.baseDomain,
|
|
641
|
+
selectorParam: i.selectorParam
|
|
642
|
+
},
|
|
643
|
+
{
|
|
644
|
+
hostname: window.location.hostname,
|
|
645
|
+
search: window.location.search
|
|
646
|
+
},
|
|
647
|
+
window.localStorage
|
|
648
|
+
), [i.tenantMode, i.baseDomain, i.selectorParam]), [g, y] = k(() => o()), A = Q(
|
|
719
649
|
() => {
|
|
720
|
-
var
|
|
650
|
+
var l, x, b;
|
|
721
651
|
return {
|
|
722
|
-
enabled: ((
|
|
723
|
-
ttl: ((
|
|
652
|
+
enabled: ((l = i.cache) == null ? void 0 : l.enabled) ?? !0,
|
|
653
|
+
ttl: ((x = i.cache) == null ? void 0 : x.ttl) ?? 5 * 60 * 1e3,
|
|
724
654
|
// 5 minutes default
|
|
725
|
-
storageKey: ((
|
|
655
|
+
storageKey: ((b = i.cache) == null ? void 0 : b.storageKey) ?? `tenant_cache_${g || "default"}`
|
|
726
656
|
};
|
|
727
657
|
},
|
|
728
|
-
[i.cache,
|
|
729
|
-
), [
|
|
658
|
+
[i.cache, g]
|
|
659
|
+
), [w, T] = k(() => {
|
|
730
660
|
if (i.initialTenant) return i.initialTenant;
|
|
731
|
-
if (!A.enabled || !
|
|
661
|
+
if (!A.enabled || !g) return null;
|
|
732
662
|
try {
|
|
733
|
-
const
|
|
734
|
-
if (!
|
|
735
|
-
const
|
|
736
|
-
return Date.now() -
|
|
663
|
+
const l = localStorage.getItem(A.storageKey);
|
|
664
|
+
if (!l) return null;
|
|
665
|
+
const x = JSON.parse(l);
|
|
666
|
+
return Date.now() - x.timestamp < A.ttl && x.tenantSlug === g ? x.data : (localStorage.removeItem(A.storageKey), null);
|
|
737
667
|
} catch {
|
|
738
668
|
return null;
|
|
739
669
|
}
|
|
740
|
-
}), [
|
|
670
|
+
}), [f, p] = k(!w && !i.initialTenant), [h, m] = k(null), [R, C] = k(null), [U, P] = k(!1), [u, M] = k(null);
|
|
741
671
|
te(() => {
|
|
742
|
-
const
|
|
743
|
-
|
|
744
|
-
}, [
|
|
745
|
-
const
|
|
746
|
-
async (
|
|
747
|
-
if (!(!
|
|
672
|
+
const l = o();
|
|
673
|
+
y(l);
|
|
674
|
+
}, [o]);
|
|
675
|
+
const E = (r == null ? void 0 : r.settingsSchema) || null, q = ne(
|
|
676
|
+
async (l, x = !1) => {
|
|
677
|
+
if (!(!x && A.enabled && w && w.domain === l))
|
|
748
678
|
try {
|
|
749
|
-
|
|
750
|
-
const
|
|
751
|
-
if (
|
|
679
|
+
p(!0), m(null);
|
|
680
|
+
const b = new re(t), c = await new ue(b, s).getPublicTenantInfo(l);
|
|
681
|
+
if (T(c), A.enabled)
|
|
752
682
|
try {
|
|
753
|
-
const
|
|
683
|
+
const S = {
|
|
754
684
|
data: c,
|
|
755
685
|
timestamp: Date.now(),
|
|
756
|
-
tenantSlug:
|
|
686
|
+
tenantSlug: l
|
|
757
687
|
};
|
|
758
|
-
localStorage.setItem(A.storageKey, JSON.stringify(
|
|
759
|
-
} catch (
|
|
760
|
-
console.warn("Failed to cache tenant info:",
|
|
688
|
+
localStorage.setItem(A.storageKey, JSON.stringify(S));
|
|
689
|
+
} catch (S) {
|
|
690
|
+
console.warn("Failed to cache tenant info:", S);
|
|
761
691
|
}
|
|
762
|
-
} catch (
|
|
763
|
-
const d =
|
|
764
|
-
|
|
692
|
+
} catch (b) {
|
|
693
|
+
const d = b instanceof Error ? b : new Error("Failed to load tenant information");
|
|
694
|
+
m(d), T(null);
|
|
765
695
|
} finally {
|
|
766
|
-
|
|
696
|
+
p(!1);
|
|
767
697
|
}
|
|
768
698
|
},
|
|
769
|
-
[t, s, A,
|
|
770
|
-
),
|
|
771
|
-
if (!(!A.enabled || !
|
|
699
|
+
[t, s, A, w]
|
|
700
|
+
), V = ne(async () => {
|
|
701
|
+
if (!(!A.enabled || !w || !g))
|
|
772
702
|
try {
|
|
773
|
-
const
|
|
774
|
-
if (!
|
|
775
|
-
const
|
|
776
|
-
if (Date.now() -
|
|
777
|
-
const d = new re(t),
|
|
778
|
-
|
|
779
|
-
const
|
|
780
|
-
data:
|
|
703
|
+
const l = localStorage.getItem(A.storageKey);
|
|
704
|
+
if (!l) return;
|
|
705
|
+
const x = JSON.parse(l);
|
|
706
|
+
if (Date.now() - x.timestamp > A.ttl * 0.5) {
|
|
707
|
+
const d = new re(t), S = await new ue(d, s).getPublicTenantInfo(g);
|
|
708
|
+
T(S);
|
|
709
|
+
const G = {
|
|
710
|
+
data: S,
|
|
781
711
|
timestamp: Date.now(),
|
|
782
|
-
tenantSlug:
|
|
712
|
+
tenantSlug: g
|
|
783
713
|
};
|
|
784
|
-
localStorage.setItem(A.storageKey, JSON.stringify(
|
|
714
|
+
localStorage.setItem(A.storageKey, JSON.stringify(G));
|
|
785
715
|
}
|
|
786
|
-
} catch (
|
|
787
|
-
console.warn("Background tenant refresh failed:",
|
|
716
|
+
} catch (l) {
|
|
717
|
+
console.warn("Background tenant refresh failed:", l);
|
|
788
718
|
}
|
|
789
|
-
}, [t, s, A,
|
|
790
|
-
if (
|
|
719
|
+
}, [t, s, A, w, g]), $ = ne(async () => {
|
|
720
|
+
if (w != null && w.id)
|
|
791
721
|
try {
|
|
792
|
-
|
|
793
|
-
const
|
|
794
|
-
C(
|
|
795
|
-
} catch (
|
|
796
|
-
const
|
|
797
|
-
|
|
722
|
+
P(!0), M(null);
|
|
723
|
+
const l = new re(t), b = await new ue(l, w.appId).getTenantSettings(w.id);
|
|
724
|
+
C(b);
|
|
725
|
+
} catch (l) {
|
|
726
|
+
const x = l instanceof Error ? l : new Error("Failed to load tenant settings");
|
|
727
|
+
M(x), C(null);
|
|
798
728
|
} finally {
|
|
799
|
-
|
|
729
|
+
P(!1);
|
|
800
730
|
}
|
|
801
|
-
}, [t,
|
|
802
|
-
|
|
803
|
-
}, [
|
|
804
|
-
(
|
|
805
|
-
if (!
|
|
731
|
+
}, [t, w]), j = ne(() => {
|
|
732
|
+
$();
|
|
733
|
+
}, [$]), v = ne(
|
|
734
|
+
(l) => {
|
|
735
|
+
if (!E)
|
|
806
736
|
return { isValid: !0, errors: [] };
|
|
807
|
-
const
|
|
737
|
+
const x = [];
|
|
808
738
|
try {
|
|
809
|
-
return
|
|
810
|
-
var
|
|
811
|
-
const c =
|
|
812
|
-
if ((
|
|
813
|
-
|
|
739
|
+
return E.properties && Object.entries(E.properties).forEach(([b, d]) => {
|
|
740
|
+
var S;
|
|
741
|
+
const c = l[b];
|
|
742
|
+
if ((S = E.required) != null && S.includes(b) && c == null) {
|
|
743
|
+
x.push(`Field '${b}' is required`);
|
|
814
744
|
return;
|
|
815
745
|
}
|
|
816
746
|
if (c != null) {
|
|
817
747
|
if (d.type) {
|
|
818
|
-
const
|
|
819
|
-
|
|
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`);
|
|
820
750
|
}
|
|
821
|
-
d.minLength !== void 0 && typeof c == "string" && c.length < d.minLength &&
|
|
822
|
-
`Field '${
|
|
823
|
-
), d.maxLength !== void 0 && typeof c == "string" && c.length > d.maxLength &&
|
|
824
|
-
`Field '${
|
|
825
|
-
), d.minimum !== void 0 && typeof c == "number" && c < d.minimum &&
|
|
751
|
+
d.minLength !== void 0 && typeof c == "string" && c.length < d.minLength && x.push(
|
|
752
|
+
`Field '${b}' must be at least ${d.minLength} characters long`
|
|
753
|
+
), d.maxLength !== void 0 && typeof c == "string" && c.length > d.maxLength && x.push(
|
|
754
|
+
`Field '${b}' must be no more than ${d.maxLength} characters long`
|
|
755
|
+
), d.minimum !== void 0 && typeof c == "number" && c < d.minimum && x.push(`Field '${b}' must be at least ${d.minimum}`), d.maximum !== void 0 && typeof c == "number" && c > d.maximum && x.push(`Field '${b}' must be no more than ${d.maximum}`), d.pattern && typeof c == "string" && (new RegExp(d.pattern).test(c) || x.push(`Field '${b}' does not match the required pattern`)), d.enum && !d.enum.includes(c) && x.push(`Field '${b}' must be one of: ${d.enum.join(", ")}`);
|
|
826
756
|
}
|
|
827
757
|
}), {
|
|
828
|
-
isValid:
|
|
829
|
-
errors:
|
|
758
|
+
isValid: x.length === 0,
|
|
759
|
+
errors: x
|
|
830
760
|
};
|
|
831
761
|
} catch {
|
|
832
762
|
return {
|
|
@@ -835,92 +765,84 @@ function xt({ config: i, children: e }) {
|
|
|
835
765
|
};
|
|
836
766
|
}
|
|
837
767
|
},
|
|
838
|
-
[
|
|
768
|
+
[E]
|
|
839
769
|
);
|
|
840
770
|
te(() => {
|
|
841
|
-
!i.initialTenant &&
|
|
842
|
-
}, [i.initialTenant,
|
|
843
|
-
|
|
844
|
-
}, [
|
|
845
|
-
const
|
|
846
|
-
(
|
|
847
|
-
const
|
|
848
|
-
if (
|
|
849
|
-
targetTenantSlug: o,
|
|
850
|
-
currentTenantSlug: p,
|
|
851
|
-
tenantMode: f,
|
|
852
|
-
mode: g
|
|
853
|
-
}), localStorage.setItem("tenant", o), f === "subdomain") {
|
|
771
|
+
!i.initialTenant && g ? w ? V() : q(g) : !i.initialTenant && !g && (T(null), m(null), p(!1));
|
|
772
|
+
}, [i.initialTenant, g, w, q, V]), te(() => {
|
|
773
|
+
w != null && w.id ? $() : (C(null), M(null), P(!1));
|
|
774
|
+
}, [w == null ? void 0 : w.id, $]);
|
|
775
|
+
const I = ne(
|
|
776
|
+
(l, x = "reload") => {
|
|
777
|
+
const b = i.tenantMode || "selector";
|
|
778
|
+
if (localStorage.setItem("tenant", l), b === "subdomain") {
|
|
854
779
|
const d = window.location.hostname, c = d.split(".");
|
|
855
780
|
if (c.length >= 2) {
|
|
856
|
-
c[0] =
|
|
857
|
-
const
|
|
858
|
-
|
|
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;
|
|
859
784
|
} else
|
|
860
785
|
console.warn(
|
|
861
786
|
"[TenantProvider] Cannot switch subdomain, invalid hostname:",
|
|
862
787
|
d
|
|
863
788
|
);
|
|
864
|
-
} else if (
|
|
789
|
+
} else if (b === "selector") {
|
|
865
790
|
const d = new URLSearchParams(window.location.search);
|
|
866
|
-
if (d.set(i.selectorParam || "tenant",
|
|
791
|
+
if (d.set(i.selectorParam || "tenant", l), x === "reload") {
|
|
867
792
|
const c = `${window.location.pathname}?${d.toString()}${window.location.hash}`;
|
|
868
|
-
|
|
793
|
+
window.location.href = c;
|
|
869
794
|
} else {
|
|
870
795
|
const c = `${window.location.pathname}?${d.toString()}${window.location.hash}`;
|
|
871
|
-
|
|
796
|
+
window.history.pushState({}, "", c), y(l), q(l);
|
|
872
797
|
}
|
|
873
798
|
}
|
|
874
799
|
},
|
|
875
|
-
[i.tenantMode, i.selectorParam,
|
|
876
|
-
),
|
|
800
|
+
[i.tenantMode, i.selectorParam, q, g]
|
|
801
|
+
), L = Q(() => ({
|
|
877
802
|
// Tenant info
|
|
878
|
-
tenant:
|
|
879
|
-
tenantSlug:
|
|
880
|
-
isTenantLoading:
|
|
803
|
+
tenant: w,
|
|
804
|
+
tenantSlug: g,
|
|
805
|
+
isTenantLoading: f,
|
|
881
806
|
tenantError: h,
|
|
882
807
|
retryTenant: () => {
|
|
883
|
-
|
|
808
|
+
g && q(g);
|
|
884
809
|
},
|
|
885
810
|
// Settings
|
|
886
|
-
settings:
|
|
887
|
-
settingsSchema:
|
|
888
|
-
isSettingsLoading:
|
|
811
|
+
settings: R,
|
|
812
|
+
settingsSchema: E,
|
|
813
|
+
isSettingsLoading: U,
|
|
889
814
|
settingsError: u,
|
|
890
815
|
// Actions
|
|
891
|
-
refreshSettings:
|
|
892
|
-
switchTenant:
|
|
816
|
+
refreshSettings: j,
|
|
817
|
+
switchTenant: I,
|
|
893
818
|
// Validation
|
|
894
|
-
validateSettings:
|
|
819
|
+
validateSettings: v
|
|
895
820
|
}), [
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
821
|
+
w,
|
|
822
|
+
g,
|
|
823
|
+
f,
|
|
899
824
|
h,
|
|
900
|
-
L,
|
|
901
825
|
R,
|
|
902
|
-
|
|
826
|
+
E,
|
|
827
|
+
U,
|
|
903
828
|
u,
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
829
|
+
j,
|
|
830
|
+
I,
|
|
831
|
+
v
|
|
907
832
|
]);
|
|
908
|
-
|
|
909
|
-
return /* @__PURE__ */ n(N, { children: i.loadingFallback || /* @__PURE__ */ n(Ue, {}) });
|
|
910
|
-
if (h) {
|
|
911
|
-
const o = typeof i.errorFallback == "function" ? i.errorFallback(h, () => H(p || "")) : i.errorFallback || /* @__PURE__ */ n(qe, { error: h, retry: () => H(p || "") });
|
|
912
|
-
return /* @__PURE__ */ n(N, { children: o });
|
|
913
|
-
}
|
|
914
|
-
return /* @__PURE__ */ n(Pe.Provider, { value: E, children: e });
|
|
833
|
+
return /* @__PURE__ */ n(be.Provider, { value: L, children: e });
|
|
915
834
|
}
|
|
916
835
|
function fe() {
|
|
917
|
-
const i =
|
|
836
|
+
const i = ce(be);
|
|
918
837
|
if (!i)
|
|
919
838
|
throw new Error("useTenant must be used within a TenantProvider");
|
|
920
839
|
return i;
|
|
921
840
|
}
|
|
922
|
-
|
|
923
|
-
|
|
841
|
+
function Pe() {
|
|
842
|
+
return ce(be);
|
|
843
|
+
}
|
|
844
|
+
const Tt = fe;
|
|
845
|
+
function Pt() {
|
|
924
846
|
const { settings: i, settingsSchema: e, isSettingsLoading: t, settingsError: r, validateSettings: s } = fe();
|
|
925
847
|
return {
|
|
926
848
|
settings: i,
|
|
@@ -940,51 +862,51 @@ function se() {
|
|
|
940
862
|
retry: s
|
|
941
863
|
};
|
|
942
864
|
}
|
|
943
|
-
const
|
|
944
|
-
function
|
|
945
|
-
const { appId: t, baseUrl: r } =
|
|
946
|
-
tenantSlug:
|
|
865
|
+
const Me = he(null);
|
|
866
|
+
function Mt({ config: i = {}, children: e }) {
|
|
867
|
+
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
|
+
tenantSlug: o,
|
|
947
869
|
// SessionManager will generate storageKey internally
|
|
948
870
|
onRefreshFailed: i.onRefreshFailed,
|
|
949
871
|
baseUrl: r
|
|
950
|
-
}), [
|
|
951
|
-
const
|
|
952
|
-
return
|
|
953
|
-
}, [r, u]),
|
|
954
|
-
const
|
|
872
|
+
}), [o, r, i.onRefreshFailed]), M = Q(() => {
|
|
873
|
+
const x = new re(r);
|
|
874
|
+
return x.setSessionManager(u), x;
|
|
875
|
+
}, [r, u]), E = Q(() => new He(new re(r)), [r]), q = Q(() => new Ne(M, u), [M, u]), V = Q(() => new ve(new re(r)), [r]), $ = Q(() => f || u.getUser(), [f, u]), j = Q(() => $ != null && $.roleId && y.find((x) => x.id === $.roleId) || null, [$, y]), v = Q(() => (j == null ? void 0 : j.permissions) || [], [j]), I = Q(() => u.hasValidSession() && f !== null, [u, f]), L = 5 * 60 * 1e3, l = Q(() => {
|
|
876
|
+
const x = async (F = !1) => {
|
|
955
877
|
try {
|
|
956
878
|
if (!u.hasValidSession())
|
|
957
879
|
return;
|
|
958
|
-
const
|
|
959
|
-
if (
|
|
880
|
+
const N = Date.now();
|
|
881
|
+
if (!F && N - U < L && f)
|
|
960
882
|
return;
|
|
961
|
-
const
|
|
962
|
-
if (!
|
|
883
|
+
const W = u.getUserId();
|
|
884
|
+
if (!W) {
|
|
963
885
|
console.warn("[AuthProvider] No userId available in token or storage");
|
|
964
886
|
return;
|
|
965
887
|
}
|
|
966
|
-
|
|
967
|
-
const X = await
|
|
968
|
-
|
|
969
|
-
} catch (
|
|
970
|
-
const
|
|
971
|
-
C(
|
|
888
|
+
m(!0), C(null);
|
|
889
|
+
const X = await q.getUserById(W);
|
|
890
|
+
p(X), u.setUser(X), P(Date.now());
|
|
891
|
+
} 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:", _);
|
|
972
894
|
} finally {
|
|
973
|
-
|
|
895
|
+
m(!1);
|
|
974
896
|
}
|
|
975
|
-
},
|
|
976
|
-
await
|
|
977
|
-
}, d = async (
|
|
978
|
-
const { username:
|
|
979
|
-
let X = s == null ? void 0 : s.id, Y =
|
|
980
|
-
|
|
981
|
-
const J = await
|
|
982
|
-
username:
|
|
983
|
-
password:
|
|
897
|
+
}, b = async () => {
|
|
898
|
+
await x();
|
|
899
|
+
}, d = async (F) => {
|
|
900
|
+
const { username: N, password: _, tenantSlug: W } = F;
|
|
901
|
+
let X = s == null ? void 0 : s.id, Y = o, Z = u;
|
|
902
|
+
W && (X = (await new ue(M, t).getPublicTenantInfo(W)).id, Y = W);
|
|
903
|
+
const J = await E.login({
|
|
904
|
+
username: N,
|
|
905
|
+
password: _,
|
|
984
906
|
appId: t,
|
|
985
907
|
tenantId: X
|
|
986
|
-
}),
|
|
987
|
-
if (
|
|
908
|
+
}), le = W && W !== o;
|
|
909
|
+
if (le && (Z = new ye({
|
|
988
910
|
tenantSlug: Y,
|
|
989
911
|
baseUrl: r
|
|
990
912
|
})), Z.setTokens({
|
|
@@ -992,79 +914,79 @@ function Pt({ config: i = {}, children: e }) {
|
|
|
992
914
|
refreshToken: J.refreshToken,
|
|
993
915
|
expiresIn: J.expiresIn
|
|
994
916
|
}), J.user) {
|
|
995
|
-
Z.setUser(J.user),
|
|
917
|
+
Z.setUser(J.user), p(J.user);
|
|
996
918
|
try {
|
|
997
|
-
await
|
|
998
|
-
} catch (
|
|
999
|
-
console.warn("Failed to load complete user data after login:",
|
|
919
|
+
await x();
|
|
920
|
+
} catch (de) {
|
|
921
|
+
console.warn("Failed to load complete user data after login:", de);
|
|
1000
922
|
}
|
|
1001
923
|
}
|
|
1002
|
-
return
|
|
1003
|
-
}, c = async (
|
|
1004
|
-
const { email:
|
|
1005
|
-
if (!
|
|
924
|
+
return le && Y && Y !== o && g(Y), J;
|
|
925
|
+
}, c = async (F) => {
|
|
926
|
+
const { email: N, phoneNumber: _, name: W, password: X, lastName: Y, tenantId: Z } = F;
|
|
927
|
+
if (!N && !_)
|
|
1006
928
|
throw new Error("Either email or phoneNumber is required");
|
|
1007
|
-
if (!
|
|
929
|
+
if (!W || !X)
|
|
1008
930
|
throw new Error("Name and password are required");
|
|
1009
931
|
const J = Z ?? (s == null ? void 0 : s.id);
|
|
1010
|
-
return await
|
|
1011
|
-
email:
|
|
1012
|
-
phoneNumber:
|
|
1013
|
-
name:
|
|
932
|
+
return await E.signup({
|
|
933
|
+
email: N,
|
|
934
|
+
phoneNumber: _,
|
|
935
|
+
name: W,
|
|
1014
936
|
password: X,
|
|
1015
937
|
tenantId: J,
|
|
1016
938
|
lastName: Y,
|
|
1017
939
|
appId: t
|
|
1018
940
|
});
|
|
1019
|
-
},
|
|
1020
|
-
const { email:
|
|
1021
|
-
if (!
|
|
941
|
+
}, S = async (F) => {
|
|
942
|
+
const { email: N, phoneNumber: _, name: W, password: X, tenantName: Y, lastName: Z } = F;
|
|
943
|
+
if (!N && !_)
|
|
1022
944
|
throw new Error("Either email or phoneNumber is required");
|
|
1023
|
-
if (!
|
|
945
|
+
if (!W || !X || !Y)
|
|
1024
946
|
throw new Error("Name, password, and tenantName are required");
|
|
1025
|
-
return await
|
|
1026
|
-
email:
|
|
1027
|
-
phoneNumber:
|
|
1028
|
-
name:
|
|
947
|
+
return await E.signupTenantAdmin({
|
|
948
|
+
email: N,
|
|
949
|
+
phoneNumber: _,
|
|
950
|
+
name: W,
|
|
1029
951
|
password: X,
|
|
1030
952
|
tenantName: Y,
|
|
1031
953
|
appId: t,
|
|
1032
954
|
lastName: Z
|
|
1033
955
|
});
|
|
1034
|
-
},
|
|
1035
|
-
const { currentPassword:
|
|
1036
|
-
await
|
|
1037
|
-
}, ee = async (
|
|
1038
|
-
const { email:
|
|
1039
|
-
if (!
|
|
956
|
+
}, G = async (F) => {
|
|
957
|
+
const { currentPassword: N, newPassword: _ } = F, W = await u.getAuthHeaders();
|
|
958
|
+
await E.changePassword({ currentPassword: N, newPassword: _ }, W);
|
|
959
|
+
}, ee = async (F) => {
|
|
960
|
+
const { email: N, tenantId: _ } = F, W = _ ?? (s == null ? void 0 : s.id);
|
|
961
|
+
if (!W)
|
|
1040
962
|
throw new Error("tenantId is required for password reset");
|
|
1041
|
-
await
|
|
1042
|
-
}, z = async (
|
|
1043
|
-
const { token:
|
|
1044
|
-
await
|
|
1045
|
-
},
|
|
1046
|
-
const { email:
|
|
963
|
+
await E.requestPasswordReset({ email: N, tenantId: W });
|
|
964
|
+
}, z = async (F) => {
|
|
965
|
+
const { token: N, newPassword: _ } = F;
|
|
966
|
+
await E.confirmPasswordReset({ token: N, newPassword: _ });
|
|
967
|
+
}, H = async (F) => {
|
|
968
|
+
const { email: N, frontendUrl: _, name: W, lastName: X, tenantId: Y } = F, Z = Y ?? (s == null ? void 0 : s.id);
|
|
1047
969
|
if (!Z)
|
|
1048
970
|
throw new Error("tenantId is required for magic link authentication");
|
|
1049
|
-
return await
|
|
1050
|
-
email:
|
|
971
|
+
return await E.sendMagicLink({
|
|
972
|
+
email: N,
|
|
1051
973
|
tenantId: Z,
|
|
1052
|
-
frontendUrl:
|
|
1053
|
-
name:
|
|
974
|
+
frontendUrl: _,
|
|
975
|
+
name: W,
|
|
1054
976
|
lastName: X,
|
|
1055
977
|
appId: t
|
|
1056
978
|
});
|
|
1057
|
-
}, O = async (
|
|
1058
|
-
const { token:
|
|
1059
|
-
let X = s == null ? void 0 : s.id, Y =
|
|
1060
|
-
|
|
1061
|
-
const J = await
|
|
1062
|
-
token:
|
|
1063
|
-
email:
|
|
979
|
+
}, O = async (F) => {
|
|
980
|
+
const { token: N, email: _, tenantSlug: W } = F;
|
|
981
|
+
let X = s == null ? void 0 : s.id, Y = o, Z = u;
|
|
982
|
+
W && (X = (await new ue(M, t).getPublicTenantInfo(W)).id, Y = W);
|
|
983
|
+
const J = await E.verifyMagicLink({
|
|
984
|
+
token: N,
|
|
985
|
+
email: _,
|
|
1064
986
|
appId: t,
|
|
1065
987
|
tenantId: X
|
|
1066
|
-
}),
|
|
1067
|
-
if (
|
|
988
|
+
}), le = W && W !== o;
|
|
989
|
+
if (le && (Z = new ye({
|
|
1068
990
|
tenantSlug: Y,
|
|
1069
991
|
baseUrl: r
|
|
1070
992
|
})), Z.setTokens({
|
|
@@ -1072,136 +994,136 @@ function Pt({ config: i = {}, children: e }) {
|
|
|
1072
994
|
refreshToken: J.refreshToken,
|
|
1073
995
|
expiresIn: J.expiresIn
|
|
1074
996
|
}), J.user) {
|
|
1075
|
-
Z.setUser(J.user),
|
|
997
|
+
Z.setUser(J.user), p(J.user);
|
|
1076
998
|
try {
|
|
1077
|
-
await
|
|
1078
|
-
} catch (
|
|
1079
|
-
console.warn("Failed to load complete user data after magic link login:",
|
|
999
|
+
await x();
|
|
1000
|
+
} catch (de) {
|
|
1001
|
+
console.warn("Failed to load complete user data after magic link login:", de);
|
|
1080
1002
|
}
|
|
1081
1003
|
}
|
|
1082
|
-
return
|
|
1004
|
+
return le && Y && Y !== o && g(Y), J;
|
|
1083
1005
|
}, D = async () => {
|
|
1084
|
-
const
|
|
1085
|
-
if (!(
|
|
1006
|
+
const F = u.getTokens();
|
|
1007
|
+
if (!(F != null && F.refreshToken))
|
|
1086
1008
|
throw new Error("No refresh token available");
|
|
1087
|
-
const
|
|
1088
|
-
refreshToken:
|
|
1009
|
+
const N = await E.refreshToken({
|
|
1010
|
+
refreshToken: F.refreshToken
|
|
1089
1011
|
});
|
|
1090
1012
|
u.setTokens({
|
|
1091
|
-
accessToken:
|
|
1092
|
-
refreshToken:
|
|
1093
|
-
expiresIn:
|
|
1013
|
+
accessToken: N.accessToken,
|
|
1014
|
+
refreshToken: N.refreshToken || F.refreshToken,
|
|
1015
|
+
expiresIn: N.expiresIn
|
|
1094
1016
|
});
|
|
1095
|
-
},
|
|
1096
|
-
u.clearSession(),
|
|
1097
|
-
}, ge = (
|
|
1098
|
-
u.setTokens(
|
|
1017
|
+
}, K = () => {
|
|
1018
|
+
u.clearSession(), p(null), C(null);
|
|
1019
|
+
}, ge = (F) => {
|
|
1020
|
+
u.setTokens(F);
|
|
1099
1021
|
}, Re = () => u.hasValidSession(), Ce = () => {
|
|
1100
|
-
u.clearSession(),
|
|
1101
|
-
},
|
|
1022
|
+
u.clearSession(), p(null), C(null);
|
|
1023
|
+
}, $e = async () => {
|
|
1102
1024
|
if (t)
|
|
1103
1025
|
try {
|
|
1104
|
-
|
|
1105
|
-
const { roles:
|
|
1106
|
-
A(
|
|
1107
|
-
} catch (
|
|
1108
|
-
console.error("Failed to fetch roles:",
|
|
1026
|
+
T(!0);
|
|
1027
|
+
const { roles: F } = await V.getRolesByApp(t);
|
|
1028
|
+
A(F);
|
|
1029
|
+
} catch (F) {
|
|
1030
|
+
console.error("Failed to fetch roles:", F);
|
|
1109
1031
|
} finally {
|
|
1110
|
-
|
|
1032
|
+
T(!1);
|
|
1111
1033
|
}
|
|
1112
1034
|
}, Fe = async () => {
|
|
1113
|
-
await
|
|
1114
|
-
}, me = (
|
|
1115
|
-
if (!
|
|
1035
|
+
await $e();
|
|
1036
|
+
}, me = (F) => {
|
|
1037
|
+
if (!v || v.length === 0)
|
|
1116
1038
|
return !1;
|
|
1117
|
-
if (typeof
|
|
1118
|
-
return
|
|
1119
|
-
const
|
|
1120
|
-
return
|
|
1039
|
+
if (typeof F == "string")
|
|
1040
|
+
return v.includes(F);
|
|
1041
|
+
const N = `${F.resource}.${F.action}`;
|
|
1042
|
+
return v.includes(N);
|
|
1121
1043
|
};
|
|
1122
1044
|
return {
|
|
1123
1045
|
// RFC-003: Authentication state
|
|
1124
|
-
isAuthenticated:
|
|
1046
|
+
isAuthenticated: I,
|
|
1125
1047
|
sessionManager: u,
|
|
1126
|
-
authenticatedHttpService:
|
|
1048
|
+
authenticatedHttpService: M,
|
|
1127
1049
|
login: d,
|
|
1128
1050
|
signup: c,
|
|
1129
|
-
signupTenantAdmin:
|
|
1130
|
-
sendMagicLink:
|
|
1051
|
+
signupTenantAdmin: S,
|
|
1052
|
+
sendMagicLink: H,
|
|
1131
1053
|
verifyMagicLink: O,
|
|
1132
|
-
changePassword:
|
|
1054
|
+
changePassword: G,
|
|
1133
1055
|
requestPasswordReset: ee,
|
|
1134
1056
|
confirmPasswordReset: z,
|
|
1135
1057
|
refreshToken: D,
|
|
1136
|
-
logout:
|
|
1058
|
+
logout: K,
|
|
1137
1059
|
setTokens: ge,
|
|
1138
1060
|
hasValidSession: Re,
|
|
1139
1061
|
clearSession: Ce,
|
|
1140
|
-
currentUser:
|
|
1062
|
+
currentUser: f,
|
|
1141
1063
|
isUserLoading: h,
|
|
1142
|
-
userError:
|
|
1143
|
-
loadUserData:
|
|
1144
|
-
refreshUser:
|
|
1145
|
-
userRole:
|
|
1146
|
-
userPermissions:
|
|
1147
|
-
availableRoles:
|
|
1148
|
-
rolesLoading:
|
|
1064
|
+
userError: R,
|
|
1065
|
+
loadUserData: x,
|
|
1066
|
+
refreshUser: b,
|
|
1067
|
+
userRole: j,
|
|
1068
|
+
userPermissions: v,
|
|
1069
|
+
availableRoles: y,
|
|
1070
|
+
rolesLoading: w,
|
|
1149
1071
|
hasPermission: me,
|
|
1150
|
-
hasAnyPermission: (
|
|
1151
|
-
hasAllPermissions: (
|
|
1152
|
-
getUserPermissionStrings: () =>
|
|
1072
|
+
hasAnyPermission: (F) => F.some((N) => me(N)),
|
|
1073
|
+
hasAllPermissions: (F) => F.every((N) => me(N)),
|
|
1074
|
+
getUserPermissionStrings: () => v || [],
|
|
1153
1075
|
refreshRoles: Fe
|
|
1154
1076
|
};
|
|
1155
1077
|
}, [
|
|
1156
|
-
|
|
1078
|
+
I,
|
|
1157
1079
|
u,
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1080
|
+
M,
|
|
1081
|
+
E,
|
|
1082
|
+
q,
|
|
1083
|
+
V,
|
|
1162
1084
|
t,
|
|
1163
1085
|
s,
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1086
|
+
o,
|
|
1087
|
+
g,
|
|
1088
|
+
y,
|
|
1089
|
+
f,
|
|
1168
1090
|
h,
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1091
|
+
R,
|
|
1092
|
+
j,
|
|
1093
|
+
v,
|
|
1094
|
+
U,
|
|
1095
|
+
L
|
|
1174
1096
|
]);
|
|
1175
1097
|
return te(() => {
|
|
1176
1098
|
!i.initialRoles && t && (async () => {
|
|
1177
1099
|
try {
|
|
1178
|
-
|
|
1179
|
-
const
|
|
1100
|
+
T(!0);
|
|
1101
|
+
const b = new re(r), d = new ve(b), { roles: c } = await d.getRolesByApp(t);
|
|
1180
1102
|
A(c);
|
|
1181
|
-
} catch (
|
|
1182
|
-
console.error("Failed to fetch roles:",
|
|
1103
|
+
} catch (b) {
|
|
1104
|
+
console.error("Failed to fetch roles:", b);
|
|
1183
1105
|
} finally {
|
|
1184
|
-
|
|
1106
|
+
T(!1);
|
|
1185
1107
|
}
|
|
1186
1108
|
})();
|
|
1187
1109
|
}, [t, r, i.initialRoles]), te(() => {
|
|
1188
|
-
const
|
|
1189
|
-
|
|
1110
|
+
const x = u.getUser();
|
|
1111
|
+
x && u.hasValidSession() && p(x);
|
|
1190
1112
|
}, [u]), te(() => {
|
|
1191
|
-
!
|
|
1113
|
+
!f && !h && l.loadUserData().catch(() => {
|
|
1192
1114
|
});
|
|
1193
|
-
}, [
|
|
1194
|
-
if (!u.hasValidSession() || !
|
|
1115
|
+
}, [f, h, l]), te(() => {
|
|
1116
|
+
if (!u.hasValidSession() || !f)
|
|
1195
1117
|
return;
|
|
1196
|
-
const
|
|
1197
|
-
|
|
1118
|
+
const x = setInterval(() => {
|
|
1119
|
+
l.loadUserData().catch(() => {
|
|
1198
1120
|
});
|
|
1199
|
-
},
|
|
1200
|
-
return () => clearInterval(
|
|
1201
|
-
}, [u,
|
|
1121
|
+
}, L);
|
|
1122
|
+
return () => clearInterval(x);
|
|
1123
|
+
}, [u, f, l, L]), /* @__PURE__ */ n(Me.Provider, { value: l, children: e });
|
|
1202
1124
|
}
|
|
1203
|
-
function
|
|
1204
|
-
const i =
|
|
1125
|
+
function ae() {
|
|
1126
|
+
const i = ce(Me);
|
|
1205
1127
|
if (!i)
|
|
1206
1128
|
throw new Error("useAuth must be used within an AuthProvider");
|
|
1207
1129
|
return i;
|
|
@@ -1227,12 +1149,12 @@ class ze {
|
|
|
1227
1149
|
throw new Error("SessionManager is required for private endpoints");
|
|
1228
1150
|
const t = await this.sessionManager.getAuthHeaders(), r = new URLSearchParams();
|
|
1229
1151
|
e != null && e.page && r.append("page", e.page.toString()), e != null && e.limit && r.append("limit", e.limit.toString()), e != null && e.sortBy && r.append("sortBy", e.sortBy), e != null && e.sortOrder && r.append("sortOrder", e.sortOrder);
|
|
1230
|
-
const s = `/feature-flags/${r.toString() ? `?${r.toString()}` : ""}`,
|
|
1152
|
+
const s = `/feature-flags/${r.toString() ? `?${r.toString()}` : ""}`, o = await this.httpService.get(s, {
|
|
1231
1153
|
headers: t
|
|
1232
1154
|
});
|
|
1233
1155
|
return {
|
|
1234
|
-
featureFlags:
|
|
1235
|
-
meta:
|
|
1156
|
+
featureFlags: o.data,
|
|
1157
|
+
meta: o.meta
|
|
1236
1158
|
};
|
|
1237
1159
|
}
|
|
1238
1160
|
async getFeatureFlagById(e) {
|
|
@@ -1280,64 +1202,64 @@ class ze {
|
|
|
1280
1202
|
throw new Error("Flag Key, Tenant ID and App ID are required");
|
|
1281
1203
|
const s = new URLSearchParams();
|
|
1282
1204
|
s.append("tenantId", t), s.append("appId", r);
|
|
1283
|
-
const
|
|
1284
|
-
return (await this.httpService.get(
|
|
1205
|
+
const o = `/tenant-feature-flags/${e}${s.toString() ? `?${s.toString()}` : ""}`;
|
|
1206
|
+
return (await this.httpService.get(o, {
|
|
1285
1207
|
headers: { "X-Tenant-ID": t }
|
|
1286
1208
|
})).data;
|
|
1287
1209
|
}
|
|
1288
1210
|
}
|
|
1289
|
-
const
|
|
1290
|
-
function
|
|
1291
|
-
const { baseUrl: t, appId: r } =
|
|
1292
|
-
const
|
|
1293
|
-
return new ze(
|
|
1294
|
-
}, [t]),
|
|
1211
|
+
const Ie = he(null);
|
|
1212
|
+
function It({ config: i = {}, children: e }) {
|
|
1213
|
+
const { baseUrl: t, appId: r } = oe(), { tenant: s } = se(), [o, g] = k([]), [y, A] = k(!1), [w, T] = k(null), f = Q(() => {
|
|
1214
|
+
const m = new re(t);
|
|
1215
|
+
return new ze(m);
|
|
1216
|
+
}, [t]), p = async () => {
|
|
1295
1217
|
if (!(s != null && s.id)) {
|
|
1296
|
-
|
|
1218
|
+
g([]);
|
|
1297
1219
|
return;
|
|
1298
1220
|
}
|
|
1299
|
-
A(!0),
|
|
1221
|
+
A(!0), T(null);
|
|
1300
1222
|
try {
|
|
1301
|
-
const
|
|
1302
|
-
|
|
1303
|
-
} catch (
|
|
1304
|
-
const
|
|
1305
|
-
|
|
1223
|
+
const m = await f.getTenantFeatureFlags(s.id, r);
|
|
1224
|
+
g(m);
|
|
1225
|
+
} catch (m) {
|
|
1226
|
+
const R = m instanceof Error ? m.message : "Failed to fetch feature flags";
|
|
1227
|
+
T(R), i.onError && i.onError(m instanceof Error ? m : new Error(R));
|
|
1306
1228
|
} finally {
|
|
1307
1229
|
A(!1);
|
|
1308
1230
|
}
|
|
1309
1231
|
};
|
|
1310
1232
|
te(() => {
|
|
1311
|
-
|
|
1312
|
-
const
|
|
1313
|
-
return () => clearInterval(
|
|
1233
|
+
p();
|
|
1234
|
+
const m = i.refreshInterval || 5 * 60 * 1e3, R = setInterval(p, m);
|
|
1235
|
+
return () => clearInterval(R);
|
|
1314
1236
|
}, [s == null ? void 0 : s.id, i.refreshInterval]);
|
|
1315
1237
|
const h = Q(() => ({
|
|
1316
|
-
featureFlags:
|
|
1317
|
-
loading:
|
|
1318
|
-
error:
|
|
1319
|
-
isEnabled: (
|
|
1320
|
-
const u =
|
|
1238
|
+
featureFlags: o,
|
|
1239
|
+
loading: y,
|
|
1240
|
+
error: w,
|
|
1241
|
+
isEnabled: (P) => {
|
|
1242
|
+
const u = o.find((M) => M.key === P);
|
|
1321
1243
|
return (u == null ? void 0 : u.value) === !0;
|
|
1322
1244
|
},
|
|
1323
|
-
getFlag: (
|
|
1324
|
-
getFlagState: (
|
|
1325
|
-
const u =
|
|
1245
|
+
getFlag: (P) => o.find((u) => u.key === P),
|
|
1246
|
+
getFlagState: (P) => {
|
|
1247
|
+
const u = o.find((M) => M.key === P);
|
|
1326
1248
|
return u ? u.value ? "enabled" : "disabled" : "not_found";
|
|
1327
1249
|
},
|
|
1328
1250
|
refresh: async () => {
|
|
1329
|
-
await
|
|
1251
|
+
await p();
|
|
1330
1252
|
}
|
|
1331
|
-
}), [
|
|
1332
|
-
return /* @__PURE__ */ n(
|
|
1253
|
+
}), [o, y, w]);
|
|
1254
|
+
return /* @__PURE__ */ n(Ie.Provider, { value: h, children: e });
|
|
1333
1255
|
}
|
|
1334
1256
|
function Oe() {
|
|
1335
|
-
const i =
|
|
1257
|
+
const i = ce(Ie);
|
|
1336
1258
|
if (!i)
|
|
1337
1259
|
throw new Error("useFeatureFlags must be used within a FeatureFlagProvider");
|
|
1338
1260
|
return i;
|
|
1339
1261
|
}
|
|
1340
|
-
class
|
|
1262
|
+
class We {
|
|
1341
1263
|
constructor(e, t) {
|
|
1342
1264
|
this.httpService = e, this.sessionManager = t;
|
|
1343
1265
|
}
|
|
@@ -1403,64 +1325,64 @@ class je {
|
|
|
1403
1325
|
)).data;
|
|
1404
1326
|
}
|
|
1405
1327
|
}
|
|
1406
|
-
const
|
|
1407
|
-
function
|
|
1408
|
-
const { baseUrl: t } =
|
|
1328
|
+
const Le = he(void 0);
|
|
1329
|
+
function Lt({ config: i = {}, children: e }) {
|
|
1330
|
+
const { baseUrl: t } = oe(), { tenant: r } = se(), [s, o] = k(null), [g, y] = k(!1), [A, w] = k(null), T = Q(() => {
|
|
1409
1331
|
const h = new re(t);
|
|
1410
|
-
return new
|
|
1411
|
-
}, [t]),
|
|
1332
|
+
return new We(h);
|
|
1333
|
+
}, [t]), f = async () => {
|
|
1412
1334
|
if (!(r != null && r.id)) {
|
|
1413
|
-
|
|
1335
|
+
o(null);
|
|
1414
1336
|
return;
|
|
1415
1337
|
}
|
|
1416
|
-
|
|
1338
|
+
y(!0), w(null);
|
|
1417
1339
|
try {
|
|
1418
|
-
const h = await
|
|
1419
|
-
|
|
1340
|
+
const h = await T.getTenantSubscriptionFeatures(r.id);
|
|
1341
|
+
o(h);
|
|
1420
1342
|
} catch (h) {
|
|
1421
|
-
const
|
|
1422
|
-
|
|
1343
|
+
const m = h instanceof Error ? h.message : "Failed to fetch subscription";
|
|
1344
|
+
w(m), i.onError && i.onError(h instanceof Error ? h : new Error(m));
|
|
1423
1345
|
} finally {
|
|
1424
|
-
|
|
1346
|
+
y(!1);
|
|
1425
1347
|
}
|
|
1426
1348
|
};
|
|
1427
1349
|
te(() => {
|
|
1428
|
-
if (
|
|
1429
|
-
const h = i.refreshInterval || 10 * 60 * 1e3,
|
|
1430
|
-
return () => clearInterval(
|
|
1350
|
+
if (f(), !i.refreshInterval) return;
|
|
1351
|
+
const h = i.refreshInterval || 10 * 60 * 1e3, m = setInterval(f, h);
|
|
1352
|
+
return () => clearInterval(m);
|
|
1431
1353
|
}, [r == null ? void 0 : r.id, i.refreshInterval]);
|
|
1432
|
-
const
|
|
1354
|
+
const p = Q(() => {
|
|
1433
1355
|
const h = (s == null ? void 0 : s.features) || [];
|
|
1434
1356
|
return {
|
|
1435
1357
|
subscription: s,
|
|
1436
1358
|
features: h,
|
|
1437
|
-
loading:
|
|
1359
|
+
loading: g,
|
|
1438
1360
|
error: A,
|
|
1439
1361
|
isFeatureEnabled: (u) => {
|
|
1440
|
-
const
|
|
1441
|
-
return
|
|
1362
|
+
const M = h.find((E) => E.key === u);
|
|
1363
|
+
return M ? M.type === "BOOLEAN" || M.type === "boolean" ? M.value === !0 : !!M.value : !1;
|
|
1442
1364
|
},
|
|
1443
|
-
getFeature: (u) => h.find((
|
|
1444
|
-
getFeatureValue: (u,
|
|
1445
|
-
const
|
|
1446
|
-
return
|
|
1365
|
+
getFeature: (u) => h.find((M) => M.key === u),
|
|
1366
|
+
getFeatureValue: (u, M) => {
|
|
1367
|
+
const E = h.find((q) => q.key === u);
|
|
1368
|
+
return E ? E.value : M;
|
|
1447
1369
|
},
|
|
1448
1370
|
hasAllowedPlan: (u) => !s || !s.isActive ? !1 : u.includes(s.planId),
|
|
1449
1371
|
refresh: async () => {
|
|
1450
|
-
await
|
|
1372
|
+
await f();
|
|
1451
1373
|
}
|
|
1452
1374
|
};
|
|
1453
|
-
}, [s,
|
|
1454
|
-
return /* @__PURE__ */ n(
|
|
1375
|
+
}, [s, g, A]);
|
|
1376
|
+
return /* @__PURE__ */ n(Le.Provider, { value: p, children: e });
|
|
1455
1377
|
}
|
|
1456
|
-
function
|
|
1457
|
-
const i =
|
|
1378
|
+
function je() {
|
|
1379
|
+
const i = ce(Le);
|
|
1458
1380
|
if (i === void 0)
|
|
1459
1381
|
throw new Error("useSubscription must be used within a SubscriptionProvider");
|
|
1460
1382
|
return i;
|
|
1461
1383
|
}
|
|
1462
1384
|
var ie = /* @__PURE__ */ ((i) => (i.SUPERUSER = "SUPERUSER", i.TENANT_ADMIN = "TENANT_ADMIN", i.USER = "USER", i))(ie || {});
|
|
1463
|
-
const
|
|
1385
|
+
const xe = () => /* @__PURE__ */ a(
|
|
1464
1386
|
"div",
|
|
1465
1387
|
{
|
|
1466
1388
|
style: {
|
|
@@ -1497,11 +1419,11 @@ const ve = () => /* @__PURE__ */ l(
|
|
|
1497
1419
|
)
|
|
1498
1420
|
]
|
|
1499
1421
|
}
|
|
1500
|
-
),
|
|
1422
|
+
), ke = ({
|
|
1501
1423
|
userType: i,
|
|
1502
1424
|
minUserType: e,
|
|
1503
1425
|
missingPermissions: t
|
|
1504
|
-
}) => /* @__PURE__ */
|
|
1426
|
+
}) => /* @__PURE__ */ a(
|
|
1505
1427
|
"div",
|
|
1506
1428
|
{
|
|
1507
1429
|
style: {
|
|
@@ -1519,26 +1441,26 @@ const ve = () => /* @__PURE__ */ l(
|
|
|
1519
1441
|
children: [
|
|
1520
1442
|
/* @__PURE__ */ n("div", { style: { fontSize: "2rem", marginBottom: "10px" }, children: "⚠️" }),
|
|
1521
1443
|
/* @__PURE__ */ n("h3", { style: { color: "#856404", marginBottom: "10px" }, children: "Insufficient Permissions" }),
|
|
1522
|
-
e && i ? /* @__PURE__ */
|
|
1523
|
-
/* @__PURE__ */
|
|
1444
|
+
e && i ? /* @__PURE__ */ a(B, { children: [
|
|
1445
|
+
/* @__PURE__ */ a("p", { style: { color: "#856404", fontSize: "14px", marginBottom: "10px" }, children: [
|
|
1524
1446
|
"This content requires ",
|
|
1525
1447
|
/* @__PURE__ */ n("strong", { children: e }),
|
|
1526
1448
|
" access level or higher."
|
|
1527
1449
|
] }),
|
|
1528
|
-
/* @__PURE__ */
|
|
1450
|
+
/* @__PURE__ */ a("p", { style: { color: "#6c757d", fontSize: "12px" }, children: [
|
|
1529
1451
|
"Your current access level: ",
|
|
1530
1452
|
/* @__PURE__ */ n("strong", { children: i })
|
|
1531
1453
|
] })
|
|
1532
|
-
] }) : /* @__PURE__ */
|
|
1454
|
+
] }) : /* @__PURE__ */ a(B, { children: [
|
|
1533
1455
|
/* @__PURE__ */ n("p", { style: { color: "#856404", fontSize: "14px", marginBottom: "10px" }, children: "You don't have the required permissions to view this content." }),
|
|
1534
|
-
t && t.length > 0 && /* @__PURE__ */
|
|
1456
|
+
t && t.length > 0 && /* @__PURE__ */ a("p", { style: { color: "#6c757d", fontSize: "12px" }, children: [
|
|
1535
1457
|
"Required permissions: ",
|
|
1536
1458
|
/* @__PURE__ */ n("strong", { children: t.join(", ") })
|
|
1537
1459
|
] })
|
|
1538
1460
|
] })
|
|
1539
1461
|
]
|
|
1540
1462
|
}
|
|
1541
|
-
),
|
|
1463
|
+
), Ve = (i, e) => {
|
|
1542
1464
|
const t = {
|
|
1543
1465
|
[ie.USER]: 1,
|
|
1544
1466
|
[ie.TENANT_ADMIN]: 2,
|
|
@@ -1546,26 +1468,26 @@ const ve = () => /* @__PURE__ */ l(
|
|
|
1546
1468
|
};
|
|
1547
1469
|
return t[i] >= t[e];
|
|
1548
1470
|
};
|
|
1549
|
-
function
|
|
1471
|
+
function Et({
|
|
1550
1472
|
children: i,
|
|
1551
1473
|
fallback: e,
|
|
1552
1474
|
minUserType: t,
|
|
1553
1475
|
requiredPermissions: r,
|
|
1554
1476
|
requireAllPermissions: s = !1
|
|
1555
1477
|
}) {
|
|
1556
|
-
const { hasValidSession:
|
|
1557
|
-
if (!
|
|
1558
|
-
return /* @__PURE__ */ n(
|
|
1559
|
-
const
|
|
1560
|
-
if (!
|
|
1561
|
-
return /* @__PURE__ */ n(
|
|
1562
|
-
if (t && !
|
|
1563
|
-
return /* @__PURE__ */ n(
|
|
1564
|
-
if (r && r.length > 0 && !(s ?
|
|
1565
|
-
const
|
|
1566
|
-
return /* @__PURE__ */ n(
|
|
1567
|
-
}
|
|
1568
|
-
return /* @__PURE__ */ n(
|
|
1478
|
+
const { hasValidSession: o, sessionManager: g, hasPermission: y, hasAnyPermission: A, hasAllPermissions: w } = ae();
|
|
1479
|
+
if (!o())
|
|
1480
|
+
return /* @__PURE__ */ n(B, { children: e || /* @__PURE__ */ n(xe, {}) });
|
|
1481
|
+
const T = g.getUser();
|
|
1482
|
+
if (!T)
|
|
1483
|
+
return /* @__PURE__ */ n(B, { children: e || /* @__PURE__ */ n(xe, {}) });
|
|
1484
|
+
if (t && !Ve(T.userType, t))
|
|
1485
|
+
return /* @__PURE__ */ n(ke, { userType: T.userType, minUserType: t });
|
|
1486
|
+
if (r && r.length > 0 && !(s ? w(r) : A(r))) {
|
|
1487
|
+
const p = r.filter((h) => !y(h)).map((h) => typeof h == "string" ? h : h.name);
|
|
1488
|
+
return /* @__PURE__ */ n(ke, { missingPermissions: p });
|
|
1489
|
+
}
|
|
1490
|
+
return /* @__PURE__ */ n(B, { children: i });
|
|
1569
1491
|
}
|
|
1570
1492
|
const Ge = ({ redirectPath: i }) => /* @__PURE__ */ n(
|
|
1571
1493
|
"div",
|
|
@@ -1580,7 +1502,7 @@ const Ge = ({ redirectPath: i }) => /* @__PURE__ */ n(
|
|
|
1580
1502
|
backgroundColor: "#f9fafb",
|
|
1581
1503
|
textAlign: "center"
|
|
1582
1504
|
},
|
|
1583
|
-
children: /* @__PURE__ */
|
|
1505
|
+
children: /* @__PURE__ */ a(
|
|
1584
1506
|
"div",
|
|
1585
1507
|
{
|
|
1586
1508
|
style: {
|
|
@@ -1594,7 +1516,7 @@ const Ge = ({ redirectPath: i }) => /* @__PURE__ */ n(
|
|
|
1594
1516
|
/* @__PURE__ */ n("div", { style: { fontSize: "3rem", marginBottom: "1rem" }, children: "🔒" }),
|
|
1595
1517
|
/* @__PURE__ */ n("h2", { style: { color: "#374151", marginBottom: "1rem" }, children: "Access Required" }),
|
|
1596
1518
|
/* @__PURE__ */ n("p", { style: { color: "#6b7280", marginBottom: "1.5rem" }, children: "You need to be signed in to access this page." }),
|
|
1597
|
-
/* @__PURE__ */
|
|
1519
|
+
/* @__PURE__ */ a("p", { style: { fontSize: "0.875rem", color: "#9ca3af" }, children: [
|
|
1598
1520
|
"Redirecting to ",
|
|
1599
1521
|
i,
|
|
1600
1522
|
"..."
|
|
@@ -1603,7 +1525,7 @@ const Ge = ({ redirectPath: i }) => /* @__PURE__ */ n(
|
|
|
1603
1525
|
}
|
|
1604
1526
|
)
|
|
1605
1527
|
}
|
|
1606
|
-
),
|
|
1528
|
+
), Ae = ({
|
|
1607
1529
|
userType: i,
|
|
1608
1530
|
minUserType: e,
|
|
1609
1531
|
missingPermissions: t
|
|
@@ -1620,7 +1542,7 @@ const Ge = ({ redirectPath: i }) => /* @__PURE__ */ n(
|
|
|
1620
1542
|
backgroundColor: "#f9fafb",
|
|
1621
1543
|
textAlign: "center"
|
|
1622
1544
|
},
|
|
1623
|
-
children: /* @__PURE__ */
|
|
1545
|
+
children: /* @__PURE__ */ a(
|
|
1624
1546
|
"div",
|
|
1625
1547
|
{
|
|
1626
1548
|
style: {
|
|
@@ -1633,19 +1555,19 @@ const Ge = ({ redirectPath: i }) => /* @__PURE__ */ n(
|
|
|
1633
1555
|
children: [
|
|
1634
1556
|
/* @__PURE__ */ n("div", { style: { fontSize: "3rem", marginBottom: "1rem" }, children: "⚠️" }),
|
|
1635
1557
|
/* @__PURE__ */ n("h2", { style: { color: "#374151", marginBottom: "1rem" }, children: "Insufficient Permissions" }),
|
|
1636
|
-
e && i ? /* @__PURE__ */
|
|
1637
|
-
/* @__PURE__ */
|
|
1558
|
+
e && i ? /* @__PURE__ */ a(B, { children: [
|
|
1559
|
+
/* @__PURE__ */ a("p", { style: { color: "#6b7280", marginBottom: "1rem" }, children: [
|
|
1638
1560
|
"This page requires ",
|
|
1639
1561
|
/* @__PURE__ */ n("strong", { children: e }),
|
|
1640
1562
|
" access level or higher."
|
|
1641
1563
|
] }),
|
|
1642
|
-
/* @__PURE__ */
|
|
1564
|
+
/* @__PURE__ */ a("p", { style: { color: "#9ca3af", fontSize: "0.875rem" }, children: [
|
|
1643
1565
|
"Your current access level: ",
|
|
1644
1566
|
/* @__PURE__ */ n("strong", { children: i })
|
|
1645
1567
|
] })
|
|
1646
|
-
] }) : /* @__PURE__ */
|
|
1568
|
+
] }) : /* @__PURE__ */ a(B, { children: [
|
|
1647
1569
|
/* @__PURE__ */ n("p", { style: { color: "#6b7280", marginBottom: "1rem" }, children: "You don't have the required permissions to access this page." }),
|
|
1648
|
-
t && t.length > 0 && /* @__PURE__ */
|
|
1570
|
+
t && t.length > 0 && /* @__PURE__ */ a("p", { style: { color: "#9ca3af", fontSize: "0.875rem" }, children: [
|
|
1649
1571
|
"Required permissions: ",
|
|
1650
1572
|
/* @__PURE__ */ n("strong", { children: t.join(", ") })
|
|
1651
1573
|
] })
|
|
@@ -1654,7 +1576,7 @@ const Ge = ({ redirectPath: i }) => /* @__PURE__ */ n(
|
|
|
1654
1576
|
}
|
|
1655
1577
|
)
|
|
1656
1578
|
}
|
|
1657
|
-
),
|
|
1579
|
+
), _e = (i, e) => {
|
|
1658
1580
|
const t = {
|
|
1659
1581
|
[ie.USER]: 1,
|
|
1660
1582
|
[ie.TENANT_ADMIN]: 2,
|
|
@@ -1662,32 +1584,32 @@ const Ge = ({ redirectPath: i }) => /* @__PURE__ */ n(
|
|
|
1662
1584
|
};
|
|
1663
1585
|
return t[i] >= t[e];
|
|
1664
1586
|
};
|
|
1665
|
-
function
|
|
1587
|
+
function Rt({
|
|
1666
1588
|
children: i,
|
|
1667
1589
|
redirectTo: e = "/login",
|
|
1668
1590
|
minUserType: t,
|
|
1669
1591
|
requiredPermissions: r,
|
|
1670
1592
|
requireAllPermissions: s = !1,
|
|
1671
|
-
fallback:
|
|
1593
|
+
fallback: o
|
|
1672
1594
|
}) {
|
|
1673
|
-
const { hasValidSession:
|
|
1674
|
-
if (!
|
|
1675
|
-
return
|
|
1595
|
+
const { hasValidSession: g, sessionManager: y, hasPermission: A, hasAnyPermission: w, hasAllPermissions: T } = ae(), f = we();
|
|
1596
|
+
if (!g())
|
|
1597
|
+
return o ? /* @__PURE__ */ n(B, { children: o }) : /* @__PURE__ */ a(B, { children: [
|
|
1676
1598
|
/* @__PURE__ */ n(Ge, { redirectPath: e }),
|
|
1677
|
-
/* @__PURE__ */ n(pe, { to: e, state: { from:
|
|
1599
|
+
/* @__PURE__ */ n(pe, { to: e, state: { from: f.pathname }, replace: !0 })
|
|
1678
1600
|
] });
|
|
1679
|
-
const
|
|
1680
|
-
if (!
|
|
1681
|
-
return /* @__PURE__ */ n(pe, { to: e, state: { from:
|
|
1682
|
-
if (t && !
|
|
1683
|
-
return /* @__PURE__ */ n(
|
|
1684
|
-
if (r && r.length > 0 && !(s ?
|
|
1685
|
-
const
|
|
1686
|
-
return /* @__PURE__ */ n(
|
|
1687
|
-
}
|
|
1688
|
-
return /* @__PURE__ */ n(
|
|
1601
|
+
const p = y.getUser();
|
|
1602
|
+
if (!p)
|
|
1603
|
+
return /* @__PURE__ */ n(pe, { to: e, state: { from: f.pathname }, replace: !0 });
|
|
1604
|
+
if (t && !_e(p.userType, t))
|
|
1605
|
+
return /* @__PURE__ */ n(Ae, { userType: p.userType, minUserType: t });
|
|
1606
|
+
if (r && r.length > 0 && !(s ? T(r) : w(r))) {
|
|
1607
|
+
const m = r.filter((R) => !A(R)).map((R) => typeof R == "string" ? R : R.name);
|
|
1608
|
+
return /* @__PURE__ */ n(Ae, { missingPermissions: m });
|
|
1609
|
+
}
|
|
1610
|
+
return /* @__PURE__ */ n(B, { children: i });
|
|
1689
1611
|
}
|
|
1690
|
-
const
|
|
1612
|
+
const Ke = ({ redirectPath: i }) => /* @__PURE__ */ n(
|
|
1691
1613
|
"div",
|
|
1692
1614
|
{
|
|
1693
1615
|
style: {
|
|
@@ -1700,7 +1622,7 @@ const _e = ({ redirectPath: i }) => /* @__PURE__ */ n(
|
|
|
1700
1622
|
backgroundColor: "#f9fafb",
|
|
1701
1623
|
textAlign: "center"
|
|
1702
1624
|
},
|
|
1703
|
-
children: /* @__PURE__ */
|
|
1625
|
+
children: /* @__PURE__ */ a(
|
|
1704
1626
|
"div",
|
|
1705
1627
|
{
|
|
1706
1628
|
style: {
|
|
@@ -1714,7 +1636,7 @@ const _e = ({ redirectPath: i }) => /* @__PURE__ */ n(
|
|
|
1714
1636
|
/* @__PURE__ */ n("div", { style: { fontSize: "3rem", marginBottom: "1rem" }, children: "🏢" }),
|
|
1715
1637
|
/* @__PURE__ */ n("h2", { style: { color: "#374151", marginBottom: "1rem" }, children: "Tenant Required" }),
|
|
1716
1638
|
/* @__PURE__ */ n("p", { style: { color: "#6b7280", marginBottom: "1.5rem" }, children: "This page requires a tenant context to access." }),
|
|
1717
|
-
/* @__PURE__ */
|
|
1639
|
+
/* @__PURE__ */ a("p", { style: { fontSize: "0.875rem", color: "#9ca3af" }, children: [
|
|
1718
1640
|
"Redirecting to ",
|
|
1719
1641
|
i,
|
|
1720
1642
|
"..."
|
|
@@ -1724,11 +1646,11 @@ const _e = ({ redirectPath: i }) => /* @__PURE__ */ n(
|
|
|
1724
1646
|
)
|
|
1725
1647
|
}
|
|
1726
1648
|
);
|
|
1727
|
-
function
|
|
1728
|
-
const { tenant: r, isLoading: s, error:
|
|
1729
|
-
return s ||
|
|
1730
|
-
/* @__PURE__ */ n(
|
|
1731
|
-
/* @__PURE__ */ n(pe, { to: e, state: { from:
|
|
1649
|
+
function Ct({ children: i, redirectTo: e = "/", fallback: t }) {
|
|
1650
|
+
const { tenant: r, isLoading: s, error: o } = se(), g = we();
|
|
1651
|
+
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 }),
|
|
1653
|
+
/* @__PURE__ */ n(pe, { to: e, state: { from: g.pathname }, replace: !0 })
|
|
1732
1654
|
] });
|
|
1733
1655
|
}
|
|
1734
1656
|
const Je = ({ redirectPath: i }) => /* @__PURE__ */ n(
|
|
@@ -1744,7 +1666,7 @@ const Je = ({ redirectPath: i }) => /* @__PURE__ */ n(
|
|
|
1744
1666
|
backgroundColor: "#f9fafb",
|
|
1745
1667
|
textAlign: "center"
|
|
1746
1668
|
},
|
|
1747
|
-
children: /* @__PURE__ */
|
|
1669
|
+
children: /* @__PURE__ */ a(
|
|
1748
1670
|
"div",
|
|
1749
1671
|
{
|
|
1750
1672
|
style: {
|
|
@@ -1758,7 +1680,7 @@ const Je = ({ redirectPath: i }) => /* @__PURE__ */ n(
|
|
|
1758
1680
|
/* @__PURE__ */ n("div", { style: { fontSize: "3rem", marginBottom: "1rem" }, children: "🚀" }),
|
|
1759
1681
|
/* @__PURE__ */ n("h2", { style: { color: "#374151", marginBottom: "1rem" }, children: "Tenant Detected" }),
|
|
1760
1682
|
/* @__PURE__ */ n("p", { style: { color: "#6b7280", marginBottom: "1.5rem" }, children: "You are accessing a tenant-specific context. Redirecting to the appropriate page." }),
|
|
1761
|
-
/* @__PURE__ */
|
|
1683
|
+
/* @__PURE__ */ a("p", { style: { fontSize: "0.875rem", color: "#9ca3af" }, children: [
|
|
1762
1684
|
"Redirecting to ",
|
|
1763
1685
|
i,
|
|
1764
1686
|
"..."
|
|
@@ -1768,14 +1690,14 @@ const Je = ({ redirectPath: i }) => /* @__PURE__ */ n(
|
|
|
1768
1690
|
)
|
|
1769
1691
|
}
|
|
1770
1692
|
);
|
|
1771
|
-
function
|
|
1772
|
-
const { tenant: r, isLoading: s, error:
|
|
1773
|
-
return s ||
|
|
1693
|
+
function $t({ children: i, redirectTo: e = "/dashboard", fallback: t }) {
|
|
1694
|
+
const { tenant: r, isLoading: s, error: o } = se(), g = we();
|
|
1695
|
+
return s || o ? null : r ? t ? /* @__PURE__ */ n(B, { children: t }) : /* @__PURE__ */ a(B, { children: [
|
|
1774
1696
|
/* @__PURE__ */ n(Je, { redirectPath: e }),
|
|
1775
|
-
/* @__PURE__ */ n(pe, { to: e, state: { from:
|
|
1776
|
-
] }) : /* @__PURE__ */ n(
|
|
1697
|
+
/* @__PURE__ */ n(pe, { to: e, state: { from: g.pathname }, replace: !0 })
|
|
1698
|
+
] }) : /* @__PURE__ */ n(B, { children: i });
|
|
1777
1699
|
}
|
|
1778
|
-
const Ye = () => /* @__PURE__ */
|
|
1700
|
+
const Ye = () => /* @__PURE__ */ a(
|
|
1779
1701
|
"div",
|
|
1780
1702
|
{
|
|
1781
1703
|
style: {
|
|
@@ -1792,14 +1714,14 @@ const Ye = () => /* @__PURE__ */ l(
|
|
|
1792
1714
|
]
|
|
1793
1715
|
}
|
|
1794
1716
|
);
|
|
1795
|
-
function
|
|
1717
|
+
function Ft({
|
|
1796
1718
|
children: i,
|
|
1797
1719
|
fallback: e = /* @__PURE__ */ n(Ye, {}),
|
|
1798
1720
|
allowedPlans: t,
|
|
1799
1721
|
requiredFeature: r
|
|
1800
1722
|
}) {
|
|
1801
|
-
const { subscription: s, hasAllowedPlan:
|
|
1802
|
-
return
|
|
1723
|
+
const { subscription: s, hasAllowedPlan: o, isFeatureEnabled: g, loading: y } = je();
|
|
1724
|
+
return y ? /* @__PURE__ */ n(
|
|
1803
1725
|
"div",
|
|
1804
1726
|
{
|
|
1805
1727
|
style: {
|
|
@@ -1809,9 +1731,9 @@ function Lt({
|
|
|
1809
1731
|
},
|
|
1810
1732
|
children: "Loading subscription..."
|
|
1811
1733
|
}
|
|
1812
|
-
) : s ? s.isActive ? t && t.length > 0 && !
|
|
1734
|
+
) : 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 });
|
|
1813
1735
|
}
|
|
1814
|
-
const Qe = ({ flagName: i }) => /* @__PURE__ */
|
|
1736
|
+
const Qe = ({ flagName: i }) => /* @__PURE__ */ a(
|
|
1815
1737
|
"div",
|
|
1816
1738
|
{
|
|
1817
1739
|
style: {
|
|
@@ -1830,7 +1752,7 @@ const Qe = ({ flagName: i }) => /* @__PURE__ */ l(
|
|
|
1830
1752
|
children: [
|
|
1831
1753
|
/* @__PURE__ */ n("div", { style: { fontSize: "24px", marginBottom: "8px" }, children: "🚧" }),
|
|
1832
1754
|
/* @__PURE__ */ n("div", { style: { fontSize: "14px", fontWeight: "500", marginBottom: "4px" }, children: "Feature Not Available" }),
|
|
1833
|
-
/* @__PURE__ */
|
|
1755
|
+
/* @__PURE__ */ a("div", { style: { fontSize: "12px", opacity: 0.7 }, children: [
|
|
1834
1756
|
'Feature flag "',
|
|
1835
1757
|
i,
|
|
1836
1758
|
'" is disabled'
|
|
@@ -1838,7 +1760,7 @@ const Qe = ({ flagName: i }) => /* @__PURE__ */ l(
|
|
|
1838
1760
|
]
|
|
1839
1761
|
}
|
|
1840
1762
|
);
|
|
1841
|
-
function
|
|
1763
|
+
function Dt({ name: i, children: e, fallback: t }) {
|
|
1842
1764
|
const { isEnabled: r, loading: s } = Oe();
|
|
1843
1765
|
return s ? /* @__PURE__ */ n(
|
|
1844
1766
|
"div",
|
|
@@ -1853,9 +1775,9 @@ function Ft({ name: i, children: e, fallback: t }) {
|
|
|
1853
1775
|
},
|
|
1854
1776
|
children: "Loading feature flags..."
|
|
1855
1777
|
}
|
|
1856
|
-
) :
|
|
1778
|
+
) : r(i) ? /* @__PURE__ */ n(B, { children: e }) : /* @__PURE__ */ n(B, { children: t || /* @__PURE__ */ n(Qe, { flagName: i }) });
|
|
1857
1779
|
}
|
|
1858
|
-
const Xe = () => /* @__PURE__ */
|
|
1780
|
+
const Xe = () => /* @__PURE__ */ a(
|
|
1859
1781
|
"svg",
|
|
1860
1782
|
{
|
|
1861
1783
|
width: "16",
|
|
@@ -1872,7 +1794,7 @@ const Xe = () => /* @__PURE__ */ l(
|
|
|
1872
1794
|
/* @__PURE__ */ n("circle", { cx: "12", cy: "12", r: "3" })
|
|
1873
1795
|
]
|
|
1874
1796
|
}
|
|
1875
|
-
), Ze = () => /* @__PURE__ */
|
|
1797
|
+
), Ze = () => /* @__PURE__ */ a(
|
|
1876
1798
|
"svg",
|
|
1877
1799
|
{
|
|
1878
1800
|
width: "16",
|
|
@@ -2013,128 +1935,128 @@ const Xe = () => /* @__PURE__ */ l(
|
|
|
2013
1935
|
fontSize: "0.875rem"
|
|
2014
1936
|
}
|
|
2015
1937
|
};
|
|
2016
|
-
function
|
|
1938
|
+
function Ht({
|
|
2017
1939
|
copy: i = {},
|
|
2018
1940
|
styles: e = {},
|
|
2019
1941
|
icons: t = {},
|
|
2020
1942
|
onSuccess: r,
|
|
2021
1943
|
onError: s,
|
|
2022
|
-
onForgotPassword:
|
|
2023
|
-
onSignupClick:
|
|
2024
|
-
onMagicLinkClick:
|
|
1944
|
+
onForgotPassword: o,
|
|
1945
|
+
onSignupClick: g,
|
|
1946
|
+
onMagicLinkClick: y,
|
|
2025
1947
|
showForgotPassword: A = !0,
|
|
2026
|
-
showSignupLink:
|
|
2027
|
-
showMagicLinkOption:
|
|
2028
|
-
className:
|
|
1948
|
+
showSignupLink: w = !0,
|
|
1949
|
+
showMagicLinkOption: T = !0,
|
|
1950
|
+
className: f
|
|
2029
1951
|
}) {
|
|
2030
|
-
const [
|
|
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 = () => {
|
|
2031
1953
|
const c = {};
|
|
2032
|
-
return
|
|
2033
|
-
},
|
|
2034
|
-
if (c.preventDefault(), !!
|
|
2035
|
-
if (!(
|
|
2036
|
-
|
|
1954
|
+
return p.trim() || (c.username = !0), m.trim() || (c.password = !0), V(c), Object.keys(c).length === 0;
|
|
1955
|
+
}, x = async (c) => {
|
|
1956
|
+
if (c.preventDefault(), !!l()) {
|
|
1957
|
+
if (!(j != null && j.id)) {
|
|
1958
|
+
E("Tenant not found");
|
|
2037
1959
|
return;
|
|
2038
1960
|
}
|
|
2039
|
-
u(!0),
|
|
1961
|
+
u(!0), E("");
|
|
2040
1962
|
try {
|
|
2041
|
-
const
|
|
2042
|
-
username:
|
|
2043
|
-
password:
|
|
1963
|
+
const S = await $({
|
|
1964
|
+
username: p,
|
|
1965
|
+
password: m
|
|
2044
1966
|
// tenantId inferred from context automatically
|
|
2045
1967
|
});
|
|
2046
|
-
r == null || r(
|
|
2047
|
-
} catch (
|
|
2048
|
-
const
|
|
2049
|
-
|
|
1968
|
+
r == null || r(S);
|
|
1969
|
+
} catch (S) {
|
|
1970
|
+
const G = S.message || v.errorMessage;
|
|
1971
|
+
E(G), s == null || s(G);
|
|
2050
1972
|
} finally {
|
|
2051
1973
|
u(!1);
|
|
2052
1974
|
}
|
|
2053
1975
|
}
|
|
2054
|
-
},
|
|
2055
|
-
...
|
|
2056
|
-
...
|
|
1976
|
+
}, b = (c) => ({
|
|
1977
|
+
...I.input,
|
|
1978
|
+
...q[c] ? I.inputError : {}
|
|
2057
1979
|
}), d = () => ({
|
|
2058
|
-
...
|
|
2059
|
-
...
|
|
2060
|
-
...!
|
|
1980
|
+
...I.button,
|
|
1981
|
+
...P ? I.buttonLoading : {},
|
|
1982
|
+
...!p || !m || P ? I.buttonDisabled : {}
|
|
2061
1983
|
});
|
|
2062
|
-
return /* @__PURE__ */
|
|
2063
|
-
/* @__PURE__ */ n("h2", { style:
|
|
2064
|
-
/* @__PURE__ */
|
|
2065
|
-
/* @__PURE__ */
|
|
2066
|
-
/* @__PURE__ */ n("label", { style:
|
|
1984
|
+
return /* @__PURE__ */ a("div", { className: f, style: I.container, children: [
|
|
1985
|
+
/* @__PURE__ */ n("h2", { style: I.title, children: v.title }),
|
|
1986
|
+
/* @__PURE__ */ a("form", { onSubmit: x, style: I.form, children: [
|
|
1987
|
+
/* @__PURE__ */ a("div", { style: I.fieldGroup, children: [
|
|
1988
|
+
/* @__PURE__ */ n("label", { style: I.label, children: v.usernameLabel }),
|
|
2067
1989
|
/* @__PURE__ */ n(
|
|
2068
1990
|
"input",
|
|
2069
1991
|
{
|
|
2070
1992
|
id: "username",
|
|
2071
1993
|
name: "username",
|
|
2072
1994
|
type: "text",
|
|
2073
|
-
value:
|
|
1995
|
+
value: p,
|
|
2074
1996
|
onChange: (c) => {
|
|
2075
|
-
h(c.target.value),
|
|
1997
|
+
h(c.target.value), q.username && V((S) => ({ ...S, username: !1 }));
|
|
2076
1998
|
},
|
|
2077
|
-
placeholder:
|
|
2078
|
-
style:
|
|
2079
|
-
disabled:
|
|
1999
|
+
placeholder: v.usernamePlaceholder,
|
|
2000
|
+
style: b("username"),
|
|
2001
|
+
disabled: P
|
|
2080
2002
|
}
|
|
2081
2003
|
)
|
|
2082
2004
|
] }),
|
|
2083
|
-
/* @__PURE__ */
|
|
2084
|
-
/* @__PURE__ */ n("label", { style:
|
|
2085
|
-
/* @__PURE__ */
|
|
2005
|
+
/* @__PURE__ */ a("div", { style: I.fieldGroup, children: [
|
|
2006
|
+
/* @__PURE__ */ n("label", { style: I.label, children: v.passwordLabel }),
|
|
2007
|
+
/* @__PURE__ */ a("div", { style: I.inputContainer, children: [
|
|
2086
2008
|
/* @__PURE__ */ n(
|
|
2087
2009
|
"input",
|
|
2088
2010
|
{
|
|
2089
2011
|
id: "password",
|
|
2090
2012
|
name: "password",
|
|
2091
2013
|
type: C ? "text" : "password",
|
|
2092
|
-
value:
|
|
2014
|
+
value: m,
|
|
2093
2015
|
onChange: (c) => {
|
|
2094
|
-
|
|
2016
|
+
R(c.target.value), q.password && V((S) => ({ ...S, password: !1 }));
|
|
2095
2017
|
},
|
|
2096
|
-
placeholder:
|
|
2018
|
+
placeholder: v.passwordPlaceholder,
|
|
2097
2019
|
style: {
|
|
2098
|
-
...
|
|
2020
|
+
...b("password"),
|
|
2099
2021
|
paddingRight: "2.5rem"
|
|
2100
2022
|
// Make room for the icon
|
|
2101
2023
|
},
|
|
2102
|
-
disabled:
|
|
2024
|
+
disabled: P
|
|
2103
2025
|
}
|
|
2104
2026
|
),
|
|
2105
2027
|
/* @__PURE__ */ n(
|
|
2106
2028
|
"button",
|
|
2107
2029
|
{
|
|
2108
2030
|
type: "button",
|
|
2109
|
-
onClick: () =>
|
|
2110
|
-
style:
|
|
2111
|
-
disabled:
|
|
2031
|
+
onClick: () => U(!C),
|
|
2032
|
+
style: I.passwordToggle,
|
|
2033
|
+
disabled: P,
|
|
2112
2034
|
"aria-label": C ? "Hide password" : "Show password",
|
|
2113
|
-
children: C ?
|
|
2035
|
+
children: C ? L.hidePassword : L.showPassword
|
|
2114
2036
|
}
|
|
2115
2037
|
)
|
|
2116
2038
|
] })
|
|
2117
2039
|
] }),
|
|
2118
|
-
/* @__PURE__ */ n("button", { type: "submit", disabled: !
|
|
2119
|
-
|
|
2040
|
+
/* @__PURE__ */ n("button", { type: "submit", disabled: !p || !m || P, style: d(), children: P ? v.loadingText : v.submitButton }),
|
|
2041
|
+
M && /* @__PURE__ */ n("div", { style: I.errorText, children: M })
|
|
2120
2042
|
] }),
|
|
2121
|
-
(A ||
|
|
2122
|
-
|
|
2123
|
-
/* @__PURE__ */
|
|
2124
|
-
|
|
2043
|
+
(A || w || T) && /* @__PURE__ */ a("div", { style: I.linkContainer, children: [
|
|
2044
|
+
T && /* @__PURE__ */ a("div", { children: [
|
|
2045
|
+
/* @__PURE__ */ a("span", { style: I.divider, children: [
|
|
2046
|
+
v.magicLinkText,
|
|
2125
2047
|
" "
|
|
2126
2048
|
] }),
|
|
2127
|
-
/* @__PURE__ */ n("a", { onClick:
|
|
2049
|
+
/* @__PURE__ */ n("a", { onClick: y, style: I.link, children: v.magicLinkLink })
|
|
2128
2050
|
] }),
|
|
2129
|
-
|
|
2130
|
-
A && /* @__PURE__ */ n("a", { onClick:
|
|
2131
|
-
A &&
|
|
2132
|
-
|
|
2133
|
-
/* @__PURE__ */
|
|
2134
|
-
|
|
2051
|
+
T && (A || w) && /* @__PURE__ */ n("div", { style: I.divider, children: "•" }),
|
|
2052
|
+
A && /* @__PURE__ */ n("a", { onClick: o, style: I.link, children: v.forgotPasswordLink }),
|
|
2053
|
+
A && w && /* @__PURE__ */ n("div", { style: I.divider, children: "•" }),
|
|
2054
|
+
w && /* @__PURE__ */ a("div", { children: [
|
|
2055
|
+
/* @__PURE__ */ a("span", { style: I.divider, children: [
|
|
2056
|
+
v.signupText,
|
|
2135
2057
|
" "
|
|
2136
2058
|
] }),
|
|
2137
|
-
/* @__PURE__ */ n("a", { onClick:
|
|
2059
|
+
/* @__PURE__ */ n("a", { onClick: g, style: I.link, children: v.signupLink })
|
|
2138
2060
|
] })
|
|
2139
2061
|
] })
|
|
2140
2062
|
] });
|
|
@@ -2264,121 +2186,121 @@ const nt = {
|
|
|
2264
2186
|
fontSize: "0.875rem"
|
|
2265
2187
|
}
|
|
2266
2188
|
};
|
|
2267
|
-
function
|
|
2189
|
+
function Nt({
|
|
2268
2190
|
copy: i = {},
|
|
2269
2191
|
styles: e = {},
|
|
2270
2192
|
signupType: t = "user",
|
|
2271
2193
|
onSuccess: r,
|
|
2272
2194
|
onError: s,
|
|
2273
|
-
onLoginClick:
|
|
2274
|
-
onMagicLinkClick:
|
|
2275
|
-
showLoginLink:
|
|
2195
|
+
onLoginClick: o,
|
|
2196
|
+
onMagicLinkClick: g,
|
|
2197
|
+
showLoginLink: y = !0,
|
|
2276
2198
|
showMagicLinkOption: A = !0,
|
|
2277
|
-
className:
|
|
2199
|
+
className: w
|
|
2278
2200
|
}) {
|
|
2279
|
-
const [
|
|
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 = () => {
|
|
2280
2202
|
const D = {};
|
|
2281
|
-
return
|
|
2203
|
+
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;
|
|
2282
2204
|
}, ee = async (D) => {
|
|
2283
|
-
if (D.preventDefault(), !!
|
|
2284
|
-
if (
|
|
2285
|
-
|
|
2205
|
+
if (D.preventDefault(), !!G()) {
|
|
2206
|
+
if (P !== M) {
|
|
2207
|
+
I(c.passwordMismatchError), l({ confirmPassword: !0 });
|
|
2286
2208
|
return;
|
|
2287
2209
|
}
|
|
2288
2210
|
if (t === "user" && !(d != null && d.id)) {
|
|
2289
|
-
|
|
2211
|
+
I("Tenant not found");
|
|
2290
2212
|
return;
|
|
2291
2213
|
}
|
|
2292
|
-
|
|
2214
|
+
j(!0), I("");
|
|
2293
2215
|
try {
|
|
2294
|
-
let
|
|
2295
|
-
t === "tenant" ?
|
|
2296
|
-
email:
|
|
2216
|
+
let K;
|
|
2217
|
+
t === "tenant" ? K = await b({
|
|
2218
|
+
email: m || void 0,
|
|
2297
2219
|
phoneNumber: C || void 0,
|
|
2298
|
-
name:
|
|
2299
|
-
password:
|
|
2300
|
-
tenantName:
|
|
2301
|
-
lastName:
|
|
2302
|
-
}) :
|
|
2303
|
-
email:
|
|
2220
|
+
name: T,
|
|
2221
|
+
password: P,
|
|
2222
|
+
tenantName: q,
|
|
2223
|
+
lastName: p || void 0
|
|
2224
|
+
}) : K = await x({
|
|
2225
|
+
email: m || void 0,
|
|
2304
2226
|
phoneNumber: C || void 0,
|
|
2305
|
-
name:
|
|
2306
|
-
password:
|
|
2227
|
+
name: T,
|
|
2228
|
+
password: P,
|
|
2307
2229
|
tenantId: d.id,
|
|
2308
|
-
lastName:
|
|
2309
|
-
}), r == null || r(
|
|
2310
|
-
} catch (
|
|
2311
|
-
const ge =
|
|
2312
|
-
|
|
2230
|
+
lastName: p || void 0
|
|
2231
|
+
}), r == null || r(K);
|
|
2232
|
+
} catch (K) {
|
|
2233
|
+
const ge = K.message || c.errorMessage;
|
|
2234
|
+
I(ge), s == null || s(ge);
|
|
2313
2235
|
} finally {
|
|
2314
|
-
|
|
2236
|
+
j(!1);
|
|
2315
2237
|
}
|
|
2316
2238
|
}
|
|
2317
2239
|
}, z = (D) => ({
|
|
2318
|
-
...
|
|
2319
|
-
...
|
|
2320
|
-
}),
|
|
2321
|
-
...
|
|
2322
|
-
|
|
2323
|
-
...!
|
|
2324
|
-
}), O =
|
|
2325
|
-
return /* @__PURE__ */
|
|
2326
|
-
/* @__PURE__ */ n("h2", { style:
|
|
2327
|
-
/* @__PURE__ */
|
|
2328
|
-
/* @__PURE__ */
|
|
2329
|
-
/* @__PURE__ */ n("label", { style:
|
|
2240
|
+
...S.input,
|
|
2241
|
+
...L[D] ? S.inputError : {}
|
|
2242
|
+
}), H = () => ({
|
|
2243
|
+
...S.button,
|
|
2244
|
+
...$ ? S.buttonLoading : {},
|
|
2245
|
+
...!T || !m && !C || !P || !M || $ || t === "tenant" && !q ? S.buttonDisabled : {}
|
|
2246
|
+
}), O = T && (m || C) && P && M && (t === "user" || q);
|
|
2247
|
+
return /* @__PURE__ */ a("div", { className: w, style: S.container, children: [
|
|
2248
|
+
/* @__PURE__ */ n("h2", { style: S.title, children: c.title }),
|
|
2249
|
+
/* @__PURE__ */ a("form", { onSubmit: ee, style: S.form, children: [
|
|
2250
|
+
/* @__PURE__ */ a("div", { style: S.fieldGroup, children: [
|
|
2251
|
+
/* @__PURE__ */ n("label", { style: S.label, children: c.nameLabel }),
|
|
2330
2252
|
/* @__PURE__ */ n(
|
|
2331
2253
|
"input",
|
|
2332
2254
|
{
|
|
2333
2255
|
id: "name",
|
|
2334
2256
|
name: "name",
|
|
2335
2257
|
type: "text",
|
|
2336
|
-
value:
|
|
2258
|
+
value: T,
|
|
2337
2259
|
onChange: (D) => {
|
|
2338
|
-
|
|
2260
|
+
f(D.target.value), L.name && l((K) => ({ ...K, name: !1 }));
|
|
2339
2261
|
},
|
|
2340
2262
|
placeholder: c.namePlaceholder,
|
|
2341
2263
|
style: z("name"),
|
|
2342
|
-
disabled:
|
|
2264
|
+
disabled: $
|
|
2343
2265
|
}
|
|
2344
2266
|
)
|
|
2345
2267
|
] }),
|
|
2346
|
-
/* @__PURE__ */
|
|
2347
|
-
/* @__PURE__ */ n("label", { style:
|
|
2268
|
+
/* @__PURE__ */ a("div", { style: S.fieldGroup, children: [
|
|
2269
|
+
/* @__PURE__ */ n("label", { style: S.label, children: c.lastNameLabel }),
|
|
2348
2270
|
/* @__PURE__ */ n(
|
|
2349
2271
|
"input",
|
|
2350
2272
|
{
|
|
2351
2273
|
id: "lastName",
|
|
2352
2274
|
name: "lastName",
|
|
2353
2275
|
type: "text",
|
|
2354
|
-
value:
|
|
2276
|
+
value: p,
|
|
2355
2277
|
onChange: (D) => h(D.target.value),
|
|
2356
2278
|
placeholder: c.lastNamePlaceholder,
|
|
2357
|
-
style:
|
|
2358
|
-
disabled:
|
|
2279
|
+
style: S.input,
|
|
2280
|
+
disabled: $
|
|
2359
2281
|
}
|
|
2360
2282
|
)
|
|
2361
2283
|
] }),
|
|
2362
|
-
/* @__PURE__ */
|
|
2363
|
-
/* @__PURE__ */ n("label", { style:
|
|
2284
|
+
/* @__PURE__ */ a("div", { style: S.fieldGroup, children: [
|
|
2285
|
+
/* @__PURE__ */ n("label", { style: S.label, children: c.emailLabel }),
|
|
2364
2286
|
/* @__PURE__ */ n(
|
|
2365
2287
|
"input",
|
|
2366
2288
|
{
|
|
2367
2289
|
id: "email",
|
|
2368
2290
|
name: "email",
|
|
2369
2291
|
type: "email",
|
|
2370
|
-
value:
|
|
2292
|
+
value: m,
|
|
2371
2293
|
onChange: (D) => {
|
|
2372
|
-
|
|
2294
|
+
R(D.target.value), L.email && l((K) => ({ ...K, email: !1, phoneNumber: !1 }));
|
|
2373
2295
|
},
|
|
2374
2296
|
placeholder: c.emailPlaceholder,
|
|
2375
2297
|
style: z("email"),
|
|
2376
|
-
disabled:
|
|
2298
|
+
disabled: $
|
|
2377
2299
|
}
|
|
2378
2300
|
)
|
|
2379
2301
|
] }),
|
|
2380
|
-
/* @__PURE__ */
|
|
2381
|
-
/* @__PURE__ */ n("label", { style:
|
|
2302
|
+
/* @__PURE__ */ a("div", { style: S.fieldGroup, children: [
|
|
2303
|
+
/* @__PURE__ */ n("label", { style: S.label, children: c.phoneNumberLabel }),
|
|
2382
2304
|
/* @__PURE__ */ n(
|
|
2383
2305
|
"input",
|
|
2384
2306
|
{
|
|
@@ -2387,11 +2309,11 @@ function Dt({
|
|
|
2387
2309
|
type: "tel",
|
|
2388
2310
|
value: C,
|
|
2389
2311
|
onChange: (D) => {
|
|
2390
|
-
|
|
2312
|
+
U(D.target.value), L.phoneNumber && l((K) => ({ ...K, email: !1, phoneNumber: !1 }));
|
|
2391
2313
|
},
|
|
2392
2314
|
placeholder: c.phoneNumberPlaceholder,
|
|
2393
2315
|
style: z("phoneNumber"),
|
|
2394
|
-
disabled:
|
|
2316
|
+
disabled: $
|
|
2395
2317
|
}
|
|
2396
2318
|
)
|
|
2397
2319
|
] }),
|
|
@@ -2407,78 +2329,78 @@ function Dt({
|
|
|
2407
2329
|
children: "At least one contact method (email or phone) is required"
|
|
2408
2330
|
}
|
|
2409
2331
|
),
|
|
2410
|
-
/* @__PURE__ */
|
|
2411
|
-
/* @__PURE__ */ n("label", { style:
|
|
2332
|
+
/* @__PURE__ */ a("div", { style: S.fieldGroup, children: [
|
|
2333
|
+
/* @__PURE__ */ n("label", { style: S.label, children: c.passwordLabel }),
|
|
2412
2334
|
/* @__PURE__ */ n(
|
|
2413
2335
|
"input",
|
|
2414
2336
|
{
|
|
2415
2337
|
id: "password",
|
|
2416
2338
|
name: "password",
|
|
2417
2339
|
type: "password",
|
|
2418
|
-
value:
|
|
2340
|
+
value: P,
|
|
2419
2341
|
onChange: (D) => {
|
|
2420
|
-
u(D.target.value),
|
|
2342
|
+
u(D.target.value), L.password && l((K) => ({ ...K, password: !1 }));
|
|
2421
2343
|
},
|
|
2422
2344
|
placeholder: c.passwordPlaceholder,
|
|
2423
2345
|
style: z("password"),
|
|
2424
|
-
disabled:
|
|
2346
|
+
disabled: $
|
|
2425
2347
|
}
|
|
2426
2348
|
)
|
|
2427
2349
|
] }),
|
|
2428
|
-
/* @__PURE__ */
|
|
2429
|
-
/* @__PURE__ */ n("label", { style:
|
|
2350
|
+
/* @__PURE__ */ a("div", { style: S.fieldGroup, children: [
|
|
2351
|
+
/* @__PURE__ */ n("label", { style: S.label, children: c.confirmPasswordLabel }),
|
|
2430
2352
|
/* @__PURE__ */ n(
|
|
2431
2353
|
"input",
|
|
2432
2354
|
{
|
|
2433
2355
|
id: "confirmPassword",
|
|
2434
2356
|
name: "confirmPassword",
|
|
2435
2357
|
type: "password",
|
|
2436
|
-
value:
|
|
2358
|
+
value: M,
|
|
2437
2359
|
onChange: (D) => {
|
|
2438
|
-
|
|
2360
|
+
E(D.target.value), L.confirmPassword && l((K) => ({ ...K, confirmPassword: !1 })), v === c.passwordMismatchError && I("");
|
|
2439
2361
|
},
|
|
2440
2362
|
placeholder: c.confirmPasswordPlaceholder,
|
|
2441
2363
|
style: z("confirmPassword"),
|
|
2442
|
-
disabled:
|
|
2364
|
+
disabled: $
|
|
2443
2365
|
}
|
|
2444
2366
|
)
|
|
2445
2367
|
] }),
|
|
2446
|
-
t === "tenant" && /* @__PURE__ */
|
|
2447
|
-
/* @__PURE__ */ n("label", { style:
|
|
2368
|
+
t === "tenant" && /* @__PURE__ */ a("div", { style: S.fieldGroup, children: [
|
|
2369
|
+
/* @__PURE__ */ n("label", { style: S.label, children: c.tenantNameLabel }),
|
|
2448
2370
|
/* @__PURE__ */ n(
|
|
2449
2371
|
"input",
|
|
2450
2372
|
{
|
|
2451
2373
|
id: "tenantName",
|
|
2452
2374
|
name: "tenantName",
|
|
2453
2375
|
type: "text",
|
|
2454
|
-
value:
|
|
2376
|
+
value: q,
|
|
2455
2377
|
onChange: (D) => {
|
|
2456
|
-
|
|
2378
|
+
V(D.target.value), L.tenantName && l((K) => ({ ...K, tenantName: !1 }));
|
|
2457
2379
|
},
|
|
2458
2380
|
placeholder: c.tenantNamePlaceholder,
|
|
2459
2381
|
style: z("tenantName"),
|
|
2460
|
-
disabled:
|
|
2382
|
+
disabled: $
|
|
2461
2383
|
}
|
|
2462
2384
|
)
|
|
2463
2385
|
] }),
|
|
2464
|
-
/* @__PURE__ */ n("button", { type: "submit", disabled: !O ||
|
|
2465
|
-
|
|
2386
|
+
/* @__PURE__ */ n("button", { type: "submit", disabled: !O || $, style: H(), children: $ ? c.loadingText : c.submitButton }),
|
|
2387
|
+
v && /* @__PURE__ */ n("div", { style: S.errorText, children: v })
|
|
2466
2388
|
] }),
|
|
2467
|
-
(
|
|
2468
|
-
A && /* @__PURE__ */
|
|
2469
|
-
/* @__PURE__ */
|
|
2389
|
+
(y || A) && /* @__PURE__ */ a("div", { style: S.linkContainer, children: [
|
|
2390
|
+
A && /* @__PURE__ */ a("div", { children: [
|
|
2391
|
+
/* @__PURE__ */ a("span", { style: S.divider, children: [
|
|
2470
2392
|
c.magicLinkText,
|
|
2471
2393
|
" "
|
|
2472
2394
|
] }),
|
|
2473
|
-
/* @__PURE__ */ n("a", { onClick:
|
|
2395
|
+
/* @__PURE__ */ n("a", { onClick: g, style: S.link, children: c.magicLinkLink })
|
|
2474
2396
|
] }),
|
|
2475
|
-
A &&
|
|
2476
|
-
|
|
2477
|
-
/* @__PURE__ */
|
|
2397
|
+
A && y && /* @__PURE__ */ n("div", { style: S.divider, children: "•" }),
|
|
2398
|
+
y && /* @__PURE__ */ a("div", { children: [
|
|
2399
|
+
/* @__PURE__ */ a("span", { style: S.divider, children: [
|
|
2478
2400
|
c.loginText,
|
|
2479
2401
|
" "
|
|
2480
2402
|
] }),
|
|
2481
|
-
/* @__PURE__ */ n("a", { onClick:
|
|
2403
|
+
/* @__PURE__ */ n("a", { onClick: o, style: S.link, children: c.loginLink })
|
|
2482
2404
|
] })
|
|
2483
2405
|
] })
|
|
2484
2406
|
] });
|
|
@@ -2604,105 +2526,105 @@ const it = {
|
|
|
2604
2526
|
fontSize: "0.875rem"
|
|
2605
2527
|
}
|
|
2606
2528
|
};
|
|
2607
|
-
function
|
|
2529
|
+
function Bt({
|
|
2608
2530
|
copy: i = {},
|
|
2609
2531
|
styles: e = {},
|
|
2610
2532
|
onSuccess: t,
|
|
2611
2533
|
onError: r,
|
|
2612
2534
|
onLoginClick: s,
|
|
2613
|
-
onSignupClick:
|
|
2614
|
-
showTraditionalLinks:
|
|
2615
|
-
className:
|
|
2535
|
+
onSignupClick: o,
|
|
2536
|
+
showTraditionalLinks: g = !0,
|
|
2537
|
+
className: y,
|
|
2616
2538
|
verifyToken: A,
|
|
2617
|
-
frontendUrl:
|
|
2539
|
+
frontendUrl: w
|
|
2618
2540
|
}) {
|
|
2619
|
-
const [
|
|
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 };
|
|
2620
2542
|
te(() => {
|
|
2621
2543
|
A && c(A);
|
|
2622
2544
|
}, [A]);
|
|
2623
|
-
const c = async (
|
|
2624
|
-
if (!
|
|
2625
|
-
|
|
2545
|
+
const c = async (H) => {
|
|
2546
|
+
if (!x || !T) {
|
|
2547
|
+
E("Missing tenant or email");
|
|
2626
2548
|
return;
|
|
2627
2549
|
}
|
|
2628
|
-
u(!0),
|
|
2550
|
+
u(!0), E("");
|
|
2629
2551
|
try {
|
|
2630
|
-
const O = await
|
|
2631
|
-
token:
|
|
2632
|
-
email:
|
|
2552
|
+
const O = await l({
|
|
2553
|
+
token: H,
|
|
2554
|
+
email: T
|
|
2633
2555
|
// tenantId inferred from context automatically
|
|
2634
2556
|
});
|
|
2635
2557
|
t == null || t(O);
|
|
2636
2558
|
} catch (O) {
|
|
2637
2559
|
const D = O.message || "Failed to verify magic link";
|
|
2638
|
-
|
|
2560
|
+
E(D), r == null || r(D);
|
|
2639
2561
|
} finally {
|
|
2640
2562
|
u(!1);
|
|
2641
2563
|
}
|
|
2642
|
-
},
|
|
2643
|
-
const
|
|
2644
|
-
return
|
|
2645
|
-
},
|
|
2646
|
-
if (
|
|
2647
|
-
if (!(
|
|
2648
|
-
|
|
2564
|
+
}, S = () => {
|
|
2565
|
+
const H = {};
|
|
2566
|
+
return T.trim() || (H.email = !0), v && !p.trim() && (H.name = !0), j(H), Object.keys(H).length === 0;
|
|
2567
|
+
}, G = async (H) => {
|
|
2568
|
+
if (H.preventDefault(), !!S()) {
|
|
2569
|
+
if (!(x != null && x.id)) {
|
|
2570
|
+
E("Tenant not found");
|
|
2649
2571
|
return;
|
|
2650
2572
|
}
|
|
2651
|
-
|
|
2573
|
+
U(!0), E(""), V("");
|
|
2652
2574
|
try {
|
|
2653
|
-
const O =
|
|
2654
|
-
email:
|
|
2655
|
-
tenantId:
|
|
2575
|
+
const O = w || (typeof window < "u" ? window.location.origin : ""), D = await L({
|
|
2576
|
+
email: T,
|
|
2577
|
+
tenantId: x.id,
|
|
2656
2578
|
frontendUrl: O,
|
|
2657
|
-
name:
|
|
2658
|
-
lastName:
|
|
2579
|
+
name: v ? p : void 0,
|
|
2580
|
+
lastName: v ? m : void 0
|
|
2659
2581
|
});
|
|
2660
|
-
|
|
2582
|
+
V(b.successMessage), t == null || t(D);
|
|
2661
2583
|
} catch (O) {
|
|
2662
|
-
const D = O.message ||
|
|
2663
|
-
|
|
2584
|
+
const D = O.message || b.errorMessage;
|
|
2585
|
+
E(D), r == null || r(D);
|
|
2664
2586
|
} finally {
|
|
2665
|
-
|
|
2587
|
+
U(!1);
|
|
2666
2588
|
}
|
|
2667
2589
|
}
|
|
2668
|
-
}, ee = (
|
|
2590
|
+
}, ee = (H) => ({
|
|
2669
2591
|
...d.input,
|
|
2670
|
-
|
|
2592
|
+
...$[H] ? d.inputError : {}
|
|
2671
2593
|
}), z = () => ({
|
|
2672
2594
|
...d.button,
|
|
2673
|
-
...C ||
|
|
2674
|
-
...!
|
|
2595
|
+
...C || P ? d.buttonLoading : {},
|
|
2596
|
+
...!T || C || P ? d.buttonDisabled : {}
|
|
2675
2597
|
});
|
|
2676
|
-
return
|
|
2677
|
-
/* @__PURE__ */ n("h2", { style: d.title, children:
|
|
2598
|
+
return P ? /* @__PURE__ */ a("div", { className: y, style: d.container, children: [
|
|
2599
|
+
/* @__PURE__ */ n("h2", { style: d.title, children: b.verifyingText }),
|
|
2678
2600
|
/* @__PURE__ */ n("div", { style: { textAlign: "center", padding: "2rem" }, children: /* @__PURE__ */ n("div", { style: { fontSize: "1rem", color: "#6b7280" }, children: "Please wait while we verify your magic link..." }) })
|
|
2679
|
-
] }) : /* @__PURE__ */
|
|
2680
|
-
/* @__PURE__ */ n("h2", { style: d.title, children:
|
|
2681
|
-
/* @__PURE__ */ n("p", { style: d.description, children:
|
|
2682
|
-
/* @__PURE__ */
|
|
2683
|
-
/* @__PURE__ */
|
|
2684
|
-
/* @__PURE__ */ n("label", { style: d.label, children:
|
|
2601
|
+
] }) : /* @__PURE__ */ a("div", { className: y, style: d.container, children: [
|
|
2602
|
+
/* @__PURE__ */ n("h2", { style: d.title, children: b.title }),
|
|
2603
|
+
/* @__PURE__ */ n("p", { style: d.description, children: b.description }),
|
|
2604
|
+
/* @__PURE__ */ a("form", { onSubmit: G, style: d.form, children: [
|
|
2605
|
+
/* @__PURE__ */ a("div", { style: d.fieldGroup, children: [
|
|
2606
|
+
/* @__PURE__ */ n("label", { style: d.label, children: b.emailLabel }),
|
|
2685
2607
|
/* @__PURE__ */ n(
|
|
2686
2608
|
"input",
|
|
2687
2609
|
{
|
|
2688
2610
|
id: "email",
|
|
2689
2611
|
name: "email",
|
|
2690
2612
|
type: "email",
|
|
2691
|
-
value:
|
|
2692
|
-
onChange: (
|
|
2693
|
-
|
|
2613
|
+
value: T,
|
|
2614
|
+
onChange: (H) => {
|
|
2615
|
+
f(H.target.value), $.email && j((O) => ({ ...O, email: !1 }));
|
|
2694
2616
|
},
|
|
2695
|
-
placeholder:
|
|
2617
|
+
placeholder: b.emailPlaceholder,
|
|
2696
2618
|
style: ee("email"),
|
|
2697
|
-
disabled: C ||
|
|
2619
|
+
disabled: C || P
|
|
2698
2620
|
}
|
|
2699
2621
|
)
|
|
2700
2622
|
] }),
|
|
2701
|
-
!
|
|
2623
|
+
!v && /* @__PURE__ */ n("div", { style: { textAlign: "center", marginTop: "0.5rem" }, children: /* @__PURE__ */ n(
|
|
2702
2624
|
"button",
|
|
2703
2625
|
{
|
|
2704
2626
|
type: "button",
|
|
2705
|
-
onClick: () =>
|
|
2627
|
+
onClick: () => I(!0),
|
|
2706
2628
|
style: {
|
|
2707
2629
|
background: "none",
|
|
2708
2630
|
border: "none",
|
|
@@ -2714,38 +2636,38 @@ function Ht({
|
|
|
2714
2636
|
children: "New user? Add your name"
|
|
2715
2637
|
}
|
|
2716
2638
|
) }),
|
|
2717
|
-
|
|
2718
|
-
/* @__PURE__ */
|
|
2719
|
-
/* @__PURE__ */ n("label", { style: d.label, children:
|
|
2639
|
+
v && /* @__PURE__ */ a(B, { children: [
|
|
2640
|
+
/* @__PURE__ */ a("div", { style: d.fieldGroup, children: [
|
|
2641
|
+
/* @__PURE__ */ n("label", { style: d.label, children: b.nameLabel }),
|
|
2720
2642
|
/* @__PURE__ */ n(
|
|
2721
2643
|
"input",
|
|
2722
2644
|
{
|
|
2723
2645
|
id: "name",
|
|
2724
2646
|
name: "name",
|
|
2725
2647
|
type: "text",
|
|
2726
|
-
value:
|
|
2727
|
-
onChange: (
|
|
2728
|
-
h(
|
|
2648
|
+
value: p,
|
|
2649
|
+
onChange: (H) => {
|
|
2650
|
+
h(H.target.value), $.name && j((O) => ({ ...O, name: !1 }));
|
|
2729
2651
|
},
|
|
2730
|
-
placeholder:
|
|
2652
|
+
placeholder: b.namePlaceholder,
|
|
2731
2653
|
style: ee("name"),
|
|
2732
|
-
disabled: C ||
|
|
2654
|
+
disabled: C || P
|
|
2733
2655
|
}
|
|
2734
2656
|
)
|
|
2735
2657
|
] }),
|
|
2736
|
-
/* @__PURE__ */
|
|
2737
|
-
/* @__PURE__ */ n("label", { style: d.label, children:
|
|
2658
|
+
/* @__PURE__ */ a("div", { style: d.fieldGroup, children: [
|
|
2659
|
+
/* @__PURE__ */ n("label", { style: d.label, children: b.lastNameLabel }),
|
|
2738
2660
|
/* @__PURE__ */ n(
|
|
2739
2661
|
"input",
|
|
2740
2662
|
{
|
|
2741
2663
|
id: "lastName",
|
|
2742
2664
|
name: "lastName",
|
|
2743
2665
|
type: "text",
|
|
2744
|
-
value:
|
|
2745
|
-
onChange: (
|
|
2746
|
-
placeholder:
|
|
2666
|
+
value: m,
|
|
2667
|
+
onChange: (H) => R(H.target.value),
|
|
2668
|
+
placeholder: b.lastNamePlaceholder,
|
|
2747
2669
|
style: d.input,
|
|
2748
|
-
disabled: C ||
|
|
2670
|
+
disabled: C || P
|
|
2749
2671
|
}
|
|
2750
2672
|
)
|
|
2751
2673
|
] }),
|
|
@@ -2754,7 +2676,7 @@ function Ht({
|
|
|
2754
2676
|
{
|
|
2755
2677
|
type: "button",
|
|
2756
2678
|
onClick: () => {
|
|
2757
|
-
|
|
2679
|
+
I(!1), h(""), R("");
|
|
2758
2680
|
},
|
|
2759
2681
|
style: {
|
|
2760
2682
|
background: "none",
|
|
@@ -2768,25 +2690,25 @@ function Ht({
|
|
|
2768
2690
|
}
|
|
2769
2691
|
) })
|
|
2770
2692
|
] }),
|
|
2771
|
-
/* @__PURE__ */ n("button", { type: "submit", disabled: !
|
|
2772
|
-
|
|
2773
|
-
|
|
2693
|
+
/* @__PURE__ */ n("button", { type: "submit", disabled: !T || C || P, style: z(), children: C ? b.loadingText : b.submitButton }),
|
|
2694
|
+
M && /* @__PURE__ */ n("div", { style: d.errorText, children: M }),
|
|
2695
|
+
q && /* @__PURE__ */ n("div", { style: d.successText, children: q })
|
|
2774
2696
|
] }),
|
|
2775
|
-
|
|
2776
|
-
/* @__PURE__ */
|
|
2777
|
-
/* @__PURE__ */
|
|
2778
|
-
|
|
2697
|
+
g && /* @__PURE__ */ a("div", { style: d.linkContainer, children: [
|
|
2698
|
+
/* @__PURE__ */ a("div", { children: [
|
|
2699
|
+
/* @__PURE__ */ a("span", { style: d.divider, children: [
|
|
2700
|
+
b.loginText,
|
|
2779
2701
|
" "
|
|
2780
2702
|
] }),
|
|
2781
|
-
/* @__PURE__ */ n("a", { onClick: s, style: d.link, children:
|
|
2703
|
+
/* @__PURE__ */ n("a", { onClick: s, style: d.link, children: b.loginLink })
|
|
2782
2704
|
] }),
|
|
2783
2705
|
/* @__PURE__ */ n("div", { style: d.divider, children: "•" }),
|
|
2784
|
-
/* @__PURE__ */
|
|
2785
|
-
/* @__PURE__ */
|
|
2786
|
-
|
|
2706
|
+
/* @__PURE__ */ a("div", { children: [
|
|
2707
|
+
/* @__PURE__ */ a("span", { style: d.divider, children: [
|
|
2708
|
+
b.signupText,
|
|
2787
2709
|
" "
|
|
2788
2710
|
] }),
|
|
2789
|
-
/* @__PURE__ */ n("a", { onClick:
|
|
2711
|
+
/* @__PURE__ */ n("a", { onClick: o, style: d.link, children: b.signupLink })
|
|
2790
2712
|
] })
|
|
2791
2713
|
] })
|
|
2792
2714
|
] });
|
|
@@ -2886,7 +2808,7 @@ const at = {
|
|
|
2886
2808
|
cursor: "pointer",
|
|
2887
2809
|
transition: "all 0.15s ease-in-out"
|
|
2888
2810
|
}
|
|
2889
|
-
}, lt = () => /* @__PURE__ */ n("div", { style: Ee.spinner }), ct = () => /* @__PURE__ */
|
|
2811
|
+
}, lt = () => /* @__PURE__ */ n("div", { style: Ee.spinner }), ct = () => /* @__PURE__ */ a(
|
|
2890
2812
|
"svg",
|
|
2891
2813
|
{
|
|
2892
2814
|
width: "48",
|
|
@@ -2903,7 +2825,7 @@ const at = {
|
|
|
2903
2825
|
/* @__PURE__ */ n("polyline", { points: "22,4 12,14.01 9,11.01" })
|
|
2904
2826
|
]
|
|
2905
2827
|
}
|
|
2906
|
-
), dt = () => /* @__PURE__ */
|
|
2828
|
+
), dt = () => /* @__PURE__ */ a(
|
|
2907
2829
|
"svg",
|
|
2908
2830
|
{
|
|
2909
2831
|
width: "48",
|
|
@@ -2926,104 +2848,104 @@ const at = {
|
|
|
2926
2848
|
success: /* @__PURE__ */ n(ct, {}),
|
|
2927
2849
|
error: /* @__PURE__ */ n(dt, {})
|
|
2928
2850
|
};
|
|
2929
|
-
function
|
|
2851
|
+
function Ut({
|
|
2930
2852
|
copy: i = {},
|
|
2931
2853
|
styles: e = {},
|
|
2932
2854
|
icons: t = {},
|
|
2933
2855
|
onSuccess: r,
|
|
2934
2856
|
onError: s,
|
|
2935
|
-
onRetry:
|
|
2936
|
-
onBackToLogin:
|
|
2937
|
-
className:
|
|
2857
|
+
onRetry: o,
|
|
2858
|
+
onBackToLogin: g,
|
|
2859
|
+
className: y,
|
|
2938
2860
|
token: A,
|
|
2939
|
-
email:
|
|
2940
|
-
appId:
|
|
2941
|
-
tenantSlug:
|
|
2942
|
-
autoRedirectDelay:
|
|
2861
|
+
email: w,
|
|
2862
|
+
appId: T,
|
|
2863
|
+
tenantSlug: f,
|
|
2864
|
+
autoRedirectDelay: p = 3e3
|
|
2943
2865
|
}) {
|
|
2944
|
-
const [h,
|
|
2866
|
+
const [h, m] = k("verifying"), [R, C] = k(""), { verifyMagicLink: U } = ae(), P = { ...at, ...i }, u = { ...Ee, ...e }, M = { ...ut, ...t }, E = () => {
|
|
2945
2867
|
if (typeof window > "u") return {};
|
|
2946
|
-
const
|
|
2868
|
+
const v = new URLSearchParams(window.location.search);
|
|
2947
2869
|
return {
|
|
2948
|
-
token: A ||
|
|
2949
|
-
email:
|
|
2950
|
-
appId:
|
|
2951
|
-
tenantSlug:
|
|
2870
|
+
token: A || v.get("token") || "",
|
|
2871
|
+
email: w || v.get("email") || "",
|
|
2872
|
+
appId: T || v.get("appId") || "",
|
|
2873
|
+
tenantSlug: f || v.get("tenantSlug") || void 0
|
|
2952
2874
|
};
|
|
2953
|
-
},
|
|
2954
|
-
|
|
2875
|
+
}, q = async () => {
|
|
2876
|
+
m("verifying"), C("");
|
|
2955
2877
|
try {
|
|
2956
|
-
const
|
|
2957
|
-
if (!
|
|
2878
|
+
const v = E();
|
|
2879
|
+
if (!v.token || !v.email)
|
|
2958
2880
|
throw new Error("Missing required parameters: token or email");
|
|
2959
|
-
const
|
|
2960
|
-
token:
|
|
2961
|
-
email:
|
|
2962
|
-
tenantSlug:
|
|
2881
|
+
const I = await U({
|
|
2882
|
+
token: v.token,
|
|
2883
|
+
email: v.email,
|
|
2884
|
+
tenantSlug: v.tenantSlug
|
|
2963
2885
|
});
|
|
2964
|
-
|
|
2965
|
-
|
|
2966
|
-
},
|
|
2967
|
-
} catch (
|
|
2968
|
-
const
|
|
2969
|
-
C(
|
|
2886
|
+
m("success"), r == null || r(I), p > 0 && setTimeout(() => {
|
|
2887
|
+
m("redirecting");
|
|
2888
|
+
}, p);
|
|
2889
|
+
} catch (v) {
|
|
2890
|
+
const I = v.message || P.errorMessage;
|
|
2891
|
+
C(I), m("error"), s == null || s(I);
|
|
2970
2892
|
}
|
|
2971
|
-
},
|
|
2972
|
-
|
|
2973
|
-
},
|
|
2974
|
-
|
|
2893
|
+
}, V = () => {
|
|
2894
|
+
o == null || o(), q();
|
|
2895
|
+
}, $ = () => {
|
|
2896
|
+
g == null || g();
|
|
2975
2897
|
};
|
|
2976
2898
|
te(() => {
|
|
2977
|
-
|
|
2899
|
+
q();
|
|
2978
2900
|
}, []);
|
|
2979
|
-
const
|
|
2901
|
+
const j = () => {
|
|
2980
2902
|
switch (h) {
|
|
2981
2903
|
case "verifying":
|
|
2982
|
-
return /* @__PURE__ */
|
|
2983
|
-
|
|
2984
|
-
|
|
2904
|
+
return /* @__PURE__ */ a("div", { style: u.message, children: [
|
|
2905
|
+
M.loading,
|
|
2906
|
+
P.verifyingMessage
|
|
2985
2907
|
] });
|
|
2986
2908
|
case "success":
|
|
2987
|
-
return /* @__PURE__ */
|
|
2988
|
-
|
|
2989
|
-
/* @__PURE__ */ n("div", { style: u.successMessage, children:
|
|
2909
|
+
return /* @__PURE__ */ a(B, { children: [
|
|
2910
|
+
M.success,
|
|
2911
|
+
/* @__PURE__ */ n("div", { style: u.successMessage, children: P.successMessage })
|
|
2990
2912
|
] });
|
|
2991
2913
|
case "redirecting":
|
|
2992
|
-
return /* @__PURE__ */
|
|
2993
|
-
|
|
2994
|
-
/* @__PURE__ */ n("div", { style: u.message, children:
|
|
2914
|
+
return /* @__PURE__ */ a(B, { children: [
|
|
2915
|
+
M.loading,
|
|
2916
|
+
/* @__PURE__ */ n("div", { style: u.message, children: P.redirectingMessage })
|
|
2995
2917
|
] });
|
|
2996
2918
|
case "error":
|
|
2997
|
-
return /* @__PURE__ */
|
|
2998
|
-
|
|
2999
|
-
/* @__PURE__ */ n("div", { style: u.errorMessage, children:
|
|
3000
|
-
/* @__PURE__ */
|
|
2919
|
+
return /* @__PURE__ */ a(B, { children: [
|
|
2920
|
+
M.error,
|
|
2921
|
+
/* @__PURE__ */ n("div", { style: u.errorMessage, children: R || P.errorMessage }),
|
|
2922
|
+
/* @__PURE__ */ a("div", { style: u.buttonContainer, children: [
|
|
3001
2923
|
/* @__PURE__ */ n(
|
|
3002
2924
|
"button",
|
|
3003
2925
|
{
|
|
3004
|
-
onClick:
|
|
2926
|
+
onClick: V,
|
|
3005
2927
|
style: u.retryButton,
|
|
3006
|
-
onMouseOver: (
|
|
3007
|
-
|
|
2928
|
+
onMouseOver: (v) => {
|
|
2929
|
+
v.currentTarget.style.backgroundColor = "#2563eb";
|
|
3008
2930
|
},
|
|
3009
|
-
onMouseOut: (
|
|
3010
|
-
|
|
2931
|
+
onMouseOut: (v) => {
|
|
2932
|
+
v.currentTarget.style.backgroundColor = "#3b82f6";
|
|
3011
2933
|
},
|
|
3012
|
-
children:
|
|
2934
|
+
children: P.retryButton
|
|
3013
2935
|
}
|
|
3014
2936
|
),
|
|
3015
2937
|
/* @__PURE__ */ n(
|
|
3016
2938
|
"button",
|
|
3017
2939
|
{
|
|
3018
|
-
onClick:
|
|
2940
|
+
onClick: $,
|
|
3019
2941
|
style: u.backButton,
|
|
3020
|
-
onMouseOver: (
|
|
3021
|
-
|
|
2942
|
+
onMouseOver: (v) => {
|
|
2943
|
+
v.currentTarget.style.backgroundColor = "#e5e7eb";
|
|
3022
2944
|
},
|
|
3023
|
-
onMouseOut: (
|
|
3024
|
-
|
|
2945
|
+
onMouseOut: (v) => {
|
|
2946
|
+
v.currentTarget.style.backgroundColor = "#f3f4f6";
|
|
3025
2947
|
},
|
|
3026
|
-
children:
|
|
2948
|
+
children: P.backToLoginButton
|
|
3027
2949
|
}
|
|
3028
2950
|
)
|
|
3029
2951
|
] })
|
|
@@ -3032,15 +2954,15 @@ function Nt({
|
|
|
3032
2954
|
return null;
|
|
3033
2955
|
}
|
|
3034
2956
|
};
|
|
3035
|
-
return /* @__PURE__ */
|
|
2957
|
+
return /* @__PURE__ */ a("div", { style: u.container, className: y, children: [
|
|
3036
2958
|
/* @__PURE__ */ n("style", { children: `
|
|
3037
2959
|
@keyframes spin {
|
|
3038
2960
|
0% { transform: rotate(0deg); }
|
|
3039
2961
|
100% { transform: rotate(360deg); }
|
|
3040
2962
|
}
|
|
3041
2963
|
` }),
|
|
3042
|
-
/* @__PURE__ */ n("h1", { style: u.title, children:
|
|
3043
|
-
|
|
2964
|
+
/* @__PURE__ */ n("h1", { style: u.title, children: P.title }),
|
|
2965
|
+
j()
|
|
3044
2966
|
] });
|
|
3045
2967
|
}
|
|
3046
2968
|
const ht = {
|
|
@@ -3157,113 +3079,113 @@ const ht = {
|
|
|
3157
3079
|
cursor: "pointer"
|
|
3158
3080
|
}
|
|
3159
3081
|
};
|
|
3160
|
-
function
|
|
3082
|
+
function qt({
|
|
3161
3083
|
copy: i = {},
|
|
3162
3084
|
styles: e = {},
|
|
3163
3085
|
mode: t = "request",
|
|
3164
3086
|
token: r = "",
|
|
3165
3087
|
onSuccess: s,
|
|
3166
|
-
onError:
|
|
3167
|
-
onBackToLogin:
|
|
3168
|
-
onModeChange:
|
|
3088
|
+
onError: o,
|
|
3089
|
+
onBackToLogin: g,
|
|
3090
|
+
onModeChange: y,
|
|
3169
3091
|
className: A
|
|
3170
3092
|
}) {
|
|
3171
|
-
const [
|
|
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 = () => {
|
|
3172
3094
|
const z = {};
|
|
3173
|
-
return
|
|
3174
|
-
},
|
|
3095
|
+
return w.trim() || (z.email = !0), $(z), Object.keys(z).length === 0;
|
|
3096
|
+
}, b = () => {
|
|
3175
3097
|
const z = {};
|
|
3176
|
-
return
|
|
3098
|
+
return f.trim() || (z.token = !0), h.trim() || (z.newPassword = !0), R.trim() || (z.confirmPassword = !0), $(z), Object.keys(z).length === 0;
|
|
3177
3099
|
}, d = async (z) => {
|
|
3178
|
-
if (z.preventDefault(), !!
|
|
3179
|
-
if (!(
|
|
3180
|
-
|
|
3100
|
+
if (z.preventDefault(), !!x()) {
|
|
3101
|
+
if (!(I != null && I.id)) {
|
|
3102
|
+
M("Tenant not found");
|
|
3181
3103
|
return;
|
|
3182
3104
|
}
|
|
3183
|
-
|
|
3105
|
+
P(!0), M(""), q("");
|
|
3184
3106
|
try {
|
|
3185
|
-
await
|
|
3186
|
-
} catch (
|
|
3187
|
-
const O =
|
|
3188
|
-
|
|
3107
|
+
await j({ email: w, tenantId: I.id }), q(L.successMessage), s == null || s();
|
|
3108
|
+
} catch (H) {
|
|
3109
|
+
const O = H.message || L.errorMessage;
|
|
3110
|
+
M(O), o == null || o(O);
|
|
3189
3111
|
} finally {
|
|
3190
|
-
|
|
3112
|
+
P(!1);
|
|
3191
3113
|
}
|
|
3192
3114
|
}
|
|
3193
3115
|
}, c = async (z) => {
|
|
3194
|
-
if (z.preventDefault(), !!
|
|
3195
|
-
if (h !==
|
|
3196
|
-
|
|
3116
|
+
if (z.preventDefault(), !!b()) {
|
|
3117
|
+
if (h !== R) {
|
|
3118
|
+
M(L.passwordMismatchError), $({ confirmPassword: !0 });
|
|
3197
3119
|
return;
|
|
3198
3120
|
}
|
|
3199
|
-
|
|
3121
|
+
P(!0), M(""), q("");
|
|
3200
3122
|
try {
|
|
3201
|
-
await
|
|
3202
|
-
} catch (
|
|
3203
|
-
const O =
|
|
3204
|
-
|
|
3123
|
+
await v({ token: f, newPassword: h }), q(L.resetSuccessMessage), s == null || s();
|
|
3124
|
+
} catch (H) {
|
|
3125
|
+
const O = H.message || L.errorMessage;
|
|
3126
|
+
M(O), o == null || o(O);
|
|
3205
3127
|
} finally {
|
|
3206
|
-
|
|
3128
|
+
P(!1);
|
|
3207
3129
|
}
|
|
3208
3130
|
}
|
|
3209
|
-
},
|
|
3210
|
-
...
|
|
3211
|
-
...
|
|
3212
|
-
}),
|
|
3213
|
-
...
|
|
3214
|
-
...
|
|
3131
|
+
}, S = (z) => ({
|
|
3132
|
+
...l.input,
|
|
3133
|
+
...V[z] ? l.inputError : {}
|
|
3134
|
+
}), G = () => ({
|
|
3135
|
+
...l.button,
|
|
3136
|
+
...U ? l.buttonLoading : {}
|
|
3215
3137
|
});
|
|
3216
3138
|
if (t === "reset") {
|
|
3217
|
-
const z =
|
|
3218
|
-
return /* @__PURE__ */
|
|
3219
|
-
/* @__PURE__ */ n("h2", { style:
|
|
3220
|
-
/* @__PURE__ */ n("p", { style:
|
|
3221
|
-
/* @__PURE__ */
|
|
3222
|
-
/* @__PURE__ */
|
|
3223
|
-
/* @__PURE__ */ n("label", { style:
|
|
3139
|
+
const z = f && h && R;
|
|
3140
|
+
return /* @__PURE__ */ a("div", { className: A, style: l.container, children: [
|
|
3141
|
+
/* @__PURE__ */ n("h2", { style: l.title, children: L.resetTitle }),
|
|
3142
|
+
/* @__PURE__ */ n("p", { style: l.subtitle, children: L.resetSubtitle }),
|
|
3143
|
+
/* @__PURE__ */ a("form", { onSubmit: c, style: l.form, children: [
|
|
3144
|
+
/* @__PURE__ */ a("div", { style: l.fieldGroup, children: [
|
|
3145
|
+
/* @__PURE__ */ n("label", { style: l.label, children: L.tokenLabel }),
|
|
3224
3146
|
/* @__PURE__ */ n(
|
|
3225
3147
|
"input",
|
|
3226
3148
|
{
|
|
3227
3149
|
type: "text",
|
|
3228
|
-
value:
|
|
3229
|
-
onChange: (
|
|
3230
|
-
|
|
3150
|
+
value: f,
|
|
3151
|
+
onChange: (H) => {
|
|
3152
|
+
p(H.target.value), V.token && $((O) => ({ ...O, token: !1 }));
|
|
3231
3153
|
},
|
|
3232
|
-
placeholder:
|
|
3233
|
-
style:
|
|
3234
|
-
disabled:
|
|
3154
|
+
placeholder: L.tokenPlaceholder,
|
|
3155
|
+
style: S("token"),
|
|
3156
|
+
disabled: U
|
|
3235
3157
|
}
|
|
3236
3158
|
)
|
|
3237
3159
|
] }),
|
|
3238
|
-
/* @__PURE__ */
|
|
3239
|
-
/* @__PURE__ */ n("label", { style:
|
|
3160
|
+
/* @__PURE__ */ a("div", { style: l.fieldGroup, children: [
|
|
3161
|
+
/* @__PURE__ */ n("label", { style: l.label, children: L.newPasswordLabel }),
|
|
3240
3162
|
/* @__PURE__ */ n(
|
|
3241
3163
|
"input",
|
|
3242
3164
|
{
|
|
3243
3165
|
type: "password",
|
|
3244
3166
|
value: h,
|
|
3245
|
-
onChange: (
|
|
3246
|
-
|
|
3167
|
+
onChange: (H) => {
|
|
3168
|
+
m(H.target.value), V.newPassword && $((O) => ({ ...O, newPassword: !1 }));
|
|
3247
3169
|
},
|
|
3248
|
-
placeholder:
|
|
3249
|
-
style:
|
|
3250
|
-
disabled:
|
|
3170
|
+
placeholder: L.newPasswordPlaceholder,
|
|
3171
|
+
style: S("newPassword"),
|
|
3172
|
+
disabled: U
|
|
3251
3173
|
}
|
|
3252
3174
|
)
|
|
3253
3175
|
] }),
|
|
3254
|
-
/* @__PURE__ */
|
|
3255
|
-
/* @__PURE__ */ n("label", { style:
|
|
3176
|
+
/* @__PURE__ */ a("div", { style: l.fieldGroup, children: [
|
|
3177
|
+
/* @__PURE__ */ n("label", { style: l.label, children: L.confirmPasswordLabel }),
|
|
3256
3178
|
/* @__PURE__ */ n(
|
|
3257
3179
|
"input",
|
|
3258
3180
|
{
|
|
3259
3181
|
type: "password",
|
|
3260
|
-
value:
|
|
3261
|
-
onChange: (
|
|
3262
|
-
C(
|
|
3182
|
+
value: R,
|
|
3183
|
+
onChange: (H) => {
|
|
3184
|
+
C(H.target.value), V.confirmPassword && $((O) => ({ ...O, confirmPassword: !1 })), u === L.passwordMismatchError && M("");
|
|
3263
3185
|
},
|
|
3264
|
-
placeholder:
|
|
3265
|
-
style:
|
|
3266
|
-
disabled:
|
|
3186
|
+
placeholder: L.confirmPasswordPlaceholder,
|
|
3187
|
+
style: S("confirmPassword"),
|
|
3188
|
+
disabled: U
|
|
3267
3189
|
}
|
|
3268
3190
|
)
|
|
3269
3191
|
] }),
|
|
@@ -3271,44 +3193,44 @@ function Bt({
|
|
|
3271
3193
|
"button",
|
|
3272
3194
|
{
|
|
3273
3195
|
type: "submit",
|
|
3274
|
-
disabled: !z ||
|
|
3196
|
+
disabled: !z || U,
|
|
3275
3197
|
style: {
|
|
3276
|
-
...
|
|
3277
|
-
...!z ||
|
|
3198
|
+
...G(),
|
|
3199
|
+
...!z || U ? l.buttonDisabled : {}
|
|
3278
3200
|
},
|
|
3279
|
-
children:
|
|
3201
|
+
children: U ? L.resetLoadingText : L.resetSubmitButton
|
|
3280
3202
|
}
|
|
3281
3203
|
),
|
|
3282
|
-
u && /* @__PURE__ */ n("div", { style:
|
|
3283
|
-
|
|
3204
|
+
u && /* @__PURE__ */ n("div", { style: l.errorText, children: u }),
|
|
3205
|
+
E && /* @__PURE__ */ n("div", { style: l.successText, children: E })
|
|
3284
3206
|
] }),
|
|
3285
|
-
/* @__PURE__ */
|
|
3286
|
-
/* @__PURE__ */ n("a", { onClick:
|
|
3287
|
-
|
|
3207
|
+
/* @__PURE__ */ a("div", { style: l.linkContainer, children: [
|
|
3208
|
+
/* @__PURE__ */ n("a", { onClick: g, style: l.link, children: L.backToLoginLink }),
|
|
3209
|
+
y && /* @__PURE__ */ a(B, { children: [
|
|
3288
3210
|
/* @__PURE__ */ n("span", { style: { margin: "0 0.5rem", color: "#6b7280" }, children: "•" }),
|
|
3289
|
-
/* @__PURE__ */ n("a", { onClick: () =>
|
|
3211
|
+
/* @__PURE__ */ n("a", { onClick: () => y("request"), style: l.link, children: "Request New Link" })
|
|
3290
3212
|
] })
|
|
3291
3213
|
] })
|
|
3292
3214
|
] });
|
|
3293
3215
|
}
|
|
3294
|
-
const ee =
|
|
3295
|
-
return /* @__PURE__ */
|
|
3296
|
-
/* @__PURE__ */ n("h2", { style:
|
|
3297
|
-
/* @__PURE__ */ n("p", { style:
|
|
3298
|
-
/* @__PURE__ */
|
|
3299
|
-
/* @__PURE__ */
|
|
3300
|
-
/* @__PURE__ */ n("label", { style:
|
|
3216
|
+
const ee = w;
|
|
3217
|
+
return /* @__PURE__ */ a("div", { className: A, style: l.container, children: [
|
|
3218
|
+
/* @__PURE__ */ n("h2", { style: l.title, children: L.title }),
|
|
3219
|
+
/* @__PURE__ */ n("p", { style: l.subtitle, children: L.subtitle }),
|
|
3220
|
+
/* @__PURE__ */ a("form", { onSubmit: d, style: l.form, children: [
|
|
3221
|
+
/* @__PURE__ */ a("div", { style: l.fieldGroup, children: [
|
|
3222
|
+
/* @__PURE__ */ n("label", { style: l.label, children: L.emailLabel }),
|
|
3301
3223
|
/* @__PURE__ */ n(
|
|
3302
3224
|
"input",
|
|
3303
3225
|
{
|
|
3304
3226
|
type: "email",
|
|
3305
|
-
value:
|
|
3227
|
+
value: w,
|
|
3306
3228
|
onChange: (z) => {
|
|
3307
|
-
|
|
3229
|
+
T(z.target.value), V.email && $((H) => ({ ...H, email: !1 }));
|
|
3308
3230
|
},
|
|
3309
|
-
placeholder:
|
|
3310
|
-
style:
|
|
3311
|
-
disabled:
|
|
3231
|
+
placeholder: L.emailPlaceholder,
|
|
3232
|
+
style: S("email"),
|
|
3233
|
+
disabled: U
|
|
3312
3234
|
}
|
|
3313
3235
|
)
|
|
3314
3236
|
] }),
|
|
@@ -3316,27 +3238,106 @@ function Bt({
|
|
|
3316
3238
|
"button",
|
|
3317
3239
|
{
|
|
3318
3240
|
type: "submit",
|
|
3319
|
-
disabled: !ee ||
|
|
3241
|
+
disabled: !ee || U,
|
|
3320
3242
|
style: {
|
|
3321
|
-
...
|
|
3322
|
-
...!ee ||
|
|
3243
|
+
...G(),
|
|
3244
|
+
...!ee || U ? l.buttonDisabled : {}
|
|
3323
3245
|
},
|
|
3324
|
-
children:
|
|
3246
|
+
children: U ? L.loadingText : L.submitButton
|
|
3325
3247
|
}
|
|
3326
3248
|
),
|
|
3327
|
-
u && /* @__PURE__ */ n("div", { style:
|
|
3328
|
-
|
|
3249
|
+
u && /* @__PURE__ */ n("div", { style: l.errorText, children: u }),
|
|
3250
|
+
E && /* @__PURE__ */ n("div", { style: l.successText, children: E })
|
|
3329
3251
|
] }),
|
|
3330
|
-
/* @__PURE__ */
|
|
3331
|
-
/* @__PURE__ */ n("a", { onClick:
|
|
3332
|
-
|
|
3252
|
+
/* @__PURE__ */ a("div", { style: l.linkContainer, children: [
|
|
3253
|
+
/* @__PURE__ */ n("a", { onClick: g, style: l.link, children: L.backToLoginLink }),
|
|
3254
|
+
y && /* @__PURE__ */ a(B, { children: [
|
|
3333
3255
|
/* @__PURE__ */ n("span", { style: { margin: "0 0.5rem", color: "#6b7280" }, children: "•" }),
|
|
3334
|
-
/* @__PURE__ */ n("a", { onClick: () =>
|
|
3256
|
+
/* @__PURE__ */ n("a", { onClick: () => y("reset"), style: l.link, children: "I have a token" })
|
|
3335
3257
|
] })
|
|
3336
3258
|
] })
|
|
3337
3259
|
] });
|
|
3338
3260
|
}
|
|
3339
|
-
|
|
3261
|
+
const pt = () => /* @__PURE__ */ n(
|
|
3262
|
+
"div",
|
|
3263
|
+
{
|
|
3264
|
+
style: {
|
|
3265
|
+
display: "flex",
|
|
3266
|
+
justifyContent: "center",
|
|
3267
|
+
alignItems: "center",
|
|
3268
|
+
height: "100vh",
|
|
3269
|
+
fontFamily: "system-ui, sans-serif"
|
|
3270
|
+
},
|
|
3271
|
+
children: /* @__PURE__ */ n("div", { children: "Loading..." })
|
|
3272
|
+
}
|
|
3273
|
+
), ft = ({ error: i, retry: e }) => /* @__PURE__ */ a(
|
|
3274
|
+
"div",
|
|
3275
|
+
{
|
|
3276
|
+
style: {
|
|
3277
|
+
display: "flex",
|
|
3278
|
+
flexDirection: "column",
|
|
3279
|
+
justifyContent: "center",
|
|
3280
|
+
alignItems: "center",
|
|
3281
|
+
height: "100vh",
|
|
3282
|
+
fontFamily: "system-ui, sans-serif",
|
|
3283
|
+
textAlign: "center",
|
|
3284
|
+
padding: "20px"
|
|
3285
|
+
},
|
|
3286
|
+
children: [
|
|
3287
|
+
/* @__PURE__ */ n("h2", { style: { color: "#dc3545", marginBottom: "16px" }, children: "Error" }),
|
|
3288
|
+
/* @__PURE__ */ n("p", { style: { color: "#6c757d", marginBottom: "24px" }, children: i.message || "Unable to load application" }),
|
|
3289
|
+
/* @__PURE__ */ n(
|
|
3290
|
+
"button",
|
|
3291
|
+
{
|
|
3292
|
+
onClick: e,
|
|
3293
|
+
style: {
|
|
3294
|
+
padding: "8px 16px",
|
|
3295
|
+
backgroundColor: "#007bff",
|
|
3296
|
+
color: "white",
|
|
3297
|
+
border: "none",
|
|
3298
|
+
borderRadius: "4px",
|
|
3299
|
+
cursor: "pointer"
|
|
3300
|
+
},
|
|
3301
|
+
children: "Retry"
|
|
3302
|
+
}
|
|
3303
|
+
)
|
|
3304
|
+
]
|
|
3305
|
+
}
|
|
3306
|
+
);
|
|
3307
|
+
function zt({
|
|
3308
|
+
children: i,
|
|
3309
|
+
loadingFallback: e,
|
|
3310
|
+
errorFallback: t,
|
|
3311
|
+
requireTenant: r = !0
|
|
3312
|
+
}) {
|
|
3313
|
+
const { isAppLoading: s, appError: o, retryApp: g } = oe(), y = Pe(), A = (y == null ? void 0 : y.isTenantLoading) ?? !1, w = (y == null ? void 0 : y.tenantError) ?? null, T = (y == null ? void 0 : y.tenantSlug) ?? null, f = (y == null ? void 0 : y.retryTenant) ?? (() => {
|
|
3314
|
+
}), p = r && y && T, h = s || p && A, m = o || (p ? w : null), R = () => {
|
|
3315
|
+
o && g(), w && y && f();
|
|
3316
|
+
};
|
|
3317
|
+
if (h)
|
|
3318
|
+
return /* @__PURE__ */ n(B, { children: e || /* @__PURE__ */ n(pt, {}) });
|
|
3319
|
+
if (m) {
|
|
3320
|
+
const C = typeof t == "function" ? t(m, R) : t || /* @__PURE__ */ n(ft, { error: m, retry: R });
|
|
3321
|
+
return /* @__PURE__ */ n(B, { children: C });
|
|
3322
|
+
}
|
|
3323
|
+
return /* @__PURE__ */ n(B, { children: i });
|
|
3324
|
+
}
|
|
3325
|
+
function Ot(i = !0) {
|
|
3326
|
+
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
|
+
}), f = i && o && w, p = e || f && g, h = t || (f ? y : null);
|
|
3328
|
+
return {
|
|
3329
|
+
isLoading: p,
|
|
3330
|
+
error: h,
|
|
3331
|
+
isReady: !p && !h && s !== null && (!f || A !== null),
|
|
3332
|
+
retry: () => {
|
|
3333
|
+
t && r(), y && o && T();
|
|
3334
|
+
},
|
|
3335
|
+
// Individual states
|
|
3336
|
+
app: { isLoading: e, error: t, data: s },
|
|
3337
|
+
tenant: o ? { isLoading: g, error: y, data: A } : null
|
|
3338
|
+
};
|
|
3339
|
+
}
|
|
3340
|
+
class Wt {
|
|
3340
3341
|
constructor(e, t) {
|
|
3341
3342
|
this.httpService = e, this.sessionManager = t;
|
|
3342
3343
|
}
|
|
@@ -3357,12 +3358,12 @@ class Ut {
|
|
|
3357
3358
|
throw new Error("SessionManager is required for private endpoints");
|
|
3358
3359
|
const t = await this.sessionManager.getAuthHeaders(), r = new URLSearchParams();
|
|
3359
3360
|
e != null && e.page && r.append("page", e.page.toString()), e != null && e.limit && r.append("limit", e.limit.toString()), e != null && e.sortBy && r.append("sortBy", e.sortBy), e != null && e.sortOrder && r.append("sortOrder", e.sortOrder);
|
|
3360
|
-
const s = `/permissions/${r.toString() ? `?${r.toString()}` : ""}`,
|
|
3361
|
+
const s = `/permissions/${r.toString() ? `?${r.toString()}` : ""}`, o = await this.httpService.get(s, {
|
|
3361
3362
|
headers: t
|
|
3362
3363
|
});
|
|
3363
3364
|
return {
|
|
3364
|
-
permissions:
|
|
3365
|
-
meta:
|
|
3365
|
+
permissions: o.data,
|
|
3366
|
+
meta: o.meta
|
|
3366
3367
|
};
|
|
3367
3368
|
}
|
|
3368
3369
|
async getPermissionById(e) {
|
|
@@ -3397,14 +3398,14 @@ class Ut {
|
|
|
3397
3398
|
async getAppPermissions(e, t) {
|
|
3398
3399
|
const r = new URLSearchParams();
|
|
3399
3400
|
t != null && t.page && r.append("page", t.page.toString()), t != null && t.limit && r.append("limit", t.limit.toString()), t != null && t.sortBy && r.append("sortBy", t.sortBy), t != null && t.sortOrder && r.append("sortOrder", t.sortOrder);
|
|
3400
|
-
const s = `/permissions/apps/${e}${r.toString() ? `?${r.toString()}` : ""}`,
|
|
3401
|
+
const s = `/permissions/apps/${e}${r.toString() ? `?${r.toString()}` : ""}`, o = await this.httpService.get(s);
|
|
3401
3402
|
return {
|
|
3402
|
-
permissions:
|
|
3403
|
-
meta:
|
|
3403
|
+
permissions: o.data,
|
|
3404
|
+
meta: o.meta
|
|
3404
3405
|
};
|
|
3405
3406
|
}
|
|
3406
3407
|
}
|
|
3407
|
-
class
|
|
3408
|
+
class jt {
|
|
3408
3409
|
constructor(e, t) {
|
|
3409
3410
|
this.httpService = e, this.sessionManager = t;
|
|
3410
3411
|
}
|
|
@@ -3421,12 +3422,12 @@ class qt {
|
|
|
3421
3422
|
async getSubscriptionPlans(e) {
|
|
3422
3423
|
const t = await this.sessionManager.getAuthHeaders(), r = new URLSearchParams();
|
|
3423
3424
|
e != null && e.page && r.append("page", e.page.toString()), e != null && e.limit && r.append("limit", e.limit.toString()), e != null && e.sortBy && r.append("sortBy", e.sortBy), e != null && e.sortOrder && r.append("sortOrder", e.sortOrder), e != null && e.appId && r.append("appId", e.appId);
|
|
3424
|
-
const s = `/subscription-plans/${r.toString() ? `?${r.toString()}` : ""}`,
|
|
3425
|
+
const s = `/subscription-plans/${r.toString() ? `?${r.toString()}` : ""}`, o = await this.httpService.get(s, {
|
|
3425
3426
|
headers: t
|
|
3426
3427
|
});
|
|
3427
3428
|
return {
|
|
3428
|
-
plans:
|
|
3429
|
-
meta:
|
|
3429
|
+
plans: o.data,
|
|
3430
|
+
meta: o.meta
|
|
3430
3431
|
};
|
|
3431
3432
|
}
|
|
3432
3433
|
async getSubscriptionPlanById(e) {
|
|
@@ -3455,7 +3456,7 @@ class qt {
|
|
|
3455
3456
|
});
|
|
3456
3457
|
}
|
|
3457
3458
|
}
|
|
3458
|
-
class
|
|
3459
|
+
class Vt {
|
|
3459
3460
|
constructor(e) {
|
|
3460
3461
|
this.httpService = e;
|
|
3461
3462
|
}
|
|
@@ -3464,7 +3465,7 @@ class zt {
|
|
|
3464
3465
|
return await this.httpService.get("/health");
|
|
3465
3466
|
}
|
|
3466
3467
|
}
|
|
3467
|
-
class
|
|
3468
|
+
class Gt {
|
|
3468
3469
|
// Date string to Date object
|
|
3469
3470
|
static toDate(e) {
|
|
3470
3471
|
return new Date(e);
|
|
@@ -3587,44 +3588,47 @@ class Ot {
|
|
|
3587
3588
|
}
|
|
3588
3589
|
}
|
|
3589
3590
|
export {
|
|
3590
|
-
|
|
3591
|
-
|
|
3592
|
-
|
|
3593
|
-
|
|
3594
|
-
|
|
3595
|
-
|
|
3591
|
+
Gt as ApiMappers,
|
|
3592
|
+
Se as AppApiService,
|
|
3593
|
+
zt as AppLoader,
|
|
3594
|
+
xt as AppProvider,
|
|
3595
|
+
He as AuthApiService,
|
|
3596
|
+
Mt as AuthProvider,
|
|
3597
|
+
Dt as FeatureFlag,
|
|
3596
3598
|
ze as FeatureFlagApiService,
|
|
3597
|
-
|
|
3598
|
-
|
|
3599
|
+
It as FeatureFlagProvider,
|
|
3600
|
+
Vt as HealthApiService,
|
|
3599
3601
|
re as HttpService,
|
|
3600
|
-
|
|
3601
|
-
|
|
3602
|
-
|
|
3603
|
-
|
|
3604
|
-
|
|
3605
|
-
|
|
3606
|
-
|
|
3607
|
-
|
|
3608
|
-
|
|
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,
|
|
3610
|
+
ve as RoleApiService,
|
|
3609
3611
|
ye as SessionManager,
|
|
3610
|
-
|
|
3611
|
-
|
|
3612
|
-
|
|
3613
|
-
|
|
3614
|
-
|
|
3615
|
-
|
|
3616
|
-
|
|
3617
|
-
|
|
3618
|
-
|
|
3612
|
+
Nt as SignupForm,
|
|
3613
|
+
We as SubscriptionApiService,
|
|
3614
|
+
Ft as SubscriptionGuard,
|
|
3615
|
+
jt as SubscriptionPlanApiService,
|
|
3616
|
+
Lt as SubscriptionProvider,
|
|
3617
|
+
ue as TenantApiService,
|
|
3618
|
+
At as TenantProvider,
|
|
3619
|
+
Ct as TenantRoute,
|
|
3620
|
+
Ne as UserApiService,
|
|
3619
3621
|
ie as UserType,
|
|
3620
|
-
|
|
3621
|
-
|
|
3622
|
-
|
|
3622
|
+
kt as useApi,
|
|
3623
|
+
oe as useApp,
|
|
3624
|
+
Ot as useAppLoaderState,
|
|
3625
|
+
ae as useAuth,
|
|
3623
3626
|
Oe as useFeatureFlags,
|
|
3624
|
-
|
|
3625
|
-
|
|
3627
|
+
Pt as useSettings,
|
|
3628
|
+
je as useSubscription,
|
|
3626
3629
|
fe as useTenant,
|
|
3627
3630
|
se as useTenantInfo,
|
|
3628
|
-
|
|
3631
|
+
Pe as useTenantOptional,
|
|
3632
|
+
Tt as useTenantSettings
|
|
3629
3633
|
};
|
|
3630
3634
|
//# sourceMappingURL=index.es.js.map
|