@devtable/settings-form 8.50.6 → 8.51.0

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.
@@ -1,819 +1,205 @@
1
- import { Box as F, TextInput as D, Divider as Te, Group as O, NumberInput as Wr, PasswordInput as de, Button as T, Modal as ne, Stack as ze, SegmentedControl as Yr, useMantineTheme as Kr, Tooltip as Br, Text as ue, LoadingOverlay as Oe, Table as Ae, Select as Gr, Switch as Hr } from "@mantine/core";
2
- import { showNotification as V, updateNotification as k } from "@mantine/notifications";
3
- import * as ee from "react";
4
- import H, { useEffect as xe, forwardRef as ke, useState as lr, useMemo as ur } from "react";
5
- import { Recycle as Jr, PlaylistAdd as De, Trash as je, Edit as Xr } from "tabler-icons-react";
6
- import Qr from "axios";
7
- import Zr from "crypto-js";
8
- import et from "lodash";
9
- import { useForm as J, Controller as R } from "react-hook-form";
10
- import { useBoolean as rt, useRequest as G } from "ahooks";
11
- import tt, { loader as Ee } from "@monaco-editor/react";
12
- import { useModals as fe, closeAllModals as nt } from "@mantine/modals";
13
- function at(t) {
1
+ import * as K from "/Users/leto/Merico/merico-dev/table/node_modules/react/jsx-runtime.js";
2
+ import { Box as v, TextInput as z, Divider as V, Group as w, NumberInput as ie, PasswordInput as L, Button as b, Modal as R, Stack as B, SegmentedControl as oe, useMantineTheme as ae, Tooltip as se, Text as I, LoadingOverlay as H, Table as $, Select as ce, Switch as le } from "@mantine/core";
3
+ import { showNotification as _, updateNotification as S } from "@mantine/notifications";
4
+ import * as x from "react";
5
+ import F, { useEffect as G, forwardRef as J, useState as Z, useMemo as ee } from "react";
6
+ import { Recycle as de, PlaylistAdd as Q, Trash as W, Edit as ue } from "tabler-icons-react";
7
+ import pe from "axios";
8
+ import ge from "crypto-js";
9
+ import me from "lodash";
10
+ import { useForm as T, Controller as m } from "react-hook-form";
11
+ import { useBoolean as he, useRequest as D } from "ahooks";
12
+ import fe, { loader as U } from "@monaco-editor/react";
13
+ import { useModals as j, closeAllModals as be } from "@mantine/modals";
14
+ const C = K.Fragment, e = K.jsx, d = K.jsxs;
15
+ function we(t) {
14
16
  t = t || {};
15
- const n = Object.keys(t).sort(), i = [];
16
- for (let o = 0; o < n.length; o++) {
17
- const l = n[o];
18
- if (l != "authentication" && t[l])
19
- i.push(n[o] + "=" + (typeof t[l] == "object" ? JSON.stringify(t[l]) : t[l]));
17
+ const n = Object.keys(t).sort(), r = [];
18
+ for (let i = 0; i < n.length; i++) {
19
+ const s = n[i];
20
+ if (s != "authentication" && t[s])
21
+ r.push(n[i] + "=" + (typeof t[s] == "object" ? JSON.stringify(t[s]) : t[s]));
20
22
  else {
21
- const s = Object.keys(t[l]).sort();
22
- for (let c = 0; c < s.length; c++) {
23
- const d = s[c];
24
- d != "sign" && t[l][d] && i.push(
25
- s[c] + "=" + (typeof t[l][d] == "object" ? JSON.stringify(t[l][d]) : t[l][d])
26
- );
23
+ const o = Object.keys(t[s]).sort();
24
+ for (let a = 0; a < o.length; a++) {
25
+ const c = o[a];
26
+ c != "sign" && t[s][c] && r.push(o[a] + "=" + (typeof t[s][c] == "object" ? JSON.stringify(t[s][c]) : t[s][c]));
27
27
  }
28
28
  }
29
29
  }
30
- return i.sort().join("&");
30
+ return r.sort().join("&");
31
31
  }
32
- function it(t, n) {
33
- let i = at(t);
34
- return i += "&key=" + n, Zr.MD5(i).toString().toUpperCase();
32
+ function Se(t, n) {
33
+ let r = we(t);
34
+ return r += "&key=" + n, ge.MD5(r).toString().toUpperCase();
35
35
  }
36
- const C = {
36
+ const f = {
37
37
  baseURL: "http://localhost:31200",
38
38
  app_id: "",
39
39
  app_secret: "",
40
40
  getAuthentication(t) {
41
41
  if (!this.app_id || !this.app_secret)
42
42
  return;
43
- const n = new Date().getTime().toString();
43
+ const n = (/* @__PURE__ */ new Date()).getTime().toString();
44
44
  return {
45
45
  app_id: this.app_id,
46
46
  nonce_str: n,
47
- sign: it(
48
- {
49
- app_id: this.app_id,
50
- nonce_str: n,
51
- ...t
52
- },
53
- this.app_secret
54
- )
47
+ sign: Se({
48
+ app_id: this.app_id,
49
+ nonce_str: n,
50
+ ...t
51
+ }, this.app_secret)
55
52
  };
56
53
  },
57
54
  getRequest(t) {
58
- return (n, i, o = {}) => {
59
- const l = window.localStorage.getItem("token"), s = {
55
+ return (n, r, i = {}) => {
56
+ const s = window.localStorage.getItem("token"), o = {
60
57
  "X-Requested-With": "XMLHttpRequest",
61
- "Content-Type": o.string ? "application/x-www-form-urlencoded" : "application/json",
62
- authorization: l ? `bearer ${l}` : "",
63
- ...o.headers
64
- }, c = {
58
+ "Content-Type": i.string ? "application/x-www-form-urlencoded" : "application/json",
59
+ authorization: s ? `bearer ${s}` : "",
60
+ ...i.headers
61
+ }, a = {
65
62
  baseURL: this.baseURL,
66
63
  method: t,
67
64
  url: n,
68
- params: t === "GET" ? i : o.params,
69
- headers: s
65
+ params: t === "GET" ? r : i.params,
66
+ headers: o
70
67
  };
71
- return ["POST", "PUT"].includes(t) && (c.data = o.string ? JSON.stringify(i) : i, c.data.authentication = this.getAuthentication(c.data)), Qr(c).then((d) => d.data).catch((d) => et.has(d, "response.data.detail.message") ? Promise.reject(new Error(d.response.data.detail.message)) : Promise.reject(d));
68
+ return ["POST", "PUT"].includes(t) && (a.data = i.string ? JSON.stringify(r) : r, a.data.authentication = this.getAuthentication(a.data)), pe(a).then((c) => c.data).catch((c) => me.has(c, "response.data.detail.message") ? Promise.reject(new Error(c.response.data.detail.message)) : Promise.reject(c));
72
69
  };
73
70
  }
74
71
  };
75
- function pe(t) {
76
- C.baseURL !== t.apiBaseURL && (C.baseURL = t.apiBaseURL), t.app_id && (C.app_id = t.app_id), t.app_secret && (C.app_secret = t.app_secret);
72
+ function E(t) {
73
+ f.baseURL !== t.apiBaseURL && (f.baseURL = t.apiBaseURL), t.app_id && (f.app_id = t.app_id), t.app_secret && (f.app_secret = t.app_secret);
77
74
  }
78
- const ot = {
75
+ const ze = {
79
76
  login: async (t, n) => {
80
- const i = {
77
+ const r = {
81
78
  name: t,
82
79
  password: n
83
80
  };
84
- return await C.getRequest("POST")("/account/login", i);
81
+ return await f.getRequest("POST")("/account/login", r);
85
82
  },
86
- list: async () => await C.getRequest("POST")("/account/list", {
83
+ list: async () => await f.getRequest("POST")("/account/list", {
87
84
  filter: {},
88
- sort: [
89
- {
90
- field: "name",
91
- order: "ASC"
92
- }
93
- ],
85
+ sort: [{
86
+ field: "name",
87
+ order: "ASC"
88
+ }],
94
89
  pagination: {
95
90
  page: 1,
96
91
  pagesize: 100
97
92
  }
98
93
  }),
99
- get: async () => await C.getRequest("GET")("/account/get", {}),
94
+ /**
95
+ * get current account
96
+ */
97
+ get: async () => await f.getRequest("GET")("/account/get", {}),
98
+ /**
99
+ * update current account
100
+ */
100
101
  update: async (t, n) => {
101
- const i = {
102
+ const r = {
102
103
  name: t,
103
104
  email: n
104
105
  };
105
- return await C.getRequest("PUT")("/account/update", i);
106
+ return await f.getRequest("PUT")("/account/update", r);
106
107
  },
108
+ /**
109
+ * change current account's password
110
+ */
107
111
  changepassword: async (t, n) => {
108
- const i = {
112
+ const r = {
109
113
  old_password: t,
110
114
  new_password: n
111
115
  };
112
- return await C.getRequest("POST")("/account/changepassword", i);
116
+ return await f.getRequest("POST")("/account/changepassword", r);
113
117
  },
114
- create: async (t, n, i, o) => await C.getRequest("POST")("/account/create", {
118
+ create: async (t, n, r, i) => await f.getRequest("POST")("/account/create", {
115
119
  name: t,
116
120
  email: n,
117
- password: i,
118
- role_id: o
121
+ password: r,
122
+ role_id: i
119
123
  }),
120
- edit: async (t) => (t.reset_password || (t.new_password = void 0), await C.getRequest("PUT")("/account/edit", t)),
124
+ edit: async (t) => (t.reset_password || (t.new_password = void 0), await f.getRequest("PUT")("/account/edit", t)),
121
125
  delete: async (t) => {
122
- if (!!t)
123
- return C.getRequest("POST")("/account/delete", { id: t });
126
+ if (t)
127
+ return f.getRequest("POST")("/account/delete", {
128
+ id: t
129
+ });
124
130
  }
125
- }, st = {
126
- list: async () => await C.getRequest("POST")("/api/key/list", {
131
+ }, Pe = {
132
+ list: async () => await f.getRequest("POST")("/api/key/list", {
127
133
  filter: {
128
134
  search: ""
129
135
  },
130
- sort: [
131
- {
132
- field: "name",
133
- order: "ASC"
134
- }
135
- ],
136
+ sort: [{
137
+ field: "name",
138
+ order: "ASC"
139
+ }],
136
140
  pagination: {
137
141
  page: 1,
138
142
  pagesize: 100
139
143
  }
140
144
  }),
141
- create: async (t, n) => C.getRequest("POST")("/api/key/create", {
145
+ create: async (t, n) => f.getRequest("POST")("/api/key/create", {
142
146
  name: t,
143
147
  role_id: n
144
148
  }),
145
149
  delete: async (t) => {
146
- if (!!t)
147
- return C.getRequest("POST")("/api/key/delete", { id: t });
150
+ if (t)
151
+ return f.getRequest("POST")("/api/key/delete", {
152
+ id: t
153
+ });
148
154
  }
149
- }, ct = {
150
- list: async () => await C.getRequest("POST")("/datasource/list", {
155
+ }, ve = {
156
+ list: async () => await f.getRequest("POST")("/datasource/list", {
151
157
  filter: {},
152
- sort: [
153
- {
154
- field: "create_time",
155
- order: "ASC"
156
- }
157
- ],
158
+ sort: [{
159
+ field: "create_time",
160
+ order: "ASC"
161
+ }],
158
162
  pagination: {
159
163
  page: 1,
160
164
  pagesize: 100
161
165
  }
162
166
  }),
163
- create: async (t, n, i) => await C.getRequest("POST")("/datasource/create", {
167
+ create: async (t, n, r) => await f.getRequest("POST")("/datasource/create", {
164
168
  type: t,
165
169
  key: n,
166
- config: i
170
+ config: r
167
171
  }),
168
172
  delete: async (t) => {
169
- await C.getRequest("POST")("/datasource/delete", { id: t });
173
+ await f.getRequest("POST")("/datasource/delete", {
174
+ id: t
175
+ });
170
176
  }
171
- }, lt = {
172
- list: async () => await C.getRequest("GET")("/role/list", {})
173
- }, j = {
174
- datasource: ct,
175
- account: ot,
176
- role: lt,
177
- api_key: st
178
- }, X = {
177
+ }, Ae = {
178
+ list: async () => await f.getRequest("GET")("/role/list", {})
179
+ }, P = {
180
+ datasource: ve,
181
+ account: ze,
182
+ role: Ae,
183
+ api_key: Pe
184
+ }, q = {
179
185
  size: "sm",
180
186
  spacing: "md",
181
187
  button: {
182
188
  size: "xs"
183
189
  }
184
190
  };
185
- var ge = { exports: {} }, re = {};
186
- /**
187
- * @license React
188
- * react-jsx-runtime.production.min.js
189
- *
190
- * Copyright (c) Facebook, Inc. and its affiliates.
191
- *
192
- * This source code is licensed under the MIT license found in the
193
- * LICENSE file in the root directory of this source tree.
194
- */
195
- var or;
196
- function ut() {
197
- if (or)
198
- return re;
199
- or = 1;
200
- var t = H, n = Symbol.for("react.element"), i = Symbol.for("react.fragment"), o = Object.prototype.hasOwnProperty, l = t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, s = { key: !0, ref: !0, __self: !0, __source: !0 };
201
- function c(d, p, v) {
202
- var S, h = {}, f = null, z = null;
203
- v !== void 0 && (f = "" + v), p.key !== void 0 && (f = "" + p.key), p.ref !== void 0 && (z = p.ref);
204
- for (S in p)
205
- o.call(p, S) && !s.hasOwnProperty(S) && (h[S] = p[S]);
206
- if (d && d.defaultProps)
207
- for (S in p = d.defaultProps, p)
208
- h[S] === void 0 && (h[S] = p[S]);
209
- return { $$typeof: n, type: d, key: f, ref: z, props: h, _owner: l.current };
210
- }
211
- return re.Fragment = i, re.jsx = c, re.jsxs = c, re;
212
- }
213
- var te = {};
214
- /**
215
- * @license React
216
- * react-jsx-runtime.development.js
217
- *
218
- * Copyright (c) Facebook, Inc. and its affiliates.
219
- *
220
- * This source code is licensed under the MIT license found in the
221
- * LICENSE file in the root directory of this source tree.
222
- */
223
- var sr;
224
- function dt() {
225
- return sr || (sr = 1, process.env.NODE_ENV !== "production" && function() {
226
- var t = H, n = Symbol.for("react.element"), i = Symbol.for("react.portal"), o = Symbol.for("react.fragment"), l = Symbol.for("react.strict_mode"), s = Symbol.for("react.profiler"), c = Symbol.for("react.provider"), d = Symbol.for("react.context"), p = Symbol.for("react.forward_ref"), v = Symbol.for("react.suspense"), S = Symbol.for("react.suspense_list"), h = Symbol.for("react.memo"), f = Symbol.for("react.lazy"), z = Symbol.for("react.offscreen"), q = Symbol.iterator, W = "@@iterator";
227
- function me(e) {
228
- if (e === null || typeof e != "object")
229
- return null;
230
- var a = q && e[q] || e[W];
231
- return typeof a == "function" ? a : null;
232
- }
233
- var U = t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
234
- function A(e) {
235
- {
236
- for (var a = arguments.length, u = new Array(a > 1 ? a - 1 : 0), g = 1; g < a; g++)
237
- u[g - 1] = arguments[g];
238
- dr("error", e, u);
239
- }
240
- }
241
- function dr(e, a, u) {
242
- {
243
- var g = U.ReactDebugCurrentFrame, _ = g.getStackAddendum();
244
- _ !== "" && (a += "%s", u = u.concat([_]));
245
- var y = u.map(function(w) {
246
- return String(w);
247
- });
248
- y.unshift("Warning: " + a), Function.prototype.apply.call(console[e], console, y);
249
- }
250
- }
251
- var fr = !1, pr = !1, gr = !1, hr = !1, mr = !1, Fe;
252
- Fe = Symbol.for("react.module.reference");
253
- function br(e) {
254
- return !!(typeof e == "string" || typeof e == "function" || e === o || e === s || mr || e === l || e === v || e === S || hr || e === z || fr || pr || gr || typeof e == "object" && e !== null && (e.$$typeof === f || e.$$typeof === h || e.$$typeof === c || e.$$typeof === d || e.$$typeof === p || e.$$typeof === Fe || e.getModuleId !== void 0));
255
- }
256
- function vr(e, a, u) {
257
- var g = e.displayName;
258
- if (g)
259
- return g;
260
- var _ = a.displayName || a.name || "";
261
- return _ !== "" ? u + "(" + _ + ")" : u;
262
- }
263
- function qe(e) {
264
- return e.displayName || "Context";
265
- }
266
- function L(e) {
267
- if (e == null)
268
- return null;
269
- if (typeof e.tag == "number" && A("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."), typeof e == "function")
270
- return e.displayName || e.name || null;
271
- if (typeof e == "string")
272
- return e;
273
- switch (e) {
274
- case o:
275
- return "Fragment";
276
- case i:
277
- return "Portal";
278
- case s:
279
- return "Profiler";
280
- case l:
281
- return "StrictMode";
282
- case v:
283
- return "Suspense";
284
- case S:
285
- return "SuspenseList";
286
- }
287
- if (typeof e == "object")
288
- switch (e.$$typeof) {
289
- case d:
290
- var a = e;
291
- return qe(a) + ".Consumer";
292
- case c:
293
- var u = e;
294
- return qe(u._context) + ".Provider";
295
- case p:
296
- return vr(e, e.render, "ForwardRef");
297
- case h:
298
- var g = e.displayName || null;
299
- return g !== null ? g : L(e.type) || "Memo";
300
- case f: {
301
- var _ = e, y = _._payload, w = _._init;
302
- try {
303
- return L(w(y));
304
- } catch {
305
- return null;
306
- }
307
- }
308
- }
309
- return null;
310
- }
311
- var Y = Object.assign, Q = 0, Le, Me, Ne, Ue, Ve, $e, We;
312
- function Ye() {
313
- }
314
- Ye.__reactDisabledLog = !0;
315
- function wr() {
316
- {
317
- if (Q === 0) {
318
- Le = console.log, Me = console.info, Ne = console.warn, Ue = console.error, Ve = console.group, $e = console.groupCollapsed, We = console.groupEnd;
319
- var e = {
320
- configurable: !0,
321
- enumerable: !0,
322
- value: Ye,
323
- writable: !0
324
- };
325
- Object.defineProperties(console, {
326
- info: e,
327
- log: e,
328
- warn: e,
329
- error: e,
330
- group: e,
331
- groupCollapsed: e,
332
- groupEnd: e
333
- });
334
- }
335
- Q++;
336
- }
337
- }
338
- function Sr() {
339
- {
340
- if (Q--, Q === 0) {
341
- var e = {
342
- configurable: !0,
343
- enumerable: !0,
344
- writable: !0
345
- };
346
- Object.defineProperties(console, {
347
- log: Y({}, e, {
348
- value: Le
349
- }),
350
- info: Y({}, e, {
351
- value: Me
352
- }),
353
- warn: Y({}, e, {
354
- value: Ne
355
- }),
356
- error: Y({}, e, {
357
- value: Ue
358
- }),
359
- group: Y({}, e, {
360
- value: Ve
361
- }),
362
- groupCollapsed: Y({}, e, {
363
- value: $e
364
- }),
365
- groupEnd: Y({}, e, {
366
- value: We
367
- })
368
- });
369
- }
370
- Q < 0 && A("disabledDepth fell below zero. This is a bug in React. Please file an issue.");
371
- }
372
- }
373
- var be = U.ReactCurrentDispatcher, ve;
374
- function ae(e, a, u) {
375
- {
376
- if (ve === void 0)
377
- try {
378
- throw Error();
379
- } catch (_) {
380
- var g = _.stack.trim().match(/\n( *(at )?)/);
381
- ve = g && g[1] || "";
382
- }
383
- return `
384
- ` + ve + e;
385
- }
386
- }
387
- var we = !1, ie;
388
- {
389
- var _r = typeof WeakMap == "function" ? WeakMap : Map;
390
- ie = new _r();
391
- }
392
- function Ke(e, a) {
393
- if (!e || we)
394
- return "";
395
- {
396
- var u = ie.get(e);
397
- if (u !== void 0)
398
- return u;
399
- }
400
- var g;
401
- we = !0;
402
- var _ = Error.prepareStackTrace;
403
- Error.prepareStackTrace = void 0;
404
- var y;
405
- y = be.current, be.current = null, wr();
406
- try {
407
- if (a) {
408
- var w = function() {
409
- throw Error();
410
- };
411
- if (Object.defineProperty(w.prototype, "props", {
412
- set: function() {
413
- throw Error();
414
- }
415
- }), typeof Reflect == "object" && Reflect.construct) {
416
- try {
417
- Reflect.construct(w, []);
418
- } catch (M) {
419
- g = M;
420
- }
421
- Reflect.construct(e, [], w);
422
- } else {
423
- try {
424
- w.call();
425
- } catch (M) {
426
- g = M;
427
- }
428
- e.call(w.prototype);
429
- }
430
- } else {
431
- try {
432
- throw Error();
433
- } catch (M) {
434
- g = M;
435
- }
436
- e();
437
- }
438
- } catch (M) {
439
- if (M && g && typeof M.stack == "string") {
440
- for (var m = M.stack.split(`
441
- `), x = g.stack.split(`
442
- `), P = m.length - 1, E = x.length - 1; P >= 1 && E >= 0 && m[P] !== x[E]; )
443
- E--;
444
- for (; P >= 1 && E >= 0; P--, E--)
445
- if (m[P] !== x[E]) {
446
- if (P !== 1 || E !== 1)
447
- do
448
- if (P--, E--, E < 0 || m[P] !== x[E]) {
449
- var I = `
450
- ` + m[P].replace(" at new ", " at ");
451
- return e.displayName && I.includes("<anonymous>") && (I = I.replace("<anonymous>", e.displayName)), typeof e == "function" && ie.set(e, I), I;
452
- }
453
- while (P >= 1 && E >= 0);
454
- break;
455
- }
456
- }
457
- } finally {
458
- we = !1, be.current = y, Sr(), Error.prepareStackTrace = _;
459
- }
460
- var B = e ? e.displayName || e.name : "", ir = B ? ae(B) : "";
461
- return typeof e == "function" && ie.set(e, ir), ir;
462
- }
463
- function yr(e, a, u) {
464
- return Ke(e, !1);
465
- }
466
- function Rr(e) {
467
- var a = e.prototype;
468
- return !!(a && a.isReactComponent);
469
- }
470
- function oe(e, a, u) {
471
- if (e == null)
472
- return "";
473
- if (typeof e == "function")
474
- return Ke(e, Rr(e));
475
- if (typeof e == "string")
476
- return ae(e);
477
- switch (e) {
478
- case v:
479
- return ae("Suspense");
480
- case S:
481
- return ae("SuspenseList");
482
- }
483
- if (typeof e == "object")
484
- switch (e.$$typeof) {
485
- case p:
486
- return yr(e.render);
487
- case h:
488
- return oe(e.type, a, u);
489
- case f: {
490
- var g = e, _ = g._payload, y = g._init;
491
- try {
492
- return oe(y(_), a, u);
493
- } catch {
494
- }
495
- }
496
- }
497
- return "";
498
- }
499
- var se = Object.prototype.hasOwnProperty, Be = {}, Ge = U.ReactDebugCurrentFrame;
500
- function ce(e) {
501
- if (e) {
502
- var a = e._owner, u = oe(e.type, e._source, a ? a.type : null);
503
- Ge.setExtraStackFrame(u);
504
- } else
505
- Ge.setExtraStackFrame(null);
506
- }
507
- function Pr(e, a, u, g, _) {
508
- {
509
- var y = Function.call.bind(se);
510
- for (var w in e)
511
- if (y(e, w)) {
512
- var m = void 0;
513
- try {
514
- if (typeof e[w] != "function") {
515
- var x = Error((g || "React class") + ": " + u + " type `" + w + "` is invalid; it must be a function, usually from the `prop-types` package, but received `" + typeof e[w] + "`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");
516
- throw x.name = "Invariant Violation", x;
517
- }
518
- m = e[w](a, w, g, u, null, "SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED");
519
- } catch (P) {
520
- m = P;
521
- }
522
- m && !(m instanceof Error) && (ce(_), A("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).", g || "React class", u, w, typeof m), ce(null)), m instanceof Error && !(m.message in Be) && (Be[m.message] = !0, ce(_), A("Failed %s type: %s", u, m.message), ce(null));
523
- }
524
- }
525
- }
526
- var Er = Array.isArray;
527
- function Se(e) {
528
- return Er(e);
529
- }
530
- function Cr(e) {
531
- {
532
- var a = typeof Symbol == "function" && Symbol.toStringTag, u = a && e[Symbol.toStringTag] || e.constructor.name || "Object";
533
- return u;
534
- }
535
- }
536
- function Tr(e) {
537
- try {
538
- return He(e), !1;
539
- } catch {
540
- return !0;
541
- }
542
- }
543
- function He(e) {
544
- return "" + e;
545
- }
546
- function Je(e) {
547
- if (Tr(e))
548
- return A("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.", Cr(e)), He(e);
549
- }
550
- var Z = U.ReactCurrentOwner, zr = {
551
- key: !0,
552
- ref: !0,
553
- __self: !0,
554
- __source: !0
555
- }, Xe, Qe, _e;
556
- _e = {};
557
- function Or(e) {
558
- if (se.call(e, "ref")) {
559
- var a = Object.getOwnPropertyDescriptor(e, "ref").get;
560
- if (a && a.isReactWarning)
561
- return !1;
562
- }
563
- return e.ref !== void 0;
564
- }
565
- function Ar(e) {
566
- if (se.call(e, "key")) {
567
- var a = Object.getOwnPropertyDescriptor(e, "key").get;
568
- if (a && a.isReactWarning)
569
- return !1;
570
- }
571
- return e.key !== void 0;
572
- }
573
- function xr(e, a) {
574
- if (typeof e.ref == "string" && Z.current && a && Z.current.stateNode !== a) {
575
- var u = L(Z.current.type);
576
- _e[u] || (A('Component "%s" contains the string ref "%s". Support for string refs will be removed in a future major release. This case cannot be automatically converted to an arrow function. We ask you to manually fix this case by using useRef() or createRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref', L(Z.current.type), e.ref), _e[u] = !0);
577
- }
578
- }
579
- function kr(e, a) {
580
- {
581
- var u = function() {
582
- Xe || (Xe = !0, A("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)", a));
583
- };
584
- u.isReactWarning = !0, Object.defineProperty(e, "key", {
585
- get: u,
586
- configurable: !0
587
- });
588
- }
589
- }
590
- function Dr(e, a) {
591
- {
592
- var u = function() {
593
- Qe || (Qe = !0, A("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)", a));
594
- };
595
- u.isReactWarning = !0, Object.defineProperty(e, "ref", {
596
- get: u,
597
- configurable: !0
598
- });
599
- }
600
- }
601
- var jr = function(e, a, u, g, _, y, w) {
602
- var m = {
603
- $$typeof: n,
604
- type: e,
605
- key: a,
606
- ref: u,
607
- props: w,
608
- _owner: y
609
- };
610
- return m._store = {}, Object.defineProperty(m._store, "validated", {
611
- configurable: !1,
612
- enumerable: !1,
613
- writable: !0,
614
- value: !1
615
- }), Object.defineProperty(m, "_self", {
616
- configurable: !1,
617
- enumerable: !1,
618
- writable: !1,
619
- value: g
620
- }), Object.defineProperty(m, "_source", {
621
- configurable: !1,
622
- enumerable: !1,
623
- writable: !1,
624
- value: _
625
- }), Object.freeze && (Object.freeze(m.props), Object.freeze(m)), m;
626
- };
627
- function Ir(e, a, u, g, _) {
628
- {
629
- var y, w = {}, m = null, x = null;
630
- u !== void 0 && (Je(u), m = "" + u), Ar(a) && (Je(a.key), m = "" + a.key), Or(a) && (x = a.ref, xr(a, _));
631
- for (y in a)
632
- se.call(a, y) && !zr.hasOwnProperty(y) && (w[y] = a[y]);
633
- if (e && e.defaultProps) {
634
- var P = e.defaultProps;
635
- for (y in P)
636
- w[y] === void 0 && (w[y] = P[y]);
637
- }
638
- if (m || x) {
639
- var E = typeof e == "function" ? e.displayName || e.name || "Unknown" : e;
640
- m && kr(w, E), x && Dr(w, E);
641
- }
642
- return jr(e, m, x, _, g, Z.current, w);
643
- }
644
- }
645
- var ye = U.ReactCurrentOwner, Ze = U.ReactDebugCurrentFrame;
646
- function K(e) {
647
- if (e) {
648
- var a = e._owner, u = oe(e.type, e._source, a ? a.type : null);
649
- Ze.setExtraStackFrame(u);
650
- } else
651
- Ze.setExtraStackFrame(null);
652
- }
653
- var Re;
654
- Re = !1;
655
- function Pe(e) {
656
- return typeof e == "object" && e !== null && e.$$typeof === n;
657
- }
658
- function er() {
659
- {
660
- if (ye.current) {
661
- var e = L(ye.current.type);
662
- if (e)
663
- return `
664
-
665
- Check the render method of \`` + e + "`.";
666
- }
667
- return "";
668
- }
669
- }
670
- function Fr(e) {
671
- {
672
- if (e !== void 0) {
673
- var a = e.fileName.replace(/^.*[\\\/]/, ""), u = e.lineNumber;
674
- return `
675
-
676
- Check your code at ` + a + ":" + u + ".";
677
- }
678
- return "";
679
- }
680
- }
681
- var rr = {};
682
- function qr(e) {
683
- {
684
- var a = er();
685
- if (!a) {
686
- var u = typeof e == "string" ? e : e.displayName || e.name;
687
- u && (a = `
688
-
689
- Check the top-level render call using <` + u + ">.");
690
- }
691
- return a;
692
- }
693
- }
694
- function tr(e, a) {
695
- {
696
- if (!e._store || e._store.validated || e.key != null)
697
- return;
698
- e._store.validated = !0;
699
- var u = qr(a);
700
- if (rr[u])
701
- return;
702
- rr[u] = !0;
703
- var g = "";
704
- e && e._owner && e._owner !== ye.current && (g = " It was passed a child from " + L(e._owner.type) + "."), K(e), A('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.', u, g), K(null);
705
- }
706
- }
707
- function nr(e, a) {
708
- {
709
- if (typeof e != "object")
710
- return;
711
- if (Se(e))
712
- for (var u = 0; u < e.length; u++) {
713
- var g = e[u];
714
- Pe(g) && tr(g, a);
715
- }
716
- else if (Pe(e))
717
- e._store && (e._store.validated = !0);
718
- else if (e) {
719
- var _ = me(e);
720
- if (typeof _ == "function" && _ !== e.entries)
721
- for (var y = _.call(e), w; !(w = y.next()).done; )
722
- Pe(w.value) && tr(w.value, a);
723
- }
724
- }
725
- }
726
- function Lr(e) {
727
- {
728
- var a = e.type;
729
- if (a == null || typeof a == "string")
730
- return;
731
- var u;
732
- if (typeof a == "function")
733
- u = a.propTypes;
734
- else if (typeof a == "object" && (a.$$typeof === p || a.$$typeof === h))
735
- u = a.propTypes;
736
- else
737
- return;
738
- if (u) {
739
- var g = L(a);
740
- Pr(u, e.props, "prop", g, e);
741
- } else if (a.PropTypes !== void 0 && !Re) {
742
- Re = !0;
743
- var _ = L(a);
744
- A("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?", _ || "Unknown");
745
- }
746
- typeof a.getDefaultProps == "function" && !a.getDefaultProps.isReactClassApproved && A("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.");
747
- }
748
- }
749
- function Mr(e) {
750
- {
751
- for (var a = Object.keys(e.props), u = 0; u < a.length; u++) {
752
- var g = a[u];
753
- if (g !== "children" && g !== "key") {
754
- K(e), A("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.", g), K(null);
755
- break;
756
- }
757
- }
758
- e.ref !== null && (K(e), A("Invalid attribute `ref` supplied to `React.Fragment`."), K(null));
759
- }
760
- }
761
- function ar(e, a, u, g, _, y) {
762
- {
763
- var w = br(e);
764
- if (!w) {
765
- var m = "";
766
- (e === void 0 || typeof e == "object" && e !== null && Object.keys(e).length === 0) && (m += " You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");
767
- var x = Fr(_);
768
- x ? m += x : m += er();
769
- var P;
770
- e === null ? P = "null" : Se(e) ? P = "array" : e !== void 0 && e.$$typeof === n ? (P = "<" + (L(e.type) || "Unknown") + " />", m = " Did you accidentally export a JSX literal instead of a component?") : P = typeof e, A("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s", P, m);
771
- }
772
- var E = Ir(e, a, u, _, y);
773
- if (E == null)
774
- return E;
775
- if (w) {
776
- var I = a.children;
777
- if (I !== void 0)
778
- if (g)
779
- if (Se(I)) {
780
- for (var B = 0; B < I.length; B++)
781
- nr(I[B], e);
782
- Object.freeze && Object.freeze(I);
783
- } else
784
- A("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");
785
- else
786
- nr(I, e);
787
- }
788
- return e === o ? Mr(E) : Lr(E), E;
789
- }
790
- }
791
- function Nr(e, a, u) {
792
- return ar(e, a, u, !0);
793
- }
794
- function Ur(e, a, u) {
795
- return ar(e, a, u, !1);
796
- }
797
- var Vr = Ur, $r = Nr;
798
- te.Fragment = o, te.jsx = Vr, te.jsxs = $r;
799
- }()), te;
800
- }
801
- (function(t) {
802
- process.env.NODE_ENV === "production" ? t.exports = ut() : t.exports = dt();
803
- })(ge);
804
- const N = ge.exports.Fragment, r = ge.exports.jsx, b = ge.exports.jsxs;
805
- function ft({
191
+ function Ce({
806
192
  submit: t,
807
- styles: n = X,
808
- type: i
193
+ styles: n = q,
194
+ type: r
809
195
  }) {
810
196
  const {
811
- control: o,
812
- setValue: l,
813
- handleSubmit: s
814
- } = J({
197
+ control: i,
198
+ setValue: s,
199
+ handleSubmit: o
200
+ } = T({
815
201
  defaultValues: {
816
- type: i,
202
+ type: r,
817
203
  key: "",
818
204
  config: {
819
205
  host: "",
@@ -824,306 +210,141 @@ function ft({
824
210
  }
825
211
  }
826
212
  });
827
- return xe(() => {
828
- l("type", i);
829
- }, [l, i]), /* @__PURE__ */ r(F, {
830
- mx: "auto",
831
- children: /* @__PURE__ */ b("form", {
832
- onSubmit: s(t),
833
- children: [/* @__PURE__ */ r(R, {
834
- name: "key",
835
- control: o,
836
- render: ({
837
- field: c
838
- }) => /* @__PURE__ */ r(D, {
839
- mb: n.spacing,
840
- size: n.size,
841
- required: !0,
842
- label: "Name",
843
- placeholder: "A unique name",
844
- ...c
845
- })
846
- }), /* @__PURE__ */ r(Te, {
847
- label: "Connection Info",
848
- labelPosition: "center"
849
- }), /* @__PURE__ */ b(O, {
850
- grow: !0,
851
- children: [/* @__PURE__ */ r(R, {
852
- name: "config.host",
853
- control: o,
854
- render: ({
855
- field: c
856
- }) => /* @__PURE__ */ r(D, {
857
- mb: n.spacing,
858
- size: n.size,
859
- required: !0,
860
- label: "Host",
861
- sx: {
862
- flexGrow: 1
863
- },
864
- ...c
865
- })
866
- }), /* @__PURE__ */ r(R, {
867
- name: "config.port",
868
- control: o,
869
- render: ({
870
- field: c
871
- }) => /* @__PURE__ */ r(Wr, {
872
- mb: n.spacing,
873
- size: n.size,
874
- required: !0,
875
- label: "Port",
876
- hideControls: !0,
877
- sx: {
878
- width: "8em"
879
- },
880
- ...c
881
- })
882
- })]
883
- }), /* @__PURE__ */ r(R, {
884
- name: "config.username",
885
- control: o,
886
- render: ({
887
- field: c
888
- }) => /* @__PURE__ */ r(D, {
889
- mb: n.spacing,
890
- size: n.size,
891
- required: !0,
892
- label: "Username",
893
- ...c
894
- })
895
- }), /* @__PURE__ */ r(R, {
896
- name: "config.password",
897
- control: o,
898
- render: ({
899
- field: c
900
- }) => /* @__PURE__ */ r(de, {
901
- mb: n.spacing,
902
- size: n.size,
903
- required: !0,
904
- label: "Password",
905
- ...c
906
- })
907
- }), /* @__PURE__ */ r(R, {
908
- name: "config.database",
909
- control: o,
910
- render: ({
911
- field: c
912
- }) => /* @__PURE__ */ r(D, {
913
- mb: n.spacing,
914
- size: n.size,
915
- required: !0,
916
- label: "Database",
917
- ...c
918
- })
919
- }), /* @__PURE__ */ r(O, {
920
- position: "right",
921
- mt: n.spacing,
922
- children: /* @__PURE__ */ r(T, {
923
- type: "submit",
924
- size: n.button.size,
925
- children: "Save"
926
- })
927
- })]
928
- })
929
- });
213
+ return G(() => {
214
+ s("type", r);
215
+ }, [s, r]), /* @__PURE__ */ e(v, { mx: "auto", children: /* @__PURE__ */ d("form", { onSubmit: o(t), children: [
216
+ /* @__PURE__ */ e(m, { name: "key", control: i, render: ({
217
+ field: a
218
+ }) => /* @__PURE__ */ e(z, { mb: n.spacing, size: n.size, required: !0, label: "Name", placeholder: "A unique name", ...a }) }),
219
+ /* @__PURE__ */ e(V, { label: "Connection Info", labelPosition: "center" }),
220
+ /* @__PURE__ */ d(w, { grow: !0, children: [
221
+ /* @__PURE__ */ e(m, { name: "config.host", control: i, render: ({
222
+ field: a
223
+ }) => /* @__PURE__ */ e(z, { mb: n.spacing, size: n.size, required: !0, label: "Host", sx: {
224
+ flexGrow: 1
225
+ }, ...a }) }),
226
+ /* @__PURE__ */ e(m, { name: "config.port", control: i, render: ({
227
+ field: a
228
+ }) => /* @__PURE__ */ e(ie, { mb: n.spacing, size: n.size, required: !0, label: "Port", hideControls: !0, sx: {
229
+ width: "8em"
230
+ }, ...a }) })
231
+ ] }),
232
+ /* @__PURE__ */ e(m, { name: "config.username", control: i, render: ({
233
+ field: a
234
+ }) => /* @__PURE__ */ e(z, { mb: n.spacing, size: n.size, required: !0, label: "Username", ...a }) }),
235
+ /* @__PURE__ */ e(m, { name: "config.password", control: i, render: ({
236
+ field: a
237
+ }) => /* @__PURE__ */ e(L, { mb: n.spacing, size: n.size, required: !0, label: "Password", ...a }) }),
238
+ /* @__PURE__ */ e(m, { name: "config.database", control: i, render: ({
239
+ field: a
240
+ }) => /* @__PURE__ */ e(z, { mb: n.spacing, size: n.size, required: !0, label: "Database", ...a }) }),
241
+ /* @__PURE__ */ e(w, { position: "right", mt: n.spacing, children: /* @__PURE__ */ e(b, { type: "submit", size: n.button.size, children: "Save" }) })
242
+ ] }) });
930
243
  }
931
- const pt = ({
244
+ const _e = ({
932
245
  value: t,
933
246
  onChange: n
934
- }) => /* @__PURE__ */ r(F, {
935
- sx: {
936
- position: "relative"
937
- },
938
- children: /* @__PURE__ */ r(tt, {
939
- height: "500px",
940
- defaultLanguage: "javascript",
941
- value: t,
942
- onChange: (o) => {
943
- !o || n(o);
944
- },
945
- theme: "vs-dark",
946
- options: {
947
- minimap: {
948
- enabled: !1
949
- }
950
- }
951
- })
952
- }), cr = ke(({
247
+ }) => /* @__PURE__ */ e(v, { sx: {
248
+ position: "relative"
249
+ }, children: /* @__PURE__ */ e(fe, { height: "500px", defaultLanguage: "javascript", value: t, onChange: (i) => {
250
+ i && n(i);
251
+ }, theme: "vs-dark", options: {
252
+ minimap: {
253
+ enabled: !1
254
+ }
255
+ } }) }), Y = J(({
953
256
  value: t,
954
257
  onChange: n,
955
- label: i,
956
- modalTitle: o,
957
- defaultValue: l,
958
- styles: s
959
- }, c) => {
960
- const [d, {
961
- setTrue: p,
962
- setFalse: v
963
- }] = rt(), [S, h] = lr(t), f = () => {
964
- v(), n(S);
965
- }, z = () => {
966
- v(), h(t);
967
- }, q = () => {
968
- h(l);
258
+ label: r,
259
+ modalTitle: i,
260
+ defaultValue: s,
261
+ styles: o
262
+ }, a) => {
263
+ const [c, {
264
+ setTrue: u,
265
+ setFalse: g
266
+ }] = he(), [l, p] = Z(t), h = () => {
267
+ g(), n(l);
268
+ }, A = () => {
269
+ g(), p(t);
270
+ }, k = () => {
271
+ p(s);
969
272
  };
970
- return xe(() => {
971
- h(t);
972
- }, [t]), /* @__PURE__ */ b(N, {
973
- children: [/* @__PURE__ */ r(T, {
974
- variant: "filled",
975
- size: s.button.size,
976
- onClick: p,
977
- sx: {
978
- flexGrow: 1
979
- },
980
- children: i
981
- }), /* @__PURE__ */ r(ne, {
982
- size: 800,
983
- title: o,
984
- opened: d,
985
- onClose: v,
986
- closeOnClickOutside: !1,
987
- withCloseButton: !1,
988
- children: d && /* @__PURE__ */ b(ze, {
989
- children: [/* @__PURE__ */ r(pt, {
990
- value: S,
991
- onChange: h
992
- }), /* @__PURE__ */ b(O, {
993
- position: "apart",
994
- children: [/* @__PURE__ */ r(T, {
995
- onClick: q,
996
- color: "red",
997
- leftIcon: /* @__PURE__ */ r(Jr, {
998
- size: 20
999
- }),
1000
- children: "Rest"
1001
- }), /* @__PURE__ */ b(O, {
1002
- position: "right",
1003
- children: [/* @__PURE__ */ r(T, {
1004
- onClick: z,
1005
- variant: "subtle",
1006
- children: "Cancel"
1007
- }), /* @__PURE__ */ r(T, {
1008
- onClick: f,
1009
- children: "OK"
1010
- })]
1011
- })]
1012
- })]
1013
- })
1014
- })]
1015
- });
1016
- }), le = {
273
+ return G(() => {
274
+ p(t);
275
+ }, [t]), /* @__PURE__ */ d(C, { children: [
276
+ /* @__PURE__ */ e(b, { variant: "filled", size: o.button.size, onClick: u, sx: {
277
+ flexGrow: 1
278
+ }, children: r }),
279
+ /* @__PURE__ */ e(R, { size: 800, title: i, opened: c, onClose: g, closeOnClickOutside: !1, withCloseButton: !1, children: c && /* @__PURE__ */ d(B, { children: [
280
+ /* @__PURE__ */ e(_e, { value: l, onChange: p }),
281
+ /* @__PURE__ */ d(w, { position: "apart", children: [
282
+ /* @__PURE__ */ e(b, { onClick: k, color: "red", leftIcon: /* @__PURE__ */ e(de, { size: 20 }), children: "Rest" }),
283
+ /* @__PURE__ */ d(w, { position: "right", children: [
284
+ /* @__PURE__ */ e(b, { onClick: A, variant: "subtle", children: "Cancel" }),
285
+ /* @__PURE__ */ e(b, { onClick: h, children: "OK" })
286
+ ] })
287
+ ] })
288
+ ] }) })
289
+ ] });
290
+ }), O = {
1017
291
  pre: ["function pre_process({ method, url, params, headers, data }, utils) {", " // your code goes here", " return { method, url, params, headers, data }", "}"].join(`
1018
292
  `),
1019
293
  post: ["function post_process(res, utils) {", " // your code goes here", " return data", "}"].join(`
1020
294
  `)
1021
295
  };
1022
- function gt({
296
+ function ye({
1023
297
  submit: t,
1024
- styles: n = X
298
+ styles: n = q
1025
299
  }) {
1026
300
  const {
1027
- control: i,
1028
- setValue: o,
1029
- handleSubmit: l
1030
- } = J({
301
+ control: r,
302
+ setValue: i,
303
+ handleSubmit: s
304
+ } = T({
1031
305
  defaultValues: {
1032
306
  type: "http",
1033
307
  key: "",
1034
308
  config: {
1035
309
  host: "",
1036
310
  processing: {
1037
- pre: le.pre,
1038
- post: le.post
311
+ pre: O.pre,
312
+ post: O.post
1039
313
  }
1040
314
  }
1041
315
  }
1042
316
  });
1043
- return /* @__PURE__ */ r(F, {
1044
- mx: "auto",
1045
- children: /* @__PURE__ */ b("form", {
1046
- onSubmit: l(t),
1047
- children: [/* @__PURE__ */ r(R, {
1048
- name: "key",
1049
- control: i,
1050
- render: ({
1051
- field: s
1052
- }) => /* @__PURE__ */ r(D, {
1053
- mb: n.spacing,
1054
- size: n.size,
1055
- required: !0,
1056
- label: "Name",
1057
- placeholder: "A unique name",
1058
- ...s
1059
- })
1060
- }), /* @__PURE__ */ r(Te, {
1061
- label: "Connection Info",
1062
- labelPosition: "center"
1063
- }), /* @__PURE__ */ r(R, {
1064
- name: "config.host",
1065
- control: i,
1066
- render: ({
1067
- field: s
1068
- }) => /* @__PURE__ */ r(D, {
1069
- mb: n.spacing,
1070
- size: n.size,
1071
- required: !0,
1072
- label: "Base URL",
1073
- sx: {
1074
- flexGrow: 1
1075
- },
1076
- ...s
1077
- })
1078
- }), /* @__PURE__ */ b(O, {
1079
- grow: !0,
1080
- children: [/* @__PURE__ */ r(R, {
1081
- name: "config.processing.pre",
1082
- control: i,
1083
- render: ({
1084
- field: s
1085
- }) => /* @__PURE__ */ r(cr, {
1086
- label: "Pre Processing",
1087
- modalTitle: "This function will run before sending the request (for scenarios like encryption)",
1088
- defaultValue: le.pre,
1089
- ...s,
1090
- styles: n
1091
- })
1092
- }), /* @__PURE__ */ r(R, {
1093
- name: "config.processing.post",
1094
- control: i,
1095
- render: ({
1096
- field: s
1097
- }) => /* @__PURE__ */ r(cr, {
1098
- label: "Post Processing",
1099
- modalTitle: "This function will run after sending the request (for scenarios like decryption)",
1100
- defaultValue: le.post,
1101
- ...s,
1102
- styles: n
1103
- })
1104
- })]
1105
- }), /* @__PURE__ */ r(O, {
1106
- position: "right",
1107
- mt: n.spacing,
1108
- children: /* @__PURE__ */ r(T, {
1109
- type: "submit",
1110
- size: n.button.size,
1111
- children: "Save"
1112
- })
1113
- })]
1114
- })
1115
- });
317
+ return /* @__PURE__ */ e(v, { mx: "auto", children: /* @__PURE__ */ d("form", { onSubmit: s(t), children: [
318
+ /* @__PURE__ */ e(m, { name: "key", control: r, render: ({
319
+ field: o
320
+ }) => /* @__PURE__ */ e(z, { mb: n.spacing, size: n.size, required: !0, label: "Name", placeholder: "A unique name", ...o }) }),
321
+ /* @__PURE__ */ e(V, { label: "Connection Info", labelPosition: "center" }),
322
+ /* @__PURE__ */ e(m, { name: "config.host", control: r, render: ({
323
+ field: o
324
+ }) => /* @__PURE__ */ e(z, { mb: n.spacing, size: n.size, required: !0, label: "Base URL", sx: {
325
+ flexGrow: 1
326
+ }, ...o }) }),
327
+ /* @__PURE__ */ d(w, { grow: !0, children: [
328
+ /* @__PURE__ */ e(m, { name: "config.processing.pre", control: r, render: ({
329
+ field: o
330
+ }) => /* @__PURE__ */ e(Y, { label: "Pre Processing", modalTitle: "This function will run before sending the request (for scenarios like encryption)", defaultValue: O.pre, ...o, styles: n }) }),
331
+ /* @__PURE__ */ e(m, { name: "config.processing.post", control: r, render: ({
332
+ field: o
333
+ }) => /* @__PURE__ */ e(Y, { label: "Post Processing", modalTitle: "This function will run after sending the request (for scenarios like decryption)", defaultValue: O.post, ...o, styles: n }) })
334
+ ] }),
335
+ /* @__PURE__ */ e(w, { position: "right", mt: n.spacing, children: /* @__PURE__ */ e(b, { type: "submit", size: n.button.size, children: "Save" }) })
336
+ ] }) });
1116
337
  }
1117
- function ht({
338
+ function ke({
1118
339
  postSubmit: t,
1119
- styles: n = X
340
+ styles: n = q
1120
341
  }) {
1121
- const [i, o] = lr("postgresql"), l = async ({
1122
- type: d,
1123
- key: p,
1124
- config: v
342
+ const [r, i] = Z("postgresql"), s = async ({
343
+ type: c,
344
+ key: u,
345
+ config: g
1125
346
  }) => {
1126
- V({
347
+ _({
1127
348
  id: "for-creating",
1128
349
  title: "Pending",
1129
350
  message: "Adding data source...",
@@ -1131,1194 +352,782 @@ function ht({
1131
352
  });
1132
353
  try {
1133
354
  console.log({
1134
- type: d,
1135
- key: p,
1136
- config: v
1137
- }), await j.datasource.create(d, p, v), k({
355
+ type: c,
356
+ key: u,
357
+ config: g
358
+ }), await P.datasource.create(c, u, g), S({
1138
359
  id: "for-creating",
1139
360
  title: "Successful",
1140
361
  message: "Data source is added",
1141
362
  color: "green"
1142
363
  }), t();
1143
- } catch (S) {
1144
- k({
364
+ } catch (l) {
365
+ S({
1145
366
  id: "for-creating",
1146
367
  title: "Failed",
1147
- message: S.message,
368
+ message: l.message,
1148
369
  color: "red"
1149
370
  });
1150
371
  }
1151
- }, s = i === "postgresql" || i === "mysql", c = i === "http";
1152
- return /* @__PURE__ */ b(F, {
1153
- mx: "auto",
1154
- children: [/* @__PURE__ */ r(Yr, {
1155
- fullWidth: !0,
1156
- mb: n.spacing,
1157
- size: n.size,
1158
- data: [{
1159
- label: "PostgreSQL",
1160
- value: "postgresql"
1161
- }, {
1162
- label: "MySQL",
1163
- value: "mysql"
1164
- }, {
1165
- label: "HTTP",
1166
- value: "http"
1167
- }],
1168
- value: i,
1169
- onChange: (d) => o(d)
1170
- }), s && /* @__PURE__ */ r(ft, {
1171
- submit: l,
1172
- styles: n,
1173
- type: i
1174
- }), c && /* @__PURE__ */ r(gt, {
1175
- submit: l,
1176
- styles: n
1177
- })]
1178
- });
372
+ }, o = r === "postgresql" || r === "mysql", a = r === "http";
373
+ return /* @__PURE__ */ d(v, { mx: "auto", children: [
374
+ /* @__PURE__ */ e(oe, { fullWidth: !0, mb: n.spacing, size: n.size, data: [{
375
+ label: "PostgreSQL",
376
+ value: "postgresql"
377
+ }, {
378
+ label: "MySQL",
379
+ value: "mysql"
380
+ }, {
381
+ label: "HTTP",
382
+ value: "http"
383
+ }], value: r, onChange: (c) => i(c) }),
384
+ o && /* @__PURE__ */ e(Ce, { submit: s, styles: n, type: r }),
385
+ a && /* @__PURE__ */ e(ye, { submit: s, styles: n })
386
+ ] });
1179
387
  }
1180
- function mt({
388
+ function De({
1181
389
  onSuccess: t,
1182
- styles: n = X
390
+ styles: n = q
1183
391
  }) {
1184
- const [i, o] = H.useState(!1), l = () => o(!0), s = () => o(!1);
1185
- return /* @__PURE__ */ b(N, {
1186
- children: [/* @__PURE__ */ r(ne, {
1187
- overflow: "inside",
1188
- opened: i,
1189
- onClose: () => o(!1),
1190
- title: "Add a data source",
1191
- trapFocus: !0,
1192
- onDragStart: (d) => {
1193
- d.stopPropagation();
1194
- },
1195
- children: /* @__PURE__ */ r(ht, {
1196
- postSubmit: () => {
1197
- t(), s();
1198
- },
1199
- styles: n
1200
- })
1201
- }), /* @__PURE__ */ r(T, {
1202
- size: n.button.size,
1203
- onClick: l,
1204
- leftIcon: /* @__PURE__ */ r(De, {
1205
- size: 20
1206
- }),
1207
- children: "Add a Data Source"
1208
- })]
1209
- });
392
+ const [r, i] = F.useState(!1), s = () => i(!0), o = () => i(!1);
393
+ return /* @__PURE__ */ d(C, { children: [
394
+ /* @__PURE__ */ e(R, { overflow: "inside", opened: r, onClose: () => i(!1), title: "Add a data source", trapFocus: !0, onDragStart: (c) => {
395
+ c.stopPropagation();
396
+ }, children: /* @__PURE__ */ e(ke, { postSubmit: () => {
397
+ t(), o();
398
+ }, styles: n }) }),
399
+ /* @__PURE__ */ e(b, { size: n.button.size, onClick: s, leftIcon: /* @__PURE__ */ e(Q, { size: 20 }), children: "Add a Data Source" })
400
+ ] });
1210
401
  }
1211
- const bt = (t) => t.replace(/([^:])(\/\/+)/g, "$1/");
1212
- function vt(t) {
1213
- xe(() => {
1214
- if (Ee.__getMonacoInstance())
402
+ const Te = (t) => t.replace(/([^:])(\/\/+)/g, "$1/");
403
+ function qe(t) {
404
+ G(() => {
405
+ if (U.__getMonacoInstance())
1215
406
  return;
1216
407
  console.log("loading monaco for @devtable/settings-form");
1217
- const i = bt(t);
1218
- Ee.config({ paths: { vs: i } }), Ee.init().then((o) => console.log("monaco instance:", o));
408
+ const r = Te(t);
409
+ U.config({
410
+ paths: {
411
+ vs: r
412
+ }
413
+ }), U.init().then((i) => console.log("monaco instance:", i));
1219
414
  }, []);
1220
415
  }
1221
- function Ce() {
1222
- return Ce = Object.assign ? Object.assign.bind() : function(t) {
416
+ function N() {
417
+ return N = Object.assign ? Object.assign.bind() : function(t) {
1223
418
  for (var n = 1; n < arguments.length; n++) {
1224
- var i = arguments[n];
1225
- for (var o in i)
1226
- Object.prototype.hasOwnProperty.call(i, o) && (t[o] = i[o]);
419
+ var r = arguments[n];
420
+ for (var i in r)
421
+ Object.prototype.hasOwnProperty.call(r, i) && (t[i] = r[i]);
1227
422
  }
1228
423
  return t;
1229
- }, Ce.apply(this, arguments);
424
+ }, N.apply(this, arguments);
1230
425
  }
1231
- function wt(t, n) {
426
+ function xe(t, n) {
1232
427
  if (t == null)
1233
428
  return {};
1234
- var i, o, l = function(c, d) {
1235
- if (c == null)
429
+ var r, i, s = function(a, c) {
430
+ if (a == null)
1236
431
  return {};
1237
- var p, v, S = {}, h = Object.keys(c);
1238
- for (v = 0; v < h.length; v++)
1239
- p = h[v], d.indexOf(p) >= 0 || (S[p] = c[p]);
1240
- return S;
432
+ var u, g, l = {}, p = Object.keys(a);
433
+ for (g = 0; g < p.length; g++)
434
+ u = p[g], c.indexOf(u) >= 0 || (l[u] = a[u]);
435
+ return l;
1241
436
  }(t, n);
1242
437
  if (Object.getOwnPropertySymbols) {
1243
- var s = Object.getOwnPropertySymbols(t);
1244
- for (o = 0; o < s.length; o++)
1245
- i = s[o], n.indexOf(i) >= 0 || Object.prototype.propertyIsEnumerable.call(t, i) && (l[i] = t[i]);
438
+ var o = Object.getOwnPropertySymbols(t);
439
+ for (i = 0; i < o.length; i++)
440
+ r = o[i], n.indexOf(r) >= 0 || Object.prototype.propertyIsEnumerable.call(t, r) && (s[r] = t[r]);
1246
441
  }
1247
- return l;
442
+ return s;
1248
443
  }
1249
- var St = ["size", "color", "stroke"];
1250
- function _t(t) {
1251
- var n = t.size, i = n === void 0 ? 24 : n, o = t.color, l = o === void 0 ? "currentColor" : o, s = t.stroke, c = s === void 0 ? 2 : s, d = wt(t, St);
1252
- return ee.createElement("svg", Ce({ xmlns: "http://www.w3.org/2000/svg", className: "icon icon-tabler icon-tabler-lock", width: i, height: i, viewBox: "0 0 24 24", strokeWidth: c, stroke: l, fill: "none", strokeLinecap: "round", strokeLinejoin: "round" }, d), ee.createElement("path", { stroke: "none", d: "M0 0h24v24H0z", fill: "none" }), ee.createElement("rect", { x: 5, y: 11, width: 14, height: 10, rx: 2 }), ee.createElement("circle", { cx: 12, cy: 16, r: 1 }), ee.createElement("path", { d: "M8 11v-4a4 4 0 0 1 8 0v4" }));
444
+ var Re = ["size", "color", "stroke"];
445
+ function Oe(t) {
446
+ var n = t.size, r = n === void 0 ? 24 : n, i = t.color, s = i === void 0 ? "currentColor" : i, o = t.stroke, a = o === void 0 ? 2 : o, c = xe(t, Re);
447
+ return x.createElement("svg", N({ xmlns: "http://www.w3.org/2000/svg", className: "icon icon-tabler icon-tabler-lock", width: r, height: r, viewBox: "0 0 24 24", strokeWidth: a, stroke: s, fill: "none", strokeLinecap: "round", strokeLinejoin: "round" }, c), x.createElement("path", { stroke: "none", d: "M0 0h24v24H0z", fill: "none" }), x.createElement("rect", { x: 5, y: 11, width: 14, height: 10, rx: 2 }), x.createElement("circle", { cx: 12, cy: 16, r: 1 }), x.createElement("path", { d: "M8 11v-4a4 4 0 0 1 8 0v4" }));
1253
448
  }
1254
- function yt({
449
+ function Ie({
1255
450
  id: t,
1256
451
  name: n,
1257
- isProtected: i,
1258
- onSuccess: o,
1259
- styles: l = X
452
+ isProtected: r,
453
+ onSuccess: i,
454
+ styles: s = q
1260
455
  }) {
1261
- const s = fe(), c = async () => {
1262
- !t || (V({
456
+ const o = j(), a = async () => {
457
+ t && (_({
1263
458
  id: "for-deleting",
1264
459
  title: "Pending",
1265
460
  message: "Deleting data source...",
1266
461
  loading: !0
1267
- }), await j.datasource.delete(t), k({
462
+ }), await P.datasource.delete(t), S({
1268
463
  id: "for-deleting",
1269
464
  title: "Successful",
1270
465
  message: `Data source [${n}] is deleted`,
1271
466
  color: "green"
1272
- }), o());
1273
- }, d = () => s.openConfirmModal({
467
+ }), i());
468
+ }, c = () => o.openConfirmModal({
1274
469
  title: "Delete this data source?",
1275
- children: /* @__PURE__ */ r(ue, {
1276
- size: l.size,
1277
- children: "This action won't affect your database."
1278
- }),
470
+ children: /* @__PURE__ */ e(I, { size: s.size, children: "This action won't affect your database." }),
1279
471
  labels: {
1280
472
  confirm: "Confirm",
1281
473
  cancel: "Cancel"
1282
474
  },
1283
475
  onCancel: () => console.log("Cancel"),
1284
- onConfirm: c
1285
- }), p = Kr();
1286
- return i ? /* @__PURE__ */ r(Br, {
1287
- withArrow: !0,
1288
- events: {
1289
- hover: !0,
1290
- touch: !1,
1291
- focus: !1
1292
- },
1293
- label: "This is a preset datasource, it can not be deleted",
1294
- children: /* @__PURE__ */ r("span", {
1295
- children: /* @__PURE__ */ r(_t, {
1296
- size: 16,
1297
- color: p.colors.gray[7]
1298
- })
1299
- })
1300
- }) : /* @__PURE__ */ r(T, {
1301
- size: l.button.size,
1302
- color: "red",
1303
- onClick: d,
1304
- leftIcon: /* @__PURE__ */ r(je, {
1305
- size: 20
1306
- }),
1307
- children: "Delete"
1308
- });
476
+ onConfirm: a
477
+ }), u = ae();
478
+ return r ? /* @__PURE__ */ e(se, { withArrow: !0, events: {
479
+ hover: !0,
480
+ touch: !1,
481
+ focus: !1
482
+ }, label: "This is a preset datasource, it can not be deleted", children: /* @__PURE__ */ e("span", { children: /* @__PURE__ */ e(Oe, { size: 16, color: u.colors.gray[7] }) }) }) : /* @__PURE__ */ e(b, { size: s.button.size, color: "red", onClick: c, leftIcon: /* @__PURE__ */ e(W, { size: 20 }), children: "Delete" });
1309
483
  }
1310
- function Wt({
1311
- styles: t = X,
484
+ function nt({
485
+ styles: t = q,
1312
486
  config: n
1313
487
  }) {
1314
- vt(n.monacoPath), pe(n);
488
+ qe(n.monacoPath), E(n);
1315
489
  const {
1316
- data: i = [],
1317
- loading: o,
1318
- refresh: l
1319
- } = G(async () => {
490
+ data: r = [],
491
+ loading: i,
492
+ refresh: s
493
+ } = D(async () => {
1320
494
  const {
1321
- data: s
1322
- } = await j.datasource.list();
1323
- return s;
495
+ data: o
496
+ } = await P.datasource.list();
497
+ return o;
1324
498
  }, {
1325
499
  refreshDeps: []
1326
500
  });
1327
- return /* @__PURE__ */ b(N, {
1328
- children: [/* @__PURE__ */ r(O, {
1329
- pt: t.spacing,
1330
- position: "right",
1331
- children: /* @__PURE__ */ r(mt, {
1332
- onSuccess: l
1333
- })
1334
- }), /* @__PURE__ */ b(F, {
1335
- mt: t.spacing,
1336
- sx: {
1337
- position: "relative"
1338
- },
1339
- children: [/* @__PURE__ */ r(Oe, {
1340
- visible: o
1341
- }), /* @__PURE__ */ b(Ae, {
1342
- horizontalSpacing: t.spacing,
1343
- verticalSpacing: t.spacing,
1344
- fontSize: t.size,
1345
- highlightOnHover: !0,
1346
- children: [/* @__PURE__ */ r("thead", {
1347
- children: /* @__PURE__ */ b("tr", {
1348
- children: [/* @__PURE__ */ r("th", {
1349
- children: "Type"
1350
- }), /* @__PURE__ */ r("th", {
1351
- children: "Name"
1352
- }), /* @__PURE__ */ r("th", {
1353
- children: "Action"
1354
- })]
1355
- })
1356
- }), /* @__PURE__ */ r("tbody", {
1357
- children: i.map(({
1358
- id: s,
1359
- key: c,
1360
- type: d,
1361
- is_preset: p
1362
- }) => /* @__PURE__ */ b("tr", {
1363
- children: [/* @__PURE__ */ r("td", {
1364
- width: 200,
1365
- children: d
1366
- }), /* @__PURE__ */ r("td", {
1367
- children: c
1368
- }), /* @__PURE__ */ r("td", {
1369
- width: 200,
1370
- children: /* @__PURE__ */ r(O, {
1371
- position: "left",
1372
- children: /* @__PURE__ */ r(yt, {
1373
- isProtected: p,
1374
- id: s,
1375
- name: c,
1376
- onSuccess: l
1377
- })
1378
- })
1379
- })]
1380
- }, c))
1381
- })]
1382
- })]
1383
- })]
1384
- });
501
+ return /* @__PURE__ */ d(C, { children: [
502
+ /* @__PURE__ */ e(w, { pt: t.spacing, position: "right", children: /* @__PURE__ */ e(De, { onSuccess: s }) }),
503
+ /* @__PURE__ */ d(v, { mt: t.spacing, sx: {
504
+ position: "relative"
505
+ }, children: [
506
+ /* @__PURE__ */ e(H, { visible: i }),
507
+ /* @__PURE__ */ d($, { horizontalSpacing: t.spacing, verticalSpacing: t.spacing, fontSize: t.size, highlightOnHover: !0, children: [
508
+ /* @__PURE__ */ e("thead", { children: /* @__PURE__ */ d("tr", { children: [
509
+ /* @__PURE__ */ e("th", { children: "Type" }),
510
+ /* @__PURE__ */ e("th", { children: "Name" }),
511
+ /* @__PURE__ */ e("th", { children: "Action" })
512
+ ] }) }),
513
+ /* @__PURE__ */ e("tbody", { children: r.map(({
514
+ id: o,
515
+ key: a,
516
+ type: c,
517
+ is_preset: u
518
+ }) => /* @__PURE__ */ d("tr", { children: [
519
+ /* @__PURE__ */ e("td", { width: 200, children: c }),
520
+ /* @__PURE__ */ e("td", { children: a }),
521
+ /* @__PURE__ */ e("td", { width: 200, children: /* @__PURE__ */ e(w, { position: "left", children: /* @__PURE__ */ e(Ie, { isProtected: u, id: o, name: a, onSuccess: s }) }) })
522
+ ] }, a)) })
523
+ ] })
524
+ ] })
525
+ ] });
1385
526
  }
1386
- const Rt = ke(({
527
+ const Le = J(({
1387
528
  label: t,
1388
529
  value: n,
1389
- description: i,
1390
- ...o
1391
- }, l) => /* @__PURE__ */ b(ze, {
1392
- spacing: 2,
1393
- ref: l,
1394
- ...o,
1395
- children: [/* @__PURE__ */ r(ue, {
1396
- size: "sm",
1397
- children: t
1398
- }), /* @__PURE__ */ r(ue, {
1399
- size: "xs",
1400
- color: "dimmed",
1401
- className: "role-description",
1402
- children: i
1403
- })]
1404
- })), Ie = ke(({
530
+ description: r,
531
+ ...i
532
+ }, s) => /* @__PURE__ */ d(B, { spacing: 2, ref: s, ...i, children: [
533
+ /* @__PURE__ */ e(I, { size: "sm", children: t }),
534
+ /* @__PURE__ */ e(I, { size: "xs", color: "dimmed", className: "role-description", children: r })
535
+ ] })), X = J(({
1405
536
  styles: t,
1406
537
  value: n,
1407
- onChange: i
1408
- }, o) => {
538
+ onChange: r
539
+ }, i) => {
1409
540
  const {
1410
- data: l = [],
1411
- loading: s
1412
- } = G(async () => (await j.role.list()).map((d) => ({
1413
- label: d.name,
1414
- value: d.id,
1415
- description: d.description,
1416
- disabled: d.id === 50
541
+ data: s = [],
542
+ loading: o
543
+ } = D(async () => (await P.role.list()).map((c) => ({
544
+ label: c.name,
545
+ value: c.id,
546
+ description: c.description,
547
+ disabled: c.id === 50
548
+ // SUPERADMIN
1417
549
  })), {
1418
550
  refreshDeps: []
1419
551
  });
1420
- return /* @__PURE__ */ r(Gr, {
1421
- ref: o,
1422
- mb: t.spacing,
1423
- size: t.size,
1424
- required: !0,
1425
- label: "Role",
1426
- itemComponent: Rt,
1427
- data: l,
1428
- disabled: s,
1429
- styles: () => ({
1430
- item: {
1431
- "&[data-selected]": {
1432
- "&, &:hover": {
1433
- ".role-description": {
1434
- color: "rgba(255,255,255,.8)"
552
+ return /* @__PURE__ */ e(
553
+ ce,
554
+ {
555
+ ref: i,
556
+ mb: t.spacing,
557
+ size: t.size,
558
+ required: !0,
559
+ label: "Role",
560
+ itemComponent: Le,
561
+ data: s,
562
+ disabled: o,
563
+ styles: () => ({
564
+ item: {
565
+ "&[data-selected]": {
566
+ "&, &:hover": {
567
+ ".role-description": {
568
+ color: "rgba(255,255,255,.8)"
569
+ }
1435
570
  }
1436
571
  }
1437
572
  }
1438
- }
1439
- }),
1440
- value: n,
1441
- onChange: i
1442
- });
1443
- }), $ = {
573
+ }),
574
+ value: n,
575
+ onChange: r
576
+ }
577
+ );
578
+ }), y = {
1444
579
  size: "sm",
1445
580
  spacing: "md",
1446
581
  button: {
1447
582
  size: "xs"
1448
583
  }
1449
584
  };
1450
- function Pt({
585
+ function Fe({
1451
586
  postSubmit: t,
1452
- styles: n = $,
1453
- initialRoleID: i
587
+ styles: n = y,
588
+ initialRoleID: r
1454
589
  }) {
1455
590
  const {
1456
- control: o,
1457
- handleSubmit: l
1458
- } = J({
591
+ control: i,
592
+ handleSubmit: s
593
+ } = T({
1459
594
  defaultValues: {
1460
595
  name: "",
1461
596
  email: "",
1462
- role_id: i,
597
+ role_id: r,
1463
598
  password: ""
1464
599
  }
1465
600
  });
1466
- return /* @__PURE__ */ r(F, {
1467
- mx: "auto",
1468
- children: /* @__PURE__ */ b("form", {
1469
- onSubmit: l(async ({
1470
- name: c,
1471
- email: d,
1472
- password: p,
1473
- role_id: v
1474
- }) => {
1475
- try {
1476
- V({
1477
- id: "for-creating",
1478
- title: "Pending",
1479
- message: "Adding account...",
1480
- loading: !0
1481
- }), await j.account.create(c, d, p, v), k({
1482
- id: "for-creating",
1483
- title: "Successful",
1484
- message: "Account is added",
1485
- color: "green"
1486
- }), t();
1487
- } catch (S) {
1488
- k({
1489
- id: "for-creating",
1490
- title: "Failed",
1491
- message: S.message,
1492
- color: "red"
1493
- });
1494
- }
1495
- }),
1496
- children: [/* @__PURE__ */ r(R, {
1497
- name: "name",
1498
- control: o,
1499
- render: ({
1500
- field: c
1501
- }) => /* @__PURE__ */ r(D, {
1502
- mb: n.spacing,
1503
- size: n.size,
1504
- required: !0,
1505
- label: "Username",
1506
- ...c
1507
- })
1508
- }), /* @__PURE__ */ r(R, {
1509
- name: "email",
1510
- control: o,
1511
- render: ({
1512
- field: c
1513
- }) => /* @__PURE__ */ r(D, {
1514
- mb: n.spacing,
1515
- size: n.size,
1516
- required: !0,
1517
- label: "Email",
1518
- ...c
1519
- })
1520
- }), /* @__PURE__ */ r(R, {
1521
- name: "password",
1522
- control: o,
1523
- render: ({
1524
- field: c
1525
- }) => /* @__PURE__ */ r(de, {
1526
- mb: n.spacing,
1527
- size: n.size,
1528
- required: !0,
1529
- label: "Password",
1530
- description: "Password must be at least 8 characters long",
1531
- ...c
1532
- })
1533
- }), /* @__PURE__ */ r(R, {
1534
- name: "role_id",
1535
- control: o,
1536
- render: ({
1537
- field: c
1538
- }) => /* @__PURE__ */ r(Ie, {
1539
- styles: n,
1540
- ...c
1541
- })
1542
- }), /* @__PURE__ */ r(O, {
1543
- position: "right",
1544
- mt: n.spacing,
1545
- children: /* @__PURE__ */ r(T, {
1546
- type: "submit",
1547
- size: n.button.size,
1548
- children: "Save"
1549
- })
1550
- })]
1551
- })
1552
- });
601
+ return /* @__PURE__ */ e(v, { mx: "auto", children: /* @__PURE__ */ d("form", { onSubmit: s(async ({
602
+ name: a,
603
+ email: c,
604
+ password: u,
605
+ role_id: g
606
+ }) => {
607
+ try {
608
+ _({
609
+ id: "for-creating",
610
+ title: "Pending",
611
+ message: "Adding account...",
612
+ loading: !0
613
+ }), await P.account.create(a, c, u, g), S({
614
+ id: "for-creating",
615
+ title: "Successful",
616
+ message: "Account is added",
617
+ color: "green"
618
+ }), t();
619
+ } catch (l) {
620
+ S({
621
+ id: "for-creating",
622
+ title: "Failed",
623
+ message: l.message,
624
+ color: "red"
625
+ });
626
+ }
627
+ }), children: [
628
+ /* @__PURE__ */ e(m, { name: "name", control: i, render: ({
629
+ field: a
630
+ }) => /* @__PURE__ */ e(z, { mb: n.spacing, size: n.size, required: !0, label: "Username", ...a }) }),
631
+ /* @__PURE__ */ e(m, { name: "email", control: i, render: ({
632
+ field: a
633
+ }) => /* @__PURE__ */ e(z, { mb: n.spacing, size: n.size, required: !0, label: "Email", ...a }) }),
634
+ /* @__PURE__ */ e(m, { name: "password", control: i, render: ({
635
+ field: a
636
+ }) => /* @__PURE__ */ e(L, { mb: n.spacing, size: n.size, required: !0, label: "Password", description: "Password must be at least 8 characters long", ...a }) }),
637
+ /* @__PURE__ */ e(m, { name: "role_id", control: i, render: ({
638
+ field: a
639
+ }) => /* @__PURE__ */ e(X, { styles: n, ...a }) }),
640
+ /* @__PURE__ */ e(w, { position: "right", mt: n.spacing, children: /* @__PURE__ */ e(b, { type: "submit", size: n.button.size, children: "Save" }) })
641
+ ] }) });
1553
642
  }
1554
- function Et({
643
+ function je({
1555
644
  onSuccess: t,
1556
- styles: n = $,
1557
- initialRoleID: i
645
+ styles: n = y,
646
+ initialRoleID: r
1558
647
  }) {
1559
- const [o, l] = H.useState(!1), s = () => l(!0), c = () => l(!1);
1560
- return /* @__PURE__ */ b(N, {
1561
- children: [/* @__PURE__ */ r(ne, {
1562
- overflow: "inside",
1563
- opened: o,
1564
- onClose: () => l(!1),
1565
- title: "Add an Account",
1566
- trapFocus: !0,
1567
- onDragStart: (p) => {
1568
- p.stopPropagation();
1569
- },
1570
- children: /* @__PURE__ */ r(Pt, {
1571
- postSubmit: () => {
1572
- t(), c();
1573
- },
1574
- styles: n,
1575
- initialRoleID: i
1576
- })
1577
- }), /* @__PURE__ */ r(T, {
1578
- size: n.button.size,
1579
- onClick: s,
1580
- leftIcon: /* @__PURE__ */ r(De, {
1581
- size: 20
1582
- }),
1583
- children: "Add an Account"
1584
- })]
1585
- });
648
+ const [i, s] = F.useState(!1), o = () => s(!0), a = () => s(!1);
649
+ return /* @__PURE__ */ d(C, { children: [
650
+ /* @__PURE__ */ e(R, { overflow: "inside", opened: i, onClose: () => s(!1), title: "Add an Account", trapFocus: !0, onDragStart: (u) => {
651
+ u.stopPropagation();
652
+ }, children: /* @__PURE__ */ e(Fe, { postSubmit: () => {
653
+ t(), a();
654
+ }, styles: n, initialRoleID: r }) }),
655
+ /* @__PURE__ */ e(b, { size: n.button.size, onClick: o, leftIcon: /* @__PURE__ */ e(Q, { size: 20 }), children: "Add an Account" })
656
+ ] });
1586
657
  }
1587
- function Ct({
658
+ function Ee({
1588
659
  id: t,
1589
660
  name: n,
1590
- onSuccess: i,
1591
- styles: o = $
661
+ onSuccess: r,
662
+ styles: i = y
1592
663
  }) {
1593
- const l = fe(), s = async () => {
1594
- if (!!t) {
1595
- V({
664
+ const s = j(), o = async () => {
665
+ if (t) {
666
+ _({
1596
667
  id: "for-deleting",
1597
668
  title: "Pending",
1598
669
  message: "Deleting account...",
1599
670
  loading: !0
1600
671
  });
1601
672
  try {
1602
- await j.account.delete(t), k({
673
+ await P.account.delete(t), S({
1603
674
  id: "for-deleting",
1604
675
  title: "Successful",
1605
676
  message: `Account [${n}] is deleted`,
1606
677
  color: "green"
1607
- }), i();
1608
- } catch (d) {
1609
- k({
678
+ }), r();
679
+ } catch (c) {
680
+ S({
1610
681
  id: "for-deleting",
1611
682
  title: "Failed",
1612
- message: d.message,
683
+ message: c.message,
1613
684
  color: "red"
1614
685
  });
1615
686
  }
1616
687
  }
1617
- }, c = () => l.openConfirmModal({
688
+ }, a = () => s.openConfirmModal({
1618
689
  title: "Delete this account?",
1619
690
  labels: {
1620
691
  confirm: "Confirm",
1621
692
  cancel: "Cancel"
1622
693
  },
1623
694
  onCancel: () => console.log("Cancel"),
1624
- onConfirm: s
1625
- });
1626
- return /* @__PURE__ */ r(T, {
1627
- size: o.button.size,
1628
- color: "red",
1629
- onClick: c,
1630
- leftIcon: /* @__PURE__ */ r(je, {
1631
- size: 20
1632
- }),
1633
- children: "Delete"
695
+ onConfirm: o
1634
696
  });
697
+ return /* @__PURE__ */ e(b, { size: i.button.size, color: "red", onClick: a, leftIcon: /* @__PURE__ */ e(W, { size: 20 }), children: "Delete" });
1635
698
  }
1636
- function Tt({
699
+ function Me({
1637
700
  id: t,
1638
701
  name: n,
1639
- email: i,
1640
- role_id: o,
1641
- postSubmit: l,
1642
- styles: s = $
702
+ email: r,
703
+ role_id: i,
704
+ postSubmit: s,
705
+ styles: o = y
1643
706
  }) {
1644
707
  const {
1645
- control: c,
1646
- handleSubmit: d,
1647
- watch: p
1648
- } = J({
708
+ control: a,
709
+ handleSubmit: c,
710
+ watch: u
711
+ } = T({
1649
712
  defaultValues: {
1650
713
  name: n,
1651
- email: i,
1652
- role_id: o,
714
+ email: r,
715
+ role_id: i,
1653
716
  reset_password: !1,
1654
717
  new_password: ""
1655
718
  }
1656
- }), v = async ({
1657
- name: f,
1658
- email: z,
1659
- role_id: q,
1660
- reset_password: W,
1661
- new_password: me
719
+ }), g = async ({
720
+ name: h,
721
+ email: A,
722
+ role_id: k,
723
+ reset_password: te,
724
+ new_password: ne
1662
725
  }) => {
1663
726
  try {
1664
- V({
727
+ _({
1665
728
  id: "for-updating",
1666
729
  title: "Pending",
1667
730
  message: "Updating account...",
1668
731
  loading: !0
1669
- }), await j.account.edit({
732
+ }), await P.account.edit({
1670
733
  id: t,
1671
- name: f,
1672
- email: z,
1673
- role_id: q,
1674
- reset_password: W,
1675
- new_password: me
1676
- }), k({
734
+ name: h,
735
+ email: A,
736
+ role_id: k,
737
+ reset_password: te,
738
+ new_password: ne
739
+ }), S({
1677
740
  id: "for-updating",
1678
741
  title: "Successful",
1679
742
  message: "Account is updated",
1680
743
  color: "green"
1681
- }), l();
1682
- } catch (U) {
1683
- k({
744
+ }), s();
745
+ } catch (re) {
746
+ S({
1684
747
  id: "for-updating",
1685
748
  title: "Failed",
1686
- message: U.message,
749
+ message: re.message,
1687
750
  color: "red"
1688
751
  });
1689
752
  }
1690
- }, [S, h] = p(["reset_password", "new_password"]);
1691
- return /* @__PURE__ */ r(F, {
1692
- mx: "auto",
1693
- children: /* @__PURE__ */ b("form", {
1694
- onSubmit: d(v),
1695
- children: [/* @__PURE__ */ r(R, {
1696
- name: "name",
1697
- control: c,
1698
- render: ({
1699
- field: f
1700
- }) => /* @__PURE__ */ r(D, {
1701
- mb: s.spacing,
1702
- size: s.size,
1703
- required: !0,
1704
- label: "Username",
1705
- ...f
1706
- })
1707
- }), /* @__PURE__ */ r(R, {
1708
- name: "email",
1709
- control: c,
1710
- render: ({
1711
- field: f
1712
- }) => /* @__PURE__ */ r(D, {
1713
- mb: s.spacing,
1714
- size: s.size,
1715
- required: !0,
1716
- label: "Email",
1717
- ...f
1718
- })
1719
- }), /* @__PURE__ */ r(R, {
1720
- name: "role_id",
1721
- control: c,
1722
- render: ({
1723
- field: f
1724
- }) => /* @__PURE__ */ r(Ie, {
1725
- styles: s,
1726
- ...f
1727
- })
1728
- }), /* @__PURE__ */ r(Te, {
1729
- my: 20,
1730
- variant: "dashed",
1731
- label: "",
1732
- labelPosition: "center"
1733
- }), /* @__PURE__ */ r(R, {
1734
- name: "reset_password",
1735
- control: c,
1736
- render: ({
1737
- field: f
1738
- }) => /* @__PURE__ */ r(Hr, {
1739
- mb: s.spacing,
1740
- size: s.size,
1741
- label: "Reset password",
1742
- checked: f.value,
1743
- onChange: (z) => f.onChange(z.currentTarget.checked),
1744
- styles: {
1745
- label: {
1746
- verticalAlign: "middle"
1747
- }
1748
- }
1749
- })
1750
- }), S && /* @__PURE__ */ r(R, {
753
+ }, [l, p] = u(["reset_password", "new_password"]);
754
+ return /* @__PURE__ */ e(v, { mx: "auto", children: /* @__PURE__ */ d("form", { onSubmit: c(g), children: [
755
+ /* @__PURE__ */ e(m, { name: "name", control: a, render: ({
756
+ field: h
757
+ }) => /* @__PURE__ */ e(z, { mb: o.spacing, size: o.size, required: !0, label: "Username", ...h }) }),
758
+ /* @__PURE__ */ e(m, { name: "email", control: a, render: ({
759
+ field: h
760
+ }) => /* @__PURE__ */ e(z, { mb: o.spacing, size: o.size, required: !0, label: "Email", ...h }) }),
761
+ /* @__PURE__ */ e(m, { name: "role_id", control: a, render: ({
762
+ field: h
763
+ }) => /* @__PURE__ */ e(X, { styles: o, ...h }) }),
764
+ /* @__PURE__ */ e(V, { my: 20, variant: "dashed", label: "", labelPosition: "center" }),
765
+ /* @__PURE__ */ e(m, { name: "reset_password", control: a, render: ({
766
+ field: h
767
+ }) => /* @__PURE__ */ e(le, { mb: o.spacing, size: o.size, label: "Reset password", checked: h.value, onChange: (A) => h.onChange(A.currentTarget.checked), styles: {
768
+ label: {
769
+ verticalAlign: "middle"
770
+ }
771
+ } }) }),
772
+ l && /* @__PURE__ */ e(
773
+ m,
774
+ {
1751
775
  name: "new_password",
1752
- control: c,
776
+ control: a,
1753
777
  render: ({
1754
- field: f
1755
- }) => /* @__PURE__ */ r(de, {
1756
- autoComplete: "off",
1757
- mb: s.spacing,
1758
- size: s.size,
1759
- required: !0,
1760
- description: "Password must be at least 8 characters long",
1761
- label: "New Password",
1762
- ...f
1763
- })
1764
- }), /* @__PURE__ */ r(O, {
1765
- position: "right",
1766
- mt: s.spacing,
1767
- children: /* @__PURE__ */ r(T, {
1768
- type: "submit",
1769
- size: s.button.size,
1770
- children: "Submit"
1771
- })
1772
- })]
1773
- })
1774
- });
778
+ field: h
779
+ }) => /* @__PURE__ */ e(L, { autoComplete: "off", mb: o.spacing, size: o.size, required: !0, description: "Password must be at least 8 characters long", label: "New Password", ...h })
780
+ }
781
+ ),
782
+ /* @__PURE__ */ e(w, { position: "right", mt: o.spacing, children: /* @__PURE__ */ e(b, { type: "submit", size: o.button.size, children: "Submit" }) })
783
+ ] }) });
1775
784
  }
1776
- function zt({
785
+ function Ue({
1777
786
  account: t,
1778
787
  onSuccess: n,
1779
- styles: i = $
788
+ styles: r = y
1780
789
  }) {
1781
- const [o, l] = H.useState(!1), s = () => l(!0), c = () => l(!1), d = () => {
1782
- n(), c();
790
+ const [i, s] = F.useState(!1), o = () => s(!0), a = () => s(!1), c = () => {
791
+ n(), a();
1783
792
  };
1784
- return /* @__PURE__ */ b(N, {
1785
- children: [/* @__PURE__ */ r(ne, {
1786
- overflow: "inside",
1787
- opened: o,
1788
- onClose: () => l(!1),
1789
- title: `Editing ${t.name}`,
1790
- trapFocus: !0,
1791
- onDragStart: (p) => {
1792
- p.stopPropagation();
1793
- },
1794
- children: /* @__PURE__ */ r(Tt, {
1795
- ...t,
1796
- postSubmit: d,
1797
- styles: i
1798
- })
1799
- }), /* @__PURE__ */ r(T, {
1800
- size: i.button.size,
1801
- onClick: s,
1802
- leftIcon: /* @__PURE__ */ r(Xr, {
1803
- size: 20
1804
- }),
1805
- children: "Edit"
1806
- })]
1807
- });
793
+ return /* @__PURE__ */ d(C, { children: [
794
+ /* @__PURE__ */ e(R, { overflow: "inside", opened: i, onClose: () => s(!1), title: `Editing ${t.name}`, trapFocus: !0, onDragStart: (u) => {
795
+ u.stopPropagation();
796
+ }, children: /* @__PURE__ */ e(Me, { ...t, postSubmit: c, styles: r }) }),
797
+ /* @__PURE__ */ e(b, { size: r.button.size, onClick: o, leftIcon: /* @__PURE__ */ e(ue, { size: 20 }), children: "Edit" })
798
+ ] });
1808
799
  }
1809
- function Yt({
1810
- styles: t = $,
800
+ function rt({
801
+ styles: t = y,
1811
802
  config: n
1812
803
  }) {
1813
- var v, S;
1814
- pe(n);
804
+ var g;
805
+ E(n);
1815
806
  const {
1816
- data: i = [],
1817
- loading: o,
1818
- refresh: l
1819
- } = G(async () => {
807
+ data: r = [],
808
+ loading: i,
809
+ refresh: s
810
+ } = D(async () => {
1820
811
  const {
1821
- data: h
1822
- } = await j.account.list();
1823
- return h;
812
+ data: l
813
+ } = await P.account.list();
814
+ return l;
1824
815
  }, {
1825
816
  refreshDeps: []
1826
817
  }), {
1827
- data: s = [],
1828
- loading: c
1829
- } = G(async () => (await j.role.list()).map((f) => ({
1830
- label: f.name,
1831
- value: f.id,
1832
- description: f.description,
1833
- disabled: f.id === 50
818
+ data: o = [],
819
+ loading: a
820
+ } = D(async () => (await P.role.list()).map((p) => ({
821
+ label: p.name,
822
+ value: p.id,
823
+ description: p.description,
824
+ disabled: p.id === 50
825
+ // SUPERADMIN
1834
826
  })), {
1835
827
  refreshDeps: []
1836
- }), d = ur(() => s.reduce((h, f) => (h.set(f.value, f.label), h), /* @__PURE__ */ new Map()), [s]), p = (h) => {
1837
- var f;
1838
- return (f = d.get(h)) != null ? f : h;
1839
- };
1840
- return /* @__PURE__ */ b(N, {
1841
- children: [/* @__PURE__ */ r(O, {
1842
- pt: t.spacing,
1843
- position: "right",
1844
- children: /* @__PURE__ */ r(Et, {
1845
- onSuccess: l,
1846
- initialRoleID: (S = (v = s == null ? void 0 : s[0]) == null ? void 0 : v.value) != null ? S : 0
1847
- })
1848
- }), /* @__PURE__ */ b(F, {
1849
- mt: t.spacing,
1850
- sx: {
1851
- position: "relative"
1852
- },
1853
- children: [/* @__PURE__ */ r(Oe, {
1854
- visible: o || c
1855
- }), /* @__PURE__ */ b(Ae, {
1856
- horizontalSpacing: t.spacing,
1857
- verticalSpacing: t.spacing,
1858
- fontSize: t.size,
1859
- highlightOnHover: !0,
1860
- children: [/* @__PURE__ */ r("thead", {
1861
- children: /* @__PURE__ */ b("tr", {
1862
- children: [/* @__PURE__ */ r("th", {
1863
- children: "Username"
1864
- }), /* @__PURE__ */ r("th", {
1865
- children: "Email"
1866
- }), /* @__PURE__ */ r("th", {
1867
- children: "Role"
1868
- }), /* @__PURE__ */ r("th", {
1869
- children: "Action"
1870
- })]
1871
- })
1872
- }), /* @__PURE__ */ r("tbody", {
1873
- children: i.map((h) => {
1874
- const {
1875
- id: f,
1876
- name: z,
1877
- email: q,
1878
- role_id: W
1879
- } = h;
1880
- return /* @__PURE__ */ b("tr", {
1881
- children: [/* @__PURE__ */ r("td", {
1882
- width: 200,
1883
- children: z
1884
- }), /* @__PURE__ */ r("td", {
1885
- width: 200,
1886
- children: q
1887
- }), /* @__PURE__ */ r("td", {
1888
- width: 200,
1889
- children: p(W)
1890
- }), /* @__PURE__ */ r("td", {
1891
- width: 200,
1892
- children: /* @__PURE__ */ b(O, {
1893
- position: "left",
1894
- children: [/* @__PURE__ */ r(zt, {
1895
- account: h,
1896
- onSuccess: l
1897
- }), /* @__PURE__ */ r(Ct, {
1898
- id: f,
1899
- name: z,
1900
- onSuccess: l
1901
- })]
1902
- })
1903
- })]
1904
- }, f);
1905
- })
1906
- })]
1907
- })]
1908
- })]
1909
- });
828
+ }), c = ee(() => o.reduce((l, p) => (l.set(p.value, p.label), l), /* @__PURE__ */ new Map()), [o]), u = (l) => c.get(l) ?? l;
829
+ return /* @__PURE__ */ d(C, { children: [
830
+ /* @__PURE__ */ e(w, { pt: t.spacing, position: "right", children: /* @__PURE__ */ e(je, { onSuccess: s, initialRoleID: ((g = o == null ? void 0 : o[0]) == null ? void 0 : g.value) ?? 0 }) }),
831
+ /* @__PURE__ */ d(v, { mt: t.spacing, sx: {
832
+ position: "relative"
833
+ }, children: [
834
+ /* @__PURE__ */ e(H, { visible: i || a }),
835
+ /* @__PURE__ */ d($, { horizontalSpacing: t.spacing, verticalSpacing: t.spacing, fontSize: t.size, highlightOnHover: !0, children: [
836
+ /* @__PURE__ */ e("thead", { children: /* @__PURE__ */ d("tr", { children: [
837
+ /* @__PURE__ */ e("th", { children: "Username" }),
838
+ /* @__PURE__ */ e("th", { children: "Email" }),
839
+ /* @__PURE__ */ e("th", { children: "Role" }),
840
+ /* @__PURE__ */ e("th", { children: "Action" })
841
+ ] }) }),
842
+ /* @__PURE__ */ e("tbody", { children: r.map((l) => {
843
+ const {
844
+ id: p,
845
+ name: h,
846
+ email: A,
847
+ role_id: k
848
+ } = l;
849
+ return /* @__PURE__ */ d("tr", { children: [
850
+ /* @__PURE__ */ e("td", { width: 200, children: h }),
851
+ /* @__PURE__ */ e("td", { width: 200, children: A }),
852
+ /* @__PURE__ */ e("td", { width: 200, children: u(k) }),
853
+ /* @__PURE__ */ e("td", { width: 200, children: /* @__PURE__ */ d(w, { position: "left", children: [
854
+ /* @__PURE__ */ e(Ue, { account: l, onSuccess: s }),
855
+ /* @__PURE__ */ e(Ee, { id: p, name: h, onSuccess: s })
856
+ ] }) })
857
+ ] }, p);
858
+ }) })
859
+ ] })
860
+ ] })
861
+ ] });
1910
862
  }
1911
- function Ot({
863
+ function Ne({
1912
864
  postSubmit: t,
1913
- styles: n = $
865
+ styles: n = y
1914
866
  }) {
1915
867
  const {
1916
- control: i,
1917
- handleSubmit: o
1918
- } = J({
868
+ control: r,
869
+ handleSubmit: i
870
+ } = T({
1919
871
  defaultValues: {
1920
872
  name: "",
1921
873
  password: ""
1922
874
  }
1923
875
  });
1924
- return /* @__PURE__ */ r(F, {
1925
- mx: "auto",
1926
- children: /* @__PURE__ */ b("form", {
1927
- onSubmit: o(async ({
1928
- name: s,
1929
- password: c
1930
- }) => {
1931
- try {
1932
- V({
1933
- id: "for-login",
1934
- title: "Pending",
1935
- message: "Loggin in...",
1936
- loading: !0
1937
- });
1938
- const d = await j.account.login(s, c);
1939
- window.localStorage.setItem("token", d.token), k({
1940
- id: "for-login",
1941
- title: "Successful",
1942
- message: "Logged in",
1943
- color: "green"
1944
- }), t(d);
1945
- } catch (d) {
1946
- k({
1947
- id: "for-login",
1948
- title: "Login Failed",
1949
- message: d.message,
1950
- color: "red"
1951
- });
1952
- }
1953
- }),
1954
- children: [/* @__PURE__ */ r(R, {
1955
- name: "name",
1956
- control: i,
1957
- render: ({
1958
- field: s
1959
- }) => /* @__PURE__ */ r(D, {
1960
- mb: n.spacing,
1961
- size: n.size,
1962
- required: !0,
1963
- label: "Username",
1964
- ...s
1965
- })
1966
- }), /* @__PURE__ */ r(R, {
1967
- name: "password",
1968
- control: i,
1969
- render: ({
1970
- field: s
1971
- }) => /* @__PURE__ */ r(de, {
1972
- mb: n.spacing,
1973
- size: n.size,
1974
- required: !0,
1975
- label: "Password",
1976
- ...s
1977
- })
1978
- }), /* @__PURE__ */ r(O, {
1979
- position: "right",
1980
- mt: n.spacing,
1981
- children: /* @__PURE__ */ r(T, {
1982
- type: "submit",
1983
- size: n.button.size,
1984
- children: "Submit"
1985
- })
1986
- })]
1987
- })
1988
- });
876
+ return /* @__PURE__ */ e(v, { mx: "auto", children: /* @__PURE__ */ d("form", { onSubmit: i(async ({
877
+ name: o,
878
+ password: a
879
+ }) => {
880
+ try {
881
+ _({
882
+ id: "for-login",
883
+ title: "Pending",
884
+ message: "Loggin in...",
885
+ loading: !0
886
+ });
887
+ const c = await P.account.login(o, a);
888
+ window.localStorage.setItem("token", c.token), S({
889
+ id: "for-login",
890
+ title: "Successful",
891
+ message: "Logged in",
892
+ color: "green"
893
+ }), t(c);
894
+ } catch (c) {
895
+ S({
896
+ id: "for-login",
897
+ title: "Login Failed",
898
+ message: c.message,
899
+ color: "red"
900
+ });
901
+ }
902
+ }), children: [
903
+ /* @__PURE__ */ e(m, { name: "name", control: r, render: ({
904
+ field: o
905
+ }) => /* @__PURE__ */ e(z, { mb: n.spacing, size: n.size, required: !0, label: "Username", ...o }) }),
906
+ /* @__PURE__ */ e(m, { name: "password", control: r, render: ({
907
+ field: o
908
+ }) => /* @__PURE__ */ e(L, { mb: n.spacing, size: n.size, required: !0, label: "Password", ...o }) }),
909
+ /* @__PURE__ */ e(w, { position: "right", mt: n.spacing, children: /* @__PURE__ */ e(b, { type: "submit", size: n.button.size, children: "Submit" }) })
910
+ ] }) });
1989
911
  }
1990
- function Kt({
1991
- styles: t = $,
912
+ function it({
913
+ styles: t = y,
1992
914
  config: n,
1993
- onSuccess: i
915
+ onSuccess: r
1994
916
  }) {
1995
- return pe(n), /* @__PURE__ */ r(N, {
1996
- children: /* @__PURE__ */ r(F, {
1997
- mt: t.spacing,
1998
- sx: {
1999
- position: "relative"
2000
- },
2001
- children: /* @__PURE__ */ r(Ot, {
2002
- styles: t,
2003
- postSubmit: i
2004
- })
2005
- })
2006
- });
917
+ return E(n), /* @__PURE__ */ e(C, { children: /* @__PURE__ */ e(v, { mt: t.spacing, sx: {
918
+ position: "relative"
919
+ }, children: /* @__PURE__ */ e(Ne, { styles: t, postSubmit: r }) }) });
2007
920
  }
2008
- const he = {
921
+ const M = {
2009
922
  size: "sm",
2010
923
  spacing: "md",
2011
924
  button: {
2012
925
  size: "xs"
2013
926
  }
2014
927
  };
2015
- function At({
928
+ function Ke({
2016
929
  postSubmit: t,
2017
- styles: n = he,
2018
- initialRoleID: i
930
+ styles: n = M,
931
+ initialRoleID: r
2019
932
  }) {
2020
933
  const {
2021
- control: o,
2022
- handleSubmit: l
2023
- } = J({
934
+ control: i,
935
+ handleSubmit: s
936
+ } = T({
2024
937
  defaultValues: {
2025
938
  name: "",
2026
- role_id: i
939
+ role_id: r
2027
940
  }
2028
941
  });
2029
- return /* @__PURE__ */ r(F, {
2030
- mx: "auto",
2031
- children: /* @__PURE__ */ b("form", {
2032
- onSubmit: l(async ({
2033
- name: c,
2034
- role_id: d
2035
- }) => {
2036
- try {
2037
- V({
2038
- id: "for-creating",
2039
- title: "Pending",
2040
- message: "Adding API Key...",
2041
- loading: !0
2042
- });
2043
- const {
2044
- app_id: p,
2045
- app_secret: v
2046
- } = await j.api_key.create(c, d);
2047
- k({
2048
- id: "for-creating",
2049
- title: "Successful",
2050
- message: "API Key is added",
2051
- color: "green"
2052
- }), t(p, v);
2053
- } catch (p) {
2054
- k({
2055
- id: "for-creating",
2056
- title: "Failed",
2057
- message: p.message,
2058
- color: "red"
2059
- });
2060
- }
2061
- }),
2062
- children: [/* @__PURE__ */ r(R, {
2063
- name: "name",
2064
- control: o,
2065
- render: ({
2066
- field: c
2067
- }) => /* @__PURE__ */ r(D, {
2068
- mb: n.spacing,
2069
- size: n.size,
2070
- required: !0,
2071
- label: "Name",
2072
- ...c
2073
- })
2074
- }), /* @__PURE__ */ r(R, {
2075
- name: "role_id",
2076
- control: o,
2077
- render: ({
2078
- field: c
2079
- }) => /* @__PURE__ */ r(Ie, {
2080
- styles: n,
2081
- ...c
2082
- })
2083
- }), /* @__PURE__ */ r(O, {
2084
- position: "right",
2085
- mt: n.spacing,
2086
- children: /* @__PURE__ */ r(T, {
2087
- type: "submit",
2088
- size: n.button.size,
2089
- children: "Save"
2090
- })
2091
- })]
2092
- })
2093
- });
942
+ return /* @__PURE__ */ e(v, { mx: "auto", children: /* @__PURE__ */ d("form", { onSubmit: s(async ({
943
+ name: a,
944
+ role_id: c
945
+ }) => {
946
+ try {
947
+ _({
948
+ id: "for-creating",
949
+ title: "Pending",
950
+ message: "Adding API Key...",
951
+ loading: !0
952
+ });
953
+ const {
954
+ app_id: u,
955
+ app_secret: g
956
+ } = await P.api_key.create(a, c);
957
+ S({
958
+ id: "for-creating",
959
+ title: "Successful",
960
+ message: "API Key is added",
961
+ color: "green"
962
+ }), t(u, g);
963
+ } catch (u) {
964
+ S({
965
+ id: "for-creating",
966
+ title: "Failed",
967
+ message: u.message,
968
+ color: "red"
969
+ });
970
+ }
971
+ }), children: [
972
+ /* @__PURE__ */ e(m, { name: "name", control: i, render: ({
973
+ field: a
974
+ }) => /* @__PURE__ */ e(z, { mb: n.spacing, size: n.size, required: !0, label: "Name", ...a }) }),
975
+ /* @__PURE__ */ e(m, { name: "role_id", control: i, render: ({
976
+ field: a
977
+ }) => /* @__PURE__ */ e(X, { styles: n, ...a }) }),
978
+ /* @__PURE__ */ e(w, { position: "right", mt: n.spacing, children: /* @__PURE__ */ e(b, { type: "submit", size: n.button.size, children: "Save" }) })
979
+ ] }) });
2094
980
  }
2095
- function xt({
981
+ function Ve({
2096
982
  onSuccess: t,
2097
- styles: n = he,
2098
- initialRoleID: i
983
+ styles: n = M,
984
+ initialRoleID: r
2099
985
  }) {
2100
- const o = fe(), [l, s] = H.useState(!1), c = () => s(!0), d = () => s(!1);
2101
- return /* @__PURE__ */ b(N, {
2102
- children: [/* @__PURE__ */ r(ne, {
2103
- overflow: "inside",
2104
- opened: l,
2105
- onClose: () => s(!1),
2106
- title: "Add an API Key",
2107
- trapFocus: !0,
2108
- onDragStart: (v) => {
2109
- v.stopPropagation();
2110
- },
2111
- children: /* @__PURE__ */ r(At, {
2112
- postSubmit: (v, S) => {
2113
- d(), o.openModal({
2114
- title: "API Key is generated",
2115
- children: /* @__PURE__ */ b(ze, {
2116
- children: [/* @__PURE__ */ r(ue, {
2117
- color: "dimmed",
2118
- children: "Make sure you save it - you won't be able to access it again."
2119
- }), /* @__PURE__ */ r(D, {
2120
- defaultValue: v,
2121
- disabled: !0,
2122
- label: "APP ID",
2123
- styles: {
2124
- input: {
2125
- cursor: "text !important"
2126
- }
2127
- }
2128
- }), /* @__PURE__ */ r(D, {
2129
- defaultValue: S,
2130
- disabled: !0,
2131
- label: "APP Secret",
2132
- styles: {
2133
- input: {
2134
- cursor: "text !important"
2135
- }
2136
- }
2137
- }), /* @__PURE__ */ r(T, {
2138
- size: "sm",
2139
- onClick: () => {
2140
- nt();
2141
- },
2142
- children: "I've saved this API Key"
2143
- })]
2144
- }),
2145
- onClose: () => {
2146
- t();
986
+ const i = j(), [s, o] = F.useState(!1), a = () => o(!0), c = () => o(!1);
987
+ return /* @__PURE__ */ d(C, { children: [
988
+ /* @__PURE__ */ e(R, { overflow: "inside", opened: s, onClose: () => o(!1), title: "Add an API Key", trapFocus: !0, onDragStart: (g) => {
989
+ g.stopPropagation();
990
+ }, children: /* @__PURE__ */ e(Ke, { postSubmit: (g, l) => {
991
+ c(), i.openModal({
992
+ title: "API Key is generated",
993
+ children: /* @__PURE__ */ d(B, { children: [
994
+ /* @__PURE__ */ e(I, { color: "dimmed", children: "Make sure you save it - you won't be able to access it again." }),
995
+ /* @__PURE__ */ e(z, { defaultValue: g, disabled: !0, label: "APP ID", styles: {
996
+ input: {
997
+ cursor: "text !important"
2147
998
  }
2148
- });
2149
- },
2150
- styles: n,
2151
- initialRoleID: i
2152
- })
2153
- }), /* @__PURE__ */ r(T, {
2154
- size: n.button.size,
2155
- onClick: c,
2156
- leftIcon: /* @__PURE__ */ r(De, {
2157
- size: 20
2158
- }),
2159
- children: "Add an API Key"
2160
- })]
2161
- });
999
+ } }),
1000
+ /* @__PURE__ */ e(z, { defaultValue: l, disabled: !0, label: "APP Secret", styles: {
1001
+ input: {
1002
+ cursor: "text !important"
1003
+ }
1004
+ } }),
1005
+ /* @__PURE__ */ e(b, { size: "sm", onClick: () => {
1006
+ be();
1007
+ }, children: "I've saved this API Key" })
1008
+ ] }),
1009
+ onClose: () => {
1010
+ t();
1011
+ }
1012
+ });
1013
+ }, styles: n, initialRoleID: r }) }),
1014
+ /* @__PURE__ */ e(b, { size: n.button.size, onClick: a, leftIcon: /* @__PURE__ */ e(Q, { size: 20 }), children: "Add an API Key" })
1015
+ ] });
2162
1016
  }
2163
- function kt({
1017
+ function Be({
2164
1018
  id: t,
2165
1019
  name: n,
2166
- onSuccess: i,
2167
- styles: o = he
1020
+ onSuccess: r,
1021
+ styles: i = M
2168
1022
  }) {
2169
- const l = fe(), s = async () => {
2170
- if (!!t) {
2171
- V({
1023
+ const s = j(), o = async () => {
1024
+ if (t) {
1025
+ _({
2172
1026
  id: "for-deleting",
2173
1027
  title: "Pending",
2174
1028
  message: "Deleting API Key...",
2175
1029
  loading: !0
2176
1030
  });
2177
1031
  try {
2178
- await j.api_key.delete(t), k({
1032
+ await P.api_key.delete(t), S({
2179
1033
  id: "for-deleting",
2180
1034
  title: "Successful",
2181
1035
  message: `API Key [${n}] is deleted`,
2182
1036
  color: "green"
2183
- }), i();
2184
- } catch (d) {
2185
- k({
1037
+ }), r();
1038
+ } catch (c) {
1039
+ S({
2186
1040
  id: "for-deleting",
2187
1041
  title: "Failed",
2188
- message: d.message,
1042
+ message: c.message,
2189
1043
  color: "red"
2190
1044
  });
2191
1045
  }
2192
1046
  }
2193
- }, c = () => l.openConfirmModal({
1047
+ }, a = () => s.openConfirmModal({
2194
1048
  title: "Delete this api-key?",
2195
1049
  labels: {
2196
1050
  confirm: "Confirm",
2197
1051
  cancel: "Cancel"
2198
1052
  },
2199
1053
  onCancel: () => console.log("Cancel"),
2200
- onConfirm: s
2201
- });
2202
- return /* @__PURE__ */ r(T, {
2203
- size: o.button.size,
2204
- color: "red",
2205
- onClick: c,
2206
- leftIcon: /* @__PURE__ */ r(je, {
2207
- size: 20
2208
- }),
2209
- children: "Delete"
1054
+ onConfirm: o
2210
1055
  });
1056
+ return /* @__PURE__ */ e(b, { size: i.button.size, color: "red", onClick: a, leftIcon: /* @__PURE__ */ e(W, { size: 20 }), children: "Delete" });
2211
1057
  }
2212
- function Bt({
2213
- styles: t = he,
1058
+ function ot({
1059
+ styles: t = M,
2214
1060
  config: n
2215
1061
  }) {
2216
- var v, S;
2217
- pe(n);
1062
+ var g;
1063
+ E(n);
2218
1064
  const {
2219
- data: i = [],
2220
- loading: o,
2221
- refresh: l
2222
- } = G(async () => {
1065
+ data: r = [],
1066
+ loading: i,
1067
+ refresh: s
1068
+ } = D(async () => {
2223
1069
  const {
2224
- data: h
2225
- } = await j.api_key.list();
2226
- return h;
1070
+ data: l
1071
+ } = await P.api_key.list();
1072
+ return l;
2227
1073
  }, {
2228
1074
  refreshDeps: []
2229
1075
  }), {
2230
- data: s = [],
2231
- loading: c
2232
- } = G(async () => (await j.role.list()).map((f) => ({
2233
- label: f.name,
2234
- value: f.id,
2235
- description: f.description,
2236
- disabled: f.id === 50
1076
+ data: o = [],
1077
+ loading: a
1078
+ } = D(async () => (await P.role.list()).map((p) => ({
1079
+ label: p.name,
1080
+ value: p.id,
1081
+ description: p.description,
1082
+ disabled: p.id === 50
1083
+ // SUPERADMIN
2237
1084
  })), {
2238
1085
  refreshDeps: []
2239
- }), d = ur(() => s.reduce((h, f) => (h.set(f.value, f.label), h), /* @__PURE__ */ new Map()), [s]), p = (h) => {
2240
- var f;
2241
- return (f = d.get(h)) != null ? f : h;
2242
- };
2243
- return /* @__PURE__ */ b(N, {
2244
- children: [/* @__PURE__ */ r(O, {
2245
- pt: t.spacing,
2246
- position: "right",
2247
- children: /* @__PURE__ */ r(xt, {
2248
- onSuccess: l,
2249
- initialRoleID: (S = (v = s == null ? void 0 : s[0]) == null ? void 0 : v.value) != null ? S : 0
2250
- })
2251
- }), /* @__PURE__ */ b(F, {
2252
- mt: t.spacing,
2253
- sx: {
2254
- position: "relative"
2255
- },
2256
- children: [/* @__PURE__ */ r(Oe, {
2257
- visible: o || c
2258
- }), /* @__PURE__ */ b(Ae, {
2259
- horizontalSpacing: t.spacing,
2260
- verticalSpacing: t.spacing,
2261
- fontSize: t.size,
2262
- highlightOnHover: !0,
2263
- children: [/* @__PURE__ */ r("thead", {
2264
- children: /* @__PURE__ */ b("tr", {
2265
- children: [/* @__PURE__ */ r("th", {
2266
- children: "Name"
2267
- }), /* @__PURE__ */ r("th", {
2268
- children: "APP ID"
2269
- }), /* @__PURE__ */ r("th", {
2270
- children: "Role"
2271
- }), /* @__PURE__ */ r("th", {
2272
- children: "Action"
2273
- })]
2274
- })
2275
- }), /* @__PURE__ */ r("tbody", {
2276
- children: i.map((h) => {
2277
- const {
2278
- id: f,
2279
- name: z,
2280
- app_id: q,
2281
- role_id: W
2282
- } = h;
2283
- return /* @__PURE__ */ b("tr", {
2284
- children: [/* @__PURE__ */ r("td", {
2285
- width: 200,
2286
- children: z
2287
- }), /* @__PURE__ */ r("td", {
2288
- width: 200,
2289
- children: q
2290
- }), /* @__PURE__ */ r("td", {
2291
- width: 200,
2292
- children: p(W)
2293
- }), /* @__PURE__ */ r("td", {
2294
- width: 200,
2295
- children: /* @__PURE__ */ r(O, {
2296
- position: "left",
2297
- children: /* @__PURE__ */ r(kt, {
2298
- id: f,
2299
- name: z,
2300
- onSuccess: l
2301
- })
2302
- })
2303
- })]
2304
- }, f);
2305
- })
2306
- })]
2307
- })]
2308
- })]
2309
- });
1086
+ }), c = ee(() => o.reduce((l, p) => (l.set(p.value, p.label), l), /* @__PURE__ */ new Map()), [o]), u = (l) => c.get(l) ?? l;
1087
+ return /* @__PURE__ */ d(C, { children: [
1088
+ /* @__PURE__ */ e(w, { pt: t.spacing, position: "right", children: /* @__PURE__ */ e(Ve, { onSuccess: s, initialRoleID: ((g = o == null ? void 0 : o[0]) == null ? void 0 : g.value) ?? 0 }) }),
1089
+ /* @__PURE__ */ d(v, { mt: t.spacing, sx: {
1090
+ position: "relative"
1091
+ }, children: [
1092
+ /* @__PURE__ */ e(H, { visible: i || a }),
1093
+ /* @__PURE__ */ d($, { horizontalSpacing: t.spacing, verticalSpacing: t.spacing, fontSize: t.size, highlightOnHover: !0, children: [
1094
+ /* @__PURE__ */ e("thead", { children: /* @__PURE__ */ d("tr", { children: [
1095
+ /* @__PURE__ */ e("th", { children: "Name" }),
1096
+ /* @__PURE__ */ e("th", { children: "APP ID" }),
1097
+ /* @__PURE__ */ e("th", { children: "Role" }),
1098
+ /* @__PURE__ */ e("th", { children: "Action" })
1099
+ ] }) }),
1100
+ /* @__PURE__ */ e("tbody", { children: r.map((l) => {
1101
+ const {
1102
+ id: p,
1103
+ name: h,
1104
+ app_id: A,
1105
+ role_id: k
1106
+ } = l;
1107
+ return /* @__PURE__ */ d("tr", { children: [
1108
+ /* @__PURE__ */ e("td", { width: 200, children: h }),
1109
+ /* @__PURE__ */ e("td", { width: 200, children: A }),
1110
+ /* @__PURE__ */ e("td", { width: 200, children: u(k) }),
1111
+ /* @__PURE__ */ e("td", { width: 200, children: /* @__PURE__ */ e(w, { position: "left", children: /* @__PURE__ */ e(Be, { id: p, name: h, onSuccess: s }) }) })
1112
+ ] }, p);
1113
+ }) })
1114
+ ] })
1115
+ ] })
1116
+ ] });
2310
1117
  }
2311
- const Gt = () => import("./package.7070d91c.mjs").then(({ version: t }) => (console.log(`[@devtable/dashboard] version: ${t}`), t));
1118
+ const at = () => import("./package-f107145d.mjs").then(({
1119
+ version: t
1120
+ }) => (console.log(`[@devtable/dashboard] version: ${t}`), t));
2312
1121
  export {
2313
- Bt as APIKeyList,
2314
- Yt as AccountList,
2315
- xt as AddAPIKey,
2316
- Et as AddAccount,
2317
- mt as AddDataSource,
2318
- Wt as DataSourceList,
2319
- kt as DeleteAPIKey,
2320
- Ct as DeleteAccount,
2321
- yt as DeleteDataSource,
2322
- Kt as Login,
2323
- Gt as getVersion
1122
+ ot as APIKeyList,
1123
+ rt as AccountList,
1124
+ Ve as AddAPIKey,
1125
+ je as AddAccount,
1126
+ De as AddDataSource,
1127
+ nt as DataSourceList,
1128
+ Be as DeleteAPIKey,
1129
+ Ee as DeleteAccount,
1130
+ Ie as DeleteDataSource,
1131
+ it as Login,
1132
+ at as getVersion
2324
1133
  };