semaphor 0.0.63 → 0.0.65

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,4787 +0,0 @@
1
- import { J as T, L as Pe, b as w, c as js, u as je, j as e, M as bs, O as ys, P as z, Q as vs, R as Ns, U as Cs, V as Ss, W as ws, X as H, Y as de, Z as et, _ as _t, $ as Rt, a0 as Ht, a1 as $t, a2 as Pt, a3 as Bt, a4 as Hs, f as Z, a5 as Ve, a6 as st, a7 as Ze, a8 as Xe, T as ks, e as tt, g as zs, a9 as ke, aa as ze, ab as Fe, ac as Le, ad as _e, ae as Me, af as te, ag as Fs, G as o, ah as Ls, ai as Ms, aj as Os, w as at, v as nt, t as ue, ak as Gt, r as Kt, N as rt, s as Ut, al as Wt, B as Qt, am as it, an as Jt, S as Ds, z as Yt, n as $s, A as lt, ao as ms, ap as he, aq as ge, ar as Re, as as ts, at as ot, au as Zt, av as Xt, aw as ct, ax as ea, ay as sa, az as ta, aA as aa, aB as na, aC as xs, aD as ra, aE as ia, aF as qe, aG as ps, aH as we, aI as fs, aJ as Ps, aK as la, aL as oa, aM as ca, aN as da, aO as ha, aP as us, aQ as ua, aR as Bs, aS as ma, aT as Gs, aU as xa, aV as pa, aW as fa, aX as dt, l as ga, C as ja, E as Qe, d as ba, h as ya, aY as va, i as Na, o as Ca, aZ as Sa, m as wa, H as as, a_ as ka, a$ as ht, b0 as ut, b1 as Je, b2 as mt, b3 as Ye, b4 as Ks, b5 as ns, b6 as rs, b7 as is, b8 as xt, K as za, b9 as Fa, ba as La, bb as Ts, bc as Oe, bd as pt, be as Ma, bf as Oa, bg as Da, bh as Ta, bi as Aa, bj as Us, bk as Ea, bl as Ia, bm as qa, bn as Va, bo as _a, bp as Ra, bq as Ha, br as $a, bs as Ne, bt as B, bu as G, bv as As, bw as K, bx as Ws, by as Pa, bz as Ba, bA as Ga, bB as Ka, bC as Ua, bD as Wa, bE as Qa, bF as Ja, bG as Ya, bH as Za } from "./index-hj7e5VOs.js";
2
- import * as Qs from "react";
3
- import me, { useState as A, useMemo as Xa, useEffect as Y, useRef as He } from "react";
4
- /**
5
- * @license lucide-react v0.379.0 - ISC
6
- *
7
- * This source code is licensed under the ISC license.
8
- * See the LICENSE file in the root directory of this source tree.
9
- */
10
- const en = T("AreaChart", [
11
- ["path", { d: "M3 3v18h18", key: "1s2lah" }],
12
- ["path", { d: "M7 12v5h12V8l-5 5-4-4Z", key: "zxz28u" }]
13
- ]);
14
- /**
15
- * @license lucide-react v0.379.0 - ISC
16
- *
17
- * This source code is licensed under the ISC license.
18
- * See the LICENSE file in the root directory of this source tree.
19
- */
20
- const Es = T("BarChart4", [
21
- ["path", { d: "M3 3v18h18", key: "1s2lah" }],
22
- ["path", { d: "M13 17V9", key: "1fwyjl" }],
23
- ["path", { d: "M18 17V5", key: "sfb6ij" }],
24
- ["path", { d: "M8 17v-3", key: "17ska0" }]
25
- ]);
26
- /**
27
- * @license lucide-react v0.379.0 - ISC
28
- *
29
- * This source code is licensed under the ISC license.
30
- * See the LICENSE file in the root directory of this source tree.
31
- */
32
- const sn = T("Box", [
33
- [
34
- "path",
35
- {
36
- d: "M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z",
37
- key: "hh9hay"
38
- }
39
- ],
40
- ["path", { d: "m3.3 7 8.7 5 8.7-5", key: "g66t2b" }],
41
- ["path", { d: "M12 22V12", key: "d0xqtd" }]
42
- ]);
43
- /**
44
- * @license lucide-react v0.379.0 - ISC
45
- *
46
- * This source code is licensed under the ISC license.
47
- * See the LICENSE file in the root directory of this source tree.
48
- */
49
- const tn = T("CircleX", [
50
- ["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }],
51
- ["path", { d: "m15 9-6 6", key: "1uzhvr" }],
52
- ["path", { d: "m9 9 6 6", key: "z0biqf" }]
53
- ]);
54
- /**
55
- * @license lucide-react v0.379.0 - ISC
56
- *
57
- * This source code is licensed under the ISC license.
58
- * See the LICENSE file in the root directory of this source tree.
59
- */
60
- const an = T("Database", [
61
- ["ellipse", { cx: "12", cy: "5", rx: "9", ry: "3", key: "msslwz" }],
62
- ["path", { d: "M3 5V19A9 3 0 0 0 21 19V5", key: "1wlel7" }],
63
- ["path", { d: "M3 12A9 3 0 0 0 21 12", key: "mv7ke4" }]
64
- ]);
65
- /**
66
- * @license lucide-react v0.379.0 - ISC
67
- *
68
- * This source code is licensed under the ISC license.
69
- * See the LICENSE file in the root directory of this source tree.
70
- */
71
- const nn = T("EllipsisVertical", [
72
- ["circle", { cx: "12", cy: "12", r: "1", key: "41hilf" }],
73
- ["circle", { cx: "12", cy: "5", r: "1", key: "gxeob9" }],
74
- ["circle", { cx: "12", cy: "19", r: "1", key: "lyex9k" }]
75
- ]);
76
- /**
77
- * @license lucide-react v0.379.0 - ISC
78
- *
79
- * This source code is licensed under the ISC license.
80
- * See the LICENSE file in the root directory of this source tree.
81
- */
82
- const rn = T("Eraser", [
83
- [
84
- "path",
85
- {
86
- d: "m7 21-4.3-4.3c-1-1-1-2.5 0-3.4l9.6-9.6c1-1 2.5-1 3.4 0l5.6 5.6c1 1 1 2.5 0 3.4L13 21",
87
- key: "182aya"
88
- }
89
- ],
90
- ["path", { d: "M22 21H7", key: "t4ddhn" }],
91
- ["path", { d: "m5 11 9 9", key: "1mo9qw" }]
92
- ]);
93
- /**
94
- * @license lucide-react v0.379.0 - ISC
95
- *
96
- * This source code is licensed under the ISC license.
97
- * See the LICENSE file in the root directory of this source tree.
98
- */
99
- const ft = T("GanttChart", [
100
- ["path", { d: "M8 6h10", key: "9lnwnk" }],
101
- ["path", { d: "M6 12h9", key: "1g9pqf" }],
102
- ["path", { d: "M11 18h7", key: "c8dzvl" }]
103
- ]);
104
- /**
105
- * @license lucide-react v0.379.0 - ISC
106
- *
107
- * This source code is licensed under the ISC license.
108
- * See the LICENSE file in the root directory of this source tree.
109
- */
110
- const ln = T("Glasses", [
111
- ["circle", { cx: "6", cy: "15", r: "4", key: "vux9w4" }],
112
- ["circle", { cx: "18", cy: "15", r: "4", key: "18o8ve" }],
113
- ["path", { d: "M14 15a2 2 0 0 0-2-2 2 2 0 0 0-2 2", key: "1ag4bs" }],
114
- ["path", { d: "M2.5 13 5 7c.7-1.3 1.4-2 3-2", key: "1hm1gs" }],
115
- ["path", { d: "M21.5 13 19 7c-.7-1.3-1.5-2-3-2", key: "1r31ai" }]
116
- ]);
117
- /**
118
- * @license lucide-react v0.379.0 - ISC
119
- *
120
- * This source code is licensed under the ISC license.
121
- * See the LICENSE file in the root directory of this source tree.
122
- */
123
- const on = T("Hammer", [
124
- ["path", { d: "m15 12-8.373 8.373a1 1 0 1 1-3-3L12 9", key: "eefl8a" }],
125
- ["path", { d: "m18 15 4-4", key: "16gjal" }],
126
- [
127
- "path",
128
- {
129
- d: "m21.5 11.5-1.914-1.914A2 2 0 0 1 19 8.172V7l-2.26-2.26a6 6 0 0 0-4.202-1.756L9 2.96l.92.82A6.18 6.18 0 0 1 12 8.4V10l2 2h1.172a2 2 0 0 1 1.414.586L18.5 14.5",
130
- key: "b7pghm"
131
- }
132
- ]
133
- ]);
134
- /**
135
- * @license lucide-react v0.379.0 - ISC
136
- *
137
- * This source code is licensed under the ISC license.
138
- * See the LICENSE file in the root directory of this source tree.
139
- */
140
- const cn = T("Hash", [
141
- ["line", { x1: "4", x2: "20", y1: "9", y2: "9", key: "4lhtct" }],
142
- ["line", { x1: "4", x2: "20", y1: "15", y2: "15", key: "vyu0kd" }],
143
- ["line", { x1: "10", x2: "8", y1: "3", y2: "21", key: "1ggp8o" }],
144
- ["line", { x1: "16", x2: "14", y1: "3", y2: "21", key: "weycgp" }]
145
- ]);
146
- /**
147
- * @license lucide-react v0.379.0 - ISC
148
- *
149
- * This source code is licensed under the ISC license.
150
- * See the LICENSE file in the root directory of this source tree.
151
- */
152
- const dn = T("Home", [
153
- ["path", { d: "m3 9 9-7 9 7v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z", key: "y5dka4" }],
154
- ["polyline", { points: "9 22 9 12 15 12 15 22", key: "e2us08" }]
155
- ]);
156
- /**
157
- * @license lucide-react v0.379.0 - ISC
158
- *
159
- * This source code is licensed under the ISC license.
160
- * See the LICENSE file in the root directory of this source tree.
161
- */
162
- const hn = T("Key", [
163
- ["path", { d: "m15.5 7.5 2.3 2.3a1 1 0 0 0 1.4 0l2.1-2.1a1 1 0 0 0 0-1.4L19 4", key: "g0fldk" }],
164
- ["path", { d: "m21 2-9.6 9.6", key: "1j0ho8" }],
165
- ["circle", { cx: "7.5", cy: "15.5", r: "5.5", key: "yqb3hr" }]
166
- ]);
167
- /**
168
- * @license lucide-react v0.379.0 - ISC
169
- *
170
- * This source code is licensed under the ISC license.
171
- * See the LICENSE file in the root directory of this source tree.
172
- */
173
- const Is = T("LineChart", [
174
- ["path", { d: "M3 3v18h18", key: "1s2lah" }],
175
- ["path", { d: "m19 9-5 5-4-4-3 3", key: "2osh9i" }]
176
- ]);
177
- /**
178
- * @license lucide-react v0.379.0 - ISC
179
- *
180
- * This source code is licensed under the ISC license.
181
- * See the LICENSE file in the root directory of this source tree.
182
- */
183
- const un = T("ListEnd", [
184
- ["path", { d: "M16 12H3", key: "1a2rj7" }],
185
- ["path", { d: "M16 6H3", key: "1wxfjs" }],
186
- ["path", { d: "M10 18H3", key: "13769t" }],
187
- ["path", { d: "M21 6v10a2 2 0 0 1-2 2h-5", key: "ilrcs8" }],
188
- ["path", { d: "m16 16-2 2 2 2", key: "kkc6pm" }]
189
- ]);
190
- /**
191
- * @license lucide-react v0.379.0 - ISC
192
- *
193
- * This source code is licensed under the ISC license.
194
- * See the LICENSE file in the root directory of this source tree.
195
- */
196
- const mn = T("ListStart", [
197
- ["path", { d: "M16 12H3", key: "1a2rj7" }],
198
- ["path", { d: "M16 18H3", key: "12xzn7" }],
199
- ["path", { d: "M10 6H3", key: "lf8lx7" }],
200
- ["path", { d: "M21 18V8a2 2 0 0 0-2-2h-5", key: "1hghli" }],
201
- ["path", { d: "m16 8-2-2 2-2", key: "160uvd" }]
202
- ]);
203
- /**
204
- * @license lucide-react v0.379.0 - ISC
205
- *
206
- * This source code is licensed under the ISC license.
207
- * See the LICENSE file in the root directory of this source tree.
208
- */
209
- const xn = T("ListX", [
210
- ["path", { d: "M11 12H3", key: "51ecnj" }],
211
- ["path", { d: "M16 6H3", key: "1wxfjs" }],
212
- ["path", { d: "M16 18H3", key: "12xzn7" }],
213
- ["path", { d: "m19 10-4 4", key: "1tz659" }],
214
- ["path", { d: "m15 10 4 4", key: "1n7nei" }]
215
- ]);
216
- /**
217
- * @license lucide-react v0.379.0 - ISC
218
- *
219
- * This source code is licensed under the ISC license.
220
- * See the LICENSE file in the root directory of this source tree.
221
- */
222
- const $e = T("LoaderCircle", [
223
- ["path", { d: "M21 12a9 9 0 1 1-6.219-8.56", key: "13zald" }]
224
- ]);
225
- /**
226
- * @license lucide-react v0.379.0 - ISC
227
- *
228
- * This source code is licensed under the ISC license.
229
- * See the LICENSE file in the root directory of this source tree.
230
- */
231
- const pn = T("MessageSquareMore", [
232
- ["path", { d: "M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z", key: "1lielz" }],
233
- ["path", { d: "M8 10h.01", key: "19clt8" }],
234
- ["path", { d: "M12 10h.01", key: "1nrarc" }],
235
- ["path", { d: "M16 10h.01", key: "1m94wz" }]
236
- ]);
237
- /**
238
- * @license lucide-react v0.379.0 - ISC
239
- *
240
- * This source code is licensed under the ISC license.
241
- * See the LICENSE file in the root directory of this source tree.
242
- */
243
- const fn = T("Network", [
244
- ["rect", { x: "16", y: "16", width: "6", height: "6", rx: "1", key: "4q2zg0" }],
245
- ["rect", { x: "2", y: "16", width: "6", height: "6", rx: "1", key: "8cvhb9" }],
246
- ["rect", { x: "9", y: "2", width: "6", height: "6", rx: "1", key: "1egb70" }],
247
- ["path", { d: "M5 16v-3a1 1 0 0 1 1-1h12a1 1 0 0 1 1 1v3", key: "1jsf9p" }],
248
- ["path", { d: "M12 12V8", key: "2874zd" }]
249
- ]);
250
- /**
251
- * @license lucide-react v0.379.0 - ISC
252
- *
253
- * This source code is licensed under the ISC license.
254
- * See the LICENSE file in the root directory of this source tree.
255
- */
256
- const gt = T("Pencil", [
257
- ["path", { d: "M17 3a2.85 2.83 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5Z", key: "5qss01" }],
258
- ["path", { d: "m15 5 4 4", key: "1mk7zo" }]
259
- ]);
260
- /**
261
- * @license lucide-react v0.379.0 - ISC
262
- *
263
- * This source code is licensed under the ISC license.
264
- * See the LICENSE file in the root directory of this source tree.
265
- */
266
- const jt = T("PieChart", [
267
- ["path", { d: "M21.21 15.89A10 10 0 1 1 8 2.83", key: "k2fpak" }],
268
- ["path", { d: "M22 12A10 10 0 0 0 12 2v10z", key: "1rfc4y" }]
269
- ]);
270
- /**
271
- * @license lucide-react v0.379.0 - ISC
272
- *
273
- * This source code is licensed under the ISC license.
274
- * See the LICENSE file in the root directory of this source tree.
275
- */
276
- const gn = T("Play", [
277
- ["polygon", { points: "6 3 20 12 6 21 6 3", key: "1oa8hb" }]
278
- ]);
279
- /**
280
- * @license lucide-react v0.379.0 - ISC
281
- *
282
- * This source code is licensed under the ISC license.
283
- * See the LICENSE file in the root directory of this source tree.
284
- */
285
- const jn = T("Plug2", [
286
- ["path", { d: "M9 2v6", key: "17ngun" }],
287
- ["path", { d: "M15 2v6", key: "s7yy2p" }],
288
- ["path", { d: "M12 17v5", key: "bb1du9" }],
289
- ["path", { d: "M5 8h14", key: "pcz4l3" }],
290
- ["path", { d: "M6 11V8h12v3a6 6 0 1 1-12 0v0Z", key: "nd4hoy" }]
291
- ]);
292
- /**
293
- * @license lucide-react v0.379.0 - ISC
294
- *
295
- * This source code is licensed under the ISC license.
296
- * See the LICENSE file in the root directory of this source tree.
297
- */
298
- const bn = T("Save", [
299
- [
300
- "path",
301
- {
302
- d: "M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",
303
- key: "1c8476"
304
- }
305
- ],
306
- ["path", { d: "M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7", key: "1ydtos" }],
307
- ["path", { d: "M7 3v4a1 1 0 0 0 1 1h7", key: "t51u73" }]
308
- ]);
309
- /**
310
- * @license lucide-react v0.379.0 - ISC
311
- *
312
- * This source code is licensed under the ISC license.
313
- * See the LICENSE file in the root directory of this source tree.
314
- */
315
- const bt = T("ScatterChart", [
316
- ["circle", { cx: "7.5", cy: "7.5", r: ".5", fill: "currentColor", key: "kqv944" }],
317
- ["circle", { cx: "18.5", cy: "5.5", r: ".5", fill: "currentColor", key: "lysivs" }],
318
- ["circle", { cx: "11.5", cy: "11.5", r: ".5", fill: "currentColor", key: "byv1b8" }],
319
- ["circle", { cx: "7.5", cy: "16.5", r: ".5", fill: "currentColor", key: "nkw3mc" }],
320
- ["circle", { cx: "17.5", cy: "14.5", r: ".5", fill: "currentColor", key: "1gjh6j" }],
321
- ["path", { d: "M3 3v18h18", key: "1s2lah" }]
322
- ]);
323
- /**
324
- * @license lucide-react v0.379.0 - ISC
325
- *
326
- * This source code is licensed under the ISC license.
327
- * See the LICENSE file in the root directory of this source tree.
328
- */
329
- const yn = T("ShieldQuestion", [
330
- [
331
- "path",
332
- {
333
- d: "M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",
334
- key: "oel41y"
335
- }
336
- ],
337
- ["path", { d: "M9.1 9a3 3 0 0 1 5.82 1c0 2-3 3-3 3", key: "mhlwft" }],
338
- ["path", { d: "M12 17h.01", key: "p32p05" }]
339
- ]);
340
- /**
341
- * @license lucide-react v0.379.0 - ISC
342
- *
343
- * This source code is licensed under the ISC license.
344
- * See the LICENSE file in the root directory of this source tree.
345
- */
346
- const vn = T("Sigma", [
347
- ["path", { d: "M18 7V4H6l6 8-6 8h12v-3", key: "zis8ev" }]
348
- ]);
349
- /**
350
- * @license lucide-react v0.379.0 - ISC
351
- *
352
- * This source code is licensed under the ISC license.
353
- * See the LICENSE file in the root directory of this source tree.
354
- */
355
- const Nn = T("SwatchBook", [
356
- ["path", { d: "M11 17a4 4 0 0 1-8 0V5a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2Z", key: "1ldrpk" }],
357
- ["path", { d: "M16.7 13H19a2 2 0 0 1 2 2v4a2 2 0 0 1-2 2H7", key: "11i5po" }],
358
- ["path", { d: "M 7 17h0.01", key: "10821z" }],
359
- [
360
- "path",
361
- {
362
- d: "m11 8 2.3-2.3a2.4 2.4 0 0 1 3.404.004L18.6 7.6a2.4 2.4 0 0 1 .026 3.434L9.9 19.8",
363
- key: "o2gii7"
364
- }
365
- ]
366
- ]);
367
- /**
368
- * @license lucide-react v0.379.0 - ISC
369
- *
370
- * This source code is licensed under the ISC license.
371
- * See the LICENSE file in the root directory of this source tree.
372
- */
373
- const Cn = T("Tag", [
374
- [
375
- "path",
376
- {
377
- d: "M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z",
378
- key: "vktsd0"
379
- }
380
- ],
381
- ["circle", { cx: "7.5", cy: "7.5", r: ".5", fill: "currentColor", key: "kqv944" }]
382
- ]);
383
- /**
384
- * @license lucide-react v0.379.0 - ISC
385
- *
386
- * This source code is licensed under the ISC license.
387
- * See the LICENSE file in the root directory of this source tree.
388
- */
389
- const Sn = T("ToggleLeft", [
390
- ["rect", { width: "20", height: "12", x: "2", y: "6", rx: "6", ry: "6", key: "f2vt7d" }],
391
- ["circle", { cx: "8", cy: "12", r: "2", key: "1nvbw3" }]
392
- ]);
393
- /**
394
- * @license lucide-react v0.379.0 - ISC
395
- *
396
- * This source code is licensed under the ISC license.
397
- * See the LICENSE file in the root directory of this source tree.
398
- */
399
- const qs = T("Type", [
400
- ["polyline", { points: "4 7 4 4 20 4 20 7", key: "1nosan" }],
401
- ["line", { x1: "9", x2: "15", y1: "20", y2: "20", key: "swin9y" }],
402
- ["line", { x1: "12", x2: "12", y1: "4", y2: "20", key: "1tx1rr" }]
403
- ]);
404
- /**
405
- * @license lucide-react v0.379.0 - ISC
406
- *
407
- * This source code is licensed under the ISC license.
408
- * See the LICENSE file in the root directory of this source tree.
409
- */
410
- const wn = T("User", [
411
- ["path", { d: "M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2", key: "975kel" }],
412
- ["circle", { cx: "12", cy: "7", r: "4", key: "17ys0d" }]
413
- ]);
414
- function yt(s) {
415
- var n;
416
- return {
417
- ...s,
418
- sheets: (n = s == null ? void 0 : s.sheets) == null ? void 0 : n.map((t) => {
419
- var a;
420
- return {
421
- ...t,
422
- frames: (a = t.frames) == null ? void 0 : a.map((i) => {
423
- var h;
424
- return {
425
- ...i,
426
- cards: (h = i.cards) == null ? void 0 : h.map((r) => kn(r))
427
- };
428
- })
429
- };
430
- })
431
- };
432
- }
433
- function kn(s) {
434
- var n, t, a, i;
435
- return {
436
- ...s,
437
- cfg: {
438
- ...s.cfg,
439
- data: {
440
- ...(n = s.cfg) == null ? void 0 : n.data,
441
- labels: [],
442
- datasets: (i = (a = (t = s.cfg) == null ? void 0 : t.data) == null ? void 0 : a.datasets) == null ? void 0 : i.map((h) => ({
443
- ...h,
444
- data: []
445
- }))
446
- }
447
- },
448
- customCfg: zn(s.customCfg),
449
- // if customCfg is present, clean it, otherwise return null{
450
- data: []
451
- };
452
- }
453
- function zn(s) {
454
- var n, t;
455
- return s ? {
456
- ...s,
457
- data: {
458
- ...s == null ? void 0 : s.data,
459
- labels: [],
460
- datasets: (t = (n = s == null ? void 0 : s.data) == null ? void 0 : n.datasets) == null ? void 0 : t.map((a) => ({
461
- ...a,
462
- data: []
463
- }))
464
- }
465
- } : null;
466
- }
467
- async function Fn(s, n, t, a) {
468
- if (!a)
469
- return null;
470
- const i = JSON.stringify(n);
471
- return await Pe("https://semaphor.cloud/api/v1/lens", a, {
472
- name: s,
473
- template: i,
474
- filterValues: t,
475
- operation: "create"
476
- });
477
- }
478
- async function gs(s, n) {
479
- if (!n)
480
- return null;
481
- const { id: t, template: a, filterValues: i, isDefault: h, shared: r } = s;
482
- return await Pe("https://semaphor.cloud/api/v1/lens", n, {
483
- lensId: t,
484
- template: a,
485
- filterValues: i,
486
- isDefault: h,
487
- shared: r,
488
- operation: "update"
489
- });
490
- }
491
- async function Ln(s, n) {
492
- return n ? await Pe("https://semaphor.cloud/api/v1/lens", n, {
493
- operation: "delete",
494
- lensId: s
495
- }) : null;
496
- }
497
- function Mn() {
498
- const [s, n] = A(""), [t, a] = A(!1), i = w((y) => y.lenses), { setLenses: h, setSelectedLensId: r } = js(), [l, c] = A(!1), [m, u] = A(!1), g = w((y) => y.dashboard), j = w((y) => y.filterValues), { authToken: d } = je();
499
- async function x() {
500
- c(!0);
501
- const y = yt(
502
- g
503
- ), f = await Fn(
504
- s,
505
- y,
506
- j,
507
- d == null ? void 0 : d.accessToken
508
- );
509
- f && (h([...i || [], f]), r(f.id), u(!1)), c(!1);
510
- }
511
- return /* @__PURE__ */ e.jsxs(bs, { open: m, onOpenChange: u, children: [
512
- /* @__PURE__ */ e.jsx(ys, { asChild: !0, children: /* @__PURE__ */ e.jsxs(
513
- z,
514
- {
515
- variant: "secondary",
516
- className: "h-7 p-2",
517
- size: "sm",
518
- children: [
519
- /* @__PURE__ */ e.jsx(vs, { className: "mr-2 h-4 w-4", strokeWidth: 1.5 }),
520
- "Lens"
521
- ]
522
- }
523
- ) }),
524
- /* @__PURE__ */ e.jsxs(Ns, { className: "sm:max-w-[425px]", children: [
525
- /* @__PURE__ */ e.jsxs(Cs, { children: [
526
- /* @__PURE__ */ e.jsx(Ss, { children: "Create Lens" }),
527
- /* @__PURE__ */ e.jsx(ws, { children: "Lenses are private by default and are only visible to you." })
528
- ] }),
529
- /* @__PURE__ */ e.jsx("div", { className: "grid gap-4 py-4", children: /* @__PURE__ */ e.jsxs("div", { className: "grid grid-cols-8 items-center gap-4", children: [
530
- /* @__PURE__ */ e.jsx(H, { className: "text-right", children: "Name" }),
531
- /* @__PURE__ */ e.jsx(
532
- de,
533
- {
534
- value: s,
535
- onChange: (y) => {
536
- n(y.target.value);
537
- },
538
- id: "name",
539
- className: "col-span-7 focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0"
540
- }
541
- )
542
- ] }) }),
543
- t && /* @__PURE__ */ e.jsx("p", { className: "text-sm", children: "The lens name already exists. Use a differnet name." }),
544
- /* @__PURE__ */ e.jsx(et, { children: /* @__PURE__ */ e.jsx(
545
- z,
546
- {
547
- size: "sm",
548
- variant: "outline",
549
- type: "submit",
550
- onClick: x,
551
- disabled: l,
552
- children: l ? "Creating..." : "Add"
553
- }
554
- ) })
555
- ] })
556
- ] });
557
- }
558
- function On() {
559
- const [s, n] = A(!1), t = w((u) => u.lenses), a = w((u) => u.selectedLensId), { setLenses: i, setSelectedLensId: h } = js(), { authToken: r } = je();
560
- async function l(u) {
561
- h(u);
562
- }
563
- async function c(u) {
564
- if (await Ln(u, r == null ? void 0 : r.accessToken)) {
565
- const j = t == null ? void 0 : t.filter((d) => d.id !== u);
566
- i(j || []), h("original");
567
- }
568
- }
569
- async function m(u) {
570
- const g = t == null ? void 0 : t.map((x) => x.id === u.id ? {
571
- ...x,
572
- isDefault: !u.isDefault
573
- } : {
574
- ...x,
575
- isDefault: !1
576
- });
577
- i(g || []);
578
- const j = {
579
- ...u,
580
- isDefault: !u.isDefault
581
- };
582
- await gs(j, r == null ? void 0 : r.accessToken);
583
- const d = t == null ? void 0 : t.find((x) => x.isDefault);
584
- if (d && d.id !== u.id) {
585
- const x = {
586
- ...d,
587
- isDefault: !1
588
- };
589
- await gs(x, r == null ? void 0 : r.accessToken);
590
- }
591
- }
592
- return /* @__PURE__ */ e.jsxs(_t, { open: s, onOpenChange: n, children: [
593
- /* @__PURE__ */ e.jsx(Rt, { asChild: !0, children: /* @__PURE__ */ e.jsx(z, { variant: "ghost", className: "h-7 p-2", children: /* @__PURE__ */ e.jsx(ln, { className: "h-4 w-4", strokeWidth: 1.5 }) }) }),
594
- /* @__PURE__ */ e.jsxs(Ht, { align: "end", className: "w-60", children: [
595
- /* @__PURE__ */ e.jsx($t, { className: "px-3", children: "Lenses" }),
596
- /* @__PURE__ */ e.jsx(Pt, {}),
597
- /* @__PURE__ */ e.jsxs(
598
- Bt,
599
- {
600
- value: a,
601
- onValueChange: l,
602
- children: [
603
- /* @__PURE__ */ e.jsx(Hs, { value: "original", children: "Original" }),
604
- t == null ? void 0 : t.map((u) => /* @__PURE__ */ e.jsxs(
605
- Hs,
606
- {
607
- className: "group flex justify-between",
608
- value: u.id,
609
- children: [
610
- /* @__PURE__ */ e.jsx("p", { children: u.name }),
611
- /* @__PURE__ */ e.jsxs("span", { className: "flex items-center gap-3", children: [
612
- /* @__PURE__ */ e.jsx(
613
- dn,
614
- {
615
- onClick: (g) => {
616
- g.preventDefault(), m(u);
617
- },
618
- className: Z(
619
- "size-3.5 text-muted-foreground hover:cursor-pointer hover:text-foreground group-hover:visible",
620
- {
621
- invisible: !u.isDefault
622
- }
623
- ),
624
- strokeWidth: 1.5
625
- }
626
- ),
627
- /* @__PURE__ */ e.jsx(
628
- Ve,
629
- {
630
- onClick: (g) => {
631
- g.preventDefault(), c(u.id);
632
- },
633
- className: "invisible size-3.5 text-muted-foreground hover:cursor-pointer hover:text-foreground group-hover:visible",
634
- strokeWidth: 1.5
635
- }
636
- )
637
- ] })
638
- ]
639
- },
640
- u.id
641
- ))
642
- ]
643
- }
644
- )
645
- ] })
646
- ] });
647
- }
648
- function Dn() {
649
- const { authToken: s } = je(), n = w((S) => S.lenses), t = w((S) => S.selectedLensId), a = n == null ? void 0 : n.find((S) => S.id === t), i = w((S) => S.dashboard);
650
- w((S) => S.selectedSheetId);
651
- const h = w(
652
- (S) => S.isDashboardEditing
653
- ), [r, l] = A(!1), c = w((S) => S.filterValues), m = w((S) => S.isVisualEditing), u = w((S) => S.showFilters);
654
- w(
655
- (S) => S.showDashboardJSON
656
- );
657
- const g = w((S) => S.onSaveFunction), j = w(
658
- (S) => S.actions.setShowFilters
659
- ), { addFrame: d, setSelectedFrameId: x } = w(
660
- (S) => S.actions
661
- ), { getSelectedSheet: y, setIsDashboardEditing: f, setShowDashboardJSON: L } = w((S) => S.actions), O = y(), v = () => {
662
- if (!h || !O)
663
- return;
664
- const S = {
665
- id: Ze(),
666
- title: "Title",
667
- description: "Description",
668
- preferences: {
669
- onClickFilter: [
670
- {
671
- columnIndex: 0,
672
- expression: ""
673
- }
674
- ]
675
- },
676
- type: "bar",
677
- sql: "select COUNT(*) from YOUR_TABLE",
678
- data: []
679
- }, M = {
680
- id: Ze(),
681
- cards: [S],
682
- activeCardId: S.id
683
- };
684
- d(O.id, M), x(M.id);
685
- }, V = () => {
686
- f(!0);
687
- };
688
- async function _() {
689
- if (l(!0), !t || !a)
690
- return;
691
- const S = yt(
692
- i
693
- ), M = JSON.stringify(S), N = {
694
- ...a,
695
- template: M,
696
- filterValues: c
697
- };
698
- await gs(N, s == null ? void 0 : s.accessToken), Xe.success("Lens saved"), g == null || g(S), l(!1);
699
- }
700
- return m ? null : /* @__PURE__ */ e.jsxs(
701
- "div",
702
- {
703
- className: "flex items-center justify-between gap-2 border-b bg-muted/50 py-2 pl-3 pr-2",
704
- role: "dashboard-controls",
705
- children: [
706
- !m && /* @__PURE__ */ e.jsx("div", { className: "flex items-center gap-3", children: /* @__PURE__ */ e.jsx(H, { children: a == null ? void 0 : a.name }) }),
707
- /* @__PURE__ */ e.jsxs("div", { className: "flex gap-2", children: [
708
- h && !m && /* @__PURE__ */ e.jsx(Mn, {}),
709
- !m && /* @__PURE__ */ e.jsx(On, {}),
710
- h && !m && /* @__PURE__ */ e.jsxs(
711
- z,
712
- {
713
- variant: "secondary",
714
- className: "h-7 p-2",
715
- size: "sm",
716
- disabled: !h,
717
- onClick: v,
718
- children: [
719
- /* @__PURE__ */ e.jsx(vs, { className: "mr-2 h-4 w-4", strokeWidth: 1.5 }),
720
- "Frame"
721
- ]
722
- }
723
- ),
724
- !h && /* @__PURE__ */ e.jsx(
725
- z,
726
- {
727
- variant: "ghost",
728
- className: "h-7 p-2",
729
- onClick: V,
730
- size: "sm",
731
- children: /* @__PURE__ */ e.jsx(gt, { className: "h-4 w-4", strokeWidth: 1.5 })
732
- }
733
- ),
734
- h && !m && /* @__PURE__ */ e.jsx(
735
- z,
736
- {
737
- variant: "ghost",
738
- role: "close",
739
- className: "h-7 p-2",
740
- onClick: () => {
741
- f(!1), L(!1);
742
- },
743
- size: "sm",
744
- children: /* @__PURE__ */ e.jsx(Ve, { className: "h-4 w-4", strokeWidth: 1.5 })
745
- }
746
- ),
747
- h && !m && /* @__PURE__ */ e.jsx(
748
- z,
749
- {
750
- className: "h-7 p-2",
751
- variant: "ghost",
752
- disabled: r,
753
- onClick: _,
754
- size: "sm",
755
- children: /* @__PURE__ */ e.jsx(bn, { className: "h-4 w-4", strokeWidth: 1.5 })
756
- }
757
- ),
758
- !u && !m && h && /* @__PURE__ */ e.jsx(
759
- z,
760
- {
761
- className: "h-7 p-2",
762
- variant: "ghost",
763
- onClick: () => j(!0),
764
- size: "sm",
765
- children: /* @__PURE__ */ e.jsx(st, { className: "h-4 w-4", strokeWidth: 1.5 })
766
- }
767
- ),
768
- !m && h && !1,
769
- !m && !1
770
- ] })
771
- ]
772
- }
773
- );
774
- }
775
- function Ie({
776
- title: s,
777
- items: n,
778
- value: t,
779
- isLoading: a,
780
- isError: i,
781
- connectionTooltip: h,
782
- onChange: r,
783
- showNone: l = !1,
784
- className: c,
785
- showIcon: m = !0,
786
- disabled: u = !1
787
- }) {
788
- const g = a ? "Loading..." : i ? "Error" : t;
789
- function j() {
790
- if (s === "Connection")
791
- return /* @__PURE__ */ e.jsx(jn, { className: "size-4 rotate-90" });
792
- if (s === "Database")
793
- return /* @__PURE__ */ e.jsx(an, { className: "size-4" });
794
- if (s === "Schema")
795
- return /* @__PURE__ */ e.jsx(fn, { className: "size-4" });
796
- if (s === "Table")
797
- return /* @__PURE__ */ e.jsx(Fs, { className: "size-4" });
798
- if (s === "Model")
799
- return /* @__PURE__ */ e.jsx(sn, { className: "size-4" });
800
- }
801
- return /* @__PURE__ */ e.jsxs("div", { className: "flex items-center gap-2", children: [
802
- m && /* @__PURE__ */ e.jsx("div", { className: "shrink-0", children: h ? /* @__PURE__ */ e.jsxs(ks, { children: [
803
- /* @__PURE__ */ e.jsx(tt, { children: j() }),
804
- /* @__PURE__ */ e.jsx(zs, { className: "text-xs", align: "start", children: h })
805
- ] }) : j() }),
806
- /* @__PURE__ */ e.jsxs(ke, { disabled: u, value: g, onValueChange: r, children: [
807
- /* @__PURE__ */ e.jsx(
808
- ze,
809
- {
810
- className: Z(
811
- "h-9 w-full focus:ring-1 focus:ring-offset-0",
812
- c
813
- ),
814
- children: /* @__PURE__ */ e.jsx(
815
- Fe,
816
- {
817
- placeholder: a ? "Loading..." : i ? "Error" : `Select ${s}`
818
- }
819
- )
820
- }
821
- ),
822
- /* @__PURE__ */ e.jsx(Le, { children: /* @__PURE__ */ e.jsxs(_e, { children: [
823
- a ? /* @__PURE__ */ e.jsx(Me, { children: "Loading..." }) : /* @__PURE__ */ e.jsx(Me, { children: s }),
824
- /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
825
- l && /* @__PURE__ */ e.jsx(te, { value: "none", children: "None" }, "none"),
826
- n && n.map((d, x) => /* @__PURE__ */ e.jsx(te, { value: d.id, children: d.name }, x))
827
- ] }),
828
- (a || i) && /* @__PURE__ */ e.jsx(te, { value: g, children: g })
829
- ] }) })
830
- ] })
831
- ] });
832
- }
833
- function Tn({ column: s }) {
834
- const [n, t] = A(!1), a = o((d) => d.selectedTableName), i = o(
835
- (d) => d.selectedSchemaName
836
- ), h = o(
837
- (d) => d.selectedDatamodelId
838
- ), r = o((d) => d.sqlGen), { modelItems: l } = De(), c = o((d) => d.actions.setSqlGen), m = o((d) => d.actions.setCardSql), u = o((d) => d.actions.setRunSql);
839
- function g(d, x) {
840
- var O;
841
- const y = at(d, r, x), f = (O = l == null ? void 0 : l.find(
842
- (v) => v.id === h
843
- )) == null ? void 0 : O.name;
844
- c(y);
845
- const L = nt(
846
- y,
847
- ue(i || ""),
848
- ue(a),
849
- f
850
- );
851
- L && (m(L), u(!0)), t(!1);
852
- }
853
- function j() {
854
- return /* @__PURE__ */ e.jsxs("ul", { className: "text-xs", children: [
855
- /* @__PURE__ */ e.jsx(
856
- "li",
857
- {
858
- onClick: () => g(s, "COUNT"),
859
- className: "cursor-pointer p-1 px-3 transition-colors hover:bg-muted",
860
- children: "Count"
861
- }
862
- ),
863
- /* @__PURE__ */ e.jsx(
864
- "li",
865
- {
866
- onClick: () => g(s, "AVG"),
867
- className: "cursor-pointer p-1 px-3 transition-colors hover:bg-muted",
868
- children: "Avg"
869
- }
870
- ),
871
- /* @__PURE__ */ e.jsx(
872
- "li",
873
- {
874
- onClick: () => g(s, "SUM"),
875
- className: "cursor-pointer p-1 px-3 transition-colors hover:bg-muted",
876
- children: "Sum"
877
- }
878
- ),
879
- /* @__PURE__ */ e.jsx(
880
- "li",
881
- {
882
- onClick: () => g(s, "MAX"),
883
- className: "cursor-pointer p-1 px-3 transition-colors hover:bg-muted",
884
- children: "Max"
885
- }
886
- ),
887
- /* @__PURE__ */ e.jsx(
888
- "li",
889
- {
890
- onClick: () => g(s, "MIN"),
891
- className: "cursor-pointer p-1 px-3 transition-colors hover:bg-muted",
892
- children: "Min"
893
- }
894
- )
895
- ] });
896
- }
897
- return /* @__PURE__ */ e.jsxs(Ls, { openDelay: 0, open: n, onOpenChange: t, children: [
898
- /* @__PURE__ */ e.jsx(Ms, { asChild: !0, children: /* @__PURE__ */ e.jsx(nn, { className: "invisible size-3.5 cursor-pointer text-foreground/40 group-hover:visible" }) }),
899
- /* @__PURE__ */ e.jsx(
900
- Os,
901
- {
902
- align: "center",
903
- className: "w-20 rounded-md p-0 shadow-none",
904
- children: j()
905
- }
906
- )
907
- ] });
908
- }
909
- function vt({ column: s }) {
910
- return /* @__PURE__ */ e.jsxs(ks, { children: [
911
- /* @__PURE__ */ e.jsx(Gt, { asChild: !0, children: Kt.includes(s.data_type.toLowerCase()) ? (
912
- // <span className=" font-thin">T</span>
913
- /* @__PURE__ */ e.jsx(qs, { className: "size-3" })
914
- ) : rt.includes(s.data_type.toLowerCase()) ? (
915
- //
916
- /* @__PURE__ */ e.jsx(cn, { className: "size-3" })
917
- ) : Ut.includes(s.data_type.toLowerCase()) ? /* @__PURE__ */ e.jsx(Wt, { className: "size-3" }) : Qt.includes(s.data_type.toLowerCase()) ? /* @__PURE__ */ e.jsx(Sn, { className: "size-3" }) : /* @__PURE__ */ e.jsx(yn, { className: "size-3" }) }),
918
- /* @__PURE__ */ e.jsx(zs, { children: /* @__PURE__ */ e.jsx("p", { className: "font-mono text-xs", children: s.data_type }) })
919
- ] });
920
- }
921
- function An({
922
- schemaName: s,
923
- tableName: n,
924
- columns: t,
925
- status: a
926
- }) {
927
- const i = o((N) => N.sqlGen), h = o(
928
- (N) => N.selectedConnectionId
929
- ), r = o(
930
- (N) => N.selectedDatabaseName
931
- ), l = o(
932
- (N) => N.selectedSchemaName
933
- ), c = o((N) => N.selectedTableName), m = o(
934
- (N) => N.selectedDatamodelId
935
- ), u = w(
936
- (N) => N.dashboard.aiScopeTables
937
- ), { setAIScopeTables: g } = w((N) => N.actions), j = o((N) => N.actions.setRunSql), d = o((N) => N.actions.setSqlGen), x = o(
938
- (N) => N.actions.setIsShowingVisual
939
- ), y = o((N) => N.actions.setCardSql), { connectionType: f, modelItems: L } = De();
940
- function O(N) {
941
- var E;
942
- const F = at(N, i);
943
- d(F);
944
- const R = (E = L == null ? void 0 : L.find(
945
- (P) => P.id === m
946
- )) == null ? void 0 : E.name, $ = nt(F, ue(s), ue(n), R);
947
- $ && (y($), j(!0));
948
- }
949
- function v() {
950
- return (u == null ? void 0 : u.find(
951
- (N) => N.connectinonId === h && N.tableName === c
952
- )) !== void 0;
953
- }
954
- function V(N) {
955
- if (N === !0 && c && h) {
956
- const F = {
957
- connectinonId: h,
958
- connectionType: f,
959
- databaseName: r,
960
- schemaName: l,
961
- tableName: c
962
- }, $ = [...u || [], F].filter(
963
- (E, P, X) => X.findIndex(
964
- (W) => W.connectinonId === E.connectinonId && W.tableName === E.tableName
965
- ) === P
966
- );
967
- g($), Xe.success(`Added '${c}' to AI Scope`, {
968
- position: "top-right",
969
- duration: 2500,
970
- richColors: !0
971
- });
972
- } else {
973
- const F = (u || []).filter(
974
- (R) => R.connectinonId !== h && R.tableName !== c
975
- );
976
- g(F), Xe(`Removed '${c}' from AI Scope`, {
977
- position: "top-right",
978
- duration: 2e3,
979
- richColors: !0
980
- });
981
- }
982
- }
983
- function _() {
984
- var E;
985
- let N = lt(s, n);
986
- const F = (E = L == null ? void 0 : L.find(
987
- (P) => P.id === m
988
- )) == null ? void 0 : E.name;
989
- console.log("modelName", F), m && m !== "none" && (N = `${ms}.${F}`);
990
- let R = N;
991
- return ((P) => /[A-Z]/.test(P))(n) && (R = R.split(".").map((X) => `"${X}"`).join(".")), R;
992
- }
993
- function S() {
994
- const N = _();
995
- x(!1);
996
- const F = f === "MSSQL" ? `SELECT top 10 * FROM ${N}` : `SELECT * FROM ${N} LIMIT 10`;
997
- y(F), j(!0);
998
- }
999
- function M() {
1000
- const N = _();
1001
- y(`SELECT COUNT(*) as count FROM ${N}`), j(!0);
1002
- }
1003
- return /* @__PURE__ */ e.jsxs("div", { className: "flex grow flex-col space-y-4 px-4", children: [
1004
- /* @__PURE__ */ e.jsxs("div", { className: "flex items-center justify-center gap-1", children: [
1005
- /* @__PURE__ */ e.jsx(
1006
- it,
1007
- {
1008
- title: `${v() ? "Remove from" : "Add to"} AI Scope`,
1009
- pressed: v(),
1010
- onPressedChange: V,
1011
- variant: "outline",
1012
- className: "h-9 px-2",
1013
- children: /* @__PURE__ */ e.jsx(
1014
- Jt,
1015
- {
1016
- className: Z("size-4", {
1017
- "text-primary": v(),
1018
- "text-muted-foreground": !v()
1019
- })
1020
- }
1021
- )
1022
- }
1023
- ),
1024
- /* @__PURE__ */ e.jsxs(
1025
- z,
1026
- {
1027
- disabled: a !== "Success",
1028
- onClick: S,
1029
- size: "sm",
1030
- variant: "secondary",
1031
- className: "flex",
1032
- children: [
1033
- a !== "Success" ? /* @__PURE__ */ e.jsx($e, { className: "mr-2 h-4 w-4 animate-spin text-foreground/50" }) : /* @__PURE__ */ e.jsx(Nn, { className: "mr-2 size-4" }),
1034
- "Top 10"
1035
- ]
1036
- }
1037
- ),
1038
- /* @__PURE__ */ e.jsxs(
1039
- z,
1040
- {
1041
- disabled: a !== "Success",
1042
- onClick: M,
1043
- size: "sm",
1044
- variant: "secondary",
1045
- className: "flex",
1046
- children: [
1047
- a !== "Success" ? /* @__PURE__ */ e.jsx($e, { className: "mr-2 h-4 w-4 animate-spin text-foreground/50" }) : /* @__PURE__ */ e.jsx(vn, { className: "mr-2 size-4" }),
1048
- "Count"
1049
- ]
1050
- }
1051
- )
1052
- ] }),
1053
- /* @__PURE__ */ e.jsxs(
1054
- Ds,
1055
- {
1056
- className: "flex-1 basis-0 overflow-y-auto border-b border-t border-muted py-3",
1057
- children: [
1058
- t == null ? void 0 : t.map((N) => /* @__PURE__ */ e.jsxs(
1059
- "div",
1060
- {
1061
- onClick: () => O(N),
1062
- className: Z(
1063
- "group mx-3 flex cursor-pointer items-center justify-between rounded px-2 py-[6px] text-sm transition-colors hover:bg-muted/50",
1064
- {
1065
- "bg-muted": Yt(N, i)
1066
- }
1067
- ),
1068
- children: [
1069
- /* @__PURE__ */ e.jsxs("div", { className: "flex items-center space-x-2", children: [
1070
- /* @__PURE__ */ e.jsx(vt, { column: N }),
1071
- /* @__PURE__ */ e.jsx("span", { children: N.column_name })
1072
- ] }),
1073
- /* @__PURE__ */ e.jsx(
1074
- "div",
1075
- {
1076
- onClick: (F) => F.stopPropagation(),
1077
- className: "flex items-center justify-end",
1078
- children: rt.includes(N.data_type) && /* @__PURE__ */ e.jsx(Tn, { column: N })
1079
- }
1080
- )
1081
- ]
1082
- },
1083
- N.column_name
1084
- )),
1085
- /* @__PURE__ */ e.jsx($s, { orientation: "vertical" }),
1086
- /* @__PURE__ */ e.jsx($s, { orientation: "horizontal" })
1087
- ]
1088
- }
1089
- )
1090
- ] });
1091
- }
1092
- function De(s, n) {
1093
- var Ge, Ee, Ke, Ue, p;
1094
- let t = Xa(() => [], []);
1095
- const a = je().authToken || s, i = o(
1096
- (b) => b.selectedConnectionId
1097
- ), h = o(
1098
- (b) => b.selectedDatamodelId
1099
- ), r = o(
1100
- (b) => b.selectedDatabaseName
1101
- ), l = o(
1102
- (b) => b.selectedSchemaName
1103
- ), c = o((b) => b.selectedTableName), m = o(
1104
- (b) => b.actions.setCurrentColumns
1105
- ), u = o(
1106
- (b) => b.actions.setSelectedConnectionId
1107
- ), g = o(
1108
- (b) => b.actions.setSelectedDatamodelId
1109
- ), j = o(
1110
- (b) => b.actions.setSelectedDatabaseName
1111
- ), d = o(
1112
- (b) => b.actions.setSelectedSchemaName
1113
- ), x = o(
1114
- (b) => b.actions.setSelectedTableName
1115
- ), y = o((b) => b.actions.setCardSql);
1116
- function f(b) {
1117
- return i && r && l && r !== "NA" ? !0 : i && b === "API" ? !1 : !!(i && b === "S3");
1118
- }
1119
- function L(b) {
1120
- return !!(i && r && r !== "NA" && l && c || i && (b === "S3" || b === "API") || h && h);
1121
- }
1122
- function O(b) {
1123
- return i && b ? !(b === "API" || b === "S3") : !1;
1124
- }
1125
- const {
1126
- data: v,
1127
- isLoading: V,
1128
- isError: _
1129
- } = he({
1130
- queryKey: ["connections"],
1131
- queryFn: () => ge(
1132
- "https://semaphor.cloud/api/v1/connections",
1133
- (a == null ? void 0 : a.accessToken) || ""
1134
- ),
1135
- enabled: !!(a != null && a.accessToken)
1136
- // Only fetch if authToken is present
1137
- }), {
1138
- data: S,
1139
- isLoading: M,
1140
- isError: N
1141
- } = he({
1142
- queryKey: ["models", i],
1143
- queryFn: () => ge(
1144
- "https://semaphor.cloud/api/v1/datamodels",
1145
- (a == null ? void 0 : a.accessToken) || "",
1146
- {
1147
- connection_id: i
1148
- }
1149
- ),
1150
- enabled: !!(a != null && a.accessToken) && !!i
1151
- // Only fetch if authToken is present
1152
- }), F = v == null ? void 0 : v.connections.find(
1153
- (b) => b.id === i
1154
- ), R = F == null ? void 0 : F.type, $ = (F == null ? void 0 : F.type) === "API" || (F == null ? void 0 : F.type) === "S3", {
1155
- data: E,
1156
- isLoading: P,
1157
- isFetching: X,
1158
- isError: W,
1159
- refetch: re
1160
- } = he({
1161
- queryKey: ["databases", i],
1162
- queryFn: () => ge(
1163
- "https://semaphor.cloud/api/v1/databases",
1164
- (a == null ? void 0 : a.accessToken) || "",
1165
- {
1166
- connection_id: i
1167
- }
1168
- ),
1169
- enabled: O(R)
1170
- // !!selectedConnectionId && !isNonDbConnection, //currentConnection?.type !== 'API', // Only fetch if connectionId is present
1171
- }), {
1172
- data: U,
1173
- isLoading: ie,
1174
- isFetching: C,
1175
- isError: D,
1176
- refetch: J
1177
- } = he({
1178
- queryKey: ["schemas", i, r],
1179
- queryFn: () => ge(
1180
- "https://semaphor.cloud/api/v1/schemas",
1181
- (a == null ? void 0 : a.accessToken) || "",
1182
- {
1183
- connection_id: i,
1184
- database_name: r
1185
- }
1186
- ),
1187
- enabled: !!i && !!r && !$ && r !== "NA"
1188
- //currentConnection?.type !== 'API', // Only fetch if connectionId and database is present
1189
- }), {
1190
- data: k,
1191
- isLoading: I,
1192
- isFetching: ee,
1193
- isError: q,
1194
- refetch: se
1195
- } = he({
1196
- queryKey: [
1197
- "tables",
1198
- i,
1199
- r,
1200
- l
1201
- ],
1202
- queryFn: () => ge(
1203
- "https://semaphor.cloud/api/v1/tables",
1204
- (a == null ? void 0 : a.accessToken) || "",
1205
- {
1206
- connection_id: i,
1207
- database_name: r,
1208
- schema_name: l
1209
- }
1210
- ),
1211
- enabled: f(R)
1212
- }), {
1213
- data: ae,
1214
- isLoading: be,
1215
- isFetching: pe,
1216
- isError: Q
1217
- } = he({
1218
- queryKey: [
1219
- "columns",
1220
- i,
1221
- r,
1222
- h,
1223
- l,
1224
- c
1225
- ],
1226
- queryFn: () => ge(
1227
- "https://semaphor.cloud/api/v1/columns",
1228
- (a == null ? void 0 : a.accessToken) || "",
1229
- {
1230
- connection_id: i,
1231
- datamodel_id: h || "",
1232
- // don't pass undefined. Pass empty string
1233
- database_name: r,
1234
- schema_name: l,
1235
- table_name: c
1236
- }
1237
- ),
1238
- enabled: L(R)
1239
- // (!!selectedConnectionId &&
1240
- // !!selectedDatabaseName &&
1241
- // !!selectedSchemaName &&
1242
- // !!selectedTableName) ||
1243
- // isNonDbConnection,
1244
- //currentConnection?.type === 'API',
1245
- // && currentConnection?.type !== 'API', // Only fetch if connectionId, database, and table is present
1246
- });
1247
- Y(() => {
1248
- m(t);
1249
- }, [ae, m, t]), Y(() => {
1250
- }, [
1251
- $,
1252
- y,
1253
- x,
1254
- d,
1255
- j,
1256
- F
1257
- ]);
1258
- const le = (F == null ? void 0 : F.type) === "API" ? (Ge = F == null ? void 0 : F.type) == null ? void 0 : Ge.toLowerCase() : c || "", oe = $ ? "" : l || "";
1259
- function ye(b) {
1260
- d(b), x("");
1261
- }
1262
- function ce(b) {
1263
- j(b === "none" ? "" : b), d(""), x(""), b !== "none" && b !== "" && g("");
1264
- }
1265
- function fe(b) {
1266
- u(b);
1267
- }
1268
- function _s(b) {
1269
- g(b === "none" ? "" : b), b !== "none" && b !== "" && j("");
1270
- }
1271
- E && ((Ee = E == null ? void 0 : E.databases) == null ? void 0 : Ee.length) > 0, U && ((Ke = U == null ? void 0 : U.schemas) == null ? void 0 : Ke.length) > 0, ae && ((Ue = ae == null ? void 0 : ae.columns) == null ? void 0 : Ue.length) > 0 && (t = ae.columns.map((b) => ({
1272
- ...b,
1273
- data_type: b.data_type.toLowerCase()
1274
- }))), W && (t = []), (Q || _) && (t = []);
1275
- const Ce = v == null ? void 0 : v.connections.map(
1276
- (b) => ({
1277
- id: b.id,
1278
- name: b.name,
1279
- type: b.type
1280
- })
1281
- ), os = (p = S == null ? void 0 : S.datamodels) == null ? void 0 : p.map((b) => ({
1282
- id: b.id,
1283
- name: b.name
1284
- })), Be = E == null ? void 0 : E.databases.map((b) => ({
1285
- id: b.database_name,
1286
- name: b.database_name
1287
- })), cs = U == null ? void 0 : U.schemas.map((b) => ({
1288
- id: b.schema_name,
1289
- name: b.schema_name
1290
- })), ds = k == null ? void 0 : k.tables.map((b) => ({
1291
- id: b.table_name,
1292
- name: b.table_name
1293
- }));
1294
- return {
1295
- connectionItems: Ce,
1296
- isConnectionsLoading: V,
1297
- isConnectionsError: _,
1298
- modelItems: os,
1299
- isModelsLoading: M,
1300
- isModelsError: N,
1301
- databaseItems: Be,
1302
- isDatabasesLoadingOrFetching: P || X,
1303
- isDatabaseError: W,
1304
- schemaItems: cs,
1305
- isSchemaLoadingOrFetching: ie || C,
1306
- isSchemaError: D,
1307
- tableItems: ds,
1308
- isTableLoadingOrFetching: I || ee,
1309
- isTableError: q,
1310
- columns: t,
1311
- isColumnsLoadingOrFetching: be || pe,
1312
- isColumnsError: Q,
1313
- isNonDbConnection: $,
1314
- connectionType: R,
1315
- tableName: le,
1316
- schemaName: oe,
1317
- handleConnectionChange: fe,
1318
- handleDatamodelChange: _s,
1319
- handleDatabaseChange: ce,
1320
- handleSchemaChange: ye
1321
- };
1322
- }
1323
- function Nt({
1324
- ColumnsComponent: s
1325
- }) {
1326
- var ee;
1327
- const n = o(
1328
- (q) => q.selectedConnectionId
1329
- ), t = o(
1330
- (q) => q.selectedDatamodelId
1331
- ), a = o(
1332
- (q) => q.selectedDatabaseName
1333
- ), i = o(
1334
- (q) => q.selectedSchemaName
1335
- ), h = o((q) => q.selectedTableName), r = o(
1336
- (q) => q.actions.setSelectedTableName
1337
- ), {
1338
- connectionItems: l,
1339
- modelItems: c,
1340
- schemaItems: m,
1341
- databaseItems: u,
1342
- tableItems: g,
1343
- columns: j,
1344
- isConnectionsLoading: d,
1345
- isModelsLoading: x,
1346
- isConnectionsError: y,
1347
- isModelsError: f,
1348
- isDatabasesLoadingOrFetching: L,
1349
- isDatabaseError: O,
1350
- isSchemaLoadingOrFetching: v,
1351
- isSchemaError: V,
1352
- isColumnsError: _,
1353
- isColumnsLoadingOrFetching: S,
1354
- isTableLoadingOrFetching: M,
1355
- isTableError: N,
1356
- connectionType: F,
1357
- isNonDbConnection: R,
1358
- handleConnectionChange: $,
1359
- handleDatabaseChange: E,
1360
- handleSchemaChange: P,
1361
- handleDatamodelChange: X,
1362
- tableName: W,
1363
- schemaName: re
1364
- } = De();
1365
- function U() {
1366
- return s ? s(re, W, j) : /* @__PURE__ */ e.jsx(
1367
- An,
1368
- {
1369
- schemaName: re,
1370
- tableName: W,
1371
- columns: j,
1372
- status: S ? "Loading..." : _ ? "Error" : "Success"
1373
- }
1374
- );
1375
- }
1376
- function ie() {
1377
- window.location.href = "mailto:support@semaphor.cloud?subject=Help&body=I need help with...";
1378
- }
1379
- function C() {
1380
- if (!n || F === "S3" || F === "API")
1381
- return null;
1382
- if (!t || t === "none")
1383
- return /* @__PURE__ */ e.jsx(
1384
- Ie,
1385
- {
1386
- showNone: !0,
1387
- onChange: E,
1388
- isError: O,
1389
- isLoading: L,
1390
- items: u,
1391
- value: a || "",
1392
- title: "Database"
1393
- }
1394
- );
1395
- }
1396
- function D() {
1397
- if (n && !R && (!a || a === "none") && (!t || t === "none"))
1398
- return /* @__PURE__ */ e.jsxs("div", { className: "grid grid-cols-3", children: [
1399
- /* @__PURE__ */ e.jsx("div", { className: "col-span-1 grid place-items-center", children: /* @__PURE__ */ e.jsx(Re, {}) }),
1400
- /* @__PURE__ */ e.jsx("div", { className: "col-span-1 grid place-items-center", children: /* @__PURE__ */ e.jsx(H, { children: "OR" }) }),
1401
- /* @__PURE__ */ e.jsx("div", { className: "col-span-1 grid place-items-center", children: /* @__PURE__ */ e.jsx(Re, {}) })
1402
- ] });
1403
- }
1404
- function J() {
1405
- if (!n || F === "S3" || F === "API")
1406
- return null;
1407
- if (!a || a === "none")
1408
- return /* @__PURE__ */ e.jsx(
1409
- Ie,
1410
- {
1411
- showNone: !0,
1412
- onChange: X,
1413
- isError: f,
1414
- isLoading: x,
1415
- items: c,
1416
- value: t || "",
1417
- title: "Model"
1418
- }
1419
- );
1420
- }
1421
- function k() {
1422
- return !n || F === "S3" || F === "API" || !a || a === "none" ? null : /* @__PURE__ */ e.jsx(
1423
- Ie,
1424
- {
1425
- onChange: P,
1426
- isError: V,
1427
- isLoading: v,
1428
- items: m,
1429
- value: i || "",
1430
- title: "Schema"
1431
- }
1432
- );
1433
- }
1434
- function I() {
1435
- function q() {
1436
- let se = !1;
1437
- return F === "API" ? (se = !1, se) : ((F === "S3" || n && a && a !== "none" && i) && (se = !0), se);
1438
- }
1439
- return q() ? /* @__PURE__ */ e.jsx(
1440
- Ie,
1441
- {
1442
- onChange: r,
1443
- isError: N,
1444
- items: g,
1445
- isLoading: M,
1446
- value: h || "",
1447
- title: "Table"
1448
- }
1449
- ) : null;
1450
- }
1451
- return /* @__PURE__ */ e.jsxs("aside", { className: "xbg-red-100 flex grow flex-col justify-between", children: [
1452
- /* @__PURE__ */ e.jsxs("section", { className: "space-y-3 px-6 py-4", children: [
1453
- /* @__PURE__ */ e.jsx(
1454
- Ie,
1455
- {
1456
- items: l,
1457
- title: "Connection",
1458
- value: n || "",
1459
- onChange: $,
1460
- isLoading: d,
1461
- isError: y,
1462
- connectionTooltip: ((ee = l == null ? void 0 : l.find(
1463
- (q) => q.id === n
1464
- )) == null ? void 0 : ee.type) || ""
1465
- }
1466
- ),
1467
- J(),
1468
- D(),
1469
- C(),
1470
- k(),
1471
- I()
1472
- ] }),
1473
- U(),
1474
- /* @__PURE__ */ e.jsx("div", { className: "flex items-end justify-center gap-2 px-6 py-4", children: /* @__PURE__ */ e.jsxs(
1475
- z,
1476
- {
1477
- onClick: ie,
1478
- size: "sm",
1479
- variant: "secondary",
1480
- className: "w-full",
1481
- children: [
1482
- /* @__PURE__ */ e.jsx(pn, { className: "mr-2 size-4" }),
1483
- "Help"
1484
- ]
1485
- }
1486
- ) })
1487
- ] });
1488
- }
1489
- function En(s) {
1490
- const n = s.toUpperCase().indexOf("WHERE"), t = s.toUpperCase().indexOf("GROUP BY"), a = s.toUpperCase().indexOf("LIMIT"), i = s.toUpperCase().indexOf("ORDER BY");
1491
- let h = s.length;
1492
- if (i !== -1 && (h = i), a !== -1 && a < h && (h = a), n !== -1) {
1493
- const r = s.substring(0, n), l = s.substring(n);
1494
- return `${r} {{ filters | where }} AND ${l.substring(
1495
- 6
1496
- )}`;
1497
- } else if (t !== -1) {
1498
- const r = s.substring(0, t), l = s.substring(t);
1499
- return `${r} {{ filters | where }} ${l}`;
1500
- } else {
1501
- const r = s.substring(0, h), l = s.substring(h);
1502
- return `${r} {{ filters | where }} ${l}`;
1503
- }
1504
- }
1505
- function In({
1506
- error: s,
1507
- setShowAIDialog: n,
1508
- setUserInputforAI: t,
1509
- setTriggerAIRun: a
1510
- }) {
1511
- return /* @__PURE__ */ e.jsxs(Ls, { openDelay: 0, children: [
1512
- /* @__PURE__ */ e.jsx(Ms, { asChild: !0, children: /* @__PURE__ */ e.jsx(z, { variant: "link", className: "h-5 p-0", children: /* @__PURE__ */ e.jsx(tn, { className: "h-4 w-4 text-red-500" }) }) }),
1513
- /* @__PURE__ */ e.jsx(Os, { align: "start", className: "min-w-fit max-w-[500px]", children: /* @__PURE__ */ e.jsx("div", { className: "flex justify-between space-x-4", children: /* @__PURE__ */ e.jsxs("div", { className: "flex grow flex-col space-y-2", children: [
1514
- /* @__PURE__ */ e.jsx(Ds, { className: "max-h-[250px] min-h-0 overflow-scroll", children: /* @__PURE__ */ e.jsx("p", { className: "overflow-auto rounded-md bg-muted p-2 text-xs leading-relaxed", children: s }) }),
1515
- /* @__PURE__ */ e.jsxs(
1516
- z,
1517
- {
1518
- onClick: () => {
1519
- n(!0), t(s), a(!0);
1520
- },
1521
- size: "sm",
1522
- variant: "outline",
1523
- children: [
1524
- /* @__PURE__ */ e.jsx(on, { className: "mr-2 h-4 w-4" }),
1525
- "Debug with AI"
1526
- ]
1527
- }
1528
- )
1529
- ] }) }) })
1530
- ] });
1531
- }
1532
- function qn({
1533
- text: s,
1534
- onCheckedChange: n,
1535
- checked: t
1536
- }) {
1537
- return /* @__PURE__ */ e.jsxs("div", { className: "xbg-red-100 ml-6 flex items-center gap-2", children: [
1538
- /* @__PURE__ */ e.jsx(ts, { checked: t, onCheckedChange: n }),
1539
- /* @__PURE__ */ e.jsx("label", { className: "text-xs leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70", children: s })
1540
- ] });
1541
- }
1542
- function Vn() {
1543
- const { authToken: s } = je(), n = o(
1544
- (h) => h.selectedConnectionId
1545
- ), { data: t } = he({
1546
- queryKey: ["connections"],
1547
- queryFn: () => ge(
1548
- "https://semaphor.cloud/api/v1/connections",
1549
- (s == null ? void 0 : s.accessToken) || ""
1550
- ),
1551
- enabled: !!(s != null && s.accessToken)
1552
- // Only fetch if authToken is present
1553
- }), a = t == null ? void 0 : t.connections.find(
1554
- (h) => h.id === n
1555
- );
1556
- return a == null ? void 0 : a.type;
1557
- }
1558
- function _n() {
1559
- const { authToken: s } = je(), n = He(null), t = o((c) => c.applyFilters), [a, i] = A(""), h = o((c) => c.filterValues), r = o((c) => c.card.sql), l = Vn();
1560
- return /* @__PURE__ */ e.jsxs(
1561
- Ls,
1562
- {
1563
- openDelay: 0,
1564
- onOpenChange: async (c) => {
1565
- if (!c)
1566
- return;
1567
- console.log("onOpenChange");
1568
- const m = await Pe(
1569
- "https://semaphor.cloud/api/v1/filter-sql",
1570
- (s == null ? void 0 : s.accessToken) || "",
1571
- {
1572
- sql: r,
1573
- active_filters: h,
1574
- connection_type: l
1575
- }
1576
- );
1577
- console.log(m), m.sql ? (console.log(m.records), i(m.sql)) : i("Error");
1578
- },
1579
- children: [
1580
- /* @__PURE__ */ e.jsx(Ms, { asChild: !0, children: t && /* @__PURE__ */ e.jsx("p", { className: "p-0 text-xs hover:cursor-pointer", children: "|  Filter Query" }) }),
1581
- /* @__PURE__ */ e.jsxs(Os, { align: "end", className: "w-[600px]", children: [
1582
- /* @__PURE__ */ e.jsx("div", { className: "flex justify-between space-x-4", children: /* @__PURE__ */ e.jsx("div", { className: "rounded-sm bg-muted p-2", children: /* @__PURE__ */ e.jsxs("code", { ref: n, className: "font-mono text-sm", children: [
1583
- a,
1584
- /* @__PURE__ */ e.jsx(
1585
- ot,
1586
- {
1587
- onClick: () => Zt(n),
1588
- className: "ml-3 inline-block h-4 w-4 opacity-70 hover:cursor-pointer hover:opacity-100"
1589
- }
1590
- )
1591
- ] }) }) }),
1592
- /* @__PURE__ */ e.jsxs("div", { className: "flex items-center gap-2 pt-2", children: [
1593
- /* @__PURE__ */ e.jsx(Xt, { className: "h-4 w-4 opacity-70" }),
1594
- /* @__PURE__ */ e.jsx("span", { className: "text-xs text-muted-foreground", children: "A preview of the query with filters applied." })
1595
- ] })
1596
- ] })
1597
- ]
1598
- }
1599
- );
1600
- }
1601
- const Rn = `
1602
-
1603
- Use the following syntax to create a chart query. Please replace the x-axis, y-axis, stack-by, label, and measure with the actual column names of the table.
1604
-
1605
- Bar / Line Chart:
1606
-
1607
- SELECT x-axis, y-axis-1, y-axis-2, y-axis-3,... FROM table
1608
-
1609
- - X-axis - Category
1610
- - Y-axis - Number
1611
-
1612
- Stacked Chart:
1613
-
1614
- SELECT x-axis, stack-by, y-axis FROM table
1615
-
1616
- - X-axis - Category
1617
- - Stack by - Category
1618
- - Y-axis - Number
1619
-
1620
-
1621
- Scatter Chart:
1622
-
1623
- SELECT label, x-axis, y-axis FROM table
1624
-
1625
- - Label - Category
1626
- - Group (opt) - Category
1627
- - X-axis - Number
1628
- - Y-axis - Number
1629
-
1630
-
1631
- Bubble Chart:
1632
-
1633
- SELECT label, x-axis, y-axis, radius FROM table
1634
-
1635
- - Label - Category
1636
- - Bubble Group (opt) - Category
1637
- - X-axis - Number
1638
- - Y-axis - Number
1639
- - Radius - Number
1640
-
1641
- Pie / Dougnut Chart:
1642
-
1643
- SELECT label, measure FROM table
1644
-
1645
- - Label - Category
1646
- - Measure - Number
1647
- `;
1648
- function Hn({
1649
- open: s,
1650
- setOpen: n,
1651
- userInput: t,
1652
- setUserInput: a,
1653
- triggerAIRun: i,
1654
- setTriggerAIRun: h
1655
- }) {
1656
- const r = He(null), l = He(null), { authToken: c } = je(), [m, u] = A(!1), g = o((C) => C.actions.setCardSql), j = w((C) => C.dashboard.baseQueries), d = o((C) => C.actions.setRunSql), x = o((C) => C.actions.setCardType), [y, f] = A([]), L = o((C) => C.currentColumns), O = o((C) => C.card.sql), v = o((C) => C.selectedTableName), V = `
1657
- ${t}
1658
-
1659
- Database Query Dialect: ${v === "api" || v === "s3" ? "DuckDb" : ""}
1660
- Table Name: ${v}
1661
- Table Columns: ${L == null ? void 0 : L.map((C) => `${C.column_name} | ${C.data_type}`).join(", ")}
1662
- User SQL: ${O}
1663
- ${j && `Base Queries: ${JSON.stringify(j)} `}`, _ = ` When the user asks for a specific chart please use the following query structure to generate the chart query. Do not make up the column names. Use only the table columns provided above for the query. Replace x-axis, y-axis, and lables with the appropriate column names.
1664
- Visual Query Syntax: ${Rn}`, { data: S, isLoading: M, isFetching: N, isError: F, refetch: R } = he({
1665
- queryKey: ["ai-query"],
1666
- queryFn: () => ge(
1667
- "https://semaphor.cloud/api/v1/ai",
1668
- (c == null ? void 0 : c.accessToken) || "",
1669
- {
1670
- user_content: `userContent: ${V} ${m ? _ : ""}`
1671
- }
1672
- ),
1673
- enabled: !1
1674
- // Do not run by default.
1675
- });
1676
- function $(C) {
1677
- if (C.toLowerCase().includes("bar"))
1678
- x("bar");
1679
- else if (C.toLowerCase().includes("line"))
1680
- x("line");
1681
- else if (C.toLowerCase().includes("bubble"))
1682
- x("bubble");
1683
- else if (C.toLowerCase().includes("scatter"))
1684
- x("scatter");
1685
- else if (C.toLowerCase().includes("stacked"))
1686
- x("stackedBar");
1687
- else if (C.toLowerCase().includes("pie"))
1688
- x("pie");
1689
- else if (C.toLowerCase().includes("donut") || C.toLowerCase().includes("doughnut"))
1690
- x("doughnut");
1691
- else if (C.toLowerCase().includes("radar"))
1692
- x("radar");
1693
- else
1694
- return x("bar"), !1;
1695
- return !0;
1696
- }
1697
- Y(() => {
1698
- S && f((C) => [...C, { role: "ai", content: S.response }]);
1699
- }, [S]), Y(() => {
1700
- const C = setTimeout(() => {
1701
- var D;
1702
- l.current && (l.current.scroll({
1703
- top: l.current.scrollHeight,
1704
- behavior: "smooth"
1705
- }), (D = r.current) == null || D.focus());
1706
- }, 100);
1707
- return () => clearTimeout(C);
1708
- }, [y]);
1709
- function E() {
1710
- t && (f((C) => [...C, { role: "user", content: t }]), $(t) && u(!0), a(""), R());
1711
- }
1712
- Y(() => {
1713
- i && (E(), h(!1));
1714
- }, [i, h]);
1715
- const P = {
1716
- //seleect a darker color
1717
- // color: '#000',
1718
- fontFamily: "Arial, sans-serif",
1719
- lineHeight: 1.6,
1720
- fontSize: 15,
1721
- // padding: '5px',
1722
- width: "100%"
1723
- }, X = {
1724
- // background: '#f6f8fa',
1725
- // color: '#000',
1726
- fontFamily: "monospace",
1727
- fontSize: 14,
1728
- lineHeight: 1.6
1729
- // padding: 20,
1730
- }, W = {
1731
- // color: '#000',
1732
- fontFamily: "Arial, sans-serif",
1733
- lineHeight: 1.6,
1734
- fontSize: 15,
1735
- padding: "2px 0",
1736
- // add a bit of left margin to make it look nice
1737
- marginLeft: 20,
1738
- // add bullet points for unordered lists
1739
- listStyleType: "disc"
1740
- }, re = {
1741
- // Override how paragraphs are rendered
1742
- p: ({ node: C, ...D }) => /* @__PURE__ */ e.jsx("p", { style: P, ...D }),
1743
- code: ({ node: C, ...D }) => /* @__PURE__ */ e.jsx("code", { className: "rounded-sm bg-muted px-2 py-1 text-sm", ...D }),
1744
- pre: ({ node: C, ...D }) => /* @__PURE__ */ e.jsxs("pre", { className: "space-y-2 rounded-sm bg-muted/50 p-3", style: X, children: [
1745
- /* @__PURE__ */ e.jsx("code", { className: "whitespace-normal text-sm", children: D.children }),
1746
- /* @__PURE__ */ e.jsxs("div", { className: "flex justify-start gap-2", children: [
1747
- /* @__PURE__ */ e.jsx(z, { onClick: U, size: "sm", variant: "outline", children: /* @__PURE__ */ e.jsx(ot, {}) }),
1748
- /* @__PURE__ */ e.jsx(
1749
- z,
1750
- {
1751
- onClick: (J) => {
1752
- const k = U(J);
1753
- k && (n(!1), g(k), d(!0));
1754
- },
1755
- size: "sm",
1756
- variant: "outline",
1757
- children: /* @__PURE__ */ e.jsx(ta, {})
1758
- }
1759
- )
1760
- ] })
1761
- ] }),
1762
- li: ({ node: C, ...D }) => /* @__PURE__ */ e.jsx("li", { style: W, ...D })
1763
- // You can add more overrides for other elements like h1, h2, etc.
1764
- };
1765
- function U(C) {
1766
- const D = C.currentTarget.closest("pre");
1767
- if (!D)
1768
- return;
1769
- const J = D.textContent || D.innerText;
1770
- return navigator.clipboard.writeText(J).then(() => console.log("Text copied to clipboard")).catch((k) => console.error("Error in copying text: ", k)), J;
1771
- }
1772
- function ie() {
1773
- return y == null ? void 0 : y.map((C, D) => C.role === "user" ? /* @__PURE__ */ e.jsxs(
1774
- "div",
1775
- {
1776
- className: "flex items-start rounded-md bg-muted p-3 text-sm",
1777
- children: [
1778
- /* @__PURE__ */ e.jsx(wn, { className: "mr-2 h-5 w-5" }),
1779
- /* @__PURE__ */ e.jsx("div", { children: C.content })
1780
- ]
1781
- },
1782
- D
1783
- ) : C.role === "ai" ? /* @__PURE__ */ e.jsx(
1784
- sa,
1785
- {
1786
- className: "w-full overflow-auto py-1",
1787
- components: re,
1788
- children: S == null ? void 0 : S.response.replace(/DuckDB/gi, "Semaphor")
1789
- },
1790
- D
1791
- ) : /* @__PURE__ */ e.jsx("div", {}, D));
1792
- }
1793
- return /* @__PURE__ */ e.jsxs(bs, { open: s, onOpenChange: n, children: [
1794
- /* @__PURE__ */ e.jsx(ys, { asChild: !0, children: /* @__PURE__ */ e.jsx(
1795
- z,
1796
- {
1797
- size: "sm",
1798
- className: "w-full justify-start border font-normal text-muted-foreground focus-visible:ring-0 focus-visible:ring-offset-0",
1799
- variant: "secondary",
1800
- children: "Type your question here..."
1801
- }
1802
- ) }),
1803
- /* @__PURE__ */ e.jsxs(
1804
- Ns,
1805
- {
1806
- className: "flex flex-col justify-between overflow-auto sm:max-w-[425px] md:max-h-[625px] md:min-w-[625px]",
1807
- children: [
1808
- /* @__PURE__ */ e.jsxs(Cs, { children: [
1809
- /* @__PURE__ */ e.jsx(Ss, { children: "Assistant" }),
1810
- /* @__PURE__ */ e.jsx(ws, { children: "What can I help you with?" })
1811
- ] }),
1812
- /* @__PURE__ */ e.jsx(
1813
- "div",
1814
- {
1815
- ref: l,
1816
- className: "h-[625px] w-full overflow-auto border-t border-t-muted",
1817
- children: /* @__PURE__ */ e.jsx("div", { className: "space-y-4 py-2 pr-3", role: "messages", children: ie() })
1818
- }
1819
- ),
1820
- /* @__PURE__ */ e.jsx(
1821
- "div",
1822
- {
1823
- children: /* @__PURE__ */ e.jsxs("div", { className: "flex w-full items-center rounded-md border", children: [
1824
- /* @__PURE__ */ e.jsx(
1825
- ct,
1826
- {
1827
- autoFocus: !0,
1828
- ref: r,
1829
- onKeyDown: (C) => {
1830
- C.key === "Enter" && !C.shiftKey && (C.preventDefault(), a(""), E());
1831
- },
1832
- placeholder: "Type your question here...",
1833
- onFocus: (C) => {
1834
- const D = C.target, J = D.value.length;
1835
- D.setSelectionRange(J, J);
1836
- },
1837
- className: Z(
1838
- "max-h-10 min-h-7 resize-none border-none focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0"
1839
- ),
1840
- disabled: M || N,
1841
- value: t,
1842
- onChange: (C) => a(C.target.value)
1843
- }
1844
- ),
1845
- " ",
1846
- /* @__PURE__ */ e.jsx(
1847
- z,
1848
- {
1849
- className: "h-8",
1850
- size: "sm",
1851
- variant: "ghost",
1852
- onClick: E,
1853
- children: !M && !N ? /* @__PURE__ */ e.jsx(ea, {}) : /* @__PURE__ */ e.jsx($e, { className: "mr-2 h-4 w-4 animate-spin text-foreground/50" })
1854
- }
1855
- )
1856
- ] })
1857
- }
1858
- )
1859
- ]
1860
- }
1861
- )
1862
- ] });
1863
- }
1864
- var Ct = {
1865
- color: void 0,
1866
- size: void 0,
1867
- className: void 0,
1868
- style: void 0,
1869
- attr: void 0
1870
- }, Js = me.createContext && /* @__PURE__ */ me.createContext(Ct), $n = ["attr", "size", "title"];
1871
- function Pn(s, n) {
1872
- if (s == null)
1873
- return {};
1874
- var t = Bn(s, n), a, i;
1875
- if (Object.getOwnPropertySymbols) {
1876
- var h = Object.getOwnPropertySymbols(s);
1877
- for (i = 0; i < h.length; i++)
1878
- a = h[i], !(n.indexOf(a) >= 0) && Object.prototype.propertyIsEnumerable.call(s, a) && (t[a] = s[a]);
1879
- }
1880
- return t;
1881
- }
1882
- function Bn(s, n) {
1883
- if (s == null)
1884
- return {};
1885
- var t = {}, a = Object.keys(s), i, h;
1886
- for (h = 0; h < a.length; h++)
1887
- i = a[h], !(n.indexOf(i) >= 0) && (t[i] = s[i]);
1888
- return t;
1889
- }
1890
- function es() {
1891
- return es = Object.assign ? Object.assign.bind() : function(s) {
1892
- for (var n = 1; n < arguments.length; n++) {
1893
- var t = arguments[n];
1894
- for (var a in t)
1895
- Object.prototype.hasOwnProperty.call(t, a) && (s[a] = t[a]);
1896
- }
1897
- return s;
1898
- }, es.apply(this, arguments);
1899
- }
1900
- function Ys(s, n) {
1901
- var t = Object.keys(s);
1902
- if (Object.getOwnPropertySymbols) {
1903
- var a = Object.getOwnPropertySymbols(s);
1904
- n && (a = a.filter(function(i) {
1905
- return Object.getOwnPropertyDescriptor(s, i).enumerable;
1906
- })), t.push.apply(t, a);
1907
- }
1908
- return t;
1909
- }
1910
- function ss(s) {
1911
- for (var n = 1; n < arguments.length; n++) {
1912
- var t = arguments[n] != null ? arguments[n] : {};
1913
- n % 2 ? Ys(Object(t), !0).forEach(function(a) {
1914
- Gn(s, a, t[a]);
1915
- }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(s, Object.getOwnPropertyDescriptors(t)) : Ys(Object(t)).forEach(function(a) {
1916
- Object.defineProperty(s, a, Object.getOwnPropertyDescriptor(t, a));
1917
- });
1918
- }
1919
- return s;
1920
- }
1921
- function Gn(s, n, t) {
1922
- return n = Kn(n), n in s ? Object.defineProperty(s, n, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : s[n] = t, s;
1923
- }
1924
- function Kn(s) {
1925
- var n = Un(s, "string");
1926
- return typeof n == "symbol" ? n : String(n);
1927
- }
1928
- function Un(s, n) {
1929
- if (typeof s != "object" || s === null)
1930
- return s;
1931
- var t = s[Symbol.toPrimitive];
1932
- if (t !== void 0) {
1933
- var a = t.call(s, n || "default");
1934
- if (typeof a != "object")
1935
- return a;
1936
- throw new TypeError("@@toPrimitive must return a primitive value.");
1937
- }
1938
- return (n === "string" ? String : Number)(s);
1939
- }
1940
- function St(s) {
1941
- return s && s.map((n, t) => /* @__PURE__ */ me.createElement(n.tag, ss({
1942
- key: t
1943
- }, n.attr), St(n.child)));
1944
- }
1945
- function xe(s) {
1946
- return (n) => /* @__PURE__ */ me.createElement(Wn, es({
1947
- attr: ss({}, s.attr)
1948
- }, n), St(s.child));
1949
- }
1950
- function Wn(s) {
1951
- var n = (t) => {
1952
- var {
1953
- attr: a,
1954
- size: i,
1955
- title: h
1956
- } = s, r = Pn(s, $n), l = i || t.size || "1em", c;
1957
- return t.className && (c = t.className), s.className && (c = (c ? c + " " : "") + s.className), /* @__PURE__ */ me.createElement("svg", es({
1958
- stroke: "currentColor",
1959
- fill: "currentColor",
1960
- strokeWidth: "0"
1961
- }, t.attr, a, r, {
1962
- className: c,
1963
- style: ss(ss({
1964
- color: s.color || t.color
1965
- }, t.style), s.style),
1966
- height: l,
1967
- width: l,
1968
- xmlns: "http://www.w3.org/2000/svg"
1969
- }), h && /* @__PURE__ */ me.createElement("title", null, h), s.children);
1970
- };
1971
- return Js !== void 0 ? /* @__PURE__ */ me.createElement(Js.Consumer, null, (t) => n(t)) : n(Ct);
1972
- }
1973
- function Qn(s) {
1974
- return xe({ tag: "svg", attr: { viewBox: "0 0 448 512" }, child: [{ tag: "path", attr: { d: "M439.8 200.5c-7.7-30.9-22.3-54.2-53.4-54.2h-40.1v47.4c0 36.8-31.2 67.8-66.8 67.8H172.7c-29.2 0-53.4 25-53.4 54.3v101.8c0 29 25.2 46 53.4 54.3 33.8 9.9 66.3 11.7 106.8 0 26.9-7.8 53.4-23.5 53.4-54.3v-40.7H226.2v-13.6h160.2c31.1 0 42.6-21.7 53.4-54.2 11.2-33.5 10.7-65.7 0-108.6zM286.2 404c11.1 0 20.1 9.1 20.1 20.3 0 11.3-9 20.4-20.1 20.4-11 0-20.1-9.2-20.1-20.4.1-11.3 9.1-20.3 20.1-20.3zM167.8 248.1h106.8c29.7 0 53.4-24.5 53.4-54.3V91.9c0-29-24.4-50.7-53.4-55.6-35.8-5.9-74.7-5.6-106.8.1-45.2 8-53.4 24.7-53.4 55.6v40.7h106.9v13.6h-147c-31.1 0-58.3 18.7-66.8 54.2-9.8 40.7-10.2 66.1 0 108.6 7.6 31.6 25.7 54.2 56.8 54.2H101v-48.8c0-35.3 30.5-66.4 66.8-66.4zm-6.7-142.6c-11.1 0-20.1-9.1-20.1-20.3.1-11.3 9-20.4 20.1-20.4 11 0 20.1 9.2 20.1 20.4s-9 20.3-20.1 20.3z" }, child: [] }] })(s);
1975
- }
1976
- function Jn() {
1977
- const { theme: s } = aa(), n = He(), t = He(), [a, i] = A(!1), [h, r] = A(!1), [l, c] = A(!1), [m, u] = A(""), [g, j] = A(!1), { authToken: d } = je();
1978
- w((p) => p.selectedSheetId);
1979
- const x = w((p) => p.dashboard.baseQueries), y = o((p) => p.card), f = w((p) => p.theme), L = o((p) => p.isShowingVisual), O = o(
1980
- (p) => p.selectedConnectionId
1981
- ), v = o(
1982
- (p) => p.selectedDatabaseName
1983
- ), V = o(
1984
- (p) => p.selectedDatamodelId
1985
- ), _ = o(
1986
- (p) => p.selectedSchemaName
1987
- );
1988
- w(
1989
- (p) => p.actions.updateFrameCard
1990
- );
1991
- const S = o((p) => p.selectedTableName), M = o((p) => p.card.sql), N = o((p) => p.card.python), F = na(M, x), R = o((p) => p.selectedConnectionId), $ = o((p) => p.frame), E = w((p) => p.filterValues), P = o((p) => p.applyFilters), {
1992
- setCardCustomCfg: X,
1993
- setQueryResultColumns: W,
1994
- setFilterValues: re,
1995
- setCardSql: U,
1996
- setCardPython: ie,
1997
- setQueryError: C,
1998
- setPythonStdOut: D,
1999
- setCardPreferences: J
2000
- } = o((p) => p.actions), k = o((p) => p.onSave), I = o(
2001
- (p) => p.actions.setApplyFilters
2002
- ), ee = o((p) => p.onClose), q = o((p) => p.actions.setCardData), se = o((p) => p.actions.setSqlGen), ae = o((p) => p.runSql), be = o((p) => p.actions.setRunSql), pe = o(
2003
- (p) => p.actions.setIsSqlRunning
2004
- ), {
2005
- data: Q,
2006
- isLoading: le,
2007
- isFetching: oe,
2008
- isSuccess: ye,
2009
- isError: ce,
2010
- error: fe,
2011
- status: _s,
2012
- refetch: Ce
2013
- } = he({
2014
- queryKey: [F, N],
2015
- queryFn: () => Pe(
2016
- "https://semaphor.cloud/api/v1/query",
2017
- (d == null ? void 0 : d.accessToken) || "",
2018
- {
2019
- connection_id: R,
2020
- sql: F,
2021
- python: N === Ps ? "" : N,
2022
- active_filters: P ? E : []
2023
- }
2024
- ),
2025
- enabled: !1,
2026
- retry: !1
2027
- });
2028
- Y(() => {
2029
- if (Q && (q(Q.records), Q.rowLimitExceeded && Xe.error("Row limit (10,000) exceeded. Refine your query.", {
2030
- position: "top-center",
2031
- richColors: !0
2032
- }), D((Q == null ? void 0 : Q.output) || ""), Q.records.length > 0)) {
2033
- const { dimensionKeys: p } = xs(Q.records);
2034
- W(p);
2035
- }
2036
- }, [Q, q, W, D]), Y(() => {
2037
- ae && (Ce(), be(!1));
2038
- }, [ae, Ce, be]), Y(() => {
2039
- (le || oe) && pe(!0), (ce || ye) && pe(!1), ce ? (C(fe.message), q([]), W([]), D("")) : C("");
2040
- }, [
2041
- le,
2042
- oe,
2043
- Q,
2044
- D,
2045
- ce,
2046
- ye,
2047
- pe,
2048
- q,
2049
- W,
2050
- C,
2051
- fe
2052
- ]);
2053
- function os() {
2054
- U(""), q([]), se({}), X(""), J({});
2055
- }
2056
- const Be = (p) => {
2057
- t.current = p;
2058
- };
2059
- function cs(p, b) {
2060
- if (p.length === 0)
2061
- return "";
2062
- if (b) {
2063
- const ve = p.find((ne) => ne.id === b);
2064
- if (ve) {
2065
- const ne = ve.tabTitle;
2066
- if (ne == "All__Header")
2067
- return p[0].id;
2068
- if (ne && ne.endsWith("__Header")) {
2069
- const qt = ne.split("__")[0], Rs = p.find(
2070
- (Vt) => Vt.tabTitle === qt
2071
- );
2072
- return Rs ? Rs.id : p[0].id;
2073
- }
2074
- return b;
2075
- }
2076
- }
2077
- return p[0].id;
2078
- }
2079
- function ds() {
2080
- let p = M;
2081
- M && !M.includes("{{") && (p = En(M), U(p));
2082
- const b = {
2083
- ...y,
2084
- lastSelectedSchema: _,
2085
- lastSelectedDatamodelId: V,
2086
- lastSelectedDatabase: v,
2087
- lastSelectedTable: S,
2088
- connectionId: O,
2089
- type: L ? y.type : "table",
2090
- sql: p,
2091
- customCfg: L ? y.customCfg : null
2092
- }, ve = $.cards.map(
2093
- (hs) => hs.id === y.id ? b : hs
2094
- ), ne = {
2095
- ...$,
2096
- cards: ve,
2097
- activeCardId: cs(ve, $.activeCardId)
2098
- };
2099
- k == null || k(ne);
2100
- }
2101
- function Ge() {
2102
- ee == null || ee();
2103
- }
2104
- Y(() => {
2105
- const p = n.current, b = t.current;
2106
- if (p) {
2107
- const ve = window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light", ne = f === "system" ? ve : f;
2108
- p.editor.defineTheme("default", {
2109
- // base: theme === 'light' ? 'hc-light' : 'vs-dark',
2110
- base: ne === "light" ? "vs" : "vs-dark",
2111
- inherit: !0,
2112
- rules: [],
2113
- colors: {
2114
- // 'editor.background': activeTheme === 'light' ? '#ffffff' : '#020817',
2115
- "editor.background": ne === "light" ? "#ffffff" : ra("--semaphor-background")
2116
- }
2117
- }), p.editor.setTheme("default");
2118
- }
2119
- return b && p && b.addCommand(
2120
- p.KeyMod.Shift | p.KeyCode.Enter,
2121
- function() {
2122
- return console.log("Executing query..."), Ce(), !1;
2123
- }
2124
- ), () => {
2125
- };
2126
- }, [s, f, n.current]);
2127
- function Ee(p) {
2128
- n.current = p;
2129
- }
2130
- function Ke() {
2131
- return /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
2132
- h && /* @__PURE__ */ e.jsx(
2133
- "div",
2134
- {
2135
- className: "xbg-yellow-100 relative flex w-1/3 min-w-0 grow overflow-hidden border-l p-1 text-xs",
2136
- role: "editor-filter-container",
2137
- children: /* @__PURE__ */ e.jsxs("div", { className: "w-[99%]", children: [
2138
- /* @__PURE__ */ e.jsxs("div", { className: "flex items-center gap-2 pt-3", children: [
2139
- /* @__PURE__ */ e.jsx(
2140
- qn,
2141
- {
2142
- checked: P,
2143
- onCheckedChange: () => I(!P),
2144
- text: "Apply Filters"
2145
- }
2146
- ),
2147
- /* @__PURE__ */ e.jsx(_n, {}),
2148
- E && h && /* @__PURE__ */ e.jsx(
2149
- Ve,
2150
- {
2151
- onClick: () => r(!1),
2152
- className: "bg-background/50 text-foreground/50 hover:cursor-pointer hover:text-foreground"
2153
- }
2154
- )
2155
- ] }),
2156
- /* @__PURE__ */ e.jsx(
2157
- qe,
2158
- {
2159
- theme: "default",
2160
- onChange: (p) => {
2161
- if (p)
2162
- try {
2163
- JSON.parse(p), re(JSON.parse(p));
2164
- } catch {
2165
- }
2166
- },
2167
- defaultLanguage: "json",
2168
- className: "mt-1 min-h-[220px]",
2169
- value: JSON.stringify(E, null, 2),
2170
- options: {
2171
- readOnly: !0,
2172
- minimap: {
2173
- enabled: !1
2174
- },
2175
- lineNumbers: "off",
2176
- glyphMargin: !1,
2177
- wordWrap: "on",
2178
- scrollbar: {
2179
- verticalScrollbarSize: 0,
2180
- horizontalScrollbarSize: 0
2181
- },
2182
- fontSize: 12,
2183
- renderLineHighlight: "none"
2184
- }
2185
- }
2186
- )
2187
- ] })
2188
- }
2189
- ),
2190
- E && !h && /* @__PURE__ */ e.jsx(
2191
- st,
2192
- {
2193
- onClick: () => r(!0),
2194
- className: Z(
2195
- "absolute bottom-4 right-6 h-3 w-3 text-foreground/50 hover:cursor-pointer hover:text-foreground",
2196
- {
2197
- "font-bold text-red-800": P
2198
- }
2199
- )
2200
- }
2201
- )
2202
- ] });
2203
- }
2204
- function Ue() {
2205
- return /* @__PURE__ */ e.jsxs(
2206
- ps,
2207
- {
2208
- className: "flex grow pb-1",
2209
- direction: "vertical",
2210
- role: "editor-resizable-group",
2211
- children: [
2212
- /* @__PURE__ */ e.jsxs(
2213
- we,
2214
- {
2215
- id: "1",
2216
- order: 1,
2217
- defaultSize: a ? 20 : 100,
2218
- className: "relative flex grow",
2219
- children: [
2220
- /* @__PURE__ */ e.jsx(
2221
- "div",
2222
- {
2223
- role: "sql-container",
2224
- className: "relative flex w-[99%]",
2225
- children: /* @__PURE__ */ e.jsx(
2226
- qe,
2227
- {
2228
- theme: "default",
2229
- className: "pt-3",
2230
- onChange: (p) => {
2231
- U(p);
2232
- },
2233
- value: M,
2234
- options: {
2235
- minimap: {
2236
- enabled: !1
2237
- },
2238
- wordWrap: "on",
2239
- scrollbar: {
2240
- verticalScrollbarSize: 0,
2241
- horizontalScrollbarSize: 0
2242
- },
2243
- fontSize: 14,
2244
- renderLineHighlight: "none"
2245
- },
2246
- defaultLanguage: "sql",
2247
- beforeMount: Ee,
2248
- onMount: Be
2249
- }
2250
- )
2251
- }
2252
- ),
2253
- a && /* @__PURE__ */ e.jsx("code", { className: "absolute right-6 top-3 text-sm text-muted-foreground/70", children: "sql" })
2254
- ]
2255
- }
2256
- ),
2257
- a && /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
2258
- /* @__PURE__ */ e.jsx(fs, { withHandle: !0, className: "border" }),
2259
- /* @__PURE__ */ e.jsxs(
2260
- we,
2261
- {
2262
- id: "2",
2263
- order: 2,
2264
- defaultSize: 80,
2265
- className: "relative flex grow",
2266
- children: [
2267
- /* @__PURE__ */ e.jsx(
2268
- "div",
2269
- {
2270
- role: "python-container",
2271
- className: "relative flex w-[99%] pt-0",
2272
- children: /* @__PURE__ */ e.jsx(
2273
- qe,
2274
- {
2275
- className: "pt-3",
2276
- theme: "default",
2277
- onChange: (p) => {
2278
- ie(p && p.trim() || "");
2279
- },
2280
- value: N || Ps,
2281
- options: {
2282
- minimap: {
2283
- enabled: !1
2284
- },
2285
- wordWrap: "on",
2286
- scrollbar: {
2287
- verticalScrollbarSize: 0,
2288
- horizontalScrollbarSize: 0
2289
- },
2290
- fontSize: 14,
2291
- renderLineHighlight: "none"
2292
- },
2293
- defaultLanguage: "python",
2294
- beforeMount: Ee,
2295
- onMount: Be
2296
- }
2297
- )
2298
- }
2299
- ),
2300
- /* @__PURE__ */ e.jsx("code", { className: "absolute right-6 top-3 text-sm text-muted-foreground/70", children: "python" })
2301
- ]
2302
- }
2303
- )
2304
- ] })
2305
- ]
2306
- }
2307
- );
2308
- }
2309
- return (
2310
- // This is a tricky css, the pt-8 is to make sure the editor doesn't slide under the header
2311
- /* @__PURE__ */ e.jsxs(
2312
- "section",
2313
- {
2314
- role: "editor-section",
2315
- className: "flex grow flex-col justify-end",
2316
- children: [
2317
- /* @__PURE__ */ e.jsxs(
2318
- "div",
2319
- {
2320
- role: "sql-editor",
2321
- className: "relative flex grow justify-between overflow-y-scroll",
2322
- children: [
2323
- Ue(),
2324
- Ke()
2325
- ]
2326
- }
2327
- ),
2328
- /* @__PURE__ */ e.jsxs(
2329
- "div",
2330
- {
2331
- role: "editor-controls",
2332
- className: "item-center flex flex-wrap justify-between gap-2 px-6 py-4",
2333
- children: [
2334
- /* @__PURE__ */ e.jsxs("div", { className: "flex grow items-center gap-2", children: [
2335
- /* @__PURE__ */ e.jsxs(
2336
- z,
2337
- {
2338
- title: "Shift + Enter",
2339
- disabled: le || oe,
2340
- onClick: () => {
2341
- Ce();
2342
- },
2343
- className: "shrink-0",
2344
- size: "sm",
2345
- variant: "outline",
2346
- children: [
2347
- le || oe ? /* @__PURE__ */ e.jsx($e, { className: "mr-2 h-4 w-4 animate-spin text-foreground/50" }) : /* @__PURE__ */ e.jsx(gn, { className: "mr-2 h-4 w-4" }),
2348
- "Run"
2349
- ]
2350
- }
2351
- ),
2352
- ce && /* @__PURE__ */ e.jsx(
2353
- In,
2354
- {
2355
- error: fe.message,
2356
- setShowAIDialog: c,
2357
- setTriggerAIRun: j,
2358
- setUserInputforAI: u
2359
- }
2360
- ),
2361
- /* @__PURE__ */ e.jsxs(
2362
- z,
2363
- {
2364
- onClick: os,
2365
- className: "",
2366
- size: "sm",
2367
- variant: "outline",
2368
- children: [
2369
- /* @__PURE__ */ e.jsx(rn, { className: "mr-2 size-4" }),
2370
- "Clear"
2371
- ]
2372
- }
2373
- ),
2374
- /* @__PURE__ */ e.jsx(
2375
- it,
2376
- {
2377
- pressed: a,
2378
- onPressedChange: (p) => i(p),
2379
- className: "",
2380
- size: "sm",
2381
- variant: "outline",
2382
- children: /* @__PURE__ */ e.jsx(Qn, { className: "size-4 text-foreground/70" })
2383
- }
2384
- ),
2385
- /* @__PURE__ */ e.jsx(
2386
- Hn,
2387
- {
2388
- open: l,
2389
- setOpen: c,
2390
- userInput: m,
2391
- triggerAIRun: g,
2392
- setTriggerAIRun: j,
2393
- setUserInput: (p) => u(p)
2394
- }
2395
- )
2396
- ] }),
2397
- /* @__PURE__ */ e.jsxs("div", { className: "flex items-end gap-2", children: [
2398
- /* @__PURE__ */ e.jsxs(
2399
- z,
2400
- {
2401
- onClick: ds,
2402
- size: "sm",
2403
- variant: "outline",
2404
- children: [
2405
- /* @__PURE__ */ e.jsx(ia, { className: "mr-2 size-4 font-bold text-green-600" }),
2406
- "Accept"
2407
- ]
2408
- }
2409
- ),
2410
- /* @__PURE__ */ e.jsxs(
2411
- z,
2412
- {
2413
- onClick: Ge,
2414
- className: "w-full",
2415
- size: "sm",
2416
- variant: "outline",
2417
- children: [
2418
- /* @__PURE__ */ e.jsx(Ve, { className: "mr-2 size-4" }),
2419
- "Close"
2420
- ]
2421
- }
2422
- )
2423
- ] })
2424
- ]
2425
- }
2426
- )
2427
- ]
2428
- }
2429
- )
2430
- );
2431
- }
2432
- function Yn({ data: s }) {
2433
- var r;
2434
- const [n, t] = me.useState([]), i = Object.keys(s[0]).map((l) => ({
2435
- // header: key,
2436
- accessorKey: l,
2437
- header: ({ column: c }) => {
2438
- const m = c.getIsSorted();
2439
- return /* @__PURE__ */ e.jsx("div", { className: "flex gap-2", children: /* @__PURE__ */ e.jsxs(
2440
- "div",
2441
- {
2442
- className: "flex cursor-pointer items-center",
2443
- onClick: () => c.toggleSorting(c.getIsSorted() === "asc"),
2444
- children: [
2445
- l,
2446
- m === "asc" ? /* @__PURE__ */ e.jsx(la, { className: "ml-2 h-5 w-5" }) : m === "desc" ? /* @__PURE__ */ e.jsx(oa, { className: "ml-2 h-5 w-5" }) : null
2447
- ]
2448
- }
2449
- ) });
2450
- }
2451
- })), h = ca({
2452
- data: s,
2453
- columns: i,
2454
- getCoreRowModel: xa(),
2455
- getPaginationRowModel: pa(),
2456
- onSortingChange: t,
2457
- getSortedRowModel: fa(),
2458
- manualPagination: !0,
2459
- state: {
2460
- sorting: n
2461
- }
2462
- });
2463
- return /* @__PURE__ */ e.jsxs(da, { children: [
2464
- /* @__PURE__ */ e.jsx(ha, { children: h.getHeaderGroups().map((l) => /* @__PURE__ */ e.jsx(us, { children: l.headers.map((c) => /* @__PURE__ */ e.jsx(ua, { className: "sticky top-0 bg-muted", children: c.isPlaceholder ? null : Bs(
2465
- c.column.columnDef.header,
2466
- c.getContext()
2467
- ) }, c.id)) }, l.id)) }),
2468
- /* @__PURE__ */ e.jsx(ma, { children: (r = h.getRowModel().rows) != null && r.length ? h.getRowModel().rows.map((l) => /* @__PURE__ */ e.jsx(
2469
- us,
2470
- {
2471
- className: "whitespace-nowrap py-2",
2472
- "data-state": l.getIsSelected() && "selected",
2473
- children: l.getVisibleCells().map((c) => /* @__PURE__ */ e.jsx(Gs, { children: Bs(c.column.columnDef.cell, c.getContext()) }, c.id))
2474
- },
2475
- l.id
2476
- )) : /* @__PURE__ */ e.jsx(us, { children: /* @__PURE__ */ e.jsx(Gs, { colSpan: i.length, className: "h-24 text-center", children: "No results." }) }) })
2477
- ] });
2478
- }
2479
- function wt({
2480
- // card,
2481
- // showCard,
2482
- className: s,
2483
- ...n
2484
- }) {
2485
- var j;
2486
- me.useState(0);
2487
- const t = w((d) => d.themeStyle), a = o((d) => d.card), i = o((d) => d.frame), h = w((d) => d.dashboard.filters), r = w((d) => d.filterValues), l = o((d) => d.actions.setRunSql), { updateFilter: c } = js(), m = h == null ? void 0 : h.find((d) => d.id === i.filterId), u = o((d) => d.actions.setCard);
2488
- if (Y(() => {
2489
- a.sql && l(!0);
2490
- }, [r]), Y(() => {
2491
- }, [
2492
- a.data,
2493
- a.type,
2494
- a.cfg,
2495
- a.customCfg,
2496
- t,
2497
- a.preferences
2498
- ]), !a.id)
2499
- return null;
2500
- let g;
2501
- return a.data && a.data.length > 0 && (g = dt({
2502
- data: a.data,
2503
- cardType: a.type,
2504
- cfg: a.cfg,
2505
- customCfg: a.customCfg,
2506
- preferences: a.preferences
2507
- })), /* @__PURE__ */ e.jsxs(
2508
- ga,
2509
- {
2510
- role: "editor-visual-card",
2511
- className: Z("relative flex h-full flex-col rounded-none", s),
2512
- ...n,
2513
- children: [
2514
- /* @__PURE__ */ e.jsxs(ja, { className: "flex flex-row items-start justify-between py-4", children: [
2515
- /* @__PURE__ */ e.jsxs("div", { children: [
2516
- /* @__PURE__ */ e.jsx(
2517
- Qe,
2518
- {
2519
- text: a.title,
2520
- onSave: (d) => u({ ...a, title: d }),
2521
- children: /* @__PURE__ */ e.jsx("div", { className: "flex items-center gap-2", children: /* @__PURE__ */ e.jsx(ba, { className: "text-base", children: a.title }) })
2522
- },
2523
- a.title
2524
- ),
2525
- /* @__PURE__ */ e.jsx(
2526
- Qe,
2527
- {
2528
- text: a.description || "",
2529
- onSave: (d) => u({ ...a, description: d }),
2530
- children: /* @__PURE__ */ e.jsxs(ya, { children: [
2531
- " ",
2532
- a.description
2533
- ] })
2534
- },
2535
- a.description
2536
- )
2537
- ] }),
2538
- m && /* @__PURE__ */ e.jsxs("div", { className: "flex items-center gap-3", children: [
2539
- /* @__PURE__ */ e.jsx(
2540
- Qe,
2541
- {
2542
- className: "my-1",
2543
- text: m.title || m.column,
2544
- onSave: (d) => c({ ...m, title: d }),
2545
- children: /* @__PURE__ */ e.jsx(H, { children: m.title })
2546
- }
2547
- ),
2548
- va(m)
2549
- ] })
2550
- ] }),
2551
- /* @__PURE__ */ e.jsxs(Na, { className: "flex grow flex-col pb-3", children: [
2552
- a.type !== "table" && g && // <ChartJsVisual key={visualKey} cfg={cfg} />
2553
- /* @__PURE__ */ e.jsx(
2554
- Ca,
2555
- {
2556
- cfg: g
2557
- },
2558
- JSON.stringify(g) + JSON.stringify(a.preferences) + ((j = a == null ? void 0 : a.preferences) == null ? void 0 : j.customVisualCode)
2559
- ),
2560
- a.type === "table" && a.data && a.data.length > 0 && // All of the below css classes are #IMPORTANT for the table to scroll properly
2561
- /* @__PURE__ */ e.jsx(Sa, { className: "flex min-h-0 flex-1 grow basis-0", children: /* @__PURE__ */ e.jsx(wa, { card: a, data: a == null ? void 0 : a.data }) })
2562
- ] })
2563
- ]
2564
- }
2565
- );
2566
- }
2567
- function Zn() {
2568
- const [s, n] = A(!1), [t, a] = A(""), [i, h] = A(""), [r, l] = A(""), [c, m] = A(""), u = o((v) => v.card), g = o(
2569
- (v) => v.card.customCfg
2570
- ), { setCardCustomCfg: j, setCustomVisualCode: d } = as();
2571
- function x(v) {
2572
- var S, M;
2573
- const V = {
2574
- ...v,
2575
- data: {
2576
- ...v == null ? void 0 : v.data,
2577
- datasets: (M = (S = v == null ? void 0 : v.data) == null ? void 0 : S.datasets) == null ? void 0 : M.map((N) => ({
2578
- ...N,
2579
- data: []
2580
- }))
2581
- }
2582
- };
2583
- return JSON.stringify(V, null, 1);
2584
- }
2585
- function y() {
2586
- var V, _;
2587
- if (!u.data || u.data.length === 0)
2588
- return;
2589
- const v = dt({
2590
- data: u.data,
2591
- cardType: u.type,
2592
- cfg: u.cfg,
2593
- preferences: u.preferences
2594
- });
2595
- v && (a(JSON.stringify(v, null, 1)), (V = u == null ? void 0 : u.preferences) != null && V.customVisualCode && l((_ = u == null ? void 0 : u.preferences) == null ? void 0 : _.customVisualCode), g && h(JSON.stringify(g, null, 1)));
2596
- }
2597
- function f() {
2598
- if (r && d(r), !!i)
2599
- try {
2600
- const v = JSON.parse(i);
2601
- return v ? (j(v), m(""), h(""), v) : void 0;
2602
- } catch (v) {
2603
- console.log(v), m("Invalid JSON");
2604
- }
2605
- }
2606
- function L() {
2607
- h(""), j(null);
2608
- }
2609
- function O() {
2610
- let v;
2611
- if (g) {
2612
- const V = Ks.cloneDeep(u.cfg), _ = Ks.merge(V, g);
2613
- return v = x(_), v;
2614
- }
2615
- return t ? (v = x(JSON.parse(t)), v) : "";
2616
- }
2617
- return /* @__PURE__ */ e.jsxs(bs, { open: s, onOpenChange: n, children: [
2618
- /* @__PURE__ */ e.jsx(ys, { asChild: !0, children: /* @__PURE__ */ e.jsx(
2619
- z,
2620
- {
2621
- onClick: y,
2622
- className: ` ${g && "border-foreground/50 dark:border-foreground/70"}`,
2623
- size: "sm",
2624
- variant: "outline",
2625
- children: /* @__PURE__ */ e.jsx(ka, { className: "h-4 w-4" })
2626
- }
2627
- ) }),
2628
- /* @__PURE__ */ e.jsxs(
2629
- Ns,
2630
- {
2631
- className: "max-h-[70vh] min-h-[70vh] overflow-auto sm:min-w-[900px] lg:min-w-[1200px]",
2632
- children: [
2633
- /* @__PURE__ */ e.jsxs(Cs, { className: "", children: [
2634
- /* @__PURE__ */ e.jsxs("div", { className: "flex items-center gap-2", children: [
2635
- /* @__PURE__ */ e.jsx(Ss, { children: "Customize Card" }),
2636
- /* @__PURE__ */ e.jsxs(ks, { children: [
2637
- /* @__PURE__ */ e.jsx(tt, { children: /* @__PURE__ */ e.jsx(
2638
- hn,
2639
- {
2640
- onClick: () => {
2641
- navigator.clipboard.writeText(u.id);
2642
- },
2643
- className: "size-3 cursor-pointer text-muted-foreground/70 transition-colors hover:text-muted-foreground"
2644
- }
2645
- ) }),
2646
- /* @__PURE__ */ e.jsx(zs, { side: "right", align: "center", children: /* @__PURE__ */ e.jsx("p", { className: "text-xs", children: "Copy Card ID" }) })
2647
- ] })
2648
- ] }),
2649
- /* @__PURE__ */ e.jsxs(ws, { children: [
2650
- "See the configuration options and documentation",
2651
- /* @__PURE__ */ e.jsx(
2652
- "a",
2653
- {
2654
- target: "_blank",
2655
- className: "ml-1 text-blue-500 underline",
2656
- href: "https://www.chartjs.org/docs/latest/samples/bar/vertical.html",
2657
- children: "here."
2658
- }
2659
- )
2660
- ] })
2661
- ] }),
2662
- /* @__PURE__ */ e.jsxs("div", { className: "flex grow gap-2", children: [
2663
- /* @__PURE__ */ e.jsx(wt, { className: "w-1/2 rounded shadow-none" }),
2664
- /* @__PURE__ */ e.jsxs(ht, { defaultValue: "custom-config", className: "flex w-1/2 flex-col", children: [
2665
- /* @__PURE__ */ e.jsxs(ut, { className: "justify-start rounded-sm rounded-b-none border border-b-0", children: [
2666
- /* @__PURE__ */ e.jsxs(Je, { value: "custom-config", children: [
2667
- g && /* @__PURE__ */ e.jsx(mt, { className: "mr-1 h-5 w-5 text-green-600" }),
2668
- g ? "Custom Config" : "Default Config"
2669
- ] }),
2670
- /* @__PURE__ */ e.jsx(Je, { className: "", value: "output", children: "Output" }),
2671
- /* @__PURE__ */ e.jsx(Je, { className: "", value: "custom-code", children: "Custom Code" })
2672
- ] }),
2673
- /* @__PURE__ */ e.jsx(
2674
- Ye,
2675
- {
2676
- className: "bg-red-x mt-0 grow rounded-b border border-t-0 p-2",
2677
- value: "output",
2678
- children: /* @__PURE__ */ e.jsx(
2679
- ct,
2680
- {
2681
- disabled: !0,
2682
- value: t,
2683
- className: "h-full resize-none border-none font-mono focus-visible:ring-0 focus-visible:ring-offset-0"
2684
- }
2685
- )
2686
- }
2687
- ),
2688
- /* @__PURE__ */ e.jsx(
2689
- Ye,
2690
- {
2691
- className: "mt-0 grow rounded-b border border-t-0",
2692
- value: "custom-config",
2693
- children: /* @__PURE__ */ e.jsx(
2694
- qe,
2695
- {
2696
- className: "h-full w-full overflow-hidden",
2697
- theme: "default",
2698
- options: {
2699
- minimap: {
2700
- enabled: !1
2701
- },
2702
- wordWrap: "on",
2703
- scrollbar: {
2704
- verticalScrollbarSize: 0,
2705
- horizontalScrollbarSize: 0
2706
- },
2707
- fontSize: 14,
2708
- renderLineHighlight: "none"
2709
- },
2710
- defaultLanguage: "json",
2711
- value: O(),
2712
- onChange: (v) => h(v)
2713
- }
2714
- )
2715
- }
2716
- ),
2717
- /* @__PURE__ */ e.jsx(
2718
- Ye,
2719
- {
2720
- className: "mt-0 grow rounded-b border border-t-0",
2721
- value: "custom-code",
2722
- children: /* @__PURE__ */ e.jsx(
2723
- qe,
2724
- {
2725
- className: "h-full w-full overflow-hidden",
2726
- theme: "default",
2727
- options: {
2728
- minimap: {
2729
- enabled: !1
2730
- },
2731
- wordWrap: "on",
2732
- scrollbar: {
2733
- verticalScrollbarSize: 0,
2734
- horizontalScrollbarSize: 0
2735
- },
2736
- fontSize: 14,
2737
- renderLineHighlight: "none"
2738
- },
2739
- defaultLanguage: "javascript",
2740
- value: r,
2741
- onChange: (v) => l(v || "")
2742
- }
2743
- )
2744
- }
2745
- )
2746
- ] })
2747
- ] }),
2748
- /* @__PURE__ */ e.jsxs(et, { className: "flex items-center", children: [
2749
- /* @__PURE__ */ e.jsx(H, { className: "mr-2 text-red-500", children: c }),
2750
- /* @__PURE__ */ e.jsx(
2751
- z,
2752
- {
2753
- disabled: !g,
2754
- onClick: L,
2755
- variant: "outline",
2756
- children: "Reset"
2757
- }
2758
- ),
2759
- /* @__PURE__ */ e.jsx(z, { onClick: f, variant: "outline", children: "Apply" }),
2760
- /* @__PURE__ */ e.jsx(z, { onClick: () => n(!1), variant: "outline", children: "Close" })
2761
- ] })
2762
- ]
2763
- }
2764
- )
2765
- ] });
2766
- }
2767
- function kt(s) {
2768
- return xe({ tag: "svg", attr: { viewBox: "0 0 1024 1024" }, child: [{ tag: "path", attr: { d: "M926.8 397.1l-396-288a31.81 31.81 0 0 0-37.6 0l-396 288a31.99 31.99 0 0 0-11.6 35.8l151.3 466a32 32 0 0 0 30.4 22.1h489.5c13.9 0 26.1-8.9 30.4-22.1l151.3-466c4.2-13.2-.5-27.6-11.7-35.8zM838.6 417l-98.5 32-200-144.7V199.9L838.6 417zM466 567.2l-89.1 122.3-55.2-169.2L466 567.2zm-116.3-96.8L484 373.3v140.8l-134.3-43.7zM512 599.2l93.9 128.9H418.1L512 599.2zm28.1-225.9l134.2 97.1L540.1 514V373.3zM558 567.2l144.3-46.9-55.2 169.2L558 567.2zm-74-367.3v104.4L283.9 449l-98.5-32L484 199.9zM169.3 470.8l86.5 28.1 80.4 246.4-53.8 73.9-113.1-348.4zM327.1 853l50.3-69h269.3l50.3 69H327.1zm414.5-33.8l-53.8-73.9 80.4-246.4 86.5-28.1-113.1 348.4z" }, child: [] }] })(s);
2769
- }
2770
- function zt(s) {
2771
- return xe({ tag: "svg", attr: { viewBox: "0 0 256 256", fill: "currentColor" }, child: [{ tag: "path", attr: { d: "M137.39,24.06A16,16,0,0,0,120,40V80.67a15.86,15.86,0,0,0,13.25,15.76A32,32,0,1,1,96,129.68c-.41-8.22,1.27-15,5-20.26h0a15.86,15.86,0,0,0-1.69-20.47L71.69,60.68a16,16,0,0,0-23.63,1.1A103.6,103.6,0,0,0,55,202.05,103.24,103.24,0,0,0,128,232h1.49A104.3,104.3,0,0,0,232,129.48C232.75,75.18,191.19,28.88,137.39,24.06ZM60.32,71.94l27.61,28.19,0,.06A43.29,43.29,0,0,0,80.44,120H40.36A87.13,87.13,0,0,1,60.32,71.94ZM40.37,136h40.3A48,48,0,0,0,120,175.34v40.3A88,88,0,0,1,40.37,136Zm149.77,54.14A87.45,87.45,0,0,1,136,215.61V175.34a47.55,47.55,0,0,0,24.73-12.23A48,48,0,0,0,136,80.66L136,40c45.52,4.08,80.67,43.28,80,89.25A87.45,87.45,0,0,1,190.14,190.14Z" }, child: [] }] })(s);
2772
- }
2773
- function Ft(s) {
2774
- return xe({ tag: "svg", attr: { viewBox: "0 0 256 256", fill: "currentColor" }, child: [{ tag: "path", attr: { d: "M128,24A104,104,0,1,0,232,128,104.11,104.11,0,0,0,128,24Zm87.63,96H191.48A64.1,64.1,0,0,0,136,64.52V40.37A88.13,88.13,0,0,1,215.63,120ZM120,120H80.68A48.09,48.09,0,0,1,120,80.68Zm0,16v39.32A48.09,48.09,0,0,1,80.68,136Zm16,0h39.32A48.09,48.09,0,0,1,136,175.32Zm0-16V80.68A48.09,48.09,0,0,1,175.32,120ZM120,40.37V64.52A64.1,64.1,0,0,0,64.52,120H40.37A88.13,88.13,0,0,1,120,40.37ZM40.37,136H64.52A64.1,64.1,0,0,0,120,191.48v24.15A88.13,88.13,0,0,1,40.37,136ZM136,215.63V191.48A64.1,64.1,0,0,0,191.48,136h24.15A88.13,88.13,0,0,1,136,215.63Z" }, child: [] }] })(s);
2775
- }
2776
- function Lt(s) {
2777
- return xe({ tag: "svg", attr: { viewBox: "0 0 24 24", strokeWidth: "2", stroke: "currentColor", fill: "none", strokeLinecap: "round", strokeLinejoin: "round" }, child: [{ tag: "path", attr: { stroke: "none", d: "M0 0h24v24H0z", fill: "none" }, child: [] }, { tag: "path", attr: { d: "M6 16m-3 0a3 3 0 1 0 6 0a3 3 0 1 0 -6 0" }, child: [] }, { tag: "path", attr: { d: "M16 19m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0" }, child: [] }, { tag: "path", attr: { d: "M14.5 7.5m-4.5 0a4.5 4.5 0 1 0 9 0a4.5 4.5 0 1 0 -9 0" }, child: [] }] })(s);
2778
- }
2779
- function Mt(s) {
2780
- return xe({ tag: "svg", attr: { viewBox: "0 0 24 24" }, child: [{ tag: "path", attr: { fill: "none", d: "M0 0h24v24H0z" }, child: [] }, { tag: "path", attr: { d: "m2 19.99 7.5-7.51 4 4 7.09-7.97L22 9.92l-8.5 9.56-4-4-6 6.01-1.5-1.5zm1.5-4.5 6-6.01 4 4L22 3.92l-1.41-1.41-7.09 7.97-4-4L2 13.99l1.5 1.5z" }, child: [] }] })(s);
2781
- }
2782
- function Ot(s) {
2783
- return xe({ tag: "svg", attr: { viewBox: "0 0 24 24" }, child: [{ tag: "path", attr: { fill: "none", d: "M0 0h24v24H0z" }, child: [] }, { tag: "path", attr: { d: "M4 9h4v11H4zM4 4h4v4H4zM10 7h4v4h-4zM16 10h4v4h-4zM16 15h4v5h-4zM10 12h4v8h-4z" }, child: [] }] })(s);
2784
- }
2785
- function Dt(s) {
2786
- return xe({ tag: "svg", attr: { version: "1.2", baseProfile: "tiny", viewBox: "0 0 24 24" }, child: [{ tag: "path", attr: { d: "M4 18c-.552 0-1-.448-1-1v-6.382l-.553.276c-.495.248-1.095.046-1.342-.447-.247-.494-.046-1.094.448-1.342l2-1c.31-.155.678-.139.973.044.294.183.474.504.474.851v8c0 .552-.448 1-1 1zM13 18h-5c-.404 0-.769-.244-.924-.617-.155-.374-.069-.804.217-1.09l4-4c.254-.254.394-.591.394-.95 0-.358-.14-.695-.394-.949-.508-.508-1.39-.508-1.9.001-.253.252-.393.589-.393.948 0 .552-.448 1-1 1s-1-.448-1-1c0-.894.348-1.733.98-2.364 1.265-1.263 3.464-1.263 4.727.001.632.631.979 1.471.979 2.363 0 .893-.348 1.733-.979 2.364l-2.293 2.293h2.586c.552 0 1 .448 1 1s-.448 1-1 1zM20.955 12.377c.338-.457.545-1.016.545-1.627 0-1.517-1.234-2.75-2.75-2.75-1.031 0-1.966.569-2.44 1.484-.254.49-.063 1.094.428 1.348.49.254 1.094.062 1.348-.428.128-.249.383-.404.664-.404.414 0 .75.336.75.75s-.336.75-.75.75c-.552 0-1 .448-1 1s.448 1 1 1c.689 0 1.25.561 1.25 1.25s-.561 1.25-1.25 1.25-1.25-.561-1.25-1.25c0-.552-.448-1-1-1s-1 .448-1 1c0 1.792 1.458 3.25 3.25 3.25s3.25-1.458 3.25-3.25c0-.939-.406-1.779-1.045-2.373z" }, child: [] }] })(s);
2787
- }
2788
- function Tt(s) {
2789
- return xe({ tag: "svg", attr: { viewBox: "0 0 512 512" }, child: [{ tag: "path", attr: { d: "M217 25v14h78V25h-78zm0 32v46h14V71h50v32h14V57h-78zm32 32v14h14V89h-14zm-64 32v46h30v-46h-30zm48 0v14h46v-14h-46zm64 0v46h30v-46h-30zm-64 32v14h46v-14h-46zm-80 32v46h62v-46h-62zm80 0v14h46v-14h-46zm64 0v46h62v-46h-62zm-64 32v14h46v-14h-46zm-112 32v46h94v-46h-94zm112 0v14h46v-14h-46zm64 0v46h94v-46h-94zm-64 32v14h46v-14h-46zM89 313v46h126v-46H89zm144 0v14h46v-14h-46zm64 0v46h126v-46H297zm-64 32v14h46v-14h-46zM57 377v46h158v-46H57zm176 0v14h46v-14h-46zm64 0v46h158v-46H297zm-64 32v14h46v-14h-46zM25 441v46h190v-46H25zm208 0v14h46v-14h-46zm64 0v46h190v-46H297zm-64 32v14h46v-14h-46z" }, child: [] }] })(s);
2790
- }
2791
- function Xn() {
2792
- const [s, n] = A(!1), t = o((c) => c.card.type), { setCardType: a, setCardPreferences: i, setChartOrientation: h } = o((c) => c.actions), r = o(
2793
- (c) => c.actions.setCardCustomCfg
2794
- );
2795
- function l(c) {
2796
- r(null), i({}), a(c), n(!1);
2797
- }
2798
- return /* @__PURE__ */ e.jsxs(ns, { open: s, onOpenChange: n, children: [
2799
- /* @__PURE__ */ e.jsx(rs, { asChild: !0, children: /* @__PURE__ */ e.jsx(z, { size: "sm", variant: "outline", children: /* @__PURE__ */ e.jsx(er, { className: "h-4 w-4", chartType: t }) }) }),
2800
- /* @__PURE__ */ e.jsx(is, { className: "w-50", children: /* @__PURE__ */ e.jsxs("div", { className: "grid grid-cols-3 place-items-center", children: [
2801
- /* @__PURE__ */ e.jsx(
2802
- z,
2803
- {
2804
- onClick: () => l("bar"),
2805
- className: "font-normal",
2806
- variant: "ghost",
2807
- children: /* @__PURE__ */ e.jsx(Es, { className: "size-5" })
2808
- }
2809
- ),
2810
- /* @__PURE__ */ e.jsx(
2811
- z,
2812
- {
2813
- onClick: () => l("line"),
2814
- variant: "ghost",
2815
- children: /* @__PURE__ */ e.jsx(Is, { className: "size-5" })
2816
- }
2817
- ),
2818
- /* @__PURE__ */ e.jsx(
2819
- z,
2820
- {
2821
- onClick: () => l("stackedBar"),
2822
- variant: "ghost",
2823
- children: /* @__PURE__ */ e.jsx(Ot, { className: "size-5", strokeWidth: 0 })
2824
- }
2825
- ),
2826
- /* @__PURE__ */ e.jsx(
2827
- z,
2828
- {
2829
- onClick: () => l("stackedLine"),
2830
- variant: "ghost",
2831
- children: /* @__PURE__ */ e.jsx(Mt, { className: "size-5", strokeWidth: 0 })
2832
- }
2833
- ),
2834
- /* @__PURE__ */ e.jsx(
2835
- z,
2836
- {
2837
- onClick: () => l("scatter"),
2838
- variant: "ghost",
2839
- children: /* @__PURE__ */ e.jsx(bt, { className: "size-5" })
2840
- }
2841
- ),
2842
- /* @__PURE__ */ e.jsx(
2843
- z,
2844
- {
2845
- onClick: () => l("bubble"),
2846
- variant: "ghost",
2847
- children: /* @__PURE__ */ e.jsx(Lt, { className: "size-4" })
2848
- }
2849
- ),
2850
- /* @__PURE__ */ e.jsx(
2851
- z,
2852
- {
2853
- onClick: () => l("pie"),
2854
- variant: "ghost",
2855
- children: /* @__PURE__ */ e.jsx(jt, { className: "size-5" })
2856
- }
2857
- ),
2858
- /* @__PURE__ */ e.jsx(
2859
- z,
2860
- {
2861
- onClick: () => l("doughnut"),
2862
- variant: "ghost",
2863
- children: /* @__PURE__ */ e.jsx(zt, { className: "size-5", strokeWidth: 1 })
2864
- }
2865
- ),
2866
- /* @__PURE__ */ e.jsx(
2867
- z,
2868
- {
2869
- onClick: () => l("radar"),
2870
- variant: "ghost",
2871
- children: /* @__PURE__ */ e.jsx(
2872
- kt,
2873
- {
2874
- className: "size-5 font-extralight",
2875
- strokeWidth: 0.5
2876
- }
2877
- )
2878
- }
2879
- ),
2880
- /* @__PURE__ */ e.jsx(
2881
- z,
2882
- {
2883
- onClick: () => l("polarArea"),
2884
- variant: "ghost",
2885
- children: /* @__PURE__ */ e.jsx(Ft, { className: "size-5" })
2886
- }
2887
- ),
2888
- /* @__PURE__ */ e.jsx(
2889
- z,
2890
- {
2891
- onClick: () => l("pyramid"),
2892
- variant: "ghost",
2893
- children: /* @__PURE__ */ e.jsx(Tt, { className: "size-5" })
2894
- }
2895
- ),
2896
- /* @__PURE__ */ e.jsx(
2897
- z,
2898
- {
2899
- onClick: () => l("range"),
2900
- variant: "ghost",
2901
- children: /* @__PURE__ */ e.jsx(ft, { className: "size-5" })
2902
- }
2903
- ),
2904
- /* @__PURE__ */ e.jsx(
2905
- z,
2906
- {
2907
- onClick: () => l("table"),
2908
- variant: "ghost",
2909
- children: /* @__PURE__ */ e.jsx(Fs, { className: "size-5" })
2910
- }
2911
- ),
2912
- /* @__PURE__ */ e.jsx(
2913
- z,
2914
- {
2915
- onClick: () => l("kpi"),
2916
- variant: "ghost",
2917
- children: /* @__PURE__ */ e.jsx(Dt, { className: "size-6" })
2918
- }
2919
- ),
2920
- /* @__PURE__ */ e.jsx(
2921
- z,
2922
- {
2923
- onClick: () => l("text"),
2924
- variant: "ghost",
2925
- children: /* @__PURE__ */ e.jsx(qs, { className: "size-4" })
2926
- }
2927
- )
2928
- ] }) })
2929
- ] });
2930
- }
2931
- function er({ chartType: s, className: n }) {
2932
- switch (s) {
2933
- case "bar":
2934
- return /* @__PURE__ */ e.jsx(Es, { className: n });
2935
- case "line":
2936
- return /* @__PURE__ */ e.jsx(Is, { className: n });
2937
- case "pie":
2938
- return /* @__PURE__ */ e.jsx(jt, { className: n });
2939
- case "radar":
2940
- return /* @__PURE__ */ e.jsx(kt, { className: n });
2941
- case "scatter":
2942
- return /* @__PURE__ */ e.jsx(bt, { className: n });
2943
- case "bubble":
2944
- return /* @__PURE__ */ e.jsx(Lt, { className: n });
2945
- case "doughnut":
2946
- return /* @__PURE__ */ e.jsx(zt, { className: n });
2947
- case "stackedBar":
2948
- return /* @__PURE__ */ e.jsx(Ot, { className: "size-4 text-foreground/70" });
2949
- case "stackedLine":
2950
- return /* @__PURE__ */ e.jsx(Mt, { className: "size-4 text-foreground/70" });
2951
- case "polarArea":
2952
- return /* @__PURE__ */ e.jsx(Ft, { className: n });
2953
- case "pyramid":
2954
- return /* @__PURE__ */ e.jsx(Tt, { className: n });
2955
- case "range":
2956
- return /* @__PURE__ */ e.jsx(ft, { className: n });
2957
- case "kpi":
2958
- return /* @__PURE__ */ e.jsx(Dt, { className: n });
2959
- case "text":
2960
- return /* @__PURE__ */ e.jsx(qs, { className: n });
2961
- default:
2962
- return /* @__PURE__ */ e.jsx(Fs, { className: n });
2963
- }
2964
- }
2965
- function Zs() {
2966
- const s = o((f) => f.frame), n = o((f) => f.card), t = o((f) => f.card.data), a = o((f) => f.isShowingVisual), i = o((f) => f.isSqlRunning), h = o((f) => f.queryError), r = o((f) => f.pythonStdOut), l = o((f) => f.actions.setRunSql);
2967
- o((f) => f.onSave), o((f) => f.onClose), o((f) => f.actions.setCardSql), o((f) => f.actions.setCardType), o((f) => f.actions.setSqlGen);
2968
- const { setFrame: c, setCard: m, updateCardInFrame: u } = as();
2969
- if (!n)
2970
- return /* @__PURE__ */ e.jsx(e.Fragment, { children: "No Active Card" });
2971
- function g() {
2972
- const f = {
2973
- id: Ze(),
2974
- title: "Title",
2975
- description: "Description",
2976
- preferences: {
2977
- onClickFilter: [
2978
- {
2979
- columnIndex: 0,
2980
- expression: ""
2981
- }
2982
- ]
2983
- },
2984
- type: "bar",
2985
- sql: "",
2986
- data: []
2987
- }, L = {
2988
- ...s,
2989
- cards: [...s.cards, f],
2990
- activeCardId: f.id
2991
- };
2992
- c(L), m(f);
2993
- }
2994
- function j(f) {
2995
- const L = s.cards.filter((V) => V.id !== f), O = L[0], v = {
2996
- ...s,
2997
- cards: L,
2998
- // update the active card to the first card in the frame
2999
- activeCardId: O.id
3000
- };
3001
- c(v), m(O);
3002
- }
3003
- function d(f) {
3004
- const L = {
3005
- ...s,
3006
- cards: s.cards.map((v) => v.id === n.id ? n : v),
3007
- activeCardId: f
3008
- };
3009
- c(L);
3010
- const O = L.cards.find((v) => v.id === f);
3011
- m(O), O.sql && (console.log("newActiveCard.sql", O.sql), O.data && O.data.length === 0 && l(!0));
3012
- }
3013
- function x() {
3014
- return /* @__PURE__ */ e.jsxs(
3015
- ht,
3016
- {
3017
- onValueChange: d,
3018
- value: s.activeCardId,
3019
- className: "flex grow flex-col pb-3",
3020
- children: [
3021
- s.cards.map((f) => /* @__PURE__ */ e.jsx(Ye, { className: "mt-0 grow", value: f.id, children: y() }, f.id)),
3022
- /* @__PURE__ */ e.jsx(ut, { className: "mx-6 justify-between", children: /* @__PURE__ */ e.jsxs("div", { className: "flex items-center", children: [
3023
- s.cards.map((f) => /* @__PURE__ */ e.jsx(
3024
- Qe,
3025
- {
3026
- text: f.tabTitle || f.title,
3027
- onSave: (L) => {
3028
- m({ ...n, tabTitle: L }), u({ ...n, tabTitle: L });
3029
- },
3030
- children: /* @__PURE__ */ e.jsxs(Je, { className: "", value: f.id, children: [
3031
- f.tabTitle || f.title,
3032
- s.activeCardId === f.id && s.cards.length > 1 && /* @__PURE__ */ e.jsx(
3033
- xt,
3034
- {
3035
- className: "ml-2 size-3.5 text-muted-foreground hover:text-foreground",
3036
- onClick: () => j(f.id)
3037
- }
3038
- )
3039
- ] })
3040
- },
3041
- f.id
3042
- )),
3043
- /* @__PURE__ */ e.jsx(
3044
- z,
3045
- {
3046
- className: "ml-1 h-8 px-2 hover:bg-muted-foreground/50",
3047
- variant: "outline",
3048
- onClick: g,
3049
- children: /* @__PURE__ */ e.jsx(vs, { className: "h-4 w-4" })
3050
- }
3051
- )
3052
- ] }) })
3053
- ]
3054
- }
3055
- );
3056
- }
3057
- function y() {
3058
- return n.type === "kpi" ? /* @__PURE__ */ e.jsx("div", { className: "flex h-full items-center justify-center", children: /* @__PURE__ */ e.jsx("div", { className: "w-1/2 rounded-md border", children: /* @__PURE__ */ e.jsx(za, { isLoading: i, card: n }) }) }) : n.type === "text" ? /* @__PURE__ */ e.jsx("div", { className: "flex h-full items-center justify-center", children: /* @__PURE__ */ e.jsx("div", { className: "w-1/2 rounded-md border", children: /* @__PURE__ */ e.jsx(Fa, { isLoading: i, card: n }) }) }) : /* @__PURE__ */ e.jsx(wt, { className: "grow border-none shadow-none" });
3059
- }
3060
- return /* @__PURE__ */ e.jsxs("div", { className: "relative flex h-full flex-col pt-3", children: [
3061
- i && /* @__PURE__ */ e.jsx($e, { className: "absolute bottom-0 left-0 right-0 top-0 z-10 m-auto h-10 w-10 animate-spin text-foreground/10" }),
3062
- /* @__PURE__ */ e.jsxs("div", { className: "mb-0 flex min-h-10 items-center justify-end gap-2 px-6", children: [
3063
- a && /* @__PURE__ */ e.jsxs("div", { className: "flex grow items-center gap-2", children: [
3064
- /* @__PURE__ */ e.jsx(Xn, {}),
3065
- n.type !== "table" && /* @__PURE__ */ e.jsx(Zn, {})
3066
- ] }),
3067
- /* @__PURE__ */ e.jsx(tr, {})
3068
- ] }),
3069
- a ? x() : /* @__PURE__ */ e.jsxs("div", { className: "flex min-h-0 w-full flex-1 grow basis-0 px-6", children: [
3070
- r && /* @__PURE__ */ e.jsx(sr, {}),
3071
- n.data && n.data.length > 0 && /* @__PURE__ */ e.jsx(Yn, { data: t || [] }),
3072
- h && /* @__PURE__ */ e.jsx("span", { className: "font-mono text-sm", children: h })
3073
- ] })
3074
- ] });
3075
- }
3076
- function sr() {
3077
- const s = o((t) => t.pythonStdOut);
3078
- if (!s)
3079
- return null;
3080
- const n = s.replace(/\n/g, "<br>");
3081
- return /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
3082
- /* @__PURE__ */ e.jsx("p", { className: "font-mono text-sm", children: "Output:" }),
3083
- /* @__PURE__ */ e.jsx(
3084
- "div",
3085
- {
3086
- dangerouslySetInnerHTML: { __html: n },
3087
- className: "bg-muted p-2 font-mono text-sm"
3088
- }
3089
- ),
3090
- /* @__PURE__ */ e.jsx(Re, { className: "mb-2" })
3091
- ] });
3092
- }
3093
- function tr() {
3094
- const s = o((t) => t.isShowingVisual), n = o(
3095
- (t) => t.actions.setIsShowingVisual
3096
- );
3097
- return /* @__PURE__ */ e.jsxs("div", { className: "flex items-center space-x-2", children: [
3098
- /* @__PURE__ */ e.jsx(H, { htmlFor: "visualize", children: "Chart" }),
3099
- /* @__PURE__ */ e.jsx(
3100
- La,
3101
- {
3102
- checked: s,
3103
- onCheckedChange: () => n(!s),
3104
- id: "visualize",
3105
- className: "data-[state=checked]:bg-foreground/50"
3106
- }
3107
- )
3108
- ] });
3109
- }
3110
- function Te() {
3111
- const [s, n] = A([]);
3112
- o(
3113
- (u) => u.card.cfg
3114
- );
3115
- const t = o((u) => u.card.preferences), { setCardCfg: a, setFilterOnClickColumnIndex: i, setCardPreferences: h } = o((u) => u.actions), r = o(
3116
- (u) => u.queryResultColumns
3117
- );
3118
- o(
3119
- (u) => {
3120
- var g;
3121
- return (g = u.card.preferences) == null ? void 0 : g.filterOnClickColumnIndex;
3122
- }
3123
- ), Y(() => {
3124
- r && n(new Array(r.length).fill(!1));
3125
- }, [r]);
3126
- function l(u, g) {
3127
- var j, d;
3128
- g ? t != null && t.onClickFilter && ((j = t == null ? void 0 : t.onClickFilter) == null ? void 0 : j.length) > 0 ? h({
3129
- ...t,
3130
- onClickFilter: [
3131
- ...t.onClickFilter,
3132
- {
3133
- columnIndex: u,
3134
- expression: ""
3135
- }
3136
- ]
3137
- }) : h({
3138
- ...t,
3139
- onClickFilter: [
3140
- {
3141
- columnIndex: u,
3142
- expression: ""
3143
- }
3144
- ]
3145
- }) : (h({
3146
- ...t,
3147
- onClickFilter: (d = t == null ? void 0 : t.onClickFilter) == null ? void 0 : d.filter(
3148
- (x) => x.columnIndex !== u
3149
- )
3150
- }), n((x) => {
3151
- const y = [...x];
3152
- return y[u] = !1, y;
3153
- }));
3154
- }
3155
- function c(u, g) {
3156
- var d;
3157
- const j = (d = t == null ? void 0 : t.onClickFilter) == null ? void 0 : d.map((x) => x.columnIndex === u ? {
3158
- ...x,
3159
- expression: g.target.value
3160
- } : x);
3161
- h({
3162
- ...t,
3163
- onClickFilter: j
3164
- });
3165
- }
3166
- function m(u) {
3167
- var g, j, d, x;
3168
- if (s != null && s[u] || (j = (g = t == null ? void 0 : t.onClickFilter) == null ? void 0 : g.find((y) => y.columnIndex === u)) != null && j.expression)
3169
- return /* @__PURE__ */ e.jsx(
3170
- de,
3171
- {
3172
- value: (x = (d = t == null ? void 0 : t.onClickFilter) == null ? void 0 : d.find((y) => y.columnIndex === u)) == null ? void 0 : x.expression,
3173
- onChange: (y) => c(u, y),
3174
- type: "text",
3175
- className: "h-9 w-full font-mono text-xs focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0",
3176
- placeholder: "Expression"
3177
- }
3178
- );
3179
- }
3180
- return /* @__PURE__ */ e.jsxs("div", { className: "space-y-2", children: [
3181
- /* @__PURE__ */ e.jsx(H, { children: "On Click" }),
3182
- r == null ? void 0 : r.map((u, g) => {
3183
- var j, d;
3184
- return /* @__PURE__ */ e.jsx(
3185
- "div",
3186
- {
3187
- className: "xbg-red-100 group flex items-center justify-between space-y-2",
3188
- children: /* @__PURE__ */ e.jsxs("div", { className: "grow", children: [
3189
- /* @__PURE__ */ e.jsxs("div", { className: "flex items-center space-x-2 py-2", children: [
3190
- /* @__PURE__ */ e.jsx(
3191
- ts,
3192
- {
3193
- checked: !!((j = t == null ? void 0 : t.onClickFilter) != null && j.find(
3194
- (x) => x.columnIndex === g
3195
- )),
3196
- onCheckedChange: (x) => l(g, x)
3197
- }
3198
- ),
3199
- /* @__PURE__ */ e.jsx(
3200
- "label",
3201
- {
3202
- className: "text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",
3203
- children: u
3204
- }
3205
- ),
3206
- /* @__PURE__ */ e.jsx("div", { className: "flex items-center gap-2", children: ((d = t == null ? void 0 : t.onClickFilter) == null ? void 0 : d.find(
3207
- (x) => x.columnIndex === g
3208
- )) && /* @__PURE__ */ e.jsx(
3209
- gt,
3210
- {
3211
- onClick: () => {
3212
- n((x) => {
3213
- const y = [...x];
3214
- return y[g] = !x[g], y;
3215
- });
3216
- },
3217
- className: "invisible size-3 cursor-pointer text-gray-400 group-hover:visible"
3218
- }
3219
- ) })
3220
- ] }),
3221
- m(g)
3222
- ] })
3223
- },
3224
- u
3225
- );
3226
- })
3227
- ] });
3228
- }
3229
- function ls() {
3230
- var r, l, c;
3231
- const s = o((m) => m.card.preferences), n = o(
3232
- (m) => m.card.cfg
3233
- ), { setCardCfg: t, setCardPreferences: a, setChartOrientation: i } = o((m) => m.actions);
3234
- (r = n == null ? void 0 : n.options) != null && r.indexAxis;
3235
- function h(m) {
3236
- i(m);
3237
- }
3238
- return /* @__PURE__ */ e.jsxs(
3239
- Ts,
3240
- {
3241
- value: ((l = s == null ? void 0 : s.chartOptions) == null ? void 0 : l.indexAxis) || ((c = n == null ? void 0 : n.options) == null ? void 0 : c.indexAxis) || "x",
3242
- onValueChange: h,
3243
- className: "flex gap-3",
3244
- defaultValue: "x",
3245
- children: [
3246
- /* @__PURE__ */ e.jsxs("div", { className: "flex items-center space-x-2", children: [
3247
- /* @__PURE__ */ e.jsx(Oe, { value: "x", id: "r1" }),
3248
- /* @__PURE__ */ e.jsx("label", { className: "text-sm", htmlFor: "r1", children: "Vertical" })
3249
- ] }),
3250
- /* @__PURE__ */ e.jsxs("div", { className: "flex items-center space-x-2", children: [
3251
- /* @__PURE__ */ e.jsx(Oe, { value: "y", id: "r2" }),
3252
- /* @__PURE__ */ e.jsx("label", { className: "text-sm", htmlFor: "r2", children: "Horizontal" })
3253
- ] })
3254
- ]
3255
- }
3256
- );
3257
- }
3258
- const Se = "focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0";
3259
- function Xs(s, n) {
3260
- var a, i, h;
3261
- const t = pt(s, n);
3262
- return ((h = (i = (a = s == null ? void 0 : s.chartOptions) == null ? void 0 : a.scales) == null ? void 0 : i[t]) == null ? void 0 : h.type) || "linear";
3263
- }
3264
- function At() {
3265
- var re, U, ie, C, D, J;
3266
- const [s, n] = A(!1), t = o((k) => {
3267
- var I;
3268
- return (I = k.card) == null ? void 0 : I.preferences;
3269
- }), a = o((k) => {
3270
- var I;
3271
- return (I = k.card) == null ? void 0 : I.cfg;
3272
- }), i = pt(t, a), [h, r] = A(
3273
- Xs(t)
3274
- ), [l, c] = A(
3275
- ((ie = (U = (re = t == null ? void 0 : t.chartOptions) == null ? void 0 : re.scales) == null ? void 0 : U[i]) == null ? void 0 : ie.min) || ""
3276
- ), [m, u] = A(
3277
- ((J = (D = (C = t == null ? void 0 : t.chartOptions) == null ? void 0 : C.scales) == null ? void 0 : D[i]) == null ? void 0 : J.max) || ""
3278
- ), [g, j] = A(l || m ? "custom" : "auto"), [d, x] = A(""), [y, f] = A(0), [L, O] = A(""), [v, V] = A(""), [_, S] = A(""), M = o(
3279
- (k) => k.actions.setCardPreferences
3280
- ), { updateCardInFrame: N } = as(), F = o((k) => k.card), R = o((k) => {
3281
- var I;
3282
- return (I = k.card) == null ? void 0 : I.type;
3283
- }), $ = ["pie", "doughnut", "polarArea"].includes(R);
3284
- Y(() => {
3285
- var k, I, ee, q, se, ae, be, pe, Q, le, oe, ye, ce, fe;
3286
- r(Xs(t)), c(
3287
- ((ee = (I = (k = t == null ? void 0 : t.chartOptions) == null ? void 0 : k.scales) == null ? void 0 : I[i]) == null ? void 0 : ee.min) === 0 ? 0 : ""
3288
- ), u(((ae = (se = (q = t == null ? void 0 : t.chartOptions) == null ? void 0 : q.scales) == null ? void 0 : se[i]) == null ? void 0 : ae.max) || ""), x(
3289
- ((le = (Q = (pe = (be = t == null ? void 0 : t.chartOptions) == null ? void 0 : be.scales) == null ? void 0 : pe[i]) == null ? void 0 : Q.ticks) == null ? void 0 : le.stepSize) || ""
3290
- ), f(((oe = t == null ? void 0 : t.numberAxisFormat) == null ? void 0 : oe.decimalPlaces) || 0), O(((ye = t == null ? void 0 : t.numberAxisFormat) == null ? void 0 : ye.suffix) || ""), V(((ce = t == null ? void 0 : t.numberAxisFormat) == null ? void 0 : ce.currency) || ""), S(((fe = t == null ? void 0 : t.numberAxisFormat) == null ? void 0 : fe.locale) || "");
3291
- }, [s, t, i]);
3292
- function E(k, I) {
3293
- return I === "" || /^[0-9\b]+$/.test(I) ? Number(I) : Number(k);
3294
- }
3295
- function P() {
3296
- return /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
3297
- /* @__PURE__ */ e.jsxs("div", { className: "grid grid-cols-6 items-center gap-2", children: [
3298
- /* @__PURE__ */ e.jsx(
3299
- H,
3300
- {
3301
- className: "col-span-2 hover:cursor-pointer hover:underline",
3302
- htmlFor: "currency",
3303
- children: /* @__PURE__ */ e.jsx(
3304
- "a",
3305
- {
3306
- target: "_blank",
3307
- href: "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat",
3308
- children: "Currency"
3309
- }
3310
- )
3311
- }
3312
- ),
3313
- /* @__PURE__ */ e.jsx(
3314
- de,
3315
- {
3316
- value: v,
3317
- placeholder: "USD",
3318
- onChange: (k) => V(k.target.value),
3319
- id: "currency",
3320
- className: `col-span-2 h-8 w-full ${Se}`
3321
- }
3322
- ),
3323
- /* @__PURE__ */ e.jsx(
3324
- de,
3325
- {
3326
- value: _,
3327
- placeholder: "en-US",
3328
- onChange: (k) => S(k.target.value),
3329
- id: "locale",
3330
- className: `col-span-2 h-8 w-full ${Se}`
3331
- }
3332
- )
3333
- ] }),
3334
- /* @__PURE__ */ e.jsxs("div", { className: "grid grid-cols-9 items-center gap-2", children: [
3335
- /* @__PURE__ */ e.jsx(H, { className: "col-span-3", htmlFor: "format", children: "Decimals" }),
3336
- /* @__PURE__ */ e.jsx(
3337
- de,
3338
- {
3339
- value: y,
3340
- onChange: (k) => f(Number(k.target.value)),
3341
- id: "format",
3342
- className: `col-span-6 h-8 w-full tracking-wide ${Se}`
3343
- }
3344
- )
3345
- ] })
3346
- ] });
3347
- }
3348
- function X() {
3349
- return /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
3350
- /* @__PURE__ */ e.jsxs("div", { className: "grid grid-cols-3 items-center gap-2", children: [
3351
- /* @__PURE__ */ e.jsx(H, { htmlFor: "range", children: "Range" }),
3352
- /* @__PURE__ */ e.jsx(
3353
- de,
3354
- {
3355
- id: "min",
3356
- value: l,
3357
- onChange: (k) => c((I) => E(I, k.target.value)),
3358
- className: `col-span-1 h-8 w-full ${Se}`
3359
- }
3360
- ),
3361
- /* @__PURE__ */ e.jsx(
3362
- de,
3363
- {
3364
- value: m,
3365
- onChange: (k) => u((I) => E(I, k.target.value)),
3366
- id: "max",
3367
- className: `col-span-1 h-8 w-full ${Se}`
3368
- }
3369
- )
3370
- ] }),
3371
- /* @__PURE__ */ e.jsxs("div", { className: "grid grid-cols-3 items-center gap-2", children: [
3372
- /* @__PURE__ */ e.jsx(H, { htmlFor: "step-size", children: "Step Size" }),
3373
- /* @__PURE__ */ e.jsx(
3374
- de,
3375
- {
3376
- value: d,
3377
- onChange: (k) => x((I) => E(I, k.target.value)),
3378
- id: "step-size",
3379
- className: `col-span-1 h-8 w-full ${Se}`
3380
- }
3381
- )
3382
- ] })
3383
- ] });
3384
- }
3385
- function W() {
3386
- var q;
3387
- let k = {};
3388
- g === "custom" && (k = {
3389
- min: l,
3390
- max: m,
3391
- ticks: {
3392
- stepSize: d
3393
- }
3394
- });
3395
- const I = {
3396
- ...t || {},
3397
- chartOptions: {
3398
- ...t == null ? void 0 : t.chartOptions,
3399
- scales: {
3400
- ...(q = t == null ? void 0 : t.chartOptions) == null ? void 0 : q.scales,
3401
- [i]: {
3402
- // ...cardPreferences?.chartOptions?.scales?.[axis],
3403
- type: h,
3404
- ...h === "linear" ? k : {}
3405
- }
3406
- }
3407
- },
3408
- numberAxisFormat: {
3409
- decimalPlaces: y,
3410
- suffix: L,
3411
- currency: v,
3412
- locale: _
3413
- }
3414
- };
3415
- console.log(I), M(I);
3416
- const ee = {
3417
- ...F,
3418
- preferences: I
3419
- };
3420
- N(ee);
3421
- }
3422
- return /* @__PURE__ */ e.jsxs(ns, { onOpenChange: (k) => n(k), children: [
3423
- /* @__PURE__ */ e.jsx(rs, { asChild: !0, children: /* @__PURE__ */ e.jsx(Ma, { className: "size-4 cursor-pointer text-muted-foreground hover:text-foreground" }) }),
3424
- /* @__PURE__ */ e.jsx(is, { align: "center", className: "max-w-65", children: /* @__PURE__ */ e.jsxs("div", { className: "grid gap-4", children: [
3425
- /* @__PURE__ */ e.jsxs("div", { className: "space-y-2", children: [
3426
- /* @__PURE__ */ e.jsx("h4", { className: "font-medium leading-none", children: "Scale Options" }),
3427
- /* @__PURE__ */ e.jsx("p", { className: "text-sm text-muted-foreground", children: "Set the scale for the number axis" })
3428
- ] }),
3429
- /* @__PURE__ */ e.jsxs("div", { className: "grid gap-2", children: [
3430
- /* @__PURE__ */ e.jsxs("div", { className: "grid grid-cols-3 items-center gap-2", children: [
3431
- /* @__PURE__ */ e.jsx(H, { htmlFor: "scale", children: "Type" }),
3432
- /* @__PURE__ */ e.jsxs(
3433
- ke,
3434
- {
3435
- disabled: $,
3436
- value: h,
3437
- onValueChange: (k) => r(k),
3438
- children: [
3439
- /* @__PURE__ */ e.jsx(ze, { className: "col-span-2 h-8 w-full focus:ring-1 focus:ring-offset-0", children: /* @__PURE__ */ e.jsx(Fe, {}) }),
3440
- /* @__PURE__ */ e.jsx(Le, { id: "type", children: /* @__PURE__ */ e.jsxs(_e, { children: [
3441
- /* @__PURE__ */ e.jsx(Me, { children: "Option" }),
3442
- /* @__PURE__ */ e.jsx(te, { value: "linear", children: "Linear" }),
3443
- /* @__PURE__ */ e.jsx(te, { value: "logarithmic", children: "Logarithmic" })
3444
- ] }) })
3445
- ]
3446
- }
3447
- )
3448
- ] }),
3449
- h == "linear" && /* @__PURE__ */ e.jsxs("div", { className: "grid grid-cols-3 items-center gap-2 py-1", children: [
3450
- /* @__PURE__ */ e.jsx(H, { htmlFor: "scale-option", children: "Setup" }),
3451
- /* @__PURE__ */ e.jsxs(
3452
- Ts,
3453
- {
3454
- disabled: $,
3455
- id: "scale-option",
3456
- value: g,
3457
- onValueChange: (k) => j(k),
3458
- className: "col-span-2 flex gap-3",
3459
- defaultValue: "x",
3460
- children: [
3461
- /* @__PURE__ */ e.jsxs("div", { className: "flex items-center space-x-2", children: [
3462
- /* @__PURE__ */ e.jsx(Oe, { value: "auto", id: "r1" }),
3463
- /* @__PURE__ */ e.jsx("label", { className: "text-sm", htmlFor: "r1", children: "Auto" })
3464
- ] }),
3465
- /* @__PURE__ */ e.jsxs("div", { className: "flex items-center space-x-2", children: [
3466
- /* @__PURE__ */ e.jsx(Oe, { value: "custom", id: "r2" }),
3467
- /* @__PURE__ */ e.jsx("label", { className: "text-sm", htmlFor: "r2", children: "Custom" })
3468
- ] })
3469
- ]
3470
- }
3471
- )
3472
- ] }),
3473
- g === "custom" && h == "linear" && X(),
3474
- P(),
3475
- /* @__PURE__ */ e.jsx(Oa, {}),
3476
- /* @__PURE__ */ e.jsx("div", { className: "grid grid-cols-3", children: /* @__PURE__ */ e.jsx(
3477
- z,
3478
- {
3479
- onClick: W,
3480
- variant: "secondary",
3481
- className: "col-span-1 col-start-3 h-8 w-full",
3482
- children: "Apply"
3483
- }
3484
- ) })
3485
- ] })
3486
- ] }) })
3487
- ] });
3488
- }
3489
- function ar({ idx: s }) {
3490
- var l;
3491
- const n = o((c) => {
3492
- var m;
3493
- return (m = c.card) == null ? void 0 : m.preferences;
3494
- }), t = o(
3495
- (c) => {
3496
- var m;
3497
- return (m = c.card.preferences) == null ? void 0 : m.datasetOptions;
3498
- }
3499
- ), a = o(
3500
- (c) => c.actions.setCardPreferences
3501
- ), i = (l = n == null ? void 0 : n.chartOptions) == null ? void 0 : l.indexAxis, h = t == null ? void 0 : t.find((c) => c.idx === s);
3502
- function r(c, m) {
3503
- (c === "end" || c === "start") && Da(Ta());
3504
- const u = {
3505
- display: c !== "none",
3506
- align: c,
3507
- anchor: c,
3508
- clamp: !0
3509
- };
3510
- if (!h)
3511
- a({
3512
- ...n,
3513
- datasetOptions: [
3514
- ...t || [],
3515
- {
3516
- idx: m,
3517
- datalabels: u
3518
- }
3519
- ]
3520
- });
3521
- else {
3522
- const g = { ...h };
3523
- g.datalabels = u;
3524
- const j = t == null ? void 0 : t.map(
3525
- (d) => d.idx === m ? g : d
3526
- );
3527
- a({
3528
- ...n,
3529
- datasetOptions: j
3530
- });
3531
- }
3532
- }
3533
- return /* @__PURE__ */ e.jsxs(ns, { children: [
3534
- /* @__PURE__ */ e.jsx(rs, { children: /* @__PURE__ */ e.jsx(Cn, { className: "invisible size-4 rotate-[135deg] cursor-pointer text-muted-foreground hover:text-foreground group-hover:visible" }) }),
3535
- /* @__PURE__ */ e.jsx(is, { className: "w-fit p-1", children: /* @__PURE__ */ e.jsxs("div", { className: "flex gap-1", children: [
3536
- /* @__PURE__ */ e.jsx(
3537
- z,
3538
- {
3539
- onClick: () => r("none", s),
3540
- size: "sm",
3541
- variant: "secondary",
3542
- className: "h-7 p-1 text-xs font-normal",
3543
- children: /* @__PURE__ */ e.jsx(xt, { className: "size-4" })
3544
- }
3545
- ),
3546
- /* @__PURE__ */ e.jsx(
3547
- z,
3548
- {
3549
- onClick: () => r("start", s),
3550
- size: "sm",
3551
- variant: "secondary",
3552
- className: "h-7 p-1 text-xs font-normal",
3553
- children: /* @__PURE__ */ e.jsx(
3554
- un,
3555
- {
3556
- className: Z("h-4 w-4", {
3557
- "rotate-90": i === "y"
3558
- })
3559
- }
3560
- )
3561
- }
3562
- ),
3563
- /* @__PURE__ */ e.jsx(
3564
- z,
3565
- {
3566
- onClick: () => r("center", s),
3567
- size: "sm",
3568
- variant: "secondary",
3569
- className: "h-7 p-1 text-xs font-normal",
3570
- children: /* @__PURE__ */ e.jsx(
3571
- xn,
3572
- {
3573
- className: Z("h-4 w-4", {
3574
- "rotate-90": i === "y"
3575
- })
3576
- }
3577
- )
3578
- }
3579
- ),
3580
- /* @__PURE__ */ e.jsx(
3581
- z,
3582
- {
3583
- onClick: () => r("end", s),
3584
- size: "sm",
3585
- variant: "secondary",
3586
- className: "h-7 p-1 text-xs font-normal",
3587
- children: /* @__PURE__ */ e.jsx(
3588
- mn,
3589
- {
3590
- className: Z("h-4 w-4", {
3591
- "rotate-90": i === "y"
3592
- })
3593
- }
3594
- )
3595
- }
3596
- )
3597
- ] }) })
3598
- ] });
3599
- }
3600
- function Et() {
3601
- const s = o((c) => c.card), n = o(
3602
- (c) => {
3603
- var m, u, g;
3604
- return (g = (u = (m = c == null ? void 0 : c.card) == null ? void 0 : m.preferences) == null ? void 0 : u.chartOptions) == null ? void 0 : g.indexAxis;
3605
- }
3606
- ), t = n === "y" ? "Y axis" : "X axis", a = n === "y" ? "X axis" : "Y axis", {
3607
- keys: i,
3608
- metricKeys: h,
3609
- dimensionKeys: r
3610
- } = xs(s.data || []);
3611
- let l = h;
3612
- if (["stackedBar", "stackedLine"].includes(s.type)) {
3613
- const c = Aa({
3614
- dataArray: s.data || [],
3615
- groupKey: r[0],
3616
- pivotKey: r[1],
3617
- valueKey: l[0]
3618
- }), { metricKeys: m } = xs(c);
3619
- l = m;
3620
- }
3621
- return i.length === 0 ? null : /* @__PURE__ */ e.jsxs("div", { className: "space-y-4", children: [
3622
- /* @__PURE__ */ e.jsxs("div", { className: "space-y-2", children: [
3623
- /* @__PURE__ */ e.jsx(H, { children: t }),
3624
- /* @__PURE__ */ e.jsx("div", { className: "my-1 space-y-1", children: /* @__PURE__ */ e.jsx("div", { className: "rounded-md bg-muted/70 px-2 py-1 hover:bg-muted", children: /* @__PURE__ */ e.jsx("p", { children: r[0] }) }) })
3625
- ] }),
3626
- /* @__PURE__ */ e.jsxs("div", { className: "space-y-2", children: [
3627
- /* @__PURE__ */ e.jsxs("div", { className: "flex items-center justify-between gap-5", children: [
3628
- /* @__PURE__ */ e.jsx(H, { children: a }),
3629
- /* @__PURE__ */ e.jsx(At, {})
3630
- ] }),
3631
- /* @__PURE__ */ e.jsx("div", { className: "my-1 space-y-1", children: l.map((c, m) => /* @__PURE__ */ e.jsx(nr, { col: c, idx: m }, c)) })
3632
- ] })
3633
- ] });
3634
- }
3635
- function nr({ col: s, idx: n }) {
3636
- const t = o((l) => {
3637
- var c;
3638
- return (c = l.card) == null ? void 0 : c.preferences;
3639
- }), a = o(
3640
- (l) => {
3641
- var c;
3642
- return (c = l.card.preferences) == null ? void 0 : c.datasetOptions;
3643
- }
3644
- ), i = a == null ? void 0 : a.find((l) => l.idx === n), { setCardPreferences: h } = o((l) => l.actions);
3645
- function r(l) {
3646
- if (!i)
3647
- h({
3648
- ...t,
3649
- datasetOptions: [
3650
- ...a || [],
3651
- {
3652
- idx: n,
3653
- type: l === "area" ? "line" : l,
3654
- fill: l === "area" ? "origin" : ""
3655
- }
3656
- ]
3657
- });
3658
- else {
3659
- const c = { ...i };
3660
- c.type = l === "area" ? "line" : l, c.fill = l === "area" ? "origin" : "";
3661
- const m = a == null ? void 0 : a.map(
3662
- (u) => u.idx === n ? c : u
3663
- );
3664
- h({
3665
- ...t,
3666
- datasetOptions: m
3667
- });
3668
- }
3669
- }
3670
- return /* @__PURE__ */ e.jsxs("div", { className: "group flex items-center justify-between gap-5 rounded-md bg-muted/70 px-2 py-1 hover:bg-muted", children: [
3671
- /* @__PURE__ */ e.jsx("p", { children: s }),
3672
- /* @__PURE__ */ e.jsxs("div", { className: "flex gap-2", children: [
3673
- /* @__PURE__ */ e.jsx(
3674
- Es,
3675
- {
3676
- onClick: () => r("bar"),
3677
- className: "invisible size-4 cursor-pointer text-muted-foreground hover:text-foreground group-hover:visible"
3678
- }
3679
- ),
3680
- /* @__PURE__ */ e.jsx(
3681
- Is,
3682
- {
3683
- onClick: () => r("line"),
3684
- className: "invisible size-4 cursor-pointer text-muted-foreground hover:text-foreground group-hover:visible"
3685
- }
3686
- ),
3687
- /* @__PURE__ */ e.jsx(
3688
- en,
3689
- {
3690
- onClick: () => r("area"),
3691
- className: "invisible size-4 cursor-pointer text-muted-foreground hover:text-foreground group-hover:visible"
3692
- }
3693
- ),
3694
- /* @__PURE__ */ e.jsx(
3695
- Re,
3696
- {
3697
- orientation: "vertical",
3698
- className: "invisible size-4 cursor-pointer py-2 text-muted-foreground hover:text-foreground group-hover:visible"
3699
- }
3700
- ),
3701
- /* @__PURE__ */ e.jsx(ar, { idx: n })
3702
- ] })
3703
- ] });
3704
- }
3705
- function It() {
3706
- const s = o((j) => j.selectedConnectionId), n = o((j) => j.selectedDatamodelId), t = o((j) => j.selectedDatabaseName), a = o((j) => j.selectedSchemaName), i = o((j) => j.selectedTableName), h = w((j) => j.dashboard.filters) || [], r = w((j) => j.actions.addFilter), l = w((j) => j.actions.removeFilter), c = w(
3707
- (j) => j.actions.removeFilterValue
3708
- ), { modelItems: m, tableName: u } = De();
3709
- function g(j, d = "dashboard") {
3710
- var S;
3711
- const x = ue(j.column_name), y = ue(t || ""), f = ue(a || ""), L = ue(u);
3712
- let O = lt(
3713
- f,
3714
- L
3715
- ), v = `${O}.${x}`;
3716
- const V = (S = m == null ? void 0 : m.find(
3717
- (M) => M.id === n
3718
- )) == null ? void 0 : S.name;
3719
- n && n !== "none" && (v = `${ms}.${V}.${x}`, O = `${ms}.${V}`);
3720
- const _ = h == null ? void 0 : h.find(
3721
- (M) => M.column === v && M.table === L && (M.database === y || M.database === t)
3722
- );
3723
- if (_)
3724
- c(_.id), l(_.id);
3725
- else {
3726
- const M = Ze();
3727
- return u === "api" && s ? (r({
3728
- location: d,
3729
- id: M,
3730
- //uuidv4(),
3731
- column: v,
3732
- title: j.column_name,
3733
- dataType: j.data_type,
3734
- table: "api",
3735
- database: "",
3736
- // database: 'NA',
3737
- connectionId: s,
3738
- operation: "in",
3739
- sql: Us(
3740
- j.data_type,
3741
- O,
3742
- x
3743
- )
3744
- //DATE_DATA_TYPES.includes(column.data_type) ? dateSql : sql,
3745
- }), M) : (r({
3746
- id: M,
3747
- //uuidv4(),
3748
- location: d,
3749
- column: v,
3750
- //columnName, //`${qualifiedTableName}.${formattedColumnName}`,
3751
- title: j.column_name,
3752
- dataType: j.data_type,
3753
- table: i || "",
3754
- database: t || "",
3755
- connectionId: s || "",
3756
- operation: "in",
3757
- sql: Us(
3758
- j.data_type,
3759
- O,
3760
- x
3761
- )
3762
- //DATE_DATA_TYPES.includes(column.data_type) ? dateSql : sql,
3763
- }), M);
3764
- }
3765
- }
3766
- return { assignFilter: g };
3767
- }
3768
- function Ae() {
3769
- const s = w(
3770
- (l) => l.dashboard.filters
3771
- ), n = o((l) => l.frame), { setFrame: t } = as(), { columns: a } = De(), { assignFilter: i } = It();
3772
- function h(l) {
3773
- const c = i(l, "frame");
3774
- t({ ...n, filterId: c });
3775
- }
3776
- const r = s == null ? void 0 : s.find((l) => l.id === n.filterId);
3777
- return /* @__PURE__ */ e.jsxs("div", { className: "space-y-3", children: [
3778
- /* @__PURE__ */ e.jsx(H, { children: "Card Filter" }),
3779
- /* @__PURE__ */ e.jsx(rr, { onSelect: h, columns: a }),
3780
- r && /* @__PURE__ */ e.jsx(Ea, { filter: r })
3781
- ] });
3782
- }
3783
- function rr({
3784
- columns: s,
3785
- onSelect: n
3786
- }) {
3787
- var r;
3788
- const [t, a] = Qs.useState(!1), [i, h] = Qs.useState("");
3789
- return /* @__PURE__ */ e.jsxs(ns, { open: t, onOpenChange: a, children: [
3790
- /* @__PURE__ */ e.jsx(rs, { asChild: !0, children: /* @__PURE__ */ e.jsxs(
3791
- z,
3792
- {
3793
- size: "sm",
3794
- variant: "outline",
3795
- role: "combobox",
3796
- "aria-expanded": t,
3797
- className: "w-full justify-between font-normal",
3798
- children: [
3799
- i ? (r = s.find((l) => l.column_name === i)) == null ? void 0 : r.column_name : "Select Column...",
3800
- /* @__PURE__ */ e.jsx(Ia, { className: "ml-2 h-4 w-4 shrink-0 opacity-50" })
3801
- ]
3802
- }
3803
- ) }),
3804
- /* @__PURE__ */ e.jsx(is, { className: "w-[200px] p-0", children: /* @__PURE__ */ e.jsxs(qa, { children: [
3805
- /* @__PURE__ */ e.jsx(Va, { placeholder: "Search column", className: "h-9" }),
3806
- /* @__PURE__ */ e.jsxs(_a, { children: [
3807
- /* @__PURE__ */ e.jsx(Ra, { children: "No framework found." }),
3808
- /* @__PURE__ */ e.jsx(Ha, { children: s.map((l) => /* @__PURE__ */ e.jsxs(
3809
- $a,
3810
- {
3811
- value: l.column_name,
3812
- onSelect: (c) => {
3813
- const m = c === i ? "" : c;
3814
- h(m), a(!1), m && n(l);
3815
- },
3816
- children: [
3817
- l.column_name,
3818
- /* @__PURE__ */ e.jsx(
3819
- mt,
3820
- {
3821
- className: Z(
3822
- "ml-auto h-4 w-4",
3823
- i === l.column_name ? "opacity-100" : "opacity-0"
3824
- )
3825
- }
3826
- )
3827
- ]
3828
- },
3829
- l.column_name
3830
- )) })
3831
- ] })
3832
- ] }) })
3833
- ] });
3834
- }
3835
- function ir({
3836
- cardType: s
3837
- }) {
3838
- return /* @__PURE__ */ e.jsx("div", { className: "space-y-6 px-6 py-2", children: /* @__PURE__ */ e.jsxs(Ne, { defaultValue: ["item-2"], type: "multiple", children: [
3839
- /* @__PURE__ */ e.jsxs(B, { value: "item-1", children: [
3840
- /* @__PURE__ */ e.jsx(G, { children: `${As(s)} Chart` }),
3841
- /* @__PURE__ */ e.jsxs(K, { className: "space-y-4 font-mono text-xs", children: [
3842
- /* @__PURE__ */ e.jsx("div", { className: "rounded bg-muted px-2 py-1 text-xs", children: "SELECT x-axis, y-axis-1, y-axis-2,... FROM table" }),
3843
- /* @__PURE__ */ e.jsxs("ul", { className: "ml-6 list-disc text-xs [&>li]:mt-2", children: [
3844
- /* @__PURE__ */ e.jsx("li", { children: "x-axis - category" }),
3845
- /* @__PURE__ */ e.jsx("li", { children: "y-axis1 - number" }),
3846
- /* @__PURE__ */ e.jsx("li", { children: "y-axis2 - number" })
3847
- ] }),
3848
- /* @__PURE__ */ e.jsxs("div", { children: [
3849
- "See ",
3850
- /* @__PURE__ */ e.jsx(
3851
- "a",
3852
- {
3853
- target: "_blank",
3854
- onClick: (n) => n.stopPropagation(),
3855
- className: "text-blue-700",
3856
- href: "https://docs.semaphor.cloud/concepts/visuals#line-chart",
3857
- children: "example"
3858
- }
3859
- ),
3860
- " in the docs."
3861
- ] })
3862
- ] })
3863
- ] }),
3864
- /* @__PURE__ */ e.jsxs(B, { value: "item-2", children: [
3865
- /* @__PURE__ */ e.jsx(G, { children: "Settings" }),
3866
- /* @__PURE__ */ e.jsxs(K, { className: "space-y-4 px-2", children: [
3867
- /* @__PURE__ */ e.jsx(ls, {}),
3868
- /* @__PURE__ */ e.jsx(Et, {})
3869
- ] })
3870
- ] }),
3871
- /* @__PURE__ */ e.jsxs(B, { value: "item-3", children: [
3872
- /* @__PURE__ */ e.jsx(G, { children: "Filters" }),
3873
- /* @__PURE__ */ e.jsxs(K, { className: "space-y-4 px-2", children: [
3874
- /* @__PURE__ */ e.jsx(Te, {}),
3875
- /* @__PURE__ */ e.jsx(Ae, {})
3876
- ] })
3877
- ] })
3878
- ] }) });
3879
- }
3880
- function Vs() {
3881
- var i, h, r;
3882
- const s = o(
3883
- (l) => l.card.cfg
3884
- ), n = o((l) => l.actions.setCardCfg), t = o((l) => l.card.type);
3885
- function a(l) {
3886
- var u;
3887
- const c = {
3888
- datalabels: {
3889
- display: l !== "none",
3890
- align: l,
3891
- anchor: l,
3892
- clamp: !0
3893
- }
3894
- }, m = {
3895
- ...s,
3896
- options: {
3897
- ...s == null ? void 0 : s.options,
3898
- plugins: {
3899
- ...(u = s == null ? void 0 : s.options) == null ? void 0 : u.plugins,
3900
- ...c
3901
- }
3902
- }
3903
- };
3904
- n(m), console.log(l);
3905
- }
3906
- return /* @__PURE__ */ e.jsxs("div", { className: "space-y-2", children: [
3907
- /* @__PURE__ */ e.jsxs("div", { className: "flex items-center justify-between", children: [
3908
- /* @__PURE__ */ e.jsx("label", { className: "font-medium", children: "Data Labels" }),
3909
- !["pyramid"].includes(t) && /* @__PURE__ */ e.jsx(At, {})
3910
- ] }),
3911
- /* @__PURE__ */ e.jsxs(
3912
- ke,
3913
- {
3914
- value: (r = (h = (i = s == null ? void 0 : s.options) == null ? void 0 : i.plugins) == null ? void 0 : h.datalabels) == null ? void 0 : r.anchor,
3915
- onValueChange: a,
3916
- defaultValue: "none",
3917
- children: [
3918
- /* @__PURE__ */ e.jsx(ze, { className: "h-8 w-full focus:ring-1 focus:ring-offset-0", children: /* @__PURE__ */ e.jsx(Fe, { placeholder: "Select position" }) }),
3919
- /* @__PURE__ */ e.jsx(Le, { children: /* @__PURE__ */ e.jsxs(_e, { children: [
3920
- /* @__PURE__ */ e.jsx(Me, { children: "Data Labels" }),
3921
- /* @__PURE__ */ e.jsx(te, { value: "none", children: "None" }),
3922
- t !== "pyramid" && /* @__PURE__ */ e.jsx(te, { value: "start", children: "Start" }),
3923
- /* @__PURE__ */ e.jsx(te, { value: "center", children: "Center" }),
3924
- t !== "pyramid" && /* @__PURE__ */ e.jsx(te, { value: "end", children: "End" })
3925
- ] }) })
3926
- ]
3927
- }
3928
- )
3929
- ] });
3930
- }
3931
- function lr({
3932
- cardType: s
3933
- }) {
3934
- function n(t) {
3935
- const a = "SELECT label, [group], x-axis, y-axis, radius FROM table", i = "SELECT label, [group], x-axis, y-axis FROM table";
3936
- return /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
3937
- /* @__PURE__ */ e.jsx("div", { className: "rounded bg-muted px-2 py-1 text-xs", children: t === "bubble" ? a : i }),
3938
- /* @__PURE__ */ e.jsxs("ul", { className: "ml-6 list-disc text-xs [&>li]:mt-2", children: [
3939
- /* @__PURE__ */ e.jsx("li", { children: "label - category" }),
3940
- /* @__PURE__ */ e.jsx("li", { children: "group - category" }),
3941
- /* @__PURE__ */ e.jsx("li", { children: "x-axis - category" }),
3942
- /* @__PURE__ */ e.jsx("li", { children: "y-axis - category" }),
3943
- t === "bubble" && /* @__PURE__ */ e.jsx("li", { children: "radius - number" })
3944
- ] }),
3945
- /* @__PURE__ */ e.jsxs("div", { children: [
3946
- "See ",
3947
- /* @__PURE__ */ e.jsx(
3948
- "a",
3949
- {
3950
- target: "_blank",
3951
- onClick: (h) => h.stopPropagation(),
3952
- className: "text-blue-700",
3953
- href: "https://docs.semaphor.cloud/concepts/visuals#pie-chart",
3954
- children: "example"
3955
- }
3956
- ),
3957
- " in the docs."
3958
- ] })
3959
- ] });
3960
- }
3961
- return /* @__PURE__ */ e.jsx("div", { className: "space-y-6 px-6 py-2", children: /* @__PURE__ */ e.jsxs(Ne, { defaultValue: ["item-2"], type: "multiple", children: [
3962
- /* @__PURE__ */ e.jsxs(B, { value: "item-1", children: [
3963
- /* @__PURE__ */ e.jsx(G, { children: `${As(s)} Chart` }),
3964
- /* @__PURE__ */ e.jsx(K, { className: "space-y-4 font-mono text-xs", children: n(s) })
3965
- ] }),
3966
- /* @__PURE__ */ e.jsxs(B, { value: "item-2", children: [
3967
- /* @__PURE__ */ e.jsx(G, { children: "Settings" }),
3968
- /* @__PURE__ */ e.jsx(K, { className: "px-2", children: /* @__PURE__ */ e.jsx(Vs, {}) })
3969
- ] }),
3970
- /* @__PURE__ */ e.jsxs(B, { value: "item-3", children: [
3971
- /* @__PURE__ */ e.jsx(G, { children: "Filters" }),
3972
- /* @__PURE__ */ e.jsxs(K, { className: "space-y-4 px-2", children: [
3973
- /* @__PURE__ */ e.jsx(Te, {}),
3974
- /* @__PURE__ */ e.jsx(Ae, {})
3975
- ] })
3976
- ] })
3977
- ] }) });
3978
- }
3979
- const or = {
3980
- datasets: [
3981
- {
3982
- type: "line",
3983
- label: "Sum_sales",
3984
- data: []
3985
- },
3986
- {
3987
- type: "bar",
3988
- label: "Sum_profit",
3989
- data: []
3990
- }
3991
- ]
3992
- }, cr = {
3993
- datasets: [
3994
- {
3995
- fill: "origin",
3996
- type: "line",
3997
- label: "Sum_sales",
3998
- data: []
3999
- }
4000
- ]
4001
- };
4002
- function dr() {
4003
- const s = o((n) => n.card.type);
4004
- return /* @__PURE__ */ e.jsxs("div", { className: "space-y-6 p-6", children: [
4005
- /* @__PURE__ */ e.jsx(
4006
- Ne,
4007
- {
4008
- className: " ",
4009
- type: "single",
4010
- collapsible: !0,
4011
- children: hr(s)
4012
- }
4013
- ),
4014
- /* @__PURE__ */ e.jsx("section", { className: "", children: ["line", "bar"].includes(s) && /* @__PURE__ */ e.jsx(ls, {}) }),
4015
- !["kpi"].includes(s) && /* @__PURE__ */ e.jsxs("div", { className: "space-y-4", children: [
4016
- /* @__PURE__ */ e.jsx(Vs, {}),
4017
- /* @__PURE__ */ e.jsx(Te, {}),
4018
- /* @__PURE__ */ e.jsx(Ae, {})
4019
- ] })
4020
- ] });
4021
- }
4022
- function hr(s) {
4023
- if (["line", "bar"].includes(s))
4024
- return /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
4025
- /* @__PURE__ */ e.jsxs(B, { value: "item-1", children: [
4026
- /* @__PURE__ */ e.jsx(G, { className: "font-normal", children: /* @__PURE__ */ e.jsx("p", { children: "Chart Query" }) }),
4027
- /* @__PURE__ */ e.jsxs(K, { className: " ", children: [
4028
- /* @__PURE__ */ e.jsx("div", { className: "rounded bg-muted px-2 py-1 font-mono text-xs font-semibold", children: "SELECT x-axis, y-axis-1, y-axis-2, y-axis-3,... FROM table" }),
4029
- /* @__PURE__ */ e.jsxs("ul", { className: "my-6 ml-6 list-disc text-xs font-normal [&>li]:mt-2", children: [
4030
- /* @__PURE__ */ e.jsx("li", { children: "X-axis - Category (ex. city)" }),
4031
- /* @__PURE__ */ e.jsx("li", { children: "Y-axis - Number (ex. population)" })
4032
- ] })
4033
- ] })
4034
- ] }),
4035
- /* @__PURE__ */ e.jsxs(B, { value: "item-2", children: [
4036
- /* @__PURE__ */ e.jsx(G, { className: "font-normal", children: "Mixed Chart" }),
4037
- /* @__PURE__ */ e.jsxs(K, { className: "space-y-2 text-xs", children: [
4038
- /* @__PURE__ */ e.jsxs("p", { children: [
4039
- "Click ",
4040
- /* @__PURE__ */ e.jsx("b", { children: "Customize" }),
4041
- " and change the `type` property in the dataset."
4042
- ] }),
4043
- /* @__PURE__ */ e.jsx("pre", { children: JSON.stringify(or, null, 2) })
4044
- ] })
4045
- ] }),
4046
- /* @__PURE__ */ e.jsxs(B, { value: "item-3", children: [
4047
- /* @__PURE__ */ e.jsx(G, { className: "font-normal", children: "Area Chart" }),
4048
- /* @__PURE__ */ e.jsxs(K, { className: "space-y-2 text-xs", children: [
4049
- /* @__PURE__ */ e.jsxs("p", { children: [
4050
- "Click ",
4051
- /* @__PURE__ */ e.jsx("b", { children: "Customize" }),
4052
- " and add `fill` property to the dataset. See",
4053
- /* @__PURE__ */ e.jsx(
4054
- "a",
4055
- {
4056
- className: "mx-1 text-blue-500 hover:underline",
4057
- href: "https://www.chartjs.org/docs/latest/samples/area/line-boundaries.html",
4058
- target: "_blank",
4059
- children: "docs"
4060
- }
4061
- ),
4062
- "for more options."
4063
- ] }),
4064
- /* @__PURE__ */ e.jsx("pre", { children: JSON.stringify(cr, null, 2) })
4065
- ] })
4066
- ] })
4067
- ] });
4068
- if (s === "bubble")
4069
- return /* @__PURE__ */ e.jsx(e.Fragment, { children: /* @__PURE__ */ e.jsxs(B, { value: "item-1", children: [
4070
- /* @__PURE__ */ e.jsx(G, { className: "font-normal", children: /* @__PURE__ */ e.jsxs("p", { children: [
4071
- "How to create a ",
4072
- /* @__PURE__ */ e.jsx("span", { children: s }),
4073
- " chart query?"
4074
- ] }) }),
4075
- /* @__PURE__ */ e.jsxs(K, { className: " ", children: [
4076
- /* @__PURE__ */ e.jsx("div", { className: "rounded bg-muted px-2 py-1 font-mono text-xs font-semibold", children: "SELECT label, x-axis, y-axis, radius FROM table" }),
4077
- /* @__PURE__ */ e.jsxs("ul", { className: "my-6 ml-6 list-disc text-xs font-normal [&>li]:mt-2", children: [
4078
- /* @__PURE__ */ e.jsx("li", { children: "Label - Category (ex. city)" }),
4079
- /* @__PURE__ */ e.jsx("li", { children: "Bubble Group (opt) - Category (ex. state)" }),
4080
- /* @__PURE__ */ e.jsx("li", { children: "X-axis - Number (ex. avg. age)" }),
4081
- /* @__PURE__ */ e.jsx("li", { children: "Y-axis - Number (ex. avg. weight)" }),
4082
- /* @__PURE__ */ e.jsx("li", { children: "Radius - Number (ex. population)" })
4083
- ] })
4084
- ] })
4085
- ] }) });
4086
- if (s === "scatter")
4087
- return /* @__PURE__ */ e.jsx(e.Fragment, { children: /* @__PURE__ */ e.jsxs(B, { value: "item-1", children: [
4088
- /* @__PURE__ */ e.jsx(G, { className: "font-normal", children: /* @__PURE__ */ e.jsxs("p", { children: [
4089
- "How to create a ",
4090
- /* @__PURE__ */ e.jsx("span", { children: s }),
4091
- " chart query?"
4092
- ] }) }),
4093
- /* @__PURE__ */ e.jsxs(K, { className: " ", children: [
4094
- /* @__PURE__ */ e.jsx("div", { className: "rounded bg-muted px-2 py-1 font-mono text-xs font-semibold", children: "SELECT label, x-axis, y-axis FROM table" }),
4095
- /* @__PURE__ */ e.jsxs("ul", { className: "my-6 ml-6 list-disc text-xs font-normal [&>li]:mt-2", children: [
4096
- /* @__PURE__ */ e.jsx("li", { children: "Label - Category (ex. city)" }),
4097
- /* @__PURE__ */ e.jsx("li", { children: "Group (opt) - Category (ex. state)" }),
4098
- /* @__PURE__ */ e.jsx("li", { children: "X-axis - Number (ex. avg. age)" }),
4099
- /* @__PURE__ */ e.jsx("li", { children: "Y-axis - Number (ex. avg. weight)" })
4100
- ] })
4101
- ] })
4102
- ] }) });
4103
- if (["pie", "doughnut", "polarArea"].includes(s))
4104
- return /* @__PURE__ */ e.jsx(e.Fragment, { children: /* @__PURE__ */ e.jsxs(B, { value: "item-1", children: [
4105
- /* @__PURE__ */ e.jsx(G, { className: "font-normal", children: /* @__PURE__ */ e.jsxs("p", { children: [
4106
- /* @__PURE__ */ e.jsx("span", { children: s === "polarArea" ? "Polar" : s.charAt(0).toUpperCase() + s.slice(1) }),
4107
- " ",
4108
- "chart query"
4109
- ] }) }),
4110
- /* @__PURE__ */ e.jsxs(K, { className: " ", children: [
4111
- /* @__PURE__ */ e.jsx("div", { className: "rounded bg-muted px-2 py-1 font-mono text-xs font-semibold", children: "SELECT label, measure FROM table" }),
4112
- /* @__PURE__ */ e.jsxs("ul", { className: "my-6 ml-6 list-disc text-xs font-normal [&>li]:mt-2", children: [
4113
- /* @__PURE__ */ e.jsx("li", { children: "Label - Category (ex. city)" }),
4114
- /* @__PURE__ */ e.jsx("li", { children: "Measure - Number (ex. population)" })
4115
- ] })
4116
- ] })
4117
- ] }) });
4118
- }
4119
- function ur() {
4120
- var c, m, u, g, j;
4121
- const s = o((d) => d.card.preferences), n = o(
4122
- (d) => d.actions.setCardPreferences
4123
- ), t = o(
4124
- (d) => d.actions.setNumberFormat
4125
- );
4126
- o(
4127
- (d) => {
4128
- var x, y;
4129
- return (y = (x = d.card.preferences) == null ? void 0 : x.formatNumber) == null ? void 0 : y.decimalPlaces;
4130
- }
4131
- );
4132
- const a = o(
4133
- (d) => {
4134
- var x, y;
4135
- return (y = (x = d.card.preferences) == null ? void 0 : x.formatNumber) == null ? void 0 : y.locale;
4136
- }
4137
- ), i = o(
4138
- (d) => {
4139
- var x, y;
4140
- return (y = (x = d.card.preferences) == null ? void 0 : x.formatNumber) == null ? void 0 : y.currency;
4141
- }
4142
- );
4143
- o(
4144
- (d) => d.actions.setFilterOnClickField
4145
- );
4146
- const h = o(
4147
- (d) => {
4148
- var x, y;
4149
- return (y = (x = d.card.preferences) == null ? void 0 : x.formatNumber) == null ? void 0 : y.colorRanges;
4150
- }
4151
- ) || [], r = o(
4152
- (d) => d.actions.setColorRanges
4153
- ), l = [...new Set(Ws.map((d) => d.currency))];
4154
- return /* @__PURE__ */ e.jsxs("div", { children: [
4155
- /* @__PURE__ */ e.jsxs("div", { className: "mb-3 flex items-center gap-2", children: [
4156
- /* @__PURE__ */ e.jsx(
4157
- ts,
4158
- {
4159
- checked: !!((c = s == null ? void 0 : s.formatNumber) != null && c.enabled),
4160
- onCheckedChange: (d) => {
4161
- n({
4162
- ...s,
4163
- formatNumber: {
4164
- ...s == null ? void 0 : s.formatNumber,
4165
- enabled: d
4166
- }
4167
- });
4168
- }
4169
- }
4170
- ),
4171
- /* @__PURE__ */ e.jsx(H, { children: "Format Number" })
4172
- ] }),
4173
- ((m = s == null ? void 0 : s.formatNumber) == null ? void 0 : m.enabled) === !0 && /* @__PURE__ */ e.jsxs("div", { className: "flex flex-col gap-2", children: [
4174
- /* @__PURE__ */ e.jsx("div", { children: /* @__PURE__ */ e.jsxs("div", { className: "space-y-4 p-2", children: [
4175
- /* @__PURE__ */ e.jsxs("div", { className: "flex items-center gap-2", children: [
4176
- /* @__PURE__ */ e.jsxs("div", { className: "w-full space-y-1", children: [
4177
- /* @__PURE__ */ e.jsx(H, { children: "Locale" }),
4178
- /* @__PURE__ */ e.jsxs(
4179
- ke,
4180
- {
4181
- value: a || "en-US",
4182
- onValueChange: (d) => {
4183
- var x, y, f;
4184
- return t(
4185
- ((x = s == null ? void 0 : s.formatNumber) == null ? void 0 : x.decimalPlaces) || 0,
4186
- ((y = s == null ? void 0 : s.formatNumber) == null ? void 0 : y.currency) || "",
4187
- d || "en-US",
4188
- ((f = s == null ? void 0 : s.formatNumber) == null ? void 0 : f.suffix) || ""
4189
- );
4190
- },
4191
- children: [
4192
- /* @__PURE__ */ e.jsx(ze, { className: "col-span-6 h-8 w-full focus:ring-1 focus:ring-offset-0", children: /* @__PURE__ */ e.jsx(Fe, {}) }),
4193
- /* @__PURE__ */ e.jsx(Le, { children: /* @__PURE__ */ e.jsxs(_e, { children: [
4194
- /* @__PURE__ */ e.jsx(Me, { children: "Format" }),
4195
- Ws.map((d) => /* @__PURE__ */ e.jsx(te, { value: d.locale, children: d.locale }, d.locale))
4196
- ] }) })
4197
- ]
4198
- }
4199
- )
4200
- ] }),
4201
- /* @__PURE__ */ e.jsxs("div", { className: "w-full space-y-1", children: [
4202
- /* @__PURE__ */ e.jsx(H, { children: "Currency" }),
4203
- /* @__PURE__ */ e.jsxs(
4204
- ke,
4205
- {
4206
- value: i || "none",
4207
- onValueChange: (d) => {
4208
- var x, y, f;
4209
- return t(
4210
- ((x = s == null ? void 0 : s.formatNumber) == null ? void 0 : x.decimalPlaces) || 0,
4211
- d === "none" ? "" : d,
4212
- ((y = s == null ? void 0 : s.formatNumber) == null ? void 0 : y.locale) || "",
4213
- ((f = s == null ? void 0 : s.formatNumber) == null ? void 0 : f.suffix) || ""
4214
- );
4215
- },
4216
- children: [
4217
- /* @__PURE__ */ e.jsx(ze, { className: "col-span-6 h-8 w-full focus:ring-1 focus:ring-offset-0", children: /* @__PURE__ */ e.jsx(Fe, {}) }),
4218
- /* @__PURE__ */ e.jsx(Le, { children: /* @__PURE__ */ e.jsxs(_e, { children: [
4219
- /* @__PURE__ */ e.jsx(Me, { children: "Currency" }),
4220
- /* @__PURE__ */ e.jsx(te, { value: "none", children: "None" }, "none"),
4221
- l.map((d) => /* @__PURE__ */ e.jsx(te, { value: d, children: d }, d))
4222
- ] }) })
4223
- ]
4224
- }
4225
- )
4226
- ] })
4227
- ] }),
4228
- /* @__PURE__ */ e.jsxs("div", { className: "flex gap-2", children: [
4229
- /* @__PURE__ */ e.jsxs("div", { className: "w-full space-y-1", children: [
4230
- /* @__PURE__ */ e.jsx(H, { children: "Decimals" }),
4231
- /* @__PURE__ */ e.jsxs(
4232
- ke,
4233
- {
4234
- value: ((g = (u = s == null ? void 0 : s.formatNumber) == null ? void 0 : u.decimalPlaces) == null ? void 0 : g.toString()) || "0",
4235
- onValueChange: (d) => {
4236
- var x, y, f;
4237
- return t(
4238
- Number(d),
4239
- ((x = s == null ? void 0 : s.formatNumber) == null ? void 0 : x.currency) || "",
4240
- ((y = s == null ? void 0 : s.formatNumber) == null ? void 0 : y.locale) || "",
4241
- ((f = s == null ? void 0 : s.formatNumber) == null ? void 0 : f.suffix) || ""
4242
- );
4243
- },
4244
- children: [
4245
- /* @__PURE__ */ e.jsx(ze, { className: "col-span-3 h-8 w-full focus:ring-1 focus:ring-offset-0", children: /* @__PURE__ */ e.jsx(Fe, {}) }),
4246
- /* @__PURE__ */ e.jsx(Le, { children: ["0", "1", "2", "3", "4"].map((d) => /* @__PURE__ */ e.jsx(te, { value: d, children: d }, d)) })
4247
- ]
4248
- }
4249
- )
4250
- ] }),
4251
- /* @__PURE__ */ e.jsxs("div", { className: "w-full space-y-1", children: [
4252
- /* @__PURE__ */ e.jsx(H, { children: "Suffix" }),
4253
- /* @__PURE__ */ e.jsx(
4254
- de,
4255
- {
4256
- value: ((j = s == null ? void 0 : s.formatNumber) == null ? void 0 : j.suffix) || "",
4257
- className: "h-8 font-mono text-xs focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0",
4258
- placeholder: "K, M, B, %",
4259
- onChange: (d) => {
4260
- var x, y, f;
4261
- return t(
4262
- ((x = s == null ? void 0 : s.formatNumber) == null ? void 0 : x.decimalPlaces) || 0,
4263
- ((y = s == null ? void 0 : s.formatNumber) == null ? void 0 : y.currency) || "",
4264
- ((f = s == null ? void 0 : s.formatNumber) == null ? void 0 : f.locale) || "",
4265
- d.target.value
4266
- );
4267
- }
4268
- }
4269
- )
4270
- ] })
4271
- ] })
4272
- ] }) }),
4273
- /* @__PURE__ */ e.jsx(Re, { className: "my-3" }),
4274
- /* @__PURE__ */ e.jsx(
4275
- Pa,
4276
- {
4277
- colorRanges: h,
4278
- setColorRanges: r
4279
- }
4280
- )
4281
- ] })
4282
- ] });
4283
- }
4284
- function mr() {
4285
- return /* @__PURE__ */ e.jsxs("div", { className: "space-y-6 px-6 py-2", children: [
4286
- /* @__PURE__ */ e.jsx(Ne, { type: "single", collapsible: !0, children: /* @__PURE__ */ e.jsxs(B, { value: "item-1", children: [
4287
- /* @__PURE__ */ e.jsx(G, { className: "", children: "KPI Query" }),
4288
- /* @__PURE__ */ e.jsxs(K, { className: "font-mono", children: [
4289
- /* @__PURE__ */ e.jsx("div", { className: "rounded bg-muted px-2 py-1 font-mono text-xs", children: "SELECT current, previous FROM table" }),
4290
- /* @__PURE__ */ e.jsxs("ul", { className: "my-6 ml-6 list-disc text-xs [&>li]:mt-2", children: [
4291
- /* @__PURE__ */ e.jsx("li", { children: "current - number" }),
4292
- /* @__PURE__ */ e.jsx("li", { children: "previous - number" })
4293
- ] }),
4294
- /* @__PURE__ */ e.jsxs("div", { children: [
4295
- "See ",
4296
- /* @__PURE__ */ e.jsx(
4297
- "a",
4298
- {
4299
- target: "_blank",
4300
- onClick: (s) => s.stopPropagation(),
4301
- className: "text-blue-700",
4302
- href: "https://docs.semaphor.cloud/concepts/visuals#kpi",
4303
- children: "example"
4304
- }
4305
- ),
4306
- " in the docs."
4307
- ] })
4308
- ] })
4309
- ] }) }),
4310
- /* @__PURE__ */ e.jsx("section", { className: "", children: /* @__PURE__ */ e.jsx(ur, {}) }),
4311
- /* @__PURE__ */ e.jsx("div", {}),
4312
- /* @__PURE__ */ e.jsx("div", {})
4313
- ] });
4314
- }
4315
- function xr() {
4316
- var a;
4317
- const s = o((i) => i.card.preferences), { setCardPreferences: n } = o((i) => i.actions);
4318
- function t(i) {
4319
- n({
4320
- ...s,
4321
- textVisualOptions: {
4322
- ...s == null ? void 0 : s.textVisualOptions,
4323
- isDynamicText: i === "dynamic"
4324
- }
4325
- });
4326
- }
4327
- return /* @__PURE__ */ e.jsxs(
4328
- Ts,
4329
- {
4330
- value: (a = s == null ? void 0 : s.textVisualOptions) != null && a.isDynamicText ? "dynamic" : "static",
4331
- onValueChange: t,
4332
- className: "flex gap-3",
4333
- defaultValue: "x",
4334
- children: [
4335
- /* @__PURE__ */ e.jsxs("div", { className: "flex items-center space-x-2", children: [
4336
- /* @__PURE__ */ e.jsx(Oe, { value: "static", id: "r1" }),
4337
- /* @__PURE__ */ e.jsx("label", { className: "text-sm", htmlFor: "r1", children: "Static" })
4338
- ] }),
4339
- /* @__PURE__ */ e.jsxs("div", { className: "flex items-center space-x-2", children: [
4340
- /* @__PURE__ */ e.jsx(Oe, { value: "dynamic", id: "r2" }),
4341
- /* @__PURE__ */ e.jsx("label", { className: "text-sm", htmlFor: "r2", children: "Dynamic" })
4342
- ] })
4343
- ]
4344
- }
4345
- );
4346
- }
4347
- function We({
4348
- cardType: s,
4349
- docContent: n,
4350
- suffix: t = "Chart"
4351
- }) {
4352
- return /* @__PURE__ */ e.jsx("div", { className: "space-y-6 px-6 py-2", children: /* @__PURE__ */ e.jsxs(Ne, { defaultValue: ["item-2"], type: "multiple", children: [
4353
- /* @__PURE__ */ e.jsxs(B, { value: "item-1", children: [
4354
- /* @__PURE__ */ e.jsx(G, { children: `${As(s)} ${t}` }),
4355
- /* @__PURE__ */ e.jsx(K, { children: n || /* @__PURE__ */ e.jsxs("div", { className: "space-y-4 font-mono text-xs", children: [
4356
- /* @__PURE__ */ e.jsx("div", { className: "rounded bg-muted px-2 py-1 text-xs", children: "SELECT label, measure FROM table" }),
4357
- /* @__PURE__ */ e.jsxs("ul", { className: "ml-6 list-disc text-xs [&>li]:mt-2", children: [
4358
- /* @__PURE__ */ e.jsx("li", { children: "label - category" }),
4359
- /* @__PURE__ */ e.jsx("li", { children: "measure - number" })
4360
- ] }),
4361
- /* @__PURE__ */ e.jsxs("div", { children: [
4362
- "See ",
4363
- /* @__PURE__ */ e.jsx(
4364
- "a",
4365
- {
4366
- target: "_blank",
4367
- onClick: (a) => a.stopPropagation(),
4368
- className: "text-blue-700",
4369
- href: "https://docs.semaphor.cloud/concepts/visuals#pie-chart",
4370
- children: "example"
4371
- }
4372
- ),
4373
- " in the docs."
4374
- ] })
4375
- ] }) })
4376
- ] }),
4377
- /* @__PURE__ */ e.jsxs(B, { value: "item-2", children: [
4378
- /* @__PURE__ */ e.jsx(G, { children: "Settings" }),
4379
- /* @__PURE__ */ e.jsxs(K, { className: "space-y-4 px-2", children: [
4380
- s === "range" && /* @__PURE__ */ e.jsx(ls, {}),
4381
- s !== "text" && /* @__PURE__ */ e.jsx(Vs, {}),
4382
- s === "text" && /* @__PURE__ */ e.jsx(xr, {})
4383
- ] })
4384
- ] }),
4385
- !["range", "text"].includes(s) && /* @__PURE__ */ e.jsxs(B, { value: "item-3", children: [
4386
- /* @__PURE__ */ e.jsx(G, { children: "Filters" }),
4387
- /* @__PURE__ */ e.jsxs(K, { className: "space-y-4 px-2", children: [
4388
- /* @__PURE__ */ e.jsx(Te, {}),
4389
- /* @__PURE__ */ e.jsx(Ae, {})
4390
- ] })
4391
- ] })
4392
- ] }) });
4393
- }
4394
- function pr() {
4395
- return /* @__PURE__ */ e.jsx("div", { className: "space-y-6 px-6 py-2", children: /* @__PURE__ */ e.jsxs(Ne, { defaultValue: ["item-2"], type: "multiple", children: [
4396
- /* @__PURE__ */ e.jsxs(B, { value: "item-1", children: [
4397
- /* @__PURE__ */ e.jsx(G, { children: "Stacked Chart" }),
4398
- /* @__PURE__ */ e.jsxs(K, { className: "space-y-4 font-mono text-xs", children: [
4399
- /* @__PURE__ */ e.jsx("div", { className: "rounded bg-muted px-2 py-1 text-xs", children: "SELECT x-axis, stack-by, y-axis FROM table" }),
4400
- /* @__PURE__ */ e.jsxs("ul", { className: "ml-6 list-disc text-xs [&>li]:mt-2", children: [
4401
- /* @__PURE__ */ e.jsx("li", { children: "x-axis - category" }),
4402
- /* @__PURE__ */ e.jsx("li", { children: "stack by - category" }),
4403
- /* @__PURE__ */ e.jsx("li", { children: "y-axis - number" })
4404
- ] }),
4405
- /* @__PURE__ */ e.jsxs("div", { children: [
4406
- "See ",
4407
- /* @__PURE__ */ e.jsx(
4408
- "a",
4409
- {
4410
- target: "_blank",
4411
- onClick: (s) => s.stopPropagation(),
4412
- className: "text-blue-700",
4413
- href: "https://docs.semaphor.cloud/concepts/visuals#stacked-chart",
4414
- children: "example"
4415
- }
4416
- ),
4417
- " in the docs."
4418
- ] })
4419
- ] })
4420
- ] }),
4421
- /* @__PURE__ */ e.jsxs(B, { value: "item-2", children: [
4422
- /* @__PURE__ */ e.jsx(G, { children: "Settings" }),
4423
- /* @__PURE__ */ e.jsxs(K, { className: "space-y-4 px-2", children: [
4424
- /* @__PURE__ */ e.jsx(ls, {}),
4425
- /* @__PURE__ */ e.jsx(Et, {})
4426
- ] })
4427
- ] }),
4428
- /* @__PURE__ */ e.jsxs(B, { value: "item-3", children: [
4429
- /* @__PURE__ */ e.jsx(G, { children: "Filters" }),
4430
- /* @__PURE__ */ e.jsxs(K, { className: "space-y-4 px-2", children: [
4431
- /* @__PURE__ */ e.jsx(Te, {}),
4432
- /* @__PURE__ */ e.jsx(Ae, {})
4433
- ] })
4434
- ] })
4435
- ] }) });
4436
- }
4437
- function fr({}) {
4438
- const s = o((a) => {
4439
- var i;
4440
- return (i = a.card) == null ? void 0 : i.preferences;
4441
- }), n = o(
4442
- (a) => a.actions.setCardPreferences
4443
- ), t = (a) => {
4444
- n({
4445
- ...s,
4446
- allowDownload: a
4447
- });
4448
- };
4449
- return /* @__PURE__ */ e.jsxs("div", { className: "space-y-6 px-6 py-2", children: [
4450
- /* @__PURE__ */ e.jsx(Ne, { defaultValue: ["item-3"], type: "multiple", children: /* @__PURE__ */ e.jsxs(B, { value: "item-3", children: [
4451
- /* @__PURE__ */ e.jsx(G, { children: "Filters" }),
4452
- /* @__PURE__ */ e.jsxs(K, { className: "space-y-4 px-2", children: [
4453
- /* @__PURE__ */ e.jsx(Te, {}),
4454
- /* @__PURE__ */ e.jsx(Ae, {})
4455
- ] })
4456
- ] }) }),
4457
- /* @__PURE__ */ e.jsxs("div", { className: "flex items-center space-x-2", children: [
4458
- /* @__PURE__ */ e.jsx(ts, { onCheckedChange: t, id: "allow-download" }),
4459
- /* @__PURE__ */ e.jsx(
4460
- "label",
4461
- {
4462
- htmlFor: "allow-download",
4463
- className: "text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",
4464
- children: "Allow Download"
4465
- }
4466
- )
4467
- ] })
4468
- ] });
4469
- }
4470
- const gr = /* @__PURE__ */ e.jsxs("div", { className: "space-y-4 font-mono text-xs", children: [
4471
- /* @__PURE__ */ e.jsx("div", { className: "rounded bg-muted px-2 py-1 text-xs", children: "SELECT dimension, cohort, metric FROM table" }),
4472
- /* @__PURE__ */ e.jsxs("div", { children: [
4473
- "See ",
4474
- /* @__PURE__ */ e.jsx(
4475
- "a",
4476
- {
4477
- target: "_blank",
4478
- onClick: (s) => s.stopPropagation(),
4479
- className: "text-blue-700",
4480
- href: "https://docs.semaphor.cloud/concepts/visuals#pyramid-chart",
4481
- children: "example"
4482
- }
4483
- ),
4484
- " in the docs."
4485
- ] })
4486
- ] }), jr = /* @__PURE__ */ e.jsxs("div", { className: "space-y-4 font-mono text-xs", children: [
4487
- /* @__PURE__ */ e.jsx("div", { className: "rounded bg-muted px-2 py-1 text-xs", children: "SELECT y-axis, label, range-from, range-to, range-value FROM table" }),
4488
- /* @__PURE__ */ e.jsxs("div", { children: [
4489
- "See ",
4490
- /* @__PURE__ */ e.jsx(
4491
- "a",
4492
- {
4493
- target: "_blank",
4494
- onClick: (s) => s.stopPropagation(),
4495
- className: "text-blue-700",
4496
- href: "https://docs.semaphor.cloud/concepts/visuals#range-charts",
4497
- children: "example"
4498
- }
4499
- ),
4500
- " in the docs."
4501
- ] })
4502
- ] }), br = /* @__PURE__ */ e.jsxs("div", { className: "space-y-4 font-mono text-xs", children: [
4503
- /* @__PURE__ */ e.jsx("div", { className: "rounded bg-muted px-2 py-1 text-xs", children: "SELECT text FROM table limit 1" }),
4504
- /* @__PURE__ */ e.jsxs("div", { children: [
4505
- "See ",
4506
- /* @__PURE__ */ e.jsx(
4507
- "a",
4508
- {
4509
- target: "_blank",
4510
- onClick: (s) => s.stopPropagation(),
4511
- className: "text-blue-700",
4512
- href: "https://docs.semaphor.cloud/concepts/visuals#text-visual",
4513
- children: "example"
4514
- }
4515
- ),
4516
- " in the docs."
4517
- ] })
4518
- ] });
4519
- function yr() {
4520
- const s = o((t) => t.card.type);
4521
- function n(t) {
4522
- switch (t) {
4523
- case "stackedBar":
4524
- case "stackedLine":
4525
- return /* @__PURE__ */ e.jsx(pr, {});
4526
- case "pyramid":
4527
- return /* @__PURE__ */ e.jsx(We, { docContent: gr, cardType: t });
4528
- case "kpi":
4529
- return /* @__PURE__ */ e.jsx(mr, {});
4530
- case "line":
4531
- case "bar":
4532
- return /* @__PURE__ */ e.jsx(ir, { cardType: t });
4533
- case "range":
4534
- return /* @__PURE__ */ e.jsx(We, { docContent: jr, cardType: t });
4535
- case "pie":
4536
- case "doughnut":
4537
- case "polarArea":
4538
- case "radar":
4539
- return /* @__PURE__ */ e.jsx(We, { cardType: t });
4540
- case "bubble":
4541
- case "scatter":
4542
- return /* @__PURE__ */ e.jsx(lr, { cardType: t });
4543
- case "table":
4544
- return /* @__PURE__ */ e.jsx(fr, { cardType: t });
4545
- case "text":
4546
- return /* @__PURE__ */ e.jsx(
4547
- We,
4548
- {
4549
- docContent: br,
4550
- cardType: t,
4551
- suffix: "Visual"
4552
- }
4553
- );
4554
- default:
4555
- return /* @__PURE__ */ e.jsx(dr, {});
4556
- }
4557
- }
4558
- return /* @__PURE__ */ e.jsx(Ds, { className: "h-full w-full text-sm", children: n(s) });
4559
- }
4560
- function vr() {
4561
- const s = o((n) => n.isShowingVisual);
4562
- return /* @__PURE__ */ e.jsxs(
4563
- ps,
4564
- {
4565
- direction: "vertical",
4566
- className: "min-h-[250px] min-w-full max-w-lg",
4567
- children: [
4568
- /* @__PURE__ */ e.jsx(
4569
- we,
4570
- {
4571
- role: "query-section",
4572
- className: "flex",
4573
- minSize: 20,
4574
- defaultSize: 40,
4575
- children: /* @__PURE__ */ e.jsx(Jn, {})
4576
- }
4577
- ),
4578
- /* @__PURE__ */ e.jsx(fs, { withHandle: !0, className: "border" }),
4579
- /* @__PURE__ */ e.jsx(
4580
- we,
4581
- {
4582
- className: "pb-1",
4583
- role: "visual-section",
4584
- minSize: 0,
4585
- defaultSize: 60,
4586
- children: s ? /* @__PURE__ */ e.jsxs(ps, { direction: "horizontal", children: [
4587
- /* @__PURE__ */ e.jsx(e.Fragment, { children: /* @__PURE__ */ e.jsx(
4588
- we,
4589
- {
4590
- className: "flex min-w-[275px]",
4591
- minSize: 20,
4592
- defaultSize: 25,
4593
- maxSize: 30,
4594
- children: /* @__PURE__ */ e.jsx(yr, {})
4595
- }
4596
- ) }),
4597
- /* @__PURE__ */ e.jsx(fs, { className: "border" }),
4598
- /* @__PURE__ */ e.jsx(we, { minSize: 40, defaultSize: 75, maxSize: 100, children: /* @__PURE__ */ e.jsx(Zs, {}) })
4599
- ] }) : /* @__PURE__ */ e.jsx(Zs, {})
4600
- }
4601
- )
4602
- ]
4603
- }
4604
- );
4605
- }
4606
- function Nr({ authToken: s, onSave: n, onClose: t }) {
4607
- const a = o((r) => r.actions.setOnSave), i = o((r) => r.actions.setOnClose), h = w((r) => r.actions.setAuthToken);
4608
- return Y(() => {
4609
- n && a(n), t && i(t);
4610
- }, [n, a, t, i]), Y(() => {
4611
- s && s.accessToken && h(s);
4612
- }, [s, h]), /* @__PURE__ */ e.jsxs(Ba, { className: "rounded-none", role: "editor-panel", children: [
4613
- /* @__PURE__ */ e.jsx(Ga, { className: "rounded-none border-r-[1.5px]", children: /* @__PURE__ */ e.jsx(Nt, {}) }),
4614
- /* @__PURE__ */ e.jsx(Ka, { children: /* @__PURE__ */ e.jsx(vr, {}) })
4615
- ] });
4616
- }
4617
- function Cr() {
4618
- w((r) => r.selectedCardId);
4619
- const s = w((r) => r.selectedSheetId), { setIsVisualEditing: n } = w((r) => r.actions), t = w((r) => r.isVisualEditing), a = w((r) => r.actions.updateFrame);
4620
- function i(r) {
4621
- s && (a(s, r), n(!1));
4622
- }
4623
- function h() {
4624
- n(!1);
4625
- }
4626
- return /* @__PURE__ */ e.jsx(
4627
- "div",
4628
- {
4629
- role: "editor-container",
4630
- className: Z("flex grow", {
4631
- block: t,
4632
- hidden: !t
4633
- }),
4634
- children: /* @__PURE__ */ e.jsx(Nr, { onSave: i, onClose: h })
4635
- }
4636
- );
4637
- }
4638
- function Sr() {
4639
- o((r) => r.selectedConnectionId), o((r) => r.selectedDatamodelId);
4640
- const s = o((r) => r.selectedDatabaseName);
4641
- o((r) => r.selectedSchemaName);
4642
- const n = o((r) => r.selectedTableName), t = w((r) => r.dashboard.filters) || [];
4643
- w((r) => r.actions.addFilter), w((r) => r.actions.removeFilter), w(
4644
- (r) => r.actions.removeFilterValue
4645
- );
4646
- const { modelItems: a, columns: i } = De(), { assignFilter: h } = It();
4647
- return /* @__PURE__ */ e.jsx("div", { className: "xbg-red-100 flex-1 basis-0 flex-col overflow-scroll px-3", children: i == null ? void 0 : i.map((r) => {
4648
- const l = t == null ? void 0 : t.find(
4649
- (c) => c.column === ue(r.column_name) && c.table === n && c.database === s
4650
- );
4651
- return /* @__PURE__ */ e.jsx(
4652
- "div",
4653
- {
4654
- onClick: () => h(r),
4655
- className: Z(
4656
- "group flex cursor-pointer items-center justify-between border border-dashed border-background px-3 py-[6px] text-sm transition-colors hover:bg-muted/50",
4657
- {
4658
- "bg-muted": l
4659
- }
4660
- ),
4661
- children: /* @__PURE__ */ e.jsxs("div", { className: "flex items-center gap-2", children: [
4662
- /* @__PURE__ */ e.jsx(vt, { column: r }),
4663
- /* @__PURE__ */ e.jsx("span", { children: r.column_name })
4664
- ] })
4665
- },
4666
- r.column_name
4667
- );
4668
- }) });
4669
- }
4670
- function wr() {
4671
- w((n) => n.showFilters);
4672
- const s = w(
4673
- (n) => n.actions.setShowFilters
4674
- );
4675
- return /* @__PURE__ */ e.jsxs("section", { className: "relative flex grow flex-col border-l px-4", children: [
4676
- /* @__PURE__ */ e.jsxs("div", { className: "mt-4 flex items-center justify-between gap-2 px-3", children: [
4677
- /* @__PURE__ */ e.jsx(H, { className: "text-lg", children: "Filters" }),
4678
- /* @__PURE__ */ e.jsx(
4679
- z,
4680
- {
4681
- onClick: () => s(!1),
4682
- className: "h-7 w-7 p-0",
4683
- variant: "ghost",
4684
- children: /* @__PURE__ */ e.jsx(Ve, {})
4685
- }
4686
- )
4687
- ] }),
4688
- /* @__PURE__ */ e.jsx("div", { className: "flex grow", children: /* @__PURE__ */ e.jsx(
4689
- Nt,
4690
- {
4691
- ColumnsComponent: () => (
4692
- // schemaName, tableName, columns
4693
- /* @__PURE__ */ e.jsx(
4694
- Sr,
4695
- {}
4696
- )
4697
- )
4698
- }
4699
- ) })
4700
- ] });
4701
- }
4702
- function kr() {
4703
- const s = w((t) => t.showFilters), n = w((t) => t.isVisualEditing);
4704
- return /* @__PURE__ */ e.jsxs(
4705
- "div",
4706
- {
4707
- role: "dashboard-plus-main",
4708
- className: Z("grow", {
4709
- hidden: n,
4710
- flex: !n
4711
- }),
4712
- children: [
4713
- /* @__PURE__ */ e.jsx(Ua, {}),
4714
- s && /* @__PURE__ */ e.jsx("div", { role: "filter-aside-container", className: "flex", children: /* @__PURE__ */ e.jsx(wr, {}) })
4715
- ]
4716
- }
4717
- );
4718
- }
4719
- function zr() {
4720
- const s = w((a) => a.dashboard), n = w((a) => a.actions.setDashboard), t = w(
4721
- (a) => a.showDashboardJSON
4722
- );
4723
- return w(
4724
- (a) => a.actions.setShowDashboardJSON
4725
- ), /* @__PURE__ */ e.jsx(
4726
- "div",
4727
- {
4728
- className: Z(" p-2", {
4729
- hidden: !t
4730
- }),
4731
- children: /* @__PURE__ */ e.jsx(
4732
- Wa,
4733
- {
4734
- onChange: (a) => {
4735
- if (a)
4736
- try {
4737
- JSON.parse(a), n(JSON.parse(a));
4738
- } catch {
4739
- }
4740
- },
4741
- defaultLanguage: "json",
4742
- className: "h-[550px] overflow-y-auto ",
4743
- value: JSON.stringify(s, null, 2),
4744
- options: {
4745
- minimap: {
4746
- enabled: !1
4747
- },
4748
- // lineNumbers: 'off',
4749
- glyphMargin: !1,
4750
- wordWrap: "on",
4751
- scrollbar: {
4752
- verticalScrollbarSize: 0,
4753
- horizontalScrollbarSize: 0
4754
- },
4755
- fontSize: 12,
4756
- renderLineHighlight: "none"
4757
- }
4758
- }
4759
- )
4760
- }
4761
- );
4762
- }
4763
- function Mr({
4764
- showControls: s = !1,
4765
- showFooter: n = !0,
4766
- ...t
4767
- }) {
4768
- return /* @__PURE__ */ e.jsxs(Qa, { dashboardProps: t, children: [
4769
- /* @__PURE__ */ e.jsx(Ja, {}),
4770
- /* @__PURE__ */ e.jsxs(Ya, { children: [
4771
- /* @__PURE__ */ e.jsx(zr, {}),
4772
- /* @__PURE__ */ e.jsxs(Za, { ...t, children: [
4773
- s && /* @__PURE__ */ e.jsx(Dn, {}),
4774
- /* @__PURE__ */ e.jsx(Cr, {}),
4775
- /* @__PURE__ */ e.jsx(kr, {})
4776
- ] })
4777
- ] })
4778
- ] });
4779
- }
4780
- export {
4781
- Mr as D,
4782
- $e as L,
4783
- Ie as S,
4784
- kn as c,
4785
- yt as g,
4786
- De as u
4787
- };