@feedmepos/mf-hrm-portal 2.0.25 → 2.1.0-dev.2

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 (63) hide show
  1. package/dist/AuditLogList-AGlAsWwd.js +1608 -0
  2. package/dist/ConditionFormHost.vue_vue_type_script_setup_true_lang-BYHKFwRm.js +383 -0
  3. package/dist/EmployeeList-KvjoGI87.js +884 -0
  4. package/dist/{Main-C6YMg19H.js → Main-BLh16xRg.js} +187 -184
  5. package/dist/{Main-DQg87aB2.js → Main-D3TSdtSE.js} +7 -7
  6. package/dist/{Main-CyqPnLTe.js → Main-Dn1TfDRj.js} +1033 -1029
  7. package/dist/PermissionSetList-Ds69m9UU.js +392 -0
  8. package/dist/PortalPermissionEditor.vue_vue_type_script_setup_true_lang-Bk6ub3Dv.js +4030 -0
  9. package/dist/{PortalUserSearcher.vue_vue_type_style_index_0_scoped_a439fdd8_lang-DWeS7VXx.js → PortalUserSearcher.vue_vue_type_style_index_0_scoped_a439fdd8_lang-BHxCP_uW.js} +1 -1
  10. package/dist/ResponsiveFabButton.vue_vue_type_script_setup_true_lang-QrqYEy8i.js +42 -0
  11. package/dist/RoleList-v8McRCnz.js +684 -0
  12. package/dist/Skeleton.vue_vue_type_script_setup_true_lang-B4PxNMwq.js +16 -0
  13. package/dist/{index.vue_vue_type_script_setup_true_lang-Vc5ARO29.js → TableEmptyState.vue_vue_type_script_setup_true_lang-Ci_MVqGK.js} +54 -20
  14. package/dist/TeamMemberList-BYQnNIhT.js +1169 -0
  15. package/dist/{TimesheetList-DzeE73Ns.js → TimesheetList-C1OWa6kf.js} +139 -133
  16. package/dist/{TimesheetList.vue_vue_type_style_index_0_scoped_91afda4e_lang-CTQs7MIl.js → TimesheetList.vue_vue_type_style_index_0_scoped_2c7a177a_lang-CLu9gzzi.js} +2 -2
  17. package/dist/{app-Df4eEEIU.js → app-CJouCBgi.js} +5248 -2273
  18. package/dist/app.js +1 -1
  19. package/dist/{dayjs.min-DmGoh5hw.js → dayjs.min-DUugkgDM.js} +1 -1
  20. package/dist/{employee-zWTRoOkw.js → employee-D5rEVmge.js} +3 -3
  21. package/dist/{iteration-DTV3udF0.js → iteration-QRRNYlps.js} +3 -3
  22. package/dist/{lodash-LInzVEDS.js → lodash-BlZhpHhM.js} +1 -1
  23. package/dist/rule-Dy7eMChN.js +1053 -0
  24. package/dist/src/api/audit-log/index.d.ts +6 -0
  25. package/dist/src/components/CheckboxInput.vue.d.ts +1 -1
  26. package/dist/src/components/button/ResponsiveFabButton.vue.d.ts +7 -1
  27. package/dist/src/components/table/EmptyDataTemplate/index.vue.d.ts +4 -1
  28. package/dist/src/components/table/TableEmptyState.vue.d.ts +31 -0
  29. package/dist/src/composables/useBasePermission.d.ts +1 -0
  30. package/dist/src/composables/useConditionDraft.d.ts +40 -0
  31. package/dist/src/composables/useCoverConditionOverride.d.ts +61 -0
  32. package/dist/src/helpers/business-timezone.d.ts +22 -0
  33. package/dist/src/helpers/permission-set.d.ts +4 -2
  34. package/dist/src/helpers/rule.d.ts +2 -1
  35. package/dist/src/stores/permission-set.d.ts +12 -3
  36. package/dist/src/types/audit-log.d.ts +1 -1
  37. package/dist/src/views/audit-log/event-line.d.ts +13 -0
  38. package/dist/src/views/audit-log/locales/index.d.ts +296 -0
  39. package/dist/src/views/audit-log/snapshot-diff.d.ts +11 -0
  40. package/dist/src/views/hr/employee/EmployeeList.vue.d.ts +1 -0
  41. package/dist/src/views/team/components/BasePermission.vue.d.ts +13 -0
  42. package/dist/src/views/team/condition-builders/ConditionFormHost.vue.d.ts +22 -0
  43. package/dist/src/views/team/condition-builders/ConditionFormRenderer.vue.d.ts +23 -0
  44. package/dist/src/views/team/condition-builders/component-map.d.ts +4 -0
  45. package/dist/src/views/team/condition-builders/condition-form-dedupe.d.ts +23 -0
  46. package/dist/src/views/team/locales/index.d.ts +68 -0
  47. package/dist/style.css +1 -1
  48. package/dist/tsconfig.app.tsbuildinfo +1 -1
  49. package/dist/{useAppStore-BlQSL2ZO.js → useAppStore-CtMoad7V.js} +1 -1
  50. package/dist/useDebounce-B8ZPVS5C.js +15 -0
  51. package/dist/{useLoading-NkUvAr71.js → useLoading-CNqlchYO.js} +1 -1
  52. package/dist/{useReportPermissions-R-eg1L2r.js → useReportPermissions-C5wGC9bf.js} +3 -3
  53. package/package.json +2 -2
  54. package/dist/AuditLogList-BWwgm5wH.js +0 -1145
  55. package/dist/CollapsibleWrapper.vue_vue_type_script_setup_true_lang-BLJlmPVa.js +0 -58
  56. package/dist/EmployeeList-aRGYYmxf.js +0 -851
  57. package/dist/PermissionSetList-BfKgFFUh.js +0 -356
  58. package/dist/PortalPermissionEditor.vue_vue_type_script_setup_true_lang-CNEAlTnY.js +0 -3457
  59. package/dist/ResponsiveFabButton.vue_vue_type_script_setup_true_lang-Cn-3MRBO.js +0 -38
  60. package/dist/RoleList-CtcVwAPE.js +0 -566
  61. package/dist/TeamMemberList-DU1jYeql.js +0 -1130
  62. package/dist/rule-O-E9JWJz.js +0 -995
  63. package/dist/useDebounce-CWb5QR9G.js +0 -28
@@ -0,0 +1,1053 @@
1
+ import { g as b, b as v, q as F, u as Z, s as W, d as q, e as y } from "./iteration-QRRNYlps.js";
2
+ import { h as A, P as V, d as _, v as k, n as j, b as ee } from "./app-CJouCBgi.js";
3
+ import { s as ne } 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 X } from "@feedmepos/mf-common";
7
+ const L = [
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
+ ], E = "/permission-sets", N = {
342
+ async read() {
343
+ return b(await v().get(E));
344
+ },
345
+ async create(e) {
346
+ return b(await v().post(E, e));
347
+ },
348
+ async update(e, n) {
349
+ return b(await v().put(`${E}/${e}`, n));
350
+ },
351
+ async delete(e) {
352
+ return b(await v().delete(`${E}/${e}`));
353
+ }
354
+ }, se = z("permissionSet", () => {
355
+ const { currentBusiness: e } = X(), n = S([]), t = S(!1), o = S(null);
356
+ async function i() {
357
+ var l;
358
+ const a = ((l = e.value) == null ? void 0 : l._id) ?? null;
359
+ if (o.value !== a)
360
+ try {
361
+ t.value = !0;
362
+ const d = await N.read();
363
+ n.value = u(d), o.value = a;
364
+ } finally {
365
+ t.value = !1;
366
+ }
367
+ }
368
+ async function s(a) {
369
+ const l = await N.create(a);
370
+ n.value = u([...n.value, l]);
371
+ }
372
+ async function c(a, l) {
373
+ const d = await N.update(a, l);
374
+ n.value = u(n.value.map((m) => m.id === a ? d : m));
375
+ }
376
+ async function r(a) {
377
+ await N.delete(a), n.value = u(n.value.filter((l) => l.id !== a));
378
+ }
379
+ function u(a) {
380
+ return a.sort((l, d) => l.name.localeCompare(d.name));
381
+ }
382
+ return {
383
+ permissionSets: n,
384
+ isLoading: t,
385
+ readPermissionSets: i,
386
+ createPermissionSet: s,
387
+ updatePermissionSet: c,
388
+ deletePermissionSet: r
389
+ };
390
+ }), te = () => {
391
+ const e = se();
392
+ return {
393
+ ...e,
394
+ ...K(e)
395
+ };
396
+ };
397
+ function D(e) {
398
+ if (e) {
399
+ if (typeof e == "string") {
400
+ if (e === "{}") return;
401
+ try {
402
+ return JSON.parse(e);
403
+ } catch {
404
+ return;
405
+ }
406
+ }
407
+ if (typeof e == "object")
408
+ return Object.keys(e).length > 0 ? e : void 0;
409
+ }
410
+ }
411
+ function h(e) {
412
+ return e ? Object.values(e).every(
413
+ (n) => n !== null && typeof n == "object" && !Array.isArray(n) && Object.keys(n).length === 1 && Array.isArray(n.$in)
414
+ ) : !0;
415
+ }
416
+ function Q(e) {
417
+ const n = /* @__PURE__ */ new Map(), t = /* @__PURE__ */ new Map(), o = (i, s, c) => {
418
+ var r, u;
419
+ const a = D(s.conditions);
420
+ let l = `${s.subject}::${JSON.stringify([...s.actions].sort())}`;
421
+ h(a) || (l += `::${JSON.stringify(a)}`);
422
+ const d = i.get(l);
423
+ if (!d) {
424
+ i.set(l, { ...s, setNames: [c.name], setId: c._id });
425
+ return;
426
+ }
427
+ d.setNames.push(c.name);
428
+ const m = D(d.conditions);
429
+ if (m && a) {
430
+ for (const f in a)
431
+ (r = m[f]) != null && r.$in && (u = a[f]) != null && u.$in ? m[f].$in = Array.from(
432
+ /* @__PURE__ */ new Set([...m[f].$in, ...a[f].$in])
433
+ ) : m[f] || (m[f] = a[f]);
434
+ d.conditions = JSON.stringify(m);
435
+ }
436
+ };
437
+ for (const i of e)
438
+ for (const s of i.permissions)
439
+ o(s.inverted ? t : n, s, i);
440
+ return [...Array.from(n.values()), ...Array.from(t.values())];
441
+ }
442
+ function B(e, n) {
443
+ return `${e}::${[...n].sort().join(",")}`;
444
+ }
445
+ function G(e, n) {
446
+ const t = [...e], o = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Set(), s = /* @__PURE__ */ new Set();
447
+ for (const r of e) {
448
+ const u = A(r.subject);
449
+ o.add(B(u, r.actions)), r.inverted && r.actions.includes("manage") && i.add(`set_${u}`), !r.inverted && r.actions.includes("manage") && s.add(u);
450
+ }
451
+ const c = [...e];
452
+ for (; c.length > 0; ) {
453
+ const r = c.shift(), u = `set_${A(r.subject)}`, a = n[u];
454
+ if (!a || i.has(u) || !r.actions.includes("manage") || r.inverted) continue;
455
+ i.add(u);
456
+ const l = oe(r);
457
+ r.source && !r.source.trace && (r.source = { ...r.source, trace: l });
458
+ const d = [...l, `${a.name} (system)`];
459
+ for (const m of a.permissions ?? []) {
460
+ const f = A(m.subject), p = B(f, m.actions);
461
+ o.has(p) || s.has(f) || (o.add(p), t.push({
462
+ ...m,
463
+ // FdoPermissionRule.fields is string[] | null; RawRule expects string[] | undefined
464
+ fields: m.fields ?? void 0,
465
+ source: {
466
+ type: "systemPermissionSet",
467
+ permissionSetId: a.key,
468
+ permissionSetName: a.name,
469
+ trace: d
470
+ }
471
+ }));
472
+ }
473
+ for (const m of a.permissionSets ?? []) {
474
+ const f = A(m), p = B(f, ["manage"]), g = {
475
+ subject: f,
476
+ actions: ["manage"],
477
+ source: {
478
+ type: "systemPermissionSet",
479
+ permissionSetId: a.key,
480
+ permissionSetName: a.name,
481
+ trace: d
482
+ }
483
+ };
484
+ o.has(p) || (o.add(p), t.push(g)), c.push(g);
485
+ }
486
+ }
487
+ return [...t.filter((r) => !r.inverted), ...t.filter((r) => r.inverted)];
488
+ }
489
+ function oe(e) {
490
+ if (!e.source) return [];
491
+ const { type: n, trace: t, permissionSetName: o } = e.source;
492
+ if (t && t.length > 0) return t;
493
+ switch (n) {
494
+ case "permissionSet":
495
+ return o ? [o] : [];
496
+ case "custom":
497
+ return ["custom"];
498
+ default:
499
+ return [];
500
+ }
501
+ }
502
+ function H(e, n, t = /* @__PURE__ */ new Set()) {
503
+ var i;
504
+ const o = [];
505
+ for (const s of e) {
506
+ if (t.has(s)) continue;
507
+ t.add(s);
508
+ const c = n.find((r) => r.id === s);
509
+ c && (o.push(c), (i = c.permissionSetIds) != null && i.length && o.push(...H(c.permissionSetIds, n, t)));
510
+ }
511
+ return o;
512
+ }
513
+ function $e(e) {
514
+ const n = Q(e).map(
515
+ ({ setNames: i, setId: s, ...c }) => c
516
+ ), t = n.filter((i) => !i.inverted), o = n.filter((i) => i.inverted);
517
+ return M(t, o);
518
+ }
519
+ function Ie(e, n, t) {
520
+ const o = /* @__PURE__ */ new Map();
521
+ return e.forEach(
522
+ ({ name: i, permissions: s }) => s.forEach(({ conditions: c, actions: r }) => {
523
+ var a, l;
524
+ const u = JSON.parse(c || "{}");
525
+ (a = u[n]) != null && a.$in ? (l = u[n]) == null || l.$in.forEach(
526
+ (d) => (o.get(d) ?? o.set(d, /* @__PURE__ */ new Set()).get(d)).add(i)
527
+ ) : r[0] === "manage" && t.forEach((d) => {
528
+ (o.get(d) ?? o.set(d, /* @__PURE__ */ new Set()).get(d)).add(i);
529
+ });
530
+ })
531
+ ), [...o].map(([i, s]) => ({
532
+ id: i,
533
+ setNames: [...s]
534
+ }));
535
+ }
536
+ function Ae(e, n) {
537
+ const t = (r, u) => {
538
+ const a = { ...r }, l = JSON.parse(a.conditions || "{}");
539
+ if (u)
540
+ if (u.length > 0) {
541
+ const d = Object.keys(l)[0];
542
+ l[d].$in = u;
543
+ } else
544
+ delete a.conditions;
545
+ return {
546
+ ...a,
547
+ inverted: !0,
548
+ ...a.conditions && { conditions: JSON.stringify(l) }
549
+ };
550
+ }, o = new Map(e.map((r) => [r.subject, r])), i = new Map(n.map((r) => [r.subject, r])), s = [], c = /* @__PURE__ */ new Set([...o.keys(), ...i.keys()]);
551
+ for (const r of c) {
552
+ const u = o.get(r), a = i.get(r);
553
+ if (u && a) {
554
+ if (u.conditions && a.conditions) {
555
+ const l = JSON.parse(u.conditions), d = JSON.parse(a.conditions);
556
+ if (!h(l) || !h(d)) {
557
+ JSON.stringify(l) !== JSON.stringify(d) && s.push(a);
558
+ continue;
559
+ }
560
+ const m = Object.keys(l)[0], f = l[m].$in.filter(
561
+ (g) => !d[m].$in.includes(g)
562
+ );
563
+ f.length > 0 && s.push(t(u, f)), d[m].$in.filter(
564
+ (g) => !l[m].$in.includes(g)
565
+ ).length > 0 && s.push(a);
566
+ } else if (!u.conditions && a.conditions)
567
+ s.push(a);
568
+ else if (u.conditions && !a.conditions)
569
+ h(JSON.parse(u.conditions)) || s.push(a);
570
+ else if (!u.conditions && !a.conditions) {
571
+ const l = new Set(u.actions), d = new Set(a.actions), m = a.actions.some((p) => !l.has(p)), f = u.actions.filter((p) => !d.has(p));
572
+ if (m) {
573
+ const p = a.actions.filter((g) => !l.has(g));
574
+ s.push({
575
+ ...a,
576
+ actions: p
577
+ });
578
+ }
579
+ f.length > 0 && s.push({
580
+ ...u,
581
+ actions: f,
582
+ inverted: !0
583
+ });
584
+ }
585
+ continue;
586
+ }
587
+ if (u) {
588
+ s.push(
589
+ t(
590
+ u,
591
+ // If base has conditions, set diffIds to empty array, disallow all access to collection
592
+ // otherwise, invert directly
593
+ u.conditions && []
594
+ )
595
+ );
596
+ continue;
597
+ }
598
+ a && s.push(a);
599
+ }
600
+ return s;
601
+ }
602
+ function Oe(e) {
603
+ const n = G(
604
+ e,
605
+ V
606
+ ), t = new Set(
607
+ n.filter((i) => {
608
+ var s;
609
+ return ((s = i.source) == null ? void 0 : s.type) === "systemPermissionSet" && !i.inverted;
610
+ }).map((i) => i.subject)
611
+ ), o = new Set(
612
+ n.filter(
613
+ (i) => {
614
+ var s;
615
+ return ((s = i.source) == null ? void 0 : s.type) === "systemPermissionSet" && !i.inverted && i.actions.includes("manage");
616
+ }
617
+ ).map((i) => i.subject)
618
+ );
619
+ return e.filter((i) => i.inverted ? !(t.has(i.subject) && !o.has(i.subject)) : !t.has(i.subject));
620
+ }
621
+ const ie = "business::report::";
622
+ function _e(e, n) {
623
+ const t = [], o = e.filter((i) => {
624
+ const s = i.subject;
625
+ return !s.startsWith(ie) || n.has(s) ? !0 : (t.push(s), !1);
626
+ });
627
+ return t.length > 0 && console.warn("[filterStalePermissions] dropped stale report permissions:", t), o;
628
+ }
629
+ const re = "business::report::reports::", ae = _.Subject.Business.report_reports_allDefaultReports, ce = _.Subject.Business.report_reports_allCustomReports;
630
+ function ue(e, n) {
631
+ return e.conditions ? !!n.conditions && e.conditions === n.conditions : !n.conditions;
632
+ }
633
+ function Ee(e, n) {
634
+ const t = e.find(
635
+ (c) => !c.inverted && c.subject === ae
636
+ ), o = e.find(
637
+ (c) => !c.inverted && c.subject === ce
638
+ );
639
+ if (!t && !o) return e;
640
+ const i = t ? new Set(t.actions) : null, s = o ? new Set(o.actions) : null;
641
+ return e.reduce((c, r) => {
642
+ if (r.inverted)
643
+ return c.push(r), c;
644
+ const u = r.subject;
645
+ if (!u.startsWith(re))
646
+ return c.push(r), c;
647
+ const a = n.has(u), l = a ? i : s, d = a ? t : o;
648
+ if (!l || !d || !ue(d, r))
649
+ return c.push(r), c;
650
+ if (l.has("manage")) return c;
651
+ const m = new Set(r.actions), f = m.has("manage");
652
+ let p = !1;
653
+ for (const g of l)
654
+ g !== "manage" && m.delete(g) && (p = !0);
655
+ return f && p && m.delete("manage"), m.size === 0 || c.push({ ...r, actions: Array.from(m) }), c;
656
+ }, []);
657
+ }
658
+ function M(e, n) {
659
+ var o, i;
660
+ const t = new Map(e.map((s) => [s.subject, s]));
661
+ for (const s of n) {
662
+ if (s.inverted) {
663
+ const r = t.get(s.subject);
664
+ if (s.conditions) {
665
+ if (r != null && r.conditions) {
666
+ const u = JSON.parse(r.conditions), a = JSON.parse(s.conditions);
667
+ if (!h(u) || !h(a)) {
668
+ t.delete(s.subject);
669
+ continue;
670
+ }
671
+ const l = Object.keys(a)[0], d = ((o = a[l]) == null ? void 0 : o.$in) ?? [], f = (((i = u[l]) == null ? void 0 : i.$in) ?? []).filter((p) => !d.includes(p));
672
+ f.length > 0 ? t.set(s.subject, {
673
+ ...r,
674
+ conditions: JSON.stringify({ [l]: { $in: f } })
675
+ }) : t.delete(s.subject);
676
+ } else
677
+ t.delete(s.subject);
678
+ continue;
679
+ }
680
+ if (r) {
681
+ const u = new Set(s.actions), a = r.actions.filter((l) => !u.has(l));
682
+ a.length > 0 ? t.set(s.subject, { ...r, actions: a }) : t.delete(s.subject);
683
+ continue;
684
+ }
685
+ continue;
686
+ }
687
+ if (s.conditions) {
688
+ t.set(s.subject, s);
689
+ continue;
690
+ }
691
+ const c = t.get(s.subject);
692
+ if (c != null && c.conditions && !h(JSON.parse(c.conditions))) {
693
+ t.set(s.subject, s);
694
+ continue;
695
+ }
696
+ if (c) {
697
+ const r = [
698
+ .../* @__PURE__ */ new Set([
699
+ ...c.actions,
700
+ ...s.actions
701
+ ])
702
+ ];
703
+ t.set(s.subject, { ...c, actions: r });
704
+ } else
705
+ t.set(s.subject, s);
706
+ }
707
+ return Array.from(t.values());
708
+ }
709
+ function le(e, n) {
710
+ const t = M(e, n), o = new Set(e.map((s) => s.subject)), i = n.filter(
711
+ (s) => s.inverted && !o.has(s.subject)
712
+ );
713
+ return [...t, ...i];
714
+ }
715
+ const P = "/permission-assignments", w = {
716
+ async readAll() {
717
+ return b(await v().get(P));
718
+ },
719
+ async readByUserId(e) {
720
+ return b(await v().get(`${P}/user/${e}`));
721
+ },
722
+ async readById(e) {
723
+ return b(await v().get(`${P}/${e}`));
724
+ },
725
+ async create(e) {
726
+ return b(await v().post(P, e));
727
+ },
728
+ async update(e, n) {
729
+ return b(await v().put(`${P}/${e}`, n));
730
+ },
731
+ async delete(e) {
732
+ return b(await v().delete(`${P}/${e}`));
733
+ },
734
+ async addReportManagePermission(e, n) {
735
+ return b(
736
+ await v().post("/my-permissions/report-manage", { permissionKey: e, label: n })
737
+ );
738
+ }
739
+ }, de = z("permissionAssignment", () => {
740
+ const e = S([]);
741
+ async function n() {
742
+ const r = await w.readAll();
743
+ e.value = r;
744
+ }
745
+ async function t(r) {
746
+ return await w.readByUserId(r);
747
+ }
748
+ async function o(r) {
749
+ const u = await w.create(r);
750
+ e.value = [...e.value, u];
751
+ }
752
+ async function i(r, u) {
753
+ const a = await w.update(r, u);
754
+ e.value = e.value.map((l) => l.id === r ? a : l);
755
+ }
756
+ async function s(r) {
757
+ await w.delete(r), e.value = e.value.filter((u) => u.id !== r);
758
+ }
759
+ function c(r) {
760
+ return e.value.find((u) => u.userId === r);
761
+ }
762
+ return {
763
+ permissionAssignments: e,
764
+ readPermissionAssignments: n,
765
+ readPermissionAssignmentByUserId: t,
766
+ createPermissionAssignment: o,
767
+ updatePermissionAssignment: i,
768
+ deletePermissionAssignment: s,
769
+ getPermissionAssignmentByUserId: c
770
+ };
771
+ }), me = () => {
772
+ const e = de();
773
+ return {
774
+ ...e,
775
+ ...K(e)
776
+ };
777
+ }, fe = {
778
+ async fetchReportPermissions(e, n) {
779
+ const t = n ? { lang: n } : {};
780
+ return b(
781
+ await F().get(`/report-query/hrm/${e}/reports`, { params: t })
782
+ );
783
+ },
784
+ async fetchReportPermissionsForPortal(e, n) {
785
+ const t = n ? { isSupportPos: !1, lang: n } : { isSupportPos: !1 };
786
+ return b(
787
+ await F().get(`/report-query/hrm/${e}/reports`, { params: t })
788
+ );
789
+ }
790
+ }, T = S([]), C = S(!1), R = S(!1), $ = S(null), x = S(null), J = S(!1);
791
+ function pe() {
792
+ const e = X();
793
+ async function n() {
794
+ var s;
795
+ const o = (s = e.currentBusiness.value) == null ? void 0 : s.id;
796
+ if (!o) return;
797
+ const i = localStorage.getItem("locale");
798
+ if ($.value !== o && (T.value = [], C.value = !1, R.value = !1, $.value = o, J.value = !1), !(C.value && x.value === i)) {
799
+ if (R.value) {
800
+ J.value = !0;
801
+ return;
802
+ }
803
+ R.value = !0;
804
+ try {
805
+ const c = await fe.fetchReportPermissionsForPortal(o, i);
806
+ if ($.value !== o) return;
807
+ T.value = c, C.value = !0, x.value = i;
808
+ } catch (c) {
809
+ if ($.value !== o) return;
810
+ console.warn("Failed to fetch custom report permissions:", c), T.value = [];
811
+ } finally {
812
+ $.value === o && (R.value = !1, J.value && (J.value = !1, await n()));
813
+ }
814
+ }
815
+ }
816
+ const t = U(() => T.value.map(
817
+ (o) => o.isDefault ? {
818
+ label: o.name,
819
+ subject: `business::report::reports::${o.permissionKey}`,
820
+ actions: [j.manage, j.read, j.create],
821
+ category: k.reports
822
+ } : {
823
+ label: o.name,
824
+ subject: `business::report::reports::${o.permissionKey}`,
825
+ actions: [
826
+ j.manage,
827
+ j.read,
828
+ j.create,
829
+ j.update,
830
+ j.delete
831
+ ],
832
+ category: k.customReports
833
+ }
834
+ ));
835
+ return {
836
+ fetchCustomReportPermissions: n,
837
+ customReportPermissions: t,
838
+ isLoading: U(() => R.value),
839
+ isLoaded: U(() => C.value)
840
+ };
841
+ }
842
+ function I(e) {
843
+ const n = te(), t = me(), o = Z().restaurants, { customReportPermissions: i } = pe(), s = t.getPermissionAssignmentByUserId(e.id), c = H(
844
+ (s == null ? void 0 : s.permissionSetIds) ?? [],
845
+ n.permissionSets.value
846
+ ), r = Q(c).map(
847
+ ({ setNames: p, ...g }) => g
848
+ ), u = s == null ? void 0 : s.customPermissions, a = u ?? e.permissions.map((p) => ({
849
+ ...p,
850
+ subject: A(p.subject)
851
+ })), l = M(r, a), d = G(
852
+ le(r, a),
853
+ V
854
+ ).filter((p) => !p.inverted), m = ve(d), f = m ?? o.value.map((p) => p._id);
855
+ return {
856
+ doc: e,
857
+ id: e.id,
858
+ name: e.name && e.name !== e.email && e.name !== e.phoneNumber ? e.name : "-",
859
+ phoneNumber: e.phoneNumber,
860
+ email: e.email,
861
+ restaurants: W(
862
+ f.map((p) => {
863
+ var g;
864
+ return ((g = o.value.find((Y) => Y._id === p)) == null ? void 0 : g.profile.name) ?? "";
865
+ })
866
+ ),
867
+ managableRestaurantIds: m,
868
+ permissionLabels: Se(d, i.value),
869
+ permissions: l
870
+ };
871
+ }
872
+ const be = Object.freeze(
873
+ Object.values(ee)
874
+ ), Ne = {
875
+ async readTeamMembers() {
876
+ return b(
877
+ await v().get("/portal-users")
878
+ ).map(I);
879
+ },
880
+ async readTeamMembersPage(e) {
881
+ var t, o, i;
882
+ const n = b(
883
+ await v().get("/portal-users/paged", {
884
+ params: {
885
+ limit: e.limit,
886
+ offset: e.offset,
887
+ search: e.search,
888
+ restaurantIds: (t = e.restaurantIds) != null && t.length ? e.restaurantIds : void 0,
889
+ permissionSubjects: (o = e.permissionSubjects) != null && o.length ? e.permissionSubjects : void 0,
890
+ permissionSetIds: (i = e.permissionSetIds) != null && i.length ? e.permissionSetIds : void 0
891
+ }
892
+ })
893
+ );
894
+ return {
895
+ items: n.items.map(I),
896
+ total: n.total
897
+ };
898
+ },
899
+ async readTeamMember(e) {
900
+ return I(
901
+ b(await v().get(`/portal-users/${e}`))
902
+ );
903
+ },
904
+ async createTeamMember(e) {
905
+ return I(
906
+ b(await v().post("/portal-users", e))
907
+ );
908
+ },
909
+ async updateTeamMember(e, n) {
910
+ return I(
911
+ b(await v().put(`/portal-users/${e}`, n))
912
+ );
913
+ },
914
+ async deleteTeamMember(e) {
915
+ return b(await v().delete(`/portal-users/${e}`));
916
+ },
917
+ async readTeamMemberPosUserIds() {
918
+ return b(await v().get("/portal-users")).map((n) => n.posUserId);
919
+ }
920
+ };
921
+ function Te(e, n, t) {
922
+ if (e.some((c) => c.subject === "all")) return "All";
923
+ const o = (t ?? L).filter(
924
+ (c) => c.subject === n
925
+ ), i = new Set(o.map((c) => O(c).value)), s = e.filter((c) => c.subject === n).filter((c) => i.has(O(c).value));
926
+ return s.length === o.length ? "All" : s.length === 0 ? "-" : `${s.length} permission allow`;
927
+ }
928
+ function O(e) {
929
+ const n = q(e), t = n.subject;
930
+ return {
931
+ ...n,
932
+ get conditions() {
933
+ return typeof n.conditions == "string" ? JSON.parse(n.conditions) : n.conditions;
934
+ },
935
+ get isDiscountOperation() {
936
+ var o;
937
+ return t === y.F_RULE_SUBJECT.enum.order && ((o = this.conditions) == null ? void 0 : o.operation) === y.F_RULE_ORDER_OPERATION.enum.discount;
938
+ },
939
+ get isOrderOperation() {
940
+ return t === y.F_RULE_SUBJECT.enum.order;
941
+ },
942
+ get isReportPermission() {
943
+ return t === y.F_RULE_SUBJECT.enum.report;
944
+ },
945
+ get formatted() {
946
+ const o = (i) => i.endsWith("_") ? i.slice(0, i.length - 1) : i;
947
+ return this.isOrderOperation ? o(this.conditions.operation) : this.isReportPermission ? o(this.conditions.name) : t.toString();
948
+ },
949
+ get label() {
950
+ return n.label || ne(this.formatted);
951
+ },
952
+ get value() {
953
+ return this.isOrderOperation ? `${t}:${this.conditions.operation}` : this.isReportPermission ? `${t}:${this.conditions.name}` : t.toString();
954
+ }
955
+ };
956
+ }
957
+ function Ce(e) {
958
+ const n = e.map((t) => O(t)).find((t) => t.isDiscountOperation);
959
+ return n ? parseInt((n.conditions.adjustment.$lte * 100).toFixed(0)) : 100;
960
+ }
961
+ function ve(e) {
962
+ const n = e.find(
963
+ (t) => t.subject === _.Subject.Restaurant.restaurant
964
+ );
965
+ return n ? n.conditions ? JSON.parse(n.conditions).restaurantId.$in : null : [];
966
+ }
967
+ function Je(e) {
968
+ return (e == null ? void 0 : e.some((n) => n.subject === "all")) ?? !1;
969
+ }
970
+ function Ue(e) {
971
+ const n = e.find((t) => t.subject === _.Subject.Business.role);
972
+ return n ? n.conditions ? JSON.parse(n.conditions).roleId.$in : null : [];
973
+ }
974
+ function Be(e) {
975
+ const n = O(e);
976
+ if (!n.isReportPermission) return;
977
+ const { name: t, ...o } = n.conditions ?? {};
978
+ return Object.keys(o).length > 0 ? o : void 0;
979
+ }
980
+ function Le(e, n, t) {
981
+ return e.map((o) => {
982
+ const i = ge(o), s = i.isReportPermission ? t == null ? void 0 : t.get(o) : void 0;
983
+ return {
984
+ subject: i.subject,
985
+ actions: i.actions,
986
+ conditions: {
987
+ ...i.conditions,
988
+ ...s ?? {},
989
+ adjustment: i.isDiscountOperation ? { $lte: parseFloat((n / 100).toFixed(2)) } : void 0
990
+ }
991
+ };
992
+ });
993
+ }
994
+ function ge(e) {
995
+ const [n, t] = e.split(":");
996
+ let o;
997
+ return t ? (o = L.find(
998
+ (i) => i.subject === n && [
999
+ (typeof i.conditions == "object" ? i.conditions : JSON.parse(i.conditions)).operation,
1000
+ i.conditions.name
1001
+ ].includes(t)
1002
+ ), !o && n === y.F_RULE_SUBJECT.enum.report && (o = {
1003
+ label: "",
1004
+ subject: y.F_RULE_SUBJECT.enum.report,
1005
+ actions: ["read"],
1006
+ conditions: { name: t },
1007
+ inverted: !1,
1008
+ reason: ""
1009
+ })) : o = L.find((i) => i.subject === n), O(o || { subject: y.F_RULE_SUBJECT.enum.order, actions: [], label: "" });
1010
+ }
1011
+ function Se(e, n = []) {
1012
+ return W(
1013
+ e.reduce((t, o) => {
1014
+ const i = be.find(
1015
+ (s) => s.subject === o.subject && o.actions.includes("manage")
1016
+ ) || n.find((s) => s.subject === o.subject);
1017
+ if (i) {
1018
+ const s = i.subject === _.Subject.Business.inventory_stock ? "Warehouse Management" : i.label;
1019
+ t.push(s);
1020
+ }
1021
+ return t;
1022
+ }, [])
1023
+ );
1024
+ }
1025
+ export {
1026
+ G as N,
1027
+ Q as P,
1028
+ fe as R,
1029
+ Be as a,
1030
+ Te as b,
1031
+ H as c,
1032
+ le as d,
1033
+ L as e,
1034
+ Le as f,
1035
+ Ce as g,
1036
+ Je as h,
1037
+ pe as i,
1038
+ ie as j,
1039
+ Ue as k,
1040
+ ve as l,
1041
+ $e as m,
1042
+ _e as n,
1043
+ Ee as o,
1044
+ be as p,
1045
+ Ae as q,
1046
+ O as r,
1047
+ Oe as s,
1048
+ Ne as t,
1049
+ te as u,
1050
+ me as v,
1051
+ Se as w,
1052
+ Ie as x
1053
+ };