@feedmepos/mf-hrm-portal 2.0.17-dev.3 → 2.0.17-dev.5

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.
Files changed (41) hide show
  1. package/dist/AuditLogList-Dl3Nmf00.js +1011 -0
  2. package/dist/EmployeeList-DBd_rVW2.js +831 -0
  3. package/dist/{Main-Dkr5lzbv.js → Main-CQ3KwxDY.js} +1368 -1371
  4. package/dist/{Main--tejoyEP.js → Main-pTgqNncY.js} +125 -125
  5. package/dist/{Main-BNXKItvX.js → Main-w0XUUaBp.js} +6 -6
  6. package/dist/PermissionSetList-B8qNOWH6.js +347 -0
  7. package/dist/{PortalPermissionEditor.vue_vue_type_script_setup_true_lang-BBsaxaXu.js → PortalPermissionEditor.vue_vue_type_script_setup_true_lang-C9VUjAu_.js} +1064 -1060
  8. package/dist/{RoleList-SZCgvYvC.js → RoleList-DMFJsUZv.js} +202 -200
  9. package/dist/Skeleton.vue_vue_type_script_setup_true_lang-B4PxNMwq.js +16 -0
  10. package/dist/TeamMemberList-BLRTfKLz.js +1031 -0
  11. package/dist/{TimesheetList-D-3k0Uad.js → TimesheetList-Bwp9_xHe.js} +6 -6
  12. package/dist/{app-BjXuSCis.js → app-COJbSNM4.js} +1975 -1440
  13. package/dist/app.js +1 -1
  14. package/dist/{dayjs.min-z-vrgFCL.js → dayjs.min-CcBi6N-K.js} +1 -1
  15. package/dist/{employee-DAqAMupR.js → employee-xiV0LfnL.js} +3 -3
  16. package/dist/{iteration-Cp1eSTJA.js → iteration-JOKbtlLf.js} +1 -1
  17. package/dist/{lodash-CXLZQQp8.js → lodash-D5xlVzib.js} +1 -1
  18. package/dist/rule-3sXHiW0y.js +994 -0
  19. package/dist/src/api/audit-log/index.d.ts +9 -0
  20. package/dist/src/api/report-query/index.d.ts +2 -2
  21. package/dist/src/components/Skeleton.vue.d.ts +7 -0
  22. package/dist/src/composables/useBasePermission.d.ts +1 -0
  23. package/dist/src/stores/team.d.ts +6 -6
  24. package/dist/src/types/team.d.ts +1 -1
  25. package/dist/src/views/hr/locales/index.d.ts +172 -0
  26. package/dist/src/views/team/components/BasePermission.vue.d.ts +1 -1
  27. package/dist/src/views/team/locales/index.d.ts +312 -0
  28. package/dist/style.css +1 -1
  29. package/dist/{team-CnQ_rIx2.js → team-CyNektSD.js} +1 -1
  30. package/dist/{timesheet-BlPhOifI.js → timesheet-DkD3AysG.js} +2 -2
  31. package/dist/tsconfig.app.tsbuildinfo +1 -1
  32. package/dist/{useAppStore-BVnrWyPF.js → useAppStore-CvmsaYSG.js} +1 -1
  33. package/dist/{useLoading-7ia-Bps7.js → useLoading-4TNmhm5N.js} +1 -1
  34. package/dist/useReportPermissions-CWMFFb8E.js +70 -0
  35. package/package.json +2 -2
  36. package/dist/AuditLogList-C6qAeY5g.js +0 -954
  37. package/dist/EmployeeList-COtXtTqG.js +0 -827
  38. package/dist/PermissionSetList-B_Sdvbu7.js +0 -340
  39. package/dist/TeamMemberList-Dk5HeFfQ.js +0 -1008
  40. package/dist/rule-vBxopbM_.js +0 -990
  41. package/dist/useReportPermissions-C8HMek35.js +0 -60
@@ -0,0 +1,994 @@
1
+ import { g as p, b as g, q as D, s as W, d as Y, e as h } from "./iteration-JOKbtlLf.js";
2
+ import { e as I, P as V, d as x, y as j, C as Z, i as M } from "./app-COJbSNM4.js";
3
+ import { s as q } from "./utils-BZkjJbju.js";
4
+ import { defineStore as z, storeToRefs as K } from "pinia";
5
+ import { ref as S, computed as U } from "vue";
6
+ import { useCoreStore as L } from "@feedmepos/mf-common";
7
+ const J = [
8
+ {
9
+ label: "",
10
+ subject: "order",
11
+ actions: ["update"],
12
+ conditions: {
13
+ operation: "discount",
14
+ adjustment: {
15
+ $lte: 1
16
+ }
17
+ },
18
+ inverted: !1,
19
+ reason: null
20
+ },
21
+ {
22
+ label: "",
23
+ subject: "order",
24
+ actions: ["update"],
25
+ conditions: { operation: "changePrice" },
26
+ inverted: !1,
27
+ reason: null
28
+ },
29
+ {
30
+ label: "",
31
+ subject: "order",
32
+ actions: ["update"],
33
+ conditions: { operation: "void" },
34
+ inverted: !1,
35
+ reason: null
36
+ },
37
+ {
38
+ label: "",
39
+ subject: "order",
40
+ actions: ["update"],
41
+ conditions: { operation: "payment" },
42
+ inverted: !1,
43
+ reason: null
44
+ },
45
+ {
46
+ label: "",
47
+ subject: "order",
48
+ actions: ["update"],
49
+ conditions: { operation: "claimDeposit" },
50
+ inverted: !1,
51
+ reason: null
52
+ },
53
+ {
54
+ label: "",
55
+ subject: "order",
56
+ actions: ["update"],
57
+ conditions: { operation: "resend" },
58
+ inverted: !1,
59
+ reason: null
60
+ },
61
+ {
62
+ label: "",
63
+ subject: "order",
64
+ actions: ["update"],
65
+ conditions: { operation: "changePaymentType" },
66
+ inverted: !1,
67
+ reason: null
68
+ },
69
+ {
70
+ label: "",
71
+ subject: "refund",
72
+ actions: ["create"],
73
+ conditions: null,
74
+ inverted: !1,
75
+ reason: null
76
+ },
77
+ {
78
+ label: "",
79
+ subject: "counter",
80
+ actions: ["manage"],
81
+ conditions: null,
82
+ inverted: !1,
83
+ reason: null
84
+ },
85
+ {
86
+ label: "",
87
+ subject: "mallIntegration",
88
+ actions: ["manage"],
89
+ conditions: null,
90
+ inverted: !1,
91
+ reason: null
92
+ },
93
+ {
94
+ label: "",
95
+ subject: "drawer",
96
+ actions: ["manage"],
97
+ conditions: null,
98
+ inverted: !1,
99
+ reason: null
100
+ },
101
+ {
102
+ label: "",
103
+ subject: "menu",
104
+ actions: ["manage"],
105
+ conditions: null,
106
+ inverted: !1,
107
+ reason: null
108
+ },
109
+ {
110
+ label: "",
111
+ subject: "inventory",
112
+ actions: ["manage"],
113
+ conditions: null,
114
+ inverted: !1,
115
+ reason: null
116
+ },
117
+ {
118
+ label: "",
119
+ subject: "deposit",
120
+ actions: ["manage"],
121
+ conditions: null,
122
+ inverted: !1,
123
+ reason: null
124
+ },
125
+ {
126
+ label: "",
127
+ subject: "delivery",
128
+ actions: ["manage"],
129
+ conditions: null,
130
+ inverted: !1,
131
+ reason: null
132
+ },
133
+ {
134
+ label: "",
135
+ subject: "counterRecord",
136
+ actions: ["manage"],
137
+ conditions: null,
138
+ inverted: !1,
139
+ reason: null
140
+ },
141
+ {
142
+ label: "",
143
+ subject: "restaurantSetting",
144
+ actions: ["manage"],
145
+ conditions: null,
146
+ inverted: !1,
147
+ reason: null
148
+ },
149
+ {
150
+ label: "",
151
+ subject: "display",
152
+ actions: ["manage"],
153
+ conditions: null,
154
+ inverted: !1,
155
+ reason: null
156
+ },
157
+ {
158
+ label: "",
159
+ subject: "printer",
160
+ actions: ["manage"],
161
+ conditions: null,
162
+ inverted: !1,
163
+ reason: null
164
+ },
165
+ {
166
+ label: "",
167
+ subject: "table",
168
+ actions: ["manage"],
169
+ conditions: null,
170
+ inverted: !1,
171
+ reason: null
172
+ },
173
+ {
174
+ label: "",
175
+ subject: "employee",
176
+ actions: ["manage"],
177
+ conditions: null,
178
+ inverted: !1,
179
+ reason: null
180
+ },
181
+ {
182
+ label: "",
183
+ subject: "system",
184
+ actions: ["manage"],
185
+ conditions: null,
186
+ inverted: !1,
187
+ reason: null
188
+ },
189
+ {
190
+ label: "",
191
+ subject: "tax",
192
+ actions: ["manage"],
193
+ conditions: null,
194
+ inverted: !1,
195
+ reason: null
196
+ },
197
+ {
198
+ label: "",
199
+ subject: "paymentType",
200
+ actions: ["manage"],
201
+ conditions: null,
202
+ inverted: !1,
203
+ reason: null
204
+ },
205
+ {
206
+ label: "",
207
+ subject: "faceId",
208
+ actions: ["manage"],
209
+ conditions: null,
210
+ inverted: !1,
211
+ reason: null
212
+ },
213
+ {
214
+ label: "",
215
+ subject: "report",
216
+ actions: ["read"],
217
+ conditions: { name: "closeup" },
218
+ inverted: !1,
219
+ reason: ""
220
+ },
221
+ {
222
+ label: "",
223
+ subject: "report",
224
+ actions: ["read"],
225
+ conditions: { name: "counter" },
226
+ inverted: !1,
227
+ reason: ""
228
+ },
229
+ {
230
+ label: "",
231
+ subject: "report",
232
+ actions: ["read"],
233
+ conditions: { name: "hourlySales" },
234
+ inverted: !1,
235
+ reason: ""
236
+ },
237
+ {
238
+ label: "",
239
+ subject: "report",
240
+ actions: ["read"],
241
+ conditions: { name: "dailySales" },
242
+ inverted: !1,
243
+ reason: ""
244
+ },
245
+ {
246
+ label: "",
247
+ subject: "report",
248
+ actions: ["read"],
249
+ conditions: { name: "productSales" },
250
+ inverted: !1,
251
+ reason: ""
252
+ },
253
+ {
254
+ label: "",
255
+ subject: "report",
256
+ actions: ["read"],
257
+ conditions: { name: "sourceProductSales" },
258
+ inverted: !1,
259
+ reason: ""
260
+ },
261
+ {
262
+ label: "",
263
+ subject: "report",
264
+ actions: ["read"],
265
+ conditions: { name: "userProductSales" },
266
+ inverted: !1,
267
+ reason: ""
268
+ },
269
+ {
270
+ label: "",
271
+ subject: "report",
272
+ actions: ["read"],
273
+ conditions: { name: "categorySales" },
274
+ inverted: !1,
275
+ reason: ""
276
+ },
277
+ {
278
+ label: "",
279
+ subject: "report",
280
+ actions: ["read"],
281
+ conditions: { name: "addonSales" },
282
+ inverted: !1,
283
+ reason: ""
284
+ },
285
+ {
286
+ label: "",
287
+ subject: "report",
288
+ actions: ["read"],
289
+ conditions: { name: "slotSales" },
290
+ inverted: !1,
291
+ reason: ""
292
+ },
293
+ {
294
+ label: "",
295
+ subject: "report",
296
+ actions: ["read"],
297
+ conditions: { name: "drawer" },
298
+ inverted: !1,
299
+ reason: ""
300
+ },
301
+ {
302
+ label: "",
303
+ subject: "report",
304
+ actions: ["read"],
305
+ conditions: { name: "discount" },
306
+ inverted: !1,
307
+ reason: ""
308
+ },
309
+ {
310
+ label: "",
311
+ subject: "report",
312
+ actions: ["read"],
313
+ conditions: { name: "refund" },
314
+ inverted: !1,
315
+ reason: ""
316
+ },
317
+ {
318
+ label: "",
319
+ subject: "report",
320
+ actions: ["read"],
321
+ conditions: { name: "void" },
322
+ inverted: !1,
323
+ reason: ""
324
+ },
325
+ {
326
+ label: "",
327
+ subject: "report",
328
+ actions: ["read"],
329
+ conditions: { name: "timesheet" },
330
+ inverted: !1,
331
+ reason: ""
332
+ },
333
+ {
334
+ label: "",
335
+ subject: "report",
336
+ actions: ["read"],
337
+ conditions: { name: "counterPayment" },
338
+ inverted: !1,
339
+ reason: ""
340
+ }
341
+ ], O = "/permission-sets", _ = {
342
+ async read() {
343
+ return p(await g().get(O));
344
+ },
345
+ async create(e) {
346
+ return p(await g().post(O, e));
347
+ },
348
+ async update(e, s) {
349
+ return p(await g().put(`${O}/${e}`, s));
350
+ },
351
+ async delete(e) {
352
+ return p(await g().delete(`${O}/${e}`));
353
+ }
354
+ }, ee = z("permissionSet", () => {
355
+ const { currentBusiness: e } = L(), s = S([]), n = S(null);
356
+ async function o() {
357
+ var l;
358
+ const c = ((l = e.value) == null ? void 0 : l._id) ?? null;
359
+ if (n.value === c) return;
360
+ const u = await _.read();
361
+ s.value = r(u), n.value = c;
362
+ }
363
+ async function i(c) {
364
+ const u = await _.create(c);
365
+ s.value = r([...s.value, u]);
366
+ }
367
+ async function t(c, u) {
368
+ const l = await _.update(c, u);
369
+ s.value = r(s.value.map((d) => d.id === c ? l : d));
370
+ }
371
+ async function a(c) {
372
+ await _.delete(c), s.value = r(s.value.filter((u) => u.id !== c));
373
+ }
374
+ function r(c) {
375
+ return c.sort((u, l) => u.name.localeCompare(l.name));
376
+ }
377
+ return {
378
+ permissionSets: s,
379
+ readPermissionSets: o,
380
+ createPermissionSet: i,
381
+ updatePermissionSet: t,
382
+ deletePermissionSet: a
383
+ };
384
+ }), se = () => {
385
+ const e = ee();
386
+ return {
387
+ ...e,
388
+ ...K(e)
389
+ };
390
+ };
391
+ function X(e) {
392
+ const s = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map(), o = (i, t, a) => {
393
+ var r, c;
394
+ const u = `${t.subject}::${JSON.stringify([...t.actions].sort())}`, l = i.get(u);
395
+ if (!l) {
396
+ i.set(u, { ...t, setNames: [a.name], setId: a._id });
397
+ return;
398
+ }
399
+ if (l.setNames.push(a.name), l.conditions && t.conditions) {
400
+ const d = typeof l.conditions == "string" ? JSON.parse(l.conditions) : l.conditions, f = typeof t.conditions == "string" ? JSON.parse(t.conditions) : t.conditions;
401
+ for (const m in f)
402
+ (r = d[m]) != null && r.$in && (c = f[m]) != null && c.$in ? d[m].$in = Array.from(/* @__PURE__ */ new Set([...d[m].$in, ...f[m].$in])) : d[m] || (d[m] = f[m]);
403
+ l.conditions = JSON.stringify(d);
404
+ }
405
+ };
406
+ for (const i of e)
407
+ for (const t of i.permissions)
408
+ o(t.inverted ? n : s, t, i);
409
+ return [...Array.from(s.values()), ...Array.from(n.values())];
410
+ }
411
+ function B(e, s) {
412
+ return `${e}::${[...s].sort().join(",")}`;
413
+ }
414
+ function Q(e, s) {
415
+ const n = [...e], o = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Set(), t = /* @__PURE__ */ new Set();
416
+ for (const r of e) {
417
+ const c = I(r.subject);
418
+ o.add(B(c, r.actions)), r.inverted && r.actions.includes("manage") && i.add(`set_${c}`), !r.inverted && r.actions.includes("manage") && t.add(c);
419
+ }
420
+ const a = [...e];
421
+ for (; a.length > 0; ) {
422
+ const r = a.shift(), c = `set_${I(r.subject)}`, u = s[c];
423
+ if (!u || i.has(c) || !r.actions.includes("manage") || r.inverted) continue;
424
+ i.add(c);
425
+ const l = ne(r);
426
+ r.source && !r.source.trace && (r.source = { ...r.source, trace: l });
427
+ const d = [...l, `${u.name} (system)`];
428
+ for (const f of u.permissions ?? []) {
429
+ const m = I(f.subject), b = B(m, f.actions);
430
+ o.has(b) || t.has(m) || (o.add(b), n.push({
431
+ ...f,
432
+ // FdoPermissionRule.fields is string[] | null; RawRule expects string[] | undefined
433
+ fields: f.fields ?? void 0,
434
+ source: {
435
+ type: "systemPermissionSet",
436
+ permissionSetId: u.key,
437
+ permissionSetName: u.name,
438
+ trace: d
439
+ }
440
+ }));
441
+ }
442
+ for (const f of u.permissionSets ?? []) {
443
+ const m = I(f), b = B(m, ["manage"]), v = {
444
+ subject: m,
445
+ actions: ["manage"],
446
+ source: {
447
+ type: "systemPermissionSet",
448
+ permissionSetId: u.key,
449
+ permissionSetName: u.name,
450
+ trace: d
451
+ }
452
+ };
453
+ o.has(b) || (o.add(b), n.push(v)), a.push(v);
454
+ }
455
+ }
456
+ return [...n.filter((r) => !r.inverted), ...n.filter((r) => r.inverted)];
457
+ }
458
+ function ne(e) {
459
+ if (!e.source) return [];
460
+ const { type: s, trace: n, permissionSetName: o } = e.source;
461
+ if (n && n.length > 0) return n;
462
+ switch (s) {
463
+ case "permissionSet":
464
+ return o ? [o] : [];
465
+ case "custom":
466
+ return ["custom"];
467
+ default:
468
+ return [];
469
+ }
470
+ }
471
+ function G(e, s, n = /* @__PURE__ */ new Set()) {
472
+ var i;
473
+ const o = [];
474
+ for (const t of e) {
475
+ if (n.has(t)) continue;
476
+ n.add(t);
477
+ const a = s.find((r) => r.id === t);
478
+ a && (o.push(a), (i = a.permissionSetIds) != null && i.length && o.push(...G(a.permissionSetIds, s, n)));
479
+ }
480
+ return o;
481
+ }
482
+ function Pe(e) {
483
+ const s = X(e).map(
484
+ ({ setNames: i, setId: t, ...a }) => a
485
+ ), n = s.filter((i) => !i.inverted), o = s.filter((i) => i.inverted);
486
+ return F(n, o);
487
+ }
488
+ function we(e, s, n) {
489
+ const o = /* @__PURE__ */ new Map();
490
+ return e.forEach(
491
+ ({ name: i, permissions: t }) => t.forEach(({ conditions: a, actions: r }) => {
492
+ var u, l;
493
+ const c = JSON.parse(a || "{}");
494
+ (u = c[s]) != null && u.$in ? (l = c[s]) == null || l.$in.forEach(
495
+ (d) => (o.get(d) ?? o.set(d, /* @__PURE__ */ new Set()).get(d)).add(i)
496
+ ) : r[0] === "manage" && n.forEach((d) => {
497
+ (o.get(d) ?? o.set(d, /* @__PURE__ */ new Set()).get(d)).add(i);
498
+ });
499
+ })
500
+ ), [...o].map(([i, t]) => ({
501
+ id: i,
502
+ setNames: [...t]
503
+ }));
504
+ }
505
+ function $e(e, s) {
506
+ const n = (r, c) => {
507
+ const u = { ...r }, l = JSON.parse(u.conditions || "{}");
508
+ if (c)
509
+ if (c.length > 0) {
510
+ const d = Object.keys(l)[0];
511
+ l[d].$in = c;
512
+ } else
513
+ delete u.conditions;
514
+ return {
515
+ ...u,
516
+ inverted: !0,
517
+ ...u.conditions && { conditions: JSON.stringify(l) }
518
+ };
519
+ }, o = new Map(e.map((r) => [r.subject, r])), i = new Map(s.map((r) => [r.subject, r])), t = [], a = /* @__PURE__ */ new Set([...o.keys(), ...i.keys()]);
520
+ for (const r of a) {
521
+ const c = o.get(r), u = i.get(r);
522
+ if (c && u) {
523
+ if (c.conditions && u.conditions) {
524
+ const l = JSON.parse(c.conditions), d = JSON.parse(u.conditions), f = Object.keys(l)[0], m = l[f].$in.filter(
525
+ (v) => !d[f].$in.includes(v)
526
+ );
527
+ m.length > 0 && t.push(n(c, m)), d[f].$in.filter(
528
+ (v) => !l[f].$in.includes(v)
529
+ ).length > 0 && t.push(u);
530
+ } else if (!c.conditions && u.conditions)
531
+ t.push(u);
532
+ else if (!c.conditions && !u.conditions) {
533
+ const l = new Set(c.actions), d = new Set(u.actions), f = u.actions.some((b) => !l.has(b)), m = c.actions.filter((b) => !d.has(b));
534
+ if (f) {
535
+ const b = u.actions.filter((v) => !l.has(v));
536
+ t.push({
537
+ ...u,
538
+ actions: b
539
+ });
540
+ }
541
+ m.length > 0 && t.push({
542
+ ...c,
543
+ actions: m,
544
+ inverted: !0
545
+ });
546
+ }
547
+ continue;
548
+ }
549
+ if (c) {
550
+ t.push(
551
+ n(
552
+ c,
553
+ // If base has conditions, set diffIds to empty array, disallow all access to collection
554
+ // otherwise, invert directly
555
+ c.conditions && []
556
+ )
557
+ );
558
+ continue;
559
+ }
560
+ u && t.push(u);
561
+ }
562
+ return t;
563
+ }
564
+ function Re(e) {
565
+ const s = Q(
566
+ e,
567
+ V
568
+ ), n = new Set(
569
+ s.filter((i) => {
570
+ var t;
571
+ return ((t = i.source) == null ? void 0 : t.type) === "systemPermissionSet" && !i.inverted;
572
+ }).map((i) => i.subject)
573
+ ), o = new Set(
574
+ s.filter(
575
+ (i) => {
576
+ var t;
577
+ return ((t = i.source) == null ? void 0 : t.type) === "systemPermissionSet" && !i.inverted && i.actions.includes("manage");
578
+ }
579
+ ).map((i) => i.subject)
580
+ );
581
+ return e.filter((i) => i.inverted ? !(n.has(i.subject) && !o.has(i.subject)) : !n.has(i.subject));
582
+ }
583
+ const te = "business::report::";
584
+ function Ie(e, s) {
585
+ const n = [], o = e.filter((i) => {
586
+ const t = i.subject;
587
+ return !t.startsWith(te) || s.has(t) ? !0 : (n.push(t), !1);
588
+ });
589
+ return n.length > 0 && console.warn("[filterStalePermissions] dropped stale report permissions:", n), o;
590
+ }
591
+ const oe = "business::report::reports::", ie = "business::report::allDefaultReports", re = "business::report::allCustomReports";
592
+ function Ae(e, s) {
593
+ const n = e.find(
594
+ (a) => !a.inverted && a.subject === ie
595
+ ), o = e.find(
596
+ (a) => !a.inverted && a.subject === re
597
+ );
598
+ if (!n && !o) return e;
599
+ const i = n ? new Set(n.actions) : null, t = o ? new Set(o.actions) : null;
600
+ return e.reduce((a, r) => {
601
+ if (r.inverted)
602
+ return a.push(r), a;
603
+ const c = r.subject;
604
+ if (!c.startsWith(oe))
605
+ return a.push(r), a;
606
+ const l = s.has(c) ? i : t;
607
+ if (!l)
608
+ return a.push(r), a;
609
+ if (l.has("manage")) return a;
610
+ const d = new Set(r.actions), f = d.has("manage");
611
+ let m = !1;
612
+ for (const b of l)
613
+ b !== "manage" && d.delete(b) && (m = !0);
614
+ return f && m && d.delete("manage"), d.size === 0 || a.push({ ...r, actions: Array.from(d) }), a;
615
+ }, []);
616
+ }
617
+ function F(e, s) {
618
+ var o, i;
619
+ const n = new Map(e.map((t) => [t.subject, t]));
620
+ for (const t of s) {
621
+ if (t.inverted) {
622
+ const r = n.get(t.subject);
623
+ if (t.conditions) {
624
+ if (r != null && r.conditions) {
625
+ const c = JSON.parse(r.conditions), u = JSON.parse(t.conditions), l = Object.keys(u)[0], d = ((o = u[l]) == null ? void 0 : o.$in) ?? [], m = (((i = c[l]) == null ? void 0 : i.$in) ?? []).filter((b) => !d.includes(b));
626
+ m.length > 0 ? n.set(t.subject, {
627
+ ...r,
628
+ conditions: JSON.stringify({ [l]: { $in: m } })
629
+ }) : n.delete(t.subject);
630
+ } else
631
+ n.delete(t.subject);
632
+ continue;
633
+ }
634
+ if (r) {
635
+ const c = new Set(t.actions), u = r.actions.filter((l) => !c.has(l));
636
+ u.length > 0 ? n.set(t.subject, { ...r, actions: u }) : n.delete(t.subject);
637
+ continue;
638
+ }
639
+ continue;
640
+ }
641
+ if (t.conditions) {
642
+ n.set(t.subject, t);
643
+ continue;
644
+ }
645
+ const a = n.get(t.subject);
646
+ if (a) {
647
+ const r = [
648
+ .../* @__PURE__ */ new Set([
649
+ ...a.actions,
650
+ ...t.actions
651
+ ])
652
+ ];
653
+ n.set(t.subject, { ...a, actions: r });
654
+ } else
655
+ n.set(t.subject, t);
656
+ }
657
+ return Array.from(n.values());
658
+ }
659
+ function ae(e, s) {
660
+ const n = F(e, s), o = new Set(e.map((t) => t.subject)), i = s.filter(
661
+ (t) => t.inverted && !o.has(t.subject)
662
+ );
663
+ return [...n, ...i];
664
+ }
665
+ const y = "/permission-assignments", P = {
666
+ async readAll() {
667
+ return p(await g().get(y));
668
+ },
669
+ async readByUserId(e) {
670
+ return p(await g().get(`${y}/user/${e}`));
671
+ },
672
+ async readById(e) {
673
+ return p(await g().get(`${y}/${e}`));
674
+ },
675
+ async create(e) {
676
+ return p(await g().post(y, e));
677
+ },
678
+ async update(e, s) {
679
+ return p(await g().put(`${y}/${e}`, s));
680
+ },
681
+ async delete(e) {
682
+ return p(await g().delete(`${y}/${e}`));
683
+ },
684
+ async addReportManagePermission(e, s) {
685
+ return p(
686
+ await g().post("/my-permissions/report-manage", { permissionKey: e, label: s })
687
+ );
688
+ }
689
+ }, ce = z("permissionAssignment", () => {
690
+ const e = S([]);
691
+ async function s() {
692
+ const r = await P.readAll();
693
+ e.value = r;
694
+ }
695
+ async function n(r) {
696
+ return await P.readByUserId(r);
697
+ }
698
+ async function o(r) {
699
+ const c = await P.create(r);
700
+ e.value = [...e.value, c];
701
+ }
702
+ async function i(r, c) {
703
+ const u = await P.update(r, c);
704
+ e.value = e.value.map((l) => l.id === r ? u : l);
705
+ }
706
+ async function t(r) {
707
+ await P.delete(r), e.value = e.value.filter((c) => c.id !== r);
708
+ }
709
+ function a(r) {
710
+ return e.value.find((c) => c.userId === r);
711
+ }
712
+ return {
713
+ permissionAssignments: e,
714
+ readPermissionAssignments: s,
715
+ readPermissionAssignmentByUserId: n,
716
+ createPermissionAssignment: o,
717
+ updatePermissionAssignment: i,
718
+ deletePermissionAssignment: t,
719
+ getPermissionAssignmentByUserId: a
720
+ };
721
+ }), ue = () => {
722
+ const e = ce();
723
+ return {
724
+ ...e,
725
+ ...K(e)
726
+ };
727
+ }, le = {
728
+ async fetchReportPermissions(e, s) {
729
+ const n = s ? { lang: s } : {};
730
+ return p(
731
+ await D().get(`/report-query/hrm/${e}/reports`, { params: n })
732
+ );
733
+ },
734
+ async fetchReportPermissionsForPortal(e, s) {
735
+ const n = s ? { isSupportPos: !1, lang: s } : { isSupportPos: !1 };
736
+ return p(
737
+ await D().get(`/report-query/hrm/${e}/reports`, { params: n })
738
+ );
739
+ }
740
+ }, E = S([]), C = S(!1), w = S(!1), $ = S(null), k = S(null), N = S(!1);
741
+ function de() {
742
+ const e = L();
743
+ async function s() {
744
+ var t;
745
+ const o = (t = e.currentBusiness.value) == null ? void 0 : t.id;
746
+ if (!o) return;
747
+ const i = localStorage.getItem("locale");
748
+ if ($.value !== o && (E.value = [], C.value = !1, w.value = !1, $.value = o, N.value = !1), !(C.value && k.value === i)) {
749
+ if (w.value) {
750
+ N.value = !0;
751
+ return;
752
+ }
753
+ w.value = !0;
754
+ try {
755
+ const a = await le.fetchReportPermissionsForPortal(o, i);
756
+ if ($.value !== o) return;
757
+ E.value = a, C.value = !0, k.value = i;
758
+ } catch (a) {
759
+ if ($.value !== o) return;
760
+ console.warn("Failed to fetch custom report permissions:", a), E.value = [];
761
+ } finally {
762
+ $.value === o && (w.value = !1, N.value && (N.value = !1, await s()));
763
+ }
764
+ }
765
+ }
766
+ const n = U(() => E.value.map(
767
+ (o) => o.isDefault ? {
768
+ label: o.name,
769
+ subject: `business::report::reports::${o.permissionKey}`,
770
+ actions: [j.manage, j.read, j.create],
771
+ category: x.reports
772
+ } : {
773
+ label: o.name,
774
+ subject: `business::report::reports::${o.permissionKey}`,
775
+ actions: [
776
+ j.manage,
777
+ j.read,
778
+ j.create,
779
+ j.update,
780
+ j.delete
781
+ ],
782
+ category: x.customReports
783
+ }
784
+ ));
785
+ return {
786
+ fetchCustomReportPermissions: s,
787
+ customReportPermissions: n,
788
+ isLoading: U(() => w.value),
789
+ isLoaded: U(() => C.value)
790
+ };
791
+ }
792
+ function R(e) {
793
+ const s = L(), n = se(), o = ue(), i = s.restaurants, { customReportPermissions: t } = de(), a = o.getPermissionAssignmentByUserId(e.id), r = G(
794
+ (a == null ? void 0 : a.permissionSetIds) ?? [],
795
+ n.permissionSets.value
796
+ ), c = X(r).map(
797
+ ({ setNames: v, ...A }) => A
798
+ ), u = a == null ? void 0 : a.customPermissions, l = u ?? e.permissions.map((v) => ({
799
+ ...v,
800
+ subject: I(v.subject)
801
+ })), d = F(c, l), f = Q(
802
+ ae(c, l),
803
+ V
804
+ ).filter((v) => !v.inverted), m = fe(f), b = m ?? i.value.map((v) => v._id);
805
+ return {
806
+ doc: e,
807
+ id: e.id,
808
+ name: e.name && e.name !== e.email && e.name !== e.phoneNumber ? e.name : "-",
809
+ phoneNumber: e.phoneNumber,
810
+ email: e.email,
811
+ restaurants: W(
812
+ b.map((v) => {
813
+ var A;
814
+ return ((A = i.value.find((H) => H._id === v)) == null ? void 0 : A.profile.name) ?? "";
815
+ })
816
+ ),
817
+ managableRestaurantIds: m,
818
+ permissionLabels: be(f, t.value),
819
+ permissions: d
820
+ };
821
+ }
822
+ const me = Object.freeze(
823
+ Object.values(Z)
824
+ ), Oe = {
825
+ async readTeamMembers() {
826
+ return p(
827
+ await g().get("/portal-users")
828
+ ).map(R);
829
+ },
830
+ async readTeamMembersPage(e) {
831
+ var n, o;
832
+ const s = p(
833
+ await g().get("/portal-users/paged", {
834
+ params: {
835
+ limit: e.limit,
836
+ offset: e.offset,
837
+ search: e.search,
838
+ restaurantIds: (n = e.restaurantIds) != null && n.length ? e.restaurantIds : void 0,
839
+ permissionSubjects: (o = e.permissionSubjects) != null && o.length ? e.permissionSubjects : void 0
840
+ }
841
+ })
842
+ );
843
+ return {
844
+ items: s.items.map(R),
845
+ total: s.total
846
+ };
847
+ },
848
+ async readTeamMember(e) {
849
+ return R(
850
+ p(await g().get(`/portal-users/${e}`))
851
+ );
852
+ },
853
+ async createTeamMember(e) {
854
+ return R(
855
+ p(await g().post("/portal-users", e))
856
+ );
857
+ },
858
+ async updateTeamMember(e, s) {
859
+ return R(
860
+ p(await g().put(`/portal-users/${e}`, s))
861
+ );
862
+ },
863
+ async deleteTeamMember(e) {
864
+ return p(await g().delete(`/portal-users/${e}`));
865
+ },
866
+ async readTeamMemberPosUserIds() {
867
+ return p(await g().get("/portal-users")).map((s) => s.posUserId);
868
+ }
869
+ };
870
+ function _e(e, s, n) {
871
+ if (e.some((a) => a.subject === "all")) return "All";
872
+ const o = (n ?? J).filter(
873
+ (a) => a.subject === s
874
+ ), i = new Set(o.map((a) => T(a).value)), t = e.filter((a) => a.subject === s).filter((a) => i.has(T(a).value));
875
+ return t.length === o.length ? "All" : t.length === 0 ? "-" : `${t.length} permission allow`;
876
+ }
877
+ function T(e) {
878
+ const s = Y(e), n = s.subject;
879
+ return {
880
+ ...s,
881
+ get conditions() {
882
+ return typeof s.conditions == "string" ? JSON.parse(s.conditions) : s.conditions;
883
+ },
884
+ get isDiscountOperation() {
885
+ var o;
886
+ return n === h.F_RULE_SUBJECT.enum.order && ((o = this.conditions) == null ? void 0 : o.operation) === h.F_RULE_ORDER_OPERATION.enum.discount;
887
+ },
888
+ get isOrderOperation() {
889
+ return n === h.F_RULE_SUBJECT.enum.order;
890
+ },
891
+ get isReportPermission() {
892
+ return n === h.F_RULE_SUBJECT.enum.report;
893
+ },
894
+ get formatted() {
895
+ const o = (i) => i.endsWith("_") ? i.slice(0, i.length - 1) : i;
896
+ return this.isOrderOperation ? o(this.conditions.operation) : this.isReportPermission ? o(this.conditions.name) : n.toString();
897
+ },
898
+ get label() {
899
+ return s.label || q(this.formatted);
900
+ },
901
+ get value() {
902
+ return this.isOrderOperation ? `${n}:${this.conditions.operation}` : this.isReportPermission ? `${n}:${this.conditions.name}` : n.toString();
903
+ }
904
+ };
905
+ }
906
+ function Ee(e) {
907
+ const s = e.map((n) => T(n)).find((n) => n.isDiscountOperation);
908
+ return s ? parseInt((s.conditions.adjustment.$lte * 100).toFixed(0)) : 100;
909
+ }
910
+ function fe(e) {
911
+ const s = e.find(
912
+ (n) => n.subject === M.Subject.Restaurant.restaurant
913
+ );
914
+ return s ? s.conditions ? JSON.parse(s.conditions).restaurantId.$in : null : [];
915
+ }
916
+ function Ce(e) {
917
+ return (e == null ? void 0 : e.some((s) => s.subject === "all")) ?? !1;
918
+ }
919
+ function Ne(e) {
920
+ const s = e.find((n) => n.subject === M.Subject.Business.role);
921
+ return s ? s.conditions ? JSON.parse(s.conditions).roleId.$in : null : [];
922
+ }
923
+ function Te(e, s) {
924
+ return e.map((n) => {
925
+ const o = pe(n);
926
+ return {
927
+ subject: o.subject,
928
+ actions: o.actions,
929
+ conditions: {
930
+ ...o.conditions,
931
+ adjustment: o.isDiscountOperation ? { $lte: parseFloat((s / 100).toFixed(2)) } : void 0
932
+ }
933
+ };
934
+ });
935
+ }
936
+ function pe(e) {
937
+ const [s, n] = e.split(":");
938
+ let o;
939
+ return n ? (o = J.find(
940
+ (i) => i.subject === s && [
941
+ (typeof i.conditions == "object" ? i.conditions : JSON.parse(i.conditions)).operation,
942
+ i.conditions.name
943
+ ].includes(n)
944
+ ), !o && s === h.F_RULE_SUBJECT.enum.report && (o = {
945
+ label: "",
946
+ subject: h.F_RULE_SUBJECT.enum.report,
947
+ actions: ["read"],
948
+ conditions: { name: n },
949
+ inverted: !1,
950
+ reason: ""
951
+ })) : o = J.find((i) => i.subject === s), T(o || { subject: h.F_RULE_SUBJECT.enum.order, actions: [], label: "" });
952
+ }
953
+ function be(e, s = []) {
954
+ return W(
955
+ e.reduce((n, o) => {
956
+ const i = me.find(
957
+ (t) => t.subject === o.subject && o.actions.includes("manage")
958
+ ) || s.find((t) => t.subject === o.subject);
959
+ if (i) {
960
+ const t = i.subject === M.Subject.Business.inventory_stock ? "Warehouse Management" : i.label;
961
+ n.push(t);
962
+ }
963
+ return n;
964
+ }, [])
965
+ );
966
+ }
967
+ export {
968
+ Q as $,
969
+ le as R,
970
+ _e as a,
971
+ ae as b,
972
+ G as c,
973
+ de as d,
974
+ J as e,
975
+ Te as f,
976
+ Ee as g,
977
+ Ce as h,
978
+ te as i,
979
+ Ne as j,
980
+ Ie as k,
981
+ Ae as l,
982
+ Pe as m,
983
+ $e as n,
984
+ ue as o,
985
+ me as p,
986
+ be as q,
987
+ T as r,
988
+ Re as s,
989
+ Oe as t,
990
+ se as u,
991
+ X as v,
992
+ we as w,
993
+ fe as x
994
+ };