@argusoft/medplat-form-engine 1.0.8 → 1.0.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 (119) hide show
  1. package/dist/AccessRights-sgIhYR30-DWNCTLI6.js +1238 -0
  2. package/dist/AccessRights-sgIhYR30-DWNCTLI6.js.map +1 -0
  3. package/dist/AddEditQueryBuilder-BaZxS2Cm-emLM3Oli.js +289 -0
  4. package/dist/AddEditQueryBuilder-BaZxS2Cm-emLM3Oli.js.map +1 -0
  5. package/dist/AddEditQueryBuilder-BaZxS2Cm.css +1 -0
  6. package/dist/AddFeatures-BxXCC6ex-1VYoA24R.js +212 -0
  7. package/dist/AddFeatures-BxXCC6ex-1VYoA24R.js.map +1 -0
  8. package/dist/AddLabelModal-DE3ploGD-DWF1SOUp.js +734 -0
  9. package/dist/AddLabelModal-DE3ploGD-DWF1SOUp.js.map +1 -0
  10. package/dist/AddMenuConfiguration-QWfpcnuP-TAM2c68S.js +5389 -0
  11. package/dist/AddMenuConfiguration-QWfpcnuP-TAM2c68S.js.map +1 -0
  12. package/dist/AddMenuConfiguration-QWfpcnuP.css +1 -0
  13. package/dist/AddRoleDrawer-ZK1eejxI-ldfhQqA_.js +453 -0
  14. package/dist/AddRoleDrawer-ZK1eejxI-ldfhQqA_.js.map +1 -0
  15. package/dist/AppModal-BgZyfrd--CNvWjWhL.js +428 -0
  16. package/dist/AppModal-BgZyfrd--CNvWjWhL.js.map +1 -0
  17. package/dist/ChangePasswordModal-MV7g8tkA-BDA1Pw0i.js +176 -0
  18. package/dist/ChangePasswordModal-MV7g8tkA-BDA1Pw0i.js.map +1 -0
  19. package/dist/ConditionConfig-GDCXIg3C-XbR1fp6h.js +395 -0
  20. package/dist/ConditionConfig-GDCXIg3C-XbR1fp6h.js.map +1 -0
  21. package/dist/ConditionConfig-GDCXIg3C.css +1 -0
  22. package/dist/EntityManagement-D-x6Qzal-BE01iKNR.js +50 -0
  23. package/dist/EntityManagement-D-x6Qzal-BE01iKNR.js.map +1 -0
  24. package/dist/EventConfigurations-jGCJ4LqP-B_ftXinp.js +384 -0
  25. package/dist/EventConfigurations-jGCJ4LqP-B_ftXinp.js.map +1 -0
  26. package/dist/EventConfigurations-jGCJ4LqP.css +1 -0
  27. package/dist/EventsExceptionModal-BF6E1Np7-DHT7pQsx.js +200 -0
  28. package/dist/EventsExceptionModal-BF6E1Np7-DHT7pQsx.js.map +1 -0
  29. package/dist/EventsSkeleton-BN7_0IGs-BAnd1Vug.js +74 -0
  30. package/dist/EventsSkeleton-BN7_0IGs-BAnd1Vug.js.map +1 -0
  31. package/dist/FeatureMenu-BYSRoNm0-D2Ak-EDd.js +249 -0
  32. package/dist/FeatureMenu-BYSRoNm0-D2Ak-EDd.js.map +1 -0
  33. package/dist/Features-CKMmuqcs-ClXAzWGV.js +11 -0
  34. package/dist/Features-CKMmuqcs-ClXAzWGV.js.map +1 -0
  35. package/dist/FlywayQuery-Cx2sly6g-B1LLSyLE.js +169 -0
  36. package/dist/FlywayQuery-Cx2sly6g-B1LLSyLE.js.map +1 -0
  37. package/dist/ImmunizationConfigurationBase-DZ8EqXlF-CSPs9x_q.js +5162 -0
  38. package/dist/ImmunizationConfigurationBase-DZ8EqXlF-CSPs9x_q.js.map +1 -0
  39. package/dist/ImmunizationConfigurationBase-DZ8EqXlF.css +1 -0
  40. package/dist/ImmunizationConfigurationsList-CQnxWa09-DIujYt0W.js +335 -0
  41. package/dist/ImmunizationConfigurationsList-CQnxWa09-DIujYt0W.js.map +1 -0
  42. package/dist/ImmunizationSkeleton-D2tdv5k--B7SY-gnr.js +186 -0
  43. package/dist/ImmunizationSkeleton-D2tdv5k--B7SY-gnr.js.map +1 -0
  44. package/dist/LanguagesModal-rk6IGQwY-Cxw9xctN.js +394 -0
  45. package/dist/LanguagesModal-rk6IGQwY-Cxw9xctN.js.map +1 -0
  46. package/dist/ManageDynamicFeature-CeeqiS3K-D2Se68tC.js +4189 -0
  47. package/dist/ManageDynamicFeature-CeeqiS3K-D2Se68tC.js.map +1 -0
  48. package/dist/ManageEventConfiguration-BJxS2Su0-yd2dUxgz.js +1017 -0
  49. package/dist/ManageEventConfiguration-BJxS2Su0-yd2dUxgz.js.map +1 -0
  50. package/dist/ManageEventConfiguration-BJxS2Su0.css +1 -0
  51. package/dist/ManageNotification-B4prX-9Z-B4mRuGir.js +6819 -0
  52. package/dist/ManageNotification-B4prX-9Z-B4mRuGir.js.map +1 -0
  53. package/dist/ManageRole-ByqBmjuc-CApL3DJy.js +699 -0
  54. package/dist/ManageRole-ByqBmjuc-CApL3DJy.js.map +1 -0
  55. package/dist/ManageTranslation-BTxvSYKb-CwT975cy.js +616 -0
  56. package/dist/ManageTranslation-BTxvSYKb-CwT975cy.js.map +1 -0
  57. package/dist/ManageTranslation-BTxvSYKb.css +1 -0
  58. package/dist/ManageUser-PHiTNyF8-Bddmh2CC.js +2160 -0
  59. package/dist/ManageUser-PHiTNyF8-Bddmh2CC.js.map +1 -0
  60. package/dist/ManageUser-PHiTNyF8.css +1 -0
  61. package/dist/{MedplatFormWrapper-YzMB3zpp.js → MedplatFormWrapper-DbdQUpEu.js} +13624 -13168
  62. package/dist/MedplatFormWrapper-DbdQUpEu.js.map +1 -0
  63. package/dist/MobileMenuManagement-DmQU5TTo-D7n_NP0X.js +108 -0
  64. package/dist/MobileMenuManagement-DmQU5TTo-D7n_NP0X.js.map +1 -0
  65. package/dist/MobileTypeEventConfigModal-ChhO_A4f-Wd3d3SEP.js +782 -0
  66. package/dist/MobileTypeEventConfigModal-ChhO_A4f-Wd3d3SEP.js.map +1 -0
  67. package/dist/NewServerManagement-5YcAtF-g-DHV6PFTR.js +1002 -0
  68. package/dist/NewServerManagement-5YcAtF-g-DHV6PFTR.js.map +1 -0
  69. package/dist/NotificationFlywayQuery-BY8Zzml_-C7G-28dx.js +244 -0
  70. package/dist/NotificationFlywayQuery-BY8Zzml_-C7G-28dx.js.map +1 -0
  71. package/dist/NotificationList-BkpOrCpM-B-vKDGd_.js +400 -0
  72. package/dist/NotificationList-BkpOrCpM-B-vKDGd_.js.map +1 -0
  73. package/dist/OtherTypeEventConfigModal-ZnCGWm9v-tpC-SI0P.js +1952 -0
  74. package/dist/OtherTypeEventConfigModal-ZnCGWm9v-tpC-SI0P.js.map +1 -0
  75. package/dist/QueryBuilder-Cus_mRwZ-DLXSM32i.js +378 -0
  76. package/dist/QueryBuilder-Cus_mRwZ-DLXSM32i.js.map +1 -0
  77. package/dist/QueryBuilder-Cus_mRwZ.css +1 -0
  78. package/dist/QueryManagement-DXA73N2j-Wlk7hKP3.js +671 -0
  79. package/dist/QueryManagement-DXA73N2j-Wlk7hKP3.js.map +1 -0
  80. package/dist/QueryManagement-DXA73N2j.css +1 -0
  81. package/dist/RoleManagement-CLaEJ90J-BW0tG5t9.js +410 -0
  82. package/dist/RoleManagement-CLaEJ90J-BW0tG5t9.js.map +1 -0
  83. package/dist/ServerSyncModal-uNjGCQJz--PJ3F3xg.js +869 -0
  84. package/dist/ServerSyncModal-uNjGCQJz--PJ3F3xg.js.map +1 -0
  85. package/dist/ShowFlywayQuery-DMsAbtOW-TT9XXzUi.js +130 -0
  86. package/dist/ShowFlywayQuery-DMsAbtOW-TT9XXzUi.js.map +1 -0
  87. package/dist/ShowFlywayQuery-DVRCd384-BypXcNWX.js +259 -0
  88. package/dist/ShowFlywayQuery-DVRCd384-BypXcNWX.js.map +1 -0
  89. package/dist/ShowQueryHistory-BDN0tzHg-17BxK88Z.js +190 -0
  90. package/dist/ShowQueryHistory-BDN0tzHg-17BxK88Z.js.map +1 -0
  91. package/dist/SubMenu-BHcSNSUF-d-_yEXeN.js +187 -0
  92. package/dist/SubMenu-BHcSNSUF-d-_yEXeN.js.map +1 -0
  93. package/dist/TableDetails-DzREeJkm-B-WEBbQz.js +1508 -0
  94. package/dist/TableDetails-DzREeJkm-B-WEBbQz.js.map +1 -0
  95. package/dist/TableList-B9hr05Hs-BIsMbnIV.js +428 -0
  96. package/dist/TableList-B9hr05Hs-BIsMbnIV.js.map +1 -0
  97. package/dist/TypeConfiguration-C-lk8Szs-DKu6I5Im.js +116 -0
  98. package/dist/TypeConfiguration-C-lk8Szs-DKu6I5Im.js.map +1 -0
  99. package/dist/UserList-BxB1tCwM-7YIwwGQ9.js +13039 -0
  100. package/dist/UserList-BxB1tCwM-7YIwwGQ9.js.map +1 -0
  101. package/dist/UserList-BxB1tCwM.css +1 -0
  102. package/dist/UserListSkeleton-cglK2SaU-B_Tj5gUp.js +184 -0
  103. package/dist/UserListSkeleton-cglK2SaU-B_Tj5gUp.js.map +1 -0
  104. package/dist/WidgetList-BSApErov-CBYLh0Oh.js +188 -0
  105. package/dist/WidgetList-BSApErov-CBYLh0Oh.js.map +1 -0
  106. package/dist/_commonjsHelpers-BItOPCY9-B9tZyK9c.js +29 -0
  107. package/dist/_commonjsHelpers-BItOPCY9-B9tZyK9c.js.map +1 -0
  108. package/dist/i18next-CTOWN_jH-BKKbdDel.js +1389 -0
  109. package/dist/i18next-CTOWN_jH-BKKbdDel.js.map +1 -0
  110. package/dist/index-B4r0wjBD.js +563 -0
  111. package/dist/index-B4r0wjBD.js.map +1 -0
  112. package/dist/{index-CBsXn92s.js → index-CdFr9tGu.js} +107 -107
  113. package/dist/{index-CBsXn92s.js.map → index-CdFr9tGu.js.map} +1 -1
  114. package/dist/index.js +1 -1
  115. package/dist/manageImmunization-B4swS745-JldexHrO.js +1204 -0
  116. package/dist/manageImmunization-B4swS745-JldexHrO.js.map +1 -0
  117. package/dist/manageImmunization-B4swS745.css +1 -0
  118. package/package.json +1 -1
  119. package/dist/MedplatFormWrapper-YzMB3zpp.js.map +0 -1
@@ -0,0 +1,4189 @@
1
+ import { jsx as i, jsxs as l, Fragment as pe } from "react/jsx-runtime";
2
+ import { execute as J, executeAll as Pi } from "@/common/services/QueryBuilder";
3
+ import { useDebounceFn as cn } from "@/hooks/useDebounceFn.js";
4
+ import Ee from "@/views/custom-components/CustomDropdown";
5
+ import Mt from "@/views/custom-components/CustomSvgUpload";
6
+ import ie from "@/views/custom-components/CustomTextField";
7
+ import { yupResolver as Nn } from "@hookform/resolvers/yup";
8
+ import { d as $t } from "./index-B4r0wjBD.js";
9
+ import { generateUUID as mn } from "@/utils/UUIDgenerator";
10
+ import { getRoleList as Lt, executeQuery as jt } from "@/common/services/GlobalApis";
11
+ import { useTheme as In, debounce as Jt, Box as d, Step as Qt, Typography as c, FormControl as ee, Accordion as Fi, AccordionSummary as Di, AccordionDetails as Vi, Tooltip as Gt, RadioGroup as pn, FormControlLabel as di, Radio as ui, Divider as Xe, Button as U, Checkbox as fn, FormGroup as Ht, TextField as kn, TableContainer as hn, Table as gn, TableHead as yn, TableRow as ci, TableCell as X, TableBody as bn, IconButton as Be, Dialog as _n, DialogTitle as Tn, DialogContent as Fn, DialogContentText as Yt, Grid2 as ve, Chip as mi, Alert as Zt, DialogActions as Dn, Stack as Vn, Select as Xt, MenuItem as vn, Modal as Kt, Card as er, alpha as ir } from "@mui/material";
12
+ import Q from "@mui/material/Grid2";
13
+ import { D as h } from "./i18next-CTOWN_jH-BKKbdDel.js";
14
+ import nr, { useRef as tr, useMemo as xn, useState as g, useEffect as te, useCallback as rr } from "react";
15
+ import { useForm as fi, useWatch as pi, Controller as $ } from "react-hook-form";
16
+ import { useSelector as ar } from "react-redux";
17
+ import { useLocation as lr, useNavigate as or } from "react-router";
18
+ import * as z from "yup";
19
+ import { showToast as me } from "@/common/toaster/toaster";
20
+ import { FormConfiguratorService as Cn } from "@/common/services/FormConfiguratorService";
21
+ import w from "prop-types";
22
+ import { useDebounceFn as sr } from "@/hooks/useDebounceFn";
23
+ import se from "@/common/fontAwesomeIcons/FontAwesomeIcons";
24
+ import Pe from "@/views/custom-components/CustomAutoComplete.jsx";
25
+ import { u as Sn } from "./Features-CKMmuqcs-ClXAzWGV.js";
26
+ import ke from "@/views/custom-components/CustomSwitch";
27
+ import dr from "@/views/custom-components/CustomTextArea";
28
+ import Ei from "@/views/custom-components/CustomCheckBox";
29
+ import wn from "@/views/custom-components/CustomDatePicker";
30
+ import ye from "@/views/custom-components/FieldDescription";
31
+ import { useTranslateProvider as ur } from "@/common/languageTranslator/TranslationContext";
32
+ import { getFeatureData as cr, updateUserMenuItems as mr } from "@/common/services/Features";
33
+ import pr from "@/views/custom-components/CustomRadioComponent";
34
+ function En({
35
+ mainFormCtrl: F,
36
+ openAddFormModal: A,
37
+ setModal: W,
38
+ reloadForms: P
39
+ }) {
40
+ const [f, _] = g(""), [S, K] = g([]), [de, G] = g(!0), B = z.object().shape({
41
+ formName: z.string().required("Enter form name"),
42
+ formCode: z.string().required("Enter form code").matches(
43
+ /^[A-Z_]*$/,
44
+ "Only uppercase letters and underscores are allowed"
45
+ ),
46
+ state: z.string().required("Select state"),
47
+ formType: z.string().required("Select form type"),
48
+ description: z.string().required("Enter description")
49
+ }), I = fi({
50
+ defaultValues: {
51
+ formName: "",
52
+ formCode: "",
53
+ state: "ACTIVE",
54
+ description: "",
55
+ menuConfigId: null,
56
+ pageParams: "",
57
+ formType: null,
58
+ navigationState: "medplat.form"
59
+ },
60
+ resolver: Nn(B),
61
+ mode: "onChange"
62
+ }), re = () => {
63
+ if (f.trim() && !S.includes(f)) {
64
+ const C = [...S, f];
65
+ K(C), _(""), I.setValue("pageParams", C.join(","));
66
+ }
67
+ }, be = (C) => {
68
+ const k = S.filter((H) => H !== C);
69
+ K(k), I.setValue("pageParams", k.join(","));
70
+ }, q = (C) => {
71
+ const k = C.target.value;
72
+ /^[a-zA-Z_]*$/.test(k) && _(k);
73
+ }, T = () => {
74
+ W(!1);
75
+ }, x = (C) => {
76
+ ue(C);
77
+ }, ue = (C) => {
78
+ if (!de) {
79
+ me({ message: "Form Code is already taken!", type: "error" });
80
+ return;
81
+ }
82
+ const k = () => {
83
+ const H = new FormData();
84
+ return H.append(
85
+ "form",
86
+ new Blob([JSON.stringify(C)], {
87
+ type: "application/json"
88
+ })
89
+ ), console.log(H), H;
90
+ };
91
+ C.isSeparateFeature = !0, Cn.saveForm(k()).then(() => {
92
+ me({
93
+ message: "Configuration created sucessfully!",
94
+ type: "success"
95
+ });
96
+ let H = [];
97
+ C.formName && C.formName.length > 0 && H.push({
98
+ code: "medplat_form_insert_into_translation_master",
99
+ parameters: {
100
+ translation_key: C.formName.replaceAll(" ", ""),
101
+ translation_value: C.formName,
102
+ form_code: C.formCode
103
+ },
104
+ sequence: 1
105
+ }), H.length > 0 && Pi(H), F.setValue("formCode", C.formCode), F.setValue("version", "DRAFT"), F.setValue("navigationState", C.navigationState), T(), I.reset({
106
+ formName: "",
107
+ formCode: "",
108
+ state: "ACTIVE",
109
+ description: "",
110
+ menuConfigId: null,
111
+ pageParams: "",
112
+ formType: null,
113
+ navigationState: "medplat.form"
114
+ }), P();
115
+ });
116
+ }, fe = sr(async (C) => {
117
+ if (!(C != null && C.trim())) return;
118
+ const k = (await Cn.checkFormCodeAvailability(C)).data;
119
+ return G(k), k;
120
+ }, 500);
121
+ return /* @__PURE__ */ i(
122
+ _n,
123
+ {
124
+ open: A,
125
+ fullWidth: !0,
126
+ maxWidth: "lg",
127
+ onClose: T,
128
+ slotProps: {
129
+ paper: {
130
+ style: {
131
+ borderRadius: "8px"
132
+ }
133
+ }
134
+ },
135
+ children: /* @__PURE__ */ l(
136
+ "form",
137
+ {
138
+ noValidate: !0,
139
+ onSubmit: (C) => {
140
+ C.preventDefault(), C.stopPropagation(), I.handleSubmit(x)();
141
+ },
142
+ children: [
143
+ /* @__PURE__ */ i(Tn, { children: "Add new form" }),
144
+ /* @__PURE__ */ l(Fn, { children: [
145
+ /* @__PURE__ */ i(Yt, { id: "alert-dialog-slide-description", children: "Please enter all details" }),
146
+ /* @__PURE__ */ l(ve, { container: !0, spacing: 2, columns: 12, sx: { mt: 1 }, children: [
147
+ /* @__PURE__ */ i(ve, { size: 12, children: /* @__PURE__ */ i(Xe, { children: /* @__PURE__ */ i(mi, { label: "Basic Details", size: "small" }) }) }),
148
+ /* @__PURE__ */ i(ve, { size: 4, children: /* @__PURE__ */ i(
149
+ ie,
150
+ {
151
+ control: I.control,
152
+ name: "formName",
153
+ id: "formName",
154
+ fullWidth: !0,
155
+ size: "small",
156
+ label: "Name",
157
+ errors: I.formState.errors,
158
+ required: !0
159
+ }
160
+ ) }),
161
+ /* @__PURE__ */ i(ve, { size: 4, children: /* @__PURE__ */ i(
162
+ ie,
163
+ {
164
+ control: I.control,
165
+ name: "formCode",
166
+ id: "formCode",
167
+ fullWidth: !0,
168
+ size: "small",
169
+ label: "Code",
170
+ errors: {
171
+ ...I.formState.errors,
172
+ ...de === !1 && {
173
+ formCode: { message: "Form Code is already taken!" }
174
+ }
175
+ },
176
+ required: !0,
177
+ onChange: (C) => {
178
+ const k = C.target.value.toUpperCase().replace(/[^A-Z_]/g, "");
179
+ I.setValue("formCode", k), I.setValue(
180
+ "navigationState",
181
+ `medplat.form.${k}`
182
+ ), fe(k);
183
+ }
184
+ }
185
+ ) }),
186
+ /* @__PURE__ */ i(ve, { size: 2, children: /* @__PURE__ */ i(ee, { required: !0, fullWidth: !0, size: "small", children: /* @__PURE__ */ i(
187
+ Ee,
188
+ {
189
+ control: I.control,
190
+ name: "state",
191
+ id: "state",
192
+ options: ["ACTIVE", "INACTIVE"],
193
+ errors: I.formState.errors,
194
+ size: "small",
195
+ placeholder: "",
196
+ label: "State",
197
+ required: !0
198
+ }
199
+ ) }) }),
200
+ /* @__PURE__ */ i(ve, { size: 2, children: /* @__PURE__ */ i(ee, { required: !0, fullWidth: !0, size: "small", children: /* @__PURE__ */ i(
201
+ Ee,
202
+ {
203
+ control: I.control,
204
+ name: "formType",
205
+ id: "formType",
206
+ options: ["FORM", "SEARCH"],
207
+ errors: I.formState.errors,
208
+ size: "small",
209
+ placeholder: "",
210
+ label: "Type",
211
+ required: !0
212
+ }
213
+ ) }) }),
214
+ /* @__PURE__ */ i(ve, { size: 12, children: /* @__PURE__ */ i(
215
+ ie,
216
+ {
217
+ control: I.control,
218
+ name: "description",
219
+ id: "description",
220
+ fullWidth: !0,
221
+ multiline: !0,
222
+ rows: 2,
223
+ size: "small",
224
+ label: "Description",
225
+ errors: I.formState.errors,
226
+ required: !0
227
+ }
228
+ ) }),
229
+ /* @__PURE__ */ i(ve, { size: 12, children: /* @__PURE__ */ i(Xe, { children: /* @__PURE__ */ i(mi, { label: "Page Param Details", size: "small" }) }) }),
230
+ /* @__PURE__ */ l(ve, { size: 12, children: [
231
+ /* @__PURE__ */ i(
232
+ $,
233
+ {
234
+ name: "pageParams",
235
+ control: I.control,
236
+ render: ({ field: C }) => /* @__PURE__ */ i(
237
+ kn,
238
+ {
239
+ ...C,
240
+ label: "Page Params",
241
+ size: "small",
242
+ placeholder: "Add Page Params",
243
+ value: f,
244
+ onChange: q,
245
+ onKeyDown: (k) => {
246
+ k.key === "Enter" && (k.preventDefault(), re());
247
+ },
248
+ fullWidth: !0,
249
+ slotProps: {
250
+ input: {
251
+ endAdornment: /* @__PURE__ */ i(Be, { color: "primary", onClick: re, children: /* @__PURE__ */ i(
252
+ se,
253
+ {
254
+ iconName: "faArrowRightToBracket",
255
+ size: "xs"
256
+ }
257
+ ) })
258
+ }
259
+ }
260
+ }
261
+ )
262
+ }
263
+ ),
264
+ /* @__PURE__ */ i(d, { sx: { display: "flex", flexWrap: "wrap", gap: 1, mt: 2 }, children: S.map((C, k) => /* @__PURE__ */ i(
265
+ mi,
266
+ {
267
+ label: C,
268
+ onDelete: () => be(C),
269
+ color: "primary"
270
+ },
271
+ k + 1
272
+ )) }),
273
+ S.length === 0 && /* @__PURE__ */ i(Zt, { severity: "info", variant: "outlined", children: "No page params added" })
274
+ ] }),
275
+ ["FORM", "SEARCH"].includes(I.getValues("formType")) && /* @__PURE__ */ l(pe, { children: [
276
+ /* @__PURE__ */ i(ve, { size: 12, children: /* @__PURE__ */ i(Xe, { children: /* @__PURE__ */ i(mi, { label: "Route Details", size: "small" }) }) }),
277
+ /* @__PURE__ */ i(
278
+ ie,
279
+ {
280
+ control: I.control,
281
+ name: "navigationState",
282
+ id: "navigationState",
283
+ fullWidth: !0,
284
+ size: "small",
285
+ label: "Navigation State",
286
+ errors: I.formState.errors,
287
+ disabled: !0
288
+ }
289
+ )
290
+ ] })
291
+ ] })
292
+ ] }),
293
+ /* @__PURE__ */ l(Dn, { children: [
294
+ /* @__PURE__ */ i(U, { type: "submit", color: "success", children: "Create" }),
295
+ /* @__PURE__ */ i(U, { onClick: T, children: "Close" })
296
+ ] })
297
+ ]
298
+ }
299
+ )
300
+ }
301
+ );
302
+ }
303
+ En.propTypes = {
304
+ mainFormCtrl: w.any,
305
+ openAddFormModal: w.any,
306
+ setModal: w.any,
307
+ reloadForms: w.any
308
+ };
309
+ const Wi = ({
310
+ permission: F,
311
+ index: A,
312
+ depth: W = 0,
313
+ onEdit: P,
314
+ onRemove: f,
315
+ handleAddChildClick: _,
316
+ isLastChild: S = !1,
317
+ isDynamicFeature: K
318
+ }) => {
319
+ var de;
320
+ const G = In(), B = (I) => I.replaceAll(".child.", ".");
321
+ return /* @__PURE__ */ l(d, { sx: { position: "relative", pl: W * 3 }, children: [
322
+ W > 0 && /* @__PURE__ */ l(pe, { children: [
323
+ /* @__PURE__ */ i(
324
+ d,
325
+ {
326
+ sx: {
327
+ position: "absolute",
328
+ left: 16,
329
+ top: 0,
330
+ bottom: S ? "50%" : 0,
331
+ width: 2,
332
+ bgcolor: G.palette.divider
333
+ }
334
+ }
335
+ ),
336
+ /* @__PURE__ */ i(
337
+ d,
338
+ {
339
+ sx: {
340
+ position: "absolute",
341
+ left: 16,
342
+ top: 22,
343
+ width: 24,
344
+ height: 2,
345
+ bgcolor: G.palette.divider
346
+ }
347
+ }
348
+ )
349
+ ] }),
350
+ /* @__PURE__ */ l(
351
+ d,
352
+ {
353
+ sx: {
354
+ display: "flex",
355
+ alignItems: "center",
356
+ gap: 1.5,
357
+ border: `1px solid ${G.palette.divider}`,
358
+ borderRadius: 2,
359
+ padding: "8px 12px",
360
+ backgroundColor: W === 0 ? G.palette.background.paper : ir(G.palette.background.paper, 0.8),
361
+ ml: W > 0 ? 3 : 0,
362
+ position: "relative"
363
+ },
364
+ children: [
365
+ W === 0 && /* @__PURE__ */ l(c, { sx: { width: 24, color: "text.secondary" }, children: [
366
+ A + 1,
367
+ "."
368
+ ] }),
369
+ /* @__PURE__ */ i(c, { sx: { flexGrow: 1, fontWeight: 500 }, children: B(F.permissionId) }),
370
+ W === 0 && /* @__PURE__ */ i(
371
+ U,
372
+ {
373
+ variant: "outlined",
374
+ size: "small",
375
+ startIcon: /* @__PURE__ */ i(se, { iconName: "faPlus" }),
376
+ onClick: () => _(F),
377
+ children: "Add Child"
378
+ }
379
+ ),
380
+ (!F.isDefault || F.isDefault && !K) && /* @__PURE__ */ i(
381
+ Be,
382
+ {
383
+ color: "secondary",
384
+ onClick: () => P(F, A),
385
+ children: /* @__PURE__ */ i(se, { iconName: "faEdit", size: "sm" })
386
+ }
387
+ ),
388
+ !F.isDefault && /* @__PURE__ */ i(Be, { color: "error", onClick: () => f(F), children: /* @__PURE__ */ i(se, { iconName: "faTrash", size: "sm" }) })
389
+ ]
390
+ }
391
+ ),
392
+ ((de = F.childPermissions) == null ? void 0 : de.length) > 0 && /* @__PURE__ */ i(Vn, { spacing: 1, sx: { mt: 1 }, children: F.childPermissions.map((I, re) => /* @__PURE__ */ i(
393
+ Wi,
394
+ {
395
+ permission: I,
396
+ index: re,
397
+ depth: W + 1,
398
+ onEdit: P,
399
+ onRemove: f,
400
+ handleAddChildClick: _,
401
+ isLastChild: re === F.childPermissions.length - 1,
402
+ isDynamicFeature: K
403
+ },
404
+ re
405
+ )) })
406
+ ] });
407
+ }, Pn = ({
408
+ permissions: F,
409
+ onEdit: A,
410
+ onRemove: W,
411
+ handleAddChildClick: P,
412
+ isDynamicFeature: f
413
+ }) => /* @__PURE__ */ i(Vn, { spacing: 1, children: F.map((_, S) => /* @__PURE__ */ i(
414
+ Wi,
415
+ {
416
+ permission: _,
417
+ index: S,
418
+ depth: 0,
419
+ onEdit: A,
420
+ onRemove: W,
421
+ handleAddChildClick: P,
422
+ isLastChild: S === F.length - 1,
423
+ isDynamicFeature: f
424
+ },
425
+ S
426
+ )) }), Wn = ({
427
+ open: F,
428
+ onClose: A,
429
+ onSave: W,
430
+ formCtrl: P,
431
+ editData: f,
432
+ parentPermissionId: _ = null,
433
+ mode: S = "add-parent",
434
+ permissionTypes: K,
435
+ setPermissionTypes: de,
436
+ existingPermissionIds: G,
437
+ isDynamicFeature: B = !0
438
+ }) => {
439
+ var I, re, be;
440
+ const [q, T] = g(""), [x, ue] = g([]), [fe, C] = g(""), k = {
441
+ permissionType: "",
442
+ permissionId: "--",
443
+ permissionName: "",
444
+ permissionDesc: "",
445
+ enabled: !0,
446
+ permissionSuffix: "",
447
+ parentPermissionSuffix: ""
448
+ }, H = {
449
+ backendUrl: "",
450
+ urlType: "",
451
+ queryCodeRequired: f ? (I = f == null ? void 0 : f.backendUrl) != null && I.trim() && (re = f == null ? void 0 : f.urlType) != null && re.trim() ? !1 : (be = f == null ? void 0 : f.queryCode) != null && be.trim() ? !0 : void 0 : void 0,
452
+ queryCode: ""
453
+ }, hi = B ? k : { ...k, ...H }, {
454
+ control: R,
455
+ watch: ce,
456
+ handleSubmit: gi,
457
+ reset: we,
458
+ setValue: L,
459
+ getValues: xe,
460
+ setError: Ce,
461
+ clearErrors: _e,
462
+ formState: Te
463
+ } = fi({
464
+ mode: "onChange",
465
+ defaultValues: hi
466
+ }), j = ce("queryCodeRequired"), M = ce("permissionType"), We = ce("permissionSuffix"), qe = ce("backendUrl"), Ae = ce("queryCode"), Me = [
467
+ { label: "Query", value: !0 },
468
+ { label: "API", value: !1 }
469
+ ], $e = (p = {}) => ({ ...B ? k : { ...k, ...H }, ...p }), Re = ce("parentPermissionSuffix"), Se = (p) => p.trim().toLowerCase().split(/\s+/).map(
470
+ (b, y) => y === 0 ? b : b.charAt(0).toUpperCase() + b.slice(1)
471
+ ).join(""), yi = async (p) => {
472
+ const b = (await J({
473
+ code: "GET_ALL_QUERY_CODE",
474
+ parameters: { search: p }
475
+ })).data;
476
+ ue((b == null ? void 0 : b.result) || []);
477
+ };
478
+ te(() => {
479
+ !B && (async () => {
480
+ const p = (await J({
481
+ code: "GET_ALL_QUERY_CODE",
482
+ parameters: {
483
+ search: xe("queryCode") ? xe("queryCode") : ""
484
+ }
485
+ })).data;
486
+ ue((p == null ? void 0 : p.result) || []), C(xe("queryCode"));
487
+ })();
488
+ }, [Ae]), te(() => {
489
+ j === !0 && !qe ? (L("backendUrl", ""), L("urlType", "")) : j === !1 && !Ae && L("queryCode", "");
490
+ }, [j]), te(() => {
491
+ var p, b, y;
492
+ if (F) {
493
+ if (S === "edit" && f) {
494
+ const D = {
495
+ permissionType: f.permissionType || "",
496
+ permissionId: f.permissionId || "--",
497
+ permissionName: f.permissionName || "",
498
+ permissionDesc: f.permissionDesc || "",
499
+ enabled: !!f.enabled,
500
+ permissionSuffix: ""
501
+ };
502
+ if (B)
503
+ we(D);
504
+ else {
505
+ const ae = ((p = f == null ? void 0 : f.backendUrl) == null ? void 0 : p.trim()) && ((b = f == null ? void 0 : f.urlType) == null ? void 0 : b.trim()), ne = (y = f == null ? void 0 : f.queryCode) == null ? void 0 : y.trim();
506
+ we({
507
+ ...D,
508
+ urlType: f.urlType || "",
509
+ backendUrl: f.backendUrl || "",
510
+ queryCode: f.queryCode || "",
511
+ queryCodeRequired: f ? ae ? !1 : ne ? !0 : void 0 : void 0
512
+ });
513
+ }
514
+ return;
515
+ }
516
+ if (S === "add-child" && _) {
517
+ const D = _.split(".")[0] || "";
518
+ we(
519
+ $e({
520
+ permissionType: D,
521
+ permissionId: _,
522
+ permissionName: "",
523
+ permissionDesc: "",
524
+ enabled: !0,
525
+ permissionSuffix: "",
526
+ urlType: "",
527
+ backendUrl: "",
528
+ queryCodeRequired: void 0,
529
+ queryCode: ""
530
+ })
531
+ );
532
+ return;
533
+ }
534
+ we($e());
535
+ }
536
+ }, [F, S, f, _, we]), te(() => {
537
+ if (S === "add-parent") {
538
+ const p = (M == null ? void 0 : M.type) === "menu" ? "view" : M == null ? void 0 : M.type;
539
+ if (!p) {
540
+ L("permissionId", "--");
541
+ return;
542
+ }
543
+ const b = P.getValues("menuType") || "menuType", y = P.getValues("featureConstant") || "feature";
544
+ let D;
545
+ if (B)
546
+ D = `${p}.${b}.${y}`;
547
+ else {
548
+ const ae = P.getValues("menuName");
549
+ D = `${p}.${b}.${Se(ae)}`;
550
+ }
551
+ Re != null && Re.trim() && (D = `${D}.${Re.trim()}`), L("permissionId", D);
552
+ }
553
+ }, [M, Re, S]), te(() => {
554
+ j === !0 && !qe ? (L("backendUrl", ""), L("urlType", "")) : j === !1 && !Ae && L("queryCode", "");
555
+ }, [j]), te(() => {
556
+ if (S === "add-child" && _ !== null) {
557
+ const p = _.split(".")[0] || "", b = `${_}.child`, y = We ? `${b}.${We}` : b;
558
+ L("permissionId", y), L("permissionType", p);
559
+ }
560
+ }, [We, S, _, L]);
561
+ const bi = (p) => {
562
+ const b = {
563
+ permissionId: p.permissionId,
564
+ permissionType: p.permissionType || (_ ? _.split(".")[0] : ""),
565
+ permissionName: p.permissionName,
566
+ permissionDesc: p.permissionDesc,
567
+ enabled: p.enabled,
568
+ backendUrl: p != null && p.backendUrl && !j ? p.backendUrl : null,
569
+ urlType: p != null && p.urlType && !j ? p.urlType : null,
570
+ queryCode: p != null && p.queryCode && j ? p.queryCode : null,
571
+ childPermissions: [],
572
+ isDefault: f != null && f.isDefault ? f == null ? void 0 : f.isDefault : !1
573
+ };
574
+ W(b), we(), A();
575
+ }, Ke = async (p) => !p || p === "--" ? void 0 : (await J({
576
+ code: "CHECK_UNIQUE_PERMISSION_ID",
577
+ parameters: { permissionId: p }
578
+ })).data.result[0].exists;
579
+ return /* @__PURE__ */ l(_n, { open: F, onClose: A, fullWidth: !0, maxWidth: "sm", children: [
580
+ /* @__PURE__ */ i(Tn, { children: S === "edit" ? "Edit Permission" : "Add Permission" }),
581
+ /* @__PURE__ */ l(
582
+ Fn,
583
+ {
584
+ sx: { display: "flex", flexDirection: "column", gap: 2, mt: 1 },
585
+ children: [
586
+ S !== "add-child" && S !== "edit" && /* @__PURE__ */ l(d, { display: "flex", alignItems: "center", gap: 2, children: [
587
+ /* @__PURE__ */ l(
588
+ c,
589
+ {
590
+ sx: { minWidth: 160, fontWeight: 500, color: "text.secondary" },
591
+ children: [
592
+ "Permission Type",
593
+ /* @__PURE__ */ i("span", { className: "text-red-500 ml-1", children: "*" })
594
+ ]
595
+ }
596
+ ),
597
+ /* @__PURE__ */ i(ee, { fullWidth: !0, size: "small", children: /* @__PURE__ */ i(
598
+ $,
599
+ {
600
+ name: "permissionType",
601
+ control: R,
602
+ rules: { required: !0 },
603
+ render: ({ field: p }) => /* @__PURE__ */ i(
604
+ Pe,
605
+ {
606
+ id: "permissionType",
607
+ name: "permissionType",
608
+ control: R,
609
+ singleSelect: !0,
610
+ checkEquality: "type",
611
+ freeSolo: !0,
612
+ disableClearable: !1,
613
+ placeholder: "Choose permission type",
614
+ options: K ? !q || K.some(
615
+ (b) => b.type.toLowerCase() === q.toLowerCase()
616
+ ) ? K : [
617
+ ...K,
618
+ { type: `__add_new__${q}`, isNew: !0 }
619
+ ] : [],
620
+ getOptionLabel: (b) => b.isNew ? `Add "${b.type.replace("__add_new__", "")}"` : b.type,
621
+ onInputChange: (b, y) => T(y),
622
+ onChange: (b, y) => {
623
+ if (!y) {
624
+ p.onChange(null), L("permissionId", "--");
625
+ return;
626
+ }
627
+ if (y.isNew) {
628
+ const D = y.type.replace("__add_new__", ""), ae = { type: D };
629
+ de(
630
+ (ne) => ne.some((ei) => ei.type === D) ? ne : [...ne, ae]
631
+ ), p.onChange(ae);
632
+ return;
633
+ }
634
+ p.onChange(y);
635
+ }
636
+ }
637
+ )
638
+ }
639
+ ) })
640
+ ] }),
641
+ S === "add-child" ? /* @__PURE__ */ i(pe, { children: /* @__PURE__ */ l(d, { display: "flex", alignItems: "center", gap: 2, children: [
642
+ /* @__PURE__ */ l(
643
+ c,
644
+ {
645
+ sx: {
646
+ minWidth: 160,
647
+ fontWeight: 500,
648
+ color: "text.secondary"
649
+ },
650
+ children: [
651
+ "Permission ID",
652
+ /* @__PURE__ */ i("span", { className: "text-red-500 ml-1", children: "*" })
653
+ ]
654
+ }
655
+ ),
656
+ /* @__PURE__ */ l(d, { sx: { display: "flex", gap: 1, flexGrow: 1 }, children: [
657
+ /* @__PURE__ */ i(
658
+ ie,
659
+ {
660
+ control: R,
661
+ name: "parentPermissionDisplay",
662
+ value: `${_}.child.`,
663
+ disabled: !0,
664
+ fullWidth: !0
665
+ }
666
+ ),
667
+ /* @__PURE__ */ i(
668
+ ie,
669
+ {
670
+ control: R,
671
+ name: "permissionSuffix",
672
+ placeholder: "Enter child suffix",
673
+ errors: Te.errors,
674
+ fullWidth: !0,
675
+ onChange: async (p) => {
676
+ const b = p.target.value.trim();
677
+ if (L("permissionSuffix", b), b.toLowerCase() === "child") {
678
+ Ce("permissionSuffix", {
679
+ type: "manual",
680
+ message: "Suffix cannot be 'child'"
681
+ });
682
+ return;
683
+ }
684
+ _e("permissionSuffix");
685
+ const y = `${_}.child.${b}`;
686
+ if (L("permissionId", y), G != null && G.has(y)) {
687
+ Ce("permissionSuffix", {
688
+ type: "manual",
689
+ message: "Permission ID already exists"
690
+ });
691
+ return;
692
+ }
693
+ await Ke(y) ? Ce("permissionSuffix", {
694
+ type: "manual",
695
+ message: "Permission ID already exists in DB"
696
+ }) : _e("permissionSuffix");
697
+ }
698
+ }
699
+ )
700
+ ] })
701
+ ] }) }) : S === "add-parent" ? M != null && M.type ? /* @__PURE__ */ i(pe, { children: /* @__PURE__ */ l(d, { display: "flex", alignItems: "center", gap: 2, children: [
702
+ /* @__PURE__ */ l(
703
+ c,
704
+ {
705
+ sx: {
706
+ minWidth: 160,
707
+ fontWeight: 500,
708
+ color: "text.secondary"
709
+ },
710
+ children: [
711
+ "Permission ID",
712
+ /* @__PURE__ */ i("span", { className: "text-red-500 ml-1", children: "*" })
713
+ ]
714
+ }
715
+ ),
716
+ /* @__PURE__ */ i(
717
+ ie,
718
+ {
719
+ control: R,
720
+ name: "baseId",
721
+ value: `${(M == null ? void 0 : M.type) === "menu" ? "view" : M == null ? void 0 : M.type}.${P.getValues("menuType")}.${B ? P.getValues("featureConstant") : Se(P.getValues("menuName"))}.`,
722
+ disabled: !0,
723
+ fullWidth: !0
724
+ }
725
+ ),
726
+ /* @__PURE__ */ i(
727
+ ie,
728
+ {
729
+ control: R,
730
+ name: "parentPermissionSuffix",
731
+ placeholder: "Enter suffix",
732
+ errors: Te.errors,
733
+ fullWidth: !0,
734
+ onChange: async (p) => {
735
+ const b = p.target.value.trim();
736
+ if (L("parentPermissionSuffix", b), b.toLowerCase() === "child") {
737
+ Ce("parentPermissionSuffix", {
738
+ type: "manual",
739
+ message: "Suffix cannot be 'child'"
740
+ });
741
+ return;
742
+ }
743
+ _e("parentPermissionSuffix");
744
+ const y = (M == null ? void 0 : M.type) === "menu" ? "view" : (M == null ? void 0 : M.type) || M || "", D = P.getValues("menuType"), ae = P.getValues("featureConstant");
745
+ let ne;
746
+ if (B ? ne = `${y}.${D}.${ae}.${b}` : ne = `${y}.${D}.${Se(P.getValues("menuName"))}.${b}`, L("permissionId", ne), G != null && G.has(ne)) {
747
+ Ce("parentPermissionSuffix", {
748
+ type: "manual",
749
+ message: "Permission ID already exists"
750
+ });
751
+ return;
752
+ }
753
+ await Ke(ne) ? Ce("parentPermissionSuffix", {
754
+ type: "manual",
755
+ message: "Permission ID already exists in DB"
756
+ }) : _e("parentPermissionSuffix");
757
+ }
758
+ }
759
+ )
760
+ ] }) }) : /* @__PURE__ */ l(d, { display: "flex", alignItems: "center", gap: 2, children: [
761
+ /* @__PURE__ */ l(
762
+ c,
763
+ {
764
+ sx: { minWidth: 160, fontWeight: 500, color: "text.secondary" },
765
+ children: [
766
+ "Permission ID",
767
+ /* @__PURE__ */ i("span", { className: "text-red-500 ml-1", children: "*" })
768
+ ]
769
+ }
770
+ ),
771
+ /* @__PURE__ */ i(
772
+ ie,
773
+ {
774
+ control: R,
775
+ name: "permissionId",
776
+ value: "--",
777
+ disabled: !0,
778
+ fullWidth: !0
779
+ }
780
+ )
781
+ ] }) : /* @__PURE__ */ l(d, { display: "flex", alignItems: "center", gap: 2, children: [
782
+ /* @__PURE__ */ l(
783
+ c,
784
+ {
785
+ sx: {
786
+ minWidth: 160,
787
+ fontWeight: 500,
788
+ color: "text.secondary"
789
+ },
790
+ children: [
791
+ "Permission ID",
792
+ /* @__PURE__ */ i("span", { className: "text-red-500 ml-1", children: "*" })
793
+ ]
794
+ }
795
+ ),
796
+ /* @__PURE__ */ i(
797
+ ie,
798
+ {
799
+ control: R,
800
+ name: "permissionId",
801
+ label: "Permission ID",
802
+ disabled: !0,
803
+ fullWidth: !0
804
+ }
805
+ )
806
+ ] }),
807
+ /* @__PURE__ */ l(d, { display: "flex", alignItems: "center", gap: 2, children: [
808
+ /* @__PURE__ */ l(
809
+ c,
810
+ {
811
+ sx: { minWidth: 160, fontWeight: 500, color: "text.secondary" },
812
+ children: [
813
+ "Permission Name",
814
+ /* @__PURE__ */ i("span", { className: "text-red-500 ml-1", children: "*" })
815
+ ]
816
+ }
817
+ ),
818
+ /* @__PURE__ */ i(
819
+ $,
820
+ {
821
+ name: "permissionName",
822
+ control: R,
823
+ rules: { required: !0 },
824
+ render: ({ field: p }) => /* @__PURE__ */ i(
825
+ ie,
826
+ {
827
+ control: R,
828
+ ...p,
829
+ placeholder: "Enter name"
830
+ }
831
+ )
832
+ }
833
+ )
834
+ ] }),
835
+ /* @__PURE__ */ l(d, { display: "flex", alignItems: "flex-start", gap: 2, children: [
836
+ /* @__PURE__ */ i(
837
+ c,
838
+ {
839
+ sx: {
840
+ minWidth: 160,
841
+ fontWeight: 500,
842
+ color: "text.secondary",
843
+ mt: 1
844
+ },
845
+ children: "Description"
846
+ }
847
+ ),
848
+ /* @__PURE__ */ i(
849
+ $,
850
+ {
851
+ name: "permissionDesc",
852
+ control: R,
853
+ render: ({ field: p }) => /* @__PURE__ */ i(
854
+ dr,
855
+ {
856
+ control: R,
857
+ ...p,
858
+ placeholder: "Enter description (optional)",
859
+ minRows: 2
860
+ }
861
+ )
862
+ }
863
+ )
864
+ ] }),
865
+ !B && /* @__PURE__ */ l(d, { display: "flex", alignItems: "center", gap: 2, children: [
866
+ /* @__PURE__ */ l(
867
+ c,
868
+ {
869
+ sx: {
870
+ minWidth: 160,
871
+ fontWeight: 500,
872
+ color: "text.secondary"
873
+ },
874
+ children: [
875
+ "Type",
876
+ " "
877
+ ]
878
+ }
879
+ ),
880
+ /* @__PURE__ */ i(
881
+ pr,
882
+ {
883
+ name: "queryCodeRequired",
884
+ control: R,
885
+ options: Me,
886
+ direction: "row",
887
+ dataTestId: "queryOrApi"
888
+ }
889
+ )
890
+ ] }),
891
+ !B && j !== void 0 && /* @__PURE__ */ i(pe, { children: j === !1 ? /* @__PURE__ */ l(pe, { children: [
892
+ /* @__PURE__ */ l(d, { display: "flex", alignItems: "center", gap: 2, children: [
893
+ /* @__PURE__ */ i(
894
+ c,
895
+ {
896
+ sx: {
897
+ minWidth: 160,
898
+ fontWeight: 500,
899
+ color: "text.secondary"
900
+ },
901
+ children: "URL Type"
902
+ }
903
+ ),
904
+ /* @__PURE__ */ i(ee, { fullWidth: !0, size: "small", children: /* @__PURE__ */ i(
905
+ $,
906
+ {
907
+ name: "urlType",
908
+ control: R,
909
+ render: ({ field: p }) => /* @__PURE__ */ l(Xt, { ...p, displayEmpty: !0, children: [
910
+ /* @__PURE__ */ i(vn, { value: "", children: /* @__PURE__ */ i("em", { children: "Select Type" }) }),
911
+ ["GET", "POST", "PUT", "DELETE"].map((b) => /* @__PURE__ */ i(vn, { value: b, children: b }, b))
912
+ ] })
913
+ }
914
+ ) })
915
+ ] }),
916
+ /* @__PURE__ */ l(d, { display: "flex", alignItems: "center", gap: 2, children: [
917
+ /* @__PURE__ */ i(
918
+ c,
919
+ {
920
+ sx: {
921
+ minWidth: 160,
922
+ fontWeight: 500,
923
+ color: "text.secondary"
924
+ },
925
+ children: "Backend URL"
926
+ }
927
+ ),
928
+ /* @__PURE__ */ i(
929
+ $,
930
+ {
931
+ name: "backendUrl",
932
+ control: R,
933
+ render: ({ field: p }) => /* @__PURE__ */ i(
934
+ ie,
935
+ {
936
+ control: R,
937
+ ...p,
938
+ placeholder: "Enter URL"
939
+ }
940
+ )
941
+ }
942
+ )
943
+ ] })
944
+ ] }) : /* @__PURE__ */ l(d, { display: "flex", alignItems: "center", gap: 2, children: [
945
+ /* @__PURE__ */ i(
946
+ c,
947
+ {
948
+ sx: {
949
+ minWidth: 160,
950
+ fontWeight: 500,
951
+ color: "text.secondary"
952
+ },
953
+ children: "Query Code"
954
+ }
955
+ ),
956
+ /* @__PURE__ */ i(
957
+ $,
958
+ {
959
+ name: "queryCode",
960
+ control: R,
961
+ render: ({ field: p, fieldState: { error: b } }) => /* @__PURE__ */ i(
962
+ Pe,
963
+ {
964
+ id: "queryCode",
965
+ name: "queryCode",
966
+ control: R,
967
+ options: x,
968
+ getOptionLabel: (y) => (y == null ? void 0 : y.code) || "",
969
+ checkEquality: "code",
970
+ inputValue: fe,
971
+ disableClearable: !1,
972
+ value: (x == null ? void 0 : x.find((y) => y.code === p.value)) || null,
973
+ onInputChange: (y, D, ae) => {
974
+ ae === "input" && (C(D), yi(D));
975
+ },
976
+ singleSelect: !0,
977
+ onChange: (y, D) => {
978
+ p.onChange((D == null ? void 0 : D.code) || ""), C((D == null ? void 0 : D.code) || "");
979
+ },
980
+ placeholder: "Search Query Code...",
981
+ errors: b,
982
+ fullWidth: !0,
983
+ freeSolo: !1
984
+ }
985
+ )
986
+ }
987
+ )
988
+ ] }) }),
989
+ /* @__PURE__ */ l(d, { display: "flex", alignItems: "center", gap: 2, children: [
990
+ /* @__PURE__ */ l(
991
+ c,
992
+ {
993
+ sx: { minWidth: 160, fontWeight: 500, color: "text.secondary" },
994
+ children: [
995
+ "Is Active",
996
+ /* @__PURE__ */ i("span", { className: "text-red-500 ml-1", children: "*" })
997
+ ]
998
+ }
999
+ ),
1000
+ /* @__PURE__ */ i(
1001
+ $,
1002
+ {
1003
+ name: "enabled",
1004
+ control: R,
1005
+ render: ({ field: p }) => /* @__PURE__ */ i(
1006
+ ke,
1007
+ {
1008
+ ...p,
1009
+ disabled: (f == null ? void 0 : f.isDefault) && !B,
1010
+ checked: p.value,
1011
+ onChange: (b) => p.onChange(b.target.checked)
1012
+ }
1013
+ )
1014
+ }
1015
+ )
1016
+ ] })
1017
+ ]
1018
+ }
1019
+ ),
1020
+ /* @__PURE__ */ l(Dn, { children: [
1021
+ /* @__PURE__ */ i(U, { onClick: A, children: "Cancel" }),
1022
+ /* @__PURE__ */ i(
1023
+ U,
1024
+ {
1025
+ onClick: gi(bi),
1026
+ variant: "contained",
1027
+ disabled: !Te.isValid || Object.keys(Te.errors).length > 0,
1028
+ children: S === "edit" ? "Update" : S === "add-child" ? "Add Child" : "Add"
1029
+ }
1030
+ )
1031
+ ] })
1032
+ ] });
1033
+ }, qn = ({
1034
+ open: F,
1035
+ onClose: A,
1036
+ onSave: W,
1037
+ entityData: P,
1038
+ permissions: f = []
1039
+ }) => {
1040
+ const { control: _, watch: S, getValues: K } = fi({
1041
+ defaultValues: {
1042
+ noStartDate: !0,
1043
+ noEndDate: !0,
1044
+ startDate: null,
1045
+ endDate: null,
1046
+ isBackendOnly: !1
1047
+ }
1048
+ }), de = S("noStartDate"), G = S("noEndDate"), B = S("startDate"), I = S("endDate"), re = () => {
1049
+ const q = K();
1050
+ be(q);
1051
+ }, be = (q) => {
1052
+ const T = [];
1053
+ P.forEach((x) => {
1054
+ if (x.type === "user") {
1055
+ const ue = Array.isArray(x.id) ? x.id : [x.id];
1056
+ T.push(
1057
+ ...ue.map((fe) => ({
1058
+ entityType: "user",
1059
+ user_id: fe,
1060
+ name: x.name,
1061
+ startDate: q.noStartDate ? null : q.startDate,
1062
+ endDate: q.noEndDate ? null : q.endDate,
1063
+ isBackendOnly: q.isBackendOnly,
1064
+ permissions: JSON.parse(JSON.stringify(f))
1065
+ }))
1066
+ );
1067
+ }
1068
+ x.type === "role" && x.ids.forEach((ue, fe) => {
1069
+ T.push({
1070
+ entityType: "role",
1071
+ role_id: ue,
1072
+ name: x.names[fe],
1073
+ startDate: q.noStartDate ? null : q.startDate,
1074
+ endDate: q.noEndDate ? null : q.endDate,
1075
+ isBackendOnly: q.isBackendOnly,
1076
+ permissions: JSON.parse(JSON.stringify(f))
1077
+ });
1078
+ });
1079
+ }), T.forEach((x) => W(x)), A();
1080
+ };
1081
+ return /* @__PURE__ */ i(Kt, { open: F, onClose: A, children: /* @__PURE__ */ i(d, { className: "fixed inset-0 flex items-start justify-center z-50 bg-opacity-10 overflow-y-auto", children: /* @__PURE__ */ l(er, { className: "relative mt-10 p-4 shadow-lg flex flex-col rounded-xl", children: [
1082
+ /* @__PURE__ */ l(Q, { className: "flex justify-between items-center mb-4", children: [
1083
+ /* @__PURE__ */ i(c, { variant: "h6", children: "Grant Access" }),
1084
+ /* @__PURE__ */ i(Be, { onClick: A, children: /* @__PURE__ */ i(se, { iconName: "faXmark", size: "sm" }) })
1085
+ ] }),
1086
+ /* @__PURE__ */ i(Q, { container: !0, spacing: 2, children: /* @__PURE__ */ l(Q, { item: !0, xs: 12, display: "flex", gap: 2, children: [
1087
+ /* @__PURE__ */ l(d, { display: "flex", flexDirection: "column", flex: 1, children: [
1088
+ /* @__PURE__ */ i(
1089
+ Ei,
1090
+ {
1091
+ label: "No Start Date",
1092
+ name: "noStartDate",
1093
+ control: _,
1094
+ sx: { mb: 1 }
1095
+ }
1096
+ ),
1097
+ /* @__PURE__ */ i(
1098
+ wn,
1099
+ {
1100
+ name: "startDate",
1101
+ control: _,
1102
+ disabled: de,
1103
+ maxDate: I || void 0
1104
+ }
1105
+ )
1106
+ ] }),
1107
+ /* @__PURE__ */ l(d, { display: "flex", flexDirection: "column", flex: 1, children: [
1108
+ /* @__PURE__ */ i(
1109
+ Ei,
1110
+ {
1111
+ label: "No End Date",
1112
+ name: "noEndDate",
1113
+ control: _,
1114
+ sx: { mb: 1 }
1115
+ }
1116
+ ),
1117
+ /* @__PURE__ */ i(
1118
+ wn,
1119
+ {
1120
+ name: "endDate",
1121
+ control: _,
1122
+ disabled: G,
1123
+ minDate: B || void 0
1124
+ }
1125
+ )
1126
+ ] })
1127
+ ] }) }),
1128
+ /* @__PURE__ */ i(d, { mt: 2, children: /* @__PURE__ */ i(
1129
+ Ei,
1130
+ {
1131
+ label: "Is Backend Only?",
1132
+ name: "isBackendOnly",
1133
+ control: _
1134
+ }
1135
+ ) }),
1136
+ /* @__PURE__ */ l(Q, { className: "flex justify-end gap-2 mt-4", children: [
1137
+ /* @__PURE__ */ i(U, { type: "button", variant: "outlined", onClick: A, children: "Cancel" }),
1138
+ /* @__PURE__ */ i(U, { variant: "contained", type: "button", onClick: re, children: "Save" })
1139
+ ] })
1140
+ ] }) }) });
1141
+ }, qi = ({ permissions: F, onToggle: A, isChild: W = !1 }) => {
1142
+ const P = (f) => f.replaceAll(".child", "");
1143
+ return F.map((f, _) => {
1144
+ var S;
1145
+ return /* @__PURE__ */ l(
1146
+ d,
1147
+ {
1148
+ display: "flex",
1149
+ flexDirection: "column",
1150
+ gap: 1,
1151
+ ml: W ? 2 : 0,
1152
+ children: [
1153
+ /* @__PURE__ */ l(d, { display: "flex", alignItems: "center", gap: 1, children: [
1154
+ /* @__PURE__ */ i(
1155
+ ke,
1156
+ {
1157
+ sx: {
1158
+ transform: "scale(0.75)",
1159
+ transformOrigin: "left center"
1160
+ },
1161
+ checked: !!f.enabled,
1162
+ disabled: W,
1163
+ onChange: () => {
1164
+ W || A(f);
1165
+ }
1166
+ }
1167
+ ),
1168
+ /* @__PURE__ */ i(c, { variant: "subtitle1", children: P(f.permissionId) })
1169
+ ] }),
1170
+ ((S = f.childPermissions) == null ? void 0 : S.length) > 0 && /* @__PURE__ */ i(
1171
+ qi,
1172
+ {
1173
+ permissions: f.childPermissions,
1174
+ onToggle: A,
1175
+ isChild: !0
1176
+ }
1177
+ )
1178
+ ]
1179
+ },
1180
+ _
1181
+ );
1182
+ });
1183
+ };
1184
+ function Jr() {
1185
+ var F, A, W, P, f, _, S, K, de, G, B;
1186
+ const { translate: I } = ur(), re = tr(null), be = lr(), q = or(), { isNew: T } = be.state || {}, x = xn(
1187
+ () => new URLSearchParams(be.search),
1188
+ [be.search]
1189
+ ), ue = In(), [fe, C] = g([]), [k, H] = g(!1), [hi, R] = g([]), [ce, gi] = g([]), [we, L] = g(), [xe, Ce] = g({}), [_e, Te] = g(!1), [j, M] = g(!1), [We, qe] = g(""), [Ae, Me] = g(""), [$e, Re] = g(""), [Se, yi] = g(), [bi, Ke] = g([]), [p, b] = g(!1), [y, D] = g(0), [ae, ne] = g(!1), [ei, Ai] = g([]), [Ri, Oi] = g([]), [Oe, An] = g([]), [Ne, vi] = g([]), [Rn, xi] = g([]), [le, ii] = g({}), [Le, je] = g([]), [ni, On] = g({}), [he, Je] = g([]), [zn, Qe] = g(!1), [Ge, ti] = g("add-parent"), [Ci, ri] = g(null), [Un, ai] = g(null), [Bn, li] = g(null), [Mn, Si] = g(!1), [$n, Ln] = g(null), [Ie, ze] = g([]), [jn, zi] = g(!1), [Fe, oi] = g(!1), [Ui, Jn] = g(!1), [Y, Bi] = g({ value: !1, length: 0 }), [Qn, Gn] = g([
1190
+ { type: "update" },
1191
+ { type: "menu" },
1192
+ { type: "create" },
1193
+ { type: "download" },
1194
+ { type: "execute" }
1195
+ ]), [Ue, Hn] = g([]), [Yn, He] = g(""), [Zn, Ye] = g(""), [wi, Ni] = g({
1196
+ basicConfig: !0,
1197
+ trainingConfig: !1,
1198
+ notificationConfig: !1
1199
+ }), [Mi, Xn] = nr.useState(null), Kn = (e) => ei.includes(e), [et, $i] = g(/* @__PURE__ */ new Set()), it = ar((e) => e.theme.mode), O = [
1200
+ { key: "featureDetails", label: "Feature Details" },
1201
+ { key: "mobileConfig", label: "Mobile Config" },
1202
+ { key: "formLinking", label: "Form Linking" },
1203
+ { key: "additionalPermissions", label: "Permission Management" },
1204
+ { key: "assignFeatures", label: "Assignment" },
1205
+ { key: "submit", label: "Submit" }
1206
+ ], nt = z.object().shape({
1207
+ menuName: z.string().required("Enter Feature Name"),
1208
+ featureConstant: z.string().when("isDynamicFeature", {
1209
+ is: !0,
1210
+ then: (e) => e.required("Enter Feature Constant"),
1211
+ otherwise: (e) => e.notRequired()
1212
+ }),
1213
+ navigationState: z.string().when("isDynamicFeature", {
1214
+ is: !1,
1215
+ then: (e) => e.required("Enter Navigation State").matches(
1216
+ /^(techo\.[a-zA-Z]+\.[a-zA-Z]+|medplat\.form\.[a-zA-Z_]+)$/,
1217
+ "invalid format for state"
1218
+ ),
1219
+ otherwise: (e) => e.notRequired()
1220
+ }),
1221
+ menuType: z.string().required("Enter Feature Type"),
1222
+ icon: z.string().when("$showMobileFields", {
1223
+ is: !0,
1224
+ then: (e) => e.required("Please upload an icon"),
1225
+ otherwise: (e) => e.notRequired()
1226
+ }),
1227
+ conditions: z.string().transform((e) => e ? e.trim() : ""),
1228
+ mobileMode: z.string().when("$showMobileFields", {
1229
+ is: !0,
1230
+ then: (e) => e.required("Please select a mode"),
1231
+ otherwise: (e) => e.notRequired()
1232
+ }),
1233
+ trainingQuery: z.string().when("trainingRequired", {
1234
+ is: !0,
1235
+ then: (e) => e.required("Please select a training query"),
1236
+ otherwise: (e) => e.notRequired()
1237
+ }),
1238
+ notificationBadgeType: z.string().when("notificationBadgeEnabled", {
1239
+ is: !0,
1240
+ then: (e) => e.required("Please select a badge type"),
1241
+ otherwise: (e) => e.notRequired()
1242
+ }),
1243
+ notificationBadgeQuery: z.string().when(
1244
+ ["notificationBadgeEnabled", "notificationBadgeType"],
1245
+ (e, n) => {
1246
+ const [t, r] = e;
1247
+ return t && r ? n.required(
1248
+ r === "COUNT" ? "Please select a count query" : "Please select a nudge query"
1249
+ ) : n.notRequired();
1250
+ }
1251
+ ),
1252
+ updatedFields: z.array().when(
1253
+ ["isDynamicFeature", "isNew", "isUpdate", "showFields"],
1254
+ (e, n) => {
1255
+ const [t, r, o, u] = e;
1256
+ return t === !1 && (r == null ? void 0 : r.val) === !1 && (o == null ? void 0 : o.value) === !0 && u === !0 ? n.of(
1257
+ z.object().shape({
1258
+ value: z.string().required("Right is required")
1259
+ })
1260
+ ) : n.optional();
1261
+ }
1262
+ )
1263
+ }), a = fi({
1264
+ defaultValues: {
1265
+ menuName: "",
1266
+ featureConstant: "",
1267
+ navigationState: "medplat.form",
1268
+ menuType: "",
1269
+ menuGroup: "",
1270
+ isDynamicFeature: !0,
1271
+ isWebFeature: !1,
1272
+ isMobileFeature: !1,
1273
+ accessRights: [],
1274
+ entityName: null,
1275
+ mobileEntitiesSync: [],
1276
+ icon: "",
1277
+ mobileMode: null,
1278
+ conditions: "",
1279
+ formCode: "",
1280
+ version: null,
1281
+ additionalPermissions: [],
1282
+ fields: [],
1283
+ updatedFields: [],
1284
+ trainingRequired: !1,
1285
+ trainingQuery: "",
1286
+ notificationBadgeEnabled: !1,
1287
+ notificationBadgeType: "",
1288
+ notificationBadgeQuery: ""
1289
+ },
1290
+ resolver: Nn(nt),
1291
+ mode: "onChange"
1292
+ }), V = pi({
1293
+ control: a.control,
1294
+ name: "isDynamicFeature"
1295
+ }), Li = pi({
1296
+ control: a.control,
1297
+ name: "isMobileFeature"
1298
+ }), ji = pi({
1299
+ control: a.control,
1300
+ name: "isWebFeature"
1301
+ }), tt = pi({
1302
+ control: a.control,
1303
+ name: at((F = O[y]) == null ? void 0 : F.key)
1304
+ }), rt = a.watch();
1305
+ function at(e) {
1306
+ switch (e) {
1307
+ case "featureDetails":
1308
+ return V ? ["menuName", "featureConstant", "menuType"] : ["menuName", "navigationState", "menuType"];
1309
+ case "mobileConfig":
1310
+ return k ? [
1311
+ "icon",
1312
+ "mobileMode",
1313
+ "trainingRequired",
1314
+ "trainingQuery",
1315
+ "notificationBadgeEnabled",
1316
+ "notificationBadgeType",
1317
+ "notificationBadgeQuery"
1318
+ ] : [];
1319
+ case "formLinking":
1320
+ return V ? ["formCode", "version"] : [];
1321
+ case "additionalPermissions":
1322
+ return !V && (T == null ? void 0 : T.val) === !1 ? ["updatedFields"] : ["additionalPermissions"];
1323
+ default:
1324
+ return [];
1325
+ }
1326
+ }
1327
+ const Ji = xn(() => {
1328
+ var e;
1329
+ switch ((e = O[y]) == null ? void 0 : e.key) {
1330
+ case "featureDetails": {
1331
+ const n = !!a.formState.errors.navigationState, t = !!a.formState.errors.featureConstant;
1332
+ return a.formState.isValid && !!a.getValues("menuName") && (V ? !!a.getValues("featureConstant") && !t : !!a.getValues("navigationState") && !n) && !!a.getValues("menuType");
1333
+ }
1334
+ case "mobileConfig": {
1335
+ if (!k) return !0;
1336
+ const n = !!a.getValues("icon"), t = !!a.getValues("mobileMode"), r = a.getValues("trainingRequired"), o = a.getValues("trainingQuery"), u = a.getValues("notificationBadgeEnabled"), s = a.getValues("notificationBadgeType"), m = a.getValues("notificationBadgeQuery");
1337
+ return n && t && (!r || !!o) && (!u || !!s) && (!u || !s || !!m);
1338
+ }
1339
+ case "formLinking": {
1340
+ if (!V) return !0;
1341
+ const n = a.getValues("formCode"), t = a.getValues("version");
1342
+ return !!n && !!t;
1343
+ }
1344
+ case "additionalPermissions": {
1345
+ if (!V && (T == null ? void 0 : T.val) === !1 && Fe)
1346
+ return (a.getValues("updatedFields") || []).every(
1347
+ (n) => n.value && n.value.trim()
1348
+ );
1349
+ {
1350
+ const n = a.getValues("additionalPermissions") || [];
1351
+ return n.length > 0 && n.every(
1352
+ (t) => {
1353
+ var r, o, u, s;
1354
+ return ((r = t.permissionId) == null ? void 0 : r.trim()) && ((o = t.permissionName) == null ? void 0 : o.trim()) && ((s = (u = t.permissionType) == null ? void 0 : u.type) == null ? void 0 : s.trim());
1355
+ }
1356
+ );
1357
+ }
1358
+ }
1359
+ default:
1360
+ return !0;
1361
+ }
1362
+ }, [
1363
+ tt,
1364
+ a.formState.isValid,
1365
+ y,
1366
+ k
1367
+ ]), Ze = O.filter(
1368
+ (e) => (e.key !== "mobileConfig" || k) && (e.key !== "formLinking" || V)
1369
+ ), Ii = async () => {
1370
+ const e = O[y].key;
1371
+ if (Kn(e)) {
1372
+ Qi();
1373
+ return;
1374
+ }
1375
+ await a.trigger(Gi(e)) && ($i((n) => new Set(n).add(e)), Ai((n) => n.filter((t) => t !== e)), Qi());
1376
+ }, Qi = () => {
1377
+ const e = O[y].key, n = Ze.findIndex(
1378
+ (r) => r.key === e
1379
+ ), t = Ze[n + 1];
1380
+ if (t) {
1381
+ t.key === "additionalPermissions" && he.length === 0 && ut(), e === "additionalPermissions" && t.key === "assignFeatures" && ze(
1382
+ st(he, Ie)
1383
+ );
1384
+ const r = O.findIndex(
1385
+ (o) => o.key === t.key
1386
+ );
1387
+ D(r);
1388
+ }
1389
+ };
1390
+ te(() => {
1391
+ if (j === !0) {
1392
+ const e = a.getValues("mobileMode");
1393
+ Xn(e);
1394
+ }
1395
+ }, [j, a]), te(() => {
1396
+ V ? a.setValue("navigationState", "medplat.form") : (x.get("featureId") === null && a.setValue("navigationState", ""), a.setValue("featureConstant", ""), qe(""), a.clearErrors("featureConstant"));
1397
+ }, [V]);
1398
+ const Gi = (e) => {
1399
+ switch (e) {
1400
+ case "formLinking":
1401
+ return ["formCode", "version"];
1402
+ case "additionalPermissions":
1403
+ return ["permissionId", "permissionName", "permissionType"];
1404
+ default:
1405
+ return [];
1406
+ }
1407
+ }, lt = () => {
1408
+ y === 0 && q("/ui/medplat/manage/menu");
1409
+ const e = O[y].key, n = Ze.findIndex(
1410
+ (r) => r.key === e
1411
+ ), t = Ze[n - 1];
1412
+ if (t) {
1413
+ const r = O.findIndex(
1414
+ (o) => o.key === t.key
1415
+ );
1416
+ D(r);
1417
+ }
1418
+ }, ot = (e) => {
1419
+ const n = O[e].key;
1420
+ return et.has(n);
1421
+ };
1422
+ te(() => {
1423
+ (async () => {
1424
+ var e;
1425
+ if (await ft(), await ht(), await gt(), b(!0), await Xi(), await yt(), await De(), x.get("featureId") && V) {
1426
+ const { data: n } = await Sn(x.get("featureId"));
1427
+ if (n != null && n.permissions) {
1428
+ const t = Hi(
1429
+ n.permissions
1430
+ );
1431
+ if (((e = n == null ? void 0 : n.userMenuItemDtos) == null ? void 0 : e.length) > 0) {
1432
+ const r = Yi(
1433
+ t,
1434
+ n.userMenuItemDtos
1435
+ ).map((o) => ({
1436
+ ...o,
1437
+ permissions: ki(o.permissions)
1438
+ }));
1439
+ ze(r);
1440
+ }
1441
+ Je(t);
1442
+ }
1443
+ }
1444
+ })();
1445
+ }, []), te(() => {
1446
+ if (ni != null && ni.userMenuItemDtos) {
1447
+ const e = a.getValues("updatedFields") || [], n = e == null ? void 0 : e.reduce((r, o) => (r[o.name] = o.enabled, r), {}), t = ni.userMenuItemDtos.map((r) => {
1448
+ let o = {};
1449
+ try {
1450
+ o = r.featureJson ? JSON.parse(r.featureJson) : {};
1451
+ } catch (s) {
1452
+ console.warn("Invalid JSON in featureJson:", s);
1453
+ }
1454
+ const u = {
1455
+ ...n,
1456
+ ...o
1457
+ };
1458
+ return {
1459
+ ...r,
1460
+ featureJson: JSON.stringify(u)
1461
+ };
1462
+ });
1463
+ je(t);
1464
+ }
1465
+ }, [ni]), te(() => {
1466
+ try {
1467
+ const e = x.get("featureId");
1468
+ if (x.get("featureType") && e) {
1469
+ const n = async () => {
1470
+ var t;
1471
+ if (T != null && T.val) {
1472
+ const { data: r } = await Sn(e);
1473
+ if (zi(!0), await Zi(), r != null && r.permissions) {
1474
+ const o = Hi(
1475
+ r.permissions
1476
+ );
1477
+ if (((t = r == null ? void 0 : r.userMenuItemDtos) == null ? void 0 : t.length) > 0) {
1478
+ const u = Yi(
1479
+ o,
1480
+ r.userMenuItemDtos
1481
+ ).map((s) => ({
1482
+ ...s,
1483
+ permissions: ki(s.permissions)
1484
+ }));
1485
+ ze(u);
1486
+ }
1487
+ Je(o);
1488
+ }
1489
+ Bi((o) => ({ ...o, value: !0, length: 0 }));
1490
+ } else {
1491
+ const { data: r } = await cr(e);
1492
+ On(r), await Zi();
1493
+ const o = JSON.parse(r.featureJson || "{}"), u = Object.keys(o).map((s, m) => ({
1494
+ id: m + 1,
1495
+ value: s,
1496
+ checkbox: o[s],
1497
+ updated: !0
1498
+ }));
1499
+ a.setValue("updatedFields", u), oi(u.length > 0), u.length > 0 && zi(!0), Bi((s) => ({ ...s, value: !0, length: o.length || 0 })), Jn(r == null ? void 0 : r.isSeparateFeature);
1500
+ }
1501
+ };
1502
+ _i(), n();
1503
+ }
1504
+ } catch (e) {
1505
+ me({
1506
+ type: "error",
1507
+ message: `error :${e == null ? void 0 : e.message}`
1508
+ });
1509
+ }
1510
+ }, [x, a.setValue, p, Se]);
1511
+ const Hi = (e) => {
1512
+ const n = a.getValues("menuType"), t = a.getValues("featureConstant"), r = (s) => s.trim().toLowerCase().split(/\s+/).map(
1513
+ (m, v) => v === 0 ? m : m.charAt(0).toUpperCase() + m.slice(1)
1514
+ ).join("");
1515
+ let o;
1516
+ if (!V || (t == null ? void 0 : t.length) === 0) {
1517
+ const s = a.getValues("menuName");
1518
+ o = `view.${n}.${r(s)}`;
1519
+ } else
1520
+ o = `view.${n}.${t}`;
1521
+ const u = (s) => {
1522
+ const m = s.id === o;
1523
+ return {
1524
+ permissionId: s.id,
1525
+ permissionType: { type: s.type },
1526
+ permissionName: s.name,
1527
+ permissionDesc: s.desc || "",
1528
+ enabled: s.is_active,
1529
+ isDefault: m,
1530
+ childPermissions: s.child ? s.child.map((v) => u(v)) : [],
1531
+ urlType: (s == null ? void 0 : s.httpMethod) || "",
1532
+ backendUrl: (s == null ? void 0 : s.url) || "",
1533
+ queryCodeRequired: !(s != null && s.url),
1534
+ queryCode: (s == null ? void 0 : s.queryCodes) || ""
1535
+ };
1536
+ };
1537
+ return e.map(u);
1538
+ }, Yi = (e, n) => {
1539
+ if (!Array.isArray(n)) return [];
1540
+ const t = (r, o) => {
1541
+ var u;
1542
+ const s = ((u = r.childPermissions) == null ? void 0 : u.map(
1543
+ (E) => t(E, o)
1544
+ )) || [], m = s.some((E) => E.enabled), v = o.includes(r.permissionId) || m;
1545
+ return { ...r, enabled: v, childPermissions: s };
1546
+ };
1547
+ return n.map((r) => {
1548
+ var o, u, s, m, v, E, N;
1549
+ const ge = ((o = r.permissions) == null ? void 0 : o.map((Ti) => Ti.id)) || [], Z = !!r.roleName || !!r.designationId || !!r.roleId, oe = !!r.userId || !!r.fullName, Ve = e.map(
1550
+ (Ti) => t(Ti, ge)
1551
+ );
1552
+ return {
1553
+ entityType: Z ? "role" : "user",
1554
+ user_id: oe && r.userId || null,
1555
+ role_id: Z && (r.designationId || r.roleId) || null,
1556
+ name: oe ? r.fullName || "" : r.roleName || "",
1557
+ startDate: ((s = (u = r.permissions) == null ? void 0 : u[0]) == null ? void 0 : s.startDate) || null,
1558
+ endDate: ((v = (m = r.permissions) == null ? void 0 : m[0]) == null ? void 0 : v.endDate) || null,
1559
+ isBackendOnly: ((N = (E = r.permissions) == null ? void 0 : E[0]) == null ? void 0 : N.isBackendOnly) || !1,
1560
+ permissions: Ve
1561
+ };
1562
+ });
1563
+ }, ki = (e) => {
1564
+ const n = (t) => {
1565
+ var r, o;
1566
+ let u = [];
1567
+ if ((r = t.childPermissions) != null && r.length) {
1568
+ u = t.childPermissions.map(n);
1569
+ const s = u.every((m) => m.enabled);
1570
+ t.enabled = t.enabled || s;
1571
+ }
1572
+ return t.enabled && (o = t.childPermissions) != null && o.length && (u = u.map((s) => {
1573
+ var m;
1574
+ return {
1575
+ ...s,
1576
+ enabled: !0,
1577
+ childPermissions: (m = s.childPermissions) != null && m.length ? ki(s.childPermissions) : []
1578
+ };
1579
+ })), {
1580
+ ...t,
1581
+ childPermissions: u
1582
+ };
1583
+ };
1584
+ return e.map(n);
1585
+ }, st = (e, n) => {
1586
+ const t = /* @__PURE__ */ new Map(), r = (u) => {
1587
+ u.forEach((s) => {
1588
+ var m;
1589
+ t.set(s.permissionId, s), (m = s.childPermissions) != null && m.length && r(s.childPermissions);
1590
+ });
1591
+ };
1592
+ r(e);
1593
+ const o = (u, s) => u.map((m) => {
1594
+ const v = (s == null ? void 0 : s.find((N) => N.permissionId === m.permissionId)) || {}, E = o(
1595
+ m.childPermissions || [],
1596
+ v.childPermissions || []
1597
+ );
1598
+ return {
1599
+ ...m,
1600
+ enabled: v.enabled ?? m.enabled,
1601
+ childPermissions: E
1602
+ };
1603
+ });
1604
+ return n.map((u) => ({
1605
+ ...u,
1606
+ permissions: o(e, u.permissions)
1607
+ }));
1608
+ }, dt = async () => {
1609
+ try {
1610
+ const e = (await J({
1611
+ code: "RETREIVE_DYNAMIC_FEATURE_INFO",
1612
+ parameters: {
1613
+ id: parseInt(x.get("featureId")),
1614
+ menuType: x.get("featureType")
1615
+ }
1616
+ })).data;
1617
+ if (e.result) {
1618
+ let n = e.result[0];
1619
+ const t = (() => {
1620
+ try {
1621
+ return n.mobile_config ? JSON.parse(n.mobile_config) : {};
1622
+ } catch {
1623
+ return {};
1624
+ }
1625
+ })(), r = ((t == null ? void 0 : t.mobile_entities_sync) ?? []).map(
1626
+ (s) => ce == null ? void 0 : ce.find((m) => m.tableName === s)
1627
+ ).filter(Boolean);
1628
+ a.reset({
1629
+ menuName: n.menuName ? n.menuName : "",
1630
+ featureConstant: n.featureConstant ? n.featureConstant : "",
1631
+ navigationState: n.navigationState ? n.navigationState : "medplat.form",
1632
+ isDynamicFeature: n.isDynamicFeature !== void 0 && n.isDynamicFeature !== null ? n.isDynamicFeature : !1,
1633
+ menuType: n.menuType ? n.menuType : "",
1634
+ menuGroup: n.group_id ? n.group_id.toString() : "",
1635
+ isWebFeature: n.isWebFeature ? n.isWebFeature : !1,
1636
+ isMobileFeature: n.isMobileFeature ? n.isMobileFeature : !1,
1637
+ entityName: (t == null ? void 0 : t.entity_name) ?? "",
1638
+ mobileMode: (t == null ? void 0 : t.mobile_mode) ?? null,
1639
+ icon: (t == null ? void 0 : t.icon) ?? "",
1640
+ mobileEntitiesSync: t != null && t.mobile_entities_sync ? t.mobile_entities_sync : [],
1641
+ conditions: (t == null ? void 0 : t.conditions) ?? "",
1642
+ formCode: n.formCode ? n.formCode : "",
1643
+ version: n.currentVersion ? n.currentVersion : "",
1644
+ trainingRequired: (t == null ? void 0 : t.training_required) ?? !1,
1645
+ trainingQuery: (t == null ? void 0 : t.training_query) ?? "",
1646
+ notificationBadgeEnabled: (t == null ? void 0 : t.notification_badge_enabled) ?? !1,
1647
+ notificationBadgeType: (t == null ? void 0 : t.notification_badge_type) ?? "",
1648
+ notificationBadgeQuery: (t == null ? void 0 : t.notification_badge_query) ?? ""
1649
+ }), xi(r), n.isMobileFeature && H(!0);
1650
+ const o = (t == null ? void 0 : t.training_query) ?? "", u = (t == null ? void 0 : t.notification_badge_query) ?? "";
1651
+ o && (He(o), De(o)), u && (Ye(u), De(u)), n.formCode && (Me(n.formCode), Re(n.formCode)), _i(), M(!0);
1652
+ }
1653
+ } catch (e) {
1654
+ me({
1655
+ message: e.message,
1656
+ type: "error"
1657
+ });
1658
+ }
1659
+ }, Zi = async () => {
1660
+ try {
1661
+ const e = (await J({
1662
+ code: "RETREIVE_DYNAMIC_FEATURE_INFO",
1663
+ parameters: {
1664
+ id: parseInt(x.get("featureId")),
1665
+ menuType: x.get("featureType")
1666
+ }
1667
+ })).data;
1668
+ if (e.result) {
1669
+ let n = e.result[0];
1670
+ const t = (() => {
1671
+ try {
1672
+ return n.mobile_config ? JSON.parse(n.mobile_config) : {};
1673
+ } catch {
1674
+ return {};
1675
+ }
1676
+ })(), r = (m, v = null) => {
1677
+ try {
1678
+ return !m || typeof m != "string" ? v : JSON.parse(m);
1679
+ } catch {
1680
+ return v;
1681
+ }
1682
+ }, o = ((t == null ? void 0 : t.mobile_entities_sync) ?? []).map(
1683
+ (m) => ce == null ? void 0 : ce.find((v) => v.tableName === m)
1684
+ ).filter(Boolean);
1685
+ a.setValue("menuName", n.menuName ? n.menuName : ""), a.setValue(
1686
+ "navigationState",
1687
+ n.navigationState ? n.navigationState : ""
1688
+ ), a.setValue(
1689
+ "isDynamicFeature",
1690
+ n.isDynamicFeature !== void 0 && n.isDynamicFeature !== null ? n.isDynamicFeature : !1
1691
+ ), a.setValue("menuType", n.menuType ? n.menuType : ""), a.setValue(
1692
+ "menuGroup",
1693
+ n.group_id ? n.group_id.toString() : ""
1694
+ ), a.setValue(
1695
+ "isWebFeature",
1696
+ n.isWebFeature ? n.isWebFeature : !1
1697
+ ), a.setValue(
1698
+ "isMobileFeature",
1699
+ n.isMobileFeature ? n.isMobileFeature : !1
1700
+ ), a.setValue("entityName", (t == null ? void 0 : t.entity_name) ?? ""), a.setValue("mobileMode", (t == null ? void 0 : t.mobile_mode) ?? null), a.setValue("icon", (t == null ? void 0 : t.icon) ?? ""), a.setValue(
1701
+ "mobileEntitiesSync",
1702
+ (t == null ? void 0 : t.mobile_entities_sync) ?? []
1703
+ ), a.setValue("conditions", (t == null ? void 0 : t.conditions) ?? ""), a.setValue(
1704
+ "trainingRequired",
1705
+ (t == null ? void 0 : t.training_required) ?? !1
1706
+ ), a.setValue("trainingQuery", (t == null ? void 0 : t.training_query) ?? ""), a.setValue(
1707
+ "notificationBadgeEnabled",
1708
+ (t == null ? void 0 : t.notification_badge_enabled) ?? !1
1709
+ ), a.setValue(
1710
+ "notificationBadgeType",
1711
+ (t == null ? void 0 : t.notification_badge_type) ?? ""
1712
+ ), a.setValue(
1713
+ "notificationBadgeQuery",
1714
+ (t == null ? void 0 : t.notification_badge_query) ?? ""
1715
+ ), xi(o), n.isMobileFeature && H(!0);
1716
+ const u = (t == null ? void 0 : t.training_query) ?? "", s = (t == null ? void 0 : t.notification_badge_query) ?? "";
1717
+ u && (He(u), De(u)), s && (Ye(s), De(s)), M(!0);
1718
+ }
1719
+ } catch (e) {
1720
+ me({
1721
+ message: e.message,
1722
+ type: "error"
1723
+ });
1724
+ }
1725
+ }, ut = () => {
1726
+ const e = a.getValues("menuType") || "menuType", n = a.getValues("featureConstant") || "feature", t = (u) => u.trim().toLowerCase().split(/\s+/).map(
1727
+ (s, m) => m === 0 ? s : s.charAt(0).toUpperCase() + s.slice(1)
1728
+ ).join("");
1729
+ let r;
1730
+ if (V)
1731
+ r = `view.${e}.${n}`;
1732
+ else {
1733
+ const u = a.getValues("menuName");
1734
+ r = `view.${e}.${t(u)}`;
1735
+ }
1736
+ const o = {
1737
+ permissionId: r,
1738
+ permissionType: { type: "menu" },
1739
+ permissionName: `view ${n}`,
1740
+ permissionDesc: "",
1741
+ enabled: !0,
1742
+ isDefault: !0,
1743
+ childPermissions: [],
1744
+ ...V === !1 && {
1745
+ backendUrl: "",
1746
+ urlType: "",
1747
+ queryCode: ""
1748
+ }
1749
+ };
1750
+ Je([o]);
1751
+ }, ct = (e) => {
1752
+ vi(e);
1753
+ }, mt = (e) => {
1754
+ const n = (e == null ? void 0 : e.map((t) => t == null ? void 0 : t.tableName)) || [];
1755
+ xi(e), a.setValue("mobileEntitiesSync", n);
1756
+ }, pt = (e, n) => {
1757
+ ii(n);
1758
+ };
1759
+ te(() => {
1760
+ const e = (x == null ? void 0 : x.get("staticOrDynamic")) === "STATIC";
1761
+ p && Se && x.get("featureId") && !e && dt();
1762
+ }, [p, Se]);
1763
+ const ft = async () => {
1764
+ const e = (await J({
1765
+ code: "fetch_menu_groups"
1766
+ })).data;
1767
+ Ke(e.result.map((n) => n.menu_type)), yi(e.result);
1768
+ }, ht = async () => {
1769
+ const e = (await J({
1770
+ code: "mfa_retreive_all_table_names"
1771
+ })).data;
1772
+ R(e.result.map((n) => n.table_name));
1773
+ }, gt = async () => {
1774
+ const e = (await J({
1775
+ code: "retrieve_synced_tables"
1776
+ })).data;
1777
+ gi(e == null ? void 0 : e.result);
1778
+ }, Xi = async () => {
1779
+ const e = (await J({
1780
+ code: "mfa_retrieve_separate_feature_forms"
1781
+ })).data;
1782
+ if (e.result) {
1783
+ let n = e.result;
1784
+ L(n);
1785
+ let t = {};
1786
+ return n.forEach((r) => {
1787
+ try {
1788
+ const o = JSON.parse(r.versions);
1789
+ t[r.form_code] = o;
1790
+ } catch (o) {
1791
+ console.error("Invalid JSON in form.versions:", r.versions, o), t[r.form_code] = [];
1792
+ }
1793
+ }), Ce(t), t;
1794
+ }
1795
+ }, yt = async () => {
1796
+ try {
1797
+ const { data: e } = await J({
1798
+ code: "user_search_for_selectize",
1799
+ parameters: {
1800
+ searchString: ""
1801
+ }
1802
+ });
1803
+ Oi(e == null ? void 0 : e.result);
1804
+ const n = await Lt();
1805
+ An(n.data);
1806
+ } catch (e) {
1807
+ console.error("Error fetching users or roles:", e);
1808
+ }
1809
+ }, De = async (e = "") => {
1810
+ try {
1811
+ const n = (await J({
1812
+ code: "GET_ALL_QUERY_CODE",
1813
+ parameters: { search: e }
1814
+ })).data;
1815
+ Hn((n == null ? void 0 : n.result) || []);
1816
+ } catch (n) {
1817
+ console.error("Error fetching query codes:", n);
1818
+ }
1819
+ }, Ki = () => a.getValues("isMobileFeature") && a.getValues("isWebFeature") ? Oe : Oe.filter((e) => {
1820
+ const { roleType: n } = e;
1821
+ return !!(n === null || a.getValues("isMobileFeature") && (n === "MOBILE" || n === "BOTH") || a.getValues("isWebFeature") && (n === "WEB" || n === "BOTH"));
1822
+ });
1823
+ te(() => {
1824
+ if (!(Oe != null && Oe.length)) return;
1825
+ const e = Le.filter((n) => {
1826
+ if (!n.roleName) return !0;
1827
+ const t = Oe.find((o) => o.name === n.roleName);
1828
+ if (!t) return !0;
1829
+ const { roleType: r } = t;
1830
+ return !(!Li && r === "MOBILE" || !ji && r === "WEB");
1831
+ });
1832
+ je(e);
1833
+ }, [Li, ji, Oe]);
1834
+ const bt = (e) => {
1835
+ const { firstName: n, lastName: t, userName: r } = e;
1836
+ return !n && !t && !r ? "" : n && !t && !r ? n : `${n} ${t} (${r})`;
1837
+ }, _i = () => {
1838
+ C(() => {
1839
+ const e = a.getValues("menuType") ? JSON.parse(
1840
+ Se == null ? void 0 : Se.find(
1841
+ (t) => t.menu_type === a.getValues("menuType")
1842
+ ).groupNames
1843
+ ) : null, n = e == null ? void 0 : e.filter((t) => t.id !== null);
1844
+ return n != null && n.length || a.setValue("menuGroup", ""), n;
1845
+ });
1846
+ }, vt = (e) => {
1847
+ a.setValue("menuGroup", e.target.value);
1848
+ }, xt = (e) => {
1849
+ e.target.checked ? H(!0) : (H(!1), a.setValue("entityName", null), a.setValue("icon", null), a.setValue("mobileEntitiesSync", null), a.setValue("conditions", null), a.setValue("mobileMode", null));
1850
+ }, Ct = (e) => {
1851
+ e.target.checked || (a.setValue("formCode", null), a.setValue("version", null));
1852
+ }, St = () => {
1853
+ ti("add-parent"), ri(null), ai(null), li(null), Qe(!0);
1854
+ }, wt = (e) => {
1855
+ ti("add-child"), ri(e.permissionId), ai(null), li(null), Qe(!0);
1856
+ }, Nt = (e) => {
1857
+ ti("edit"), ri(null), ai(e), li(e.permissionId), Qe(!0);
1858
+ }, en = (e, n, t) => e.map((r) => r.permissionId === n ? {
1859
+ ...r,
1860
+ childPermissions: [...r.childPermissions || [], t]
1861
+ } : {
1862
+ ...r,
1863
+ childPermissions: en(
1864
+ r.childPermissions || [],
1865
+ n,
1866
+ t
1867
+ )
1868
+ }), nn = (e, n, t) => e.map((r) => r.permissionId === n ? {
1869
+ ...t,
1870
+ childPermissions: r.childPermissions || []
1871
+ } : {
1872
+ ...r,
1873
+ childPermissions: nn(
1874
+ r.childPermissions || [],
1875
+ n,
1876
+ t
1877
+ )
1878
+ }), tn = (e, n) => e.filter((t) => t.permissionId !== n).map((t) => ({
1879
+ ...t,
1880
+ childPermissions: tn(
1881
+ t.childPermissions || [],
1882
+ n
1883
+ )
1884
+ })), It = (e) => {
1885
+ Je((n) => {
1886
+ let t = [...n];
1887
+ if (Ge === "add-parent")
1888
+ t = [...n, e];
1889
+ else if (Ge === "add-child") {
1890
+ const r = (s, m) => {
1891
+ var v;
1892
+ for (const E of s) {
1893
+ if (E.permissionId === m) return E;
1894
+ if ((v = E.childPermissions) != null && v.length) {
1895
+ const N = r(E.childPermissions, m);
1896
+ if (N) return N;
1897
+ }
1898
+ }
1899
+ return null;
1900
+ }, o = r(n, Ci), u = {
1901
+ ...e,
1902
+ permissionType: typeof o.permissionType == "string" ? { type: o.permissionType } : o.permissionType
1903
+ };
1904
+ t = en(
1905
+ n,
1906
+ Ci,
1907
+ u
1908
+ );
1909
+ } else Ge === "edit" && (t = nn(
1910
+ n,
1911
+ Bn,
1912
+ e
1913
+ ));
1914
+ return t;
1915
+ }), Qe(!1), ti("add-parent"), ri(null), ai(null), li(null);
1916
+ }, kt = (e) => {
1917
+ const n = typeof e == "string" ? e : e.permissionId;
1918
+ Je((t) => tn(t, n));
1919
+ };
1920
+ te(() => {
1921
+ a.setValue("additionalPermissions", he);
1922
+ }, [he, a]);
1923
+ const si = (e, n = null) => {
1924
+ let t = [];
1925
+ return e.forEach((r) => {
1926
+ const {
1927
+ permissionId: o,
1928
+ permissionType: u,
1929
+ permissionName: s,
1930
+ permissionDesc: m,
1931
+ enabled: v,
1932
+ backendUrl: E,
1933
+ urlType: N,
1934
+ queryCode: ge
1935
+ } = r;
1936
+ t.push({
1937
+ permissionId: o,
1938
+ permissionType: u == null ? void 0 : u.type,
1939
+ permissionName: s,
1940
+ permissionDesc: m,
1941
+ parentPermissionId: n,
1942
+ enabled: v,
1943
+ backendUrl: E,
1944
+ urlType: N,
1945
+ queryCode: ge
1946
+ }), r.childPermissions && r.childPermissions.length > 0 && (t = t.concat(
1947
+ si(r.childPermissions, o)
1948
+ ));
1949
+ }), t;
1950
+ }, _t = () => {
1951
+ (async () => {
1952
+ let e = await Xi();
1953
+ Ce(e), Me(a.getValues("formCode"));
1954
+ })();
1955
+ }, rn = JSON.stringify(
1956
+ (A = Y.value ? a.getValues("updatedFields") : a.getValues("fields")) == null ? void 0 : A.reduce((e, n) => {
1957
+ var t;
1958
+ return (t = n.value) != null && t.trim() && (e[n.value.trim()] = n.checkbox), e;
1959
+ }, {})
1960
+ ), Tt = () => {
1961
+ if (!V && (T == null ? void 0 : T.val) === !1)
1962
+ try {
1963
+ const e = [];
1964
+ le != null && le.id && e.push({
1965
+ designationId: null,
1966
+ userId: le.id,
1967
+ fullName: `${le.firstName || ""} ${le.lastName || ""}`.trim(),
1968
+ featureJson: rn
1969
+ }), (Ne == null ? void 0 : Ne.length) > 0 && e.push(
1970
+ ...Ne.map((n) => ({
1971
+ designationId: n.id,
1972
+ roleName: n.name,
1973
+ featureJson: rn
1974
+ }))
1975
+ ), je((n) => [...n, ...e]), me({
1976
+ message: "Menu item added successfully",
1977
+ type: "success"
1978
+ }), vi([]), ii({});
1979
+ } catch (e) {
1980
+ console.error(e), me({
1981
+ message: "Cannot add menu item",
1982
+ type: "error"
1983
+ });
1984
+ }
1985
+ else {
1986
+ const e = [];
1987
+ if (le != null && le.id && e.push({
1988
+ type: "user",
1989
+ id: le.id,
1990
+ name: le.firstName + " " + le.lastName
1991
+ }), Ne.length > 0 && e.push({
1992
+ type: "role",
1993
+ ids: Ne.map((n) => n.id),
1994
+ names: Ne.map((n) => n.name)
1995
+ }), e.length === 0) return;
1996
+ Ln(e), Si(!0), ii(null), vi([]);
1997
+ }
1998
+ }, an = (e) => {
1999
+ const n = [], t = (r, o) => {
2000
+ for (const u of r)
2001
+ u.enabled && n.push({
2002
+ permission_id: u.permissionId,
2003
+ user_id: o.user_id || null,
2004
+ role_id: o.role_id || null,
2005
+ is_backend_only: o.isBackendOnly || !1,
2006
+ start_date: o.startDate || null,
2007
+ end_date: o.endDate || null
2008
+ });
2009
+ };
2010
+ for (const r of e)
2011
+ t(r.permissions || [], r);
2012
+ return n;
2013
+ }, Ft = (e, n) => {
2014
+ ze((t) => {
2015
+ const r = [...t];
2016
+ return r[e] = {
2017
+ ...r[e],
2018
+ permissions: ln(
2019
+ r[e].permissions,
2020
+ n.permissionId,
2021
+ !n.enabled
2022
+ )
2023
+ }, r;
2024
+ });
2025
+ }, ln = (e, n, t) => e.map((r) => {
2026
+ var o, u;
2027
+ if (r.permissionId === n)
2028
+ return {
2029
+ ...r,
2030
+ enabled: t,
2031
+ childPermissions: (o = r.childPermissions) != null && o.length ? on(r.childPermissions, t) : []
2032
+ };
2033
+ if ((u = r.childPermissions) != null && u.length) {
2034
+ const s = ln(
2035
+ r.childPermissions,
2036
+ n,
2037
+ t
2038
+ ), m = s.length > 0 && s.every((v) => v.enabled === !0);
2039
+ return {
2040
+ ...r,
2041
+ enabled: m,
2042
+ childPermissions: s
2043
+ };
2044
+ }
2045
+ return r;
2046
+ }), on = (e, n) => e.map((t) => {
2047
+ var r;
2048
+ return {
2049
+ ...t,
2050
+ enabled: n,
2051
+ childPermissions: (r = t.childPermissions) != null && r.length ? on(t.childPermissions, n) : []
2052
+ };
2053
+ }), Dt = async (e) => {
2054
+ (await J({
2055
+ code: "check_unique_feature_constant",
2056
+ parameters: {
2057
+ featureConstant: e
2058
+ }
2059
+ })).data.result[0].exists ? a.setError("featureConstant", {
2060
+ type: "manual",
2061
+ message: "Feature constant already exists"
2062
+ }) : qe(`${e} Feature constant is available`);
2063
+ }, Vt = async (e) => {
2064
+ (await J({
2065
+ code: "CHECK_UNIQUE_NAVIGATION_STATE",
2066
+ parameters: {
2067
+ featureState: e
2068
+ }
2069
+ })).data.result[0].exists ? a.setError("navigationState", {
2070
+ type: "manual",
2071
+ message: "Feature State already exists"
2072
+ }) : qe(`${e} Feature State is available`);
2073
+ }, Et = cn(Dt, 500), Pt = cn(
2074
+ Vt,
2075
+ 500
2076
+ ), sn = Jt(
2077
+ async (e, n, t) => {
2078
+ const { data: r } = await J({
2079
+ code: "user_search_for_selectize",
2080
+ parameters: {
2081
+ searchString: e
2082
+ }
2083
+ });
2084
+ n(r.result), t({ firstName: e, lastName: "", userName: "" });
2085
+ },
2086
+ 500
2087
+ ), Wt = async (e) => {
2088
+ const n = si(he);
2089
+ let t = {
2090
+ code: "insert_dynamic_feature_into_menu_config",
2091
+ parameters: {
2092
+ menuName: e.menuName ? e.menuName : null,
2093
+ featureConstant: e.featureConstant ? e.featureConstant : null,
2094
+ formCode: e.formCode && e.formCode !== "" ? e.formCode : null,
2095
+ prevFormCode: $e || null,
2096
+ deLinkPrevForm: $e !== e.formCode,
2097
+ menuType: e.menuType ? e.menuType : null,
2098
+ menuGroup: e.menuGroup ? parseInt(e.menuGroup) : null,
2099
+ navigationState: e.navigationState && e.formCode && e.formCode !== "" ? e.navigationState : null,
2100
+ formVersion: e.version ? e.version : null,
2101
+ isMobileFeature: e.isMobileFeature ? e.isMobileFeature : null,
2102
+ isWebFeature: e.isWebFeature ? e.isWebFeature : null,
2103
+ permissions: JSON.stringify(n),
2104
+ mobileConfig: JSON.stringify({
2105
+ entity_name: e.entityName ?? null,
2106
+ mobile_mode: e.mobileMode ? e.mobileMode.toUpperCase() : null,
2107
+ icon: e.icon ?? null,
2108
+ mobile_entities_sync: e.mobileEntitiesSync ?? [],
2109
+ conditions: e.conditions ?? null,
2110
+ training_required: e.trainingRequired ?? !1,
2111
+ training_query: e.trainingQuery ?? null,
2112
+ notification_badge_enabled: e.notificationBadgeEnabled ?? !1,
2113
+ notification_badge_type: e.notificationBadgeType ?? null,
2114
+ notification_badge_query: e.notificationBadgeQuery ?? null
2115
+ })
2116
+ }
2117
+ };
2118
+ try {
2119
+ if (await J(t)) {
2120
+ let r = [];
2121
+ e.menuName && e.menuName.length > 0 && r.push({
2122
+ code: "medplat_form_insert_into_translation_master",
2123
+ parameters: {
2124
+ translation_key: e.menuName.replaceAll(" ", ""),
2125
+ translation_value: e.menuName,
2126
+ form_code: "General"
2127
+ },
2128
+ sequence: 1
2129
+ }), r.length > 0 && await Pi(r);
2130
+ const o = an(Ie);
2131
+ o && await J({
2132
+ code: "GRANT_PERMISSION_USER_MAP",
2133
+ parameters: {
2134
+ permissionUserMap: JSON.stringify(o)
2135
+ }
2136
+ });
2137
+ }
2138
+ me({
2139
+ message: x.get("featureId") ? "Feature updated successfully" : "New Dynamic feature created successfully!",
2140
+ type: "success"
2141
+ }), ne(!0);
2142
+ } catch (r) {
2143
+ me({
2144
+ message: r.message,
2145
+ type: "error"
2146
+ });
2147
+ }
2148
+ }, qt = async (e) => {
2149
+ var n, t, r, o;
2150
+ try {
2151
+ let u = null, s = null, m = null;
2152
+ const v = mn();
2153
+ (n = e == null ? void 0 : e.menuGroup) != null && n.length && (u = mn());
2154
+ const E = si(he), N = {
2155
+ code: "insert_menu_config",
2156
+ parameters: {
2157
+ UUID: v,
2158
+ featureJson: null,
2159
+ menuGroup: e.menuGroup ? parseInt(e.menuGroup) : null,
2160
+ groupUUID: u,
2161
+ menuName: e.menuName ? e.menuName : null,
2162
+ menuType: e.menuType ? e.menuType : null,
2163
+ navigationState: e.navigationState ? e.navigationState : null,
2164
+ subgroupId: s,
2165
+ subgroupUUID: m,
2166
+ isMobileFeature: e != null && e.isMobileFeature ? e == null ? void 0 : e.isMobileFeature : null,
2167
+ isWebFeature: e != null && e.isWebFeature ? e == null ? void 0 : e.isWebFeature : null,
2168
+ permissions: JSON.stringify(E),
2169
+ isNewFeature: "true",
2170
+ mobileConfig: JSON.stringify({
2171
+ entity_name: (e == null ? void 0 : e.entityName) ?? null,
2172
+ mobile_mode: e != null && e.mobileMode ? e == null ? void 0 : e.mobileMode.toUpperCase() : null,
2173
+ icon: (e == null ? void 0 : e.icon) ?? null,
2174
+ mobile_entities_sync: (e == null ? void 0 : e.mobileEntitiesSync) ?? [],
2175
+ conditions: (e == null ? void 0 : e.conditions) ?? null,
2176
+ training_required: e.trainingRequired ?? !1,
2177
+ training_query: e.trainingQuery ?? null,
2178
+ notification_badge_enabled: e.notificationBadgeEnabled ?? !1,
2179
+ notification_badge_type: e.notificationBadgeType ?? null,
2180
+ notification_badge_query: e.notificationBadgeQuery ?? null
2181
+ })
2182
+ }
2183
+ };
2184
+ if (Y.value && (T == null ? void 0 : T.val) === !1) {
2185
+ N.code = "update_menu_config";
2186
+ const { fields: Z, updatedFields: oe } = e, Ve = Y.value && Fe ? un(oe) : (t = Z[0]) != null && t.value && Fe ? un(Z) : {};
2187
+ a.setValue("featureJson", Ve), delete N.parameters.UUID, delete N.parameters.groupUUID, delete N.parameters.subgroupUUID, delete N.parameters.permissions, delete N.parameters.isNewFeature, N.parameters.featureType = x.get("featureType"), N.parameters.featureId = x.get("featureId"), N.parameters.featureJson = Ve;
2188
+ }
2189
+ let ge;
2190
+ if (Y.value && (T == null ? void 0 : T.val) === !1) {
2191
+ const { data: Z } = await jt(N);
2192
+ ge = Z, await mr((r = Z == null ? void 0 : Z.result[0]) == null ? void 0 : r.id, Le);
2193
+ } else {
2194
+ Y.value && (delete N.parameters.UUID, delete N.parameters.groupUUID, delete N.parameters.subgroupUUID, delete N.parameters.isNewFeature, N.parameters.featureType = x.get("featureType"), N.parameters.featureId = x.get("featureId"));
2195
+ const { data: Z } = await J(N);
2196
+ if (ge = Z, Z) {
2197
+ let oe = [];
2198
+ e.menuName && e.menuName.length > 0 && oe.push({
2199
+ code: "medplat_form_insert_into_translation_master",
2200
+ parameters: {
2201
+ translation_key: e.menuName.replaceAll(" ", ""),
2202
+ translation_value: e.menuName,
2203
+ form_code: "General"
2204
+ },
2205
+ sequence: 1
2206
+ }), oe.length > 0 && await Pi(oe);
2207
+ const Ve = an(Ie);
2208
+ Ve && await J({
2209
+ code: "GRANT_PERMISSION_USER_MAP",
2210
+ parameters: {
2211
+ permissionUserMap: JSON.stringify(Ve)
2212
+ }
2213
+ });
2214
+ }
2215
+ }
2216
+ (o = ge == null ? void 0 : ge.result) != null && o.length ? me({
2217
+ message: Y.value ? "FEATURE EDITED SUCCESFULLY" : "FEATURE ADDED SUCCESFULLY",
2218
+ type: "success"
2219
+ }) : me({
2220
+ message: "FEATURE CONFIGURATION ALREADY EXISTS ",
2221
+ type: "error"
2222
+ }), ne(!0);
2223
+ } catch (u) {
2224
+ me({
2225
+ message: u.message,
2226
+ type: "error"
2227
+ });
2228
+ }
2229
+ }, dn = async (e) => {
2230
+ V ? Wt(e) : qt(e);
2231
+ }, un = (e) => JSON.stringify(
2232
+ e == null ? void 0 : e.reduce((n, t) => (n[t.value] = t.checkbox, n), {})
2233
+ ), At = (e, n) => {
2234
+ e && e.type === "change" && Rt(n);
2235
+ }, Rt = rr(
2236
+ (e) => {
2237
+ sn(e, Oi, ii);
2238
+ },
2239
+ [sn]
2240
+ ), Ot = () => {
2241
+ oi(!Fe), Fe || (Y.value ? a.setValue("updatedFields", [
2242
+ { id: 1, value: "", checkbox: !1 }
2243
+ ]) : a.setValue("fields", [{ id: 1, value: "", checkbox: !1 }]));
2244
+ }, zt = (e) => {
2245
+ const n = (Y.value ? a.getValues("updatedFields") : a.getValues("fields")).map((t) => t.id === e ? { ...t, checkbox: !t.checkbox } : t);
2246
+ Y.value ? a.setValue("updatedFields", n) : a.setValue("fields", n);
2247
+ }, Ut = () => {
2248
+ const e = Y.value ? a.getValues("updatedFields") : a.getValues("fields"), n = e[(e == null ? void 0 : e.length) - 1];
2249
+ if ((n == null ? void 0 : n.value.trim()) === "") {
2250
+ alert("Enter the right name before adding a new one.");
2251
+ return;
2252
+ }
2253
+ const t = {
2254
+ id: e.length + 1,
2255
+ value: "",
2256
+ checkbox: !1
2257
+ };
2258
+ Y.value ? a.setValue("updatedFields", [...e, t]) : a.setValue("fields", [...e, t]);
2259
+ }, Bt = (e) => {
2260
+ const n = (Y.value ? a.getValues("updatedFields") : a.getValues("fields")).filter((t) => t.id !== e);
2261
+ Y.value ? a.setValue("updatedFields", n) : a.setValue("fields", n), (n == null ? void 0 : n.length) === 0 && (Y.value ? oi(!0) : oi(!1));
2262
+ };
2263
+ return /* @__PURE__ */ i(
2264
+ "form",
2265
+ {
2266
+ noValidate: !0,
2267
+ ref: re,
2268
+ onSubmit: a.handleSubmit(dn),
2269
+ method: "POST",
2270
+ children: /* @__PURE__ */ i(d, { sx: { width: "100%", p: 3, borderRadius: 2 }, children: /* @__PURE__ */ l(d, { sx: { display: "flex" }, children: [
2271
+ /* @__PURE__ */ i(
2272
+ d,
2273
+ {
2274
+ sx: {
2275
+ width: "30%",
2276
+ maxHeight: "87vh",
2277
+ background: `linear-gradient(to right, ${ue.palette.custom.featureList || "#3576BA"}, ${ue.palette.custom.black2 || "#1C2128"})`,
2278
+ p: 3,
2279
+ borderTopLeftRadius: 16,
2280
+ borderBottomLeftRadius: 16,
2281
+ borderTopRightRadius: 0,
2282
+ borderBottomRightRadius: 0,
2283
+ display: "flex",
2284
+ flexDirection: "column",
2285
+ justifyContent: "center",
2286
+ gap: 5
2287
+ },
2288
+ children: O.map((e, n) => {
2289
+ const t = n === y, r = ot(n), o = Ze.some((E) => E.key === e.key) && !r && !t, u = !o && !r && !t;
2290
+ let s = "transparent", m = "2px solid rgba(255,255,255,0.5)", v = "white";
2291
+ return t ? (s = "#BEE2FD", v = "#1e3a8a", m = "2px solid #BEE2FD") : r ? (s = "white", v = "#4caf50", m = "2px solid #4caf50") : o ? (s = "transparent", v = "white", m = "2px solid #BEE2FD") : u && (s = "transparent", v = "rgba(255,255,255,0.5)", m = "2px solid rgba(255,255,255,0.2)"), /* @__PURE__ */ i(Qt, { sx: { p: 0, m: 0 }, children: /* @__PURE__ */ l(
2292
+ d,
2293
+ {
2294
+ sx: {
2295
+ display: "flex",
2296
+ alignItems: "center",
2297
+ position: "relative",
2298
+ backgroundColor: t ? "custom.gray3" : "transparent",
2299
+ px: 1,
2300
+ py: 1,
2301
+ transition: "all 0.3s ease",
2302
+ borderRadius: 2,
2303
+ minHeight: 64
2304
+ },
2305
+ children: [
2306
+ n < (O == null ? void 0 : O.length) - 1 && /* @__PURE__ */ i(
2307
+ d,
2308
+ {
2309
+ sx: {
2310
+ position: "absolute",
2311
+ top: "45%",
2312
+ left: 22,
2313
+ height: "calc(100% + -10px)",
2314
+ width: 2,
2315
+ backgroundColor: "white",
2316
+ opacity: u ? 0.3 : 1,
2317
+ zIndex: 0,
2318
+ transform: "translateY(50%)"
2319
+ }
2320
+ }
2321
+ ),
2322
+ /* @__PURE__ */ i(
2323
+ d,
2324
+ {
2325
+ sx: {
2326
+ width: 32,
2327
+ height: 32,
2328
+ borderRadius: "50%",
2329
+ backgroundColor: s,
2330
+ border: m,
2331
+ color: v,
2332
+ fontWeight: "bold",
2333
+ fontSize: 14,
2334
+ display: "flex",
2335
+ alignItems: "center",
2336
+ justifyContent: "center",
2337
+ zIndex: 1,
2338
+ flexShrink: 0
2339
+ },
2340
+ children: r && !t ? /* @__PURE__ */ i(se, { iconName: "faCheck", size: "lg" }) : n + 1
2341
+ }
2342
+ ),
2343
+ /* @__PURE__ */ l(d, { sx: { ml: 2 }, children: [
2344
+ /* @__PURE__ */ l(
2345
+ c,
2346
+ {
2347
+ variant: "caption",
2348
+ sx: {
2349
+ color: r ? "primary.main" : "white",
2350
+ fontWeight: "bold",
2351
+ textTransform: "uppercase",
2352
+ fontSize: 14,
2353
+ opacity: u ? 0.5 : 1
2354
+ },
2355
+ children: [
2356
+ "STEP ",
2357
+ n + 1
2358
+ ]
2359
+ }
2360
+ ),
2361
+ /* @__PURE__ */ i(
2362
+ c,
2363
+ {
2364
+ variant: "subtitle2",
2365
+ sx: {
2366
+ color: r ? "primary.main" : "white",
2367
+ fontWeight: "bold",
2368
+ textTransform: "uppercase",
2369
+ fontSize: 14,
2370
+ opacity: u ? 0.5 : 1
2371
+ },
2372
+ children: e.label
2373
+ }
2374
+ )
2375
+ ] })
2376
+ ]
2377
+ }
2378
+ ) }, e.key);
2379
+ })
2380
+ }
2381
+ ),
2382
+ /* @__PURE__ */ l(
2383
+ d,
2384
+ {
2385
+ sx: {
2386
+ width: "80%",
2387
+ backgroundColor: "background.paper",
2388
+ padding: 2,
2389
+ borderRadius: "10px",
2390
+ display: "flex",
2391
+ flexDirection: "column",
2392
+ maxHeight: "87vh",
2393
+ overflowY: "auto"
2394
+ },
2395
+ children: [
2396
+ ((W = O[y]) == null ? void 0 : W.key) === "featureDetails" && /* @__PURE__ */ i(d, { display: "flex", justifyContent: "center", children: /* @__PURE__ */ l(d, { width: "80%", children: [
2397
+ /* @__PURE__ */ i(
2398
+ c,
2399
+ {
2400
+ variant: "h5",
2401
+ sx: {
2402
+ fontWeight: "bold",
2403
+ textAlign: "center",
2404
+ marginBottom: 1,
2405
+ marginTop: 2
2406
+ },
2407
+ children: h("Feature Details")
2408
+ }
2409
+ ),
2410
+ /* @__PURE__ */ i(
2411
+ c,
2412
+ {
2413
+ sx: { textAlign: "center", marginBottom: 4, color: "grey" },
2414
+ children: "Please provide the necessary details for the new feature, including its name, constant, and where it should be linked in the menu."
2415
+ }
2416
+ ),
2417
+ /* @__PURE__ */ i(Q, { children: /* @__PURE__ */ l(
2418
+ ee,
2419
+ {
2420
+ variant: "outlined",
2421
+ className: "m-3 flex flex-row items-center w-[80%] justify-between",
2422
+ children: [
2423
+ /* @__PURE__ */ l(
2424
+ c,
2425
+ {
2426
+ variant: "subtitle1",
2427
+ className: "whitespace-nowrap",
2428
+ children: [
2429
+ h("Is"),
2430
+ " ",
2431
+ h("dynamic"),
2432
+ " ",
2433
+ h("feature? "),
2434
+ ":"
2435
+ ]
2436
+ }
2437
+ ),
2438
+ /* @__PURE__ */ i(d, { className: "w-[60%]", children: /* @__PURE__ */ i(
2439
+ $,
2440
+ {
2441
+ name: "isDynamicFeature",
2442
+ control: a.control,
2443
+ rules: { required: "Required field" },
2444
+ render: ({ field: e }) => /* @__PURE__ */ i(
2445
+ ke,
2446
+ {
2447
+ checked: e.value,
2448
+ disabled: !!x.get("featureId"),
2449
+ onChange: (n) => {
2450
+ e.onChange(n.target.checked), Ct(n);
2451
+ }
2452
+ }
2453
+ )
2454
+ }
2455
+ ) })
2456
+ ]
2457
+ }
2458
+ ) }),
2459
+ /* @__PURE__ */ i(Q, { children: /* @__PURE__ */ l(
2460
+ ee,
2461
+ {
2462
+ variant: "outlined",
2463
+ className: " m-3 flex flex-row items-center w-[80%] justify-between",
2464
+ children: [
2465
+ /* @__PURE__ */ l(c, { variant: "subtitle1", children: [
2466
+ h("Feature"),
2467
+ " ",
2468
+ h("Name"),
2469
+ /* @__PURE__ */ i("span", { className: "text-red-500 ml-1", children: "*" }),
2470
+ " :"
2471
+ ] }),
2472
+ /* @__PURE__ */ i(d, { className: "w-[60%]", children: /* @__PURE__ */ i(
2473
+ ie,
2474
+ {
2475
+ control: a.control,
2476
+ id: "menuName",
2477
+ name: "menuName",
2478
+ errors: a.formState.errors,
2479
+ disabled: Ui,
2480
+ placeholder: "Feature Name"
2481
+ }
2482
+ ) })
2483
+ ]
2484
+ }
2485
+ ) }),
2486
+ V ? /* @__PURE__ */ i(Q, { children: /* @__PURE__ */ l(
2487
+ ee,
2488
+ {
2489
+ variant: "outlined",
2490
+ className: " m-3 flex flex-row items-center w-[80%] justify-between",
2491
+ children: [
2492
+ /* @__PURE__ */ l(c, { variant: "subtitle1", children: [
2493
+ h("Feature"),
2494
+ " ",
2495
+ h("Constant"),
2496
+ /* @__PURE__ */ i("span", { className: "text-red-500 ml-1", children: "*" }),
2497
+ " :"
2498
+ ] }),
2499
+ /* @__PURE__ */ i(d, { className: "w-[60%]", children: /* @__PURE__ */ i(
2500
+ ie,
2501
+ {
2502
+ control: a.control,
2503
+ id: "featureConstant",
2504
+ name: "featureConstant",
2505
+ errors: a.formState.errors,
2506
+ successMessage: We,
2507
+ placeholder: "Feature Constant",
2508
+ disabled: j,
2509
+ onChange: (e) => Et(e.target.value)
2510
+ }
2511
+ ) })
2512
+ ]
2513
+ }
2514
+ ) }, "static-feature") : /* @__PURE__ */ i(Q, { children: /* @__PURE__ */ l(
2515
+ ee,
2516
+ {
2517
+ variant: "outlined",
2518
+ className: " m-2 flex flex-row items-center w-[80%] justify-between",
2519
+ children: [
2520
+ /* @__PURE__ */ l(c, { variant: "subtitle1", children: [
2521
+ h("Feature"),
2522
+ " ",
2523
+ h("State"),
2524
+ /* @__PURE__ */ i("span", { className: "text-red-500 mx-1", children: "*" }),
2525
+ /* @__PURE__ */ i(
2526
+ ye,
2527
+ {
2528
+ title: /* @__PURE__ */ i(
2529
+ c,
2530
+ {
2531
+ fontSize: 12,
2532
+ maxWidth: 200,
2533
+ sx: { whiteSpace: "pre-line" },
2534
+ children: `Must follow one of these formats:
2535
+ • techo.*
2536
+ • medplat.form.*`
2537
+ }
2538
+ ),
2539
+ size: "sm"
2540
+ }
2541
+ )
2542
+ ] }),
2543
+ /* @__PURE__ */ i(d, { className: "w-[60%]", children: /* @__PURE__ */ i(
2544
+ ie,
2545
+ {
2546
+ control: a.control,
2547
+ id: "navigationState",
2548
+ name: "navigationState",
2549
+ placeholder: "Feature State",
2550
+ disabled: Ui || j,
2551
+ successMessage: We,
2552
+ dataTestId: "managefeature-textfield-feature-state",
2553
+ errors: a.formState.errors,
2554
+ onChange: (e) => Pt(
2555
+ e.target.value
2556
+ )
2557
+ }
2558
+ ) })
2559
+ ]
2560
+ }
2561
+ ) }, "dynamic-feature"),
2562
+ /* @__PURE__ */ i(Q, { children: /* @__PURE__ */ l(
2563
+ ee,
2564
+ {
2565
+ variant: "outlined",
2566
+ className: " m-3 flex flex-row items-center w-[80%] justify-between",
2567
+ children: [
2568
+ /* @__PURE__ */ l(c, { variant: "subtitle1", children: [
2569
+ h("Link"),
2570
+ " ",
2571
+ h("to"),
2572
+ " ",
2573
+ h("Menu"),
2574
+ /* @__PURE__ */ i("span", { className: "text-red-500 ml-1", children: "*" }),
2575
+ " :"
2576
+ ] }),
2577
+ /* @__PURE__ */ i(d, { className: " w-[60%]", children: /* @__PURE__ */ i(
2578
+ Ee,
2579
+ {
2580
+ control: a.control,
2581
+ name: "menuType",
2582
+ options: bi,
2583
+ errors: a.formState.errors,
2584
+ disableClearable: !1,
2585
+ onChange: (e) => {
2586
+ a.setValue("menuType", e.target.value), _i();
2587
+ }
2588
+ }
2589
+ ) })
2590
+ ]
2591
+ }
2592
+ ) }),
2593
+ /* @__PURE__ */ i(Q, { children: (fe == null ? void 0 : fe.length) > 0 && /* @__PURE__ */ l(
2594
+ ee,
2595
+ {
2596
+ variant: "outlined",
2597
+ className: " m-3 flex flex-row items-center w-[80%] justify-between",
2598
+ children: [
2599
+ /* @__PURE__ */ l(c, { variant: "subtitle1", children: [
2600
+ h("Menu"),
2601
+ " ",
2602
+ h("SubGroup"),
2603
+ " :"
2604
+ ] }),
2605
+ /* @__PURE__ */ i(d, { className: " w-[60%]", children: /* @__PURE__ */ i(
2606
+ Ee,
2607
+ {
2608
+ control: a.control,
2609
+ name: "menuGroup",
2610
+ errors: a.formState.errors,
2611
+ displayName: "name",
2612
+ optionValue: "id",
2613
+ options: fe,
2614
+ disableClearable: !1,
2615
+ onChange: vt
2616
+ }
2617
+ ) })
2618
+ ]
2619
+ }
2620
+ ) }),
2621
+ /* @__PURE__ */ i(Q, { children: /* @__PURE__ */ l(
2622
+ ee,
2623
+ {
2624
+ variant: "outlined",
2625
+ className: "m-3 flex flex-row items-center w-[80%] justify-between",
2626
+ children: [
2627
+ /* @__PURE__ */ l(
2628
+ c,
2629
+ {
2630
+ variant: "subtitle1",
2631
+ className: "whitespace-nowrap",
2632
+ children: [
2633
+ h("Enable"),
2634
+ " ",
2635
+ h("feature"),
2636
+ " ",
2637
+ h("for"),
2638
+ ":"
2639
+ ]
2640
+ }
2641
+ ),
2642
+ /* @__PURE__ */ l(d, { className: "w-[60%] flex flex-row gap-6 items-center", children: [
2643
+ /* @__PURE__ */ l(d, { className: "flex items-center gap-1", children: [
2644
+ /* @__PURE__ */ i(c, { variant: "subtitle1", children: h("Web") }),
2645
+ /* @__PURE__ */ i(
2646
+ $,
2647
+ {
2648
+ name: "isWebFeature",
2649
+ control: a.control,
2650
+ render: ({ field: e }) => /* @__PURE__ */ i(
2651
+ ke,
2652
+ {
2653
+ ...e,
2654
+ checked: e.value,
2655
+ onChange: (n) => e.onChange(n.target.checked)
2656
+ }
2657
+ )
2658
+ }
2659
+ )
2660
+ ] }),
2661
+ /* @__PURE__ */ l(d, { className: "flex items-center gap-1", children: [
2662
+ /* @__PURE__ */ i(c, { variant: "subtitle1", children: h("Mobile") }),
2663
+ /* @__PURE__ */ i(
2664
+ $,
2665
+ {
2666
+ name: "isMobileFeature",
2667
+ control: a.control,
2668
+ render: ({ field: e }) => /* @__PURE__ */ i(
2669
+ ke,
2670
+ {
2671
+ ...e,
2672
+ checked: e.value,
2673
+ onChange: (n) => {
2674
+ e.onChange(n.target.checked), xt(n);
2675
+ }
2676
+ }
2677
+ )
2678
+ }
2679
+ )
2680
+ ] })
2681
+ ] })
2682
+ ]
2683
+ }
2684
+ ) })
2685
+ ] }) }),
2686
+ ((P = O[y]) == null ? void 0 : P.key) === "mobileConfig" && k && /* @__PURE__ */ i(d, { display: "flex", justifyContent: "center", children: /* @__PURE__ */ l(d, { width: "95%", children: [
2687
+ /* @__PURE__ */ i(
2688
+ c,
2689
+ {
2690
+ variant: "h5",
2691
+ sx: { fontWeight: "bold", textAlign: "center", mb: 1 },
2692
+ children: h("Mobile Setup")
2693
+ }
2694
+ ),
2695
+ /* @__PURE__ */ i(
2696
+ c,
2697
+ {
2698
+ sx: { textAlign: "center", mb: 3, color: "grey" },
2699
+ children: "Set up how this feature should behave and appear in the mobile app, including its entity, icon and condition query."
2700
+ }
2701
+ ),
2702
+ /* @__PURE__ */ l(
2703
+ Fi,
2704
+ {
2705
+ expanded: wi.basicConfig,
2706
+ onChange: () => Ni((e) => ({
2707
+ ...e,
2708
+ basicConfig: !e.basicConfig
2709
+ })),
2710
+ sx: {
2711
+ mb: 1.5,
2712
+ borderRadius: 2,
2713
+ boxShadow: "0 2px 8px rgba(0,0,0,0.08)",
2714
+ border: "1px solid rgba(33, 150, 243, 0.2)",
2715
+ borderLeft: "4px solid #2196f3",
2716
+ "&:before": { display: "none" },
2717
+ overflow: "hidden"
2718
+ },
2719
+ children: [
2720
+ /* @__PURE__ */ i(
2721
+ Di,
2722
+ {
2723
+ expandIcon: /* @__PURE__ */ i(se, { iconName: "faChevronDown", size: "sm" }),
2724
+ sx: {
2725
+ backgroundColor: "rgba(33, 150, 243, 0.06)",
2726
+ "&:hover": {
2727
+ backgroundColor: "rgba(33, 150, 243, 0.12)"
2728
+ },
2729
+ minHeight: 52
2730
+ },
2731
+ children: /* @__PURE__ */ i(c, { fontWeight: 700, fontSize: 15, children: "Basic Config" })
2732
+ }
2733
+ ),
2734
+ /* @__PURE__ */ l(
2735
+ Vi,
2736
+ {
2737
+ sx: { display: "flex", flexDirection: "column", gap: 2 },
2738
+ children: [
2739
+ /* @__PURE__ */ l(
2740
+ d,
2741
+ {
2742
+ display: "flex",
2743
+ flexDirection: "row",
2744
+ alignItems: "center",
2745
+ children: [
2746
+ /* @__PURE__ */ l(
2747
+ d,
2748
+ {
2749
+ display: "flex",
2750
+ alignItems: "center",
2751
+ gap: 2,
2752
+ sx: { width: "50%" },
2753
+ children: [
2754
+ /* @__PURE__ */ l(
2755
+ c,
2756
+ {
2757
+ variant: "subtitle1",
2758
+ sx: { minWidth: "140px", flexShrink: 0 },
2759
+ children: [
2760
+ h("Feature Icon"),
2761
+ " ",
2762
+ /* @__PURE__ */ i("span", { style: { color: "#d32f2f" }, children: "* " }),
2763
+ /* @__PURE__ */ i(
2764
+ ye,
2765
+ {
2766
+ title: /* @__PURE__ */ i(c, { fontSize: 12, maxWidth: 200, children: "Upload Feature Icon" }),
2767
+ size: "sm"
2768
+ }
2769
+ )
2770
+ ]
2771
+ }
2772
+ ),
2773
+ /* @__PURE__ */ i(Gt, { title: "Upload Icon", children: /* @__PURE__ */ i(
2774
+ d,
2775
+ {
2776
+ sx: {
2777
+ transform: "scale(0.55)",
2778
+ transformOrigin: "left center",
2779
+ "& svg": {
2780
+ fontSize: "2.5rem"
2781
+ }
2782
+ },
2783
+ children: /* @__PURE__ */ i(
2784
+ Mt,
2785
+ {
2786
+ onUpload: (e) => a.setValue("icon", e),
2787
+ formControl: a,
2788
+ name: "icon",
2789
+ accept: "image/svg+xml, image/svg",
2790
+ errors: k ? a.formState.errors : null,
2791
+ triggerType: "icon"
2792
+ }
2793
+ )
2794
+ }
2795
+ ) })
2796
+ ]
2797
+ }
2798
+ ),
2799
+ /* @__PURE__ */ l(
2800
+ d,
2801
+ {
2802
+ display: "flex",
2803
+ alignItems: "center",
2804
+ gap: 2,
2805
+ my: 4,
2806
+ sx: { width: "50%" },
2807
+ children: [
2808
+ /* @__PURE__ */ l(
2809
+ c,
2810
+ {
2811
+ variant: "subtitle1",
2812
+ sx: { minWidth: "140px", flexShrink: 0 },
2813
+ children: [
2814
+ h("Mode"),
2815
+ " ",
2816
+ /* @__PURE__ */ i("span", { style: { color: "#d32f2f" }, children: "* " }),
2817
+ /* @__PURE__ */ i(
2818
+ ye,
2819
+ {
2820
+ title: /* @__PURE__ */ i(c, { fontSize: 12, maxWidth: 200, children: "Choose whether this feature should work online or offline" }),
2821
+ size: "sm"
2822
+ }
2823
+ )
2824
+ ]
2825
+ }
2826
+ ),
2827
+ /* @__PURE__ */ i(d, { sx: { display: "flex", flex: 1 }, children: /* @__PURE__ */ i(
2828
+ $,
2829
+ {
2830
+ name: "mobileMode",
2831
+ control: a.control,
2832
+ render: ({ field: e, fieldState: { error: n } }) => /* @__PURE__ */ l(pe, { children: [
2833
+ /* @__PURE__ */ l(
2834
+ pn,
2835
+ {
2836
+ value: e.value ?? "",
2837
+ row: !0,
2838
+ ...e,
2839
+ children: [
2840
+ /* @__PURE__ */ i(
2841
+ di,
2842
+ {
2843
+ value: "ONLINE",
2844
+ control: /* @__PURE__ */ i(
2845
+ ui,
2846
+ {
2847
+ disabled: j && Mi !== null
2848
+ }
2849
+ ),
2850
+ label: "Online"
2851
+ }
2852
+ ),
2853
+ /* @__PURE__ */ i(
2854
+ di,
2855
+ {
2856
+ value: "OFFLINE",
2857
+ control: /* @__PURE__ */ i(
2858
+ ui,
2859
+ {
2860
+ disabled: j && Mi !== null
2861
+ }
2862
+ ),
2863
+ label: "Offline"
2864
+ }
2865
+ )
2866
+ ]
2867
+ }
2868
+ ),
2869
+ (n == null ? void 0 : n.message) && /* @__PURE__ */ i(
2870
+ c,
2871
+ {
2872
+ variant: "caption",
2873
+ color: "error",
2874
+ sx: { mt: 0.5 },
2875
+ children: n.message
2876
+ }
2877
+ )
2878
+ ] })
2879
+ }
2880
+ ) })
2881
+ ]
2882
+ }
2883
+ )
2884
+ ]
2885
+ }
2886
+ ),
2887
+ /* @__PURE__ */ l(d, { display: "flex", alignItems: "center", gap: 2, children: [
2888
+ /* @__PURE__ */ l(
2889
+ c,
2890
+ {
2891
+ variant: "subtitle1",
2892
+ sx: { minWidth: "140px", flexShrink: 0 },
2893
+ children: [
2894
+ h("Entity Name"),
2895
+ " ",
2896
+ /* @__PURE__ */ i(
2897
+ ye,
2898
+ {
2899
+ title: /* @__PURE__ */ i(c, { fontSize: 12, maxWidth: 200, children: "Select Entity Name" }),
2900
+ size: "sm"
2901
+ }
2902
+ )
2903
+ ]
2904
+ }
2905
+ ),
2906
+ /* @__PURE__ */ i(
2907
+ d,
2908
+ {
2909
+ sx: {
2910
+ display: "flex",
2911
+ alignItems: "center",
2912
+ gap: 2,
2913
+ flex: 1
2914
+ },
2915
+ children: /* @__PURE__ */ i(
2916
+ Ee,
2917
+ {
2918
+ control: a.control,
2919
+ name: "entityName",
2920
+ options: hi || [],
2921
+ errors: k ? a.formState.errors : null,
2922
+ size: "small",
2923
+ disableClearable: !1,
2924
+ sx: { flex: 1 }
2925
+ }
2926
+ )
2927
+ }
2928
+ )
2929
+ ] }),
2930
+ a.getValues("entityName") && ((f = a.getValues("entityName")) == null ? void 0 : f.trim().length) > 0 && /* @__PURE__ */ l(
2931
+ d,
2932
+ {
2933
+ display: "flex",
2934
+ alignItems: "flex-start",
2935
+ gap: 2,
2936
+ my: 2,
2937
+ children: [
2938
+ /* @__PURE__ */ l(
2939
+ c,
2940
+ {
2941
+ variant: "subtitle1",
2942
+ sx: {
2943
+ minWidth: "140px",
2944
+ flexShrink: 0,
2945
+ pt: 0.5
2946
+ },
2947
+ children: [
2948
+ h("Condition Query"),
2949
+ " :",
2950
+ " ",
2951
+ /* @__PURE__ */ i(
2952
+ ye,
2953
+ {
2954
+ title: /* @__PURE__ */ i(c, { fontSize: 12, maxWidth: 200, children: "Write Condition Query in the editor" }),
2955
+ size: "sm"
2956
+ }
2957
+ )
2958
+ ]
2959
+ }
2960
+ ),
2961
+ /* @__PURE__ */ i(
2962
+ d,
2963
+ {
2964
+ flex: 1,
2965
+ sx: {
2966
+ border: "1px solid #bdbdbd",
2967
+ borderRadius: 2,
2968
+ height: "20vh",
2969
+ overflow: "hidden",
2970
+ boxShadow: "0 1px 6px rgba(0, 0, 0, 0.08)"
2971
+ },
2972
+ children: /* @__PURE__ */ i(
2973
+ $,
2974
+ {
2975
+ name: "conditions",
2976
+ control: a.control,
2977
+ render: ({ field: e, fieldState: { error: n } }) => /* @__PURE__ */ l(pe, { children: [
2978
+ /* @__PURE__ */ i(
2979
+ $t,
2980
+ {
2981
+ height: "100%",
2982
+ defaultLanguage: "sql",
2983
+ theme: it == "light" ? "light" : "vs-dark",
2984
+ options: {
2985
+ fontSize: 13,
2986
+ minimap: { enabled: !1 },
2987
+ automaticLayout: !0,
2988
+ scrollBeyondLastLine: !1,
2989
+ wordWrap: "on",
2990
+ occurrencesHighlight: !1,
2991
+ selectionHighlight: !1
2992
+ },
2993
+ value: e.value || "",
2994
+ onChange: e.onChange,
2995
+ editorProps: { $blockScrolling: !0 }
2996
+ }
2997
+ ),
2998
+ (n == null ? void 0 : n.message) && /* @__PURE__ */ i(
2999
+ c,
3000
+ {
3001
+ variant: "caption",
3002
+ color: "error",
3003
+ sx: { mt: 0.75, ml: 1 },
3004
+ children: n.message
3005
+ }
3006
+ )
3007
+ ] })
3008
+ }
3009
+ )
3010
+ }
3011
+ )
3012
+ ]
3013
+ }
3014
+ ),
3015
+ /* @__PURE__ */ l(d, { display: "flex", alignItems: "center", gap: 2, children: [
3016
+ /* @__PURE__ */ l(
3017
+ c,
3018
+ {
3019
+ variant: "subtitle1",
3020
+ sx: { minWidth: "140px", flexShrink: 0 },
3021
+ children: [
3022
+ h("Tables to sync"),
3023
+ " ",
3024
+ /* @__PURE__ */ i(
3025
+ ye,
3026
+ {
3027
+ title: /* @__PURE__ */ i(c, { fontSize: 12, maxWidth: 200, children: "Select at least one table to sync" }),
3028
+ size: "sm"
3029
+ }
3030
+ )
3031
+ ]
3032
+ }
3033
+ ),
3034
+ /* @__PURE__ */ i(
3035
+ d,
3036
+ {
3037
+ sx: {
3038
+ display: "flex",
3039
+ alignItems: "center",
3040
+ gap: 2,
3041
+ flex: 1
3042
+ },
3043
+ children: /* @__PURE__ */ i(
3044
+ Pe,
3045
+ {
3046
+ id: "mobileEntitiesSync",
3047
+ name: "mobileEntitiesSync",
3048
+ control: a.control,
3049
+ options: ce,
3050
+ onChange: (e, n) => mt(n),
3051
+ getOptionLabel: (e) => e == null ? void 0 : e.tableName,
3052
+ checkEquality: "tableName",
3053
+ errors: k ? a.formState.errors : null,
3054
+ dataTestId: "syncentities-select-table",
3055
+ value: Rn,
3056
+ fullWidth: !0
3057
+ }
3058
+ )
3059
+ }
3060
+ )
3061
+ ] })
3062
+ ]
3063
+ }
3064
+ )
3065
+ ]
3066
+ }
3067
+ ),
3068
+ /* @__PURE__ */ l(
3069
+ Fi,
3070
+ {
3071
+ expanded: wi.trainingConfig,
3072
+ onChange: () => Ni((e) => ({
3073
+ ...e,
3074
+ trainingConfig: !e.trainingConfig
3075
+ })),
3076
+ sx: {
3077
+ mb: 1.5,
3078
+ borderRadius: 2,
3079
+ boxShadow: "0 2px 8px rgba(0,0,0,0.08)",
3080
+ border: "1px solid rgba(76, 175, 80, 0.2)",
3081
+ borderLeft: "4px solid #4caf50",
3082
+ "&:before": { display: "none" },
3083
+ overflow: "hidden"
3084
+ },
3085
+ children: [
3086
+ /* @__PURE__ */ i(
3087
+ Di,
3088
+ {
3089
+ expandIcon: /* @__PURE__ */ i(se, { iconName: "faChevronDown", size: "sm" }),
3090
+ sx: {
3091
+ backgroundColor: "rgba(76, 175, 80, 0.06)",
3092
+ "&:hover": {
3093
+ backgroundColor: "rgba(76, 175, 80, 0.12)"
3094
+ },
3095
+ minHeight: 52
3096
+ },
3097
+ children: /* @__PURE__ */ i(c, { fontWeight: 700, fontSize: 15, children: "Training Config" })
3098
+ }
3099
+ ),
3100
+ /* @__PURE__ */ l(
3101
+ Vi,
3102
+ {
3103
+ sx: { display: "flex", flexDirection: "column", gap: 2 },
3104
+ children: [
3105
+ /* @__PURE__ */ l(
3106
+ d,
3107
+ {
3108
+ display: "flex",
3109
+ alignItems: "center",
3110
+ justifyContent: "space-between",
3111
+ children: [
3112
+ /* @__PURE__ */ l(
3113
+ c,
3114
+ {
3115
+ variant: "subtitle1",
3116
+ sx: { minWidth: "200px", flexShrink: 0 },
3117
+ children: [
3118
+ h("Training Required"),
3119
+ " ",
3120
+ /* @__PURE__ */ i(
3121
+ ye,
3122
+ {
3123
+ title: /* @__PURE__ */ i(c, { fontSize: 12, maxWidth: 220, children: h(
3124
+ "Enable if the user must complete training before accessing this feature"
3125
+ ) }),
3126
+ size: "sm"
3127
+ }
3128
+ )
3129
+ ]
3130
+ }
3131
+ ),
3132
+ /* @__PURE__ */ i(d, { sx: { flex: 1 }, children: /* @__PURE__ */ i(
3133
+ $,
3134
+ {
3135
+ name: "trainingRequired",
3136
+ control: a.control,
3137
+ render: ({ field: e }) => /* @__PURE__ */ i(
3138
+ ke,
3139
+ {
3140
+ ...e,
3141
+ checked: !!e.value,
3142
+ onChange: (n) => {
3143
+ e.onChange(n.target.checked), n.target.checked || (a.setValue("trainingQuery", ""), He(""));
3144
+ }
3145
+ }
3146
+ )
3147
+ }
3148
+ ) })
3149
+ ]
3150
+ }
3151
+ ),
3152
+ a.watch("trainingRequired") && /* @__PURE__ */ l(d, { display: "flex", alignItems: "center", gap: 2, children: [
3153
+ /* @__PURE__ */ l(
3154
+ c,
3155
+ {
3156
+ variant: "subtitle1",
3157
+ sx: { minWidth: "200px", flexShrink: 0 },
3158
+ children: [
3159
+ h("Training Query"),
3160
+ " ",
3161
+ /* @__PURE__ */ i(
3162
+ ye,
3163
+ {
3164
+ title: /* @__PURE__ */ i(c, { fontSize: 12, maxWidth: 220, children: h(
3165
+ "Select a query that returns a boolean — true if training is completed, false otherwise"
3166
+ ) }),
3167
+ size: "sm"
3168
+ }
3169
+ )
3170
+ ]
3171
+ }
3172
+ ),
3173
+ /* @__PURE__ */ i(d, { sx: { flex: 1 }, children: /* @__PURE__ */ i(
3174
+ $,
3175
+ {
3176
+ name: "trainingQuery",
3177
+ control: a.control,
3178
+ render: ({ field: e, fieldState: { error: n } }) => /* @__PURE__ */ i(
3179
+ Pe,
3180
+ {
3181
+ id: "trainingQuery",
3182
+ name: "trainingQuery",
3183
+ control: a.control,
3184
+ options: Ue,
3185
+ getOptionLabel: (t) => (t == null ? void 0 : t.code) || "",
3186
+ checkEquality: "code",
3187
+ inputValue: Yn,
3188
+ disableClearable: !1,
3189
+ singleSelect: !0,
3190
+ value: (Ue == null ? void 0 : Ue.find(
3191
+ (t) => t.code === e.value
3192
+ )) || null,
3193
+ onInputChange: (t, r, o) => {
3194
+ o === "input" && (He(r), De(r));
3195
+ },
3196
+ onChange: (t, r) => {
3197
+ e.onChange((r == null ? void 0 : r.code) || ""), He((r == null ? void 0 : r.code) || "");
3198
+ },
3199
+ placeholder: "Search training query code...",
3200
+ errors: n,
3201
+ fullWidth: !0,
3202
+ freeSolo: !1
3203
+ }
3204
+ )
3205
+ }
3206
+ ) })
3207
+ ] })
3208
+ ]
3209
+ }
3210
+ )
3211
+ ]
3212
+ }
3213
+ ),
3214
+ /* @__PURE__ */ l(
3215
+ Fi,
3216
+ {
3217
+ expanded: wi.notificationConfig,
3218
+ onChange: () => Ni((e) => ({
3219
+ ...e,
3220
+ notificationConfig: !e.notificationConfig
3221
+ })),
3222
+ sx: {
3223
+ mb: 1.5,
3224
+ borderRadius: 2,
3225
+ boxShadow: "0 2px 8px rgba(0,0,0,0.08)",
3226
+ border: "1px solid rgba(255, 152, 0, 0.2)",
3227
+ borderLeft: "4px solid #ff9800",
3228
+ "&:before": { display: "none" },
3229
+ overflow: "hidden"
3230
+ },
3231
+ children: [
3232
+ /* @__PURE__ */ i(
3233
+ Di,
3234
+ {
3235
+ expandIcon: /* @__PURE__ */ i(se, { iconName: "faChevronDown", size: "sm" }),
3236
+ sx: {
3237
+ backgroundColor: "rgba(255, 152, 0, 0.06)",
3238
+ "&:hover": {
3239
+ backgroundColor: "rgba(255, 152, 0, 0.12)"
3240
+ },
3241
+ minHeight: 52
3242
+ },
3243
+ children: /* @__PURE__ */ l(c, { fontWeight: 700, fontSize: 15, children: [
3244
+ h("Notification Config"),
3245
+ " "
3246
+ ] })
3247
+ }
3248
+ ),
3249
+ /* @__PURE__ */ l(
3250
+ Vi,
3251
+ {
3252
+ sx: { display: "flex", flexDirection: "column", gap: 2 },
3253
+ children: [
3254
+ /* @__PURE__ */ l(
3255
+ d,
3256
+ {
3257
+ display: "flex",
3258
+ alignItems: "center",
3259
+ justifyContent: "space-between",
3260
+ children: [
3261
+ /* @__PURE__ */ l(
3262
+ c,
3263
+ {
3264
+ variant: "subtitle1",
3265
+ sx: { minWidth: "200px", flexShrink: 0 },
3266
+ children: [
3267
+ h("Enable Notification Badge"),
3268
+ " ",
3269
+ /* @__PURE__ */ i(
3270
+ ye,
3271
+ {
3272
+ title: /* @__PURE__ */ i(c, { fontSize: 12, maxWidth: 220, children: h(
3273
+ "Show a count or nudge badge on this feature's icon in the mobile app"
3274
+ ) }),
3275
+ size: "sm"
3276
+ }
3277
+ )
3278
+ ]
3279
+ }
3280
+ ),
3281
+ /* @__PURE__ */ i(d, { sx: { flex: 1 }, children: /* @__PURE__ */ i(
3282
+ $,
3283
+ {
3284
+ name: "notificationBadgeEnabled",
3285
+ control: a.control,
3286
+ render: ({ field: e }) => /* @__PURE__ */ i(
3287
+ ke,
3288
+ {
3289
+ ...e,
3290
+ checked: !!e.value,
3291
+ onChange: (n) => {
3292
+ e.onChange(n.target.checked), n.target.checked || (a.setValue(
3293
+ "notificationBadgeType",
3294
+ ""
3295
+ ), a.setValue(
3296
+ "notificationBadgeQuery",
3297
+ ""
3298
+ ), Ye(""));
3299
+ }
3300
+ }
3301
+ )
3302
+ }
3303
+ ) })
3304
+ ]
3305
+ }
3306
+ ),
3307
+ a.watch("notificationBadgeEnabled") && /* @__PURE__ */ l(pe, { children: [
3308
+ /* @__PURE__ */ l(d, { display: "flex", alignItems: "center", gap: 2, children: [
3309
+ /* @__PURE__ */ l(
3310
+ c,
3311
+ {
3312
+ variant: "subtitle1",
3313
+ sx: { minWidth: "200px", flexShrink: 0 },
3314
+ children: [
3315
+ h("Badge Type"),
3316
+ " ",
3317
+ /* @__PURE__ */ i(
3318
+ ye,
3319
+ {
3320
+ title: /* @__PURE__ */ i(c, { fontSize: 12, maxWidth: 220, children: h(
3321
+ `Count Based: query returns a number.
3322
+
3323
+ Nudge Based: query returns true/false.`
3324
+ ) }),
3325
+ size: "sm"
3326
+ }
3327
+ )
3328
+ ]
3329
+ }
3330
+ ),
3331
+ /* @__PURE__ */ i(d, { sx: { flex: 1 }, children: /* @__PURE__ */ i(
3332
+ $,
3333
+ {
3334
+ name: "notificationBadgeType",
3335
+ control: a.control,
3336
+ render: ({ field: e }) => /* @__PURE__ */ l(pn, { row: !0, ...e, children: [
3337
+ /* @__PURE__ */ i(
3338
+ di,
3339
+ {
3340
+ value: "COUNT",
3341
+ control: /* @__PURE__ */ i(ui, {}),
3342
+ label: "Count Based"
3343
+ }
3344
+ ),
3345
+ /* @__PURE__ */ i(
3346
+ di,
3347
+ {
3348
+ value: "NUDGE",
3349
+ control: /* @__PURE__ */ i(ui, {}),
3350
+ label: "Nudge Based"
3351
+ }
3352
+ )
3353
+ ] })
3354
+ }
3355
+ ) })
3356
+ ] }),
3357
+ a.watch("notificationBadgeType") && /* @__PURE__ */ l(d, { display: "flex", alignItems: "center", gap: 2, children: [
3358
+ /* @__PURE__ */ l(
3359
+ c,
3360
+ {
3361
+ variant: "subtitle1",
3362
+ sx: { minWidth: "200px", flexShrink: 0 },
3363
+ children: [
3364
+ a.watch("notificationBadgeType") === "COUNT" ? "Count Query" : "Nudge Query",
3365
+ " ",
3366
+ /* @__PURE__ */ i(
3367
+ ye,
3368
+ {
3369
+ title: /* @__PURE__ */ i(c, { fontSize: 12, maxWidth: 220, children: a.watch(
3370
+ "notificationBadgeType"
3371
+ ) === "COUNT" ? "Select a query that returns a numeric count for the badge" : "Select a query that returns true/false to show or hide the badge" }),
3372
+ size: "sm"
3373
+ }
3374
+ )
3375
+ ]
3376
+ }
3377
+ ),
3378
+ /* @__PURE__ */ i(d, { sx: { flex: 1 }, children: /* @__PURE__ */ i(
3379
+ $,
3380
+ {
3381
+ name: "notificationBadgeQuery",
3382
+ control: a.control,
3383
+ render: ({
3384
+ field: e,
3385
+ fieldState: { error: n }
3386
+ }) => /* @__PURE__ */ i(
3387
+ Pe,
3388
+ {
3389
+ id: "notificationBadgeQuery",
3390
+ name: "notificationBadgeQuery",
3391
+ control: a.control,
3392
+ options: Ue,
3393
+ getOptionLabel: (t) => (t == null ? void 0 : t.code) || "",
3394
+ checkEquality: "code",
3395
+ inputValue: Zn,
3396
+ disableClearable: !1,
3397
+ singleSelect: !0,
3398
+ value: (Ue == null ? void 0 : Ue.find(
3399
+ (t) => t.code === e.value
3400
+ )) || null,
3401
+ onInputChange: (t, r, o) => {
3402
+ o === "input" && (Ye(r), De(r));
3403
+ },
3404
+ onChange: (t, r) => {
3405
+ e.onChange((r == null ? void 0 : r.code) || ""), Ye(
3406
+ (r == null ? void 0 : r.code) || ""
3407
+ );
3408
+ },
3409
+ placeholder: a.watch(
3410
+ "notificationBadgeType"
3411
+ ) === "COUNT" ? "Search count query code..." : "Search nudge query code...",
3412
+ errors: n,
3413
+ fullWidth: !0,
3414
+ freeSolo: !1
3415
+ }
3416
+ )
3417
+ }
3418
+ ) })
3419
+ ] })
3420
+ ] })
3421
+ ]
3422
+ }
3423
+ )
3424
+ ]
3425
+ }
3426
+ )
3427
+ ] }) }),
3428
+ ((_ = O[y]) == null ? void 0 : _.key) === "formLinking" && V && /* @__PURE__ */ i(d, { display: "flex", justifyContent: "center", children: /* @__PURE__ */ l(d, { width: "80%", children: [
3429
+ /* @__PURE__ */ i(
3430
+ c,
3431
+ {
3432
+ variant: "h5",
3433
+ sx: {
3434
+ fontWeight: "bold",
3435
+ textAlign: "center",
3436
+ marginBottom: 1,
3437
+ marginTop: 2
3438
+ },
3439
+ children: h("Form Linking")
3440
+ }
3441
+ ),
3442
+ /* @__PURE__ */ i(
3443
+ c,
3444
+ {
3445
+ sx: { textAlign: "center", mb: 4, color: "grey" },
3446
+ children: "Link this feature to an existing form, or create a new form to be associated with it."
3447
+ }
3448
+ ),
3449
+ /* @__PURE__ */ l(Q, { container: !0, mt: 3, className: "flex flex-col w-[98%]", children: [
3450
+ /* @__PURE__ */ i(
3451
+ c,
3452
+ {
3453
+ variant: "subtitle1",
3454
+ sx: {
3455
+ marginLeft: 1,
3456
+ marginBottom: "0.5rem",
3457
+ fontWeight: 600
3458
+ },
3459
+ children: "Use Existing Form"
3460
+ }
3461
+ ),
3462
+ /* @__PURE__ */ i(Q, { container: !0, sx: { alignItems: "center" }, children: /* @__PURE__ */ l(
3463
+ ee,
3464
+ {
3465
+ variant: "outlined",
3466
+ className: "m-3 flex flex-row items-center w-[80%] justify-between",
3467
+ children: [
3468
+ /* @__PURE__ */ l(c, { variant: "subtitle1", children: [
3469
+ h("Select"),
3470
+ " ",
3471
+ h("Form"),
3472
+ ":"
3473
+ ] }),
3474
+ /* @__PURE__ */ i(d, { className: "w-[60%]", children: /* @__PURE__ */ i(
3475
+ Ee,
3476
+ {
3477
+ control: a.control,
3478
+ name: "formCode",
3479
+ options: we || [],
3480
+ getOptionDisabled: (e) => e.menu_config_id && e.menu_config_id !== parseInt(x.get("featureId")),
3481
+ displayName: "form_name",
3482
+ optionValue: "form_code",
3483
+ errors: a.formState.errors,
3484
+ size: "small",
3485
+ disableClearable: !1,
3486
+ onChange: (e) => {
3487
+ e.target.value ? (a.setValue(
3488
+ "navigationState",
3489
+ `medplat.form.${e.target.value}`
3490
+ ), Me(e.target.value)) : (a.setValue("version", null), a.setValue(
3491
+ "navigationState",
3492
+ "medplat.form."
3493
+ ));
3494
+ }
3495
+ }
3496
+ ) })
3497
+ ]
3498
+ }
3499
+ ) }),
3500
+ /* @__PURE__ */ l(
3501
+ ee,
3502
+ {
3503
+ variant: "outlined",
3504
+ className: "m-3 flex flex-row items-center w-[80%] justify-between",
3505
+ children: [
3506
+ /* @__PURE__ */ l(c, { variant: "subtitle1", children: [
3507
+ h("Select"),
3508
+ " ",
3509
+ h("Version"),
3510
+ ":"
3511
+ ] }),
3512
+ /* @__PURE__ */ i(d, { className: "w-[60%]", children: /* @__PURE__ */ i(
3513
+ Ee,
3514
+ {
3515
+ control: a.control,
3516
+ name: "version",
3517
+ options: Array.isArray(xe == null ? void 0 : xe[Ae]) ? xe[Ae].map(
3518
+ (e) => e.version
3519
+ ) : [],
3520
+ errors: a.formState.errors,
3521
+ disableClearable: !1,
3522
+ size: "small"
3523
+ }
3524
+ ) })
3525
+ ]
3526
+ }
3527
+ ),
3528
+ /* @__PURE__ */ i(
3529
+ Xe,
3530
+ {
3531
+ sx: {
3532
+ width: "80%",
3533
+ margin: "1rem auto",
3534
+ position: "relative"
3535
+ },
3536
+ children: /* @__PURE__ */ i(
3537
+ c,
3538
+ {
3539
+ variant: "caption",
3540
+ sx: {
3541
+ position: "absolute",
3542
+ top: "-0.6rem",
3543
+ left: "50%",
3544
+ transform: "translateX(-50%)",
3545
+ backgroundColor: "background.paper",
3546
+ padding: "0 0.5rem"
3547
+ },
3548
+ children: "OR"
3549
+ }
3550
+ )
3551
+ }
3552
+ ),
3553
+ /* @__PURE__ */ l(d, { className: "flex justify-center", children: [
3554
+ /* @__PURE__ */ i(
3555
+ U,
3556
+ {
3557
+ variant: "outlined",
3558
+ size: "small",
3559
+ onClick: () => {
3560
+ a.setValue("formCode", null), Te(!0);
3561
+ },
3562
+ children: "Add New Form"
3563
+ }
3564
+ ),
3565
+ _e && /* @__PURE__ */ i(
3566
+ En,
3567
+ {
3568
+ mainFormCtrl: a,
3569
+ openAddFormModal: _e,
3570
+ setModal: (e) => {
3571
+ Te(e);
3572
+ },
3573
+ reloadForms: _t
3574
+ }
3575
+ )
3576
+ ] })
3577
+ ] })
3578
+ ] }) }),
3579
+ ((S = O[y]) == null ? void 0 : S.key) === "additionalPermissions" && /* @__PURE__ */ i(Q, { item: !0, xs: 12, md: 6, children: /* @__PURE__ */ l(d, { mt: 3, className: "flex flex-col w-full", children: [
3580
+ /* @__PURE__ */ i(
3581
+ c,
3582
+ {
3583
+ variant: "h5",
3584
+ sx: { fontWeight: "bold", textAlign: "center", mb: 1 },
3585
+ children: "Additional Permissions"
3586
+ }
3587
+ ),
3588
+ /* @__PURE__ */ i(
3589
+ c,
3590
+ {
3591
+ sx: { textAlign: "center", mb: 4, color: "grey" },
3592
+ children: "Define custom permissions for this feature. These will be used to control fine-grained permissions beyond default roles."
3593
+ }
3594
+ ),
3595
+ !V && (T == null ? void 0 : T.val) === !1 ? /* @__PURE__ */ l(pe, { children: [
3596
+ /* @__PURE__ */ i(Q, { children: /* @__PURE__ */ l(
3597
+ ee,
3598
+ {
3599
+ variant: "outlined",
3600
+ className: "flex flex-row items-center ml-3 ",
3601
+ children: [
3602
+ /* @__PURE__ */ i(c, { variant: "body2", children: I("Add feature JSON access rights") }),
3603
+ /* @__PURE__ */ i(
3604
+ fn,
3605
+ {
3606
+ disabled: jn,
3607
+ checked: Fe,
3608
+ onChange: Ot,
3609
+ "data-testid": "managefeature-checkbox-access-rights"
3610
+ }
3611
+ )
3612
+ ]
3613
+ }
3614
+ ) }),
3615
+ /* @__PURE__ */ i(Q, { children: Y.value && Fe && /* @__PURE__ */ i(Q, { children: /* @__PURE__ */ i(Ht, { className: "ml-2", children: (K = a.getValues("updatedFields")) == null ? void 0 : K.map((e, n) => {
3616
+ var t;
3617
+ return /* @__PURE__ */ l(
3618
+ Q,
3619
+ {
3620
+ className: " mb-2.5 flex flex-row items-center ",
3621
+ children: [
3622
+ /* @__PURE__ */ i(ee, { children: /* @__PURE__ */ i(
3623
+ $,
3624
+ {
3625
+ name: `updatedFields[${n}].value`,
3626
+ control: a.control,
3627
+ render: ({ field: r }) => /* @__PURE__ */ i(
3628
+ kn,
3629
+ {
3630
+ ...r,
3631
+ label: `${I("Right")} ${n + 1}`,
3632
+ value: r.value || "",
3633
+ sx: {
3634
+ "& .MuiInputLabel-root": {
3635
+ fontSize: "14px"
3636
+ },
3637
+ "& .MuiInputBase-input": {
3638
+ fontSize: "14px"
3639
+ }
3640
+ }
3641
+ }
3642
+ )
3643
+ }
3644
+ ) }),
3645
+ /* @__PURE__ */ i(
3646
+ fn,
3647
+ {
3648
+ disabled: e.updated,
3649
+ checked: e.checkbox,
3650
+ onChange: () => zt(e.id),
3651
+ className: " mr-2.5",
3652
+ "data-testid": `managefeature-checkbox-updated-right-${n + 1}`
3653
+ }
3654
+ ),
3655
+ n + 1 === ((t = a.getValues("updatedFields")) == null ? void 0 : t.length) && /* @__PURE__ */ i(
3656
+ U,
3657
+ {
3658
+ variant: "contained",
3659
+ color: "primary",
3660
+ onClick: Ut,
3661
+ size: "small",
3662
+ className: " mr-2.5",
3663
+ disabled: !rt.updatedFields.some(
3664
+ (r) => r.id === (e == null ? void 0 : e.id) && r.value
3665
+ ),
3666
+ "data-testid": "managefeature-button-add-updated",
3667
+ children: I("Add")
3668
+ }
3669
+ ),
3670
+ !e.updated && /* @__PURE__ */ i(
3671
+ U,
3672
+ {
3673
+ variant: "contained",
3674
+ size: "small",
3675
+ color: "secondary",
3676
+ onClick: () => Bt(e.id),
3677
+ "data-testid": `managefeature-button-delete-updated-${n + 1}`,
3678
+ children: I("Delete")
3679
+ }
3680
+ )
3681
+ ]
3682
+ },
3683
+ e.id
3684
+ );
3685
+ }) }) }) })
3686
+ ] }) : /* @__PURE__ */ l(pe, { children: [
3687
+ (he == null ? void 0 : he.length) === 0 ? /* @__PURE__ */ i(
3688
+ c,
3689
+ {
3690
+ variant: "subtitle1",
3691
+ color: "text.secondary",
3692
+ align: "center",
3693
+ sx: { py: 2 },
3694
+ children: "No permissions added yet."
3695
+ }
3696
+ ) : /* @__PURE__ */ i(
3697
+ Pn,
3698
+ {
3699
+ permissions: he,
3700
+ onEdit: (e) => Nt(e),
3701
+ onRemove: (e) => kt(e),
3702
+ handleAddChildClick: (e) => wt(e),
3703
+ isDynamicFeature: V
3704
+ }
3705
+ ),
3706
+ /* @__PURE__ */ i(
3707
+ d,
3708
+ {
3709
+ sx: {
3710
+ display: "flex",
3711
+ justifyContent: "flex-end",
3712
+ mt: 2
3713
+ },
3714
+ children: /* @__PURE__ */ i(
3715
+ U,
3716
+ {
3717
+ variant: "outlined",
3718
+ size: "small",
3719
+ startIcon: /* @__PURE__ */ i(se, { iconName: "faPlus" }),
3720
+ onClick: St,
3721
+ sx: {
3722
+ textTransform: "none",
3723
+ fontWeight: 500,
3724
+ borderRadius: 2,
3725
+ px: 2,
3726
+ py: 0.75,
3727
+ minWidth: 120
3728
+ },
3729
+ children: "Add Parent Permission"
3730
+ }
3731
+ )
3732
+ }
3733
+ ),
3734
+ /* @__PURE__ */ i(
3735
+ Wn,
3736
+ {
3737
+ open: zn,
3738
+ onClose: () => Qe(!1),
3739
+ onSave: It,
3740
+ formCtrl: a,
3741
+ editData: Un,
3742
+ parentPermissionId: Ge === "add-child" ? Ci : null,
3743
+ mode: Ge,
3744
+ permissionTypes: Qn,
3745
+ setPermissionTypes: Gn,
3746
+ existingPermissionIds: new Set(
3747
+ si(he).map(
3748
+ (e) => e.permissionId
3749
+ )
3750
+ ),
3751
+ isDynamicFeature: V
3752
+ }
3753
+ )
3754
+ ] })
3755
+ ] }) }),
3756
+ ((de = O[y]) == null ? void 0 : de.key) === "assignFeatures" && /* @__PURE__ */ l(d, { mt: 3, className: "flex flex-col w-full", children: [
3757
+ /* @__PURE__ */ i(
3758
+ c,
3759
+ {
3760
+ variant: "h5",
3761
+ sx: { fontWeight: "bold", textAlign: "center", mb: 1 },
3762
+ children: h("Assign Features")
3763
+ }
3764
+ ),
3765
+ /* @__PURE__ */ i(c, { sx: { textAlign: "center", mb: 4, color: "grey" }, children: "Assign this feature to specific users or roles. You can toggle individual permissions below after assigning." }),
3766
+ /* @__PURE__ */ l(d, { display: "flex", gap: 2, flexWrap: "wrap", mb: 3, children: [
3767
+ /* @__PURE__ */ l(d, { flex: "1 1 300px", minWidth: 300, children: [
3768
+ /* @__PURE__ */ i(c, { variant: "subtitle1", sx: { mb: 1 }, children: h("User") }),
3769
+ /* @__PURE__ */ i(
3770
+ Pe,
3771
+ {
3772
+ id: "roles",
3773
+ name: "roles",
3774
+ control: a.control,
3775
+ options: !V && (T == null ? void 0 : T.val) === !1 ? Ri.filter(
3776
+ (e) => !Ie.some(
3777
+ (n) => n.entityType === "user" && n.user_id === e.id
3778
+ )
3779
+ ) : Ri,
3780
+ value: le,
3781
+ singleSelect: !0,
3782
+ onChange: pt,
3783
+ onInputChange: At,
3784
+ getOptionLabel: bt,
3785
+ "data-testid": "accessrights-autocomplete-user",
3786
+ fullWidth: !0
3787
+ }
3788
+ )
3789
+ ] }),
3790
+ /* @__PURE__ */ l(d, { flex: "1 1 300px", minWidth: 300, children: [
3791
+ /* @__PURE__ */ i(c, { variant: "subtitle1", sx: { mb: 1 }, children: h("Role") }),
3792
+ /* @__PURE__ */ i(
3793
+ Pe,
3794
+ {
3795
+ id: "selectedRoles",
3796
+ name: "selectedRoles",
3797
+ control: a.control,
3798
+ options: !V && (T == null ? void 0 : T.val) === !1 ? Ki().filter(
3799
+ (e) => !Ie.some(
3800
+ (n) => n.entityType === "role" && n.role_id === e.id
3801
+ )
3802
+ ) : Ki(),
3803
+ onChange: (e, n) => ct(n),
3804
+ getOptionLabel: (e) => e == null ? void 0 : e.name,
3805
+ dataTestId: "accessrights-select-role",
3806
+ value: Ne,
3807
+ fullWidth: !0
3808
+ }
3809
+ )
3810
+ ] }),
3811
+ /* @__PURE__ */ i(
3812
+ d,
3813
+ {
3814
+ display: "flex",
3815
+ alignItems: "flex-end",
3816
+ flexShrink: 0,
3817
+ sx: { minWidth: 120 },
3818
+ children: /* @__PURE__ */ i(
3819
+ U,
3820
+ {
3821
+ variant: "contained",
3822
+ size: "medium",
3823
+ fullWidth: !0,
3824
+ disabled: !(Ne.length > 0 || le != null && le.id),
3825
+ "data-testid": "accessrights-add-button",
3826
+ onClick: Tt,
3827
+ sx: { minWidth: 120, marginBottom: "10px" },
3828
+ children: h("Add")
3829
+ }
3830
+ )
3831
+ }
3832
+ )
3833
+ ] }),
3834
+ !V && (T == null ? void 0 : T.val) === !1 ? /* @__PURE__ */ i(hn, { sx: { maxHeight: 360, overflowY: "auto" }, children: /* @__PURE__ */ l(gn, { size: "small", children: [
3835
+ /* @__PURE__ */ i(yn, { children: /* @__PURE__ */ l(ci, { children: [
3836
+ /* @__PURE__ */ i(X, { sx: { fontWeight: "bold" }, children: h("Type") }),
3837
+ /* @__PURE__ */ i(X, { sx: { fontWeight: "bold" }, children: h("Name") }),
3838
+ /* @__PURE__ */ i(X, { sx: { fontWeight: "bold" }, children: h("Access Right") }),
3839
+ /* @__PURE__ */ i(X, { sx: { fontWeight: "bold" }, children: h("Actions") })
3840
+ ] }) }),
3841
+ /* @__PURE__ */ i(bn, { children: Le.map((e, n) => /* @__PURE__ */ l(ci, { children: [
3842
+ /* @__PURE__ */ i(X, { children: e.designationId ? "Role" : "User" }),
3843
+ /* @__PURE__ */ i(X, { children: e.roleName || e.fullName }),
3844
+ /* @__PURE__ */ i(X, { children: /* @__PURE__ */ i(
3845
+ d,
3846
+ {
3847
+ display: "flex",
3848
+ flexDirection: "column",
3849
+ gap: 1,
3850
+ children: (() => {
3851
+ const t = Y.value ? a.getValues("updatedFields") : a.getValues("fields"), r = t == null ? void 0 : t.reduce((m, v) => (m[v.value] = v.checkbox, m), {}), o = e.featureJson ? JSON.parse(e.featureJson) : {}, u = Object.fromEntries(
3852
+ Object.entries(o).map(
3853
+ ([m, v]) => [
3854
+ m,
3855
+ v === !0 || v === "true"
3856
+ ]
3857
+ )
3858
+ ), s = {
3859
+ ...u,
3860
+ ...Object.fromEntries(
3861
+ Object.entries(
3862
+ r || {}
3863
+ ).filter(
3864
+ ([m]) => !(m in u)
3865
+ )
3866
+ )
3867
+ };
3868
+ return Object.entries(s).map(
3869
+ ([m, v]) => /* @__PURE__ */ l(
3870
+ d,
3871
+ {
3872
+ display: "flex",
3873
+ alignItems: "center",
3874
+ gap: 1,
3875
+ children: [
3876
+ /* @__PURE__ */ i(
3877
+ ke,
3878
+ {
3879
+ sx: {
3880
+ transform: "scale(0.75)",
3881
+ transformOrigin: "left center"
3882
+ },
3883
+ checked: !!v,
3884
+ onChange: () => {
3885
+ const E = [
3886
+ ...Le
3887
+ ];
3888
+ let N = {};
3889
+ try {
3890
+ N = e.featureJson ? JSON.parse(
3891
+ e.featureJson
3892
+ ) : {};
3893
+ } catch (Z) {
3894
+ console.warn(
3895
+ "Invalid JSON in featureJson:",
3896
+ Z
3897
+ );
3898
+ }
3899
+ const ge = (Y.value ? a.getValues(
3900
+ "updatedFields"
3901
+ ) : a.getValues(
3902
+ "fields"
3903
+ ) || []).reduce(
3904
+ (Z, oe) => (Z[oe.value] = oe.value in N ? N[oe.value] : oe.checkbox, Z),
3905
+ {}
3906
+ );
3907
+ ge[m] = !v, E[n] = {
3908
+ ...e,
3909
+ featureJson: JSON.stringify(
3910
+ ge
3911
+ )
3912
+ }, je(E);
3913
+ }
3914
+ }
3915
+ ),
3916
+ /* @__PURE__ */ i(c, { variant: "subtitle1", children: m })
3917
+ ]
3918
+ },
3919
+ m
3920
+ )
3921
+ );
3922
+ })()
3923
+ }
3924
+ ) }),
3925
+ /* @__PURE__ */ i(X, { children: /* @__PURE__ */ i(
3926
+ Be,
3927
+ {
3928
+ size: "small",
3929
+ color: "error",
3930
+ onClick: () => {
3931
+ const t = Le.filter(
3932
+ (r, o) => o !== n
3933
+ );
3934
+ je(t);
3935
+ },
3936
+ children: /* @__PURE__ */ i(
3937
+ se,
3938
+ {
3939
+ iconName: "faTrashAlt",
3940
+ size: "sm"
3941
+ }
3942
+ )
3943
+ }
3944
+ ) })
3945
+ ] }, n)) })
3946
+ ] }) }) : /* @__PURE__ */ i(pe, { children: Ie.length > 0 && /* @__PURE__ */ i(
3947
+ hn,
3948
+ {
3949
+ sx: { maxHeight: 360, overflowY: "auto" },
3950
+ children: /* @__PURE__ */ l(gn, { size: "small", children: [
3951
+ /* @__PURE__ */ i(yn, { children: /* @__PURE__ */ l(ci, { children: [
3952
+ /* @__PURE__ */ i(X, { sx: { fontWeight: "bold" }, children: h("Type") }),
3953
+ /* @__PURE__ */ i(X, { sx: { fontWeight: "bold" }, children: h("Name") }),
3954
+ /* @__PURE__ */ i(X, { sx: { fontWeight: "bold" }, children: h("Permissions") }),
3955
+ /* @__PURE__ */ i(X, { sx: { fontWeight: "bold" }, children: h("Actions") })
3956
+ ] }) }),
3957
+ /* @__PURE__ */ i(bn, { children: Ie.map((e, n) => /* @__PURE__ */ l(ci, { children: [
3958
+ /* @__PURE__ */ i(X, { children: e.entityType === "role" ? "Role" : "User" }),
3959
+ /* @__PURE__ */ i(X, { children: e.name }),
3960
+ /* @__PURE__ */ i(X, { children: /* @__PURE__ */ i(
3961
+ qi,
3962
+ {
3963
+ permissions: e.permissions,
3964
+ onToggle: (t) => Ft(n, t)
3965
+ }
3966
+ ) }),
3967
+ /* @__PURE__ */ i(X, { children: /* @__PURE__ */ i(
3968
+ Be,
3969
+ {
3970
+ size: "small",
3971
+ color: "error",
3972
+ onClick: () => {
3973
+ const t = Ie.filter(
3974
+ (r, o) => o !== n
3975
+ );
3976
+ ze(t);
3977
+ },
3978
+ children: /* @__PURE__ */ i(
3979
+ se,
3980
+ {
3981
+ iconName: "faTrashAlt",
3982
+ size: "sm"
3983
+ }
3984
+ )
3985
+ }
3986
+ ) })
3987
+ ] }, n)) })
3988
+ ] })
3989
+ }
3990
+ ) }),
3991
+ /* @__PURE__ */ i(
3992
+ qn,
3993
+ {
3994
+ open: Mn,
3995
+ onClose: () => Si(!1),
3996
+ permissions: he,
3997
+ entityData: $n,
3998
+ onSave: (e) => {
3999
+ ze((n) => [...n, e]), Si(!1);
4000
+ }
4001
+ }
4002
+ )
4003
+ ] }),
4004
+ ((G = O[y]) == null ? void 0 : G.key) === "submit" && ae && /* @__PURE__ */ l(
4005
+ d,
4006
+ {
4007
+ sx: {
4008
+ mt: 4,
4009
+ display: "flex",
4010
+ flexDirection: "column",
4011
+ alignItems: "center",
4012
+ justifyContent: "center",
4013
+ textAlign: "center",
4014
+ minHeight: "300px",
4015
+ px: 3,
4016
+ mx: "auto",
4017
+ maxWidth: 500,
4018
+ backgroundColor: "background.default",
4019
+ borderRadius: 3,
4020
+ boxShadow: "0 4px 12px rgba(0,0,0,0.1)",
4021
+ border: `1px solid ${ue.palette.divider}`,
4022
+ p: 6
4023
+ },
4024
+ children: [
4025
+ /* @__PURE__ */ i(d, { sx: { color: "success.main", fontSize: 40, mb: 2 }, children: /* @__PURE__ */ i(se, { iconName: "faCheckCircle" }) }),
4026
+ /* @__PURE__ */ l(
4027
+ c,
4028
+ {
4029
+ variant: "h6",
4030
+ gutterBottom: !0,
4031
+ sx: { fontWeight: "bold" },
4032
+ children: [
4033
+ "Feature was successfully",
4034
+ x.get("featureId") ? "updated" : "created",
4035
+ "!"
4036
+ ]
4037
+ }
4038
+ ),
4039
+ /* @__PURE__ */ i(Xe, { sx: { my: 2, width: "100%" } }),
4040
+ /* @__PURE__ */ l(c, { variant: "subtitle1", gutterBottom: !0, children: [
4041
+ /* @__PURE__ */ i("strong", { children: "Feature Name:" }),
4042
+ " ",
4043
+ a.getValues("menuName")
4044
+ ] }),
4045
+ V && /* @__PURE__ */ l(c, { variant: "subtitle1", gutterBottom: !0, children: [
4046
+ /* @__PURE__ */ i("strong", { children: "Feature Constant:" }),
4047
+ " ",
4048
+ a.getValues("featureConstant")
4049
+ ] }),
4050
+ /* @__PURE__ */ i(d, { mt: 5, width: "100%", display: "flex", justifyContent: "center", children: a.getValues("formCode") && a.getValues("version") ? /* @__PURE__ */ i(
4051
+ U,
4052
+ {
4053
+ variant: "contained",
4054
+ color: "primary",
4055
+ onClick: () => {
4056
+ var e;
4057
+ const n = a.getValues("formCode"), t = a.getValues("version"), r = (e = xe == null ? void 0 : xe[n]) == null ? void 0 : e.find(
4058
+ (o) => o.version === t
4059
+ );
4060
+ r != null && r.uuid ? q(
4061
+ `/ui/medplat/admin/medplatForms/form/${r.uuid}`
4062
+ ) : console.warn("Could not find matching version UUID");
4063
+ },
4064
+ children: "Configure Form"
4065
+ }
4066
+ ) : /* @__PURE__ */ i(
4067
+ U,
4068
+ {
4069
+ variant: "outlined",
4070
+ color: "primary",
4071
+ onClick: () => q("/ui/medplat/manage/menu"),
4072
+ children: "Go Back to Menu"
4073
+ }
4074
+ ) })
4075
+ ]
4076
+ }
4077
+ ),
4078
+ !ae && /* @__PURE__ */ l(
4079
+ d,
4080
+ {
4081
+ mt: "auto",
4082
+ display: "flex",
4083
+ justifyContent: "flex-end",
4084
+ gap: 2,
4085
+ sx: { paddingTop: 4 },
4086
+ children: [
4087
+ /* @__PURE__ */ i(
4088
+ U,
4089
+ {
4090
+ variant: "outlined",
4091
+ sx: { color: "text.secondary" },
4092
+ onClick: lt,
4093
+ children: "Back"
4094
+ }
4095
+ ),
4096
+ ((B = O[y]) == null ? void 0 : B.key) !== "submit" && (() => {
4097
+ var e;
4098
+ const n = (e = O[y]) == null ? void 0 : e.key, t = ["formLinking"].includes(n), r = ei.includes(n), [o, u] = a.getValues(Gi(n)), s = n === "formLinking" ? !!(o != null && o.trim()) || !!(u != null && u.trim()) : n === "additionalPermissions" ? Array.isArray(o) && o.length > 0 : !1, m = a.handleSubmit(
4099
+ (v) => {
4100
+ dn(v);
4101
+ const E = O.findIndex(
4102
+ (N) => N.key === "submit"
4103
+ );
4104
+ $i((N) => new Set(N).add(n)), D(E);
4105
+ }
4106
+ );
4107
+ return n === "assignFeatures" || n === "accessRights" ? /* @__PURE__ */ i(
4108
+ U,
4109
+ {
4110
+ variant: "contained",
4111
+ onClick: m,
4112
+ children: "Save"
4113
+ }
4114
+ ) : t ? Ji ? /* @__PURE__ */ i(U, { variant: "contained", onClick: Ii, children: "Next" }) : s ? /* @__PURE__ */ i(U, { variant: "contained", disabled: !0, children: "Next" }) : /* @__PURE__ */ i(
4115
+ U,
4116
+ {
4117
+ variant: "outlined",
4118
+ color: "secondary",
4119
+ onClick: () => {
4120
+ r || Ai((v) => [...v, n]), Ii();
4121
+ },
4122
+ children: "Skip for now"
4123
+ }
4124
+ ) : /* @__PURE__ */ i(
4125
+ U,
4126
+ {
4127
+ variant: "contained",
4128
+ onClick: Ii,
4129
+ disabled: !Ji,
4130
+ children: "Next"
4131
+ }
4132
+ );
4133
+ })()
4134
+ ]
4135
+ }
4136
+ )
4137
+ ]
4138
+ }
4139
+ )
4140
+ ] }) })
4141
+ }
4142
+ );
4143
+ }
4144
+ Pn.propTypes = {
4145
+ permissions: w.any,
4146
+ onEdit: w.any,
4147
+ onRemove: w.any,
4148
+ handleAddChildClick: w.any,
4149
+ isDynamicFeature: w.any
4150
+ };
4151
+ Wn.propTypes = {
4152
+ open: w.any,
4153
+ onClose: w.any,
4154
+ onSave: w.any,
4155
+ formCtrl: w.any,
4156
+ editData: w.any,
4157
+ parentPermissionId: w.any,
4158
+ mode: w.any,
4159
+ permissionTypes: w.any,
4160
+ setPermissionTypes: w.any,
4161
+ isDynamicFeature: w.any,
4162
+ existingPermissionIds: w.any
4163
+ };
4164
+ Wi.propTypes = {
4165
+ permission: w.any,
4166
+ index: w.any,
4167
+ depth: w.any,
4168
+ onEdit: w.any,
4169
+ onRemove: w.any,
4170
+ handleAddChildClick: w.any,
4171
+ isLastChild: w.any,
4172
+ isDynamicFeature: w.any
4173
+ };
4174
+ qi.propTypes = {
4175
+ permissions: w.any,
4176
+ onToggle: w.any,
4177
+ isChild: w.any
4178
+ };
4179
+ qn.propTypes = {
4180
+ open: w.any,
4181
+ onClose: w.any,
4182
+ onSave: w.any,
4183
+ entityData: w.any,
4184
+ permissions: w.any
4185
+ };
4186
+ export {
4187
+ Jr as default
4188
+ };
4189
+ //# sourceMappingURL=ManageDynamicFeature-CeeqiS3K-D2Se68tC.js.map