@firecms/user_management 3.0.0-3.0.0-canary.27.0 → 3.0.0-3.0.0-canary.44.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.es.js CHANGED
@@ -1,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 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
+ const fn = ["Admin"], qe = {
11
11
  read: !1,
12
12
  edit: !1,
13
13
  create: !1,
14
14
  delete: !1
15
15
  };
16
- function je({
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,296 +27,304 @@ 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) => We(i, t.id)).reduce(te, l);
37
37
  }
38
38
  } else
39
- return We;
39
+ return qe;
40
40
  }
41
- function ze(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] ? 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 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), c = i.map((r) => r.id);
61
- return n.length === i.length && n.every((r) => c.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 vn(t, i) {
64
- if (!i)
63
+ function pn(t, r) {
64
+ if (!r)
65
65
  return;
66
- const n = Ge(i), c = 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: 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 Cn(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 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
- function Ge(t) {
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, "/"), 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 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 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 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 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), f = r / 100;
108
+ return `rgba(${l}, ${i}, ${m}, ${f})`;
109
109
  }
110
- function Rn({
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: c,
115
- canEditRoles: r = !0,
116
- allowDefaultRolesCreation: h,
117
- includeCollectionConfigPermissions: w
114
+ usersLimit: l,
115
+ canEditRoles: i = !0,
116
+ allowDefaultRolesCreation: m,
117
+ includeCollectionConfigPermissions: f
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), [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(() => {
126
124
  if (!t || !n)
127
125
  return;
128
- const m = ee(t);
129
- return ae(
130
- ne(m, n),
126
+ const g = Y(t);
127
+ return ue(
128
+ ee(g, 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 = Ge(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 g = Y(t);
149
+ return ue(
150
+ ee(g, 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 = Je(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 (g) => {
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", g);
175
+ const N = g.roles?.map((ke) => ke.id), {
176
+ uid: q,
177
+ ...Z
178
+ } = g, 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(() => g) : Fe(ee(p, r), de).then(() => g);
183
+ }, [r, t]), D = k((g) => {
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", g);
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
+ } = g, Z = H(p, n, N);
194
+ return me(Z, q, { merge: !0 });
195
+ }, [n, t]), T = k(async (g) => {
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", g);
202
+ const { uid: N } = g;
203
+ return he(H(p, r, N));
204
+ }, [r, t]), o = k((g) => {
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", g);
211
+ const { id: N } = g, q = H(p, n, N);
212
+ return he(q);
213
+ }, [n, t]), E = k(({
214
+ collection: g,
215
+ user: p
216
+ }) => Ye({
217
+ collection: g,
218
+ user: p
219
+ }), []), $ = k((g) => {
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() === 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()))
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]);
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: S,
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
+ canEditRoles: i === void 0 ? !0 : i,
242
+ allowDefaultRolesCreation: m === void 0 ? !0 : m,
243
+ includeCollectionConfigPermissions: !!f,
244
+ collectionPermissions: E,
245
+ defineRolesFor: $,
246
+ authenticator: G
239
247
  };
240
248
  }
241
- const He = (t) => t.map((i) => {
242
- const n = i.data();
249
+ const Je = (t) => t.map((r) => {
250
+ const n = r.data();
243
251
  return {
244
- uid: i.id,
252
+ uid: r.id,
245
253
  ...n,
246
254
  created_on: n?.created_on?.toDate(),
247
255
  updated_on: n?.updated_on?.toDate()
248
256
  };
249
- }), Ke = (t) => t.map((i) => ({
250
- id: i.id,
251
- ...i.data()
252
- })), Ue = A.createContext({});
253
- function Qe({
257
+ }), Ge = (t) => t.map((r) => ({
258
+ id: r.id,
259
+ ...r.data()
260
+ })), Ee = F.createContext({});
261
+ function He({
254
262
  children: t,
255
- userManagement: i
263
+ userManagement: r
256
264
  }) {
257
- return /* @__PURE__ */ e(Ue.Provider, { value: i, children: t });
265
+ return /* @__PURE__ */ e(Ee.Provider, { value: r, children: t });
258
266
  }
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(
263
- Te,
267
+ const j = () => Ie(Ee);
268
+ function X({ role: t }) {
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,
264
272
  {
265
- colorScheme: i,
273
+ colorScheme: r,
266
274
  children: t.name
267
275
  },
268
276
  t.id
269
277
  );
270
278
  }
271
- const Xe = _.object().shape({
272
- id: _.string().required("Required"),
273
- name: _.string().required("Required")
279
+ const Ke = M.object().shape({
280
+ id: M.string().required("Required"),
281
+ name: M.string().required("Required")
274
282
  });
275
- function Ze({
283
+ function Qe({
276
284
  open: t,
277
- role: i,
285
+ role: r,
278
286
  editable: n,
279
- handleClose: c,
280
- collections: r
287
+ handleClose: l,
288
+ collections: i
281
289
  }) {
282
- const { saveRole: h } = W(), w = !i, [f, x] = P(), y = k((o) => (x(void 0), h(o)), [h]), d = xe({
283
- 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 ?? {
284
292
  name: ""
285
293
  },
286
- onSubmit: (o, S) => y(o).then(() => {
287
- S.resetForm({
294
+ onSubmit: (o, E) => w(o).then(() => {
295
+ E.resetForm({
288
296
  values: o
289
- }), c();
290
- }).catch(($) => x($)),
291
- validation: (o) => Xe.validate(o, { abortEarly: !1 }).then(() => ({})).catch((S) => {
297
+ }), l();
298
+ }).catch(($) => R($)),
299
+ validation: (o) => Ke.validate(o, { abortEarly: !1 }).then(() => ({})).catch((E) => {
292
300
  const $ = {};
293
- return S.inner.forEach((J) => {
294
- $[J.path] = J.message;
301
+ return E.inner.forEach((G) => {
302
+ $[G.path] = G.message;
295
303
  }), $;
296
304
  })
297
305
  }), {
298
- isSubmitting: I,
299
- touched: b,
300
- values: s,
306
+ isSubmitting: S,
307
+ touched: U,
308
+ values: a,
301
309
  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,
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;
315
+ return F.useEffect(() => {
316
+ !J(U, "id") && a.name && b("id", Be(a.name));
317
+ }, [U, a.name]), /* @__PURE__ */ e(
318
+ fe,
311
319
  {
312
320
  open: t,
313
321
  maxWidth: "4xl",
314
- children: /* @__PURE__ */ e(De, { value: d, children: /* @__PURE__ */ l(
322
+ children: /* @__PURE__ */ e(De, { value: c, children: /* @__PURE__ */ s(
315
323
  "form",
316
324
  {
317
325
  noValidate: !0,
318
326
  autoComplete: "off",
319
- onSubmit: d.handleSubmit,
327
+ onSubmit: c.handleSubmit,
320
328
  style: {
321
329
  display: "flex",
322
330
  flexDirection: "column",
@@ -324,13 +332,13 @@ function Ze({
324
332
  height: "100%"
325
333
  },
326
334
  children: [
327
- /* @__PURE__ */ l(me, { className: "flex-grow", children: [
335
+ /* @__PURE__ */ s(ge, { className: "flex-grow", children: [
328
336
  /* @__PURE__ */ e(
329
337
  "div",
330
338
  {
331
339
  className: "flex flex-row pt-12 pb-8",
332
340
  children: /* @__PURE__ */ e(
333
- O,
341
+ A,
334
342
  {
335
343
  variant: "h4",
336
344
  className: "flex-grow",
@@ -339,89 +347,89 @@ function Ze({
339
347
  )
340
348
  }
341
349
  ),
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: [
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: [
344
352
  /* @__PURE__ */ e(
345
- K,
353
+ Q,
346
354
  {
347
355
  name: "name",
348
356
  required: !0,
349
- error: b.name && !!C.name,
350
- value: s.name,
351
- disabled: g || !n,
352
- onChange: D,
357
+ error: U.name && !!C.name,
358
+ value: a.name,
359
+ disabled: u || !n,
360
+ onChange: y,
353
361
  "aria-describedby": "name-helper-text",
354
362
  label: "Name"
355
363
  }
356
364
  ),
357
- /* @__PURE__ */ e(B, { children: b.name && C.name ? C.name : "Name of this role" })
365
+ /* @__PURE__ */ e(B, { children: U.name && C.name ? C.name : "Name of this role" })
358
366
  ] }),
359
- /* @__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: [
360
368
  /* @__PURE__ */ e(
361
- K,
369
+ Q,
362
370
  {
363
371
  name: "id",
364
372
  required: !0,
365
- error: b.id && !!C.id,
366
- value: s.id,
367
- disabled: !w || !n,
373
+ error: U.id && !!C.id,
374
+ value: a.id,
375
+ disabled: !f || !n,
368
376
  onChange: (o) => {
369
- D(o), L("id", !0);
377
+ y(o), z("id", !0);
370
378
  },
371
379
  "aria-describedby": "id-helper-text",
372
380
  label: "ID"
373
381
  }
374
382
  ),
375
- /* @__PURE__ */ e(B, { children: b.id && C.id ? C.id : "ID of this role" })
383
+ /* @__PURE__ */ e(B, { children: U.id && C.id ? C.id : "ID of this role" })
376
384
  ] }),
377
- /* @__PURE__ */ l("div", { className: "col-span-12", children: [
385
+ /* @__PURE__ */ s("div", { className: "col-span-12", children: [
378
386
  /* @__PURE__ */ e(
379
- Be,
387
+ pe,
380
388
  {
381
389
  className: "bg-inherit",
382
- children: /* @__PURE__ */ l(re, { children: [
383
- /* @__PURE__ */ l(oe, { children: [
384
- /* @__PURE__ */ e(a, {}),
390
+ children: /* @__PURE__ */ s(re, { children: [
391
+ /* @__PURE__ */ s(ie, { children: [
392
+ /* @__PURE__ */ e(d, {}),
385
393
  /* @__PURE__ */ e(
386
- a,
394
+ d,
387
395
  {
388
396
  align: "center",
389
397
  children: "Create entities"
390
398
  }
391
399
  ),
392
400
  /* @__PURE__ */ e(
393
- a,
401
+ d,
394
402
  {
395
403
  align: "center",
396
404
  children: "Read entities"
397
405
  }
398
406
  ),
399
407
  /* @__PURE__ */ e(
400
- a,
408
+ d,
401
409
  {
402
410
  align: "center",
403
411
  children: "Update entities"
404
412
  }
405
413
  ),
406
414
  /* @__PURE__ */ e(
407
- a,
415
+ d,
408
416
  {
409
417
  align: "center",
410
418
  children: "Delete entities"
411
419
  }
412
420
  )
413
421
  ] }),
414
- /* @__PURE__ */ l(le, { children: [
415
- /* @__PURE__ */ l(q, { children: [
422
+ /* @__PURE__ */ s(oe, { children: [
423
+ /* @__PURE__ */ s(W, { children: [
416
424
  /* @__PURE__ */ e(
417
- a,
425
+ d,
418
426
  {
419
427
  scope: "row",
420
428
  children: /* @__PURE__ */ e("strong", { children: "All collections" })
421
429
  }
422
430
  ),
423
431
  /* @__PURE__ */ e(
424
- a,
432
+ d,
425
433
  {
426
434
  align: "center",
427
435
  children: /* @__PURE__ */ e(
@@ -429,11 +437,11 @@ function Ze({
429
437
  {
430
438
  title: "Create entities in collections",
431
439
  children: /* @__PURE__ */ e(
432
- E,
440
+ I,
433
441
  {
434
- disabled: g || !n,
435
- checked: (g || u) ?? !1,
436
- onCheckedChange: (o) => p("defaultPermissions.create", o)
442
+ disabled: u || !n,
443
+ checked: (u || h) ?? !1,
444
+ onCheckedChange: (o) => b("defaultPermissions.create", o)
437
445
  }
438
446
  )
439
447
  }
@@ -441,7 +449,7 @@ function Ze({
441
449
  }
442
450
  ),
443
451
  /* @__PURE__ */ e(
444
- a,
452
+ d,
445
453
  {
446
454
  align: "center",
447
455
  children: /* @__PURE__ */ e(
@@ -449,11 +457,11 @@ function Ze({
449
457
  {
450
458
  title: "Access all data in every collection",
451
459
  children: /* @__PURE__ */ e(
452
- E,
460
+ I,
453
461
  {
454
- disabled: g || !n,
455
- checked: (g || N) ?? !1,
456
- onCheckedChange: (o) => p("defaultPermissions.read", o)
462
+ disabled: u || !n,
463
+ checked: (u || x) ?? !1,
464
+ onCheckedChange: (o) => b("defaultPermissions.read", o)
457
465
  }
458
466
  )
459
467
  }
@@ -461,7 +469,7 @@ function Ze({
461
469
  }
462
470
  ),
463
471
  /* @__PURE__ */ e(
464
- a,
472
+ d,
465
473
  {
466
474
  align: "center",
467
475
  children: /* @__PURE__ */ e(
@@ -469,11 +477,11 @@ function Ze({
469
477
  {
470
478
  title: "Update data in any collection",
471
479
  children: /* @__PURE__ */ e(
472
- E,
480
+ I,
473
481
  {
474
- disabled: g || !n,
475
- checked: (g || U) ?? !1,
476
- onCheckedChange: (o) => p("defaultPermissions.edit", o)
482
+ disabled: u || !n,
483
+ checked: (u || D) ?? !1,
484
+ onCheckedChange: (o) => b("defaultPermissions.edit", o)
477
485
  }
478
486
  )
479
487
  }
@@ -481,7 +489,7 @@ function Ze({
481
489
  }
482
490
  ),
483
491
  /* @__PURE__ */ e(
484
- a,
492
+ d,
485
493
  {
486
494
  align: "center",
487
495
  children: /* @__PURE__ */ e(
@@ -489,11 +497,11 @@ function Ze({
489
497
  {
490
498
  title: "Delete data in any collection",
491
499
  children: /* @__PURE__ */ e(
492
- E,
500
+ I,
493
501
  {
494
- disabled: g || !n,
495
- checked: (g || F) ?? !1,
496
- onCheckedChange: (o) => p("defaultPermissions.delete", o)
502
+ disabled: u || !n,
503
+ checked: (u || T) ?? !1,
504
+ onCheckedChange: (o) => b("defaultPermissions.delete", o)
497
505
  }
498
506
  )
499
507
  }
@@ -501,66 +509,66 @@ function Ze({
501
509
  }
502
510
  )
503
511
  ] }),
504
- r && r.map((o) => /* @__PURE__ */ l(q, { children: [
512
+ i && i.map((o) => /* @__PURE__ */ s(W, { children: [
505
513
  /* @__PURE__ */ e(
506
- a,
514
+ d,
507
515
  {
508
516
  scope: "row",
509
517
  children: o.name
510
518
  }
511
519
  ),
512
520
  /* @__PURE__ */ e(
513
- a,
521
+ d,
514
522
  {
515
523
  align: "center",
516
524
  children: /* @__PURE__ */ e(
517
- E,
525
+ I,
518
526
  {
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)
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)
522
530
  }
523
531
  )
524
532
  }
525
533
  ),
526
534
  /* @__PURE__ */ e(
527
- a,
535
+ d,
528
536
  {
529
537
  align: "center",
530
538
  children: /* @__PURE__ */ e(
531
- E,
539
+ I,
532
540
  {
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)
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)
536
544
  }
537
545
  )
538
546
  }
539
547
  ),
540
548
  /* @__PURE__ */ e(
541
- a,
549
+ d,
542
550
  {
543
551
  align: "center",
544
552
  children: /* @__PURE__ */ e(
545
- E,
553
+ I,
546
554
  {
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)
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)
550
558
  }
551
559
  )
552
560
  }
553
561
  ),
554
562
  /* @__PURE__ */ e(
555
- a,
563
+ d,
556
564
  {
557
565
  align: "center",
558
566
  children: /* @__PURE__ */ e(
559
- E,
567
+ I,
560
568
  {
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)
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)
564
572
  }
565
573
  )
566
574
  }
@@ -572,29 +580,29 @@ function Ze({
572
580
  ),
573
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" })
574
582
  ] }),
575
- /* @__PURE__ */ l("div", { className: "col-span-12 md:col-span-4", children: [
576
- /* @__PURE__ */ l(
577
- te,
583
+ /* @__PURE__ */ s("div", { className: "col-span-12 md:col-span-4", children: [
584
+ /* @__PURE__ */ s(
585
+ ne,
578
586
  {
579
- error: b.config && !!C.config,
587
+ error: U.config && !!C.config,
580
588
  id: "createCollections",
581
589
  name: "createCollections",
582
590
  label: "Create collections",
583
591
  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",
592
+ disabled: u || !n,
593
+ onChange: (o) => b("config.createCollections", o.target.value === "true"),
594
+ value: u || a.config?.createCollections ? "true" : "false",
587
595
  renderValue: (o) => o === "true" ? "Yes" : "No",
588
596
  children: [
589
597
  /* @__PURE__ */ e(
590
- T,
598
+ L,
591
599
  {
592
600
  value: "true",
593
601
  children: " Yes "
594
602
  }
595
603
  ),
596
604
  /* @__PURE__ */ e(
597
- T,
605
+ L,
598
606
  {
599
607
  value: "false",
600
608
  children: " No "
@@ -603,38 +611,38 @@ function Ze({
603
611
  ]
604
612
  }
605
613
  ),
606
- /* @__PURE__ */ e(B, { children: b.config && C.config ? C.config : "Can the user create collections" })
614
+ /* @__PURE__ */ e(B, { children: U.config && C.config ? C.config : "Can the user create collections" })
607
615
  ] }),
608
- /* @__PURE__ */ l("div", { className: "col-span-12 md:col-span-4", children: [
609
- /* @__PURE__ */ l(
610
- te,
616
+ /* @__PURE__ */ s("div", { className: "col-span-12 md:col-span-4", children: [
617
+ /* @__PURE__ */ s(
618
+ ne,
611
619
  {
612
- error: b.config && !!C.config,
620
+ error: U.config && !!C.config,
613
621
  id: "editCollections",
614
622
  name: "editCollections",
615
623
  label: "Edit collections",
616
- disabled: g || !n,
624
+ disabled: u || !n,
617
625
  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",
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",
620
628
  renderValue: (o) => o === "own" ? "Own" : o === "true" ? "Yes" : "No",
621
629
  children: [
622
630
  /* @__PURE__ */ e(
623
- T,
631
+ L,
624
632
  {
625
633
  value: "true",
626
634
  children: " Yes "
627
635
  }
628
636
  ),
629
637
  /* @__PURE__ */ e(
630
- T,
638
+ L,
631
639
  {
632
640
  value: "false",
633
641
  children: " No "
634
642
  }
635
643
  ),
636
644
  /* @__PURE__ */ e(
637
- T,
645
+ L,
638
646
  {
639
647
  value: "own",
640
648
  children: " Only his/her own "
@@ -643,38 +651,38 @@ function Ze({
643
651
  ]
644
652
  }
645
653
  ),
646
- /* @__PURE__ */ e(B, { children: b.config && C.config ? C.config : "Can the user edit collections" })
654
+ /* @__PURE__ */ e(B, { children: U.config && C.config ? C.config : "Can the user edit collections" })
647
655
  ] }),
648
- /* @__PURE__ */ l("div", { className: "col-span-12 md:col-span-4", children: [
649
- /* @__PURE__ */ l(
650
- te,
656
+ /* @__PURE__ */ s("div", { className: "col-span-12 md:col-span-4", children: [
657
+ /* @__PURE__ */ s(
658
+ ne,
651
659
  {
652
- error: b.config && !!C.config,
660
+ error: U.config && !!C.config,
653
661
  id: "deleteCollections",
654
662
  name: "deleteCollections",
655
663
  label: "Delete collections",
656
- disabled: g || !n,
664
+ disabled: u || !n,
657
665
  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",
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",
660
668
  renderValue: (o) => o === "own" ? "Own" : o === "true" ? "Yes" : "No",
661
669
  children: [
662
670
  /* @__PURE__ */ e(
663
- T,
671
+ L,
664
672
  {
665
673
  value: "true",
666
674
  children: " Yes "
667
675
  }
668
676
  ),
669
677
  /* @__PURE__ */ e(
670
- T,
678
+ L,
671
679
  {
672
680
  value: "false",
673
681
  children: " No "
674
682
  }
675
683
  ),
676
684
  /* @__PURE__ */ e(
677
- T,
685
+ L,
678
686
  {
679
687
  value: "own",
680
688
  children: " Only his/her own "
@@ -683,32 +691,32 @@ function Ze({
683
691
  ]
684
692
  }
685
693
  ),
686
- /* @__PURE__ */ e(B, { children: b.config && C.config ? C.config : "Can the user delete collections" })
694
+ /* @__PURE__ */ e(B, { children: U.config && C.config ? C.config : "Can the user delete collections" })
687
695
  ] })
688
696
  ] })
689
697
  ] }),
690
- /* @__PURE__ */ l(he, { position: "sticky", children: [
691
- f && /* @__PURE__ */ e(O, { 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" }),
692
700
  /* @__PURE__ */ e(
693
- Y,
701
+ O,
694
702
  {
695
703
  variant: "text",
696
704
  onClick: () => {
697
- c();
705
+ l();
698
706
  },
699
707
  children: "Cancel"
700
708
  }
701
709
  ),
702
710
  /* @__PURE__ */ e(
703
- fe,
711
+ ve,
704
712
  {
705
713
  variant: "filled",
706
714
  color: "primary",
707
715
  type: "submit",
708
- disabled: !z,
709
- loading: I,
710
- startIcon: /* @__PURE__ */ e(ge, {}),
711
- children: w ? "Create role" : "Update"
716
+ disabled: !_,
717
+ loading: S,
718
+ startIcon: /* @__PURE__ */ e(we, {}),
719
+ children: f ? "Create role" : "Update"
712
720
  }
713
721
  )
714
722
  ] })
@@ -718,7 +726,7 @@ function Ze({
718
726
  }
719
727
  );
720
728
  }
721
- const en = [
729
+ const Se = [
722
730
  {
723
731
  id: "admin",
724
732
  name: "Admin",
@@ -752,69 +760,69 @@ const en = [
752
760
  }
753
761
  }
754
762
  ];
755
- function nn({
763
+ function Xe({
756
764
  onRoleClicked: t,
757
- editable: i
765
+ editable: r
758
766
  }) {
759
767
  const {
760
768
  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(
769
+ saveRole: l,
770
+ deleteRole: i,
771
+ allowDefaultRolesCreation: m
772
+ } = j(), [f, v] = P(void 0), [R, w] = P(!1);
773
+ return /* @__PURE__ */ s(
766
774
  "div",
767
775
  {
768
776
  className: "w-full overflow-auto",
769
777
  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" })
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" })
776
784
  ] }),
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,
785
+ /* @__PURE__ */ s(oe, { children: [
786
+ n && n.map((c) => {
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,
782
790
  {
783
791
  onClick: () => {
784
- t(d);
792
+ t(c);
785
793
  },
786
794
  children: [
787
- /* @__PURE__ */ e(a, { style: { width: "64px" }, children: !d.isAdmin && /* @__PURE__ */ e(V, { title: "Delete this role", children: /* @__PURE__ */ e(
788
- pe,
795
+ /* @__PURE__ */ e(d, { style: { width: "64px" }, children: !c.isAdmin && /* @__PURE__ */ e(V, { title: "Delete this role", children: /* @__PURE__ */ e(
796
+ ye,
789
797
  {
790
798
  size: "small",
791
- disabled: !i,
792
- onClick: (D) => (D.stopPropagation(), f(d)),
793
- children: /* @__PURE__ */ e(Ce, {})
799
+ disabled: !r,
800
+ onClick: (y) => (y.stopPropagation(), v(c)),
801
+ children: /* @__PURE__ */ e(be, {})
794
802
  }
795
803
  ) }) }),
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" }),
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" }),
802
810
  C && /* @__PURE__ */ e("li", { children: "Delete" })
803
811
  ] }) })
804
812
  ]
805
813
  },
806
- d.name
814
+ c.name
807
815
  );
808
816
  }),
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,
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,
813
821
  {
814
822
  variant: "outlined",
815
823
  onClick: () => {
816
- en.forEach((d) => {
817
- c(d);
824
+ Se.forEach((c) => {
825
+ l(c);
818
826
  });
819
827
  },
820
828
  children: "Create default roles"
@@ -824,38 +832,38 @@ function nn({
824
832
  ] })
825
833
  ] }),
826
834
  /* @__PURE__ */ e(
827
- be,
835
+ xe,
828
836
  {
829
- open: !!w,
830
- loading: x,
837
+ open: !!f,
838
+ loading: R,
831
839
  onAccept: () => {
832
- w && (y(!0), r(w).then(() => {
833
- f(void 0);
840
+ f && (w(!0), i(f).then(() => {
841
+ v(void 0);
834
842
  }).finally(() => {
835
- y(!1);
843
+ w(!1);
836
844
  }));
837
845
  },
838
846
  onCancel: () => {
839
- f(void 0);
847
+ v(void 0);
840
848
  },
841
- title: /* @__PURE__ */ e(H, { children: "Delete?" }),
842
- body: /* @__PURE__ */ e(H, { children: "Are you sure you want to delete this role?" })
849
+ title: /* @__PURE__ */ e(K, { children: "Delete?" }),
850
+ body: /* @__PURE__ */ e(K, { children: "Are you sure you want to delete this role?" })
843
851
  }
844
852
  )
845
853
  ]
846
854
  }
847
855
  );
848
856
  }
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);
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);
853
861
  }, []);
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: [
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: [
857
865
  /* @__PURE__ */ e(
858
- O,
866
+ A,
859
867
  {
860
868
  gutterBottom: !0,
861
869
  variant: "h4",
@@ -864,103 +872,103 @@ const tn = A.memo(
864
872
  children: "Roles"
865
873
  }
866
874
  ),
867
- /* @__PURE__ */ e(V, { title: f ? void 0 : "Update plans to customise roles", children: /* @__PURE__ */ e(
868
- Y,
875
+ /* @__PURE__ */ e(V, { title: v ? void 0 : "Update plans to customise roles", children: /* @__PURE__ */ e(
876
+ O,
869
877
  {
870
878
  size: "large",
871
- disabled: !f,
872
- startIcon: /* @__PURE__ */ e(ye, {}),
873
- onClick: () => r(!0),
879
+ disabled: !v,
880
+ startIcon: /* @__PURE__ */ e(le, {}),
881
+ onClick: () => i(!0),
874
882
  children: "Add role"
875
883
  }
876
884
  ) })
877
885
  ] }),
878
- /* @__PURE__ */ e(nn, { onRoleClicked: x, editable: !!f }),
886
+ /* @__PURE__ */ e(Xe, { onRoleClicked: R, editable: !!v }),
879
887
  /* @__PURE__ */ e(
880
- Ze,
888
+ Qe,
881
889
  {
882
- open: c,
883
- role: h,
884
- editable: f,
890
+ open: l,
891
+ role: m,
892
+ editable: v,
885
893
  collections: n,
886
894
  handleClose: () => {
887
- w(void 0), r(!1);
895
+ f(void 0), i(!1);
888
896
  }
889
897
  },
890
- h?.id ?? "new"
898
+ m?.id ?? "new"
891
899
  )
892
900
  ] });
893
901
  }
894
- ), rn = _.object().shape({
895
- displayName: _.string().required("Required"),
896
- email: _.string().email().required("Required"),
897
- roles: _.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)
898
906
  });
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)
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)
902
910
  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)
911
+ if (i && i.roles?.map((w) => w.id).includes("admin") && !r.roles?.map((w) => w.id).includes("admin") && m.length === 1)
904
912
  throw new Error("There must be at least one admin");
905
913
  return !0;
906
914
  }
907
- function ln({
915
+ function tn({
908
916
  open: t,
909
- user: i,
917
+ user: r,
910
918
  handleClose: n
911
919
  }) {
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)
920
+ const l = se(), {
921
+ user: i
922
+ } = ae(), {
923
+ saveUser: m,
924
+ users: f,
925
+ roles: v
926
+ } = j(), R = !r, w = k((h) => {
927
+ if (!i)
920
928
  throw new Error("Logged user not found");
921
929
  try {
922
- return on(r, u, w, f, i), h(u);
923
- } catch (N) {
924
- return Promise.reject(N);
930
+ return nn(i, h, f, v, r), m(h);
931
+ } catch (x) {
932
+ return Promise.reject(x);
925
933
  }
926
- }, [f, h, i, w, r]), d = xe({
927
- initialValues: i ?? {
934
+ }, [v, m, r, f, i]), c = Re({
935
+ initialValues: r ?? {
928
936
  displayName: "",
929
937
  email: "",
930
- roles: f.filter((u) => u.id === "editor")
938
+ roles: v.filter((h) => h.id === "editor")
931
939
  },
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
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
936
944
  });
937
- }).catch((U) => {
938
- c.open({
945
+ }).catch((D) => {
946
+ l.open({
939
947
  type: "error",
940
- message: U.message
948
+ message: D.message
941
949
  });
942
950
  })
943
951
  }), {
944
- isSubmitting: I,
945
- touched: b,
946
- handleChange: s,
952
+ isSubmitting: S,
953
+ touched: U,
954
+ handleChange: a,
947
955
  values: C,
948
- errors: D,
949
- setFieldValue: p,
950
- dirty: z,
951
- handleSubmit: L,
952
- submitCount: g
953
- } = d;
956
+ errors: y,
957
+ setFieldValue: b,
958
+ dirty: _,
959
+ handleSubmit: z,
960
+ submitCount: u
961
+ } = c;
954
962
  return /* @__PURE__ */ e(
955
- ue,
963
+ fe,
956
964
  {
957
965
  open: t,
958
- onOpenChange: (u) => u ? void 0 : n(),
966
+ onOpenChange: (h) => h ? void 0 : n(),
959
967
  maxWidth: "4xl",
960
- children: /* @__PURE__ */ e(De, { value: d, children: /* @__PURE__ */ l(
968
+ children: /* @__PURE__ */ e(De, { value: c, children: /* @__PURE__ */ s(
961
969
  "form",
962
970
  {
963
- onSubmit: L,
971
+ onSubmit: z,
964
972
  autoComplete: "off",
965
973
  noValidate: !0,
966
974
  style: {
@@ -970,13 +978,13 @@ function ln({
970
978
  height: "100%"
971
979
  },
972
980
  children: [
973
- /* @__PURE__ */ l(me, { className: "h-full flex-grow", children: [
981
+ /* @__PURE__ */ s(ge, { className: "h-full flex-grow", children: [
974
982
  /* @__PURE__ */ e(
975
983
  "div",
976
984
  {
977
985
  className: "flex flex-row pt-4 pb-4",
978
986
  children: /* @__PURE__ */ e(
979
- O,
987
+ A,
980
988
  {
981
989
  variant: "h4",
982
990
  className: "flex-grow",
@@ -985,62 +993,62 @@ function ln({
985
993
  )
986
994
  }
987
995
  ),
988
- /* @__PURE__ */ l("div", { className: "grid grid-cols-12 gap-8", children: [
989
- /* @__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: [
990
998
  /* @__PURE__ */ e(
991
- K,
999
+ Q,
992
1000
  {
993
1001
  name: "displayName",
994
1002
  required: !0,
995
- error: g > 0 && !!D.displayName,
1003
+ error: u > 0 && !!y.displayName,
996
1004
  value: C.displayName ?? "",
997
- onChange: s,
1005
+ onChange: a,
998
1006
  "aria-describedby": "name-helper-text",
999
1007
  label: "Name"
1000
1008
  }
1001
1009
  ),
1002
- /* @__PURE__ */ e(B, { children: g > 0 && D.displayName ? D.displayName : "Name of this user" })
1010
+ /* @__PURE__ */ e(B, { children: u > 0 && y.displayName ? y.displayName : "Name of this user" })
1003
1011
  ] }),
1004
- /* @__PURE__ */ l("div", { className: "col-span-12", children: [
1012
+ /* @__PURE__ */ s("div", { className: "col-span-12", children: [
1005
1013
  /* @__PURE__ */ e(
1006
- K,
1014
+ Q,
1007
1015
  {
1008
1016
  required: !0,
1009
- error: g > 0 && !!D.email,
1017
+ error: u > 0 && !!y.email,
1010
1018
  name: "email",
1011
1019
  value: C.email ?? "",
1012
- onChange: s,
1020
+ onChange: a,
1013
1021
  "aria-describedby": "email-helper-text",
1014
1022
  label: "Email"
1015
1023
  }
1016
1024
  ),
1017
- /* @__PURE__ */ e(B, { children: g > 0 && D.email ? D.email : "Email of this user" })
1025
+ /* @__PURE__ */ e(B, { children: u > 0 && y.email ? y.email : "Email of this user" })
1018
1026
  ] }),
1019
1027
  /* @__PURE__ */ e("div", { className: "col-span-12", children: /* @__PURE__ */ e(
1020
- Le,
1028
+ Te,
1021
1029
  {
1022
1030
  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;
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;
1028
1036
  },
1029
- children: f.map((u) => /* @__PURE__ */ e(
1030
- Ve,
1037
+ children: v.map((h) => /* @__PURE__ */ e(
1038
+ Le,
1031
1039
  {
1032
- value: u.id,
1033
- children: /* @__PURE__ */ e(Q, { role: u }, u?.id)
1040
+ value: h.id,
1041
+ children: /* @__PURE__ */ e(X, { role: h }, h?.id)
1034
1042
  },
1035
- u.id
1043
+ h.id
1036
1044
  ))
1037
1045
  }
1038
1046
  ) })
1039
1047
  ] })
1040
1048
  ] }),
1041
- /* @__PURE__ */ l(he, { children: [
1049
+ /* @__PURE__ */ s(Ce, { children: [
1042
1050
  /* @__PURE__ */ e(
1043
- Y,
1051
+ O,
1044
1052
  {
1045
1053
  variant: "text",
1046
1054
  onClick: () => {
@@ -1050,15 +1058,15 @@ function ln({
1050
1058
  }
1051
1059
  ),
1052
1060
  /* @__PURE__ */ e(
1053
- fe,
1061
+ ve,
1054
1062
  {
1055
1063
  variant: "filled",
1056
1064
  color: "primary",
1057
1065
  type: "submit",
1058
- disabled: !z,
1059
- loading: I,
1060
- startIcon: /* @__PURE__ */ e(ge, {}),
1061
- children: x ? "Create user" : "Update"
1066
+ disabled: !_,
1067
+ loading: S,
1068
+ startIcon: /* @__PURE__ */ e(we, {}),
1069
+ children: R ? "Create user" : "Update"
1062
1070
  }
1063
1071
  )
1064
1072
  ] })
@@ -1068,79 +1076,79 @@ function ln({
1068
1076
  }
1069
1077
  );
1070
1078
  }
1071
- function sn({ onUserClicked: t }) {
1079
+ function rn({ onUserClicked: t }) {
1072
1080
  const {
1073
- users: i,
1081
+ users: r,
1074
1082
  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" })
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" })
1086
1094
  ] }),
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,
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,
1092
1100
  {
1093
1101
  onClick: () => {
1094
- t(s);
1102
+ t(a);
1095
1103
  },
1096
1104
  children: [
1097
- /* @__PURE__ */ e(a, { className: "w-10", children: /* @__PURE__ */ e(V, { title: "Delete this user", children: /* @__PURE__ */ e(
1098
- pe,
1105
+ /* @__PURE__ */ e(d, { className: "w-10", children: /* @__PURE__ */ e(V, { title: "Delete this user", children: /* @__PURE__ */ e(
1106
+ ye,
1099
1107
  {
1100
1108
  size: "small",
1101
- onClick: (p) => (p.stopPropagation(), d(s)),
1102
- children: /* @__PURE__ */ e(Ce, {})
1109
+ onClick: (b) => (b.stopPropagation(), c(a)),
1110
+ children: /* @__PURE__ */ e(be, {})
1103
1111
  }
1104
1112
  ) }) }),
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)
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)
1110
1118
  ) }) : null }),
1111
- /* @__PURE__ */ e(a, { children: D })
1119
+ /* @__PURE__ */ e(d, { children: y })
1112
1120
  ]
1113
1121
  },
1114
- "row_" + s.uid
1122
+ "row_" + a.uid
1115
1123
  );
1116
1124
  }),
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" }),
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" }),
1119
1127
  /* @__PURE__ */ e(
1120
- Y,
1128
+ O,
1121
1129
  {
1122
1130
  variant: "outlined",
1123
1131
  onClick: () => {
1124
- if (!r.user?.uid)
1132
+ if (!i.user?.uid)
1125
1133
  throw Error("UsersTable, authController misconfiguration");
1126
1134
  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,
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,
1133
1141
  roles: [{ id: "admin", name: "Admin" }],
1134
1142
  created_on: /* @__PURE__ */ new Date()
1135
1143
  }).then(() => {
1136
- h.open({
1144
+ m.open({
1137
1145
  type: "success",
1138
1146
  message: "User added successfully"
1139
1147
  });
1140
- }).catch((s) => {
1141
- h.open({
1148
+ }).catch((a) => {
1149
+ m.open({
1142
1150
  type: "error",
1143
- message: "Error adding user: " + s.message
1151
+ message: "Error adding user: " + a.message
1144
1152
  });
1145
1153
  });
1146
1154
  },
@@ -1151,46 +1159,46 @@ function sn({ onUserClicked: t }) {
1151
1159
  ] })
1152
1160
  ] }),
1153
1161
  /* @__PURE__ */ e(
1154
- be,
1162
+ xe,
1155
1163
  {
1156
- open: !!y,
1157
- loading: I,
1164
+ open: !!w,
1165
+ loading: S,
1158
1166
  onAccept: () => {
1159
- y && (b(!0), c(y).then(() => {
1160
- d(void 0);
1161
- }).catch((s) => {
1162
- h.open({
1167
+ w && (U(!0), l(w).then(() => {
1168
+ c(void 0);
1169
+ }).catch((a) => {
1170
+ m.open({
1163
1171
  type: "error",
1164
- message: "Error deleting user: " + s.message
1172
+ message: "Error deleting user: " + a.message
1165
1173
  });
1166
1174
  }).finally(() => {
1167
- b(!1);
1175
+ U(!1);
1168
1176
  }));
1169
1177
  },
1170
1178
  onCancel: () => {
1171
- d(void 0);
1179
+ c(void 0);
1172
1180
  },
1173
- title: /* @__PURE__ */ e(H, { children: "Delete?" }),
1174
- body: /* @__PURE__ */ e(H, { children: "Are you sure you want to delete this user?" })
1181
+ title: /* @__PURE__ */ e(K, { children: "Delete?" }),
1182
+ body: /* @__PURE__ */ e(K, { children: "Are you sure you want to delete this user?" })
1175
1183
  }
1176
1184
  )
1177
1185
  ] });
1178
1186
  }
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);
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);
1184
1192
  }, []);
1185
- return /* @__PURE__ */ l(we, { className: "w-full flex flex-col py-4 gap-4", maxWidth: "6xl", children: [
1186
- i,
1187
- /* @__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(
1188
1196
  "div",
1189
1197
  {
1190
1198
  className: "flex items-center mt-12",
1191
1199
  children: [
1192
1200
  /* @__PURE__ */ e(
1193
- O,
1201
+ A,
1194
1202
  {
1195
1203
  gutterBottom: !0,
1196
1204
  variant: "h4",
@@ -1200,82 +1208,143 @@ const an = function({ children: i }) {
1200
1208
  }
1201
1209
  ),
1202
1210
  /* @__PURE__ */ e(
1203
- Y,
1211
+ O,
1204
1212
  {
1205
1213
  size: "large",
1206
- disabled: x,
1207
- startIcon: /* @__PURE__ */ e(ye, {}),
1208
- onClick: () => c(!0),
1214
+ disabled: R,
1215
+ startIcon: /* @__PURE__ */ e(le, {}),
1216
+ onClick: () => l(!0),
1209
1217
  children: "Add user"
1210
1218
  }
1211
1219
  )
1212
1220
  ]
1213
1221
  }
1214
1222
  ),
1215
- /* @__PURE__ */ e(sn, { onUserClicked: y }),
1223
+ /* @__PURE__ */ e(rn, { onUserClicked: w }),
1216
1224
  /* @__PURE__ */ e(
1217
- ln,
1225
+ tn,
1218
1226
  {
1219
1227
  open: n ?? !1,
1220
- user: r,
1221
- handleClose: d
1228
+ user: i,
1229
+ handleClose: c
1222
1230
  },
1223
- r?.uid ?? "new"
1231
+ i?.uid ?? "new"
1224
1232
  )
1225
1233
  ] });
1226
1234
  };
1227
- function xn({ userManagement: t }) {
1235
+ function Nn({ userManagement: t }) {
1236
+ const r = t.users.length === 0, n = t.roles.length === 0;
1228
1237
  return {
1229
1238
  key: "user_management",
1230
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
+ },
1231
1250
  provider: {
1232
- Component: Qe,
1251
+ Component: He,
1233
1252
  props: {
1234
1253
  userManagement: t
1235
1254
  }
1236
1255
  }
1237
1256
  };
1238
1257
  }
1239
- const Dn = [
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 = [
1240
1308
  {
1241
1309
  path: "users",
1242
1310
  name: "CMS Users",
1243
1311
  group: "Admin",
1244
1312
  icon: "face",
1245
- view: /* @__PURE__ */ e(an, {})
1313
+ view: /* @__PURE__ */ e(on, {})
1246
1314
  },
1247
1315
  {
1248
1316
  path: "roles",
1249
1317
  name: "Roles",
1250
1318
  group: "Admin",
1251
1319
  icon: "gpp_good",
1252
- view: /* @__PURE__ */ e(tn, {})
1320
+ view: /* @__PURE__ */ e(Ze, {})
1253
1321
  }
1254
1322
  ];
1255
1323
  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
1324
+ ln as IntroWidget,
1325
+ fn as RESERVED_GROUPS,
1326
+ X as RoleChip,
1327
+ Ke as RoleYupSchema,
1328
+ Qe as RolesDetailsForm,
1329
+ Xe as RolesTable,
1330
+ Ze as RolesView,
1331
+ tn as UserDetailsForm,
1332
+ Ee as UserManagementContext,
1333
+ He as UserManagementProvider,
1334
+ en as UserYupSchema,
1335
+ rn as UsersTable,
1336
+ on as UsersView,
1337
+ je as areRolesEqual,
1338
+ pn as cacheDelegatedLoginToken,
1339
+ vn as clearDelegatedLoginTokensCache,
1340
+ wn as darkenColor,
1341
+ Cn as getDelegatedLoginTokenFromCache,
1342
+ gn as getUserRoles,
1343
+ yn as hexToRgbaWithOpacity,
1344
+ Ye as resolveUserRolePermissions,
1345
+ bn as useFirestoreUserManagement,
1346
+ j as useUserManagement,
1347
+ Nn as useUserManagementPlugin,
1348
+ Un as userManagementAdminViews
1280
1349
  };
1281
1350
  //# sourceMappingURL=index.es.js.map