@feedmepos/mf-hrm-portal 2.3.1 → 2.3.2-dev.10

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 (121) hide show
  1. package/dist/{ApprovalCodeList-CcvVEriB.js → ApprovalCodeList-RKU5B8SO.js} +14 -15
  2. package/dist/{AuditLogList-C61-SnWG.js → AuditLogList-DuDCMjGR.js} +796 -720
  3. package/dist/ConditionBuilderForm.vue_vue_type_script_setup_true_lang-pL2zRc67.js +459 -0
  4. package/dist/EmployeeList-nrYsS5uz.js +896 -0
  5. package/dist/FormSection.vue_vue_type_script_setup_true_lang-7S2w36aY.js +90 -0
  6. package/dist/{GrantUserList-1ErIV7b7.js → GrantUserList-BSjeC4MC.js} +15 -16
  7. package/dist/{Main-R0qyd8Ea.js → Main-CpuHaXU6.js} +5 -5
  8. package/dist/Main-DbdoVLCE.js +101 -0
  9. package/dist/{Main-CD8OS1rM.js → Main-DtmCBbTR.js} +1005 -999
  10. package/dist/MyPosProfile-CsTCfGNT.js +360 -0
  11. package/dist/PasscodePinField.vue_vue_type_script_setup_true_lang-TXPEqa46.js +126 -0
  12. package/dist/{PermissionSetList-ig3oxdhh.js → PermissionSetList-B1c-uGZO.js} +80 -80
  13. package/dist/PortalPermissionEditor.vue_vue_type_script_setup_true_lang-Toq6qrLx.js +4208 -0
  14. package/dist/PortalUserSearcher.vue_vue_type_style_index_0_scoped_827dfd60_lang-D6Z9z_Yt.js +1831 -0
  15. package/dist/RoleForm.vue_vue_type_script_setup_true_lang-TWTVo_9Y.js +547 -0
  16. package/dist/RoleList-CwaGNsFy.js +265 -0
  17. package/dist/{ScheduleAddPositionModal.vue_vue_type_script_setup_true_lang-Dg7S6nFO.js → ScheduleAddPositionModal.vue_vue_type_script_setup_true_lang-C2ekVXdR.js} +1 -1
  18. package/dist/{ScheduleGeneralPage-QYijA95u.js → ScheduleGeneralPage-BVtXmxtp.js} +2 -2
  19. package/dist/{ScheduleModal.vue_vue_type_script_setup_true_lang-Bnyqna_E.js → ScheduleModal.vue_vue_type_script_setup_true_lang-DdsQ8v-5.js} +187 -186
  20. package/dist/{SchedulePage-BrBZmuMj.js → SchedulePage-3qksmT2I.js} +193 -205
  21. package/dist/{SchedulePositionPage-NCvNg8v5.js → SchedulePositionPage-DAU20KPZ.js} +3 -3
  22. package/dist/{SelectFilter-r-QOCO99.js → SelectFilter-BpzBwBmQ.js} +2 -3
  23. package/dist/TeamMemberList-Bdpm40i3.js +2087 -0
  24. package/dist/TimesheetList-CL_eJp2h.js +437 -0
  25. package/dist/{app-DKHtjxyC.js → app-DEZT4wdV.js} +7789 -3967
  26. package/dist/app.js +3 -3
  27. package/dist/{approval-code-BIpLingm.js → approval-code-BZTz5OXK.js} +4 -4
  28. package/dist/{dayjs.min-CNNMpacl.js → dayjs.min-B55I-uhI.js} +21 -21
  29. package/dist/employee-C6z5i6O4.js +172 -0
  30. package/dist/{grant-user-uZmvD_bw.js → grant-user-B2rYztyf.js} +2 -2
  31. package/dist/{iteration-DkcNkScw.js → index-Bfdseotz.js} +698 -726
  32. package/dist/iteration-CcXrOMQe.js +30 -0
  33. package/dist/{lodash-g-62RoFP.js → lodash-B8bqa6a9.js} +1 -1
  34. package/dist/member-grant-BIpKkuu8.js +54 -0
  35. package/dist/restaurant-ejyX2jEG.js +52 -0
  36. package/dist/role-C_t3DDlG.js +98 -0
  37. package/dist/rule-Ccopk8R_.js +843 -0
  38. package/dist/src/api/audit-log/index.d.ts +2 -0
  39. package/dist/src/api/employee/index.d.ts +1 -2
  40. package/dist/src/api/my-pos-profile/index.d.ts +3 -0
  41. package/dist/src/api/sso-provider/index.d.ts +5 -0
  42. package/dist/src/api/staff-invite/index.d.ts +16 -0
  43. package/dist/src/api/timesheet/index.d.ts +1 -1
  44. package/dist/src/components/CollapsibleWrapper.vue.d.ts +11 -3
  45. package/dist/src/components/form/SegmentedTabs.vue.d.ts +23 -0
  46. package/dist/src/composables/useMenuAccess.d.ts +56 -0
  47. package/dist/src/composables/useSsoProviders.d.ts +19 -0
  48. package/dist/src/composables/useStaffInviteProviders.d.ts +8 -0
  49. package/dist/src/helpers/member-grant.d.ts +36 -0
  50. package/dist/src/helpers/my-pos-profile.d.ts +37 -0
  51. package/dist/src/helpers/permission-set.d.ts +1 -102
  52. package/dist/src/helpers/pos-assignment-rows.d.ts +28 -0
  53. package/dist/src/helpers/rule.d.ts +2 -2
  54. package/dist/src/helpers/staff-invite.d.ts +54 -0
  55. package/dist/src/helpers/string.d.ts +10 -1
  56. package/dist/src/router/menu-access-guard.d.ts +17 -0
  57. package/dist/src/router/shared.d.ts +3 -1
  58. package/dist/src/stores/approval-code.d.ts +1 -1
  59. package/dist/src/stores/employee.d.ts +3 -9
  60. package/dist/src/stores/grant-user.d.ts +1 -1
  61. package/dist/src/stores/permission-assignment.d.ts +2 -2
  62. package/dist/src/stores/permission-set.d.ts +2 -2
  63. package/dist/src/stores/restaurant.d.ts +70 -10
  64. package/dist/src/stores/role.d.ts +2 -2
  65. package/dist/src/stores/team.d.ts +31 -1
  66. package/dist/src/stores/timesheet.d.ts +68 -53
  67. package/dist/src/types/my-pos-profile.d.ts +24 -0
  68. package/dist/src/types/sso-provider.d.ts +10 -0
  69. package/dist/src/types/staff-invite.d.ts +100 -0
  70. package/dist/src/types/team.d.ts +17 -1
  71. package/dist/src/types/timesheet.d.ts +3 -0
  72. package/dist/src/views/audit-log/locales/index.d.ts +40 -0
  73. package/dist/src/views/audit-log/useTraceIdDeepLink.d.ts +19 -0
  74. package/dist/src/views/hr/locales/index.d.ts +24 -4
  75. package/dist/src/views/hr/role/RoleForm.vue.d.ts +29 -2
  76. package/dist/src/views/my-pos-profile/MyPosProfile.vue.d.ts +2 -0
  77. package/dist/src/views/my-pos-profile/components/PasscodeChangedDialog.vue.d.ts +4 -0
  78. package/dist/src/views/my-pos-profile/locales/index.d.ts +236 -0
  79. package/dist/src/views/scheduling/composables/useScheduleOnboardingAvailability.d.ts +1 -1
  80. package/dist/src/views/scheduling/composables/useScheduleOnboardingWizard.d.ts +1 -1
  81. package/dist/src/views/scheduling/composables/useScheduleShiftDraft.d.ts +1 -1
  82. package/dist/src/views/scheduling/composables/useScheduleShiftPopover.d.ts +1 -1
  83. package/dist/src/views/team/components/BasePermission.vue.d.ts +11 -0
  84. package/dist/src/views/team/components/ConditionPermission.vue.d.ts +11 -0
  85. package/dist/src/views/team/components/MemberGrantFields.vue.d.ts +51 -0
  86. package/dist/src/views/team/{member/MemberInfo.vue.d.ts → components/MemberStatusBadge.vue.d.ts} +2 -2
  87. package/dist/src/views/team/components/PortalPermissionEditor.vue.d.ts +21 -0
  88. package/dist/src/views/team/components/PosAssignmentRows.vue.d.ts +44 -0
  89. package/dist/src/views/team/components/PosRolePermission.vue.d.ts +11 -0
  90. package/dist/src/views/team/locales/index.d.ts +716 -0
  91. package/dist/src/views/team/member/AddMemberForm.vue.d.ts +48 -3
  92. package/dist/src/views/team/member/ExistingMemberNotice.vue.d.ts +11 -0
  93. package/dist/src/views/team/member/MemberDetailsCard.vue.d.ts +35 -0
  94. package/dist/src/views/team/member/MemberHeaderCard.vue.d.ts +19 -0
  95. package/dist/src/views/team/member/TeamMemberList.vue.d.ts +1 -0
  96. package/dist/string-DZQ1uNjn.js +22 -0
  97. package/dist/style.css +1 -1
  98. package/dist/timesheet-CZHcebqS.js +76 -0
  99. package/dist/tsconfig.app.tsbuildinfo +1 -1
  100. package/dist/{useAppStore-Bp0PwbAN.js → useAppStore-DfqsbhT2.js} +1 -1
  101. package/dist/{useLoading-sgL8DRUz.js → useLoading-CQnX5WjI.js} +1 -1
  102. package/dist/useMessage-_ywT_N9X.js +17 -0
  103. package/dist/{useReportPermissions-CcIHwTRI.js → useReportPermissions-kTjftFk7.js} +13 -13
  104. package/package.json +4 -4
  105. package/dist/ConditionBuilderForm.vue_vue_type_script_setup_true_lang-BZ-ZDviW.js +0 -438
  106. package/dist/EmployeeList-Cucr2mxn.js +0 -776
  107. package/dist/FormItem.vue_vue_type_script_setup_true_lang-4XV2qPxn.js +0 -45
  108. package/dist/FormSection.vue_vue_type_script_setup_true_lang-DknXTYiK.js +0 -49
  109. package/dist/Main-B-F_cdM_.js +0 -96
  110. package/dist/PasscodePinField.vue_vue_type_script_setup_true_lang-CqG0v0Sz.js +0 -243
  111. package/dist/PortalPermissionEditor.vue_vue_type_script_setup_true_lang-ClG4YhnF.js +0 -4167
  112. package/dist/PortalUserSearcher.vue_vue_type_style_index_0_scoped_827dfd60_lang-DaAx79pC.js +0 -35
  113. package/dist/RoleList-BqR_Vf8H.js +0 -740
  114. package/dist/TeamMemberList-B6ZnfKV0.js +0 -1154
  115. package/dist/TimesheetList-BvsUk6kd.js +0 -402
  116. package/dist/TimesheetList.vue_vue_type_style_index_0_scoped_63294af2_lang-D3--3EhR.js +0 -58
  117. package/dist/employee-H2J0xRqJ.js +0 -209
  118. package/dist/restaurant-CHpkjUPy.js +0 -1880
  119. package/dist/role-CkxDtfst.js +0 -92
  120. package/dist/rule-BWvSqhBk.js +0 -783
  121. package/dist/string-VNuQNweN.js +0 -15
@@ -1,783 +0,0 @@
1
- import { s as W, c as q, e as y } from "./iteration-DkcNkScw.js";
2
- import { h as O, c as V, d as _, v as F, n as h, O as ee, D as M } from "./app-DKHtjxyC.js";
3
- import { s as se } from "./utils-BZkjJbju.js";
4
- import { g, b as v, q as x, u as te } from "./restaurant-CHpkjUPy.js";
5
- import { defineStore as z, storeToRefs as K } from "pinia";
6
- import { ref as S, computed as T } from "vue";
7
- import { useCoreStore as X } from "@feedmepos/mf-common";
8
- const E = "/permission-sets", N = {
9
- async read() {
10
- return g(await v().get(E));
11
- },
12
- async create(e) {
13
- return g(await v().post(E, e));
14
- },
15
- async update(e, s) {
16
- return g(await v().put(`${E}/${e}`, s));
17
- },
18
- async delete(e) {
19
- return g(await v().delete(`${E}/${e}`));
20
- }
21
- }, ne = z("permissionSet", () => {
22
- const { currentBusiness: e } = X(), s = S([]), r = S(!1), n = S(null);
23
- async function i() {
24
- var l;
25
- const c = ((l = e.value) == null ? void 0 : l._id) ?? null;
26
- if (n.value !== c)
27
- try {
28
- r.value = !0;
29
- const d = await N.read();
30
- s.value = u(d), n.value = c;
31
- } finally {
32
- r.value = !1;
33
- }
34
- }
35
- async function t(c) {
36
- const l = await N.create(c);
37
- s.value = u([...s.value, l]);
38
- }
39
- async function a(c, l) {
40
- const d = await N.update(c, l);
41
- s.value = u(s.value.map((f) => f.id === c ? d : f));
42
- }
43
- async function o(c) {
44
- await N.delete(c), s.value = u(s.value.filter((l) => l.id !== c));
45
- }
46
- function u(c) {
47
- return c.sort((l, d) => l.name.localeCompare(d.name));
48
- }
49
- return {
50
- permissionSets: s,
51
- isLoading: r,
52
- readPermissionSets: i,
53
- createPermissionSet: t,
54
- updatePermissionSet: a,
55
- deletePermissionSet: o
56
- };
57
- }), re = () => {
58
- const e = ne();
59
- return {
60
- ...e,
61
- ...K(e)
62
- };
63
- };
64
- function D(e) {
65
- if (e) {
66
- if (typeof e == "string") {
67
- if (e === "{}") return;
68
- try {
69
- return JSON.parse(e);
70
- } catch {
71
- return;
72
- }
73
- }
74
- if (typeof e == "object")
75
- return Object.keys(e).length > 0 ? e : void 0;
76
- }
77
- }
78
- function j(e) {
79
- return e ? Object.values(e).every(
80
- (s) => s !== null && typeof s == "object" && !Array.isArray(s) && Object.keys(s).length === 1 && Array.isArray(s.$in)
81
- ) : !0;
82
- }
83
- function Q(e) {
84
- const s = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map(), n = (i, t, a) => {
85
- var o, u;
86
- const c = D(t.conditions);
87
- let l = `${t.subject}::${JSON.stringify([...t.actions].sort())}`;
88
- j(c) || (l += `::${JSON.stringify(c)}`);
89
- const d = i.get(l);
90
- if (!d) {
91
- i.set(l, { ...t, setNames: [a.name], setId: a._id });
92
- return;
93
- }
94
- d.setNames.push(a.name);
95
- const f = D(d.conditions);
96
- if (!f || !c) {
97
- d.conditions = void 0;
98
- return;
99
- }
100
- for (const m in c)
101
- (o = f[m]) != null && o.$in && (u = c[m]) != null && u.$in ? f[m].$in = Array.from(
102
- /* @__PURE__ */ new Set([...f[m].$in, ...c[m].$in])
103
- ) : f[m] || (f[m] = c[m]);
104
- d.conditions = JSON.stringify(f);
105
- };
106
- for (const i of e)
107
- for (const t of i.permissions)
108
- n(t.inverted ? r : s, t, i);
109
- return [...Array.from(s.values()), ...Array.from(r.values())];
110
- }
111
- function B(e, s) {
112
- return `${e}::${[...s].sort().join(",")}`;
113
- }
114
- function G(e, s) {
115
- const r = [...e], n = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Set(), t = /* @__PURE__ */ new Set();
116
- for (const o of e) {
117
- const u = O(o.subject);
118
- n.add(B(u, o.actions)), o.inverted && o.actions.includes("manage") && i.add(`set_${u}`), !o.inverted && o.actions.includes("manage") && t.add(u);
119
- }
120
- const a = [...e];
121
- for (; a.length > 0; ) {
122
- const o = a.shift(), u = `set_${O(o.subject)}`, c = s[u];
123
- if (!c || i.has(u) || !o.actions.includes("manage") || o.inverted) continue;
124
- i.add(u);
125
- const l = ie(o);
126
- o.source && !o.source.trace && (o.source = { ...o.source, trace: l });
127
- const d = [...l, `${c.name} (system)`];
128
- for (const f of c.permissions ?? []) {
129
- const m = O(f.subject), p = B(m, f.actions);
130
- n.has(p) || t.has(m) || (n.add(p), r.push({
131
- ...f,
132
- // FdoPermissionRule.fields is string[] | null; RawRule expects string[] | undefined
133
- fields: f.fields ?? void 0,
134
- source: {
135
- type: "systemPermissionSet",
136
- permissionSetId: c.key,
137
- permissionSetName: c.name,
138
- trace: d
139
- }
140
- }));
141
- }
142
- for (const f of c.permissionSets ?? []) {
143
- const m = O(f), p = B(m, ["manage"]), b = {
144
- subject: m,
145
- actions: ["manage"],
146
- source: {
147
- type: "systemPermissionSet",
148
- permissionSetId: c.key,
149
- permissionSetName: c.name,
150
- trace: d
151
- }
152
- };
153
- n.has(p) || (n.add(p), r.push(b)), a.push(b);
154
- }
155
- }
156
- return [...r.filter((o) => !o.inverted), ...r.filter((o) => o.inverted)];
157
- }
158
- function ie(e) {
159
- if (!e.source) return [];
160
- const { type: s, trace: r, permissionSetName: n } = e.source;
161
- if (r && r.length > 0) return r;
162
- switch (s) {
163
- case "permissionSet":
164
- return n ? [n] : [];
165
- case "custom":
166
- return ["custom"];
167
- default:
168
- return [];
169
- }
170
- }
171
- function H(e, s, r = /* @__PURE__ */ new Set()) {
172
- var i;
173
- const n = [];
174
- for (const t of e) {
175
- if (r.has(t)) continue;
176
- r.add(t);
177
- const a = s.find((o) => o.id === t);
178
- a && (n.push(a), (i = a.permissionSetIds) != null && i.length && n.push(...H(a.permissionSetIds, s, r)));
179
- }
180
- return n;
181
- }
182
- function Ae(e) {
183
- const s = Q(e).map(
184
- ({ setNames: i, setId: t, ...a }) => a
185
- ), r = s.filter((i) => !i.inverted), n = s.filter((i) => i.inverted);
186
- return L(r, n);
187
- }
188
- function Oe(e, s, r) {
189
- const n = /* @__PURE__ */ new Map();
190
- return e.forEach(
191
- ({ name: i, permissions: t }) => t.forEach(({ conditions: a, actions: o }) => {
192
- var c, l;
193
- const u = JSON.parse(a || "{}");
194
- (c = u[s]) != null && c.$in ? (l = u[s]) == null || l.$in.forEach(
195
- (d) => (n.get(d) ?? n.set(d, /* @__PURE__ */ new Set()).get(d)).add(i)
196
- ) : o[0] === "manage" && r.forEach((d) => {
197
- (n.get(d) ?? n.set(d, /* @__PURE__ */ new Set()).get(d)).add(i);
198
- });
199
- })
200
- ), [...n].map(([i, t]) => ({
201
- id: i,
202
- setNames: [...t]
203
- }));
204
- }
205
- function _e(e, s) {
206
- const r = (o, u) => {
207
- const c = { ...o }, l = JSON.parse(c.conditions || "{}");
208
- if (u)
209
- if (u.length > 0) {
210
- const d = Object.keys(l)[0];
211
- l[d].$in = u;
212
- } else
213
- delete c.conditions;
214
- return {
215
- ...c,
216
- inverted: !0,
217
- ...c.conditions && { conditions: JSON.stringify(l) }
218
- };
219
- }, n = new Map(e.map((o) => [o.subject, o])), i = new Map(s.map((o) => [o.subject, o])), t = [], a = /* @__PURE__ */ new Set([...n.keys(), ...i.keys()]);
220
- for (const o of a) {
221
- const u = n.get(o), c = i.get(o);
222
- if (u && c) {
223
- if (u.conditions && c.conditions) {
224
- const l = JSON.parse(u.conditions), d = JSON.parse(c.conditions);
225
- if (!j(l) || !j(d)) {
226
- JSON.stringify(l) !== JSON.stringify(d) && t.push(c);
227
- continue;
228
- }
229
- const f = Object.keys(l)[0], m = l[f].$in.filter(
230
- (b) => !d[f].$in.includes(b)
231
- );
232
- m.length > 0 && t.push(r(u, m)), d[f].$in.filter(
233
- (b) => !l[f].$in.includes(b)
234
- ).length > 0 && t.push(c);
235
- } else if (!u.conditions && c.conditions)
236
- t.push(c);
237
- else if (u.conditions && !c.conditions)
238
- j(JSON.parse(u.conditions)) || t.push(c);
239
- else if (!u.conditions && !c.conditions) {
240
- const l = new Set(u.actions), d = new Set(c.actions), f = c.actions.some((p) => !l.has(p)), m = u.actions.filter((p) => !d.has(p));
241
- if (f) {
242
- const p = c.actions.filter((b) => !l.has(b));
243
- t.push({
244
- ...c,
245
- actions: p
246
- });
247
- }
248
- m.length > 0 && t.push({
249
- ...u,
250
- actions: m,
251
- inverted: !0
252
- });
253
- }
254
- continue;
255
- }
256
- if (u) {
257
- t.push(
258
- r(
259
- u,
260
- // If base has conditions, set diffIds to empty array, disallow all access to collection
261
- // otherwise, invert directly
262
- u.conditions && []
263
- )
264
- );
265
- continue;
266
- }
267
- c && t.push(c);
268
- }
269
- return t;
270
- }
271
- function Ee(e) {
272
- const s = G(
273
- e,
274
- V
275
- ), r = new Set(
276
- s.filter((i) => {
277
- var t;
278
- return ((t = i.source) == null ? void 0 : t.type) === "systemPermissionSet" && !i.inverted;
279
- }).map((i) => i.subject)
280
- ), n = new Set(
281
- s.filter(
282
- (i) => {
283
- var t;
284
- return ((t = i.source) == null ? void 0 : t.type) === "systemPermissionSet" && !i.inverted && i.actions.includes("manage");
285
- }
286
- ).map((i) => i.subject)
287
- );
288
- return e.filter((i) => i.inverted ? !(r.has(i.subject) && !n.has(i.subject)) : !r.has(i.subject));
289
- }
290
- const oe = "business::report::";
291
- function Ne(e, s) {
292
- const r = [], n = e.filter((i) => {
293
- const t = i.subject;
294
- return !t.startsWith(oe) || s.has(t) ? !0 : (r.push(t), !1);
295
- });
296
- return r.length > 0 && console.warn("[filterStalePermissions] dropped stale report permissions:", r), n;
297
- }
298
- const ae = "business::report::reports::", ce = _.Subject.Business.report_reports_allDefaultReports, ue = _.Subject.Business.report_reports_allCustomReports;
299
- function le(e, s) {
300
- return e.conditions ? !!s.conditions && e.conditions === s.conditions : !s.conditions;
301
- }
302
- function Ue(e, s) {
303
- const r = e.find(
304
- (a) => !a.inverted && a.subject === ce
305
- ), n = e.find(
306
- (a) => !a.inverted && a.subject === ue
307
- );
308
- if (!r && !n) return e;
309
- const i = r ? new Set(r.actions) : null, t = n ? new Set(n.actions) : null;
310
- return e.reduce((a, o) => {
311
- if (o.inverted)
312
- return a.push(o), a;
313
- const u = o.subject;
314
- if (!u.startsWith(ae))
315
- return a.push(o), a;
316
- const c = s.has(u), l = c ? i : t, d = c ? r : n;
317
- if (!l || !d || !le(d, o))
318
- return a.push(o), a;
319
- if (l.has("manage")) return a;
320
- const f = o.actions;
321
- if (f.includes("manage"))
322
- return a.push(o), a;
323
- const m = new Set(f);
324
- for (const p of l)
325
- m.delete(p);
326
- return m.size === 0 || a.push({ ...o, actions: Array.from(m) }), a;
327
- }, []);
328
- }
329
- function L(e, s) {
330
- var n, i;
331
- const r = new Map(e.map((t) => [t.subject, t]));
332
- for (const t of s) {
333
- if (t.inverted) {
334
- const o = r.get(t.subject);
335
- if (t.conditions) {
336
- if (o != null && o.conditions) {
337
- const u = JSON.parse(o.conditions), c = JSON.parse(t.conditions);
338
- if (!j(u) || !j(c)) {
339
- r.delete(t.subject);
340
- continue;
341
- }
342
- const l = Object.keys(c)[0], d = ((n = c[l]) == null ? void 0 : n.$in) ?? [], m = (((i = u[l]) == null ? void 0 : i.$in) ?? []).filter((p) => !d.includes(p));
343
- m.length > 0 ? r.set(t.subject, {
344
- ...o,
345
- conditions: JSON.stringify({ [l]: { $in: m } })
346
- }) : r.delete(t.subject);
347
- } else
348
- r.delete(t.subject);
349
- continue;
350
- }
351
- if (o) {
352
- const u = new Set(t.actions), c = o.actions.filter((l) => !u.has(l));
353
- c.length > 0 ? r.set(t.subject, { ...o, actions: c }) : r.delete(t.subject);
354
- continue;
355
- }
356
- continue;
357
- }
358
- if (t.conditions) {
359
- r.set(t.subject, t);
360
- continue;
361
- }
362
- const a = r.get(t.subject);
363
- if (a != null && a.conditions && !j(JSON.parse(a.conditions))) {
364
- r.set(t.subject, t);
365
- continue;
366
- }
367
- if (a) {
368
- const o = [
369
- .../* @__PURE__ */ new Set([
370
- ...a.actions,
371
- ...t.actions
372
- ])
373
- ];
374
- r.set(t.subject, { ...a, actions: o });
375
- } else
376
- r.set(t.subject, t);
377
- }
378
- return Array.from(r.values());
379
- }
380
- function de(e, s) {
381
- const r = L(e, s), n = new Set(e.map((t) => t.subject)), i = s.filter(
382
- (t) => t.inverted && !n.has(t.subject)
383
- );
384
- return [...r, ...i];
385
- }
386
- const P = "/permission-assignments", I = {
387
- async readAll() {
388
- return g(await v().get(P));
389
- },
390
- async readByUserId(e) {
391
- return g(await v().get(`${P}/user/${e}`));
392
- },
393
- async readById(e) {
394
- return g(await v().get(`${P}/${e}`));
395
- },
396
- async create(e) {
397
- return g(await v().post(P, e));
398
- },
399
- async update(e, s) {
400
- return g(await v().put(`${P}/${e}`, s));
401
- },
402
- async delete(e) {
403
- return g(await v().delete(`${P}/${e}`));
404
- },
405
- async addReportManagePermission(e, s) {
406
- return g(
407
- await v().post("/my-permissions/report-manage", { permissionKey: e, label: s })
408
- );
409
- }
410
- }, fe = z("permissionAssignment", () => {
411
- const e = S([]);
412
- async function s() {
413
- const o = await I.readAll();
414
- e.value = o;
415
- }
416
- async function r(o) {
417
- return await I.readByUserId(o);
418
- }
419
- async function n(o) {
420
- const u = await I.create(o);
421
- e.value = [...e.value, u];
422
- }
423
- async function i(o, u) {
424
- const c = await I.update(o, u);
425
- e.value = e.value.map((l) => l.id === o ? c : l);
426
- }
427
- async function t(o) {
428
- await I.delete(o), e.value = e.value.filter((u) => u.id !== o);
429
- }
430
- function a(o) {
431
- return e.value.find((u) => u.userId === o);
432
- }
433
- return {
434
- permissionAssignments: e,
435
- readPermissionAssignments: s,
436
- readPermissionAssignmentByUserId: r,
437
- createPermissionAssignment: n,
438
- updatePermissionAssignment: i,
439
- deletePermissionAssignment: t,
440
- getPermissionAssignmentByUserId: a
441
- };
442
- }), me = () => {
443
- const e = fe();
444
- return {
445
- ...e,
446
- ...K(e)
447
- };
448
- }, pe = {
449
- async fetchReportPermissions(e, s) {
450
- const r = s ? { lang: s } : {};
451
- return g(
452
- await x().get(`/report-query/hrm/${e}/reports`, { params: r })
453
- );
454
- },
455
- async fetchReportPermissionsForPortal(e, s) {
456
- const r = s ? { isSupportPos: !1, lang: s } : { isSupportPos: !1 };
457
- return g(
458
- await x().get(`/report-query/hrm/${e}/reports`, { params: r })
459
- );
460
- }
461
- }, U = S([]), C = S(!1), R = S(!1), $ = S(null), k = S(null), J = S(!1);
462
- function ge() {
463
- const e = X();
464
- async function s() {
465
- var t;
466
- const n = (t = e.currentBusiness.value) == null ? void 0 : t.id;
467
- if (!n) return;
468
- const i = localStorage.getItem("locale");
469
- if ($.value !== n && (U.value = [], C.value = !1, R.value = !1, $.value = n, J.value = !1), !(C.value && k.value === i)) {
470
- if (R.value) {
471
- J.value = !0;
472
- return;
473
- }
474
- R.value = !0;
475
- try {
476
- const a = await pe.fetchReportPermissionsForPortal(n, i);
477
- if ($.value !== n) return;
478
- U.value = a, C.value = !0, k.value = i;
479
- } catch (a) {
480
- if ($.value !== n) return;
481
- console.warn("Failed to fetch custom report permissions:", a), U.value = [];
482
- } finally {
483
- $.value === n && (R.value = !1, J.value && (J.value = !1, await s()));
484
- }
485
- }
486
- }
487
- const r = T(() => U.value.map(
488
- (n) => n.isDefault ? {
489
- label: n.name,
490
- subject: `business::report::reports::${n.permissionKey}`,
491
- actions: [h.manage, h.read, h.create],
492
- category: F.reports
493
- } : {
494
- label: n.name,
495
- subject: `business::report::reports::${n.permissionKey}`,
496
- actions: [
497
- h.manage,
498
- h.read,
499
- h.create,
500
- h.update,
501
- h.delete
502
- ],
503
- category: F.customReports
504
- }
505
- ));
506
- return {
507
- fetchCustomReportPermissions: s,
508
- customReportPermissions: r,
509
- isLoading: T(() => R.value),
510
- isLoaded: T(() => C.value)
511
- };
512
- }
513
- function A(e) {
514
- const s = re(), r = me(), n = te().restaurants, { customReportPermissions: i } = ge(), t = r.getPermissionAssignmentByUserId(e.id), a = H(
515
- (t == null ? void 0 : t.permissionSetIds) ?? [],
516
- s.permissionSets.value
517
- ), o = Q(a).map(
518
- ({ setNames: p, ...b }) => b
519
- ), u = t == null ? void 0 : t.customPermissions, c = u ?? e.permissions.map((p) => ({
520
- ...p,
521
- subject: O(p.subject)
522
- })), l = L(o, c), d = G(
523
- de(o, c),
524
- V
525
- ).filter((p) => !p.inverted), f = Y(d), m = f ?? n.value.map((p) => p._id);
526
- return {
527
- doc: e,
528
- id: e.id,
529
- name: e.name && e.name !== e.email && e.name !== e.phoneNumber ? e.name : "-",
530
- phoneNumber: e.phoneNumber,
531
- email: e.email,
532
- restaurants: W(
533
- m.map((p) => {
534
- var b;
535
- return ((b = n.value.find((Z) => Z._id === p)) == null ? void 0 : b.profile.name) ?? "";
536
- })
537
- ),
538
- managableRestaurantIds: f,
539
- permissionLabels: he(d, i.value),
540
- permissions: l
541
- };
542
- }
543
- const ve = Object.freeze(
544
- Object.values(ee)
545
- ), Ce = {
546
- async readTeamMembers() {
547
- return g(
548
- await v().get("/portal-users")
549
- ).map(A);
550
- },
551
- async readTeamMembersPage(e) {
552
- var r, n, i;
553
- const s = g(
554
- await v().get("/portal-users/paged", {
555
- params: {
556
- limit: e.limit,
557
- offset: e.offset,
558
- search: e.search,
559
- restaurantIds: (r = e.restaurantIds) != null && r.length ? e.restaurantIds : void 0,
560
- permissionSubjects: (n = e.permissionSubjects) != null && n.length ? e.permissionSubjects : void 0,
561
- permissionSetIds: (i = e.permissionSetIds) != null && i.length ? e.permissionSetIds : void 0
562
- }
563
- })
564
- );
565
- return {
566
- items: s.items.map(A),
567
- total: s.total
568
- };
569
- },
570
- async readTeamMember(e) {
571
- return A(
572
- g(await v().get(`/portal-users/${e}`))
573
- );
574
- },
575
- async createTeamMember(e) {
576
- return A(
577
- g(await v().post("/portal-users", e))
578
- );
579
- },
580
- async updateTeamMember(e, s) {
581
- return A(
582
- g(await v().put(`/portal-users/${e}`, s))
583
- );
584
- },
585
- async deleteTeamMember(e) {
586
- return g(await v().delete(`/portal-users/${e}`));
587
- },
588
- async readTeamMemberPosUserIds() {
589
- return g(await v().get("/portal-users")).map((s) => s.posUserId);
590
- },
591
- async generateMasterUserPasscode(e) {
592
- return `${g(
593
- await v().post("/portal-users/generate-passcode", {
594
- restaurantIds: e.restaurantIds,
595
- excludePosUserId: e.excludePosUserId
596
- })
597
- )}`;
598
- }
599
- };
600
- function Je(e, s, r) {
601
- if (e.some((a) => a.subject === "all")) return "All";
602
- const n = (r ?? M).filter(
603
- (a) => a.subject === s
604
- ), i = new Set(n.map((a) => w(a).value)), t = e.filter((a) => a.subject === s).filter((a) => i.has(w(a).value));
605
- return t.length === n.length ? "All" : t.length === 0 ? "-" : `${t.length} permission allow`;
606
- }
607
- function w(e) {
608
- const s = q(e), r = s.subject;
609
- return {
610
- ...s,
611
- get conditions() {
612
- if (typeof s.conditions != "string") return s.conditions;
613
- try {
614
- return JSON.parse(s.conditions);
615
- } catch {
616
- return;
617
- }
618
- },
619
- get isDiscountOperation() {
620
- var n;
621
- return r === y.F_RULE_SUBJECT.enum.order && ((n = this.conditions) == null ? void 0 : n.operation) === y.F_RULE_ORDER_OPERATION.enum.discount;
622
- },
623
- get isOrderOperation() {
624
- return r === y.F_RULE_SUBJECT.enum.order;
625
- },
626
- get isReportPermission() {
627
- return r === y.F_RULE_SUBJECT.enum.report;
628
- },
629
- /**
630
- * Order and report rules are only meaningful together with the condition
631
- * that names them. A rule missing it cannot be rendered or matched against
632
- * the available permission list, so callers must preserve it verbatim —
633
- * see `splitRoleFormPermissions`, which routes it to `passthrough`, not
634
- * `dropped`. Dropping it would silently revoke a grant the portal cannot
635
- * display (HRM-0027).
636
- */
637
- get isResolvable() {
638
- return this.discriminator !== void 0;
639
- },
640
- /**
641
- * The condition value that identifies this rule, if the subject needs one.
642
- * An empty condition counts as missing: `{ name: '' }` is a known corrupted
643
- * shape that used to resolve to the first hardcoded report permission on
644
- * save (HRM-0027), so it must not look resolvable here either.
645
- */
646
- get discriminator() {
647
- var n, i;
648
- return this.isOrderOperation ? ((n = this.conditions) == null ? void 0 : n.operation) || void 0 : this.isReportPermission ? ((i = this.conditions) == null ? void 0 : i.name) || void 0 : r.toString();
649
- },
650
- get formatted() {
651
- const n = this.discriminator;
652
- return n === void 0 ? r.toString() : n.endsWith("_") ? n.slice(0, n.length - 1) : n;
653
- },
654
- get label() {
655
- return s.label || se(this.formatted);
656
- },
657
- get value() {
658
- const n = this.discriminator;
659
- return this.isOrderOperation || this.isReportPermission ? n === void 0 ? r.toString() : `${r}:${n}` : r.toString();
660
- }
661
- };
662
- }
663
- function Te(e) {
664
- var n, i;
665
- const s = e.map((t) => w(t)).find((t) => t.isDiscountOperation);
666
- if (!s) return 100;
667
- const r = Number((i = (n = s.conditions) == null ? void 0 : n.adjustment) == null ? void 0 : i.$lte);
668
- return Number.isFinite(r) ? parseInt((r * 100).toFixed(0)) : 0;
669
- }
670
- function Y(e) {
671
- const s = e.find(
672
- (r) => r.subject === _.Subject.Restaurant.restaurant
673
- );
674
- return s ? s.conditions ? JSON.parse(s.conditions).restaurantId.$in : null : [];
675
- }
676
- function Be(e, s) {
677
- return s.isOwner ? { restaurantIds: null, roleIds: null } : { restaurantIds: Y(e), roleIds: be(e) };
678
- }
679
- function Me(e) {
680
- return (e == null ? void 0 : e.some((s) => s.subject === "all")) ?? !1;
681
- }
682
- function be(e) {
683
- const s = e.find((r) => r.subject === _.Subject.Business.role);
684
- return s ? s.conditions ? JSON.parse(s.conditions).roleId.$in : null : [];
685
- }
686
- function Le(e) {
687
- const s = w(e);
688
- if (!s.isReportPermission) return;
689
- const { name: r, ...n } = s.conditions ?? {};
690
- return Object.keys(n).length > 0 ? n : void 0;
691
- }
692
- function Fe(e, s, r) {
693
- return e.flatMap((n) => {
694
- const i = Se(n);
695
- if (!i) return [];
696
- const t = i.isReportPermission ? r == null ? void 0 : r.get(n) : void 0;
697
- return [
698
- {
699
- subject: i.subject,
700
- actions: i.actions,
701
- conditions: {
702
- ...i.conditions,
703
- ...t ?? {},
704
- adjustment: i.isDiscountOperation ? { $lte: parseFloat((s / 100).toFixed(2)) } : void 0
705
- }
706
- }
707
- ];
708
- });
709
- }
710
- function Se(e) {
711
- const s = e.indexOf(":"), r = s === -1 ? e : e.slice(0, s), n = s === -1 ? void 0 : e.slice(s + 1);
712
- if (s !== -1 && !n) return;
713
- let i;
714
- return n ? (i = M.find((t) => {
715
- if (t.subject !== r) return !1;
716
- const a = typeof t.conditions == "string" ? JSON.parse(t.conditions) : t.conditions;
717
- return [a == null ? void 0 : a.operation, a == null ? void 0 : a.name].includes(n);
718
- }), !i && r === y.F_RULE_SUBJECT.enum.report && (i = {
719
- label: "",
720
- subject: y.F_RULE_SUBJECT.enum.report,
721
- actions: ["read"],
722
- conditions: { name: n },
723
- inverted: !1,
724
- reason: ""
725
- })) : i = M.find((t) => t.subject === r), i ? w(i) : void 0;
726
- }
727
- function xe(e, s) {
728
- const r = { values: [], passthrough: [], dropped: [] };
729
- for (const n of e) {
730
- const i = n == null ? void 0 : n.actions;
731
- if (typeof (n == null ? void 0 : n.subject) != "string" || n.subject.trim().length === 0 || !Array.isArray(i) || i.length === 0 || i.some((u) => typeof u != "string" || u.trim().length === 0)) {
732
- r.dropped.push(n);
733
- continue;
734
- }
735
- const t = w(n).value, a = `${y.F_RULE_SUBJECT.enum.report}:`, o = t.startsWith(a) ? t.slice(a.length) : "";
736
- s.has(t) || o && o !== "undefined" ? r.values.push(t) : r.passthrough.push(n);
737
- }
738
- return r;
739
- }
740
- function he(e, s = []) {
741
- return W(
742
- e.reduce((r, n) => {
743
- const i = ve.find(
744
- (t) => t.subject === n.subject && n.actions.includes("manage")
745
- ) || s.find((t) => t.subject === n.subject);
746
- if (i) {
747
- const t = i.subject === _.Subject.Business.inventory_stock ? "Warehouse Management" : i.label;
748
- r.push(t);
749
- }
750
- return r;
751
- }, [])
752
- );
753
- }
754
- export {
755
- G as N,
756
- Q as P,
757
- pe as R,
758
- Je as a,
759
- de as b,
760
- H as c,
761
- ge as d,
762
- Le as e,
763
- Fe as f,
764
- Te as g,
765
- Me as h,
766
- oe as i,
767
- Be as j,
768
- Ee as k,
769
- _e as l,
770
- Ae as m,
771
- Ne as n,
772
- Ue as o,
773
- ve as p,
774
- me as q,
775
- w as r,
776
- xe as s,
777
- Ce as t,
778
- re as u,
779
- he as v,
780
- Oe as w,
781
- Y as x,
782
- be as y
783
- };