semaphor 0.0.47 → 0.0.48

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