@firecms/user_management 3.0.0-canary.40 → 3.0.0-canary.42

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,12 +1,12 @@
1
- import F, { useEffect as se, useCallback as I, useContext as Ie, useState as P } from "react";
2
- import { getFirestore as q, onSnapshot as ae, collection as ee, setDoc as ce, doc as H, addDoc as ke, deleteDoc as de } from "firebase/firestore";
3
- import { jsx as e, jsxs as l, Fragment as K } from "react/jsx-runtime";
4
- import { getColorSchemeForSeed as Fe, Chip as Pe, Dialog as ue, DialogContent as me, Typography as $, TextField as Q, Paper as Ae, Table as ie, TableHeader as re, TableCell as a, TableBody as oe, TableRow as Y, Tooltip as _, Checkbox as k, Select as ne, SelectItem as T, DialogActions as he, Button as W, LoadingButton as fe, DoneIcon as ge, IconButton as pe, DeleteIcon as Ce, CenteredView as ve, Container as we, AddIcon as ye, MultiSelect as Te, MultiSelectItem as Be } from "@firecms/ui";
5
- import * as O from "yup";
6
- import { toSnakeCase as Le, FieldCaption as B, DeleteConfirmationDialog as be, useNavigationController as Ve, useSnackbarController as Ne, useAuthController as xe, useCustomizationController as _e, defaultDateFormat as Oe } from "@firecms/core";
7
- import { useCreateFormex as Re, getIn as z, Formex as De } from "@firecms/formex";
8
- import { format as $e } from "date-fns";
9
- import * as Me from "date-fns/locale";
1
+ import F, { useEffect as ce, useCallback as k, useContext as Ie, useState as P } from "react";
2
+ import { getFirestore as Y, onSnapshot as ue, collection as ee, setDoc as me, doc as H, addDoc as Fe, deleteDoc as he } from "firebase/firestore";
3
+ import { jsx as e, jsxs as s, Fragment as K } from "react/jsx-runtime";
4
+ import { getColorSchemeForSeed as Pe, Chip as Ae, Dialog as fe, DialogContent as ge, Typography as A, TextField as Q, Paper as pe, Table as re, TableHeader as ie, TableCell as d, TableBody as oe, TableRow as W, Tooltip as V, Checkbox as I, Select as ne, SelectItem as L, DialogActions as Ce, Button as O, LoadingButton as ve, DoneIcon as we, IconButton as ye, DeleteIcon as be, CenteredView as Ne, Container as Ue, AddIcon as le, MultiSelect as Te, MultiSelectItem as Le } from "@firecms/ui";
5
+ import * as M from "yup";
6
+ import { toSnakeCase as Be, FieldCaption as B, DeleteConfirmationDialog as xe, useNavigationController as _e, useSnackbarController as se, useAuthController as ae, useCustomizationController as Ve, defaultDateFormat as Me } from "@firecms/core";
7
+ import { useCreateFormex as Re, getIn as J, Formex as De } from "@firecms/formex";
8
+ import { format as Oe } from "date-fns";
9
+ import * as $e from "date-fns/locale";
10
10
  const fn = ["Admin"], qe = {
11
11
  read: !1,
12
12
  edit: !1,
@@ -15,11 +15,11 @@ const fn = ["Admin"], qe = {
15
15
  };
16
16
  function Ye({
17
17
  collection: t,
18
- user: i
18
+ user: r
19
19
  }) {
20
- const n = i?.roles;
20
+ const n = r?.roles;
21
21
  if (n) {
22
- if (t.ownerId === i?.uid)
22
+ if (t.ownerId === r?.uid)
23
23
  return {
24
24
  read: !0,
25
25
  create: !0,
@@ -27,297 +27,299 @@ function Ye({
27
27
  delete: !0
28
28
  };
29
29
  {
30
- const d = {
30
+ const l = {
31
31
  read: !1,
32
32
  create: !1,
33
33
  edit: !1,
34
34
  delete: !1
35
35
  };
36
- return n.map((r) => We(r, t.id)).reduce(te, d);
36
+ return n.map((i) => We(i, t.id)).reduce(te, l);
37
37
  }
38
38
  } else
39
39
  return qe;
40
40
  }
41
- function We(t, i) {
41
+ function We(t, r) {
42
42
  const n = {
43
43
  read: t.isAdmin || t.defaultPermissions?.read,
44
44
  create: t.isAdmin || t.defaultPermissions?.create,
45
45
  edit: t.isAdmin || t.defaultPermissions?.edit,
46
46
  delete: t.isAdmin || t.defaultPermissions?.delete
47
47
  };
48
- return t.collectionPermissions && t.collectionPermissions[i] ? te(t.collectionPermissions[i], n) : t.defaultPermissions ? te(t.defaultPermissions, n) : n;
48
+ return t.collectionPermissions && t.collectionPermissions[r] ? te(t.collectionPermissions[r], n) : t.defaultPermissions ? te(t.defaultPermissions, n) : n;
49
49
  }
50
- const te = (t, i) => ({
51
- read: t.read || i.read,
52
- create: t.create || i.create,
53
- edit: t.edit || i.edit,
54
- delete: t.delete || i.delete
50
+ const te = (t, r) => ({
51
+ read: t.read || r.read,
52
+ create: t.create || r.create,
53
+ edit: t.edit || r.edit,
54
+ delete: t.delete || r.delete
55
55
  });
56
- function gn(t, i) {
57
- return t ? i.roles ? i.roles.map((n) => t.find((d) => d.id === n.id)).filter(Boolean) : [] : void 0;
56
+ function gn(t, r) {
57
+ return t ? r.roles ? r.roles.map((n) => t.find((l) => l.id === n.id)).filter(Boolean) : [] : void 0;
58
58
  }
59
- const je = (t, i) => {
60
- const n = t.map((r) => r.id), d = i.map((r) => r.id);
61
- return n.length === i.length && n.every((r) => d.includes(r));
59
+ const je = (t, r) => {
60
+ const n = t.map((i) => i.id), l = r.map((i) => i.id);
61
+ return n.length === r.length && n.every((i) => l.includes(i));
62
62
  };
63
- function pn(t, i) {
64
- if (!i)
63
+ function pn(t, r) {
64
+ if (!r)
65
65
  return;
66
- const n = ze(i), d = new Date(n.exp * 1e3);
66
+ const n = ze(r), l = new Date(n.exp * 1e3);
67
67
  localStorage.setItem(`auth_token::${t}`, JSON.stringify({
68
- token: i,
69
- expiry: d
68
+ token: r,
69
+ expiry: l
70
70
  }));
71
71
  }
72
72
  function Cn(t) {
73
- const i = localStorage.getItem(`auth_token::${t}`);
74
- if (i) {
75
- const n = JSON.parse(i);
73
+ const r = localStorage.getItem(`auth_token::${t}`);
74
+ if (r) {
75
+ const n = JSON.parse(r);
76
76
  if (n.expiry = new Date(n.expiry), n.expiry > /* @__PURE__ */ new Date())
77
77
  return n.token;
78
78
  }
79
79
  }
80
80
  function vn() {
81
81
  for (let t = 0; t < localStorage.length; t++) {
82
- const i = localStorage.key(t);
83
- i?.startsWith("auth_token::") && localStorage.removeItem(i);
82
+ const r = localStorage.key(t);
83
+ r?.startsWith("auth_token::") && localStorage.removeItem(r);
84
84
  }
85
85
  }
86
86
  function ze(t) {
87
87
  if (!t)
88
88
  throw new Error("No JWT token");
89
- const n = t.split(".")[1].replace(/-/g, "+").replace(/_/g, "/"), d = decodeURIComponent(window.atob(n).split("").map(function(r) {
90
- return "%" + ("00" + r.charCodeAt(0).toString(16)).slice(-2);
89
+ const n = t.split(".")[1].replace(/-/g, "+").replace(/_/g, "/"), l = decodeURIComponent(window.atob(n).split("").map(function(i) {
90
+ return "%" + ("00" + i.charCodeAt(0).toString(16)).slice(-2);
91
91
  }).join(""));
92
- return JSON.parse(d);
92
+ return JSON.parse(l);
93
93
  }
94
- function wn(t, i = 10) {
94
+ function wn(t, r = 10) {
95
95
  if (!/^#([0-9A-Fa-f]{3}){1,2}$/.test(t))
96
96
  throw new Error("Invalid color format");
97
97
  let n = t.substring(1).split("");
98
98
  n.length === 3 && (n = [n[0], n[0], n[1], n[1], n[2], n[2]]);
99
- let d = parseInt(n[0] + n[1], 16), r = parseInt(n[2] + n[3], 16), f = parseInt(n[4] + n[5], 16);
100
- return d = Math.floor(d * (1 - i / 100)), r = Math.floor(r * (1 - i / 100)), f = Math.floor(f * (1 - i / 100)), "#" + (d < 16 ? "0" : "") + d.toString(16) + (r < 16 ? "0" : "") + r.toString(16) + (f < 16 ? "0" : "") + f.toString(16);
99
+ let l = parseInt(n[0] + n[1], 16), i = parseInt(n[2] + n[3], 16), m = parseInt(n[4] + n[5], 16);
100
+ return l = Math.floor(l * (1 - r / 100)), i = Math.floor(i * (1 - r / 100)), m = Math.floor(m * (1 - r / 100)), "#" + (l < 16 ? "0" : "") + l.toString(16) + (i < 16 ? "0" : "") + i.toString(16) + (m < 16 ? "0" : "") + m.toString(16);
101
101
  }
102
- function yn(t, i = 10) {
102
+ function yn(t, r = 10) {
103
103
  if (!/^#([0-9A-Fa-f]{3}){1,2}$/.test(t))
104
104
  throw new Error("Invalid color format");
105
105
  let n = t.substring(1).split("");
106
106
  n.length === 3 && (n = [n[0], n[0], n[1], n[1], n[2], n[2]]);
107
- const d = parseInt(n[0] + n[1], 16), r = parseInt(n[2] + n[3], 16), f = parseInt(n[4] + n[5], 16), C = i / 100;
108
- return `rgba(${d}, ${r}, ${f}, ${C})`;
107
+ const l = parseInt(n[0] + n[1], 16), i = parseInt(n[2] + n[3], 16), m = parseInt(n[4] + n[5], 16), f = r / 100;
108
+ return `rgba(${l}, ${i}, ${m}, ${f})`;
109
109
  }
110
110
  function bn({
111
111
  firebaseApp: t,
112
- usersPath: i = "__FIRECMS/config/users",
112
+ usersPath: r = "__FIRECMS/config/users",
113
113
  rolesPath: n = "__FIRECMS/config/roles",
114
- usersLimit: d,
115
- canEditRoles: r = !0,
116
- allowDefaultRolesCreation: f,
117
- includeCollectionConfigPermissions: C
114
+ usersLimit: l,
115
+ canEditRoles: i = !0,
116
+ allowDefaultRolesCreation: m,
117
+ includeCollectionConfigPermissions: f
118
118
  }) {
119
- const [v, D] = F.useState(!0), [w, c] = F.useState(!0), [E, y] = F.useState([]), [s, g] = F.useState([]), b = s.map((h) => ({
120
- ...h,
121
- roles: E.filter((p) => h.roles?.includes(p.id))
122
- })), [N, L] = F.useState(), [J, u] = F.useState(), m = v || w;
123
- se(() => {
119
+ const [v, R] = F.useState(!0), [w, c] = F.useState(!0), [S, U] = F.useState([]), [a, C] = F.useState([]), y = a.map((g) => ({
120
+ ...g,
121
+ roles: S.filter((p) => g.roles?.includes(p.id))
122
+ })), [b, _] = F.useState(), [z, u] = F.useState(), h = v || w;
123
+ ce(() => {
124
124
  if (!t || !n)
125
125
  return;
126
- const h = q(t);
127
- return ae(
128
- ee(h, n),
126
+ const g = Y(t);
127
+ return ue(
128
+ ee(g, n),
129
129
  {
130
130
  next: (p) => {
131
- L(void 0);
131
+ _(void 0);
132
132
  try {
133
- const x = Ge(p.docs);
134
- y(x);
135
- } catch (x) {
136
- L(x);
133
+ const N = Ge(p.docs);
134
+ U(N);
135
+ } catch (N) {
136
+ console.error("Error loading roles", N), _(N);
137
137
  }
138
- D(!1);
138
+ R(!1);
139
139
  },
140
140
  error: (p) => {
141
- L(p), D(!1);
141
+ console.error("Error loading roles", p), _(p), R(!1);
142
142
  }
143
143
  }
144
144
  );
145
- }, [t, n]), se(() => {
146
- if (!t || !i)
145
+ }, [t, n]), ce(() => {
146
+ if (!t || !r)
147
147
  return;
148
- const h = q(t);
149
- return ae(
150
- ee(h, i),
148
+ const g = Y(t);
149
+ return ue(
150
+ ee(g, r),
151
151
  {
152
152
  next: (p) => {
153
153
  u(void 0);
154
154
  try {
155
- const x = Je(p.docs);
156
- g(x);
157
- } catch (x) {
158
- u(x);
155
+ const N = Je(p.docs);
156
+ C(N);
157
+ } catch (N) {
158
+ console.error("Error loading users", N), u(N);
159
159
  }
160
160
  c(!1);
161
161
  },
162
162
  error: (p) => {
163
- u(p), c(!1);
163
+ console.error("Error loading users", p), u(p), c(!1);
164
164
  }
165
165
  }
166
166
  );
167
- }, [t, i]);
168
- const R = I(async (h) => {
167
+ }, [t, r]);
168
+ const x = k(async (g) => {
169
169
  if (!t)
170
- throw Error("useFirestoreConfigurationPersistence Firebase not initialised");
171
- const p = q(t);
172
- if (!p || !i)
173
- throw Error("useFirestoreConfigurationPersistence Firestore not initialised");
174
- console.debug("Persisting user", h);
175
- const x = h.roles?.map((Ee) => Ee.id), {
176
- uid: M,
170
+ throw Error("useFirestoreUserManagement Firebase not initialised");
171
+ const p = Y(t);
172
+ if (!p || !r)
173
+ throw Error("useFirestoreUserManagement Firestore not initialised");
174
+ console.debug("Persisting user", g);
175
+ const N = g.roles?.map((ke) => ke.id), {
176
+ uid: q,
177
177
  ...Z
178
- } = h, le = {
178
+ } = g, de = {
179
179
  ...Z,
180
- roles: x
180
+ roles: N
181
181
  };
182
- return M ? ce(H(p, i, M), le, { merge: !0 }).then(() => h) : ke(ee(p, i), le).then(() => h);
183
- }, [i]), U = I((h) => {
182
+ return q ? me(H(p, r, q), de, { merge: !0 }).then(() => g) : Fe(ee(p, r), de).then(() => g);
183
+ }, [r, t]), D = k((g) => {
184
184
  if (!t)
185
- throw Error("useFirestoreConfigurationPersistence Firebase not initialised");
186
- const p = q(t);
185
+ throw Error("useFirestoreUserManagement Firebase not initialised");
186
+ const p = Y(t);
187
187
  if (!p || !n)
188
- throw Error("useFirestoreConfigurationPersistence Firestore not initialised");
189
- console.debug("Persisting role", h);
188
+ throw Error("useFirestoreUserManagement Firestore not initialised");
189
+ console.debug("Persisting role", g);
190
190
  const {
191
- id: x,
192
- ...M
193
- } = h, Z = H(p, n, x);
194
- return ce(Z, M, { merge: !0 });
195
- }, [n]), A = I(async (h) => {
191
+ id: N,
192
+ ...q
193
+ } = g, Z = H(p, n, N);
194
+ return me(Z, q, { merge: !0 });
195
+ }, [n, t]), T = k(async (g) => {
196
196
  if (!t)
197
- throw Error("useFirestoreConfigurationPersistence Firebase not initialised");
198
- const p = q(t);
199
- if (!p || !i)
200
- throw Error("useFirestoreConfigurationPersistence Firestore not initialised");
201
- console.debug("Deleting", h);
202
- const { uid: x } = h;
203
- return de(H(p, i, x));
204
- }, [i]), o = I((h) => {
197
+ throw Error("useFirestoreUserManagement Firebase not initialised");
198
+ const p = Y(t);
199
+ if (!p || !r)
200
+ throw Error("useFirestoreUserManagement Firestore not initialised");
201
+ console.debug("Deleting", g);
202
+ const { uid: N } = g;
203
+ return he(H(p, r, N));
204
+ }, [r, t]), o = k((g) => {
205
205
  if (!t)
206
- throw Error("useFirestoreConfigurationPersistence Firebase not initialised");
207
- const p = q(t);
206
+ throw Error("useFirestoreUserManagement Firebase not initialised");
207
+ const p = Y(t);
208
208
  if (!p || !n)
209
- throw Error("useFirestoreConfigurationPersistence Firestore not initialised");
210
- console.debug("Deleting", h);
211
- const { id: x } = h, M = H(p, n, x);
212
- return de(M);
213
- }, [n]), S = I(({
214
- collection: h,
209
+ throw Error("useFirestoreUserManagement Firestore not initialised");
210
+ console.debug("Deleting", g);
211
+ const { id: N } = g, q = H(p, n, N);
212
+ return he(q);
213
+ }, [n, t]), E = k(({
214
+ collection: g,
215
215
  user: p
216
216
  }) => Ye({
217
- collection: h,
217
+ collection: g,
218
218
  user: p
219
- }), []), V = b.map((h) => h.uid), G = I((h) => {
220
- if (!b)
219
+ }), []), $ = k((g) => {
220
+ if (!y)
221
221
  throw Error("Users not loaded");
222
- return b.find((x) => x.email?.toLowerCase() === h?.email?.toLowerCase())?.roles;
223
- }, [V]), Se = I(({ user: h }) => {
224
- if (console.log("Authenticating user", h), m)
225
- return console.log("User management is still loading"), !1;
226
- if (b.length === 0 || b.find((x) => x.email?.toLowerCase() === h?.email?.toLowerCase()))
222
+ return y.find((N) => N.email?.toLowerCase() === g?.email?.toLowerCase())?.roles;
223
+ }, [y]), G = k(({ user: g }) => {
224
+ if (console.debug("Authenticating user", g), h)
225
+ return console.warn("User management is still loading"), !1;
226
+ if (y.length === 0 || y.find((N) => N.email?.toLowerCase() === g?.email?.toLowerCase()))
227
227
  return !0;
228
- throw Error("Could not find a user with the provided email");
229
- }, [m, V]);
228
+ throw Error("Could not find a user with the provided email in the user management system.");
229
+ }, [h, y]);
230
230
  return {
231
- loading: m,
232
- roles: E,
233
- users: b,
234
- saveUser: R,
235
- saveRole: U,
236
- deleteUser: A,
231
+ loading: h,
232
+ roles: S,
233
+ users: y,
234
+ saveUser: x,
235
+ saveRole: D,
236
+ rolesError: b,
237
+ deleteUser: T,
237
238
  deleteRole: o,
238
- usersLimit: d,
239
- canEditRoles: r === void 0 ? !0 : r,
240
- allowDefaultRolesCreation: f === void 0 ? !0 : f,
241
- includeCollectionConfigPermissions: !!C,
242
- collectionPermissions: S,
243
- defineRolesFor: G,
244
- authenticator: Se
239
+ usersLimit: l,
240
+ usersError: z,
241
+ canEditRoles: i === void 0 ? !0 : i,
242
+ allowDefaultRolesCreation: m === void 0 ? !0 : m,
243
+ includeCollectionConfigPermissions: !!f,
244
+ collectionPermissions: E,
245
+ defineRolesFor: $,
246
+ authenticator: G
245
247
  };
246
248
  }
247
- const Je = (t) => t.map((i) => {
248
- const n = i.data();
249
+ const Je = (t) => t.map((r) => {
250
+ const n = r.data();
249
251
  return {
250
- uid: i.id,
252
+ uid: r.id,
251
253
  ...n,
252
254
  created_on: n?.created_on?.toDate(),
253
255
  updated_on: n?.updated_on?.toDate()
254
256
  };
255
- }), Ge = (t) => t.map((i) => ({
256
- id: i.id,
257
- ...i.data()
258
- })), Ue = F.createContext({});
257
+ }), Ge = (t) => t.map((r) => ({
258
+ id: r.id,
259
+ ...r.data()
260
+ })), Ee = F.createContext({});
259
261
  function He({
260
262
  children: t,
261
- userManagement: i
263
+ userManagement: r
262
264
  }) {
263
- return /* @__PURE__ */ e(Ue.Provider, { value: i, children: t });
265
+ return /* @__PURE__ */ e(Ee.Provider, { value: r, children: t });
264
266
  }
265
- const j = () => Ie(Ue);
267
+ const j = () => Ie(Ee);
266
268
  function X({ role: t }) {
267
- let i;
268
- return t.isAdmin ? i = "blueDarker" : t.id === "editor" ? i = "yellowLight" : t.id === "viewer" ? i = "grayLight" : i = Fe(t.id), /* @__PURE__ */ e(
269
- Pe,
269
+ let r;
270
+ return t.isAdmin ? r = "blueDarker" : t.id === "editor" ? r = "yellowLight" : t.id === "viewer" ? r = "grayLight" : r = Pe(t.id), /* @__PURE__ */ e(
271
+ Ae,
270
272
  {
271
- colorScheme: i,
273
+ colorScheme: r,
272
274
  children: t.name
273
275
  },
274
276
  t.id
275
277
  );
276
278
  }
277
- const Ke = O.object().shape({
278
- id: O.string().required("Required"),
279
- name: O.string().required("Required")
279
+ const Ke = M.object().shape({
280
+ id: M.string().required("Required"),
281
+ name: M.string().required("Required")
280
282
  });
281
283
  function Qe({
282
284
  open: t,
283
- role: i,
285
+ role: r,
284
286
  editable: n,
285
- handleClose: d,
286
- collections: r
287
+ handleClose: l,
288
+ collections: i
287
289
  }) {
288
- const { saveRole: f } = j(), C = !i, [v, D] = P(), w = I((o) => (D(void 0), f(o)), [f]), c = Re({
289
- initialValues: i ?? {
290
+ const { saveRole: m } = j(), f = !r, [v, R] = P(), w = k((o) => (R(void 0), m(o)), [m]), c = Re({
291
+ initialValues: r ?? {
290
292
  name: ""
291
293
  },
292
- onSubmit: (o, S) => w(o).then(() => {
293
- S.resetForm({
294
+ onSubmit: (o, E) => w(o).then(() => {
295
+ E.resetForm({
294
296
  values: o
295
- }), d();
296
- }).catch((V) => D(V)),
297
- validation: (o) => Ke.validate(o, { abortEarly: !1 }).then(() => ({})).catch((S) => {
298
- const V = {};
299
- return S.inner.forEach((G) => {
300
- V[G.path] = G.message;
301
- }), V;
297
+ }), l();
298
+ }).catch(($) => R($)),
299
+ validation: (o) => Ke.validate(o, { abortEarly: !1 }).then(() => ({})).catch((E) => {
300
+ const $ = {};
301
+ return E.inner.forEach((G) => {
302
+ $[G.path] = G.message;
303
+ }), $;
302
304
  })
303
305
  }), {
304
- isSubmitting: E,
305
- touched: y,
306
- values: s,
307
- errors: g,
308
- handleChange: b,
309
- setFieldValue: N,
310
- dirty: L,
311
- setFieldTouched: J
312
- } = c, u = s.isAdmin ?? !1, m = s.defaultPermissions?.create ?? !1, R = s.defaultPermissions?.read ?? !1, U = s.defaultPermissions?.edit ?? !1, A = s.defaultPermissions?.delete ?? !1;
306
+ isSubmitting: S,
307
+ touched: U,
308
+ values: a,
309
+ errors: C,
310
+ handleChange: y,
311
+ setFieldValue: b,
312
+ dirty: _,
313
+ setFieldTouched: z
314
+ } = c, u = a.isAdmin ?? !1, h = a.defaultPermissions?.create ?? !1, x = a.defaultPermissions?.read ?? !1, D = a.defaultPermissions?.edit ?? !1, T = a.defaultPermissions?.delete ?? !1;
313
315
  return F.useEffect(() => {
314
- !z(y, "id") && s.name && N("id", Le(s.name));
315
- }, [y, s.name]), /* @__PURE__ */ e(
316
- ue,
316
+ !J(U, "id") && a.name && b("id", Be(a.name));
317
+ }, [U, a.name]), /* @__PURE__ */ e(
318
+ fe,
317
319
  {
318
320
  open: t,
319
321
  maxWidth: "4xl",
320
- children: /* @__PURE__ */ e(De, { value: c, children: /* @__PURE__ */ l(
322
+ children: /* @__PURE__ */ e(De, { value: c, children: /* @__PURE__ */ s(
321
323
  "form",
322
324
  {
323
325
  noValidate: !0,
@@ -330,13 +332,13 @@ function Qe({
330
332
  height: "100%"
331
333
  },
332
334
  children: [
333
- /* @__PURE__ */ l(me, { className: "flex-grow", children: [
335
+ /* @__PURE__ */ s(ge, { className: "flex-grow", children: [
334
336
  /* @__PURE__ */ e(
335
337
  "div",
336
338
  {
337
339
  className: "flex flex-row pt-12 pb-8",
338
340
  children: /* @__PURE__ */ e(
339
- $,
341
+ A,
340
342
  {
341
343
  variant: "h4",
342
344
  className: "flex-grow",
@@ -345,101 +347,101 @@ function Qe({
345
347
  )
346
348
  }
347
349
  ),
348
- /* @__PURE__ */ l("div", { className: "grid grid-cols-12 gap-8", children: [
349
- /* @__PURE__ */ l("div", { className: "col-span-12 md:col-span-8", children: [
350
+ /* @__PURE__ */ s("div", { className: "grid grid-cols-12 gap-8", children: [
351
+ /* @__PURE__ */ s("div", { className: "col-span-12 md:col-span-8", children: [
350
352
  /* @__PURE__ */ e(
351
353
  Q,
352
354
  {
353
355
  name: "name",
354
356
  required: !0,
355
- error: y.name && !!g.name,
356
- value: s.name,
357
+ error: U.name && !!C.name,
358
+ value: a.name,
357
359
  disabled: u || !n,
358
- onChange: b,
360
+ onChange: y,
359
361
  "aria-describedby": "name-helper-text",
360
362
  label: "Name"
361
363
  }
362
364
  ),
363
- /* @__PURE__ */ e(B, { children: y.name && g.name ? g.name : "Name of this role" })
365
+ /* @__PURE__ */ e(B, { children: U.name && C.name ? C.name : "Name of this role" })
364
366
  ] }),
365
- /* @__PURE__ */ l("div", { className: "col-span-12 md:col-span-4", children: [
367
+ /* @__PURE__ */ s("div", { className: "col-span-12 md:col-span-4", children: [
366
368
  /* @__PURE__ */ e(
367
369
  Q,
368
370
  {
369
371
  name: "id",
370
372
  required: !0,
371
- error: y.id && !!g.id,
372
- value: s.id,
373
- disabled: !C || !n,
373
+ error: U.id && !!C.id,
374
+ value: a.id,
375
+ disabled: !f || !n,
374
376
  onChange: (o) => {
375
- b(o), J("id", !0);
377
+ y(o), z("id", !0);
376
378
  },
377
379
  "aria-describedby": "id-helper-text",
378
380
  label: "ID"
379
381
  }
380
382
  ),
381
- /* @__PURE__ */ e(B, { children: y.id && g.id ? g.id : "ID of this role" })
383
+ /* @__PURE__ */ e(B, { children: U.id && C.id ? C.id : "ID of this role" })
382
384
  ] }),
383
- /* @__PURE__ */ l("div", { className: "col-span-12", children: [
385
+ /* @__PURE__ */ s("div", { className: "col-span-12", children: [
384
386
  /* @__PURE__ */ e(
385
- Ae,
387
+ pe,
386
388
  {
387
389
  className: "bg-inherit",
388
- children: /* @__PURE__ */ l(ie, { children: [
389
- /* @__PURE__ */ l(re, { children: [
390
- /* @__PURE__ */ e(a, {}),
390
+ children: /* @__PURE__ */ s(re, { children: [
391
+ /* @__PURE__ */ s(ie, { children: [
392
+ /* @__PURE__ */ e(d, {}),
391
393
  /* @__PURE__ */ e(
392
- a,
394
+ d,
393
395
  {
394
396
  align: "center",
395
397
  children: "Create entities"
396
398
  }
397
399
  ),
398
400
  /* @__PURE__ */ e(
399
- a,
401
+ d,
400
402
  {
401
403
  align: "center",
402
404
  children: "Read entities"
403
405
  }
404
406
  ),
405
407
  /* @__PURE__ */ e(
406
- a,
408
+ d,
407
409
  {
408
410
  align: "center",
409
411
  children: "Update entities"
410
412
  }
411
413
  ),
412
414
  /* @__PURE__ */ e(
413
- a,
415
+ d,
414
416
  {
415
417
  align: "center",
416
418
  children: "Delete entities"
417
419
  }
418
420
  )
419
421
  ] }),
420
- /* @__PURE__ */ l(oe, { children: [
421
- /* @__PURE__ */ l(Y, { children: [
422
+ /* @__PURE__ */ s(oe, { children: [
423
+ /* @__PURE__ */ s(W, { children: [
422
424
  /* @__PURE__ */ e(
423
- a,
425
+ d,
424
426
  {
425
427
  scope: "row",
426
428
  children: /* @__PURE__ */ e("strong", { children: "All collections" })
427
429
  }
428
430
  ),
429
431
  /* @__PURE__ */ e(
430
- a,
432
+ d,
431
433
  {
432
434
  align: "center",
433
435
  children: /* @__PURE__ */ e(
434
- _,
436
+ V,
435
437
  {
436
438
  title: "Create entities in collections",
437
439
  children: /* @__PURE__ */ e(
438
- k,
440
+ I,
439
441
  {
440
442
  disabled: u || !n,
441
- checked: (u || m) ?? !1,
442
- onCheckedChange: (o) => N("defaultPermissions.create", o)
443
+ checked: (u || h) ?? !1,
444
+ onCheckedChange: (o) => b("defaultPermissions.create", o)
443
445
  }
444
446
  )
445
447
  }
@@ -447,19 +449,19 @@ function Qe({
447
449
  }
448
450
  ),
449
451
  /* @__PURE__ */ e(
450
- a,
452
+ d,
451
453
  {
452
454
  align: "center",
453
455
  children: /* @__PURE__ */ e(
454
- _,
456
+ V,
455
457
  {
456
458
  title: "Access all data in every collection",
457
459
  children: /* @__PURE__ */ e(
458
- k,
460
+ I,
459
461
  {
460
462
  disabled: u || !n,
461
- checked: (u || R) ?? !1,
462
- onCheckedChange: (o) => N("defaultPermissions.read", o)
463
+ checked: (u || x) ?? !1,
464
+ onCheckedChange: (o) => b("defaultPermissions.read", o)
463
465
  }
464
466
  )
465
467
  }
@@ -467,19 +469,19 @@ function Qe({
467
469
  }
468
470
  ),
469
471
  /* @__PURE__ */ e(
470
- a,
472
+ d,
471
473
  {
472
474
  align: "center",
473
475
  children: /* @__PURE__ */ e(
474
- _,
476
+ V,
475
477
  {
476
478
  title: "Update data in any collection",
477
479
  children: /* @__PURE__ */ e(
478
- k,
480
+ I,
479
481
  {
480
482
  disabled: u || !n,
481
- checked: (u || U) ?? !1,
482
- onCheckedChange: (o) => N("defaultPermissions.edit", o)
483
+ checked: (u || D) ?? !1,
484
+ onCheckedChange: (o) => b("defaultPermissions.edit", o)
483
485
  }
484
486
  )
485
487
  }
@@ -487,19 +489,19 @@ function Qe({
487
489
  }
488
490
  ),
489
491
  /* @__PURE__ */ e(
490
- a,
492
+ d,
491
493
  {
492
494
  align: "center",
493
495
  children: /* @__PURE__ */ e(
494
- _,
496
+ V,
495
497
  {
496
498
  title: "Delete data in any collection",
497
499
  children: /* @__PURE__ */ e(
498
- k,
500
+ I,
499
501
  {
500
502
  disabled: u || !n,
501
- checked: (u || A) ?? !1,
502
- onCheckedChange: (o) => N("defaultPermissions.delete", o)
503
+ checked: (u || T) ?? !1,
504
+ onCheckedChange: (o) => b("defaultPermissions.delete", o)
503
505
  }
504
506
  )
505
507
  }
@@ -507,66 +509,66 @@ function Qe({
507
509
  }
508
510
  )
509
511
  ] }),
510
- r && r.map((o) => /* @__PURE__ */ l(Y, { children: [
512
+ i && i.map((o) => /* @__PURE__ */ s(W, { children: [
511
513
  /* @__PURE__ */ e(
512
- a,
514
+ d,
513
515
  {
514
516
  scope: "row",
515
517
  children: o.name
516
518
  }
517
519
  ),
518
520
  /* @__PURE__ */ e(
519
- a,
521
+ d,
520
522
  {
521
523
  align: "center",
522
524
  children: /* @__PURE__ */ e(
523
- k,
525
+ I,
524
526
  {
525
- disabled: u || m || !n,
526
- checked: (u || m || z(s, `collectionPermissions.${o.path}.create`)) ?? !1,
527
- onCheckedChange: (S) => N(`collectionPermissions.${o.path}.create`, S)
527
+ disabled: u || h || !n,
528
+ checked: (u || h || J(a, `collectionPermissions.${o.path}.create`)) ?? !1,
529
+ onCheckedChange: (E) => b(`collectionPermissions.${o.path}.create`, E)
528
530
  }
529
531
  )
530
532
  }
531
533
  ),
532
534
  /* @__PURE__ */ e(
533
- a,
535
+ d,
534
536
  {
535
537
  align: "center",
536
538
  children: /* @__PURE__ */ e(
537
- k,
539
+ I,
538
540
  {
539
- disabled: u || R || !n,
540
- checked: (u || R || z(s, `collectionPermissions.${o.path}.read`)) ?? !1,
541
- onCheckedChange: (S) => N(`collectionPermissions.${o.path}.read`, S)
541
+ disabled: u || x || !n,
542
+ checked: (u || x || J(a, `collectionPermissions.${o.path}.read`)) ?? !1,
543
+ onCheckedChange: (E) => b(`collectionPermissions.${o.path}.read`, E)
542
544
  }
543
545
  )
544
546
  }
545
547
  ),
546
548
  /* @__PURE__ */ e(
547
- a,
549
+ d,
548
550
  {
549
551
  align: "center",
550
552
  children: /* @__PURE__ */ e(
551
- k,
553
+ I,
552
554
  {
553
- disabled: u || U || !n,
554
- checked: (u || U || z(s, `collectionPermissions.${o.path}.edit`)) ?? !1,
555
- onCheckedChange: (S) => N(`collectionPermissions.${o.path}.edit`, S)
555
+ disabled: u || D || !n,
556
+ checked: (u || D || J(a, `collectionPermissions.${o.path}.edit`)) ?? !1,
557
+ onCheckedChange: (E) => b(`collectionPermissions.${o.path}.edit`, E)
556
558
  }
557
559
  )
558
560
  }
559
561
  ),
560
562
  /* @__PURE__ */ e(
561
- a,
563
+ d,
562
564
  {
563
565
  align: "center",
564
566
  children: /* @__PURE__ */ e(
565
- k,
567
+ I,
566
568
  {
567
- disabled: u || A || !n,
568
- checked: (u || A || z(s, `collectionPermissions.${o.path}.delete`)) ?? !1,
569
- onCheckedChange: (S) => N(`collectionPermissions.${o.path}.delete`, S)
569
+ disabled: u || T || !n,
570
+ checked: (u || T || J(a, `collectionPermissions.${o.path}.delete`)) ?? !1,
571
+ onCheckedChange: (E) => b(`collectionPermissions.${o.path}.delete`, E)
570
572
  }
571
573
  )
572
574
  }
@@ -578,29 +580,29 @@ function Qe({
578
580
  ),
579
581
  /* @__PURE__ */ e(B, { children: "You can customise the permissions that the users related to this role can perform in the entities of each collection" })
580
582
  ] }),
581
- /* @__PURE__ */ l("div", { className: "col-span-12 md:col-span-4", children: [
582
- /* @__PURE__ */ l(
583
+ /* @__PURE__ */ s("div", { className: "col-span-12 md:col-span-4", children: [
584
+ /* @__PURE__ */ s(
583
585
  ne,
584
586
  {
585
- error: y.config && !!g.config,
587
+ error: U.config && !!C.config,
586
588
  id: "createCollections",
587
589
  name: "createCollections",
588
590
  label: "Create collections",
589
591
  position: "item-aligned",
590
592
  disabled: u || !n,
591
- onChange: (o) => N("config.createCollections", o.target.value === "true"),
592
- value: u || s.config?.createCollections ? "true" : "false",
593
+ onChange: (o) => b("config.createCollections", o.target.value === "true"),
594
+ value: u || a.config?.createCollections ? "true" : "false",
593
595
  renderValue: (o) => o === "true" ? "Yes" : "No",
594
596
  children: [
595
597
  /* @__PURE__ */ e(
596
- T,
598
+ L,
597
599
  {
598
600
  value: "true",
599
601
  children: " Yes "
600
602
  }
601
603
  ),
602
604
  /* @__PURE__ */ e(
603
- T,
605
+ L,
604
606
  {
605
607
  value: "false",
606
608
  children: " No "
@@ -609,38 +611,38 @@ function Qe({
609
611
  ]
610
612
  }
611
613
  ),
612
- /* @__PURE__ */ e(B, { children: y.config && g.config ? g.config : "Can the user create collections" })
614
+ /* @__PURE__ */ e(B, { children: U.config && C.config ? C.config : "Can the user create collections" })
613
615
  ] }),
614
- /* @__PURE__ */ l("div", { className: "col-span-12 md:col-span-4", children: [
615
- /* @__PURE__ */ l(
616
+ /* @__PURE__ */ s("div", { className: "col-span-12 md:col-span-4", children: [
617
+ /* @__PURE__ */ s(
616
618
  ne,
617
619
  {
618
- error: y.config && !!g.config,
620
+ error: U.config && !!C.config,
619
621
  id: "editCollections",
620
622
  name: "editCollections",
621
623
  label: "Edit collections",
622
624
  disabled: u || !n,
623
625
  position: "item-aligned",
624
- onChange: (o) => N("config.editCollections", o.target.value === "own" ? "own" : o.target.value === "true"),
625
- value: u ? "true" : s.config?.editCollections === "own" ? "own" : s.config?.editCollections ? "true" : "false",
626
+ onChange: (o) => b("config.editCollections", o.target.value === "own" ? "own" : o.target.value === "true"),
627
+ value: u ? "true" : a.config?.editCollections === "own" ? "own" : a.config?.editCollections ? "true" : "false",
626
628
  renderValue: (o) => o === "own" ? "Own" : o === "true" ? "Yes" : "No",
627
629
  children: [
628
630
  /* @__PURE__ */ e(
629
- T,
631
+ L,
630
632
  {
631
633
  value: "true",
632
634
  children: " Yes "
633
635
  }
634
636
  ),
635
637
  /* @__PURE__ */ e(
636
- T,
638
+ L,
637
639
  {
638
640
  value: "false",
639
641
  children: " No "
640
642
  }
641
643
  ),
642
644
  /* @__PURE__ */ e(
643
- T,
645
+ L,
644
646
  {
645
647
  value: "own",
646
648
  children: " Only his/her own "
@@ -649,38 +651,38 @@ function Qe({
649
651
  ]
650
652
  }
651
653
  ),
652
- /* @__PURE__ */ e(B, { children: y.config && g.config ? g.config : "Can the user edit collections" })
654
+ /* @__PURE__ */ e(B, { children: U.config && C.config ? C.config : "Can the user edit collections" })
653
655
  ] }),
654
- /* @__PURE__ */ l("div", { className: "col-span-12 md:col-span-4", children: [
655
- /* @__PURE__ */ l(
656
+ /* @__PURE__ */ s("div", { className: "col-span-12 md:col-span-4", children: [
657
+ /* @__PURE__ */ s(
656
658
  ne,
657
659
  {
658
- error: y.config && !!g.config,
660
+ error: U.config && !!C.config,
659
661
  id: "deleteCollections",
660
662
  name: "deleteCollections",
661
663
  label: "Delete collections",
662
664
  disabled: u || !n,
663
665
  position: "item-aligned",
664
- onChange: (o) => N("config.deleteCollections", o.target.value === "own" ? "own" : o.target.value === "true"),
665
- value: u ? "true" : s.config?.deleteCollections === "own" ? "own" : s.config?.deleteCollections ? "true" : "false",
666
+ onChange: (o) => b("config.deleteCollections", o.target.value === "own" ? "own" : o.target.value === "true"),
667
+ value: u ? "true" : a.config?.deleteCollections === "own" ? "own" : a.config?.deleteCollections ? "true" : "false",
666
668
  renderValue: (o) => o === "own" ? "Own" : o === "true" ? "Yes" : "No",
667
669
  children: [
668
670
  /* @__PURE__ */ e(
669
- T,
671
+ L,
670
672
  {
671
673
  value: "true",
672
674
  children: " Yes "
673
675
  }
674
676
  ),
675
677
  /* @__PURE__ */ e(
676
- T,
678
+ L,
677
679
  {
678
680
  value: "false",
679
681
  children: " No "
680
682
  }
681
683
  ),
682
684
  /* @__PURE__ */ e(
683
- T,
685
+ L,
684
686
  {
685
687
  value: "own",
686
688
  children: " Only his/her own "
@@ -689,32 +691,32 @@ function Qe({
689
691
  ]
690
692
  }
691
693
  ),
692
- /* @__PURE__ */ e(B, { children: y.config && g.config ? g.config : "Can the user delete collections" })
694
+ /* @__PURE__ */ e(B, { children: U.config && C.config ? C.config : "Can the user delete collections" })
693
695
  ] })
694
696
  ] })
695
697
  ] }),
696
- /* @__PURE__ */ l(he, { position: "sticky", children: [
697
- v && /* @__PURE__ */ e($, { className: "text-red-500", children: "There was an error saving this role" }),
698
+ /* @__PURE__ */ s(Ce, { position: "sticky", children: [
699
+ v && /* @__PURE__ */ e(A, { className: "text-red-500", children: "There was an error saving this role" }),
698
700
  /* @__PURE__ */ e(
699
- W,
701
+ O,
700
702
  {
701
703
  variant: "text",
702
704
  onClick: () => {
703
- d();
705
+ l();
704
706
  },
705
707
  children: "Cancel"
706
708
  }
707
709
  ),
708
710
  /* @__PURE__ */ e(
709
- fe,
711
+ ve,
710
712
  {
711
713
  variant: "filled",
712
714
  color: "primary",
713
715
  type: "submit",
714
- disabled: !L,
715
- loading: E,
716
- startIcon: /* @__PURE__ */ e(ge, {}),
717
- children: C ? "Create role" : "Update"
716
+ disabled: !_,
717
+ loading: S,
718
+ startIcon: /* @__PURE__ */ e(we, {}),
719
+ children: f ? "Create role" : "Update"
718
720
  }
719
721
  )
720
722
  ] })
@@ -724,7 +726,7 @@ function Qe({
724
726
  }
725
727
  );
726
728
  }
727
- const Xe = [
729
+ const Se = [
728
730
  {
729
731
  id: "admin",
730
732
  name: "Admin",
@@ -758,69 +760,69 @@ const Xe = [
758
760
  }
759
761
  }
760
762
  ];
761
- function Ze({
763
+ function Xe({
762
764
  onRoleClicked: t,
763
- editable: i
765
+ editable: r
764
766
  }) {
765
767
  const {
766
768
  roles: n,
767
- saveRole: d,
768
- deleteRole: r,
769
- allowDefaultRolesCreation: f
770
- } = j(), [C, v] = P(void 0), [D, w] = P(!1);
771
- return /* @__PURE__ */ l(
769
+ saveRole: l,
770
+ deleteRole: i,
771
+ allowDefaultRolesCreation: m
772
+ } = j(), [f, v] = P(void 0), [R, w] = P(!1);
773
+ return /* @__PURE__ */ s(
772
774
  "div",
773
775
  {
774
776
  className: "w-full overflow-auto",
775
777
  children: [
776
- /* @__PURE__ */ l(ie, { children: [
777
- /* @__PURE__ */ l(re, { children: [
778
- /* @__PURE__ */ e(a, { header: !0, className: "w-16" }),
779
- /* @__PURE__ */ e(a, { header: !0, children: "Role" }),
780
- /* @__PURE__ */ e(a, { header: !0, className: "items-center", children: "Is Admin" }),
781
- /* @__PURE__ */ e(a, { header: !0, children: "Default permissions" })
778
+ /* @__PURE__ */ s(re, { children: [
779
+ /* @__PURE__ */ s(ie, { children: [
780
+ /* @__PURE__ */ e(d, { header: !0, className: "w-16" }),
781
+ /* @__PURE__ */ e(d, { header: !0, children: "Role" }),
782
+ /* @__PURE__ */ e(d, { header: !0, className: "items-center", children: "Is Admin" }),
783
+ /* @__PURE__ */ e(d, { header: !0, children: "Default permissions" })
782
784
  ] }),
783
- /* @__PURE__ */ l(oe, { children: [
785
+ /* @__PURE__ */ s(oe, { children: [
784
786
  n && n.map((c) => {
785
- const E = c.isAdmin || c.defaultPermissions?.create, y = c.isAdmin || c.defaultPermissions?.read, s = c.isAdmin || c.defaultPermissions?.edit, g = c.isAdmin || c.defaultPermissions?.delete;
786
- return /* @__PURE__ */ l(
787
- Y,
787
+ const S = c.isAdmin || c.defaultPermissions?.create, U = c.isAdmin || c.defaultPermissions?.read, a = c.isAdmin || c.defaultPermissions?.edit, C = c.isAdmin || c.defaultPermissions?.delete;
788
+ return /* @__PURE__ */ s(
789
+ W,
788
790
  {
789
791
  onClick: () => {
790
792
  t(c);
791
793
  },
792
794
  children: [
793
- /* @__PURE__ */ e(a, { style: { width: "64px" }, children: !c.isAdmin && /* @__PURE__ */ e(_, { title: "Delete this role", children: /* @__PURE__ */ e(
794
- pe,
795
+ /* @__PURE__ */ e(d, { style: { width: "64px" }, children: !c.isAdmin && /* @__PURE__ */ e(V, { title: "Delete this role", children: /* @__PURE__ */ e(
796
+ ye,
795
797
  {
796
798
  size: "small",
797
- disabled: !i,
798
- onClick: (b) => (b.stopPropagation(), v(c)),
799
- children: /* @__PURE__ */ e(Ce, {})
799
+ disabled: !r,
800
+ onClick: (y) => (y.stopPropagation(), v(c)),
801
+ children: /* @__PURE__ */ e(be, {})
800
802
  }
801
803
  ) }) }),
802
- /* @__PURE__ */ e(a, { children: /* @__PURE__ */ e(X, { role: c }) }),
803
- /* @__PURE__ */ e(a, { className: "items-center", children: /* @__PURE__ */ e(k, { checked: c.isAdmin ?? !1 }) }),
804
- /* @__PURE__ */ e(a, { children: /* @__PURE__ */ l("ul", { children: [
805
- E && /* @__PURE__ */ e("li", { children: "Create" }),
806
- y && /* @__PURE__ */ e("li", { children: "Read" }),
807
- s && /* @__PURE__ */ e("li", { children: "Update" }),
808
- g && /* @__PURE__ */ e("li", { children: "Delete" })
804
+ /* @__PURE__ */ e(d, { children: /* @__PURE__ */ e(X, { role: c }) }),
805
+ /* @__PURE__ */ e(d, { className: "items-center", children: /* @__PURE__ */ e(I, { checked: c.isAdmin ?? !1 }) }),
806
+ /* @__PURE__ */ e(d, { children: /* @__PURE__ */ s("ul", { children: [
807
+ S && /* @__PURE__ */ e("li", { children: "Create" }),
808
+ U && /* @__PURE__ */ e("li", { children: "Read" }),
809
+ a && /* @__PURE__ */ e("li", { children: "Update" }),
810
+ C && /* @__PURE__ */ e("li", { children: "Delete" })
809
811
  ] }) })
810
812
  ]
811
813
  },
812
814
  c.name
813
815
  );
814
816
  }),
815
- (!n || n.length === 0) && /* @__PURE__ */ e(Y, { children: /* @__PURE__ */ e(a, { colspan: 4, children: /* @__PURE__ */ l(ve, { className: "flex flex-col gap-4 my-8 items-center", children: [
816
- /* @__PURE__ */ e($, { variant: "label", children: "You don't have any roles yet." }),
817
- f && /* @__PURE__ */ e(
818
- W,
817
+ (!n || n.length === 0) && /* @__PURE__ */ e(W, { children: /* @__PURE__ */ e(d, { colspan: 4, children: /* @__PURE__ */ s(Ne, { className: "flex flex-col gap-4 my-8 items-center", children: [
818
+ /* @__PURE__ */ e(A, { variant: "label", children: "You don't have any roles yet." }),
819
+ m && /* @__PURE__ */ e(
820
+ O,
819
821
  {
820
822
  variant: "outlined",
821
823
  onClick: () => {
822
- Xe.forEach((c) => {
823
- d(c);
824
+ Se.forEach((c) => {
825
+ l(c);
824
826
  });
825
827
  },
826
828
  children: "Create default roles"
@@ -830,12 +832,12 @@ function Ze({
830
832
  ] })
831
833
  ] }),
832
834
  /* @__PURE__ */ e(
833
- be,
835
+ xe,
834
836
  {
835
- open: !!C,
836
- loading: D,
837
+ open: !!f,
838
+ loading: R,
837
839
  onAccept: () => {
838
- C && (w(!0), r(C).then(() => {
840
+ f && (w(!0), i(f).then(() => {
839
841
  v(void 0);
840
842
  }).finally(() => {
841
843
  w(!1);
@@ -852,16 +854,16 @@ function Ze({
852
854
  }
853
855
  );
854
856
  }
855
- const en = F.memo(
856
- function({ children: i }) {
857
- const { collections: n } = Ve(), [d, r] = P(!1), [f, C] = P(), { canEditRoles: v } = j(), D = I((c) => {
858
- r(!0), C(c);
857
+ const Ze = F.memo(
858
+ function({ children: r }) {
859
+ const { collections: n } = _e(), [l, i] = P(!1), [m, f] = P(), { canEditRoles: v } = j(), R = k((c) => {
860
+ i(!0), f(c);
859
861
  }, []);
860
- return /* @__PURE__ */ l(we, { className: "w-full flex flex-col py-4 gap-4", maxWidth: "6xl", children: [
861
- i,
862
- /* @__PURE__ */ l("div", { className: "flex items-center mt-12", children: [
862
+ return /* @__PURE__ */ s(Ue, { className: "w-full flex flex-col py-4 gap-4", maxWidth: "6xl", children: [
863
+ r,
864
+ /* @__PURE__ */ s("div", { className: "flex items-center mt-12", children: [
863
865
  /* @__PURE__ */ e(
864
- $,
866
+ A,
865
867
  {
866
868
  gutterBottom: !0,
867
869
  variant: "h4",
@@ -870,103 +872,103 @@ const en = F.memo(
870
872
  children: "Roles"
871
873
  }
872
874
  ),
873
- /* @__PURE__ */ e(_, { title: v ? void 0 : "Update plans to customise roles", children: /* @__PURE__ */ e(
874
- W,
875
+ /* @__PURE__ */ e(V, { title: v ? void 0 : "Update plans to customise roles", children: /* @__PURE__ */ e(
876
+ O,
875
877
  {
876
878
  size: "large",
877
879
  disabled: !v,
878
- startIcon: /* @__PURE__ */ e(ye, {}),
879
- onClick: () => r(!0),
880
+ startIcon: /* @__PURE__ */ e(le, {}),
881
+ onClick: () => i(!0),
880
882
  children: "Add role"
881
883
  }
882
884
  ) })
883
885
  ] }),
884
- /* @__PURE__ */ e(Ze, { onRoleClicked: D, editable: !!v }),
886
+ /* @__PURE__ */ e(Xe, { onRoleClicked: R, editable: !!v }),
885
887
  /* @__PURE__ */ e(
886
888
  Qe,
887
889
  {
888
- open: d,
889
- role: f,
890
+ open: l,
891
+ role: m,
890
892
  editable: v,
891
893
  collections: n,
892
894
  handleClose: () => {
893
- C(void 0), r(!1);
895
+ f(void 0), i(!1);
894
896
  }
895
897
  },
896
- f?.id ?? "new"
898
+ m?.id ?? "new"
897
899
  )
898
900
  ] });
899
901
  }
900
- ), nn = O.object().shape({
901
- displayName: O.string().required("Required"),
902
- email: O.string().email().required("Required"),
903
- roles: O.array().min(1)
902
+ ), en = M.object().shape({
903
+ displayName: M.string().required("Required"),
904
+ email: M.string().email().required("Required"),
905
+ roles: M.array().min(1)
904
906
  });
905
- function tn(t, i, n, d, r) {
906
- const f = n.filter((w) => w.roles?.map((c) => c.id).includes("admin")), C = t.roles?.map((w) => w.id).includes("admin");
907
- if ((!r || !je(r.roles ?? [], i.roles ?? [])) && !C)
907
+ function nn(t, r, n, l, i) {
908
+ const m = n.filter((w) => w.roles?.map((c) => c.id).includes("admin")), f = t.roles?.map((w) => w.id).includes("admin");
909
+ if ((!i || !je(i.roles ?? [], r.roles ?? [])) && !f)
908
910
  throw new Error("Only admins can change roles");
909
- if (r && r.roles?.map((w) => w.id).includes("admin") && !i.roles?.map((w) => w.id).includes("admin") && f.length === 1)
911
+ if (i && i.roles?.map((w) => w.id).includes("admin") && !r.roles?.map((w) => w.id).includes("admin") && m.length === 1)
910
912
  throw new Error("There must be at least one admin");
911
913
  return !0;
912
914
  }
913
- function rn({
915
+ function tn({
914
916
  open: t,
915
- user: i,
917
+ user: r,
916
918
  handleClose: n
917
919
  }) {
918
- const d = Ne(), {
919
- user: r
920
- } = xe(), {
921
- saveUser: f,
922
- users: C,
920
+ const l = se(), {
921
+ user: i
922
+ } = ae(), {
923
+ saveUser: m,
924
+ users: f,
923
925
  roles: v
924
- } = j(), D = !i, w = I((m) => {
925
- if (!r)
926
+ } = j(), R = !r, w = k((h) => {
927
+ if (!i)
926
928
  throw new Error("Logged user not found");
927
929
  try {
928
- return tn(r, m, C, v, i), f(m);
929
- } catch (R) {
930
- return Promise.reject(R);
930
+ return nn(i, h, f, v, r), m(h);
931
+ } catch (x) {
932
+ return Promise.reject(x);
931
933
  }
932
- }, [v, f, i, C, r]), c = Re({
933
- initialValues: i ?? {
934
+ }, [v, m, r, f, i]), c = Re({
935
+ initialValues: r ?? {
934
936
  displayName: "",
935
937
  email: "",
936
- roles: v.filter((m) => m.id === "editor")
938
+ roles: v.filter((h) => h.id === "editor")
937
939
  },
938
- validation: (m) => nn.validate(m, { abortEarly: !1 }).then(() => ({})).catch((R) => R.inner.reduce((U, A) => (U[A.path] = A.message, U), {})),
939
- onSubmit: (m, R) => w(m).then(() => {
940
- n(), R.resetForm({
941
- values: m
940
+ validation: (h) => en.validate(h, { abortEarly: !1 }).then(() => ({})).catch((x) => x.inner.reduce((D, T) => (D[T.path] = T.message, D), {})),
941
+ onSubmit: (h, x) => w(h).then(() => {
942
+ n(), x.resetForm({
943
+ values: h
942
944
  });
943
- }).catch((U) => {
944
- d.open({
945
+ }).catch((D) => {
946
+ l.open({
945
947
  type: "error",
946
- message: U.message
948
+ message: D.message
947
949
  });
948
950
  })
949
951
  }), {
950
- isSubmitting: E,
951
- touched: y,
952
- handleChange: s,
953
- values: g,
954
- errors: b,
955
- setFieldValue: N,
956
- dirty: L,
957
- handleSubmit: J,
952
+ isSubmitting: S,
953
+ touched: U,
954
+ handleChange: a,
955
+ values: C,
956
+ errors: y,
957
+ setFieldValue: b,
958
+ dirty: _,
959
+ handleSubmit: z,
958
960
  submitCount: u
959
961
  } = c;
960
962
  return /* @__PURE__ */ e(
961
- ue,
963
+ fe,
962
964
  {
963
965
  open: t,
964
- onOpenChange: (m) => m ? void 0 : n(),
966
+ onOpenChange: (h) => h ? void 0 : n(),
965
967
  maxWidth: "4xl",
966
- children: /* @__PURE__ */ e(De, { value: c, children: /* @__PURE__ */ l(
968
+ children: /* @__PURE__ */ e(De, { value: c, children: /* @__PURE__ */ s(
967
969
  "form",
968
970
  {
969
- onSubmit: J,
971
+ onSubmit: z,
970
972
  autoComplete: "off",
971
973
  noValidate: !0,
972
974
  style: {
@@ -976,13 +978,13 @@ function rn({
976
978
  height: "100%"
977
979
  },
978
980
  children: [
979
- /* @__PURE__ */ l(me, { className: "h-full flex-grow", children: [
981
+ /* @__PURE__ */ s(ge, { className: "h-full flex-grow", children: [
980
982
  /* @__PURE__ */ e(
981
983
  "div",
982
984
  {
983
985
  className: "flex flex-row pt-4 pb-4",
984
986
  children: /* @__PURE__ */ e(
985
- $,
987
+ A,
986
988
  {
987
989
  variant: "h4",
988
990
  className: "flex-grow",
@@ -991,62 +993,62 @@ function rn({
991
993
  )
992
994
  }
993
995
  ),
994
- /* @__PURE__ */ l("div", { className: "grid grid-cols-12 gap-8", children: [
995
- /* @__PURE__ */ l("div", { className: "col-span-12", children: [
996
+ /* @__PURE__ */ s("div", { className: "grid grid-cols-12 gap-8", children: [
997
+ /* @__PURE__ */ s("div", { className: "col-span-12", children: [
996
998
  /* @__PURE__ */ e(
997
999
  Q,
998
1000
  {
999
1001
  name: "displayName",
1000
1002
  required: !0,
1001
- error: u > 0 && !!b.displayName,
1002
- value: g.displayName ?? "",
1003
- onChange: s,
1003
+ error: u > 0 && !!y.displayName,
1004
+ value: C.displayName ?? "",
1005
+ onChange: a,
1004
1006
  "aria-describedby": "name-helper-text",
1005
1007
  label: "Name"
1006
1008
  }
1007
1009
  ),
1008
- /* @__PURE__ */ e(B, { children: u > 0 && b.displayName ? b.displayName : "Name of this user" })
1010
+ /* @__PURE__ */ e(B, { children: u > 0 && y.displayName ? y.displayName : "Name of this user" })
1009
1011
  ] }),
1010
- /* @__PURE__ */ l("div", { className: "col-span-12", children: [
1012
+ /* @__PURE__ */ s("div", { className: "col-span-12", children: [
1011
1013
  /* @__PURE__ */ e(
1012
1014
  Q,
1013
1015
  {
1014
1016
  required: !0,
1015
- error: u > 0 && !!b.email,
1017
+ error: u > 0 && !!y.email,
1016
1018
  name: "email",
1017
- value: g.email ?? "",
1018
- onChange: s,
1019
+ value: C.email ?? "",
1020
+ onChange: a,
1019
1021
  "aria-describedby": "email-helper-text",
1020
1022
  label: "Email"
1021
1023
  }
1022
1024
  ),
1023
- /* @__PURE__ */ e(B, { children: u > 0 && b.email ? b.email : "Email of this user" })
1025
+ /* @__PURE__ */ e(B, { children: u > 0 && y.email ? y.email : "Email of this user" })
1024
1026
  ] }),
1025
1027
  /* @__PURE__ */ e("div", { className: "col-span-12", children: /* @__PURE__ */ e(
1026
1028
  Te,
1027
1029
  {
1028
1030
  label: "Roles",
1029
- value: g.roles?.map((m) => m.id) ?? [],
1030
- onMultiValueChange: (m) => N("roles", m.map((R) => v.find((U) => U.id === R))),
1031
- renderValue: (m) => {
1032
- const R = v.find((U) => U.id === m);
1033
- return R ? /* @__PURE__ */ e("div", { className: "flex flex-wrap space-x-2 space-y-2", children: /* @__PURE__ */ e(X, { role: R }, R?.id) }) : null;
1031
+ value: C.roles?.map((h) => h.id) ?? [],
1032
+ onMultiValueChange: (h) => b("roles", h.map((x) => v.find((D) => D.id === x))),
1033
+ renderValue: (h) => {
1034
+ const x = v.find((D) => D.id === h);
1035
+ return x ? /* @__PURE__ */ e("div", { className: "flex flex-wrap space-x-2 space-y-2", children: /* @__PURE__ */ e(X, { role: x }, x?.id) }) : null;
1034
1036
  },
1035
- children: v.map((m) => /* @__PURE__ */ e(
1036
- Be,
1037
+ children: v.map((h) => /* @__PURE__ */ e(
1038
+ Le,
1037
1039
  {
1038
- value: m.id,
1039
- children: /* @__PURE__ */ e(X, { role: m }, m?.id)
1040
+ value: h.id,
1041
+ children: /* @__PURE__ */ e(X, { role: h }, h?.id)
1040
1042
  },
1041
- m.id
1043
+ h.id
1042
1044
  ))
1043
1045
  }
1044
1046
  ) })
1045
1047
  ] })
1046
1048
  ] }),
1047
- /* @__PURE__ */ l(he, { children: [
1049
+ /* @__PURE__ */ s(Ce, { children: [
1048
1050
  /* @__PURE__ */ e(
1049
- W,
1051
+ O,
1050
1052
  {
1051
1053
  variant: "text",
1052
1054
  onClick: () => {
@@ -1056,15 +1058,15 @@ function rn({
1056
1058
  }
1057
1059
  ),
1058
1060
  /* @__PURE__ */ e(
1059
- fe,
1061
+ ve,
1060
1062
  {
1061
1063
  variant: "filled",
1062
1064
  color: "primary",
1063
1065
  type: "submit",
1064
- disabled: !L,
1065
- loading: E,
1066
- startIcon: /* @__PURE__ */ e(ge, {}),
1067
- children: D ? "Create user" : "Update"
1066
+ disabled: !_,
1067
+ loading: S,
1068
+ startIcon: /* @__PURE__ */ e(we, {}),
1069
+ children: R ? "Create user" : "Update"
1068
1070
  }
1069
1071
  )
1070
1072
  ] })
@@ -1074,79 +1076,79 @@ function rn({
1074
1076
  }
1075
1077
  );
1076
1078
  }
1077
- function on({ onUserClicked: t }) {
1079
+ function rn({ onUserClicked: t }) {
1078
1080
  const {
1079
- users: i,
1081
+ users: r,
1080
1082
  saveUser: n,
1081
- deleteUser: d
1082
- } = j(), r = xe(), f = Ne(), C = _e(), v = C?.locale ? Me[C?.locale] : void 0, D = C?.dateTimeFormat ?? Oe, [w, c] = P(void 0), [E, y] = P(!1);
1083
- return /* @__PURE__ */ l("div", { className: "overflow-auto", children: [
1084
- /* @__PURE__ */ l(ie, { children: [
1085
- /* @__PURE__ */ l(re, { children: [
1086
- /* @__PURE__ */ e(a, { className: "truncate w-16" }),
1087
- /* @__PURE__ */ e(a, { children: "ID" }),
1088
- /* @__PURE__ */ e(a, { children: "Email" }),
1089
- /* @__PURE__ */ e(a, { children: "Name" }),
1090
- /* @__PURE__ */ e(a, { children: "Roles" }),
1091
- /* @__PURE__ */ e(a, { children: "Created on" })
1083
+ deleteUser: l
1084
+ } = j(), i = ae(), m = se(), f = Ve(), v = f?.locale ? $e[f?.locale] : void 0, R = f?.dateTimeFormat ?? Me, [w, c] = P(void 0), [S, U] = P(!1);
1085
+ return /* @__PURE__ */ s("div", { className: "overflow-auto", children: [
1086
+ /* @__PURE__ */ s(re, { children: [
1087
+ /* @__PURE__ */ s(ie, { children: [
1088
+ /* @__PURE__ */ e(d, { className: "truncate w-16" }),
1089
+ /* @__PURE__ */ e(d, { children: "ID" }),
1090
+ /* @__PURE__ */ e(d, { children: "Email" }),
1091
+ /* @__PURE__ */ e(d, { children: "Name" }),
1092
+ /* @__PURE__ */ e(d, { children: "Roles" }),
1093
+ /* @__PURE__ */ e(d, { children: "Created on" })
1092
1094
  ] }),
1093
- /* @__PURE__ */ l(oe, { children: [
1094
- i && i.map((s) => {
1095
- const g = s.roles, b = s.created_on ? $e(s.created_on, D, { locale: v }) : "";
1096
- return /* @__PURE__ */ l(
1097
- Y,
1095
+ /* @__PURE__ */ s(oe, { children: [
1096
+ r && r.map((a) => {
1097
+ const C = a.roles, y = a.created_on ? Oe(a.created_on, R, { locale: v }) : "";
1098
+ return /* @__PURE__ */ s(
1099
+ W,
1098
1100
  {
1099
1101
  onClick: () => {
1100
- t(s);
1102
+ t(a);
1101
1103
  },
1102
1104
  children: [
1103
- /* @__PURE__ */ e(a, { className: "w-10", children: /* @__PURE__ */ e(_, { title: "Delete this user", children: /* @__PURE__ */ e(
1104
- pe,
1105
+ /* @__PURE__ */ e(d, { className: "w-10", children: /* @__PURE__ */ e(V, { title: "Delete this user", children: /* @__PURE__ */ e(
1106
+ ye,
1105
1107
  {
1106
1108
  size: "small",
1107
- onClick: (N) => (N.stopPropagation(), c(s)),
1108
- children: /* @__PURE__ */ e(Ce, {})
1109
+ onClick: (b) => (b.stopPropagation(), c(a)),
1110
+ children: /* @__PURE__ */ e(be, {})
1109
1111
  }
1110
1112
  ) }) }),
1111
- /* @__PURE__ */ e(a, { children: s.uid }),
1112
- /* @__PURE__ */ e(a, { children: s.email }),
1113
- /* @__PURE__ */ e(a, { className: "font-medium align-left", children: s.displayName }),
1114
- /* @__PURE__ */ e(a, { className: "align-left", children: g ? /* @__PURE__ */ e("div", { className: "flex flex-wrap gap-2", children: g.map(
1115
- (N) => /* @__PURE__ */ e(X, { role: N }, N?.id)
1113
+ /* @__PURE__ */ e(d, { children: a.uid }),
1114
+ /* @__PURE__ */ e(d, { children: a.email }),
1115
+ /* @__PURE__ */ e(d, { className: "font-medium align-left", children: a.displayName }),
1116
+ /* @__PURE__ */ e(d, { className: "align-left", children: C ? /* @__PURE__ */ e("div", { className: "flex flex-wrap gap-2", children: C.map(
1117
+ (b) => /* @__PURE__ */ e(X, { role: b }, b?.id)
1116
1118
  ) }) : null }),
1117
- /* @__PURE__ */ e(a, { children: b })
1119
+ /* @__PURE__ */ e(d, { children: y })
1118
1120
  ]
1119
1121
  },
1120
- "row_" + s.uid
1122
+ "row_" + a.uid
1121
1123
  );
1122
1124
  }),
1123
- (!i || i.length === 0) && /* @__PURE__ */ e(Y, { children: /* @__PURE__ */ e(a, { colspan: 6, children: /* @__PURE__ */ l(ve, { className: "flex flex-col gap-4 my-8 items-center", children: [
1124
- /* @__PURE__ */ e($, { variant: "label", children: "There are no users yet" }),
1125
+ (!r || r.length === 0) && /* @__PURE__ */ e(W, { children: /* @__PURE__ */ e(d, { colspan: 6, children: /* @__PURE__ */ s(Ne, { className: "flex flex-col gap-4 my-8 items-center", children: [
1126
+ /* @__PURE__ */ e(A, { variant: "label", children: "There are no users yet" }),
1125
1127
  /* @__PURE__ */ e(
1126
- W,
1128
+ O,
1127
1129
  {
1128
1130
  variant: "outlined",
1129
1131
  onClick: () => {
1130
- if (!r.user?.uid)
1132
+ if (!i.user?.uid)
1131
1133
  throw Error("UsersTable, authController misconfiguration");
1132
1134
  n({
1133
- uid: r.user?.uid,
1134
- email: r.user?.email,
1135
- displayName: r.user?.displayName,
1136
- photoURL: r.user?.photoURL,
1137
- providerId: r.user?.providerId,
1138
- isAnonymous: r.user?.isAnonymous,
1135
+ uid: i.user?.uid,
1136
+ email: i.user?.email,
1137
+ displayName: i.user?.displayName,
1138
+ photoURL: i.user?.photoURL,
1139
+ providerId: i.user?.providerId,
1140
+ isAnonymous: i.user?.isAnonymous,
1139
1141
  roles: [{ id: "admin", name: "Admin" }],
1140
1142
  created_on: /* @__PURE__ */ new Date()
1141
1143
  }).then(() => {
1142
- f.open({
1144
+ m.open({
1143
1145
  type: "success",
1144
1146
  message: "User added successfully"
1145
1147
  });
1146
- }).catch((s) => {
1147
- f.open({
1148
+ }).catch((a) => {
1149
+ m.open({
1148
1150
  type: "error",
1149
- message: "Error adding user: " + s.message
1151
+ message: "Error adding user: " + a.message
1150
1152
  });
1151
1153
  });
1152
1154
  },
@@ -1157,20 +1159,20 @@ function on({ onUserClicked: t }) {
1157
1159
  ] })
1158
1160
  ] }),
1159
1161
  /* @__PURE__ */ e(
1160
- be,
1162
+ xe,
1161
1163
  {
1162
1164
  open: !!w,
1163
- loading: E,
1165
+ loading: S,
1164
1166
  onAccept: () => {
1165
- w && (y(!0), d(w).then(() => {
1167
+ w && (U(!0), l(w).then(() => {
1166
1168
  c(void 0);
1167
- }).catch((s) => {
1168
- f.open({
1169
+ }).catch((a) => {
1170
+ m.open({
1169
1171
  type: "error",
1170
- message: "Error deleting user: " + s.message
1172
+ message: "Error deleting user: " + a.message
1171
1173
  });
1172
1174
  }).finally(() => {
1173
- y(!1);
1175
+ U(!1);
1174
1176
  }));
1175
1177
  },
1176
1178
  onCancel: () => {
@@ -1182,21 +1184,21 @@ function on({ onUserClicked: t }) {
1182
1184
  )
1183
1185
  ] });
1184
1186
  }
1185
- const ln = function({ children: i }) {
1186
- const [n, d] = P(), [r, f] = P(), { users: C, usersLimit: v } = j(), D = v !== void 0 && C && C.length >= v, w = I((E) => {
1187
- f(E), d(!0);
1188
- }, []), c = I(() => {
1189
- d(!1), f(void 0);
1187
+ const on = function({ children: r }) {
1188
+ const [n, l] = P(), [i, m] = P(), { users: f, usersLimit: v } = j(), R = v !== void 0 && f && f.length >= v, w = k((S) => {
1189
+ m(S), l(!0);
1190
+ }, []), c = k(() => {
1191
+ l(!1), m(void 0);
1190
1192
  }, []);
1191
- return /* @__PURE__ */ l(we, { className: "w-full flex flex-col py-4 gap-4", maxWidth: "6xl", children: [
1192
- i,
1193
- /* @__PURE__ */ l(
1193
+ return /* @__PURE__ */ s(Ue, { className: "w-full flex flex-col py-4 gap-4", maxWidth: "6xl", children: [
1194
+ r,
1195
+ /* @__PURE__ */ s(
1194
1196
  "div",
1195
1197
  {
1196
1198
  className: "flex items-center mt-12",
1197
1199
  children: [
1198
1200
  /* @__PURE__ */ e(
1199
- $,
1201
+ A,
1200
1202
  {
1201
1203
  gutterBottom: !0,
1202
1204
  variant: "h4",
@@ -1206,34 +1208,45 @@ const ln = function({ children: i }) {
1206
1208
  }
1207
1209
  ),
1208
1210
  /* @__PURE__ */ e(
1209
- W,
1211
+ O,
1210
1212
  {
1211
1213
  size: "large",
1212
- disabled: D,
1213
- startIcon: /* @__PURE__ */ e(ye, {}),
1214
- onClick: () => d(!0),
1214
+ disabled: R,
1215
+ startIcon: /* @__PURE__ */ e(le, {}),
1216
+ onClick: () => l(!0),
1215
1217
  children: "Add user"
1216
1218
  }
1217
1219
  )
1218
1220
  ]
1219
1221
  }
1220
1222
  ),
1221
- /* @__PURE__ */ e(on, { onUserClicked: w }),
1223
+ /* @__PURE__ */ e(rn, { onUserClicked: w }),
1222
1224
  /* @__PURE__ */ e(
1223
- rn,
1225
+ tn,
1224
1226
  {
1225
1227
  open: n ?? !1,
1226
- user: r,
1228
+ user: i,
1227
1229
  handleClose: c
1228
1230
  },
1229
- r?.uid ?? "new"
1231
+ i?.uid ?? "new"
1230
1232
  )
1231
1233
  ] });
1232
1234
  };
1233
1235
  function Nn({ userManagement: t }) {
1236
+ const r = t.users.length === 0, n = t.roles.length === 0;
1234
1237
  return {
1235
1238
  key: "user_management",
1236
1239
  loading: t.loading,
1240
+ homePage: {
1241
+ additionalChildrenStart: r || n ? /* @__PURE__ */ e(
1242
+ ln,
1243
+ {
1244
+ noUsers: r,
1245
+ noRoles: n,
1246
+ userManagement: t
1247
+ }
1248
+ ) : void 0
1249
+ },
1237
1250
  provider: {
1238
1251
  Component: He,
1239
1252
  props: {
@@ -1242,35 +1255,85 @@ function Nn({ userManagement: t }) {
1242
1255
  }
1243
1256
  };
1244
1257
  }
1245
- const xn = [
1258
+ function ln({
1259
+ noUsers: t,
1260
+ noRoles: r,
1261
+ userManagement: n
1262
+ }) {
1263
+ const l = ae(), i = se();
1264
+ return /* @__PURE__ */ s(
1265
+ pe,
1266
+ {
1267
+ className: "my-4 flex flex-col px-4 py-6 bg-white dark:bg-slate-800 gap-2",
1268
+ children: [
1269
+ /* @__PURE__ */ e(A, { variant: "subtitle2", className: "uppercase", children: "Create your users and roles" }),
1270
+ /* @__PURE__ */ e(A, { children: "You have no users or roles defined. You can create default roles and add the current user as admin." }),
1271
+ /* @__PURE__ */ s(O, { onClick: () => {
1272
+ if (!l.user?.uid)
1273
+ throw Error("UsersTable, authController misconfiguration");
1274
+ t && n.saveUser({
1275
+ uid: l.user?.uid,
1276
+ email: l.user?.email,
1277
+ displayName: l.user?.displayName,
1278
+ photoURL: l.user?.photoURL,
1279
+ providerId: l.user?.providerId,
1280
+ isAnonymous: l.user?.isAnonymous,
1281
+ roles: [{
1282
+ id: "admin",
1283
+ name: "Admin"
1284
+ }],
1285
+ created_on: /* @__PURE__ */ new Date()
1286
+ }).then(() => {
1287
+ i.open({
1288
+ type: "success",
1289
+ message: "User added successfully"
1290
+ });
1291
+ }).catch((f) => {
1292
+ i.open({
1293
+ type: "error",
1294
+ message: "Error adding user: " + f.message
1295
+ });
1296
+ }), r && Se.forEach((f) => {
1297
+ n.saveRole(f);
1298
+ });
1299
+ }, children: [
1300
+ /* @__PURE__ */ e(le, {}),
1301
+ t && r ? "Create default roles and add current user as admin" : t ? "Add current user as admin" : r ? "Create default roles" : void 0
1302
+ ] })
1303
+ ]
1304
+ }
1305
+ );
1306
+ }
1307
+ const Un = [
1246
1308
  {
1247
1309
  path: "users",
1248
1310
  name: "CMS Users",
1249
1311
  group: "Admin",
1250
1312
  icon: "face",
1251
- view: /* @__PURE__ */ e(ln, {})
1313
+ view: /* @__PURE__ */ e(on, {})
1252
1314
  },
1253
1315
  {
1254
1316
  path: "roles",
1255
1317
  name: "Roles",
1256
1318
  group: "Admin",
1257
1319
  icon: "gpp_good",
1258
- view: /* @__PURE__ */ e(en, {})
1320
+ view: /* @__PURE__ */ e(Ze, {})
1259
1321
  }
1260
1322
  ];
1261
1323
  export {
1324
+ ln as IntroWidget,
1262
1325
  fn as RESERVED_GROUPS,
1263
1326
  X as RoleChip,
1264
1327
  Ke as RoleYupSchema,
1265
1328
  Qe as RolesDetailsForm,
1266
- Ze as RolesTable,
1267
- en as RolesView,
1268
- rn as UserDetailsForm,
1269
- Ue as UserManagementContext,
1329
+ Xe as RolesTable,
1330
+ Ze as RolesView,
1331
+ tn as UserDetailsForm,
1332
+ Ee as UserManagementContext,
1270
1333
  He as UserManagementProvider,
1271
- nn as UserYupSchema,
1272
- on as UsersTable,
1273
- ln as UsersView,
1334
+ en as UserYupSchema,
1335
+ rn as UsersTable,
1336
+ on as UsersView,
1274
1337
  je as areRolesEqual,
1275
1338
  pn as cacheDelegatedLoginToken,
1276
1339
  vn as clearDelegatedLoginTokensCache,
@@ -1279,9 +1342,9 @@ export {
1279
1342
  gn as getUserRoles,
1280
1343
  yn as hexToRgbaWithOpacity,
1281
1344
  Ye as resolveUserRolePermissions,
1282
- bn as useBuildFirestoreUserManagement,
1345
+ bn as useFirestoreUserManagement,
1283
1346
  j as useUserManagement,
1284
1347
  Nn as useUserManagementPlugin,
1285
- xn as userManagementAdminViews
1348
+ Un as userManagementAdminViews
1286
1349
  };
1287
1350
  //# sourceMappingURL=index.es.js.map