@feedmepos/mf-hrm-portal 2.1.1-dev.5 → 2.1.1-dev.7

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 (60) hide show
  1. package/dist/ApprovalCodeList-CQApO-t4.js +728 -0
  2. package/dist/{AuditLogList-CXUkbDyT.js → AuditLogList-DH2ZvAVE.js} +244 -240
  3. package/dist/ConditionFormHost.vue_vue_type_script_setup_true_lang-B5OgqCR0.js +387 -0
  4. package/dist/EmployeeList-B1Q4RH2r.js +883 -0
  5. package/dist/{GrantUserList-DKP4MBQM.js → GrantUserList-DURXYzRs.js} +140 -137
  6. package/dist/{Main-CyCfz4ka.js → Main-B06aoNy1.js} +1033 -1029
  7. package/dist/{Main-Cz1pfe2k.js → Main-BC7IPhbz.js} +7 -7
  8. package/dist/Main-BRrcfqXc.js +121 -0
  9. package/dist/PermissionSetList-CiVFvnlW.js +393 -0
  10. package/dist/PortalPermissionEditor.vue_vue_type_script_setup_true_lang-BAmLIGEn.js +4122 -0
  11. package/dist/{PortalUserSearcher.vue_vue_type_style_index_0_scoped_a439fdd8_lang-BJp9hEfv.js → PortalUserSearcher.vue_vue_type_style_index_0_scoped_827dfd60_lang-DVVSBIx2.js} +1 -0
  12. package/dist/ResponsiveFabButton.vue_vue_type_script_setup_true_lang-QrqYEy8i.js +42 -0
  13. package/dist/RoleList-BVFWURdS.js +685 -0
  14. package/dist/TableEmptyState.vue_vue_type_script_setup_true_lang-IfAZmWr0.js +37 -0
  15. package/dist/TeamMemberList-DlurP2WR.js +1215 -0
  16. package/dist/{TimesheetList-s_bP5OGA.js → TimesheetList-C4G2Va4m.js} +118 -112
  17. package/dist/{TimesheetList.vue_vue_type_style_index_0_scoped_91afda4e_lang-BCLv-2Re.js → TimesheetList.vue_vue_type_style_index_0_scoped_2c7a177a_lang-BJujYg6e.js} +2 -2
  18. package/dist/{app-BP0oihBR.js → app-CGL_lSgW.js} +5073 -2360
  19. package/dist/app.js +1 -1
  20. package/dist/{dayjs.min-BTSZLci9.js → dayjs.min-BXDtus8O.js} +1 -1
  21. package/dist/{employee-BPv1j6T4.js → employee-CVZUQI_y.js} +3 -3
  22. package/dist/{iteration-BNA1cEos.js → iteration-BXcl549C.js} +1 -1
  23. package/dist/{lodash-DKG9IyB-.js → lodash-CmrNrQXn.js} +1 -1
  24. package/dist/{role-BS3LFO8u.js → role-Ct8MPQeS.js} +1 -1
  25. package/dist/rule-M8SC_Jhl.js +1058 -0
  26. package/dist/src/components/CheckboxInput.vue.d.ts +1 -1
  27. package/dist/src/components/button/ResponsiveFabButton.vue.d.ts +7 -1
  28. package/dist/src/components/table/TableEmptyState.vue.d.ts +7 -15
  29. package/dist/src/composables/useBasePermission.d.ts +2 -1
  30. package/dist/src/composables/useConditionDraft.d.ts +40 -0
  31. package/dist/src/composables/useCoverConditionOverride.d.ts +61 -0
  32. package/dist/src/helpers/business-timezone.d.ts +22 -0
  33. package/dist/src/helpers/filter.d.ts +15 -0
  34. package/dist/src/helpers/permission-reconcile.d.ts +15 -0
  35. package/dist/src/helpers/permission-reconcile.test.d.ts +1 -0
  36. package/dist/src/helpers/permission-set.d.ts +8 -4
  37. package/dist/src/helpers/rule.d.ts +2 -1
  38. package/dist/src/stores/permission-set.d.ts +12 -3
  39. package/dist/src/types/approval-code.d.ts +29 -48
  40. package/dist/src/views/hr/employee/EmployeeList.vue.d.ts +1 -0
  41. package/dist/src/views/team/components/BasePermission.vue.d.ts +13 -0
  42. package/dist/src/views/team/condition-builders/ConditionFormHost.vue.d.ts +22 -0
  43. package/dist/src/views/team/condition-builders/ConditionFormRenderer.vue.d.ts +23 -0
  44. package/dist/src/views/team/condition-builders/component-map.d.ts +4 -0
  45. package/dist/src/views/team/condition-builders/condition-form-dedupe.d.ts +23 -0
  46. package/dist/src/views/team/locales/index.d.ts +80 -0
  47. package/dist/style.css +1 -1
  48. package/dist/tsconfig.app.tsbuildinfo +1 -1
  49. package/dist/{useReportPermissions-J3-DjopO.js → useReportPermissions-COONOIe1.js} +3 -3
  50. package/package.json +2 -2
  51. package/dist/ApprovalCodeList-CXJyMKEg.js +0 -757
  52. package/dist/CollapsibleWrapper.vue_vue_type_script_setup_true_lang-BLJlmPVa.js +0 -58
  53. package/dist/EmployeeList-BSfUFTcN.js +0 -899
  54. package/dist/Main-CblWfQk_.js +0 -122
  55. package/dist/PermissionSetList-BwyblSeE.js +0 -357
  56. package/dist/PortalPermissionEditor.vue_vue_type_script_setup_true_lang-BJ-PZ2Nv.js +0 -3458
  57. package/dist/ResponsiveFabButton.vue_vue_type_script_setup_true_lang-Cn-3MRBO.js +0 -38
  58. package/dist/RoleList-CXYgCmHp.js +0 -567
  59. package/dist/TeamMemberList-CnLbqaPS.js +0 -1131
  60. package/dist/rule-DaSLVZWm.js +0 -996
@@ -0,0 +1,1215 @@
1
+ import { defineComponent as Ie, resolveComponent as F, createElementBlock as N, openBlock as y, createElementVNode as u, createVNode as d, toDisplayString as k, unref as r, computed as I, ref as b, createCommentVNode as K, withCtx as ue, createBlock as z, watch as fe, Fragment as Ne, renderList as us, withKeys as qe, withModifiers as Ve, nextTick as ms, onUnmounted as ds, h as cs, createTextVNode as ps } from "vue";
2
+ import { useI18n as Pe, useCoreStore as Ae, baseClientInstance as Ke } from "@feedmepos/mf-common";
3
+ import { useSnackbar as He, useDialog as es, useBreakpoints as ss, components as je } from "@feedmepos/ui-library";
4
+ import { u as fs, _ as vs } from "./useDebounce-CWb5QR9G.js";
5
+ import { _ as bs, S as ye } from "./SelectFilter-ATOm0hdn.js";
6
+ import { v as ze, m as hs, b as ys, _ as _s, a as gs } from "./app-CGL_lSgW.js";
7
+ import { u as xs, _ as Us } from "./useDiscardConfirm-DPhEV6v0.js";
8
+ import { _ as Ss } from "./TableEmptyState.vue_vue_type_script_setup_true_lang-IfAZmWr0.js";
9
+ import { u as Fs } from "./useLoading-BH02lYns.js";
10
+ import { l as Se } from "./lodash-CmrNrQXn.js";
11
+ import { c as he } from "./iteration-BXcl549C.js";
12
+ import { u as ts, c as Le, d as Ge, m as Me, i as as, p as We, j as Vs, k as Je, l as Xe, s as ws, n as Is, o as Ps, q as ks, v as Rs, t as Fe } from "./rule-M8SC_Jhl.js";
13
+ import { u as ls } from "./role-Ct8MPQeS.js";
14
+ import { u as os, i as $s } from "./PortalUserSearcher.vue_vue_type_style_index_0_scoped_827dfd60_lang-DVVSBIx2.js";
15
+ import { g as Ze, u as rs } from "./restaurant-YOVMuuFY.js";
16
+ import { _ as Cs } from "./PortalPermissionEditor.vue_vue_type_script_setup_true_lang-BAmLIGEn.js";
17
+ var ge = /* @__PURE__ */ ((i) => (i.Update = "Update", i.Remove = "Remove", i))(ge || {});
18
+ const we = "__unassigned__";
19
+ function Qe(i) {
20
+ if (!(i != null && i.length) || i[0] === we) return i;
21
+ const R = i.filter((n) => n !== we);
22
+ return R.length === i.length ? i : [we, ...R];
23
+ }
24
+ const Ms = { class: "w-full flex flex-col gap-16" }, Ns = { class: "flex items-center gap-16" }, As = { class: "space-y-4 min-w-0 flex-1" }, Es = { class: "text-fm-color-typo-secondary fm-typo-en-body-lg-400" }, Ds = { class: "fm-typo-en-body-lg-600 truncate" }, Os = { class: "w-full flex gap-16 items-center" }, Bs = { class: "flex-1 flex flex-col gap-4 min-w-0" }, js = { class: "text-fm-color-typo-secondary fm-typo-en-body-lg-400" }, Ls = { class: "fm-typo-en-body-lg-600 truncate" }, Ts = { class: "flex-1 flex flex-col gap-4 min-w-0" }, qs = { class: "text-fm-color-typo-secondary fm-typo-en-body-lg-400" }, Ks = { class: "fm-typo-en-body-lg-600 truncate" }, zs = /* @__PURE__ */ Ie({
25
+ __name: "MemberInfo",
26
+ props: {
27
+ data: {}
28
+ },
29
+ setup(i) {
30
+ const { t: R } = Pe();
31
+ return (n, a) => {
32
+ const f = F("FmAvatar");
33
+ return y(), N("div", Ms, [
34
+ u("div", Ns, [
35
+ d(f, {
36
+ size: "xl",
37
+ name: i.data.name
38
+ }, null, 8, ["name"]),
39
+ u("div", As, [
40
+ u("p", Es, k(r(R)("team.memberForm.memberInfo.memberName")), 1),
41
+ u("p", Ds, k(i.data.name || "--"), 1)
42
+ ])
43
+ ]),
44
+ u("div", Os, [
45
+ u("div", Bs, [
46
+ u("p", js, k(r(R)("team.memberForm.memberInfo.mobileNumber")), 1),
47
+ u("p", Ls, k(i.data.phoneNumber || "--"), 1)
48
+ ]),
49
+ u("div", Ts, [
50
+ u("p", qs, k(r(R)("team.memberForm.memberInfo.emailAddress")), 1),
51
+ u("p", Ks, k(i.data.email || "--"), 1)
52
+ ])
53
+ ])
54
+ ]);
55
+ };
56
+ }
57
+ }), Ye = {
58
+ async readPermissionUserByPhoneNo(i) {
59
+ var n;
60
+ const { currentBusiness: R } = Ae();
61
+ return Ze(
62
+ await Ke("/").get(`/user/b/${(n = R.value) == null ? void 0 : n._id}/phone/${i}`)
63
+ );
64
+ },
65
+ async readPermissionUserByEmail(i) {
66
+ var n;
67
+ const { currentBusiness: R } = Ae();
68
+ return Ze(
69
+ await Ke("/").get(`/user/b/${(n = R.value) == null ? void 0 : n._id}/email/${i}`)
70
+ );
71
+ }
72
+ }, Gs = { class: "flex flex-col gap-24 w-full" }, Ws = {
73
+ key: 0,
74
+ class: "flex flex-col gap-8"
75
+ }, Js = { class: "user-info-icon user-info-icon--lg" }, Xs = { class: "flex-1 overflow-hidden" }, Zs = { class: "profile-displayName" }, Qs = { class: "profile-email" }, Ys = { class: "profile-phone" }, Hs = { key: 2 }, et = /* @__PURE__ */ Ie({
76
+ __name: "PortalUserSearcher",
77
+ emits: ["invite"],
78
+ setup(i, { emit: R }) {
79
+ const n = R, { t: a } = Pe(), f = He(), A = Ae(), { supportedCountries: V, ready: $ } = os(), se = I(() => {
80
+ var l;
81
+ const o = (l = A.currentCountry.value) == null ? void 0 : l.toUpperCase();
82
+ return o && $s(o) ? o : void 0;
83
+ }), g = b("phone"), S = b(""), p = b(""), h = b(), me = /^[^\s@]+@[^\s@]+\.[^\s@]+$/, j = I(() => me.test(p.value.trim()));
84
+ async function L() {
85
+ const o = g.value === "phone" ? S.value.replace(/ /g, "") : p.value.trim();
86
+ if (!o) {
87
+ f.open({
88
+ type: "error",
89
+ title: a("team.memberForm.searchUser.emptyError")
90
+ });
91
+ return;
92
+ }
93
+ if (g.value === "email" && !j.value) {
94
+ f.open({
95
+ type: "error",
96
+ title: a("team.memberForm.searchUser.invalidEmail")
97
+ });
98
+ return;
99
+ }
100
+ const l = () => {
101
+ h.value = void 0, f.open({
102
+ type: "error",
103
+ title: a("team.memberForm.searchUser.userNotFound")
104
+ });
105
+ };
106
+ try {
107
+ const v = g.value === "phone" ? await Ye.readPermissionUserByPhoneNo(o) : await Ye.readPermissionUserByEmail(o);
108
+ if (!v) {
109
+ l();
110
+ return;
111
+ }
112
+ h.value = v;
113
+ } catch {
114
+ h.value = void 0, f.open({
115
+ type: "error",
116
+ title: a("team.memberForm.searchUser.searchFailed")
117
+ });
118
+ }
119
+ }
120
+ const C = I(() => {
121
+ var x;
122
+ let o = ((x = h.value) == null ? void 0 : x.displayName) ?? "";
123
+ o || (o = "Feed Me");
124
+ const [l, v] = o.split(" ");
125
+ return v ? `${l[0]}${v[0]}` : l.slice(0, 2);
126
+ }), E = b(!1);
127
+ function W(o) {
128
+ n("invite", o), E.value = !0;
129
+ }
130
+ function te() {
131
+ E.value = !1;
132
+ }
133
+ return (o, l) => {
134
+ var B, m, _;
135
+ const v = F("FmRadio"), x = F("FmPhoneNumber"), J = F("FmCircularProgress"), X = F("FmTextField"), O = F("FmRadioGroup"), D = F("FmButton");
136
+ return y(), N("div", Gs, [
137
+ E.value ? K("", !0) : (y(), N("div", Ws, [
138
+ d(O, {
139
+ modelValue: g.value,
140
+ "onUpdate:modelValue": l[2] || (l[2] = (w) => g.value = w)
141
+ }, {
142
+ default: ue(() => [
143
+ d(v, {
144
+ value: "phone",
145
+ label: r(a)("team.memberForm.searchUser.phoneNumber")
146
+ }, null, 8, ["label"]),
147
+ g.value === "phone" && r($) ? (y(), z(x, {
148
+ key: 0,
149
+ modelValue: S.value,
150
+ "onUpdate:modelValue": l[0] || (l[0] = (w) => S.value = w),
151
+ "default-country": se.value,
152
+ "extra-country-codes": r(V),
153
+ class: "ml-8"
154
+ }, null, 8, ["modelValue", "default-country", "extra-country-codes"])) : g.value === "phone" ? (y(), z(J, {
155
+ key: 1,
156
+ class: "ml-8"
157
+ })) : K("", !0),
158
+ d(v, {
159
+ value: "email",
160
+ label: r(a)("team.memberForm.searchUser.email")
161
+ }, null, 8, ["label"]),
162
+ g.value === "email" ? (y(), z(X, {
163
+ key: 2,
164
+ modelValue: p.value,
165
+ "onUpdate:modelValue": l[1] || (l[1] = (w) => p.value = w),
166
+ placeholder: r(a)("team.memberForm.searchUser.emailPlaceholder"),
167
+ rules: [
168
+ (w) => !w || j.value || r(a)("team.memberForm.searchUser.invalidEmail")
169
+ ],
170
+ class: "ml-8"
171
+ }, null, 8, ["modelValue", "placeholder", "rules"])) : K("", !0)
172
+ ]),
173
+ _: 1
174
+ }, 8, ["modelValue"]),
175
+ d(D, {
176
+ label: r(a)("team.memberForm.searchUser.search"),
177
+ variant: "secondary",
178
+ onClick: L
179
+ }, null, 8, ["label"])
180
+ ])),
181
+ h.value ? (y(), N("div", {
182
+ key: 1,
183
+ class: "profile-menu--profile cursor-pointer hover:bg-fm-color-opacity-sm",
184
+ onClick: l[3] || (l[3] = (w) => W(h.value))
185
+ }, [
186
+ u("div", Js, k(C.value), 1),
187
+ u("div", Xs, [
188
+ u("p", Zs, k((B = h.value) == null ? void 0 : B.displayName), 1),
189
+ u("p", Qs, k((m = h.value) == null ? void 0 : m.email), 1),
190
+ u("p", Ys, k((_ = h.value) == null ? void 0 : _.phoneNumber), 1)
191
+ ])
192
+ ])) : K("", !0),
193
+ E.value ? (y(), N("div", Hs, [
194
+ d(D, {
195
+ label: r(a)("team.memberForm.searchUser.changeUser"),
196
+ variant: "secondary",
197
+ onClick: te
198
+ }, null, 8, ["label"])
199
+ ])) : K("", !0)
200
+ ]);
201
+ };
202
+ }
203
+ }), st = /* @__PURE__ */ bs(et, [["__scopeId", "data-v-827dfd60"]]), tt = { class: "flex flex-col gap-40" }, at = { class: "flex items-center" }, lt = { class: "flex-1 flex flex-col" }, ot = { class: "fm-typo-en-title-sm-600" }, rt = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, nt = { class: "flex flex-row gap-16" }, it = { class: "flex flex-col gap-8" }, ut = { class: "fm-typo-en-body-lg-400" }, mt = { class: "space-y-16 rounded-lg border border-fm-color-neutral-gray-200 p-16" }, dt = { class: "fm-typo-en-title-sm-600" }, ct = { class: "space-y-16" }, pt = { class: "grid grid-cols-[minmax(0,1fr)_minmax(0,1fr)_auto] gap-16" }, ft = { class: "text-sm font-semibold text-fm-color-typo-primary" }, vt = { class: "text-sm font-semibold text-fm-color-typo-primary" }, bt = { class: "flex justify-self-end" }, ht = ["aria-label", "onClick", "onKeydown"], Te = 4, yt = /* @__PURE__ */ Ie({
204
+ __name: "TeamMemberMasterUser",
205
+ props: {
206
+ modelValue: {
207
+ type: Object,
208
+ default: void 0
209
+ },
210
+ fallbackName: {
211
+ type: String,
212
+ required: !0
213
+ },
214
+ fallbackPasscode: {
215
+ type: String,
216
+ default: void 0
217
+ },
218
+ restaurants: {
219
+ type: Array,
220
+ required: !0
221
+ },
222
+ roles: {
223
+ type: Array,
224
+ required: !0
225
+ }
226
+ },
227
+ emits: ["update:model-value"],
228
+ setup(i, { emit: R }) {
229
+ const n = i, a = R, { t: f } = Pe(), A = b(!0), V = b([]);
230
+ function $() {
231
+ return { restaurantId: "", roleId: "" };
232
+ }
233
+ const se = I(
234
+ () => {
235
+ var o;
236
+ return ((o = n.modelValue) == null ? void 0 : o.roles.map((l) => l.restaurantId).filter(Boolean)) ?? [];
237
+ }
238
+ );
239
+ function g(o) {
240
+ o ? n.modelValue || a("update:model-value", {
241
+ code: "",
242
+ name: n.fallbackName,
243
+ roles: [$()],
244
+ passcode: n.fallbackPasscode || ""
245
+ }) : a("update:model-value", null);
246
+ }
247
+ function S(o, l) {
248
+ if (!n.modelValue || o === "passcode" && n.modelValue.passcode === l) return;
249
+ const v = he(n.modelValue);
250
+ v[o] = l, a("update:model-value", v);
251
+ }
252
+ function p(o = "") {
253
+ return n.restaurants.filter((l) => l.managable || l._id === o).map((l) => ({
254
+ label: `${l.profile.code ? `${l.profile.code} - ` : ""}${l.profile.name}`,
255
+ value: l._id,
256
+ disabled: se.value.includes(l._id) && l._id !== o
257
+ }));
258
+ }
259
+ function h(o = "") {
260
+ return n.roles.map((l) => ({
261
+ label: l.label,
262
+ value: l.value,
263
+ disabled: !!l.disabled && l.value !== o
264
+ }));
265
+ }
266
+ function me(o, l) {
267
+ var O, D, B;
268
+ if (!n.modelValue) return;
269
+ const v = n.modelValue.roles.length > 0 ? [...n.modelValue.roles] : [$()], x = ((O = v[o]) == null ? void 0 : O.roleId) ?? "", J = h(x), X = ((D = J.find((m) => m.value === x && !m.disabled)) == null ? void 0 : D.value) ?? ((B = J.find((m) => !m.disabled)) == null ? void 0 : B.value) ?? "";
270
+ v[o] = { restaurantId: l, roleId: X }, S("roles", v);
271
+ }
272
+ function j(o, l) {
273
+ var x;
274
+ if (!n.modelValue) return;
275
+ const v = n.modelValue.roles.length > 0 ? [...n.modelValue.roles] : [$()];
276
+ v[o] = {
277
+ restaurantId: ((x = v[o]) == null ? void 0 : x.restaurantId) ?? "",
278
+ roleId: l
279
+ }, S("roles", v);
280
+ }
281
+ function L() {
282
+ n.modelValue && S("roles", [...n.modelValue.roles, $()]);
283
+ }
284
+ function C(o) {
285
+ if (!n.modelValue) return;
286
+ const l = n.modelValue.roles.length > 0 ? [...n.modelValue.roles] : [$()];
287
+ S(
288
+ "roles",
289
+ l.length === 1 ? [$()] : l.filter((v, x) => x !== o)
290
+ );
291
+ }
292
+ const E = I(() => {
293
+ if (!n.modelValue) return !1;
294
+ const o = n.restaurants.some(
295
+ (v) => v.managable && !se.value.includes(v._id)
296
+ ), l = n.modelValue.roles.every(
297
+ (v) => v.restaurantId && v.roleId
298
+ );
299
+ return o && l;
300
+ });
301
+ function W() {
302
+ A.value && (A.value = !1, V.value = [], S("passcode", ""));
303
+ }
304
+ fe(
305
+ () => {
306
+ var o;
307
+ return (o = n.modelValue) == null ? void 0 : o.passcode;
308
+ },
309
+ (o) => {
310
+ o && o.length === Te ? (V.value = o.split(""), A.value = !0) : (V.value = [], A.value = !1);
311
+ },
312
+ { immediate: !0 }
313
+ ), fe(
314
+ () => {
315
+ var o;
316
+ return (o = n.modelValue) == null ? void 0 : o.roles;
317
+ },
318
+ (o) => {
319
+ n.modelValue && (!o || o.length === 0) && S("roles", [$()]);
320
+ },
321
+ { immediate: !0, deep: !0 }
322
+ );
323
+ const te = I({
324
+ get: () => {
325
+ var o;
326
+ return ((o = n.modelValue) == null ? void 0 : o.roles) ?? [];
327
+ },
328
+ set: () => {
329
+ }
330
+ });
331
+ return (o, l) => {
332
+ const v = F("FmSwitch"), x = F("FmTextField"), J = F("FmPinField"), X = F("FmFormGroup"), O = F("FmSelect"), D = F("FmIcon"), B = F("FmButton");
333
+ return y(), N("div", tt, [
334
+ u("div", at, [
335
+ u("div", lt, [
336
+ u("div", ot, k(r(f)("team.memberForm.masterUser.title")), 1),
337
+ u("div", rt, k(r(f)("team.memberForm.masterUser.sublabel")), 1)
338
+ ]),
339
+ u("div", null, [
340
+ d(v, {
341
+ "model-value": !!i.modelValue,
342
+ value: "master-user",
343
+ "onUpdate:modelValue": g
344
+ }, null, 8, ["model-value"])
345
+ ])
346
+ ]),
347
+ i.modelValue ? (y(), N(Ne, { key: 0 }, [
348
+ u("div", nt, [
349
+ d(x, {
350
+ "model-value": i.modelValue.code,
351
+ label: r(f)("team.memberForm.masterUser.code"),
352
+ "onUpdate:modelValue": l[0] || (l[0] = (m) => S("code", m))
353
+ }, null, 8, ["model-value", "label"]),
354
+ d(x, {
355
+ "model-value": i.modelValue.name,
356
+ class: "w-full",
357
+ label: r(f)("team.memberForm.masterUser.name"),
358
+ rules: [(m) => !!m || r(f)("team.memberForm.masterUser.nameEmptyError")],
359
+ "onUpdate:modelValue": l[1] || (l[1] = (m) => S("name", m))
360
+ }, null, 8, ["model-value", "label", "rules"])
361
+ ]),
362
+ u("div", it, [
363
+ u("div", ut, k(r(f)("team.memberForm.masterUser.passcode")), 1),
364
+ d(X, {
365
+ modelValue: V.value,
366
+ "onUpdate:modelValue": l[4] || (l[4] = (m) => V.value = m),
367
+ rules: [
368
+ (m) => (m == null ? void 0 : m.filter((_) => !!_).length) !== Te ? r(f)("team.memberForm.masterUser.passcodeRequired") : !0
369
+ ]
370
+ }, {
371
+ default: ue(() => [
372
+ (y(), z(J, {
373
+ key: `pin-field-${A.value}`,
374
+ modelValue: V.value,
375
+ "onUpdate:modelValue": l[2] || (l[2] = (m) => V.value = m),
376
+ length: Te,
377
+ masked: A.value,
378
+ onComplete: l[3] || (l[3] = (m) => S("passcode", m)),
379
+ onFocus: W
380
+ }, null, 8, ["modelValue", "masked"]))
381
+ ]),
382
+ _: 1
383
+ }, 8, ["modelValue", "rules"])
384
+ ]),
385
+ d(X, {
386
+ tag: "div",
387
+ modelValue: te.value,
388
+ "onUpdate:modelValue": l[5] || (l[5] = (m) => te.value = m),
389
+ rules: [
390
+ (m) => !m || m.length === 0 || m.every((_) => !_.restaurantId) ? r(f)("team.memberForm.masterUser.restaurantRequired") : m.some((_) => !_.restaurantId || !_.roleId) ? r(f)("team.memberForm.masterUser.roleRequired") : !0
391
+ ]
392
+ }, {
393
+ default: ue(() => [
394
+ u("div", mt, [
395
+ u("div", dt, k(r(f)("team.memberForm.masterUser.assignmentSection")), 1),
396
+ u("div", ct, [
397
+ u("div", pt, [
398
+ u("div", ft, k(r(f)("team.table.columns.restaurant")), 1),
399
+ u("div", vt, k(r(f)("team.memberForm.masterUser.role")), 1),
400
+ l[6] || (l[6] = u("div", null, null, -1))
401
+ ]),
402
+ (y(!0), N(Ne, null, us(i.modelValue.roles, (m, _) => (y(), N("div", {
403
+ key: `${m.restaurantId || "new"}-${_}`,
404
+ class: "grid grid-cols-[minmax(0,1fr)_minmax(0,1fr)_auto] items-center gap-16"
405
+ }, [
406
+ d(O, {
407
+ class: "min-w-0",
408
+ "model-value": m.restaurantId,
409
+ items: p(m.restaurantId),
410
+ multiselect: !1,
411
+ placeholder: r(f)("team.table.columns.restaurant"),
412
+ "onUpdate:modelValue": (w) => me(_, w)
413
+ }, null, 8, ["model-value", "items", "placeholder", "onUpdate:modelValue"]),
414
+ d(O, {
415
+ class: "min-w-0",
416
+ "model-value": m.roleId,
417
+ items: h(m.roleId),
418
+ multiselect: !1,
419
+ placeholder: r(f)("team.memberForm.masterUser.role"),
420
+ disabled: !m.restaurantId,
421
+ "onUpdate:modelValue": (w) => j(_, w)
422
+ }, null, 8, ["model-value", "items", "placeholder", "disabled", "onUpdate:modelValue"]),
423
+ u("div", bt, [
424
+ i.modelValue.roles.length > 1 ? (y(), N("div", {
425
+ key: 0,
426
+ role: "button",
427
+ tabindex: "0",
428
+ class: "inline-flex h-40 w-40 shrink-0 cursor-pointer items-center justify-center rounded-lg text-fm-color-neutral-gray-400 transition-colors hover:bg-fm-color-neutral-gray-100 focus:outline-none focus:ring-2 focus:ring-fm-color-primary",
429
+ "aria-label": r(f)("common.remove"),
430
+ onClick: Ve((w) => C(_), ["stop"]),
431
+ onKeydown: [
432
+ qe(Ve((w) => C(_), ["prevent", "stop"]), ["enter"]),
433
+ qe(Ve((w) => C(_), ["prevent", "stop"]), ["space"])
434
+ ]
435
+ }, [
436
+ d(D, {
437
+ name: "delete",
438
+ size: "md"
439
+ })
440
+ ], 40, ht)) : K("", !0)
441
+ ])
442
+ ]))), 128))
443
+ ]),
444
+ d(B, {
445
+ type: "button",
446
+ variant: "secondary",
447
+ "text-color": "primary",
448
+ "border-color": "primary",
449
+ "prepend-icon": "add",
450
+ label: r(f)("team.memberForm.masterUser.addAnother"),
451
+ size: "md",
452
+ disabled: !E.value,
453
+ onClick: Ve(L, ["stop"])
454
+ }, null, 8, ["label", "disabled"])
455
+ ])
456
+ ]),
457
+ _: 1
458
+ }, 8, ["modelValue", "rules"])
459
+ ], 64)) : K("", !0)
460
+ ]);
461
+ };
462
+ }
463
+ }), _t = { class: "flex flex-col gap-32" }, gt = { class: "flex w-full" }, xt = {
464
+ key: 0,
465
+ class: "space-y-24"
466
+ }, Ut = { class: "space-y-16 rounded-lg border border-fm-color-neutral-gray-200 p-16" }, St = { class: "fm-typo-en-title-sm-600" }, Ft = { class: "space-y-16" }, Vt = { class: "fm-typo-en-title-sm-600" }, wt = {
467
+ key: 1,
468
+ class: "flex items-center justify-center py-64"
469
+ }, It = /* @__PURE__ */ Ie({
470
+ __name: "AddMemberForm",
471
+ props: {
472
+ initialValue: {
473
+ type: Object
474
+ },
475
+ roleErrorMessage: {
476
+ type: String,
477
+ default: ""
478
+ },
479
+ loading: {
480
+ type: Boolean,
481
+ default: !1
482
+ }
483
+ },
484
+ setup(i, { expose: R }) {
485
+ var Re, le, Z;
486
+ const n = i, { t: a } = Pe(), f = es(), { breakpoints: A } = ss(), V = b(), $ = ts(), se = I(
487
+ () => $.permissionSets.value.map((s) => ({
488
+ label: s.name,
489
+ value: s.id
490
+ }))
491
+ ), g = b(((Re = n.initialValue) == null ? void 0 : Re.permissionSetIds) || []), S = I(
492
+ () => Le(g.value, $.permissionSets.value)
493
+ ), p = b((le = n.initialValue) == null ? void 0 : le.posUser), h = b(
494
+ Ge(
495
+ Me(S.value),
496
+ ((Z = n.initialValue) == null ? void 0 : Z.permissions) || []
497
+ )
498
+ ), { customReportPermissions: me, isLoaded: j } = as(), L = new Set(
499
+ We.filter((s) => s.subject.startsWith(Vs)).map((s) => s.subject)
500
+ ), C = I(() => {
501
+ const s = new Set(L);
502
+ for (const c of me.value) s.add(c.subject);
503
+ return s;
504
+ }), E = I(() => {
505
+ const s = /* @__PURE__ */ new Set();
506
+ for (const c of We)
507
+ c.category === ze.reports && s.add(c.subject);
508
+ for (const c of me.value)
509
+ c.category === ze.reports && s.add(c.subject);
510
+ return s;
511
+ }), W = rs(), te = ls().roles, o = I(() => Je(h.value)), l = I(() => {
512
+ const s = Xe(h.value);
513
+ return s === null ? W.restaurants.value : W.restaurants.value.filter((c) => s.includes(c._id));
514
+ }), v = I(() => {
515
+ const s = o.value;
516
+ return te.value.map(
517
+ (c) => ({
518
+ label: c.name,
519
+ value: c._id,
520
+ disabled: !!s && !s.includes(c._id)
521
+ })
522
+ );
523
+ }), x = b({ permissionSetIds: [], userPermissions: [], posUser: void 0 });
524
+ function J(s) {
525
+ V.value = void 0, g.value = [...(s == null ? void 0 : s.permissionSetIds) ?? []], h.value = Ge(
526
+ Me(
527
+ Le(
528
+ g.value,
529
+ $.permissionSets.value
530
+ )
531
+ ),
532
+ (s == null ? void 0 : s.permissions) || []
533
+ ), p.value = s != null && s.posUser ? ve(he(s.posUser), h.value) : void 0, be.value = !!p.value, x.value = {
534
+ permissionSetIds: [...g.value],
535
+ userPermissions: he(h.value),
536
+ posUser: p.value ? he(p.value) : void 0
537
+ };
538
+ }
539
+ function X() {
540
+ return !n.initialValue && V.value ? !0 : !Se.isEqual(g.value, x.value.permissionSetIds) || !Se.isEqual(h.value, x.value.userPermissions) || !Se.isEqual(p.value, x.value.posUser);
541
+ }
542
+ function O(s) {
543
+ V.value = s;
544
+ }
545
+ function D(s) {
546
+ p.value = ve(p.value, s);
547
+ }
548
+ function B(s) {
549
+ return Me(
550
+ Le(s, $.permissionSets.value)
551
+ );
552
+ }
553
+ function m(s) {
554
+ h.value = B(s);
555
+ }
556
+ function _(s) {
557
+ const c = [...s ?? []];
558
+ if (Se.isEqual(c, g.value)) return;
559
+ const T = !Se.isEqual(
560
+ h.value,
561
+ B(g.value)
562
+ );
563
+ if (g.value = c, !T) {
564
+ m(c);
565
+ return;
566
+ }
567
+ f.open({
568
+ title: a("permissionSet.form.overrideInherited.title"),
569
+ message: a("permissionSet.form.overrideInherited.message"),
570
+ minWidth: A.value.lg ? 588 : 0,
571
+ primaryActions: {
572
+ text: a("permissionSet.form.overrideInherited.override"),
573
+ close: !1
574
+ },
575
+ secondaryActions: {
576
+ text: a("permissionSet.form.overrideInherited.keepCurrent"),
577
+ close: !0
578
+ }
579
+ }).onPrimary(() => {
580
+ m(c), f.close();
581
+ });
582
+ }
583
+ function w() {
584
+ const s = j.value ? C.value : L, c = Ps(h.value, s);
585
+ return ks(c, E.value);
586
+ }
587
+ function Ee() {
588
+ const s = Me(S.value), c = ws(w());
589
+ return Is(s, c);
590
+ }
591
+ function ke() {
592
+ var T, G, Q, q, ce, Y, H, oe, pe, $e;
593
+ const s = Ee(), c = w().filter((re) => !re.inverted);
594
+ return {
595
+ email: ((T = V.value) == null ? void 0 : T.email) ?? void 0,
596
+ phoneNumber: ((G = V.value) == null ? void 0 : G.phoneNumber) ?? void 0,
597
+ customPermissions: s,
598
+ permissions: c.map((re) => ({
599
+ ...re,
600
+ subject: hs(re.subject)
601
+ })),
602
+ permissionSetIds: g.value,
603
+ name: ((Q = V.value) == null ? void 0 : Q.displayName) || ((q = n.initialValue) == null ? void 0 : q.name) || "",
604
+ posUser: p.value ? {
605
+ ...p.value,
606
+ name: p.value.name || ((Y = (ce = n.initialValue) == null ? void 0 : ce.posUser) == null ? void 0 : Y.name) || ((H = n.initialValue) == null ? void 0 : H.name) || ((oe = V.value) == null ? void 0 : oe.displayName) || "",
607
+ code: p.value.code || (($e = (pe = n.initialValue) == null ? void 0 : pe.posUser) == null ? void 0 : $e.code) || "",
608
+ passcode: p.value.passcode,
609
+ roles: p.value.roles.filter((re) => !!re.roleId)
610
+ } : p.value === null ? null : void 0
611
+ };
612
+ }
613
+ const ae = b();
614
+ function ve(s, c) {
615
+ if (!s) return s;
616
+ const T = Je(c), G = Xe(c);
617
+ if (T === null && G === null) return s;
618
+ const Q = he(s);
619
+ return Q.roles = Q.roles.filter(
620
+ (q) => (T === null || T.includes(q.roleId)) && (G === null || G.includes(q.restaurantId))
621
+ ), Q;
622
+ }
623
+ const be = b(!!p.value), de = b(!1);
624
+ function De(s) {
625
+ p.value = s, de.value = !0;
626
+ }
627
+ fe(
628
+ () => !!p.value,
629
+ async (s) => {
630
+ s && !be.value && de.value && (await ms(), ae.value && ae.value.$el.scrollIntoView({ behavior: "smooth", block: "start" })), be.value = s;
631
+ }
632
+ );
633
+ const xe = b();
634
+ async function Oe() {
635
+ return (await xe.value.validateInputsWithoutSubmit()).length ? null : ke();
636
+ }
637
+ return fe(
638
+ () => n.initialValue,
639
+ (s, c) => {
640
+ if (!c || !s || c.id !== s.id) {
641
+ de.value = !1, J(s);
642
+ return;
643
+ }
644
+ s.posUser !== void 0 && !de.value && (p.value = s.posUser ? ve(he(s.posUser), h.value) : void 0, x.value = {
645
+ ...x.value,
646
+ posUser: p.value ? he(p.value) : void 0
647
+ });
648
+ },
649
+ { immediate: !0 }
650
+ ), fe(
651
+ h,
652
+ (s) => {
653
+ p.value = ve(p.value, s);
654
+ },
655
+ { deep: !0 }
656
+ ), R({
657
+ readFormData: ke,
658
+ validate: Oe,
659
+ isModified: X
660
+ }), (s, c) => {
661
+ const T = F("FmSelect"), G = F("FmCircularProgress"), Q = F("FmForm");
662
+ return y(), z(Q, {
663
+ ref_key: "formRef",
664
+ ref: xe,
665
+ class: "mx-4"
666
+ }, {
667
+ default: ue(() => {
668
+ var q, ce, Y, H, oe;
669
+ return [
670
+ u("div", _t, [
671
+ u("div", gt, [
672
+ i.initialValue ? (y(), z(zs, {
673
+ key: 1,
674
+ data: i.initialValue
675
+ }, null, 8, ["data"])) : (y(), z(st, {
676
+ key: 0,
677
+ onInvite: c[0] || (c[0] = (pe) => O(pe))
678
+ }))
679
+ ]),
680
+ V.value || i.initialValue ? (y(), N(Ne, { key: 0 }, [
681
+ (q = i.initialValue) != null && q.isOwner ? K("", !0) : (y(), N("div", xt, [
682
+ u("div", Ut, [
683
+ u("div", St, k(r(a)("team.memberForm.permissionSet.title")), 1),
684
+ d(T, {
685
+ "model-value": g.value,
686
+ multiselect: "",
687
+ searchable: "",
688
+ "search-debounce": 300,
689
+ items: se.value,
690
+ placeholder: r(a)("team.memberForm.permissionSet.selectPlaceholder"),
691
+ "onUpdate:modelValue": _
692
+ }, null, 8, ["model-value", "items", "placeholder"])
693
+ ]),
694
+ u("div", Ft, [
695
+ u("div", Vt, k(r(a)("team.memberForm.permissions.title")), 1),
696
+ d(Cs, {
697
+ modelValue: h.value,
698
+ "onUpdate:modelValue": c[1] || (c[1] = (pe) => h.value = pe),
699
+ "inherit-permissions": S.value,
700
+ onPermissionChanged: D
701
+ }, null, 8, ["modelValue", "inherit-permissions"])
702
+ ])
703
+ ])),
704
+ i.loading ? (y(), N("div", wt, [
705
+ d(G, { size: "xl" })
706
+ ])) : (y(), z(yt, {
707
+ key: 2,
708
+ ref_key: "masterUserContentRef",
709
+ ref: ae,
710
+ "model-value": p.value,
711
+ "fallback-name": ((ce = i.initialValue) == null ? void 0 : ce.name) || ((Y = V.value) == null ? void 0 : Y.displayName) || "",
712
+ "fallback-passcode": (oe = (H = i.initialValue) == null ? void 0 : H.posUser) == null ? void 0 : oe.passcode,
713
+ roles: v.value,
714
+ restaurants: l.value,
715
+ "onUpdate:modelValue": De
716
+ }, null, 8, ["model-value", "fallback-name", "fallback-passcode", "roles", "restaurants"]))
717
+ ], 64)) : K("", !0)
718
+ ])
719
+ ];
720
+ }),
721
+ _: 1
722
+ }, 512);
723
+ };
724
+ }
725
+ }), Pt = {
726
+ class: "space-y-24"
727
+ }, kt = {
728
+ class: "space-y-8"
729
+ }, Rt = {
730
+ key: 0,
731
+ class: "flex w-full items-start justify-between px-16"
732
+ }, $t = {
733
+ class: "flex items-start gap-8"
734
+ }, Ct = {
735
+ key: 1,
736
+ class: "space-y-4 px-16"
737
+ }, Mt = {
738
+ class: "flex items-start gap-8"
739
+ }, Nt = {
740
+ class: "flex h-full flex-col overflow-auto"
741
+ }, At = {
742
+ class: "flex w-full items-center justify-between"
743
+ }, Et = {
744
+ class: "fm-typo-en-title-md-600"
745
+ }, Dt = {
746
+ class: "flex items-center justify-start gap-8"
747
+ }, _e = 100;
748
+ var ee = /* @__PURE__ */ function(i) {
749
+ return i[i.ADD = 0] = "ADD", i[i.UPDATE = 1] = "UPDATE", i[i.CLOSED = 2] = "CLOSED", i;
750
+ }(ee || {});
751
+ const ea = /* @__PURE__ */ Ie({
752
+ __name: "TeamMemberList",
753
+ setup(i, {
754
+ expose: R
755
+ }) {
756
+ const {
757
+ fetchCustomReportPermissions: n
758
+ } = as();
759
+ os();
760
+ const {
761
+ t: a
762
+ } = Pe(), f = Ae(), A = rs(), V = ls(), $ = He(), se = Fs($), g = ts(), S = Rs(), p = b(!0), h = b(!1), me = I(() => A.isLoading.value), j = b([]), L = b(0), C = b(1), E = b(""), W = b("");
763
+ fe(A.restaurants, (e) => {
764
+ if (e.length > 0 && j.value.length > 0) {
765
+ const t = new Map(e.map((P) => [P._id, P.profile.name])), U = e.map((P) => P.profile.name).sort();
766
+ j.value = j.value.map((P) => ({
767
+ ...P,
768
+ restaurants: P.managableRestaurantIds === null ? U : P.managableRestaurantIds.map((ne) => t.get(ne) ?? "").filter(Boolean).sort()
769
+ }));
770
+ }
771
+ });
772
+ const te = I(() => [{
773
+ label: a("team.filter.unassigned_label"),
774
+ value: we
775
+ }, ...A.restaurants.value.map((e) => ({
776
+ label: `${e.profile.code ? `${e.profile.code} - ` : ""}${e.profile.name}`,
777
+ value: e._id
778
+ }))]), o = ({
779
+ member: e,
780
+ className: t = ""
781
+ }) => {
782
+ const U = {
783
+ label: a("team.actions.updateMember"),
784
+ onClick: () => B(ge.Update, e)
785
+ }, P = {
786
+ label: a("team.actions.removeMember"),
787
+ onClick: () => B(ge.Remove, e),
788
+ itemClass: "text-fm-color-typo-error"
789
+ }, ne = e.doc.isOwner ? [U] : [U, P];
790
+ return d(Us, {
791
+ class: t,
792
+ items: ne
793
+ }, null);
794
+ }, l = (e) => e.doc.isOwner ? a("team.labels.businessOwner") : e.restaurants.join(", "), v = [{
795
+ accessorKey: "name",
796
+ header: () => a("team.table.columns.name"),
797
+ enableSorting: !1,
798
+ cell(e) {
799
+ const t = e.row.original;
800
+ return d("div", {
801
+ class: "flex items-center gap-8"
802
+ }, [d(je.FmAvatar, {
803
+ name: t.name,
804
+ size: "sm",
805
+ class: "shrink-0"
806
+ }, null), d("span", {
807
+ class: "truncate"
808
+ }, [t.name])]);
809
+ }
810
+ }, {
811
+ accessorKey: "phoneNumber",
812
+ header: () => a("team.table.columns.phoneNumber"),
813
+ enableSorting: !1
814
+ }, {
815
+ accessorKey: "restaurant",
816
+ header: () => a("team.table.columns.restaurant"),
817
+ enableSorting: !1,
818
+ cell(e) {
819
+ if (me.value)
820
+ return cs(vs);
821
+ const t = e.row.original;
822
+ return l(t);
823
+ }
824
+ }, {
825
+ accessorKey: "assignedRoles",
826
+ header: () => a("team.table.columns.assignedRoles"),
827
+ enableSorting: !1,
828
+ cell(e) {
829
+ const t = e.row.original, U = S.getPermissionAssignmentByUserId(t.id), P = (U == null ? void 0 : U.permissionSetIds) || t.doc.permissionSetIds || [];
830
+ return g.permissionSets.value.filter((ie) => P.includes(ie.id)).map((ie) => ie.name).join(", ");
831
+ }
832
+ }, {
833
+ accessorKey: "permission",
834
+ header: () => a("team.table.columns.permission"),
835
+ enableSorting: !1,
836
+ cell(e) {
837
+ const t = e.row.original;
838
+ return x(t);
839
+ },
840
+ meta: {
841
+ width: "200px"
842
+ }
843
+ }, {
844
+ id: "action",
845
+ meta: {
846
+ cellClass: "pl-16",
847
+ headerContentClass: "-mx-16"
848
+ },
849
+ cell(e) {
850
+ const t = e.row.original;
851
+ return o({
852
+ member: t,
853
+ className: "flex justify-end w-full"
854
+ });
855
+ },
856
+ enableSorting: !1
857
+ }];
858
+ function x(e) {
859
+ if (e.doc.isOwner)
860
+ return a("team.labels.businessOwner");
861
+ const t = d(je.FmTooltip, {
862
+ variant: "plain",
863
+ placement: "top"
864
+ }, {
865
+ default: () => d(je.FmIcon, {
866
+ name: "info",
867
+ class: "cursor-pointer text-fm-color-neutral-gray-300"
868
+ }, null),
869
+ content: () => d("div", null, [a("team.labels.permission"), e.permissionLabels.map((U) => d("div", null, [ps("- "), U]))])
870
+ });
871
+ return d("div", {
872
+ class: "flex flex-row items-center gap-8"
873
+ }, [d("span", null, [a("team.labels.allowed", {
874
+ count: e.permissionLabels.length
875
+ })]), e.permissionLabels.length > 0 && t]);
876
+ }
877
+ function J(e) {
878
+ var ne, ie, Ce, Ue;
879
+ const t = S.getPermissionAssignmentByUserId(e.id), U = (t == null ? void 0 : t.customPermissions) ?? e.permissions ?? [], P = (t == null ? void 0 : t.permissionSetIds) ?? e.doc.permissionSetIds ?? [];
880
+ return {
881
+ id: e.id,
882
+ isOwner: e.doc.isOwner,
883
+ name: e.name,
884
+ phoneNumber: e.phoneNumber,
885
+ email: e.email,
886
+ permissions: U,
887
+ permissionSetIds: P,
888
+ posUser: e.doc.posUser ? {
889
+ code: ((ne = e.doc.posUser) == null ? void 0 : ne.code) ?? "",
890
+ name: ((ie = e.doc.posUser) == null ? void 0 : ie.name) ?? e.name,
891
+ passcode: ((Ce = e.doc.posUser) == null ? void 0 : Ce.passcode) ?? "",
892
+ roles: ((Ue = e.doc.posUser) == null ? void 0 : Ue.roles) ?? []
893
+ } : void 0
894
+ };
895
+ }
896
+ function X(e) {
897
+ const t = S.getPermissionAssignmentByUserId(e.id), U = (t == null ? void 0 : t.customPermissions) ?? e.permissions ?? [], P = (t == null ? void 0 : t.permissionSetIds) ?? e.doc.permissionSetIds ?? [];
898
+ return {
899
+ id: e.id,
900
+ isOwner: e.doc.isOwner,
901
+ name: e.name,
902
+ phoneNumber: e.phoneNumber,
903
+ email: e.email,
904
+ permissions: U,
905
+ permissionSetIds: P,
906
+ posUser: void 0
907
+ };
908
+ }
909
+ const O = b(!1);
910
+ let D = 0;
911
+ const B = async (e, t) => {
912
+ if (e == ge.Update) {
913
+ const U = ++D;
914
+ ae.value = X(t), _.value = ee.UPDATE, O.value = t.doc.hasPosUser === !0;
915
+ try {
916
+ const P = await Fe.readTeamMember(t.id);
917
+ if (U !== D) return;
918
+ ae.value = J(P);
919
+ } catch {
920
+ if (U !== D) return;
921
+ $.open({
922
+ message: a("common.error"),
923
+ type: "error"
924
+ }), de();
925
+ } finally {
926
+ U === D && (O.value = !1);
927
+ }
928
+ }
929
+ e == ge.Remove && Oe(t);
930
+ }, m = es(), _ = b(ee.CLOSED), w = I(() => _.value !== ee.CLOSED), Ee = I(() => _.value === ee.ADD ? a("common.add") : a("common.update")), ke = I(() => _.value === ee.ADD ? a("team.actions.addMember") : a("team.actions.updateMember")), ae = b();
931
+ function ve() {
932
+ D++, O.value = !1, _.value = ee.CLOSED;
933
+ }
934
+ const be = xs(() => {
935
+ var e;
936
+ return ((e = Y.value) == null ? void 0 : e.isModified()) ?? !1;
937
+ }, ve);
938
+ function de() {
939
+ be();
940
+ }
941
+ function De(e) {
942
+ e || de();
943
+ }
944
+ const {
945
+ breakpoints: xe
946
+ } = ss(), Oe = (e) => {
947
+ m.open({
948
+ title: a("team.actions.removeMember"),
949
+ message: a("team.removeMember.confirmationMessage", {
950
+ memberName: e.name
951
+ }),
952
+ minWidth: xe.value.lg ? 588 : 0,
953
+ primaryActions: {
954
+ text: "Remove",
955
+ close: !1,
956
+ variant: "destructive",
957
+ isLoading: oe
958
+ },
959
+ secondaryActions: {
960
+ text: "Cancel",
961
+ close: !0
962
+ }
963
+ }).onPrimary(async () => {
964
+ oe.value || (await se.minor(async () => {
965
+ await Fe.deleteTeamMember(e.id), await ce();
966
+ }, {
967
+ isLoading: oe,
968
+ successMessage: a("team.removeMember.successMessage", {
969
+ memberName: e.name
970
+ })
971
+ }), m.close());
972
+ });
973
+ }, Re = () => {
974
+ ae.value = null, _.value = ee.ADD;
975
+ }, le = b(), Z = b(), s = b(), c = I(() => {
976
+ var e;
977
+ return JSON.stringify({
978
+ businessId: ((e = f.currentBusiness.value) == null ? void 0 : e._id) ?? "",
979
+ search: W.value.trim(),
980
+ restaurantIds: [...le.value ?? []].sort(),
981
+ permissionSubjects: [...Z.value ?? []].sort(),
982
+ permissionSetIds: [...s.value ?? []].sort()
983
+ });
984
+ }), T = I(() => Object.values(ys).map((e) => ({
985
+ label: e.label,
986
+ value: e.subject
987
+ }))), G = I(() => [{
988
+ label: a("team.filter.unassigned_label"),
989
+ value: we
990
+ }, ...g.permissionSets.value.map((e) => ({
991
+ label: e.name,
992
+ value: e.id
993
+ }))]);
994
+ async function Q() {
995
+ await V.readRoles();
996
+ }
997
+ async function q(e = C.value) {
998
+ var t;
999
+ p.value = !0;
1000
+ try {
1001
+ const U = await Fe.readTeamMembersPage({
1002
+ limit: _e,
1003
+ offset: (e - 1) * _e,
1004
+ search: W.value.trim() || void 0,
1005
+ restaurantIds: Qe(le.value),
1006
+ permissionSubjects: (t = Z.value) != null && t.length ? Z.value : void 0,
1007
+ permissionSetIds: Qe(s.value)
1008
+ });
1009
+ j.value = U.items, L.value = U.total;
1010
+ } finally {
1011
+ p.value = !1;
1012
+ }
1013
+ }
1014
+ async function ce() {
1015
+ var t;
1016
+ if (!((t = f.currentBusiness.value) != null && t._id)) return;
1017
+ await q(C.value);
1018
+ const e = Math.max(1, Math.ceil(L.value / _e));
1019
+ C.value > e && (C.value = e, await q(C.value));
1020
+ }
1021
+ const Y = b(), H = b(!1), oe = b(!1);
1022
+ async function pe() {
1023
+ if (!Y.value) return;
1024
+ const e = await Y.value.validate();
1025
+ if (!e) return;
1026
+ const t = _.value === ee.ADD;
1027
+ await se.minor(async () => {
1028
+ await (t ? Fe.createTeamMember(e) : Fe.updateTeamMember(ae.value.id, e)), ve(), await re(), await ce();
1029
+ }, {
1030
+ successMessage: t ? a("team.addMember.successMessage", {
1031
+ memberName: e.name
1032
+ }) : a("team.updateMember.successMessage", {
1033
+ memberName: e.name
1034
+ }),
1035
+ isLoading: H
1036
+ }), _.value = ee.CLOSED;
1037
+ }
1038
+ async function $e() {
1039
+ await g.readPermissionSets();
1040
+ }
1041
+ async function re() {
1042
+ await S.readPermissionAssignments();
1043
+ }
1044
+ let Be = !1;
1045
+ async function ns({
1046
+ pageIndex: e
1047
+ }) {
1048
+ var t;
1049
+ if ((t = f.currentBusiness.value) != null && t._id && !Be && !(e === 0 && C.value === 1 && j.value.length > 0)) {
1050
+ Be = !0, C.value = e + 1;
1051
+ try {
1052
+ await q(C.value);
1053
+ } finally {
1054
+ Be = !1;
1055
+ }
1056
+ }
1057
+ }
1058
+ const is = fs(E, () => {
1059
+ W.value = E.value;
1060
+ });
1061
+ return ds(is), fe(c, async () => {
1062
+ var e;
1063
+ C.value = 1, h.value = !1, (e = f.currentBusiness.value) != null && e._id && (await q(1), h.value = !0);
1064
+ }, {
1065
+ immediate: !0
1066
+ }), fe(f.currentBusiness, async () => {
1067
+ var e;
1068
+ if ((e = f.currentBusiness.value) != null && e._id)
1069
+ try {
1070
+ await Promise.all([A.readRestaurants(), $e(), re(), n(), Q()]);
1071
+ } catch (t) {
1072
+ console.error("Failed to load team member dependencies:", t), $.open({
1073
+ message: t instanceof Error ? t.message : String(t),
1074
+ type: "error"
1075
+ });
1076
+ }
1077
+ }, {
1078
+ immediate: !0
1079
+ }), R({
1080
+ create: Re
1081
+ }), (e, t) => {
1082
+ var Ue;
1083
+ const U = F("FmSearch"), P = F("FmTable"), ne = F("FmIcon"), ie = F("FmButton"), Ce = F("FmSideSheet");
1084
+ return y(), N(Ne, null, [u("div", Pt, [u("div", kt, [r(xe).xs ? (y(), N("div", Ct, [d(U, {
1085
+ modelValue: E.value,
1086
+ "onUpdate:modelValue": t[4] || (t[4] = (M) => E.value = M),
1087
+ class: "w-[320px] xs:w-full xs:mt-8",
1088
+ placeholder: r(a)("team.search.placeholder")
1089
+ }, null, 8, ["modelValue", "placeholder"]), u("div", Mt, [d(ye, {
1090
+ modelValue: le.value,
1091
+ "onUpdate:modelValue": t[5] || (t[5] = (M) => le.value = M),
1092
+ multiple: "",
1093
+ items: te.value,
1094
+ variant: "dark",
1095
+ "selected-prefix": r(a)("team.table.columns.restaurant"),
1096
+ placeholder: r(a)("team.table.columns.restaurant"),
1097
+ class: "!w-auto"
1098
+ }, null, 8, ["modelValue", "items", "selected-prefix", "placeholder"]), d(ye, {
1099
+ modelValue: Z.value,
1100
+ "onUpdate:modelValue": t[6] || (t[6] = (M) => Z.value = M),
1101
+ multiple: "",
1102
+ variant: "dark",
1103
+ items: T.value,
1104
+ "selected-prefix": r(a)("team.filter.selected_permission_prefix"),
1105
+ placeholder: r(a)("team.filter.permission_placeholder")
1106
+ }, null, 8, ["modelValue", "items", "selected-prefix", "placeholder"]), d(ye, {
1107
+ modelValue: s.value,
1108
+ "onUpdate:modelValue": t[7] || (t[7] = (M) => s.value = M),
1109
+ multiple: "",
1110
+ variant: "dark",
1111
+ items: G.value,
1112
+ "selected-prefix": r(a)("team.filter.selected_assigned_role_prefix"),
1113
+ placeholder: r(a)("team.filter.assigned_role_placeholder")
1114
+ }, null, 8, ["modelValue", "items", "selected-prefix", "placeholder"])])])) : (y(), N("div", Rt, [u("div", $t, [d(ye, {
1115
+ modelValue: le.value,
1116
+ "onUpdate:modelValue": t[0] || (t[0] = (M) => le.value = M),
1117
+ multiple: "",
1118
+ items: te.value,
1119
+ variant: "dark",
1120
+ "selected-prefix": r(a)("team.table.columns.restaurant"),
1121
+ placeholder: r(a)("team.table.columns.restaurant"),
1122
+ class: "!w-auto"
1123
+ }, null, 8, ["modelValue", "items", "selected-prefix", "placeholder"]), d(ye, {
1124
+ modelValue: Z.value,
1125
+ "onUpdate:modelValue": t[1] || (t[1] = (M) => Z.value = M),
1126
+ multiple: "",
1127
+ variant: "dark",
1128
+ items: T.value,
1129
+ "selected-prefix": r(a)("team.filter.selected_permission_prefix"),
1130
+ placeholder: r(a)("team.filter.permission_placeholder")
1131
+ }, null, 8, ["modelValue", "items", "selected-prefix", "placeholder"]), d(ye, {
1132
+ modelValue: s.value,
1133
+ "onUpdate:modelValue": t[2] || (t[2] = (M) => s.value = M),
1134
+ multiple: "",
1135
+ variant: "dark",
1136
+ items: G.value,
1137
+ "selected-prefix": r(a)("team.filter.selected_assigned_role_prefix"),
1138
+ placeholder: r(a)("team.filter.assigned_role_placeholder")
1139
+ }, null, 8, ["modelValue", "items", "selected-prefix", "placeholder"])]), d(U, {
1140
+ modelValue: E.value,
1141
+ "onUpdate:modelValue": t[3] || (t[3] = (M) => E.value = M),
1142
+ class: "w-[320px] xs:w-full xs:mt-8",
1143
+ autofocus: "",
1144
+ placeholder: r(a)("team.search.placeholder")
1145
+ }, null, 8, ["modelValue", "placeholder"])])), (Ue = r(f).currentBusiness.value) != null && Ue._id ? (y(), z(_s, {
1146
+ key: 2
1147
+ }, {
1148
+ default: ue(() => [u("div", Nt, [h.value ? K("", !0) : (y(), z(gs, {
1149
+ key: 0
1150
+ })), h.value ? (y(), z(Ss, {
1151
+ key: 1,
1152
+ "is-loading": p.value,
1153
+ "is-empty": L.value === 0,
1154
+ title: r(a)("team.emptyState.title"),
1155
+ subtitle: r(a)("team.emptyState.description")
1156
+ }, {
1157
+ default: ue(() => [(y(), z(P, {
1158
+ key: c.value,
1159
+ "column-defs": v,
1160
+ "row-data": j.value,
1161
+ "page-size": _e,
1162
+ "page-count": Math.ceil(L.value / _e),
1163
+ "row-count": L.value,
1164
+ "fetch-fn": ns,
1165
+ "hide-footer": L.value <= _e,
1166
+ loading: p.value,
1167
+ "pin-header-row": "",
1168
+ onRowClick: t[8] || (t[8] = (M) => B(r(ge).Update, M.original))
1169
+ }, null, 8, ["row-data", "page-count", "row-count", "hide-footer", "loading"]))]),
1170
+ _: 1
1171
+ }, 8, ["is-loading", "is-empty", "title", "subtitle"])) : K("", !0)])]),
1172
+ _: 1
1173
+ })) : K("", !0)])]), d(Ce, {
1174
+ "model-value": w.value,
1175
+ "max-width": 960,
1176
+ "close-button": !1,
1177
+ "onUpdate:modelValue": De,
1178
+ "onOn:clickedAway": r(be)
1179
+ }, {
1180
+ "side-sheet-header": ue(() => [u("div", At, [u("p", Et, k(ke.value), 1), d(ne, {
1181
+ name: "close",
1182
+ size: "md",
1183
+ class: "cursor-pointer",
1184
+ onClick: r(be)
1185
+ }, null, 8, ["onClick"])])]),
1186
+ "side-sheet-footer": ue(() => [u("div", Dt, [d(ie, {
1187
+ label: Ee.value,
1188
+ size: "md",
1189
+ variant: "primary",
1190
+ "is-loading": H.value,
1191
+ disabled: H.value,
1192
+ onClick: Ve(pe, ["prevent"])
1193
+ }, null, 8, ["label", "is-loading", "disabled"]), d(ie, {
1194
+ label: r(a)("common.cancel"),
1195
+ size: "md",
1196
+ variant: "secondary",
1197
+ disabled: H.value,
1198
+ onClick: de
1199
+ }, null, 8, ["label", "disabled"])])]),
1200
+ default: ue(() => [w.value ? (y(), z(It, {
1201
+ key: 0,
1202
+ ref_key: "memberForm",
1203
+ ref: Y,
1204
+ initialValue: ae.value,
1205
+ loading: O.value,
1206
+ class: "gap-8"
1207
+ }, null, 8, ["initialValue", "loading"])) : K("", !0)]),
1208
+ _: 1
1209
+ }, 8, ["model-value", "onOn:clickedAway"])], 64);
1210
+ };
1211
+ }
1212
+ });
1213
+ export {
1214
+ ea as default
1215
+ };