@feedmepos/mf-hrm-portal 2.0.15-dev → 2.0.15-dev.3

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 (36) hide show
  1. package/dist/{AuditLogList-DBIsI4YF.js → AuditLogList-eyzJecZc.js} +4 -4
  2. package/dist/EmployeeList-QibdsTN-.js +736 -0
  3. package/dist/{Main-BAZAQTWi.js → Main-B_QCpWOx.js} +4 -4
  4. package/dist/{Main-D7yzD5SW.js → Main-Bjfm9a6M.js} +5 -5
  5. package/dist/{Main-B3YiMuFq.js → Main-DX1aet8y.js} +1298 -1294
  6. package/dist/{PermissionSetList-DBT9LtfT.js → PermissionSetList-fE9Zfrl6.js} +30 -30
  7. package/dist/{PortalPermissionEditor.vue_vue_type_script_setup_true_lang-BfqnjeTK.js → PortalPermissionEditor.vue_vue_type_script_setup_true_lang-JpCfRxA9.js} +500 -500
  8. package/dist/RoleList-ByXZemFz.js +528 -0
  9. package/dist/{TeamMemberList-BCv5Vixx.js → TeamMemberList-D-_icv19.js} +327 -324
  10. package/dist/{TimesheetList-DpMBgVtY.js → TimesheetList-DVvz6id4.js} +7 -7
  11. package/dist/{app-pvHHFjbx.js → app-DJG3HGqG.js} +220 -261
  12. package/dist/app.js +2 -2
  13. package/dist/{dayjs.min-BK_bM9xY.js → dayjs.min-CN6o-ax9.js} +1 -1
  14. package/dist/{employee-DhkixwiI.js → employee-CU-G-rAZ.js} +71 -74
  15. package/dist/{index-DK4fVbTF.js → index-ynxje0mm.js} +1 -1
  16. package/dist/{iteration-Bk3cnP07.js → iteration-C6Km_Rno.js} +1 -1
  17. package/dist/{lodash-TrOlqj07.js → lodash-DZvG4gEx.js} +1 -1
  18. package/dist/rule-X41LxaES.js +991 -0
  19. package/dist/src/helpers/rule.d.ts +1 -1
  20. package/dist/src/stores/employee.d.ts +124 -19
  21. package/dist/src/types/employee.d.ts +3 -0
  22. package/dist/src/views/hr/employee/EmployeeList.vue.d.ts +4 -0
  23. package/dist/style.css +1 -1
  24. package/dist/{timesheet-DSQeCVfL.js → timesheet-DUtxTIA4.js} +9 -9
  25. package/dist/tsconfig.app.tsbuildinfo +1 -1
  26. package/dist/useAppStore-CrUYEAtX.js +171 -0
  27. package/dist/useDiscardConfirm-BHni0LNu.js +28 -0
  28. package/dist/{useLoading-fEAOlgoV.js → useLoading-hGUqfW4U.js} +1 -1
  29. package/dist/{useReportPermissions-CkOk_2tl.js → useReportPermissions-BgTdISQy.js} +3 -3
  30. package/dist/utils-BZkjJbju.js +17 -0
  31. package/package.json +1 -1
  32. package/dist/EmployeeList-BOSxLZbY.js +0 -702
  33. package/dist/RoleList-DeE5tN-5.js +0 -519
  34. package/dist/index-Bckj5jnu.js +0 -998
  35. package/dist/useAppStore-DwfwjZpc.js +0 -168
  36. package/dist/useRestaurantMap-e9fQJiLC.js +0 -39
@@ -0,0 +1,991 @@
1
+ import { g as b, b as v, q as L, s as D, d as Q, e as h } from "./iteration-C6Km_Rno.js";
2
+ import { b as I, A as x, p as F, e as S, C as G, u as J } from "./app-DJG3HGqG.js";
3
+ import { s as H } from "./utils-BZkjJbju.js";
4
+ import { defineStore as k, storeToRefs as W } from "pinia";
5
+ import { ref as j, computed as T } from "vue";
6
+ import { useCoreStore as N } from "@feedmepos/mf-common";
7
+ const B = [
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
+ ], A = "/permission-sets", _ = {
342
+ async read() {
343
+ return b(await v().get(A));
344
+ },
345
+ async create(e) {
346
+ return b(await v().post(A, e));
347
+ },
348
+ async update(e, s) {
349
+ return b(await v().put(`${A}/${e}`, s));
350
+ },
351
+ async delete(e) {
352
+ return b(await v().delete(`${A}/${e}`));
353
+ }
354
+ }, Y = k("permissionSet", () => {
355
+ const { currentBusiness: e } = N(), s = j([]), t = j(null);
356
+ async function o() {
357
+ var l;
358
+ const u = ((l = e.value) == null ? void 0 : l._id) ?? null;
359
+ if (t.value === u) return;
360
+ const r = await _.read();
361
+ s.value = a(r), t.value = u;
362
+ }
363
+ async function i(u) {
364
+ const r = await _.create(u);
365
+ s.value = a([...s.value, r]);
366
+ }
367
+ async function n(u, r) {
368
+ const l = await _.update(u, r);
369
+ s.value = a(s.value.map((d) => d.id === u ? l : d));
370
+ }
371
+ async function c(u) {
372
+ await _.delete(u), s.value = a(s.value.filter((r) => r.id !== u));
373
+ }
374
+ function a(u) {
375
+ return u.sort((r, l) => r.name.localeCompare(l.name));
376
+ }
377
+ return {
378
+ permissionSets: s,
379
+ readPermissionSets: o,
380
+ createPermissionSet: i,
381
+ updatePermissionSet: n,
382
+ deletePermissionSet: c
383
+ };
384
+ }), Z = () => {
385
+ const e = Y();
386
+ return {
387
+ ...e,
388
+ ...W(e)
389
+ };
390
+ };
391
+ function V(e) {
392
+ const s = /* @__PURE__ */ new Map(), t = /* @__PURE__ */ new Map(), o = (i, n, c) => {
393
+ var a, u;
394
+ const r = `${n.subject}::${JSON.stringify([...n.actions].sort())}`, l = i.get(r);
395
+ if (!l) {
396
+ i.set(r, { ...n, setNames: [c.name], setId: c._id });
397
+ return;
398
+ }
399
+ if (l.setNames.push(c.name), l.conditions && n.conditions) {
400
+ const d = typeof l.conditions == "string" ? JSON.parse(l.conditions) : l.conditions, f = typeof n.conditions == "string" ? JSON.parse(n.conditions) : n.conditions;
401
+ for (const m in f)
402
+ (a = d[m]) != null && a.$in && (u = f[m]) != null && u.$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 n of i.permissions)
408
+ o(n.inverted ? t : s, n, i);
409
+ return [...Array.from(s.values()), ...Array.from(t.values())];
410
+ }
411
+ function U(e, s) {
412
+ return `${e}::${[...s].sort().join(",")}`;
413
+ }
414
+ function z(e, s) {
415
+ const t = [...e], o = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Set(), n = /* @__PURE__ */ new Set();
416
+ for (const a of e) {
417
+ const u = I(a.subject);
418
+ o.add(U(u, a.actions)), a.inverted && a.actions.includes("manage") && i.add(`set_${u}`), !a.inverted && a.actions.includes("manage") && n.add(u);
419
+ }
420
+ const c = [...e];
421
+ for (; c.length > 0; ) {
422
+ const a = c.shift(), u = `set_${I(a.subject)}`, r = s[u];
423
+ if (!r || i.has(u) || !a.actions.includes("manage") || a.inverted) continue;
424
+ i.add(u);
425
+ const l = q(a);
426
+ a.source && !a.source.trace && (a.source = { ...a.source, trace: l });
427
+ const d = [...l, `${r.name} (system)`];
428
+ for (const f of r.permissions ?? []) {
429
+ const m = I(f.subject), p = U(m, f.actions);
430
+ o.has(p) || n.has(m) || (o.add(p), t.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: r.key,
437
+ permissionSetName: r.name,
438
+ trace: d
439
+ }
440
+ }));
441
+ }
442
+ for (const f of r.permissionSets ?? []) {
443
+ const m = I(f), p = U(m, ["manage"]), g = {
444
+ subject: m,
445
+ actions: ["manage"],
446
+ source: {
447
+ type: "systemPermissionSet",
448
+ permissionSetId: r.key,
449
+ permissionSetName: r.name,
450
+ trace: d
451
+ }
452
+ };
453
+ o.has(p) || (o.add(p), t.push(g)), c.push(g);
454
+ }
455
+ }
456
+ return [...t.filter((a) => !a.inverted), ...t.filter((a) => a.inverted)];
457
+ }
458
+ function q(e) {
459
+ if (!e.source) return [];
460
+ const { type: s, trace: t, permissionSetName: o } = e.source;
461
+ if (t && t.length > 0) return t;
462
+ switch (s) {
463
+ case "permissionSet":
464
+ return o ? [o] : [];
465
+ case "custom":
466
+ return ["custom"];
467
+ default:
468
+ return [];
469
+ }
470
+ }
471
+ function K(e, s, t = /* @__PURE__ */ new Set()) {
472
+ var i;
473
+ const o = [];
474
+ for (const n of e) {
475
+ if (t.has(n)) continue;
476
+ t.add(n);
477
+ const c = s.find((a) => a.id === n);
478
+ c && (o.push(c), (i = c.permissionSetIds) != null && i.length && o.push(...K(c.permissionSetIds, s, t)));
479
+ }
480
+ return o;
481
+ }
482
+ function je(e) {
483
+ const s = V(e).map(
484
+ ({ setNames: i, setId: n, ...c }) => c
485
+ ), t = s.filter((i) => !i.inverted), o = s.filter((i) => i.inverted);
486
+ return M(t, o);
487
+ }
488
+ function he(e, s, t) {
489
+ const o = /* @__PURE__ */ new Map();
490
+ return e.forEach(
491
+ ({ name: i, permissions: n }) => n.forEach(({ conditions: c, actions: a }) => {
492
+ var r, l;
493
+ const u = JSON.parse(c || "{}");
494
+ (r = u[s]) != null && r.$in ? (l = u[s]) == null || l.$in.forEach(
495
+ (d) => (o.get(d) ?? o.set(d, /* @__PURE__ */ new Set()).get(d)).add(i)
496
+ ) : a[0] === "manage" && t.forEach((d) => {
497
+ (o.get(d) ?? o.set(d, /* @__PURE__ */ new Set()).get(d)).add(i);
498
+ });
499
+ })
500
+ ), [...o].map(([i, n]) => ({
501
+ id: i,
502
+ setNames: [...n]
503
+ }));
504
+ }
505
+ function ye(e, s) {
506
+ const t = (a, u) => {
507
+ const r = { ...a }, l = JSON.parse(r.conditions || "{}");
508
+ if (u)
509
+ if (u.length > 0) {
510
+ const d = Object.keys(l)[0];
511
+ l[d].$in = u;
512
+ } else
513
+ delete r.conditions;
514
+ return {
515
+ ...r,
516
+ inverted: !0,
517
+ ...r.conditions && { conditions: JSON.stringify(l) }
518
+ };
519
+ }, o = new Map(e.map((a) => [a.subject, a])), i = new Map(s.map((a) => [a.subject, a])), n = [], c = /* @__PURE__ */ new Set([...o.keys(), ...i.keys()]);
520
+ for (const a of c) {
521
+ const u = o.get(a), r = i.get(a);
522
+ if (u && r) {
523
+ if (u.conditions && r.conditions) {
524
+ const l = JSON.parse(u.conditions), d = JSON.parse(r.conditions), f = Object.keys(l)[0], m = l[f].$in.filter(
525
+ (g) => !d[f].$in.includes(g)
526
+ );
527
+ m.length > 0 && n.push(t(u, m)), d[f].$in.filter(
528
+ (g) => !l[f].$in.includes(g)
529
+ ).length > 0 && n.push(r);
530
+ } else if (!u.conditions && r.conditions)
531
+ n.push(r);
532
+ else if (!u.conditions && !r.conditions) {
533
+ const l = new Set(u.actions), d = new Set(r.actions), f = r.actions.some((p) => !l.has(p)), m = u.actions.filter((p) => !d.has(p));
534
+ if (f) {
535
+ const p = r.actions.filter((g) => !l.has(g));
536
+ n.push({
537
+ ...r,
538
+ actions: p
539
+ });
540
+ }
541
+ m.length > 0 && n.push({
542
+ ...u,
543
+ actions: m,
544
+ inverted: !0
545
+ });
546
+ }
547
+ continue;
548
+ }
549
+ if (u) {
550
+ n.push(
551
+ t(
552
+ u,
553
+ // If base has conditions, set diffIds to empty array, disallow all access to collection
554
+ // otherwise, invert directly
555
+ u.conditions && []
556
+ )
557
+ );
558
+ continue;
559
+ }
560
+ r && n.push(r);
561
+ }
562
+ return n;
563
+ }
564
+ function Pe(e) {
565
+ const s = z(
566
+ e,
567
+ x
568
+ ), t = new Set(
569
+ s.filter((i) => {
570
+ var n;
571
+ return ((n = i.source) == null ? void 0 : n.type) === "systemPermissionSet" && !i.inverted;
572
+ }).map((i) => i.subject)
573
+ ), o = new Set(
574
+ s.filter(
575
+ (i) => {
576
+ var n;
577
+ return ((n = i.source) == null ? void 0 : n.type) === "systemPermissionSet" && !i.inverted && i.actions.includes("manage");
578
+ }
579
+ ).map((i) => i.subject)
580
+ );
581
+ return e.filter((i) => i.inverted ? !(t.has(i.subject) && !o.has(i.subject)) : !t.has(i.subject));
582
+ }
583
+ const ee = "business::report::";
584
+ function we(e, s) {
585
+ const t = [], o = e.filter((i) => {
586
+ const n = i.subject;
587
+ return !n.startsWith(ee) || s.has(n) ? !0 : (t.push(n), !1);
588
+ });
589
+ return t.length > 0 && console.warn("[filterStalePermissions] dropped stale report permissions:", t), o;
590
+ }
591
+ const se = "business::report::reports::", ne = "business::report::allDefaultReports", te = "business::report::allCustomReports";
592
+ function $e(e, s) {
593
+ const t = e.find(
594
+ (c) => !c.inverted && c.subject === ne
595
+ ), o = e.find(
596
+ (c) => !c.inverted && c.subject === te
597
+ );
598
+ if (!t && !o) return e;
599
+ const i = t ? new Set(t.actions) : null, n = o ? new Set(o.actions) : null;
600
+ return e.reduce((c, a) => {
601
+ if (a.inverted)
602
+ return c.push(a), c;
603
+ const u = a.subject;
604
+ if (!u.startsWith(se))
605
+ return c.push(a), c;
606
+ const l = s.has(u) ? i : n;
607
+ if (!l)
608
+ return c.push(a), c;
609
+ if (l.has("manage")) return c;
610
+ const d = new Set(a.actions), f = d.has("manage");
611
+ let m = !1;
612
+ for (const p of l)
613
+ p !== "manage" && d.delete(p) && (m = !0);
614
+ return f && m && d.delete("manage"), d.size === 0 || c.push({ ...a, actions: Array.from(d) }), c;
615
+ }, []);
616
+ }
617
+ function M(e, s) {
618
+ var o, i;
619
+ const t = new Map(e.map((n) => [n.subject, n]));
620
+ for (const n of s) {
621
+ if (n.inverted) {
622
+ const a = t.get(n.subject);
623
+ if (n.conditions) {
624
+ if (a != null && a.conditions) {
625
+ const u = JSON.parse(a.conditions), r = JSON.parse(n.conditions), l = Object.keys(r)[0], d = ((o = r[l]) == null ? void 0 : o.$in) ?? [], m = (((i = u[l]) == null ? void 0 : i.$in) ?? []).filter((p) => !d.includes(p));
626
+ m.length > 0 ? t.set(n.subject, {
627
+ ...a,
628
+ conditions: JSON.stringify({ [l]: { $in: m } })
629
+ }) : t.delete(n.subject);
630
+ } else
631
+ t.delete(n.subject);
632
+ continue;
633
+ }
634
+ if (a) {
635
+ const u = new Set(n.actions), r = a.actions.filter((l) => !u.has(l));
636
+ r.length > 0 ? t.set(n.subject, { ...a, actions: r }) : t.delete(n.subject);
637
+ continue;
638
+ }
639
+ continue;
640
+ }
641
+ if (n.conditions) {
642
+ t.set(n.subject, n);
643
+ continue;
644
+ }
645
+ const c = t.get(n.subject);
646
+ if (c) {
647
+ const a = [
648
+ .../* @__PURE__ */ new Set([
649
+ ...c.actions,
650
+ ...n.actions
651
+ ])
652
+ ];
653
+ t.set(n.subject, { ...c, actions: a });
654
+ } else
655
+ t.set(n.subject, n);
656
+ }
657
+ return Array.from(t.values());
658
+ }
659
+ function oe(e, s) {
660
+ const t = M(e, s), o = new Set(e.map((n) => n.subject)), i = s.filter(
661
+ (n) => n.inverted && !o.has(n.subject)
662
+ );
663
+ return [...t, ...i];
664
+ }
665
+ const y = "/permission-assignments", P = {
666
+ async readAll() {
667
+ return b(await v().get(y));
668
+ },
669
+ async readByUserId(e) {
670
+ return b(await v().get(`${y}/user/${e}`));
671
+ },
672
+ async readById(e) {
673
+ return b(await v().get(`${y}/${e}`));
674
+ },
675
+ async create(e) {
676
+ return b(await v().post(y, e));
677
+ },
678
+ async update(e, s) {
679
+ return b(await v().put(`${y}/${e}`, s));
680
+ },
681
+ async delete(e) {
682
+ return b(await v().delete(`${y}/${e}`));
683
+ },
684
+ async addReportManagePermission(e, s) {
685
+ return b(
686
+ await v().post("/my-permissions/report-manage", { permissionKey: e, label: s })
687
+ );
688
+ }
689
+ }, ie = k("permissionAssignment", () => {
690
+ const { currentBusiness: e } = N(), s = j([]), t = j(null);
691
+ async function o() {
692
+ var d;
693
+ const r = ((d = e.value) == null ? void 0 : d._id) ?? null;
694
+ if (t.value === r) return;
695
+ const l = await P.readAll();
696
+ s.value = l, t.value = r;
697
+ }
698
+ async function i(r) {
699
+ return await P.readByUserId(r);
700
+ }
701
+ async function n(r) {
702
+ const l = await P.create(r);
703
+ s.value = [...s.value, l];
704
+ }
705
+ async function c(r, l) {
706
+ const d = await P.update(r, l);
707
+ s.value = s.value.map((f) => f.id === r ? d : f);
708
+ }
709
+ async function a(r) {
710
+ await P.delete(r), s.value = s.value.filter((l) => l.id !== r);
711
+ }
712
+ function u(r) {
713
+ return s.value.find((l) => l.userId === r);
714
+ }
715
+ return {
716
+ permissionAssignments: s,
717
+ readPermissionAssignments: o,
718
+ readPermissionAssignmentByUserId: i,
719
+ createPermissionAssignment: n,
720
+ updatePermissionAssignment: c,
721
+ deletePermissionAssignment: a,
722
+ getPermissionAssignmentByUserId: u
723
+ };
724
+ }), re = () => {
725
+ const e = ie();
726
+ return {
727
+ ...e,
728
+ ...W(e)
729
+ };
730
+ }, ae = {
731
+ async fetchReportPermissions(e) {
732
+ return b(
733
+ await L().get(`/report-query/hrm/${e}/reports`)
734
+ );
735
+ },
736
+ async fetchReportPermissionsForPortal(e) {
737
+ return b(
738
+ await L().get(
739
+ `/report-query/hrm/${e}/reports?isSupportPos=false`
740
+ )
741
+ );
742
+ }
743
+ }, O = j([]), E = j(!1), w = j(!1), $ = j(null);
744
+ function ce() {
745
+ const e = N();
746
+ async function s() {
747
+ var i;
748
+ const o = (i = e.currentBusiness.value) == null ? void 0 : i.id;
749
+ if (o && ($.value !== o && (O.value = [], E.value = !1, w.value = !1, $.value = o), !(E.value || w.value))) {
750
+ w.value = !0;
751
+ try {
752
+ const n = await ae.fetchReportPermissionsForPortal(o);
753
+ if ($.value !== o) return;
754
+ O.value = n, E.value = !0;
755
+ } catch (n) {
756
+ if ($.value !== o) return;
757
+ console.warn("Failed to fetch custom report permissions:", n), O.value = [];
758
+ } finally {
759
+ $.value === o && (w.value = !1);
760
+ }
761
+ }
762
+ }
763
+ const t = T(() => O.value.map(
764
+ (o) => o.isDefault ? {
765
+ label: o.name,
766
+ subject: `business::report::reports::${o.permissionKey}`,
767
+ actions: [S.manage, S.read, S.create],
768
+ category: F.reports
769
+ } : {
770
+ label: o.name,
771
+ subject: `business::report::reports::${o.permissionKey}`,
772
+ actions: [
773
+ S.manage,
774
+ S.read,
775
+ S.create,
776
+ S.update,
777
+ S.delete
778
+ ],
779
+ category: F.customReports
780
+ }
781
+ ));
782
+ return {
783
+ fetchCustomReportPermissions: s,
784
+ customReportPermissions: t,
785
+ isLoading: T(() => w.value),
786
+ isLoaded: T(() => E.value)
787
+ };
788
+ }
789
+ function R(e) {
790
+ const s = N(), t = Z(), o = re(), i = s.restaurants, { customReportPermissions: n } = ce(), c = o.getPermissionAssignmentByUserId(e.id), a = K(
791
+ (c == null ? void 0 : c.permissionSetIds) ?? [],
792
+ t.permissionSets.value
793
+ ), u = V(a).map(
794
+ ({ setNames: p, ...g }) => g
795
+ ), r = c == null ? void 0 : c.customPermissions, l = r ?? e.permissions.map((p) => ({
796
+ ...p,
797
+ subject: I(p.subject)
798
+ })), d = M(u, l), f = z(
799
+ oe(u, l),
800
+ x
801
+ ).filter((p) => !p.inverted), m = le(f) || i.value.map((p) => p._id);
802
+ return {
803
+ doc: e,
804
+ id: e.id,
805
+ name: e.name && e.name !== e.email && e.name !== e.phoneNumber ? e.name : "-",
806
+ phoneNumber: e.phoneNumber,
807
+ email: e.email,
808
+ restaurants: D(
809
+ m.map(
810
+ (p) => {
811
+ var g;
812
+ return ((g = i.value.find((X) => X._id === p)) == null ? void 0 : g.profile.name) ?? "";
813
+ }
814
+ )
815
+ ),
816
+ managableRestaurantIds: m,
817
+ permissionLabels: me(f, n.value),
818
+ permissions: d
819
+ };
820
+ }
821
+ const ue = Object.freeze(
822
+ Object.values(G)
823
+ ), Re = {
824
+ async readTeamMembers() {
825
+ return b(
826
+ await v().get("/portal-users")
827
+ ).map(R);
828
+ },
829
+ async readTeamMembersPage(e) {
830
+ var t, o;
831
+ const s = b(
832
+ await v().get("/portal-users/paged", {
833
+ params: {
834
+ limit: e.limit,
835
+ offset: e.offset,
836
+ search: e.search,
837
+ restaurantIds: (t = e.restaurantIds) != null && t.length ? e.restaurantIds : void 0,
838
+ permissionSubjects: (o = e.permissionSubjects) != null && o.length ? e.permissionSubjects : void 0
839
+ }
840
+ })
841
+ );
842
+ return {
843
+ items: s.items.map(R),
844
+ total: s.total
845
+ };
846
+ },
847
+ async readTeamMember(e) {
848
+ return R(
849
+ b(await v().get(`/portal-users/${e}`))
850
+ );
851
+ },
852
+ async createTeamMember(e) {
853
+ return R(
854
+ b(await v().post("/portal-users", e))
855
+ );
856
+ },
857
+ async updateTeamMember(e, s) {
858
+ return R(
859
+ b(await v().put(`/portal-users/${e}`, s))
860
+ );
861
+ },
862
+ async deleteTeamMember(e) {
863
+ return b(await v().delete(`/portal-users/${e}`));
864
+ },
865
+ async readTeamMemberPosUserIds() {
866
+ return b(await v().get("/portal-users")).map((s) => s.posUserId);
867
+ }
868
+ };
869
+ function Ie(e, s, t) {
870
+ if (e.some((c) => c.subject === "all")) return "All";
871
+ const o = (t ?? B).filter(
872
+ (c) => c.subject === s
873
+ ), i = new Set(o.map((c) => C(c).value)), n = e.filter((c) => c.subject === s).filter((c) => i.has(C(c).value));
874
+ return n.length === o.length ? "All" : n.length === 0 ? "-" : `${n.length} permission allow`;
875
+ }
876
+ function C(e) {
877
+ const s = Q(e), t = s.subject;
878
+ return {
879
+ ...s,
880
+ get conditions() {
881
+ return typeof s.conditions == "string" ? JSON.parse(s.conditions) : s.conditions;
882
+ },
883
+ get isDiscountOperation() {
884
+ var o;
885
+ return t === h.F_RULE_SUBJECT.enum.order && ((o = this.conditions) == null ? void 0 : o.operation) === h.F_RULE_ORDER_OPERATION.enum.discount;
886
+ },
887
+ get isOrderOperation() {
888
+ return t === h.F_RULE_SUBJECT.enum.order;
889
+ },
890
+ get isReportPermission() {
891
+ return t === h.F_RULE_SUBJECT.enum.report;
892
+ },
893
+ get formatted() {
894
+ const o = (i) => i.endsWith("_") ? i.slice(0, i.length - 1) : i;
895
+ return this.isOrderOperation ? o(this.conditions.operation) : this.isReportPermission ? o(this.conditions.name) : t.toString();
896
+ },
897
+ get label() {
898
+ return s.label || H(this.formatted);
899
+ },
900
+ get value() {
901
+ return this.isOrderOperation ? `${t}:${this.conditions.operation}` : this.isReportPermission ? `${t}:${this.conditions.name}` : t.toString();
902
+ }
903
+ };
904
+ }
905
+ function Ae(e) {
906
+ const s = e.map((t) => C(t)).find((t) => t.isDiscountOperation);
907
+ return s ? parseInt((s.conditions.adjustment.$lte * 100).toFixed(0)) : 100;
908
+ }
909
+ function le(e) {
910
+ const s = e.find(
911
+ (t) => t.subject === J.Subject.Restaurant.restaurant
912
+ );
913
+ return s ? s.conditions ? JSON.parse(s.conditions).restaurantId.$in : null : [];
914
+ }
915
+ function _e(e) {
916
+ return (e == null ? void 0 : e.some((s) => s.subject === "all")) ?? !1;
917
+ }
918
+ function Oe(e) {
919
+ const s = e.find((t) => t.subject === J.Subject.Business.role);
920
+ return s ? s.conditions ? JSON.parse(s.conditions).roleId.$in : null : [];
921
+ }
922
+ function Ee(e, s) {
923
+ return e.map((t) => {
924
+ const o = de(t);
925
+ return {
926
+ subject: o.subject,
927
+ actions: o.actions,
928
+ conditions: {
929
+ ...o.conditions,
930
+ adjustment: o.isDiscountOperation ? { $lte: parseFloat((s / 100).toFixed(2)) } : void 0
931
+ }
932
+ };
933
+ });
934
+ }
935
+ function de(e) {
936
+ const [s, t] = e.split(":");
937
+ let o;
938
+ return t ? (o = B.find(
939
+ (i) => i.subject === s && [
940
+ (typeof i.conditions == "object" ? i.conditions : JSON.parse(i.conditions)).operation,
941
+ i.conditions.name
942
+ ].includes(t)
943
+ ), !o && s === h.F_RULE_SUBJECT.enum.report && (o = {
944
+ label: "",
945
+ subject: h.F_RULE_SUBJECT.enum.report,
946
+ actions: ["read"],
947
+ conditions: { name: t },
948
+ inverted: !1,
949
+ reason: ""
950
+ })) : o = B.find((i) => i.subject === s), C(o || { subject: h.F_RULE_SUBJECT.enum.order, actions: [], label: "" });
951
+ }
952
+ function me(e, s = []) {
953
+ return D(
954
+ e.reduce((t, o) => {
955
+ const i = ue.find((n) => n.subject === o.subject) || s.find((n) => n.subject === o.subject);
956
+ if (i) {
957
+ const n = i.subject === J.Subject.Business.inventory_stock ? "Warehouse Management" : i.label;
958
+ t.push(n);
959
+ }
960
+ return t;
961
+ }, [])
962
+ );
963
+ }
964
+ export {
965
+ z as $,
966
+ ae as R,
967
+ Ie as a,
968
+ oe as b,
969
+ K as c,
970
+ ce as d,
971
+ B as e,
972
+ Ee as f,
973
+ Ae as g,
974
+ _e as h,
975
+ ee as i,
976
+ Oe as j,
977
+ we as k,
978
+ $e as l,
979
+ je as m,
980
+ ye as n,
981
+ re as o,
982
+ ue as p,
983
+ me as q,
984
+ C as r,
985
+ Pe as s,
986
+ Re as t,
987
+ Z as u,
988
+ V as v,
989
+ he as w,
990
+ le as x
991
+ };