@firecms/user_management 3.0.0-beta.5 → 3.0.0-beta.7

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