react-semaphor 0.0.215 → 0.0.216
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.
- package/dist/chunks/dashboard-plus-ilMqnQmr.js +215 -0
- package/dist/chunks/{dashboard-plus-6cxhQU7b.js → dashboard-plus-p12gQech.js} +1557 -1535
- package/dist/chunks/{index-icDf4hJ3.js → index-hVIdvh3Y.js} +1 -0
- package/dist/dashboard/index.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +3 -3
- package/dist/surfboard/index.cjs +1 -1
- package/dist/surfboard/index.js +2 -2
- package/dist/types/dashboard.d.ts +1 -0
- package/dist/types/main.d.ts +7 -0
- package/dist/types/surfboard.d.ts +1 -0
- package/dist/types/types.d.ts +1 -0
- package/package.json +1 -1
- package/dist/chunks/dashboard-plus-8ek7Ti6E.js +0 -215
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
"use strict";const e=require("./index-WM7PvYE2.js"),f=require("react");/**
|
|
2
|
+
* @license lucide-react v0.379.0 - ISC
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the ISC license.
|
|
5
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/const ds=e.createLucideIcon("Activity",[["path",{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",key:"169zse"}]]);/**
|
|
7
|
+
* @license lucide-react v0.379.0 - ISC
|
|
8
|
+
*
|
|
9
|
+
* This source code is licensed under the ISC license.
|
|
10
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
11
|
+
*/const ms=e.createLucideIcon("AreaChart",[["path",{d:"M3 3v18h18",key:"1s2lah"}],["path",{d:"M7 12v5h12V8l-5 5-4-4Z",key:"zxz28u"}]]);/**
|
|
12
|
+
* @license lucide-react v0.379.0 - ISC
|
|
13
|
+
*
|
|
14
|
+
* This source code is licensed under the ISC license.
|
|
15
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
16
|
+
*/const ze=e.createLucideIcon("BarChart4",[["path",{d:"M3 3v18h18",key:"1s2lah"}],["path",{d:"M13 17V9",key:"1fwyjl"}],["path",{d:"M18 17V5",key:"sfb6ij"}],["path",{d:"M8 17v-3",key:"17ska0"}]]);/**
|
|
17
|
+
* @license lucide-react v0.379.0 - ISC
|
|
18
|
+
*
|
|
19
|
+
* This source code is licensed under the ISC license.
|
|
20
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
21
|
+
*/const ps=e.createLucideIcon("Box",[["path",{d:"M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z",key:"hh9hay"}],["path",{d:"m3.3 7 8.7 5 8.7-5",key:"g66t2b"}],["path",{d:"M12 22V12",key:"d0xqtd"}]]);/**
|
|
22
|
+
* @license lucide-react v0.379.0 - ISC
|
|
23
|
+
*
|
|
24
|
+
* This source code is licensed under the ISC license.
|
|
25
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
26
|
+
*/const hs=e.createLucideIcon("CircleX",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]]);/**
|
|
27
|
+
* @license lucide-react v0.379.0 - ISC
|
|
28
|
+
*
|
|
29
|
+
* This source code is licensed under the ISC license.
|
|
30
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
31
|
+
*/const js=e.createLucideIcon("Database",[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5V19A9 3 0 0 0 21 19V5",key:"1wlel7"}],["path",{d:"M3 12A9 3 0 0 0 21 12",key:"mv7ke4"}]]);/**
|
|
32
|
+
* @license lucide-react v0.379.0 - ISC
|
|
33
|
+
*
|
|
34
|
+
* This source code is licensed under the ISC license.
|
|
35
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
36
|
+
*/const Es=e.createLucideIcon("Eraser",[["path",{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",key:"182aya"}],["path",{d:"M22 21H7",key:"t4ddhn"}],["path",{d:"m5 11 9 9",key:"1mo9qw"}]]);/**
|
|
37
|
+
* @license lucide-react v0.379.0 - ISC
|
|
38
|
+
*
|
|
39
|
+
* This source code is licensed under the ISC license.
|
|
40
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
41
|
+
*/const He=e.createLucideIcon("Filter",[["polygon",{points:"22 3 2 3 10 12.46 10 19 14 21 14 12.46 22 3",key:"1yg77f"}]]);/**
|
|
42
|
+
* @license lucide-react v0.379.0 - ISC
|
|
43
|
+
*
|
|
44
|
+
* This source code is licensed under the ISC license.
|
|
45
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
46
|
+
*/const Pe=e.createLucideIcon("GanttChart",[["path",{d:"M8 6h10",key:"9lnwnk"}],["path",{d:"M6 12h9",key:"1g9pqf"}],["path",{d:"M11 18h7",key:"c8dzvl"}]]);/**
|
|
47
|
+
* @license lucide-react v0.379.0 - ISC
|
|
48
|
+
*
|
|
49
|
+
* This source code is licensed under the ISC license.
|
|
50
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
51
|
+
*/const fs=e.createLucideIcon("Glasses",[["circle",{cx:"6",cy:"15",r:"4",key:"vux9w4"}],["circle",{cx:"18",cy:"15",r:"4",key:"18o8ve"}],["path",{d:"M14 15a2 2 0 0 0-2-2 2 2 0 0 0-2 2",key:"1ag4bs"}],["path",{d:"M2.5 13 5 7c.7-1.3 1.4-2 3-2",key:"1hm1gs"}],["path",{d:"M21.5 13 19 7c-.7-1.3-1.5-2-3-2",key:"1r31ai"}]]);/**
|
|
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
|
+
*/const gs=e.createLucideIcon("Hammer",[["path",{d:"m15 12-8.373 8.373a1 1 0 1 1-3-3L12 9",key:"eefl8a"}],["path",{d:"m18 15 4-4",key:"16gjal"}],["path",{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",key:"b7pghm"}]]);/**
|
|
57
|
+
* @license lucide-react v0.379.0 - ISC
|
|
58
|
+
*
|
|
59
|
+
* This source code is licensed under the ISC license.
|
|
60
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
61
|
+
*/const Rs=e.createLucideIcon("Hash",[["line",{x1:"4",x2:"20",y1:"9",y2:"9",key:"4lhtct"}],["line",{x1:"4",x2:"20",y1:"15",y2:"15",key:"vyu0kd"}],["line",{x1:"10",x2:"8",y1:"3",y2:"21",key:"1ggp8o"}],["line",{x1:"16",x2:"14",y1:"3",y2:"21",key:"weycgp"}]]);/**
|
|
62
|
+
* @license lucide-react v0.379.0 - ISC
|
|
63
|
+
*
|
|
64
|
+
* This source code is licensed under the ISC license.
|
|
65
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
66
|
+
*/const bs=e.createLucideIcon("Key",[["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"}],["path",{d:"m21 2-9.6 9.6",key:"1j0ho8"}],["circle",{cx:"7.5",cy:"15.5",r:"5.5",key:"yqb3hr"}]]);/**
|
|
67
|
+
* @license lucide-react v0.379.0 - ISC
|
|
68
|
+
*
|
|
69
|
+
* This source code is licensed under the ISC license.
|
|
70
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
71
|
+
*/const Te=e.createLucideIcon("LineChart",[["path",{d:"M3 3v18h18",key:"1s2lah"}],["path",{d:"m19 9-5 5-4-4-3 3",key:"2osh9i"}]]);/**
|
|
72
|
+
* @license lucide-react v0.379.0 - ISC
|
|
73
|
+
*
|
|
74
|
+
* This source code is licensed under the ISC license.
|
|
75
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
76
|
+
*/const Ss=e.createLucideIcon("ListEnd",[["path",{d:"M16 12H3",key:"1a2rj7"}],["path",{d:"M16 6H3",key:"1wxfjs"}],["path",{d:"M10 18H3",key:"13769t"}],["path",{d:"M21 6v10a2 2 0 0 1-2 2h-5",key:"ilrcs8"}],["path",{d:"m16 16-2 2 2 2",key:"kkc6pm"}]]);/**
|
|
77
|
+
* @license lucide-react v0.379.0 - ISC
|
|
78
|
+
*
|
|
79
|
+
* This source code is licensed under the ISC license.
|
|
80
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
81
|
+
*/const ys=e.createLucideIcon("ListStart",[["path",{d:"M16 12H3",key:"1a2rj7"}],["path",{d:"M16 18H3",key:"12xzn7"}],["path",{d:"M10 6H3",key:"lf8lx7"}],["path",{d:"M21 18V8a2 2 0 0 0-2-2h-5",key:"1hghli"}],["path",{d:"m16 8-2-2 2-2",key:"160uvd"}]]);/**
|
|
82
|
+
* @license lucide-react v0.379.0 - ISC
|
|
83
|
+
*
|
|
84
|
+
* This source code is licensed under the ISC license.
|
|
85
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
86
|
+
*/const vs=e.createLucideIcon("ListX",[["path",{d:"M11 12H3",key:"51ecnj"}],["path",{d:"M16 6H3",key:"1wxfjs"}],["path",{d:"M16 18H3",key:"12xzn7"}],["path",{d:"m19 10-4 4",key:"1tz659"}],["path",{d:"m15 10 4 4",key:"1n7nei"}]]);/**
|
|
87
|
+
* @license lucide-react v0.379.0 - ISC
|
|
88
|
+
*
|
|
89
|
+
* This source code is licensed under the ISC license.
|
|
90
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
91
|
+
*/const Cs=e.createLucideIcon("MessageSquareMore",[["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"}],["path",{d:"M8 10h.01",key:"19clt8"}],["path",{d:"M12 10h.01",key:"1nrarc"}],["path",{d:"M16 10h.01",key:"1m94wz"}]]);/**
|
|
92
|
+
* @license lucide-react v0.379.0 - ISC
|
|
93
|
+
*
|
|
94
|
+
* This source code is licensed under the ISC license.
|
|
95
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
96
|
+
*/const Ns=e.createLucideIcon("Network",[["rect",{x:"16",y:"16",width:"6",height:"6",rx:"1",key:"4q2zg0"}],["rect",{x:"2",y:"16",width:"6",height:"6",rx:"1",key:"8cvhb9"}],["rect",{x:"9",y:"2",width:"6",height:"6",rx:"1",key:"1egb70"}],["path",{d:"M5 16v-3a1 1 0 0 1 1-1h12a1 1 0 0 1 1 1v3",key:"1jsf9p"}],["path",{d:"M12 12V8",key:"2874zd"}]]);/**
|
|
97
|
+
* @license lucide-react v0.379.0 - ISC
|
|
98
|
+
*
|
|
99
|
+
* This source code is licensed under the ISC license.
|
|
100
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
101
|
+
*/const $e=e.createLucideIcon("Pencil",[["path",{d:"M17 3a2.85 2.83 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5Z",key:"5qss01"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]]);/**
|
|
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
|
+
*/const Ke=e.createLucideIcon("PieChart",[["path",{d:"M21.21 15.89A10 10 0 1 1 8 2.83",key:"k2fpak"}],["path",{d:"M22 12A10 10 0 0 0 12 2v10z",key:"1rfc4y"}]]);/**
|
|
107
|
+
* @license lucide-react v0.379.0 - ISC
|
|
108
|
+
*
|
|
109
|
+
* This source code is licensed under the ISC license.
|
|
110
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
111
|
+
*/const ks=e.createLucideIcon("Play",[["polygon",{points:"6 3 20 12 6 21 6 3",key:"1oa8hb"}]]);/**
|
|
112
|
+
* @license lucide-react v0.379.0 - ISC
|
|
113
|
+
*
|
|
114
|
+
* This source code is licensed under the ISC license.
|
|
115
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
116
|
+
*/const ws=e.createLucideIcon("Plug2",[["path",{d:"M9 2v6",key:"17ngun"}],["path",{d:"M15 2v6",key:"s7yy2p"}],["path",{d:"M12 17v5",key:"bb1du9"}],["path",{d:"M5 8h14",key:"pcz4l3"}],["path",{d:"M6 11V8h12v3a6 6 0 1 1-12 0v0Z",key:"nd4hoy"}]]);/**
|
|
117
|
+
* @license lucide-react v0.379.0 - ISC
|
|
118
|
+
*
|
|
119
|
+
* This source code is licensed under the ISC license.
|
|
120
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
121
|
+
*/const As=e.createLucideIcon("Save",[["path",{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",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]]);/**
|
|
122
|
+
* @license lucide-react v0.379.0 - ISC
|
|
123
|
+
*
|
|
124
|
+
* This source code is licensed under the ISC license.
|
|
125
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
126
|
+
*/const Ge=e.createLucideIcon("ScatterChart",[["circle",{cx:"7.5",cy:"7.5",r:".5",fill:"currentColor",key:"kqv944"}],["circle",{cx:"18.5",cy:"5.5",r:".5",fill:"currentColor",key:"lysivs"}],["circle",{cx:"11.5",cy:"11.5",r:".5",fill:"currentColor",key:"byv1b8"}],["circle",{cx:"7.5",cy:"16.5",r:".5",fill:"currentColor",key:"nkw3mc"}],["circle",{cx:"17.5",cy:"14.5",r:".5",fill:"currentColor",key:"1gjh6j"}],["path",{d:"M3 3v18h18",key:"1s2lah"}]]);/**
|
|
127
|
+
* @license lucide-react v0.379.0 - ISC
|
|
128
|
+
*
|
|
129
|
+
* This source code is licensed under the ISC license.
|
|
130
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
131
|
+
*/const Is=e.createLucideIcon("ShieldQuestion",[["path",{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",key:"oel41y"}],["path",{d:"M9.1 9a3 3 0 0 1 5.82 1c0 2-3 3-3 3",key:"mhlwft"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);/**
|
|
132
|
+
* @license lucide-react v0.379.0 - ISC
|
|
133
|
+
*
|
|
134
|
+
* This source code is licensed under the ISC license.
|
|
135
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
136
|
+
*/const zs=e.createLucideIcon("Sigma",[["path",{d:"M18 7V4H6l6 8-6 8h12v-3",key:"zis8ev"}]]);/**
|
|
137
|
+
* @license lucide-react v0.379.0 - ISC
|
|
138
|
+
*
|
|
139
|
+
* This source code is licensed under the ISC license.
|
|
140
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
141
|
+
*/const Ts=e.createLucideIcon("SwatchBook",[["path",{d:"M11 17a4 4 0 0 1-8 0V5a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2Z",key:"1ldrpk"}],["path",{d:"M16.7 13H19a2 2 0 0 1 2 2v4a2 2 0 0 1-2 2H7",key:"11i5po"}],["path",{d:"M 7 17h0.01",key:"10821z"}],["path",{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",key:"o2gii7"}]]);/**
|
|
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
|
+
*/const Ls=e.createLucideIcon("Tag",[["path",{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",key:"vktsd0"}],["circle",{cx:"7.5",cy:"7.5",r:".5",fill:"currentColor",key:"kqv944"}]]);/**
|
|
147
|
+
* @license lucide-react v0.379.0 - ISC
|
|
148
|
+
*
|
|
149
|
+
* This source code is licensed under the ISC license.
|
|
150
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
151
|
+
*/const Ds=e.createLucideIcon("ToggleLeft",[["rect",{width:"20",height:"12",x:"2",y:"6",rx:"6",ry:"6",key:"f2vt7d"}],["circle",{cx:"8",cy:"12",r:"2",key:"1nvbw3"}]]);/**
|
|
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
|
+
*/const Le=e.createLucideIcon("Type",[["polyline",{points:"4 7 4 4 20 4 20 7",key:"1nosan"}],["line",{x1:"9",x2:"15",y1:"20",y2:"20",key:"swin9y"}],["line",{x1:"12",x2:"12",y1:"4",y2:"20",key:"1tx1rr"}]]);/**
|
|
157
|
+
* @license lucide-react v0.379.0 - ISC
|
|
158
|
+
*
|
|
159
|
+
* This source code is licensed under the ISC license.
|
|
160
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
161
|
+
*/const Fs=e.createLucideIcon("User",[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]]);function Os(){const[s,n]=f.useState(""),[t,r]=f.useState(!1),[a,c]=f.useState(!1),x=e.useDashboardStore(l=>l.dashboard);function o(){const l=e.getDashbaordStateWithoutData(x),h=e.getBookmarkKey(x.id),d=JSON.parse(localStorage.getItem(h)||"[]");if(d.some(y=>y.name===s)){r(!0);return}d.push({name:s,template:l}),localStorage.setItem(h,JSON.stringify(d)),c(!1)}return e.jsxRuntimeExports.jsxs(e.Dialog,{open:a,onOpenChange:c,children:[e.jsxRuntimeExports.jsx(e.DialogTrigger,{asChild:!0,children:e.jsxRuntimeExports.jsxs(e.Button,{variant:"outline",className:"h-7 p-2",size:"sm",children:[e.jsxRuntimeExports.jsx(e.Plus,{className:" mr-2 h-4 w-4",strokeWidth:1.5}),"Add Lens"]})}),e.jsxRuntimeExports.jsxs(e.DialogContent,{className:"sm:max-w-[425px]",children:[e.jsxRuntimeExports.jsxs(e.DialogHeader,{children:[e.jsxRuntimeExports.jsx(e.DialogTitle,{children:"Add a Lens"}),e.jsxRuntimeExports.jsx(e.DialogDescription,{children:"Lenses are private by default and are only visible to you."})]}),e.jsxRuntimeExports.jsx("div",{className:"grid gap-4 py-4",children:e.jsxRuntimeExports.jsxs("div",{className:"grid grid-cols-8 items-center gap-4",children:[e.jsxRuntimeExports.jsx(e.Label,{className:"text-right",children:"Name"}),e.jsxRuntimeExports.jsx(e.Input,{value:s,onChange:l=>{t&&r(!1),n(l.target.value)},id:"name",className:"col-span-7 focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0"})]})}),t&&e.jsxRuntimeExports.jsx("p",{className:"text-sm",children:"The bookmark name already exists. Use a differnet name."}),e.jsxRuntimeExports.jsx(e.DialogFooter,{children:e.jsxRuntimeExports.jsx(e.Button,{variant:"outline",type:"submit",disabled:!s,onClick:o,children:"Save"})})]})]})}function Ms(){const[s,n]=f.useState(!1),[t,r]=f.useState(""),a=e.useDashboardStore(u=>u.dashboard),c=e.useDashboardStore(u=>u.bookmarkKey),[x,o]=f.useState([]),l=e.useDashboardStore(u=>u.actions.setDashboard),h=e.useDashboardStore(u=>u.actions.setFilterValues),d=e.useDashboardStore(u=>u.actions.setBookmarkKey);f.useEffect(()=>{const u=e.getBookmarkKey(a.id),p=JSON.parse(localStorage.getItem(u)||"[]");o(p);const j=p.find(v=>v.default);j&&j.name===c&&r(j.name)},[s,a,c]);function m(u){if(u===t)return;const p=x.find(v=>v.name===u),j=p==null?void 0:p.template;j&&(l(j),h(p.filterValues||[]),d(u==="Original"?"":u)),r(u)}function y(u){const p=e.getBookmarkKey(a.id),v=JSON.parse(localStorage.getItem(p)||"[]").filter(S=>S.name!==u);localStorage.setItem(p,JSON.stringify(v)),o(v)}return e.jsxRuntimeExports.jsxs(e.DropdownMenu,{open:s,onOpenChange:n,children:[e.jsxRuntimeExports.jsx(e.DropdownMenuTrigger,{asChild:!0,children:e.jsxRuntimeExports.jsx(e.Button,{variant:"outline",className:"h-7 p-2",children:e.jsxRuntimeExports.jsx(fs,{className:"h-4 w-4",strokeWidth:1.5})})}),e.jsxRuntimeExports.jsxs(e.DropdownMenuContent,{className:"w-56",children:[e.jsxRuntimeExports.jsx(e.DropdownMenuLabel,{children:"Lenses"}),e.jsxRuntimeExports.jsx(e.DropdownMenuSeparator,{}),e.jsxRuntimeExports.jsxs(e.DropdownMenuRadioGroup,{value:t,onValueChange:m,children:[e.jsxRuntimeExports.jsx(e.DropdownMenuRadioItem,{value:"Original",children:"Original"}),x.filter(u=>u.name!="Original").map((u,p)=>e.jsxRuntimeExports.jsxs(e.DropdownMenuRadioItem,{className:"xbg-red-100 flex justify-between",value:u.name,defaultChecked:u.name===c,children:[e.jsxRuntimeExports.jsx("p",{children:u.name}),e.jsxRuntimeExports.jsx(e.Cross2Icon,{onClick:j=>{j.preventDefault(),y(u.name)},className:"h-3 w-3 hover:cursor-pointer",strokeWidth:1.5})]},p))]})]})]})}function qs(){const[s,n]=f.useState(!1),t=e.useDashboardStore(c=>c.dashboard),r=e.useDashboardStore(c=>c.bookmarkKey);f.useEffect(()=>{if(!r){n(!1);return}const c=e.getBookmarkKey(t.id),o=JSON.parse(localStorage.getItem(c)||"[]").find(l=>l.name===r);n(o?o.default:!1)},[r,t.id]);function a(c){if(n(c),!r)return;const x=e.getBookmarkKey(t.id),l=JSON.parse(localStorage.getItem(x)||"[]").map(h=>(h.name===r?h.default=c:h.default=!1,h));console.log(l),localStorage.setItem(x,JSON.stringify(l))}return e.jsxRuntimeExports.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxRuntimeExports.jsx(e.Checkbox,{checked:s,onCheckedChange:a,id:"terms"}),e.jsxRuntimeExports.jsx("label",{htmlFor:"terms",className:"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",children:"Set as default"})]})}function Bs(){const s=e.useDashboardStore(S=>S.bookmarkKey),n=e.useDashboardStore(S=>S.dashboard);e.useDashboardStore(S=>S.selectedSheetId);const t=e.useDashboardStore(S=>S.isDashboardEditing),r=e.useDashboardStore(S=>S.filterValues),a=e.useDashboardStore(S=>S.isVisualEditing),c=e.useDashboardStore(S=>S.showFilters);e.useDashboardStore(S=>S.showDashboardJSON);const x=e.useDashboardStore(S=>S.onSaveFunction),o=e.useDashboardStore(S=>S.actions.setShowFilters),{addFrame:l,setSelectedFrameId:h}=e.useDashboardStore(S=>S.actions),{getSelectedSheet:d,setIsDashboardEditing:m,setShowDashboardJSON:y}=e.useDashboardStore(S=>S.actions),u=d(),p=()=>{if(!t||!u)return;const S={id:e.v4(),title:"Title",description:"Description",preferences:{onClickFilter:[{columnIndex:0,expression:""}]},type:"bar",sql:"select COUNT(*) from YOUR_TABLE",data:[]},A={id:e.v4(),cards:[S],activeCardId:S.id};l(u.id,A),h(A.id)},j=()=>{m(!0)};function v(){if(!s||s==="")return;const S=e.getDashbaordStateWithoutData(n),A=e.getBookmarkKey(n.id),R=JSON.parse(localStorage.getItem(A)||"[]"),I=R.findIndex(b=>b.name===s);I!==-1?R[I]={name:s,template:S,default:R[I].default,filterValues:r}:R.push({name:s,template:S,filterValues:r}),localStorage.setItem(A,JSON.stringify(R)),x==null||x(S)}return a?null:e.jsxRuntimeExports.jsxs("div",{className:"flex items-center justify-between gap-2 border-b bg-muted/50 px-2 py-2",role:"dashboard-controls",children:[!a&&e.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxRuntimeExports.jsx(e.Label,{children:s}),!!s&&e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx("span",{className:"text-muted-foreground",children:"|"}),e.jsxRuntimeExports.jsx(qs,{})]})]}),e.jsxRuntimeExports.jsxs("div",{className:"flex gap-2",children:[t&&!a&&e.jsxRuntimeExports.jsx(Os,{}),!a&&e.jsxRuntimeExports.jsx(Ms,{}),t&&!a&&e.jsxRuntimeExports.jsxs(e.Button,{variant:"outline",className:"h-7 p-2",size:"sm",disabled:!t,onClick:p,children:[e.jsxRuntimeExports.jsx(e.Plus,{className:"mr-2 h-4 w-4",strokeWidth:1.5}),"Add Frame"]}),!t&&e.jsxRuntimeExports.jsx(e.Button,{variant:"outline",className:"h-7 p-2",onClick:j,size:"sm",children:e.jsxRuntimeExports.jsx($e,{className:"h-4 w-4",strokeWidth:1.5})}),t&&!a&&e.jsxRuntimeExports.jsx(e.Button,{variant:"outline",role:"close",className:"h-7 p-2",onClick:()=>{m(!1),y(!1)},size:"sm",children:e.jsxRuntimeExports.jsx(e.Cross2Icon,{className:"h-4 w-4",strokeWidth:1.5})}),t&&!a&&e.jsxRuntimeExports.jsx(e.Button,{className:"h-7 p-2",variant:"outline",onClick:v,size:"sm",children:e.jsxRuntimeExports.jsx(As,{className:"h-4 w-4",strokeWidth:1.5})}),!c&&!a&&t&&e.jsxRuntimeExports.jsx(e.Button,{className:"h-7 p-2",variant:"outline",onClick:()=>o(!0),size:"sm",children:e.jsxRuntimeExports.jsx(He,{className:"h-4 w-4",strokeWidth:1.5})}),!a&&t&&!1,!a&&!1]})]})}function he({title:s,items:n,value:t,isLoading:r,isError:a,connectionTooltip:c,onChange:x,showNone:o=!1,className:l,showIcon:h=!0,disabled:d=!1}){const m=r?"Loading...":a?"Error":t;function y(){if(s==="Connection")return e.jsxRuntimeExports.jsx(ws,{className:"size-4 rotate-90"});if(s==="Database")return e.jsxRuntimeExports.jsx(js,{className:"size-4"});if(s==="Schema")return e.jsxRuntimeExports.jsx(Ns,{className:"size-4"});if(s==="Table")return e.jsxRuntimeExports.jsx(e.Table,{className:"size-4"});if(s==="Dataset")return e.jsxRuntimeExports.jsx(ps,{className:"size-4"})}return e.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-2",children:[h&&e.jsxRuntimeExports.jsx("div",{className:"shrink-0",children:c?e.jsxRuntimeExports.jsxs(e.Tooltip,{children:[e.jsxRuntimeExports.jsx(e.TooltipTrigger,{children:y()}),e.jsxRuntimeExports.jsx(e.TooltipContent,{className:"text-xs",align:"start",children:c})]}):y()}),e.jsxRuntimeExports.jsxs(e.Select,{disabled:d,value:m,onValueChange:x,children:[e.jsxRuntimeExports.jsx(e.SelectTrigger,{className:e.cn("h-9 w-full focus:ring-1 focus:ring-offset-0",l),children:e.jsxRuntimeExports.jsx(e.SelectValue,{placeholder:r?"Loading...":a?"Error":`Select ${s}`})}),e.jsxRuntimeExports.jsx(e.SelectContent,{children:e.jsxRuntimeExports.jsxs(e.SelectGroup,{children:[r?e.jsxRuntimeExports.jsx(e.SelectLabel,{children:"Loading..."}):e.jsxRuntimeExports.jsx(e.SelectLabel,{children:s}),e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[o&&e.jsxRuntimeExports.jsx(e.SelectItem,{value:"none",children:"None"},"none"),n&&n.map((u,p)=>e.jsxRuntimeExports.jsx(e.SelectItem,{value:u.id,children:u.name},p))]}),(r||a)&&e.jsxRuntimeExports.jsx(e.SelectItem,{value:m,children:m})]})})]})]})}function Vs({column:s}){const[n,t]=f.useState(!1),r=e.useEditorStore(d=>d.selectedTableName),a=e.useEditorStore(d=>d.selectedSchemaName),c=e.useEditorStore(d=>d.sqlGen),x=e.useEditorStore(d=>d.actions.setSqlGen),o=e.useEditorStore(d=>d.actions.setCardSql),l=e.useEditorStore(d=>d.actions.setRunSql);function h(d,m){const y=e.createSqlGenConfig(d,c,m);x(y);const u=e.getSql(y,e.fmt(a||""),e.fmt(r));u&&(o(u),l(!0)),t(!1)}return e.jsxRuntimeExports.jsxs(e.Popover,{open:n,onOpenChange:t,children:[e.jsxRuntimeExports.jsx(e.PopoverTrigger,{asChild:!0,children:e.jsxRuntimeExports.jsx(e.ChevronDown,{className:"h-4 w-4 cursor-pointer text-foreground/40"})}),e.jsxRuntimeExports.jsx(e.PopoverContent,{align:"center",className:"w-18 rounded-md p-0 shadow-none",children:e.jsxRuntimeExports.jsxs("ul",{className:"text-xs",children:[e.jsxRuntimeExports.jsx("li",{onClick:()=>h(s,"COUNT"),className:"cursor-pointer p-1 px-3 transition-colors hover:bg-muted",children:"Count"}),e.jsxRuntimeExports.jsx("li",{onClick:()=>h(s,"AVG"),className:"cursor-pointer p-1 px-3 transition-colors hover:bg-muted",children:"Avg"}),e.jsxRuntimeExports.jsx("li",{onClick:()=>h(s,"SUM"),className:"cursor-pointer p-1 px-3 transition-colors hover:bg-muted",children:"Sum"}),e.jsxRuntimeExports.jsx("li",{onClick:()=>h(s,"MAX"),className:"cursor-pointer p-1 px-3 transition-colors hover:bg-muted",children:"Max"}),e.jsxRuntimeExports.jsx("li",{onClick:()=>h(s,"MIN"),className:"cursor-pointer p-1 px-3 transition-colors hover:bg-muted",children:"Min"})]})})]})}function Qe({column:s}){return e.jsxRuntimeExports.jsxs(e.Tooltip,{children:[e.jsxRuntimeExports.jsx(e.$a093c7e1ec25a057$export$8c610744efcf8a1d,{asChild:!0,children:e.TEXT_DATA_TYPES.includes(s.data_type.toLowerCase())?e.jsxRuntimeExports.jsx(Le,{className:"size-3"}):e.NUMBER_DATA_TYPES.includes(s.data_type.toLowerCase())?e.jsxRuntimeExports.jsx(Rs,{className:"size-3"}):e.DATE_DATA_TYPES.includes(s.data_type.toLowerCase())?e.jsxRuntimeExports.jsx(e.Calendar,{className:"size-3"}):e.BOOLEAN_DATA_TYPES.includes(s.data_type.toLowerCase())?e.jsxRuntimeExports.jsx(Ds,{className:"size-3"}):e.jsxRuntimeExports.jsx(Is,{className:"size-3"})}),e.jsxRuntimeExports.jsx(e.TooltipContent,{children:e.jsxRuntimeExports.jsx("p",{className:"font-mono text-xs",children:s.data_type})})]})}function _s({schemaName:s,tableName:n,columns:t,status:r}){const a=e.useEditorStore(b=>b.sqlGen),c=e.useEditorStore(b=>b.selectedConnectionId),x=e.useEditorStore(b=>b.selectedDatabaseName),o=e.useEditorStore(b=>b.selectedSchemaName),l=e.useEditorStore(b=>b.selectedTableName),h=e.useDashboardStore(b=>b.dashboard.aiScopeTables),{setAIScopeTables:d}=e.useDashboardStore(b=>b.actions),m=e.useEditorStore(b=>b.actions.setRunSql),y=e.useEditorStore(b=>b.actions.setSqlGen),u=e.useEditorStore(b=>b.actions.setIsShowingVisual),p=e.useEditorStore(b=>b.actions.setCardSql),{connectionType:j}=De();function v(b){const N=e.createSqlGenConfig(b,a);y(N);const w=e.getSql(N,e.fmt(s),e.fmt(n));w&&(p(w),m(!0))}function S(){return(h==null?void 0:h.find(b=>b.connectinonId===c&&b.tableName===l))!==void 0}function A(b){if(b===!0&&l&&c){const N={connectinonId:c,connectionType:j,databaseName:x,schemaName:o,tableName:l},T=[...h||[],N].filter((k,M,q)=>q.findIndex(z=>z.connectinonId===k.connectinonId&&z.tableName===k.tableName)===M);d(T),e.Jt.success(`Added '${l}' to AI Scope`,{position:"top-right",duration:2500,richColors:!0})}else{const N=(h||[]).filter(w=>w.connectinonId!==c&&w.tableName!==l);d(N),e.Jt(`Removed '${l}' from AI Scope`,{position:"top-right",duration:2e3,richColors:!0})}}function R(){let N=e.getQualifiedTableName(s,n);(k=>k.charAt(0)===k.charAt(0).toUpperCase())(n)&&(N=`"${n}"`),u(!1);const T=j==="MSSQL"?`SELECT top 10 * FROM ${N}`:`SELECT * FROM ${N} LIMIT 10`;p(T),m(!0)}function I(){let N=e.getQualifiedTableName(s,n);(T=>T.charAt(0)===T.charAt(0).toUpperCase())(n)&&(N=`"${n}"`),u(!1),p(`SELECT COUNT(*) as count FROM ${N}`),m(!0)}return e.jsxRuntimeExports.jsxs("div",{className:"flex grow flex-col space-y-4 px-4",children:[e.jsxRuntimeExports.jsxs("div",{className:"flex items-center justify-center gap-1",children:[e.jsxRuntimeExports.jsx(e.Toggle,{title:`${S()?"Remove from":"Add to"} AI Scope`,pressed:S(),onPressedChange:A,variant:"outline",className:"h-9 px-2",children:e.jsxRuntimeExports.jsx(e.Bot,{className:e.cn("size-4",{"text-primary":S(),"text-muted-foreground":!S()})})}),e.jsxRuntimeExports.jsxs(e.Button,{disabled:r!=="Success",onClick:R,size:"sm",variant:"secondary",className:"flex",children:[r!=="Success"?e.jsxRuntimeExports.jsx(e.LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin text-foreground/50"}):e.jsxRuntimeExports.jsx(Ts,{className:"mr-2 size-4"}),"Top 10"]}),e.jsxRuntimeExports.jsxs(e.Button,{disabled:r!=="Success",onClick:I,size:"sm",variant:"secondary",className:"flex",children:[r!=="Success"?e.jsxRuntimeExports.jsx(e.LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin text-foreground/50"}):e.jsxRuntimeExports.jsx(zs,{className:"mr-2 size-4"}),"Count"]})]}),e.jsxRuntimeExports.jsxs(e.ScrollArea,{className:"flex-1 basis-0 overflow-y-auto border-b border-t border-muted py-3",children:[t==null?void 0:t.map(b=>e.jsxRuntimeExports.jsxs("div",{onClick:()=>v(b),className:e.cn("mx-3 flex cursor-pointer items-center justify-between rounded px-2 py-[6px] text-sm transition-colors hover:bg-muted/50",{"bg-muted":e.isColumnInSqlGen(b,a)}),children:[e.jsxRuntimeExports.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxRuntimeExports.jsx(Qe,{column:b}),e.jsxRuntimeExports.jsx("span",{children:b.column_name})]}),e.NUMBER_DATA_TYPES.includes(b.data_type)&&e.jsxRuntimeExports.jsx("div",{onClick:N=>N.stopPropagation(),className:"flex items-center justify-end",children:e.jsxRuntimeExports.jsx(Vs,{column:b})})]},b.column_name)),e.jsxRuntimeExports.jsx(e.ScrollBar,{orientation:"vertical"}),e.jsxRuntimeExports.jsx(e.ScrollBar,{orientation:"horizontal"})]})]})}function De(s,n){var Ee,fe,me,ge,Re;let t=f.useMemo(()=>[],[]);const r=e.useSemaphorContext().authToken||s,a=e.useEditorStore(i=>i.selectedConnectionId),c=e.useEditorStore(i=>i.selectedDatamodelId),x=e.useEditorStore(i=>i.selectedDatabaseName),o=e.useEditorStore(i=>i.selectedSchemaName),l=e.useEditorStore(i=>i.selectedTableName),h=e.useEditorStore(i=>i.actions.setCurrentColumns),d=e.useEditorStore(i=>i.actions.setSelectedConnectionId),m=e.useEditorStore(i=>i.actions.setSelectedDatamodelId),y=e.useEditorStore(i=>i.actions.setSelectedDatabaseName),u=e.useEditorStore(i=>i.actions.setSelectedSchemaName),p=e.useEditorStore(i=>i.actions.setSelectedTableName),j=e.useEditorStore(i=>i.actions.setCardSql);function v(i){return a&&x&&o&&x!=="NA"?!0:a&&i==="API"?!1:!!(a&&i==="S3")}function S(i){return!!(a&&x&&x!=="NA"&&o&&l||a&&(i==="S3"||i==="API")||c&&c)}function A(i){return a&&i?!(i==="API"||i==="S3"):!1}const{data:R,isLoading:I,isError:b}=e.useQuery({queryKey:["connections"],queryFn:()=>e.getRequest("https://semaphor.cloud/api/v1/connections",(r==null?void 0:r.accessToken)||""),enabled:!!(r!=null&&r.accessToken)}),{data:N,isLoading:w,isError:T}=e.useQuery({queryKey:["models",a],queryFn:()=>e.getRequest("https://semaphor.cloud/api/v1/datamodels",(r==null?void 0:r.accessToken)||"",{connection_id:a}),enabled:!!(r!=null&&r.accessToken)&&!!a}),k=R==null?void 0:R.connections.find(i=>i.id===a),M=k==null?void 0:k.type,q=(k==null?void 0:k.type)==="API"||(k==null?void 0:k.type)==="S3",{data:z,isLoading:_,isFetching:G,isError:B,refetch:P}=e.useQuery({queryKey:["databases",a],queryFn:()=>e.getRequest("https://semaphor.cloud/api/v1/databases",(r==null?void 0:r.accessToken)||"",{connection_id:a}),enabled:A(M)}),{data:F,isLoading:$,isFetching:g,isError:E,refetch:C}=e.useQuery({queryKey:["schemas",a,x],queryFn:()=>e.getRequest("https://semaphor.cloud/api/v1/schemas",(r==null?void 0:r.accessToken)||"",{connection_id:a,database_name:x}),enabled:!!a&&!!x&&!q&&x!=="NA"}),{data:L,isLoading:D,isFetching:ee,isError:K,refetch:ue}=e.useQuery({queryKey:["tables",a,x,o],queryFn:()=>e.getRequest("https://semaphor.cloud/api/v1/tables",(r==null?void 0:r.accessToken)||"",{connection_id:a,database_name:x,schema_name:o}),enabled:v(M)}),{data:H,isLoading:re,isFetching:se,isError:O}=e.useQuery({queryKey:["columns",a,x,c,o,l],queryFn:()=>e.getRequest("https://semaphor.cloud/api/v1/columns",(r==null?void 0:r.accessToken)||"",{connection_id:a,datamodel_id:c||"",database_name:x,schema_name:o,table_name:l}),enabled:S(M)});f.useEffect(()=>{h(t)},[H,h,t]),f.useEffect(()=>{},[q,j,p,u,y,k]);const Q=(k==null?void 0:k.type)==="API"?(Ee=k==null?void 0:k.type)==null?void 0:Ee.toLowerCase():l||"",U=q?"":o||"";function ne(i){u(i),p("")}function ie(i){y(i==="none"?"":i),u(""),p(""),i!=="none"&&i!==""&&m("")}function de(i){d(i)}function Oe(i){m(i==="none"?"":i),i!=="none"&&i!==""&&y("")}z&&((fe=z==null?void 0:z.databases)==null?void 0:fe.length)>0,F&&((me=F==null?void 0:F.schemas)==null?void 0:me.length)>0,H&&((ge=H==null?void 0:H.columns)==null?void 0:ge.length)>0&&(t=H.columns.map(i=>({...i,data_type:i.data_type.toLowerCase()}))),B&&(t=[]),(O||b)&&(t=[]);const ae=R==null?void 0:R.connections.map(i=>({id:i.id,name:i.name,type:i.type})),Ce=(Re=N==null?void 0:N.datamodels)==null?void 0:Re.map(i=>({id:i.id,name:i.name})),je=z==null?void 0:z.databases.map(i=>({id:i.database_name,name:i.database_name})),Ne=F==null?void 0:F.schemas.map(i=>({id:i.schema_name,name:i.schema_name})),ke=L==null?void 0:L.tables.map(i=>({id:i.table_name,name:i.table_name}));return{connectionItems:ae,isConnectionsLoading:I,isConnectionsError:b,modelItems:Ce,isModelsLoading:w,isModelsError:T,databaseItems:je,isDatabasesLoadingOrFetching:_||G,isDatabaseError:B,schemaItems:Ne,isSchemaLoadingOrFetching:$||g,isSchemaError:E,tableItems:ke,isTableLoadingOrFetching:D||ee,isTableError:K,columns:t,isColumnsLoadingOrFetching:re||se,isColumnsError:O,isNonDbConnection:q,connectionType:M,tableName:Q,schemaName:U,handleConnectionChange:de,handleDatamodelChange:Oe,handleDatabaseChange:ie,handleSchemaChange:ne}}function Ue({ColumnsComponent:s}){var L;const n=e.useEditorStore(D=>D.selectedConnectionId),t=e.useEditorStore(D=>D.selectedDatamodelId),r=e.useEditorStore(D=>D.selectedDatabaseName),a=e.useEditorStore(D=>D.selectedSchemaName),c=e.useEditorStore(D=>D.selectedTableName),x=e.useEditorStore(D=>D.actions.setSelectedTableName),{connectionItems:o,modelItems:l,schemaItems:h,databaseItems:d,tableItems:m,columns:y,isConnectionsLoading:u,isModelsLoading:p,isConnectionsError:j,isModelsError:v,isDatabasesLoadingOrFetching:S,isDatabaseError:A,isSchemaLoadingOrFetching:R,isSchemaError:I,isColumnsError:b,isColumnsLoadingOrFetching:N,isTableLoadingOrFetching:w,isTableError:T,connectionType:k,isNonDbConnection:M,handleConnectionChange:q,handleDatabaseChange:z,handleSchemaChange:_,handleDatamodelChange:G,tableName:B,schemaName:P}=De();function F(){return s?s(P,B,y):e.jsxRuntimeExports.jsx(_s,{schemaName:P,tableName:B,columns:y,status:N?"Loading...":b?"Error":"Success"})}function $(){window.location.href="mailto:support@semaphor.cloud?subject=Help&body=I need help with..."}function g(){return k==="S3"||k==="API"||!n||n==="none"||t&&t!=="none"?null:e.jsxRuntimeExports.jsx(he,{showNone:!0,onChange:z,isError:A,isLoading:S,items:d,value:r||"",title:"Database"})}function E(){return k==="S3"||k==="API"||!r||n==="none"||r==="none"?null:e.jsxRuntimeExports.jsx(he,{onChange:_,isError:I,isLoading:R,items:h,value:a||"",title:"Schema"})}function C(){return k==="API"||k!=="S3"&&(!a||a==="none"||n==="none"||r==="none")?null:e.jsxRuntimeExports.jsx(he,{onChange:x,isError:T,items:m,isLoading:w,value:c||"",title:"Table"})}return e.jsxRuntimeExports.jsxs("aside",{className:"xbg-red-100 flex grow flex-col justify-between",children:[e.jsxRuntimeExports.jsxs("section",{className:"space-y-3 px-6 py-4",children:[e.jsxRuntimeExports.jsx(he,{items:o,title:"Connection",value:n||"",onChange:q,isLoading:u,isError:j,connectionTooltip:((L=o==null?void 0:o.find(D=>D.id===n))==null?void 0:L.type)||""}),g(),E(),C()]}),F(),e.jsxRuntimeExports.jsx("div",{className:"flex items-end justify-center gap-2 px-6 py-4",children:e.jsxRuntimeExports.jsxs(e.Button,{onClick:$,size:"sm",variant:"secondary",className:"w-full",children:[e.jsxRuntimeExports.jsx(Cs,{className:"mr-2 size-4"}),"Help"]})})]})}function Hs(s){const n=s.toUpperCase().indexOf("WHERE"),t=s.toUpperCase().indexOf("GROUP BY"),r=s.toUpperCase().indexOf("LIMIT"),a=s.toUpperCase().indexOf("ORDER BY");let c=s.length;if(a!==-1&&(c=a),r!==-1&&r<c&&(c=r),n!==-1){const x=s.substring(0,n),o=s.substring(n);return`${x} {{ filters | where }} AND ${o.substring(6)}`}else if(t!==-1){const x=s.substring(0,t),o=s.substring(t);return`${x} {{ filters | where }} ${o}`}else{const x=s.substring(0,c),o=s.substring(c);return`${x} {{ filters | where }} ${o}`}}function Ps({error:s,setShowAIDialog:n,setUserInputforAI:t,setTriggerAIRun:r}){return e.jsxRuntimeExports.jsxs(e.HoverCard,{openDelay:0,children:[e.jsxRuntimeExports.jsx(e.HoverCardTrigger,{asChild:!0,children:e.jsxRuntimeExports.jsx(e.Button,{variant:"link",className:" p-0 h-5",children:e.jsxRuntimeExports.jsx(hs,{className:"h-4 w-4 text-red-500"})})}),e.jsxRuntimeExports.jsx(e.HoverCardContent,{align:"start",className:" min-w-fit max-w-[500px]",children:e.jsxRuntimeExports.jsx("div",{className:"flex justify-between space-x-4",children:e.jsxRuntimeExports.jsxs("div",{className:"grow space-y-1 flex flex-col ",children:[e.jsxRuntimeExports.jsxs(e.Button,{onClick:()=>{n(!0),t(s),r(!0)},size:"sm",variant:"outline",children:[e.jsxRuntimeExports.jsx(gs,{className:"h-4 w-4 mr-2"}),"Fix It"]}),e.jsxRuntimeExports.jsx(e.ScrollArea,{className:" min-h-0 max-h-[250px] overflow-scroll ",children:e.jsxRuntimeExports.jsx("p",{className:" overflow-auto text-sm leading-relaxed font-mono ",children:s})})]})})})]})}function $s({text:s,onCheckedChange:n,checked:t}){return e.jsxRuntimeExports.jsxs("div",{className:"xbg-red-100 ml-6 flex items-center gap-2",children:[e.jsxRuntimeExports.jsx(e.Checkbox,{checked:t,onCheckedChange:n}),e.jsxRuntimeExports.jsx("label",{className:"text-xs leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",children:s})]})}function Ks(){const{authToken:s}=e.useSemaphorContext(),n=e.useEditorStore(c=>c.selectedConnectionId),{data:t}=e.useQuery({queryKey:["connections"],queryFn:()=>e.getRequest("https://semaphor.cloud/api/v1/connections",(s==null?void 0:s.accessToken)||""),enabled:!!(s!=null&&s.accessToken)}),r=t==null?void 0:t.connections.find(c=>c.id===n);return r==null?void 0:r.type}function Gs(){const{authToken:s}=e.useSemaphorContext(),n=f.useRef(null),t=e.useEditorStore(l=>l.applyFilters),[r,a]=f.useState(""),c=e.useEditorStore(l=>l.filterValues),x=e.useEditorStore(l=>l.card.sql),o=Ks();return e.jsxRuntimeExports.jsxs(e.HoverCard,{openDelay:0,onOpenChange:async l=>{if(!l)return;console.log("onOpenChange");const h=await e.postRequest("https://semaphor.cloud/api/v1/filter-sql",(s==null?void 0:s.accessToken)||"",{sql:x,active_filters:c,connection_type:o});console.log(h),h.sql?(console.log(h.records),a(h.sql)):a("Error")},children:[e.jsxRuntimeExports.jsx(e.HoverCardTrigger,{asChild:!0,children:t&&e.jsxRuntimeExports.jsx("p",{className:"p-0 text-xs hover:cursor-pointer",children:"| Filter Query"})}),e.jsxRuntimeExports.jsxs(e.HoverCardContent,{align:"end",className:"w-[600px]",children:[e.jsxRuntimeExports.jsx("div",{className:"flex justify-between space-x-4",children:e.jsxRuntimeExports.jsx("div",{className:"rounded-sm bg-muted p-2",children:e.jsxRuntimeExports.jsxs("code",{ref:n,className:"font-mono text-sm",children:[r,e.jsxRuntimeExports.jsx(e.ClipboardCopyIcon,{onClick:()=>e.copyToClipboard(n),className:"ml-3 inline-block h-4 w-4 opacity-70 hover:cursor-pointer hover:opacity-100"})]})})}),e.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-2 pt-2",children:[e.jsxRuntimeExports.jsx(e.InfoCircledIcon,{className:"h-4 w-4 opacity-70"}),e.jsxRuntimeExports.jsx("span",{className:"text-xs text-muted-foreground",children:"A preview of the query with filters applied."})]})]})]})}const Qs=`
|
|
162
|
+
|
|
163
|
+
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.
|
|
164
|
+
|
|
165
|
+
Bar / Line Chart:
|
|
166
|
+
|
|
167
|
+
SELECT x-axis, y-axis-1, y-axis-2, y-axis-3,... FROM table
|
|
168
|
+
|
|
169
|
+
- X-axis - Category
|
|
170
|
+
- Y-axis - Number
|
|
171
|
+
|
|
172
|
+
Stacked Chart:
|
|
173
|
+
|
|
174
|
+
SELECT x-axis, stack-by, y-axis FROM table
|
|
175
|
+
|
|
176
|
+
- X-axis - Category
|
|
177
|
+
- Stack by - Category
|
|
178
|
+
- Y-axis - Number
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+
Scatter Chart:
|
|
182
|
+
|
|
183
|
+
SELECT label, x-axis, y-axis FROM table
|
|
184
|
+
|
|
185
|
+
- Label - Category
|
|
186
|
+
- Group (opt) - Category
|
|
187
|
+
- X-axis - Number
|
|
188
|
+
- Y-axis - Number
|
|
189
|
+
|
|
190
|
+
|
|
191
|
+
Bubble Chart:
|
|
192
|
+
|
|
193
|
+
SELECT label, x-axis, y-axis, radius FROM table
|
|
194
|
+
|
|
195
|
+
- Label - Category
|
|
196
|
+
- Bubble Group (opt) - Category
|
|
197
|
+
- X-axis - Number
|
|
198
|
+
- Y-axis - Number
|
|
199
|
+
- Radius - Number
|
|
200
|
+
|
|
201
|
+
Pie / Dougnut Chart:
|
|
202
|
+
|
|
203
|
+
SELECT label, measure FROM table
|
|
204
|
+
|
|
205
|
+
- Label - Category
|
|
206
|
+
- Measure - Number
|
|
207
|
+
`;function Us({open:s,setOpen:n,userInput:t,setUserInput:r,triggerAIRun:a,setTriggerAIRun:c}){const x=f.useRef(null),o=f.useRef(null),{authToken:l}=e.useSemaphorContext(),[h,d]=f.useState(!1),m=e.useEditorStore(g=>g.actions.setCardSql),y=e.useDashboardStore(g=>g.dashboard.baseQueries),u=e.useEditorStore(g=>g.actions.setRunSql),p=e.useEditorStore(g=>g.actions.setCardType),[j,v]=f.useState([]),S=e.useEditorStore(g=>g.currentColumns),A=e.useEditorStore(g=>g.card.sql),R=e.useEditorStore(g=>g.selectedTableName),I=`
|
|
208
|
+
${t}
|
|
209
|
+
|
|
210
|
+
Database Query Dialect: ${R==="api"||R==="s3"?"DuckDb":""}
|
|
211
|
+
Table Name: ${R}
|
|
212
|
+
Table Columns: ${S==null?void 0:S.map(g=>`${g.column_name} | ${g.data_type}`).join(", ")}
|
|
213
|
+
User SQL: ${A}
|
|
214
|
+
${y&&`Base Queries: ${JSON.stringify(y)} `}`,b=` 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.
|
|
215
|
+
Visual Query Syntax: ${Qs}`,{data:N,isLoading:w,isFetching:T,isError:k,refetch:M}=e.useQuery({queryKey:["ai-query"],queryFn:()=>e.getRequest("https://semaphor.cloud/api/v1/ai",(l==null?void 0:l.accessToken)||"",{user_content:`userContent: ${I} ${h?b:""}`}),enabled:!1});function q(g){if(g.toLowerCase().includes("bar"))p("bar");else if(g.toLowerCase().includes("line"))p("line");else if(g.toLowerCase().includes("bubble"))p("bubble");else if(g.toLowerCase().includes("scatter"))p("scatter");else if(g.toLowerCase().includes("stacked"))p("stackedBar");else if(g.toLowerCase().includes("pie"))p("pie");else if(g.toLowerCase().includes("donut")||g.toLowerCase().includes("doughnut"))p("doughnut");else if(g.toLowerCase().includes("radar"))p("radar");else return p("bar"),!1;return!0}f.useEffect(()=>{N&&v(g=>[...g,{role:"ai",content:N.response}])},[N]),f.useEffect(()=>{const g=setTimeout(()=>{var E;o.current&&(o.current.scroll({top:o.current.scrollHeight,behavior:"smooth"}),(E=x.current)==null||E.focus())},100);return()=>clearTimeout(g)},[j]);function z(){t&&(v(g=>[...g,{role:"user",content:t}]),q(t)&&d(!0),r(""),M())}f.useEffect(()=>{a&&(z(),c(!1))},[a,c]);const _={fontFamily:"Arial, sans-serif",lineHeight:1.6,fontSize:15,width:"100%"},G={fontFamily:"monospace",fontSize:14,lineHeight:1.6},B={fontFamily:"Arial, sans-serif",lineHeight:1.6,fontSize:15,padding:"2px 0",marginLeft:20,listStyleType:"disc"},P={p:({node:g,...E})=>e.jsxRuntimeExports.jsx("p",{style:_,...E}),code:({node:g,...E})=>e.jsxRuntimeExports.jsx("code",{className:"rounded-sm bg-muted px-2 py-1 text-sm",...E}),pre:({node:g,...E})=>e.jsxRuntimeExports.jsxs("pre",{className:"space-y-2 rounded-sm bg-muted/50 p-3",style:G,children:[e.jsxRuntimeExports.jsx("code",{className:"whitespace-normal text-sm",children:E.children}),e.jsxRuntimeExports.jsxs("div",{className:"flex justify-start gap-2",children:[e.jsxRuntimeExports.jsx(e.Button,{onClick:F,size:"sm",variant:"outline",children:e.jsxRuntimeExports.jsx(e.ClipboardCopyIcon,{})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:C=>{const L=F(C);L&&(n(!1),m(L),u(!0))},size:"sm",variant:"outline",children:e.jsxRuntimeExports.jsx(e.PlayIcon,{})})]})]}),li:({node:g,...E})=>e.jsxRuntimeExports.jsx("li",{style:B,...E})};function F(g){const E=g.currentTarget.closest("pre");if(!E)return;const C=E.textContent||E.innerText;return navigator.clipboard.writeText(C).then(()=>console.log("Text copied to clipboard")).catch(L=>console.error("Error in copying text: ",L)),C}function $(){return j==null?void 0:j.map((g,E)=>g.role==="user"?e.jsxRuntimeExports.jsxs("div",{className:"flex items-start rounded-md bg-muted p-3 text-sm",children:[e.jsxRuntimeExports.jsx(Fs,{className:"mr-2 h-5 w-5"}),e.jsxRuntimeExports.jsx("div",{children:g.content})]},E):g.role==="ai"?e.jsxRuntimeExports.jsx(e.Markdown,{className:"w-full overflow-auto py-1",components:P,children:N==null?void 0:N.response.replace(/DuckDB/gi,"Semaphor")},E):e.jsxRuntimeExports.jsx("div",{},E))}return e.jsxRuntimeExports.jsxs(e.Dialog,{open:s,onOpenChange:n,children:[e.jsxRuntimeExports.jsx(e.DialogTrigger,{asChild:!0,children:e.jsxRuntimeExports.jsx(e.Button,{size:"sm",className:"w-full justify-start border font-normal text-muted-foreground focus-visible:ring-0 focus-visible:ring-offset-0",variant:"secondary",children:"Type your question here..."})}),e.jsxRuntimeExports.jsxs(e.DialogContent,{className:"flex flex-col justify-between overflow-auto sm:max-w-[425px] md:max-h-[625px] md:min-w-[625px]",children:[e.jsxRuntimeExports.jsxs(e.DialogHeader,{children:[e.jsxRuntimeExports.jsx(e.DialogTitle,{children:"Assistant"}),e.jsxRuntimeExports.jsx(e.DialogDescription,{children:"What can I help you with?"})]}),e.jsxRuntimeExports.jsx("div",{ref:o,className:"h-[625px] w-full overflow-auto border-t border-t-muted",children:e.jsxRuntimeExports.jsx("div",{className:"space-y-4 py-2 pr-3",role:"messages",children:$()})}),e.jsxRuntimeExports.jsx("div",{children:e.jsxRuntimeExports.jsxs("div",{className:"flex w-full items-center rounded-md border",children:[e.jsxRuntimeExports.jsx(e.Textarea,{autoFocus:!0,ref:x,onKeyDown:g=>{g.key==="Enter"&&!g.shiftKey&&(g.preventDefault(),r(""),z())},placeholder:"Type your question here...",onFocus:g=>{const E=g.target,C=E.value.length;E.setSelectionRange(C,C)},className:e.cn("max-h-10 min-h-7 resize-none border-none focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0"),disabled:w||T,value:t,onChange:g=>r(g.target.value)})," ",e.jsxRuntimeExports.jsx(e.Button,{className:"h-8",size:"sm",variant:"ghost",onClick:z,children:!w&&!T?e.jsxRuntimeExports.jsx(e.PaperPlaneIcon,{}):e.jsxRuntimeExports.jsx(e.LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin text-foreground/50"})})]})})]})]})}var Je={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},qe=f.createContext&&f.createContext(Je),Js=["attr","size","title"];function Ws(s,n){if(s==null)return{};var t=Ys(s,n),r,a;if(Object.getOwnPropertySymbols){var c=Object.getOwnPropertySymbols(s);for(a=0;a<c.length;a++)r=c[a],!(n.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(s,r)&&(t[r]=s[r])}return t}function Ys(s,n){if(s==null)return{};var t={},r=Object.keys(s),a,c;for(c=0;c<r.length;c++)a=r[c],!(n.indexOf(a)>=0)&&(t[a]=s[a]);return t}function Se(){return Se=Object.assign?Object.assign.bind():function(s){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(s[r]=t[r])}return s},Se.apply(this,arguments)}function Be(s,n){var t=Object.keys(s);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(s);n&&(r=r.filter(function(a){return Object.getOwnPropertyDescriptor(s,a).enumerable})),t.push.apply(t,r)}return t}function ye(s){for(var n=1;n<arguments.length;n++){var t=arguments[n]!=null?arguments[n]:{};n%2?Be(Object(t),!0).forEach(function(r){Xs(s,r,t[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(s,Object.getOwnPropertyDescriptors(t)):Be(Object(t)).forEach(function(r){Object.defineProperty(s,r,Object.getOwnPropertyDescriptor(t,r))})}return s}function Xs(s,n,t){return n=Zs(n),n in s?Object.defineProperty(s,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):s[n]=t,s}function Zs(s){var n=et(s,"string");return typeof n=="symbol"?n:String(n)}function et(s,n){if(typeof s!="object"||s===null)return s;var t=s[Symbol.toPrimitive];if(t!==void 0){var r=t.call(s,n||"default");if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(n==="string"?String:Number)(s)}function We(s){return s&&s.map((n,t)=>f.createElement(n.tag,ye({key:t},n.attr),We(n.child)))}function Z(s){return n=>f.createElement(st,Se({attr:ye({},s.attr)},n),We(s.child))}function st(s){var n=t=>{var{attr:r,size:a,title:c}=s,x=Ws(s,Js),o=a||t.size||"1em",l;return t.className&&(l=t.className),s.className&&(l=(l?l+" ":"")+s.className),f.createElement("svg",Se({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},t.attr,r,x,{className:l,style:ye(ye({color:s.color||t.color},t.style),s.style),height:o,width:o,xmlns:"http://www.w3.org/2000/svg"}),c&&f.createElement("title",null,c),s.children)};return qe!==void 0?f.createElement(qe.Consumer,null,t=>n(t)):n(Je)}function tt(s){return Z({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)}function rt(){const{theme:s}=e.useTheme(),n=f.useRef(),t=f.useRef(),[r,a]=f.useState(!1),[c,x]=f.useState(!1),[o,l]=f.useState(!1),[h,d]=f.useState(""),[m,y]=f.useState(!1),{authToken:u}=e.useSemaphorContext();e.useDashboardStore(i=>i.selectedSheetId);const p=e.useDashboardStore(i=>i.dashboard.baseQueries),j=e.useEditorStore(i=>i.card),v=e.useDashboardStore(i=>i.theme),S=e.useEditorStore(i=>i.isShowingVisual),A=e.useEditorStore(i=>i.selectedConnectionId),R=e.useEditorStore(i=>i.selectedDatabaseName),I=e.useEditorStore(i=>i.selectedDatamodelId),b=e.useEditorStore(i=>i.selectedSchemaName);e.useDashboardStore(i=>i.actions.updateFrameCard);const N=e.useEditorStore(i=>i.selectedTableName),w=e.useEditorStore(i=>i.card.sql),T=e.useEditorStore(i=>i.card.python),k=e.resolveBaseQuery(w,p),M=e.useEditorStore(i=>i.selectedConnectionId),q=e.useEditorStore(i=>i.frame),z=e.useEditorStore(i=>i.filterValues),_=e.useEditorStore(i=>i.applyFilters),{setCardCustomCfg:G,setQueryResultColumns:B,setFilterValues:P,setCardSql:F,setCardPython:$,setQueryError:g,setPythonStdOut:E,setCardPreferences:C}=e.useEditorStore(i=>i.actions),L=e.useEditorStore(i=>i.onSave),D=e.useEditorStore(i=>i.actions.setApplyFilters),ee=e.useEditorStore(i=>i.onClose),K=e.useEditorStore(i=>i.actions.setCardData),ue=e.useEditorStore(i=>i.actions.setSqlGen),H=e.useEditorStore(i=>i.runSql),re=e.useEditorStore(i=>i.actions.setRunSql),se=e.useEditorStore(i=>i.actions.setIsSqlRunning),{data:O,isLoading:Q,isFetching:U,isSuccess:ne,isError:ie,error:de,status:Oe,refetch:ae}=e.useQuery({queryKey:[k,T],queryFn:()=>e.postRequest("https://semaphor.cloud/api/v1/query",(u==null?void 0:u.accessToken)||"",{connection_id:M,sql:k,python:T===e.PYTHON_DEFAULT_CODE?"":T,active_filters:_?z:[]}),enabled:!1,retry:!1});f.useEffect(()=>{if(O&&(K(O.records),O.rowLimitExceeded&&e.Jt.error("Row limit (10,000) exceeded. Refine your query.",{position:"top-center",richColors:!0}),E((O==null?void 0:O.output)||""),O.records.length>0)){const{dimensionKeys:i}=e.getKeys(O.records);B(i)}},[O,K,B,E]),f.useEffect(()=>{H&&(ae(),re(!1))},[H,ae,re]),f.useEffect(()=>{(Q||U)&&se(!0),(ie||ne)&&se(!1),ie?(g(de.message),K([]),B([]),E("")):g("")},[Q,U,O,E,ie,ne,se,K,B,g,de]);function Ce(){F(""),K([]),ue({}),G(""),C({})}const je=i=>{t.current=i};function Ne(){let i=w;w&&!w.includes("{{")&&(i=Hs(w),F(i));const J={...j,lastSelectedSchema:b,lastSelectedDatamodelId:I,lastSelectedDatabase:R,lastSelectedTable:N,connectionId:A,type:S?j.type:"table",sql:i,customCfg:S?j.customCfg:null},pe=q.cards.map(oe=>oe.id===j.id?J:oe);L==null||L({...q,cards:pe})}function ke(){ee==null||ee()}function Ee(i){const J=getComputedStyle(document.documentElement).getPropertyValue(i);return fe(J)}function fe(i){const[J,pe,oe]=i.split(" "),V=parseFloat(J),ls=parseFloat(pe),cs=parseFloat(oe),xs=ls/100,Me=cs/100,te=(1-Math.abs(2*Me-1))*xs,le=te*(1-Math.abs(V/60%2-1)),we=Me-te/2;let W=0,Y=0,X=0;0<=V&&V<60?(W=te,Y=le,X=0):60<=V&&V<120?(W=le,Y=te,X=0):120<=V&&V<180?(W=0,Y=te,X=le):180<=V&&V<240?(W=0,Y=le,X=te):240<=V&&V<300?(W=le,Y=0,X=te):300<=V&&V<360&&(W=te,Y=0,X=le),W=Math.round((W+we)*255),Y=Math.round((Y+we)*255),X=Math.round((X+we)*255);const Ae=us=>{const Ie=us.toString(16);return Ie.length==1?"0"+Ie:Ie};return`#${Ae(W)}${Ae(Y)}${Ae(X)}`}f.useEffect(()=>{const i=n.current,J=t.current;if(i){const pe=window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light",oe=v==="system"?pe:v;i.editor.defineTheme("default",{base:oe==="light"?"vs":"vs-dark",inherit:!0,rules:[],colors:{"editor.background":oe==="light"?"#ffffff":Ee("--semaphor-background")}}),i.editor.setTheme("default")}return J&&i&&J.addCommand(i.KeyMod.Shift|i.KeyCode.Enter,function(){return console.log("Executing query..."),ae(),!1}),()=>{}},[s,v,n.current]);function me(i){n.current=i}function ge(){return e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[c&&e.jsxRuntimeExports.jsx("div",{className:"xbg-yellow-100 relative flex w-1/3 min-w-0 grow overflow-hidden border-l p-1 text-xs",role:"editor-filter-container",children:e.jsxRuntimeExports.jsxs("div",{className:"w-[99%]",children:[e.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-2 pt-3",children:[e.jsxRuntimeExports.jsx($s,{checked:_,onCheckedChange:()=>D(!_),text:"Apply Filters"}),e.jsxRuntimeExports.jsx(Gs,{}),z&&c&&e.jsxRuntimeExports.jsx(e.Cross2Icon,{onClick:()=>x(!1),className:"bg-background/50 text-foreground/50 hover:cursor-pointer hover:text-foreground"})]}),e.jsxRuntimeExports.jsx(e.Ft,{theme:"default",onChange:i=>{if(i)try{JSON.parse(i),P(JSON.parse(i))}catch{}},defaultLanguage:"json",className:"mt-1 min-h-[220px]",value:JSON.stringify(z,null,2),options:{readOnly:!0,minimap:{enabled:!1},lineNumbers:"off",glyphMargin:!1,wordWrap:"on",scrollbar:{verticalScrollbarSize:0,horizontalScrollbarSize:0},fontSize:12,renderLineHighlight:"none"}})]})}),z&&!c&&e.jsxRuntimeExports.jsx(He,{onClick:()=>x(!0),className:e.cn("absolute bottom-4 right-6 h-3 w-3 text-foreground/50 hover:cursor-pointer hover:text-foreground",{"font-bold text-red-800":_})})]})}function Re(){return e.jsxRuntimeExports.jsxs(e.ResizablePanelGroup,{className:"flex grow pb-1",direction:"vertical",role:"editor-resizable-group",children:[e.jsxRuntimeExports.jsxs(e.ResizablePanel,{id:"1",order:1,defaultSize:r?20:100,className:"relative flex grow",children:[e.jsxRuntimeExports.jsx("div",{role:"sql-container",className:"relative flex w-[99%]",children:e.jsxRuntimeExports.jsx(e.Ft,{theme:"default",className:"pt-3",onChange:i=>{F(i)},value:w,options:{minimap:{enabled:!1},wordWrap:"on",scrollbar:{verticalScrollbarSize:0,horizontalScrollbarSize:0},fontSize:14,renderLineHighlight:"none"},defaultLanguage:"sql",defaultValue:"SELECT * FROM table",beforeMount:me,onMount:je})}),r&&e.jsxRuntimeExports.jsx("code",{className:"absolute right-6 top-3 text-sm text-muted-foreground/70",children:"sql"})]}),r&&e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx(e.ResizableHandle,{withHandle:!0,className:"border"}),e.jsxRuntimeExports.jsxs(e.ResizablePanel,{id:"2",order:2,defaultSize:80,className:"relative flex grow",children:[e.jsxRuntimeExports.jsx("div",{role:"python-container",className:"relative flex w-[99%] pt-0",children:e.jsxRuntimeExports.jsx(e.Ft,{className:"pt-3",theme:"default",onChange:i=>{$(i&&i.trim()||"")},value:T||e.PYTHON_DEFAULT_CODE,options:{minimap:{enabled:!1},wordWrap:"on",scrollbar:{verticalScrollbarSize:0,horizontalScrollbarSize:0},fontSize:14,renderLineHighlight:"none"},defaultLanguage:"python",beforeMount:me,onMount:je})}),e.jsxRuntimeExports.jsx("code",{className:"absolute right-6 top-3 text-sm text-muted-foreground/70",children:"python"})]})]})]})}return e.jsxRuntimeExports.jsxs("section",{role:"editor-section",className:"flex grow flex-col justify-end",children:[e.jsxRuntimeExports.jsxs("div",{role:"sql-editor",className:"relative flex grow justify-between overflow-y-scroll",children:[Re(),ge()]}),e.jsxRuntimeExports.jsxs("div",{role:"editor-controls",className:"item-center flex flex-wrap justify-between gap-2 px-6 py-4",children:[e.jsxRuntimeExports.jsxs("div",{className:"flex grow items-center gap-2",children:[e.jsxRuntimeExports.jsxs(e.Button,{title:"Shift + Enter",disabled:Q||U,onClick:()=>{ae()},className:"shrink-0",size:"sm",variant:"outline",children:[Q||U?e.jsxRuntimeExports.jsx(e.LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin text-foreground/50"}):e.jsxRuntimeExports.jsx(ks,{className:"mr-2 h-4 w-4"}),"Run"]}),ie&&e.jsxRuntimeExports.jsx(Ps,{error:de.message,setShowAIDialog:l,setTriggerAIRun:y,setUserInputforAI:d}),e.jsxRuntimeExports.jsxs(e.Button,{onClick:Ce,className:"",size:"sm",variant:"outline",children:[e.jsxRuntimeExports.jsx(Es,{className:"mr-2 size-4"}),"Clear"]}),e.jsxRuntimeExports.jsx(e.Toggle,{pressed:r,onPressedChange:i=>a(i),className:"",size:"sm",variant:"outline",children:e.jsxRuntimeExports.jsx(tt,{className:"size-4 text-foreground/70"})}),e.jsxRuntimeExports.jsx(Us,{open:o,setOpen:l,userInput:h,triggerAIRun:m,setTriggerAIRun:y,setUserInput:i=>d(i)})]}),e.jsxRuntimeExports.jsxs("div",{className:"flex items-end gap-2",children:[e.jsxRuntimeExports.jsxs(e.Button,{onClick:Ne,size:"sm",variant:"outline",children:[e.jsxRuntimeExports.jsx(e.Check,{className:"mr-2 size-4 font-bold text-green-600"}),"Accept"]}),e.jsxRuntimeExports.jsxs(e.Button,{onClick:ke,className:"w-full",size:"sm",variant:"outline",children:[e.jsxRuntimeExports.jsx(e.Cross2Icon,{className:"mr-2 size-4"}),"Close"]})]})]})]})}function nt({data:s}){var x;const[n,t]=f.useState([]),a=Object.keys(s[0]).map(o=>({accessorKey:o,header:({column:l})=>{const h=l.getIsSorted();return e.jsxRuntimeExports.jsx("div",{className:"flex gap-2",children:e.jsxRuntimeExports.jsxs("div",{className:"flex cursor-pointer items-center",onClick:()=>l.toggleSorting(l.getIsSorted()==="asc"),children:[o,h==="asc"?e.jsxRuntimeExports.jsx(e.TriangleUpIcon,{className:"ml-2 h-5 w-5"}):h==="desc"?e.jsxRuntimeExports.jsx(e.TriangleDownIcon,{className:"ml-2 h-5 w-5"}):null]})})}})),c=e.useReactTable({data:s,columns:a,getCoreRowModel:e.getCoreRowModel(),getPaginationRowModel:e.getPaginationRowModel(),onSortingChange:t,getSortedRowModel:e.getSortedRowModel(),manualPagination:!0,state:{sorting:n}});return e.jsxRuntimeExports.jsxs(e.Table$1,{children:[e.jsxRuntimeExports.jsx(e.TableHeader,{children:c.getHeaderGroups().map(o=>e.jsxRuntimeExports.jsx(e.TableRow,{children:o.headers.map(l=>e.jsxRuntimeExports.jsx(e.TableHead,{className:"sticky top-0 bg-muted",children:l.isPlaceholder?null:e.flexRender(l.column.columnDef.header,l.getContext())},l.id))},o.id))}),e.jsxRuntimeExports.jsx(e.TableBody,{children:(x=c.getRowModel().rows)!=null&&x.length?c.getRowModel().rows.map(o=>e.jsxRuntimeExports.jsx(e.TableRow,{className:"whitespace-nowrap py-2","data-state":o.getIsSelected()&&"selected",children:o.getVisibleCells().map(l=>e.jsxRuntimeExports.jsx(e.TableCell,{children:e.flexRender(l.column.columnDef.cell,l.getContext())},l.id))},o.id)):e.jsxRuntimeExports.jsx(e.TableRow,{children:e.jsxRuntimeExports.jsx(e.TableCell,{colSpan:a.length,className:"h-24 text-center",children:"No results."})})})]})}function Ye({className:s,...n}){var x;f.useState(0);const t=e.useDashboardStore(o=>o.themeStyle),r=e.useEditorStore(o=>o.card),a=e.useEditorStore(o=>o.actions.setCard);if(f.useEffect(()=>{},[r.data,r.type,r.cfg,r.customCfg,t,r.preferences]),!r.id)return null;let c;return r.data&&r.data.length>0&&(c=e.createChartConfig({data:r.data,cardType:r.type,cfg:r.cfg,customCfg:r.customCfg,preferences:r.preferences})),e.jsxRuntimeExports.jsxs(e.Card,{role:"editor-visual-card",className:e.cn("relative flex h-full flex-col rounded-none",s),...n,children:[e.jsxRuntimeExports.jsxs(e.CardHeader,{className:"py-4",children:[e.jsxRuntimeExports.jsx(e.Editable,{text:r.title,onSave:o=>a({...r,title:o}),children:e.jsxRuntimeExports.jsx("div",{className:"flex items-center gap-2",children:e.jsxRuntimeExports.jsx(e.CardTitle,{className:"text-base",children:r.title})})},r.title),e.jsxRuntimeExports.jsx(e.Editable,{text:r.description||"",onSave:o=>a({...r,description:o}),children:e.jsxRuntimeExports.jsxs(e.CardDescription,{children:[" ",r.description]})},r.description)]}),e.jsxRuntimeExports.jsxs(e.CardContent,{className:"flex grow flex-col pb-3",children:[r.type!=="table"&&c&&e.jsxRuntimeExports.jsx(e.ChartJsVisual,{cfg:c},JSON.stringify(c)+JSON.stringify(r.preferences)+((x=r==null?void 0:r.preferences)==null?void 0:x.customVisualCode)),r.type==="table"&&r.data&&r.data.length>0&&e.jsxRuntimeExports.jsx(e.$57acba87d6e25586$export$ccf8d8d7bbf3c2cc,{className:"flex min-h-0 flex-1 grow basis-0",children:e.jsxRuntimeExports.jsx(e.TableVisual,{card:r,data:r==null?void 0:r.data})})]})]})}function ot(){const[s,n]=f.useState(!1),[t,r]=f.useState(""),[a,c]=f.useState(""),[x,o]=f.useState(""),[l,h]=f.useState(""),d=e.useEditorStore(R=>R.card),m=e.useEditorStore(R=>R.card.customCfg),{setCardCustomCfg:y,setCustomVisualCode:u}=e.useEditorActions();function p(R){var N,w;const I={...R,data:{...R==null?void 0:R.data,datasets:(w=(N=R==null?void 0:R.data)==null?void 0:N.datasets)==null?void 0:w.map(T=>({...T,data:[]}))}};return JSON.stringify(I,null,1)}function j(){var I,b;if(!d.data||d.data.length===0)return;const R=e.createChartConfig({data:d.data,cardType:d.type,cfg:d.cfg,preferences:d.preferences});R&&(r(JSON.stringify(R,null,1)),(I=d==null?void 0:d.preferences)!=null&&I.customVisualCode&&o((b=d==null?void 0:d.preferences)==null?void 0:b.customVisualCode),m&&c(JSON.stringify(m,null,1)))}function v(){if(x&&u(x),!!a)try{const R=JSON.parse(a);return R?(y(R),h(""),c(""),R):void 0}catch(R){console.log(R),h("Invalid JSON")}}function S(){c(""),y(null)}function A(){let R;if(m){const I=e._.cloneDeep(d.cfg),b=e._.merge(I,m);return R=p(b),R}return t?(R=p(JSON.parse(t)),R):""}return e.jsxRuntimeExports.jsxs(e.Dialog,{open:s,onOpenChange:n,children:[e.jsxRuntimeExports.jsx(e.DialogTrigger,{asChild:!0,children:e.jsxRuntimeExports.jsx(e.Button,{onClick:j,className:` ${m&&"border-foreground/50 dark:border-foreground/70"}`,size:"sm",variant:"outline",children:e.jsxRuntimeExports.jsx(e.Settings,{className:"h-4 w-4"})})}),e.jsxRuntimeExports.jsxs(e.DialogContent,{className:"max-h-[70vh] min-h-[70vh] overflow-auto sm:min-w-[900px] lg:min-w-[1200px]",children:[e.jsxRuntimeExports.jsxs(e.DialogHeader,{className:"",children:[e.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxRuntimeExports.jsx(e.DialogTitle,{children:"Customize Card"}),e.jsxRuntimeExports.jsxs(e.Tooltip,{children:[e.jsxRuntimeExports.jsx(e.TooltipTrigger,{children:e.jsxRuntimeExports.jsx(bs,{onClick:()=>{navigator.clipboard.writeText(d.id)},className:"size-3 cursor-pointer text-muted-foreground/70 transition-colors hover:text-muted-foreground"})}),e.jsxRuntimeExports.jsx(e.TooltipContent,{side:"right",align:"center",children:e.jsxRuntimeExports.jsx("p",{className:"text-xs",children:"Copy Card ID"})})]})]}),e.jsxRuntimeExports.jsxs(e.DialogDescription,{children:["See the configuration options and documentation",e.jsxRuntimeExports.jsx("a",{target:"_blank",className:"ml-1 text-blue-500 underline",href:"https://www.chartjs.org/docs/latest/samples/bar/vertical.html",children:"here."})]})]}),e.jsxRuntimeExports.jsxs("div",{className:"flex grow gap-2",children:[e.jsxRuntimeExports.jsx(Ye,{className:"w-1/2 rounded shadow-none"}),e.jsxRuntimeExports.jsxs(e.Tabs,{defaultValue:"custom-config",className:"flex w-1/2 flex-col",children:[e.jsxRuntimeExports.jsxs(e.TabsList,{className:"justify-start rounded-sm rounded-b-none border border-b-0",children:[e.jsxRuntimeExports.jsxs(e.TabsTrigger,{value:"custom-config",children:[m&&e.jsxRuntimeExports.jsx(e.CheckIcon,{className:"mr-1 h-5 w-5 text-green-600"}),m?"Custom Config":"Default Config"]}),e.jsxRuntimeExports.jsx(e.TabsTrigger,{className:"",value:"output",children:"Output"}),e.jsxRuntimeExports.jsx(e.TabsTrigger,{className:"",value:"custom-code",children:"Custom Code"})]}),e.jsxRuntimeExports.jsx(e.TabsContent,{className:"bg-red-x mt-0 grow rounded-b border border-t-0 p-2",value:"output",children:e.jsxRuntimeExports.jsx(e.Textarea,{disabled:!0,value:t,className:"h-full resize-none border-none font-mono focus-visible:ring-0 focus-visible:ring-offset-0"})}),e.jsxRuntimeExports.jsx(e.TabsContent,{className:"mt-0 grow rounded-b border border-t-0",value:"custom-config",children:e.jsxRuntimeExports.jsx(e.Ft,{className:"h-full w-full overflow-hidden",theme:"default",options:{minimap:{enabled:!1},wordWrap:"on",scrollbar:{verticalScrollbarSize:0,horizontalScrollbarSize:0},fontSize:14,renderLineHighlight:"none"},defaultLanguage:"json",value:A(),onChange:R=>c(R)})}),e.jsxRuntimeExports.jsx(e.TabsContent,{className:"mt-0 grow rounded-b border border-t-0",value:"custom-code",children:e.jsxRuntimeExports.jsx(e.Ft,{className:"h-full w-full overflow-hidden",theme:"default",options:{minimap:{enabled:!1},wordWrap:"on",scrollbar:{verticalScrollbarSize:0,horizontalScrollbarSize:0},fontSize:14,renderLineHighlight:"none"},defaultLanguage:"javascript",value:x,onChange:R=>o(R||"")})})]})]}),e.jsxRuntimeExports.jsxs(e.DialogFooter,{className:"flex items-center",children:[e.jsxRuntimeExports.jsx(e.Label,{className:"mr-2 text-red-500",children:l}),e.jsxRuntimeExports.jsx(e.Button,{disabled:!m,onClick:S,variant:"outline",children:"Reset"}),e.jsxRuntimeExports.jsx(e.Button,{onClick:v,variant:"outline",children:"Apply"}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>n(!1),variant:"outline",children:"Close"})]})]})]})}function Xe(s){return Z({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)}function Ze(s){return Z({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)}function es(s){return Z({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)}function ss(s){return Z({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)}function ts(s){return Z({tag:"svg",attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{fill:"none",d:"M0 0h24v24H0z"},child:[]},{tag:"path",attr:{d:"m2 19.99 7.5-7.51 4 4 7.09-7.97L22 9.92l-8.5 9.56-4-4-6 6.01-1.5-1.5zm1.5-4.5 6-6.01 4 4L22 3.92l-1.41-1.41-7.09 7.97-4-4L2 13.99l1.5 1.5z"},child:[]}]})(s)}function rs(s){return Z({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)}function ns(s){return Z({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)}function os(s){return Z({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)}function it(){const[s,n]=f.useState(!1),t=e.useEditorStore(l=>l.card.type),{setCardType:r,setCardPreferences:a,setChartOrientation:c}=e.useEditorStore(l=>l.actions),x=e.useEditorStore(l=>l.actions.setCardCustomCfg);function o(l){x(null),a({}),r(l),n(!1)}return e.jsxRuntimeExports.jsxs(e.Popover,{open:s,onOpenChange:n,children:[e.jsxRuntimeExports.jsx(e.PopoverTrigger,{asChild:!0,children:e.jsxRuntimeExports.jsx(e.Button,{size:"sm",variant:"outline",children:e.jsxRuntimeExports.jsx(at,{className:"h-4 w-4",chartType:t})})}),e.jsxRuntimeExports.jsx(e.PopoverContent,{className:"w-50",children:e.jsxRuntimeExports.jsxs("div",{className:"grid grid-cols-3 place-items-center",children:[e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>o("bar"),className:"font-normal",variant:"ghost",children:e.jsxRuntimeExports.jsx(ze,{className:"size-5"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>o("line"),variant:"ghost",children:e.jsxRuntimeExports.jsx(Te,{className:"size-5"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>o("stackedBar"),variant:"ghost",children:e.jsxRuntimeExports.jsx(rs,{className:"size-5",strokeWidth:0})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>o("stackedLine"),variant:"ghost",children:e.jsxRuntimeExports.jsx(ts,{className:"size-5",strokeWidth:0})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>o("scatter"),variant:"ghost",children:e.jsxRuntimeExports.jsx(Ge,{className:"size-5"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>o("bubble"),variant:"ghost",children:e.jsxRuntimeExports.jsx(ss,{className:"size-4"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>o("pie"),variant:"ghost",children:e.jsxRuntimeExports.jsx(Ke,{className:"size-5"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>o("doughnut"),variant:"ghost",children:e.jsxRuntimeExports.jsx(Ze,{className:"size-5",strokeWidth:1})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>o("radar"),variant:"ghost",children:e.jsxRuntimeExports.jsx(Xe,{className:"size-5 font-extralight",strokeWidth:.5})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>o("polarArea"),variant:"ghost",children:e.jsxRuntimeExports.jsx(es,{className:"size-5"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>o("pyramid"),variant:"ghost",children:e.jsxRuntimeExports.jsx(os,{className:"size-5"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>o("range"),variant:"ghost",children:e.jsxRuntimeExports.jsx(Pe,{className:"size-5"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>o("table"),variant:"ghost",children:e.jsxRuntimeExports.jsx(e.Table,{className:"size-5"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>o("kpi"),variant:"ghost",children:e.jsxRuntimeExports.jsx(ns,{className:"size-6"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>o("text"),variant:"ghost",children:e.jsxRuntimeExports.jsx(Le,{className:"size-4"})})]})})]})}function at({chartType:s,className:n}){switch(s){case"bar":return e.jsxRuntimeExports.jsx(ze,{className:n});case"line":return e.jsxRuntimeExports.jsx(Te,{className:n});case"pie":return e.jsxRuntimeExports.jsx(Ke,{className:n});case"radar":return e.jsxRuntimeExports.jsx(Xe,{className:n});case"scatter":return e.jsxRuntimeExports.jsx(Ge,{className:n});case"bubble":return e.jsxRuntimeExports.jsx(ss,{className:n});case"doughnut":return e.jsxRuntimeExports.jsx(Ze,{className:n});case"stackedBar":return e.jsxRuntimeExports.jsx(rs,{className:"size-4 text-foreground/70"});case"stackedLine":return e.jsxRuntimeExports.jsx(ts,{className:"size-4 text-foreground/70"});case"polarArea":return e.jsxRuntimeExports.jsx(es,{className:n});case"pyramid":return e.jsxRuntimeExports.jsx(os,{className:n});case"range":return e.jsxRuntimeExports.jsx(Pe,{className:n});case"kpi":return e.jsxRuntimeExports.jsx(ns,{className:n});case"text":return e.jsxRuntimeExports.jsx(Le,{className:n});default:return e.jsxRuntimeExports.jsx(e.Table,{className:n})}}function lt(){const s=e.useEditorStore(t=>t.card.refreshInterval),n=e.useEditorStore(t=>t.actions.setCardRefreshInterval);return e.jsxRuntimeExports.jsxs(e.Popover,{children:[e.jsxRuntimeExports.jsx(e.PopoverTrigger,{asChild:!0,children:e.jsxRuntimeExports.jsx(e.Button,{size:"sm",variant:"outline",children:e.jsxRuntimeExports.jsx(ds,{className:"w-4 h-4"})})}),e.jsxRuntimeExports.jsx(e.PopoverContent,{className:"w-[200px]",children:e.jsxRuntimeExports.jsx("div",{className:"grid gap-4",children:e.jsxRuntimeExports.jsx("div",{className:"grid gap-2",children:e.jsxRuntimeExports.jsxs("div",{className:"grid grid-cols-5 items-center gap-1",children:[e.jsxRuntimeExports.jsx(e.Label,{className:"col-span-3",htmlFor:"width",children:"Refresh Every"}),e.jsxRuntimeExports.jsx(e.Input,{value:s||"",onChange:t=>n(t.target.value),id:"width",placeholder:"30s",className:"col-span-2 h-7 focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-0"})]})})})})]})}function Ve(){e.useEditorStore(o=>o.frame);const s=e.useEditorStore(o=>o.card),n=e.useEditorStore(o=>o.card.data),t=e.useEditorStore(o=>o.isShowingVisual),r=e.useEditorStore(o=>o.isSqlRunning),a=e.useEditorStore(o=>o.queryError),c=e.useEditorStore(o=>o.pythonStdOut);if(e.useEditorStore(o=>o.onSave),e.useEditorStore(o=>o.onClose),e.useEditorStore(o=>o.actions.setCardSql),e.useEditorStore(o=>o.actions.setCardType),e.useEditorStore(o=>o.actions.setSqlGen),!s)return e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:"No Active Card"});function x(){return s.type==="kpi"?e.jsxRuntimeExports.jsx("div",{className:"flex grow items-center justify-center",children:e.jsxRuntimeExports.jsx("div",{className:"w-1/2 rounded-md border",children:e.jsxRuntimeExports.jsx(e.KPICard,{isLoading:r,card:s})})}):s.type==="text"?e.jsxRuntimeExports.jsx("div",{className:"flex grow items-center justify-center",children:e.jsxRuntimeExports.jsx("div",{className:"w-1/2 rounded-md border",children:e.jsxRuntimeExports.jsx(e.TextCard,{isLoading:r,card:s})})}):e.jsxRuntimeExports.jsx(Ye,{className:"grow border-none shadow-none"})}return e.jsxRuntimeExports.jsxs("div",{className:"relative flex h-full flex-col pt-3",children:[r&&e.jsxRuntimeExports.jsx(e.LoaderCircle,{className:"absolute bottom-0 left-0 right-0 top-0 z-10 m-auto h-10 w-10 animate-spin text-foreground/10"}),e.jsxRuntimeExports.jsxs("div",{className:"mb-0 flex min-h-10 items-center justify-end gap-2 px-6",children:[t&&e.jsxRuntimeExports.jsxs("div",{className:"flex grow items-center gap-2",children:[e.jsxRuntimeExports.jsx(it,{}),s.type!=="table"&&e.jsxRuntimeExports.jsx(ot,{}),e.jsxRuntimeExports.jsx(lt,{})]}),e.jsxRuntimeExports.jsx(xt,{})]}),t?x():e.jsxRuntimeExports.jsxs("div",{className:"flex min-h-0 w-full flex-1 grow basis-0 px-6",children:[c&&e.jsxRuntimeExports.jsx(ct,{}),s.data&&s.data.length>0&&e.jsxRuntimeExports.jsx(nt,{data:n||[]}),a&&e.jsxRuntimeExports.jsx("span",{className:"font-mono text-sm",children:a})]})]})}function ct(){const s=e.useEditorStore(t=>t.pythonStdOut);if(!s)return null;const n=s.replace(/\n/g,"<br>");return e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx("p",{className:"font-mono text-sm",children:"Output:"}),e.jsxRuntimeExports.jsx("div",{dangerouslySetInnerHTML:{__html:n},className:"bg-muted p-2 font-mono text-sm"}),e.jsxRuntimeExports.jsx(e.Separator,{className:"mb-2"})]})}function xt(){const s=e.useEditorStore(t=>t.isShowingVisual),n=e.useEditorStore(t=>t.actions.setIsShowingVisual);return e.jsxRuntimeExports.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxRuntimeExports.jsx(e.Label,{htmlFor:"visualize",children:"Chart"}),e.jsxRuntimeExports.jsx(e.Switch,{checked:s,onCheckedChange:()=>n(!s),id:"visualize",className:"data-[state=checked]:bg-foreground/50"})]})}function xe(){const[s,n]=f.useState([]);e.useEditorStore(d=>d.card.cfg);const t=e.useEditorStore(d=>d.card.preferences),{setCardCfg:r,setFilterOnClickColumnIndex:a,setCardPreferences:c}=e.useEditorStore(d=>d.actions),x=e.useEditorStore(d=>d.queryResultColumns);e.useEditorStore(d=>{var m;return(m=d.card.preferences)==null?void 0:m.filterOnClickColumnIndex}),f.useEffect(()=>{x&&n(new Array(x.length).fill(!1))},[x]);function o(d,m){var y,u;m?t!=null&&t.onClickFilter&&((y=t==null?void 0:t.onClickFilter)==null?void 0:y.length)>0?c({...t,onClickFilter:[...t.onClickFilter,{columnIndex:d,expression:""}]}):c({...t,onClickFilter:[{columnIndex:d,expression:""}]}):(c({...t,onClickFilter:(u=t==null?void 0:t.onClickFilter)==null?void 0:u.filter(p=>p.columnIndex!==d)}),n(p=>{const j=[...p];return j[d]=!1,j}))}function l(d,m){var u;const y=(u=t==null?void 0:t.onClickFilter)==null?void 0:u.map(p=>p.columnIndex===d?{...p,expression:m.target.value}:p);c({...t,onClickFilter:y})}function h(d){var m,y,u,p;if(s!=null&&s[d]||(y=(m=t==null?void 0:t.onClickFilter)==null?void 0:m.find(j=>j.columnIndex===d))!=null&&y.expression)return e.jsxRuntimeExports.jsx(e.Input,{value:(p=(u=t==null?void 0:t.onClickFilter)==null?void 0:u.find(j=>j.columnIndex===d))==null?void 0:p.expression,onChange:j=>l(d,j),type:"text",className:" h-9 w-full focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0 font-mono text-xs",placeholder:"Expression"})}return e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:x==null?void 0:x.map((d,m)=>{var y,u;return e.jsxRuntimeExports.jsx("div",{className:"flex items-center justify-between space-y-2 xbg-red-100 group",children:e.jsxRuntimeExports.jsxs("div",{className:" grow",children:[e.jsxRuntimeExports.jsxs("div",{className:"flex items-center py-2 space-x-2",children:[e.jsxRuntimeExports.jsx(e.Checkbox,{checked:!!((y=t==null?void 0:t.onClickFilter)!=null&&y.find(p=>p.columnIndex===m)),onCheckedChange:p=>o(m,p)}),e.jsxRuntimeExports.jsx("label",{className:"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",children:d}),e.jsxRuntimeExports.jsx("div",{className:"flex gap-2 items-center ",children:((u=t==null?void 0:t.onClickFilter)==null?void 0:u.find(p=>p.columnIndex===m))&&e.jsxRuntimeExports.jsx($e,{onClick:()=>{n(p=>{const j=[...p];return j[m]=!p[m],j})},className:" invisible group-hover:visible size-3 text-gray-400 cursor-pointer"})})]}),h(m)]})},d)})})}function ve(){var x,o,l;const s=e.useEditorStore(h=>h.card.preferences),n=e.useEditorStore(h=>h.card.cfg),{setCardCfg:t,setCardPreferences:r,setChartOrientation:a}=e.useEditorStore(h=>h.actions);(x=n==null?void 0:n.options)!=null&&x.indexAxis;function c(h){a(h)}return e.jsxRuntimeExports.jsxs(e.RadioGroup,{value:((o=s==null?void 0:s.chartOptions)==null?void 0:o.indexAxis)||((l=n==null?void 0:n.options)==null?void 0:l.indexAxis)||"x",onValueChange:c,className:"flex gap-3",defaultValue:"x",children:[e.jsxRuntimeExports.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxRuntimeExports.jsx(e.RadioGroupItem,{value:"x",id:"r1"}),e.jsxRuntimeExports.jsx("label",{className:"text-sm",htmlFor:"r1",children:"Vertical"})]}),e.jsxRuntimeExports.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxRuntimeExports.jsx(e.RadioGroupItem,{value:"y",id:"r2"}),e.jsxRuntimeExports.jsx("label",{className:"text-sm",htmlFor:"r2",children:"Horizontal"})]})]})}const ce="focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0";function _e(s,n){var r,a,c;const t=e.getNumberAxis(s,n);return((c=(a=(r=s==null?void 0:s.chartOptions)==null?void 0:r.scales)==null?void 0:a[t])==null?void 0:c.type)||"linear"}function is(){var G,B,P,F,$,g;const[s,n]=f.useState(!1),t=e.useEditorStore(E=>{var C;return(C=E.card)==null?void 0:C.preferences}),r=e.useEditorStore(E=>{var C;return(C=E.card)==null?void 0:C.cfg}),a=e.getNumberAxis(t,r),[c,x]=f.useState(_e(t)),[o,l]=f.useState(((P=(B=(G=t==null?void 0:t.chartOptions)==null?void 0:G.scales)==null?void 0:B[a])==null?void 0:P.min)||""),[h,d]=f.useState(((g=($=(F=t==null?void 0:t.chartOptions)==null?void 0:F.scales)==null?void 0:$[a])==null?void 0:g.max)||""),[m,y]=f.useState(o||h?"custom":"auto"),[u,p]=f.useState(""),[j,v]=f.useState(0),[S,A]=f.useState(""),[R,I]=f.useState(""),[b,N]=f.useState(""),w=e.useEditorStore(E=>E.actions.setCardPreferences),T=e.useEditorStore(E=>{var C;return(C=E.card)==null?void 0:C.type}),k=["pie","doughnut","polarArea"].includes(T);f.useEffect(()=>{var E,C,L,D,ee,K,ue,H,re,se,O,Q,U,ne;x(_e(t)),l(((L=(C=(E=t==null?void 0:t.chartOptions)==null?void 0:E.scales)==null?void 0:C[a])==null?void 0:L.min)===0?0:""),d(((K=(ee=(D=t==null?void 0:t.chartOptions)==null?void 0:D.scales)==null?void 0:ee[a])==null?void 0:K.max)||""),p(((se=(re=(H=(ue=t==null?void 0:t.chartOptions)==null?void 0:ue.scales)==null?void 0:H[a])==null?void 0:re.ticks)==null?void 0:se.stepSize)||""),v(((O=t==null?void 0:t.numberAxisFormat)==null?void 0:O.decimalPlaces)||0),A(((Q=t==null?void 0:t.numberAxisFormat)==null?void 0:Q.suffix)||""),I(((U=t==null?void 0:t.numberAxisFormat)==null?void 0:U.currency)||""),N(((ne=t==null?void 0:t.numberAxisFormat)==null?void 0:ne.locale)||"")},[s,t,a]);function M(E,C){return C===""||/^[0-9\b]+$/.test(C)?Number(C):Number(E)}function q(){return e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsxs("div",{className:"grid grid-cols-6 items-center gap-2",children:[e.jsxRuntimeExports.jsx(e.Label,{className:"col-span-2 hover:cursor-pointer hover:underline",htmlFor:"currency",children:e.jsxRuntimeExports.jsx("a",{target:"_blank",href:"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat",children:"Currency"})}),e.jsxRuntimeExports.jsx(e.Input,{value:R,placeholder:"USD",onChange:E=>I(E.target.value),id:"currency",className:`col-span-2 h-8 w-full ${ce}`}),e.jsxRuntimeExports.jsx(e.Input,{value:b,placeholder:"en-US",onChange:E=>N(E.target.value),id:"locale",className:`col-span-2 h-8 w-full ${ce}`})]}),e.jsxRuntimeExports.jsxs("div",{className:"grid grid-cols-9 items-center gap-2",children:[e.jsxRuntimeExports.jsx(e.Label,{className:"col-span-3",htmlFor:"format",children:"Decimals"}),e.jsxRuntimeExports.jsx(e.Input,{value:j,onChange:E=>v(Number(E.target.value)),id:"format",className:`col-span-6 h-8 w-full tracking-wide ${ce}`})]})]})}function z(){return e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsxs("div",{className:"grid grid-cols-3 items-center gap-2",children:[e.jsxRuntimeExports.jsx(e.Label,{htmlFor:"range",children:"Range"}),e.jsxRuntimeExports.jsx(e.Input,{id:"min",value:o,onChange:E=>l(C=>M(C,E.target.value)),className:`col-span-1 h-8 w-full ${ce}`}),e.jsxRuntimeExports.jsx(e.Input,{value:h,onChange:E=>d(C=>M(C,E.target.value)),id:"max",className:`col-span-1 h-8 w-full ${ce}`})]}),e.jsxRuntimeExports.jsxs("div",{className:"grid grid-cols-3 items-center gap-2",children:[e.jsxRuntimeExports.jsx(e.Label,{htmlFor:"step-size",children:"Step Size"}),e.jsxRuntimeExports.jsx(e.Input,{value:u,onChange:E=>p(C=>M(C,E.target.value)),id:"step-size",className:`col-span-1 h-8 w-full ${ce}`})]})]})}function _(){var L;let E={};m==="custom"&&(E={min:o,max:h,ticks:{stepSize:u}});const C={...t||{},chartOptions:{...t==null?void 0:t.chartOptions,scales:{...(L=t==null?void 0:t.chartOptions)==null?void 0:L.scales,[a]:{type:c,...c==="linear"?E:{}}}},numberAxisFormat:{decimalPlaces:j,suffix:S,currency:R,locale:b}};console.log(C),w(C)}return e.jsxRuntimeExports.jsxs(e.Popover,{onOpenChange:E=>n(E),children:[e.jsxRuntimeExports.jsx(e.PopoverTrigger,{asChild:!0,children:e.jsxRuntimeExports.jsx(e.SliderIcon,{className:"size-4 cursor-pointer text-muted-foreground hover:text-foreground"})}),e.jsxRuntimeExports.jsx(e.PopoverContent,{align:"center",className:"max-w-65",children:e.jsxRuntimeExports.jsxs("div",{className:"grid gap-4",children:[e.jsxRuntimeExports.jsxs("div",{className:"space-y-2",children:[e.jsxRuntimeExports.jsx("h4",{className:"font-medium leading-none",children:"Scale Options"}),e.jsxRuntimeExports.jsx("p",{className:"text-sm text-muted-foreground",children:"Set the scale for the number axis"})]}),e.jsxRuntimeExports.jsxs("div",{className:"grid gap-2",children:[e.jsxRuntimeExports.jsxs("div",{className:"grid grid-cols-3 items-center gap-2",children:[e.jsxRuntimeExports.jsx(e.Label,{htmlFor:"scale",children:"Type"}),e.jsxRuntimeExports.jsxs(e.Select,{disabled:k,value:c,onValueChange:E=>x(E),children:[e.jsxRuntimeExports.jsx(e.SelectTrigger,{className:"col-span-2 h-8 w-full focus:ring-1 focus:ring-offset-0",children:e.jsxRuntimeExports.jsx(e.SelectValue,{})}),e.jsxRuntimeExports.jsx(e.SelectContent,{id:"type",children:e.jsxRuntimeExports.jsxs(e.SelectGroup,{children:[e.jsxRuntimeExports.jsx(e.SelectLabel,{children:"Option"}),e.jsxRuntimeExports.jsx(e.SelectItem,{value:"linear",children:"Linear"}),e.jsxRuntimeExports.jsx(e.SelectItem,{value:"logarithmic",children:"Logarithmic"})]})})]})]}),c=="linear"&&e.jsxRuntimeExports.jsxs("div",{className:"grid grid-cols-3 items-center gap-2 py-1",children:[e.jsxRuntimeExports.jsx(e.Label,{htmlFor:"scale-option",children:"Setup"}),e.jsxRuntimeExports.jsxs(e.RadioGroup,{disabled:k,id:"scale-option",value:m,onValueChange:E=>y(E),className:"col-span-2 flex gap-3",defaultValue:"x",children:[e.jsxRuntimeExports.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxRuntimeExports.jsx(e.RadioGroupItem,{value:"auto",id:"r1"}),e.jsxRuntimeExports.jsx("label",{className:"text-sm",htmlFor:"r1",children:"Auto"})]}),e.jsxRuntimeExports.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxRuntimeExports.jsx(e.RadioGroupItem,{value:"custom",id:"r2"}),e.jsxRuntimeExports.jsx("label",{className:"text-sm",htmlFor:"r2",children:"Custom"})]})]})]}),m==="custom"&&c=="linear"&&z(),q(),e.jsxRuntimeExports.jsx(e.SelectSeparator,{}),e.jsxRuntimeExports.jsx("div",{className:"grid grid-cols-3",children:e.jsxRuntimeExports.jsx(e.Button,{onClick:_,variant:"secondary",className:"col-span-1 col-start-3 h-8 w-full",children:"Apply"})})]})]})})]})}function ut({idx:s}){var o;const n=e.useEditorStore(l=>{var h;return(h=l.card)==null?void 0:h.preferences}),t=e.useEditorStore(l=>{var h;return(h=l.card.preferences)==null?void 0:h.datasetOptions}),r=e.useEditorStore(l=>l.actions.setCardPreferences),a=(o=n==null?void 0:n.chartOptions)==null?void 0:o.indexAxis,c=t==null?void 0:t.find(l=>l.idx===s);function x(l,h){(l==="end"||l==="start")&&e.getContrastColor(e.getCanvasBackgroundColor());const d={display:l!=="none",align:l,anchor:l,clamp:!0};if(!c)r({...n,datasetOptions:[...t||[],{idx:h,datalabels:d}]});else{const m={...c};m.datalabels=d;const y=t==null?void 0:t.map(u=>u.idx===h?m:u);r({...n,datasetOptions:y})}}return e.jsxRuntimeExports.jsxs(e.Popover,{children:[e.jsxRuntimeExports.jsx(e.PopoverTrigger,{children:e.jsxRuntimeExports.jsx(Ls,{className:"invisible size-4 rotate-[135deg] cursor-pointer text-muted-foreground hover:text-foreground group-hover:visible"})}),e.jsxRuntimeExports.jsx(e.PopoverContent,{className:"w-fit p-1",children:e.jsxRuntimeExports.jsxs("div",{className:"flex gap-1",children:[e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>x("none",s),size:"sm",variant:"secondary",className:"h-7 p-1 text-xs font-normal",children:e.jsxRuntimeExports.jsx(e.X,{className:"size-4"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>x("start",s),size:"sm",variant:"secondary",className:"h-7 p-1 text-xs font-normal",children:e.jsxRuntimeExports.jsx(Ss,{className:e.cn("h-4 w-4",{"rotate-90":a==="y"})})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>x("center",s),size:"sm",variant:"secondary",className:"h-7 p-1 text-xs font-normal",children:e.jsxRuntimeExports.jsx(vs,{className:e.cn("h-4 w-4",{"rotate-90":a==="y"})})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>x("end",s),size:"sm",variant:"secondary",className:"h-7 p-1 text-xs font-normal",children:e.jsxRuntimeExports.jsx(ys,{className:e.cn("h-4 w-4",{"rotate-90":a==="y"})})})]})})]})}function as(){const s=e.useEditorStore(l=>l.card),n=e.useEditorStore(l=>{var h,d,m;return(m=(d=(h=l==null?void 0:l.card)==null?void 0:h.preferences)==null?void 0:d.chartOptions)==null?void 0:m.indexAxis}),t=n==="y"?"Y axis":"X axis",r=n==="y"?"X axis":"Y axis",{keys:a,metricKeys:c,dimensionKeys:x}=e.getKeys(s.data||[]);let o=c;if(["stackedBar","stackedLine"].includes(s.type)){const l=e.pivotData({dataArray:s.data||[],groupKey:x[0],pivotKey:x[1],valueKey:o[0]}),{metricKeys:h}=e.getKeys(l);o=h}return a.length===0?null:e.jsxRuntimeExports.jsxs("div",{className:"space-y-4",children:[e.jsxRuntimeExports.jsxs("div",{className:"space-y-2",children:[e.jsxRuntimeExports.jsx(e.Label,{children:t}),e.jsxRuntimeExports.jsx("div",{className:"my-1 space-y-1",children:e.jsxRuntimeExports.jsx("div",{className:"rounded-md bg-muted/70 px-2 py-1 hover:bg-muted",children:e.jsxRuntimeExports.jsx("p",{children:x[0]})})})]}),e.jsxRuntimeExports.jsxs("div",{className:"space-y-2",children:[e.jsxRuntimeExports.jsxs("div",{className:"flex items-center justify-between gap-5",children:[e.jsxRuntimeExports.jsx(e.Label,{children:r}),e.jsxRuntimeExports.jsx(is,{})]}),e.jsxRuntimeExports.jsx("div",{className:"my-1 space-y-1",children:o.map((l,h)=>e.jsxRuntimeExports.jsx(dt,{col:l,idx:h},l))})]})]})}function dt({col:s,idx:n}){const t=e.useEditorStore(o=>{var l;return(l=o.card)==null?void 0:l.preferences}),r=e.useEditorStore(o=>{var l;return(l=o.card.preferences)==null?void 0:l.datasetOptions}),a=r==null?void 0:r.find(o=>o.idx===n),{setCardPreferences:c}=e.useEditorStore(o=>o.actions);function x(o){if(!a)c({...t,datasetOptions:[...r||[],{idx:n,type:o==="area"?"line":o,fill:o==="area"?"origin":""}]});else{const l={...a};l.type=o==="area"?"line":o,l.fill=o==="area"?"origin":"";const h=r==null?void 0:r.map(d=>d.idx===n?l:d);c({...t,datasetOptions:h})}}return e.jsxRuntimeExports.jsxs("div",{className:"group flex items-center justify-between gap-5 rounded-md bg-muted/70 px-2 py-1 hover:bg-muted",children:[e.jsxRuntimeExports.jsx("p",{children:s}),e.jsxRuntimeExports.jsxs("div",{className:"flex gap-2",children:[e.jsxRuntimeExports.jsx(ze,{onClick:()=>x("bar"),className:"invisible size-4 cursor-pointer text-muted-foreground hover:text-foreground group-hover:visible"}),e.jsxRuntimeExports.jsx(Te,{onClick:()=>x("line"),className:"invisible size-4 cursor-pointer text-muted-foreground hover:text-foreground group-hover:visible"}),e.jsxRuntimeExports.jsx(ms,{onClick:()=>x("area"),className:"invisible size-4 cursor-pointer text-muted-foreground hover:text-foreground group-hover:visible"}),e.jsxRuntimeExports.jsx(e.Separator,{orientation:"vertical",className:"invisible size-4 cursor-pointer py-2 text-muted-foreground hover:text-foreground group-hover:visible"}),e.jsxRuntimeExports.jsx(ut,{idx:n})]})]})}function mt({cardType:s}){return e.jsxRuntimeExports.jsx("div",{className:"space-y-6 px-6 py-2",children:e.jsxRuntimeExports.jsxs(e.Accordion,{defaultValue:["item-2"],type:"multiple",children:[e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-1",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{children:`${e.titleCase(s)} Chart`}),e.jsxRuntimeExports.jsxs(e.AccordionContent,{className:"space-y-4 font-mono text-xs",children:[e.jsxRuntimeExports.jsx("div",{className:"rounded bg-muted px-2 py-1 text-xs",children:"SELECT x-axis, y-axis-1, y-axis-2,... FROM table"}),e.jsxRuntimeExports.jsxs("ul",{className:"ml-6 list-disc text-xs [&>li]:mt-2",children:[e.jsxRuntimeExports.jsx("li",{children:"x-axis - category"}),e.jsxRuntimeExports.jsx("li",{children:"y-axis1 - number"}),e.jsxRuntimeExports.jsx("li",{children:"y-axis2 - number"})]}),e.jsxRuntimeExports.jsxs("div",{children:["See ",e.jsxRuntimeExports.jsx("a",{target:"_blank",onClick:n=>n.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/concepts/visuals#line-chart",children:"example"})," in the docs."]})]})]}),e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-2",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{children:"Settings"}),e.jsxRuntimeExports.jsxs(e.AccordionContent,{className:"space-y-4 px-2",children:[e.jsxRuntimeExports.jsx(ve,{}),e.jsxRuntimeExports.jsx(as,{})]})]}),e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-3",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{children:"Filter on click"}),e.jsxRuntimeExports.jsx(e.AccordionContent,{className:"px-2",children:e.jsxRuntimeExports.jsx(xe,{})})]})]})})}function Fe(){var a,c,x;const s=e.useEditorStore(o=>o.card.cfg),n=e.useEditorStore(o=>o.actions.setCardCfg),t=e.useEditorStore(o=>o.card.type);function r(o){var d;const l={datalabels:{display:o!=="none",align:o,anchor:o,clamp:!0}},h={...s,options:{...s==null?void 0:s.options,plugins:{...(d=s==null?void 0:s.options)==null?void 0:d.plugins,...l}}};n(h),console.log(o)}return e.jsxRuntimeExports.jsxs("div",{className:"space-y-2",children:[e.jsxRuntimeExports.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxRuntimeExports.jsx("label",{className:"font-medium",children:"Data Labels"}),!["pyramid"].includes(t)&&e.jsxRuntimeExports.jsx(is,{})]}),e.jsxRuntimeExports.jsxs(e.Select,{value:(x=(c=(a=s==null?void 0:s.options)==null?void 0:a.plugins)==null?void 0:c.datalabels)==null?void 0:x.anchor,onValueChange:r,defaultValue:"none",children:[e.jsxRuntimeExports.jsx(e.SelectTrigger,{className:"h-8 w-full focus:ring-1 focus:ring-offset-0",children:e.jsxRuntimeExports.jsx(e.SelectValue,{placeholder:"Select position"})}),e.jsxRuntimeExports.jsx(e.SelectContent,{children:e.jsxRuntimeExports.jsxs(e.SelectGroup,{children:[e.jsxRuntimeExports.jsx(e.SelectLabel,{children:"Data Labels"}),e.jsxRuntimeExports.jsx(e.SelectItem,{value:"none",children:"None"}),t!=="pyramid"&&e.jsxRuntimeExports.jsx(e.SelectItem,{value:"start",children:"Start"}),e.jsxRuntimeExports.jsx(e.SelectItem,{value:"center",children:"Center"}),t!=="pyramid"&&e.jsxRuntimeExports.jsx(e.SelectItem,{value:"end",children:"End"})]})})]})]})}function pt({cardType:s}){function n(t){const r="SELECT label, [group], x-axis, y-axis, radius FROM table",a="SELECT label, [group], x-axis, y-axis FROM table";return e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx("div",{className:"bg-muted px-2 py-1 rounded text-xs",children:t==="bubble"?r:a}),e.jsxRuntimeExports.jsxs("ul",{className:" ml-6 list-disc [&>li]:mt-2 text-xs",children:[e.jsxRuntimeExports.jsx("li",{children:"label - category"}),e.jsxRuntimeExports.jsx("li",{children:"group - category"}),e.jsxRuntimeExports.jsx("li",{children:"x-axis - category"}),e.jsxRuntimeExports.jsx("li",{children:"y-axis - category"}),t==="bubble"&&e.jsxRuntimeExports.jsx("li",{children:"radius - number"})]}),e.jsxRuntimeExports.jsxs("div",{children:["See ",e.jsxRuntimeExports.jsx("a",{target:"_blank",onClick:c=>c.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/concepts/visuals#pie-chart",children:"example"})," in the docs."]})]})}return e.jsxRuntimeExports.jsx("div",{className:"px-6 py-2 space-y-6",children:e.jsxRuntimeExports.jsxs(e.Accordion,{defaultValue:["item-2"],type:"multiple",children:[e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-1",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{children:`${e.titleCase(s)} Chart`}),e.jsxRuntimeExports.jsx(e.AccordionContent,{className:" space-y-4 font-mono text-xs ",children:n(s)})]}),e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-2",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{children:"Settings"}),e.jsxRuntimeExports.jsx(e.AccordionContent,{className:"px-2",children:e.jsxRuntimeExports.jsx(Fe,{})})]}),e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-3",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{children:"Filter on click"}),e.jsxRuntimeExports.jsx(e.AccordionContent,{className:"px-2",children:e.jsxRuntimeExports.jsx(xe,{})})]})]})})}const ht={datasets:[{type:"line",label:"Sum_sales",data:[]},{type:"bar",label:"Sum_profit",data:[]}]},jt={datasets:[{fill:"origin",type:"line",label:"Sum_sales",data:[]}]};function Et(){const s=e.useEditorStore(n=>n.card.type);return e.jsxRuntimeExports.jsxs("div",{className:"space-y-6 p-6",children:[e.jsxRuntimeExports.jsx(e.Accordion,{className:" ",type:"single",collapsible:!0,children:ft(s)}),e.jsxRuntimeExports.jsx("section",{className:"",children:["line","bar"].includes(s)&&e.jsxRuntimeExports.jsx(ve,{})}),e.jsxRuntimeExports.jsx("div",{children:!["kpi"].includes(s)&&e.jsxRuntimeExports.jsx(Fe,{})}),e.jsxRuntimeExports.jsx("div",{children:!["kpi"].includes(s)&&e.jsxRuntimeExports.jsx(xe,{})})]})}function ft(s){if(["line","bar"].includes(s))return e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-1",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{className:"font-normal",children:e.jsxRuntimeExports.jsx("p",{children:"Chart Query"})}),e.jsxRuntimeExports.jsxs(e.AccordionContent,{className:" ",children:[e.jsxRuntimeExports.jsx("div",{className:"rounded bg-muted px-2 py-1 font-mono text-xs font-semibold",children:"SELECT x-axis, y-axis-1, y-axis-2, y-axis-3,... FROM table"}),e.jsxRuntimeExports.jsxs("ul",{className:"my-6 ml-6 list-disc text-xs font-normal [&>li]:mt-2",children:[e.jsxRuntimeExports.jsx("li",{children:"X-axis - Category (ex. city)"}),e.jsxRuntimeExports.jsx("li",{children:"Y-axis - Number (ex. population)"})]})]})]}),e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-2",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{className:"font-normal",children:"Mixed Chart"}),e.jsxRuntimeExports.jsxs(e.AccordionContent,{className:"space-y-2 text-xs",children:[e.jsxRuntimeExports.jsxs("p",{children:["Click ",e.jsxRuntimeExports.jsx("b",{children:"Customize"})," and change the `type` property in the dataset."]}),e.jsxRuntimeExports.jsx("pre",{children:JSON.stringify(ht,null,2)})]})]}),e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-3",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{className:"font-normal",children:"Area Chart"}),e.jsxRuntimeExports.jsxs(e.AccordionContent,{className:"space-y-2 text-xs",children:[e.jsxRuntimeExports.jsxs("p",{children:["Click ",e.jsxRuntimeExports.jsx("b",{children:"Customize"})," and add `fill` property to the dataset. See",e.jsxRuntimeExports.jsx("a",{className:"mx-1 text-blue-500 hover:underline",href:"https://www.chartjs.org/docs/latest/samples/area/line-boundaries.html",target:"_blank",children:"docs"}),"for more options."]}),e.jsxRuntimeExports.jsx("pre",{children:JSON.stringify(jt,null,2)})]})]})]});if(s==="bubble")return e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-1",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{className:"font-normal",children:e.jsxRuntimeExports.jsxs("p",{children:["How to create a ",e.jsxRuntimeExports.jsx("span",{children:s})," chart query?"]})}),e.jsxRuntimeExports.jsxs(e.AccordionContent,{className:" ",children:[e.jsxRuntimeExports.jsx("div",{className:"rounded bg-muted px-2 py-1 font-mono text-xs font-semibold",children:"SELECT label, x-axis, y-axis, radius FROM table"}),e.jsxRuntimeExports.jsxs("ul",{className:"my-6 ml-6 list-disc text-xs font-normal [&>li]:mt-2",children:[e.jsxRuntimeExports.jsx("li",{children:"Label - Category (ex. city)"}),e.jsxRuntimeExports.jsx("li",{children:"Bubble Group (opt) - Category (ex. state)"}),e.jsxRuntimeExports.jsx("li",{children:"X-axis - Number (ex. avg. age)"}),e.jsxRuntimeExports.jsx("li",{children:"Y-axis - Number (ex. avg. weight)"}),e.jsxRuntimeExports.jsx("li",{children:"Radius - Number (ex. population)"})]})]})]})});if(s==="scatter")return e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-1",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{className:"font-normal",children:e.jsxRuntimeExports.jsxs("p",{children:["How to create a ",e.jsxRuntimeExports.jsx("span",{children:s})," chart query?"]})}),e.jsxRuntimeExports.jsxs(e.AccordionContent,{className:" ",children:[e.jsxRuntimeExports.jsx("div",{className:"rounded bg-muted px-2 py-1 font-mono text-xs font-semibold",children:"SELECT label, x-axis, y-axis FROM table"}),e.jsxRuntimeExports.jsxs("ul",{className:"my-6 ml-6 list-disc text-xs font-normal [&>li]:mt-2",children:[e.jsxRuntimeExports.jsx("li",{children:"Label - Category (ex. city)"}),e.jsxRuntimeExports.jsx("li",{children:"Group (opt) - Category (ex. state)"}),e.jsxRuntimeExports.jsx("li",{children:"X-axis - Number (ex. avg. age)"}),e.jsxRuntimeExports.jsx("li",{children:"Y-axis - Number (ex. avg. weight)"})]})]})]})});if(["pie","doughnut","polarArea"].includes(s))return e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-1",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{className:"font-normal",children:e.jsxRuntimeExports.jsxs("p",{children:[e.jsxRuntimeExports.jsx("span",{children:s==="polarArea"?"Polar":s.charAt(0).toUpperCase()+s.slice(1)})," ","chart query"]})}),e.jsxRuntimeExports.jsxs(e.AccordionContent,{className:" ",children:[e.jsxRuntimeExports.jsx("div",{className:"rounded bg-muted px-2 py-1 font-mono text-xs font-semibold",children:"SELECT label, measure FROM table"}),e.jsxRuntimeExports.jsxs("ul",{className:"my-6 ml-6 list-disc text-xs font-normal [&>li]:mt-2",children:[e.jsxRuntimeExports.jsx("li",{children:"Label - Category (ex. city)"}),e.jsxRuntimeExports.jsx("li",{children:"Measure - Number (ex. population)"})]})]})]})})}function gt(){var l,h,d,m,y;const s=e.useEditorStore(u=>u.card.preferences),n=e.useEditorStore(u=>u.actions.setCardPreferences),t=e.useEditorStore(u=>u.actions.setNumberFormat);e.useEditorStore(u=>{var p,j;return(j=(p=u.card.preferences)==null?void 0:p.formatNumber)==null?void 0:j.decimalPlaces});const r=e.useEditorStore(u=>{var p,j;return(j=(p=u.card.preferences)==null?void 0:p.formatNumber)==null?void 0:j.locale}),a=e.useEditorStore(u=>{var p,j;return(j=(p=u.card.preferences)==null?void 0:p.formatNumber)==null?void 0:j.currency});e.useEditorStore(u=>u.actions.setFilterOnClickField);const c=e.useEditorStore(u=>{var p,j;return(j=(p=u.card.preferences)==null?void 0:p.formatNumber)==null?void 0:j.colorRanges})||[],x=e.useEditorStore(u=>u.actions.setColorRanges),o=[...new Set(e.LOCALE_CURRENCY_PAIRS.map(u=>u.currency))];return e.jsxRuntimeExports.jsxs("div",{children:[e.jsxRuntimeExports.jsxs("div",{className:"mb-3 flex items-center gap-2",children:[e.jsxRuntimeExports.jsx(e.Checkbox,{checked:!!((l=s==null?void 0:s.formatNumber)!=null&&l.enabled),onCheckedChange:u=>{n({...s,formatNumber:{...s==null?void 0:s.formatNumber,enabled:u}})}}),e.jsxRuntimeExports.jsx(e.Label,{children:"Format Number"})]}),((h=s==null?void 0:s.formatNumber)==null?void 0:h.enabled)===!0&&e.jsxRuntimeExports.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsxRuntimeExports.jsx("div",{children:e.jsxRuntimeExports.jsxs("div",{className:"space-y-4 p-2",children:[e.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxRuntimeExports.jsxs("div",{className:"w-full space-y-1",children:[e.jsxRuntimeExports.jsx(e.Label,{children:"Locale"}),e.jsxRuntimeExports.jsxs(e.Select,{value:r||"en-US",onValueChange:u=>{var p,j,v;return t(((p=s==null?void 0:s.formatNumber)==null?void 0:p.decimalPlaces)||0,((j=s==null?void 0:s.formatNumber)==null?void 0:j.currency)||"",u||"en-US",((v=s==null?void 0:s.formatNumber)==null?void 0:v.suffix)||"")},children:[e.jsxRuntimeExports.jsx(e.SelectTrigger,{className:"col-span-6 h-8 w-full focus:ring-1 focus:ring-offset-0",children:e.jsxRuntimeExports.jsx(e.SelectValue,{})}),e.jsxRuntimeExports.jsx(e.SelectContent,{children:e.jsxRuntimeExports.jsxs(e.SelectGroup,{children:[e.jsxRuntimeExports.jsx(e.SelectLabel,{children:"Format"}),e.LOCALE_CURRENCY_PAIRS.map(u=>e.jsxRuntimeExports.jsx(e.SelectItem,{value:u.locale,children:u.locale},u.locale))]})})]})]}),e.jsxRuntimeExports.jsxs("div",{className:"w-full space-y-1",children:[e.jsxRuntimeExports.jsx(e.Label,{children:"Currency"}),e.jsxRuntimeExports.jsxs(e.Select,{value:a||"none",onValueChange:u=>{var p,j,v;return t(((p=s==null?void 0:s.formatNumber)==null?void 0:p.decimalPlaces)||0,u==="none"?"":u,((j=s==null?void 0:s.formatNumber)==null?void 0:j.locale)||"",((v=s==null?void 0:s.formatNumber)==null?void 0:v.suffix)||"")},children:[e.jsxRuntimeExports.jsx(e.SelectTrigger,{className:"col-span-6 h-8 w-full focus:ring-1 focus:ring-offset-0",children:e.jsxRuntimeExports.jsx(e.SelectValue,{})}),e.jsxRuntimeExports.jsx(e.SelectContent,{children:e.jsxRuntimeExports.jsxs(e.SelectGroup,{children:[e.jsxRuntimeExports.jsx(e.SelectLabel,{children:"Currency"}),e.jsxRuntimeExports.jsx(e.SelectItem,{value:"none",children:"None"},"none"),o.map(u=>e.jsxRuntimeExports.jsx(e.SelectItem,{value:u,children:u},u))]})})]})]})]}),e.jsxRuntimeExports.jsxs("div",{className:"flex gap-2",children:[e.jsxRuntimeExports.jsxs("div",{className:"w-full space-y-1",children:[e.jsxRuntimeExports.jsx(e.Label,{children:"Decimals"}),e.jsxRuntimeExports.jsxs(e.Select,{value:((m=(d=s==null?void 0:s.formatNumber)==null?void 0:d.decimalPlaces)==null?void 0:m.toString())||"0",onValueChange:u=>{var p,j,v;return t(Number(u),((p=s==null?void 0:s.formatNumber)==null?void 0:p.currency)||"",((j=s==null?void 0:s.formatNumber)==null?void 0:j.locale)||"",((v=s==null?void 0:s.formatNumber)==null?void 0:v.suffix)||"")},children:[e.jsxRuntimeExports.jsx(e.SelectTrigger,{className:"col-span-3 h-8 w-full focus:ring-1 focus:ring-offset-0",children:e.jsxRuntimeExports.jsx(e.SelectValue,{})}),e.jsxRuntimeExports.jsx(e.SelectContent,{children:["0","1","2","3","4"].map(u=>e.jsxRuntimeExports.jsx(e.SelectItem,{value:u,children:u},u))})]})]}),e.jsxRuntimeExports.jsxs("div",{className:"w-full space-y-1",children:[e.jsxRuntimeExports.jsx(e.Label,{children:"Suffix"}),e.jsxRuntimeExports.jsx(e.Input,{value:((y=s==null?void 0:s.formatNumber)==null?void 0:y.suffix)||"",className:"h-8 font-mono text-xs focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0",placeholder:"K, M, B, %",onChange:u=>{var p,j,v;return t(((p=s==null?void 0:s.formatNumber)==null?void 0:p.decimalPlaces)||0,((j=s==null?void 0:s.formatNumber)==null?void 0:j.currency)||"",((v=s==null?void 0:s.formatNumber)==null?void 0:v.locale)||"",u.target.value)}})]})]})]})}),e.jsxRuntimeExports.jsx(e.Separator,{className:"my-3"}),e.jsxRuntimeExports.jsx(e.ColorFormat,{colorRanges:c,setColorRanges:x})]})]})}function Rt(){return e.jsxRuntimeExports.jsxs("div",{className:"space-y-6 px-6 py-2",children:[e.jsxRuntimeExports.jsx(e.Accordion,{type:"single",collapsible:!0,children:e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-1",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{className:"",children:"KPI Query"}),e.jsxRuntimeExports.jsxs(e.AccordionContent,{className:"font-mono",children:[e.jsxRuntimeExports.jsx("div",{className:"rounded bg-muted px-2 py-1 font-mono text-xs",children:"SELECT current, previous FROM table"}),e.jsxRuntimeExports.jsxs("ul",{className:"my-6 ml-6 list-disc text-xs [&>li]:mt-2",children:[e.jsxRuntimeExports.jsx("li",{children:"current - number"}),e.jsxRuntimeExports.jsx("li",{children:"previous - number"})]}),e.jsxRuntimeExports.jsxs("div",{children:["See ",e.jsxRuntimeExports.jsx("a",{target:"_blank",onClick:s=>s.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/concepts/visuals#kpi",children:"example"})," in the docs."]})]})]})}),e.jsxRuntimeExports.jsx("section",{className:"",children:e.jsxRuntimeExports.jsx(gt,{})}),e.jsxRuntimeExports.jsx("div",{}),e.jsxRuntimeExports.jsx("div",{})]})}function bt(){var r;const s=e.useEditorStore(a=>a.card.preferences),{setCardPreferences:n}=e.useEditorStore(a=>a.actions);function t(a){n({...s,textVisualOptions:{...s==null?void 0:s.textVisualOptions,isDynamicText:a==="dynamic"}})}return e.jsxRuntimeExports.jsxs(e.RadioGroup,{value:(r=s==null?void 0:s.textVisualOptions)!=null&&r.isDynamicText?"dynamic":"static",onValueChange:t,className:"flex gap-3",defaultValue:"x",children:[e.jsxRuntimeExports.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxRuntimeExports.jsx(e.RadioGroupItem,{value:"static",id:"r1"}),e.jsxRuntimeExports.jsx("label",{className:"text-sm",htmlFor:"r1",children:"Static"})]}),e.jsxRuntimeExports.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxRuntimeExports.jsx(e.RadioGroupItem,{value:"dynamic",id:"r2"}),e.jsxRuntimeExports.jsx("label",{className:"text-sm",htmlFor:"r2",children:"Dynamic"})]})]})}function be({cardType:s,docContent:n,suffix:t="Chart"}){return e.jsxRuntimeExports.jsx("div",{className:"space-y-6 px-6 py-2",children:e.jsxRuntimeExports.jsxs(e.Accordion,{defaultValue:["item-2"],type:"multiple",children:[e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-1",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{children:`${e.titleCase(s)} ${t}`}),e.jsxRuntimeExports.jsx(e.AccordionContent,{children:n||e.jsxRuntimeExports.jsxs("div",{className:"space-y-4 font-mono text-xs",children:[e.jsxRuntimeExports.jsx("div",{className:"rounded bg-muted px-2 py-1 text-xs",children:"SELECT label, measure FROM table"}),e.jsxRuntimeExports.jsxs("ul",{className:"ml-6 list-disc text-xs [&>li]:mt-2",children:[e.jsxRuntimeExports.jsx("li",{children:"label - category"}),e.jsxRuntimeExports.jsx("li",{children:"measure - number"})]}),e.jsxRuntimeExports.jsxs("div",{children:["See ",e.jsxRuntimeExports.jsx("a",{target:"_blank",onClick:r=>r.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/concepts/visuals#pie-chart",children:"example"})," in the docs."]})]})})]}),e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-2",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{children:"Settings"}),e.jsxRuntimeExports.jsxs(e.AccordionContent,{className:"space-y-4 px-2",children:[s==="range"&&e.jsxRuntimeExports.jsx(ve,{}),s!=="text"&&e.jsxRuntimeExports.jsx(Fe,{}),s==="text"&&e.jsxRuntimeExports.jsx(bt,{})]})]}),!["range","text"].includes(s)&&e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-3",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{children:"Filter on click"}),e.jsxRuntimeExports.jsx(e.AccordionContent,{className:"px-2",children:e.jsxRuntimeExports.jsx(xe,{})})]})]})})}function St(){return e.jsxRuntimeExports.jsx("div",{className:"space-y-6 px-6 py-2",children:e.jsxRuntimeExports.jsxs(e.Accordion,{defaultValue:["item-2"],type:"multiple",children:[e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-1",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{children:"Stacked Chart"}),e.jsxRuntimeExports.jsxs(e.AccordionContent,{className:"space-y-4 font-mono text-xs",children:[e.jsxRuntimeExports.jsx("div",{className:"rounded bg-muted px-2 py-1 text-xs",children:"SELECT x-axis, stack-by, y-axis FROM table"}),e.jsxRuntimeExports.jsxs("ul",{className:"ml-6 list-disc text-xs [&>li]:mt-2",children:[e.jsxRuntimeExports.jsx("li",{children:"x-axis - category"}),e.jsxRuntimeExports.jsx("li",{children:"stack by - category"}),e.jsxRuntimeExports.jsx("li",{children:"y-axis - number"})]}),e.jsxRuntimeExports.jsxs("div",{children:["See ",e.jsxRuntimeExports.jsx("a",{target:"_blank",onClick:s=>s.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/concepts/visuals#stacked-chart",children:"example"})," in the docs."]})]})]}),e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-2",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{children:"Settings"}),e.jsxRuntimeExports.jsxs(e.AccordionContent,{className:"space-y-4 px-2",children:[e.jsxRuntimeExports.jsx(ve,{}),e.jsxRuntimeExports.jsx(as,{})]})]}),e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-3",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{children:"Filter on click"}),e.jsxRuntimeExports.jsx(e.AccordionContent,{className:"px-2",children:e.jsxRuntimeExports.jsx(xe,{})})]})]})})}function yt({}){const s=e.useEditorStore(r=>{var a;return(a=r.card)==null?void 0:a.preferences}),n=e.useEditorStore(r=>r.actions.setCardPreferences),t=r=>{n({...s,allowDownload:r})};return e.jsxRuntimeExports.jsxs("div",{className:"space-y-6 px-6 py-2",children:[e.jsxRuntimeExports.jsx(e.Accordion,{defaultValue:["item-3"],type:"multiple",children:e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-3",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{children:"Filter on click"}),e.jsxRuntimeExports.jsx(e.AccordionContent,{className:"px-2",children:e.jsxRuntimeExports.jsx(xe,{})})]})}),e.jsxRuntimeExports.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxRuntimeExports.jsx(e.Checkbox,{onCheckedChange:t,id:"allow-download"}),e.jsxRuntimeExports.jsx("label",{htmlFor:"allow-download",className:"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",children:"Allow Download"})]})]})}const vt=e.jsxRuntimeExports.jsxs("div",{className:"space-y-4 font-mono text-xs",children:[e.jsxRuntimeExports.jsx("div",{className:"rounded bg-muted px-2 py-1 text-xs",children:"SELECT dimension, cohort, metric FROM table"}),e.jsxRuntimeExports.jsxs("div",{children:["See ",e.jsxRuntimeExports.jsx("a",{target:"_blank",onClick:s=>s.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/concepts/visuals#pyramid-chart",children:"example"})," in the docs."]})]}),Ct=e.jsxRuntimeExports.jsxs("div",{className:"space-y-4 font-mono text-xs",children:[e.jsxRuntimeExports.jsx("div",{className:"rounded bg-muted px-2 py-1 text-xs",children:"SELECT y-axis, label, range-from, range-to, range-value FROM table"}),e.jsxRuntimeExports.jsxs("div",{children:["See ",e.jsxRuntimeExports.jsx("a",{target:"_blank",onClick:s=>s.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/concepts/visuals#range-charts",children:"example"})," in the docs."]})]}),Nt=e.jsxRuntimeExports.jsxs("div",{className:"space-y-4 font-mono text-xs",children:[e.jsxRuntimeExports.jsx("div",{className:"rounded bg-muted px-2 py-1 text-xs",children:"SELECT text FROM table limit 1"}),e.jsxRuntimeExports.jsxs("div",{children:["See ",e.jsxRuntimeExports.jsx("a",{target:"_blank",onClick:s=>s.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/concepts/visuals#text-visual",children:"example"})," in the docs."]})]});function kt(){const s=e.useEditorStore(t=>t.card.type);function n(t){switch(t){case"stackedBar":case"stackedLine":return e.jsxRuntimeExports.jsx(St,{});case"pyramid":return e.jsxRuntimeExports.jsx(be,{docContent:vt,cardType:t});case"kpi":return e.jsxRuntimeExports.jsx(Rt,{});case"line":case"bar":return e.jsxRuntimeExports.jsx(mt,{cardType:t});case"range":return e.jsxRuntimeExports.jsx(be,{docContent:Ct,cardType:t});case"pie":case"doughnut":case"polarArea":case"radar":return e.jsxRuntimeExports.jsx(be,{cardType:t});case"bubble":case"scatter":return e.jsxRuntimeExports.jsx(pt,{cardType:t});case"table":return e.jsxRuntimeExports.jsx(yt,{cardType:t});case"text":return e.jsxRuntimeExports.jsx(be,{docContent:Nt,cardType:t,suffix:"Visual"});default:return e.jsxRuntimeExports.jsx(Et,{})}}return e.jsxRuntimeExports.jsx(e.ScrollArea,{className:"h-full w-full text-sm",children:n(s)})}function wt(){const s=e.useEditorStore(n=>n.isShowingVisual);return e.jsxRuntimeExports.jsxs(e.ResizablePanelGroup,{direction:"vertical",className:"min-h-[250px] min-w-full max-w-lg",children:[e.jsxRuntimeExports.jsx(e.ResizablePanel,{role:"query-section",className:"flex",minSize:20,defaultSize:40,children:e.jsxRuntimeExports.jsx(rt,{})}),e.jsxRuntimeExports.jsx(e.ResizableHandle,{withHandle:!0,className:"border"}),e.jsxRuntimeExports.jsx(e.ResizablePanel,{className:"pb-1",role:"visual-section",minSize:0,defaultSize:60,children:s?e.jsxRuntimeExports.jsxs(e.ResizablePanelGroup,{direction:"horizontal",children:[e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:e.jsxRuntimeExports.jsx(e.ResizablePanel,{className:"flex min-w-[275px]",minSize:20,defaultSize:25,maxSize:30,children:e.jsxRuntimeExports.jsx(kt,{})})}),e.jsxRuntimeExports.jsx(e.ResizableHandle,{className:"border"}),e.jsxRuntimeExports.jsx(e.ResizablePanel,{minSize:40,defaultSize:75,maxSize:100,children:e.jsxRuntimeExports.jsx(Ve,{})})]}):e.jsxRuntimeExports.jsx(Ve,{})})]})}function At({authToken:s,onSave:n,onClose:t}){const r=e.useEditorStore(x=>x.actions.setOnSave),a=e.useEditorStore(x=>x.actions.setOnClose),c=e.useDashboardStore(x=>x.actions.setAuthToken);return f.useEffect(()=>{n&&r(n),t&&a(t)},[n,r,t,a]),f.useEffect(()=>{s&&s.accessToken&&c(s)},[s,c]),e.jsxRuntimeExports.jsxs(e.EditorPanel,{className:"rounded-none",role:"editor-panel",children:[e.jsxRuntimeExports.jsx(e.EditorAside,{className:"rounded-none border-r-[1.5px]",children:e.jsxRuntimeExports.jsx(Ue,{})}),e.jsxRuntimeExports.jsx(e.EditorMain,{children:e.jsxRuntimeExports.jsx(wt,{})})]})}function It(){e.useDashboardStore(x=>x.selectedCardId);const s=e.useDashboardStore(x=>x.selectedSheetId),{setIsVisualEditing:n}=e.useDashboardStore(x=>x.actions),t=e.useDashboardStore(x=>x.isVisualEditing),r=e.useDashboardStore(x=>x.actions.updateFrame);function a(x){s&&(r(s,x),n(!1))}function c(){n(!1)}return e.jsxRuntimeExports.jsx("div",{role:"editor-container",className:e.cn("flex grow",{block:t,hidden:!t}),children:e.jsxRuntimeExports.jsx(At,{onSave:a,onClose:c})})}function zt({columns:s,tableName:n}){const t=e.useEditorStore(m=>m.selectedConnectionId),r=e.useEditorStore(m=>m.selectedDatabaseName),a=e.useEditorStore(m=>m.selectedSchemaName),c=e.useEditorStore(m=>m.selectedTableName),x=e.useDashboardStore(m=>m.dashboard.filters)||[],o=e.useDashboardStore(m=>m.actions.addFilter),l=e.useDashboardStore(m=>m.actions.removeFilter),h=e.useDashboardStore(m=>m.actions.removeFilterValue);function d(m){const y=e.fmt(m.column_name),u=e.fmt(r||""),p=e.fmt(a||""),j=e.fmt(n),v=e.getQualifiedTableName(p,j),S=`${v}.${y}`;console.log("find",S,j,u);const A=x==null?void 0:x.find(R=>R.column===S&&R.table===j&&(R.database===u||R.database===r));if(A)h(A.id),l(A.id);else{if(n==="api"&&t){o({id:e.v4(),column:S,title:m.column_name,dataType:m.data_type,table:"api",database:"",connectionId:t,operation:"in",sql:e.getDefaultFilterSql(m.data_type,v,y)});return}o({id:e.v4(),column:`${v}.${y}`,title:m.column_name,dataType:m.data_type,table:c||"",database:r||"",connectionId:t||"",operation:"in",sql:e.getDefaultFilterSql(m.data_type,v,y)})}}return e.jsxRuntimeExports.jsx("div",{className:"xbg-red-100 flex-1 basis-0 flex-col overflow-scroll px-3",children:s==null?void 0:s.map(m=>{const y=x==null?void 0:x.find(u=>u.column===e.fmt(m.column_name)&&u.table===c&&u.database===r);return e.jsxRuntimeExports.jsx("div",{onClick:()=>d(m),className:e.cn("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",{"bg-muted":y}),children:e.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxRuntimeExports.jsx(Qe,{column:m}),e.jsxRuntimeExports.jsx("span",{children:m.column_name})]})},m.column_name)})})}function Tt(){e.useDashboardStore(n=>n.showFilters);const s=e.useDashboardStore(n=>n.actions.setShowFilters);return e.jsxRuntimeExports.jsxs("section",{className:"relative flex grow flex-col border-l px-4",children:[e.jsxRuntimeExports.jsxs("div",{className:"mt-4 flex items-center justify-between gap-2 px-3",children:[e.jsxRuntimeExports.jsx(e.Label,{className:"text-lg",children:"Filters"}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>s(!1),className:"h-7 w-7 p-0",variant:"ghost",children:e.jsxRuntimeExports.jsx(e.Cross2Icon,{})})]}),e.jsxRuntimeExports.jsx("div",{className:"flex grow",children:e.jsxRuntimeExports.jsx(Ue,{ColumnsComponent:(n,t,r)=>e.jsxRuntimeExports.jsx(zt,{schemaName:n,tableName:t,columns:r})})})]})}function Lt(){e.useDashboardStore(t=>t.dashboard);const s=e.useDashboardStore(t=>t.showFilters),n=e.useDashboardStore(t=>t.isVisualEditing);return e.useDashboardStore(t=>t.bookmarkKey),e.jsxRuntimeExports.jsxs("div",{role:"dashboard-plus-main",className:e.cn("grow",{hidden:n,flex:!n}),children:[e.jsxRuntimeExports.jsx(e.DashboardTabs,{}),s&&e.jsxRuntimeExports.jsx("div",{role:"filter-aside-container",className:"flex",children:e.jsxRuntimeExports.jsx(Tt,{})})]})}function Dt(){const s=e.useDashboardStore(r=>r.dashboard),n=e.useDashboardStore(r=>r.actions.setDashboard),t=e.useDashboardStore(r=>r.showDashboardJSON);return e.useDashboardStore(r=>r.actions.setShowDashboardJSON),e.jsxRuntimeExports.jsx("div",{className:e.cn(" p-2",{hidden:!t}),children:e.jsxRuntimeExports.jsx(e.de,{onChange:r=>{if(r)try{JSON.parse(r),n(JSON.parse(r))}catch{}},defaultLanguage:"json",className:"h-[550px] overflow-y-auto ",value:JSON.stringify(s,null,2),options:{minimap:{enabled:!1},glyphMargin:!1,wordWrap:"on",scrollbar:{verticalScrollbarSize:0,horizontalScrollbarSize:0},fontSize:12,renderLineHighlight:"none"}})})}function Ft({showControls:s=!1,showFooter:n=!0,...t}){return e.jsxRuntimeExports.jsxs(e.SemaphorContextProvider,{dashboardProps:t,children:[e.jsxRuntimeExports.jsx(e.Te,{}),e.jsxRuntimeExports.jsxs(e.UXProvider,{children:[e.jsxRuntimeExports.jsx(Dt,{}),e.jsxRuntimeExports.jsxs(e.DashboardPanel,{...t,children:[s&&e.jsxRuntimeExports.jsx(Bs,{}),e.jsxRuntimeExports.jsx(It,{}),e.jsxRuntimeExports.jsx(Lt,{})]})]})]})}exports.DashboardPlus=Ft;exports.SelectComponent=he;exports.useEditorAside=De;
|