@argusoft/medplat-core 1.0.14 → 1.0.15

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 (111) hide show
  1. package/dist/AccessRights-Bvd5Bm5K.js +1259 -0
  2. package/dist/AccessRights-Bvd5Bm5K.js.map +1 -0
  3. package/dist/{AddEditQueryBuilder-7JRplV5J.js → AddEditQueryBuilder-Bcjl5mXE.js} +2 -2
  4. package/dist/{AddEditQueryBuilder-7JRplV5J.js.map → AddEditQueryBuilder-Bcjl5mXE.js.map} +1 -1
  5. package/dist/{AddFeatures-CkTu7sOI.js → AddFeatures-CE5rBxEG.js} +2 -2
  6. package/dist/{AddFeatures-CkTu7sOI.js.map → AddFeatures-CE5rBxEG.js.map} +1 -1
  7. package/dist/{AddLabelModal-DE3ploGD.js → AddLabelModal-CB8E8cYG.js} +2 -2
  8. package/dist/{AddLabelModal-DE3ploGD.js.map → AddLabelModal-CB8E8cYG.js.map} +1 -1
  9. package/dist/{AddRoleDrawer-ZK1eejxI.js → AddRoleDrawer-SvntLdRu.js} +44 -43
  10. package/dist/AddRoleDrawer-SvntLdRu.js.map +1 -0
  11. package/dist/{AppModal-BgZyfrd-.js → AppModal-BKgIwe1h.js} +2 -2
  12. package/dist/{AppModal-BgZyfrd-.js.map → AppModal-BKgIwe1h.js.map} +1 -1
  13. package/dist/{ChangePasswordModalCore-DIe4rzW-.js → ChangePasswordModalCore-CTGy8Ttf.js} +2 -2
  14. package/dist/{ChangePasswordModalCore-DIe4rzW-.js.map → ChangePasswordModalCore-CTGy8Ttf.js.map} +1 -1
  15. package/dist/{ConditionConfig-GDCXIg3C.js → ConditionConfig-DB0FqwgG.js} +2 -2
  16. package/dist/{ConditionConfig-GDCXIg3C.js.map → ConditionConfig-DB0FqwgG.js.map} +1 -1
  17. package/dist/{EntityManagement-D-x6Qzal.js → EntityManagement-DQKXnEzz.js} +2 -2
  18. package/dist/{EntityManagement-D-x6Qzal.js.map → EntityManagement-DQKXnEzz.js.map} +1 -1
  19. package/dist/EventConfigurations-DZvSJ5EZ.js +395 -0
  20. package/dist/EventConfigurations-DZvSJ5EZ.js.map +1 -0
  21. package/dist/{EventsExceptionModal-BF6E1Np7.js → EventsExceptionModal-DsvngLi8.js} +2 -2
  22. package/dist/{EventsExceptionModal-BF6E1Np7.js.map → EventsExceptionModal-DsvngLi8.js.map} +1 -1
  23. package/dist/EventsSkeleton-DCXwwPbb.js +76 -0
  24. package/dist/EventsSkeleton-DCXwwPbb.js.map +1 -0
  25. package/dist/FeatureMenu-CLX8VNZ-.js +265 -0
  26. package/dist/FeatureMenu-CLX8VNZ-.js.map +1 -0
  27. package/dist/Features-Cpf1PDx0.js +13 -0
  28. package/dist/Features-Cpf1PDx0.js.map +1 -0
  29. package/dist/FileSaver.min-CN9EpL2h.js.map +1 -1
  30. package/dist/ImmunizationConfigurationsList-K2ddBpPJ.js +345 -0
  31. package/dist/ImmunizationConfigurationsList-K2ddBpPJ.js.map +1 -0
  32. package/dist/ImmunizationSkeleton-D2tdv5k-.js.map +1 -1
  33. package/dist/{LanguagesModal-rk6IGQwY.js → LanguagesModal-CX3oS8rk.js} +2 -2
  34. package/dist/{LanguagesModal-rk6IGQwY.js.map → LanguagesModal-CX3oS8rk.js.map} +1 -1
  35. package/dist/{ManageDynamicFeature-C2I7Ho7i.js → ManageDynamicFeature-CsIett5x.js} +2 -2
  36. package/dist/{ManageDynamicFeature-C2I7Ho7i.js.map → ManageDynamicFeature-CsIett5x.js.map} +1 -1
  37. package/dist/{ManageEventConfiguration-BJxS2Su0.js → ManageEventConfiguration-0YBDaxOI.js} +60 -60
  38. package/dist/ManageEventConfiguration-0YBDaxOI.js.map +1 -0
  39. package/dist/{ManageNotification-DMN2szWy.js → ManageNotification-EQgnOO0U.js} +632 -632
  40. package/dist/ManageNotification-EQgnOO0U.js.map +1 -0
  41. package/dist/{ManageRole-CuXmWQyp.js → ManageRole-Cbs9dUhc.js} +244 -191
  42. package/dist/ManageRole-Cbs9dUhc.js.map +1 -0
  43. package/dist/ManageTranslation-D9IScGhk.js +625 -0
  44. package/dist/ManageTranslation-D9IScGhk.js.map +1 -0
  45. package/dist/{ManageUser-Dr3ptCYp.js → ManageUser-C9uMe9av.js} +744 -735
  46. package/dist/ManageUser-C9uMe9av.js.map +1 -0
  47. package/dist/{MobileTypeEventConfigModal-ChhO_A4f.js → MobileTypeEventConfigModal-Ltm529jG.js} +2 -2
  48. package/dist/{MobileTypeEventConfigModal-ChhO_A4f.js.map → MobileTypeEventConfigModal-Ltm529jG.js.map} +1 -1
  49. package/dist/NotificationList-BZwvgsf6.js +402 -0
  50. package/dist/NotificationList-BZwvgsf6.js.map +1 -0
  51. package/dist/{OtherTypeEventConfigModal-ZnCGWm9v.js → OtherTypeEventConfigModal-dXt2qDg_.js} +2 -2
  52. package/dist/OtherTypeEventConfigModal-dXt2qDg_.js.map +1 -0
  53. package/dist/{QueryBuilder-BPfavHH9.js → QueryBuilder-DXexUIe8.js} +154 -148
  54. package/dist/QueryBuilder-DXexUIe8.js.map +1 -0
  55. package/dist/{QueryManagement-DXA73N2j.js → QueryManagement-BpIRH8hI.js} +228 -214
  56. package/dist/QueryManagement-BpIRH8hI.js.map +1 -0
  57. package/dist/RoleManagement-BThAL5LO.js +422 -0
  58. package/dist/RoleManagement-BThAL5LO.js.map +1 -0
  59. package/dist/SubMenu-BGznOP2a.js +191 -0
  60. package/dist/SubMenu-BGznOP2a.js.map +1 -0
  61. package/dist/TableDetails-DztbjsIA.js +2069 -0
  62. package/dist/TableDetails-DztbjsIA.js.map +1 -0
  63. package/dist/TableList-DYwotUDO.js +1425 -0
  64. package/dist/TableList-DYwotUDO.js.map +1 -0
  65. package/dist/{TypeConfiguration-C-lk8Szs.js → TypeConfiguration-DYbBG_hZ.js} +2 -2
  66. package/dist/{TypeConfiguration-C-lk8Szs.js.map → TypeConfiguration-DYbBG_hZ.js.map} +1 -1
  67. package/dist/{UserList-S5Q76wO7.js → UserList-BH6OpZvq.js} +410 -400
  68. package/dist/UserList-BH6OpZvq.js.map +1 -0
  69. package/dist/UserListSkeleton-cglK2SaU.js.map +1 -1
  70. package/dist/WidgetList-D-fIf3N2.js +200 -0
  71. package/dist/WidgetList-D-fIf3N2.js.map +1 -0
  72. package/dist/i18next-CTOWN_jH.js.map +1 -1
  73. package/dist/index.css +1 -1
  74. package/dist/index.js +13 -13
  75. package/dist/xlsx.min-D1LFqt_b.js.map +1 -1
  76. package/package.json +1 -1
  77. package/dist/AccessRights-BMRM1u9S.js +0 -1228
  78. package/dist/AccessRights-BMRM1u9S.js.map +0 -1
  79. package/dist/AddRoleDrawer-ZK1eejxI.js.map +0 -1
  80. package/dist/EventConfigurations-jGCJ4LqP.js +0 -384
  81. package/dist/EventConfigurations-jGCJ4LqP.js.map +0 -1
  82. package/dist/EventsSkeleton-BN7_0IGs.js +0 -74
  83. package/dist/EventsSkeleton-BN7_0IGs.js.map +0 -1
  84. package/dist/FeatureMenu-Ds6lFg4w.js +0 -249
  85. package/dist/FeatureMenu-Ds6lFg4w.js.map +0 -1
  86. package/dist/Features-Cshdl06N.js +0 -12
  87. package/dist/Features-Cshdl06N.js.map +0 -1
  88. package/dist/ImmunizationConfigurationsList-CQnxWa09.js +0 -335
  89. package/dist/ImmunizationConfigurationsList-CQnxWa09.js.map +0 -1
  90. package/dist/ManageEventConfiguration-BJxS2Su0.js.map +0 -1
  91. package/dist/ManageNotification-DMN2szWy.js.map +0 -1
  92. package/dist/ManageRole-CuXmWQyp.js.map +0 -1
  93. package/dist/ManageTranslation-BTxvSYKb.js +0 -616
  94. package/dist/ManageTranslation-BTxvSYKb.js.map +0 -1
  95. package/dist/ManageUser-Dr3ptCYp.js.map +0 -1
  96. package/dist/NotificationList-BqibwMaM.js +0 -400
  97. package/dist/NotificationList-BqibwMaM.js.map +0 -1
  98. package/dist/OtherTypeEventConfigModal-ZnCGWm9v.js.map +0 -1
  99. package/dist/QueryBuilder-BPfavHH9.js.map +0 -1
  100. package/dist/QueryManagement-DXA73N2j.js.map +0 -1
  101. package/dist/RoleManagement-C0feJCuq.js +0 -410
  102. package/dist/RoleManagement-C0feJCuq.js.map +0 -1
  103. package/dist/SubMenu-DAfZC9Xi.js +0 -188
  104. package/dist/SubMenu-DAfZC9Xi.js.map +0 -1
  105. package/dist/TableDetails-DzREeJkm.js +0 -1508
  106. package/dist/TableDetails-DzREeJkm.js.map +0 -1
  107. package/dist/TableList-B9hr05Hs.js +0 -428
  108. package/dist/TableList-B9hr05Hs.js.map +0 -1
  109. package/dist/UserList-S5Q76wO7.js.map +0 -1
  110. package/dist/WidgetList-BSApErov.js +0 -188
  111. package/dist/WidgetList-BSApErov.js.map +0 -1
@@ -0,0 +1,2069 @@
1
+ import { jsxs as s, jsx as r, Fragment as Q } from "react/jsx-runtime";
2
+ import { execute as H } from "@/common/services/QueryBuilder";
3
+ import { showToast as V } from "@/common/toaster/toaster";
4
+ import { useDebounceFn as mr } from "@/hooks/useDebounceFn";
5
+ import hr from "@/views/custom-components/CustomConfirmationModal";
6
+ import pr from "@/views/custom-components/CustomTextField";
7
+ import C from "@/common/fontAwesomeIcons/FontAwesomeIcons";
8
+ import de from "@monaco-editor/react";
9
+ import { Paper as ge, Typography as u, Tooltip as B, Button as O, FormControl as M, RadioGroup as xe, FormControlLabel as W, Radio as U, Autocomplete as ce, TextField as D, IconButton as _, InputAdornment as Ce, Popover as yr, Checkbox as fr, TableContainer as gr, Table as xr, TableHead as Cr, TableRow as ee, TableCell as re, TableBody as Ye, Modal as br, Switch as vr } from "@mui/material";
10
+ import y from "@mui/material/Grid2";
11
+ import { Box as f } from "@mui/system";
12
+ import S from "prop-types";
13
+ import { useState as w, useEffect as be } from "react";
14
+ import { useForm as wr, useWatch as Nr, Controller as N } from "react-hook-form";
15
+ import { useSelector as Sr } from "react-redux";
16
+ function kr({
17
+ tableInfo: d,
18
+ table: b,
19
+ isEditMode: m,
20
+ updateEditMode: ve,
21
+ tableCompleteInfo: k,
22
+ reloadComponents: Je,
23
+ isCreateTableMode: i,
24
+ isSyncTableMode: G,
25
+ updateCreateTableMode: we,
26
+ openDeleteModal: Xe,
27
+ setOpenDeleteModal: Ne,
28
+ generateRebuildScript: Ze
29
+ }) {
30
+ var We, _e, $e, Ee, Fe, je, Qe, He, Ue;
31
+ const Se = [
32
+ "Document Master",
33
+ "Form Configurator",
34
+ "Form Media Record",
35
+ "LMS"
36
+ ], ke = (e) => (e == null ? void 0 : e.toUpperCase().replace(/ /g, "_")) || "", Pe = (e) => Se.find((n) => ke(n) === e) || "", Me = (e) => {
37
+ var n;
38
+ return e != null && e.downloadType ? Pe(e.downloadType) || e.downloadType : (n = e == null ? void 0 : e.data) != null && n.downloadType ? Pe(e.data.downloadType) || e.data.downloadType : "";
39
+ }, er = (e) => {
40
+ var a;
41
+ const n = e == null ? void 0 : e.downloadUrl;
42
+ if (typeof n == "object" && n !== null)
43
+ return n.apiEndpoint || "";
44
+ const l = (a = e == null ? void 0 : e.data) == null ? void 0 : a.downloadUrl;
45
+ return typeof l == "object" && l !== null && l.apiEndpoint || "";
46
+ }, ue = (e) => {
47
+ var a;
48
+ const n = e == null ? void 0 : e.downloadUrl;
49
+ if (typeof n == "object" && n !== null)
50
+ return n.requestParameters || [];
51
+ const l = (a = e == null ? void 0 : e.data) == null ? void 0 : a.downloadUrl;
52
+ return typeof l == "object" && l !== null ? l.requestParameters || [] : [];
53
+ }, [Ve, me] = w([]), [De, ne] = w(!1), [$, ae] = w(""), [rr, nr] = w({}), [te, I] = w(""), [v, K] = w([]), [Y, R] = w([]), [g, le] = w(0), [J, he] = w(0), [Ke, oe] = w(null), [X, ie] = w(null), [E, ar] = w({}), [L, A] = w(
54
+ i ? [] : ue(d == null ? void 0 : d.mediaConfiguration)
55
+ ), Te = !!Ke, tr = Te ? "simple-popover" : void 0, ze = ["TEXT", "INTEGER"], se = Sr((e) => e.Authenticate.user.id), T = {
56
+ selectedColumns: i ? [] : [...d.columnInfo],
57
+ modifiedOnQuery: i ? "" : d.modifiedOnQuery,
58
+ dataFetchQuery: i ? "" : d.selectQuery,
59
+ tableName: "",
60
+ createTableQuery: "",
61
+ syncByDefault: i ? null : (We = d == null ? void 0 : d.syncByDefault) == null ? void 0 : We.toString(),
62
+ primaryKey: i ? null : d.primaryKey ? d.primaryKey : null,
63
+ userData: i ? null : ((_e = d == null ? void 0 : d.userData) == null ? void 0 : _e.toString()) || null,
64
+ hasMedia: i ? null : (($e = d == null ? void 0 : d.hasMedia) == null ? void 0 : $e.toString()) || null,
65
+ downloadType: i ? "" : Me(d.mediaConfiguration),
66
+ apiEndpoint: i ? "" : er(d.mediaConfiguration),
67
+ requestParameters: i ? [] : ue(d.mediaConfiguration),
68
+ directoryPath: i ? "" : ((Fe = (Ee = d.mediaConfiguration) == null ? void 0 : Ee.directoryPath) == null ? void 0 : Fe.split("/")[1]) || ((He = (Qe = (je = d.mediaConfiguration) == null ? void 0 : je.data) == null ? void 0 : Qe.directoryPath) == null ? void 0 : He.split("/")[1]) || ""
69
+ }, t = wr({
70
+ defaultValues: {
71
+ ...T
72
+ },
73
+ mode: "onChange"
74
+ }), lr = !t.formState.isValid, F = t.watch("hasMedia"), Oe = t.watch("newColumnName"), Re = t.watch("newColumnType");
75
+ t.register("requestParameters", {
76
+ validate: (e) => F !== "true" ? !0 : !e || e.length === 0 ? "At least one request parameter is required." : e.some(
77
+ (l) => {
78
+ var a, o;
79
+ return !((a = l.key) != null && a.trim()) || !((o = l.value) != null && o.trim());
80
+ }
81
+ ) ? "Each parameter must have both a key and a value filled." : !0
82
+ });
83
+ const or = async (e) => {
84
+ var l;
85
+ const n = i ? t.getValues("createTableQuery") : await Ae(
86
+ [...d.columnInfo],
87
+ e.selectedColumns,
88
+ d.primaryKey,
89
+ (l = e.primaryKey) == null ? void 0 : l.toString()
90
+ );
91
+ n ? (nr(() => e), ae(() => n), qe(), ne(!0)) : Le(e, !1);
92
+ }, Le = async (e, n) => {
93
+ var h;
94
+ const l = {};
95
+ let a, o = e || rr;
96
+ if (n || ae(""), Object.keys(o).length > 0) {
97
+ o.selectedColumns.forEach((p) => {
98
+ l[p.name] = p.type;
99
+ }), o.columns = JSON.stringify(l), o.primaryKey = (h = o.primaryKey) == null ? void 0 : h.toString();
100
+ let c = {
101
+ downloadType: ke(o.downloadType),
102
+ downloadUrl: {
103
+ apiEndpoint: o.apiEndpoint || "",
104
+ requestParameters: L || []
105
+ },
106
+ directoryPath: "#directoryPath#/" + o.directoryPath + "/"
107
+ };
108
+ c = JSON.stringify(c);
109
+ try {
110
+ if (a = (await H({
111
+ code: "update_mobile_entity",
112
+ parameters: {
113
+ tableName: (i ? t.getValues("tableName") : b) || "",
114
+ syncByDefault: o.syncByDefault === "true",
115
+ columnInfo: o.columns || "",
116
+ primaryKey: o.primaryKey || "",
117
+ modifiedOnQuery: o.modifiedOnQuery || "",
118
+ selectQuery: o.dataFetchQuery || "",
119
+ userData: o.userData === "true",
120
+ hasMedia: o.hasMedia === "true",
121
+ mediaConfiguration: o.hasMedia === "true" ? c : null,
122
+ modifiedBy: se || "",
123
+ isUpdate: !0
124
+ }
125
+ })).data, a != null && a.result && n && $) {
126
+ const p = (await H({
127
+ code: "INSERT_MOBILE_MIGRATION",
128
+ parameters: {
129
+ migrationScript: $,
130
+ modifiedBy: se || "",
131
+ generateMigration: !0
132
+ }
133
+ })).data;
134
+ (p == null ? void 0 : p.status) === 0 && V({
135
+ message: `Migration insertion failed: ${p == null ? void 0 : p.message}`,
136
+ type: "error"
137
+ });
138
+ }
139
+ } catch (p) {
140
+ V({
141
+ message: `Submission failure ${p}`,
142
+ type: "error"
143
+ });
144
+ }
145
+ } else
146
+ try {
147
+ if (a = (await H({
148
+ code: "update_mobile_entity",
149
+ parameters: {
150
+ tableName: (i ? t.getValues("tableName") : b) || "",
151
+ syncByDefault: !1,
152
+ columnInfo: "",
153
+ primaryKey: "",
154
+ modifiedOnQuery: "",
155
+ selectQuery: "",
156
+ userData: !1,
157
+ hasMedia: !1,
158
+ mediaConfiguration: null,
159
+ modifiedBy: se || "",
160
+ isUpdate: !1
161
+ }
162
+ })).data, a != null && a.result && $) {
163
+ const c = (await H({
164
+ code: "INSERT_MOBILE_MIGRATION",
165
+ parameters: {
166
+ migrationScript: $,
167
+ modifiedBy: se || "",
168
+ generateMigration: !0
169
+ }
170
+ })).data;
171
+ (c == null ? void 0 : c.status) === 0 && V({
172
+ message: `Migration insertion failed: ${c == null ? void 0 : c.message}`,
173
+ type: "error"
174
+ });
175
+ }
176
+ } catch (c) {
177
+ V({
178
+ message: `Submission failure ${c}`,
179
+ type: "error"
180
+ });
181
+ }
182
+ a != null && a.result && (ve(!1), we(!1), Je((c) => !c), V({
183
+ message: "Table configuration saved successfully!",
184
+ type: "success"
185
+ })), ne(!1);
186
+ }, ir = () => {
187
+ ne(!1);
188
+ }, Ae = async (e, n, l, a) => {
189
+ let o = "";
190
+ if (e.length > 0) {
191
+ const h = Object.fromEntries(
192
+ e.map((x) => [x.name, x.type])
193
+ ), c = Object.fromEntries(
194
+ n.map((x) => [x.name, x.type])
195
+ ), p = Object.keys(h), j = Object.keys(c), Z = e.filter(
196
+ (x) => !j.includes(x.name)
197
+ ), P = n.filter(
198
+ (x) => !p.includes(x.name)
199
+ ), q = e.filter((x) => {
200
+ const Ie = c[x.name];
201
+ return Ie !== void 0 && Ie !== x.type;
202
+ }), z = Z.map((x) => `ALTER TABLE ${b} DROP COLUMN ${x.name};`).join(`
203
+ `), Ge = P.map(
204
+ (x) => `ALTER TABLE ${b} ADD COLUMN ${x.name} ${x.type};`
205
+ ).join(`
206
+ `);
207
+ let fe = "";
208
+ return q.length > 0 && (fe = Ze(
209
+ b,
210
+ {
211
+ columnInfo: e,
212
+ primaryKey: l
213
+ },
214
+ {
215
+ columnInfo: n,
216
+ primaryKey: a
217
+ }
218
+ )), fe ? fe.trim() : (z && (o += `${z}
219
+ `), Ge && (o += `${Ge}
220
+ `), o.trim());
221
+ } else {
222
+ const h = i ? t.getValues("tableName") : b;
223
+ return o = `CREATE TABLE ${h} (
224
+ `, o += n.map((c) => `${c.name} ${c.type}`).join(`,
225
+ `), a && (o += `,
226
+ CONSTRAINT ${h}_pkey PRIMARY KEY (${a})`), o += ");", o;
227
+ }
228
+ }, qe = async () => {
229
+ var n;
230
+ const e = (n = await H({
231
+ code: "MFA_MIGRATION_MASTER_GET_LATEST_VERSIONS"
232
+ }).catch((l) => {
233
+ V({
234
+ message: `Failed to fetch migration versions ${l}`,
235
+ type: "error"
236
+ });
237
+ })) == null ? void 0 : n.data;
238
+ ar(e == null ? void 0 : e.result[0]);
239
+ };
240
+ be(() => {
241
+ if (I(""), he(0), le(0), i && (me([]), K([]), R([]), A([]), t.reset({
242
+ ...T
243
+ }), setTimeout(() => t.trigger(), 0)), b && d && !i) {
244
+ me(k !== void 0 ? () => k.columnInfo : () => d.columnInfo);
245
+ let e = k !== void 0 ? k.columnInfo.map((a) => a.name) : d.columnInfo.map((a) => a.name), n = {};
246
+ k !== void 0 ? k.columnInfo.forEach((a) => {
247
+ n[a.name] = a.type;
248
+ }) : d.columnInfo.forEach((a) => {
249
+ n[a.name] = a.type;
250
+ });
251
+ let l = {};
252
+ d.columnInfo.forEach((a) => {
253
+ l[a.name] = a.type;
254
+ }), d.columnInfo.map((a) => {
255
+ e.includes(a.name) || (a.onlyMobileDb = !0), l[a.name] !== n[a.name] && (a.isTypeChanged = !0), a.name === d.primaryKey && (a.isPrimaryKey = !0);
256
+ }), t.reset({
257
+ ...T
258
+ }), setTimeout(() => t.trigger(), 0), A(ue(d == null ? void 0 : d.mediaConfiguration)), K(
259
+ () => d.columnInfo.sort((a, o) => a.name === d.primaryKey ? (a.isPrimaryKey = !0, -1) : o.name === d.primaryKey ? (o.isPrimaryKey = !0, 1) : a.name.localeCompare(o.name))
260
+ ), R(k !== void 0 ? () => {
261
+ const a = new Set(
262
+ d.columnInfo.map((h) => h.name)
263
+ );
264
+ return k.columnInfo.map((h) => ({
265
+ ...h,
266
+ isSynced: a.has(h.name)
267
+ })).sort((h, c) => h.name === d.primaryKey ? -1 : c.name === d.primaryKey ? 1 : h.name.localeCompare(c.name));
268
+ } : []);
269
+ }
270
+ }, [d, k, b, i]), be(() => {
271
+ const e = te.toLowerCase();
272
+ if (g === 0) {
273
+ const n = t.getValues("selectedColumns"), l = e ? n.filter(
274
+ (a) => a.name.toLowerCase().includes(e)
275
+ ) : n;
276
+ K(l);
277
+ } else {
278
+ const n = new Set(
279
+ t.getValues("selectedColumns").map((a) => a.name)
280
+ ), l = e ? Ve.filter((a) => a.name.toLowerCase().includes(e)).map((a) => ({
281
+ ...a,
282
+ isSynced: n.has(a.name)
283
+ })) : Ve.map((a) => ({
284
+ ...a,
285
+ isSynced: n.has(a.name)
286
+ }));
287
+ R(l);
288
+ }
289
+ }, [te, g]);
290
+ const Be = Nr({
291
+ control: t.control,
292
+ name: "tableName"
293
+ });
294
+ be(() => {
295
+ i && t.getValues("selectedColumns").length > 0 && Be && ye(t.getValues("selectedColumns"));
296
+ }, [Be]);
297
+ const sr = (e) => {
298
+ ae(e);
299
+ }, dr = () => {
300
+ m && ve(!m), i && we(!i), t.reset({
301
+ ...T,
302
+ newColumnName: null,
303
+ newColumnType: null
304
+ }), A(T.requestParameters || []), K(T.selectedColumns || []);
305
+ const e = new Set(
306
+ (T.selectedColumns || []).map((n) => n.name)
307
+ );
308
+ R(
309
+ (T.allColumns || []).map((n) => ({
310
+ ...n,
311
+ isSynced: e.has(n.name)
312
+ }))
313
+ );
314
+ }, cr = async () => {
315
+ var l, a, o;
316
+ Ne(() => !1);
317
+ const e = await H({
318
+ code: "DELETE_MOBILE_ENTITY",
319
+ parameters: {
320
+ tableName: b
321
+ }
322
+ }).catch((h) => {
323
+ V({
324
+ message: `Metadata deletion failure ${h}`,
325
+ type: "error"
326
+ });
327
+ });
328
+ (o = (a = (l = e == null ? void 0 : e.data) == null ? void 0 : l.result) == null ? void 0 : a[0]) != null && o.table_name && V({ message: `${b} deleted successfully!`, type: "success" });
329
+ let n = `DROP TABLE if exists ${b};`;
330
+ ae(() => n), qe(), ne(!0);
331
+ }, ur = mr(async (e) => {
332
+ const n = /^[a-zA-Z_][a-zA-Z0-9_]*$/.test(e);
333
+ if (e.trim().length === 0) {
334
+ t.setError("newColumnName", {
335
+ type: "manual",
336
+ message: "*Column name is required. "
337
+ });
338
+ return;
339
+ }
340
+ if (!n) {
341
+ t.setError("newColumnName", {
342
+ type: "manual",
343
+ message: "Must start with a letter/underscore and contain only letters, numbers, and underscores."
344
+ });
345
+ return;
346
+ }
347
+ Y.some((l) => l.name === e) || v.some((l) => l.name === e) ? t.setError("newColumnName", {
348
+ type: "manual",
349
+ message: "Column name already exists in the table."
350
+ }) : t.clearErrors("newColumnName");
351
+ }, 500), pe = v.some(
352
+ (e) => e.isPrimaryKey === !0
353
+ ), ye = async (e) => {
354
+ var a;
355
+ if (J !== 2 && i && he(2), e.length === 0) {
356
+ t.setValue("createTableQuery", "", { shouldDirty: !0 });
357
+ return;
358
+ }
359
+ const n = ((a = e.find((o) => o.isPrimaryKey)) == null ? void 0 : a.name) || "", l = await Ae([], e, "", n);
360
+ t.setValue("createTableQuery", l, { shouldDirty: !0 });
361
+ };
362
+ return /* @__PURE__ */ s(
363
+ y,
364
+ {
365
+ size: 9,
366
+ sx: {
367
+ maxHeight: "88vh",
368
+ overflowY: "auto",
369
+ overflowX: "hidden"
370
+ },
371
+ children: [
372
+ /* @__PURE__ */ r(
373
+ ge,
374
+ {
375
+ variant: "outlined",
376
+ sx: {
377
+ p: 2.5,
378
+ borderRadius: 2.5,
379
+ backgroundColor: "background.paper"
380
+ },
381
+ children: /* @__PURE__ */ s(
382
+ "form",
383
+ {
384
+ onSubmit: t.handleSubmit(or),
385
+ noValidate: !0,
386
+ className: "w-full",
387
+ children: [
388
+ /* @__PURE__ */ s(
389
+ f,
390
+ {
391
+ sx: {
392
+ display: "flex",
393
+ justifyContent: "space-between",
394
+ alignItems: "center",
395
+ mb: 2.5,
396
+ pb: 2,
397
+ borderBottom: "1px solid",
398
+ borderColor: "divider"
399
+ },
400
+ children: [
401
+ /* @__PURE__ */ s(f, { sx: { flex: 1 }, children: [
402
+ i ? /* @__PURE__ */ s(f, { sx: { maxWidth: 350 }, children: [
403
+ /* @__PURE__ */ r(
404
+ u,
405
+ {
406
+ variant: "subtitle2",
407
+ sx: { fontWeight: 600, mb: 0.5 },
408
+ children: "New Table"
409
+ }
410
+ ),
411
+ /* @__PURE__ */ r(
412
+ pr,
413
+ {
414
+ control: t.control,
415
+ id: "tableName",
416
+ name: "tableName",
417
+ errors: t.formState.errors,
418
+ label: "Table Name",
419
+ size: "small",
420
+ rules: {
421
+ required: {
422
+ value: !0,
423
+ message: "Please Enter the name"
424
+ },
425
+ pattern: {
426
+ value: /^[a-z0-9_]+$/,
427
+ message: "Only lowercase letters, numbers, and underscores are allowed"
428
+ },
429
+ validate: {}
430
+ }
431
+ }
432
+ )
433
+ ] }) : /* @__PURE__ */ s(Q, { children: [
434
+ /* @__PURE__ */ r(
435
+ u,
436
+ {
437
+ variant: "h6",
438
+ sx: { fontWeight: 700, color: "text.primary" },
439
+ children: b || "No Table Selected"
440
+ }
441
+ ),
442
+ /* @__PURE__ */ r(u, { variant: "caption", color: "text.secondary", children: b ? "View and manage table configuration" : "Select a table from the list" })
443
+ ] }),
444
+ /* @__PURE__ */ r(
445
+ hr,
446
+ {
447
+ description: "Do you want to drop this table?",
448
+ title: "CONFIRMATION",
449
+ open: Xe,
450
+ handleClick: cr,
451
+ handleClose: () => Ne((e) => !e)
452
+ }
453
+ )
454
+ ] }),
455
+ /* @__PURE__ */ s(f, { sx: { display: "flex", gap: 1 }, children: [
456
+ (m || i) && /* @__PURE__ */ r(
457
+ B,
458
+ {
459
+ title: pe ? "" : "A primary key is required to proceed.",
460
+ arrow: !0,
461
+ placement: "bottom",
462
+ children: /* @__PURE__ */ r("span", { children: /* @__PURE__ */ r(
463
+ O,
464
+ {
465
+ type: "submit",
466
+ variant: "contained",
467
+ size: "small",
468
+ sx: {
469
+ borderRadius: 2,
470
+ fontWeight: 600,
471
+ textTransform: "none",
472
+ boxShadow: "none",
473
+ px: 2.5
474
+ },
475
+ disabled: lr || !pe,
476
+ startIcon: /* @__PURE__ */ r(C, { iconName: "faCheck" }),
477
+ children: "Submit"
478
+ }
479
+ ) })
480
+ }
481
+ ),
482
+ (m || i) && /* @__PURE__ */ r(
483
+ O,
484
+ {
485
+ type: "button",
486
+ variant: "outlined",
487
+ onClick: () => dr(),
488
+ size: "small",
489
+ sx: {
490
+ borderRadius: 2,
491
+ fontWeight: 600,
492
+ textTransform: "none",
493
+ borderColor: "divider",
494
+ color: "text.secondary",
495
+ px: 2.5,
496
+ "&:hover": {
497
+ backgroundColor: "action.hover",
498
+ borderColor: "text.disabled"
499
+ }
500
+ },
501
+ children: "Cancel"
502
+ }
503
+ )
504
+ ] })
505
+ ]
506
+ }
507
+ ),
508
+ /* @__PURE__ */ s(y, { container: !0, spacing: 2, children: [
509
+ /* @__PURE__ */ s(y, { size: 7, children: [
510
+ /* @__PURE__ */ r(
511
+ f,
512
+ {
513
+ sx: {
514
+ display: "inline-flex",
515
+ gap: 0.75,
516
+ p: 0.75,
517
+ backgroundColor: "action.hover",
518
+ borderRadius: 2.5,
519
+ border: "1px solid",
520
+ borderColor: "divider",
521
+ mb: 2
522
+ },
523
+ children: [
524
+ { value: 0, label: "Modified On Query", icon: "faClock" },
525
+ { value: 1, label: "Data Fetch Query", icon: "faDatabase" },
526
+ ...i ? [
527
+ {
528
+ value: 2,
529
+ label: "Create Table Query",
530
+ icon: "faCode"
531
+ }
532
+ ] : []
533
+ ].map((e) => {
534
+ const n = J === e.value;
535
+ return /* @__PURE__ */ r(
536
+ O,
537
+ {
538
+ onClick: () => he(e.value),
539
+ size: "small",
540
+ disableElevation: !0,
541
+ sx: {
542
+ px: 2,
543
+ py: 0.6,
544
+ borderRadius: 2,
545
+ textTransform: "none",
546
+ fontSize: "0.8rem",
547
+ fontWeight: n ? 700 : 500,
548
+ color: n ? "primary.dark" : "text.secondary",
549
+ backgroundColor: n ? "background.paper" : "transparent",
550
+ boxShadow: n ? "0px 2px 6px rgba(0,0,0,0.06)" : "none",
551
+ border: "1px solid",
552
+ borderColor: n ? "divider" : "transparent",
553
+ transition: "all 0.2s ease",
554
+ "&:hover": {
555
+ backgroundColor: n ? "background.paper" : "action.hover"
556
+ }
557
+ },
558
+ startIcon: /* @__PURE__ */ r(C, { iconName: e.icon }),
559
+ children: e.label
560
+ },
561
+ e.value
562
+ );
563
+ })
564
+ }
565
+ ),
566
+ J === 0 && /* @__PURE__ */ s(y, { children: [
567
+ /* @__PURE__ */ r(u, { variant: "subtitle1", children: "Modified On Query:" }),
568
+ /* @__PURE__ */ r(
569
+ N,
570
+ {
571
+ name: "modifiedOnQuery",
572
+ control: t.control,
573
+ render: ({ field: e, fieldState: { error: n } }) => /* @__PURE__ */ s(Q, { children: [
574
+ /* @__PURE__ */ r(
575
+ de,
576
+ {
577
+ height: "35vh",
578
+ defaultLanguage: "sql",
579
+ theme: "vs-dark",
580
+ options: {
581
+ fontSize: 12,
582
+ minimap: { enabled: !1 },
583
+ automaticLayout: !0,
584
+ scrollBeyondLastLine: !1,
585
+ wordWrap: "on",
586
+ occurrencesHighlight: !1,
587
+ selectionHighlight: !1,
588
+ readOnly: !m && !i
589
+ },
590
+ value: e.value || "",
591
+ defaultValue: e.value || "",
592
+ onChange: e.onChange,
593
+ editorProps: { $blockScrolling: !0 }
594
+ }
595
+ ),
596
+ (n == null ? void 0 : n.message) && /* @__PURE__ */ r(
597
+ u,
598
+ {
599
+ variant: "subtitle1",
600
+ color: "error",
601
+ fontSize: "13px",
602
+ className: "mt-1 ml-[13px]",
603
+ children: n.message
604
+ }
605
+ )
606
+ ] })
607
+ }
608
+ )
609
+ ] }),
610
+ J === 1 && /* @__PURE__ */ s(y, { children: [
611
+ /* @__PURE__ */ r(u, { variant: "subtitle1", children: "Data Fetch Query:" }),
612
+ /* @__PURE__ */ r(
613
+ N,
614
+ {
615
+ name: "dataFetchQuery",
616
+ control: t.control,
617
+ render: ({ field: e, fieldState: { error: n } }) => /* @__PURE__ */ s(Q, { children: [
618
+ /* @__PURE__ */ r(
619
+ de,
620
+ {
621
+ height: "35vh",
622
+ defaultLanguage: "sql",
623
+ theme: "vs-dark",
624
+ options: {
625
+ fontSize: 12,
626
+ minimap: { enabled: !1 },
627
+ automaticLayout: !0,
628
+ scrollBeyondLastLine: !1,
629
+ wordWrap: "on",
630
+ occurrencesHighlight: !1,
631
+ selectionHighlight: !1,
632
+ readOnly: !m && !i
633
+ },
634
+ value: e.value || "",
635
+ defaultValue: e.value || "",
636
+ onChange: e.onChange,
637
+ editorProps: { $blockScrolling: !0 }
638
+ }
639
+ ),
640
+ (n == null ? void 0 : n.message) && /* @__PURE__ */ r(
641
+ u,
642
+ {
643
+ variant: "subtitle1",
644
+ color: "error",
645
+ fontSize: "13px",
646
+ className: "mt-1 ml-[13px]",
647
+ children: n.message
648
+ }
649
+ )
650
+ ] })
651
+ }
652
+ )
653
+ ] }),
654
+ J === 2 && /* @__PURE__ */ s(y, { children: [
655
+ /* @__PURE__ */ r(u, { variant: "subtitle1", children: "Create Table Query:" }),
656
+ /* @__PURE__ */ r(
657
+ N,
658
+ {
659
+ name: "createTableQuery",
660
+ control: t.control,
661
+ render: ({ field: e, fieldState: { error: n } }) => /* @__PURE__ */ s(Q, { children: [
662
+ /* @__PURE__ */ r(
663
+ de,
664
+ {
665
+ height: "35vh",
666
+ defaultLanguage: "sql",
667
+ theme: "vs-dark",
668
+ options: {
669
+ fontSize: 12,
670
+ minimap: { enabled: !1 },
671
+ automaticLayout: !0,
672
+ scrollBeyondLastLine: !1,
673
+ wordWrap: "on",
674
+ occurrencesHighlight: !1,
675
+ selectionHighlight: !1,
676
+ readOnly: !0
677
+ },
678
+ value: e.value || "",
679
+ defaultValue: e.value || "",
680
+ onChange: e.onChange,
681
+ editorProps: { $blockScrolling: !0 }
682
+ }
683
+ ),
684
+ (n == null ? void 0 : n.message) && /* @__PURE__ */ r(
685
+ u,
686
+ {
687
+ variant: "subtitle1",
688
+ color: "error",
689
+ fontSize: "13px",
690
+ className: "mt-1 ml-[13px]",
691
+ children: n.message
692
+ }
693
+ )
694
+ ] })
695
+ }
696
+ )
697
+ ] }),
698
+ /* @__PURE__ */ s(
699
+ ge,
700
+ {
701
+ variant: "outlined",
702
+ sx: {
703
+ p: 2,
704
+ mt: 2,
705
+ borderRadius: 2,
706
+ backgroundColor: "action.hover"
707
+ },
708
+ children: [
709
+ /* @__PURE__ */ r(
710
+ u,
711
+ {
712
+ variant: "subtitle2",
713
+ sx: { fontWeight: 700, mb: 1.5, color: "text.primary" },
714
+ children: "Table Settings"
715
+ }
716
+ ),
717
+ /* @__PURE__ */ s(y, { container: !0, spacing: 2, children: [
718
+ /* @__PURE__ */ s(y, { size: 6, xs: 12, children: [
719
+ /* @__PURE__ */ s(
720
+ u,
721
+ {
722
+ variant: "body2",
723
+ sx: { fontWeight: 600, mb: 0.5 },
724
+ children: [
725
+ "Data Scope ",
726
+ /* @__PURE__ */ r("span", { style: { color: "#ef4444" }, children: "*" })
727
+ ]
728
+ }
729
+ ),
730
+ /* @__PURE__ */ r(M, { children: /* @__PURE__ */ r(
731
+ N,
732
+ {
733
+ name: "userData",
734
+ control: t.control,
735
+ rules: { required: "Required field." },
736
+ disabled: !m && !i,
737
+ defaultValue: d.userData !== void 0 && d.userData !== null ? String(d.userData) : "",
738
+ render: ({ field: e }) => /* @__PURE__ */ s(xe, { row: !0, ...e, value: e.value, children: [
739
+ /* @__PURE__ */ r(
740
+ W,
741
+ {
742
+ value: "true",
743
+ control: /* @__PURE__ */ r(
744
+ U,
745
+ {
746
+ disabled: !m && !i,
747
+ size: "small"
748
+ }
749
+ ),
750
+ label: /* @__PURE__ */ r(u, { variant: "body2", children: "User" })
751
+ }
752
+ ),
753
+ /* @__PURE__ */ r(
754
+ W,
755
+ {
756
+ value: "false",
757
+ control: /* @__PURE__ */ r(
758
+ U,
759
+ {
760
+ disabled: !m && !i,
761
+ size: "small"
762
+ }
763
+ ),
764
+ label: /* @__PURE__ */ r(u, { variant: "body2", children: "System" })
765
+ }
766
+ )
767
+ ] })
768
+ }
769
+ ) })
770
+ ] }),
771
+ /* @__PURE__ */ s(y, { size: 6, xs: 12, children: [
772
+ /* @__PURE__ */ s(
773
+ u,
774
+ {
775
+ variant: "body2",
776
+ sx: { fontWeight: 600, mb: 0.5 },
777
+ children: [
778
+ "Sync by Default",
779
+ " ",
780
+ /* @__PURE__ */ r("span", { style: { color: "#ef4444" }, children: "*" })
781
+ ]
782
+ }
783
+ ),
784
+ /* @__PURE__ */ r(M, { children: /* @__PURE__ */ r(
785
+ N,
786
+ {
787
+ name: "syncByDefault",
788
+ id: "syncByDefault",
789
+ control: t.control,
790
+ rules: { required: "Required field." },
791
+ disabled: !m && !i,
792
+ defaultValue: d.syncByDefault !== void 0 && d.syncByDefault !== null ? String(d.syncByDefault) : "",
793
+ render: ({ field: e }) => /* @__PURE__ */ s(xe, { row: !0, ...e, value: e.value, children: [
794
+ /* @__PURE__ */ r(
795
+ W,
796
+ {
797
+ value: "true",
798
+ control: /* @__PURE__ */ r(
799
+ U,
800
+ {
801
+ disabled: !m && !i,
802
+ size: "small"
803
+ }
804
+ ),
805
+ label: /* @__PURE__ */ r(u, { variant: "body2", children: "Yes" })
806
+ }
807
+ ),
808
+ /* @__PURE__ */ r(
809
+ W,
810
+ {
811
+ value: "false",
812
+ control: /* @__PURE__ */ r(
813
+ U,
814
+ {
815
+ disabled: !m && !i,
816
+ size: "small"
817
+ }
818
+ ),
819
+ label: /* @__PURE__ */ r(u, { variant: "body2", children: "No" })
820
+ }
821
+ )
822
+ ] })
823
+ }
824
+ ) })
825
+ ] }),
826
+ /* @__PURE__ */ s(y, { size: 6, xs: 12, children: [
827
+ /* @__PURE__ */ s(
828
+ u,
829
+ {
830
+ variant: "body2",
831
+ sx: { fontWeight: 600, mb: 0.5 },
832
+ children: [
833
+ "Has Media ",
834
+ /* @__PURE__ */ r("span", { style: { color: "#ef4444" }, children: "*" })
835
+ ]
836
+ }
837
+ ),
838
+ /* @__PURE__ */ r(M, { children: /* @__PURE__ */ r(
839
+ N,
840
+ {
841
+ name: "hasMedia",
842
+ id: "hasMedia",
843
+ control: t.control,
844
+ rules: { required: "Required field." },
845
+ disabled: !m && !i,
846
+ defaultValue: d.hasMedia !== void 0 && d.hasMedia !== null ? String(d.hasMedia) : "",
847
+ render: ({ field: e }) => /* @__PURE__ */ s(xe, { row: !0, ...e, value: e.value, children: [
848
+ /* @__PURE__ */ r(
849
+ W,
850
+ {
851
+ value: "true",
852
+ control: /* @__PURE__ */ r(
853
+ U,
854
+ {
855
+ disabled: !m && !i,
856
+ size: "small"
857
+ }
858
+ ),
859
+ label: /* @__PURE__ */ r(u, { variant: "body2", children: "Yes" })
860
+ }
861
+ ),
862
+ /* @__PURE__ */ r(
863
+ W,
864
+ {
865
+ value: "false",
866
+ control: /* @__PURE__ */ r(
867
+ U,
868
+ {
869
+ disabled: !m && !i,
870
+ size: "small"
871
+ }
872
+ ),
873
+ label: /* @__PURE__ */ r(u, { variant: "body2", children: "No" })
874
+ }
875
+ )
876
+ ] })
877
+ }
878
+ ) })
879
+ ] })
880
+ ] })
881
+ ]
882
+ }
883
+ ),
884
+ F === "true" && /* @__PURE__ */ s(Q, { children: [
885
+ /* @__PURE__ */ r(
886
+ u,
887
+ {
888
+ variant: "h6",
889
+ className: "mt-2",
890
+ sx: { fontWeight: 600, color: "#566A79" },
891
+ children: "Media Configuration:"
892
+ }
893
+ ),
894
+ /* @__PURE__ */ s(y, { container: !0, spacing: 2, className: "mt-2", children: [
895
+ /* @__PURE__ */ s(y, { size: 6, xs: 12, children: [
896
+ /* @__PURE__ */ s(
897
+ u,
898
+ {
899
+ variant: "subtitle2",
900
+ sx: { mb: 0.5, fontWeight: 600 },
901
+ children: [
902
+ "Download Type",
903
+ /* @__PURE__ */ r("span", { style: { color: "red" }, children: "*" }),
904
+ ":"
905
+ ]
906
+ }
907
+ ),
908
+ /* @__PURE__ */ r(
909
+ N,
910
+ {
911
+ name: "downloadType",
912
+ control: t.control,
913
+ rules: {
914
+ validate: (e) => F !== "true" || !!e || "Download Type is required."
915
+ },
916
+ render: ({
917
+ field: { onChange: e, value: n },
918
+ fieldState: { error: l }
919
+ }) => /* @__PURE__ */ r(
920
+ ce,
921
+ {
922
+ options: Se,
923
+ value: n || null,
924
+ disabled: !m && !i,
925
+ onChange: (a, o) => e(o),
926
+ renderInput: (a) => /* @__PURE__ */ r(
927
+ D,
928
+ {
929
+ ...a,
930
+ size: "small",
931
+ placeholder: "Select download type",
932
+ error: !!l,
933
+ helperText: l == null ? void 0 : l.message
934
+ }
935
+ )
936
+ }
937
+ )
938
+ }
939
+ )
940
+ ] }),
941
+ /* @__PURE__ */ r(y, { size: 12, children: /* @__PURE__ */ s(
942
+ f,
943
+ {
944
+ sx: {
945
+ border: "1px solid #ddd",
946
+ borderRadius: "8px",
947
+ p: 2,
948
+ backgroundColor: "#fafafa"
949
+ },
950
+ children: [
951
+ /* @__PURE__ */ r(
952
+ u,
953
+ {
954
+ variant: "subtitle1",
955
+ sx: { fontWeight: 600, mb: 1.5, color: "#374151" },
956
+ children: "Download URL"
957
+ }
958
+ ),
959
+ /* @__PURE__ */ s(
960
+ u,
961
+ {
962
+ variant: "subtitle2",
963
+ sx: { mb: 0.5, fontWeight: 600 },
964
+ children: [
965
+ "API Endpoint",
966
+ /* @__PURE__ */ r("span", { style: { color: "red" }, children: "*" }),
967
+ ":"
968
+ ]
969
+ }
970
+ ),
971
+ /* @__PURE__ */ r(
972
+ N,
973
+ {
974
+ name: "apiEndpoint",
975
+ control: t.control,
976
+ rules: {
977
+ validate: (e) => F !== "true" || !!(e != null && e.trim()) || "API Endpoint is required."
978
+ },
979
+ render: ({ field: e, fieldState: { error: n } }) => /* @__PURE__ */ r(
980
+ D,
981
+ {
982
+ ...e,
983
+ value: e.value || "",
984
+ size: "small",
985
+ variant: "outlined",
986
+ fullWidth: !0,
987
+ placeholder: "https://api.example.com/endpoint",
988
+ error: !!n,
989
+ helperText: n == null ? void 0 : n.message,
990
+ slotProps: {
991
+ input: {
992
+ readOnly: !m && !i
993
+ }
994
+ },
995
+ sx: { mb: 2 }
996
+ }
997
+ )
998
+ }
999
+ ),
1000
+ /* @__PURE__ */ s(
1001
+ f,
1002
+ {
1003
+ sx: { display: "flex", alignItems: "center", mb: 1 },
1004
+ children: [
1005
+ /* @__PURE__ */ s(
1006
+ u,
1007
+ {
1008
+ variant: "subtitle2",
1009
+ sx: { fontWeight: 600, color: "#374151", flex: 1 },
1010
+ children: [
1011
+ "Request Parameters",
1012
+ /* @__PURE__ */ r("span", { style: { color: "red" }, children: "*" }),
1013
+ ":"
1014
+ ]
1015
+ }
1016
+ ),
1017
+ (m || i) && /* @__PURE__ */ r(B, { title: "Add parameter", arrow: !0, children: /* @__PURE__ */ r(
1018
+ _,
1019
+ {
1020
+ size: "small",
1021
+ onClick: () => {
1022
+ const e = [
1023
+ ...L,
1024
+ { key: "", value: "" }
1025
+ ];
1026
+ A(e), t.setValue(
1027
+ "requestParameters",
1028
+ e,
1029
+ {
1030
+ shouldDirty: !0,
1031
+ shouldValidate: !0
1032
+ }
1033
+ );
1034
+ },
1035
+ sx: {
1036
+ backgroundColor: "#566A79",
1037
+ color: "white",
1038
+ "&:hover": { backgroundColor: "#3d4f5c" },
1039
+ borderRadius: "6px",
1040
+ width: "28px",
1041
+ height: "28px"
1042
+ },
1043
+ children: /* @__PURE__ */ r(
1044
+ C,
1045
+ {
1046
+ iconName: "faPlus",
1047
+ className: "text-[0.75rem]"
1048
+ }
1049
+ )
1050
+ }
1051
+ ) })
1052
+ ]
1053
+ }
1054
+ ),
1055
+ L.length === 0 && /* @__PURE__ */ r(
1056
+ u,
1057
+ {
1058
+ variant: "caption",
1059
+ sx: { color: "#9ca3af", fontStyle: "italic" },
1060
+ children: "No request parameters added."
1061
+ }
1062
+ ),
1063
+ L.map((e, n) => /* @__PURE__ */ s(
1064
+ f,
1065
+ {
1066
+ sx: {
1067
+ display: "flex",
1068
+ gap: 1,
1069
+ alignItems: "flex-start",
1070
+ mb: 1,
1071
+ p: 1,
1072
+ borderRadius: "6px",
1073
+ backgroundColor: "#f0f4f8",
1074
+ border: "1px solid #e2e8f0"
1075
+ },
1076
+ children: [
1077
+ /* @__PURE__ */ r(
1078
+ D,
1079
+ {
1080
+ size: "small",
1081
+ label: "Key",
1082
+ value: e.key,
1083
+ placeholder: "parameterKey",
1084
+ disabled: !m && !i,
1085
+ onChange: (l) => {
1086
+ const a = L.map(
1087
+ (o, h) => h === n ? { ...o, key: l.target.value } : o
1088
+ );
1089
+ A(a), t.setValue(
1090
+ "requestParameters",
1091
+ a,
1092
+ {
1093
+ shouldDirty: !0,
1094
+ shouldValidate: !0
1095
+ }
1096
+ );
1097
+ },
1098
+ sx: { flex: 1 }
1099
+ }
1100
+ ),
1101
+ /* @__PURE__ */ r(
1102
+ ce,
1103
+ {
1104
+ size: "small",
1105
+ options: v.map(
1106
+ (l) => l.name
1107
+ ),
1108
+ value: e.value || null,
1109
+ disabled: !m && !i,
1110
+ noOptionsText: v.length === 0 ? "No synced columns yet" : "No match",
1111
+ onChange: (l, a) => {
1112
+ const o = L.map(
1113
+ (h, c) => c === n ? { ...h, value: a || "" } : h
1114
+ );
1115
+ A(o), t.setValue(
1116
+ "requestParameters",
1117
+ o,
1118
+ {
1119
+ shouldDirty: !0,
1120
+ shouldValidate: !0
1121
+ }
1122
+ );
1123
+ },
1124
+ renderInput: (l) => /* @__PURE__ */ r(
1125
+ D,
1126
+ {
1127
+ ...l,
1128
+ label: "Value (Column)",
1129
+ placeholder: "Select column"
1130
+ }
1131
+ ),
1132
+ sx: { flex: 1 }
1133
+ }
1134
+ ),
1135
+ (m || i) && /* @__PURE__ */ r(B, { title: "Remove parameter", arrow: !0, children: /* @__PURE__ */ r(
1136
+ _,
1137
+ {
1138
+ size: "small",
1139
+ onClick: () => {
1140
+ const l = L.filter(
1141
+ (a, o) => o !== n
1142
+ );
1143
+ A(l), t.setValue(
1144
+ "requestParameters",
1145
+ l,
1146
+ {
1147
+ shouldDirty: !0,
1148
+ shouldValidate: !0
1149
+ }
1150
+ );
1151
+ },
1152
+ sx: { color: "#ef4444", alignSelf: "center" },
1153
+ children: /* @__PURE__ */ r(
1154
+ C,
1155
+ {
1156
+ iconName: "faTrashCan",
1157
+ className: "text-[0.85rem]"
1158
+ }
1159
+ )
1160
+ }
1161
+ ) })
1162
+ ]
1163
+ },
1164
+ n
1165
+ )),
1166
+ t.formState.errors.requestParameters && /* @__PURE__ */ r(
1167
+ u,
1168
+ {
1169
+ variant: "caption",
1170
+ sx: { color: "#ef4444", mt: 0.5, display: "block" },
1171
+ children: t.formState.errors.requestParameters.message
1172
+ }
1173
+ )
1174
+ ]
1175
+ }
1176
+ ) }),
1177
+ /* @__PURE__ */ s(y, { size: 6, xs: 12, children: [
1178
+ /* @__PURE__ */ s(
1179
+ u,
1180
+ {
1181
+ variant: "subtitle2",
1182
+ sx: { mb: 0.5, fontWeight: 600 },
1183
+ children: [
1184
+ "Directory Path",
1185
+ /* @__PURE__ */ r("span", { style: { color: "red" }, children: "*" }),
1186
+ ":"
1187
+ ]
1188
+ }
1189
+ ),
1190
+ /* @__PURE__ */ r(
1191
+ N,
1192
+ {
1193
+ name: "directoryPath",
1194
+ control: t.control,
1195
+ defaultValue: "",
1196
+ rules: {
1197
+ validate: (e) => F !== "true" || !!(e != null && e.trim()) && e.trim().length > 0 || "Directory Path is required."
1198
+ },
1199
+ render: ({ field: e, fieldState: { error: n } }) => /* @__PURE__ */ r(
1200
+ D,
1201
+ {
1202
+ ...e,
1203
+ size: "small",
1204
+ variant: "outlined",
1205
+ fullWidth: !0,
1206
+ error: !!n,
1207
+ helperText: n == null ? void 0 : n.message,
1208
+ slotProps: {
1209
+ input: {
1210
+ readOnly: !m && !i,
1211
+ startAdornment: /* @__PURE__ */ r(Ce, { position: "start", children: "#directoryPath#/" }),
1212
+ endAdornment: /* @__PURE__ */ r(Ce, { position: "end", children: "/" })
1213
+ }
1214
+ }
1215
+ }
1216
+ )
1217
+ }
1218
+ )
1219
+ ] })
1220
+ ] })
1221
+ ] })
1222
+ ] }),
1223
+ /* @__PURE__ */ r(y, { size: 5, children: /* @__PURE__ */ s(
1224
+ ge,
1225
+ {
1226
+ variant: "outlined",
1227
+ sx: { px: 2, borderRadius: 2.5, height: "100%", mb: 1 },
1228
+ children: [
1229
+ /* @__PURE__ */ s(
1230
+ f,
1231
+ {
1232
+ sx: {
1233
+ display: "flex",
1234
+ justifyContent: "space-between",
1235
+ alignItems: "center",
1236
+ flexWrap: "wrap",
1237
+ gap: 1,
1238
+ pt: 1.5
1239
+ },
1240
+ children: [
1241
+ /* @__PURE__ */ s(
1242
+ f,
1243
+ {
1244
+ sx: {
1245
+ display: "inline-flex",
1246
+ gap: 0.5,
1247
+ p: 0.5,
1248
+ backgroundColor: "action.hover",
1249
+ borderRadius: 2,
1250
+ border: "1px solid",
1251
+ borderColor: "divider",
1252
+ mb: 1
1253
+ },
1254
+ children: [
1255
+ !i && /* @__PURE__ */ r(
1256
+ O,
1257
+ {
1258
+ size: "small",
1259
+ onClick: () => {
1260
+ le(0), I("");
1261
+ },
1262
+ sx: {
1263
+ px: 1.5,
1264
+ py: 0.4,
1265
+ borderRadius: 1.5,
1266
+ textTransform: "none",
1267
+ fontSize: "0.78rem",
1268
+ fontWeight: g === 0 ? 700 : 500,
1269
+ color: g === 0 ? "primary.dark" : "text.secondary",
1270
+ backgroundColor: g === 0 ? "background.paper" : "transparent",
1271
+ boxShadow: g === 0 ? "0px 1px 4px rgba(0,0,0,0.06)" : "none",
1272
+ border: "1px solid",
1273
+ borderColor: g === 0 ? "divider" : "transparent",
1274
+ "&:hover": {
1275
+ backgroundColor: g === 0 ? "background.paper" : "action.hover"
1276
+ }
1277
+ },
1278
+ children: "Synced Columns"
1279
+ }
1280
+ ),
1281
+ k !== void 0 && /* @__PURE__ */ r(
1282
+ O,
1283
+ {
1284
+ size: "small",
1285
+ onClick: () => {
1286
+ le(1), I("");
1287
+ },
1288
+ sx: {
1289
+ px: 1.5,
1290
+ py: 0.4,
1291
+ borderRadius: 1.5,
1292
+ textTransform: "none",
1293
+ fontSize: "0.78rem",
1294
+ fontWeight: g === 1 ? 700 : 500,
1295
+ color: g === 1 ? "primary.dark" : "text.secondary",
1296
+ backgroundColor: g === 1 ? "background.paper" : "transparent",
1297
+ boxShadow: g === 1 ? "0px 1px 4px rgba(0,0,0,0.06)" : "none",
1298
+ border: "1px solid",
1299
+ borderColor: g === 1 ? "divider" : "transparent",
1300
+ "&:hover": {
1301
+ backgroundColor: g === 1 ? "background.paper" : "action.hover"
1302
+ }
1303
+ },
1304
+ children: i ? "Columns" : "DB Columns"
1305
+ }
1306
+ )
1307
+ ]
1308
+ }
1309
+ ),
1310
+ g === 0 && v.length > 0 && G && /* @__PURE__ */ r(f, { sx: { minWidth: 200, marginLeft: 2 }, children: /* @__PURE__ */ r(
1311
+ ce,
1312
+ {
1313
+ size: "small",
1314
+ options: v.map((e) => e.name),
1315
+ value: t.getValues("primaryKey") || "",
1316
+ readOnly: !m && !i,
1317
+ onChange: (e, n) => {
1318
+ const l = v.map(
1319
+ (a) => ({
1320
+ ...a,
1321
+ isPrimaryKey: a.name === n
1322
+ })
1323
+ );
1324
+ K(l), t.setValue("selectedColumns", l, {
1325
+ shouldDirty: !0
1326
+ }), t.setValue("primaryKey", n);
1327
+ },
1328
+ renderInput: (e) => /* @__PURE__ */ r(
1329
+ D,
1330
+ {
1331
+ ...e,
1332
+ label: "Primary Key",
1333
+ placeholder: "Select column"
1334
+ }
1335
+ ),
1336
+ renderOption: (e, n) => /* @__PURE__ */ r("li", { ...e, children: /* @__PURE__ */ r(B, { title: n, placement: "left", arrow: !0, children: /* @__PURE__ */ r("span", { className: "truncate max-w-[250px]", children: n }) }) })
1337
+ }
1338
+ ) }),
1339
+ (i || m) && /* @__PURE__ */ r(
1340
+ O,
1341
+ {
1342
+ id: "edit-button-anchor",
1343
+ size: "small",
1344
+ variant: "contained",
1345
+ sx: {
1346
+ borderRadius: 2,
1347
+ fontWeight: 600,
1348
+ textTransform: "none",
1349
+ boxShadow: "none",
1350
+ px: 1.5,
1351
+ ml: 1
1352
+ },
1353
+ disabled: !!t.formState.errors.tableName,
1354
+ onClick: async (e) => {
1355
+ const n = e.currentTarget;
1356
+ await t.trigger("tableName") && (ie(null), oe(n));
1357
+ },
1358
+ startIcon: /* @__PURE__ */ r(C, { iconName: "faPlus" }),
1359
+ children: "Column"
1360
+ }
1361
+ ),
1362
+ (i || m) && /* @__PURE__ */ r(
1363
+ yr,
1364
+ {
1365
+ id: tr,
1366
+ open: Te,
1367
+ anchorEl: Ke,
1368
+ onClose: async () => {
1369
+ oe(null), t.setValue("newColumnName", ""), t.setValue("newColumnType", null), t.setValue("isPrimaryKey", !1), t.clearErrors([
1370
+ "newColumnName",
1371
+ "newColumnType"
1372
+ ]), ie(null);
1373
+ },
1374
+ anchorOrigin: {
1375
+ vertical: "bottom",
1376
+ horizontal: "left"
1377
+ },
1378
+ children: /* @__PURE__ */ s(
1379
+ y,
1380
+ {
1381
+ container: !0,
1382
+ spacing: 1,
1383
+ sx: {
1384
+ p: 1,
1385
+ width: "200px",
1386
+ height: (Ue = t.getValues("selectedColumns")) != null && Ue.some((e) => e.isPrimaryKey) ? "180px" : "210px"
1387
+ },
1388
+ children: [
1389
+ /* @__PURE__ */ r(y, { size: 12, className: "h-fit", children: /* @__PURE__ */ r(M, { fullWidth: !0, children: /* @__PURE__ */ r(
1390
+ N,
1391
+ {
1392
+ name: "newColumnName",
1393
+ id: "newColumnName",
1394
+ control: t.control,
1395
+ render: ({
1396
+ field: { onChange: e, value: n, ...l },
1397
+ fieldState: { error: a }
1398
+ }) => /* @__PURE__ */ r(
1399
+ D,
1400
+ {
1401
+ ...l,
1402
+ value: (n == null ? void 0 : n.trim()) || "",
1403
+ variant: "outlined",
1404
+ fullWidth: !0,
1405
+ size: "small",
1406
+ error: !!a,
1407
+ helperText: a == null ? void 0 : a.message,
1408
+ label: "Column Name",
1409
+ sx: {
1410
+ "& .MuiInputLabel-root": {
1411
+ fontSize: "0.9rem"
1412
+ },
1413
+ margin: 0
1414
+ },
1415
+ onChange: (o) => {
1416
+ e(o.target.value), ur(o.target.value);
1417
+ }
1418
+ }
1419
+ )
1420
+ }
1421
+ ) }) }),
1422
+ /* @__PURE__ */ r(y, { size: 12, className: "h-fit", children: /* @__PURE__ */ r(M, { fullWidth: !0, children: /* @__PURE__ */ r(
1423
+ N,
1424
+ {
1425
+ name: "newColumnType",
1426
+ id: "newColumnType",
1427
+ control: t.control,
1428
+ render: ({
1429
+ field: { onChange: e, value: n },
1430
+ fieldState: { error: l }
1431
+ }) => /* @__PURE__ */ r(
1432
+ ce,
1433
+ {
1434
+ options: ze || [],
1435
+ value: (n == null ? void 0 : n.trim()) || null,
1436
+ getOptionLabel: (a) => a,
1437
+ onChange: (a, o) => {
1438
+ e(o);
1439
+ },
1440
+ renderInput: (a) => /* @__PURE__ */ r(
1441
+ D,
1442
+ {
1443
+ ...a,
1444
+ size: "small",
1445
+ error: !!l,
1446
+ helperText: l == null ? void 0 : l.message,
1447
+ sx: {
1448
+ "& .MuiInputLabel-root": {
1449
+ fontSize: "0.9rem"
1450
+ },
1451
+ m: 0
1452
+ },
1453
+ label: "Column Type",
1454
+ onChange: (o) => {
1455
+ e(o.target.value), t.setValue(
1456
+ "newColumnType",
1457
+ o.target.value,
1458
+ {
1459
+ shouldDirty: !0
1460
+ }
1461
+ );
1462
+ }
1463
+ }
1464
+ )
1465
+ }
1466
+ )
1467
+ }
1468
+ ) }) }),
1469
+ X === null && !t.getValues("selectedColumns").some((e) => e.isPrimaryKey) && /* @__PURE__ */ r(y, { size: 12, className: "h-fit", children: /* @__PURE__ */ r(
1470
+ W,
1471
+ {
1472
+ control: /* @__PURE__ */ r(
1473
+ N,
1474
+ {
1475
+ name: "isPrimaryKey",
1476
+ control: t.control,
1477
+ render: ({
1478
+ field: { onChange: e, value: n }
1479
+ }) => /* @__PURE__ */ r(
1480
+ fr,
1481
+ {
1482
+ checked: n || !1,
1483
+ onChange: (l) => e(l.target.checked),
1484
+ sx: {
1485
+ margin: "0px"
1486
+ }
1487
+ }
1488
+ )
1489
+ }
1490
+ ),
1491
+ label: "Primary Key"
1492
+ }
1493
+ ) }),
1494
+ /* @__PURE__ */ r(y, { children: /* @__PURE__ */ r(
1495
+ O,
1496
+ {
1497
+ size: "small",
1498
+ variant: "contained",
1499
+ disabled: !Oe || !Re || Oe.trim() === "" || !ze.includes(
1500
+ Re.trim()
1501
+ ),
1502
+ onClick: async () => {
1503
+ const e = t.getValues("isPrimaryKey"), n = t.getValues("newColumnName"), l = t.getValues("newColumnType"), a = t.getValues("selectedColumns").some((c) => c.isPrimaryKey);
1504
+ let o = [
1505
+ ...t.getValues("selectedColumns")
1506
+ ];
1507
+ if (X !== null)
1508
+ o[X] = {
1509
+ ...o[X],
1510
+ name: n,
1511
+ type: l
1512
+ };
1513
+ else {
1514
+ if (o.some(
1515
+ (p) => p.name === n
1516
+ )) {
1517
+ V({
1518
+ message: "Column already exists",
1519
+ type: "error"
1520
+ });
1521
+ return;
1522
+ }
1523
+ const c = {
1524
+ name: n,
1525
+ type: l
1526
+ };
1527
+ !a && e && (t.setValue("primaryKey", n), c.isPrimaryKey = !0), o.push(c);
1528
+ }
1529
+ t.setValue(
1530
+ "selectedColumns",
1531
+ o,
1532
+ {
1533
+ shouldDirty: !0
1534
+ }
1535
+ );
1536
+ const h = [...o].sort((c, p) => c.isPrimaryKey ? -1 : p.isPrimaryKey ? 1 : c.name.localeCompare(p.name));
1537
+ K(h), i && await ye(o), ie(null), oe(null), g !== 0 && le(0), t.setValue("newColumnName", " "), t.setValue("newColumnType", " "), t.setValue("isPrimaryKey", null);
1538
+ },
1539
+ children: X !== null ? "Update" : "Add"
1540
+ }
1541
+ ) })
1542
+ ]
1543
+ }
1544
+ )
1545
+ }
1546
+ )
1547
+ ]
1548
+ }
1549
+ ),
1550
+ /* @__PURE__ */ r(
1551
+ gr,
1552
+ {
1553
+ sx: {
1554
+ maxHeight: F === "true" ? "112vh" : "59vh",
1555
+ border: "1px solid",
1556
+ borderColor: "divider",
1557
+ borderRadius: 2
1558
+ },
1559
+ children: /* @__PURE__ */ s(xr, { stickyHeader: !0, children: [
1560
+ /* @__PURE__ */ r(Cr, { children: /* @__PURE__ */ r(ee, { children: /* @__PURE__ */ s(
1561
+ re,
1562
+ {
1563
+ className: " px-3 ",
1564
+ sx: { backgroundColor: "white" },
1565
+ children: [
1566
+ /* @__PURE__ */ r(
1567
+ D,
1568
+ {
1569
+ size: "small",
1570
+ placeholder: "Search Columns",
1571
+ variant: "outlined",
1572
+ value: te,
1573
+ onChange: (e) => {
1574
+ I(e.target.value);
1575
+ },
1576
+ className: "w-full py-0.5 text-xs",
1577
+ InputProps: {
1578
+ startAdornment: /* @__PURE__ */ r(Ce, { position: "start", children: /* @__PURE__ */ r(_, { children: /* @__PURE__ */ r(
1579
+ C,
1580
+ {
1581
+ iconName: "faMagnifyingGlass",
1582
+ className: "text-[1rem]"
1583
+ }
1584
+ ) }) })
1585
+ }
1586
+ }
1587
+ ),
1588
+ !pe && /* @__PURE__ */ s(
1589
+ u,
1590
+ {
1591
+ variant: "body2",
1592
+ color: "info",
1593
+ className: "mb-0",
1594
+ children: [
1595
+ /* @__PURE__ */ r("span", { style: { color: "red" }, children: "*" }),
1596
+ " Select a primary key for the table before submitting."
1597
+ ]
1598
+ }
1599
+ )
1600
+ ]
1601
+ }
1602
+ ) }) }),
1603
+ g === 0 && /* @__PURE__ */ r(Ye, { children: v.length ? v.map((e, n) => /* @__PURE__ */ r(
1604
+ ee,
1605
+ {
1606
+ className: `border-b ${n === v.length - 1 ? "border-none" : "border-[#ccc]"}`,
1607
+ sx: {
1608
+ backgroundColor: e.onlyMobileDb ? "#d3ecc7" : e.isTypeChanged ? "rgba(255, 0, 0, 0.1)" : "#fff",
1609
+ "&:hover": {
1610
+ backgroundColor: e.onlyMobileDb ? "#d2f7c0" : e.isTypeChanged ? "#e79a9a" : "#e9f3ff"
1611
+ }
1612
+ },
1613
+ children: /* @__PURE__ */ s(re, { className: "p-2 px-4 flex justify-between", children: [
1614
+ /* @__PURE__ */ r(
1615
+ B,
1616
+ {
1617
+ title: e.onlyMobileDb ? "Column only present in mobile database" : e.isTypeChanged ? "Type changed" : "",
1618
+ placement: "top",
1619
+ arrow: !0,
1620
+ disableHoverListener: !(e.onlyMobileDb || e.isTypeChanged),
1621
+ children: /* @__PURE__ */ s(
1622
+ u,
1623
+ {
1624
+ variant: "caption",
1625
+ className: "w-full text-ellipsis cursor-pointer",
1626
+ children: [
1627
+ e.name,
1628
+ " (",
1629
+ e.type,
1630
+ ")"
1631
+ ]
1632
+ }
1633
+ )
1634
+ }
1635
+ ),
1636
+ /* @__PURE__ */ s(f, { display: "flex", alignItems: "center", children: [
1637
+ e.isPrimaryKey && /* @__PURE__ */ r(
1638
+ _,
1639
+ {
1640
+ sx: {
1641
+ height: "1.5rem",
1642
+ marginRight: 0,
1643
+ paddingRight: 1
1644
+ },
1645
+ children: /* @__PURE__ */ r(
1646
+ C,
1647
+ {
1648
+ iconName: "faKey",
1649
+ className: "text-[1rem] text-[#d3bb51]"
1650
+ }
1651
+ )
1652
+ }
1653
+ ),
1654
+ (i || m) && /* @__PURE__ */ s(Q, { children: [
1655
+ /* @__PURE__ */ s(
1656
+ B,
1657
+ {
1658
+ title: !i && e.isPrimaryKey && !G ? "Deletion of primary key is not allowed." : "",
1659
+ arrow: !0,
1660
+ placement: "left",
1661
+ children: [
1662
+ " ",
1663
+ /* @__PURE__ */ r("span", { children: /* @__PURE__ */ r(
1664
+ _,
1665
+ {
1666
+ sx: {
1667
+ height: "1.3rem",
1668
+ marginRight: "0"
1669
+ },
1670
+ disabled: !i && e.isPrimaryKey && !G,
1671
+ onClick: async () => {
1672
+ const l = t.getValues(
1673
+ "selectedColumns"
1674
+ );
1675
+ I("");
1676
+ const a = l.filter(
1677
+ (c) => c.name !== e.name
1678
+ );
1679
+ t.setValue(
1680
+ "selectedColumns",
1681
+ a,
1682
+ { shouldDirty: !0 }
1683
+ );
1684
+ const o = te.trim().toLowerCase(), h = o ? a.filter(
1685
+ (c) => c.name.toLowerCase().includes(o)
1686
+ ) : a;
1687
+ K(
1688
+ h
1689
+ ), R(
1690
+ (c) => c.map((p) => p.name === e.name ? {
1691
+ ...p,
1692
+ isSynced: !1
1693
+ } : p)
1694
+ ), e.isPrimaryKey && t.setValue(
1695
+ "primaryKey",
1696
+ ""
1697
+ ), i && await ye(
1698
+ a
1699
+ );
1700
+ },
1701
+ children: /* @__PURE__ */ r(
1702
+ C,
1703
+ {
1704
+ iconName: "faTrashCan",
1705
+ className: "text-[1rem] text-[#df5f5f]"
1706
+ }
1707
+ )
1708
+ }
1709
+ ) })
1710
+ ]
1711
+ }
1712
+ ),
1713
+ i && /* @__PURE__ */ r(
1714
+ _,
1715
+ {
1716
+ sx: {
1717
+ height: "1.3rem",
1718
+ marginRight: "0",
1719
+ color: "success"
1720
+ },
1721
+ onClick: () => {
1722
+ const a = t.getValues(
1723
+ "selectedColumns"
1724
+ ).findIndex(
1725
+ (o) => o.name === e.name
1726
+ );
1727
+ ie(a), t.setValue(
1728
+ "newColumnName",
1729
+ e.name
1730
+ ), t.setValue(
1731
+ "newColumnType",
1732
+ e.type
1733
+ ), oe(
1734
+ document.getElementById(
1735
+ "edit-button-anchor"
1736
+ ) ?? null
1737
+ );
1738
+ },
1739
+ children: /* @__PURE__ */ r(
1740
+ C,
1741
+ {
1742
+ iconName: "faPen",
1743
+ className: "text-[1rem] text-[#4f4f4f]"
1744
+ }
1745
+ )
1746
+ }
1747
+ )
1748
+ ] })
1749
+ ] })
1750
+ ] })
1751
+ },
1752
+ n + 1
1753
+ )) : /* @__PURE__ */ r(ee, { children: /* @__PURE__ */ r(re, { colSpan: 1, className: "p-2", children: /* @__PURE__ */ s(u, { variant: "body2", children: [
1754
+ " ",
1755
+ t.getValues("selectedColumns").length === 0 ? "There are no columns to display." : v.length === 0 ? "No columns for search query." : null
1756
+ ] }) }) }) }),
1757
+ g === 1 && /* @__PURE__ */ r(Ye, { children: Y.length ? Y.map((e, n) => {
1758
+ const l = e.name === d.primaryKey, a = e.isSynced || !1, o = /* @__PURE__ */ r(
1759
+ vr,
1760
+ {
1761
+ icon: /* @__PURE__ */ r(
1762
+ f,
1763
+ {
1764
+ sx: {
1765
+ backgroundColor: "#001e3c",
1766
+ borderRadius: "50%",
1767
+ width: 20,
1768
+ height: 20,
1769
+ display: "flex",
1770
+ alignItems: "center",
1771
+ justifyContent: "center"
1772
+ },
1773
+ children: /* @__PURE__ */ r(
1774
+ C,
1775
+ {
1776
+ iconName: "faBan",
1777
+ size: "sm",
1778
+ className: "pr-[0.4px]"
1779
+ }
1780
+ )
1781
+ }
1782
+ ),
1783
+ checkedIcon: /* @__PURE__ */ r(
1784
+ f,
1785
+ {
1786
+ sx: {
1787
+ backgroundColor: "#4caf50",
1788
+ borderRadius: "50%",
1789
+ width: 20,
1790
+ height: 20,
1791
+ display: "flex",
1792
+ alignItems: "center",
1793
+ justifyContent: "center"
1794
+ },
1795
+ children: /* @__PURE__ */ r(
1796
+ C,
1797
+ {
1798
+ iconName: "faRotate",
1799
+ className: "text-white text-xs"
1800
+ }
1801
+ )
1802
+ }
1803
+ ),
1804
+ checked: a,
1805
+ disabled: !m,
1806
+ onChange: (c) => {
1807
+ const p = c.target.checked;
1808
+ if (!p && m && !G && !i && e.name === d.primaryKey)
1809
+ return;
1810
+ const j = [...Y], Z = {
1811
+ ...j[n],
1812
+ isSynced: c.target.checked
1813
+ };
1814
+ j[n] = Z, R(j);
1815
+ const P = [...v];
1816
+ if (p) {
1817
+ const q = v.some(
1818
+ (z) => z.isPrimaryKey
1819
+ );
1820
+ e.name === d.primaryKey && !q ? (P.push({
1821
+ ...Z,
1822
+ isPrimaryKey: !0
1823
+ }), t.setValue("primaryKey", e.name)) : P.push(Z);
1824
+ } else {
1825
+ const q = P.findIndex(
1826
+ (z) => z.name === j[n].name
1827
+ );
1828
+ if (q > -1) {
1829
+ const z = P[q].isPrimaryKey;
1830
+ P.splice(q, 1), z && t.setValue("primaryKey", "");
1831
+ }
1832
+ }
1833
+ K(P), t.setValue("selectedColumns", P, {
1834
+ shouldDirty: !0
1835
+ });
1836
+ }
1837
+ }
1838
+ ), h = /* @__PURE__ */ r(
1839
+ _,
1840
+ {
1841
+ sx: {
1842
+ height: "2rem",
1843
+ marginRight: m ? 1 : 0,
1844
+ paddingRight: m ? 1 : 0
1845
+ },
1846
+ children: /* @__PURE__ */ r(
1847
+ C,
1848
+ {
1849
+ iconName: "faKey",
1850
+ className: "text-lg text-[#d3bb51]"
1851
+ }
1852
+ )
1853
+ }
1854
+ );
1855
+ return /* @__PURE__ */ r(
1856
+ ee,
1857
+ {
1858
+ className: `border-b ${n === Y.length - 1 ? "border-none" : "border-[#ccc]"}`,
1859
+ sx: {
1860
+ "&:hover": { backgroundColor: "#e9f3ff" }
1861
+ },
1862
+ children: /* @__PURE__ */ s(
1863
+ re,
1864
+ {
1865
+ sx: {
1866
+ p: 0,
1867
+ px: 2,
1868
+ display: "flex",
1869
+ justifyContent: "space-between",
1870
+ alignItems: "center"
1871
+ },
1872
+ children: [
1873
+ /* @__PURE__ */ s(
1874
+ u,
1875
+ {
1876
+ variant: "caption",
1877
+ className: "w-full text-ellipsis cursor-pointer align-content-center",
1878
+ children: [
1879
+ e.name,
1880
+ " (",
1881
+ e.type,
1882
+ ")"
1883
+ ]
1884
+ }
1885
+ ),
1886
+ m ? l ? i ? h : /* @__PURE__ */ s(
1887
+ f,
1888
+ {
1889
+ sx: {
1890
+ display: "flex",
1891
+ alignItems: "center"
1892
+ },
1893
+ children: [
1894
+ h,
1895
+ /* @__PURE__ */ r(
1896
+ B,
1897
+ {
1898
+ title: m && !G && e.name === d.primaryKey ? "Primary key cannot be unsynced in edit mode." : "",
1899
+ arrow: !0,
1900
+ placement: "top",
1901
+ children: /* @__PURE__ */ r("span", { children: o })
1902
+ }
1903
+ )
1904
+ ]
1905
+ }
1906
+ ) : o : a ? /* @__PURE__ */ r(
1907
+ f,
1908
+ {
1909
+ sx: {
1910
+ backgroundColor: "#4caf50",
1911
+ borderRadius: "50%",
1912
+ width: 20,
1913
+ height: 20,
1914
+ display: "flex",
1915
+ alignItems: "center",
1916
+ justifyContent: "center",
1917
+ margin: "9px 0px"
1918
+ },
1919
+ children: /* @__PURE__ */ r(
1920
+ C,
1921
+ {
1922
+ iconName: "faRotate",
1923
+ className: "text-white text-xs"
1924
+ }
1925
+ )
1926
+ }
1927
+ ) : l ? h : /* @__PURE__ */ r(
1928
+ f,
1929
+ {
1930
+ sx: {
1931
+ backgroundColor: "#001e3c",
1932
+ borderRadius: "50%",
1933
+ width: 20,
1934
+ height: 20,
1935
+ display: "flex",
1936
+ alignItems: "center",
1937
+ justifyContent: "center",
1938
+ margin: "9px 0px"
1939
+ },
1940
+ children: /* @__PURE__ */ r(
1941
+ C,
1942
+ {
1943
+ iconName: "faBan",
1944
+ className: "text-white pl-[0.5px]"
1945
+ }
1946
+ )
1947
+ }
1948
+ )
1949
+ ]
1950
+ }
1951
+ )
1952
+ },
1953
+ n + 1
1954
+ );
1955
+ }) : /* @__PURE__ */ r(ee, { children: /* @__PURE__ */ r(re, { colSpan: 1, className: "p-2", children: /* @__PURE__ */ r(u, { variant: "body2", children: "No columns for search query." }) }) }) })
1956
+ ] })
1957
+ }
1958
+ )
1959
+ ]
1960
+ }
1961
+ ) })
1962
+ ] })
1963
+ ]
1964
+ }
1965
+ )
1966
+ }
1967
+ ),
1968
+ De && /* @__PURE__ */ r(br, { open: De, onClose: ir, children: /* @__PURE__ */ s(f, { sx: { ...Pr }, children: [
1969
+ /* @__PURE__ */ s(
1970
+ f,
1971
+ {
1972
+ sx: {
1973
+ display: "flex",
1974
+ justifyContent: "space-between",
1975
+ alignItems: "center",
1976
+ mb: 2
1977
+ },
1978
+ children: [
1979
+ /* @__PURE__ */ r(u, { variant: "h6", children: "Generated Migration Script" }),
1980
+ /* @__PURE__ */ s(u, { variant: "body2", children: [
1981
+ "From : ",
1982
+ /* @__PURE__ */ s("strong", { children: [
1983
+ "v",
1984
+ (E == null ? void 0 : E.from_version) + 1
1985
+ ] }),
1986
+ " ",
1987
+ /* @__PURE__ */ r(
1988
+ C,
1989
+ {
1990
+ iconName: "faArrowRight",
1991
+ size: "sm",
1992
+ className: "m-[0.3rem 0.3rem 0 0.3rem]"
1993
+ }
1994
+ ),
1995
+ " ",
1996
+ "To : ",
1997
+ /* @__PURE__ */ s("strong", { children: [
1998
+ "v",
1999
+ (E == null ? void 0 : E.to_version) + 1
2000
+ ] })
2001
+ ] })
2002
+ ]
2003
+ }
2004
+ ),
2005
+ /* @__PURE__ */ r(
2006
+ de,
2007
+ {
2008
+ height: "50vh",
2009
+ defaultLanguage: "sql",
2010
+ theme: "light",
2011
+ options: {
2012
+ fontSize: 12,
2013
+ minimap: { enabled: !0 },
2014
+ automaticLayout: !0,
2015
+ scrollBeyondLastLine: !1,
2016
+ wordWrap: "on",
2017
+ occurrencesHighlight: !1,
2018
+ selectionHighlight: !1
2019
+ },
2020
+ value: $ || "",
2021
+ defaultValue: $ || "",
2022
+ onChange: sr,
2023
+ editorProps: { $blockScrolling: !0 }
2024
+ }
2025
+ ),
2026
+ /* @__PURE__ */ r(
2027
+ O,
2028
+ {
2029
+ variant: "contained",
2030
+ color: "primary",
2031
+ className: "mt-2",
2032
+ onClick: () => Le(null, !0),
2033
+ children: "OK"
2034
+ }
2035
+ )
2036
+ ] }) })
2037
+ ]
2038
+ }
2039
+ );
2040
+ }
2041
+ const Pr = {
2042
+ position: "absolute",
2043
+ top: "50%",
2044
+ left: "50%",
2045
+ transform: "translate(-50%, -50%)",
2046
+ width: "50%",
2047
+ height: "70%",
2048
+ bgcolor: "background.paper",
2049
+ boxShadow: 24,
2050
+ padding: "15px",
2051
+ borderRadius: "8px"
2052
+ };
2053
+ kr.propTypes = {
2054
+ tableInfo: S.any,
2055
+ table: S.any,
2056
+ isEditMode: S.bool,
2057
+ updateEditMode: S.any,
2058
+ tableCompleteInfo: S.any,
2059
+ reloadComponents: S.any,
2060
+ isCreateTableMode: S.bool,
2061
+ isSyncTableMode: S.bool,
2062
+ updateCreateTableMode: S.any,
2063
+ openDeleteModal: S.bool,
2064
+ setOpenDeleteModal: S.func
2065
+ };
2066
+ export {
2067
+ kr as default
2068
+ };
2069
+ //# sourceMappingURL=TableDetails-DztbjsIA.js.map