@skylabs-digital/react-identity-access 1.0.0 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.es.js CHANGED
@@ -1,7 +1,7 @@
1
- import { jsx as i, Fragment as B, jsxs as g } from "react/jsx-runtime";
2
- import { createContext as te, useState as b, useCallback as X, useMemo as N, useEffect as K, useContext as re } from "react";
3
- import { useLocation as we, Navigate as ie } from "react-router";
4
- class W {
1
+ import { jsx as n, Fragment as B, jsxs as u } from "react/jsx-runtime";
2
+ import { createContext as ee, useState as m, useMemo as O, useCallback as X, useEffect as K, useContext as te } from "react";
3
+ import { useLocation as me, Navigate as ae } from "react-router";
4
+ class G {
5
5
  // SessionManager instance
6
6
  constructor(e, t = 1e4) {
7
7
  this.baseUrl = e.replace(/\/$/, ""), this.timeout = t;
@@ -15,41 +15,41 @@ class W {
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, o = !1) {
19
- const T = `${this.baseUrl}${t.startsWith("/") ? t : `/${t}`}`, M = (s == null ? void 0 : s.timeout) || this.timeout;
20
- let S = {
18
+ async executeRequest(e, t, r, s, a = !1) {
19
+ const v = `${this.baseUrl}${t.startsWith("/") ? t : `/${t}`}`, M = (s == null ? void 0 : s.timeout) || this.timeout;
20
+ let k = {
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 p = await this.sessionManager.getAuthHeaders();
27
- S = { ...S, ...p };
28
- } catch (p) {
29
- console.warn("Failed to inject auth headers:", p);
26
+ const g = await this.sessionManager.getAuthHeaders();
27
+ k = { ...k, ...g };
28
+ } catch (g) {
29
+ console.warn("Failed to inject auth headers:", g);
30
30
  }
31
- const E = new AbortController(), w = setTimeout(() => E.abort(), M);
31
+ const P = new AbortController(), h = setTimeout(() => P.abort(), M);
32
32
  try {
33
- const p = await fetch(T, {
33
+ const g = await fetch(v, {
34
34
  method: e,
35
- headers: S,
35
+ headers: k,
36
36
  body: r ? JSON.stringify(r) : void 0,
37
- signal: E.signal
37
+ signal: P.signal
38
38
  });
39
- if (clearTimeout(w), p.status === 401 && !(s != null && s.skipRetry) && !o && this.sessionManager)
39
+ if (clearTimeout(h), g.status === 401 && !(s != null && s.skipRetry) && !a && this.sessionManager)
40
40
  try {
41
41
  const f = this.sessionManager.getTokens();
42
42
  if (f != null && f.refreshToken)
43
43
  return await this.sessionManager.getAuthHeaders(), this.executeRequest(e, t, r, s, !0);
44
44
  } catch {
45
- throw new Error(`HTTP ${p.status}: ${p.statusText}`);
45
+ throw new Error(`HTTP ${g.status}: ${g.statusText}`);
46
46
  }
47
- if (!p.ok)
48
- throw new Error(`HTTP ${p.status}: ${p.statusText}`);
49
- const v = p.headers.get("content-type");
50
- return !v || !v.includes("application/json") ? {} : await p.json();
51
- } catch (p) {
52
- throw clearTimeout(w), p instanceof Error && p.name === "AbortError" ? new Error(`Request timeout after ${M}ms`) : p;
47
+ if (!g.ok)
48
+ throw new Error(`HTTP ${g.status}: ${g.statusText}`);
49
+ const x = g.headers.get("content-type");
50
+ return !x || !x.includes("application/json") ? {} : await g.json();
51
+ } catch (g) {
52
+ throw clearTimeout(h), g instanceof Error && g.name === "AbortError" ? new Error(`Request timeout after ${M}ms`) : g;
53
53
  }
54
54
  }
55
55
  async get(e, t) {
@@ -65,85 +65,7 @@ class W {
65
65
  return this.request("DELETE", e, void 0, t);
66
66
  }
67
67
  }
68
- class ne {
69
- constructor(e, t, r) {
70
- this.httpService = e, this.appId = t, this.sessionManager = r;
71
- }
72
- async createTenant(e) {
73
- if (!this.sessionManager)
74
- throw new Error("SessionManager is required for private endpoints");
75
- const t = await this.sessionManager.getAuthHeaders();
76
- return (await this.httpService.post("/tenants/", e, {
77
- headers: t
78
- })).data;
79
- }
80
- async getTenants(e) {
81
- if (!this.sessionManager)
82
- throw new Error("SessionManager is required for private endpoints");
83
- const t = await this.sessionManager.getAuthHeaders(), r = new URLSearchParams();
84
- 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);
85
- const s = `/tenants/${r.toString() ? `?${r.toString()}` : ""}`, o = await this.httpService.get(s, {
86
- headers: t
87
- });
88
- return {
89
- tenants: o.data,
90
- meta: o.meta
91
- };
92
- }
93
- async getTenantById(e) {
94
- if (!this.sessionManager)
95
- throw new Error("SessionManager is required for private endpoints");
96
- const t = await this.sessionManager.getAuthHeaders();
97
- return (await this.httpService.get(`/tenants/${e}`, {
98
- headers: t
99
- })).data;
100
- }
101
- async updateTenant(e, t) {
102
- if (!this.sessionManager)
103
- throw new Error("SessionManager is required for private endpoints");
104
- const r = await this.sessionManager.getAuthHeaders();
105
- return (await this.httpService.put(`/tenants/${e}`, t, {
106
- headers: r
107
- })).data;
108
- }
109
- async adminUpdateTenant(e, t) {
110
- if (!this.sessionManager)
111
- throw new Error("SessionManager is required for private endpoints");
112
- const r = await this.sessionManager.getAuthHeaders();
113
- return (await this.httpService.put(
114
- `/tenants/${e}/admin-update`,
115
- t,
116
- {
117
- headers: r
118
- }
119
- )).data;
120
- }
121
- // Public endpoint - no auth required
122
- async getPublicTenantInfo(e) {
123
- return (await this.httpService.get(
124
- `/tenants/${this.appId}/${e}/public`
125
- )).data;
126
- }
127
- // Settings endpoints
128
- async getTenantSettings(e) {
129
- return (await this.httpService.get(
130
- `/tenants/${e}/settings`
131
- )).data;
132
- }
133
- async updateTenantSettings(e, t) {
134
- if (!this.sessionManager)
135
- throw new Error("SessionManager is required for private endpoints");
136
- const r = await this.sessionManager.getAuthHeaders();
137
- return (await this.httpService.put(
138
- `/tenants/${e}/settings`,
139
- t,
140
- {
141
- headers: r
142
- }
143
- )).data;
144
- }
145
- }
146
- class ye {
68
+ class be {
147
69
  constructor(e, t) {
148
70
  this.httpService = e, this.sessionManager = t;
149
71
  }
@@ -156,12 +78,12 @@ class ye {
156
78
  async getApps(e) {
157
79
  const t = await this.sessionManager.getAuthHeaders(), r = new URLSearchParams();
158
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);
159
- const s = `/apps/${r.toString() ? `?${r.toString()}` : ""}`, o = await this.httpService.get(s, {
81
+ const s = `/apps/${r.toString() ? `?${r.toString()}` : ""}`, a = await this.httpService.get(s, {
160
82
  headers: t
161
83
  });
162
84
  return {
163
- apps: o.data,
164
- meta: o.meta
85
+ apps: a.data,
86
+ meta: a.meta
165
87
  };
166
88
  }
167
89
  async getAppById(e) {
@@ -202,7 +124,7 @@ class ye {
202
124
  })).data;
203
125
  }
204
126
  }
205
- const ue = te(null), me = () => /* @__PURE__ */ i(
127
+ const ge = ee(null), Se = () => /* @__PURE__ */ n(
206
128
  "div",
207
129
  {
208
130
  style: {
@@ -212,9 +134,9 @@ const ue = te(null), me = () => /* @__PURE__ */ i(
212
134
  height: "100vh",
213
135
  fontFamily: "system-ui, sans-serif"
214
136
  },
215
- children: /* @__PURE__ */ i("div", { children: "Loading application..." })
137
+ children: /* @__PURE__ */ n("div", { children: "Loading application..." })
216
138
  }
217
- ), oe = ({ error: n, retry: e }) => /* @__PURE__ */ g(
139
+ ), ve = ({ error: i, retry: e }) => /* @__PURE__ */ u(
218
140
  "div",
219
141
  {
220
142
  style: {
@@ -228,9 +150,9 @@ const ue = te(null), me = () => /* @__PURE__ */ i(
228
150
  padding: "20px"
229
151
  },
230
152
  children: [
231
- /* @__PURE__ */ i("h2", { style: { color: "#dc3545", marginBottom: "16px" }, children: "Application Error" }),
232
- /* @__PURE__ */ i("p", { style: { color: "#6c757d", marginBottom: "24px" }, children: n.message || "Unable to load application" }),
233
- /* @__PURE__ */ i(
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(
234
156
  "button",
235
157
  {
236
158
  onClick: e,
@@ -248,113 +170,50 @@ const ue = te(null), me = () => /* @__PURE__ */ i(
248
170
  ]
249
171
  }
250
172
  );
251
- function _e({ config: n, children: e }) {
252
- const [t, r] = b(n.initialTenant || null), [s, o] = b(!n.initialTenant), [T, M] = b(null), [S, E] = b(null), [w, p] = b(!0), [v, f] = b(null), y = X(() => {
253
- const l = n.tenantMode || "fixed", a = "tenant";
254
- if (l === "fixed")
255
- return n.fixedTenantSlug || null;
256
- if (typeof window > "u") return null;
257
- if (l === "subdomain") {
258
- const k = window.location.hostname.split(".");
259
- if (k.length >= 3) {
260
- const F = k[0];
261
- return localStorage.setItem(a, F), F;
262
- }
263
- return localStorage.getItem(a);
264
- } else {
265
- const k = new URLSearchParams(window.location.search).get(n.selectorParam || "tenant");
266
- return k ? (localStorage.setItem(a, k), k) : localStorage.getItem(a);
267
- }
268
- }, [n.tenantMode, n.fixedTenantSlug, n.selectorParam]), c = N(() => y(), [y]), C = N(() => {
269
- const l = () => {
270
- c && d(c);
271
- }, a = () => {
272
- x();
173
+ function Je({ config: i, children: e }) {
174
+ const [t, r] = m(null), [s, a] = m(!0), [v, M] = m(null), k = O(() => {
175
+ const h = () => {
176
+ P();
273
177
  };
274
178
  return {
275
- appId: n.appId,
276
- baseUrl: n.baseUrl,
277
- // Tenant info
278
- tenant: t,
279
- tenantSlug: c,
280
- isTenantLoading: s,
281
- tenantError: T,
282
- retryTenant: l,
179
+ appId: i.appId,
180
+ baseUrl: i.baseUrl,
283
181
  // App info
284
- appInfo: S,
285
- isAppLoading: w,
182
+ appInfo: t,
183
+ isAppLoading: s,
286
184
  appError: v,
287
- retryApp: a
185
+ retryApp: h
288
186
  };
289
- }, [n, t, c, s, T, S, w, v]), x = X(async () => {
187
+ }, [i, t, s, v]), P = X(async () => {
290
188
  try {
291
- p(!0), f(null);
292
- const l = new W(n.baseUrl), u = await new ye(l, {}).getPublicAppInfo(n.appId);
293
- E(u);
294
- } catch (l) {
295
- const a = l instanceof Error ? l : new Error("Failed to load app information");
296
- f(a), E(null);
189
+ a(!0), M(null);
190
+ const h = new G(i.baseUrl), x = await new be(h, {}).getPublicAppInfo(i.appId);
191
+ r(x);
192
+ } catch (h) {
193
+ const g = h instanceof Error ? h : new Error("Failed to load app information");
194
+ M(g), r(null);
297
195
  } finally {
298
- p(!1);
196
+ a(!1);
299
197
  }
300
- }, [n.baseUrl, n.appId]), d = X(
301
- async (l) => {
302
- try {
303
- o(!0), M(null);
304
- const a = new W(n.baseUrl), k = await new ne(a, n.appId).getPublicTenantInfo(l);
305
- r(k);
306
- } catch (a) {
307
- const u = a instanceof Error ? a : new Error("Failed to load tenant information");
308
- M(u), r(null);
309
- } finally {
310
- o(!1);
311
- }
312
- },
313
- [n.baseUrl, n.appId]
314
- );
198
+ }, [i.baseUrl, i.appId]);
315
199
  if (K(() => {
316
- x();
317
- }, [x]), K(() => {
318
- if (!n.initialTenant && c)
319
- d(c);
320
- else if (!n.initialTenant && !c && n.tenantMode !== "fixed") {
321
- const l = n.tenantMode || "fixed";
322
- M(
323
- new Error(`No tenant ${l === "subdomain" ? "subdomain" : "parameter"} found`)
324
- ), o(!1);
325
- } else n.tenantMode === "fixed" && !n.fixedTenantSlug && (M(new Error("Fixed tenant mode requires fixedTenantSlug configuration")), o(!1));
326
- }, [n.initialTenant, c, d, n.tenantMode, n.fixedTenantSlug]), s)
327
- return /* @__PURE__ */ i(B, { children: n.loadingFallback || /* @__PURE__ */ i(me, {}) });
328
- if (T) {
329
- const l = typeof n.errorFallback == "function" ? n.errorFallback(T, () => d(c || "")) : n.errorFallback || /* @__PURE__ */ i(oe, { error: T, retry: () => d(c || "") });
330
- return /* @__PURE__ */ i(B, { children: l });
331
- }
332
- return !t && n.tenantMode !== "fixed" ? /* @__PURE__ */ i(
333
- oe,
334
- {
335
- error: new Error("No tenant information available"),
336
- retry: () => d(c || "")
337
- }
338
- ) : /* @__PURE__ */ i(ue.Provider, { value: C, children: e });
200
+ P();
201
+ }, [P]), s)
202
+ return /* @__PURE__ */ n(B, { children: i.loadingFallback || /* @__PURE__ */ n(Se, {}) });
203
+ if (v) {
204
+ const h = typeof i.errorFallback == "function" ? i.errorFallback(v, () => P()) : i.errorFallback || /* @__PURE__ */ n(ve, { error: v, retry: () => P() });
205
+ return /* @__PURE__ */ n(B, { children: h });
206
+ }
207
+ return /* @__PURE__ */ n(ge.Provider, { value: k, children: e });
339
208
  }
340
- function G() {
341
- const n = re(ue);
342
- if (!n)
209
+ function re() {
210
+ const i = te(ge);
211
+ if (!i)
343
212
  throw new Error("useApp must be used within an AppProvider");
344
- return n;
213
+ return i;
345
214
  }
346
- const Ke = G;
347
- function Ye() {
348
- const { tenant: n, tenantSlug: e, isTenantLoading: t, tenantError: r, retryTenant: s } = G();
349
- return {
350
- tenant: n,
351
- tenantSlug: e,
352
- isLoading: t,
353
- error: r,
354
- retry: s
355
- };
356
- }
357
- class be {
215
+ const Xe = re;
216
+ class xe {
358
217
  constructor(e = {}) {
359
218
  this.refreshPromise = null, this.refreshQueue = [], 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 || {
360
219
  get: () => {
@@ -471,7 +330,7 @@ class be {
471
330
  return e !== null && !this.isTokenExpired(e);
472
331
  }
473
332
  }
474
- class Se {
333
+ class Ae {
475
334
  constructor(e) {
476
335
  this.httpService = e;
477
336
  }
@@ -505,7 +364,7 @@ class Se {
505
364
  });
506
365
  }
507
366
  }
508
- class ae {
367
+ class le {
509
368
  constructor(e, t) {
510
369
  this.httpService = e, this.sessionManager = t;
511
370
  }
@@ -545,10 +404,10 @@ class ae {
545
404
  async getRolesByApp(e, t) {
546
405
  const r = new URLSearchParams();
547
406
  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);
548
- const s = `/roles/app/${e}${r.toString() ? `?${r.toString()}` : ""}`, o = await this.httpService.get(s);
407
+ const s = `/roles/app/${e}${r.toString() ? `?${r.toString()}` : ""}`, a = await this.httpService.get(s);
549
408
  return {
550
- roles: o.data,
551
- meta: o.meta
409
+ roles: a.data,
410
+ meta: a.meta
552
411
  };
553
412
  }
554
413
  async assignRole(e, t) {
@@ -572,16 +431,16 @@ class ae {
572
431
  throw new Error("SessionManager is required for private endpoints");
573
432
  const r = await this.sessionManager.getAuthHeaders(), s = new URLSearchParams();
574
433
  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);
575
- const o = `/roles/user/${e}${s.toString() ? `?${s.toString()}` : ""}`, T = await this.httpService.get(o, {
434
+ const a = `/roles/user/${e}${s.toString() ? `?${s.toString()}` : ""}`, v = await this.httpService.get(a, {
576
435
  headers: r
577
436
  });
578
437
  return {
579
- roles: T.data,
580
- meta: T.meta
438
+ roles: v.data,
439
+ meta: v.meta
581
440
  };
582
441
  }
583
442
  }
584
- class ve {
443
+ class Pe {
585
444
  constructor(e, t) {
586
445
  this.httpService = e, this.sessionManager = t;
587
446
  }
@@ -594,12 +453,12 @@ class ve {
594
453
  async getUsers(e) {
595
454
  const t = await this.sessionManager.getAuthHeaders(), r = new URLSearchParams();
596
455
  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);
597
- const s = `/users/${r.toString() ? `?${r.toString()}` : ""}`, o = await this.httpService.get(s, {
456
+ const s = `/users/${r.toString() ? `?${r.toString()}` : ""}`, a = await this.httpService.get(s, {
598
457
  headers: t
599
458
  });
600
459
  return {
601
- users: o.data,
602
- meta: o.meta
460
+ users: a.data,
461
+ meta: a.meta
603
462
  };
604
463
  }
605
464
  async getUserById(e) {
@@ -621,197 +480,483 @@ class ve {
621
480
  });
622
481
  }
623
482
  }
624
- const he = te(null);
625
- function Qe({ config: n = {}, children: e }) {
626
- const { appId: t, tenantSlug: r, baseUrl: s } = G(), [o, T] = b(n.initialRoles || []), [M, S] = b(!n.initialRoles), [E, w] = b(null), [p, v] = b(!1), [f, y] = b(null), c = N(() => {
627
- const m = r ? `auth_tokens_${r}` : "auth_tokens", R = {
483
+ class ce {
484
+ constructor(e, t, r) {
485
+ this.httpService = e, this.appId = t, this.sessionManager = r;
486
+ }
487
+ async createTenant(e) {
488
+ if (!this.sessionManager)
489
+ throw new Error("SessionManager is required for private endpoints");
490
+ const t = await this.sessionManager.getAuthHeaders();
491
+ return (await this.httpService.post("/tenants/", e, {
492
+ headers: t
493
+ })).data;
494
+ }
495
+ async getTenants(e) {
496
+ if (!this.sessionManager)
497
+ throw new Error("SessionManager is required for private endpoints");
498
+ const t = await this.sessionManager.getAuthHeaders(), r = new URLSearchParams();
499
+ 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);
500
+ const s = `/tenants/${r.toString() ? `?${r.toString()}` : ""}`, a = await this.httpService.get(s, {
501
+ headers: t
502
+ });
503
+ return {
504
+ tenants: a.data,
505
+ meta: a.meta
506
+ };
507
+ }
508
+ async getTenantById(e) {
509
+ if (!this.sessionManager)
510
+ throw new Error("SessionManager is required for private endpoints");
511
+ const t = await this.sessionManager.getAuthHeaders();
512
+ return (await this.httpService.get(`/tenants/${e}`, {
513
+ headers: t
514
+ })).data;
515
+ }
516
+ async updateTenant(e, t) {
517
+ if (!this.sessionManager)
518
+ throw new Error("SessionManager is required for private endpoints");
519
+ const r = await this.sessionManager.getAuthHeaders();
520
+ return (await this.httpService.put(`/tenants/${e}`, t, {
521
+ headers: r
522
+ })).data;
523
+ }
524
+ async adminUpdateTenant(e, t) {
525
+ if (!this.sessionManager)
526
+ throw new Error("SessionManager is required for private endpoints");
527
+ const r = await this.sessionManager.getAuthHeaders();
528
+ return (await this.httpService.put(
529
+ `/tenants/${e}/admin-update`,
530
+ t,
531
+ {
532
+ headers: r
533
+ }
534
+ )).data;
535
+ }
536
+ // Public endpoint - no auth required
537
+ async getPublicTenantInfo(e) {
538
+ return (await this.httpService.get(
539
+ `/tenants/${this.appId}/${e}/public`
540
+ )).data;
541
+ }
542
+ // Settings endpoints
543
+ async getTenantSettings(e) {
544
+ return (await this.httpService.get(
545
+ `/tenants/${e}/settings`
546
+ )).data;
547
+ }
548
+ async updateTenantSettings(e, t) {
549
+ if (!this.sessionManager)
550
+ throw new Error("SessionManager is required for private endpoints");
551
+ const r = await this.sessionManager.getAuthHeaders();
552
+ return (await this.httpService.put(
553
+ `/tenants/${e}/settings`,
554
+ t,
555
+ {
556
+ headers: r
557
+ }
558
+ )).data;
559
+ }
560
+ }
561
+ const pe = ee(null), Te = () => /* @__PURE__ */ n(
562
+ "div",
563
+ {
564
+ style: {
565
+ display: "flex",
566
+ justifyContent: "center",
567
+ alignItems: "center",
568
+ height: "100vh",
569
+ fontFamily: "system-ui, sans-serif"
570
+ },
571
+ children: /* @__PURE__ */ n("div", { children: "Loading tenant..." })
572
+ }
573
+ ), ke = ({ error: i, retry: e }) => /* @__PURE__ */ u(
574
+ "div",
575
+ {
576
+ style: {
577
+ display: "flex",
578
+ flexDirection: "column",
579
+ justifyContent: "center",
580
+ alignItems: "center",
581
+ height: "100vh",
582
+ fontFamily: "system-ui, sans-serif",
583
+ textAlign: "center",
584
+ padding: "20px"
585
+ },
586
+ children: [
587
+ /* @__PURE__ */ n("h2", { style: { color: "#dc3545", marginBottom: "16px" }, children: "Tenant Error" }),
588
+ /* @__PURE__ */ n("p", { style: { color: "#6c757d", marginBottom: "24px" }, children: i.message || "Unable to load tenant" }),
589
+ /* @__PURE__ */ n(
590
+ "button",
591
+ {
592
+ onClick: e,
593
+ style: {
594
+ padding: "8px 16px",
595
+ backgroundColor: "#007bff",
596
+ color: "white",
597
+ border: "none",
598
+ borderRadius: "4px",
599
+ cursor: "pointer"
600
+ },
601
+ children: "Retry"
602
+ }
603
+ )
604
+ ]
605
+ }
606
+ );
607
+ function Ze({ config: i, children: e }) {
608
+ const { baseUrl: t, appInfo: r, appId: s } = re(), [a, v] = m(i.initialTenant || null), [M, k] = m(!i.initialTenant), [P, h] = m(null), [g, x] = m(null), [f, A] = m(!1), [F, y] = m(null), C = X(() => {
609
+ const l = i.tenantMode || "optional", w = "tenant";
610
+ if (l === "fixed")
611
+ return i.fixedTenantSlug || null;
612
+ if (typeof window > "u") return null;
613
+ if (l === "subdomain") {
614
+ const o = window.location.hostname.split(".");
615
+ if (o.length >= 3) {
616
+ const c = o[0];
617
+ return localStorage.setItem(w, c), c;
618
+ }
619
+ return localStorage.getItem(w);
620
+ } else if (l === "selector") {
621
+ const o = new URLSearchParams(window.location.search).get(i.selectorParam || "tenant");
622
+ return o ? (localStorage.setItem(w, o), o) : localStorage.getItem(w);
623
+ }
624
+ return null;
625
+ }, [i.tenantMode, i.fixedTenantSlug, i.selectorParam]), p = O(() => C(), [C]), b = (r == null ? void 0 : r.settingsSchema) || null, T = X(
626
+ async (l) => {
627
+ try {
628
+ k(!0), h(null);
629
+ const w = new G(t), o = await new ce(w, s).getPublicTenantInfo(l);
630
+ v(o);
631
+ } catch (w) {
632
+ const d = w instanceof Error ? w : new Error("Failed to load tenant information");
633
+ h(d), v(null);
634
+ } finally {
635
+ k(!1);
636
+ }
637
+ },
638
+ [t, s]
639
+ ), R = X(async () => {
640
+ if (a != null && a.id)
641
+ try {
642
+ A(!0), y(null);
643
+ const l = new G(t), d = await new ce(l, a.appId).getTenantSettings(a.id);
644
+ x(d);
645
+ } catch (l) {
646
+ const w = l instanceof Error ? l : new Error("Failed to load tenant settings");
647
+ y(w), x(null);
648
+ } finally {
649
+ A(!1);
650
+ }
651
+ }, [t, a]), L = X(() => {
652
+ R();
653
+ }, [R]), E = X(
654
+ (l) => {
655
+ if (!b)
656
+ return { isValid: !0, errors: [] };
657
+ const w = [];
658
+ try {
659
+ return b.properties && Object.entries(b.properties).forEach(([d, o]) => {
660
+ var W;
661
+ const c = l[d];
662
+ if ((W = b.required) != null && W.includes(d) && c == null) {
663
+ w.push(`Field '${d}' is required`);
664
+ return;
665
+ }
666
+ if (c != null) {
667
+ if (o.type) {
668
+ const I = o.type, N = typeof c;
669
+ I === "string" && N !== "string" ? w.push(`Field '${d}' must be a string`) : (I === "number" || I === "integer") && N !== "number" ? w.push(`Field '${d}' must be a number`) : I === "boolean" && N !== "boolean" ? w.push(`Field '${d}' must be a boolean`) : I === "array" && !Array.isArray(c) && w.push(`Field '${d}' must be an array`);
670
+ }
671
+ o.minLength !== void 0 && typeof c == "string" && c.length < o.minLength && w.push(
672
+ `Field '${d}' must be at least ${o.minLength} characters long`
673
+ ), o.maxLength !== void 0 && typeof c == "string" && c.length > o.maxLength && w.push(
674
+ `Field '${d}' must be no more than ${o.maxLength} characters long`
675
+ ), o.minimum !== void 0 && typeof c == "number" && c < o.minimum && w.push(`Field '${d}' must be at least ${o.minimum}`), o.maximum !== void 0 && typeof c == "number" && c > o.maximum && w.push(`Field '${d}' must be no more than ${o.maximum}`), o.pattern && typeof c == "string" && (new RegExp(o.pattern).test(c) || w.push(`Field '${d}' does not match the required pattern`)), o.enum && !o.enum.includes(c) && w.push(`Field '${d}' must be one of: ${o.enum.join(", ")}`);
676
+ }
677
+ }), {
678
+ isValid: w.length === 0,
679
+ errors: w
680
+ };
681
+ } catch {
682
+ return {
683
+ isValid: !1,
684
+ errors: ["Invalid settings schema or validation error"]
685
+ };
686
+ }
687
+ },
688
+ [b]
689
+ );
690
+ K(() => {
691
+ const l = i.tenantMode || "optional";
692
+ !i.initialTenant && p ? T(p) : !i.initialTenant && !p && l === "fixed" ? (h(new Error("Fixed tenant mode requires fixedTenantSlug configuration")), k(!1)) : !i.initialTenant && !p && (l === "subdomain" || l === "selector") ? (h(
693
+ new Error(`No tenant ${l === "subdomain" ? "subdomain" : "parameter"} found`)
694
+ ), k(!1)) : !i.initialTenant && !p && l === "optional" && (v(null), h(null), k(!1));
695
+ }, [i.initialTenant, p, T, i.tenantMode, i.fixedTenantSlug]), K(() => {
696
+ a != null && a.id ? R() : (x(null), y(null), A(!1));
697
+ }, [a == null ? void 0 : a.id, R]);
698
+ const D = O(() => ({
699
+ // Tenant info
700
+ tenant: a,
701
+ tenantSlug: p,
702
+ isTenantLoading: M,
703
+ tenantError: P,
704
+ retryTenant: () => {
705
+ p && T(p);
706
+ },
707
+ // Settings
708
+ settings: g,
709
+ settingsSchema: b,
710
+ isSettingsLoading: f,
711
+ settingsError: F,
712
+ // Actions
713
+ refreshSettings: L,
714
+ // Validation
715
+ validateSettings: E
716
+ }), [
717
+ a,
718
+ p,
719
+ M,
720
+ P,
721
+ g,
722
+ b,
723
+ f,
724
+ F,
725
+ L,
726
+ E
727
+ ]);
728
+ if (M)
729
+ return /* @__PURE__ */ n(B, { children: i.loadingFallback || /* @__PURE__ */ n(Te, {}) });
730
+ if (P && i.tenantMode !== "optional") {
731
+ const l = typeof i.errorFallback == "function" ? i.errorFallback(P, () => T(p || "")) : i.errorFallback || /* @__PURE__ */ n(ke, { error: P, retry: () => T(p || "") });
732
+ return /* @__PURE__ */ n(B, { children: l });
733
+ }
734
+ return /* @__PURE__ */ n(pe.Provider, { value: D, children: e });
735
+ }
736
+ function oe() {
737
+ const i = te(pe);
738
+ if (!i)
739
+ throw new Error("useTenant must be used within a TenantProvider");
740
+ return i;
741
+ }
742
+ const et = oe;
743
+ function tt() {
744
+ const {
745
+ settings: i,
746
+ settingsSchema: e,
747
+ isSettingsLoading: t,
748
+ settingsError: r,
749
+ validateSettings: s
750
+ } = oe();
751
+ return {
752
+ settings: i,
753
+ settingsSchema: e,
754
+ isLoading: t,
755
+ error: r,
756
+ validateSettings: s
757
+ };
758
+ }
759
+ function Z() {
760
+ const { tenant: i, tenantSlug: e, isTenantLoading: t, tenantError: r, retryTenant: s } = oe();
761
+ return {
762
+ tenant: i,
763
+ tenantSlug: e,
764
+ isLoading: t,
765
+ error: r,
766
+ retry: s
767
+ };
768
+ }
769
+ const fe = ee(null);
770
+ function rt({ config: i = {}, children: e }) {
771
+ const { appId: t, baseUrl: r } = re(), s = Z(), a = (s == null ? void 0 : s.tenantSlug) || null, [v, M] = m(i.initialRoles || []), [k, P] = m(!i.initialRoles), [h, g] = m(null), [x, f] = m(!1), [A, F] = m(null), y = O(() => {
772
+ const l = a ? `auth_tokens_${a}` : "auth_tokens", w = {
628
773
  get: () => {
629
774
  try {
630
- const U = localStorage.getItem(m);
631
- return U ? JSON.parse(U) : null;
775
+ const d = localStorage.getItem(l);
776
+ return d ? JSON.parse(d) : null;
632
777
  } catch {
633
778
  return null;
634
779
  }
635
780
  },
636
- set: (U) => {
781
+ set: (d) => {
637
782
  try {
638
- localStorage.setItem(m, JSON.stringify(U));
783
+ localStorage.setItem(l, JSON.stringify(d));
639
784
  } catch {
640
785
  }
641
786
  },
642
787
  clear: () => {
643
788
  try {
644
- localStorage.removeItem(m);
789
+ localStorage.removeItem(l);
645
790
  } catch {
646
791
  }
647
792
  }
648
793
  };
649
- return new be({
650
- onRefreshFailed: n.onRefreshFailed,
651
- tokenStorage: R,
652
- baseUrl: s
794
+ return new xe({
795
+ onRefreshFailed: i.onRefreshFailed,
796
+ tokenStorage: w,
797
+ baseUrl: r
653
798
  });
654
- }, [r, s, n.onRefreshFailed]), C = N(() => {
655
- const m = new W(s);
656
- return m.setSessionManager(c), m;
657
- }, [s, c]), x = N(() => new Se(new W(s)), [s]), d = N(() => new ve(C, c), [C, c]), l = N(() => new ae(new W(s)), [s]), a = N(() => E || c.getUser(), [E, c]), u = N(() => a != null && a.roleId && o.find((m) => m.id === a.roleId) || null, [a, o]), k = N(() => (u == null ? void 0 : u.permissions) || [], [u]);
799
+ }, [a, r, i.onRefreshFailed]), C = O(() => {
800
+ const l = new G(r);
801
+ return l.setSessionManager(y), l;
802
+ }, [r, y]), p = O(() => new Ae(new G(r)), [r]), b = O(() => new Pe(C, y), [C, y]), T = O(() => new le(new G(r)), [r]), R = O(() => h || y.getUser(), [h, y]), L = O(() => R != null && R.roleId && v.find((l) => l.id === R.roleId) || null, [R, v]), E = O(() => (L == null ? void 0 : L.permissions) || [], [L]);
658
803
  K(() => {
659
- console.log("AuthProvider - userPermissions changed:", k);
660
- }, [k]);
661
- const F = N(() => {
662
- const m = async () => {
804
+ console.log("AuthProvider - userPermissions changed:", E);
805
+ }, [E]);
806
+ const D = O(() => {
807
+ const l = async () => {
663
808
  try {
664
- v(!0), y(null);
665
- const A = c.getUser();
666
- if (!(A != null && A.id))
809
+ f(!0), F(null);
810
+ const S = y.getUser();
811
+ if (!(S != null && S.id))
667
812
  throw new Error("No user ID available in session");
668
- const $ = await d.getUserById(A.id);
669
- w($), c.setUser($);
670
- } catch (A) {
671
- const $ = A instanceof Error ? A : new Error("Failed to load user data");
672
- y($), console.error("Failed to load user data:", $);
813
+ const $ = await b.getUserById(S.id);
814
+ g($), y.setUser($);
815
+ } catch (S) {
816
+ const $ = S instanceof Error ? S : new Error("Failed to load user data");
817
+ F($), console.error("Failed to load user data:", $);
673
818
  } finally {
674
- v(!1);
819
+ f(!1);
675
820
  }
676
- }, R = async () => {
677
- await m();
678
- }, U = async (A, $, J) => {
679
- const V = await x.login({
680
- email: A,
821
+ }, w = async () => {
822
+ await l();
823
+ }, d = async (S, $, Q) => {
824
+ const V = await p.login({
825
+ email: S,
681
826
  password: $,
682
- tenantId: J
827
+ tenantId: Q
683
828
  });
684
- if (c.setTokens({
829
+ if (y.setTokens({
685
830
  accessToken: V.accessToken,
686
831
  refreshToken: V.refreshToken,
687
832
  expiresIn: V.expiresIn
688
833
  }), V.user) {
689
- c.setUser(V.user), w(V.user);
834
+ y.setUser(V.user), g(V.user);
690
835
  try {
691
- await m();
692
- } catch (se) {
693
- console.warn("Failed to load complete user data after login:", se);
836
+ await l();
837
+ } catch (ie) {
838
+ console.warn("Failed to load complete user data after login:", ie);
694
839
  }
695
840
  }
696
841
  return V;
697
- }, I = async (A, $, J, V) => await x.signup({ email: A, name: $, password: J, tenantId: V }), h = async (A, $, J, V) => await x.signupTenantAdmin({
698
- email: A,
842
+ }, o = async (S, $, Q, V) => await p.signup({ email: S, name: $, password: Q, tenantId: V }), c = async (S, $, Q, V) => await p.signupTenantAdmin({
843
+ email: S,
699
844
  name: $,
700
- password: J,
845
+ password: Q,
701
846
  tenantName: V,
702
847
  appId: t
703
- }), P = async (A, $) => {
704
- const J = await c.getAuthHeaders();
705
- await x.changePassword({ currentPassword: A, newPassword: $ }, J);
706
- }, Y = async (A, $) => {
707
- await x.requestPasswordReset({ email: A, tenantId: $ });
708
- }, L = async (A, $) => {
709
- await x.confirmPasswordReset({ token: A, newPassword: $ });
710
- }, z = async () => {
711
- const A = c.getTokens();
712
- if (!(A != null && A.refreshToken))
848
+ }), W = async (S, $) => {
849
+ const Q = await y.getAuthHeaders();
850
+ await p.changePassword({ currentPassword: S, newPassword: $ }, Q);
851
+ }, I = async (S, $) => {
852
+ await p.requestPasswordReset({ email: S, tenantId: $ });
853
+ }, N = async (S, $) => {
854
+ await p.confirmPasswordReset({ token: S, newPassword: $ });
855
+ }, _ = async () => {
856
+ const S = y.getTokens();
857
+ if (!(S != null && S.refreshToken))
713
858
  throw new Error("No refresh token available");
714
- const $ = await x.refreshToken({
715
- refreshToken: A.refreshToken
859
+ const $ = await p.refreshToken({
860
+ refreshToken: S.refreshToken
716
861
  });
717
- c.setTokens({
862
+ y.setTokens({
718
863
  accessToken: $.accessToken,
719
- refreshToken: $.refreshToken || A.refreshToken,
864
+ refreshToken: $.refreshToken || S.refreshToken,
720
865
  expiresIn: $.expiresIn
721
866
  });
722
- }, _ = () => {
723
- c.clearSession(), w(null), y(null);
724
- }, H = (A) => {
725
- c.setTokens(A);
726
- }, q = () => c.hasValidSession(), Q = () => {
727
- c.clearSession(), w(null), y(null);
728
- }, D = async () => {
867
+ }, H = () => {
868
+ y.clearSession(), g(null), F(null);
869
+ }, q = (S) => {
870
+ y.setTokens(S);
871
+ }, Y = () => y.hasValidSession(), U = () => {
872
+ y.clearSession(), g(null), F(null);
873
+ }, z = async () => {
729
874
  if (t)
730
875
  try {
731
- S(!0);
732
- const { roles: A } = await l.getRolesByApp(t);
733
- T(A);
734
- } catch (A) {
735
- console.error("Failed to fetch roles:", A);
876
+ P(!0);
877
+ const { roles: S } = await T.getRolesByApp(t);
878
+ M(S);
879
+ } catch (S) {
880
+ console.error("Failed to fetch roles:", S);
736
881
  } finally {
737
- S(!1);
882
+ P(!1);
738
883
  }
739
884
  }, j = async () => {
740
- await D();
741
- }, O = (A) => {
742
- if (!k || k.length === 0)
885
+ await z();
886
+ }, ne = (S) => {
887
+ if (!E || E.length === 0)
743
888
  return !1;
744
- if (typeof A == "string")
745
- return k.includes(A);
746
- const $ = `${A.resource}.${A.action}`;
747
- return k.includes($);
889
+ if (typeof S == "string")
890
+ return E.includes(S);
891
+ const $ = `${S.resource}.${S.action}`;
892
+ return E.includes($);
748
893
  };
749
894
  return {
750
- sessionManager: c,
895
+ sessionManager: y,
751
896
  authenticatedHttpService: C,
752
- login: U,
753
- signup: I,
754
- signupTenantAdmin: h,
755
- changePassword: P,
756
- requestPasswordReset: Y,
757
- confirmPasswordReset: L,
758
- refreshToken: z,
759
- logout: _,
760
- setTokens: H,
761
- hasValidSession: q,
762
- clearSession: Q,
763
- currentUser: E,
764
- isUserLoading: p,
765
- userError: f,
766
- refreshUser: R,
767
- userRole: u,
768
- userPermissions: k,
769
- availableRoles: o,
770
- rolesLoading: M,
771
- hasPermission: O,
772
- hasAnyPermission: (A) => A.some(($) => O($)),
773
- hasAllPermissions: (A) => A.every(($) => O($)),
774
- getUserPermissionStrings: () => k || [],
897
+ login: d,
898
+ signup: o,
899
+ signupTenantAdmin: c,
900
+ changePassword: W,
901
+ requestPasswordReset: I,
902
+ confirmPasswordReset: N,
903
+ refreshToken: _,
904
+ logout: H,
905
+ setTokens: q,
906
+ hasValidSession: Y,
907
+ clearSession: U,
908
+ currentUser: h,
909
+ isUserLoading: x,
910
+ userError: A,
911
+ refreshUser: w,
912
+ userRole: L,
913
+ userPermissions: E,
914
+ availableRoles: v,
915
+ rolesLoading: k,
916
+ hasPermission: ne,
917
+ hasAnyPermission: (S) => S.some(($) => ne($)),
918
+ hasAllPermissions: (S) => S.every(($) => ne($)),
919
+ getUserPermissionStrings: () => E || [],
775
920
  refreshRoles: j
776
921
  };
777
922
  }, [
778
- c,
923
+ y,
779
924
  C,
780
- x,
781
- d,
782
- l,
783
- t,
784
- o,
785
- E,
786
925
  p,
787
- f,
788
- u,
789
- k
926
+ b,
927
+ T,
928
+ t,
929
+ v,
930
+ h,
931
+ x,
932
+ A,
933
+ L,
934
+ E
790
935
  ]);
791
936
  return K(() => {
792
- !n.initialRoles && t && (async () => {
937
+ !i.initialRoles && t && (async () => {
793
938
  try {
794
- S(!0);
795
- const R = new W(s), U = new ae(R), { roles: I } = await U.getRolesByApp(t);
796
- T(I);
797
- } catch (R) {
798
- console.error("Failed to fetch roles:", R);
939
+ P(!0);
940
+ const w = new G(r), d = new le(w), { roles: o } = await d.getRolesByApp(t);
941
+ M(o);
942
+ } catch (w) {
943
+ console.error("Failed to fetch roles:", w);
799
944
  } finally {
800
- S(!1);
945
+ P(!1);
801
946
  }
802
947
  })();
803
- }, [t, s, n.initialRoles]), K(() => {
804
- const m = c.getUser();
805
- m && c.hasValidSession() && w(m);
806
- }, [c]), /* @__PURE__ */ i(he.Provider, { value: F, children: e });
948
+ }, [t, r, i.initialRoles]), K(() => {
949
+ const l = y.getUser();
950
+ l && y.hasValidSession() && g(l);
951
+ }, [y]), /* @__PURE__ */ n(fe.Provider, { value: D, children: e });
807
952
  }
808
- function ee() {
809
- const n = re(he);
810
- if (!n)
953
+ function se() {
954
+ const i = te(fe);
955
+ if (!i)
811
956
  throw new Error("useAuth must be used within an AuthProvider");
812
- return n;
957
+ return i;
813
958
  }
814
- class xe {
959
+ class Me {
815
960
  constructor(e, t) {
816
961
  this.httpService = e, this.sessionManager = t;
817
962
  }
@@ -832,12 +977,12 @@ class xe {
832
977
  throw new Error("SessionManager is required for private endpoints");
833
978
  const t = await this.sessionManager.getAuthHeaders(), r = new URLSearchParams();
834
979
  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);
835
- const s = `/feature-flags/${r.toString() ? `?${r.toString()}` : ""}`, o = await this.httpService.get(s, {
980
+ const s = `/feature-flags/${r.toString() ? `?${r.toString()}` : ""}`, a = await this.httpService.get(s, {
836
981
  headers: t
837
982
  });
838
983
  return {
839
- featureFlags: o.data,
840
- meta: o.meta
984
+ featureFlags: a.data,
985
+ meta: a.meta
841
986
  };
842
987
  }
843
988
  async getFeatureFlagById(e) {
@@ -885,64 +1030,64 @@ class xe {
885
1030
  throw new Error("Flag Key, Tenant ID and App ID are required");
886
1031
  const s = new URLSearchParams();
887
1032
  s.append("tenantId", t), s.append("appId", r);
888
- const o = `/tenant-feature-flags/${e}${s.toString() ? `?${s.toString()}` : ""}`;
889
- return (await this.httpService.get(o, {
1033
+ const a = `/tenant-feature-flags/${e}${s.toString() ? `?${s.toString()}` : ""}`;
1034
+ return (await this.httpService.get(a, {
890
1035
  headers: { "X-Tenant-ID": t }
891
1036
  })).data;
892
1037
  }
893
1038
  }
894
- const ge = te(null);
895
- function Je({ config: n = {}, children: e }) {
896
- const { tenant: t, baseUrl: r, appId: s } = G(), [o, T] = b([]), [M, S] = b(!1), [E, w] = b(null), p = N(() => {
897
- const y = new W(r);
898
- return new xe(y);
899
- }, [r]), v = async () => {
900
- if (!(t != null && t.id)) {
901
- T([]);
1039
+ const ye = ee(null);
1040
+ function st({ config: i = {}, children: e }) {
1041
+ const { baseUrl: t, appId: r } = re(), { tenant: s } = Z(), [a, v] = m([]), [M, k] = m(!1), [P, h] = m(null), g = O(() => {
1042
+ const A = new G(t);
1043
+ return new Me(A);
1044
+ }, [t]), x = async () => {
1045
+ if (!(s != null && s.id)) {
1046
+ v([]);
902
1047
  return;
903
1048
  }
904
- S(!0), w(null);
1049
+ k(!0), h(null);
905
1050
  try {
906
- const y = await p.getTenantFeatureFlags(t.id, s);
907
- T(y);
908
- } catch (y) {
909
- const c = y instanceof Error ? y.message : "Failed to fetch feature flags";
910
- w(c), n.onError && n.onError(y instanceof Error ? y : new Error(c));
1051
+ const A = await g.getTenantFeatureFlags(s.id, r);
1052
+ v(A);
1053
+ } catch (A) {
1054
+ const F = A instanceof Error ? A.message : "Failed to fetch feature flags";
1055
+ h(F), i.onError && i.onError(A instanceof Error ? A : new Error(F));
911
1056
  } finally {
912
- S(!1);
1057
+ k(!1);
913
1058
  }
914
1059
  };
915
1060
  K(() => {
916
- v();
917
- const y = n.refreshInterval || 5 * 60 * 1e3, c = setInterval(v, y);
918
- return () => clearInterval(c);
919
- }, [t == null ? void 0 : t.id, n.refreshInterval]);
920
- const f = N(() => ({
921
- featureFlags: o,
1061
+ x();
1062
+ const A = i.refreshInterval || 5 * 60 * 1e3, F = setInterval(x, A);
1063
+ return () => clearInterval(F);
1064
+ }, [s == null ? void 0 : s.id, i.refreshInterval]);
1065
+ const f = O(() => ({
1066
+ featureFlags: a,
922
1067
  loading: M,
923
- error: E,
924
- isEnabled: (d) => {
925
- const l = o.find((a) => a.key === d);
926
- return (l == null ? void 0 : l.value) === !0;
1068
+ error: P,
1069
+ isEnabled: (p) => {
1070
+ const b = a.find((T) => T.key === p);
1071
+ return (b == null ? void 0 : b.value) === !0;
927
1072
  },
928
- getFlag: (d) => o.find((l) => l.key === d),
929
- getFlagState: (d) => {
930
- const l = o.find((a) => a.key === d);
931
- return l ? l.value ? "enabled" : "disabled" : "not_found";
1073
+ getFlag: (p) => a.find((b) => b.key === p),
1074
+ getFlagState: (p) => {
1075
+ const b = a.find((T) => T.key === p);
1076
+ return b ? b.value ? "enabled" : "disabled" : "not_found";
932
1077
  },
933
1078
  refresh: async () => {
934
- await v();
1079
+ await x();
935
1080
  }
936
- }), [o, M, E]);
937
- return /* @__PURE__ */ i(ge.Provider, { value: f, children: e });
1081
+ }), [a, M, P]);
1082
+ return /* @__PURE__ */ n(ye.Provider, { value: f, children: e });
938
1083
  }
939
- function Ae() {
940
- const n = re(ge);
941
- if (!n)
1084
+ function Ee() {
1085
+ const i = te(ye);
1086
+ if (!i)
942
1087
  throw new Error("useFeatureFlags must be used within a FeatureFlagProvider");
943
- return n;
1088
+ return i;
944
1089
  }
945
- class Pe {
1090
+ class Re {
946
1091
  constructor(e, t) {
947
1092
  this.httpService = e, this.sessionManager = t;
948
1093
  }
@@ -1008,185 +1153,64 @@ class Pe {
1008
1153
  )).data;
1009
1154
  }
1010
1155
  }
1011
- const pe = te(void 0);
1012
- function Xe({ config: n = {}, children: e }) {
1013
- const { tenant: t, baseUrl: r } = G(), [s, o] = b(null), [T, M] = b(!1), [S, E] = b(null), w = N(() => {
1014
- const f = new W(r);
1015
- return new Pe(f);
1016
- }, [r]), p = async () => {
1017
- if (!(t != null && t.id)) {
1018
- o(null);
1156
+ const we = ee(void 0);
1157
+ function nt({ config: i = {}, children: e }) {
1158
+ const { baseUrl: t } = re(), { tenant: r } = Z(), [s, a] = m(null), [v, M] = m(!1), [k, P] = m(null), h = O(() => {
1159
+ const f = new G(t);
1160
+ return new Re(f);
1161
+ }, [t]), g = async () => {
1162
+ if (!(r != null && r.id)) {
1163
+ a(null);
1019
1164
  return;
1020
1165
  }
1021
- M(!0), E(null);
1166
+ M(!0), P(null);
1022
1167
  try {
1023
- const f = await w.getTenantSubscriptionFeatures(t.id);
1024
- o(f);
1168
+ const f = await h.getTenantSubscriptionFeatures(r.id);
1169
+ a(f);
1025
1170
  } catch (f) {
1026
- const y = f instanceof Error ? f.message : "Failed to fetch subscription";
1027
- E(y), n.onError && n.onError(f instanceof Error ? f : new Error(y));
1171
+ const A = f instanceof Error ? f.message : "Failed to fetch subscription";
1172
+ P(A), i.onError && i.onError(f instanceof Error ? f : new Error(A));
1028
1173
  } finally {
1029
1174
  M(!1);
1030
1175
  }
1031
1176
  };
1032
1177
  K(() => {
1033
- if (p(), !n.refreshInterval) return;
1034
- const f = n.refreshInterval || 10 * 60 * 1e3, y = setInterval(p, f);
1035
- return () => clearInterval(y);
1036
- }, [t == null ? void 0 : t.id, n.refreshInterval]);
1037
- const v = N(() => {
1178
+ if (g(), !i.refreshInterval) return;
1179
+ const f = i.refreshInterval || 10 * 60 * 1e3, A = setInterval(g, f);
1180
+ return () => clearInterval(A);
1181
+ }, [r == null ? void 0 : r.id, i.refreshInterval]);
1182
+ const x = O(() => {
1038
1183
  const f = (s == null ? void 0 : s.features) || [];
1039
1184
  return {
1040
1185
  subscription: s,
1041
1186
  features: f,
1042
- loading: T,
1043
- error: S,
1044
- isFeatureEnabled: (l) => {
1045
- const a = f.find((u) => u.key === l);
1046
- return a ? a.type === "BOOLEAN" || a.type === "boolean" ? a.value === !0 : !!a.value : !1;
1187
+ loading: v,
1188
+ error: k,
1189
+ isFeatureEnabled: (b) => {
1190
+ const T = f.find((R) => R.key === b);
1191
+ return T ? T.type === "BOOLEAN" || T.type === "boolean" ? T.value === !0 : !!T.value : !1;
1047
1192
  },
1048
- getFeature: (l) => f.find((a) => a.key === l),
1049
- getFeatureValue: (l, a) => {
1050
- const u = f.find((k) => k.key === l);
1051
- return u ? u.value : a;
1193
+ getFeature: (b) => f.find((T) => T.key === b),
1194
+ getFeatureValue: (b, T) => {
1195
+ const R = f.find((L) => L.key === b);
1196
+ return R ? R.value : T;
1052
1197
  },
1053
- hasAllowedPlan: (l) => !s || !s.isActive ? !1 : l.includes(s.planId),
1198
+ hasAllowedPlan: (b) => !s || !s.isActive ? !1 : b.includes(s.planId),
1054
1199
  refresh: async () => {
1055
- await p();
1200
+ await g();
1056
1201
  }
1057
1202
  };
1058
- }, [s, T, S]);
1059
- return /* @__PURE__ */ i(pe.Provider, { value: v, children: e });
1203
+ }, [s, v, k]);
1204
+ return /* @__PURE__ */ n(we.Provider, { value: x, children: e });
1060
1205
  }
1061
- function Te() {
1062
- const n = re(pe);
1063
- if (n === void 0)
1206
+ function Fe() {
1207
+ const i = te(we);
1208
+ if (i === void 0)
1064
1209
  throw new Error("useSubscription must be used within a SubscriptionProvider");
1065
- return n;
1066
- }
1067
- const fe = te(null);
1068
- function Ze({ children: n }) {
1069
- const { baseUrl: e, tenant: t, appInfo: r } = G(), { sessionManager: s } = ee(), [o, T] = b(null), [M, S] = b(!1), [E, w] = b(null), p = (r == null ? void 0 : r.settingsSchema) || null, v = X(async () => {
1070
- if (t != null && t.id)
1071
- try {
1072
- S(!0), w(null);
1073
- const x = new W(e), l = await new ne(x, t.appId).getTenantSettings(t.id);
1074
- T(l);
1075
- } catch (x) {
1076
- const d = x instanceof Error ? x : new Error("Failed to load tenant settings");
1077
- w(d), T(null);
1078
- } finally {
1079
- S(!1);
1080
- }
1081
- }, [e, t]), f = X(
1082
- async (x) => {
1083
- if (!(t != null && t.id) || !s)
1084
- throw new Error("Tenant ID and authentication required to update settings");
1085
- try {
1086
- S(!0), w(null);
1087
- const d = new W(e), l = new ne(d, t.appId, s), a = { settings: x }, u = await l.updateTenantSettings(t.id, a);
1088
- T(u);
1089
- } catch (d) {
1090
- const l = d instanceof Error ? d : new Error("Failed to update tenant settings");
1091
- throw w(l), l;
1092
- } finally {
1093
- S(!1);
1094
- }
1095
- },
1096
- [e, t, s]
1097
- ), y = X(() => {
1098
- v();
1099
- }, [v]), c = X(
1100
- (x) => {
1101
- if (!p)
1102
- return { isValid: !0, errors: [] };
1103
- const d = [];
1104
- try {
1105
- return p.properties && Object.entries(p.properties).forEach(([l, a]) => {
1106
- var k;
1107
- const u = x[l];
1108
- if ((k = p.required) != null && k.includes(l) && u == null) {
1109
- d.push(`Field '${l}' is required`);
1110
- return;
1111
- }
1112
- if (u != null) {
1113
- if (a.type) {
1114
- const F = a.type, m = typeof u;
1115
- F === "string" && m !== "string" ? d.push(`Field '${l}' must be a string`) : (F === "number" || F === "integer") && m !== "number" ? d.push(`Field '${l}' must be a number`) : F === "boolean" && m !== "boolean" ? d.push(`Field '${l}' must be a boolean`) : F === "array" && !Array.isArray(u) && d.push(`Field '${l}' must be an array`);
1116
- }
1117
- a.minLength !== void 0 && typeof u == "string" && u.length < a.minLength && d.push(
1118
- `Field '${l}' must be at least ${a.minLength} characters long`
1119
- ), a.maxLength !== void 0 && typeof u == "string" && u.length > a.maxLength && d.push(
1120
- `Field '${l}' must be no more than ${a.maxLength} characters long`
1121
- ), a.minimum !== void 0 && typeof u == "number" && u < a.minimum && d.push(`Field '${l}' must be at least ${a.minimum}`), a.maximum !== void 0 && typeof u == "number" && u > a.maximum && d.push(`Field '${l}' must be no more than ${a.maximum}`), a.pattern && typeof u == "string" && (new RegExp(a.pattern).test(u) || d.push(`Field '${l}' does not match the required pattern`)), a.enum && !a.enum.includes(u) && d.push(`Field '${l}' must be one of: ${a.enum.join(", ")}`);
1122
- }
1123
- }), {
1124
- isValid: d.length === 0,
1125
- errors: d
1126
- };
1127
- } catch {
1128
- return {
1129
- isValid: !1,
1130
- errors: ["Invalid settings schema or validation error"]
1131
- };
1132
- }
1133
- },
1134
- [p]
1135
- );
1136
- K(() => {
1137
- t != null && t.id ? v() : (T(null), w(null), S(!1));
1138
- }, [t == null ? void 0 : t.id, v]);
1139
- const C = N(
1140
- () => ({
1141
- // Settings
1142
- settings: o,
1143
- settingsSchema: p,
1144
- isSettingsLoading: M,
1145
- settingsError: E,
1146
- // Actions
1147
- updateSettings: f,
1148
- refreshSettings: y,
1149
- // Validation
1150
- validateSettings: c
1151
- }),
1152
- [
1153
- o,
1154
- p,
1155
- M,
1156
- E,
1157
- f,
1158
- y,
1159
- c
1160
- ]
1161
- );
1162
- return /* @__PURE__ */ i(fe.Provider, { value: C, children: n });
1163
- }
1164
- function ke() {
1165
- const n = re(fe);
1166
- if (!n)
1167
- throw new Error("useTenantSettings must be used within a TenantProvider");
1168
- return n;
1169
- }
1170
- function et() {
1171
- const {
1172
- settings: n,
1173
- settingsSchema: e,
1174
- isSettingsLoading: t,
1175
- settingsError: r,
1176
- updateSettings: s,
1177
- validateSettings: o
1178
- } = ke();
1179
- return {
1180
- settings: n,
1181
- settingsSchema: e,
1182
- isLoading: t,
1183
- error: r,
1184
- updateSettings: s,
1185
- validateSettings: o
1186
- };
1210
+ return i;
1187
1211
  }
1188
- var Z = /* @__PURE__ */ ((n) => (n.SUPERUSER = "SUPERUSER", n.TENANT_ADMIN = "TENANT_ADMIN", n.USER = "USER", n))(Z || {});
1189
- const le = () => /* @__PURE__ */ g(
1212
+ var J = /* @__PURE__ */ ((i) => (i.SUPERUSER = "SUPERUSER", i.TENANT_ADMIN = "TENANT_ADMIN", i.USER = "USER", i))(J || {});
1213
+ const de = () => /* @__PURE__ */ u(
1190
1214
  "div",
1191
1215
  {
1192
1216
  style: {
@@ -1202,10 +1226,10 @@ const le = () => /* @__PURE__ */ g(
1202
1226
  margin: "20px 0"
1203
1227
  },
1204
1228
  children: [
1205
- /* @__PURE__ */ i("div", { style: { fontSize: "2rem", marginBottom: "10px" }, children: "🔒" }),
1206
- /* @__PURE__ */ i("h3", { style: { color: "#495057", marginBottom: "10px" }, children: "Access Required" }),
1207
- /* @__PURE__ */ i("p", { style: { color: "#6c757d", fontSize: "14px", marginBottom: "15px" }, children: "You need to be signed in to view this content." }),
1208
- /* @__PURE__ */ i(
1229
+ /* @__PURE__ */ n("div", { style: { fontSize: "2rem", marginBottom: "10px" }, children: "🔒" }),
1230
+ /* @__PURE__ */ n("h3", { style: { color: "#495057", marginBottom: "10px" }, children: "Access Required" }),
1231
+ /* @__PURE__ */ n("p", { style: { color: "#6c757d", fontSize: "14px", marginBottom: "15px" }, children: "You need to be signed in to view this content." }),
1232
+ /* @__PURE__ */ n(
1209
1233
  "button",
1210
1234
  {
1211
1235
  style: {
@@ -1223,11 +1247,11 @@ const le = () => /* @__PURE__ */ g(
1223
1247
  )
1224
1248
  ]
1225
1249
  }
1226
- ), ce = ({
1227
- userType: n,
1250
+ ), ue = ({
1251
+ userType: i,
1228
1252
  minUserType: e,
1229
1253
  missingPermissions: t
1230
- }) => /* @__PURE__ */ g(
1254
+ }) => /* @__PURE__ */ u(
1231
1255
  "div",
1232
1256
  {
1233
1257
  style: {
@@ -1243,57 +1267,57 @@ const le = () => /* @__PURE__ */ g(
1243
1267
  margin: "20px 0"
1244
1268
  },
1245
1269
  children: [
1246
- /* @__PURE__ */ i("div", { style: { fontSize: "2rem", marginBottom: "10px" }, children: "⚠️" }),
1247
- /* @__PURE__ */ i("h3", { style: { color: "#856404", marginBottom: "10px" }, children: "Insufficient Permissions" }),
1248
- e && n ? /* @__PURE__ */ g(B, { children: [
1249
- /* @__PURE__ */ g("p", { style: { color: "#856404", fontSize: "14px", marginBottom: "10px" }, children: [
1270
+ /* @__PURE__ */ n("div", { style: { fontSize: "2rem", marginBottom: "10px" }, children: "⚠️" }),
1271
+ /* @__PURE__ */ n("h3", { style: { color: "#856404", marginBottom: "10px" }, children: "Insufficient Permissions" }),
1272
+ e && i ? /* @__PURE__ */ u(B, { children: [
1273
+ /* @__PURE__ */ u("p", { style: { color: "#856404", fontSize: "14px", marginBottom: "10px" }, children: [
1250
1274
  "This content requires ",
1251
- /* @__PURE__ */ i("strong", { children: e }),
1275
+ /* @__PURE__ */ n("strong", { children: e }),
1252
1276
  " access level or higher."
1253
1277
  ] }),
1254
- /* @__PURE__ */ g("p", { style: { color: "#6c757d", fontSize: "12px" }, children: [
1278
+ /* @__PURE__ */ u("p", { style: { color: "#6c757d", fontSize: "12px" }, children: [
1255
1279
  "Your current access level: ",
1256
- /* @__PURE__ */ i("strong", { children: n })
1280
+ /* @__PURE__ */ n("strong", { children: i })
1257
1281
  ] })
1258
- ] }) : /* @__PURE__ */ g(B, { children: [
1259
- /* @__PURE__ */ i("p", { style: { color: "#856404", fontSize: "14px", marginBottom: "10px" }, children: "You don't have the required permissions to view this content." }),
1260
- t && t.length > 0 && /* @__PURE__ */ g("p", { style: { color: "#6c757d", fontSize: "12px" }, children: [
1282
+ ] }) : /* @__PURE__ */ u(B, { children: [
1283
+ /* @__PURE__ */ n("p", { style: { color: "#856404", fontSize: "14px", marginBottom: "10px" }, children: "You don't have the required permissions to view this content." }),
1284
+ t && t.length > 0 && /* @__PURE__ */ u("p", { style: { color: "#6c757d", fontSize: "12px" }, children: [
1261
1285
  "Required permissions: ",
1262
- /* @__PURE__ */ i("strong", { children: t.join(", ") })
1286
+ /* @__PURE__ */ n("strong", { children: t.join(", ") })
1263
1287
  ] })
1264
1288
  ] })
1265
1289
  ]
1266
1290
  }
1267
- ), Me = (n, e) => {
1291
+ ), Ie = (i, e) => {
1268
1292
  const t = {
1269
- [Z.USER]: 1,
1270
- [Z.TENANT_ADMIN]: 2,
1271
- [Z.SUPERUSER]: 3
1293
+ [J.USER]: 1,
1294
+ [J.TENANT_ADMIN]: 2,
1295
+ [J.SUPERUSER]: 3
1272
1296
  };
1273
- return t[n] >= t[e];
1297
+ return t[i] >= t[e];
1274
1298
  };
1275
- function tt({
1276
- children: n,
1299
+ function it({
1300
+ children: i,
1277
1301
  fallback: e,
1278
1302
  minUserType: t,
1279
1303
  requiredPermissions: r,
1280
1304
  requireAllPermissions: s = !1
1281
1305
  }) {
1282
- const { hasValidSession: o, sessionManager: T, hasPermission: M, hasAnyPermission: S, hasAllPermissions: E } = ee();
1283
- if (!o())
1284
- return /* @__PURE__ */ i(B, { children: e || /* @__PURE__ */ i(le, {}) });
1285
- const w = T.getUser();
1286
- if (!w)
1287
- return /* @__PURE__ */ i(B, { children: e || /* @__PURE__ */ i(le, {}) });
1288
- if (t && !Me(w.userType, t))
1289
- return /* @__PURE__ */ i(ce, { userType: w.userType, minUserType: t });
1290
- if (r && r.length > 0 && !(s ? E(r) : S(r))) {
1291
- const v = r.filter((f) => !M(f)).map((f) => typeof f == "string" ? f : f.name);
1292
- return /* @__PURE__ */ i(ce, { missingPermissions: v });
1293
- }
1294
- return /* @__PURE__ */ i(B, { children: n });
1306
+ const { hasValidSession: a, sessionManager: v, hasPermission: M, hasAnyPermission: k, hasAllPermissions: P } = se();
1307
+ if (!a())
1308
+ return /* @__PURE__ */ n(B, { children: e || /* @__PURE__ */ n(de, {}) });
1309
+ const h = v.getUser();
1310
+ if (!h)
1311
+ return /* @__PURE__ */ n(B, { children: e || /* @__PURE__ */ n(de, {}) });
1312
+ if (t && !Ie(h.userType, t))
1313
+ return /* @__PURE__ */ n(ue, { userType: h.userType, minUserType: t });
1314
+ if (r && r.length > 0 && !(s ? P(r) : k(r))) {
1315
+ const x = r.filter((f) => !M(f)).map((f) => typeof f == "string" ? f : f.name);
1316
+ return /* @__PURE__ */ n(ue, { missingPermissions: x });
1317
+ }
1318
+ return /* @__PURE__ */ n(B, { children: i });
1295
1319
  }
1296
- const Ee = ({ redirectPath: n }) => /* @__PURE__ */ i(
1320
+ const He = ({ redirectPath: i }) => /* @__PURE__ */ n(
1297
1321
  "div",
1298
1322
  {
1299
1323
  style: {
@@ -1306,7 +1330,7 @@ const Ee = ({ redirectPath: n }) => /* @__PURE__ */ i(
1306
1330
  backgroundColor: "#f9fafb",
1307
1331
  textAlign: "center"
1308
1332
  },
1309
- children: /* @__PURE__ */ g(
1333
+ children: /* @__PURE__ */ u(
1310
1334
  "div",
1311
1335
  {
1312
1336
  style: {
@@ -1317,23 +1341,23 @@ const Ee = ({ redirectPath: n }) => /* @__PURE__ */ i(
1317
1341
  maxWidth: "400px"
1318
1342
  },
1319
1343
  children: [
1320
- /* @__PURE__ */ i("div", { style: { fontSize: "3rem", marginBottom: "1rem" }, children: "🔒" }),
1321
- /* @__PURE__ */ i("h2", { style: { color: "#374151", marginBottom: "1rem" }, children: "Access Required" }),
1322
- /* @__PURE__ */ i("p", { style: { color: "#6b7280", marginBottom: "1.5rem" }, children: "You need to be signed in to access this page." }),
1323
- /* @__PURE__ */ g("p", { style: { fontSize: "0.875rem", color: "#9ca3af" }, children: [
1344
+ /* @__PURE__ */ n("div", { style: { fontSize: "3rem", marginBottom: "1rem" }, children: "🔒" }),
1345
+ /* @__PURE__ */ n("h2", { style: { color: "#374151", marginBottom: "1rem" }, children: "Access Required" }),
1346
+ /* @__PURE__ */ n("p", { style: { color: "#6b7280", marginBottom: "1.5rem" }, children: "You need to be signed in to access this page." }),
1347
+ /* @__PURE__ */ u("p", { style: { fontSize: "0.875rem", color: "#9ca3af" }, children: [
1324
1348
  "Redirecting to ",
1325
- n,
1349
+ i,
1326
1350
  "..."
1327
1351
  ] })
1328
1352
  ]
1329
1353
  }
1330
1354
  )
1331
1355
  }
1332
- ), de = ({
1333
- userType: n,
1356
+ ), he = ({
1357
+ userType: i,
1334
1358
  minUserType: e,
1335
1359
  missingPermissions: t
1336
- }) => /* @__PURE__ */ i(
1360
+ }) => /* @__PURE__ */ n(
1337
1361
  "div",
1338
1362
  {
1339
1363
  style: {
@@ -1346,7 +1370,7 @@ const Ee = ({ redirectPath: n }) => /* @__PURE__ */ i(
1346
1370
  backgroundColor: "#f9fafb",
1347
1371
  textAlign: "center"
1348
1372
  },
1349
- children: /* @__PURE__ */ g(
1373
+ children: /* @__PURE__ */ u(
1350
1374
  "div",
1351
1375
  {
1352
1376
  style: {
@@ -1357,63 +1381,63 @@ const Ee = ({ redirectPath: n }) => /* @__PURE__ */ i(
1357
1381
  maxWidth: "400px"
1358
1382
  },
1359
1383
  children: [
1360
- /* @__PURE__ */ i("div", { style: { fontSize: "3rem", marginBottom: "1rem" }, children: "⚠️" }),
1361
- /* @__PURE__ */ i("h2", { style: { color: "#374151", marginBottom: "1rem" }, children: "Insufficient Permissions" }),
1362
- e && n ? /* @__PURE__ */ g(B, { children: [
1363
- /* @__PURE__ */ g("p", { style: { color: "#6b7280", marginBottom: "1rem" }, children: [
1384
+ /* @__PURE__ */ n("div", { style: { fontSize: "3rem", marginBottom: "1rem" }, children: "⚠️" }),
1385
+ /* @__PURE__ */ n("h2", { style: { color: "#374151", marginBottom: "1rem" }, children: "Insufficient Permissions" }),
1386
+ e && i ? /* @__PURE__ */ u(B, { children: [
1387
+ /* @__PURE__ */ u("p", { style: { color: "#6b7280", marginBottom: "1rem" }, children: [
1364
1388
  "This page requires ",
1365
- /* @__PURE__ */ i("strong", { children: e }),
1389
+ /* @__PURE__ */ n("strong", { children: e }),
1366
1390
  " access level or higher."
1367
1391
  ] }),
1368
- /* @__PURE__ */ g("p", { style: { color: "#9ca3af", fontSize: "0.875rem" }, children: [
1392
+ /* @__PURE__ */ u("p", { style: { color: "#9ca3af", fontSize: "0.875rem" }, children: [
1369
1393
  "Your current access level: ",
1370
- /* @__PURE__ */ i("strong", { children: n })
1394
+ /* @__PURE__ */ n("strong", { children: i })
1371
1395
  ] })
1372
- ] }) : /* @__PURE__ */ g(B, { children: [
1373
- /* @__PURE__ */ i("p", { style: { color: "#6b7280", marginBottom: "1rem" }, children: "You don't have the required permissions to access this page." }),
1374
- t && t.length > 0 && /* @__PURE__ */ g("p", { style: { color: "#9ca3af", fontSize: "0.875rem" }, children: [
1396
+ ] }) : /* @__PURE__ */ u(B, { children: [
1397
+ /* @__PURE__ */ n("p", { style: { color: "#6b7280", marginBottom: "1rem" }, children: "You don't have the required permissions to access this page." }),
1398
+ t && t.length > 0 && /* @__PURE__ */ u("p", { style: { color: "#9ca3af", fontSize: "0.875rem" }, children: [
1375
1399
  "Required permissions: ",
1376
- /* @__PURE__ */ i("strong", { children: t.join(", ") })
1400
+ /* @__PURE__ */ n("strong", { children: t.join(", ") })
1377
1401
  ] })
1378
1402
  ] })
1379
1403
  ]
1380
1404
  }
1381
1405
  )
1382
1406
  }
1383
- ), Re = (n, e) => {
1407
+ ), $e = (i, e) => {
1384
1408
  const t = {
1385
- [Z.USER]: 1,
1386
- [Z.TENANT_ADMIN]: 2,
1387
- [Z.SUPERUSER]: 3
1409
+ [J.USER]: 1,
1410
+ [J.TENANT_ADMIN]: 2,
1411
+ [J.SUPERUSER]: 3
1388
1412
  };
1389
- return t[n] >= t[e];
1413
+ return t[i] >= t[e];
1390
1414
  };
1391
- function rt({
1392
- children: n,
1415
+ function ot({
1416
+ children: i,
1393
1417
  redirectTo: e = "/login",
1394
1418
  minUserType: t,
1395
1419
  requiredPermissions: r,
1396
1420
  requireAllPermissions: s = !1,
1397
- fallback: o
1421
+ fallback: a
1398
1422
  }) {
1399
- const { hasValidSession: T, sessionManager: M, hasPermission: S, hasAnyPermission: E, hasAllPermissions: w } = ee(), p = we();
1400
- if (!T())
1401
- return o ? /* @__PURE__ */ i(B, { children: o }) : /* @__PURE__ */ g(B, { children: [
1402
- /* @__PURE__ */ i(Ee, { redirectPath: e }),
1403
- /* @__PURE__ */ i(ie, { to: e, state: { from: p.pathname }, replace: !0 })
1423
+ const { hasValidSession: v, sessionManager: M, hasPermission: k, hasAnyPermission: P, hasAllPermissions: h } = se(), g = me();
1424
+ if (!v())
1425
+ return a ? /* @__PURE__ */ n(B, { children: a }) : /* @__PURE__ */ u(B, { children: [
1426
+ /* @__PURE__ */ n(He, { redirectPath: e }),
1427
+ /* @__PURE__ */ n(ae, { to: e, state: { from: g.pathname }, replace: !0 })
1404
1428
  ] });
1405
- const v = M.getUser();
1406
- if (!v)
1407
- return /* @__PURE__ */ i(ie, { to: e, state: { from: p.pathname }, replace: !0 });
1408
- if (t && !Re(v.userType, t))
1409
- return /* @__PURE__ */ i(de, { userType: v.userType, minUserType: t });
1410
- if (r && r.length > 0 && !(s ? w(r) : E(r))) {
1411
- const y = r.filter((c) => !S(c)).map((c) => typeof c == "string" ? c : c.name);
1412
- return /* @__PURE__ */ i(de, { missingPermissions: y });
1413
- }
1414
- return /* @__PURE__ */ i(B, { children: n });
1429
+ const x = M.getUser();
1430
+ if (!x)
1431
+ return /* @__PURE__ */ n(ae, { to: e, state: { from: g.pathname }, replace: !0 });
1432
+ if (t && !$e(x.userType, t))
1433
+ return /* @__PURE__ */ n(he, { userType: x.userType, minUserType: t });
1434
+ if (r && r.length > 0 && !(s ? h(r) : P(r))) {
1435
+ const A = r.filter((F) => !k(F)).map((F) => typeof F == "string" ? F : F.name);
1436
+ return /* @__PURE__ */ n(he, { missingPermissions: A });
1437
+ }
1438
+ return /* @__PURE__ */ n(B, { children: i });
1415
1439
  }
1416
- const Fe = () => /* @__PURE__ */ g(
1440
+ const Ce = () => /* @__PURE__ */ u(
1417
1441
  "div",
1418
1442
  {
1419
1443
  style: {
@@ -1425,19 +1449,19 @@ const Fe = () => /* @__PURE__ */ g(
1425
1449
  color: "#dc2626"
1426
1450
  },
1427
1451
  children: [
1428
- /* @__PURE__ */ i("h3", { style: { margin: "0 0 1rem 0" }, children: "🔒 Subscription Required" }),
1429
- /* @__PURE__ */ i("p", { style: { margin: 0 }, children: "This feature requires a higher subscription plan. Please upgrade your plan to access this content." })
1452
+ /* @__PURE__ */ n("h3", { style: { margin: "0 0 1rem 0" }, children: "🔒 Subscription Required" }),
1453
+ /* @__PURE__ */ n("p", { style: { margin: 0 }, children: "This feature requires a higher subscription plan. Please upgrade your plan to access this content." })
1430
1454
  ]
1431
1455
  }
1432
1456
  );
1433
- function st({
1434
- children: n,
1435
- fallback: e = /* @__PURE__ */ i(Fe, {}),
1457
+ function at({
1458
+ children: i,
1459
+ fallback: e = /* @__PURE__ */ n(Ce, {}),
1436
1460
  allowedPlans: t,
1437
1461
  requiredFeature: r
1438
1462
  }) {
1439
- const { subscription: s, hasAllowedPlan: o, isFeatureEnabled: T, loading: M } = Te();
1440
- return M ? /* @__PURE__ */ i(
1463
+ const { subscription: s, hasAllowedPlan: a, isFeatureEnabled: v, loading: M } = Fe();
1464
+ return M ? /* @__PURE__ */ n(
1441
1465
  "div",
1442
1466
  {
1443
1467
  style: {
@@ -1447,9 +1471,9 @@ function st({
1447
1471
  },
1448
1472
  children: "Loading subscription..."
1449
1473
  }
1450
- ) : s ? s.isActive ? t && t.length > 0 && !o(t) ? /* @__PURE__ */ i(B, { children: e }) : r && !T(r) ? /* @__PURE__ */ i(B, { children: e }) : /* @__PURE__ */ i(B, { children: n }) : /* @__PURE__ */ i(B, { children: e }) : /* @__PURE__ */ i(B, { children: e });
1474
+ ) : s ? s.isActive ? t && t.length > 0 && !a(t) ? /* @__PURE__ */ n(B, { children: e }) : r && !v(r) ? /* @__PURE__ */ n(B, { children: e }) : /* @__PURE__ */ n(B, { children: i }) : /* @__PURE__ */ n(B, { children: e }) : /* @__PURE__ */ n(B, { children: e });
1451
1475
  }
1452
- const Ie = ({ flagName: n }) => /* @__PURE__ */ g(
1476
+ const Le = ({ flagName: i }) => /* @__PURE__ */ u(
1453
1477
  "div",
1454
1478
  {
1455
1479
  style: {
@@ -1466,19 +1490,19 @@ const Ie = ({ flagName: n }) => /* @__PURE__ */ g(
1466
1490
  color: "#6c757d"
1467
1491
  },
1468
1492
  children: [
1469
- /* @__PURE__ */ i("div", { style: { fontSize: "24px", marginBottom: "8px" }, children: "🚧" }),
1470
- /* @__PURE__ */ i("div", { style: { fontSize: "14px", fontWeight: "500", marginBottom: "4px" }, children: "Feature Not Available" }),
1471
- /* @__PURE__ */ g("div", { style: { fontSize: "12px", opacity: 0.7 }, children: [
1493
+ /* @__PURE__ */ n("div", { style: { fontSize: "24px", marginBottom: "8px" }, children: "🚧" }),
1494
+ /* @__PURE__ */ n("div", { style: { fontSize: "14px", fontWeight: "500", marginBottom: "4px" }, children: "Feature Not Available" }),
1495
+ /* @__PURE__ */ u("div", { style: { fontSize: "12px", opacity: 0.7 }, children: [
1472
1496
  'Feature flag "',
1473
- n,
1497
+ i,
1474
1498
  '" is disabled'
1475
1499
  ] })
1476
1500
  ]
1477
1501
  }
1478
1502
  );
1479
- function nt({ name: n, children: e, fallback: t }) {
1480
- const { isEnabled: r, loading: s } = Ae();
1481
- return s ? /* @__PURE__ */ i(
1503
+ function lt({ name: i, children: e, fallback: t }) {
1504
+ const { isEnabled: r, loading: s } = Ee();
1505
+ return s ? /* @__PURE__ */ n(
1482
1506
  "div",
1483
1507
  {
1484
1508
  style: {
@@ -1491,9 +1515,9 @@ function nt({ name: n, children: e, fallback: t }) {
1491
1515
  },
1492
1516
  children: "Loading feature flags..."
1493
1517
  }
1494
- ) : (console.log(n, r(n)), r(n) ? /* @__PURE__ */ i(B, { children: e }) : /* @__PURE__ */ i(B, { children: t || /* @__PURE__ */ i(Ie, { flagName: n }) }));
1518
+ ) : (console.log(i, r(i)), r(i) ? /* @__PURE__ */ n(B, { children: e }) : /* @__PURE__ */ n(B, { children: t || /* @__PURE__ */ n(Le, { flagName: i }) }));
1495
1519
  }
1496
- const He = () => /* @__PURE__ */ g(
1520
+ const De = () => /* @__PURE__ */ u(
1497
1521
  "svg",
1498
1522
  {
1499
1523
  width: "16",
@@ -1506,11 +1530,11 @@ const He = () => /* @__PURE__ */ g(
1506
1530
  strokeLinejoin: "round",
1507
1531
  style: { flexShrink: 0 },
1508
1532
  children: [
1509
- /* @__PURE__ */ i("path", { d: "M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z" }),
1510
- /* @__PURE__ */ i("circle", { cx: "12", cy: "12", r: "3" })
1533
+ /* @__PURE__ */ n("path", { d: "M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z" }),
1534
+ /* @__PURE__ */ n("circle", { cx: "12", cy: "12", r: "3" })
1511
1535
  ]
1512
1536
  }
1513
- ), $e = () => /* @__PURE__ */ g(
1537
+ ), Be = () => /* @__PURE__ */ u(
1514
1538
  "svg",
1515
1539
  {
1516
1540
  width: "16",
@@ -1523,14 +1547,14 @@ const He = () => /* @__PURE__ */ g(
1523
1547
  strokeLinejoin: "round",
1524
1548
  style: { flexShrink: 0 },
1525
1549
  children: [
1526
- /* @__PURE__ */ i("path", { d: "M17.94 17.94A10.07 10.07 0 0 1 12 20c-7 0-11-8-11-8a18.45 18.45 0 0 1 5.06-5.94M9.9 4.24A9.12 9.12 0 0 1 12 4c7 0 11 8 11 8a18.5 18.5 0 0 1-2.16 3.19m-6.72-1.07a3 3 0 1 1-4.24-4.24" }),
1527
- /* @__PURE__ */ i("line", { x1: "1", y1: "1", x2: "23", y2: "23" })
1550
+ /* @__PURE__ */ n("path", { d: "M17.94 17.94A10.07 10.07 0 0 1 12 20c-7 0-11-8-11-8a18.45 18.45 0 0 1 5.06-5.94M9.9 4.24A9.12 9.12 0 0 1 12 4c7 0 11 8 11 8a18.5 18.5 0 0 1-2.16 3.19m-6.72-1.07a3 3 0 1 1-4.24-4.24" }),
1551
+ /* @__PURE__ */ n("line", { x1: "1", y1: "1", x2: "23", y2: "23" })
1528
1552
  ]
1529
1553
  }
1530
- ), Ce = {
1531
- showPassword: /* @__PURE__ */ i(He, {}),
1532
- hidePassword: /* @__PURE__ */ i($e, {})
1533
- }, Le = {
1554
+ ), Ue = {
1555
+ showPassword: /* @__PURE__ */ n(De, {}),
1556
+ hidePassword: /* @__PURE__ */ n(Be, {})
1557
+ }, qe = {
1534
1558
  title: "Sign In",
1535
1559
  emailLabel: "Email",
1536
1560
  emailPlaceholder: "Enter your email",
@@ -1542,7 +1566,7 @@ const He = () => /* @__PURE__ */ g(
1542
1566
  signupText: "Don't have an account?",
1543
1567
  errorMessage: "Invalid email or password",
1544
1568
  loadingText: "Signing in..."
1545
- }, De = {
1569
+ }, Ne = {
1546
1570
  container: {
1547
1571
  maxWidth: "400px",
1548
1572
  width: "100%",
@@ -1649,119 +1673,119 @@ const He = () => /* @__PURE__ */ g(
1649
1673
  fontSize: "0.875rem"
1650
1674
  }
1651
1675
  };
1652
- function it({
1653
- copy: n = {},
1676
+ function ct({
1677
+ copy: i = {},
1654
1678
  styles: e = {},
1655
1679
  icons: t = {},
1656
1680
  onSuccess: r,
1657
1681
  onError: s,
1658
- onForgotPassword: o,
1659
- onSignupClick: T,
1682
+ onForgotPassword: a,
1683
+ onSignupClick: v,
1660
1684
  showForgotPassword: M = !0,
1661
- showSignupLink: S = !0,
1662
- className: E
1685
+ showSignupLink: k = !0,
1686
+ className: P
1663
1687
  }) {
1664
- const [w, p] = b(""), [v, f] = b(""), [y, c] = b(!1), [C, x] = b(!1), [d, l] = b(""), [a, u] = b({}), { login: k } = ee(), { tenant: F } = G(), m = { ...Le, ...n }, R = { ...De, ...e }, U = { ...Ce, ...t }, I = () => {
1665
- const L = {};
1666
- return w.trim() || (L.email = !0), v.trim() || (L.password = !0), u(L), Object.keys(L).length === 0;
1667
- }, h = async (L) => {
1668
- if (L.preventDefault(), !!I()) {
1669
- if (!(F != null && F.id)) {
1670
- l("Tenant not found");
1688
+ const [h, g] = m(""), [x, f] = m(""), [A, F] = m(!1), [y, C] = m(!1), [p, b] = m(""), [T, R] = m({}), { login: L } = se(), { tenant: E } = Z(), D = { ...qe, ...i }, l = { ...Ne, ...e }, w = { ...Ue, ...t }, d = () => {
1689
+ const I = {};
1690
+ return h.trim() || (I.email = !0), x.trim() || (I.password = !0), R(I), Object.keys(I).length === 0;
1691
+ }, o = async (I) => {
1692
+ if (I.preventDefault(), !!d()) {
1693
+ if (!(E != null && E.id)) {
1694
+ b("Tenant not found");
1671
1695
  return;
1672
1696
  }
1673
- x(!0), l("");
1697
+ C(!0), b("");
1674
1698
  try {
1675
- const z = await k(w, v, F.id);
1676
- r == null || r(z);
1677
- } catch (z) {
1678
- const _ = z.message || m.errorMessage;
1679
- l(_), s == null || s(_);
1699
+ const N = await L(h, x, E.id);
1700
+ r == null || r(N);
1701
+ } catch (N) {
1702
+ const _ = N.message || D.errorMessage;
1703
+ b(_), s == null || s(_);
1680
1704
  } finally {
1681
- x(!1);
1705
+ C(!1);
1682
1706
  }
1683
1707
  }
1684
- }, P = (L) => ({
1685
- ...R.input,
1686
- ...a[L] ? R.inputError : {}
1687
- }), Y = () => ({
1688
- ...R.button,
1689
- ...C ? R.buttonLoading : {},
1690
- ...!w || !v || C ? R.buttonDisabled : {}
1708
+ }, c = (I) => ({
1709
+ ...l.input,
1710
+ ...T[I] ? l.inputError : {}
1711
+ }), W = () => ({
1712
+ ...l.button,
1713
+ ...y ? l.buttonLoading : {},
1714
+ ...!h || !x || y ? l.buttonDisabled : {}
1691
1715
  });
1692
- return /* @__PURE__ */ g("div", { className: E, style: R.container, children: [
1693
- /* @__PURE__ */ i("h2", { style: R.title, children: m.title }),
1694
- /* @__PURE__ */ g("form", { onSubmit: h, style: R.form, children: [
1695
- /* @__PURE__ */ g("div", { style: R.fieldGroup, children: [
1696
- /* @__PURE__ */ i("label", { style: R.label, children: m.emailLabel }),
1697
- /* @__PURE__ */ i(
1716
+ return /* @__PURE__ */ u("div", { className: P, style: l.container, children: [
1717
+ /* @__PURE__ */ n("h2", { style: l.title, children: D.title }),
1718
+ /* @__PURE__ */ u("form", { onSubmit: o, style: l.form, children: [
1719
+ /* @__PURE__ */ u("div", { style: l.fieldGroup, children: [
1720
+ /* @__PURE__ */ n("label", { style: l.label, children: D.emailLabel }),
1721
+ /* @__PURE__ */ n(
1698
1722
  "input",
1699
1723
  {
1700
1724
  id: "email",
1701
1725
  name: "email",
1702
1726
  type: "email",
1703
- value: w,
1704
- onChange: (L) => {
1705
- p(L.target.value), a.email && u((z) => ({ ...z, email: !1 }));
1727
+ value: h,
1728
+ onChange: (I) => {
1729
+ g(I.target.value), T.email && R((N) => ({ ...N, email: !1 }));
1706
1730
  },
1707
- placeholder: m.emailPlaceholder,
1708
- style: P("email"),
1709
- disabled: C
1731
+ placeholder: D.emailPlaceholder,
1732
+ style: c("email"),
1733
+ disabled: y
1710
1734
  }
1711
1735
  )
1712
1736
  ] }),
1713
- /* @__PURE__ */ g("div", { style: R.fieldGroup, children: [
1714
- /* @__PURE__ */ i("label", { style: R.label, children: m.passwordLabel }),
1715
- /* @__PURE__ */ g("div", { style: R.inputContainer, children: [
1716
- /* @__PURE__ */ i(
1737
+ /* @__PURE__ */ u("div", { style: l.fieldGroup, children: [
1738
+ /* @__PURE__ */ n("label", { style: l.label, children: D.passwordLabel }),
1739
+ /* @__PURE__ */ u("div", { style: l.inputContainer, children: [
1740
+ /* @__PURE__ */ n(
1717
1741
  "input",
1718
1742
  {
1719
1743
  id: "password",
1720
1744
  name: "password",
1721
- type: y ? "text" : "password",
1722
- value: v,
1723
- onChange: (L) => {
1724
- f(L.target.value), a.password && u((z) => ({ ...z, password: !1 }));
1745
+ type: A ? "text" : "password",
1746
+ value: x,
1747
+ onChange: (I) => {
1748
+ f(I.target.value), T.password && R((N) => ({ ...N, password: !1 }));
1725
1749
  },
1726
- placeholder: m.passwordPlaceholder,
1750
+ placeholder: D.passwordPlaceholder,
1727
1751
  style: {
1728
- ...P("password"),
1752
+ ...c("password"),
1729
1753
  paddingRight: "2.5rem"
1730
1754
  // Make room for the icon
1731
1755
  },
1732
- disabled: C
1756
+ disabled: y
1733
1757
  }
1734
1758
  ),
1735
- /* @__PURE__ */ i(
1759
+ /* @__PURE__ */ n(
1736
1760
  "button",
1737
1761
  {
1738
1762
  type: "button",
1739
- onClick: () => c(!y),
1740
- style: R.passwordToggle,
1741
- disabled: C,
1742
- "aria-label": y ? "Hide password" : "Show password",
1743
- children: y ? U.hidePassword : U.showPassword
1763
+ onClick: () => F(!A),
1764
+ style: l.passwordToggle,
1765
+ disabled: y,
1766
+ "aria-label": A ? "Hide password" : "Show password",
1767
+ children: A ? w.hidePassword : w.showPassword
1744
1768
  }
1745
1769
  )
1746
1770
  ] })
1747
1771
  ] }),
1748
- /* @__PURE__ */ i("button", { type: "submit", disabled: !w || !v || C, style: Y(), children: C ? m.loadingText : m.submitButton }),
1749
- d && /* @__PURE__ */ i("div", { style: R.errorText, children: d })
1772
+ /* @__PURE__ */ n("button", { type: "submit", disabled: !h || !x || y, style: W(), children: y ? D.loadingText : D.submitButton }),
1773
+ p && /* @__PURE__ */ n("div", { style: l.errorText, children: p })
1750
1774
  ] }),
1751
- (M || S) && /* @__PURE__ */ g("div", { style: R.linkContainer, children: [
1752
- M && /* @__PURE__ */ i("a", { onClick: o, style: R.link, children: m.forgotPasswordLink }),
1753
- M && S && /* @__PURE__ */ i("div", { style: R.divider, children: "•" }),
1754
- S && /* @__PURE__ */ g("div", { children: [
1755
- /* @__PURE__ */ g("span", { style: R.divider, children: [
1756
- m.signupText,
1775
+ (M || k) && /* @__PURE__ */ u("div", { style: l.linkContainer, children: [
1776
+ M && /* @__PURE__ */ n("a", { onClick: a, style: l.link, children: D.forgotPasswordLink }),
1777
+ M && k && /* @__PURE__ */ n("div", { style: l.divider, children: "•" }),
1778
+ k && /* @__PURE__ */ u("div", { children: [
1779
+ /* @__PURE__ */ u("span", { style: l.divider, children: [
1780
+ D.signupText,
1757
1781
  " "
1758
1782
  ] }),
1759
- /* @__PURE__ */ i("a", { onClick: T, style: R.link, children: m.signupLink })
1783
+ /* @__PURE__ */ n("a", { onClick: v, style: l.link, children: D.signupLink })
1760
1784
  ] })
1761
1785
  ] })
1762
1786
  ] });
1763
1787
  }
1764
- const Be = {
1788
+ const Oe = {
1765
1789
  title: "Create Account",
1766
1790
  nameLabel: "Full Name",
1767
1791
  namePlaceholder: "Enter your full name",
@@ -1781,7 +1805,7 @@ const Be = {
1781
1805
  passwordMismatchError: "Passwords do not match",
1782
1806
  isAdminLabel: "Create new organization",
1783
1807
  isAdminDescription: "Check this if you want to create a new organization"
1784
- }, qe = {
1808
+ }, ze = {
1785
1809
  container: {
1786
1810
  maxWidth: "400px",
1787
1811
  width: "100%",
@@ -1880,154 +1904,154 @@ const Be = {
1880
1904
  fontSize: "0.875rem"
1881
1905
  }
1882
1906
  };
1883
- function ot({
1884
- copy: n = {},
1907
+ function dt({
1908
+ copy: i = {},
1885
1909
  styles: e = {},
1886
1910
  signupType: t = "user",
1887
1911
  onSuccess: r,
1888
1912
  onError: s,
1889
- onLoginClick: o,
1890
- showLoginLink: T = !0,
1913
+ onLoginClick: a,
1914
+ showLoginLink: v = !0,
1891
1915
  className: M
1892
1916
  }) {
1893
- const [S, E] = b(""), [w, p] = b(""), [v, f] = b(""), [y, c] = b(""), [C, x] = b(""), [d, l] = b(!1), [a, u] = b(""), [k, F] = b({}), { signup: m, signupTenantAdmin: R } = ee(), { tenant: U } = G(), I = { ...Be, ...n }, h = { ...qe, ...e }, P = () => {
1917
+ const [k, P] = m(""), [h, g] = m(""), [x, f] = m(""), [A, F] = m(""), [y, C] = m(""), [p, b] = m(!1), [T, R] = m(""), [L, E] = m({}), { signup: D, signupTenantAdmin: l } = se(), { tenant: w } = Z(), d = { ...Oe, ...i }, o = { ...ze, ...e }, c = () => {
1894
1918
  const H = {};
1895
- return S.trim() || (H.name = !0), w.trim() || (H.email = !0), v.trim() || (H.password = !0), y.trim() || (H.confirmPassword = !0), t === "tenant" && !C.trim() && (H.tenantName = !0), F(H), Object.keys(H).length === 0;
1896
- }, Y = async (H) => {
1897
- if (H.preventDefault(), !!P()) {
1898
- if (v !== y) {
1899
- u(I.passwordMismatchError), F({ confirmPassword: !0 });
1919
+ return k.trim() || (H.name = !0), h.trim() || (H.email = !0), x.trim() || (H.password = !0), A.trim() || (H.confirmPassword = !0), t === "tenant" && !y.trim() && (H.tenantName = !0), E(H), Object.keys(H).length === 0;
1920
+ }, W = async (H) => {
1921
+ if (H.preventDefault(), !!c()) {
1922
+ if (x !== A) {
1923
+ R(d.passwordMismatchError), E({ confirmPassword: !0 });
1900
1924
  return;
1901
1925
  }
1902
- if (t === "user" && !(U != null && U.id)) {
1903
- u("Tenant not found");
1926
+ if (t === "user" && !(w != null && w.id)) {
1927
+ R("Tenant not found");
1904
1928
  return;
1905
1929
  }
1906
- l(!0), u("");
1930
+ b(!0), R("");
1907
1931
  try {
1908
1932
  let q;
1909
- t === "tenant" ? q = await R(w, S, v, C) : q = await m(w, S, v, U.id), r == null || r(q);
1933
+ t === "tenant" ? q = await l(h, k, x, y) : q = await D(h, k, x, w.id), r == null || r(q);
1910
1934
  } catch (q) {
1911
- const Q = q.message || I.errorMessage;
1912
- u(Q), s == null || s(Q);
1935
+ const Y = q.message || d.errorMessage;
1936
+ R(Y), s == null || s(Y);
1913
1937
  } finally {
1914
- l(!1);
1938
+ b(!1);
1915
1939
  }
1916
1940
  }
1917
- }, L = (H) => ({
1918
- ...h.input,
1919
- ...k[H] ? h.inputError : {}
1920
- }), z = () => ({
1921
- ...h.button,
1922
- ...d ? h.buttonLoading : {},
1923
- ...!S || !w || !v || !y || d || t === "tenant" && !C ? h.buttonDisabled : {}
1924
- }), _ = S && w && v && y && (t === "user" || C);
1925
- return /* @__PURE__ */ g("div", { className: M, style: h.container, children: [
1926
- /* @__PURE__ */ i("h2", { style: h.title, children: I.title }),
1927
- /* @__PURE__ */ g("form", { onSubmit: Y, style: h.form, children: [
1928
- /* @__PURE__ */ g("div", { style: h.fieldGroup, children: [
1929
- /* @__PURE__ */ i("label", { style: h.label, children: I.nameLabel }),
1930
- /* @__PURE__ */ i(
1941
+ }, I = (H) => ({
1942
+ ...o.input,
1943
+ ...L[H] ? o.inputError : {}
1944
+ }), N = () => ({
1945
+ ...o.button,
1946
+ ...p ? o.buttonLoading : {},
1947
+ ...!k || !h || !x || !A || p || t === "tenant" && !y ? o.buttonDisabled : {}
1948
+ }), _ = k && h && x && A && (t === "user" || y);
1949
+ return /* @__PURE__ */ u("div", { className: M, style: o.container, children: [
1950
+ /* @__PURE__ */ n("h2", { style: o.title, children: d.title }),
1951
+ /* @__PURE__ */ u("form", { onSubmit: W, style: o.form, children: [
1952
+ /* @__PURE__ */ u("div", { style: o.fieldGroup, children: [
1953
+ /* @__PURE__ */ n("label", { style: o.label, children: d.nameLabel }),
1954
+ /* @__PURE__ */ n(
1931
1955
  "input",
1932
1956
  {
1933
1957
  id: "name",
1934
1958
  name: "name",
1935
1959
  type: "text",
1936
- value: S,
1960
+ value: k,
1937
1961
  onChange: (H) => {
1938
- E(H.target.value), k.name && F((q) => ({ ...q, name: !1 }));
1962
+ P(H.target.value), L.name && E((q) => ({ ...q, name: !1 }));
1939
1963
  },
1940
- placeholder: I.namePlaceholder,
1941
- style: L("name"),
1942
- disabled: d
1964
+ placeholder: d.namePlaceholder,
1965
+ style: I("name"),
1966
+ disabled: p
1943
1967
  }
1944
1968
  )
1945
1969
  ] }),
1946
- /* @__PURE__ */ g("div", { style: h.fieldGroup, children: [
1947
- /* @__PURE__ */ i("label", { style: h.label, children: I.emailLabel }),
1948
- /* @__PURE__ */ i(
1970
+ /* @__PURE__ */ u("div", { style: o.fieldGroup, children: [
1971
+ /* @__PURE__ */ n("label", { style: o.label, children: d.emailLabel }),
1972
+ /* @__PURE__ */ n(
1949
1973
  "input",
1950
1974
  {
1951
1975
  id: "email",
1952
1976
  name: "email",
1953
1977
  type: "email",
1954
- value: w,
1978
+ value: h,
1955
1979
  onChange: (H) => {
1956
- p(H.target.value), k.email && F((q) => ({ ...q, email: !1 }));
1980
+ g(H.target.value), L.email && E((q) => ({ ...q, email: !1 }));
1957
1981
  },
1958
- placeholder: I.emailPlaceholder,
1959
- style: L("email"),
1960
- disabled: d
1982
+ placeholder: d.emailPlaceholder,
1983
+ style: I("email"),
1984
+ disabled: p
1961
1985
  }
1962
1986
  )
1963
1987
  ] }),
1964
- /* @__PURE__ */ g("div", { style: h.fieldGroup, children: [
1965
- /* @__PURE__ */ i("label", { style: h.label, children: I.passwordLabel }),
1966
- /* @__PURE__ */ i(
1988
+ /* @__PURE__ */ u("div", { style: o.fieldGroup, children: [
1989
+ /* @__PURE__ */ n("label", { style: o.label, children: d.passwordLabel }),
1990
+ /* @__PURE__ */ n(
1967
1991
  "input",
1968
1992
  {
1969
1993
  id: "password",
1970
1994
  name: "password",
1971
1995
  type: "password",
1972
- value: v,
1996
+ value: x,
1973
1997
  onChange: (H) => {
1974
- f(H.target.value), k.password && F((q) => ({ ...q, password: !1 }));
1998
+ f(H.target.value), L.password && E((q) => ({ ...q, password: !1 }));
1975
1999
  },
1976
- placeholder: I.passwordPlaceholder,
1977
- style: L("password"),
1978
- disabled: d
2000
+ placeholder: d.passwordPlaceholder,
2001
+ style: I("password"),
2002
+ disabled: p
1979
2003
  }
1980
2004
  )
1981
2005
  ] }),
1982
- /* @__PURE__ */ g("div", { style: h.fieldGroup, children: [
1983
- /* @__PURE__ */ i("label", { style: h.label, children: I.confirmPasswordLabel }),
1984
- /* @__PURE__ */ i(
2006
+ /* @__PURE__ */ u("div", { style: o.fieldGroup, children: [
2007
+ /* @__PURE__ */ n("label", { style: o.label, children: d.confirmPasswordLabel }),
2008
+ /* @__PURE__ */ n(
1985
2009
  "input",
1986
2010
  {
1987
2011
  id: "confirmPassword",
1988
2012
  name: "confirmPassword",
1989
2013
  type: "password",
1990
- value: y,
2014
+ value: A,
1991
2015
  onChange: (H) => {
1992
- c(H.target.value), k.confirmPassword && F((q) => ({ ...q, confirmPassword: !1 })), a === I.passwordMismatchError && u("");
2016
+ F(H.target.value), L.confirmPassword && E((q) => ({ ...q, confirmPassword: !1 })), T === d.passwordMismatchError && R("");
1993
2017
  },
1994
- placeholder: I.confirmPasswordPlaceholder,
1995
- style: L("confirmPassword"),
1996
- disabled: d
2018
+ placeholder: d.confirmPasswordPlaceholder,
2019
+ style: I("confirmPassword"),
2020
+ disabled: p
1997
2021
  }
1998
2022
  )
1999
2023
  ] }),
2000
- t === "tenant" && /* @__PURE__ */ g("div", { style: h.fieldGroup, children: [
2001
- /* @__PURE__ */ i("label", { style: h.label, children: I.tenantNameLabel }),
2002
- /* @__PURE__ */ i(
2024
+ t === "tenant" && /* @__PURE__ */ u("div", { style: o.fieldGroup, children: [
2025
+ /* @__PURE__ */ n("label", { style: o.label, children: d.tenantNameLabel }),
2026
+ /* @__PURE__ */ n(
2003
2027
  "input",
2004
2028
  {
2005
2029
  id: "tenantName",
2006
2030
  name: "tenantName",
2007
2031
  type: "text",
2008
- value: C,
2032
+ value: y,
2009
2033
  onChange: (H) => {
2010
- x(H.target.value), k.tenantName && F((q) => ({ ...q, tenantName: !1 }));
2034
+ C(H.target.value), L.tenantName && E((q) => ({ ...q, tenantName: !1 }));
2011
2035
  },
2012
- placeholder: I.tenantNamePlaceholder,
2013
- style: L("tenantName"),
2014
- disabled: d
2036
+ placeholder: d.tenantNamePlaceholder,
2037
+ style: I("tenantName"),
2038
+ disabled: p
2015
2039
  }
2016
2040
  )
2017
2041
  ] }),
2018
- /* @__PURE__ */ i("button", { type: "submit", disabled: !_ || d, style: z(), children: d ? I.loadingText : I.submitButton }),
2019
- a && /* @__PURE__ */ i("div", { style: h.errorText, children: a })
2042
+ /* @__PURE__ */ n("button", { type: "submit", disabled: !_ || p, style: N(), children: p ? d.loadingText : d.submitButton }),
2043
+ T && /* @__PURE__ */ n("div", { style: o.errorText, children: T })
2020
2044
  ] }),
2021
- T && /* @__PURE__ */ g("div", { style: h.linkContainer, children: [
2022
- /* @__PURE__ */ g("span", { style: h.divider, children: [
2023
- I.loginText,
2045
+ v && /* @__PURE__ */ u("div", { style: o.linkContainer, children: [
2046
+ /* @__PURE__ */ u("span", { style: o.divider, children: [
2047
+ d.loginText,
2024
2048
  " "
2025
2049
  ] }),
2026
- /* @__PURE__ */ i("a", { onClick: o, style: h.link, children: I.loginLink })
2050
+ /* @__PURE__ */ n("a", { onClick: a, style: o.link, children: d.loginLink })
2027
2051
  ] })
2028
2052
  ] });
2029
2053
  }
2030
- const Ue = {
2054
+ const je = {
2031
2055
  title: "Reset Password",
2032
2056
  subtitle: "Enter your email address and we'll send you a link to reset your password.",
2033
2057
  emailLabel: "Email",
@@ -2049,7 +2073,7 @@ const Ue = {
2049
2073
  resetLoadingText: "Resetting...",
2050
2074
  resetSuccessMessage: "Password reset successfully!",
2051
2075
  passwordMismatchError: "Passwords do not match"
2052
- }, Ne = {
2076
+ }, Ve = {
2053
2077
  container: {
2054
2078
  maxWidth: "400px",
2055
2079
  margin: "0 auto",
@@ -2141,186 +2165,186 @@ const Ue = {
2141
2165
  cursor: "pointer"
2142
2166
  }
2143
2167
  };
2144
- function at({
2145
- copy: n = {},
2168
+ function ut({
2169
+ copy: i = {},
2146
2170
  styles: e = {},
2147
2171
  mode: t = "request",
2148
2172
  token: r = "",
2149
2173
  onSuccess: s,
2150
- onError: o,
2151
- onBackToLogin: T,
2174
+ onError: a,
2175
+ onBackToLogin: v,
2152
2176
  onModeChange: M,
2153
- className: S
2177
+ className: k
2154
2178
  }) {
2155
- const [E, w] = b(""), [p, v] = b(r), [f, y] = b(""), [c, C] = b(""), [x, d] = b(!1), [l, a] = b(""), [u, k] = b(""), [F, m] = b({}), { requestPasswordReset: R, confirmPasswordReset: U } = ee(), { tenant: I } = G(), h = { ...Ue, ...n }, P = { ...Ne, ...e }, Y = () => {
2156
- const D = {};
2157
- return E.trim() || (D.email = !0), m(D), Object.keys(D).length === 0;
2158
- }, L = () => {
2159
- const D = {};
2160
- return p.trim() || (D.token = !0), f.trim() || (D.newPassword = !0), c.trim() || (D.confirmPassword = !0), m(D), Object.keys(D).length === 0;
2161
- }, z = async (D) => {
2162
- if (D.preventDefault(), !!Y()) {
2163
- if (!(I != null && I.id)) {
2164
- a("Tenant not found");
2179
+ const [P, h] = m(""), [g, x] = m(r), [f, A] = m(""), [F, y] = m(""), [C, p] = m(!1), [b, T] = m(""), [R, L] = m(""), [E, D] = m({}), { requestPasswordReset: l, confirmPasswordReset: w } = se(), { tenant: d } = Z(), o = { ...je, ...i }, c = { ...Ve, ...e }, W = () => {
2180
+ const U = {};
2181
+ return P.trim() || (U.email = !0), D(U), Object.keys(U).length === 0;
2182
+ }, I = () => {
2183
+ const U = {};
2184
+ return g.trim() || (U.token = !0), f.trim() || (U.newPassword = !0), F.trim() || (U.confirmPassword = !0), D(U), Object.keys(U).length === 0;
2185
+ }, N = async (U) => {
2186
+ if (U.preventDefault(), !!W()) {
2187
+ if (!(d != null && d.id)) {
2188
+ T("Tenant not found");
2165
2189
  return;
2166
2190
  }
2167
- d(!0), a(""), k("");
2191
+ p(!0), T(""), L("");
2168
2192
  try {
2169
- await R(E, I.id), k(h.successMessage), s == null || s();
2170
- } catch (j) {
2171
- const O = j.message || h.errorMessage;
2172
- a(O), o == null || o(O);
2193
+ await l(P, d.id), L(o.successMessage), s == null || s();
2194
+ } catch (z) {
2195
+ const j = z.message || o.errorMessage;
2196
+ T(j), a == null || a(j);
2173
2197
  } finally {
2174
- d(!1);
2198
+ p(!1);
2175
2199
  }
2176
2200
  }
2177
- }, _ = async (D) => {
2178
- if (D.preventDefault(), !!L()) {
2179
- if (f !== c) {
2180
- a(h.passwordMismatchError), m({ confirmPassword: !0 });
2201
+ }, _ = async (U) => {
2202
+ if (U.preventDefault(), !!I()) {
2203
+ if (f !== F) {
2204
+ T(o.passwordMismatchError), D({ confirmPassword: !0 });
2181
2205
  return;
2182
2206
  }
2183
- d(!0), a(""), k("");
2207
+ p(!0), T(""), L("");
2184
2208
  try {
2185
- await U(p, f), k(h.resetSuccessMessage), s == null || s();
2186
- } catch (j) {
2187
- const O = j.message || h.errorMessage;
2188
- a(O), o == null || o(O);
2209
+ await w(g, f), L(o.resetSuccessMessage), s == null || s();
2210
+ } catch (z) {
2211
+ const j = z.message || o.errorMessage;
2212
+ T(j), a == null || a(j);
2189
2213
  } finally {
2190
- d(!1);
2214
+ p(!1);
2191
2215
  }
2192
2216
  }
2193
- }, H = (D) => ({
2194
- ...P.input,
2195
- ...F[D] ? P.inputError : {}
2217
+ }, H = (U) => ({
2218
+ ...c.input,
2219
+ ...E[U] ? c.inputError : {}
2196
2220
  }), q = () => ({
2197
- ...P.button,
2198
- ...x ? P.buttonLoading : {}
2221
+ ...c.button,
2222
+ ...C ? c.buttonLoading : {}
2199
2223
  });
2200
2224
  if (t === "reset") {
2201
- const D = p && f && c;
2202
- return /* @__PURE__ */ g("div", { className: S, style: P.container, children: [
2203
- /* @__PURE__ */ i("h2", { style: P.title, children: h.resetTitle }),
2204
- /* @__PURE__ */ i("p", { style: P.subtitle, children: h.resetSubtitle }),
2205
- /* @__PURE__ */ g("form", { onSubmit: _, style: P.form, children: [
2206
- /* @__PURE__ */ g("div", { style: P.fieldGroup, children: [
2207
- /* @__PURE__ */ i("label", { style: P.label, children: h.tokenLabel }),
2208
- /* @__PURE__ */ i(
2225
+ const U = g && f && F;
2226
+ return /* @__PURE__ */ u("div", { className: k, style: c.container, children: [
2227
+ /* @__PURE__ */ n("h2", { style: c.title, children: o.resetTitle }),
2228
+ /* @__PURE__ */ n("p", { style: c.subtitle, children: o.resetSubtitle }),
2229
+ /* @__PURE__ */ u("form", { onSubmit: _, style: c.form, children: [
2230
+ /* @__PURE__ */ u("div", { style: c.fieldGroup, children: [
2231
+ /* @__PURE__ */ n("label", { style: c.label, children: o.tokenLabel }),
2232
+ /* @__PURE__ */ n(
2209
2233
  "input",
2210
2234
  {
2211
2235
  type: "text",
2212
- value: p,
2213
- onChange: (j) => {
2214
- v(j.target.value), F.token && m((O) => ({ ...O, token: !1 }));
2236
+ value: g,
2237
+ onChange: (z) => {
2238
+ x(z.target.value), E.token && D((j) => ({ ...j, token: !1 }));
2215
2239
  },
2216
- placeholder: h.tokenPlaceholder,
2240
+ placeholder: o.tokenPlaceholder,
2217
2241
  style: H("token"),
2218
- disabled: x
2242
+ disabled: C
2219
2243
  }
2220
2244
  )
2221
2245
  ] }),
2222
- /* @__PURE__ */ g("div", { style: P.fieldGroup, children: [
2223
- /* @__PURE__ */ i("label", { style: P.label, children: h.newPasswordLabel }),
2224
- /* @__PURE__ */ i(
2246
+ /* @__PURE__ */ u("div", { style: c.fieldGroup, children: [
2247
+ /* @__PURE__ */ n("label", { style: c.label, children: o.newPasswordLabel }),
2248
+ /* @__PURE__ */ n(
2225
2249
  "input",
2226
2250
  {
2227
2251
  type: "password",
2228
2252
  value: f,
2229
- onChange: (j) => {
2230
- y(j.target.value), F.newPassword && m((O) => ({ ...O, newPassword: !1 }));
2253
+ onChange: (z) => {
2254
+ A(z.target.value), E.newPassword && D((j) => ({ ...j, newPassword: !1 }));
2231
2255
  },
2232
- placeholder: h.newPasswordPlaceholder,
2256
+ placeholder: o.newPasswordPlaceholder,
2233
2257
  style: H("newPassword"),
2234
- disabled: x
2258
+ disabled: C
2235
2259
  }
2236
2260
  )
2237
2261
  ] }),
2238
- /* @__PURE__ */ g("div", { style: P.fieldGroup, children: [
2239
- /* @__PURE__ */ i("label", { style: P.label, children: h.confirmPasswordLabel }),
2240
- /* @__PURE__ */ i(
2262
+ /* @__PURE__ */ u("div", { style: c.fieldGroup, children: [
2263
+ /* @__PURE__ */ n("label", { style: c.label, children: o.confirmPasswordLabel }),
2264
+ /* @__PURE__ */ n(
2241
2265
  "input",
2242
2266
  {
2243
2267
  type: "password",
2244
- value: c,
2245
- onChange: (j) => {
2246
- C(j.target.value), F.confirmPassword && m((O) => ({ ...O, confirmPassword: !1 })), l === h.passwordMismatchError && a("");
2268
+ value: F,
2269
+ onChange: (z) => {
2270
+ y(z.target.value), E.confirmPassword && D((j) => ({ ...j, confirmPassword: !1 })), b === o.passwordMismatchError && T("");
2247
2271
  },
2248
- placeholder: h.confirmPasswordPlaceholder,
2272
+ placeholder: o.confirmPasswordPlaceholder,
2249
2273
  style: H("confirmPassword"),
2250
- disabled: x
2274
+ disabled: C
2251
2275
  }
2252
2276
  )
2253
2277
  ] }),
2254
- /* @__PURE__ */ i(
2278
+ /* @__PURE__ */ n(
2255
2279
  "button",
2256
2280
  {
2257
2281
  type: "submit",
2258
- disabled: !D || x,
2282
+ disabled: !U || C,
2259
2283
  style: {
2260
2284
  ...q(),
2261
- ...!D || x ? P.buttonDisabled : {}
2285
+ ...!U || C ? c.buttonDisabled : {}
2262
2286
  },
2263
- children: x ? h.resetLoadingText : h.resetSubmitButton
2287
+ children: C ? o.resetLoadingText : o.resetSubmitButton
2264
2288
  }
2265
2289
  ),
2266
- l && /* @__PURE__ */ i("div", { style: P.errorText, children: l }),
2267
- u && /* @__PURE__ */ i("div", { style: P.successText, children: u })
2290
+ b && /* @__PURE__ */ n("div", { style: c.errorText, children: b }),
2291
+ R && /* @__PURE__ */ n("div", { style: c.successText, children: R })
2268
2292
  ] }),
2269
- /* @__PURE__ */ g("div", { style: P.linkContainer, children: [
2270
- /* @__PURE__ */ i("a", { onClick: T, style: P.link, children: h.backToLoginLink }),
2271
- M && /* @__PURE__ */ g(B, { children: [
2272
- /* @__PURE__ */ i("span", { style: { margin: "0 0.5rem", color: "#6b7280" }, children: "•" }),
2273
- /* @__PURE__ */ i("a", { onClick: () => M("request"), style: P.link, children: "Request New Link" })
2293
+ /* @__PURE__ */ u("div", { style: c.linkContainer, children: [
2294
+ /* @__PURE__ */ n("a", { onClick: v, style: c.link, children: o.backToLoginLink }),
2295
+ M && /* @__PURE__ */ u(B, { children: [
2296
+ /* @__PURE__ */ n("span", { style: { margin: "0 0.5rem", color: "#6b7280" }, children: "•" }),
2297
+ /* @__PURE__ */ n("a", { onClick: () => M("request"), style: c.link, children: "Request New Link" })
2274
2298
  ] })
2275
2299
  ] })
2276
2300
  ] });
2277
2301
  }
2278
- const Q = E;
2279
- return /* @__PURE__ */ g("div", { className: S, style: P.container, children: [
2280
- /* @__PURE__ */ i("h2", { style: P.title, children: h.title }),
2281
- /* @__PURE__ */ i("p", { style: P.subtitle, children: h.subtitle }),
2282
- /* @__PURE__ */ g("form", { onSubmit: z, style: P.form, children: [
2283
- /* @__PURE__ */ g("div", { style: P.fieldGroup, children: [
2284
- /* @__PURE__ */ i("label", { style: P.label, children: h.emailLabel }),
2285
- /* @__PURE__ */ i(
2302
+ const Y = P;
2303
+ return /* @__PURE__ */ u("div", { className: k, style: c.container, children: [
2304
+ /* @__PURE__ */ n("h2", { style: c.title, children: o.title }),
2305
+ /* @__PURE__ */ n("p", { style: c.subtitle, children: o.subtitle }),
2306
+ /* @__PURE__ */ u("form", { onSubmit: N, style: c.form, children: [
2307
+ /* @__PURE__ */ u("div", { style: c.fieldGroup, children: [
2308
+ /* @__PURE__ */ n("label", { style: c.label, children: o.emailLabel }),
2309
+ /* @__PURE__ */ n(
2286
2310
  "input",
2287
2311
  {
2288
2312
  type: "email",
2289
- value: E,
2290
- onChange: (D) => {
2291
- w(D.target.value), F.email && m((j) => ({ ...j, email: !1 }));
2313
+ value: P,
2314
+ onChange: (U) => {
2315
+ h(U.target.value), E.email && D((z) => ({ ...z, email: !1 }));
2292
2316
  },
2293
- placeholder: h.emailPlaceholder,
2317
+ placeholder: o.emailPlaceholder,
2294
2318
  style: H("email"),
2295
- disabled: x
2319
+ disabled: C
2296
2320
  }
2297
2321
  )
2298
2322
  ] }),
2299
- /* @__PURE__ */ i(
2323
+ /* @__PURE__ */ n(
2300
2324
  "button",
2301
2325
  {
2302
2326
  type: "submit",
2303
- disabled: !Q || x,
2327
+ disabled: !Y || C,
2304
2328
  style: {
2305
2329
  ...q(),
2306
- ...!Q || x ? P.buttonDisabled : {}
2330
+ ...!Y || C ? c.buttonDisabled : {}
2307
2331
  },
2308
- children: x ? h.loadingText : h.submitButton
2332
+ children: C ? o.loadingText : o.submitButton
2309
2333
  }
2310
2334
  ),
2311
- l && /* @__PURE__ */ i("div", { style: P.errorText, children: l }),
2312
- u && /* @__PURE__ */ i("div", { style: P.successText, children: u })
2335
+ b && /* @__PURE__ */ n("div", { style: c.errorText, children: b }),
2336
+ R && /* @__PURE__ */ n("div", { style: c.successText, children: R })
2313
2337
  ] }),
2314
- /* @__PURE__ */ g("div", { style: P.linkContainer, children: [
2315
- /* @__PURE__ */ i("a", { onClick: T, style: P.link, children: h.backToLoginLink }),
2316
- M && /* @__PURE__ */ g(B, { children: [
2317
- /* @__PURE__ */ i("span", { style: { margin: "0 0.5rem", color: "#6b7280" }, children: "•" }),
2318
- /* @__PURE__ */ i("a", { onClick: () => M("reset"), style: P.link, children: "I have a token" })
2338
+ /* @__PURE__ */ u("div", { style: c.linkContainer, children: [
2339
+ /* @__PURE__ */ n("a", { onClick: v, style: c.link, children: o.backToLoginLink }),
2340
+ M && /* @__PURE__ */ u(B, { children: [
2341
+ /* @__PURE__ */ n("span", { style: { margin: "0 0.5rem", color: "#6b7280" }, children: "•" }),
2342
+ /* @__PURE__ */ n("a", { onClick: () => M("reset"), style: c.link, children: "I have a token" })
2319
2343
  ] })
2320
2344
  ] })
2321
2345
  ] });
2322
2346
  }
2323
- class lt {
2347
+ class ht {
2324
2348
  constructor(e, t) {
2325
2349
  this.httpService = e, this.sessionManager = t;
2326
2350
  }
@@ -2341,12 +2365,12 @@ class lt {
2341
2365
  throw new Error("SessionManager is required for private endpoints");
2342
2366
  const t = await this.sessionManager.getAuthHeaders(), r = new URLSearchParams();
2343
2367
  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);
2344
- const s = `/permissions/${r.toString() ? `?${r.toString()}` : ""}`, o = await this.httpService.get(s, {
2368
+ const s = `/permissions/${r.toString() ? `?${r.toString()}` : ""}`, a = await this.httpService.get(s, {
2345
2369
  headers: t
2346
2370
  });
2347
2371
  return {
2348
- permissions: o.data,
2349
- meta: o.meta
2372
+ permissions: a.data,
2373
+ meta: a.meta
2350
2374
  };
2351
2375
  }
2352
2376
  async getPermissionById(e) {
@@ -2381,14 +2405,14 @@ class lt {
2381
2405
  async getAppPermissions(e, t) {
2382
2406
  const r = new URLSearchParams();
2383
2407
  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);
2384
- const s = `/permissions/apps/${e}${r.toString() ? `?${r.toString()}` : ""}`, o = await this.httpService.get(s);
2408
+ const s = `/permissions/apps/${e}${r.toString() ? `?${r.toString()}` : ""}`, a = await this.httpService.get(s);
2385
2409
  return {
2386
- permissions: o.data,
2387
- meta: o.meta
2410
+ permissions: a.data,
2411
+ meta: a.meta
2388
2412
  };
2389
2413
  }
2390
2414
  }
2391
- class ct {
2415
+ class gt {
2392
2416
  constructor(e, t) {
2393
2417
  this.httpService = e, this.sessionManager = t;
2394
2418
  }
@@ -2405,12 +2429,12 @@ class ct {
2405
2429
  async getSubscriptionPlans(e) {
2406
2430
  const t = await this.sessionManager.getAuthHeaders(), r = new URLSearchParams();
2407
2431
  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);
2408
- const s = `/subscription-plans/${r.toString() ? `?${r.toString()}` : ""}`, o = await this.httpService.get(s, {
2432
+ const s = `/subscription-plans/${r.toString() ? `?${r.toString()}` : ""}`, a = await this.httpService.get(s, {
2409
2433
  headers: t
2410
2434
  });
2411
2435
  return {
2412
- plans: o.data,
2413
- meta: o.meta
2436
+ plans: a.data,
2437
+ meta: a.meta
2414
2438
  };
2415
2439
  }
2416
2440
  async getSubscriptionPlanById(e) {
@@ -2439,7 +2463,7 @@ class ct {
2439
2463
  });
2440
2464
  }
2441
2465
  }
2442
- class dt {
2466
+ class pt {
2443
2467
  constructor(e) {
2444
2468
  this.httpService = e;
2445
2469
  }
@@ -2448,7 +2472,7 @@ class dt {
2448
2472
  return await this.httpService.get("/health");
2449
2473
  }
2450
2474
  }
2451
- class ut {
2475
+ class ft {
2452
2476
  // Date string to Date object
2453
2477
  static toDate(e) {
2454
2478
  return new Date(e);
@@ -2571,39 +2595,40 @@ class ut {
2571
2595
  }
2572
2596
  }
2573
2597
  export {
2574
- ut as ApiMappers,
2575
- ye as AppApiService,
2576
- _e as AppProvider,
2577
- Se as AuthApiService,
2578
- Qe as AuthProvider,
2579
- nt as FeatureFlag,
2580
- xe as FeatureFlagApiService,
2581
- Je as FeatureFlagProvider,
2582
- dt as HealthApiService,
2583
- W as HttpService,
2584
- it as LoginForm,
2585
- at as PasswordRecoveryForm,
2586
- lt as PermissionApiService,
2587
- tt as Protected,
2588
- rt as ProtectedRoute,
2589
- ae as RoleApiService,
2590
- be as SessionManager,
2591
- ot as SignupForm,
2592
- Pe as SubscriptionApiService,
2593
- st as SubscriptionGuard,
2594
- ct as SubscriptionPlanApiService,
2595
- Xe as SubscriptionProvider,
2596
- ne as TenantApiService,
2598
+ ft as ApiMappers,
2599
+ be as AppApiService,
2600
+ Je as AppProvider,
2601
+ Ae as AuthApiService,
2602
+ rt as AuthProvider,
2603
+ lt as FeatureFlag,
2604
+ Me as FeatureFlagApiService,
2605
+ st as FeatureFlagProvider,
2606
+ pt as HealthApiService,
2607
+ G as HttpService,
2608
+ ct as LoginForm,
2609
+ ut as PasswordRecoveryForm,
2610
+ ht as PermissionApiService,
2611
+ it as Protected,
2612
+ ot as ProtectedRoute,
2613
+ le as RoleApiService,
2614
+ xe as SessionManager,
2615
+ dt as SignupForm,
2616
+ Re as SubscriptionApiService,
2617
+ at as SubscriptionGuard,
2618
+ gt as SubscriptionPlanApiService,
2619
+ nt as SubscriptionProvider,
2620
+ ce as TenantApiService,
2597
2621
  Ze as TenantProvider,
2598
- ve as UserApiService,
2599
- Z as UserType,
2600
- Ke as useApi,
2601
- G as useApp,
2602
- ee as useAuth,
2603
- Ae as useFeatureFlags,
2604
- et as useSettings,
2605
- Te as useSubscription,
2606
- Ye as useTenant,
2607
- ke as useTenantSettings
2622
+ Pe as UserApiService,
2623
+ J as UserType,
2624
+ Xe as useApi,
2625
+ re as useApp,
2626
+ se as useAuth,
2627
+ Ee as useFeatureFlags,
2628
+ tt as useSettings,
2629
+ Fe as useSubscription,
2630
+ oe as useTenant,
2631
+ Z as useTenantInfo,
2632
+ et as useTenantSettings
2608
2633
  };
2609
2634
  //# sourceMappingURL=index.es.js.map