@firecms/user_management 3.0.0-canary.16 → 3.0.0-canary.18

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