react-semaphor 0.0.360 → 0.0.362
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/index-04SBdWDu.js +181 -0
- package/dist/chunks/{index-D2YdeeT8.js → index-CkXUj_Qx.js} +107 -107
- package/dist/chunks/{index-CV8XB1Cf.js → index-IxKvGWeb.js} +13180 -12953
- package/dist/chunks/{index-B9Q9zOHW.js → index-ga2D6Voj.js} +2092 -2069
- package/dist/chunks/{lucide-react-DGiYoZzy.js → lucide-react-C2M8zyBa.js} +7699 -7662
- package/dist/chunks/{lucide-react-Ddec0ua4.js → lucide-react-C8dhM7am.js} +634 -619
- package/dist/dashboard/index.cjs +1 -1
- package/dist/dashboard/index.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +2 -2
- package/dist/style.css +1 -1
- package/dist/surfboard/index.cjs +1 -1
- package/dist/surfboard/index.js +1 -1
- package/dist/types/dashboard.d.ts +3 -2
- package/dist/types/main.d.ts +11 -7
- package/dist/types/surfboard.d.ts +3 -2
- package/dist/types/types.d.ts +3 -2
- package/package.json +3 -3
- package/dist/chunks/index-C53Hv24f.js +0 -196
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
"use strict";const e=require("./index-CkXUj_Qx.js"),R=require("react");require("react-dom");function Fs(s){const r=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(s){for(const t in s)if(t!=="default"){const n=Object.getOwnPropertyDescriptor(s,t);Object.defineProperty(r,t,n.get?n:{enumerable:!0,get:()=>s[t]})}}return r.default=s,Object.freeze(r)}const qe=Fs(R);/**
|
|
2
|
+
* @license lucide-react v0.453.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 Ue=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"}]]);/**
|
|
7
|
+
* @license lucide-react v0.453.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 Qe=e.createLucideIcon("Braces",[["path",{d:"M8 3H7a2 2 0 0 0-2 2v5a2 2 0 0 1-2 2 2 2 0 0 1 2 2v5c0 1.1.9 2 2 2h1",key:"ezmyqa"}],["path",{d:"M16 21h1a2 2 0 0 0 2-2v-5c0-1.1.9-2 2-2a2 2 0 0 1-2-2V5a2 2 0 0 0-2-2h-1",key:"e1hn23"}]]);/**
|
|
12
|
+
* @license lucide-react v0.453.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 $e=e.createLucideIcon("ChartArea",[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"M7 11.207a.5.5 0 0 1 .146-.353l2-2a.5.5 0 0 1 .708 0l3.292 3.292a.5.5 0 0 0 .708 0l4.292-4.292a.5.5 0 0 1 .854.353V16a1 1 0 0 1-1 1H8a1 1 0 0 1-1-1z",key:"q0gr47"}]]);/**
|
|
17
|
+
* @license lucide-react v0.453.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 fe=e.createLucideIcon("ChartColumnIncreasing",[["path",{d:"M13 17V9",key:"1fwyjl"}],["path",{d:"M18 17V5",key:"sfb6ij"}],["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"M8 17v-3",key:"17ska0"}]]);/**
|
|
22
|
+
* @license lucide-react v0.453.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 ge=e.createLucideIcon("ChartLine",[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"m19 9-5 5-4-4-3 3",key:"2osh9i"}]]);/**
|
|
27
|
+
* @license lucide-react v0.453.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 Ne=e.createLucideIcon("ChartNoAxesGantt",[["path",{d:"M8 6h10",key:"9lnwnk"}],["path",{d:"M6 12h9",key:"1g9pqf"}],["path",{d:"M11 18h7",key:"c8dzvl"}]]);/**
|
|
32
|
+
* @license lucide-react v0.453.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 we=e.createLucideIcon("ChartPie",[["path",{d:"M21 12c.552 0 1.005-.449.95-.998a10 10 0 0 0-8.953-8.951c-.55-.055-.998.398-.998.95v8a1 1 0 0 0 1 1z",key:"pzmjnu"}],["path",{d:"M21.21 15.89A10 10 0 1 1 8 2.83",key:"k2fpak"}]]);/**
|
|
37
|
+
* @license lucide-react v0.453.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 ke=e.createLucideIcon("ChartScatter",[["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 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}]]);/**
|
|
42
|
+
* @license lucide-react v0.453.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 Je=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"}]]);/**
|
|
47
|
+
* @license lucide-react v0.453.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 Ke=e.createLucideIcon("CopyPlus",[["line",{x1:"15",x2:"15",y1:"12",y2:"18",key:"1p7wdc"}],["line",{x1:"12",x2:"18",y1:"15",y2:"15",key:"1nscbv"}],["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]);/**
|
|
52
|
+
* @license lucide-react v0.453.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 We=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"}]]);/**
|
|
57
|
+
* @license lucide-react v0.453.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 Re=e.createLucideIcon("EllipsisVertical",[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"12",cy:"5",r:"1",key:"gxeob9"}],["circle",{cx:"12",cy:"19",r:"1",key:"lyex9k"}]]);/**
|
|
62
|
+
* @license lucide-react v0.453.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 Xe=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"}]]);/**
|
|
67
|
+
* @license lucide-react v0.453.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 Ye=e.createLucideIcon("EyeClosed",[["path",{d:"m15 18-.722-3.25",key:"1j64jw"}],["path",{d:"M2 8a10.645 10.645 0 0 0 20 0",key:"1e7gxb"}],["path",{d:"m20 15-1.726-2.05",key:"1cnuld"}],["path",{d:"m4 15 1.726-2.05",key:"1dsqqd"}],["path",{d:"m9 18 .722-3.25",key:"ypw2yx"}]]);/**
|
|
72
|
+
* @license lucide-react v0.453.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 Ze=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"}]]);/**
|
|
77
|
+
* @license lucide-react v0.453.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 es=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"}]]);/**
|
|
82
|
+
* @license lucide-react v0.453.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 ss=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"}]]);/**
|
|
87
|
+
* @license lucide-react v0.453.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 ts=e.createLucideIcon("House",[["path",{d:"M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8",key:"5wwlr5"}],["path",{d:"M3 10a2 2 0 0 1 .709-1.528l7-5.999a2 2 0 0 1 2.582 0l7 5.999A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z",key:"1d0kgt"}]]);/**
|
|
92
|
+
* @license lucide-react v0.453.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("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"}]]);/**
|
|
97
|
+
* @license lucide-react v0.453.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 rs=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"}]]);/**
|
|
102
|
+
* @license lucide-react v0.453.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 os=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"}]]);/**
|
|
107
|
+
* @license lucide-react v0.453.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 ae=e.createLucideIcon("LoaderCircle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]);/**
|
|
112
|
+
* @license lucide-react v0.453.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 Ie=e.createLucideIcon("Map",[["path",{d:"M14.106 5.553a2 2 0 0 0 1.788 0l3.659-1.83A1 1 0 0 1 21 4.619v12.764a1 1 0 0 1-.553.894l-4.553 2.277a2 2 0 0 1-1.788 0l-4.212-2.106a2 2 0 0 0-1.788 0l-3.659 1.83A1 1 0 0 1 3 19.381V6.618a1 1 0 0 1 .553-.894l4.553-2.277a2 2 0 0 1 1.788 0z",key:"169xi5"}],["path",{d:"M15 5.764v15",key:"1pn4in"}],["path",{d:"M9 3.236v15",key:"1uimfh"}]]);/**
|
|
117
|
+
* @license lucide-react v0.453.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 is=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"}]]);/**
|
|
122
|
+
* @license lucide-react v0.453.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 as=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"}]]);/**
|
|
127
|
+
* @license lucide-react v0.453.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 ls=e.createLucideIcon("Play",[["polygon",{points:"6 3 20 12 6 21 6 3",key:"1oa8hb"}]]);/**
|
|
132
|
+
* @license lucide-react v0.453.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 cs=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 0Z",key:"wtfw2c"}]]);/**
|
|
137
|
+
* @license lucide-react v0.453.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 xs=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"}]]);/**
|
|
142
|
+
* @license lucide-react v0.453.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 De=e.createLucideIcon("Shapes",[["path",{d:"M8.3 10a.7.7 0 0 1-.626-1.079L11.4 3a.7.7 0 0 1 1.198-.043L16.3 8.9a.7.7 0 0 1-.572 1.1Z",key:"1bo67w"}],["rect",{x:"3",y:"14",width:"7",height:"7",rx:"1",key:"1bkyp8"}],["circle",{cx:"17.5",cy:"17.5",r:"3.5",key:"w3z12y"}]]);/**
|
|
147
|
+
* @license lucide-react v0.453.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 us=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"}]]);/**
|
|
152
|
+
* @license lucide-react v0.453.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 ds=e.createLucideIcon("Sigma",[["path",{d:"M18 7V5a1 1 0 0 0-1-1H6.5a.5.5 0 0 0-.4.8l4.5 6a2 2 0 0 1 0 2.4l-4.5 6a.5.5 0 0 0 .4.8H17a1 1 0 0 0 1-1v-2",key:"wuwx1p"}]]);/**
|
|
157
|
+
* @license lucide-react v0.453.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 ms=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 17h.01",key:"1euzgo"}],["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"}]]);/**
|
|
162
|
+
* @license lucide-react v0.453.0 - ISC
|
|
163
|
+
*
|
|
164
|
+
* This source code is licensed under the ISC license.
|
|
165
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
166
|
+
*/const ps=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"}]]);/**
|
|
167
|
+
* @license lucide-react v0.453.0 - ISC
|
|
168
|
+
*
|
|
169
|
+
* This source code is licensed under the ISC license.
|
|
170
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
171
|
+
*/const js=e.createLucideIcon("TicketX",[["path",{d:"M2 9a3 3 0 0 1 0 6v2a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-2a3 3 0 0 1 0-6V7a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2Z",key:"qn84l0"}],["path",{d:"m9.5 14.5 5-5",key:"qviqfa"}],["path",{d:"m9.5 9.5 5 5",key:"18nt4w"}]]);/**
|
|
172
|
+
* @license lucide-react v0.453.0 - ISC
|
|
173
|
+
*
|
|
174
|
+
* This source code is licensed under the ISC license.
|
|
175
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
176
|
+
*/const hs=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"}]]);/**
|
|
177
|
+
* @license lucide-react v0.453.0 - ISC
|
|
178
|
+
*
|
|
179
|
+
* This source code is licensed under the ISC license.
|
|
180
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
181
|
+
*/const be=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"}]]);function Te(s){var r;return{...s,sheets:(r=s==null?void 0:s.sheets)==null?void 0:r.map(t=>{var n;return{...t,frames:(n=t.frames)==null?void 0:n.map(o=>{var i;return{...o,cards:(i=o.cards)==null?void 0:i.map(a=>Es(a))}})}})}}function Es(s){var r,t,n,o;return{...s,cfg:{...s.cfg,data:{...(r=s.cfg)==null?void 0:r.data,labels:[],datasets:(o=(n=(t=s.cfg)==null?void 0:t.data)==null?void 0:n.datasets)==null?void 0:o.map(i=>({...i,data:[]}))}},customCfg:Vs(s.customCfg),data:[]}}function Vs(s){var r,t;return s?{...s,data:{...s==null?void 0:s.data,labels:[],datasets:(t=(r=s==null?void 0:s.data)==null?void 0:r.datasets)==null?void 0:t.map(n=>({...n,data:[]}))}}:null}async function qs(s,r,t,n){if(!n)return null;const o=JSON.stringify(r);return await e.postRequest("https://semaphor.cloud/api/v1/lens",n,{name:s,template:o,filterValues:t,operation:"create"})}async function Ce(s,r){if(!r)return null;const{id:t,template:n,filterValues:o,isDefault:i,shared:a}=s;return await e.postRequest("https://semaphor.cloud/api/v1/lens",r,{lensId:t,template:n,filterValues:o,isDefault:i,shared:a,operation:"update"})}async function _s(s,r){return r?await e.postRequest("https://semaphor.cloud/api/v1/lens",r,{operation:"delete",lensId:s}):null}function Bs(){const[s,r]=R.useState(""),[t,n]=R.useState(!1),o=e.useDashboardStore(h=>h.lenses),{setLenses:i,setSelectedLensId:a}=e.useDashboardActions(),[l,c]=R.useState(!1),[u,m]=R.useState(!1),f=e.useDashboardStore(h=>h.dashboard),g=e.useDashboardStore(h=>h.filterValues),{authToken:x}=e.useSemaphorContext();async function p(){c(!0);const h=Te(f),y=await qs(s,h,g,x==null?void 0:x.accessToken);y&&(i([...o||[],y]),a(y.id),m(!1)),c(!1)}return e.jsxRuntimeExports.jsxs(e.Dialog,{open:u,onOpenChange:m,children:[e.jsxRuntimeExports.jsx(e.DialogTrigger,{asChild:!0,children:e.jsxRuntimeExports.jsxs(e.Button,{variant:"secondary",className:"h-7 p-2",size:"sm",children:[e.jsxRuntimeExports.jsx(e.Plus,{className:"mr-2 h-4 w-4",strokeWidth:1.5}),"Lens"]})}),e.jsxRuntimeExports.jsxs(e.DialogContent,{className:"sm:max-w-[425px]",children:[e.jsxRuntimeExports.jsxs(e.DialogHeader,{children:[e.jsxRuntimeExports.jsx(e.DialogTitle,{children:"Create 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:h=>{r(h.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 lens name already exists. Use a differnet name."}),e.jsxRuntimeExports.jsx(e.DialogFooter,{children:e.jsxRuntimeExports.jsx(e.Button,{size:"sm",variant:"outline",type:"submit",onClick:p,disabled:l,children:l?"Creating...":"Add"})})]})]})}function Hs(){const[s,r]=R.useState(!1),t=e.useDashboardStore(m=>m.lenses),n=e.useDashboardStore(m=>m.selectedLensId),{setLenses:o,setSelectedLensId:i}=e.useDashboardActions(),{authToken:a}=e.useSemaphorContext();async function l(m){i(m)}async function c(m){if(await _s(m,a==null?void 0:a.accessToken)){const g=t==null?void 0:t.filter(x=>x.id!==m);o(g||[]),i("original")}}async function u(m){const f=t==null?void 0:t.map(p=>p.id===m.id?{...p,isDefault:!m.isDefault}:{...p,isDefault:!1});o(f||[]);const g={...m,isDefault:!m.isDefault};await Ce(g,a==null?void 0:a.accessToken);const x=t==null?void 0:t.find(p=>p.isDefault);if(x&&x.id!==m.id){const p={...x,isDefault:!1};await Ce(p,a==null?void 0:a.accessToken)}}return e.jsxRuntimeExports.jsxs(e.DropdownMenu,{open:s,onOpenChange:r,children:[e.jsxRuntimeExports.jsx(e.DropdownMenuTrigger,{asChild:!0,children:e.jsxRuntimeExports.jsx(e.Button,{variant:"ghost",className:"h-7 p-2",children:e.jsxRuntimeExports.jsx(Ze,{className:"h-4 w-4",strokeWidth:1.5})})}),e.jsxRuntimeExports.jsxs(e.DropdownMenuContent,{align:"end",className:"w-60",children:[e.jsxRuntimeExports.jsx(e.DropdownMenuLabel,{className:"px-3",children:"Lenses"}),e.jsxRuntimeExports.jsx(e.DropdownMenuSeparator,{}),e.jsxRuntimeExports.jsxs(e.DropdownMenuRadioGroup,{value:n,onValueChange:l,children:[e.jsxRuntimeExports.jsx(e.DropdownMenuRadioItem,{value:"original",children:"Original"}),t==null?void 0:t.map(m=>e.jsxRuntimeExports.jsxs(e.DropdownMenuRadioItem,{className:"group flex justify-between gap-2",value:m.id,children:[e.jsxRuntimeExports.jsx("p",{children:m.name}),e.jsxRuntimeExports.jsxs("span",{className:"flex items-center gap-3",children:[e.jsxRuntimeExports.jsx(ts,{onClick:f=>{f.preventDefault(),u(m)},className:e.cn("size-3.5 text-muted-foreground hover:cursor-pointer hover:text-foreground group-hover:visible",{invisible:!m.isDefault,"text-green-500":m.isDefault}),strokeWidth:1.5}),e.jsxRuntimeExports.jsx(e.Cross2Icon,{onClick:f=>{f.preventDefault(),c(m.id)},className:"invisible size-3.5 text-muted-foreground hover:cursor-pointer hover:text-foreground group-hover:visible",strokeWidth:1.5})]})]},m.id))]})]})]})}function Ps({iconClassName:s}){const[r,t]=R.useState(!1),{authToken:n}=e.useSemaphorContext(),o=e.useDashboardStore(l=>l.theme),i=e.useDashboardStore(l=>l.filterValues);async function a(){{t(!0);const l=new URLSearchParams;l.set("token",(n==null?void 0:n.accessToken)||""),l.set("theme",o||"light"),l.set("filterValues",JSON.stringify(i));const c=`https://semaphor.cloud/api/v1/generate-pdf?params=${encodeURIComponent(l.toString())}`,m=await(await fetch(c,{method:"GET",headers:{Authorization:`Bearer ${n==null?void 0:n.accessToken}`}})).blob(),f=URL.createObjectURL(m);window.open(f,"_blank"),t(!1)}}return e.jsxRuntimeExports.jsx(e.Button,{variant:"link",className:"group h-7 p-2",size:"sm",onClick:a,children:r?e.jsxRuntimeExports.jsx(ae,{className:e.cn("size-3.5 animate-spin",s)}):e.jsxRuntimeExports.jsx(e.Download,{className:e.cn("size-3.5",s),strokeWidth:1.5})})}function Gs(){const{authToken:s}=e.useSemaphorContext();e.useDashboardStore(j=>j.theme);const r=e.useDashboardStore(j=>j.lenses),t=e.useDashboardStore(j=>j.selectedLensId),n=r==null?void 0:r.find(j=>j.id===t),o=e.useDashboardStore(j=>j.dashboard);e.useDashboardStore(j=>j.selectedSheetId);const i=e.useDashboardStore(j=>j.isDashboardEditing),a=e.useEditorStore(j=>j.selectedConnectionId),[l,c]=R.useState(!1),u=e.useDashboardStore(j=>j.filterValues),m=e.useDashboardStore(j=>j.isVisualEditing),f=e.useDashboardStore(j=>j.showFilters);e.useDashboardStore(j=>j.showDashboardJSON);const g=e.useDashboardStore(j=>j.onSaveFunction),x=e.useDashboardStore(j=>j.actions.setShowFilters),{addFrame:p,setSelectedFrameId:h}=e.useDashboardStore(j=>j.actions),{getSelectedSheet:y,setIsDashboardEditing:E,setShowDashboardJSON:z}=e.useDashboardStore(j=>j.actions),L=y(),{tenantId:S,endUserId:C}=R.useMemo(()=>e.getTenantAndEndUserId(s==null?void 0:s.accessToken),[s==null?void 0:s.accessToken]),D=R.useMemo(()=>S||C,[S,C]),F=()=>{if(!i||!L)return;const j={connectionId:a,id:e.v4(),title:"Title",description:"Description",preferences:{onClickFilter:[{columnIndex:0,expression:""}]},type:"bar",sql:"select COUNT(*) from YOUR_TABLE",data:[]},k={id:e.v4(),cards:[j],activeCardId:j.id};p(L.id,k),h(k.id)},N=()=>{E(!0)};async function d(){if(c(!0),!t||!n)return;const j=Te(o),k=JSON.stringify(j),I={...n,template:k,filterValues:u};await Ce(I,s==null?void 0:s.accessToken),e.ce.success("Lens saved"),g==null||g(j),c(!1)}return m?null:e.jsxRuntimeExports.jsxs("div",{className:"flex items-center justify-between gap-2 border-b bg-muted/50 py-2 pl-3 pr-2",role:"dashboard-controls",children:[!m&&e.jsxRuntimeExports.jsx("div",{className:"flex items-center gap-3",children:e.jsxRuntimeExports.jsx(e.Label,{children:n==null?void 0:n.name})}),e.jsxRuntimeExports.jsxs("div",{className:"flex gap-2",children:[e.jsxRuntimeExports.jsx("button",{onClick:e.invalidateToken,children:e.jsxRuntimeExports.jsx(js,{className:"h-4 w-4",strokeWidth:1.5})}),e.jsxRuntimeExports.jsx(Ps,{}),i&&!m&&D&&e.jsxRuntimeExports.jsx(Bs,{}),!m&&D&&e.jsxRuntimeExports.jsx(Hs,{}),i&&!m&&e.jsxRuntimeExports.jsxs(e.Button,{variant:"secondary",className:"h-7 p-2",size:"sm",disabled:!i,onClick:F,children:[e.jsxRuntimeExports.jsx(e.Plus,{className:"mr-2 h-4 w-4",strokeWidth:1.5}),"Frame"]}),!i&&e.jsxRuntimeExports.jsx(e.Button,{variant:"ghost",className:"h-7 p-2",onClick:N,size:"sm",children:e.jsxRuntimeExports.jsx(e.Pencil,{className:"h-4 w-4",strokeWidth:1.5})}),i&&!m&&e.jsxRuntimeExports.jsx(e.Button,{variant:"ghost",role:"close",className:"h-7 p-2",onClick:()=>{E(!1),z(!1)},size:"sm",children:e.jsxRuntimeExports.jsx(e.Cross2Icon,{className:"h-4 w-4",strokeWidth:1.5})}),i&&!m&&D&&e.jsxRuntimeExports.jsx(e.Button,{className:"h-7 p-2",variant:"ghost",disabled:l,onClick:d,size:"sm",children:e.jsxRuntimeExports.jsx(xs,{className:"h-4 w-4",strokeWidth:1.5})}),!f&&!m&&i&&e.jsxRuntimeExports.jsx(e.Button,{className:"h-7 p-2",variant:"ghost",onClick:()=>x(!0),size:"sm",children:e.jsxRuntimeExports.jsx(e.Filter,{className:"h-4 w-4",strokeWidth:1.5})}),!m&&i&&!1,!m&&!1]})]})}function ce({title:s,items:r,value:t,isLoading:n,isError:o,connectionTooltip:i,onChange:a,showNone:l=!1,className:c,showIcon:u=!0,disabled:m=!1}){const f=n?"Loading...":o?"Error":t;function g(){if(s==="Connection")return e.jsxRuntimeExports.jsx(cs,{className:"size-4 rotate-90"});if(s==="Database")return e.jsxRuntimeExports.jsx(We,{className:"size-4"});if(s==="Schema")return e.jsxRuntimeExports.jsx(as,{className:"size-4"});if(s==="Table")return e.jsxRuntimeExports.jsx(e.Table,{className:"size-4"});if(s==="Model")return e.jsxRuntimeExports.jsx(Ue,{className:"size-4"})}return e.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-2",children:[u&&e.jsxRuntimeExports.jsx("div",{className:"shrink-0",children:i?e.jsxRuntimeExports.jsxs(e.Tooltip,{children:[e.jsxRuntimeExports.jsx(e.TooltipTrigger,{children:g()}),e.jsxRuntimeExports.jsx(e.TooltipContent,{className:"text-xs",align:"start",children:i})]}):g()}),e.jsxRuntimeExports.jsxs(e.Select,{disabled:m,value:f,onValueChange:a,children:[e.jsxRuntimeExports.jsx(e.SelectTrigger,{className:e.cn("h-9 w-full focus:ring-1 focus:ring-offset-0",c),children:e.jsxRuntimeExports.jsx(e.SelectValue,{placeholder:n?"Loading...":o?"Error":`Select ${s}`})}),e.jsxRuntimeExports.jsx(e.SelectContent,{children:e.jsxRuntimeExports.jsxs(e.SelectGroup,{children:[n?e.jsxRuntimeExports.jsx(e.SelectLabel,{children:"Loading..."}):e.jsxRuntimeExports.jsx(e.SelectLabel,{children:s}),e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[l&&e.jsxRuntimeExports.jsx(e.SelectItem,{value:"none",children:"None"},"none"),r&&r.map((x,p)=>e.jsxRuntimeExports.jsx(e.SelectItem,{value:x.id,children:x.name},p))]}),(n||o)&&e.jsxRuntimeExports.jsx(e.SelectItem,{value:f,children:f})]})})]})]})}function Us({column:s}){const[r,t]=R.useState(!1),n=e.useEditorStore(p=>p.selectedTableName),o=e.useEditorStore(p=>p.selectedSchemaName),i=e.useEditorStore(p=>p.selectedDatamodelId),a=e.useEditorStore(p=>p.sqlGen),{modelItems:l,connectionType:c}=oe(),u=e.useEditorStore(p=>p.actions.setSqlGen),m=e.useEditorStore(p=>p.actions.setCardSql),f=e.useEditorStore(p=>p.actions.setRunSql);function g(p,h){var L;const y=e.createSqlGenConfig(p,a,h),E=(L=l==null?void 0:l.find(S=>S.id===i))==null?void 0:L.name;u(y);const z=e.getSql(y,e.fmt(o||""),e.fmt(n),E,c);z&&(m(z),f(!0)),t(!1)}function x(){return e.jsxRuntimeExports.jsxs("ul",{className:"text-xs",children:[e.jsxRuntimeExports.jsx("li",{onClick:()=>g(s,"COUNT"),className:"cursor-pointer p-1 px-3 transition-colors hover:bg-muted",children:"Count"}),e.jsxRuntimeExports.jsx("li",{onClick:()=>g(s,"AVG"),className:"cursor-pointer p-1 px-3 transition-colors hover:bg-muted",children:"Avg"}),e.jsxRuntimeExports.jsx("li",{onClick:()=>g(s,"SUM"),className:"cursor-pointer p-1 px-3 transition-colors hover:bg-muted",children:"Sum"}),e.jsxRuntimeExports.jsx("li",{onClick:()=>g(s,"MAX"),className:"cursor-pointer p-1 px-3 transition-colors hover:bg-muted",children:"Max"}),e.jsxRuntimeExports.jsx("li",{onClick:()=>g(s,"MIN"),className:"cursor-pointer p-1 px-3 transition-colors hover:bg-muted",children:"Min"})]})}return e.jsxRuntimeExports.jsxs(e.HoverCard,{openDelay:0,open:r,onOpenChange:t,children:[e.jsxRuntimeExports.jsx(e.HoverCardTrigger,{asChild:!0,children:e.jsxRuntimeExports.jsx(Re,{className:"invisible size-3.5 cursor-pointer text-foreground/40 group-hover:visible"})}),e.jsxRuntimeExports.jsx(e.HoverCardContent,{align:"center",className:"w-20 rounded-md p-0 shadow-none",children:x()})]})}function fs({column:s}){return e.jsxRuntimeExports.jsxs(e.Tooltip,{children:[e.jsxRuntimeExports.jsx(e.TooltipTrigger$1,{asChild:!0,children:e.isTextDataType(s.data_type)?e.jsxRuntimeExports.jsx(be,{className:"size-3"}):e.isNumberDataType(s.data_type)?e.jsxRuntimeExports.jsx(ss,{className:"size-3"}):e.isDateDataType(s.data_type)?e.jsxRuntimeExports.jsx(e.Calendar,{className:"size-3"}):e.isBooleanDataType(s.data_type)?e.jsxRuntimeExports.jsx(hs,{className:"size-3"}):s.data_type.toLowerCase()==="json"?e.jsxRuntimeExports.jsx(Qe,{className:"size-3"}):e.jsxRuntimeExports.jsx(us,{className:"size-3"})}),e.jsxRuntimeExports.jsx(e.TooltipContent,{children:e.jsxRuntimeExports.jsx("p",{className:"font-mono text-xs",children:s.data_type})})]})}function Qs({schemaName:s,tableName:r,columns:t,status:n}){const o=e.useEditorStore(d=>d.sqlGen),i=e.useEditorStore(d=>d.selectedConnectionId),a=e.useEditorStore(d=>d.selectedDatabaseName),l=e.useEditorStore(d=>d.selectedSchemaName),c=e.useEditorStore(d=>d.selectedTableName),u=e.useEditorStore(d=>d.selectedDatamodelId),m=e.useDashboardStore(d=>d.dashboard.aiScopeTables),{addToAIScope:f,removeFromAIScope:g}=e.useDashboardActions();e.useDashboardStore(d=>d.actions);const x=e.useEditorStore(d=>d.actions.setRunSql),p=e.useEditorStore(d=>d.actions.setSqlGen),h=e.useEditorStore(d=>d.actions.setIsShowingVisual),y=e.useEditorStore(d=>d.actions.setCardSql),{connectionType:E,modelItems:z,selectedDatamodelName:L}=oe();function S(d){var O;const j=e.createSqlGenConfig(d,o);p(j);const k=(O=z==null?void 0:z.find(q=>q.id===u))==null?void 0:O.name,I=e.getSql(j,e.fmt(s),e.fmt(r),k,E);I&&(y(I),x(!0))}function C(){return(m==null?void 0:m.find(d=>d.connectionId===i&&(d.tableName===c||d.datamodelName===L)))!==void 0}function D(d){d===!0&&(c||L)&&i?(f({connectionId:i,connectionType:E,databaseName:a,schemaName:l,tableName:c,datamodelName:L}),e.ce.success("Added to Assistant Scope",{position:"top-right",duration:2500,richColors:!0})):(g({connectionId:i||"",connectionType:E||"",tableName:c||"",datamodelName:L||""}),e.ce("Removed from Assistant Scope",{position:"top-right",duration:2e3,richColors:!0}))}function F(){const d=e.getFormattedTableNameForQuery({schemaName:s,tableName:r,modelName:L,connectionType:E});h(!1);const j=E==="MSSQL"?`SELECT top 10 * FROM ${d}`:`SELECT * FROM ${d} LIMIT 10`;y(j),x(!0)}function N(){const d=e.getFormattedTableNameForQuery({schemaName:s,tableName:r,modelName:L,connectionType:E});y(`SELECT COUNT(*) as count FROM ${d}`),x(!0)}return e.jsxRuntimeExports.jsxs("div",{className:"flex grow flex-col space-y-4 px-4",children:[e.jsxRuntimeExports.jsxs("div",{className:"mx-2 flex items-center justify-center gap-2",children:[e.jsxRuntimeExports.jsxs(e.Toggle,{title:`${C()?"Remove from":"Add to"} Assistant Scope`,pressed:C(),onPressedChange:D,variant:"outline",className:e.cn("h-9 px-2",{}),children:[e.jsxRuntimeExports.jsx(e.Plus,{className:e.cn("mr-1 size-4",{"text-green-400":C(),"text-muted-foreground":!C()})}),"AI"]}),e.jsxRuntimeExports.jsxs(e.Button,{disabled:n!=="Success",onClick:F,size:"sm",variant:"secondary",className:"flex",children:[n!=="Success"?e.jsxRuntimeExports.jsx(ae,{className:"mr-2 h-4 w-4 animate-spin text-foreground/50"}):e.jsxRuntimeExports.jsx(ms,{className:"mr-2 size-4"}),"Top 10"]}),e.jsxRuntimeExports.jsxs(e.Button,{disabled:n!=="Success",onClick:N,size:"sm",variant:"secondary",className:"w-full",children:[n!=="Success"?e.jsxRuntimeExports.jsx(ae,{className:"mr-2 h-4 w-4 animate-spin text-foreground/50"}):e.jsxRuntimeExports.jsx(ds,{className:"mr-2 size-4"}),"Count"]})]}),e.jsxRuntimeExports.jsxs(e.ScrollArea,{className:"flex-1 basis-0 border-b border-t border-muted py-3",children:[e.jsxRuntimeExports.jsx("div",{className:"flex flex-col gap-1",children:t==null?void 0:t.map(d=>e.jsxRuntimeExports.jsxs("div",{onClick:()=>S(d),className:e.cn("group mx-3 flex cursor-pointer items-center justify-between rounded px-2 py-1 text-sm transition-colors hover:bg-muted/50",{"border border-dashed border-muted-foreground bg-muted":e.isColumnInSqlGen(d,o)}),children:[e.jsxRuntimeExports.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxRuntimeExports.jsx(fs,{column:d}),e.jsxRuntimeExports.jsx("span",{children:d.column_name})]}),e.jsxRuntimeExports.jsx("div",{onClick:j=>j.stopPropagation(),className:"flex items-center justify-end",children:e.isNumberDataType(d.data_type)&&e.jsxRuntimeExports.jsx(Us,{column:d})})]},d.column_name))}),e.jsxRuntimeExports.jsx(e.ScrollBar,{orientation:"vertical"}),e.jsxRuntimeExports.jsx(e.ScrollBar,{orientation:"horizontal"})]})]})}function oe(s,r){var Ae,ze,Oe,Me,Fe,Ve;let t=R.useMemo(()=>[],[]);const n=e.useSemaphorContext().authToken||s,o=e.useEditorStore(b=>b.selectedConnectionId),i=e.useEditorStore(b=>b.selectedDatamodelId),a=e.useEditorStore(b=>b.selectedDatabaseName),l=e.useEditorStore(b=>b.selectedSchemaName),c=e.useEditorStore(b=>b.selectedTableName),u=e.useEditorStore(b=>b.actions.setCurrentColumns),m=e.useEditorStore(b=>b.actions.setSelectedConnectionId),f=e.useEditorStore(b=>b.actions.setSelectedDatamodelId),g=e.useEditorStore(b=>b.actions.setSelectedDatabaseName),x=e.useEditorStore(b=>b.actions.setSelectedSchemaName),p=e.useEditorStore(b=>b.actions.setSelectedTableName),h=e.useEditorStore(b=>b.actions.setCardSql);function y(b){return o&&a&&l&&a!=="NA"?!0:o&&b==="API"?!1:!!(o&&b==="S3")}function E(b){return!!(o&&a&&a!=="NA"&&l&&c||o&&(b==="S3"||b==="API")||i&&i)}function z(b){return o&&b?!(b==="API"||b==="S3"):!1}const{data:L,isLoading:S,isError:C}=e.useQuery({queryKey:["connections"],queryFn:()=>e.getRequest("https://semaphor.cloud/api/v1/connections",(n==null?void 0:n.accessToken)||""),enabled:!!(n!=null&&n.accessToken)}),{data:D,isLoading:F,isError:N}=e.useQuery({queryKey:["models",o],queryFn:()=>e.getRequest("https://semaphor.cloud/api/v1/datamodels",(n==null?void 0:n.accessToken)||"",{connection_id:o}),enabled:!!(n!=null&&n.accessToken)&&!!o}),d=L==null?void 0:L.connections.find(b=>b.id===o),j=d==null?void 0:d.type,k=(d==null?void 0:d.type)==="API"||(d==null?void 0:d.type)==="S3",{data:I,isLoading:O,isFetching:q,isError:G,refetch:H}=e.useQuery({queryKey:["databases",o],queryFn:()=>e.getRequest("https://semaphor.cloud/api/v1/databases",(n==null?void 0:n.accessToken)||"",{connection_id:o}),enabled:z(j)}),{data:B,isLoading:K,isFetching:Y,isError:_,refetch:Q}=e.useQuery({queryKey:["schemas",o,a],queryFn:()=>e.getRequest("https://semaphor.cloud/api/v1/schemas",(n==null?void 0:n.accessToken)||"",{connection_id:o,database_name:a}),enabled:!!o&&!!a&&!k&&a!=="NA"}),{data:A,isLoading:T,isFetching:$,isError:V,refetch:P}=e.useQuery({queryKey:["tables",o,a,l],queryFn:()=>e.getRequest("https://semaphor.cloud/api/v1/tables",(n==null?void 0:n.accessToken)||"",{connection_id:o,database_name:a,schema_name:l}),enabled:y(j)}),{data:J,isLoading:X,isFetching:ne,isError:Z}=e.useQuery({queryKey:["columns",o,a,i,l,c],queryFn:()=>e.getRequest("https://semaphor.cloud/api/v1/columns",(n==null?void 0:n.accessToken)||"",{connection_id:o,datamodel_id:i||"",database_name:a,schema_name:l,table_name:c}),enabled:E(j)});R.useEffect(()=>{u(t)},[J,u,t]),R.useEffect(()=>{},[k,j,h,p,x,g,d]);const re=(d==null?void 0:d.type)==="API"?(Ae=d==null?void 0:d.type)==null?void 0:Ae.toLowerCase():c||"",w=k?"":l||"";function M(b){x(b),p("")}function U(b){g(b==="none"?"":b),x(""),p(""),b!=="none"&&b!==""&&f("")}function v(b){m(b)}function W(b){f(b==="none"?"":b),b!=="none"&&b!==""&&g("")}I&&((ze=I==null?void 0:I.databases)==null?void 0:ze.length)>0,B&&((Oe=B==null?void 0:B.schemas)==null?void 0:Oe.length)>0,J&&((Me=J==null?void 0:J.columns)==null?void 0:Me.length)>0&&(t=J.columns.map(b=>({...b,data_type:b.data_type.toLowerCase()}))),G&&(t=[]),(Z||C)&&(t=[]);const ie=L==null?void 0:L.connections.map(b=>({id:b.id,name:b.name,type:b.type})),ee=(Fe=D==null?void 0:D.datamodels)==null?void 0:Fe.map(b=>({id:b.id,name:b.name})),ue=I==null?void 0:I.databases.map(b=>({id:b.database_name,name:b.database_name})),ye=B==null?void 0:B.schemas.map(b=>({id:b.schema_name,name:b.schema_name})),me=A==null?void 0:A.tables.map(b=>({id:b.table_name,name:b.table_name})),Se=(Ve=D==null?void 0:D.datamodels.find(b=>b.id===i))==null?void 0:Ve.name;return{connectionItems:ie,isConnectionsLoading:S,isConnectionsError:C,modelItems:ee,selectedDatamodelId:i,selectedDatamodelName:Se,isModelsLoading:F,isModelsError:N,databaseItems:ue,isDatabasesLoadingOrFetching:O||q,isDatabaseError:G,schemaItems:ye,isSchemaLoadingOrFetching:K||Y,isSchemaError:_,tableItems:me,isTableLoadingOrFetching:T||$,isTableError:V,columns:t,isColumnsLoadingOrFetching:X||ne,isColumnsError:Z,isNonDbConnection:k,connectionType:j,tableName:re,schemaName:w,handleConnectionChange:v,handleDatamodelChange:W,handleDatabaseChange:U,handleSchemaChange:M}}function gs({ColumnsComponent:s}){var $;const r=e.useEditorStore(V=>V.selectedConnectionId),t=e.useEditorStore(V=>V.selectedDatamodelId),n=e.useEditorStore(V=>V.selectedDatabaseName),o=e.useEditorStore(V=>V.selectedSchemaName),i=e.useEditorStore(V=>V.selectedTableName),a=e.useEditorStore(V=>V.actions.setSelectedTableName),{connectionItems:l,modelItems:c,schemaItems:u,databaseItems:m,tableItems:f,columns:g,isConnectionsLoading:x,isModelsLoading:p,isConnectionsError:h,isModelsError:y,isDatabasesLoadingOrFetching:E,isDatabaseError:z,isSchemaLoadingOrFetching:L,isSchemaError:S,isColumnsError:C,isColumnsLoadingOrFetching:D,isTableLoadingOrFetching:F,isTableError:N,connectionType:d,isNonDbConnection:j,handleConnectionChange:k,handleDatabaseChange:I,handleSchemaChange:O,handleDatamodelChange:q,tableName:G,schemaName:H}=oe();function B(){return s?s(H,G,g):e.jsxRuntimeExports.jsx(Qs,{schemaName:H,tableName:G,columns:g,status:D?"Loading...":C?"Error":"Success"})}function K(){window.location.href="mailto:support@semaphor.cloud?subject=Help&body=I need help with..."}function Y(){if(!r||d==="S3"||d==="API")return null;if(!t||t==="none")return e.jsxRuntimeExports.jsx(ce,{showNone:!0,onChange:I,isError:z,isLoading:E,items:m,value:n||"",title:"Database"})}function _(){if(r&&!j&&(!n||n==="none")&&(!t||t==="none"))return e.jsxRuntimeExports.jsxs("div",{className:"grid grid-cols-3",children:[e.jsxRuntimeExports.jsx("div",{className:"col-span-1 grid place-items-center",children:e.jsxRuntimeExports.jsx(e.Separator,{})}),e.jsxRuntimeExports.jsx("div",{className:"col-span-1 grid place-items-center",children:e.jsxRuntimeExports.jsx(e.Label,{children:"OR"})}),e.jsxRuntimeExports.jsx("div",{className:"col-span-1 grid place-items-center",children:e.jsxRuntimeExports.jsx(e.Separator,{})})]})}function Q(){if(!r||d==="S3"||d==="API")return null;if(!n||n==="none")return e.jsxRuntimeExports.jsx(ce,{showNone:!0,onChange:q,isError:y,isLoading:p,items:c,value:t||"",title:"Model"})}function A(){return!r||d==="S3"||d==="API"||!n||n==="none"?null:e.jsxRuntimeExports.jsx(ce,{onChange:O,isError:S,isLoading:L,items:u,value:o||"",title:"Schema"})}function T(){function V(){let P=!1;return d==="API"?(P=!1,P):((d==="S3"||r&&n&&n!=="none"&&o)&&(P=!0),P)}return V()?e.jsxRuntimeExports.jsx(ce,{onChange:a,isError:N,items:f,isLoading:F,value:i||"",title:"Table"}):null}return e.jsxRuntimeExports.jsxs("aside",{className:"flex grow flex-col justify-between",children:[e.jsxRuntimeExports.jsxs("section",{className:"space-y-3 px-6 py-4",children:[e.jsxRuntimeExports.jsx(ce,{items:l,title:"Connection",value:r||"",onChange:k,isLoading:x,isError:h,connectionTooltip:(($=l==null?void 0:l.find(V=>V.id===r))==null?void 0:$.type)||""}),Y(),_(),Q(),A(),T()]}),B(),e.jsxRuntimeExports.jsx("div",{className:"flex items-end justify-center gap-2 px-6 py-4",children:e.jsxRuntimeExports.jsxs(e.Button,{onClick:K,size:"sm",variant:"secondary",className:"w-full",children:[e.jsxRuntimeExports.jsx(is,{className:"mr-2 size-4"}),"Help"]})})]})}function $s(s){const r=s.toUpperCase().indexOf("WHERE"),t=s.toUpperCase().indexOf("GROUP BY"),n=s.toUpperCase().indexOf("LIMIT"),o=s.toUpperCase().indexOf("ORDER BY");let i=s.length;if(o!==-1&&(i=o),n!==-1&&n<i&&(i=n),r!==-1){const a=s.substring(0,r),l=s.substring(r);return`${a} {{ filters | where }} AND ${l.substring(6)}`}else if(t!==-1){const a=s.substring(0,t),l=s.substring(t);return`${a} {{ filters | where }} ${l}`}else{const a=s.substring(0,i),l=s.substring(i);return console.log("beforeClause",a),console.log("afterClause",l),l?`${a} {{ filters | where }} ${l}`:`${a.replace(/;$/,"")} {{ filters | where }}`}}function Js({error:s,setShowAIDialog:r,setUserInputforAI:t,setTriggerAIRun:n}){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:"h-5 p-0",children:e.jsxRuntimeExports.jsx(Je,{className:"h-4 w-4 text-red-500"})})}),e.jsxRuntimeExports.jsx(e.HoverCardContent,{align:"start",className:"w-full min-w-fit max-w-[700px]",children:e.jsxRuntimeExports.jsx("div",{className:"flex justify-between space-x-4",children:e.jsxRuntimeExports.jsxs("div",{className:"flex grow flex-col space-y-2",children:[e.jsxRuntimeExports.jsx(e.ScrollArea,{className:"max-h-[250px] min-h-0 overflow-scroll",children:e.jsxRuntimeExports.jsx("p",{className:"overflow-auto rounded-md bg-muted p-2 text-xs leading-relaxed",children:s})}),e.jsxRuntimeExports.jsxs(e.Button,{onClick:()=>{r(!0),t(s),n(!0)},size:"sm",variant:"outline",children:[e.jsxRuntimeExports.jsx(es,{className:"mr-2 h-4 w-4"}),"Debug with AI"]})]})})})]})}const Ks=e.Root,Ws=e.CollapsibleTrigger,Xs=e.CollapsibleContent;function Ys({open:s,setOpen:r,userInput:t,triggerAIRun:n,setTriggerAIRun:o}){const i=R.useRef(null),a=R.useRef(null),[l,c]=R.useState(""),{authToken:u}=e.useSemaphorContext(),[m,f]=R.useState(!1),[g,x]=R.useState(!1),p=e.useEditorStore(w=>w.actions.setCardSql),h=e.useEditorStore(w=>w.actions.setRunSql),y=e.useEditorStore(w=>w.actions.switchCardType),[E,z]=R.useState(null),L=e.useEditorStore(w=>w.currentColumns),S=e.useEditorStore(w=>w.selectedDatabaseName),C=e.useEditorStore(w=>w.selectedTableName),D=e.useEditorStore(w=>w.selectedConnectionId),F=e.useEditorStore(w=>w.selectedSchemaName),N=e.useDashboardStore(w=>w.dashboard.aiScopeTables),{removeFromAIScope:d,addToAIScope:j}=e.useDashboardActions(),{selectedDatamodelName:k,selectedDatamodelId:I,connectionType:O}=oe(),q=e.getFormattedTableNameForQuery({schemaName:F||"",tableName:C||"",modelName:k,connectionType:O||""}),G=O==="api"||O==="S3"?"DuckDb":O,{messages:H,setMessages:B,reload:K,append:Y,input:_,status:Q,handleInputChange:A,handleSubmit:T,addToolResult:$,stop:V}=e.useChat({api:"https://semaphor.cloud/api/v1/assistant",headers:{Authorization:`Bearer ${u==null?void 0:u.accessToken}`},body:{random:Math.random()},maxSteps:10,async onToolCall({toolCall:w}){if(w.toolName==="getAiScopeTables")return c("Getting tables in scope..."),{status:"success",tables:N||[]};if(w.toolName==="createChart"){console.log("createChart",w.args);const M=w.args.sql,U=w.args.chartType;return y(U),p(M),h(!0),{status:"success",query:M}}if(w.toolName==="getTableColumns"&&c("Getting table columns..."),w.toolName==="getCurrentSchema")return c("Getting current table columns..."),{sqlDialect:G,tableName:q,columns:L}},onFinish(w,M){P(M.usage),c(""),console.log("onFinish",w,M),M.finishReason==="stop"&&c(""),w.content}});R.useEffect(()=>{n&&t&&(A({target:{value:t}}),setTimeout(()=>{T(),o(!1)},100))},[n,T,t,o,A]),R.useEffect(()=>{const w=setTimeout(()=>{var M;a.current&&(a.current.scroll({top:a.current.scrollHeight,behavior:"auto"}),(M=i.current)==null||M.focus())},50);return()=>clearTimeout(w)},[H,s]);function P(w){z(M=>M?{promptTokens:M.promptTokens+w.promptTokens,completionTokens:M.completionTokens+w.completionTokens,totalTokens:M.totalTokens+w.totalTokens}:w)}function J(){return l||(Q==="ready"?"":Q==="error"?"Error":Q==="streaming"?"Generating response...":"Thinking...")}const X=!["ready","error"].includes(Q),ne={p:({node:w,...M})=>e.jsxRuntimeExports.jsx("p",{className:"text-sm",...M}),code:({node:w,...M})=>e.jsxRuntimeExports.jsx("code",{className:"rounded-md bg-muted px-2 py-1 text-xs",...M}),pre:({node:w,...M})=>e.jsxRuntimeExports.jsxs("pre",{className:"my-2 space-y-2 rounded-md bg-muted/50 p-3",children:[e.jsxRuntimeExports.jsx("code",{className:"whitespace-normal text-xs",children:M.children}),e.jsxRuntimeExports.jsx("div",{className:"flex justify-between gap-2",children:e.jsxRuntimeExports.jsxs("div",{className:"flex gap-2",children:[e.jsxRuntimeExports.jsx(e.Button,{className:"h-8 p-2",onClick:Z,size:"sm",variant:"outline",children:e.jsxRuntimeExports.jsx(e.ClipboardCopyIcon,{})}),e.jsxRuntimeExports.jsx(e.Button,{className:"h-8 p-2",onClick:U=>{const v=Z(U);v&&(r(!1),p(v),h(!0))},size:"sm",variant:"outline",children:e.jsxRuntimeExports.jsx(e.PlayIcon,{})})]})})]}),li:({node:w,...M})=>e.jsxRuntimeExports.jsx("li",{className:"my-2 list-outside pl-4 text-sm",...M})};function Z(w){const M=w.currentTarget.closest("pre");if(!M)return;const U=M.textContent||M.innerText;return navigator.clipboard.writeText(U).then(()=>console.log("Text copied to clipboard")).catch(v=>console.error("Error in copying text: ",v)),U}function re(){return H==null?void 0:H.map((w,M)=>w.role==="user"?e.jsxRuntimeExports.jsxs("div",{className:"rounded-md bg-muted/50 p-3 text-sm",children:[e.jsxRuntimeExports.jsx(e.UserRound,{className:"float-left mr-2 size-4"}),e.jsxRuntimeExports.jsx("div",{children:w.content})]},M):g&&w.toolInvocations?w.toolInvocations.map((U,v)=>e.jsxRuntimeExports.jsxs(Ks,{children:[e.jsxRuntimeExports.jsxs(Ws,{className:"rounded-md bg-green-200 p-1 px-2 font-mono text-xs text-black",children:[e.jsxRuntimeExports.jsx("span",{className:"font-bold",children:"Tool:"})," ",U.toolName]}),e.jsxRuntimeExports.jsx(Xs,{className:"mt-2",children:e.jsxRuntimeExports.jsxs("pre",{className:"overflow-auto rounded-sm bg-muted/50 p-3 font-mono text-xs",children:[e.jsxRuntimeExports.jsx("span",{className:"font-bold",children:"Args:"})," ",JSON.stringify(U.args,null,2),e.jsxRuntimeExports.jsx("br",{}),e.jsxRuntimeExports.jsx("span",{className:"font-bold",children:"Result:"})," ",JSON.stringify(U.result,null,2)]})})]},v)):w.role==="assistant"?e.jsxRuntimeExports.jsx(e.Markdown,{components:ne,children:w.content.replace(/DuckDB/gi,"Semaphor")},M):e.jsxRuntimeExports.jsx("div",{},M))}return e.jsxRuntimeExports.jsxs(e.Dialog,{open:s,onOpenChange:r,children:[e.jsxRuntimeExports.jsx(e.DialogTrigger,{asChild:!0,children:e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>{(!N||(N==null?void 0:N.length)===0)&&j({connectionId:D||"",connectionType:O||"",databaseName:S||"",schemaName:F||"",tableName:C||"",datamodelName:k||""})},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,{"aria-describedby":"ai-dialog-description",className:"flex flex-col justify-between overflow-auto sm:max-w-[425px] md:max-h-[625px] md:min-w-[625px]",children:[e.jsxRuntimeExports.jsx(e.DialogHeader,{children:e.jsxRuntimeExports.jsxs("div",{className:"flex items-start justify-between gap-2 pr-5",children:[e.jsxRuntimeExports.jsxs("div",{children:[e.jsxRuntimeExports.jsx(e.DialogTitle,{children:"Assistant"}),N&&N.length>0&&e.jsxRuntimeExports.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-2",children:[e.jsxRuntimeExports.jsx("span",{className:"text-xs text-muted-foreground",children:"Tables in scope:"}),N==null?void 0:N.map((w,M)=>e.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-2 rounded-md bg-muted px-2 py-1 text-xs",children:[e.getFormattedTableNameForQuery({schemaName:w.schemaName||"",tableName:w.tableName||"",modelName:w.datamodelName||"",connectionType:w.connectionType||""}),e.jsxRuntimeExports.jsx("button",{onClick:()=>{d(w)},children:e.jsxRuntimeExports.jsx(e.X,{className:"size-3 text-muted-foreground hover:text-foreground"})})]},M))]}),(!N||(N==null?void 0:N.length)===0)&&e.jsxRuntimeExports.jsxs("div",{className:"mt-2 flex items-center gap-2",children:[e.jsxRuntimeExports.jsx("span",{className:"text-xs text-muted-foreground",children:"Tables in scope: None"}),e.jsxRuntimeExports.jsxs(e.Button,{className:"h-6 text-xs",size:"sm",variant:"secondary",onClick:()=>{j({connectionId:D||"",connectionType:O||"",databaseName:S||"",schemaName:F||"",tableName:C||"",datamodelName:k||""})},children:[e.jsxRuntimeExports.jsx(e.Plus,{className:"mr-2 size-3"}),"Current Table"]})]})]}),e.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxRuntimeExports.jsxs(e.DropdownMenu,{children:[e.jsxRuntimeExports.jsx(e.DropdownMenuTrigger,{children:e.jsxRuntimeExports.jsx(Re,{className:"h-4 w-4 text-muted-foreground"})}),e.jsxRuntimeExports.jsxs(e.DropdownMenuContent,{align:"end",children:[e.jsxRuntimeExports.jsx(e.DropdownMenuLabel,{children:"Options"}),e.jsxRuntimeExports.jsx(e.DropdownMenuSeparator,{}),e.jsxRuntimeExports.jsx(e.DropdownMenuCheckboxItem,{checked:m,onCheckedChange:f,children:m?"Hide Usage":"Show Usage"}),e.jsxRuntimeExports.jsx(e.DropdownMenuCheckboxItem,{checked:g,onCheckedChange:x,children:g?"Hide Tools":"Show Tools"})]})]}),e.jsxRuntimeExports.jsx(e.Button,{className:"h-8",size:"sm",variant:"outline",onClick:()=>{B([]),K()},children:"Clear"})]})]})}),e.jsxRuntimeExports.jsx("div",{ref:a,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:re()})}),e.jsxRuntimeExports.jsx("div",{className:"text-xs text-muted-foreground",children:J()}),e.jsxRuntimeExports.jsxs("form",{onSubmit:T,className:"flex w-full items-center rounded-md border",children:[e.jsxRuntimeExports.jsx(e.Input,{autoFocus:!0,ref:i,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:X,value:_,onChange:A}),e.jsxRuntimeExports.jsxs("div",{className:"mr-3 flex items-center gap-2",children:[e.jsxRuntimeExports.jsx("button",{onClick:T,disabled:X,children:X?e.jsxRuntimeExports.jsx(ae,{className:"mr-2 h-4 w-4 animate-spin text-foreground/50"}):e.jsxRuntimeExports.jsx(e.PaperPlaneIcon,{className:"h-4 w-4 text-muted-foreground hover:text-foreground"})}),X&&e.jsxRuntimeExports.jsx("button",{onClick:V,disabled:!X,children:e.jsxRuntimeExports.jsx(e.X,{className:"h-4 w-4 text-muted-foreground hover:text-foreground"})})]})]}),E&&m&&e.jsxRuntimeExports.jsx("div",{className:"flex h-8 items-center justify-between",children:e.jsxRuntimeExports.jsxs("div",{className:"text-xs text-muted-foreground",children:["Usage: ",E.promptTokens," prompt tokens,"," ",E.completionTokens," completion tokens,"," ",E.totalTokens," total tokens"]})})]})]})}var Rs={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},_e=R.createContext&&R.createContext(Rs),Zs=["attr","size","title"];function et(s,r){if(s==null)return{};var t=st(s,r),n,o;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(s);for(o=0;o<i.length;o++)n=i[o],!(r.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(s,n)&&(t[n]=s[n])}return t}function st(s,r){if(s==null)return{};var t={};for(var n in s)if(Object.prototype.hasOwnProperty.call(s,n)){if(r.indexOf(n)>=0)continue;t[n]=s[n]}return t}function he(){return he=Object.assign?Object.assign.bind():function(s){for(var r=1;r<arguments.length;r++){var t=arguments[r];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(s[n]=t[n])}return s},he.apply(this,arguments)}function Be(s,r){var t=Object.keys(s);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(s);r&&(n=n.filter(function(o){return Object.getOwnPropertyDescriptor(s,o).enumerable})),t.push.apply(t,n)}return t}function Ee(s){for(var r=1;r<arguments.length;r++){var t=arguments[r]!=null?arguments[r]:{};r%2?Be(Object(t),!0).forEach(function(n){tt(s,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(s,Object.getOwnPropertyDescriptors(t)):Be(Object(t)).forEach(function(n){Object.defineProperty(s,n,Object.getOwnPropertyDescriptor(t,n))})}return s}function tt(s,r,t){return r=nt(r),r in s?Object.defineProperty(s,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):s[r]=t,s}function nt(s){var r=rt(s,"string");return typeof r=="symbol"?r:r+""}function rt(s,r){if(typeof s!="object"||!s)return s;var t=s[Symbol.toPrimitive];if(t!==void 0){var n=t.call(s,r||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(s)}function bs(s){return s&&s.map((r,t)=>R.createElement(r.tag,Ee({key:t},r.attr),bs(r.child)))}function te(s){return r=>R.createElement(ot,he({attr:Ee({},s.attr)},r),bs(s.child))}function ot(s){var r=t=>{var{attr:n,size:o,title:i}=s,a=et(s,Zs),l=o||t.size||"1em",c;return t.className&&(c=t.className),s.className&&(c=(c?c+" ":"")+s.className),R.createElement("svg",he({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},t.attr,n,a,{className:c,style:Ee(Ee({color:s.color||t.color},t.style),s.style),height:l,width:l,xmlns:"http://www.w3.org/2000/svg"}),i&&R.createElement("title",null,i),s.children)};return _e!==void 0?R.createElement(_e.Consumer,null,t=>r(t)):r(Rs)}function it(s){return te({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 at({sql:s}){return e.jsxRuntimeExports.jsxs(e.HoverCard,{children:[e.jsxRuntimeExports.jsx(e.HoverCardTrigger,{asChild:!0,children:e.jsxRuntimeExports.jsx(e.Button,{variant:"link",className:"h-5 p-0",children:e.jsxRuntimeExports.jsx(e.Info,{className:"h-4 w-4 text-muted-foreground"})})}),e.jsxRuntimeExports.jsx(e.HoverCardContent,{align:"end",className:"w-full min-w-fit max-w-[700px] p-3 pt-2",children:e.jsxRuntimeExports.jsxs("div",{className:"space-y-2",children:[e.jsxRuntimeExports.jsx(e.Label,{className:"text-xs font-semibold",children:"Resolved Query"}),e.jsxRuntimeExports.jsx("div",{className:"flex grow flex-col space-y-2",children:e.jsxRuntimeExports.jsx(e.ScrollArea,{className:"max-h-[250px] min-h-0 overflow-scroll",children:e.jsxRuntimeExports.jsx("p",{className:"overflow-auto rounded-md bg-muted p-2 font-mono text-xs leading-relaxed",children:s})})})]})})]})}function vs(s){const{theme:r}=e.useTheme(),t=e.useDashboardStore(h=>h.theme),n=e.useEditorStore(h=>h.frame),o=e.useEditorStore(h=>h.card),i=e.useEditorStore(h=>h.activeTabCardId),a=e.Le(),{refetch:l}=e.useDashboardCardQuery(o),{updateCardTab:c,setRunSql:u}=e.useEditorActions(),m=R.useRef(),f=R.useRef({}),g=n.cards.find(h=>h.id===i),x=R.useCallback(()=>{let h="";return s==="python"&&(h=(g==null?void 0:g.python)||e.PYTHON_DEFAULT_CODE),s==="sql"&&(h=(g==null?void 0:g.sql)||""),h},[s,g]);R.useEffect(()=>{if(i&&o.id&&o.id!==i){if(m.current&&a){const h=m.current.getModel();h&&(f.current[o.id]=h);let y=f.current[i];if(!y){const E=x();y=a.editor.createModel(E,s),f.current[i]=y}m.current.setModel(y)}c(i,o),u(!0)}},[i,o,c,a,u,s,x]),R.useEffect(()=>{if(!a)return;const h=window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light",y=t==="system"?h:t;a.editor.defineTheme("default",{base:y==="light"?"vs":"vs-dark",inherit:!0,rules:[],colors:{"editor.background":y==="light"?"#ffffff":e.hslStringToHex("240 10% 10%")}}),a.editor.setTheme("default")},[r,t,a]),R.useEffect(()=>{const h=m.current;h&&a&&o&&h.addCommand(a.KeyMod.Shift|a.KeyCode.Enter,function(){return l(),!1})},[a,l,o]);function p(h,y){if(m.current=h,!f.current[o.id]){const E=h.getModel(),z=x();f.current[o.id]=E||(y==null?void 0:y.editor.createModel(z,s))||h.getModel()}h.setModel(f.current[o.id])}return{handleEditorDidMount:p}}function lt(){const s=e.useEditorStore(a=>a.card.sql),r=e.useEditorStore(a=>a.sqlGen),{setCardSql:t,setSqlGen:n}=e.useEditorActions(),{handleEditorDidMount:o}=vs("sql");function i(a){t(a),e.isObjectEmpty(r)||n({})}return e.jsxRuntimeExports.jsx(e.Ft,{theme:"default",className:"pt-3",onChange:i,value:s||"",options:{minimap:{enabled:!1},wordWrap:"on",scrollbar:{verticalScrollbarSize:0,horizontalScrollbarSize:0},fontSize:13,renderLineHighlight:"none"},defaultLanguage:"sql",onMount:o})}function ct(){const s=e.useEditorStore(o=>o.card.python),{setCardPython:r}=e.useEditorActions(),{handleEditorDidMount:t}=vs("python");function n(o){r(o)}return e.jsxRuntimeExports.jsx(e.Ft,{className:"pt-3",theme:"default",onChange:n,value:s||e.PYTHON_DEFAULT_CODE,options:{minimap:{enabled:!1},wordWrap:"on",scrollbar:{verticalScrollbarSize:0,horizontalScrollbarSize:0},fontSize:13,renderLineHighlight:"none"},defaultLanguage:"python",onMount:t})}function xt(){const s=e.useDashboardStore(i=>i.dashboard.filters),r=e.useDashboardStore(i=>i.filterValues),t=e.useDashboardStore(i=>i.selectedSheetId),n=s==null?void 0:s.filter(i=>i.sheetId===t||!i.sheetId),o=r==null?void 0:r.filter(i=>(n==null?void 0:n.some(a=>a.id===i.filterId))||i.filterId.endsWith(t));return e.jsxRuntimeExports.jsx(e.Ft,{theme:"default",defaultLanguage:"json",className:"mt-1 min-h-[220px]",value:JSON.stringify(o,null,2),options:{readOnly:!0,minimap:{enabled:!1},lineNumbers:"off",glyphMargin:!1,wordWrap:"on",scrollbar:{verticalScrollbarSize:0,horizontalScrollbarSize:0},fontSize:12,renderLineHighlight:"none"}})}function ut(){var U;const[s,r]=R.useState({queryKey:[],queryData:null}),t=e.useQueryClient(),[n,o]=R.useState(!1),[i,a]=R.useState(!1),[l,c]=R.useState(!1),[u,m]=R.useState(""),[f,g]=R.useState(!1),x=e.useEditorStore(v=>v.frame),p=e.useEditorStore(v=>v.card),h=e.useEditorStore(v=>v.isShowingVisual),y=e.useEditorStore(v=>v.selectedConnectionId),E=e.useEditorStore(v=>v.selectedDatabaseName),z=e.useEditorStore(v=>v.selectedDatamodelId),L=e.useEditorStore(v=>v.selectedSchemaName),S=e.useEditorStore(v=>v.selectedTableName),C=e.useEditorStore(v=>{var W;return(W=v==null?void 0:v.card)==null?void 0:W.sql}),D=e.useEditorStore(v=>v.applyFilters),{setCardCustomCfg:F,setQueryResultColumns:N,setCardSql:d,setPythonStdOut:j,setCardPreferences:k,setCardType:I}=e.useEditorActions(),O=e.useEditorStore(v=>v.onSave),q=e.useEditorStore(v=>v.onClose),G=e.useEditorStore(v=>v.actions.setSqlGen),H=e.useEditorStore(v=>v.runSql),B=e.useEditorStore(v=>v.actions.setRunSql),K=e.useEditorStore(v=>v.actions.setCardCfg),Y=e.useEditorStore(v=>v.actions.setIsSqlRunning),{data:_,isLoading:Q,isFetching:A,isSuccess:T,isError:$,error:V,queryKey:P,refetch:J}=e.useDashboardCardQuery(p);R.useEffect(()=>{if(_&&(_.rowLimitExceeded&&e.ce.error("Row limit (10,000) exceeded. Refine your query.",{position:"top-center",richColors:!0}),j((_==null?void 0:_.output)||""),_.records.length>0)){const{dimensionKeys:v}=e.getKeys(_.records);N(v)}},[_,N,j]),R.useEffect(()=>{(Q||A)&&Y(!0),($||T)&&Y(!1),$&&(N([]),j(""))},[Q,A,_,j,$,T,Y,N,V]),R.useEffect(()=>{H&&(t.getQueryData(P)||J(),B(!1))},[H,J,B,P,t]);function X(){const v=t.getQueryData(P);s.queryData||r({queryKey:P,queryData:v}),t.setQueryData(P,null),t.removeQueries({queryKey:P,exact:!0}),d(""),G({}),K(void 0),F(""),k({}),I("bar")}function ne(v,W){if(v.length===0)return"";if(W){const ie=v.find(ee=>ee.id===W);if(ie){const ee=ie.tabTitle;if(ee=="All__Header")return v[0].id;if(ee&&ee.endsWith("__Header")){const ye=ee.split("__")[0],me=v.find(Se=>Se.tabTitle===ye);return me?me.id:v[0].id}return W}}return v[0].id}function Z(){let v=C;C&&!C.includes("{{")&&(v=$s(C),d(v));const W={...p,lastSelectedSchema:L,lastSelectedDatamodelId:z,lastSelectedDatabase:E,lastSelectedTable:S,connectionId:y,type:h?p.type:"table",sql:v,customCfg:h?p.customCfg:null},ie=x.cards.map(ue=>ue.id===p.id?W:ue),ee={...x,cards:ie,activeCardId:ne(ie,x.activeCardId)};O==null||O(ee)}function re(){const{queryKey:v,queryData:W}=s;v&&W&&t.setQueryData(v,W),G({}),q==null||q()}function w(){return e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[i&&e.jsxRuntimeExports.jsx("div",{className:"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(e.Label,{className:"ml-6 text-xs font-semibold",children:"Filters"}),i&&e.jsxRuntimeExports.jsx(e.Cross2Icon,{onClick:()=>a(!1),className:"bg-background/50 text-foreground/50 hover:cursor-pointer hover:text-foreground"})]}),e.jsxRuntimeExports.jsx(xt,{})]})}),!i&&e.jsxRuntimeExports.jsx(e.Filter,{onClick:()=>a(!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":D})})]})}function M(){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:n?20:100,className:"relative flex grow",children:[e.jsxRuntimeExports.jsx("div",{id:"sql-container",className:"relative flex w-[99%]",children:e.jsxRuntimeExports.jsx(lt,{})}),n&&e.jsxRuntimeExports.jsx("code",{className:"absolute right-6 top-3 text-xs text-muted-foreground/70",children:"sql"})]}),n&&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",{id:"python-container",className:"relative flex w-[99%] pt-0",children:e.jsxRuntimeExports.jsx(ct,{})}),e.jsxRuntimeExports.jsx("code",{className:"absolute right-6 top-3 text-xs 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",{className:"relative flex grow justify-between overflow-y-scroll",children:[M(),w()]}),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||A,onClick:()=>{J()},className:"shrink-0",size:"sm",variant:"outline",children:[Q||A?e.jsxRuntimeExports.jsx(ae,{className:"mr-2 h-4 w-4 animate-spin text-foreground/50"}):e.jsxRuntimeExports.jsx(ls,{className:"mr-2 h-4 w-4"}),"Run"]}),($||(_==null?void 0:_.error))&&e.jsxRuntimeExports.jsx(Js,{error:(V==null?void 0:V.message)||((U=_==null?void 0:_.error)==null?void 0:U.message),setShowAIDialog:c,setTriggerAIRun:g,setUserInputforAI:m}),e.jsxRuntimeExports.jsxs(e.Button,{onClick:X,className:"",size:"sm",variant:"outline",children:[e.jsxRuntimeExports.jsx(Xe,{className:"mr-2 size-4"}),"Clear"]}),e.jsxRuntimeExports.jsx(e.Toggle,{pressed:n,onPressedChange:v=>o(v),className:"",size:"sm",variant:"outline",children:e.jsxRuntimeExports.jsx(it,{className:"size-4 text-foreground/70"})}),e.jsxRuntimeExports.jsx(Ys,{open:l,setOpen:c,userInput:u,triggerAIRun:f,setTriggerAIRun:g})]}),e.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-2",children:[(_==null?void 0:_.sql)&&e.jsxRuntimeExports.jsx(at,{sql:_.sql}),e.jsxRuntimeExports.jsxs(e.Button,{onClick:re,className:"w-full",size:"sm",variant:"outline",children:[e.jsxRuntimeExports.jsx(e.Cross2Icon,{className:"mr-2 size-4"}),"Close"]}),e.jsxRuntimeExports.jsxs(e.Button,{onClick:Z,size:"sm",variant:"outline",children:[e.jsxRuntimeExports.jsx(e.Check,{className:"mr-2 size-4 font-bold text-green-600"}),"Accept"]})]})]})]})}function dt({data:s}){var a;const[r,t]=R.useState([]),o=Object.keys(s[0]).map(l=>({accessorKey:l,header:({column:c})=>{const u=c.getIsSorted();return e.jsxRuntimeExports.jsx("div",{className:"flex gap-2",children:e.jsxRuntimeExports.jsxs("div",{className:"flex cursor-pointer items-center",onClick:()=>c.toggleSorting(c.getIsSorted()==="asc"),children:[l,u==="asc"?e.jsxRuntimeExports.jsx(e.TriangleUpIcon,{className:"ml-2 h-5 w-5"}):u==="desc"?e.jsxRuntimeExports.jsx(e.TriangleDownIcon,{className:"ml-2 h-5 w-5"}):null]})})}})),i=e.useReactTable({data:s,columns:o,getCoreRowModel:e.getCoreRowModel(),getPaginationRowModel:e.getPaginationRowModel(),onSortingChange:t,getSortedRowModel:e.getSortedRowModel(),manualPagination:!0,state:{sorting:r}});return e.jsxRuntimeExports.jsx("div",{className:"font-mono text-xs text-foreground/95",children:e.jsxRuntimeExports.jsxs("table",{className:"w-full",children:[e.jsxRuntimeExports.jsx(e.TableHeader,{children:i.getHeaderGroups().map(l=>e.jsxRuntimeExports.jsx(e.TableRow,{children:l.headers.map(c=>e.jsxRuntimeExports.jsx(e.TableHead,{className:"sticky top-0 h-11 bg-muted font-semibold",children:c.isPlaceholder?null:e.flexRender(c.column.columnDef.header,c.getContext())},c.id))},l.id))}),e.jsxRuntimeExports.jsx(e.TableBody,{children:(a=i.getRowModel().rows)!=null&&a.length?i.getRowModel().rows.map(l=>e.jsxRuntimeExports.jsx(e.TableRow,{className:"whitespace-nowrap py-2","data-state":l.getIsSelected()&&"selected",children:l.getVisibleCells().map(c=>e.jsxRuntimeExports.jsx(e.TableCell,{className:"py-3",children:e.flexRender(c.column.columnDef.cell,c.getContext())},c.id))},l.id)):e.jsxRuntimeExports.jsx(e.TableRow,{children:e.jsxRuntimeExports.jsx(e.TableCell,{colSpan:o.length,className:"h-24 text-center",children:"No results."})})})]})})}function mt({card:s}){var E,z,L,S,C,D,F,N,d,j,k;const[r,t]=R.useState(!1),[n,o]=R.useState([]),{authToken:i}=e.useSemaphorContext(),a=e.getTokenParams(i==null?void 0:i.accessToken),l=e.useDashboardStore(I=>I.themeStyle),c={colors:((z=(E=l==null?void 0:l.chart)==null?void 0:E.dataset)==null?void 0:z.backgroundColor)||[]};(L=s.customCardPreferences)!=null&&L.inputData;const{getCard:u}=e.useCustomVisual(((S=s.customCardPreferences)==null?void 0:S.url)||""),m=((C=s.customCardPreferences)==null?void 0:C.visualType)||"single",f=e.useEditorStore(I=>I.frame);e.useEditorActions();const{data:g}=e.useDashboardCardQuery(s),x=R.useCallback((I,O)=>{o(q=>({...q,[I]:O}))},[]);if(!((D=s.customCardPreferences)!=null&&D.componentName))return null;const p=u((F=s.customCardPreferences)==null?void 0:F.componentName);function h(I){t(I)}const y=Object.keys(((N=s.customCardPreferences)==null?void 0:N.dataInputCardIds)||{}).map(I=>{var G,H,B;const O=(H=(G=s.customCardPreferences)==null?void 0:G.dataInputCardIds)==null?void 0:H[I].cardId,q=(B=f==null?void 0:f.cards)==null?void 0:B.find(K=>K.id===O);return q||null});return e.jsxRuntimeExports.jsx("div",{className:"semaphor-custom mb-3 flex grow basis-0 flex-col space-y-2 overflow-y-auto",children:e.jsxRuntimeExports.jsxs(R.Suspense,{fallback:e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{}),children:[p&&m==="single"&&e.jsxRuntimeExports.jsx(p,{params:a,theme:c,settings:(d=s.customCardPreferences)==null?void 0:d.settings,onDataChange:x,data:(g==null?void 0:g.records)||[]}),p&&m==="multiple"&&e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[Object.keys(((j=s.customCardPreferences)==null?void 0:j.dataInputCardIds)||{}).map(I=>{var G,H,B;const O=(H=(G=s.customCardPreferences)==null?void 0:G.dataInputCardIds)==null?void 0:H[I].cardId,q=(B=f==null?void 0:f.cards)==null?void 0:B.find(K=>K.id===O);if(q)return e.jsxRuntimeExports.jsx(e.MultiInputEmptyRenderer,{onLoadingStatus:h,onDataChange:x,dataInputIndex:I,card:q},q.id+I)}),e.jsxRuntimeExports.jsx("div",{className:"flex flex-col gap-2",children:e.jsxRuntimeExports.jsx(p,{theme:c,onDataChange:x,settings:y.map(I=>{var O;return(O=I==null?void 0:I.customCardPreferences)==null?void 0:O.settings}),data:y.map(I=>I!=null&&I.id?n==null?void 0:n[I.id]:[])})})]})]},(k=s.customCardPreferences)==null?void 0:k.componentName)})}function ys({className:s,...r}){var y;const t=e.useEditorStore(E=>E.card),n=((y=t.customCardPreferences)==null?void 0:y.showCardHeader)??!0,o=e.useEditorStore(E=>E.frame),i=e.useDashboardStore(E=>E.dashboard.filters);e.useEditorStore(E=>E.actions.setRunSql);const{updateFilter:a}=e.useDashboardActions(),l=i==null?void 0:i.find(E=>E.id===o.filterId),{data:c,isLoading:u,isFetching:m}=e.useDashboardCardQuery(t),{setCard:f}=e.useEditorActions(),{data:g}=e.useTopoJson(t);if(!t.id)return null;let x;c!=null&&c.records&&(c==null?void 0:c.records.length)>0&&(x=e.createChartConfig({data:c==null?void 0:c.records,cardType:t.type,cfg:t.cfg,customCfg:t.customCfg,preferences:t.preferences,topoJson:g}));function p(E){return e.jsxRuntimeExports.jsx(mt,{card:E})}function h(){var E;if(c!=null&&c.records&&(c==null?void 0:c.records.length)===0&&!u&&!m)return e.jsxRuntimeExports.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-2",children:[e.jsxRuntimeExports.jsx(e.TreePalm,{className:"size-8 text-muted-foreground"}),e.jsxRuntimeExports.jsx("p",{className:"text-sm text-muted-foreground",children:"No records to display"})]});if(t.type==="custom")return p(t);if(!["table","custom"].includes(t.type)&&x)return e.jsxRuntimeExports.jsx(e.ChartJsVisual,{cfg:x},JSON.stringify(x)+JSON.stringify(t.preferences)+((E=t==null?void 0:t.preferences)==null?void 0:E.customVisualCode));if(t.type==="table"&&(c!=null&&c.records)&&(c==null?void 0:c.records.length)>0)return e.jsxRuntimeExports.jsxs(e.ScrollArea,{className:"relative mb-2 flex h-full min-h-0 w-full flex-1 grow basis-0",children:[e.jsxRuntimeExports.jsx(e.TableVisual,{card:t,data:c==null?void 0:c.records}),e.jsxRuntimeExports.jsx(e.ScrollBar,{orientation:"horizontal"})]})}return e.jsxRuntimeExports.jsxs(e.Card,{role:"editor-visual-card",className:e.cn("relative flex h-full flex-col rounded-none",s),...r,children:[n&&e.jsxRuntimeExports.jsxs(e.CardHeader,{className:"flex flex-row items-start justify-between py-4",children:[e.jsxRuntimeExports.jsxs("div",{children:[e.jsxRuntimeExports.jsx(e.Editable,{text:t.title,onSave:E=>f({...t,title:E}),children:e.jsxRuntimeExports.jsx("div",{className:"flex items-center gap-5",children:e.jsxRuntimeExports.jsx(e.CardTitle,{className:"text-base",children:t.title||"Edit title..."})})},t.title),e.jsxRuntimeExports.jsx(e.Editable,{text:t.description||"",onSave:E=>f({...t,description:E}),children:e.jsxRuntimeExports.jsx(e.CardDescription,{children:t.description||"Edit description..."})},t.description)]}),l&&e.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxRuntimeExports.jsx(e.Editable,{className:"my-1",text:l.title||l.column,onSave:E=>a({...l,title:E}),children:e.jsxRuntimeExports.jsx(e.Label,{children:l.title})}),e.jsxRuntimeExports.jsx(e.FilterComponent,{filter:l})]})]}),e.jsxRuntimeExports.jsx(e.CardContent,{className:"flex grow flex-col",children:h()})]})}const He=({language:s,value:r,onChange:t})=>e.jsxRuntimeExports.jsx(e.Ft,{className:"h-full w-full overflow-hidden text-xs",theme:"default",options:{minimap:{enabled:!1},wordWrap:"on",scrollbar:{verticalScrollbarSize:0,horizontalScrollbarSize:0},fontSize:12,lineHeight:16,renderLineHighlight:"none"},defaultLanguage:s,value:r,onChange:t}),pt=()=>e.jsxRuntimeExports.jsxs(e.DialogHeader,{children:[e.jsxRuntimeExports.jsx("div",{className:"flex items-center gap-2",children:e.jsxRuntimeExports.jsx(e.DialogTitle,{children:"Customize Card"})}),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."})]})]}),jt=({defaultConfig:s,customCode:r,customConfig:t,onConfigChange:n,onCodeChange:o})=>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.jsx(e.TabsTrigger,{value:"custom-config",children:t?"Custom Config":"Default Config"}),e.jsxRuntimeExports.jsx(e.TabsTrigger,{value:"output",children:"Output"}),e.jsxRuntimeExports.jsx(e.TabsTrigger,{value:"custom-code",children:"Custom Code"})]}),e.jsxRuntimeExports.jsx(e.TabsContent,{value:"output",className:"mt-0 grow rounded-b border border-t-0 p-2",children:e.jsxRuntimeExports.jsx(e.Textarea,{readOnly:!0,value:s,className:"h-full resize-none border-none font-mono focus-visible:ring-0"})}),e.jsxRuntimeExports.jsx(e.TabsContent,{value:"custom-config",className:"mt-0 grow rounded-b border border-t-0",children:e.jsxRuntimeExports.jsx(He,{language:"json",value:t,onChange:n})}),e.jsxRuntimeExports.jsx(e.TabsContent,{value:"custom-code",className:"mt-0 grow rounded-b border border-t-0",children:e.jsxRuntimeExports.jsx(He,{language:"javascript",value:r,onChange:o})})]}),ht=({error:s,hasCustomConfig:r,onReset:t,onApply:n,onClose:o})=>e.jsxRuntimeExports.jsxs(e.DialogFooter,{className:"flex items-center",children:[e.jsxRuntimeExports.jsx(e.Label,{className:"mr-2 text-red-500",children:s}),e.jsxRuntimeExports.jsx(e.Button,{disabled:!r,onClick:t,variant:"outline",children:"Reset"}),e.jsxRuntimeExports.jsx(e.Button,{onClick:n,variant:"outline",children:"Apply"}),e.jsxRuntimeExports.jsx(e.Button,{onClick:o,variant:"outline",children:"Close"})]});function Et(){const[s,r]=R.useState(!1),[t,n]=R.useState(""),[o,i]=R.useState(""),[a,l]=R.useState(""),[c,u]=R.useState(""),m=e.useEditorStore(S=>S.card),f=e.useEditorStore(S=>S.card.customCfg),{data:g}=e.useDashboardCardQuery(m),{data:x}=e.useTopoJson(m),{setCardCustomCfg:p,setCustomVisualCode:h}=e.useEditorActions(),y=(S,C)=>e._.transform(S,(D,F,N)=>{if(!e._.isEqual(F,C[N]))if(e._.isArray(F)&&e._.isArray(C[N]))D[N]=C[N];else if(e._.isObject(F)&&e._.isObject(C[N])){const d=y(F,C[N]);e._.isEmpty(d)||(D[N]=d)}else D[N]=C[N]}),E=S=>{var C,D;return JSON.stringify({...S,data:{...S.data,datasets:(D=(C=S.data)==null?void 0:C.datasets)==null?void 0:D.map(F=>({...F,data:[]}))}},null,2)},z=()=>{var C,D;if(!((C=g==null?void 0:g.records)!=null&&C.length))return;const S=e.createChartConfig({data:g.records,cardType:m.type,cfg:m.cfg,preferences:m.preferences,topoJson:x});if(S){n(E(S)),l(((D=m.preferences)==null?void 0:D.customVisualCode)||"");const F=e._.merge(S,f);i(E(F))}},L=()=>{try{if(a&&h(a),o){const S=JSON.parse(o),C=y(JSON.parse(t),S);p(C),u("")}}catch{u("Invalid JSON configuration")}};return e.jsxRuntimeExports.jsxs(e.Dialog,{open:s,onOpenChange:r,children:[e.jsxRuntimeExports.jsx(e.DialogTrigger,{asChild:!0,children:e.jsxRuntimeExports.jsx(e.Button,{onClick:z,size:"sm",variant:"outline",className:f?"border-foreground/50 dark:border-foreground/70":"",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.jsx(pt,{}),e.jsxRuntimeExports.jsxs("div",{className:"flex grow gap-2",children:[e.jsxRuntimeExports.jsx(e.ErrorBoundary,{FallbackComponent:e.FallbackEditorCard,children:e.jsxRuntimeExports.jsx(ys,{className:"w-1/2 rounded shadow-none"})}),e.jsxRuntimeExports.jsx(jt,{defaultConfig:t,customCode:a,customConfig:o,onConfigChange:S=>i(S??""),onCodeChange:S=>l(S??"")})]}),e.jsxRuntimeExports.jsx(ht,{error:c,hasCustomConfig:!!f,onReset:()=>{i(t),p(null)},onApply:L,onClose:()=>r(!1)})]})]})}function Ss(s){return te({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 Cs(s){return te({tag:"svg",attr:{viewBox:"0 0 256 256",fill:"currentColor"},child:[{tag:"path",attr:{d:"M128,24a8,8,0,0,0-8,8V88a8,8,0,0,0,8,8,32,32,0,1,1-27.72,16,8,8,0,0,0-2.93-10.93l-48.5-28A8,8,0,0,0,37.92,76,104,104,0,1,0,128,24ZM48.09,91.1,83,111.26A48.09,48.09,0,0,0,80,128c0,1.53.08,3,.22,4.52L41.28,143A88.16,88.16,0,0,1,48.09,91.1Zm-2.67,67.31,39-10.44A48.1,48.1,0,0,0,120,175.32v40.31A88.2,88.2,0,0,1,45.42,158.41ZM136,215.63V175.32a48,48,0,0,0,0-94.65V40.36a88,88,0,0,1,0,175.27Z"},child:[]}]})(s)}function Ns(s){return te({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 ws(s){return te({tag:"svg",attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},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 ks(s){return te({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 Is(s){return te({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 Ds(s){return te({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 Ts(s){return te({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 Ls(s){const[r,t]=R.useState(null);return R.useEffect(()=>{s&&(async()=>{const i=(await Promise.resolve().then(()=>require("./lucide-react-C8dhM7am.js")))[s];t(i)})()},[s]),r}function As(){const{authToken:s}=e.useSemaphorContext(),{data:r,isLoading:t,isFetching:n,isError:o}=e.useQuery({queryKey:["plugins",s==null?void 0:s.accessToken],queryFn:()=>e.getPlugins(s==null?void 0:s.accessToken)});return{data:r,isLoading:t,isFetching:n,isError:o}}function ft({onChartTypeChange:s}){const[r,t]=R.useState([]),{data:n}=As();return R.useEffect(()=>{(async()=>{var i;if(n){const l=(await Promise.all((i=n==null?void 0:n.plugins)==null?void 0:i.map(async c=>(await e.loadManifest(c.value)).visuals.map(f=>({name:f.name,icon:f.icon,url:c.value}))))).flat();t(l)}})()},[n]),r.length===0?null:e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx(e.Separator,{className:"my-2"}),e.jsxRuntimeExports.jsx("div",{className:"grid grid-cols-4 place-items-center",children:r.map((o,i)=>e.jsxRuntimeExports.jsx(gt,{text:o.name,onClick:()=>s("custom",o),icon:o.icon},o.url+o.name+i))})]})}const gt=({text:s,icon:r,onClick:t})=>{const n=Ls(r||""),o=s.charAt(0).toUpperCase();return e.jsxRuntimeExports.jsx(e.Button,{onClick:t,title:s,variant:"ghost",children:n?e.jsxRuntimeExports.jsx(n,{className:"h-4 w-4"}):o})};function Rt(){var m,f;const[s,r]=R.useState(!1),t=e.useEditorStore(g=>g.card),n=t.type,{setCardType:o,setCardPreferences:i,setChartOrientation:a}=e.useEditorStore(g=>g.actions),{setCardCustomCfg:l,setCustomCardPreferences:c}=e.useEditorActions();function u(g,x){l(null),i({}),o(g),x&&c({type:"component",visualType:"single",url:x.url,componentName:x.name,icon:x.icon}),r(!1)}return e.jsxRuntimeExports.jsxs(e.Popover,{open:s,onOpenChange:r,children:[e.jsxRuntimeExports.jsx(e.PopoverTrigger,{asChild:!0,children:e.jsxRuntimeExports.jsx(e.Button,{size:"sm",variant:"outline",children:e.jsxRuntimeExports.jsx(bt,{className:"h-4 w-4",chartType:n,customIcon:(m=t.customCardPreferences)==null?void 0:m.icon,componentName:(f=t.customCardPreferences)==null?void 0:f.componentName})})}),e.jsxRuntimeExports.jsxs(e.PopoverContent,{className:"w-50",children:[e.jsxRuntimeExports.jsxs("div",{className:"grid grid-cols-4 place-items-center",children:[e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>u("bar"),className:"font-normal",variant:"ghost",children:e.jsxRuntimeExports.jsx(fe,{className:"size-5"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>u("line"),variant:"ghost",children:e.jsxRuntimeExports.jsx(ge,{className:"size-5"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>u("stackedBar"),variant:"ghost",children:e.jsxRuntimeExports.jsx(Is,{className:"size-5",strokeWidth:0})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>u("stackedLine"),variant:"ghost",children:e.jsxRuntimeExports.jsx(ks,{className:"size-5",strokeWidth:0})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>u("scatter"),variant:"ghost",children:e.jsxRuntimeExports.jsx(ke,{className:"size-5"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>u("bubble"),variant:"ghost",children:e.jsxRuntimeExports.jsx(ws,{className:"size-4"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>u("pie"),variant:"ghost",children:e.jsxRuntimeExports.jsx(we,{className:"size-5"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>u("doughnut"),variant:"ghost",children:e.jsxRuntimeExports.jsx(Cs,{className:"size-5",strokeWidth:1})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>u("radar"),variant:"ghost",children:e.jsxRuntimeExports.jsx(Ss,{className:"size-5 font-extralight",strokeWidth:.5})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>u("polarArea"),variant:"ghost",children:e.jsxRuntimeExports.jsx(Ns,{className:"size-5"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>u("pyramid"),variant:"ghost",children:e.jsxRuntimeExports.jsx(Ts,{className:"size-5"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>u("range"),variant:"ghost",children:e.jsxRuntimeExports.jsx(Ne,{className:"size-5"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>u("table"),variant:"ghost",children:e.jsxRuntimeExports.jsx(e.Table,{className:"size-5"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>u("kpi"),variant:"ghost",children:e.jsxRuntimeExports.jsx(Ds,{className:"size-6"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>u("text"),variant:"ghost",children:e.jsxRuntimeExports.jsx(be,{className:"size-4"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>u("map"),variant:"ghost",children:e.jsxRuntimeExports.jsx(Ie,{className:"size-4"})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>u("custom"),variant:"ghost",children:e.jsxRuntimeExports.jsx(De,{className:"size-4"})})]}),e.jsxRuntimeExports.jsx(ft,{onChartTypeChange:u})]})]})}function bt({chartType:s,className:r,customIcon:t,componentName:n}){const o=Ls(t||"");switch(s){case"bar":return e.jsxRuntimeExports.jsx(fe,{className:r});case"line":return e.jsxRuntimeExports.jsx(ge,{className:r});case"pie":return e.jsxRuntimeExports.jsx(we,{className:r});case"radar":return e.jsxRuntimeExports.jsx(Ss,{className:r});case"scatter":return e.jsxRuntimeExports.jsx(ke,{className:r});case"bubble":return e.jsxRuntimeExports.jsx(ws,{className:r});case"doughnut":return e.jsxRuntimeExports.jsx(Cs,{className:r});case"stackedBar":return e.jsxRuntimeExports.jsx(Is,{className:"size-4 text-foreground/70"});case"stackedLine":return e.jsxRuntimeExports.jsx(ks,{className:"size-4 text-foreground/70"});case"polarArea":return e.jsxRuntimeExports.jsx(Ns,{className:r});case"pyramid":return e.jsxRuntimeExports.jsx(Ts,{className:r});case"range":return e.jsxRuntimeExports.jsx(Ne,{className:r});case"kpi":return e.jsxRuntimeExports.jsx(Ds,{className:r});case"text":return e.jsxRuntimeExports.jsx(be,{className:r});case"map":return e.jsxRuntimeExports.jsx(Ie,{className:r});case"custom":return t&&o?e.jsxRuntimeExports.jsx(o,{className:r}):n?n==null?void 0:n.charAt(0).toUpperCase():e.jsxRuntimeExports.jsx(De,{className:r});default:return e.jsxRuntimeExports.jsx(e.Table,{className:r})}}function vt(){var r;const s=e.useEditorStore(t=>t.card);return(r=s.customCardPreferences)==null||r.showCardHeader,e.useEditorActions(),e.jsxRuntimeExports.jsxs(e.DropdownMenu,{children:[e.jsxRuntimeExports.jsx(e.DropdownMenuTrigger,{asChild:!0,children:e.jsxRuntimeExports.jsx(Re,{className:"size-4 cursor-pointer text-muted-foreground/70 transition-colors hover:text-muted-foreground"})}),e.jsxRuntimeExports.jsx(e.DropdownMenuContent,{align:"start",className:"w-40 text-muted-foreground",children:e.jsxRuntimeExports.jsxs(e.DropdownMenuItem,{onClick:()=>{navigator.clipboard.writeText(s.id),e.ce.success("Card ID copied to clipboard")},className:"cursor-pointer space-x-2",children:[e.jsxRuntimeExports.jsx(e.IdCard,{className:"size-5"}),e.jsxRuntimeExports.jsx("span",{children:"Copy Card ID"})]})})]})}function Pe(){var N;const s=e.useEditorStore(d=>d.frame),r=e.useEditorStore(d=>d.card),t=e.useEditorStore(d=>d.isShowingVisual),n=e.useEditorStore(d=>d.isSqlRunning),o=e.useEditorStore(d=>d.pythonStdOut);e.useEditorStore(d=>d.actions.setRunSql);const{setFrame:i,setCard:a,updateCardInFrame:l,setActiveTabCardId:c}=e.useEditorActions(),{data:u,isLoading:m,isFetching:f,error:g}=e.useDashboardCardQuery(r);if(!r)return e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:"No Active Card"});function x(){const d={connectionId:r.connectionId,id:e.v4(),title:"Title",description:"Description",preferences:{onClickFilter:[{columnIndex:0,expression:""}]},type:"bar",sql:"",data:[]};p(d)}function p(d){const j={...s,cards:[...s.cards,d],activeCardId:d.id};i(j),c(d.id)}function h(){const d={...r,id:e.v4(),title:`${r.title} Copy`,tabTitle:`${r.tabTitle||r.title} Copy`};p(d)}function y(d){const j=s.cards.filter(O=>O.id!==d),k=j[0],I={...s,cards:j,activeCardId:k.id};i(I),c(k.id),a(k)}function E(d){c(d)}const z=(d,j)=>{console.log("handleDragStart",j),d.dataTransfer.setData("tabIndex",j.toString())},L=d=>{d.preventDefault()},S=(d,j)=>{const k=d.dataTransfer.getData("tabIndex");if(k===j.toString())return;const I=Array.from(s.cards),[O]=I.splice(parseInt(k),1);I.splice(j,0,O),i({...s,cards:I})};function C(d,j){return d.cards.length===1&&(j.displayTab===!0||j.displayTab===void 0)||d.activeCardId!==j.id&&(j.displayTab===!0||j.displayTab===void 0)?null:e.jsxRuntimeExports.jsx("div",{onClick:()=>{const k=j.displayTab===void 0?!1:!j.displayTab;a({...j,displayTab:k}),l({...j,displayTab:k})},children:j.displayTab===!0||j.displayTab===void 0?e.jsxRuntimeExports.jsx(e.Eye,{className:"mr-2 size-3.5 text-muted-foreground hover:text-foreground"}):e.jsxRuntimeExports.jsx(Ye,{className:"mr-2 size-3.5 text-muted-foreground hover:text-foreground"})})}function D(){return e.jsxRuntimeExports.jsxs(e.Tabs,{onValueChange:E,value:s.activeCardId,className:"flex grow flex-col",children:[s.cards.map(d=>e.jsxRuntimeExports.jsx(e.TabsContent,{className:"mt-0 grow",value:d.id,children:F()},d.id)),e.jsxRuntimeExports.jsx(e.TabsList,{className:"group mx-6 justify-between",children:e.jsxRuntimeExports.jsxs("div",{className:"flex items-center",children:[s.cards.map((d,j)=>e.jsxRuntimeExports.jsx(e.Editable,{text:d.tabTitle||d.title,onSave:k=>{a({...r,tabTitle:k}),l({...r,tabTitle:k})},children:e.jsxRuntimeExports.jsxs(e.TabsTrigger,{draggable:!0,onDragStart:k=>z(k,j),onDragOver:L,onDrop:k=>S(k,j),className:"",value:d.id,children:[C(s,d),d.tabTitle||d.title,s.activeCardId===d.id&&s.cards.length>1&&e.jsxRuntimeExports.jsx(e.X,{className:"ml-2 size-3.5 text-muted-foreground hover:text-foreground",onClick:()=>y(d.id)})]})},d.id)),e.jsxRuntimeExports.jsx(e.Button,{className:"ml-1 h-8 px-2 hover:bg-muted-foreground/50",variant:"outline",onClick:x,children:e.jsxRuntimeExports.jsx(e.Plus,{className:"h-4 w-4"})}),e.jsxRuntimeExports.jsx(e.Button,{className:"invisible ml-1 h-8 px-2 hover:bg-muted-foreground/50 group-hover:visible",variant:"outline",onClick:h,children:e.jsxRuntimeExports.jsx(Ke,{className:"h-4 w-4"})})]})})]})}function F(){return r.type==="kpi"?e.jsxRuntimeExports.jsx("div",{className:"flex h-full items-center justify-center",children:e.jsxRuntimeExports.jsx("div",{className:"w-1/2 rounded-md border",children:e.jsxRuntimeExports.jsx(e.KPICard,{card:r,data:u==null?void 0:u.records})})}):r.type==="text"?e.jsxRuntimeExports.jsx("div",{className:"flex h-full items-center justify-center",children:e.jsxRuntimeExports.jsx("div",{className:"w-1/2 rounded-md border",children:e.jsxRuntimeExports.jsx(e.ScrollArea,{className:"mx-3 my-6 h-[300px] overflow-y-auto break-words px-3",children:e.jsxRuntimeExports.jsx(e.TextCard,{isLoading:n,card:r,data:u==null?void 0:u.records})})})}):e.jsxRuntimeExports.jsx(e.ErrorBoundary,{FallbackComponent:e.FallbackEditorCard,children:e.jsxRuntimeExports.jsx(ys,{className:"grow border-none shadow-none"})})}return e.jsxRuntimeExports.jsxs("div",{className:"relative flex h-full flex-col py-3",children:[(m||f)&&e.jsxRuntimeExports.jsx("div",{className:"absolute bottom-0 left-0 right-0 top-0 z-50 m-auto flex h-10 w-10 items-center justify-center rounded-md bg-muted",children:e.jsxRuntimeExports.jsx(ae,{className:"h-8 w-8 animate-spin text-muted-foreground"})}),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(Rt,{}),!["table","custom"].includes(r.type)&&e.jsxRuntimeExports.jsx(Et,{}),e.jsxRuntimeExports.jsx(vt,{})]}),e.jsxRuntimeExports.jsx(St,{})]}),t?D():e.jsxRuntimeExports.jsxs(e.ResizablePanelGroup,{className:"px-6",direction:"horizontal",children:[o&&e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx(e.ResizablePanel,{id:"1",order:1,defaultSize:30,minSize:10,className:"relative flex h-full min-h-0 w-full flex-1 basis-0",children:o&&e.jsxRuntimeExports.jsx(yt,{})}),e.jsxRuntimeExports.jsx(e.ResizableHandle,{})]}),e.jsxRuntimeExports.jsx(e.ResizablePanel,{id:"2",order:2,minSize:10,className:"relative flex h-full min-h-0 w-full flex-1 basis-0",children:e.jsxRuntimeExports.jsxs(e.ScrollArea,{className:"relative flex h-full min-h-0 w-full flex-1 basis-0",children:[(u==null?void 0:u.records)&&(u==null?void 0:u.records.length)>0&&e.jsxRuntimeExports.jsx(dt,{data:(u==null?void 0:u.records)||[]}),(g||(u==null?void 0:u.error))&&e.jsxRuntimeExports.jsx("span",{className:"font-mono text-xs",children:(g==null?void 0:g.message)||((N=u==null?void 0:u.error)==null?void 0:N.message)}),e.jsxRuntimeExports.jsx(e.ScrollBar,{orientation:"horizontal"})]})})]})]})}function yt(){const s=e.useEditorStore(t=>t.pythonStdOut);if(!s)return null;const r=s.replace(/\n/g,"<br>");return e.jsxRuntimeExports.jsxs("div",{className:"relative flex w-full flex-col border-r",children:[e.jsxRuntimeExports.jsx("div",{className:"sticky top-0 flex max-h-11 min-h-11 grow items-center border-b bg-muted px-3 font-mono text-xs font-semibold text-foreground/70",children:"Python Output"}),e.jsxRuntimeExports.jsxs(e.ScrollArea,{className:"overflow-y-auto px-2 pt-1 font-mono text-xs text-foreground/90",children:[e.jsxRuntimeExports.jsx("div",{dangerouslySetInnerHTML:{__html:r}}),e.jsxRuntimeExports.jsx(e.ScrollBar,{orientation:"horizontal"})]})]})}function St(){const s=e.useEditorStore(t=>t.isShowingVisual),r=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:()=>r(!s),id:"visualize",className:"data-[state=checked]:bg-foreground/50"})]})}function Ct({options:s,value:r,onValueChange:t}){return e.jsxRuntimeExports.jsx(e.RadioGroup,{value:r,onValueChange:t,className:"flex gap-4",defaultValue:s[0].value,children:s.map(n=>e.jsxRuntimeExports.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxRuntimeExports.jsx(e.RadioGroupItem,{value:n.value,id:n.value}),e.jsxRuntimeExports.jsx("label",{className:"text-sm",htmlFor:n.value,children:n.label})]},n.value))})}function se({label:s,options:r,value:t,onValueChange:n,className:o}){return e.jsxRuntimeExports.jsxs(e.Select,{value:t,onValueChange:n,children:[e.jsxRuntimeExports.jsx(e.SelectTrigger,{className:e.cn("w-full focus:ring-0 focus:ring-offset-0",o),children:e.jsxRuntimeExports.jsx(e.SelectValue,{placeholder:s})}),e.jsxRuntimeExports.jsx(e.SelectContent,{children:e.jsxRuntimeExports.jsxs(e.SelectGroup,{children:[e.jsxRuntimeExports.jsx(e.SelectLabel,{children:s}),r.map(i=>e.jsxRuntimeExports.jsx(e.SelectItem,{value:i.value,children:i.label},i.value))]})})]})}function de({children:s,summary:r,open:t,className:n}){return e.jsxRuntimeExports.jsxs("details",{open:t,className:e.cn("space-y-4 [&_summary>svg]:open:-rotate-180",n),children:[e.jsxRuntimeExports.jsxs("summary",{className:"flex cursor-pointer list-none items-center justify-between gap-4",children:[e.jsxRuntimeExports.jsx(e.Label,{children:r}),e.jsxRuntimeExports.jsx(e.ChevronUp,{className:"h-4 w-4"})]}),e.jsxRuntimeExports.jsx("div",{className:"transition-all ease-in-out",children:s})]})}function Nt(){var h,y;const s=e.useEditorStore(E=>E.card.customCardPreferences),{data:r}=As(),t=(r==null?void 0:r.plugins)||[],n=e.useEditorStore(E=>E.card),o=e.useEditorStore(E=>E.frame),i=(s==null?void 0:s.visualType)||"single",{setCustomCardPreferences:a}=e.useEditorActions(),{components:l,manifest:c}=e.useCustomVisual((s==null?void 0:s.url)||""),u=(h=c==null?void 0:c.visuals)==null?void 0:h.find(E=>E.name===(s==null?void 0:s.componentName));function m(E,z){if(!s)return;const S={...(s==null?void 0:s.dataInputCardIds)||{},[E]:{cardId:z,hookRef:null}};a({...s,dataInputCardIds:S})}function f(E){var L,S;const z=(L=o==null?void 0:o.cards)==null?void 0:L.filter(C=>{var D;return((D=C==null?void 0:C.customCardPreferences)==null?void 0:D.visualType)!=="multiple"}).map(C=>({value:C.id,label:C.tabTitle||C.title}));return e.jsxRuntimeExports.jsx("div",{className:"space-y-2",children:(S=E==null?void 0:E.dataInputs)==null?void 0:S.map((C,D)=>{var F,N;return e.jsxRuntimeExports.jsxs("div",{className:"grid grid-cols-10 gap-2",children:[e.jsxRuntimeExports.jsx("div",{className:"col-span-4 flex items-center",children:C}),e.jsxRuntimeExports.jsx(se,{className:"col-span-6 h-8 w-full justify-between",label:"",options:z||[],value:((N=(F=s==null?void 0:s.dataInputCardIds)==null?void 0:F[D])==null?void 0:N.cardId)||"",onValueChange:d=>m(D,d)})]},D+Math.random())})})}function g(E,z,L=[]){var S,C;return s?E==="input"?e.jsxRuntimeExports.jsx(e.Input,{className:`h-8 w-full ${e.removeRing}`,value:((S=s==null?void 0:s.settings)==null?void 0:S[z])||"",onChange:D=>{a({...s,settings:{...s==null?void 0:s.settings,[z]:D.target.value}})}},z):E==="select"?e.jsxRuntimeExports.jsx(se,{className:"h-8 w-full",label:"",options:L,value:((C=s==null?void 0:s.settings)==null?void 0:C[z])||"",onValueChange:D=>{a({...s,settings:{...s==null?void 0:s.settings,[z]:D}})}}):null:null}function x(E){const z=Object.entries((E==null?void 0:E.settings)||{});return e.jsxRuntimeExports.jsx("div",{className:"space-y-3",children:z.map(([L,S])=>e.jsxRuntimeExports.jsxs("div",{className:"space-y-2",children:[e.jsxRuntimeExports.jsx(e.Label,{children:S.title}),g(S.ui,L,S.options)]},L))})}function p(E){s&&a({...s,visualType:E,componentName:""})}return e.jsxRuntimeExports.jsxs("div",{className:"p-6",children:[e.jsxRuntimeExports.jsx(de,{summary:"Plugin Settings",children:e.jsxRuntimeExports.jsx("div",{className:"space-y-4 text-sm",children:e.jsxRuntimeExports.jsxs("div",{className:"space-y-4 text-sm",children:[e.jsxRuntimeExports.jsx("div",{className:"space-y-2",children:e.jsxRuntimeExports.jsx("div",{className:"px-2",children:e.jsxRuntimeExports.jsx(se,{className:"h-8 w-full",label:"",options:t,value:(s==null?void 0:s.url)||"",onValueChange:E=>a({...s||{url:"",componentName:""},url:E})})})}),((s==null?void 0:s.type)==="component"||(s==null?void 0:s.type)===void 0)&&e.jsxRuntimeExports.jsx(Ct,{options:[{value:"single",label:"Single Visual"},{value:"multiple",label:"Multi-Visual"}],value:i,onValueChange:p}),((s==null?void 0:s.type)==="component"||(s==null?void 0:s.type)===void 0)&&s&&e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:e.jsxRuntimeExports.jsxs("div",{className:"space-y-2",children:[e.jsxRuntimeExports.jsx(e.Label,{children:"Component"}),e.jsxRuntimeExports.jsx("div",{className:"space-y-2 px-2",children:l&&e.jsxRuntimeExports.jsx(se,{className:"h-8 w-full",label:"",options:(l==null?void 0:l.filter(E=>E.type===i).map(E=>({value:E.name,label:E.name})))||[],value:s.componentName,onValueChange:E=>{console.log("changing value",E),a({...s,componentName:E})}})})]})})]})})}),e.jsxRuntimeExports.jsx(e.Separator,{className:"my-4"}),((y=n==null?void 0:n.customCardPreferences)==null?void 0:y.componentName)&&e.jsxRuntimeExports.jsxs(de,{summary:"Component Settings",children:[u&&u.dataInputs&&e.jsxRuntimeExports.jsxs("div",{className:"space-y-3",children:[e.jsxRuntimeExports.jsx(e.Label,{children:"Input Mapping"}),e.jsxRuntimeExports.jsx("div",{className:"px-2",children:f(u)})]}),u&&u.settings&&e.jsxRuntimeExports.jsx("div",{className:"space-y-3",children:e.jsxRuntimeExports.jsx("div",{className:"px-2",children:x(u)})})]})]})}function le(){const[s,r]=R.useState([]);e.useEditorStore(m=>m.card.cfg);const t=e.useEditorStore(m=>m.card.preferences),{setCardCfg:n,setFilterOnClickColumnIndex:o,setCardPreferences:i}=e.useEditorStore(m=>m.actions),a=e.useEditorStore(m=>m.queryResultColumns);e.useEditorStore(m=>{var f;return(f=m.card.preferences)==null?void 0:f.filterOnClickColumnIndex}),R.useEffect(()=>{a&&r(new Array(a.length).fill(!1))},[a]);function l(m,f){var g,x;f?t!=null&&t.onClickFilter&&((g=t==null?void 0:t.onClickFilter)==null?void 0:g.length)>0?i({...t,onClickFilter:[...t.onClickFilter,{columnIndex:m,expression:""}]}):i({...t,onClickFilter:[{columnIndex:m,expression:""}]}):(i({...t,onClickFilter:(x=t==null?void 0:t.onClickFilter)==null?void 0:x.filter(p=>p.columnIndex!==m)}),r(p=>{const h=[...p];return h[m]=!1,h}))}function c(m,f){var x;const g=(x=t==null?void 0:t.onClickFilter)==null?void 0:x.map(p=>p.columnIndex===m?{...p,expression:f.target.value}:p);i({...t,onClickFilter:g})}function u(m){var f,g,x,p;if(s!=null&&s[m]||(g=(f=t==null?void 0:t.onClickFilter)==null?void 0:f.find(h=>h.columnIndex===m))!=null&&g.expression)return e.jsxRuntimeExports.jsx(e.Input,{value:(p=(x=t==null?void 0:t.onClickFilter)==null?void 0:x.find(h=>h.columnIndex===m))==null?void 0:p.expression,onChange:h=>c(m,h),type:"text",className:"h-9 w-full font-mono text-xs focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0",placeholder:"Expression"})}return e.jsxRuntimeExports.jsxs("div",{className:"space-y-2",children:[e.jsxRuntimeExports.jsx(e.Label,{children:"On Click"}),a==null?void 0:a.map((m,f)=>{var g,x;return e.jsxRuntimeExports.jsx("div",{className:"xbg-red-100 group flex items-center justify-between space-y-2",children:e.jsxRuntimeExports.jsxs("div",{className:"grow",children:[e.jsxRuntimeExports.jsxs("div",{className:"flex items-center space-x-2 py-2",children:[e.jsxRuntimeExports.jsx(e.Checkbox,{checked:!!((g=t==null?void 0:t.onClickFilter)!=null&&g.find(p=>p.columnIndex===f)),onCheckedChange:p=>l(f,p)}),e.jsxRuntimeExports.jsx("label",{className:"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",children:m}),e.jsxRuntimeExports.jsx("div",{className:"flex items-center gap-2",children:((x=t==null?void 0:t.onClickFilter)==null?void 0:x.find(p=>p.columnIndex===f))&&e.jsxRuntimeExports.jsx(e.Pencil,{onClick:()=>{r(p=>{const h=[...p];return h[f]=!p[f],h})},className:"invisible size-3 cursor-pointer text-gray-400 group-hover:visible"})})]}),u(f)]})},m)})]})}function ve(){var a,l,c;const s=e.useEditorStore(u=>u.card.preferences),r=e.useEditorStore(u=>u.card.cfg),{setCardCfg:t,setCardPreferences:n,setChartOrientation:o}=e.useEditorStore(u=>u.actions);(a=r==null?void 0:r.options)!=null&&a.indexAxis;function i(u){o(u)}return e.jsxRuntimeExports.jsxs(e.RadioGroup,{value:((l=s==null?void 0:s.chartOptions)==null?void 0:l.indexAxis)||((c=r==null?void 0:r.options)==null?void 0:c.indexAxis)||"x",onValueChange:i,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 pe="focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0";function Ge(s,r){var n,o,i;const t=e.getNumberAxis(s,r);return((i=(o=(n=s==null?void 0:s.chartOptions)==null?void 0:n.scales)==null?void 0:o[t])==null?void 0:i.type)||"linear"}function zs(){var H,B,K,Y,_,Q;const[s,r]=R.useState(!1),t=e.useEditorStore(A=>{var T;return(T=A.card)==null?void 0:T.preferences}),n=e.useEditorStore(A=>{var T;return(T=A.card)==null?void 0:T.cfg}),o=e.getNumberAxis(t,n),[i,a]=R.useState(Ge(t)),[l,c]=R.useState(((K=(B=(H=t==null?void 0:t.chartOptions)==null?void 0:H.scales)==null?void 0:B[o])==null?void 0:K.min)||""),[u,m]=R.useState(((Q=(_=(Y=t==null?void 0:t.chartOptions)==null?void 0:Y.scales)==null?void 0:_[o])==null?void 0:Q.max)||""),[f,g]=R.useState(l||u?"custom":"auto"),[x,p]=R.useState(""),[h,y]=R.useState(0),[E,z]=R.useState(""),[L,S]=R.useState(""),[C,D]=R.useState(""),F=e.useEditorStore(A=>A.actions.setCardPreferences),{updateCardInFrame:N}=e.useEditorActions(),d=e.useEditorStore(A=>A.card),j=e.useEditorStore(A=>{var T;return(T=A.card)==null?void 0:T.type}),k=["pie","doughnut","polarArea"].includes(j);R.useEffect(()=>{var A,T,$,V,P,J,X,ne,Z,re,w,M,U,v;a(Ge(t)),c((($=(T=(A=t==null?void 0:t.chartOptions)==null?void 0:A.scales)==null?void 0:T[o])==null?void 0:$.min)===0?0:""),m(((J=(P=(V=t==null?void 0:t.chartOptions)==null?void 0:V.scales)==null?void 0:P[o])==null?void 0:J.max)||""),p(((re=(Z=(ne=(X=t==null?void 0:t.chartOptions)==null?void 0:X.scales)==null?void 0:ne[o])==null?void 0:Z.ticks)==null?void 0:re.stepSize)||""),y(((w=t==null?void 0:t.numberAxisFormat)==null?void 0:w.decimalPlaces)||0),z(((M=t==null?void 0:t.numberAxisFormat)==null?void 0:M.suffix)||""),S(((U=t==null?void 0:t.numberAxisFormat)==null?void 0:U.currency)||""),D(((v=t==null?void 0:t.numberAxisFormat)==null?void 0:v.locale)||"")},[s,t,o]);function I(A,T){return T===""||/^[0-9\b]+$/.test(T)?Number(T):Number(A)}function O(){const A=[...new Set(e.LOCALE_CURRENCY_PAIRS.map(T=>T.currency))];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.jsxs(e.Select,{value:L||"none",onValueChange:T=>S(T==="none"?"":T),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,{children:e.jsxRuntimeExports.jsxs(e.SelectGroup,{children:[e.jsxRuntimeExports.jsx(e.SelectLabel,{children:"Currency"}),e.jsxRuntimeExports.jsx(e.SelectItem,{value:"none",children:"None"}),A.map(T=>e.jsxRuntimeExports.jsx(e.SelectItem,{value:T,children:T},T))]})})]}),e.jsxRuntimeExports.jsxs(e.Select,{value:C,onValueChange:T=>D(T),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,{children:e.jsxRuntimeExports.jsxs(e.SelectGroup,{children:[e.jsxRuntimeExports.jsx(e.SelectLabel,{children:"Locale"}),e.LOCALE_CURRENCY_PAIRS.map(T=>e.jsxRuntimeExports.jsx(e.SelectItem,{value:T.locale,children:T.locale},T.locale))]})})]})]}),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:h,onChange:T=>y(Number(T.target.value)),id:"format",className:`col-span-6 h-8 w-full tracking-wide ${pe}`})]})]})}function q(){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:l,onChange:A=>c(T=>I(T,A.target.value)),className:`col-span-1 h-8 w-full ${pe}`}),e.jsxRuntimeExports.jsx(e.Input,{value:u,onChange:A=>m(T=>I(T,A.target.value)),id:"max",className:`col-span-1 h-8 w-full ${pe}`})]}),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:x,onChange:A=>p(T=>I(T,A.target.value)),id:"step-size",className:`col-span-1 h-8 w-full ${pe}`})]})]})}function G(){var V;let A={};f==="custom"&&(A={min:l,max:u,ticks:{stepSize:x}});const T={...t||{},chartOptions:{...t==null?void 0:t.chartOptions,scales:{...(V=t==null?void 0:t.chartOptions)==null?void 0:V.scales,[o]:{type:i,...i==="linear"?A:{}}}},numberAxisFormat:{decimalPlaces:h,suffix:E,currency:L,locale:C}};console.log(T),F(T);const $={...d,preferences:T};N($)}return e.jsxRuntimeExports.jsxs(e.Popover,{onOpenChange:A=>r(A),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:i,onValueChange:A=>a(A),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"})]})})]})]}),i=="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:f,onValueChange:A=>g(A),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"})]})]})]}),f==="custom"&&i=="linear"&&q(),O(),e.jsxRuntimeExports.jsx(e.SelectSeparator,{}),e.jsxRuntimeExports.jsx("div",{className:"grid grid-cols-3",children:e.jsxRuntimeExports.jsx(e.Button,{onClick:G,variant:"secondary",className:"col-span-1 col-start-3 h-8 w-full",children:"Apply"})})]})]})})]})}function wt({idx:s}){var l;const r=e.useEditorStore(c=>{var u;return(u=c.card)==null?void 0:u.preferences}),t=e.useEditorStore(c=>{var u;return(u=c.card.preferences)==null?void 0:u.datasetOptions}),n=e.useEditorStore(c=>c.actions.setCardPreferences),o=(l=r==null?void 0:r.chartOptions)==null?void 0:l.indexAxis,i=t==null?void 0:t.find(c=>c.idx===s);function a(c,u){(c==="end"||c==="start")&&e.getContrastColor(e.getCanvasBackgroundColor());const m={display:c!=="none",align:c,anchor:c,clamp:!0};if(!i)n({...r,datasetOptions:[...t||[],{idx:u,datalabels:m}]});else{const f={...i};f.datalabels=m;const g=t==null?void 0:t.map(x=>x.idx===u?f:x);n({...r,datasetOptions:g})}}return e.jsxRuntimeExports.jsxs(e.Popover,{children:[e.jsxRuntimeExports.jsx(e.PopoverTrigger,{children:e.jsxRuntimeExports.jsx(ps,{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:()=>a("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:()=>a("start",s),size:"sm",variant:"secondary",className:"h-7 p-1 text-xs font-normal",children:e.jsxRuntimeExports.jsx(ns,{className:e.cn("h-4 w-4",{"rotate-90":o==="y"})})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>a("center",s),size:"sm",variant:"secondary",className:"h-7 p-1 text-xs font-normal",children:e.jsxRuntimeExports.jsx(os,{className:e.cn("h-4 w-4",{"rotate-90":o==="y"})})}),e.jsxRuntimeExports.jsx(e.Button,{onClick:()=>a("end",s),size:"sm",variant:"secondary",className:"h-7 p-1 text-xs font-normal",children:e.jsxRuntimeExports.jsx(rs,{className:e.cn("h-4 w-4",{"rotate-90":o==="y"})})})]})})]})}function Os(){const s=e.useEditorStore(u=>u.card),r=e.useEditorStore(u=>{var m,f,g;return(g=(f=(m=u==null?void 0:u.card)==null?void 0:m.preferences)==null?void 0:f.chartOptions)==null?void 0:g.indexAxis}),{data:t}=e.useDashboardCardQuery(s),n=r==="y"?"Y axis":"X axis",o=r==="y"?"X axis":"Y axis",{keys:i,metricKeys:a,dimensionKeys:l}=e.getKeys((t==null?void 0:t.records)||[]);let c=a;if(["stackedBar","stackedLine"].includes(s.type)){const u=e.pivotData({dataArray:(t==null?void 0:t.records)||[],groupKey:l[0],pivotKey:l[1],valueKey:c[0]}),{metricKeys:m}=e.getKeys(u);c=m}return i.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:n}),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:l[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:o}),e.jsxRuntimeExports.jsx(zs,{})]}),e.jsxRuntimeExports.jsx("div",{className:"my-1 space-y-1",children:c.map((u,m)=>e.jsxRuntimeExports.jsx(kt,{col:u,idx:m},u))})]})]})}function kt({col:s,idx:r}){const t=e.useEditorStore(l=>{var c;return(c=l.card)==null?void 0:c.preferences}),n=e.useEditorStore(l=>{var c;return(c=l.card.preferences)==null?void 0:c.datasetOptions}),o=n==null?void 0:n.find(l=>l.idx===r),{setCardPreferences:i}=e.useEditorStore(l=>l.actions);function a(l){if(!o)i({...t,datasetOptions:[...n||[],{idx:r,type:l==="area"?"line":l,fill:l==="area"?"origin":""}]});else{const c={...o};c.type=l==="area"?"line":l,c.fill=l==="area"?"origin":"";const u=n==null?void 0:n.map(m=>m.idx===r?c:m);i({...t,datasetOptions:u})}}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(fe,{onClick:()=>a("bar"),className:"invisible size-4 cursor-pointer text-muted-foreground hover:text-foreground group-hover:visible"}),e.jsxRuntimeExports.jsx(ge,{onClick:()=>a("line"),className:"invisible size-4 cursor-pointer text-muted-foreground hover:text-foreground group-hover:visible"}),e.jsxRuntimeExports.jsx($e,{onClick:()=>a("area"),className:"invisible size-4 cursor-pointer text-muted-foreground hover:text-foreground group-hover:visible"}),e.jsxRuntimeExports.jsx(wt,{idx:r})]})]})}function Ms(){const s=e.useEditorStore(x=>x.selectedConnectionId),r=e.useEditorStore(x=>x.selectedDatamodelId),t=e.useEditorStore(x=>x.selectedDatabaseName),n=e.useEditorStore(x=>x.selectedSchemaName),o=e.useEditorStore(x=>x.selectedTableName),i=e.useDashboardStore(x=>x.dashboard.filters)||[],a=e.useDashboardStore(x=>x.actions.addFilter),l=e.useDashboardStore(x=>x.actions.removeFilter),{removeFilterValues:c}=e.useDashboardActions(),{modelItems:u,tableName:m,connectionType:f}=oe();function g(x,p="dashboard"){var F;const h=e.fmt(x.column_name),y=e.fmt(t||""),E=e.fmt(n||""),z=e.fmt(m);let L=e.getQualifiedTableName(E,z,f),S=`${L}.${h}`;const C=(F=u==null?void 0:u.find(N=>N.id===r))==null?void 0:F.name;r&&r!=="none"&&(S=`${e.DATAMODEL_NAMESPCACE}.${C}.${h}`,L=`${e.DATAMODEL_NAMESPCACE}.${C}`);const D=i==null?void 0:i.find(N=>N.column===S&&N.table===z&&(N.database===y||N.database===t));if(D)c(D.id),l(D.id);else{const N=e.v4();return m==="api"&&s?(a({location:p,id:N,column:S,title:x.column_name,dataType:x.data_type,table:"api",database:"",connectionId:s,operation:"in",sql:e.getDefaultFilterSql(x.data_type,L,h)}),N):(a({id:N,location:p,column:S,title:x.column_name,dataType:x.data_type,table:o||"",database:t||"",connectionId:s||"",operation:"in",sql:e.getDefaultFilterSql(x.data_type,L,h)}),N)}}return{assignFilter:g}}function xe(){const s=e.useDashboardStore(l=>l.dashboard.filters),r=e.useEditorStore(l=>l.frame),{setFrame:t}=e.useEditorActions(),{columns:n}=oe(),{assignFilter:o}=Ms();function i(l){const c=o(l,"frame");t({...r,filterId:c})}const a=s==null?void 0:s.find(l=>l.id===r.filterId);return e.jsxRuntimeExports.jsxs("div",{className:"space-y-3",children:[e.jsxRuntimeExports.jsx(e.Label,{children:"Card Filter"}),e.jsxRuntimeExports.jsx(It,{onSelect:i,columns:n}),a&&e.jsxRuntimeExports.jsx(e.FilterHeader,{filter:a})]})}function It({columns:s,onSelect:r}){var a;const[t,n]=qe.useState(!1),[o,i]=qe.useState("");return e.jsxRuntimeExports.jsxs(e.Popover,{open:t,onOpenChange:n,children:[e.jsxRuntimeExports.jsx(e.PopoverTrigger,{asChild:!0,children:e.jsxRuntimeExports.jsxs(e.Button,{size:"sm",variant:"outline",role:"combobox","aria-expanded":t,className:"w-full justify-between font-normal",children:[o?(a=s.find(l=>l.column_name===o))==null?void 0:a.column_name:"Select Column...",e.jsxRuntimeExports.jsx(e.CaretSortIcon,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsxRuntimeExports.jsx(e.PopoverContent,{className:"w-[200px] p-0",children:e.jsxRuntimeExports.jsxs(e.Command,{children:[e.jsxRuntimeExports.jsx(e.CommandInput,{placeholder:"Search column",className:"h-9"}),e.jsxRuntimeExports.jsxs(e.CommandList,{children:[e.jsxRuntimeExports.jsx(e.CommandEmpty,{children:"No framework found."}),e.jsxRuntimeExports.jsx(e.CommandGroup,{children:s.map(l=>e.jsxRuntimeExports.jsxs(e.CommandItem,{value:l.column_name,onSelect:c=>{const u=c===o?"":c;i(u),n(!1),u&&r(l)},children:[l.column_name,e.jsxRuntimeExports.jsx(e.CheckIcon,{className:e.cn("ml-auto h-4 w-4",o===l.column_name?"opacity-100":"opacity-0")})]},l.column_name))})]})]})})]})}function Dt({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:r=>r.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(Os,{})]})]}),e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-3",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{children:"Filters"}),e.jsxRuntimeExports.jsxs(e.AccordionContent,{className:"space-y-4 px-2",children:[e.jsxRuntimeExports.jsx(le,{}),e.jsxRuntimeExports.jsx(xe,{})]})]})]})})}function Le(){var o,i,a;const s=e.useEditorStore(l=>l.card.cfg),r=e.useEditorStore(l=>l.actions.setCardCfg),t=e.useEditorStore(l=>l.card.type);function n(l){var m;const c={datalabels:{display:l!=="none",align:l,anchor:l,clamp:!0}},u={...s,options:{...s==null?void 0:s.options,plugins:{...(m=s==null?void 0:s.options)==null?void 0:m.plugins,...c}}};r(u),console.log(l)}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(zs,{})]}),e.jsxRuntimeExports.jsxs(e.Select,{value:(a=(i=(o=s==null?void 0:s.options)==null?void 0:o.plugins)==null?void 0:i.datalabels)==null?void 0:a.anchor,onValueChange:n,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 Tt({cardType:s}){function r(t){return e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx("div",{className:"rounded bg-muted px-2 py-1 text-xs",children:t==="bubble"?"SELECT label, [group], x-axis, y-axis, radius FROM table":"SELECT label, [group], x-axis, y-axis 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:"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:i=>i.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:"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.jsx(e.AccordionContent,{className:"space-y-4 font-mono text-xs",children:r(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(Le,{})})]}),e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-3",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{children:"Filters"}),e.jsxRuntimeExports.jsxs(e.AccordionContent,{className:"space-y-4 px-2",children:[e.jsxRuntimeExports.jsx(le,{}),e.jsxRuntimeExports.jsx(xe,{})]})]})]})})}const Lt={datasets:[{type:"line",label:"Sum_sales",data:[]},{type:"bar",label:"Sum_profit",data:[]}]},At={datasets:[{fill:"origin",type:"line",label:"Sum_sales",data:[]}]};function zt(){const s=e.useEditorStore(r=>r.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:Ot(s)}),e.jsxRuntimeExports.jsx("section",{className:"",children:["line","bar"].includes(s)&&e.jsxRuntimeExports.jsx(ve,{})}),!["kpi"].includes(s)&&e.jsxRuntimeExports.jsxs("div",{className:"space-y-4",children:[e.jsxRuntimeExports.jsx(Le,{}),e.jsxRuntimeExports.jsx(le,{}),e.jsxRuntimeExports.jsx(xe,{})]})]})}function Ot(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(Lt,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(At,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 Mt(){var c,u,m,f,g;const s=e.useEditorStore(x=>x.card.preferences),r=e.useEditorStore(x=>x.actions.setCardPreferences),t=e.useEditorStore(x=>x.actions.setNumberFormat);e.useEditorStore(x=>{var p,h;return(h=(p=x.card.preferences)==null?void 0:p.formatNumber)==null?void 0:h.decimalPlaces});const n=e.useEditorStore(x=>{var p,h;return(h=(p=x.card.preferences)==null?void 0:p.formatNumber)==null?void 0:h.locale}),o=e.useEditorStore(x=>{var p,h;return(h=(p=x.card.preferences)==null?void 0:p.formatNumber)==null?void 0:h.currency});e.useEditorStore(x=>x.actions.setFilterOnClickField);const i=e.useEditorStore(x=>{var p,h;return(h=(p=x.card.preferences)==null?void 0:p.formatNumber)==null?void 0:h.colorRanges})||[],a=e.useEditorStore(x=>x.actions.setColorRanges),l=[...new Set(e.LOCALE_CURRENCY_PAIRS.map(x=>x.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:!!((c=s==null?void 0:s.formatNumber)!=null&&c.enabled),onCheckedChange:x=>{r({...s,formatNumber:{...s==null?void 0:s.formatNumber,enabled:x}})}}),e.jsxRuntimeExports.jsx(e.Label,{children:"Format Number"})]}),((u=s==null?void 0:s.formatNumber)==null?void 0:u.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:n||"none",onValueChange:x=>{var p,h,y;return t(((p=s==null?void 0:s.formatNumber)==null?void 0:p.decimalPlaces)||0,((h=s==null?void 0:s.formatNumber)==null?void 0:h.currency)||"",x,((y=s==null?void 0:s.formatNumber)==null?void 0:y.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.jsxRuntimeExports.jsx(e.SelectItem,{value:"none",children:"None"},"none"),e.LOCALE_CURRENCY_PAIRS.map(x=>e.jsxRuntimeExports.jsx(e.SelectItem,{value:x.locale,children:x.locale},x.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:o||"none",onValueChange:x=>{var p,h,y;console.log("currency",x),t(((p=s==null?void 0:s.formatNumber)==null?void 0:p.decimalPlaces)||0,x==="none"?"":x,((h=s==null?void 0:s.formatNumber)==null?void 0:h.locale)||"",((y=s==null?void 0:s.formatNumber)==null?void 0:y.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"),l.map(x=>e.jsxRuntimeExports.jsx(e.SelectItem,{value:x,children:x},x))]})})]})]})]}),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:((f=(m=s==null?void 0:s.formatNumber)==null?void 0:m.decimalPlaces)==null?void 0:f.toString())||"0",onValueChange:x=>{var p,h,y;return t(Number(x),((p=s==null?void 0:s.formatNumber)==null?void 0:p.currency)||"",((h=s==null?void 0:s.formatNumber)==null?void 0:h.locale)||"",((y=s==null?void 0:s.formatNumber)==null?void 0:y.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(x=>e.jsxRuntimeExports.jsx(e.SelectItem,{value:x,children:x},x))})]})]}),e.jsxRuntimeExports.jsxs("div",{className:"w-full space-y-1",children:[e.jsxRuntimeExports.jsx(e.Label,{children:"Suffix"}),e.jsxRuntimeExports.jsx(e.Input,{value:((g=s==null?void 0:s.formatNumber)==null?void 0:g.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:x=>{var p,h,y;return t(((p=s==null?void 0:s.formatNumber)==null?void 0:p.decimalPlaces)||0,((h=s==null?void 0:s.formatNumber)==null?void 0:h.currency)||"",((y=s==null?void 0:s.formatNumber)==null?void 0:y.locale)||"",x.target.value)}})]})]})]})}),e.jsxRuntimeExports.jsx(e.Separator,{className:"my-3"}),e.jsxRuntimeExports.jsx(e.ColorFormat,{colorRanges:i,setColorRanges:a})]})]})}function Ft(){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(Mt,{})}),e.jsxRuntimeExports.jsx("div",{}),e.jsxRuntimeExports.jsx("div",{})]})}const Vt=[{label:"Mercator",value:"mercator"},{label:"Azimuthal Equidistant",value:"azimuthalEquidistant"},{label:"Gnomonic",value:"gnomonic"},{label:"Orthographic",value:"orthographic"},{label:"Stereographic",value:"stereographic"},{label:"Equal Earth",value:"equalEarth"},{label:"Albers",value:"albers"},{label:"Albers USA",value:"albersUsa"},{label:"Conic Conformal",value:"conicConformal"},{label:"Conic Equal Area",value:"conicEqualArea"},{label:"Conic Equidistant",value:"conicEquidistant"},{label:"Equirectangular",value:"equirectangular"},{label:"Transverse Mercator",value:"transverseMercator"},{label:"Natural Earth 1",value:"naturalEarth1"}],qt=["blues","brBG","buGn","buPu","cividis","cool","cubehelixDefault","gnBu","greens","greys","inferno","magma","orRd","oranges","pRGn","piYG","plasma","puBu","puBuGn","puOr","puRd","purples","rainbow","rdBu","rdGy","rdPu","rdYlBu","rdYlGn","reds","sinebow","spectral","turbo","viridis","warm","ylGn","ylGnBu","ylOrBr","ylOrRd"],_t=qt.map(s=>({label:s,value:s}));function Bt(){var c,u,m,f,g,x,p,h,y,E,z,L,S,C,D,F,N,d;const s=e.useEditorStore(j=>j.card),r=(u=(c=s==null?void 0:s.preferences)==null?void 0:c.mapVisualOptions)==null?void 0:u.topoJsonUrl,[t,n]=R.useState(((f=(m=s==null?void 0:s.preferences)==null?void 0:m.mapVisualOptions)==null?void 0:f.customTopoJsonUrl)||""),{setCardPreferences:o}=e.useEditorActions(),{data:i}=e.useTopoJson(s),a=Object.keys((i==null?void 0:i.objects)||{}).map(j=>({label:j,value:j}))||[],l=[{label:"US States 10m",value:"https://unpkg.com/us-atlas/states-10m.json"},{label:"Countries 50m",value:"https://unpkg.com/world-atlas/countries-50m.json"},{label:"Custom",value:"custom"}];return e.jsxRuntimeExports.jsxs("div",{className:"p-6",children:[e.jsxRuntimeExports.jsx(de,{summary:"Map Query",children:e.jsxRuntimeExports.jsx("p",{className:"rounded-md bg-muted p-2 font-mono text-xs",children:"SELECT country, value FROM table"})}),e.jsxRuntimeExports.jsx(e.Separator,{className:"my-4"}),e.jsxRuntimeExports.jsx(de,{open:!0,summary:"Settings",children:e.jsxRuntimeExports.jsxs("div",{className:"space-y-3 px-2",children:[e.jsxRuntimeExports.jsx(se,{className:"h-9",options:l,onValueChange:j=>{console.log("value",j),o({...s.preferences,mapVisualOptions:{topoJsonUrl:j}})},value:r||"",label:"Select Map"}),r==="custom"&&e.jsxRuntimeExports.jsx(e.Input,{onChange:j=>{n(j.target.value)},onBlur:()=>{var j;console.log("onBlur",t),o({...s.preferences,mapVisualOptions:{...(j=s.preferences)==null?void 0:j.mapVisualOptions,customTopoJsonUrl:t}})},value:t,className:`h-9 w-full ${e.removeRing}`,placeholder:"Custom URL"}),i&&e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsxs("div",{className:"space-y-1",children:[e.jsxRuntimeExports.jsx(e.Label,{children:"Map Object"}),e.jsxRuntimeExports.jsx(se,{className:"h-9",options:a,value:((x=(g=s.preferences)==null?void 0:g.mapVisualOptions)==null?void 0:x.objectKey)||"",label:"Map Object",onValueChange:j=>{var k;o({...s.preferences,mapVisualOptions:{...(k=s.preferences)==null?void 0:k.mapVisualOptions,objectKey:j}})}})]}),e.jsxRuntimeExports.jsxs("div",{className:"space-y-1",children:[e.jsxRuntimeExports.jsx(e.Label,{children:"Projection"}),e.jsxRuntimeExports.jsx(se,{className:"h-9",options:Vt,value:((h=(p=s.preferences)==null?void 0:p.mapVisualOptions)==null?void 0:h.projection)||"",label:"Projection",onValueChange:j=>{var k;o({...s.preferences,mapVisualOptions:{...(k=s.preferences)==null?void 0:k.mapVisualOptions,projection:j}})}})]}),e.jsxRuntimeExports.jsxs("div",{className:"space-y-1",children:[e.jsxRuntimeExports.jsx(e.Label,{children:"Colors"}),e.jsxRuntimeExports.jsx(se,{className:"h-9",options:_t,value:((E=(y=s.preferences)==null?void 0:y.mapVisualOptions)==null?void 0:E.colorScale)||"",label:"Select Color Scale",onValueChange:j=>{var k;o({...s.preferences,mapVisualOptions:{...(k=s.preferences)==null?void 0:k.mapVisualOptions,colorScale:j}})}})]})]})]})}),e.jsxRuntimeExports.jsx(e.Separator,{className:"my-4"}),e.jsxRuntimeExports.jsx(de,{className:"",summary:"Scale Options",children:e.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxRuntimeExports.jsx(e.Input,{className:`h-9 w-full ${e.removeRing}`,type:"number",step:.1,value:((L=(z=s.preferences)==null?void 0:z.mapVisualOptions)==null?void 0:L.projectionScale)||1,onChange:j=>{var k;o({...s.preferences,mapVisualOptions:{...(k=s.preferences)==null?void 0:k.mapVisualOptions,projectionScale:Number(j.target.value)}})}}),e.jsxRuntimeExports.jsx(e.Label,{children:"X"}),e.jsxRuntimeExports.jsx(e.Input,{className:`h-9 w-full ${e.removeRing}`,type:"number",step:10,value:((D=(C=(S=s.preferences)==null?void 0:S.mapVisualOptions)==null?void 0:C.projectionOffset)==null?void 0:D[0])||0,onChange:j=>{var k,I,O,q;o({...s.preferences,mapVisualOptions:{...(k=s.preferences)==null?void 0:k.mapVisualOptions,projectionOffset:[Number(j.target.value),((q=(O=(I=s.preferences)==null?void 0:I.mapVisualOptions)==null?void 0:O.projectionOffset)==null?void 0:q[1])||0]}})}}),e.jsxRuntimeExports.jsx(e.Label,{children:"Y"}),e.jsxRuntimeExports.jsx(e.Input,{className:`h-9 w-full ${e.removeRing}`,type:"number",step:10,value:((d=(N=(F=s.preferences)==null?void 0:F.mapVisualOptions)==null?void 0:N.projectionOffset)==null?void 0:d[1])||0,onChange:j=>{var k,I,O,q;o({...s.preferences,mapVisualOptions:{...(k=s.preferences)==null?void 0:k.mapVisualOptions,projectionOffset:[((q=(O=(I=s.preferences)==null?void 0:I.mapVisualOptions)==null?void 0:O.projectionOffset)==null?void 0:q[0])||0,Number(j.target.value)]}})}})]})}),e.jsxRuntimeExports.jsx(e.Separator,{className:"my-4"}),e.jsxRuntimeExports.jsx(le,{})]})}function Ht(){var n;const s=e.useEditorStore(o=>o.card.preferences),{setCardPreferences:r}=e.useEditorStore(o=>o.actions);function t(o){r({...s,textVisualOptions:{...s==null?void 0:s.textVisualOptions,isDynamicText:o==="dynamic"}})}return e.jsxRuntimeExports.jsxs(e.RadioGroup,{value:(n=s==null?void 0:s.textVisualOptions)!=null&&n.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 je({cardType:s,docContent:r,suffix:t="Chart"}){let n="pie-chart";return s==="radar"&&(n="radar-chart"),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:r||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:o=>o.stopPropagation(),className:"text-blue-700",href:`https://docs.semaphor.cloud/concepts/visuals#${n}`,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(Le,{}),s==="text"&&e.jsxRuntimeExports.jsx(Ht,{})]})]}),!["range","text"].includes(s)&&e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-3",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{children:"Filters"}),e.jsxRuntimeExports.jsxs(e.AccordionContent,{className:"space-y-4 px-2",children:[e.jsxRuntimeExports.jsx(le,{}),e.jsxRuntimeExports.jsx(xe,{})]})]})]})})}function Pt(){const s=e.useEditorStore(n=>{var o,i;return(i=(o=n==null?void 0:n.card)==null?void 0:o.preferences)==null?void 0:i.sortChart}),{setSortChart:r}=e.useEditorActions();function t(){return e.jsxRuntimeExports.jsxs("div",{className:"space-y-2",children:[e.jsxRuntimeExports.jsx(e.Label,{children:"Sort"}),e.jsxRuntimeExports.jsx(se,{className:"h-8",label:"Sort Chart",options:[{label:"None",value:"none"},{label:"ASC",value:"asc"},{label:"DESC",value:"desc"}],value:s||"none",onValueChange:n=>{r(n)}})]})}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:n=>n.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,{}),t(),e.jsxRuntimeExports.jsx(Os,{})]})]}),e.jsxRuntimeExports.jsxs(e.AccordionItem,{value:"item-3",children:[e.jsxRuntimeExports.jsx(e.AccordionTrigger,{children:"Filters"}),e.jsxRuntimeExports.jsxs(e.AccordionContent,{className:"space-y-4 px-2",children:[e.jsxRuntimeExports.jsx(le,{}),e.jsxRuntimeExports.jsx(xe,{})]})]})]})})}function Gt({}){const s=e.useEditorStore(n=>{var o;return(o=n.card)==null?void 0:o.preferences}),r=e.useEditorStore(n=>n.actions.setCardPreferences),t=n=>{r({...s,allowDownload:n})};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:"Filters"}),e.jsxRuntimeExports.jsxs(e.AccordionContent,{className:"space-y-4 px-2",children:[e.jsxRuntimeExports.jsx(le,{}),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 Ut=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."]})]}),Qt=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."]})]}),$t=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 Jt(){const s=e.useEditorStore(t=>t.card.type);function r(t){switch(t){case"stackedBar":case"stackedLine":return e.jsxRuntimeExports.jsx(Pt,{});case"pyramid":return e.jsxRuntimeExports.jsx(je,{docContent:Ut,cardType:t});case"kpi":return e.jsxRuntimeExports.jsx(Ft,{});case"line":case"bar":return e.jsxRuntimeExports.jsx(Dt,{cardType:t});case"range":return e.jsxRuntimeExports.jsx(je,{docContent:Qt,cardType:t});case"pie":case"doughnut":case"polarArea":case"radar":return e.jsxRuntimeExports.jsx(je,{cardType:t});case"bubble":case"scatter":return e.jsxRuntimeExports.jsx(Tt,{cardType:t});case"table":return e.jsxRuntimeExports.jsx(Gt,{cardType:t});case"text":return e.jsxRuntimeExports.jsx(je,{docContent:$t,cardType:t,suffix:"Visual"});case"map":return e.jsxRuntimeExports.jsx(Bt,{});case"custom":return e.jsxRuntimeExports.jsx(Nt,{});default:return e.jsxRuntimeExports.jsx(zt,{})}}return e.jsxRuntimeExports.jsx(e.ScrollArea,{className:"h-full w-full text-sm",children:r(s)})}function Kt(){const s=e.useEditorStore(r=>r.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(ut,{})}),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(Jt,{})})}),e.jsxRuntimeExports.jsx(e.ResizableHandle,{className:"border"}),e.jsxRuntimeExports.jsx(e.ResizablePanel,{minSize:40,defaultSize:75,maxSize:100,children:e.jsxRuntimeExports.jsx(Pe,{})})]}):e.jsxRuntimeExports.jsx(Pe,{})})]})}function Wt({authToken:s,onSave:r,onClose:t}){e.useDashboardStore(a=>a.themeStyle);const n=e.useEditorStore(a=>a.actions.setOnSave),o=e.useEditorStore(a=>a.actions.setOnClose),i=e.useDashboardStore(a=>a.actions.setAuthToken);return R.useEffect(()=>{r&&n(r),t&&o(t)},[r,n,t,o]),R.useEffect(()=>{s&&s.accessToken&&i(s)},[s,i]),e.jsxRuntimeExports.jsx(e.ErrorBoundary,{FallbackComponent:e.Fallback,children:e.jsxRuntimeExports.jsxs(e.EditorPanel,{style:{},className:"rounded-none",role:"editor-panel",children:[e.jsxRuntimeExports.jsx(e.EditorAside,{className:"rounded-none border-r-[1.5px]",children:e.jsxRuntimeExports.jsx(gs,{})}),e.jsxRuntimeExports.jsx(e.EditorMain,{children:e.jsxRuntimeExports.jsx(Kt,{})})]})})}function Xt(){e.useDashboardStore(a=>a.selectedCardId);const s=e.useDashboardStore(a=>a.selectedSheetId),{setIsVisualEditing:r}=e.useDashboardStore(a=>a.actions),t=e.useDashboardStore(a=>a.isVisualEditing),n=e.useDashboardStore(a=>a.actions.updateFrame);function o(a){s&&(n(s,a),r(!1))}function i(){r(!1)}return e.jsxRuntimeExports.jsx("div",{role:"editor-container",className:e.cn("flex grow",{"max-h-0 overflow-hidden":!t}),children:e.jsxRuntimeExports.jsx(Wt,{onSave:o,onClose:i})})}function Yt(){const s=e.useEditorStore(i=>i.selectedDatabaseName),r=e.useEditorStore(i=>i.selectedTableName),t=e.useDashboardStore(i=>i.dashboard.filters)||[],{columns:n}=oe(),{assignFilter:o}=Ms();return e.jsxRuntimeExports.jsx(e.ScrollArea,{className:"flex-1 basis-0 flex-col px-3",children:n==null?void 0:n.map(i=>{const a=t==null?void 0:t.find(l=>l.column===e.fmt(i.column_name)&&l.table===r&&l.database===s);return e.jsxRuntimeExports.jsx("div",{onClick:()=>o(i),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":a}),children:e.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxRuntimeExports.jsx(fs,{column:i}),e.jsxRuntimeExports.jsx("span",{children:i.column_name})]})},i.column_name)})})}function Zt(){e.useDashboardStore(r=>r.showFilters);const s=e.useDashboardStore(r=>r.actions.setShowFilters);return e.jsxRuntimeExports.jsxs("section",{className:"relative flex min-w-72 grow flex-col border-l px-1",children:[e.jsxRuntimeExports.jsxs("div",{className:"mt-4 flex items-center justify-between gap-2 px-3",children:[e.jsxRuntimeExports.jsx(e.Label,{className:"px-2 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(gs,{ColumnsComponent:()=>e.jsxRuntimeExports.jsx(Yt,{})})})]})}function en(){const s=e.useDashboardStore(n=>n.dashboard.filters),r=e.useDashboardStore(n=>n.theme),t=s==null?void 0:s.filter(n=>n.hide);return t!=null&&t.length?e.jsxRuntimeExports.jsx("div",{className:e.cn("mb-1 flex items-center gap-2 border-y px-0.5 pb-0.5",{"bg-[repeating-linear-gradient(45deg,_#ffffff_0_3px,_#f3f3f3_3px_6px)]":r==="light","bg-[repeating-linear-gradient(45deg,_#18171d_0_3px,_#272729_3px_6px)]":r==="dark"}),children:t==null?void 0:t.map(n=>e.jsxRuntimeExports.jsxs("div",{className:"flex min-w-[250px] max-w-fit flex-col gap-1 p-2",children:[e.jsxRuntimeExports.jsx(e.FilterHeader,{filter:n}),e.jsxRuntimeExports.jsx(e.FilterComponent,{filter:n})]},n.id))}):null}function sn(){const s=e.useDashboardStore(n=>n.showFilters),r=e.useDashboardStore(n=>n.isVisualEditing),t=e.useDashboardStore(n=>n.isDashboardEditing);return e.jsxRuntimeExports.jsxs("div",{role:"dashboard-plus-main",className:e.cn("",{"max-h-0 overflow-hidden":r,"flex grow":!r}),children:[e.jsxRuntimeExports.jsxs("section",{className:"flex grow flex-col",children:[t&&e.jsxRuntimeExports.jsx(en,{}),e.jsxRuntimeExports.jsx(e.DashboardTabs,{})]}),s&&e.jsxRuntimeExports.jsx("div",{role:"filter-aside-container",className:"flex",children:e.jsxRuntimeExports.jsx(Zt,{})})]})}function tn(){const s=e.useDashboardStore(n=>n.dashboard),r=e.useDashboardStore(n=>n.actions.setDashboard),t=e.useDashboardStore(n=>n.showDashboardJSON);return e.useDashboardStore(n=>n.actions.setShowDashboardJSON),e.jsxRuntimeExports.jsx("div",{className:e.cn(" p-2",{hidden:!t}),children:e.jsxRuntimeExports.jsx(e.de,{onChange:n=>{if(n)try{JSON.parse(n),r(JSON.parse(n))}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 nn({showControls:s=!1,showFooter:r=!0,...t}){return e.jsxRuntimeExports.jsx(e.ErrorBoundary,{FallbackComponent:e.Fallback,children:e.jsxRuntimeExports.jsxs(e.SemaphorContextProvider,{dashboardProps:t,children:[e.jsxRuntimeExports.jsx(e.Oe,{}),e.jsxRuntimeExports.jsxs(e.UXProvider,{children:[e.jsxRuntimeExports.jsx(tn,{}),e.jsxRuntimeExports.jsxs(e.DashboardPanel,{...t,children:[s&&e.jsxRuntimeExports.jsx(Gs,{}),e.jsxRuntimeExports.jsx(Xt,{}),e.jsxRuntimeExports.jsx(sn,{})]})]})]})})}exports.Box=Ue;exports.Braces=Qe;exports.ChartArea=$e;exports.ChartColumnIncreasing=fe;exports.ChartLine=ge;exports.ChartNoAxesGantt=Ne;exports.ChartPie=we;exports.ChartScatter=ke;exports.CircleX=Je;exports.CopyPlus=Ke;exports.DashboardPlus=nn;exports.Database=We;exports.EllipsisVertical=Re;exports.Eraser=Xe;exports.EyeClosed=Ye;exports.Glasses=Ze;exports.Hammer=es;exports.Hash=ss;exports.House=ts;exports.ListEnd=ns;exports.ListStart=rs;exports.ListX=os;exports.LoaderCircle=ae;exports.Map=Ie;exports.MessageSquareMore=is;exports.Network=as;exports.Play=ls;exports.Plug2=cs;exports.Save=xs;exports.SelectComponent=ce;exports.Shapes=De;exports.ShieldQuestion=us;exports.Sigma=ds;exports.SwatchBook=ms;exports.Tag=ps;exports.TicketX=js;exports.ToggleLeft=hs;exports.Type=be;exports.cleanCard=Es;exports.getDashbaordStateWithoutData=Te;exports.useEditorAside=oe;
|