@feedmepos/mf-hrm-portal 2.3.2-dev.16 → 2.3.2-dev.17

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 (108) hide show
  1. package/dist/{ApprovalCodeList-B3jNdAYD.js → ApprovalCodeList-Bo8IbNxV.js} +15 -14
  2. package/dist/{AuditLogList-khYZrM4O.js → AuditLogList-C7CjPILA.js} +833 -823
  3. package/dist/ConditionBuilderForm.vue_vue_type_script_setup_true_lang-C-4BaMN-.js +438 -0
  4. package/dist/EmployeeList-BOP-gaTp.js +776 -0
  5. package/dist/FormItem.vue_vue_type_script_setup_true_lang-BEOR-8QD.js +45 -0
  6. package/dist/FormSection.vue_vue_type_script_setup_true_lang-DknXTYiK.js +49 -0
  7. package/dist/{GrantUserList-Cyde_ZvG.js → GrantUserList-CXWGr3Wo.js} +16 -15
  8. package/dist/Main-BrP1frfO.js +96 -0
  9. package/dist/{Main-DunDfrfn.js → Main-DeuWov9n.js} +5 -5
  10. package/dist/{Main-D7L7IaSi.js → Main-bru10M5U.js} +2097 -2102
  11. package/dist/PasscodePinField.vue_vue_type_script_setup_true_lang-CqG0v0Sz.js +243 -0
  12. package/dist/{PermissionSetList-CTya3yQD.js → PermissionSetList--xt0piQz.js} +137 -136
  13. package/dist/PortalPermissionEditor.vue_vue_type_script_setup_true_lang-D5nvRsW3.js +4167 -0
  14. package/dist/PortalUserSearcher.vue_vue_type_style_index_0_scoped_827dfd60_lang-DiNDrCy0.js +35 -0
  15. package/dist/RoleList-BEE-8EQK.js +740 -0
  16. package/dist/{ScheduleAddPositionModal.vue_vue_type_script_setup_true_lang-DFIvDycw.js → ScheduleAddPositionModal.vue_vue_type_script_setup_true_lang-Cqo5kHcF.js} +1 -1
  17. package/dist/{ScheduleGeneralPage-SFsD-TKY.js → ScheduleGeneralPage-DxhgBLix.js} +2 -2
  18. package/dist/{ScheduleModal.vue_vue_type_script_setup_true_lang-YeoRA-WZ.js → ScheduleModal.vue_vue_type_script_setup_true_lang-DGPwmNQb.js} +186 -187
  19. package/dist/{SchedulePage-htF58vxp.js → SchedulePage-oBdEvGWN.js} +20 -20
  20. package/dist/{SchedulePositionPage-BVEpQvOB.js → SchedulePositionPage-BZps-kKs.js} +3 -3
  21. package/dist/{SelectFilter-C36mwNN9.js → SelectFilter-Bs_LCk3L.js} +1 -1
  22. package/dist/TeamMemberList-DCgNcs4P.js +1154 -0
  23. package/dist/{TimesheetList-CNixrC8s.js → TimesheetList-BW6iCigo.js} +9 -9
  24. package/dist/{TimesheetList.vue_vue_type_style_index_0_scoped_63294af2_lang-CYtX4RNX.js → TimesheetList.vue_vue_type_style_index_0_scoped_63294af2_lang-Dv66Af5C.js} +3 -3
  25. package/dist/{app-DwJPnksU.js → app-B8xnhtVI.js} +3702 -7565
  26. package/dist/app.js +3 -3
  27. package/dist/{approval-code-2b26Pgxl.js → approval-code-B0jU1bvk.js} +1 -1
  28. package/dist/{dayjs.min-cGJfyGlJ.js → dayjs.min-CdpSCqn1.js} +34 -34
  29. package/dist/{employee-CGDFUIei.js → employee-DlFGiUgI.js} +47 -48
  30. package/dist/{grant-user-3wYZeemh.js → grant-user-C3C6glCk.js} +1 -1
  31. package/dist/{iteration-CN3qkp7j.js → iteration-BM0iyDBd.js} +1 -1
  32. package/dist/{lodash-2kEG2kVJ.js → lodash-KK9U7NAy.js} +1 -1
  33. package/dist/restaurant-C7o2Yk6j.js +2688 -0
  34. package/dist/{role-DnK0aZXF.js → role-DYCorsOh.js} +20 -19
  35. package/dist/rule-BhGHZqKO.js +783 -0
  36. package/dist/src/components/CollapsibleWrapper.vue.d.ts +3 -11
  37. package/dist/src/helpers/permission-set.d.ts +102 -1
  38. package/dist/src/helpers/rule.d.ts +2 -2
  39. package/dist/src/helpers/string.d.ts +1 -10
  40. package/dist/src/router/shared.d.ts +1 -3
  41. package/dist/src/stores/restaurant.d.ts +7 -7
  42. package/dist/src/stores/team.d.ts +1 -31
  43. package/dist/src/types/team.d.ts +1 -17
  44. package/dist/src/views/audit-log/locales/index.d.ts +0 -12
  45. package/dist/src/views/audit-log/useTraceIdDeepLink.d.ts +1 -1
  46. package/dist/src/views/hr/locales/index.d.ts +0 -20
  47. package/dist/src/views/hr/role/RoleForm.vue.d.ts +2 -29
  48. package/dist/src/views/scheduling/composables/useScheduleOnboardingAvailability.d.ts +1 -1
  49. package/dist/src/views/scheduling/composables/useScheduleOnboardingWizard.d.ts +1 -1
  50. package/dist/src/views/scheduling/composables/useScheduleShiftDraft.d.ts +1 -1
  51. package/dist/src/views/scheduling/composables/useScheduleShiftPopover.d.ts +1 -1
  52. package/dist/src/views/team/components/BasePermission.vue.d.ts +0 -11
  53. package/dist/src/views/team/components/ConditionPermission.vue.d.ts +0 -11
  54. package/dist/src/views/team/components/PortalPermissionEditor.vue.d.ts +0 -21
  55. package/dist/src/views/team/components/PosRolePermission.vue.d.ts +0 -11
  56. package/dist/src/views/team/locales/index.d.ts +0 -716
  57. package/dist/src/views/team/member/AddMemberForm.vue.d.ts +3 -48
  58. package/dist/src/views/team/{components/MemberStatusBadge.vue.d.ts → member/MemberInfo.vue.d.ts} +2 -2
  59. package/dist/src/views/team/member/TeamMemberList.vue.d.ts +0 -1
  60. package/dist/string-VNuQNweN.js +15 -0
  61. package/dist/style.css +1 -1
  62. package/dist/tsconfig.app.tsbuildinfo +1 -1
  63. package/dist/{useAppStore-D7B1Uzy9.js → useAppStore-C1lk2Q2j.js} +1 -1
  64. package/dist/{useLoading-Bfisabfg.js → useLoading-CXdGsnHm.js} +1 -1
  65. package/dist/useReportPermissions-D_I4rFVo.js +82 -0
  66. package/package.json +3 -3
  67. package/dist/ConditionBuilderForm.vue_vue_type_script_setup_true_lang-draQ4InF.js +0 -459
  68. package/dist/EmployeeList-Dnublgsa.js +0 -896
  69. package/dist/FormSection.vue_vue_type_script_setup_true_lang-BB43cRca.js +0 -90
  70. package/dist/Main-MWuJXveM.js +0 -101
  71. package/dist/MyPosProfile-GLy8uIjr.js +0 -360
  72. package/dist/PasscodePinField.vue_vue_type_script_setup_true_lang-TXPEqa46.js +0 -126
  73. package/dist/PortalPermissionEditor.vue_vue_type_script_setup_true_lang-B819VW59.js +0 -4212
  74. package/dist/PortalUserSearcher.vue_vue_type_style_index_0_scoped_827dfd60_lang-MXPrxf7_.js +0 -1797
  75. package/dist/RoleForm.vue_vue_type_script_setup_true_lang-MEo4THC2.js +0 -547
  76. package/dist/RoleList-D7cBVxYw.js +0 -274
  77. package/dist/TeamMemberList-CQ_Q-kK_.js +0 -2082
  78. package/dist/member-grant-Tup6x9_U.js +0 -54
  79. package/dist/restaurant-BSeSCAtd.js +0 -49
  80. package/dist/rule-Di8SnWjQ.js +0 -839
  81. package/dist/src/api/my-pos-profile/index.d.ts +0 -3
  82. package/dist/src/api/sso-provider/index.d.ts +0 -5
  83. package/dist/src/api/staff-invite/index.d.ts +0 -16
  84. package/dist/src/components/form/SegmentedTabs.vue.d.ts +0 -23
  85. package/dist/src/composables/useMenuAccess.d.ts +0 -56
  86. package/dist/src/composables/useSsoProviders.d.ts +0 -19
  87. package/dist/src/composables/useStaffInviteProviders.d.ts +0 -8
  88. package/dist/src/composables/useTenant.d.ts +0 -11
  89. package/dist/src/helpers/member-grant.d.ts +0 -36
  90. package/dist/src/helpers/my-pos-profile.d.ts +0 -37
  91. package/dist/src/helpers/pos-assignment-rows.d.ts +0 -28
  92. package/dist/src/helpers/staff-invite.d.ts +0 -54
  93. package/dist/src/router/courtGuard.d.ts +0 -4
  94. package/dist/src/router/menu-access-guard.d.ts +0 -17
  95. package/dist/src/types/my-pos-profile.d.ts +0 -24
  96. package/dist/src/types/sso-provider.d.ts +0 -10
  97. package/dist/src/types/staff-invite.d.ts +0 -100
  98. package/dist/src/views/my-pos-profile/MyPosProfile.vue.d.ts +0 -2
  99. package/dist/src/views/my-pos-profile/components/PasscodeChangedDialog.vue.d.ts +0 -4
  100. package/dist/src/views/my-pos-profile/locales/index.d.ts +0 -236
  101. package/dist/src/views/team/components/MemberGrantFields.vue.d.ts +0 -51
  102. package/dist/src/views/team/components/PosAssignmentRows.vue.d.ts +0 -44
  103. package/dist/src/views/team/member/ExistingMemberNotice.vue.d.ts +0 -11
  104. package/dist/src/views/team/member/MemberDetailsCard.vue.d.ts +0 -35
  105. package/dist/src/views/team/member/MemberHeaderCard.vue.d.ts +0 -19
  106. package/dist/string-DZQ1uNjn.js +0 -22
  107. package/dist/useReportPermissions-BUmyfjFx.js +0 -80
  108. package/dist/useSsoProviders-CJQTq0Fk.js +0 -41
@@ -0,0 +1,783 @@
1
+ import { s as W, c as q, e as y } from "./iteration-BM0iyDBd.js";
2
+ import { i as A, d as V, e as _, c as F, n as S, O as ee, D as M } from "./app-B8xnhtVI.js";
3
+ import { s as se } from "./utils-BZkjJbju.js";
4
+ import { g, b, q as x, u as te } from "./restaurant-C7o2Yk6j.js";
5
+ import { defineStore as z, storeToRefs as K } from "pinia";
6
+ import { ref as h, 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 b().get(E));
11
+ },
12
+ async create(e) {
13
+ return g(await b().post(E, e));
14
+ },
15
+ async update(e, s) {
16
+ return g(await b().put(`${E}/${e}`, s));
17
+ },
18
+ async delete(e) {
19
+ return g(await b().delete(`${E}/${e}`));
20
+ }
21
+ }, ne = z("hrm-permission-set", () => {
22
+ const { currentBusiness: e } = X(), s = h([]), r = h(!1), n = h(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((m) => m.id === c ? d : m));
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 m = D(d.conditions);
96
+ if (!m || !c) {
97
+ d.conditions = void 0;
98
+ return;
99
+ }
100
+ for (const f in c)
101
+ (o = m[f]) != null && o.$in && (u = c[f]) != null && u.$in ? m[f].$in = Array.from(
102
+ /* @__PURE__ */ new Set([...m[f].$in, ...c[f].$in])
103
+ ) : m[f] || (m[f] = c[f]);
104
+ d.conditions = JSON.stringify(m);
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 = A(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_${A(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 m of c.permissions ?? []) {
129
+ const f = A(m.subject), p = B(f, m.actions);
130
+ n.has(p) || t.has(f) || (n.add(p), r.push({
131
+ ...m,
132
+ // FdoPermissionRule.fields is string[] | null; RawRule expects string[] | undefined
133
+ fields: m.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 m of c.permissionSets ?? []) {
143
+ const f = A(m), p = B(f, ["manage"]), v = {
144
+ subject: f,
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(v)), a.push(v);
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 Oe(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 Ae(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 m = Object.keys(l)[0], f = l[m].$in.filter(
230
+ (v) => !d[m].$in.includes(v)
231
+ );
232
+ f.length > 0 && t.push(r(u, f)), d[m].$in.filter(
233
+ (v) => !l[m].$in.includes(v)
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), m = c.actions.some((p) => !l.has(p)), f = u.actions.filter((p) => !d.has(p));
241
+ if (m) {
242
+ const p = c.actions.filter((v) => !l.has(v));
243
+ t.push({
244
+ ...c,
245
+ actions: p
246
+ });
247
+ }
248
+ f.length > 0 && t.push({
249
+ ...u,
250
+ actions: f,
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 m = o.actions;
321
+ if (m.includes("manage"))
322
+ return a.push(o), a;
323
+ const f = new Set(m);
324
+ for (const p of l)
325
+ f.delete(p);
326
+ return f.size === 0 || a.push({ ...o, actions: Array.from(f) }), 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) ?? [], f = (((i = u[l]) == null ? void 0 : i.$in) ?? []).filter((p) => !d.includes(p));
343
+ f.length > 0 ? r.set(t.subject, {
344
+ ...o,
345
+ conditions: JSON.stringify({ [l]: { $in: f } })
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 b().get(P));
389
+ },
390
+ async readByUserId(e) {
391
+ return g(await b().get(`${P}/user/${e}`));
392
+ },
393
+ async readById(e) {
394
+ return g(await b().get(`${P}/${e}`));
395
+ },
396
+ async create(e) {
397
+ return g(await b().post(P, e));
398
+ },
399
+ async update(e, s) {
400
+ return g(await b().put(`${P}/${e}`, s));
401
+ },
402
+ async delete(e) {
403
+ return g(await b().delete(`${P}/${e}`));
404
+ },
405
+ async addReportManagePermission(e, s) {
406
+ return g(
407
+ await b().post("/my-permissions/report-manage", { permissionKey: e, label: s })
408
+ );
409
+ }
410
+ }, me = z("hrm-permission-assignment", () => {
411
+ const e = h([]);
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
+ }), fe = () => {
443
+ const e = me();
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 = h([]), C = h(!1), R = h(!1), $ = h(null), k = h(null), J = h(!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: [S.manage, S.read, S.create],
492
+ category: F.reports
493
+ } : {
494
+ label: n.name,
495
+ subject: `business::report::reports::${n.permissionKey}`,
496
+ actions: [
497
+ S.manage,
498
+ S.read,
499
+ S.create,
500
+ S.update,
501
+ S.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 O(e) {
514
+ const s = re(), r = fe(), 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, ...v }) => v
519
+ ), u = t == null ? void 0 : t.customPermissions, c = u ?? e.permissions.map((p) => ({
520
+ ...p,
521
+ subject: A(p.subject)
522
+ })), l = L(o, c), d = G(
523
+ de(o, c),
524
+ V
525
+ ).filter((p) => !p.inverted), m = Y(d), f = m ?? 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
+ f.map((p) => {
534
+ var v;
535
+ return ((v = n.value.find((Z) => Z._id === p)) == null ? void 0 : v.profile.name) ?? "";
536
+ })
537
+ ),
538
+ managableRestaurantIds: m,
539
+ permissionLabels: Se(d, i.value),
540
+ permissions: l
541
+ };
542
+ }
543
+ const be = Object.freeze(
544
+ Object.values(ee)
545
+ ), Ce = {
546
+ async readTeamMembers() {
547
+ return g(
548
+ await b().get("/portal-users")
549
+ ).map(O);
550
+ },
551
+ async readTeamMembersPage(e) {
552
+ var r, n, i;
553
+ const s = g(
554
+ await b().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(O),
567
+ total: s.total
568
+ };
569
+ },
570
+ async readTeamMember(e) {
571
+ return O(
572
+ g(await b().get(`/portal-users/${e}`))
573
+ );
574
+ },
575
+ async createTeamMember(e) {
576
+ return O(
577
+ g(await b().post("/portal-users", e))
578
+ );
579
+ },
580
+ async updateTeamMember(e, s) {
581
+ return O(
582
+ g(await b().put(`/portal-users/${e}`, s))
583
+ );
584
+ },
585
+ async deleteTeamMember(e) {
586
+ return g(await b().delete(`/portal-users/${e}`));
587
+ },
588
+ async readTeamMemberPosUserIds() {
589
+ return g(await b().get("/portal-users")).map((s) => s.posUserId);
590
+ },
591
+ async generateMasterUserPasscode(e) {
592
+ return `${g(
593
+ await b().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: ve(e) };
678
+ }
679
+ function Me(e) {
680
+ return (e == null ? void 0 : e.some((s) => s.subject === "all")) ?? !1;
681
+ }
682
+ function ve(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 = he(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 he(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 Se(e, s = []) {
741
+ return W(
742
+ e.reduce((r, n) => {
743
+ const i = be.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
+ Oe as m,
771
+ Ne as n,
772
+ Ue as o,
773
+ be as p,
774
+ fe as q,
775
+ w as r,
776
+ xe as s,
777
+ Ce as t,
778
+ re as u,
779
+ Se as v,
780
+ Ae as w,
781
+ Y as x,
782
+ ve as y
783
+ };