react-semaphor 0.0.431 → 0.0.432

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/index.cjs CHANGED
@@ -1,99 +1,99 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./chunks/index-df1PwnFc.js"),e=require("react/jsx-runtime"),E=require("react");require("react-dom");function es(s){const a=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(s){for(const n in s)if(n!=="default"){const r=Object.getOwnPropertyDescriptor(s,n);Object.defineProperty(a,n,r.get?r:{enumerable:!0,get:()=>s[n]})}}return a.default=s,Object.freeze(a)}const ce=es(E);/**
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./chunks/index-6FRhq_ij.js"),e=require("react/jsx-runtime"),E=require("react");require("react-dom");function ss(s){const a=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(s){for(const n in s)if(n!=="default"){const r=Object.getOwnPropertyDescriptor(s,n);Object.defineProperty(a,n,r.get?r:{enumerable:!0,get:()=>s[n]})}}return a.default=s,Object.freeze(a)}const de=ss(E);/**
2
2
  * @license lucide-react v0.453.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
5
5
  * See the LICENSE file in the root directory of this source tree.
6
- */const ts=t.createLucideIcon("AlignCenter",[["path",{d:"M17 12H7",key:"16if0g"}],["path",{d:"M19 18H5",key:"18s9l3"}],["path",{d:"M21 6H3",key:"1jwq7v"}]]);/**
6
+ */const ns=t.createLucideIcon("AlignCenter",[["path",{d:"M17 12H7",key:"16if0g"}],["path",{d:"M19 18H5",key:"18s9l3"}],["path",{d:"M21 6H3",key:"1jwq7v"}]]);/**
7
7
  * @license lucide-react v0.453.0 - ISC
8
8
  *
9
9
  * This source code is licensed under the ISC license.
10
10
  * See the LICENSE file in the root directory of this source tree.
11
- */const ss=t.createLucideIcon("AlignLeft",[["path",{d:"M15 12H3",key:"6jk70r"}],["path",{d:"M17 18H3",key:"1amg6g"}],["path",{d:"M21 6H3",key:"1jwq7v"}]]);/**
11
+ */const as=t.createLucideIcon("AlignLeft",[["path",{d:"M15 12H3",key:"6jk70r"}],["path",{d:"M17 18H3",key:"1amg6g"}],["path",{d:"M21 6H3",key:"1jwq7v"}]]);/**
12
12
  * @license lucide-react v0.453.0 - ISC
13
13
  *
14
14
  * This source code is licensed under the ISC license.
15
15
  * See the LICENSE file in the root directory of this source tree.
16
- */const ns=t.createLucideIcon("AlignRight",[["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M21 18H7",key:"1ygte8"}],["path",{d:"M21 6H3",key:"1jwq7v"}]]);/**
16
+ */const rs=t.createLucideIcon("AlignRight",[["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M21 18H7",key:"1ygte8"}],["path",{d:"M21 6H3",key:"1jwq7v"}]]);/**
17
17
  * @license lucide-react v0.453.0 - ISC
18
18
  *
19
19
  * This source code is licensed under the ISC license.
20
20
  * See the LICENSE file in the root directory of this source tree.
21
- */const as=t.createLucideIcon("ArrowDown10",[["path",{d:"m3 16 4 4 4-4",key:"1co6wj"}],["path",{d:"M7 20V4",key:"1yoxec"}],["path",{d:"M17 10V4h-2",key:"zcsr5x"}],["path",{d:"M15 10h4",key:"id2lce"}],["rect",{x:"15",y:"14",width:"4",height:"6",ry:"2",key:"33xykx"}]]);/**
21
+ */const os=t.createLucideIcon("ArrowDown10",[["path",{d:"m3 16 4 4 4-4",key:"1co6wj"}],["path",{d:"M7 20V4",key:"1yoxec"}],["path",{d:"M17 10V4h-2",key:"zcsr5x"}],["path",{d:"M15 10h4",key:"id2lce"}],["rect",{x:"15",y:"14",width:"4",height:"6",ry:"2",key:"33xykx"}]]);/**
22
22
  * @license lucide-react v0.453.0 - ISC
23
23
  *
24
24
  * This source code is licensed under the ISC license.
25
25
  * See the LICENSE file in the root directory of this source tree.
26
- */const rs=t.createLucideIcon("ArrowDownToLine",[["path",{d:"M12 17V3",key:"1cwfxf"}],["path",{d:"m6 11 6 6 6-6",key:"12ii2o"}],["path",{d:"M19 21H5",key:"150jfl"}]]);/**
26
+ */const is=t.createLucideIcon("ArrowDownToLine",[["path",{d:"M12 17V3",key:"1cwfxf"}],["path",{d:"m6 11 6 6 6-6",key:"12ii2o"}],["path",{d:"M19 21H5",key:"150jfl"}]]);/**
27
27
  * @license lucide-react v0.453.0 - ISC
28
28
  *
29
29
  * This source code is licensed under the ISC license.
30
30
  * See the LICENSE file in the root directory of this source tree.
31
- */const os=t.createLucideIcon("ArrowDownZA",[["path",{d:"m3 16 4 4 4-4",key:"1co6wj"}],["path",{d:"M7 4v16",key:"1glfcx"}],["path",{d:"M15 4h5l-5 6h5",key:"8asdl1"}],["path",{d:"M15 20v-3.5a2.5 2.5 0 0 1 5 0V20",key:"r6l5cz"}],["path",{d:"M20 18h-5",key:"18j1r2"}]]);/**
31
+ */const ls=t.createLucideIcon("ArrowDownZA",[["path",{d:"m3 16 4 4 4-4",key:"1co6wj"}],["path",{d:"M7 4v16",key:"1glfcx"}],["path",{d:"M15 4h5l-5 6h5",key:"8asdl1"}],["path",{d:"M15 20v-3.5a2.5 2.5 0 0 1 5 0V20",key:"r6l5cz"}],["path",{d:"M20 18h-5",key:"18j1r2"}]]);/**
32
32
  * @license lucide-react v0.453.0 - ISC
33
33
  *
34
34
  * This source code is licensed under the ISC license.
35
35
  * See the LICENSE file in the root directory of this source tree.
36
- */const is=t.createLucideIcon("ArrowDown",[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]]);/**
36
+ */const cs=t.createLucideIcon("ArrowDown",[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]]);/**
37
37
  * @license lucide-react v0.453.0 - ISC
38
38
  *
39
39
  * This source code is licensed under the ISC license.
40
40
  * See the LICENSE file in the root directory of this source tree.
41
- */const ls=t.createLucideIcon("ArrowLeftRight",[["path",{d:"M8 3 4 7l4 4",key:"9rb6wj"}],["path",{d:"M4 7h16",key:"6tx8e3"}],["path",{d:"m16 21 4-4-4-4",key:"siv7j2"}],["path",{d:"M20 17H4",key:"h6l3hr"}]]);/**
41
+ */const ds=t.createLucideIcon("ArrowLeftRight",[["path",{d:"M8 3 4 7l4 4",key:"9rb6wj"}],["path",{d:"M4 7h16",key:"6tx8e3"}],["path",{d:"m16 21 4-4-4-4",key:"siv7j2"}],["path",{d:"M20 17H4",key:"h6l3hr"}]]);/**
42
42
  * @license lucide-react v0.453.0 - ISC
43
43
  *
44
44
  * This source code is licensed under the ISC license.
45
45
  * See the LICENSE file in the root directory of this source tree.
46
- */const cs=t.createLucideIcon("ArrowLeft",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]);/**
46
+ */const us=t.createLucideIcon("ArrowLeft",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]);/**
47
47
  * @license lucide-react v0.453.0 - ISC
48
48
  *
49
49
  * This source code is licensed under the ISC license.
50
50
  * See the LICENSE file in the root directory of this source tree.
51
- */const ds=t.createLucideIcon("ArrowRight",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]]);/**
51
+ */const ms=t.createLucideIcon("ArrowRight",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]]);/**
52
52
  * @license lucide-react v0.453.0 - ISC
53
53
  *
54
54
  * This source code is licensed under the ISC license.
55
55
  * See the LICENSE file in the root directory of this source tree.
56
- */const us=t.createLucideIcon("ArrowUp01",[["path",{d:"m3 8 4-4 4 4",key:"11wl7u"}],["path",{d:"M7 4v16",key:"1glfcx"}],["rect",{x:"15",y:"4",width:"4",height:"6",ry:"2",key:"1bwicg"}],["path",{d:"M17 20v-6h-2",key:"1qp1so"}],["path",{d:"M15 20h4",key:"1j968p"}]]);/**
56
+ */const hs=t.createLucideIcon("ArrowUp01",[["path",{d:"m3 8 4-4 4 4",key:"11wl7u"}],["path",{d:"M7 4v16",key:"1glfcx"}],["rect",{x:"15",y:"4",width:"4",height:"6",ry:"2",key:"1bwicg"}],["path",{d:"M17 20v-6h-2",key:"1qp1so"}],["path",{d:"M15 20h4",key:"1j968p"}]]);/**
57
57
  * @license lucide-react v0.453.0 - ISC
58
58
  *
59
59
  * This source code is licensed under the ISC license.
60
60
  * See the LICENSE file in the root directory of this source tree.
61
- */const ms=t.createLucideIcon("ArrowUpAZ",[["path",{d:"m3 8 4-4 4 4",key:"11wl7u"}],["path",{d:"M7 4v16",key:"1glfcx"}],["path",{d:"M20 8h-5",key:"1vsyxs"}],["path",{d:"M15 10V6.5a2.5 2.5 0 0 1 5 0V10",key:"ag13bf"}],["path",{d:"M15 14h5l-5 6h5",key:"ur5jdg"}]]);/**
61
+ */const ps=t.createLucideIcon("ArrowUpAZ",[["path",{d:"m3 8 4-4 4 4",key:"11wl7u"}],["path",{d:"M7 4v16",key:"1glfcx"}],["path",{d:"M20 8h-5",key:"1vsyxs"}],["path",{d:"M15 10V6.5a2.5 2.5 0 0 1 5 0V10",key:"ag13bf"}],["path",{d:"M15 14h5l-5 6h5",key:"ur5jdg"}]]);/**
62
62
  * @license lucide-react v0.453.0 - ISC
63
63
  *
64
64
  * This source code is licensed under the ISC license.
65
65
  * See the LICENSE file in the root directory of this source tree.
66
- */const hs=t.createLucideIcon("ArrowUpToLine",[["path",{d:"M5 3h14",key:"7usisc"}],["path",{d:"m18 13-6-6-6 6",key:"1kf1n9"}],["path",{d:"M12 7v14",key:"1akyts"}]]);/**
66
+ */const xs=t.createLucideIcon("ArrowUpToLine",[["path",{d:"M5 3h14",key:"7usisc"}],["path",{d:"m18 13-6-6-6 6",key:"1kf1n9"}],["path",{d:"M12 7v14",key:"1akyts"}]]);/**
67
67
  * @license lucide-react v0.453.0 - ISC
68
68
  *
69
69
  * This source code is licensed under the ISC license.
70
70
  * See the LICENSE file in the root directory of this source tree.
71
- */const ps=t.createLucideIcon("Blocks",[["rect",{width:"7",height:"7",x:"14",y:"3",rx:"1",key:"6d4xhi"}],["path",{d:"M10 21V8a1 1 0 0 0-1-1H4a1 1 0 0 0-1 1v12a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-5a1 1 0 0 0-1-1H3",key:"1fpvtg"}]]);/**
71
+ */const fs=t.createLucideIcon("Blocks",[["rect",{width:"7",height:"7",x:"14",y:"3",rx:"1",key:"6d4xhi"}],["path",{d:"M10 21V8a1 1 0 0 0-1-1H4a1 1 0 0 0-1 1v12a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-5a1 1 0 0 0-1-1H3",key:"1fpvtg"}]]);/**
72
72
  * @license lucide-react v0.453.0 - ISC
73
73
  *
74
74
  * This source code is licensed under the ISC license.
75
75
  * See the LICENSE file in the root directory of this source tree.
76
- */const xs=t.createLucideIcon("BookOpenText",[["path",{d:"M12 7v14",key:"1akyts"}],["path",{d:"M16 12h2",key:"7q9ll5"}],["path",{d:"M16 8h2",key:"msurwy"}],["path",{d:"M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z",key:"ruj8y"}],["path",{d:"M6 12h2",key:"32wvfc"}],["path",{d:"M6 8h2",key:"30oboj"}]]);/**
76
+ */const gs=t.createLucideIcon("BookOpenText",[["path",{d:"M12 7v14",key:"1akyts"}],["path",{d:"M16 12h2",key:"7q9ll5"}],["path",{d:"M16 8h2",key:"msurwy"}],["path",{d:"M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z",key:"ruj8y"}],["path",{d:"M6 12h2",key:"32wvfc"}],["path",{d:"M6 8h2",key:"30oboj"}]]);/**
77
77
  * @license lucide-react v0.453.0 - ISC
78
78
  *
79
79
  * This source code is licensed under the ISC license.
80
80
  * See the LICENSE file in the root directory of this source tree.
81
- */const fs=t.createLucideIcon("BookType",[["path",{d:"M10 13h4",key:"ytezjc"}],["path",{d:"M12 6v7",key:"1f6ttz"}],["path",{d:"M16 8V6H8v2",key:"x8j6u4"}],["path",{d:"M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H19a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H6.5a1 1 0 0 1 0-5H20",key:"k3hazp"}]]);/**
81
+ */const js=t.createLucideIcon("BookType",[["path",{d:"M10 13h4",key:"ytezjc"}],["path",{d:"M12 6v7",key:"1f6ttz"}],["path",{d:"M16 8V6H8v2",key:"x8j6u4"}],["path",{d:"M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H19a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H6.5a1 1 0 0 1 0-5H20",key:"k3hazp"}]]);/**
82
82
  * @license lucide-react v0.453.0 - ISC
83
83
  *
84
84
  * This source code is licensed under the ISC license.
85
85
  * See the LICENSE file in the root directory of this source tree.
86
- */const gs=t.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"}]]);/**
86
+ */const ys=t.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"}]]);/**
87
87
  * @license lucide-react v0.453.0 - ISC
88
88
  *
89
89
  * This source code is licensed under the ISC license.
90
90
  * See the LICENSE file in the root directory of this source tree.
91
- */const js=t.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"}]]);/**
91
+ */const bs=t.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"}]]);/**
92
92
  * @license lucide-react v0.453.0 - ISC
93
93
  *
94
94
  * This source code is licensed under the ISC license.
95
95
  * See the LICENSE file in the root directory of this source tree.
96
- */const ys=t.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"}]]);/**
96
+ */const Ss=t.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"}]]);/**
97
97
  * @license lucide-react v0.453.0 - ISC
98
98
  *
99
99
  * This source code is licensed under the ISC license.
@@ -103,7 +103,7 @@
103
103
  *
104
104
  * This source code is licensed under the ISC license.
105
105
  * See the LICENSE file in the root directory of this source tree.
106
- */const it=t.createLucideIcon("ChartColumnStacked",[["path",{d:"M11 13H7",key:"t0o9gq"}],["path",{d:"M19 9h-4",key:"rera1j"}],["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["rect",{x:"15",y:"5",width:"4",height:"12",rx:"1",key:"q8uenq"}],["rect",{x:"7",y:"8",width:"4",height:"9",rx:"1",key:"sr5ea"}]]);/**
106
+ */const ot=t.createLucideIcon("ChartColumnStacked",[["path",{d:"M11 13H7",key:"t0o9gq"}],["path",{d:"M19 9h-4",key:"rera1j"}],["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["rect",{x:"15",y:"5",width:"4",height:"12",rx:"1",key:"q8uenq"}],["rect",{x:"7",y:"8",width:"4",height:"9",rx:"1",key:"sr5ea"}]]);/**
107
107
  * @license lucide-react v0.453.0 - ISC
108
108
  *
109
109
  * This source code is licensed under the ISC license.
@@ -113,232 +113,232 @@
113
113
  *
114
114
  * This source code is licensed under the ISC license.
115
115
  * See the LICENSE file in the root directory of this source tree.
116
- */const lt=t.createLucideIcon("ChartNoAxesGantt",[["path",{d:"M8 6h10",key:"9lnwnk"}],["path",{d:"M6 12h9",key:"1g9pqf"}],["path",{d:"M11 18h7",key:"c8dzvl"}]]);/**
116
+ */const it=t.createLucideIcon("ChartNoAxesGantt",[["path",{d:"M8 6h10",key:"9lnwnk"}],["path",{d:"M6 12h9",key:"1g9pqf"}],["path",{d:"M11 18h7",key:"c8dzvl"}]]);/**
117
117
  * @license lucide-react v0.453.0 - ISC
118
118
  *
119
119
  * This source code is licensed under the ISC license.
120
120
  * See the LICENSE file in the root directory of this source tree.
121
- */const ct=t.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"}]]);/**
121
+ */const lt=t.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"}]]);/**
122
122
  * @license lucide-react v0.453.0 - ISC
123
123
  *
124
124
  * This source code is licensed under the ISC license.
125
125
  * See the LICENSE file in the root directory of this source tree.
126
- */const dt=t.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"}]]);/**
126
+ */const ct=t.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"}]]);/**
127
127
  * @license lucide-react v0.453.0 - ISC
128
128
  *
129
129
  * This source code is licensed under the ISC license.
130
130
  * See the LICENSE file in the root directory of this source tree.
131
- */const bs=t.createLucideIcon("CircleArrowRight",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M8 12h8",key:"1wcyev"}],["path",{d:"m12 16 4-4-4-4",key:"1i9zcv"}]]);/**
131
+ */const Cs=t.createLucideIcon("CircleArrowRight",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M8 12h8",key:"1wcyev"}],["path",{d:"m12 16 4-4-4-4",key:"1i9zcv"}]]);/**
132
132
  * @license lucide-react v0.453.0 - ISC
133
133
  *
134
134
  * This source code is licensed under the ISC license.
135
135
  * See the LICENSE file in the root directory of this source tree.
136
- */const ut=t.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"}]]);/**
136
+ */const dt=t.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"}]]);/**
137
137
  * @license lucide-react v0.453.0 - ISC
138
138
  *
139
139
  * This source code is licensed under the ISC license.
140
140
  * See the LICENSE file in the root directory of this source tree.
141
- */const Ss=t.createLucideIcon("Clock",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16 14",key:"68esgv"}]]);/**
141
+ */const vs=t.createLucideIcon("Clock",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16 14",key:"68esgv"}]]);/**
142
142
  * @license lucide-react v0.453.0 - ISC
143
143
  *
144
144
  * This source code is licensed under the ISC license.
145
145
  * See the LICENSE file in the root directory of this source tree.
146
- */const Cs=t.createLucideIcon("Columns3",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"M15 3v18",key:"14nvp0"}]]);/**
146
+ */const Ns=t.createLucideIcon("Columns3",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"M15 3v18",key:"14nvp0"}]]);/**
147
147
  * @license lucide-react v0.453.0 - ISC
148
148
  *
149
149
  * This source code is licensed under the ISC license.
150
150
  * See the LICENSE file in the root directory of this source tree.
151
- */const vs=t.createLucideIcon("Component",[["path",{d:"M15.536 11.293a1 1 0 0 0 0 1.414l2.376 2.377a1 1 0 0 0 1.414 0l2.377-2.377a1 1 0 0 0 0-1.414l-2.377-2.377a1 1 0 0 0-1.414 0z",key:"1uwlt4"}],["path",{d:"M2.297 11.293a1 1 0 0 0 0 1.414l2.377 2.377a1 1 0 0 0 1.414 0l2.377-2.377a1 1 0 0 0 0-1.414L6.088 8.916a1 1 0 0 0-1.414 0z",key:"10291m"}],["path",{d:"M8.916 17.912a1 1 0 0 0 0 1.415l2.377 2.376a1 1 0 0 0 1.414 0l2.377-2.376a1 1 0 0 0 0-1.415l-2.377-2.376a1 1 0 0 0-1.414 0z",key:"1tqoq1"}],["path",{d:"M8.916 4.674a1 1 0 0 0 0 1.414l2.377 2.376a1 1 0 0 0 1.414 0l2.377-2.376a1 1 0 0 0 0-1.414l-2.377-2.377a1 1 0 0 0-1.414 0z",key:"1x6lto"}]]);/**
151
+ */const ws=t.createLucideIcon("Component",[["path",{d:"M15.536 11.293a1 1 0 0 0 0 1.414l2.376 2.377a1 1 0 0 0 1.414 0l2.377-2.377a1 1 0 0 0 0-1.414l-2.377-2.377a1 1 0 0 0-1.414 0z",key:"1uwlt4"}],["path",{d:"M2.297 11.293a1 1 0 0 0 0 1.414l2.377 2.377a1 1 0 0 0 1.414 0l2.377-2.377a1 1 0 0 0 0-1.414L6.088 8.916a1 1 0 0 0-1.414 0z",key:"10291m"}],["path",{d:"M8.916 17.912a1 1 0 0 0 0 1.415l2.377 2.376a1 1 0 0 0 1.414 0l2.377-2.376a1 1 0 0 0 0-1.415l-2.377-2.376a1 1 0 0 0-1.414 0z",key:"1tqoq1"}],["path",{d:"M8.916 4.674a1 1 0 0 0 0 1.414l2.377 2.376a1 1 0 0 0 1.414 0l2.377-2.376a1 1 0 0 0 0-1.414l-2.377-2.377a1 1 0 0 0-1.414 0z",key:"1x6lto"}]]);/**
152
152
  * @license lucide-react v0.453.0 - ISC
153
153
  *
154
154
  * This source code is licensed under the ISC license.
155
155
  * See the LICENSE file in the root directory of this source tree.
156
- */const Ns=t.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"}]]);/**
156
+ */const ks=t.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"}]]);/**
157
157
  * @license lucide-react v0.453.0 - ISC
158
158
  *
159
159
  * This source code is licensed under the ISC license.
160
160
  * See the LICENSE file in the root directory of this source tree.
161
- */const ws=t.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"}]]);/**
161
+ */const Is=t.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"}]]);/**
162
162
  * @license lucide-react v0.453.0 - ISC
163
163
  *
164
164
  * This source code is licensed under the ISC license.
165
165
  * See the LICENSE file in the root directory of this source tree.
166
- */const mt=t.createLucideIcon("Donut",[["path",{d:"M20.5 10a2.5 2.5 0 0 1-2.4-3H18a2.95 2.95 0 0 1-2.6-4.4 10 10 0 1 0 6.3 7.1c-.3.2-.8.3-1.2.3",key:"19sr3x"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);/**
166
+ */const ut=t.createLucideIcon("Donut",[["path",{d:"M20.5 10a2.5 2.5 0 0 1-2.4-3H18a2.95 2.95 0 0 1-2.6-4.4 10 10 0 1 0 6.3 7.1c-.3.2-.8.3-1.2.3",key:"19sr3x"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);/**
167
167
  * @license lucide-react v0.453.0 - ISC
168
168
  *
169
169
  * This source code is licensed under the ISC license.
170
170
  * See the LICENSE file in the root directory of this source tree.
171
- */const ht=t.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"}]]);/**
171
+ */const mt=t.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"}]]);/**
172
172
  * @license lucide-react v0.453.0 - ISC
173
173
  *
174
174
  * This source code is licensed under the ISC license.
175
175
  * See the LICENSE file in the root directory of this source tree.
176
- */const ks=t.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"}]]);/**
176
+ */const Ds=t.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"}]]);/**
177
177
  * @license lucide-react v0.453.0 - ISC
178
178
  *
179
179
  * This source code is licensed under the ISC license.
180
180
  * See the LICENSE file in the root directory of this source tree.
181
- */const pt=t.createLucideIcon("Expand",[["path",{d:"m21 21-6-6m6 6v-4.8m0 4.8h-4.8",key:"1c15vz"}],["path",{d:"M3 16.2V21m0 0h4.8M3 21l6-6",key:"1fsnz2"}],["path",{d:"M21 7.8V3m0 0h-4.8M21 3l-6 6",key:"hawz9i"}],["path",{d:"M3 7.8V3m0 0h4.8M3 3l6 6",key:"u9ee12"}]]);/**
181
+ */const ht=t.createLucideIcon("Expand",[["path",{d:"m21 21-6-6m6 6v-4.8m0 4.8h-4.8",key:"1c15vz"}],["path",{d:"M3 16.2V21m0 0h4.8M3 21l6-6",key:"1fsnz2"}],["path",{d:"M21 7.8V3m0 0h-4.8M21 3l-6 6",key:"hawz9i"}],["path",{d:"M3 7.8V3m0 0h4.8M3 3l6 6",key:"u9ee12"}]]);/**
182
182
  * @license lucide-react v0.453.0 - ISC
183
183
  *
184
184
  * This source code is licensed under the ISC license.
185
185
  * See the LICENSE file in the root directory of this source tree.
186
- */const Is=t.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"}]]);/**
186
+ */const Es=t.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"}]]);/**
187
187
  * @license lucide-react v0.453.0 - ISC
188
188
  *
189
189
  * This source code is licensed under the ISC license.
190
190
  * See the LICENSE file in the root directory of this source tree.
191
- */const Ds=t.createLucideIcon("FileJson2",[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4",key:"1pf5j1"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M4 12a1 1 0 0 0-1 1v1a1 1 0 0 1-1 1 1 1 0 0 1 1 1v1a1 1 0 0 0 1 1",key:"fq0c9t"}],["path",{d:"M8 18a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1 1 1 0 0 1-1-1v-1a1 1 0 0 0-1-1",key:"4gibmv"}]]);/**
191
+ */const Ts=t.createLucideIcon("FileJson2",[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4",key:"1pf5j1"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M4 12a1 1 0 0 0-1 1v1a1 1 0 0 1-1 1 1 1 0 0 1 1 1v1a1 1 0 0 0 1 1",key:"fq0c9t"}],["path",{d:"M8 18a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1 1 1 0 0 1-1-1v-1a1 1 0 0 0-1-1",key:"4gibmv"}]]);/**
192
192
  * @license lucide-react v0.453.0 - ISC
193
193
  *
194
194
  * This source code is licensed under the ISC license.
195
195
  * See the LICENSE file in the root directory of this source tree.
196
- */const xt=t.createLucideIcon("Filter",[["polygon",{points:"22 3 2 3 10 12.46 10 19 14 21 14 12.46 22 3",key:"1yg77f"}]]);/**
196
+ */const pt=t.createLucideIcon("Filter",[["polygon",{points:"22 3 2 3 10 12.46 10 19 14 21 14 12.46 22 3",key:"1yg77f"}]]);/**
197
197
  * @license lucide-react v0.453.0 - ISC
198
198
  *
199
199
  * This source code is licensed under the ISC license.
200
200
  * See the LICENSE file in the root directory of this source tree.
201
- */const Es=t.createLucideIcon("Fingerprint",[["path",{d:"M12 10a2 2 0 0 0-2 2c0 1.02-.1 2.51-.26 4",key:"1nerag"}],["path",{d:"M14 13.12c0 2.38 0 6.38-1 8.88",key:"o46ks0"}],["path",{d:"M17.29 21.02c.12-.6.43-2.3.5-3.02",key:"ptglia"}],["path",{d:"M2 12a10 10 0 0 1 18-6",key:"ydlgp0"}],["path",{d:"M2 16h.01",key:"1gqxmh"}],["path",{d:"M21.8 16c.2-2 .131-5.354 0-6",key:"drycrb"}],["path",{d:"M5 19.5C5.5 18 6 15 6 12a6 6 0 0 1 .34-2",key:"1tidbn"}],["path",{d:"M8.65 22c.21-.66.45-1.32.57-2",key:"13wd9y"}],["path",{d:"M9 6.8a6 6 0 0 1 9 5.2v2",key:"1fr1j5"}]]);/**
201
+ */const Ms=t.createLucideIcon("Fingerprint",[["path",{d:"M12 10a2 2 0 0 0-2 2c0 1.02-.1 2.51-.26 4",key:"1nerag"}],["path",{d:"M14 13.12c0 2.38 0 6.38-1 8.88",key:"o46ks0"}],["path",{d:"M17.29 21.02c.12-.6.43-2.3.5-3.02",key:"ptglia"}],["path",{d:"M2 12a10 10 0 0 1 18-6",key:"ydlgp0"}],["path",{d:"M2 16h.01",key:"1gqxmh"}],["path",{d:"M21.8 16c.2-2 .131-5.354 0-6",key:"drycrb"}],["path",{d:"M5 19.5C5.5 18 6 15 6 12a6 6 0 0 1 .34-2",key:"1tidbn"}],["path",{d:"M8.65 22c.21-.66.45-1.32.57-2",key:"13wd9y"}],["path",{d:"M9 6.8a6 6 0 0 1 9 5.2v2",key:"1fr1j5"}]]);/**
202
202
  * @license lucide-react v0.453.0 - ISC
203
203
  *
204
204
  * This source code is licensed under the ISC license.
205
205
  * See the LICENSE file in the root directory of this source tree.
206
- */const Ts=t.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"}]]);/**
206
+ */const As=t.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"}]]);/**
207
207
  * @license lucide-react v0.453.0 - ISC
208
208
  *
209
209
  * This source code is licensed under the ISC license.
210
210
  * See the LICENSE file in the root directory of this source tree.
211
- */const Ms=t.createLucideIcon("Grid3x3",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}],["path",{d:"M3 15h18",key:"5xshup"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"M15 3v18",key:"14nvp0"}]]);/**
211
+ */const Ls=t.createLucideIcon("Grid3x3",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}],["path",{d:"M3 15h18",key:"5xshup"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"M15 3v18",key:"14nvp0"}]]);/**
212
212
  * @license lucide-react v0.453.0 - ISC
213
213
  *
214
214
  * This source code is licensed under the ISC license.
215
215
  * See the LICENSE file in the root directory of this source tree.
216
- */const As=t.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"}]]);/**
216
+ */const Os=t.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"}]]);/**
217
217
  * @license lucide-react v0.453.0 - ISC
218
218
  *
219
219
  * This source code is licensed under the ISC license.
220
220
  * See the LICENSE file in the root directory of this source tree.
221
- */const ft=t.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"}]]);/**
221
+ */const xt=t.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"}]]);/**
222
222
  * @license lucide-react v0.453.0 - ISC
223
223
  *
224
224
  * This source code is licensed under the ISC license.
225
225
  * See the LICENSE file in the root directory of this source tree.
226
- */const Ls=t.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"}]]);/**
226
+ */const zs=t.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"}]]);/**
227
227
  * @license lucide-react v0.453.0 - ISC
228
228
  *
229
229
  * This source code is licensed under the ISC license.
230
230
  * See the LICENSE file in the root directory of this source tree.
231
- */const Os=t.createLucideIcon("LayoutList",[["rect",{width:"7",height:"7",x:"3",y:"3",rx:"1",key:"1g98yp"}],["rect",{width:"7",height:"7",x:"3",y:"14",rx:"1",key:"1bb6yr"}],["path",{d:"M14 4h7",key:"3xa0d5"}],["path",{d:"M14 9h7",key:"1icrd9"}],["path",{d:"M14 15h7",key:"1mj8o2"}],["path",{d:"M14 20h7",key:"11slyb"}]]);/**
231
+ */const Fs=t.createLucideIcon("LayoutList",[["rect",{width:"7",height:"7",x:"3",y:"3",rx:"1",key:"1g98yp"}],["rect",{width:"7",height:"7",x:"3",y:"14",rx:"1",key:"1bb6yr"}],["path",{d:"M14 4h7",key:"3xa0d5"}],["path",{d:"M14 9h7",key:"1icrd9"}],["path",{d:"M14 15h7",key:"1mj8o2"}],["path",{d:"M14 20h7",key:"11slyb"}]]);/**
232
232
  * @license lucide-react v0.453.0 - ISC
233
233
  *
234
234
  * This source code is licensed under the ISC license.
235
235
  * See the LICENSE file in the root directory of this source tree.
236
- */const zs=t.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"}]]);/**
236
+ */const Rs=t.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"}]]);/**
237
237
  * @license lucide-react v0.453.0 - ISC
238
238
  *
239
239
  * This source code is licensed under the ISC license.
240
240
  * See the LICENSE file in the root directory of this source tree.
241
- */const Fs=t.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"}]]);/**
241
+ */const Bs=t.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"}]]);/**
242
242
  * @license lucide-react v0.453.0 - ISC
243
243
  *
244
244
  * This source code is licensed under the ISC license.
245
245
  * See the LICENSE file in the root directory of this source tree.
246
- */const Rs=t.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"}]]);/**
246
+ */const _s=t.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"}]]);/**
247
247
  * @license lucide-react v0.453.0 - ISC
248
248
  *
249
249
  * This source code is licensed under the ISC license.
250
250
  * See the LICENSE file in the root directory of this source tree.
251
- */const re=t.createLucideIcon("LoaderCircle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]);/**
251
+ */const oe=t.createLucideIcon("LoaderCircle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]);/**
252
252
  * @license lucide-react v0.453.0 - ISC
253
253
  *
254
254
  * This source code is licensed under the ISC license.
255
255
  * See the LICENSE file in the root directory of this source tree.
256
- */const Bs=t.createLucideIcon("Logs",[["path",{d:"M13 12h8",key:"h98zly"}],["path",{d:"M13 18h8",key:"oe0vm4"}],["path",{d:"M13 6h8",key:"15sg57"}],["path",{d:"M3 12h1",key:"lp3yf2"}],["path",{d:"M3 18h1",key:"1eiwyy"}],["path",{d:"M3 6h1",key:"rgxa97"}],["path",{d:"M8 12h1",key:"1con00"}],["path",{d:"M8 18h1",key:"13wk12"}],["path",{d:"M8 6h1",key:"tn6mkg"}]]);/**
256
+ */const Vs=t.createLucideIcon("Logs",[["path",{d:"M13 12h8",key:"h98zly"}],["path",{d:"M13 18h8",key:"oe0vm4"}],["path",{d:"M13 6h8",key:"15sg57"}],["path",{d:"M3 12h1",key:"lp3yf2"}],["path",{d:"M3 18h1",key:"1eiwyy"}],["path",{d:"M3 6h1",key:"rgxa97"}],["path",{d:"M8 12h1",key:"1con00"}],["path",{d:"M8 18h1",key:"13wk12"}],["path",{d:"M8 6h1",key:"tn6mkg"}]]);/**
257
257
  * @license lucide-react v0.453.0 - ISC
258
258
  *
259
259
  * This source code is licensed under the ISC license.
260
260
  * See the LICENSE file in the root directory of this source tree.
261
- */const _s=t.createLucideIcon("Mail",[["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}],["path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7",key:"1ocrg3"}]]);/**
261
+ */const qs=t.createLucideIcon("Mail",[["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}],["path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7",key:"1ocrg3"}]]);/**
262
262
  * @license lucide-react v0.453.0 - ISC
263
263
  *
264
264
  * This source code is licensed under the ISC license.
265
265
  * See the LICENSE file in the root directory of this source tree.
266
- */const gt=t.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"}]]);/**
266
+ */const ft=t.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"}]]);/**
267
267
  * @license lucide-react v0.453.0 - ISC
268
268
  *
269
269
  * This source code is licensed under the ISC license.
270
270
  * See the LICENSE file in the root directory of this source tree.
271
- */const Vs=t.createLucideIcon("MessageCircleMore",[["path",{d:"M7.9 20A9 9 0 1 0 4 16.1L2 22Z",key:"vv11sd"}],["path",{d:"M8 12h.01",key:"czm47f"}],["path",{d:"M12 12h.01",key:"1mp3jc"}],["path",{d:"M16 12h.01",key:"1l6xoz"}]]);/**
271
+ */const Ps=t.createLucideIcon("MessageCircleMore",[["path",{d:"M7.9 20A9 9 0 1 0 4 16.1L2 22Z",key:"vv11sd"}],["path",{d:"M8 12h.01",key:"czm47f"}],["path",{d:"M12 12h.01",key:"1mp3jc"}],["path",{d:"M16 12h.01",key:"1l6xoz"}]]);/**
272
272
  * @license lucide-react v0.453.0 - ISC
273
273
  *
274
274
  * This source code is licensed under the ISC license.
275
275
  * See the LICENSE file in the root directory of this source tree.
276
- */const qs=t.createLucideIcon("MoveHorizontal",[["path",{d:"m18 8 4 4-4 4",key:"1ak13k"}],["path",{d:"M2 12h20",key:"9i4pu4"}],["path",{d:"m6 8-4 4 4 4",key:"15zrgr"}]]);/**
276
+ */const Hs=t.createLucideIcon("MoveHorizontal",[["path",{d:"m18 8 4 4-4 4",key:"1ak13k"}],["path",{d:"M2 12h20",key:"9i4pu4"}],["path",{d:"m6 8-4 4 4 4",key:"15zrgr"}]]);/**
277
277
  * @license lucide-react v0.453.0 - ISC
278
278
  *
279
279
  * This source code is licensed under the ISC license.
280
280
  * See the LICENSE file in the root directory of this source tree.
281
- */const Ps=t.createLucideIcon("MoveVertical",[["path",{d:"M12 2v20",key:"t6zp3m"}],["path",{d:"m8 18 4 4 4-4",key:"bh5tu3"}],["path",{d:"m8 6 4-4 4 4",key:"ybng9g"}]]);/**
281
+ */const Gs=t.createLucideIcon("MoveVertical",[["path",{d:"M12 2v20",key:"t6zp3m"}],["path",{d:"m8 18 4 4 4-4",key:"bh5tu3"}],["path",{d:"m8 6 4-4 4 4",key:"ybng9g"}]]);/**
282
282
  * @license lucide-react v0.453.0 - ISC
283
283
  *
284
284
  * This source code is licensed under the ISC license.
285
285
  * See the LICENSE file in the root directory of this source tree.
286
- */const Hs=t.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"}]]);/**
286
+ */const Us=t.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"}]]);/**
287
287
  * @license lucide-react v0.453.0 - ISC
288
288
  *
289
289
  * This source code is licensed under the ISC license.
290
290
  * See the LICENSE file in the root directory of this source tree.
291
- */const Gs=t.createLucideIcon("Plug",[["path",{d:"M12 22v-5",key:"1ega77"}],["path",{d:"M9 8V2",key:"14iosj"}],["path",{d:"M15 8V2",key:"18g5xt"}],["path",{d:"M18 8v5a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V8Z",key:"osxo6l"}]]);/**
291
+ */const $s=t.createLucideIcon("Plug",[["path",{d:"M12 22v-5",key:"1ega77"}],["path",{d:"M9 8V2",key:"14iosj"}],["path",{d:"M15 8V2",key:"18g5xt"}],["path",{d:"M18 8v5a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V8Z",key:"osxo6l"}]]);/**
292
292
  * @license lucide-react v0.453.0 - ISC
293
293
  *
294
294
  * This source code is licensed under the ISC license.
295
295
  * See the LICENSE file in the root directory of this source tree.
296
- */const jt=t.createLucideIcon("Radar",[["path",{d:"M19.07 4.93A10 10 0 0 0 6.99 3.34",key:"z3du51"}],["path",{d:"M4 6h.01",key:"oypzma"}],["path",{d:"M2.29 9.62A10 10 0 1 0 21.31 8.35",key:"qzzz0"}],["path",{d:"M16.24 7.76A6 6 0 1 0 8.23 16.67",key:"1yjesh"}],["path",{d:"M12 18h.01",key:"mhygvu"}],["path",{d:"M17.99 11.66A6 6 0 0 1 15.77 16.67",key:"1u2y91"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}],["path",{d:"m13.41 10.59 5.66-5.66",key:"mhq4k0"}]]);/**
296
+ */const gt=t.createLucideIcon("Radar",[["path",{d:"M19.07 4.93A10 10 0 0 0 6.99 3.34",key:"z3du51"}],["path",{d:"M4 6h.01",key:"oypzma"}],["path",{d:"M2.29 9.62A10 10 0 1 0 21.31 8.35",key:"qzzz0"}],["path",{d:"M16.24 7.76A6 6 0 1 0 8.23 16.67",key:"1yjesh"}],["path",{d:"M12 18h.01",key:"mhygvu"}],["path",{d:"M17.99 11.66A6 6 0 0 1 15.77 16.67",key:"1u2y91"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}],["path",{d:"m13.41 10.59 5.66-5.66",key:"mhq4k0"}]]);/**
297
297
  * @license lucide-react v0.453.0 - ISC
298
298
  *
299
299
  * This source code is licensed under the ISC license.
300
300
  * See the LICENSE file in the root directory of this source tree.
301
- */const yt=t.createLucideIcon("RefreshCw",[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]]);/**
301
+ */const jt=t.createLucideIcon("RefreshCw",[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]]);/**
302
302
  * @license lucide-react v0.453.0 - ISC
303
303
  *
304
304
  * This source code is licensed under the ISC license.
305
305
  * See the LICENSE file in the root directory of this source tree.
306
- */const Us=t.createLucideIcon("Rows3",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M21 9H3",key:"1338ky"}],["path",{d:"M21 15H3",key:"9uk58r"}]]);/**
306
+ */const Qs=t.createLucideIcon("Rows3",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M21 9H3",key:"1338ky"}],["path",{d:"M21 15H3",key:"9uk58r"}]]);/**
307
307
  * @license lucide-react v0.453.0 - ISC
308
308
  *
309
309
  * This source code is licensed under the ISC license.
310
310
  * See the LICENSE file in the root directory of this source tree.
311
- */const $s=t.createLucideIcon("Ruler",[["path",{d:"M21.3 15.3a2.4 2.4 0 0 1 0 3.4l-2.6 2.6a2.4 2.4 0 0 1-3.4 0L2.7 8.7a2.41 2.41 0 0 1 0-3.4l2.6-2.6a2.41 2.41 0 0 1 3.4 0Z",key:"icamh8"}],["path",{d:"m14.5 12.5 2-2",key:"inckbg"}],["path",{d:"m11.5 9.5 2-2",key:"fmmyf7"}],["path",{d:"m8.5 6.5 2-2",key:"vc6u1g"}],["path",{d:"m17.5 15.5 2-2",key:"wo5hmg"}]]);/**
311
+ */const Ks=t.createLucideIcon("Ruler",[["path",{d:"M21.3 15.3a2.4 2.4 0 0 1 0 3.4l-2.6 2.6a2.4 2.4 0 0 1-3.4 0L2.7 8.7a2.41 2.41 0 0 1 0-3.4l2.6-2.6a2.41 2.41 0 0 1 3.4 0Z",key:"icamh8"}],["path",{d:"m14.5 12.5 2-2",key:"inckbg"}],["path",{d:"m11.5 9.5 2-2",key:"fmmyf7"}],["path",{d:"m8.5 6.5 2-2",key:"vc6u1g"}],["path",{d:"m17.5 15.5 2-2",key:"wo5hmg"}]]);/**
312
312
  * @license lucide-react v0.453.0 - ISC
313
313
  *
314
314
  * This source code is licensed under the ISC license.
315
315
  * See the LICENSE file in the root directory of this source tree.
316
- */const Qs=t.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"}]]);/**
316
+ */const Js=t.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"}]]);/**
317
317
  * @license lucide-react v0.453.0 - ISC
318
318
  *
319
319
  * This source code is licensed under the ISC license.
320
320
  * See the LICENSE file in the root directory of this source tree.
321
- */const bt=t.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"}]]);/**
321
+ */const yt=t.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"}]]);/**
322
322
  * @license lucide-react v0.453.0 - ISC
323
323
  *
324
324
  * This source code is licensed under the ISC license.
325
325
  * See the LICENSE file in the root directory of this source tree.
326
- */const Js=t.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"}]]);/**
326
+ */const Ws=t.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"}]]);/**
327
327
  * @license lucide-react v0.453.0 - ISC
328
328
  *
329
329
  * This source code is licensed under the ISC license.
330
330
  * See the LICENSE file in the root directory of this source tree.
331
- */const Ks=t.createLucideIcon("Shrink",[["path",{d:"m15 15 6 6m-6-6v4.8m0-4.8h4.8",key:"17vawe"}],["path",{d:"M9 19.8V15m0 0H4.2M9 15l-6 6",key:"chjx8e"}],["path",{d:"M15 4.2V9m0 0h4.8M15 9l6-6",key:"lav6yq"}],["path",{d:"M9 4.2V9m0 0H4.2M9 9 3 3",key:"1pxi2q"}]]);/**
331
+ */const Ys=t.createLucideIcon("Shrink",[["path",{d:"m15 15 6 6m-6-6v4.8m0-4.8h4.8",key:"17vawe"}],["path",{d:"M9 19.8V15m0 0H4.2M9 15l-6 6",key:"chjx8e"}],["path",{d:"M15 4.2V9m0 0h4.8M15 9l6-6",key:"lav6yq"}],["path",{d:"M9 4.2V9m0 0H4.2M9 9 3 3",key:"1pxi2q"}]]);/**
332
332
  * @license lucide-react v0.453.0 - ISC
333
333
  *
334
334
  * This source code is licensed under the ISC license.
335
335
  * See the LICENSE file in the root directory of this source tree.
336
- */const St=t.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"}]]);/**
336
+ */const bt=t.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"}]]);/**
337
337
  * @license lucide-react v0.453.0 - ISC
338
338
  *
339
339
  * This source code is licensed under the ISC license.
340
340
  * See the LICENSE file in the root directory of this source tree.
341
- */const Ws=t.createLucideIcon("Square",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]);/**
341
+ */const Zs=t.createLucideIcon("Square",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]);/**
342
342
  * @license lucide-react v0.453.0 - ISC
343
343
  *
344
344
  * This source code is licensed under the ISC license.
@@ -348,27 +348,27 @@
348
348
  *
349
349
  * This source code is licensed under the ISC license.
350
350
  * See the LICENSE file in the root directory of this source tree.
351
- */const Ys=t.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"}]]);/**
351
+ */const Xs=t.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"}]]);/**
352
352
  * @license lucide-react v0.453.0 - ISC
353
353
  *
354
354
  * This source code is licensed under the ISC license.
355
355
  * See the LICENSE file in the root directory of this source tree.
356
- */const Zs=t.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"}]]);/**
356
+ */const en=t.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"}]]);/**
357
357
  * @license lucide-react v0.453.0 - ISC
358
358
  *
359
359
  * This source code is licensed under the ISC license.
360
360
  * See the LICENSE file in the root directory of this source tree.
361
- */const Ct=t.createLucideIcon("Tornado",[["path",{d:"M21 4H3",key:"1hwok0"}],["path",{d:"M18 8H6",key:"41n648"}],["path",{d:"M19 12H9",key:"1g4lpz"}],["path",{d:"M16 16h-6",key:"1j5d54"}],["path",{d:"M11 20H9",key:"39obr8"}]]);/**
361
+ */const St=t.createLucideIcon("Tornado",[["path",{d:"M21 4H3",key:"1hwok0"}],["path",{d:"M18 8H6",key:"41n648"}],["path",{d:"M19 12H9",key:"1g4lpz"}],["path",{d:"M16 16h-6",key:"1j5d54"}],["path",{d:"M11 20H9",key:"39obr8"}]]);/**
362
362
  * @license lucide-react v0.453.0 - ISC
363
363
  *
364
364
  * This source code is licensed under the ISC license.
365
365
  * See the LICENSE file in the root directory of this source tree.
366
- */const Xs=t.createLucideIcon("Trash2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]]);/**
366
+ */const tn=t.createLucideIcon("Trash2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]]);/**
367
367
  * @license lucide-react v0.453.0 - ISC
368
368
  *
369
369
  * This source code is licensed under the ISC license.
370
370
  * See the LICENSE file in the root directory of this source tree.
371
- */const vt=t.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 Ge(s){var a;return{...s,sheets:(a=s==null?void 0:s.sheets)==null?void 0:a.map(n=>{var r;return{...n,frames:(r=n.frames)==null?void 0:r.map(o=>{var c;return{...o,cards:(c=o.cards)==null?void 0:c.map(i=>Nt(i))}})}})}}function Nt(s){return{...s,customCfg:en(s.customCfg),data:[]}}function en(s){var a,n;return s?{...s,data:{...s==null?void 0:s.data,labels:[],datasets:(n=(a=s==null?void 0:s.data)==null?void 0:a.datasets)==null?void 0:n.map(r=>({...r,data:[]}))}}:null}async function tn(s,a,n,r){if(!r)return null;const o=JSON.stringify(a);return await t.postRequest("https://semaphor.cloud/api/v1/lens",r,{name:s,template:o,filterValues:n,operation:"create"})}async function ze(s,a){if(!a)return null;const{id:n,template:r,filterValues:o,isDefault:c,shared:i}=s;return await t.postRequest("https://semaphor.cloud/api/v1/lens",a,{lensId:n,template:r,filterValues:o,isDefault:c,shared:i,operation:"update"})}async function sn(s,a){return a?await t.postRequest("https://semaphor.cloud/api/v1/lens",a,{operation:"delete",lensId:s}):null}function nn(){const[s,a]=E.useState(""),[n,r]=E.useState(!1),o=t.useDashboardStore(p=>p.lenses),{setLenses:c,setSelectedLensId:i}=t.useDashboardActions(),[l,d]=E.useState(!1),[h,m]=E.useState(!1),x=t.useDashboardStore(p=>p.dashboard),f=t.useDashboardStore(p=>p.filterValues),{authToken:u}=t.useSemaphorContext();async function C(){d(!0);const p=Ge(x),y=await tn(s,p,f,u==null?void 0:u.accessToken);y&&(c([...o||[],y]),i(y.id),m(!1)),d(!1)}return e.jsxs(t.Dialog,{open:h,onOpenChange:m,children:[e.jsx(t.DialogTrigger,{asChild:!0,children:e.jsxs(t.Button,{variant:"secondary",className:"h-7 p-2",size:"sm",children:[e.jsx(t.Plus,{className:"mr-2 h-4 w-4"}),"Lens"]})}),e.jsxs(t.DialogContent,{className:"sm:max-w-[425px]",children:[e.jsxs(t.DialogHeader,{children:[e.jsx(t.DialogTitle,{children:"Create Lens"}),e.jsx(t.DialogDescription,{children:"Lenses are private by default and are only visible to you."})]}),e.jsx("div",{className:"grid gap-4 py-4",children:e.jsxs("div",{className:"grid grid-cols-8 items-center gap-4",children:[e.jsx(t.Label,{className:"text-right",children:"Name"}),e.jsx(t.Input,{value:s,onChange:p=>{a(p.target.value)},id:"name",className:"col-span-7 focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0"})]})}),n&&e.jsx("p",{className:"text-sm",children:"The lens name already exists. Use a differnet name."}),e.jsx(t.DialogFooter,{children:e.jsx(t.Button,{size:"sm",variant:"outline",type:"submit",onClick:C,disabled:l,children:l?"Creating...":"Add"})})]})]})}function an(){const[s,a]=E.useState(!1),n=t.useDashboardStore(m=>m.lenses),r=t.useDashboardStore(m=>m.selectedLensId),{setLenses:o,setSelectedLensId:c}=t.useDashboardActions(),{authToken:i}=t.useSemaphorContext();async function l(m){c(m)}async function d(m){if(await sn(m,i==null?void 0:i.accessToken)){const f=n==null?void 0:n.filter(u=>u.id!==m);o(f||[]),c("original")}}async function h(m){const x=n==null?void 0:n.map(C=>C.id===m.id?{...C,isDefault:!m.isDefault}:{...C,isDefault:!1});o(x||[]);const f={...m,isDefault:!m.isDefault};await ze(f,i==null?void 0:i.accessToken);const u=n==null?void 0:n.find(C=>C.isDefault);if(u&&u.id!==m.id){const C={...u,isDefault:!1};await ze(C,i==null?void 0:i.accessToken)}}return e.jsxs(t.DropdownMenu,{open:s,onOpenChange:a,children:[e.jsx(t.DropdownMenuTrigger,{asChild:!0,children:e.jsx(t.IconButton,{tooltip:"Lenses",className:"h-7 p-2",children:e.jsx(Ts,{className:"h-4 w-4"})})}),e.jsxs(t.DropdownMenuContent,{align:"end",className:"w-60",children:[e.jsx(t.DropdownMenuLabel,{className:"px-3",children:"Lenses"}),e.jsx(t.DropdownMenuSeparator,{}),e.jsxs(t.DropdownMenuRadioGroup,{value:r,onValueChange:l,children:[e.jsx(t.DropdownMenuRadioItem,{value:"original",children:"Original"}),n==null?void 0:n.map(m=>e.jsxs(t.DropdownMenuRadioItem,{className:"group flex justify-between gap-2",value:m.id,children:[e.jsx("p",{children:m.name}),e.jsxs("span",{className:"flex items-center gap-3",children:[e.jsx(Ls,{onClick:x=>{x.preventDefault(),h(m)},className:t.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.jsx(t.Cross2Icon,{onClick:x=>{x.preventDefault(),d(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 wt(){var c;const s=t.useDashboardStore.getState().authToken,a=t.useDashboardStore.getState().theme,n=t.useDashboardStore.getState().filterValues,r=(c=t.useDashboardStore.getState().dashboard)==null?void 0:c.title,o=t.useDashboardStore.getState().selectedSheetId;return{authToken:s,theme:a||"light",filterValues:n,dashboardTitle:r||"",selectedSheetId:o||""}}async function kt(){const s=t.useDashboardStore.getState().isDownloadingPdf,{authToken:a,theme:n,filterValues:r,dashboardTitle:o,selectedSheetId:c}=wt();if(s)return;const i=new URLSearchParams;i.set("token",(a==null?void 0:a.accessToken)||""),i.set("theme",n),i.set("filterValues",JSON.stringify(r)),i.set("selectedSheetId",c||"");const l=`https://semaphor.cloud/api/v1/generate-pdf?params=${encodeURIComponent(i.toString())}`;t.useDashboardStore.setState({isDownloadingPdf:!0});const m=(await(await fetch(l,{method:"GET",headers:{Authorization:`Bearer ${a==null?void 0:a.accessToken}`}})).json()).url,x=document.createElement("a");x.href=m;const f=`${o}-${new Date().toISOString()}.pdf`;x.download=f,x.click(),t.useDashboardStore.setState({isDownloadingPdf:!1})}function rn({iconClassName:s}){const{authToken:a}=t.useSemaphorContext();t.useDashboardStore(o=>{var c;return(c=o.dashboard)==null?void 0:c.title}),t.useDashboardStore(o=>o.theme),t.useDashboardStore(o=>o.filterValues);const n=t.useDashboardStore(o=>o.isDownloadingPdf);async function r(){await kt()}return e.jsx(t.IconButton,{tooltip:"Download PDF",className:"h-7 p-2",onClick:r,children:n?e.jsx(re,{className:t.cn("size-3.5 animate-spin",s)}):e.jsx(t.Download,{className:t.cn("size-4",s)})})}function ee({defaultValue:s,label:a,options:n,value:r,onValueChange:o,className:c,icon:i,showPlaceholderLabel:l=!0}){return e.jsxs(t.Select,{defaultValue:s,value:r,onValueChange:o,children:[e.jsx(t.SelectTrigger,{className:t.cn("w-full focus:ring-0 focus:ring-offset-0",c),children:e.jsxs("div",{className:"flex items-center gap-2",children:[i&&e.jsx("span",{children:i}),l&&e.jsx(t.SelectValue,{placeholder:a})]})}),e.jsx(t.SelectContent,{children:e.jsxs(t.SelectGroup,{children:[e.jsx(t.SelectLabel,{children:a}),n.map(d=>e.jsx(t.SelectItem,{value:d.value,children:d.label},d.value))]})})]})}const tt=[{value:"daily",label:"Daily"},{value:"weekly",label:"Weekly"},{value:"biweekly",label:"Bi-Weekly"},{value:"monthly",label:"Monthly"}];function It({triggerButtonClassName:s}){const{data:a,handleScheduleSubscription:n,handleDeleteSubscription:r,status:o,error:c,isDeleting:i}=on(),[l,d]=E.useState(""),[h,m]=E.useState(tt[0].value),[x,f]=E.useState("06:00"),[u,C]=E.useState("");return e.jsx(t.TooltipProvider,{delayDuration:0,children:e.jsxs(t.Popover,{children:[e.jsx(t.PopoverTrigger,{asChild:!0,children:e.jsx(t.IconButton,{tooltip:"Schedule Dashboard",className:t.cn("h-7 p-2",s),children:e.jsx(Ss,{className:"size-4"})})}),e.jsx(t.PopoverContent,{align:"end",className:"w-80",children:e.jsxs("div",{className:"grid gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("h4",{className:"font-medium leading-none",children:"Schedule Subscription"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Subscribe to receive dashboard via email"})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsxs("div",{className:"grid grid-cols-3 items-center gap-4",children:[e.jsx(t.Label,{htmlFor:"email",children:"Email"}),e.jsx(t.Input,{id:"email",value:l,onChange:p=>d(p.target.value),className:`col-span-2 h-8 ${t.removeRing}`})]}),e.jsxs("div",{className:"grid grid-cols-3 items-center gap-4",children:[e.jsx(t.Label,{htmlFor:"subject",children:"Subject"}),e.jsx(t.Input,{id:"subject",placeholder:"Monthly Sales Report",value:u,onChange:p=>{C(p.target.value.replace(/[^a-zA-Z0-9\s-_]/g,""))},className:`col-span-2 h-8 ${t.removeRing}`})]}),e.jsxs("div",{className:"grid grid-cols-3 items-center gap-4",children:[e.jsx(t.Label,{htmlFor:"frequency",children:"Frequency"}),e.jsx(ee,{className:"col-span-2 h-8",label:"Select Frequency",options:tt,value:h,onValueChange:p=>m(p)})]}),e.jsxs("div",{className:"grid grid-cols-3 items-center gap-4",children:[e.jsx(t.Label,{htmlFor:"time",children:"Time"}),e.jsx(t.Input,{id:"time",type:"time",value:x,onChange:p=>f(p.target.value),className:`col-span-2 h-8 ${t.removeRing}`})]}),e.jsx("div",{className:"mt-2 flex justify-end",children:e.jsxs(t.Button,{onClick:async()=>{await n({email:l,frequency:h,time:x,subject:u}),f("00:00"),d(""),C("")},className:"h-8 p-2",disabled:o==="loading"||!l,children:[o==="loading"&&e.jsx(re,{className:"mr-2 size-4 animate-spin"}),o==="success"&&e.jsx(t.Check,{className:"mr-2 size-4"}),o==="error"&&e.jsxs(t.Tooltip,{children:[e.jsx(t.TooltipTrigger,{children:e.jsx(ut,{className:"mr-2 size-4 text-destructive"})}),e.jsx(t.TooltipContent,{children:e.jsx("p",{children:c})})]}),"Schedule"]})}),a&&a.length>0&&e.jsxs("div",{className:"space-y-4",children:[e.jsx(t.Separator,{className:"my-2"}),e.jsx("div",{className:"space-y-2",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("h4",{className:"font-medium leading-none",children:"Subscriptions"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Active email subscriptions"})]}),t.isDevEnv]})}),e.jsx("div",{className:"grid gap-2",children:a==null?void 0:a.map(p=>e.jsxs("div",{className:"group grid grid-cols-5 gap-3",children:[e.jsx("div",{className:"col-span-3 text-sm",children:e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"boder-border rounded-md border bg-muted px-2 py-1",children:[t.titleCase(p.frequency)," "]}),e.jsx(t.Label,{children:p.time})]})}),e.jsxs("div",{className:"col-span-2 flex items-center justify-end gap-4",children:[e.jsx(st,{tooltip:`Next Run: ${new Date(p.nextRun).toLocaleString()} ${p.timezone}`,children:e.jsx(bs,{className:"size-3.5"})}),e.jsx(st,{tooltip:`${p.endUserEmail}`,children:e.jsx(_s,{className:"size-3.5"})}),i===p.id?e.jsx(re,{className:"size-3.5 animate-spin"}):e.jsx(Xs,{onClick:()=>r(p.id),className:"size-3.5 cursor-pointer"})]})]},p.id))})]})]})]})})]})})}const st=({children:s,tooltip:a})=>e.jsx(t.TooltipProvider,{delayDuration:0,children:e.jsxs(t.Tooltip,{children:[e.jsx(t.TooltipTrigger,{asChild:!0,children:s}),e.jsx(t.TooltipContent,{children:a})]})});function on(){const[s,a]=E.useState("idle"),[n,r]=E.useState(""),[o,c]=E.useState(null),i=t.useDashboardStore(b=>b.authToken),l=t.useDashboardStore(b=>b.dashboard.id),d=t.useDashboardStore(b=>b.dashboard.title),{endUserId:h}=t.getTenantAndEndUserId((i==null?void 0:i.accessToken)||""),m="https://semaphor.cloud/api/v1/subscriptions/get",x={dashboardId:l,endUserId:h},{data:f,isLoading:u,isError:C,isFetching:p,refetch:y}=t.useQuery({queryKey:["subscriptions",l,h],queryFn:()=>t.getRequest(m,(i==null?void 0:i.accessToken)||"",x),enabled:!!(i!=null&&i.accessToken)&&!!l&&!!h});async function g({email:b,subject:I,frequency:N,time:T}){const{authToken:_,...R}=wt(),U=Intl.DateTimeFormat().resolvedOptions().timeZone,w={email:b,frequency:N,time:T,timezone:U,endUserId:h,endUserEmail:b,subject:I||d||"Scheduled Dashboard",dashboardId:l,dashboardParams:R};a("loading");const V="https://semaphor.cloud/api/v1/subscriptions/create";try{const $=await t.postRequestRegular(V,(_==null?void 0:_.accessToken)||"",{...w});a("success"),r(""),y(),setTimeout(()=>{a("idle")},2e3)}catch($){console.error($),a("error"),r($.message)}}async function S(b){const I="https://semaphor.cloud/api/v1/subscriptions/delete";c(b);try{await t.postRequestRegular(I,(i==null?void 0:i.accessToken)||"",{id:b}),y(),setTimeout(()=>{c(null)},2e3)}catch(N){console.error(N),c(null),a("error"),r(N.message)}}return{data:f,isLoading:u,isFetching:p,isError:C,isDeleting:o,refetch:y,handleScheduleSubscription:g,handleDeleteSubscription:S,status:s,error:n}}function ln(){const{authToken:s}=t.useSemaphorContext();t.useDashboardStore(w=>w.theme);const a=t.useDashboardStore(w=>w.lenses),n=t.useDashboardStore(w=>w.selectedLensId),r=a==null?void 0:a.find(w=>w.id===n),o=t.useDashboardStore(w=>w.dashboard);t.useDashboardStore(w=>w.selectedSheetId);const c=t.useDashboardStore(w=>w.isDashboardEditing),i=t.useEditorStore(w=>w.selectedConnectionId),[l,d]=E.useState(!1),h=t.useDashboardStore(w=>w.filterValues),m=t.useDashboardStore(w=>w.isVisualEditing),x=t.useDashboardStore(w=>w.showFilters);t.useDashboardStore(w=>w.showDashboardJSON);const f=t.useDashboardStore(w=>w.onSaveFunction),u=t.useDashboardStore(w=>w.actions.setShowFilters),{addFrame:C,setSelectedFrameId:p}=t.useDashboardStore(w=>w.actions),{getSelectedSheet:y,setIsDashboardEditing:g,setShowDashboardJSON:S}=t.useDashboardStore(w=>w.actions),b=y(),{tenantId:I,endUserId:N}=E.useMemo(()=>t.getTenantAndEndUserId(s==null?void 0:s.accessToken),[s==null?void 0:s.accessToken]),T=E.useMemo(()=>I||N,[I,N]),_=()=>{if(!c||!b)return;const w={connectionId:i,id:t.v4(),title:"Title",description:"Description",preferences:{onClickFilter:[{columnIndex:0,expression:""}]},type:"bar",sql:"",data:[]},V={id:t.v4(),cards:[w],activeCardId:w.id};C(b.id,V),p(V.id)},R=()=>{g(!0)};async function U(){if(d(!0),!n||!r)return;const w=Ge(o),V=JSON.stringify(w),$={...r,template:V,filterValues:h};await ze($,s==null?void 0:s.accessToken),t.ue.success("Lens saved"),f==null||f(w),d(!1)}return m?null:e.jsxs("div",{className:"flex items-center justify-between gap-2 border-b py-1 pl-3 pr-2",role:"dashboard-controls",children:[!m&&e.jsx("div",{className:"flex items-center gap-3",children:e.jsx(t.Label,{children:r==null?void 0:r.name})}),e.jsxs("div",{className:"flex gap-2",children:[!1,!m&&e.jsx(rn,{}),!m&&e.jsx(It,{}),c&&!m&&T&&e.jsx(nn,{}),!m&&T&&e.jsx(an,{}),c&&!m&&e.jsxs(t.Button,{variant:"secondary",className:"h-7 p-2",size:"sm",disabled:!c,onClick:_,children:[e.jsx(t.Plus,{className:"mr-2 h-4 w-4"}),"Frame"]}),!c&&e.jsx(t.Button,{variant:"ghost",className:"h-7 p-2",onClick:R,size:"sm",children:e.jsx(t.Pencil,{className:"h-4 w-4"})}),c&&!m&&e.jsx(t.IconButton,{className:"h-7 p-2",onClick:()=>{g(!1),S(!1)},children:e.jsx(t.Cross2Icon,{className:"h-4 w-4"})}),c&&!m&&T&&e.jsx(t.Button,{className:"h-7 p-2",variant:"ghost",disabled:l,onClick:U,size:"sm",children:e.jsx(Qs,{className:"h-4 w-4"})}),!x&&!m&&c&&e.jsx(t.Button,{className:"h-7 p-2",variant:"ghost",onClick:()=>u(!0),size:"sm",children:e.jsx(xt,{className:"h-4 w-4"})}),!m&&c&&!1,!m&&!1]})]})}function cn({name:s,items:a,value:n,onChange:r,isLoading:o,isError:c,refetch:i,className:l,icon:d,showNone:h=!1}){const m=ce.useRef(null),[x,f]=ce.useState(!1),[u,C]=ce.useState("100%"),p=h?[...a||[],{id:"none",name:"None"}]:a;ce.useLayoutEffect(()=>{m.current&&C(m.current.offsetWidth)},[]);function y(){var S;return o?"Loading...":c?"Error":n?(S=a==null?void 0:a.find(b=>b.id===n))==null?void 0:S.name:`Select ${s}`}function g(S,b){r(b),f(!1)}return e.jsxs(t.Popover,{open:x,onOpenChange:f,children:[e.jsx(t.PopoverTrigger,{asChild:!0,children:e.jsxs(t.Button,{ref:m,variant:"outline",role:"combobox","aria-expanded":x,className:t.cn("flex h-9 w-full justify-between",l),children:[e.jsxs("div",{className:"flex items-center gap-2",children:[d&&e.jsx("div",{className:"mr-2",children:d}),e.jsx("span",{className:"max-w-[150px] overflow-hidden truncate text-ellipsis whitespace-nowrap",children:y()})]}),e.jsx(t.ChevronDown,{className:"size-4 opacity-50"})]})}),e.jsx(t.PopoverContent,{className:"w-full p-0",style:{minWidth:u},children:e.jsxs(t.Command,{children:[e.jsxs("div",{className:"flex h-9 items-center justify-between border-b pr-1",children:[e.jsx(t.CommandInput,{className:"h-9",placeholder:"Search..."}),e.jsx(t.IconButton,{className:"h-7",onClick:i,children:e.jsx(yt,{className:t.cn("size-3.5 opacity-50",o&&"animate-spin")})})]}),e.jsxs(t.CommandList,{children:[e.jsxs(t.CommandEmpty,{children:["No ",s==null?void 0:s.toLowerCase()," found."]}),e.jsx(t.CommandGroup,{children:p==null?void 0:p.map(S=>e.jsx(t.CommandItem,{className:"overflow-x-auto",value:S.name,onSelect:b=>g(b,S.id),children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(t.Check,{className:t.cn("size-4",n===S.id?"opacity-100":"opacity-0")}),e.jsx("div",{title:S.name,children:S.name})]})},S.id))})]})]})})]})}function le({title:s,items:a,value:n,isLoading:r,isError:o,refetch:c,onChange:i,showNone:l=!1,className:d,disabled:h=!1,type:m="combobox"}){const x=r?"Loading...":o?"Error":n;function f(){if(s==="Connection")return e.jsx(Gs,{className:"size-4"});if(s==="Database")return e.jsx(ws,{className:"size-4"});if(s==="Schema")return e.jsx(Hs,{className:"size-4"});if(s==="Table")return e.jsx(He,{className:"size-4"});if(s==="Model")return e.jsx(gs,{className:"size-4"})}function u(){return e.jsxs(t.Select,{disabled:h,value:x,onValueChange:i,children:[e.jsx(t.SelectTrigger,{className:t.cn("h-9 w-full border-muted focus:ring-1 focus:ring-offset-0",d),children:e.jsx(t.SelectValue,{placeholder:r?"Loading...":o?"Error":`Select ${s}`})}),e.jsx(t.SelectContent,{children:e.jsxs(t.SelectGroup,{children:[r?e.jsx(t.SelectLabel,{children:"Loading..."}):e.jsxs(t.SelectLabel,{className:"flex items-center justify-between gap-2",children:[s,e.jsx(yt,{className:t.cn("mr-1 size-3 cursor-pointer text-muted-foreground hover:text-foreground",r&&"animate-spin"),onClick:c})]}),e.jsxs(e.Fragment,{children:[l&&e.jsx(t.SelectItem,{value:"none",children:"None"},"none"),a&&a.map((p,y)=>e.jsx(t.SelectItem,{value:p.id,children:p.name},y))]}),(r||o)&&e.jsx(t.SelectItem,{value:x,children:x})]})})]})}function C(){return e.jsx(cn,{icon:f(),items:a,value:x,onChange:i||(()=>{}),isLoading:r,isError:o,refetch:c,name:s,showNone:l})}return e.jsx(t.TooltipProvider$1,{delayDuration:0,children:e.jsx("div",{className:"flex items-center gap-2",children:m==="select"?u():C()})})}function dn({column:s}){const[a,n]=E.useState(!1),r=t.useEditorStore(p=>p.selectedTableName),o=t.useEditorStore(p=>p.selectedSchemaName),c=t.useEditorStore(p=>p.selectedDatabaseName),i=t.useEditorStore(p=>p.selectedDatamodelId),l=t.useEditorStore(p=>p.sqlGen),{modelItems:d,connectionType:h}=te(),m=t.useEditorStore(p=>p.actions.setSqlGen),x=t.useEditorStore(p=>p.actions.setCardSql),f=t.useEditorStore(p=>p.actions.setRunSql);function u(p,y){var I;const g=t.createSqlGenConfig(p,l,y),S=(I=d==null?void 0:d.find(N=>N.id===i))==null?void 0:I.name;m(g);const b=t.getSql(g,t.fmt(o||""),t.fmt(r),S,h,c||"");b&&(x(b),f(!0)),n(!1)}function C(){return e.jsxs("ul",{className:"text-xs",children:[e.jsx("li",{onClick:()=>u(s,"COUNT"),className:"cursor-pointer p-1 px-3 transition-colors hover:bg-muted",children:"Count"}),e.jsx("li",{onClick:()=>u(s,"AVG"),className:"cursor-pointer p-1 px-3 transition-colors hover:bg-muted",children:"Avg"}),e.jsx("li",{onClick:()=>u(s,"SUM"),className:"cursor-pointer p-1 px-3 transition-colors hover:bg-muted",children:"Sum"}),e.jsx("li",{onClick:()=>u(s,"MAX"),className:"cursor-pointer p-1 px-3 transition-colors hover:bg-muted",children:"Max"}),e.jsx("li",{onClick:()=>u(s,"MIN"),className:"cursor-pointer p-1 px-3 transition-colors hover:bg-muted",children:"Min"})]})}return e.jsxs(t.HoverCard,{openDelay:0,open:a,onOpenChange:n,children:[e.jsx(t.HoverCardTrigger,{asChild:!0,children:e.jsx(ht,{className:"invisible size-3.5 cursor-pointer text-foreground/40 group-hover:visible"})}),e.jsx(t.HoverCardContent,{align:"center",className:"w-20 rounded-md p-0 shadow-none",children:C()})]})}function Ue({column:s}){return e.jsxs(t.Tooltip,{children:[e.jsx(t.TooltipTrigger$1,{asChild:!0,children:t.isTextDataType(s.data_type)?e.jsx(vt,{className:"size-3"}):t.isNumberDataType(s.data_type)?e.jsx(ft,{className:"size-3"}):t.isDateDataType(s.data_type)?e.jsx(t.Calendar,{className:"size-3"}):t.isBooleanDataType(s.data_type)?e.jsx(Zs,{className:"size-3"}):s.data_type.toLowerCase()==="json"?e.jsx(js,{className:"size-3"}):e.jsx(Js,{className:"size-3"})}),e.jsx(t.TooltipContent,{children:e.jsx("p",{className:"font-mono text-xs",children:s.data_type})})]})}function Ie({column:s,className:a}){return e.jsxs("div",{className:t.cn("flex h-8 grow items-center space-x-2 px-2 text-sm",a),children:[e.jsx(Ue,{column:s}),e.jsx("span",{children:s.column_name})]})}function un({id:s,children:a,type:n="column"}){const{attributes:r,listeners:o,setNodeRef:c,transform:i}=t.useDraggable({id:s,data:{type:n}}),l=i?{translate:t.CSS.Translate.toString(i),transform:t.CSS.Transform.toString(i)}:void 0;return e.jsx("div",{ref:c,style:l,...o,...r,children:a})}function mn({onClick:s,column:a}){const n=t.useDndStore(f=>f.activeId),r=t.useEditorStore(f=>{var u;return(u=f.card.queryConfig)==null?void 0:u.groupByColumns}),o=t.useEditorStore(f=>{var u;return(u=f.card.queryConfig)==null?void 0:u.trendByColumns}),c=t.useEditorStore(f=>{var u;return(u=f.card.queryConfig)==null?void 0:u.metricColumns}),i=t.useEditorStore(f=>{var u;return(u=f.card.queryConfig)==null?void 0:u.filterColumns});function l(f){return d(f)||m(f)||h(f)||x(f)}function d(f){return r==null?void 0:r.some(u=>u.name===f.column_name)}function h(f){return o==null?void 0:o.some(u=>u.name===f.column_name)}function m(f){return c==null?void 0:c.some(u=>u.name===f.column_name)}function x(f){return i==null?void 0:i.some(u=>u.name===f.column_name)}return e.jsxs("div",{onClick:()=>s(a),className:t.cn("relative grow overflow-x-hidden overflow-y-hidden rounded-md active:border active:border-dashed active:border-muted-foreground",{"bg-muted-foreground/10":l(a)}),children:[n===a.column_name&&e.jsx(t.DragOverlay,{children:e.jsx(Ie,{column:a,className:"rounded-md border-2 border-dashed border-muted-foreground bg-muted shadow-md"})}),n===a.column_name&&e.jsx("div",{className:"absolute inset-0",children:n===a.column_name&&e.jsx(Ie,{column:a})}),e.jsx(un,{id:a.column_name,type:"column",children:e.jsx(Ie,{column:a})})]})}function Dt(s){const a=t.useDashboardStore(d=>d.authToken)||s,n=t.useEditorStore(d=>d.selectedConnectionId),{refetch:r,data:o,isLoading:c,isError:i}=t.useQuery({queryKey:["connections"],queryFn:()=>t.getRequest("https://semaphor.cloud/api/v1/connections",(a==null?void 0:a.accessToken)||""),enabled:!!(a!=null&&a.accessToken)}),l=o==null?void 0:o.connections.find(d=>d.id===n);return{connectionsData:o,isConnectionsLoading:c,isConnectionsError:i,refetchConnections:r,currentConnection:l}}function $e(s){var y;const a=t.useDashboardStore(g=>g.authToken)||s,n=t.useEditorStore(g=>g.selectedConnectionId),r=t.useEditorStore(g=>g.selectedDatabaseName),o=t.useEditorStore(g=>g.selectedDatamodelId),c=t.useEditorStore(g=>g.selectedSchemaName),i=t.useEditorStore(g=>g.selectedTableName),{currentConnection:l}=Dt(),d=l==null?void 0:l.type,{data:h,isLoading:m,isFetching:x,isError:f,refetch:u}=t.useQuery({queryKey:["columns",n,r,o,c,i],queryFn:()=>t.getRequest("https://semaphor.cloud/api/v1/columns",(a==null?void 0:a.accessToken)||"",{connection_id:n,datamodel_id:o||"",database_name:r,schema_name:c,table_name:i}),enabled:C(d)});function C(g){return a!=null&&a.accessToken?!!(n&&r&&r!=="NA"&&c&&i||n&&(g==="S3"||g==="API")||o&&o):!1}return{columns:(y=h==null?void 0:h.columns)==null?void 0:y.map(g=>({...g,data_type:g.data_type.toLowerCase()})),isColumnsLoading:m,isColumnsFetching:x,isColumnsError:f,refetchColumns:u}}function te(s,a){var We,Ye,Ze,Xe,et;const n=t.useSemaphorContext().authToken||s,r=t.useEditorStore(F=>F.selectedConnectionId),o=t.useEditorStore(F=>F.selectedDatamodelId),c=t.useEditorStore(F=>F.selectedDatabaseName),i=t.useEditorStore(F=>F.selectedSchemaName),l=t.useEditorStore(F=>F.selectedTableName),d=t.useEditorStore(F=>F.actions.setSelectedConnectionId),h=t.useEditorStore(F=>F.actions.setSelectedDatamodelId),m=t.useEditorStore(F=>F.actions.setSelectedDatabaseName),x=t.useEditorStore(F=>F.actions.setSelectedSchemaName),f=t.useEditorStore(F=>F.actions.setSelectedTableName);t.useEditorStore(F=>F.actions.setCardSql);function u(F){return r&&c&&i&&c!=="NA"?!0:r&&F==="API"?!1:!!(r&&F==="S3")}function C(F){return r&&F?!(F==="API"||F==="S3"):!1}const{refetchConnections:p,connectionsData:y,isConnectionsLoading:g,isConnectionsError:S,currentConnection:b}=Dt(s),{refetch:I,data:N,isLoading:T,isError:_}=t.useQuery({queryKey:["models",r],queryFn:()=>t.getRequest("https://semaphor.cloud/api/v1/datamodels",(n==null?void 0:n.accessToken)||"",{connection_id:r}),enabled:!!(n!=null&&n.accessToken)&&!!r}),R=b==null?void 0:b.type,U=(b==null?void 0:b.type)==="API"||(b==null?void 0:b.type)==="S3",{data:w,isLoading:V,isFetching:$,isError:q,refetch:j}=t.useQuery({queryKey:["databases",r],queryFn:()=>t.getRequest("https://semaphor.cloud/api/v1/databases",(n==null?void 0:n.accessToken)||"",{connection_id:r}),enabled:C(R)}),{data:D,isLoading:M,isFetching:G,isError:O,refetch:k}=t.useQuery({queryKey:["schemas",r,c],queryFn:()=>t.getRequest("https://semaphor.cloud/api/v1/schemas",(n==null?void 0:n.accessToken)||"",{connection_id:r,database_name:c}),enabled:!!r&&!!c&&!U&&c!=="NA"}),{data:v,isLoading:A,isFetching:L,isError:K,refetch:P}=t.useQuery({queryKey:["tables",r,c,i],queryFn:()=>t.getRequest("https://semaphor.cloud/api/v1/tables",(n==null?void 0:n.accessToken)||"",{connection_id:r,database_name:c,schema_name:i}),enabled:u(R)}),{columns:W,isColumnsLoading:B,isColumnsFetching:J,isColumnsError:H,refetchColumns:Z}=$e(s);E.useEffect(()=>{(R==="S3"||R==="API")&&(m(""),x(""),h(""),R==="API"&&f("api"))},[R,f,m,x,h]);const z=(b==null?void 0:b.type)==="API"?(We=b==null?void 0:b.type)==null?void 0:We.toLowerCase():l||"",Q=U?"":i||"";function X(F){x(F),f("")}function ne(F){m(F==="none"?"":F),x(""),f(""),F!=="none"&&F!==""&&h("")}function ie(F){d(F)}function ve(F){h(F==="none"?"":F),F!=="none"&&F!==""&&m("")}w&&((Ye=w==null?void 0:w.databases)==null?void 0:Ye.length)>0,D&&((Ze=D==null?void 0:D.schemas)==null?void 0:Ze.length)>0;const Ne=y==null?void 0:y.connections.map(F=>({id:F.id,name:F.name,type:F.type})),we=(Xe=N==null?void 0:N.datamodels)==null?void 0:Xe.map(F=>({id:F.id,name:F.name})),ke=w==null?void 0:w.databases.map(F=>({id:F.database_name,name:F.database_name})),ge=D==null?void 0:D.schemas.map(F=>({id:F.schema_name,name:F.schema_name})),Y=v==null?void 0:v.tables.map(F=>({id:F.table_name,name:F.table_name})),se=(et=N==null?void 0:N.datamodels.find(F=>F.id===o))==null?void 0:et.name,Xt=t.getFormattedTableNameForQuery({schemaName:Q,tableName:z,modelName:se,connectionType:R,databaseName:c||""});return{connectionItems:Ne,selectedConnectionId:r,isConnectionsLoading:g,isConnectionsError:S,modelItems:we,selectedDatamodelId:o,selectedDatamodelName:se,isModelsLoading:T,isModelsError:_,selectedDatabaseName:c,databaseItems:ke,isDatabasesLoadingOrFetching:V||$,isDatabaseError:q,schemaItems:ge,selectedSchemaName:i,isSchemaLoadingOrFetching:M||G,isSchemaError:O,tableItems:Y,selectedTableName:l,isTableLoadingOrFetching:A||L,isTableError:K,columns:W,isColumnsLoadingOrFetching:B||J,isColumnsError:H,isNonDbConnection:U,connectionType:R,tableName:z,formattedTableName:Xt,schemaName:Q,refetchConnections:p,refetchModels:I,refetchDatabases:j,refetchSchemas:k,refetchTables:P,refetchColumns:Z,handleConnectionChange:ie,handleDatamodelChange:ve,handleDatabaseChange:ne,handleSchemaChange:X}}const De={id:"__placeholder__",role:"groupby",type:"string"},Ee={id:"__placeholder__",role:"metric",type:"number"},Te={id:"__placeholder__",role:"trendby",type:"date"},Me={name:"Filter",id:"__placeholder__",role:"filter",type:"string"},Et={id:"__placeholder__"},de="droppable-group-by",ue="droppable-metrics",Fe="sortable-group-by",Re="sortable-metrics",me="droppable-trend-by",Be="sortable-trend-by",_e="droppable-filters",Ve="sortable-filters",Qe="sortable-order-by";function hn(){const s=t.useDndStore(j=>j.insertIndex),a=t.useEditorStore(j=>{var D;return((D=j.card.queryConfig)==null?void 0:D.groupByColumns)||[]}),n=t.useEditorStore(j=>{var D;return((D=j.card.queryConfig)==null?void 0:D.metricColumns)||[]}),r=t.useEditorStore(j=>{var D;return((D=j.card.queryConfig)==null?void 0:D.trendByColumns)||[]}),o=t.useEditorStore(j=>{var D;return((D=j.card.queryConfig)==null?void 0:D.filterColumns)||[]}),c=t.useEditorStore(j=>{var D;return((D=j.card.queryConfig)==null?void 0:D.orderBy)||[]}),{setInsertIndex:i,setActiveId:l,setPreviewGroupByColumns:d,setPreviewMetricColumns:h,setPreviewTrendByColumns:m,setPreviewFilterColumns:x}=t.useDndActions(),{setGroupByColumns:f,setMetricColumns:u,setTrendByColumns:C,setFilterColumns:p,setOrderByColumns:y}=t.useEditorActions(),{columns:g}=$e(),{formattedTableName:S}=te(),b=t.useSensors(t.useSensor(t.MouseSensor,{activationConstraint:{distance:1}})),I=j=>{var G;const{active:D,over:M}=j;if(((G=D.data.current)==null?void 0:G.type)==="column"&&M){const O=M.id,k=g.find(K=>K.column_name===D.id);if(!k)return;const v=t.isNumberDataType(k.data_type),A=t.isTextDataType(k.data_type),L=t.isDateDataType(k.data_type);if(A){if(a.some(P=>P.id===O)){const P=a.findIndex(B=>B.id===O);i(P);const W=a.filter(B=>B.id!==De.id);W.splice(P,0,De),d(W)}else if(M.id===de){i(a.length);const P=[...a,De];d(P),h(n),m(r),x(o)}}if(v||A){if(n.some(P=>P.id===O)){console.log("isOverMetricSortable",O);const P=n.findIndex(B=>B.id===O);i(P);const W=n.filter(B=>B.id!==Ee.id);W.splice(P,0,Ee),h(W)}else if(M.id===ue){i(n.length);const P=[...n,Ee];h(P),m(r),x(o),d(a)}}if(L){if(r.some(P=>P.id===O)){const P=r.findIndex(B=>B.id===O);i(P);const W=r.filter(B=>B.id!==Te.id);W.splice(P,0,Te),m(W)}else if(M.id===me){i(r.length);const P=[...r,Te];m(P),h(n),x(o),d(a)}}if(T(k)){if(o.some(P=>P.id===O)){const P=o.findIndex(B=>B.id===O);i(P);const W=o.filter(B=>B.id!==Me.id);W.splice(P,0,Me),x(W)}else if(M.id===_e){i(o.length);const P=[...o,Me];x(P),h(n),m(r),d(a)}}}else d(a),h(n),m(r),x(o)};function N(j){l(j.active.id),i(null),d(a),h(n),m(r),x(o)}function T(j){return!o.some(D=>D.name===j.column_name)}function _(j,D="SUM"){const{column_name:M,data_type:G}=j,O=[...n],k=s!==null?s:n.length,v={...j,id:ae(M),name:M,label:fe(M,D),type:G,role:"metric",aggregate:D};O.splice(k,0,v),u(O)}function R(j){const D=[...a],M=s!==null?s:a.length,G={...j,id:ae(j.column_name),name:j.column_name,type:j.data_type,role:"groupby"};D.splice(M,0,G),f(D)}function U(j){const D=[...r],M=s!==null?s:r.length,G={...j,id:ae(j.column_name),name:j.column_name,type:j.data_type,role:"trendby"};D.splice(M,0,G),C(D)}function w(j){const D=[...o],M=s!==null?s:o.length,G={...j,id:ae(j.column_name),name:j.column_name,type:j.data_type,sql:t.getDefaultFilterSql(j.data_type,S,t.fmt(j.column_name)),role:"filter"};D.splice(M,0,G),p(D)}function V(j){var O,k,v,A,L,K,P,W;const{active:D,over:M}=j,G=D.data.current;if((G==null?void 0:G.type)==="column"&&M){const B=g.find(z=>z.column_name===D.id);if(!B)return;const J=t.isNumberDataType(B.data_type),H=t.isTextDataType(B.data_type),Z=t.isDateDataType(B.data_type);H&&(M.id===de||((O=M.data.current)==null?void 0:O.type)===Fe)?R(B):(J||H)&&(M.id===ue||((k=M.data.current)==null?void 0:k.type)===Re)?(J&&_(B),H&&_(B,"COUNT")):Z&&(M.id===me||((v=M.data.current)==null?void 0:v.type)===Be)?U(B):T(B)&&(M.id===_e||((A=M.data.current)==null?void 0:A.type)===Ve)&&w(B)}if(M&&((L=M.data.current)==null?void 0:L.type)===Fe&&a.some(B=>B.id===D.id)){const B=a.findIndex(H=>H.id===D.id),J=a.findIndex(H=>H.id===M.id);if(B!==-1&&J!==-1&&B!==J){const H=[...a],[Z]=H.splice(B,1);H.splice(J,0,Z),f(H)}}if(M&&((K=M.data.current)==null?void 0:K.type)===Re&&n.some(B=>B.id===D.id)){const B=n.findIndex(H=>H.id===D.id),J=n.findIndex(H=>H.id===M.id);if(B!==-1&&J!==-1&&B!==J){const H=[...n],[Z]=H.splice(B,1);H.splice(J,0,Z),u(H)}}if(M&&((P=M.data.current)==null?void 0:P.type)===Be&&r.some(B=>B.id===D.id)){const B=r.findIndex(H=>H.id===D.id),J=r.findIndex(H=>H.id===M.id);if(B!==-1&&J!==-1&&B!==J){const H=[...r],[Z]=H.splice(B,1);H.splice(J,0,Z),C(H)}}if(M&&((W=M.data.current)==null?void 0:W.type)===Ve&&o.some(B=>B.id===D.id)){const B=o.findIndex(H=>H.id===D.id),J=o.findIndex(H=>H.id===M.id);if(B!==-1&&J!==-1&&B!==J){const H=[...o],[Z]=H.splice(B,1);H.splice(J,0,Z),p(H)}}$(j),l(null),i(null),d(a),h(n),m(r),x(o)}function $(j){const{active:D,over:M}=j,G=D.data.current;if((G==null?void 0:G.type)===Qe&&M){const O=c.findIndex(v=>xe(v.columnId)===D.id),k=c.findIndex(v=>xe(v.columnId)===M.id);if(O!==-1&&k!==-1&&O!==k){const v=[...c],[A]=v.splice(O,1);v.splice(k,0,A),y(v)}}}function q(){l(null),i(null),d(a),h(n),m(r),x(o)}return{handleDragOver:I,handleDragEnd:V,handleDragStart:N,handleDragCancel:q,sensors:b}}function ae(s){return`${s}-${t.v4()}`}function fe(s,a){const n=t.toTitleCase(s.replace(/_/g," "));switch(a){case"SUM":return`Sum of ${n}`;case"COUNT":return`Count of ${n}`;case"DISTINCT":return`Unique ${n}`;case"AVG":return`Average of ${n}`;case"MIN":return`Min of ${n}`;case"MAX":return`Max of ${n}`;default:return n}}function xe(s){return`${Qe}-${s}`}function Tt(s,a){const n=t.toTitleCase(s.replace(/_/g," "));switch(a){case"day":return`Date of ${n}`;case"week":return`Week of ${n}`;case"month":return`Month of ${n}`;case"year":return`Year of ${n}`;default:return n}}function pn({schemaName:s,tableName:a,columns:n,status:r}){const o=t.useEditorStore(j=>j.sqlGen),c=t.useEditorStore(j=>j.isDevMode),i=t.useEditorStore(j=>j.selectedConnectionId),l=t.useEditorStore(j=>j.selectedDatabaseName),d=t.useEditorStore(j=>j.selectedSchemaName),h=t.useEditorStore(j=>j.selectedTableName),m=t.useEditorStore(j=>j.selectedDatamodelId),x=t.useDashboardStore(j=>j.dashboard.aiScopeTables),{addToAIScope:f,removeFromAIScope:u}=t.useDashboardActions(),{addColumnToMetricColumns:C,addColumnToTrendByColumns:p,setCardSql:y,setRunSql:g,setSqlGen:S,setIsShowingVisual:b}=t.useEditorActions(),{connectionType:I,modelItems:N,selectedDatamodelName:T}=te();function _(j){var D;if(c){const M=t.createSqlGenConfig(j,o);S(M);const G=(D=N==null?void 0:N.find(k=>k.id===m))==null?void 0:D.name,O=t.getSql(M,t.fmt(s),t.fmt(a),G,I,l||"");O&&(y(O),g(!0))}if(!c){if(t.isTextDataType(j.data_type)){const M={...j,role:"metric",id:ae(j.column_name),name:j.column_name,label:fe(j.column_name,"COUNT"),type:j.data_type,aggregate:"COUNT"};C(M)}if(t.isNumberDataType(j.data_type)){const M={...j,role:"metric",id:ae(j.column_name),name:j.column_name,label:fe(j.column_name,"SUM"),type:j.data_type,aggregate:"SUM"};C(M)}if(t.isDateDataType(j.data_type)){const M={...j,role:"trendby",id:ae(j.column_name),name:j.column_name,type:j.data_type};p(M)}}}function R(j){j===!0&&(h||T)&&i?(f({connectionId:i,connectionType:I==="S3"||I==="API"?"DuckDb":I,databaseName:l||"",schemaName:d||"",tableName:h||"",datamodelName:t.resolveDatamodelName(T),datamodelId:m||""}),t.ue.success("Added to Assistant Scope",{position:"top-right",duration:2500,richColors:!0})):(u({connectionId:i||"",connectionType:I||"",tableName:h||"",datamodelName:t.resolveDatamodelName(T),datamodelId:m||"",databaseName:l||"",schemaName:d||""}),t.ue("Removed from Assistant Scope",{position:"top-right",duration:2e3,richColors:!0}))}function U(){const j=t.getFormattedTableNameForQuery({schemaName:s,tableName:a,modelName:T,connectionType:I,databaseName:l||""});b(!1);const D=I==="MSSQL"?`SELECT top 10 * FROM ${j}`:`SELECT * FROM ${j} LIMIT 10`;y(D),g(!0)}function w(){const j=t.getFormattedTableNameForQuery({schemaName:s,tableName:a,modelName:T,connectionType:I,databaseName:l||""});y(`SELECT COUNT(*) as count FROM ${j}`),g(!0)}function V(){return(x==null?void 0:x.find(j=>j.connectionId===i&&(j.tableName===h||j.datamodelName===T)))!==void 0}function $(j){return c?e.jsxs("div",{className:"flex grow items-center justify-between space-x-2 rounded-md px-2 py-1",onClick:()=>_(j),children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Ue,{column:j}),e.jsx("span",{children:j.column_name})]}),e.jsx("div",{onClick:D=>D.stopPropagation(),className:"flex items-center justify-end",children:t.isNumberDataType(j.data_type)&&e.jsx(dn,{column:j})})]}):e.jsx(mn,{onClick:_,column:j})}function q(){return e.jsxs(e.Fragment,{children:[e.jsxs(t.Toggle,{title:`${V()?"Remove from":"Add to"} Assistant Scope`,pressed:V(),onPressedChange:R,variant:"outline",className:t.cn("h-9 px-2",{}),children:[e.jsx(t.Plus,{className:t.cn("mr-1 size-4",{"text-green-400":V(),"text-muted-foreground":!V()})}),"AI"]}),e.jsxs(t.Button,{disabled:r!=="Success",onClick:U,size:"sm",variant:"secondary",className:"flex",children:[r!=="Success"?e.jsx(re,{className:"mr-2 h-4 w-4 animate-spin text-foreground/50"}):e.jsx(Bs,{className:"mr-2 size-4"}),"Top 10"]}),e.jsxs(t.Button,{disabled:r!=="Success",onClick:w,size:"sm",variant:"secondary",className:"w-full",children:[r!=="Success"?e.jsx(re,{className:"mr-2 h-4 w-4 animate-spin text-foreground/50"}):e.jsx(St,{className:"mr-2 size-4"}),"Count"]})]})}return e.jsxs("div",{className:"flex grow flex-col space-y-4 px-4",children:[e.jsx("div",{className:"mx-2 flex items-center justify-center gap-2",children:q()}),e.jsxs(t.CustomScrollArea,{className:"flex-1 basis-0 overflow-y-auto border-b border-t border-muted px-2 py-3",children:[e.jsx("div",{className:"flex flex-col gap-1",children:n==null?void 0:n.map(j=>e.jsx("div",{className:t.cn("mr-2 cursor-pointer rounded-md text-sm transition-colors hover:bg-muted"),children:$(j)},j.column_name))}),e.jsx(t.ScrollBar,{orientation:"vertical"}),e.jsx(t.ScrollBar,{orientation:"horizontal"})]})]})}function Mt({ColumnsComponent:s,type:a}){var ge;const n=t.useEditorStore(Y=>Y.card),r=t.useEditorStore(Y=>Y.selectedConnectionId),o=t.useDashboardStore(Y=>Y.showFilters),c=t.useEditorStore(Y=>Y.selectedDatamodelId),i=t.useEditorStore(Y=>Y.selectedDatabaseName),l=t.useEditorStore(Y=>Y.selectedSchemaName),d=t.useEditorStore(Y=>Y.selectedTableName),h=t.useEditorStore(Y=>Y.isDevMode),{setSelectedTableName:m,setIsDevMode:x,setCardSql:f}=t.useEditorActions(),{connectionItems:u,modelItems:C,schemaItems:p,databaseItems:y,tableItems:g,columns:S,isConnectionsLoading:b,isModelsLoading:I,isConnectionsError:N,isModelsError:T,isDatabasesLoadingOrFetching:_,isDatabaseError:R,isSchemaLoadingOrFetching:U,isSchemaError:w,isColumnsError:V,isColumnsLoadingOrFetching:$,isTableLoadingOrFetching:q,isTableError:j,connectionType:D,isNonDbConnection:M,refetchDatabases:G,refetchModels:O,refetchSchemas:k,refetchTables:v,refetchColumns:A,refetchConnections:L,handleConnectionChange:K,handleDatabaseChange:P,handleSchemaChange:W,handleDatamodelChange:B,tableName:J,schemaName:H}=te(),{data:Z,refetch:z}=t.useDashboardCardQuery(n);function Q(){return s?s(H,J,S):e.jsx(pn,{schemaName:H,tableName:J,columns:S,status:$?"Loading...":V?"Error":"Success"})}function X(){window.location.href="mailto:support@semaphor.cloud?subject=Help&body=I need help with..."}function ne(Y){Y===!0?Z&&(f(Z.userSql),setTimeout(()=>{z()},500)):f(""),x(Y)}function ie(){if(!r||D==="S3"||D==="API")return null;if(!c||c==="none")return e.jsx(le,{refetch:G,showNone:!0,onChange:P,isError:R,isLoading:_,items:y,value:i||"",title:"Database",type:"combobox"})}function ve(){if(r&&!M&&(!i||i==="none")&&(!c||c==="none"))return e.jsxs("div",{className:"grid grid-cols-3",children:[e.jsx("div",{className:"col-span-1 grid place-items-center",children:e.jsx(t.Separator,{})}),e.jsx("div",{className:"col-span-1 grid place-items-center",children:e.jsx(t.Label,{children:"OR"})}),e.jsx("div",{className:"col-span-1 grid place-items-center",children:e.jsx(t.Separator,{})})]})}function Ne(){if(!r||D==="S3"||D==="API")return null;if(!i||i==="none")return e.jsx(le,{refetch:O,showNone:!0,onChange:B,isError:T,isLoading:I,items:C,value:c||"",title:"Model",type:"combobox"})}function we(){return!r||D==="S3"||D==="API"||!i||i==="none"?null:e.jsx(le,{refetch:k,onChange:W,isError:w,isLoading:U,items:p,value:l||"",title:"Schema",type:"combobox"})}function ke(){function Y(){let se=!1;return D==="API"?(se=!1,se):((D==="S3"||r&&i&&i!=="none"&&l)&&(se=!0),se)}return Y()?e.jsx(le,{refetch:v,onChange:m,isError:j,items:g,isLoading:q,value:d||"",title:"Table",type:"combobox"}):null}return e.jsxs("aside",{className:t.cn("flex h-full min-w-[300px] flex-col justify-between rounded-none",{"border-r-[1px]":!o}),children:[e.jsxs("section",{className:"space-y-3 px-6 py-4",children:[e.jsx(le,{refetch:L,items:u,title:"Connection",value:r||"",onChange:K,isLoading:b,isError:N,type:"combobox",connectionTooltip:((ge=u==null?void 0:u.find(Y=>Y.id===r))==null?void 0:ge.type)||""}),ie(),ve(),Ne(),we(),ke()]}),Q(),e.jsx("div",{className:"flex items-center justify-between gap-2 px-6 py-4",children:a==="main"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(t.Switch,{className:"data-[state=checked]:bg-muted-foreground/80",checked:h,onCheckedChange:ne,id:"dev-mode"}),e.jsx(t.Label,{htmlFor:"dev-mode",children:"Dev Mode"})]}),e.jsxs(t.Button,{onClick:X,size:"sm",variant:"secondary",className:"group flex items-center gap-2 rounded-full",children:[e.jsx(Vs,{className:"size-4"}),e.jsx("span",{className:"hidden group-hover:block",children:"Help"})]})]})})]})}function At({sql:s,error:a,onClick:n}){return!s&&!a?null:e.jsxs(t.HoverCard,{openDelay:a?0:500,children:[e.jsx(t.HoverCardTrigger,{asChild:!0,children:e.jsx(t.Button,{variant:"link",className:"h-5 p-0",children:a?e.jsx(ut,{className:"h-4 w-4 text-red-500"}):e.jsx(t.Info,{className:"h-4 w-4 text-muted-foreground"})})}),e.jsx(t.HoverCardContent,{align:"start",className:"w-full min-w-fit max-w-[700px]",children:e.jsx("div",{className:"flex justify-between space-x-4",children:e.jsxs("div",{className:"flex grow flex-col space-y-2",children:[e.jsxs(t.ScrollArea,{className:"max-h-[250px] min-h-0 overflow-scroll text-xs leading-relaxed text-foreground/80",children:[a&&a,s&&e.jsxs("div",{className:"flex flex-col space-y-1.5",children:[e.jsx("span",{className:"text-xs font-semibold",children:"Resolved SQL"}),e.jsx("div",{className:"rounded-md",children:e.jsx(t.CodeHighlighter,{code:s,language:"sql"})})]})]}),a&&n&&e.jsxs(t.Button,{onClick:n,size:"sm",variant:"secondary",children:[e.jsx(As,{className:"mr-2 h-4 w-4"}),"Debug with Assistant"]})]})})})]})}var Lt={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},nt=E.createContext&&E.createContext(Lt),xn=["attr","size","title"];function fn(s,a){if(s==null)return{};var n=gn(s,a),r,o;if(Object.getOwnPropertySymbols){var c=Object.getOwnPropertySymbols(s);for(o=0;o<c.length;o++)r=c[o],!(a.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(s,r)&&(n[r]=s[r])}return n}function gn(s,a){if(s==null)return{};var n={};for(var r in s)if(Object.prototype.hasOwnProperty.call(s,r)){if(a.indexOf(r)>=0)continue;n[r]=s[r]}return n}function Se(){return Se=Object.assign?Object.assign.bind():function(s){for(var a=1;a<arguments.length;a++){var n=arguments[a];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(s[r]=n[r])}return s},Se.apply(this,arguments)}function at(s,a){var n=Object.keys(s);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(s);a&&(r=r.filter(function(o){return Object.getOwnPropertyDescriptor(s,o).enumerable})),n.push.apply(n,r)}return n}function Ce(s){for(var a=1;a<arguments.length;a++){var n=arguments[a]!=null?arguments[a]:{};a%2?at(Object(n),!0).forEach(function(r){jn(s,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(s,Object.getOwnPropertyDescriptors(n)):at(Object(n)).forEach(function(r){Object.defineProperty(s,r,Object.getOwnPropertyDescriptor(n,r))})}return s}function jn(s,a,n){return a=yn(a),a in s?Object.defineProperty(s,a,{value:n,enumerable:!0,configurable:!0,writable:!0}):s[a]=n,s}function yn(s){var a=bn(s,"string");return typeof a=="symbol"?a:a+""}function bn(s,a){if(typeof s!="object"||!s)return s;var n=s[Symbol.toPrimitive];if(n!==void 0){var r=n.call(s,a);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(a==="string"?String:Number)(s)}function Ot(s){return s&&s.map((a,n)=>E.createElement(a.tag,Ce({key:n},a.attr),Ot(a.child)))}function he(s){return a=>E.createElement(Sn,Se({attr:Ce({},s.attr)},a),Ot(s.child))}function Sn(s){var a=n=>{var{attr:r,size:o,title:c}=s,i=fn(s,xn),l=o||n.size||"1em",d;return n.className&&(d=n.className),s.className&&(d=(d?d+" ":"")+s.className),E.createElement("svg",Se({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},n.attr,r,i,{className:d,style:Ce(Ce({color:s.color||n.color},n.style),s.style),height:l,width:l,xmlns:"http://www.w3.org/2000/svg"}),c&&E.createElement("title",null,c),s.children)};return nt!==void 0?E.createElement(nt.Consumer,null,n=>a(n)):a(Lt)}function Cn(s){return he({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 zt(s){const{theme:a}=t.useTheme(),n=t.useDashboardStore(p=>p.theme),r=t.useEditorStore(p=>p.frame),o=t.useEditorStore(p=>p.card),c=t.useEditorStore(p=>p.activeTabCardId),i=t.Le(),{refetch:l}=t.useDashboardCardQuery(o),{updateCardTab:d,setRunSql:h}=t.useEditorActions(),m=E.useRef(),x=E.useRef({}),f=r.cards.find(p=>p.id===c),u=E.useCallback(()=>{let p="";return s==="python"&&(p=(f==null?void 0:f.python)||t.PYTHON_DEFAULT_CODE),s==="sql"&&(p=(f==null?void 0:f.sql)||""),p},[s,f]);E.useEffect(()=>{if(c&&o.id&&o.id!==c){if(m.current&&i){const p=m.current.getModel();p&&(x.current[o.id]=p);let y=x.current[c];if(!y){const g=u();y=i.editor.createModel(g,s),x.current[c]=y}m.current.setModel(y)}d(c,o),h(!0)}},[c,o,d,i,h,s,u]),E.useEffect(()=>{if(!i)return;const p=window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light",y=n==="system"?p:n;i.editor.defineTheme("default",{base:y==="light"?"vs":"vs-dark",inherit:!0,rules:[],colors:{"editor.background":y==="light"?"#ffffff":t.hslStringToHex("240 10% 10%")}}),i.editor.setTheme("default")},[a,n,i]),E.useEffect(()=>{const p=m.current;p&&i&&o&&p.addCommand(i.KeyMod.Shift|i.KeyCode.Enter,function(){return l(),!1})},[i,l,o]);function C(p,y){if(m.current=p,!x.current[o.id]){const g=p.getModel(),S=u();x.current[o.id]=g||(y==null?void 0:y.editor.createModel(S,s))||p.getModel()}p.setModel(x.current[o.id])}return{handleEditorDidMount:C}}function vn(){const s=t.useEditorStore(i=>i.card.sql),a=t.useEditorStore(i=>i.sqlGen),{setCardSql:n,setSqlGen:r}=t.useEditorActions(),{handleEditorDidMount:o}=zt("sql");function c(i){n(i),t.isObjectEmpty(a)||r({})}return e.jsx(t.Ft,{theme:"default",className:"pt-3",onChange:c,value:s||"",options:{minimap:{enabled:!1},wordWrap:"on",scrollbar:{verticalScrollbarSize:0,horizontalScrollbarSize:0},fontSize:13,renderLineHighlight:"none"},defaultLanguage:"sql",onMount:o})}function Nn(){const s=t.useEditorStore(o=>o.card.python),{setCardPython:a}=t.useEditorActions(),{handleEditorDidMount:n}=zt("python");function r(o){a(o)}return e.jsx(t.Ft,{className:"pt-3",theme:"default",onChange:r,value:s||t.PYTHON_DEFAULT_CODE,options:{minimap:{enabled:!1},wordWrap:"on",scrollbar:{verticalScrollbarSize:0,horizontalScrollbarSize:0},fontSize:13,renderLineHighlight:"none"},defaultLanguage:"python",onMount:n})}function wn({jsonString:s}){return e.jsx(t.Ft,{theme:"default",defaultLanguage:"json",className:"mt-1 min-h-[220px]",value:s,options:{readOnly:!0,minimap:{enabled:!1},lineNumbers:"off",glyphMargin:!1,wordWrap:"on",scrollbar:{verticalScrollbarSize:0,horizontalScrollbarSize:0},fontSize:12,renderLineHighlight:"none"}})}function Ft(s){var J,H,Z;const[a,n]=E.useState(""),[r,o]=E.useState(null),{authToken:c}=t.useSemaphorContext(),i=t.useEditorStore(z=>{var Q;return(Q=z==null?void 0:z.card)==null?void 0:Q.sql}),l=t.useEditorStore(z=>{var Q;return(Q=z==null?void 0:z.card)==null?void 0:Q.python}),d=t.useEditorStore(z=>z.actions.setCardSql),h=t.useEditorStore(z=>z.actions.setRunSql),m=t.useEditorStore(z=>z.actions.switchCardType),x=t.useEditorStore(z=>z.currentAssitantScope)||[],f=t.useEditorStore(z=>z.userInputForAI),u=t.useEditorStore(z=>z.triggerAIRun),C=t.useEditorStore(z=>z.selectedDatabaseName),p=t.useEditorStore(z=>z.selectedTableName),y=t.useEditorStore(z=>z.selectedConnectionId),g=t.useEditorStore(z=>z.selectedSchemaName),S=t.useDashboardStore(z=>z.dashboard.aiScopeTables),{setTriggerAIRun:b,setCurrentAssitantScope:I}=t.useEditorActions(),{selectedDatamodelName:N,connectionType:T,selectedDatamodelId:_}=te(),{messages:R,setMessages:U,reload:w,error:V,append:$,input:q,setInput:j,status:D,handleInputChange:M,handleSubmit:G,stop:O}=t.useChat({api:"https://semaphor.cloud/api/v1/assistant",headers:{Authorization:`Bearer ${c==null?void 0:c.accessToken}`},body:{random:Math.random()},maxSteps:10,onToolCall:k,onFinish(z,Q){v(Q.usage),n(""),Q.finishReason==="stop"&&n("")}});E.useEffect(()=>{u&&f&&(M({target:{value:f}}),setTimeout(()=>{G(),b(!1)},100))},[u,G,f,b,M]);async function k({toolCall:z}){if(z.toolName==="createChartFromSql"){const Q=z.args.sql,X=z.args.chartType;return m(X),d(Q),h(!0),{status:"success",message:"Let the user know that chart is created"}}else if(z.toolName==="getTableColumns")n("Getting table columns...");else{if(z.toolName==="getUserSql")return i?{status:"success",sql:i,python:l||""}:{status:"error",message:"No SQL found"};if(z.toolName==="getCurrentTableScope")return n("Getting table scope..."),P(),{status:"success",tables:x};n("Analyzing...")}}function v(z){o(Q=>Q?{promptTokens:Q.promptTokens+z.promptTokens,completionTokens:Q.completionTokens+z.completionTokens,totalTokens:Q.totalTokens+z.totalTokens}:z)}function A(z){const Q=t.removeFromScopeArray(x,z);L(Q)}function L(z){const Q=t.sanitizeAIScope(z);I(Q),U(X=>[...X,{id:crypto.randomUUID(),role:"system",content:`Current scope of tables | ${JSON.stringify(Q)}`}])}function K(){const z={databaseName:C||"",schemaName:g||"",tableName:p||"",datamodelId:_||"",datamodelName:t.resolveDatamodelName(N),connectionId:y||"",connectionType:T||""},Q=t.dedup([...x,z]);L(Q)}function P(){const z={databaseName:C||"",schemaName:g||"",tableName:p||"",datamodelName:t.resolveDatamodelName(N),connectionId:y||"",connectionType:T||"",datamodelId:_||""};if(!t.isInAiScopeArray([...S||[],...x],z)||x.length===0){const X=t.dedup([...S||[],...x,z]).filter(ne=>ne.connectionId===z.connectionId);L(X)}}const W=!["ready","error"].includes(D),B=(Z=(H=(J=JSON.parse((V==null?void 0:V.message)||"{}"))==null?void 0:J.error)==null?void 0:H.lastError)==null?void 0:Z.message;return{messages:R,setMessages:U,reload:w,append:$,input:q,setInput:j,isLoading:W,handleSetAIScope:P,handleAddCurrentTableToScope:K,removeFromCurrentSelections:A,currentAssitantScope:x,setCurrentAssitantScope:I,handleInputChange:M,handleSubmit:G,stop:O,chatStatus:D,toolStatus:a,llmUsage:r,onFinish:s,errorMessage:B}}function kn(s){const a=s.toUpperCase().indexOf("WHERE"),n=s.toUpperCase().indexOf("GROUP BY"),r=s.toUpperCase().indexOf("LIMIT"),o=s.toUpperCase().indexOf("ORDER BY");let c=s.length;if(o!==-1&&(c=o),r!==-1&&r<c&&(c=r),a!==-1){const i=s.substring(0,a),l=s.substring(a);return`${i} {{ filters | where }} AND ${l.substring(6)}`}else if(n!==-1){const i=s.substring(0,n),l=s.substring(n);return`${i} {{ filters | where }} ${l}`}else{const i=s.substring(0,c),l=s.substring(c);return console.log("beforeClause",i),console.log("afterClause",l),l?`${i} {{ filters | where }} ${l}`:`${i.replace(/;$/,"")} {{ filters | where }}`}}function Rt({variant:s="secondary"}){const{setCardSql:a}=t.useEditorActions(),n=t.useEditorStore(u=>u.frame),r=t.useEditorStore(u=>u.card),o=t.useEditorStore(u=>u.selectedSchemaName),c=t.useEditorStore(u=>u.selectedDatamodelId),i=t.useEditorStore(u=>u.selectedDatabaseName),l=t.useEditorStore(u=>u.selectedTableName),d=t.useEditorStore(u=>u.selectedConnectionId),h=t.useEditorStore(u=>u.isShowingVisual),m=r.sql,x=t.useEditorStore(u=>u.onSave);function f(){let u=m;m&&!m.includes("{{")&&(u=kn(m),a(u));const C={...r,lastSelectedSchema:o,lastSelectedDatamodelId:c,lastSelectedDatabase:i,lastSelectedTable:l,connectionId:d,type:h?r.type:"table",sql:u,customCfg:h?r.customCfg:null},p=n.cards.map(g=>g.id===r.id?C:g),y={...n,cards:p,activeCardId:In(p,n.activeCardId)};x==null||x(y)}return e.jsxs(t.Button,{onClick:f,size:"sm",variant:s,children:[e.jsx(t.Check,{className:"mr-2 size-4 font-bold"}),"Accept"]})}function Bt(){const{setTempQueryData:s,setSqlGen:a}=t.useEditorActions(),n=t.useQueryClient(),r=t.useEditorStore(d=>d.tempQueryData),o=t.useEditorStore(d=>d.onClose),c=t.useEditorStore(d=>d.card),{queryKey:i}=t.useDashboardCardQuery(c);function l(){if(r){const{queryKey:d,queryData:h}=r;d&&h&&n.setQueryData(d,h)}a({}),o==null||o()}return e.jsxs(t.Button,{onClick:l,size:"sm",variant:"secondary",children:[e.jsx(t.X,{className:"mr-2 size-4"}),"Close"]})}function _t(){const{setTempQueryData:s}=t.useEditorActions(),a=t.useQueryClient(),n=t.useEditorStore(u=>u.tempQueryData),r=t.useEditorStore(u=>u.card),{queryKey:o}=t.useDashboardCardQuery(r),{setCardSql:c,setSqlGen:i,setCardPython:l,setCardCustomCfg:d,setCardPreferences:h,setCardType:m,clearQueryConfig:x}=t.useEditorActions();function f(){const u=a.getQueryData(o);n!=null&&n.queryData||s({queryKey:o,queryData:u}),a.setQueryData(o,null),a.removeQueries({queryKey:o,exact:!0}),c(""),i({}),x(),l(""),d(""),h({})}return e.jsxs(t.Button,{onClick:f,className:"",size:"sm",variant:"secondary",children:[e.jsx(ks,{className:"mr-2 size-4"}),"Clear"]})}function In(s,a){if(s.length===0)return"";if(a){const n=s.find(r=>r.id===a);if(n){const r=n.tabTitle;if(r=="All__Header")return s[0].id;if(r&&r.endsWith("__Header")){const c=r.split("__")[0],i=s.find(l=>l.tabTitle===c);return i?i.id:s[0].id}return a}}return s[0].id}function Dn(){const s=t.useQueryClient(),[a,n]=E.useState(!1),[r,o]=E.useState(!1);t.useEditorStore(v=>v.frame);const c=t.useEditorStore(v=>v.card);t.useEditorStore(v=>v.isShowingVisual),t.useEditorStore(v=>v.selectedConnectionId),t.useEditorStore(v=>v.tempQueryData),t.useEditorStore(v=>v.selectedDatabaseName),t.useEditorStore(v=>v.selectedDatamodelId),t.useEditorStore(v=>v.selectedSchemaName);const i=t.useEditorStore(v=>v.showAIDialog);t.useEditorStore(v=>v.selectedTableName);const l=t.useEditorStore(v=>{var A;return(A=v==null?void 0:v.card)==null?void 0:A.sql}),{sheetFilterValues:d}=t.useSheetFilterValues(),{setCardCustomCfg:h,setQueryResultColumns:m,setCardSql:x,setTempQueryData:f,setPythonStdOut:u,setCardPreferences:C,setCardType:p,setCardPython:y,runAssistant:g,setShowAIDialog:S}=t.useEditorActions();t.useEditorStore(v=>v.onSave),t.useEditorStore(v=>v.onClose),t.useEditorStore(v=>v.actions.setSqlGen);const b=t.useEditorStore(v=>v.runSql),I=t.useEditorStore(v=>v.actions.setRunSql),N=t.useEditorStore(v=>v.actions.setIsSqlRunning),{data:T,isLoading:_,isFetching:R,isSuccess:U,isError:w,error:V,queryKey:$,refetch:q,errorMessage:j}=t.useDashboardCardQuery(c),{handleSetAIScope:D}=Ft();E.useEffect(()=>{if(T&&(T.rowLimitExceeded&&t.ue.error("Row limit (10,000) exceeded. Refine your query.",{position:"top-center",richColors:!0}),u((T==null?void 0:T.output)||""),T.records.length>0)){const{dimensionKeys:v}=t.getKeys(T.records);m(v)}},[T,m,u]),E.useEffect(()=>{(_||R)&&N(!0),(w||U)&&N(!1),w&&(m([]),u(""))},[_,R,T,u,w,U,N,m,V]),E.useEffect(()=>{b&&(s.getQueryData($)||q(),I(!1))},[b,q,I,$,s]);async function M(){const v=`Can you help me debug this query in the current table scope?
371
+ */const Ct=t.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 Ge(s){var a;return{...s,sheets:(a=s==null?void 0:s.sheets)==null?void 0:a.map(n=>{var r;return{...n,frames:(r=n.frames)==null?void 0:r.map(o=>{var l;return{...o,cards:(l=o.cards)==null?void 0:l.map(i=>vt(i))}})}})}}function vt(s){return{...s,customCfg:sn(s.customCfg),data:[]}}function sn(s){var a,n;return s?{...s,data:{...s==null?void 0:s.data,labels:[],datasets:(n=(a=s==null?void 0:s.data)==null?void 0:a.datasets)==null?void 0:n.map(r=>({...r,data:[]}))}}:null}async function nn(s,a,n,r){if(!r)return null;const o=JSON.stringify(a);return await t.postRequest("https://semaphor.cloud/api/v1/lens",r,{name:s,template:o,filterValues:n,operation:"create"})}async function ze(s,a){if(!a)return null;const{id:n,template:r,filterValues:o,isDefault:l,shared:i}=s;return await t.postRequest("https://semaphor.cloud/api/v1/lens",a,{lensId:n,template:r,filterValues:o,isDefault:l,shared:i,operation:"update"})}async function an(s,a){return a?await t.postRequest("https://semaphor.cloud/api/v1/lens",a,{operation:"delete",lensId:s}):null}function rn(){const[s,a]=E.useState(""),[n,r]=E.useState(!1),o=t.useDashboardStore(p=>p.lenses),{setLenses:l,setSelectedLensId:i}=t.useDashboardActions(),[c,d]=E.useState(!1),[h,u]=E.useState(!1),x=t.useDashboardStore(p=>p.dashboard),f=t.useDashboardStore(p=>p.filterValues),{authToken:m}=t.useSemaphorContext();async function C(){d(!0);const p=Ge(x),y=await nn(s,p,f,m==null?void 0:m.accessToken);y&&(l([...o||[],y]),i(y.id),u(!1)),d(!1)}return e.jsxs(t.Dialog,{open:h,onOpenChange:u,children:[e.jsx(t.DialogTrigger,{asChild:!0,children:e.jsxs(t.Button,{variant:"secondary",className:"h-7 p-2",size:"sm",children:[e.jsx(t.Plus,{className:"mr-2 h-4 w-4"}),"Lens"]})}),e.jsxs(t.DialogContent,{className:"sm:max-w-[425px]",children:[e.jsxs(t.DialogHeader,{children:[e.jsx(t.DialogTitle,{children:"Create Lens"}),e.jsx(t.DialogDescription,{children:"Lenses are private by default and are only visible to you."})]}),e.jsx("div",{className:"grid gap-4 py-4",children:e.jsxs("div",{className:"grid grid-cols-8 items-center gap-4",children:[e.jsx(t.Label,{className:"text-right",children:"Name"}),e.jsx(t.Input,{value:s,onChange:p=>{a(p.target.value)},id:"name",className:"col-span-7 focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0"})]})}),n&&e.jsx("p",{className:"text-sm",children:"The lens name already exists. Use a differnet name."}),e.jsx(t.DialogFooter,{children:e.jsx(t.Button,{size:"sm",variant:"outline",type:"submit",onClick:C,disabled:c,children:c?"Creating...":"Add"})})]})]})}function on(){const[s,a]=E.useState(!1),n=t.useDashboardStore(u=>u.lenses),r=t.useDashboardStore(u=>u.selectedLensId),{setLenses:o,setSelectedLensId:l}=t.useDashboardActions(),{authToken:i}=t.useSemaphorContext();async function c(u){l(u)}async function d(u){if(await an(u,i==null?void 0:i.accessToken)){const f=n==null?void 0:n.filter(m=>m.id!==u);o(f||[]),l("original")}}async function h(u){const x=n==null?void 0:n.map(C=>C.id===u.id?{...C,isDefault:!u.isDefault}:{...C,isDefault:!1});o(x||[]);const f={...u,isDefault:!u.isDefault};await ze(f,i==null?void 0:i.accessToken);const m=n==null?void 0:n.find(C=>C.isDefault);if(m&&m.id!==u.id){const C={...m,isDefault:!1};await ze(C,i==null?void 0:i.accessToken)}}return e.jsxs(t.DropdownMenu,{open:s,onOpenChange:a,children:[e.jsx(t.DropdownMenuTrigger,{asChild:!0,children:e.jsx(t.IconButton,{tooltip:"Lenses",className:"h-7 p-2",children:e.jsx(As,{className:"h-4 w-4"})})}),e.jsxs(t.DropdownMenuContent,{align:"end",className:"w-60",children:[e.jsx(t.DropdownMenuLabel,{className:"px-3",children:"Lenses"}),e.jsx(t.DropdownMenuSeparator,{}),e.jsxs(t.DropdownMenuRadioGroup,{value:r,onValueChange:c,children:[e.jsx(t.DropdownMenuRadioItem,{value:"original",children:"Original"}),n==null?void 0:n.map(u=>e.jsxs(t.DropdownMenuRadioItem,{className:"group flex justify-between gap-2",value:u.id,children:[e.jsx("p",{children:u.name}),e.jsxs("span",{className:"flex items-center gap-3",children:[e.jsx(zs,{onClick:x=>{x.preventDefault(),h(u)},className:t.cn("size-3.5 text-muted-foreground hover:cursor-pointer hover:text-foreground group-hover:visible",{invisible:!u.isDefault,"text-green-500":u.isDefault}),strokeWidth:1.5}),e.jsx(t.Cross2Icon,{onClick:x=>{x.preventDefault(),d(u.id)},className:"invisible size-3.5 text-muted-foreground hover:cursor-pointer hover:text-foreground group-hover:visible",strokeWidth:1.5})]})]},u.id))]})]})]})}function Nt(){var l;const s=t.useDashboardStore.getState().authToken,a=t.useDashboardStore.getState().theme,n=t.useDashboardStore.getState().filterValues,r=(l=t.useDashboardStore.getState().dashboard)==null?void 0:l.title,o=t.useDashboardStore.getState().selectedSheetId;return{authToken:s,theme:a||"light",filterValues:n,dashboardTitle:r||"",selectedSheetId:o||""}}async function wt(){const s=t.useDashboardStore.getState().isDownloadingPdf,{authToken:a,theme:n,filterValues:r,dashboardTitle:o,selectedSheetId:l}=Nt();if(s)return;const i=new URLSearchParams;i.set("token",(a==null?void 0:a.accessToken)||""),i.set("theme",n),i.set("filterValues",JSON.stringify(r)),i.set("selectedSheetId",l||"");const c=`https://semaphor.cloud/api/v1/generate-pdf?params=${encodeURIComponent(i.toString())}`;t.useDashboardStore.setState({isDownloadingPdf:!0});const u=(await(await fetch(c,{method:"GET",headers:{Authorization:`Bearer ${a==null?void 0:a.accessToken}`}})).json()).url,x=document.createElement("a");x.href=u;const f=`${o}-${new Date().toISOString()}.pdf`;x.download=f,x.click(),t.useDashboardStore.setState({isDownloadingPdf:!1})}function ln({iconClassName:s}){const{authToken:a}=t.useSemaphorContext();t.useDashboardStore(o=>{var l;return(l=o.dashboard)==null?void 0:l.title}),t.useDashboardStore(o=>o.theme),t.useDashboardStore(o=>o.filterValues);const n=t.useDashboardStore(o=>o.isDownloadingPdf);async function r(){await wt()}return e.jsx(t.IconButton,{tooltip:"Download PDF",className:"h-7 p-2",onClick:r,children:n?e.jsx(oe,{className:t.cn("size-3.5 animate-spin",s)}):e.jsx(t.Download,{className:t.cn("size-4",s)})})}function ee({defaultValue:s,label:a,options:n,value:r,onValueChange:o,className:l,icon:i,showPlaceholderLabel:c=!0}){return e.jsxs(t.Select,{defaultValue:s,value:r,onValueChange:o,children:[e.jsx(t.SelectTrigger,{className:t.cn("w-full focus:ring-0 focus:ring-offset-0",l),children:e.jsxs("div",{className:"flex items-center gap-2",children:[i&&e.jsx("span",{children:i}),c&&e.jsx(t.SelectValue,{placeholder:a})]})}),e.jsx(t.SelectContent,{children:e.jsxs(t.SelectGroup,{children:[e.jsx(t.SelectLabel,{children:a}),n.map(d=>e.jsx(t.SelectItem,{value:d.value,children:d.label},d.value))]})})]})}const tt=[{value:"daily",label:"Daily"},{value:"weekly",label:"Weekly"},{value:"biweekly",label:"Bi-Weekly"},{value:"monthly",label:"Monthly"}];function kt({triggerButtonClassName:s}){const{data:a,handleScheduleSubscription:n,handleDeleteSubscription:r,status:o,error:l,isDeleting:i}=cn(),[c,d]=E.useState(""),[h,u]=E.useState(tt[0].value),[x,f]=E.useState("06:00"),[m,C]=E.useState("");return e.jsx(t.TooltipProvider,{delayDuration:0,children:e.jsxs(t.Popover,{children:[e.jsx(t.PopoverTrigger,{asChild:!0,children:e.jsx(t.IconButton,{tooltip:"Schedule Dashboard",className:t.cn("h-7 p-2",s),children:e.jsx(vs,{className:"size-4"})})}),e.jsx(t.PopoverContent,{align:"end",className:"w-80",children:e.jsxs("div",{className:"grid gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("h4",{className:"font-medium leading-none",children:"Schedule Subscription"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Subscribe to receive dashboard via email"})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsxs("div",{className:"grid grid-cols-3 items-center gap-4",children:[e.jsx(t.Label,{htmlFor:"email",children:"Email"}),e.jsx(t.Input,{id:"email",value:c,onChange:p=>d(p.target.value),className:`col-span-2 h-8 ${t.removeRing}`})]}),e.jsxs("div",{className:"grid grid-cols-3 items-center gap-4",children:[e.jsx(t.Label,{htmlFor:"subject",children:"Subject"}),e.jsx(t.Input,{id:"subject",placeholder:"Monthly Sales Report",value:m,onChange:p=>{C(p.target.value.replace(/[^a-zA-Z0-9\s-_]/g,""))},className:`col-span-2 h-8 ${t.removeRing}`})]}),e.jsxs("div",{className:"grid grid-cols-3 items-center gap-4",children:[e.jsx(t.Label,{htmlFor:"frequency",children:"Frequency"}),e.jsx(ee,{className:"col-span-2 h-8",label:"Select Frequency",options:tt,value:h,onValueChange:p=>u(p)})]}),e.jsxs("div",{className:"grid grid-cols-3 items-center gap-4",children:[e.jsx(t.Label,{htmlFor:"time",children:"Time"}),e.jsx(t.Input,{id:"time",type:"time",value:x,onChange:p=>f(p.target.value),className:`col-span-2 h-8 ${t.removeRing}`})]}),e.jsx("div",{className:"mt-2 flex justify-end",children:e.jsxs(t.Button,{onClick:async()=>{await n({email:c,frequency:h,time:x,subject:m}),f("00:00"),d(""),C("")},className:"h-8 p-2",disabled:o==="loading"||!c,children:[o==="loading"&&e.jsx(oe,{className:"mr-2 size-4 animate-spin"}),o==="success"&&e.jsx(t.Check,{className:"mr-2 size-4"}),o==="error"&&e.jsxs(t.Tooltip,{children:[e.jsx(t.TooltipTrigger,{children:e.jsx(dt,{className:"mr-2 size-4 text-destructive"})}),e.jsx(t.TooltipContent,{children:e.jsx("p",{children:l})})]}),"Schedule"]})}),a&&a.length>0&&e.jsxs("div",{className:"space-y-4",children:[e.jsx(t.Separator,{className:"my-2"}),e.jsx("div",{className:"space-y-2",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("h4",{className:"font-medium leading-none",children:"Subscriptions"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Active email subscriptions"})]}),t.isDevEnv]})}),e.jsx("div",{className:"grid gap-2",children:a==null?void 0:a.map(p=>e.jsxs("div",{className:"group grid grid-cols-5 gap-3",children:[e.jsx("div",{className:"col-span-3 text-sm",children:e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"boder-border rounded-md border bg-muted px-2 py-1",children:[t.titleCase(p.frequency)," "]}),e.jsx(t.Label,{children:p.time})]})}),e.jsxs("div",{className:"col-span-2 flex items-center justify-end gap-4",children:[e.jsx(st,{tooltip:`Next Run: ${new Date(p.nextRun).toLocaleString()} ${p.timezone}`,children:e.jsx(Cs,{className:"size-3.5"})}),e.jsx(st,{tooltip:`${p.endUserEmail}`,children:e.jsx(qs,{className:"size-3.5"})}),i===p.id?e.jsx(oe,{className:"size-3.5 animate-spin"}):e.jsx(tn,{onClick:()=>r(p.id),className:"size-3.5 cursor-pointer"})]})]},p.id))})]})]})]})})]})})}const st=({children:s,tooltip:a})=>e.jsx(t.TooltipProvider,{delayDuration:0,children:e.jsxs(t.Tooltip,{children:[e.jsx(t.TooltipTrigger,{asChild:!0,children:s}),e.jsx(t.TooltipContent,{children:a})]})});function cn(){const[s,a]=E.useState("idle"),[n,r]=E.useState(""),[o,l]=E.useState(null),i=t.useDashboardStore(b=>b.authToken),c=t.useDashboardStore(b=>b.dashboard.id),d=t.useDashboardStore(b=>b.dashboard.title),{endUserId:h}=t.getTenantAndEndUserId((i==null?void 0:i.accessToken)||""),u="https://semaphor.cloud/api/v1/subscriptions/get",x={dashboardId:c,endUserId:h},{data:f,isLoading:m,isError:C,isFetching:p,refetch:y}=t.useQuery({queryKey:["subscriptions",c,h],queryFn:()=>t.getRequest(u,(i==null?void 0:i.accessToken)||"",x),enabled:!!(i!=null&&i.accessToken)&&!!c&&!!h});async function g({email:b,subject:I,frequency:N,time:T}){const{authToken:_,...R}=Nt(),U=Intl.DateTimeFormat().resolvedOptions().timeZone,w={email:b,frequency:N,time:T,timezone:U,endUserId:h,endUserEmail:b,subject:I||d||"Scheduled Dashboard",dashboardId:c,dashboardParams:R};a("loading");const V="https://semaphor.cloud/api/v1/subscriptions/create";try{const $=await t.postRequestRegular(V,(_==null?void 0:_.accessToken)||"",{...w});a("success"),r(""),y(),setTimeout(()=>{a("idle")},2e3)}catch($){console.error($),a("error"),r($.message)}}async function S(b){const I="https://semaphor.cloud/api/v1/subscriptions/delete";l(b);try{await t.postRequestRegular(I,(i==null?void 0:i.accessToken)||"",{id:b}),y(),setTimeout(()=>{l(null)},2e3)}catch(N){console.error(N),l(null),a("error"),r(N.message)}}return{data:f,isLoading:m,isFetching:p,isError:C,isDeleting:o,refetch:y,handleScheduleSubscription:g,handleDeleteSubscription:S,status:s,error:n}}function dn(){const{authToken:s}=t.useSemaphorContext();t.useDashboardStore(w=>w.theme);const a=t.useDashboardStore(w=>w.lenses),n=t.useDashboardStore(w=>w.selectedLensId),r=a==null?void 0:a.find(w=>w.id===n),o=t.useDashboardStore(w=>w.dashboard);t.useDashboardStore(w=>w.selectedSheetId);const l=t.useDashboardStore(w=>w.isDashboardEditing),i=t.useEditorStore(w=>w.selectedConnectionId),[c,d]=E.useState(!1),h=t.useDashboardStore(w=>w.filterValues),u=t.useDashboardStore(w=>w.isVisualEditing),x=t.useDashboardStore(w=>w.showFilters);t.useDashboardStore(w=>w.showDashboardJSON);const f=t.useDashboardStore(w=>w.onSaveFunction),m=t.useDashboardStore(w=>w.actions.setShowFilters),{addFrame:C,setSelectedFrameId:p}=t.useDashboardStore(w=>w.actions),{getSelectedSheet:y,setIsDashboardEditing:g,setShowDashboardJSON:S}=t.useDashboardStore(w=>w.actions),b=y(),{tenantId:I,endUserId:N}=E.useMemo(()=>t.getTenantAndEndUserId(s==null?void 0:s.accessToken),[s==null?void 0:s.accessToken]),T=E.useMemo(()=>I||N,[I,N]),_=()=>{if(!l||!b)return;const w={connectionId:i,id:t.v4(),title:"Title",description:"Description",preferences:{onClickFilter:[{columnIndex:0,expression:""}]},type:"bar",sql:"",data:[]},V={id:t.v4(),cards:[w],activeCardId:w.id};C(b.id,V),p(V.id)},R=()=>{g(!0)};async function U(){if(d(!0),!n||!r)return;const w=Ge(o),V=JSON.stringify(w),$={...r,template:V,filterValues:h};await ze($,s==null?void 0:s.accessToken),t.ue.success("Lens saved"),f==null||f(w),d(!1)}return u?null:e.jsxs("div",{className:"flex items-center justify-between gap-2 border-b py-1 pl-3 pr-2",role:"dashboard-controls",children:[!u&&e.jsx("div",{className:"flex items-center gap-3",children:e.jsx(t.Label,{children:r==null?void 0:r.name})}),e.jsxs("div",{className:"flex gap-2",children:[!1,!u&&e.jsx(ln,{}),!u&&e.jsx(kt,{}),l&&!u&&T&&e.jsx(rn,{}),!u&&T&&e.jsx(on,{}),l&&!u&&e.jsxs(t.Button,{variant:"secondary",className:"h-7 p-2",size:"sm",disabled:!l,onClick:_,children:[e.jsx(t.Plus,{className:"mr-2 h-4 w-4"}),"Frame"]}),!l&&e.jsx(t.Button,{variant:"ghost",className:"h-7 p-2",onClick:R,size:"sm",children:e.jsx(t.Pencil,{className:"h-4 w-4"})}),l&&!u&&e.jsx(t.IconButton,{className:"h-7 p-2",onClick:()=>{g(!1),S(!1)},children:e.jsx(t.Cross2Icon,{className:"h-4 w-4"})}),l&&!u&&T&&e.jsx(t.Button,{className:"h-7 p-2",variant:"ghost",disabled:c,onClick:U,size:"sm",children:e.jsx(Js,{className:"h-4 w-4"})}),!x&&!u&&l&&e.jsx(t.Button,{className:"h-7 p-2",variant:"ghost",onClick:()=>m(!0),size:"sm",children:e.jsx(pt,{className:"h-4 w-4"})}),!u&&l&&!1,!u&&!1]})]})}function un({name:s,items:a,value:n,onChange:r,isLoading:o,isError:l,refetch:i,className:c,icon:d,showNone:h=!1}){const u=de.useRef(null),[x,f]=de.useState(!1),[m,C]=de.useState("100%"),p=h?[...a||[],{id:"none",name:"None"}]:a;de.useLayoutEffect(()=>{u.current&&C(u.current.offsetWidth)},[]);function y(){var S;return o?"Loading...":l?"Error":n?(S=a==null?void 0:a.find(b=>b.id===n))==null?void 0:S.name:`Select ${s}`}function g(S,b){r(b),f(!1)}return e.jsxs(t.Popover,{open:x,onOpenChange:f,children:[e.jsx(t.PopoverTrigger,{asChild:!0,children:e.jsxs(t.Button,{ref:u,variant:"outline",role:"combobox","aria-expanded":x,className:t.cn("flex h-9 w-full justify-between",c),children:[e.jsxs("div",{className:"flex items-center gap-2",children:[d&&e.jsx("div",{className:"mr-2",children:d}),e.jsx("span",{className:"max-w-[150px] overflow-hidden truncate text-ellipsis whitespace-nowrap",children:y()})]}),e.jsx(t.ChevronDown,{className:"size-4 opacity-50"})]})}),e.jsx(t.PopoverContent,{className:"w-full p-0",style:{minWidth:m},children:e.jsxs(t.Command,{children:[e.jsxs("div",{className:"flex h-9 items-center justify-between border-b pr-1",children:[e.jsx(t.CommandInput,{className:"h-9",placeholder:"Search..."}),e.jsx(t.IconButton,{className:"h-7",onClick:i,children:e.jsx(jt,{className:t.cn("size-3.5 opacity-50",o&&"animate-spin")})})]}),e.jsxs(t.CommandList,{children:[e.jsxs(t.CommandEmpty,{children:["No ",s==null?void 0:s.toLowerCase()," found."]}),e.jsx(t.CommandGroup,{children:p==null?void 0:p.map(S=>e.jsx(t.CommandItem,{className:"overflow-x-auto",value:S.name,onSelect:b=>g(b,S.id),children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(t.Check,{className:t.cn("size-4",n===S.id?"opacity-100":"opacity-0")}),e.jsx("div",{title:S.name,children:S.name})]})},S.id))})]})]})})]})}function ce({title:s,items:a,value:n,isLoading:r,isError:o,refetch:l,onChange:i,showNone:c=!1,className:d,disabled:h=!1,type:u="combobox"}){const x=r?"Loading...":o?"Error":n;function f(){if(s==="Connection")return e.jsx($s,{className:"size-4"});if(s==="Database")return e.jsx(Is,{className:"size-4"});if(s==="Schema")return e.jsx(Us,{className:"size-4"});if(s==="Table")return e.jsx(He,{className:"size-4"});if(s==="Model")return e.jsx(ys,{className:"size-4"})}function m(){return e.jsxs(t.Select,{disabled:h,value:x,onValueChange:i,children:[e.jsx(t.SelectTrigger,{className:t.cn("h-9 w-full border-muted focus:ring-1 focus:ring-offset-0",d),children:e.jsx(t.SelectValue,{placeholder:r?"Loading...":o?"Error":`Select ${s}`})}),e.jsx(t.SelectContent,{children:e.jsxs(t.SelectGroup,{children:[r?e.jsx(t.SelectLabel,{children:"Loading..."}):e.jsxs(t.SelectLabel,{className:"flex items-center justify-between gap-2",children:[s,e.jsx(jt,{className:t.cn("mr-1 size-3 cursor-pointer text-muted-foreground hover:text-foreground",r&&"animate-spin"),onClick:l})]}),e.jsxs(e.Fragment,{children:[c&&e.jsx(t.SelectItem,{value:"none",children:"None"},"none"),a&&a.map((p,y)=>e.jsx(t.SelectItem,{value:p.id,children:p.name},y))]}),(r||o)&&e.jsx(t.SelectItem,{value:x,children:x})]})})]})}function C(){return e.jsx(un,{icon:f(),items:a,value:x,onChange:i||(()=>{}),isLoading:r,isError:o,refetch:l,name:s,showNone:c})}return e.jsx(t.TooltipProvider$1,{delayDuration:0,children:e.jsx("div",{className:"flex items-center gap-2",children:u==="select"?m():C()})})}function mn({column:s}){const[a,n]=E.useState(!1),r=t.useEditorStore(p=>p.selectedTableName),o=t.useEditorStore(p=>p.selectedSchemaName),l=t.useEditorStore(p=>p.selectedDatabaseName),i=t.useEditorStore(p=>p.selectedDatamodelId),c=t.useEditorStore(p=>p.sqlGen),{modelItems:d,connectionType:h}=te(),u=t.useEditorStore(p=>p.actions.setSqlGen),x=t.useEditorStore(p=>p.actions.setCardSql),f=t.useEditorStore(p=>p.actions.setRunSql);function m(p,y){var I;const g=t.createSqlGenConfig(p,c,y),S=(I=d==null?void 0:d.find(N=>N.id===i))==null?void 0:I.name;u(g);const b=t.getSql(g,t.fmt(o||""),t.fmt(r),S,h,l||"");b&&(x(b),f(!0)),n(!1)}function C(){return e.jsxs("ul",{className:"text-xs",children:[e.jsx("li",{onClick:()=>m(s,"COUNT"),className:"cursor-pointer p-1 px-3 transition-colors hover:bg-muted",children:"Count"}),e.jsx("li",{onClick:()=>m(s,"AVG"),className:"cursor-pointer p-1 px-3 transition-colors hover:bg-muted",children:"Avg"}),e.jsx("li",{onClick:()=>m(s,"SUM"),className:"cursor-pointer p-1 px-3 transition-colors hover:bg-muted",children:"Sum"}),e.jsx("li",{onClick:()=>m(s,"MAX"),className:"cursor-pointer p-1 px-3 transition-colors hover:bg-muted",children:"Max"}),e.jsx("li",{onClick:()=>m(s,"MIN"),className:"cursor-pointer p-1 px-3 transition-colors hover:bg-muted",children:"Min"})]})}return e.jsxs(t.HoverCard,{openDelay:0,open:a,onOpenChange:n,children:[e.jsx(t.HoverCardTrigger,{asChild:!0,children:e.jsx(mt,{className:"invisible size-3.5 cursor-pointer text-foreground/40 group-hover:visible"})}),e.jsx(t.HoverCardContent,{align:"center",className:"w-20 rounded-md p-0 shadow-none",children:C()})]})}function Ue({column:s}){return e.jsxs(t.Tooltip,{children:[e.jsx(t.TooltipTrigger$1,{asChild:!0,children:t.isTextDataType(s.data_type)?e.jsx(Ct,{className:"size-3"}):t.isNumberDataType(s.data_type)?e.jsx(xt,{className:"size-3"}):t.isDateDataType(s.data_type)?e.jsx(t.Calendar,{className:"size-3"}):t.isBooleanDataType(s.data_type)?e.jsx(en,{className:"size-3"}):s.data_type.toLowerCase()==="json"?e.jsx(bs,{className:"size-3"}):e.jsx(Ws,{className:"size-3"})}),e.jsx(t.TooltipContent,{children:e.jsx("p",{className:"font-mono text-xs",children:s.data_type})})]})}function Ie({column:s,className:a}){return e.jsxs("div",{className:t.cn("flex h-8 grow items-center space-x-2 px-2 text-sm",a),children:[e.jsx(Ue,{column:s}),e.jsx("span",{children:s.column_name})]})}function hn({id:s,children:a,type:n="column"}){const{attributes:r,listeners:o,setNodeRef:l,transform:i}=t.useDraggable({id:s,data:{type:n}}),c=i?{translate:t.CSS.Translate.toString(i),transform:t.CSS.Transform.toString(i)}:void 0;return e.jsx("div",{ref:l,style:c,...o,...r,children:a})}function pn({onClick:s,column:a}){const n=t.useDndStore(f=>f.activeId),r=t.useEditorStore(f=>{var m;return(m=f.card.queryConfig)==null?void 0:m.groupByColumns}),o=t.useEditorStore(f=>{var m;return(m=f.card.queryConfig)==null?void 0:m.trendByColumns}),l=t.useEditorStore(f=>{var m;return(m=f.card.queryConfig)==null?void 0:m.metricColumns}),i=t.useEditorStore(f=>{var m;return(m=f.card.queryConfig)==null?void 0:m.filterColumns});function c(f){return d(f)||u(f)||h(f)||x(f)}function d(f){return r==null?void 0:r.some(m=>m.name===f.column_name)}function h(f){return o==null?void 0:o.some(m=>m.name===f.column_name)}function u(f){return l==null?void 0:l.some(m=>m.name===f.column_name)}function x(f){return i==null?void 0:i.some(m=>m.name===f.column_name)}return e.jsxs("div",{onClick:()=>s(a),className:t.cn("relative grow overflow-x-hidden overflow-y-hidden rounded-md active:border active:border-dashed active:border-muted-foreground",{"bg-muted-foreground/10":c(a)}),children:[n===a.column_name&&e.jsx(t.DragOverlay,{children:e.jsx(Ie,{column:a,className:"rounded-md border-2 border-dashed border-muted-foreground bg-muted shadow-md"})}),n===a.column_name&&e.jsx("div",{className:"absolute inset-0",children:n===a.column_name&&e.jsx(Ie,{column:a})}),e.jsx(hn,{id:a.column_name,type:"column",children:e.jsx(Ie,{column:a})})]})}function It(s){const a=t.useDashboardStore(d=>d.authToken)||s,n=t.useEditorStore(d=>d.selectedConnectionId),{refetch:r,data:o,isLoading:l,isError:i}=t.useQuery({queryKey:["connections"],queryFn:()=>t.getRequest("https://semaphor.cloud/api/v1/connections",(a==null?void 0:a.accessToken)||""),enabled:!!(a!=null&&a.accessToken)}),c=o==null?void 0:o.connections.find(d=>d.id===n);return{connectionsData:o,isConnectionsLoading:l,isConnectionsError:i,refetchConnections:r,currentConnection:c}}function $e(s){var y;const a=t.useDashboardStore(g=>g.authToken)||s,n=t.useEditorStore(g=>g.selectedConnectionId),r=t.useEditorStore(g=>g.selectedDatabaseName),o=t.useEditorStore(g=>g.selectedDatamodelId),l=t.useEditorStore(g=>g.selectedSchemaName),i=t.useEditorStore(g=>g.selectedTableName),{currentConnection:c}=It(),d=c==null?void 0:c.type,{data:h,isLoading:u,isFetching:x,isError:f,refetch:m}=t.useQuery({queryKey:["columns",n,r,o,l,i],queryFn:()=>t.getRequest("https://semaphor.cloud/api/v1/columns",(a==null?void 0:a.accessToken)||"",{connection_id:n,datamodel_id:o||"",database_name:r,schema_name:l,table_name:i}),enabled:C(d)});function C(g){return a!=null&&a.accessToken?!!(n&&r&&r!=="NA"&&l&&i||n&&(g==="S3"||g==="API")||o&&o):!1}return{columns:(y=h==null?void 0:h.columns)==null?void 0:y.map(g=>({...g,data_type:g.data_type.toLowerCase()})),isColumnsLoading:u,isColumnsFetching:x,isColumnsError:f,refetchColumns:m}}function te(s,a){var We,Ye,Ze,Xe,et;const n=t.useSemaphorContext().authToken||s,r=t.useEditorStore(F=>F.selectedConnectionId),o=t.useEditorStore(F=>F.selectedDatamodelId),l=t.useEditorStore(F=>F.selectedDatabaseName),i=t.useEditorStore(F=>F.selectedSchemaName),c=t.useEditorStore(F=>F.selectedTableName),d=t.useEditorStore(F=>F.actions.setSelectedConnectionId),h=t.useEditorStore(F=>F.actions.setSelectedDatamodelId),u=t.useEditorStore(F=>F.actions.setSelectedDatabaseName),x=t.useEditorStore(F=>F.actions.setSelectedSchemaName),f=t.useEditorStore(F=>F.actions.setSelectedTableName);t.useEditorStore(F=>F.actions.setCardSql);function m(F){return r&&l&&i&&l!=="NA"?!0:r&&F==="API"?!1:!!(r&&F==="S3")}function C(F){return r&&F?!(F==="API"||F==="S3"):!1}const{refetchConnections:p,connectionsData:y,isConnectionsLoading:g,isConnectionsError:S,currentConnection:b}=It(s),{refetch:I,data:N,isLoading:T,isError:_}=t.useQuery({queryKey:["models",r],queryFn:()=>t.getRequest("https://semaphor.cloud/api/v1/datamodels",(n==null?void 0:n.accessToken)||"",{connection_id:r}),enabled:!!(n!=null&&n.accessToken)&&!!r}),R=b==null?void 0:b.type,U=(b==null?void 0:b.type)==="API"||(b==null?void 0:b.type)==="S3",{data:w,isLoading:V,isFetching:$,isError:q,refetch:j}=t.useQuery({queryKey:["databases",r],queryFn:()=>t.getRequest("https://semaphor.cloud/api/v1/databases",(n==null?void 0:n.accessToken)||"",{connection_id:r}),enabled:C(R)}),{data:D,isLoading:M,isFetching:G,isError:O,refetch:k}=t.useQuery({queryKey:["schemas",r,l],queryFn:()=>t.getRequest("https://semaphor.cloud/api/v1/schemas",(n==null?void 0:n.accessToken)||"",{connection_id:r,database_name:l}),enabled:!!r&&!!l&&!U&&l!=="NA"}),{data:v,isLoading:A,isFetching:L,isError:J,refetch:P}=t.useQuery({queryKey:["tables",r,l,i],queryFn:()=>t.getRequest("https://semaphor.cloud/api/v1/tables",(n==null?void 0:n.accessToken)||"",{connection_id:r,database_name:l,schema_name:i}),enabled:m(R)}),{columns:W,isColumnsLoading:B,isColumnsFetching:K,isColumnsError:H,refetchColumns:Z}=$e(s);E.useEffect(()=>{(R==="S3"||R==="API")&&(u(""),x(""),h(""),R==="API"&&f("api"))},[R,f,u,x,h]);const z=(b==null?void 0:b.type)==="API"?(We=b==null?void 0:b.type)==null?void 0:We.toLowerCase():c||"",Q=U?"":i||"";function X(F){x(F),f("")}function ne(F){u(F==="none"?"":F),x(""),f(""),F!=="none"&&F!==""&&h("")}function le(F){d(F)}function ve(F){h(F==="none"?"":F),F!=="none"&&F!==""&&u("")}w&&((Ye=w==null?void 0:w.databases)==null?void 0:Ye.length)>0,D&&((Ze=D==null?void 0:D.schemas)==null?void 0:Ze.length)>0;const Ne=y==null?void 0:y.connections.map(F=>({id:F.id,name:F.name,type:F.type})),we=(Xe=N==null?void 0:N.datamodels)==null?void 0:Xe.map(F=>({id:F.id,name:F.name})),ke=w==null?void 0:w.databases.map(F=>({id:F.database_name,name:F.database_name})),ge=D==null?void 0:D.schemas.map(F=>({id:F.schema_name,name:F.schema_name})),Y=v==null?void 0:v.tables.map(F=>({id:F.table_name,name:F.table_name})),se=(et=N==null?void 0:N.datamodels.find(F=>F.id===o))==null?void 0:et.name,ts=t.getFormattedTableNameForQuery({schemaName:Q,tableName:z,modelName:se,connectionType:R,databaseName:l||""});return{connectionItems:Ne,selectedConnectionId:r,isConnectionsLoading:g,isConnectionsError:S,modelItems:we,selectedDatamodelId:o,selectedDatamodelName:se,isModelsLoading:T,isModelsError:_,selectedDatabaseName:l,databaseItems:ke,isDatabasesLoadingOrFetching:V||$,isDatabaseError:q,schemaItems:ge,selectedSchemaName:i,isSchemaLoadingOrFetching:M||G,isSchemaError:O,tableItems:Y,selectedTableName:c,isTableLoadingOrFetching:A||L,isTableError:J,columns:W,isColumnsLoadingOrFetching:B||K,isColumnsError:H,isNonDbConnection:U,connectionType:R,tableName:z,formattedTableName:ts,schemaName:Q,refetchConnections:p,refetchModels:I,refetchDatabases:j,refetchSchemas:k,refetchTables:P,refetchColumns:Z,handleConnectionChange:le,handleDatamodelChange:ve,handleDatabaseChange:ne,handleSchemaChange:X}}const De={id:"__placeholder__",role:"groupby",type:"string"},Ee={id:"__placeholder__",role:"metric",type:"number"},Te={id:"__placeholder__",role:"trendby",type:"date"},Me={name:"Filter",id:"__placeholder__",role:"filter",type:"string"},Dt={id:"__placeholder__"},ue="droppable-group-by",re="droppable-metrics",Fe="sortable-group-by",Re="sortable-metrics",me="droppable-trend-by",Be="sortable-trend-by",_e="droppable-filters",Ve="sortable-filters",Qe="sortable-order-by";function xn(){const s=t.useDndStore(j=>j.insertIndex),a=t.useEditorStore(j=>{var D;return((D=j.card.queryConfig)==null?void 0:D.groupByColumns)||[]}),n=t.useEditorStore(j=>{var D;return((D=j.card.queryConfig)==null?void 0:D.metricColumns)||[]}),r=t.useEditorStore(j=>{var D;return((D=j.card.queryConfig)==null?void 0:D.trendByColumns)||[]}),o=t.useEditorStore(j=>{var D;return((D=j.card.queryConfig)==null?void 0:D.filterColumns)||[]}),l=t.useEditorStore(j=>{var D;return((D=j.card.queryConfig)==null?void 0:D.orderBy)||[]}),{setInsertIndex:i,setActiveId:c,setPreviewGroupByColumns:d,setPreviewMetricColumns:h,setPreviewTrendByColumns:u,setPreviewFilterColumns:x}=t.useDndActions(),{setGroupByColumns:f,setMetricColumns:m,setTrendByColumns:C,setFilterColumns:p,setOrderByColumns:y}=t.useEditorActions(),{columns:g}=$e(),{formattedTableName:S}=te(),b=t.useSensors(t.useSensor(t.MouseSensor,{activationConstraint:{distance:1}})),I=j=>{var G;const{active:D,over:M}=j;if(((G=D.data.current)==null?void 0:G.type)==="column"&&M){const O=M.id,k=g.find(J=>J.column_name===D.id);if(!k)return;const v=t.isNumberDataType(k.data_type),A=t.isTextDataType(k.data_type),L=t.isDateDataType(k.data_type);if(A){if(a.some(P=>P.id===O)){const P=a.findIndex(B=>B.id===O);i(P);const W=a.filter(B=>B.id!==De.id);W.splice(P,0,De),d(W)}else if(M.id===ue){i(a.length);const P=[...a,De];d(P),h(n),u(r),x(o)}}if(v||A){if(n.some(P=>P.id===O)){console.log("isOverMetricSortable",O);const P=n.findIndex(B=>B.id===O);i(P);const W=n.filter(B=>B.id!==Ee.id);W.splice(P,0,Ee),h(W)}else if(M.id===re){i(n.length);const P=[...n,Ee];h(P),u(r),x(o),d(a)}}if(L){if(r.some(P=>P.id===O)){const P=r.findIndex(B=>B.id===O);i(P);const W=r.filter(B=>B.id!==Te.id);W.splice(P,0,Te),u(W)}else if(M.id===me){i(r.length);const P=[...r,Te];u(P),h(n),x(o),d(a)}}if(T(k)){if(o.some(P=>P.id===O)){const P=o.findIndex(B=>B.id===O);i(P);const W=o.filter(B=>B.id!==Me.id);W.splice(P,0,Me),x(W)}else if(M.id===_e){i(o.length);const P=[...o,Me];x(P),h(n),u(r),d(a)}}}else d(a),h(n),u(r),x(o)};function N(j){c(j.active.id),i(null),d(a),h(n),u(r),x(o)}function T(j){return!o.some(D=>D.name===j.column_name)}function _(j,D="SUM"){const{column_name:M,data_type:G}=j,O=[...n],k=s!==null?s:n.length,v={...j,id:ae(M),name:M,label:fe(M,D),type:G,role:"metric",aggregate:D};O.splice(k,0,v),m(O)}function R(j){const D=[...a],M=s!==null?s:a.length,G={...j,id:ae(j.column_name),name:j.column_name,type:j.data_type,role:"groupby"};D.splice(M,0,G),f(D)}function U(j){const D=[...r],M=s!==null?s:r.length,G={...j,id:ae(j.column_name),name:j.column_name,type:j.data_type,role:"trendby"};D.splice(M,0,G),C(D)}function w(j){const D=[...o],M=s!==null?s:o.length,G={...j,id:ae(j.column_name),name:j.column_name,type:j.data_type,sql:t.getDefaultFilterSql(j.data_type,S,t.fmt(j.column_name)),role:"filter"};D.splice(M,0,G),p(D)}function V(j){var O,k,v,A,L,J,P,W;const{active:D,over:M}=j,G=D.data.current;if((G==null?void 0:G.type)==="column"&&M){const B=g.find(z=>z.column_name===D.id);if(!B)return;const K=t.isNumberDataType(B.data_type),H=t.isTextDataType(B.data_type),Z=t.isDateDataType(B.data_type);H&&(M.id===ue||((O=M.data.current)==null?void 0:O.type)===Fe)?R(B):(K||H)&&(M.id===re||((k=M.data.current)==null?void 0:k.type)===Re)?(K&&_(B),H&&_(B,"COUNT")):Z&&(M.id===me||((v=M.data.current)==null?void 0:v.type)===Be)?U(B):T(B)&&(M.id===_e||((A=M.data.current)==null?void 0:A.type)===Ve)&&w(B)}if(M&&((L=M.data.current)==null?void 0:L.type)===Fe&&a.some(B=>B.id===D.id)){const B=a.findIndex(H=>H.id===D.id),K=a.findIndex(H=>H.id===M.id);if(B!==-1&&K!==-1&&B!==K){const H=[...a],[Z]=H.splice(B,1);H.splice(K,0,Z),f(H)}}if(M&&((J=M.data.current)==null?void 0:J.type)===Re&&n.some(B=>B.id===D.id)){const B=n.findIndex(H=>H.id===D.id),K=n.findIndex(H=>H.id===M.id);if(B!==-1&&K!==-1&&B!==K){const H=[...n],[Z]=H.splice(B,1);H.splice(K,0,Z),m(H)}}if(M&&((P=M.data.current)==null?void 0:P.type)===Be&&r.some(B=>B.id===D.id)){const B=r.findIndex(H=>H.id===D.id),K=r.findIndex(H=>H.id===M.id);if(B!==-1&&K!==-1&&B!==K){const H=[...r],[Z]=H.splice(B,1);H.splice(K,0,Z),C(H)}}if(M&&((W=M.data.current)==null?void 0:W.type)===Ve&&o.some(B=>B.id===D.id)){const B=o.findIndex(H=>H.id===D.id),K=o.findIndex(H=>H.id===M.id);if(B!==-1&&K!==-1&&B!==K){const H=[...o],[Z]=H.splice(B,1);H.splice(K,0,Z),p(H)}}$(j),c(null),i(null),d(a),h(n),u(r),x(o)}function $(j){const{active:D,over:M}=j,G=D.data.current;if((G==null?void 0:G.type)===Qe&&M){const O=l.findIndex(v=>xe(v.columnId)===D.id),k=l.findIndex(v=>xe(v.columnId)===M.id);if(O!==-1&&k!==-1&&O!==k){const v=[...l],[A]=v.splice(O,1);v.splice(k,0,A),y(v)}}}function q(){c(null),i(null),d(a),h(n),u(r),x(o)}return{handleDragOver:I,handleDragEnd:V,handleDragStart:N,handleDragCancel:q,sensors:b}}function ae(s){return`${s}-${t.v4()}`}function fe(s,a){const n=t.toTitleCase(s.replace(/_/g," "));switch(a){case"SUM":return`Sum of ${n}`;case"COUNT":return`Count of ${n}`;case"DISTINCT":return`Unique ${n}`;case"AVG":return`Average of ${n}`;case"MIN":return`Min of ${n}`;case"MAX":return`Max of ${n}`;default:return n}}function xe(s){return`${Qe}-${s}`}function Et(s,a){const n=t.toTitleCase(s.replace(/_/g," "));switch(a){case"day":return`Date of ${n}`;case"week":return`Week of ${n}`;case"month":return`Month of ${n}`;case"year":return`Year of ${n}`;default:return n}}function fn({schemaName:s,tableName:a,columns:n,status:r}){const o=t.useEditorStore(j=>j.sqlGen),l=t.useEditorStore(j=>j.isDevMode),i=t.useEditorStore(j=>j.selectedConnectionId),c=t.useEditorStore(j=>j.selectedDatabaseName),d=t.useEditorStore(j=>j.selectedSchemaName),h=t.useEditorStore(j=>j.selectedTableName),u=t.useEditorStore(j=>j.selectedDatamodelId),x=t.useDashboardStore(j=>j.dashboard.aiScopeTables),{addToAIScope:f,removeFromAIScope:m}=t.useDashboardActions(),{addColumnToMetricColumns:C,addColumnToTrendByColumns:p,setCardSql:y,setRunSql:g,setSqlGen:S,setIsShowingVisual:b}=t.useEditorActions(),{connectionType:I,modelItems:N,selectedDatamodelName:T}=te();function _(j){var D;if(l){const M=t.createSqlGenConfig(j,o);S(M);const G=(D=N==null?void 0:N.find(k=>k.id===u))==null?void 0:D.name,O=t.getSql(M,t.fmt(s),t.fmt(a),G,I,c||"");O&&(y(O),g(!0))}if(!l){if(t.isTextDataType(j.data_type)){const M={...j,role:"metric",id:ae(j.column_name),name:j.column_name,label:fe(j.column_name,"COUNT"),type:j.data_type,aggregate:"COUNT"};C(M)}if(t.isNumberDataType(j.data_type)){const M={...j,role:"metric",id:ae(j.column_name),name:j.column_name,label:fe(j.column_name,"SUM"),type:j.data_type,aggregate:"SUM"};C(M)}if(t.isDateDataType(j.data_type)){const M={...j,role:"trendby",id:ae(j.column_name),name:j.column_name,type:j.data_type};p(M)}}}function R(j){j===!0&&(h||T)&&i?(f({connectionId:i,connectionType:I==="S3"||I==="API"?"DuckDb":I,databaseName:c||"",schemaName:d||"",tableName:h||"",datamodelName:t.resolveDatamodelName(T),datamodelId:u||""}),t.ue.success("Added to Assistant Scope",{position:"top-right",duration:2500,richColors:!0})):(m({connectionId:i||"",connectionType:I||"",tableName:h||"",datamodelName:t.resolveDatamodelName(T),datamodelId:u||"",databaseName:c||"",schemaName:d||""}),t.ue("Removed from Assistant Scope",{position:"top-right",duration:2e3,richColors:!0}))}function U(){const j=t.getFormattedTableNameForQuery({schemaName:s,tableName:a,modelName:T,connectionType:I,databaseName:c||""});b(!1);const D=I==="MSSQL"?`SELECT top 10 * FROM ${j}`:`SELECT * FROM ${j} LIMIT 10`;y(D),g(!0)}function w(){const j=t.getFormattedTableNameForQuery({schemaName:s,tableName:a,modelName:T,connectionType:I,databaseName:c||""});y(`SELECT COUNT(*) as count FROM ${j}`),g(!0)}function V(){return(x==null?void 0:x.find(j=>j.connectionId===i&&(j.tableName===h||j.datamodelName===T)))!==void 0}function $(j){return l?e.jsxs("div",{className:"flex grow items-center justify-between space-x-2 rounded-md px-2 py-1",onClick:()=>_(j),children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Ue,{column:j}),e.jsx("span",{children:j.column_name})]}),e.jsx("div",{onClick:D=>D.stopPropagation(),className:"flex items-center justify-end",children:t.isNumberDataType(j.data_type)&&e.jsx(mn,{column:j})})]}):e.jsx(pn,{onClick:_,column:j})}function q(){return e.jsxs(e.Fragment,{children:[e.jsxs(t.Toggle,{title:`${V()?"Remove from":"Add to"} Assistant Scope`,pressed:V(),onPressedChange:R,variant:"outline",className:t.cn("h-9 px-2",{}),children:[e.jsx(t.Plus,{className:t.cn("mr-1 size-4",{"text-green-400":V(),"text-muted-foreground":!V()})}),"AI"]}),e.jsxs(t.Button,{disabled:r!=="Success",onClick:U,size:"sm",variant:"secondary",className:"flex",children:[r!=="Success"?e.jsx(oe,{className:"mr-2 h-4 w-4 animate-spin text-foreground/50"}):e.jsx(Vs,{className:"mr-2 size-4"}),"Top 10"]}),e.jsxs(t.Button,{disabled:r!=="Success",onClick:w,size:"sm",variant:"secondary",className:"w-full",children:[r!=="Success"?e.jsx(oe,{className:"mr-2 h-4 w-4 animate-spin text-foreground/50"}):e.jsx(bt,{className:"mr-2 size-4"}),"Count"]})]})}return e.jsxs("div",{className:"flex grow flex-col space-y-4 px-4",children:[e.jsx("div",{className:"mx-2 flex items-center justify-center gap-2",children:q()}),e.jsxs(t.CustomScrollArea,{className:"flex-1 basis-0 overflow-y-auto border-b border-t border-muted px-2 py-3",children:[e.jsx("div",{className:"flex flex-col gap-1",children:n==null?void 0:n.map(j=>e.jsx("div",{className:t.cn("mr-2 cursor-pointer rounded-md text-sm transition-colors hover:bg-muted"),children:$(j)},j.column_name))}),e.jsx(t.ScrollBar,{orientation:"vertical"}),e.jsx(t.ScrollBar,{orientation:"horizontal"})]})]})}function Tt({ColumnsComponent:s,type:a}){var ge;const n=t.useEditorStore(Y=>Y.card),r=t.useEditorStore(Y=>Y.selectedConnectionId),o=t.useDashboardStore(Y=>Y.showFilters),l=t.useEditorStore(Y=>Y.selectedDatamodelId),i=t.useEditorStore(Y=>Y.selectedDatabaseName),c=t.useEditorStore(Y=>Y.selectedSchemaName),d=t.useEditorStore(Y=>Y.selectedTableName),h=t.useEditorStore(Y=>Y.isDevMode),{setSelectedTableName:u,setIsDevMode:x,setCardSql:f}=t.useEditorActions(),{connectionItems:m,modelItems:C,schemaItems:p,databaseItems:y,tableItems:g,columns:S,isConnectionsLoading:b,isModelsLoading:I,isConnectionsError:N,isModelsError:T,isDatabasesLoadingOrFetching:_,isDatabaseError:R,isSchemaLoadingOrFetching:U,isSchemaError:w,isColumnsError:V,isColumnsLoadingOrFetching:$,isTableLoadingOrFetching:q,isTableError:j,connectionType:D,isNonDbConnection:M,refetchDatabases:G,refetchModels:O,refetchSchemas:k,refetchTables:v,refetchColumns:A,refetchConnections:L,handleConnectionChange:J,handleDatabaseChange:P,handleSchemaChange:W,handleDatamodelChange:B,tableName:K,schemaName:H}=te(),{data:Z,refetch:z}=t.useDashboardCardQuery(n);function Q(){return s?s(H,K,S):e.jsx(fn,{schemaName:H,tableName:K,columns:S,status:$?"Loading...":V?"Error":"Success"})}function X(){window.location.href="mailto:support@semaphor.cloud?subject=Help&body=I need help with..."}function ne(Y){Y===!0?Z&&(f(Z.userSql),setTimeout(()=>{z()},500)):f(""),x(Y)}function le(){if(!r||D==="S3"||D==="API")return null;if(!l||l==="none")return e.jsx(ce,{refetch:G,showNone:!0,onChange:P,isError:R,isLoading:_,items:y,value:i||"",title:"Database",type:"combobox"})}function ve(){if(r&&!M&&(!i||i==="none")&&(!l||l==="none"))return e.jsxs("div",{className:"grid grid-cols-3",children:[e.jsx("div",{className:"col-span-1 grid place-items-center",children:e.jsx(t.Separator,{})}),e.jsx("div",{className:"col-span-1 grid place-items-center",children:e.jsx(t.Label,{children:"OR"})}),e.jsx("div",{className:"col-span-1 grid place-items-center",children:e.jsx(t.Separator,{})})]})}function Ne(){if(!r||D==="S3"||D==="API")return null;if(!i||i==="none")return e.jsx(ce,{refetch:O,showNone:!0,onChange:B,isError:T,isLoading:I,items:C,value:l||"",title:"Model",type:"combobox"})}function we(){return!r||D==="S3"||D==="API"||!i||i==="none"?null:e.jsx(ce,{refetch:k,onChange:W,isError:w,isLoading:U,items:p,value:c||"",title:"Schema",type:"combobox"})}function ke(){function Y(){let se=!1;return D==="API"?(se=!1,se):((D==="S3"||r&&i&&i!=="none"&&c)&&(se=!0),se)}return Y()?e.jsx(ce,{refetch:v,onChange:u,isError:j,items:g,isLoading:q,value:d||"",title:"Table",type:"combobox"}):null}return e.jsxs("aside",{className:t.cn("flex h-full min-w-[300px] flex-col justify-between rounded-none",{"border-r-[1px]":!o}),children:[e.jsxs("section",{className:"space-y-3 px-6 py-4",children:[e.jsx(ce,{refetch:L,items:m,title:"Connection",value:r||"",onChange:J,isLoading:b,isError:N,type:"combobox",connectionTooltip:((ge=m==null?void 0:m.find(Y=>Y.id===r))==null?void 0:ge.type)||""}),le(),ve(),Ne(),we(),ke()]}),Q(),e.jsx("div",{className:"flex items-center justify-between gap-2 px-6 py-4",children:a==="main"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(t.Switch,{className:"data-[state=checked]:bg-muted-foreground/80",checked:h,onCheckedChange:ne,id:"dev-mode"}),e.jsx(t.Label,{htmlFor:"dev-mode",children:"Dev Mode"})]}),e.jsxs(t.Button,{onClick:X,size:"sm",variant:"secondary",className:"group flex items-center gap-2 rounded-full",children:[e.jsx(Ps,{className:"size-4"}),e.jsx("span",{className:"hidden group-hover:block",children:"Help"})]})]})})]})}function Mt({sql:s,error:a,onClick:n}){return!s&&!a?null:e.jsxs(t.HoverCard,{openDelay:a?0:500,children:[e.jsx(t.HoverCardTrigger,{asChild:!0,children:e.jsx(t.Button,{variant:"link",className:"h-5 p-0",children:a?e.jsx(dt,{className:"h-4 w-4 text-red-500"}):e.jsx(t.Info,{className:"h-4 w-4 text-muted-foreground"})})}),e.jsx(t.HoverCardContent,{align:"start",className:"w-full min-w-fit max-w-[700px]",children:e.jsx("div",{className:"flex justify-between space-x-4",children:e.jsxs("div",{className:"flex grow flex-col space-y-2",children:[e.jsxs(t.ScrollArea,{className:"max-h-[250px] min-h-0 overflow-scroll text-xs leading-relaxed text-foreground/80",children:[a&&a,s&&e.jsxs("div",{className:"flex flex-col space-y-1.5",children:[e.jsx("span",{className:"text-xs font-semibold",children:"Resolved SQL"}),e.jsx("div",{className:"rounded-md",children:e.jsx(t.CodeHighlighter,{code:s,language:"sql"})})]})]}),a&&n&&e.jsxs(t.Button,{onClick:n,size:"sm",variant:"secondary",children:[e.jsx(Os,{className:"mr-2 h-4 w-4"}),"Debug with Assistant"]})]})})})]})}var At={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},nt=E.createContext&&E.createContext(At),gn=["attr","size","title"];function jn(s,a){if(s==null)return{};var n=yn(s,a),r,o;if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(s);for(o=0;o<l.length;o++)r=l[o],!(a.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(s,r)&&(n[r]=s[r])}return n}function yn(s,a){if(s==null)return{};var n={};for(var r in s)if(Object.prototype.hasOwnProperty.call(s,r)){if(a.indexOf(r)>=0)continue;n[r]=s[r]}return n}function Se(){return Se=Object.assign?Object.assign.bind():function(s){for(var a=1;a<arguments.length;a++){var n=arguments[a];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(s[r]=n[r])}return s},Se.apply(this,arguments)}function at(s,a){var n=Object.keys(s);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(s);a&&(r=r.filter(function(o){return Object.getOwnPropertyDescriptor(s,o).enumerable})),n.push.apply(n,r)}return n}function Ce(s){for(var a=1;a<arguments.length;a++){var n=arguments[a]!=null?arguments[a]:{};a%2?at(Object(n),!0).forEach(function(r){bn(s,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(s,Object.getOwnPropertyDescriptors(n)):at(Object(n)).forEach(function(r){Object.defineProperty(s,r,Object.getOwnPropertyDescriptor(n,r))})}return s}function bn(s,a,n){return a=Sn(a),a in s?Object.defineProperty(s,a,{value:n,enumerable:!0,configurable:!0,writable:!0}):s[a]=n,s}function Sn(s){var a=Cn(s,"string");return typeof a=="symbol"?a:a+""}function Cn(s,a){if(typeof s!="object"||!s)return s;var n=s[Symbol.toPrimitive];if(n!==void 0){var r=n.call(s,a);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(a==="string"?String:Number)(s)}function Lt(s){return s&&s.map((a,n)=>E.createElement(a.tag,Ce({key:n},a.attr),Lt(a.child)))}function he(s){return a=>E.createElement(vn,Se({attr:Ce({},s.attr)},a),Lt(s.child))}function vn(s){var a=n=>{var{attr:r,size:o,title:l}=s,i=jn(s,gn),c=o||n.size||"1em",d;return n.className&&(d=n.className),s.className&&(d=(d?d+" ":"")+s.className),E.createElement("svg",Se({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},n.attr,r,i,{className:d,style:Ce(Ce({color:s.color||n.color},n.style),s.style),height:c,width:c,xmlns:"http://www.w3.org/2000/svg"}),l&&E.createElement("title",null,l),s.children)};return nt!==void 0?E.createElement(nt.Consumer,null,n=>a(n)):a(At)}function Nn(s){return he({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 Ot(s){const{theme:a}=t.useTheme(),n=t.useDashboardStore(p=>p.theme),r=t.useEditorStore(p=>p.frame),o=t.useEditorStore(p=>p.card),l=t.useEditorStore(p=>p.activeTabCardId),i=t.Le(),{refetch:c}=t.useDashboardCardQuery(o),{updateCardTab:d,setRunSql:h}=t.useEditorActions(),u=E.useRef(),x=E.useRef({}),f=r.cards.find(p=>p.id===l),m=E.useCallback(()=>{let p="";return s==="python"&&(p=(f==null?void 0:f.python)||t.PYTHON_DEFAULT_CODE),s==="sql"&&(p=(f==null?void 0:f.sql)||""),p},[s,f]);E.useEffect(()=>{if(l&&o.id&&o.id!==l){if(u.current&&i){const p=u.current.getModel();p&&(x.current[o.id]=p);let y=x.current[l];if(!y){const g=m();y=i.editor.createModel(g,s),x.current[l]=y}u.current.setModel(y)}d(l,o),h(!0)}},[l,o,d,i,h,s,m]),E.useEffect(()=>{if(!i)return;const p=window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light",y=n==="system"?p:n;i.editor.defineTheme("default",{base:y==="light"?"vs":"vs-dark",inherit:!0,rules:[],colors:{"editor.background":y==="light"?"#ffffff":t.hslStringToHex("240 10% 10%")}}),i.editor.setTheme("default")},[a,n,i]),E.useEffect(()=>{const p=u.current;p&&i&&o&&p.addCommand(i.KeyMod.Shift|i.KeyCode.Enter,function(){return c(),!1})},[i,c,o]);function C(p,y){if(u.current=p,!x.current[o.id]){const g=p.getModel(),S=m();x.current[o.id]=g||(y==null?void 0:y.editor.createModel(S,s))||p.getModel()}p.setModel(x.current[o.id])}return{handleEditorDidMount:C}}function wn(){const s=t.useEditorStore(i=>i.card.sql),a=t.useEditorStore(i=>i.sqlGen),{setCardSql:n,setSqlGen:r}=t.useEditorActions(),{handleEditorDidMount:o}=Ot("sql");function l(i){n(i),t.isObjectEmpty(a)||r({})}return e.jsx(t.Ft,{theme:"default",className:"pt-3",onChange:l,value:s||"",options:{minimap:{enabled:!1},wordWrap:"on",scrollbar:{verticalScrollbarSize:0,horizontalScrollbarSize:0},fontSize:13,renderLineHighlight:"none"},defaultLanguage:"sql",onMount:o})}function kn(){const s=t.useEditorStore(o=>o.card.python),{setCardPython:a}=t.useEditorActions(),{handleEditorDidMount:n}=Ot("python");function r(o){a(o)}return e.jsx(t.Ft,{className:"pt-3",theme:"default",onChange:r,value:s||t.PYTHON_DEFAULT_CODE,options:{minimap:{enabled:!1},wordWrap:"on",scrollbar:{verticalScrollbarSize:0,horizontalScrollbarSize:0},fontSize:13,renderLineHighlight:"none"},defaultLanguage:"python",onMount:n})}function In({jsonString:s}){return e.jsx(t.Ft,{theme:"default",defaultLanguage:"json",className:"mt-1 min-h-[220px]",value:s,options:{readOnly:!0,minimap:{enabled:!1},lineNumbers:"off",glyphMargin:!1,wordWrap:"on",scrollbar:{verticalScrollbarSize:0,horizontalScrollbarSize:0},fontSize:12,renderLineHighlight:"none"}})}function zt(s){var K,H,Z;const[a,n]=E.useState(""),[r,o]=E.useState(null),{authToken:l}=t.useSemaphorContext(),i=t.useEditorStore(z=>{var Q;return(Q=z==null?void 0:z.card)==null?void 0:Q.sql}),c=t.useEditorStore(z=>{var Q;return(Q=z==null?void 0:z.card)==null?void 0:Q.python}),d=t.useEditorStore(z=>z.actions.setCardSql),h=t.useEditorStore(z=>z.actions.setRunSql),u=t.useEditorStore(z=>z.actions.switchCardType),x=t.useEditorStore(z=>z.currentAssitantScope)||[],f=t.useEditorStore(z=>z.userInputForAI),m=t.useEditorStore(z=>z.triggerAIRun),C=t.useEditorStore(z=>z.selectedDatabaseName),p=t.useEditorStore(z=>z.selectedTableName),y=t.useEditorStore(z=>z.selectedConnectionId),g=t.useEditorStore(z=>z.selectedSchemaName),S=t.useDashboardStore(z=>z.dashboard.aiScopeTables),{setTriggerAIRun:b,setCurrentAssitantScope:I}=t.useEditorActions(),{selectedDatamodelName:N,connectionType:T,selectedDatamodelId:_}=te(),{messages:R,setMessages:U,reload:w,error:V,append:$,input:q,setInput:j,status:D,handleInputChange:M,handleSubmit:G,stop:O}=t.useChat({api:"https://semaphor.cloud/api/v1/assistant",headers:{Authorization:`Bearer ${l==null?void 0:l.accessToken}`},body:{random:Math.random()},maxSteps:10,onToolCall:k,onFinish(z,Q){v(Q.usage),n(""),Q.finishReason==="stop"&&n("")}});E.useEffect(()=>{m&&f&&(M({target:{value:f}}),setTimeout(()=>{G(),b(!1)},100))},[m,G,f,b,M]);async function k({toolCall:z}){if(z.toolName==="createChartFromSql"){const Q=z.args.sql,X=z.args.chartType;return u(X),d(Q),h(!0),{status:"success",message:"Let the user know that chart is created"}}else if(z.toolName==="getTableColumns")n("Getting table columns...");else{if(z.toolName==="getUserSql")return i?{status:"success",sql:i,python:c||""}:{status:"error",message:"No SQL found"};if(z.toolName==="getCurrentTableScope")return n("Getting table scope..."),P(),{status:"success",tables:x};n("Analyzing...")}}function v(z){o(Q=>Q?{promptTokens:Q.promptTokens+z.promptTokens,completionTokens:Q.completionTokens+z.completionTokens,totalTokens:Q.totalTokens+z.totalTokens}:z)}function A(z){const Q=t.removeFromScopeArray(x,z);L(Q)}function L(z){const Q=t.sanitizeAIScope(z);I(Q),U(X=>[...X,{id:crypto.randomUUID(),role:"system",content:`Current scope of tables | ${JSON.stringify(Q)}`}])}function J(){const z={databaseName:C||"",schemaName:g||"",tableName:p||"",datamodelId:_||"",datamodelName:t.resolveDatamodelName(N),connectionId:y||"",connectionType:T||""},Q=t.dedup([...x,z]);L(Q)}function P(){const z={databaseName:C||"",schemaName:g||"",tableName:p||"",datamodelName:t.resolveDatamodelName(N),connectionId:y||"",connectionType:T||"",datamodelId:_||""};if(!t.isInAiScopeArray([...S||[],...x],z)||x.length===0){const X=t.dedup([...S||[],...x,z]).filter(ne=>ne.connectionId===z.connectionId);L(X)}}const W=!["ready","error"].includes(D),B=(Z=(H=(K=JSON.parse((V==null?void 0:V.message)||"{}"))==null?void 0:K.error)==null?void 0:H.lastError)==null?void 0:Z.message;return{messages:R,setMessages:U,reload:w,append:$,input:q,setInput:j,isLoading:W,handleSetAIScope:P,handleAddCurrentTableToScope:J,removeFromCurrentSelections:A,currentAssitantScope:x,setCurrentAssitantScope:I,handleInputChange:M,handleSubmit:G,stop:O,chatStatus:D,toolStatus:a,llmUsage:r,onFinish:s,errorMessage:B}}function Dn(s){const a=s.toUpperCase().indexOf("WHERE"),n=s.toUpperCase().indexOf("GROUP BY"),r=s.toUpperCase().indexOf("LIMIT"),o=s.toUpperCase().indexOf("ORDER BY");let l=s.length;if(o!==-1&&(l=o),r!==-1&&r<l&&(l=r),a!==-1){const i=s.substring(0,a),c=s.substring(a);return`${i} {{ filters | where }} AND ${c.substring(6)}`}else if(n!==-1){const i=s.substring(0,n),c=s.substring(n);return`${i} {{ filters | where }} ${c}`}else{const i=s.substring(0,l),c=s.substring(l);return console.log("beforeClause",i),console.log("afterClause",c),c?`${i} {{ filters | where }} ${c}`:`${i.replace(/;$/,"")} {{ filters | where }}`}}function Ft({variant:s="secondary"}){const{setCardSql:a}=t.useEditorActions(),n=t.useEditorStore(m=>m.frame),r=t.useEditorStore(m=>m.card),o=t.useEditorStore(m=>m.selectedSchemaName),l=t.useEditorStore(m=>m.selectedDatamodelId),i=t.useEditorStore(m=>m.selectedDatabaseName),c=t.useEditorStore(m=>m.selectedTableName),d=t.useEditorStore(m=>m.selectedConnectionId),h=t.useEditorStore(m=>m.isShowingVisual),u=r.sql,x=t.useEditorStore(m=>m.onSave);function f(){let m=u;u&&!u.includes("{{")&&(m=Dn(u),a(m));const C={...r,lastSelectedSchema:o,lastSelectedDatamodelId:l,lastSelectedDatabase:i,lastSelectedTable:c,connectionId:d,type:h?r.type:"table",sql:m,customCfg:h?r.customCfg:null},p=n.cards.map(g=>g.id===r.id?C:g),y={...n,cards:p,activeCardId:En(p,n.activeCardId)};x==null||x(y)}return e.jsxs(t.Button,{onClick:f,size:"sm",variant:s,children:[e.jsx(t.Check,{className:"mr-2 size-4 font-bold"}),"Accept"]})}function Rt(){const{setTempQueryData:s,setSqlGen:a}=t.useEditorActions(),n=t.useQueryClient(),r=t.useEditorStore(d=>d.tempQueryData),o=t.useEditorStore(d=>d.onClose),l=t.useEditorStore(d=>d.card),{queryKey:i}=t.useDashboardCardQuery(l);function c(){if(r){const{queryKey:d,queryData:h}=r;d&&h&&n.setQueryData(d,h)}a({}),o==null||o()}return e.jsxs(t.Button,{onClick:c,size:"sm",variant:"secondary",children:[e.jsx(t.X,{className:"mr-2 size-4"}),"Close"]})}function Bt(){const{setTempQueryData:s}=t.useEditorActions(),a=t.useQueryClient(),n=t.useEditorStore(m=>m.tempQueryData),r=t.useEditorStore(m=>m.card),{queryKey:o}=t.useDashboardCardQuery(r),{setCardSql:l,setSqlGen:i,setCardPython:c,setCardCustomCfg:d,setCardPreferences:h,setCardType:u,clearQueryConfig:x}=t.useEditorActions();function f(){const m=a.getQueryData(o);n!=null&&n.queryData||s({queryKey:o,queryData:m}),a.setQueryData(o,null),a.removeQueries({queryKey:o,exact:!0}),l(""),i({}),x(),c(""),d(""),h({})}return e.jsxs(t.Button,{onClick:f,className:"",size:"sm",variant:"secondary",children:[e.jsx(Ds,{className:"mr-2 size-4"}),"Clear"]})}function En(s,a){if(s.length===0)return"";if(a){const n=s.find(r=>r.id===a);if(n){const r=n.tabTitle;if(r=="All__Header")return s[0].id;if(r&&r.endsWith("__Header")){const l=r.split("__")[0],i=s.find(c=>c.tabTitle===l);return i?i.id:s[0].id}return a}}return s[0].id}function Tn(){const s=t.useQueryClient(),[a,n]=E.useState(!1),[r,o]=E.useState(!1);t.useEditorStore(v=>v.frame);const l=t.useEditorStore(v=>v.card);t.useEditorStore(v=>v.isShowingVisual),t.useEditorStore(v=>v.selectedConnectionId),t.useEditorStore(v=>v.tempQueryData),t.useEditorStore(v=>v.selectedDatabaseName),t.useEditorStore(v=>v.selectedDatamodelId),t.useEditorStore(v=>v.selectedSchemaName);const i=t.useEditorStore(v=>v.showAIDialog);t.useEditorStore(v=>v.selectedTableName);const c=t.useEditorStore(v=>{var A;return(A=v==null?void 0:v.card)==null?void 0:A.sql}),{sheetFilterValues:d}=t.useSheetFilterValues(),{setCardCustomCfg:h,setQueryResultColumns:u,setCardSql:x,setTempQueryData:f,setPythonStdOut:m,setCardPreferences:C,setCardType:p,setCardPython:y,runAssistant:g,setShowAIDialog:S}=t.useEditorActions();t.useEditorStore(v=>v.onSave),t.useEditorStore(v=>v.onClose),t.useEditorStore(v=>v.actions.setSqlGen);const b=t.useEditorStore(v=>v.runSql),I=t.useEditorStore(v=>v.actions.setRunSql),N=t.useEditorStore(v=>v.actions.setIsSqlRunning),{data:T,isLoading:_,isFetching:R,isSuccess:U,isError:w,error:V,queryKey:$,refetch:q,errorMessage:j}=t.useDashboardCardQuery(l),{handleSetAIScope:D}=zt();E.useEffect(()=>{if(T&&(T.rowLimitExceeded&&t.ue.error("Row limit (10,000) exceeded. Refine your query.",{position:"top-center",richColors:!0}),m((T==null?void 0:T.output)||""),T.records.length>0)){const{dimensionKeys:v}=t.getKeys(T.records);u(v)}},[T,u,m]),E.useEffect(()=>{(_||R)&&N(!0),(w||U)&&N(!1),w&&(u([]),m(""))},[_,R,T,m,w,U,N,u,V]),E.useEffect(()=>{b&&(s.getQueryData($)||q(),I(!1))},[b,q,I,$,s]);async function M(){const v=`Can you help me debug this query in the current table scope?
372
372
 
373
373
  Error:
374
374
 
@@ -376,7 +376,7 @@
376
376
 
377
377
  Query:
378
378
 
379
- ${l}
379
+ ${c}
380
380
 
381
- `;g(v)}function G(){return e.jsxs(e.Fragment,{children:[r&&e.jsx("div",{className:"relative flex w-1/3 min-w-0 grow overflow-hidden text-xs",role:"editor-filter-container",children:e.jsx("div",{className:"mt-2 w-[99%]",children:e.jsx(wn,{jsonString:JSON.stringify(d,null,2)})})}),d&&d.length>0&&e.jsx(t.Button,{variant:"ghost",onClick:()=>o(!r),className:"absolute bottom-0 right-6 size-7 p-1",children:r?e.jsx(t.X,{className:"size-3.5 text-muted-foreground"}):e.jsx(xt,{className:"size-3.5 text-muted-foreground"})})]})}function O(){return e.jsxs(t.ResizablePanelGroup,{className:"flex grow pb-1",direction:"vertical",role:"editor-resizable-group",children:[e.jsxs(t.ResizablePanel,{id:"1",order:1,defaultSize:a?20:100,className:"relative flex grow",children:[e.jsx("div",{id:"sql-container",className:"relative flex w-[99%]",children:e.jsx(vn,{})}),a&&e.jsx("code",{className:"absolute right-6 top-3 text-xs text-muted-foreground/70",children:"sql"})]}),a&&e.jsxs(e.Fragment,{children:[e.jsx(t.ResizableHandle,{withHandle:!0,className:"border"}),e.jsxs(t.ResizablePanel,{id:"2",order:2,defaultSize:80,className:"relative flex grow",children:[e.jsx("div",{id:"python-container",className:"relative flex w-[99%] pt-0",children:e.jsx(Nn,{})}),e.jsx("code",{className:"absolute right-6 top-3 text-xs text-muted-foreground/70",children:"python"})]})]})]})}function k(){return e.jsxs("div",{role:"editor-controls",className:"item-center flex flex-wrap justify-between gap-2 px-6 py-4",children:[e.jsxs("div",{className:"flex grow items-center gap-2",children:[e.jsxs(t.Button,{title:"Shift + Enter",disabled:_||R,onClick:()=>{q()},className:"shrink-0",size:"sm",children:[_||R?e.jsx(re,{className:"mr-2 h-4 w-4 animate-spin"}):e.jsx(t.Play,{className:"mr-2 h-4 w-4"}),"Run"]}),e.jsx(At,{sql:T==null?void 0:T.sql,error:j,onClick:M}),e.jsx(_t,{}),e.jsx(t.Toggle,{pressed:a,onPressedChange:v=>n(v),className:"",size:"sm",children:e.jsx(Cn,{className:"size-4 text-foreground/70"})}),e.jsx("button",{disabled:i,onClick:()=>{D(),S(!0)},className:"h-9 w-full cursor-text px-3 text-left text-sm text-muted-foreground",children:i?"":"Type your question..."})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Bt,{}),e.jsx(Rt,{})]})]})}return e.jsxs("section",{role:"editor-section",className:"flex grow flex-col justify-end",children:[e.jsxs("div",{className:"relative flex grow justify-between overflow-y-scroll",children:[O(),G()]}),k()]})}function En({data:s}){var i;const[a,n]=E.useState([]),o=Object.keys(s[0]).map(l=>({accessorKey:l,header:({column:d})=>{const h=d.getIsSorted();return e.jsx("div",{className:"flex gap-2",children:e.jsxs("div",{className:"flex cursor-pointer items-center",onClick:()=>d.toggleSorting(d.getIsSorted()==="asc"),children:[l,h==="asc"?e.jsx(t.TriangleUpIcon,{className:"ml-2 h-5 w-5"}):h==="desc"?e.jsx(t.TriangleDownIcon,{className:"ml-2 h-5 w-5"}):null]})})}})),c=t.useReactTable({data:s,columns:o,getCoreRowModel:t.getCoreRowModel(),getPaginationRowModel:t.getPaginationRowModel(),onSortingChange:n,getSortedRowModel:t.getSortedRowModel(),manualPagination:!0,state:{sorting:a}});return e.jsx(t.CustomScrollArea,{className:"grow overflow-auto font-mono text-xs text-foreground/95",children:e.jsxs("table",{className:"w-full",children:[e.jsx(t.TableHeader,{className:"sticky top-0 z-50 h-0 bg-muted",children:c.getHeaderGroups().map(l=>e.jsx(t.TableRow,{className:"",children:l.headers.map(d=>e.jsx(t.TableHead,{className:"h-11 font-semibold text-foreground",children:d.isPlaceholder?null:t.flexRender(d.column.columnDef.header,d.getContext())},d.id))},l.id))}),e.jsx(t.TableBody,{children:(i=c.getRowModel().rows)!=null&&i.length?c.getRowModel().rows.map(l=>e.jsx(t.TableRow,{className:"h-11 whitespace-nowrap py-2","data-state":l.getIsSelected()&&"selected",children:l.getVisibleCells().map(d=>e.jsx(t.TableCell,{className:"py-2",children:t.flexRender(d.column.columnDef.cell,d.getContext())},d.id))},l.id)):e.jsx(t.TableRow,{children:e.jsx(t.TableCell,{colSpan:o.length,className:"h-24 text-center",children:"No results."})})})]})})}function Tn({card:s}){var S,b,I,N,T,_,R,U,w,V,$;const[a,n]=E.useState(!1),[r,o]=E.useState([]),{authToken:c}=t.useSemaphorContext(),i=t.getTokenParams(c==null?void 0:c.accessToken),l=t.useDashboardStore(q=>q.themeStyle),d={colors:((b=(S=l==null?void 0:l.chart)==null?void 0:S.dataset)==null?void 0:b.backgroundColor)||[]};(I=s.customCardPreferences)!=null&&I.inputData;const{getCard:h}=t.useCustomVisual(((N=s.customCardPreferences)==null?void 0:N.url)||""),m=((T=s.customCardPreferences)==null?void 0:T.visualType)||"single",x=t.useEditorStore(q=>q.frame),{setCustomCardPreferences:f}=t.useEditorActions(),{data:u}=t.useDashboardCardQuery(s),C=E.useCallback((q,j)=>{o(D=>({...D,[q]:j}))},[]);if(!((_=s.customCardPreferences)!=null&&_.componentName))return null;const p=h((R=s.customCardPreferences)==null?void 0:R.componentName);function y(q){n(q)}const g=Object.keys(((U=s.customCardPreferences)==null?void 0:U.dataInputCardIds)||{}).map(q=>{var M,G,O;const j=(G=(M=s.customCardPreferences)==null?void 0:M.dataInputCardIds)==null?void 0:G[q].cardId,D=(O=x==null?void 0:x.cards)==null?void 0:O.find(k=>k.id===j);return D||null});return e.jsx("div",{className:"semaphor-custom mb-3 flex grow basis-0 flex-col space-y-2 overflow-y-auto",children:e.jsxs(E.Suspense,{fallback:e.jsx(e.Fragment,{}),children:[p&&m==="single"&&e.jsx(p,{params:i,theme:d,settings:(w=s.customCardPreferences)==null?void 0:w.settings,onDataChange:C,data:(u==null?void 0:u.records)||[]}),p&&m==="multiple"&&e.jsxs(e.Fragment,{children:[Object.keys(((V=s.customCardPreferences)==null?void 0:V.dataInputCardIds)||{}).map(q=>{var M,G,O;const j=(G=(M=s.customCardPreferences)==null?void 0:M.dataInputCardIds)==null?void 0:G[q].cardId,D=(O=x==null?void 0:x.cards)==null?void 0:O.find(k=>k.id===j);if(D)return e.jsx(t.MultiInputEmptyRenderer,{onLoadingStatus:y,onDataChange:C,dataInputIndex:q,card:D},D.id+q)}),e.jsx("div",{className:"flex flex-col gap-2",children:e.jsx(p,{theme:d,onDataChange:C,settings:g.map(q=>{var j;return(j=q==null?void 0:q.customCardPreferences)==null?void 0:j.settings}),data:g.map(q=>q!=null&&q.id?r==null?void 0:r[q.id]:[])})})]})]},($=s.customCardPreferences)==null?void 0:$.componentName)})}function Vt({className:s,...a}){var y;const n=t.useEditorStore(g=>g.card),r=((y=n.customCardPreferences)==null?void 0:y.showCardHeader)??!0,o=t.useEditorStore(g=>g.frame),c=t.useDashboardStore(g=>g.dashboard.filters);t.useEditorStore(g=>g.actions.setRunSql);const{updateFilter:i}=t.useDashboardActions(),l=c==null?void 0:c.find(g=>g.id===o.filterId),{data:d,isLoading:h,isFetching:m}=t.useDashboardCardQuery(n),{setCard:x}=t.useEditorActions(),{data:f}=t.useTopoJson(n),u=E.useMemo(()=>!n.id||!(d!=null&&d.records)?null:t.createChartConfig({data:d==null?void 0:d.records,cardType:n.type,customCfg:n.customCfg,preferences:n.preferences,topoJson:f}),[n.id,d==null?void 0:d.records,n.type,n.customCfg,n.preferences,f]);function C(g){return e.jsx(Tn,{card:g})}function p(){if(d!=null&&d.records&&(d==null?void 0:d.records.length)===0&&!h&&!m)return e.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-2",children:[e.jsx(t.TreePalm,{className:"size-8 text-muted-foreground"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"No records to display"})]});if(!n.id)return null;if(n.type==="custom")return C(n);if(!["table","custom"].includes(n.type)&&u)return e.jsx(e.Fragment,{children:h||m?e.jsx(e.Fragment,{}):e.jsx(t.ChartJsVisual,{cfg:u})});if(n.type==="table"&&(d!=null&&d.records)&&(d==null?void 0:d.records.length)>0)return e.jsxs(t.ScrollArea,{className:"relative mb-2 flex h-full min-h-0 w-full flex-1 grow basis-0",children:[e.jsx(t.TableVisual,{card:n,data:d==null?void 0:d.records}),e.jsx(t.ScrollBar,{orientation:"horizontal"})]})}return e.jsxs(t.Card,{role:"editor-visual-card",className:t.cn("relative flex h-full flex-col rounded-none",s),...a,children:[r&&e.jsxs(t.CardHeader,{className:"flex flex-row items-start justify-between py-4",children:[e.jsxs("div",{children:[e.jsx(t.Editable,{text:n.title,onSave:g=>x({...n,title:g}),children:e.jsx("div",{className:"flex items-center gap-5",children:e.jsx(t.CardTitle,{className:"text-base",children:n.title||"Edit title..."})})},n.title),e.jsx(t.Editable,{text:n.description||"",onSave:g=>x({...n,description:g}),children:e.jsx(t.CardDescription,{children:n.description||"Edit description..."})},n.description)]}),l&&e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(t.Editable,{className:"my-1",text:l.title||l.column,onSave:g=>i({...l,title:g}),children:e.jsx(t.Label,{children:l.title})}),e.jsx(t.FilterComponent,{filter:l})]})]}),e.jsx(t.CardContent,{className:"flex grow flex-col",children:p()})]})}const Ae=({language:s,value:a,onChange:n,readonly:r})=>e.jsx(t.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",readOnly:r},defaultLanguage:s,value:a,onChange:n}),Mn=()=>e.jsxs(t.DialogHeader,{children:[e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(t.DialogTitle,{children:"Customize Card"})}),e.jsxs(t.DialogDescription,{children:["See the configuration options and documentation",e.jsx("a",{target:"_blank",className:"ml-1 text-blue-500 underline",href:"https://www.chartjs.org/docs/latest/samples/bar/vertical.html",children:"here."})]})]}),An=({customCode:s,cardCustomCfgString:a,mergedConfig:n,onConfigChange:r,onCodeChange:o})=>e.jsxs(t.Tabs,{defaultValue:"final-config",className:"flex w-1/2 flex-col",children:[e.jsxs(t.TabsList,{className:"justify-start rounded-sm rounded-b-none border border-b-0",children:[e.jsx(t.TabsTrigger,{value:"final-config",children:"Config"}),e.jsx(t.TabsTrigger,{value:"custom-config",children:"Changes"}),e.jsx(t.TabsTrigger,{value:"custom-code",children:"Custom Code"})]}),e.jsx(t.TabsContent,{value:"final-config",className:"mt-0 grow rounded-b border border-t-0",children:e.jsx(Ae,{language:"json",value:n,onChange:r})}),e.jsx(t.TabsContent,{value:"custom-config",className:"mt-0 grow rounded-b border border-t-0",children:e.jsx(Ae,{readonly:!0,language:"json",value:a,onChange:()=>{}})}),e.jsx(t.TabsContent,{value:"custom-code",className:"mt-0 grow rounded-b border border-t-0",children:e.jsx(Ae,{language:"javascript",value:s,onChange:o})})]}),Ln=({error:s,hasCardCustomConfig:a,onReset:n,onApply:r,onClose:o})=>e.jsxs(t.DialogFooter,{className:"flex items-center",children:[e.jsx(t.Label,{className:"mr-2 text-red-500",children:s}),e.jsx(t.Button,{disabled:!a,onClick:n,variant:"outline",children:"Reset"}),e.jsx(t.Button,{onClick:r,variant:"outline",children:"Apply"}),e.jsx(t.Button,{onClick:o,variant:"outline",children:"Close"})]});function On(){const[s,a]=E.useState(!1),[n,r]=E.useState(""),[o,c]=E.useState(""),[i,l]=E.useState(""),[d,h]=E.useState(""),m=t.useEditorStore(N=>N.card),x=t.useEditorStore(N=>N.card.customCfg),f=x?JSON.stringify(x,null,2):"",{data:u}=t.useDashboardCardQuery(m),{data:C}=t.useTopoJson(m),{setCardCustomCfg:p,setCustomVisualCode:y}=t.useEditorActions(),g=N=>{var T,_;return JSON.stringify({...N,data:{...N.data,datasets:(_=(T=N.data)==null?void 0:T.datasets)==null?void 0:_.map(R=>({...R,data:[]}))}},null,2)},S=()=>{var T,_;if(!((T=u==null?void 0:u.records)!=null&&T.length))return;const N=t.createChartConfig({data:u.records,cardType:m.type,preferences:m.preferences,topoJson:C});if(N){r(g(N)),l(((_=m.preferences)==null?void 0:_.customVisualCode)||"");const R=t.merge(N,x);c(g(R))}},b=()=>{try{if(i&&y(i),o){const N=JSON.parse(o),T=t.getObjectDiff(JSON.parse(n),N);p(T),h("")}}catch{h("Invalid JSON configuration")}},I=Object.keys(x||{}).length===0;return e.jsxs(t.Dialog,{open:s,onOpenChange:a,children:[e.jsx(t.DialogTrigger,{asChild:!0,children:e.jsx(t.IconButton,{tooltip:"Customize Visual",onClick:S,className:I?"":"text-green-600 hover:text-green-700",children:e.jsx(t.Settings,{className:"h-4 w-4"})})}),e.jsxs(t.DialogContent,{className:"flex h-[600px] grow flex-col overflow-auto sm:min-w-[900px] lg:min-w-[1200px]",children:[e.jsx(Mn,{}),e.jsxs("div",{className:"flex grow gap-2",children:[e.jsx(t.ErrorBoundary,{FallbackComponent:t.FallbackEditorCard,children:e.jsx(Vt,{className:"w-1/2 rounded shadow-none"})}),e.jsx(An,{customCode:i,cardCustomCfgString:f,mergedConfig:o,onConfigChange:N=>c(N??""),onCodeChange:N=>l(N??"")})]}),e.jsx(Ln,{error:d,hasCardCustomConfig:!!x,onReset:()=>{c(n),p(null)},onApply:b,onClose:()=>a(!1)})]})]})}function qt(s){const[a,n]=E.useState(null);return a}function Pt(){const{authToken:s}=t.useSemaphorContext(),{data:a,isLoading:n,isFetching:r,isError:o}=t.useQuery({queryKey:["plugins",s==null?void 0:s.accessToken],queryFn:()=>t.getPlugins(s==null?void 0:s.accessToken)});return{data:a,isLoading:n,isFetching:r,isError:o}}function zn({onChartTypeChange:s}){const[a,n]=E.useState([]),{setCardCustomCfg:r,setCardPreferences:o,setCardType:c,setCustomCardPreferences:i}=t.useEditorActions(),{data:l}=Pt();function d(h,m){r(null),o({}),c(h),m&&i({type:"component",visualType:"single",url:m.url,componentName:m.name,icon:m.icon}),s==null||s()}return E.useEffect(()=>{(async()=>{var m;if(l){const f=(await Promise.all((m=l==null?void 0:l.plugins)==null?void 0:m.map(async u=>(await t.loadManifest(u.value)).visuals.map(y=>({name:y.name,icon:y.icon,url:u.value}))))).flat();n(f)}})()},[l]),a.length===0?null:e.jsxs(e.Fragment,{children:[e.jsx(t.Separator,{className:"my-2"}),e.jsx("div",{className:"grid grid-cols-4 place-items-center",children:a.map((h,m)=>e.jsx(Fn,{text:h.name,onClick:()=>d("custom",h),icon:h.icon},h.url+h.name+m))})]})}const Fn=({text:s,icon:a,onClick:n})=>{const r=qt(),o=s.charAt(0).toUpperCase();return e.jsx(t.IconButton,{onClick:n,tooltip:s,children:r?e.jsx(r,{className:"h-4 w-4"}):o})};function Ht(s){return he({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 Rn(s){return he({attr:{viewBox:"0 0 256 256",fill:"currentColor"},child:[{tag:"path",attr:{d:"M48,180c0,11,7.18,20,16,20a14.24,14.24,0,0,0,10.22-4.66A8,8,0,0,1,85.78,206.4,30.06,30.06,0,0,1,64,216c-17.65,0-32-16.15-32-36s14.35-36,32-36a30.06,30.06,0,0,1,21.78,9.6,8,8,0,0,1-11.56,11.06A14.24,14.24,0,0,0,64,160C55.18,160,48,169,48,180Zm79.6-8.69c-4-1.16-8.14-2.35-10.45-3.84-1.25-.81-1.23-1-1.12-1.9a4.57,4.57,0,0,1,2-3.67c4.6-3.12,15.34-1.73,19.82-.56A8,8,0,0,0,142,145.86c-2.12-.55-21-5.22-32.84,2.76a20.58,20.58,0,0,0-9,14.95c-2,15.88,13.65,20.41,23,23.11,12.06,3.49,13.12,4.92,12.78,7.59-.31,2.41-1.26,3.34-2.14,3.93-4.6,3.06-15.17,1.56-19.55.36A8,8,0,0,0,109.94,214a61.34,61.34,0,0,0,15.19,2c5.82,0,12.3-1,17.49-4.46a20.82,20.82,0,0,0,9.19-15.23C154,179,137.49,174.17,127.6,171.31Zm83.09-26.84a8,8,0,0,0-10.23,4.84L188,184.21l-12.47-34.9a8,8,0,0,0-15.07,5.38l20,56a8,8,0,0,0,15.07,0l20-56A8,8,0,0,0,210.69,144.47ZM216,88v24a8,8,0,0,1-16,0V96H152a8,8,0,0,1-8-8V40H56v72a8,8,0,0,1-16,0V40A16,16,0,0,1,56,24h96a8,8,0,0,1,5.66,2.34l56,56A8,8,0,0,1,216,88Zm-27.31-8L160,51.31V80Z"},child:[]}]})(s)}function Gt(s){return he({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 Ut(s){return he({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 $t(s){return he({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 Qt({onChartTypeChange:s,iconClassName:a}){const{setCardType:n,setCardPreferences:r,setChartOrientation:o}=t.useEditorStore(h=>h.actions),{setCardCustomCfg:c,setCustomCardPreferences:i}=t.useEditorActions();function l(h,m){c(null),r({}),n(h),s==null||s()}const d=1e3;return e.jsxs("div",{className:"grid grid-cols-4 place-items-center",children:[e.jsx(t.IconButton,{openDelay:d,tooltip:"Table",onClick:()=>l("table"),className:"h-10 p-4",children:e.jsx(He,{className:t.cn("size-5",a)})}),e.jsx(t.IconButton,{openDelay:d,tooltip:"Bar Chart",onClick:()=>l("bar"),className:"h-10 p-4",children:e.jsx(qe,{className:t.cn("size-5",a)})}),e.jsx(t.IconButton,{openDelay:d,tooltip:"Line Chart",onClick:()=>l("line"),className:"h-10 p-4",children:e.jsx(Pe,{className:t.cn("size-5",a)})}),e.jsx(t.IconButton,{openDelay:d,tooltip:"Stacked Bar Chart",onClick:()=>l("stackedBar"),className:"h-10 p-4",children:e.jsx(it,{className:t.cn("size-5",a)})}),e.jsx(t.IconButton,{openDelay:d,tooltip:"Stacked Line Chart",onClick:()=>l("stackedLine"),className:"h-10 p-4",children:e.jsx(Ut,{className:t.cn("size-5",a),strokeWidth:0})}),e.jsx(t.IconButton,{openDelay:d,tooltip:"Scatter Chart",onClick:()=>l("scatter"),className:"h-10 p-4",children:e.jsx(dt,{className:t.cn("size-5",a)})}),e.jsx(t.IconButton,{openDelay:d,tooltip:"Bubble Chart",onClick:()=>l("bubble"),className:"h-10 p-4",children:e.jsx(Gt,{className:t.cn("size-5",a)})}),e.jsx(t.IconButton,{openDelay:d,tooltip:"Pie Chart",onClick:()=>l("pie"),className:"h-10 p-4",children:e.jsx(ct,{className:t.cn("size-5",a)})}),e.jsx(t.IconButton,{openDelay:d,tooltip:"Doughnut Chart",onClick:()=>l("doughnut"),className:"h-10 p-4",children:e.jsx(mt,{className:t.cn("size-5",a)})}),e.jsx(t.IconButton,{openDelay:d,tooltip:"Radar Chart",onClick:()=>l("radar"),className:"h-10 p-4",children:e.jsx(jt,{className:t.cn("size-5",a)})}),e.jsx(t.IconButton,{openDelay:d,tooltip:"Polar Area Chart",onClick:()=>l("polarArea"),className:"h-10 p-4",children:e.jsx(Ht,{className:t.cn("size-5",a)})}),e.jsx(t.IconButton,{openDelay:d,tooltip:"Pyramid Chart",onClick:()=>l("pyramid"),className:"h-10 p-4",children:e.jsx(Ct,{className:t.cn("size-5",a)})}),e.jsx(t.IconButton,{tooltip:"Range Chart",onClick:()=>l("range"),className:"h-10 p-4",children:e.jsx(lt,{className:t.cn("size-5",a)})}),e.jsx(t.IconButton,{openDelay:d,tooltip:"KPI",onClick:()=>l("kpi"),className:"h-10 p-4",children:e.jsx($t,{className:t.cn("size-5",a)})}),e.jsx(t.IconButton,{openDelay:d,tooltip:"Text",onClick:()=>l("text"),className:"h-10 p-4",children:e.jsx(fs,{className:t.cn("size-5",a)})}),e.jsx(t.IconButton,{tooltip:"Map",onClick:()=>l("map"),className:"h-10 p-4",children:e.jsx(gt,{className:t.cn("size-5",a)})}),e.jsx(t.IconButton,{openDelay:d,tooltip:"Custom",onClick:()=>l("custom"),className:"h-10 p-4",children:e.jsx(bt,{className:t.cn("size-5",a)})})]})}function Bn({chartType:s,className:a,customIcon:n,componentName:r}){const o=qt();switch(s){case"bar":return e.jsx(qe,{className:a});case"line":return e.jsx(Pe,{className:a});case"pie":return e.jsx(ct,{className:a});case"radar":return e.jsx(jt,{className:a});case"scatter":return e.jsx(dt,{className:a});case"bubble":return e.jsx(Gt,{className:a});case"doughnut":return e.jsx(mt,{className:a});case"stackedBar":return e.jsx(it,{className:a});case"stackedLine":return e.jsx(Ut,{className:a});case"polarArea":return e.jsx(Ht,{className:a});case"pyramid":return e.jsx(Ct,{className:a});case"range":return e.jsx(lt,{className:a});case"kpi":return e.jsx($t,{className:a});case"text":return e.jsx(vt,{className:a});case"map":return e.jsx(gt,{className:a});case"custom":return n&&o?e.jsx(o,{className:a}):r?r==null?void 0:r.charAt(0).toUpperCase():e.jsx(bt,{className:a});default:return e.jsx(He,{className:a})}}function _n(){var c,i;const[s,a]=E.useState(!1),n=t.useEditorStore(l=>l.card),r=n.type,o=t.useDashboardStore(l=>l.isVisualEditing);return e.jsxs(t.Popover,{open:s,onOpenChange:a,children:[e.jsx(t.PopoverTrigger,{asChild:!0,children:e.jsx(t.Button,{size:"sm",variant:o?"ghost":"outline",children:e.jsx(Bn,{className:"size-4",chartType:r,customIcon:(c=n.customCardPreferences)==null?void 0:c.icon,componentName:(i=n.customCardPreferences)==null?void 0:i.componentName})})}),e.jsxs(t.PopoverContentCustom,{onOpenAutoFocus:l=>l.preventDefault(),className:"w-50",children:[e.jsx(Qt,{onChartTypeChange:()=>a(!1)}),e.jsx(zn,{onChartTypeChange:()=>a(!1)})]})]})}const je="focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0";function rt(s,a){var r,o,c;const n=t.getNumberAxis(s,a);return((c=(o=(r=s==null?void 0:s.chartOptions)==null?void 0:r.scales)==null?void 0:o[n])==null?void 0:c.type)||"linear"}function Vn(){var D,M,G,O,k,v;const[s,a]=E.useState(!1),n=t.useEditorStore(A=>{var L;return(L=A.card)==null?void 0:L.preferences}),r=t.getNumberAxis(n,{}),[o,c]=E.useState(rt(n)),[i,l]=E.useState(((G=(M=(D=n==null?void 0:n.chartOptions)==null?void 0:D.scales)==null?void 0:M[r])==null?void 0:G.min)||""),[d,h]=E.useState(((v=(k=(O=n==null?void 0:n.chartOptions)==null?void 0:O.scales)==null?void 0:k[r])==null?void 0:v.max)||""),[m,x]=E.useState(i||d?"custom":"auto"),[f,u]=E.useState(""),[C,p]=E.useState(0),[y,g]=E.useState(""),[S,b]=E.useState(""),[I,N]=E.useState(""),T=t.useEditorStore(A=>A.actions.setCardPreferences),{updateCardInFrame:_}=t.useEditorActions(),R=t.useEditorStore(A=>A.card),U=t.useEditorStore(A=>{var L;return(L=A.card)==null?void 0:L.type}),w=["pie","doughnut","polarArea"].includes(U);E.useEffect(()=>{var A,L,K,P,W,B,J,H,Z,z,Q,X,ne,ie;c(rt(n)),l(((K=(L=(A=n==null?void 0:n.chartOptions)==null?void 0:A.scales)==null?void 0:L[r])==null?void 0:K.min)===0?0:""),h(((B=(W=(P=n==null?void 0:n.chartOptions)==null?void 0:P.scales)==null?void 0:W[r])==null?void 0:B.max)||""),u(((z=(Z=(H=(J=n==null?void 0:n.chartOptions)==null?void 0:J.scales)==null?void 0:H[r])==null?void 0:Z.ticks)==null?void 0:z.stepSize)||""),p(((Q=n==null?void 0:n.numberAxisFormat)==null?void 0:Q.decimalPlaces)||0),g(((X=n==null?void 0:n.numberAxisFormat)==null?void 0:X.suffix)||""),b(((ne=n==null?void 0:n.numberAxisFormat)==null?void 0:ne.currency)||""),N(((ie=n==null?void 0:n.numberAxisFormat)==null?void 0:ie.locale)||"")},[s,n,r]);function V(A,L){return L===""||/^[0-9\b]+$/.test(L)?Number(L):Number(A)}function $(){const A=[...new Set(t.LOCALE_CURRENCY_PAIRS.map(L=>L.currency))];return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-6 items-center gap-2",children:[e.jsx(t.Label,{className:"col-span-2 hover:cursor-pointer hover:underline",htmlFor:"currency",children:e.jsx("a",{target:"_blank",href:"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat",children:"Currency"})}),e.jsxs(t.Select,{value:S||"none",onValueChange:L=>b(L==="none"?"":L),children:[e.jsx(t.SelectTrigger,{className:"col-span-2 h-8 w-full focus:ring-1 focus:ring-offset-0",children:e.jsx(t.SelectValue,{})}),e.jsx(t.SelectContent,{children:e.jsxs(t.SelectGroup,{children:[e.jsx(t.SelectLabel,{children:"Currency"}),e.jsx(t.SelectItem,{value:"none",children:"None"}),A.map(L=>e.jsx(t.SelectItem,{value:L,children:L},L))]})})]}),e.jsxs(t.Select,{value:I,onValueChange:L=>N(L),children:[e.jsx(t.SelectTrigger,{className:"col-span-2 h-8 w-full focus:ring-1 focus:ring-offset-0",children:e.jsx(t.SelectValue,{})}),e.jsx(t.SelectContent,{children:e.jsxs(t.SelectGroup,{children:[e.jsx(t.SelectLabel,{children:"Locale"}),t.LOCALE_CURRENCY_PAIRS.map(L=>e.jsx(t.SelectItem,{value:L.locale,children:L.locale},L.locale))]})})]})]}),e.jsxs("div",{className:"grid grid-cols-9 items-center gap-2",children:[e.jsx(t.Label,{className:"col-span-3",htmlFor:"format",children:"Decimals"}),e.jsx(t.Input,{value:C,onChange:L=>p(Number(L.target.value)),id:"format",className:`col-span-6 h-8 w-full tracking-wide ${je}`})]})]})}function q(){return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-3 items-center gap-2",children:[e.jsx(t.Label,{htmlFor:"range",children:"Range"}),e.jsx(t.Input,{id:"min",value:i,onChange:A=>l(L=>V(L,A.target.value)),className:`col-span-1 h-8 w-full ${je}`}),e.jsx(t.Input,{value:d,onChange:A=>h(L=>V(L,A.target.value)),id:"max",className:`col-span-1 h-8 w-full ${je}`})]}),e.jsxs("div",{className:"grid grid-cols-3 items-center gap-2",children:[e.jsx(t.Label,{htmlFor:"step-size",children:"Step Size"}),e.jsx(t.Input,{value:f,onChange:A=>u(L=>V(L,A.target.value)),id:"step-size",className:`col-span-1 h-8 w-full ${je}`})]})]})}function j(){var P;let A={};m==="custom"&&(A={min:i,max:d,ticks:{stepSize:f}});const L={...n||{},chartOptions:{...n==null?void 0:n.chartOptions,scales:{...(P=n==null?void 0:n.chartOptions)==null?void 0:P.scales,[r]:{type:o,...o==="linear"?A:{}}}},numberAxisFormat:{decimalPlaces:C,suffix:y,currency:S,locale:I}};console.log(L),T(L);const K={...R,preferences:L};_(K)}return e.jsxs(t.Popover,{onOpenChange:A=>a(A),children:[e.jsx(t.PopoverTrigger,{asChild:!0,children:e.jsx(t.IconButton,{tooltip:"Scale Options",children:e.jsx($s,{className:"size-4 rotate-45"})})}),e.jsx(t.PopoverContentCustom,{align:"center",className:"max-w-65",children:e.jsxs("div",{className:"grid gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("h4",{className:"font-medium leading-none",children:"Scale Options"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Set the scale for the number axis"})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsxs("div",{className:"grid grid-cols-3 items-center gap-2",children:[e.jsx(t.Label,{htmlFor:"scale",children:"Type"}),e.jsxs(t.Select,{disabled:w,value:o,onValueChange:A=>c(A),children:[e.jsx(t.SelectTrigger,{className:"col-span-2 h-8 w-full focus:ring-1 focus:ring-offset-0",children:e.jsx(t.SelectValue,{})}),e.jsx(t.SelectContent,{id:"type",children:e.jsxs(t.SelectGroup,{children:[e.jsx(t.SelectLabel,{children:"Option"}),e.jsx(t.SelectItem,{value:"linear",children:"Linear"}),e.jsx(t.SelectItem,{value:"logarithmic",children:"Logarithmic"})]})})]})]}),o=="linear"&&e.jsxs("div",{className:"grid grid-cols-3 items-center gap-2 py-1",children:[e.jsx(t.Label,{htmlFor:"scale-option",children:"Setup"}),e.jsxs(t.RadioGroup,{disabled:w,id:"scale-option",value:m,onValueChange:A=>x(A),className:"col-span-2 flex gap-3",defaultValue:"x",children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(t.RadioGroupItem,{value:"auto",id:"r1"}),e.jsx("label",{className:"text-sm",htmlFor:"r1",children:"Auto"})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(t.RadioGroupItem,{value:"custom",id:"r2"}),e.jsx("label",{className:"text-sm",htmlFor:"r2",children:"Custom"})]})]})]}),m==="custom"&&o=="linear"&&q(),$(),e.jsx(t.SelectSeparator,{}),e.jsx("div",{className:"grid grid-cols-3",children:e.jsx(t.Button,{onClick:j,variant:"secondary",className:"col-span-1 col-start-3 h-8 w-full",children:"Apply"})})]})]})})]})}function qn(){const s=t.useEditorStore(l=>{var d,h,m,x;return(x=(m=(h=(d=l.card.preferences)==null?void 0:d.chartOptions)==null?void 0:h.plugins)==null?void 0:m.legend)==null?void 0:x.position}),a=t.useEditorStore(l=>{var d,h,m,x;return(x=(m=(h=(d=l.card.preferences)==null?void 0:d.chartOptions)==null?void 0:h.plugins)==null?void 0:m.legend)==null?void 0:x.align}),n=t.useEditorStore(l=>{var d,h,m,x;return(x=(m=(h=(d=l.card.preferences)==null?void 0:d.chartOptions)==null?void 0:h.plugins)==null?void 0:m.legend)==null?void 0:x.display}),{setLegendOptions:r}=t.useEditorActions(),o=l=>{r({display:l,position:s,align:a})},c=l=>{r({display:n,position:l,align:a})},i=l=>{r({display:n,position:s,align:l})};return e.jsxs(t.Popover,{children:[e.jsx(t.PopoverTrigger,{asChild:!0,children:e.jsx(t.IconButton,{tooltip:"Legend Settings",children:e.jsx(Os,{className:"size-4"})})}),e.jsx(t.PopoverContentCustom,{className:"w-72",children:e.jsxs("div",{className:"grid gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("h4",{className:"font-medium leading-none",children:"Legend Options"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Set the legend options for the chart."})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsxs("div",{className:"grid grid-cols-3 items-center gap-4",children:[e.jsx(t.Label,{htmlFor:"displayLegend",children:"Display"}),e.jsx("div",{className:"col-span-2 flex h-8 items-center",children:e.jsx(t.SmallSwitch,{checked:n,onCheckedChange:o,defaultChecked:!0,id:"displayLegend"})})]}),e.jsxs("div",{className:"grid grid-cols-3 items-center gap-4",children:[e.jsx(t.Label,{htmlFor:"position",children:"Position"}),e.jsxs("div",{className:"col-span-2 flex h-8 items-center",children:[e.jsx(t.IconButton,{tooltip:"Top",onClick:()=>c("top"),children:e.jsx(t.ArrowUp,{className:"size-4"})}),e.jsx(t.IconButton,{tooltip:"Left",onClick:()=>c("left"),children:e.jsx(cs,{className:"size-4"})}),e.jsx(t.IconButton,{tooltip:"Bottom",onClick:()=>c("bottom"),children:e.jsx(is,{className:"size-4"})}),e.jsx(t.IconButton,{tooltip:"Right",onClick:()=>c("right"),children:e.jsx(ds,{className:"size-4"})})]})]}),e.jsxs("div",{className:"grid grid-cols-3 items-center gap-4",children:[e.jsx(t.Label,{htmlFor:"align",children:"Align"}),e.jsxs("div",{className:"col-span-2 flex h-8 items-center",children:[e.jsx(t.IconButton,{tooltip:"Start",onClick:()=>i("start"),children:e.jsx(ss,{className:"size-4"})}),e.jsx(t.IconButton,{tooltip:"Center",onClick:()=>i("center"),children:e.jsx(ts,{className:"size-4"})}),e.jsx(t.IconButton,{tooltip:"End",onClick:()=>i("end"),children:e.jsx(ns,{className:"size-4"})})]})]})]})]})})]})}function Pn(){var c;const s=t.useEditorStore(i=>i.card.preferences),{setCardPreferences:a,setChartOrientation:n}=t.useEditorStore(i=>i.actions);function r(i){n(i)}const o=((c=s==null?void 0:s.chartOptions)==null?void 0:c.indexAxis)||"x";return e.jsx(t.IconButton,{onClick:()=>r(o==="y"?"x":"y"),tooltip:"Chart Orientation",children:o==="y"?e.jsx(Ps,{className:"size-4"}):e.jsx(qs,{className:"size-4"})})}function Hn(){const s=t.useEditorStore(i=>i.card),a=t.useEditorStore(i=>i.isShowingVisual),n=t.useEditorStore(i=>{var l,d;return(d=(l=i.card)==null?void 0:l.preferences)==null?void 0:d.chartOptions}),r=t.getChartGridStyle(n),{setChartGrid:o}=t.useEditorActions();function c(){const i=["xy","none","x","y"],d=(i.indexOf(r)+1)%i.length;o(i[d])}return a?e.jsxs("div",{"data-info":"visual-settings",className:"flex items-center",children:[["line","bar","range","stackedBar","stackedLine","horizontalBar"].includes(s.type)&&e.jsx(Pn,{}),!["kpi","text","custom","table"].includes(s.type)&&e.jsxs(e.Fragment,{children:[e.jsx(Vn,{}),e.jsx(qn,{})]}),!["pie","doughnut","radar","polarArea","table","custom","kpi","text","map"].includes(s.type)&&e.jsxs(t.IconButton,{tooltip:"Grid Style",onClick:c,children:[(r==="xy"||!r)&&e.jsx(Ms,{className:"size-4"}),r==="x"&&e.jsx(Cs,{className:"size-4"}),r==="y"&&e.jsx(Us,{className:"size-4"}),r==="none"&&e.jsx(Ws,{className:"size-4"})]})]}):null}function ye(){var O;const s=t.useEditorStore(k=>k.frame),a=t.useEditorStore(k=>k.card),n=t.useEditorStore(k=>k.isDevMode),r=t.useEditorStore(k=>k.isShowingVisual),o=t.useDashboardStore(k=>k.isVisualEditing),c=t.useEditorStore(k=>k.isSqlRunning),i=t.useEditorStore(k=>k.pythonStdOut),l=t.useEditorStore(k=>{var v;return(v=k.card.preferences)==null?void 0:v.chartOptions}),d=t.useEditorStore(k=>k.actions.setRunSql);t.getChartGridStyle(l);const{setFrame:h,setCard:m,updateCardInFrame:x,setActiveTabCardId:f,runAssistant:u,setChartGrid:C}=t.useEditorActions(),{data:p,isLoading:y,isFetching:g,error:S}=t.useDashboardCardQuery(a);if(!a)return e.jsx(e.Fragment,{children:"No Active Card"});function b(){const k={connectionId:a.connectionId,lastSelectedDatabase:a.lastSelectedDatabase,lastSelectedSchema:a.lastSelectedSchema,lastSelectedTable:a.lastSelectedTable,lastSelectedDatamodelId:a.lastSelectedDatamodelId,id:t.v4(),title:"Title",description:"Description",preferences:{onClickFilter:[{columnIndex:0,expression:""}]},type:"bar",sql:"",data:[]};I(k)}function I(k){const v={...s,cards:[...s.cards,k],activeCardId:k.id};h(v),m(k),f(k.id)}function N(){const k={...a,id:t.v4(),title:`${a.title} Copy`,tabTitle:`${a.tabTitle||a.title} Copy`};I(k)}function T(k){const v=s.cards.filter(K=>K.id!==k),A=v[0],L={...s,cards:v,activeCardId:A.id};h(L),f(A.id),m(A)}function _(k){n||R(k),f(k)}function R(k){const v={...s,cards:s.cards.map(L=>L.id===a.id?a:L),activeCardId:k};h(v);const A=v.cards.find(L=>L.id===k);A.sql&&d(!0),m(A)}const U=(k,v)=>{console.log("handleDragStart",v),k.dataTransfer.setData("tabIndex",v.toString())},w=k=>{k.preventDefault()},V=(k,v)=>{const A=k.dataTransfer.getData("tabIndex");if(A===v.toString())return;const L=Array.from(s.cards),[K]=L.splice(parseInt(A),1);L.splice(v,0,K),h({...s,cards:L})};function $(k,v){return k.cards.length===1&&(v.displayTab===!0||v.displayTab===void 0)||k.activeCardId!==v.id&&(v.displayTab===!0||v.displayTab===void 0)?null:e.jsx("div",{onClick:()=>{const A=v.displayTab===void 0?!1:!v.displayTab;m({...v,displayTab:A}),x({...v,displayTab:A})},children:v.displayTab===!0||v.displayTab===void 0?e.jsx(t.Eye,{className:"mr-2 size-3.5 text-muted-foreground hover:text-foreground"}):e.jsx(Is,{className:"mr-2 size-3.5 text-muted-foreground hover:text-foreground"})})}function q(){return e.jsxs(t.Tabs,{onValueChange:_,value:s.activeCardId,className:"flex grow flex-col",children:[s.cards.map(k=>e.jsx(t.TabsContent,{className:"mt-0 grow",value:k.id,children:j()},k.id)),e.jsx(t.TabsList,{className:"group mx-6 justify-between overflow-x-auto",children:e.jsxs("div",{className:"flex items-center",children:[s.cards.map((k,v)=>e.jsx(t.Editable,{text:k.tabTitle||k.title,onSave:A=>{m({...a,tabTitle:A}),x({...a,tabTitle:A})},children:e.jsxs(t.TabsTrigger,{draggable:!0,onDragStart:A=>U(A,v),onDragOver:w,onDrop:A=>V(A,v),className:"",value:k.id,children:[$(s,k),k.tabTitle||k.title,s.activeCardId===k.id&&s.cards.length>1&&e.jsx(t.X,{className:"ml-2 size-3.5 text-muted-foreground hover:text-foreground",onClick:()=>T(k.id)})]})},k.id)),e.jsx(t.Button,{className:"ml-1 h-8 px-2 hover:bg-muted-foreground/50",variant:"outline",onClick:b,children:e.jsx(t.Plus,{className:"h-4 w-4"})}),e.jsx(t.Button,{className:"invisible ml-1 h-8 px-2 hover:bg-muted-foreground/50 group-hover:visible",variant:"outline",onClick:N,children:e.jsx(Ns,{className:"h-4 w-4"})})]})})]})}function j(){return a.type==="kpi"?e.jsx("div",{className:"flex h-full items-center justify-center",children:e.jsx("div",{className:"w-1/2 rounded-md border",children:e.jsx(t.KPICard,{card:a,data:p==null?void 0:p.records})})}):a.type==="text"?e.jsx("div",{className:"flex h-full items-center justify-center",children:e.jsx("div",{className:"w-1/2 rounded-md border",children:e.jsx(t.ScrollArea,{className:"mx-3 my-6 h-[300px] overflow-y-auto break-words px-3",children:e.jsx(t.TextCard,{isLoading:c,card:a,data:p==null?void 0:p.records})})})}):e.jsx(t.ErrorBoundary,{FallbackComponent:t.FallbackEditorCard,children:e.jsx(Vt,{className:"grow border-none shadow-none"})})}function D(){const k=JSON.stringify(p==null?void 0:p.records,null,2),v=new Blob([k],{type:"application/json"}),A=URL.createObjectURL(v),L=document.createElement("a");L.href=A,L.download=`${a.title}.json`,L.click()}function M(){const v=[Object.keys(p==null?void 0:p.records.reduce((P,W)=>({...P,...W}),{})).join(","),...((p==null?void 0:p.records)||[]).map(P=>Object.values(P).join(","))].join(`
382
- `),A=new Blob([v],{type:"text/csv"}),L=URL.createObjectURL(A),K=document.createElement("a");K.href=L,K.download=`${a.title}.csv`,K.click()}function G(){const k=`Can you get the documentation for ${a.type} chart?`;u(k)}return e.jsxs("div",{className:"relative isolate flex h-full flex-col py-3",children:[(y||g)&&e.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.jsx(re,{className:"h-8 w-8 animate-spin text-muted-foreground"})}),e.jsxs("div",{className:"z-10 mb-0 flex min-h-10 items-center justify-end gap-2 px-6",children:[r&&e.jsxs("div",{className:"flex grow items-center",children:[e.jsx(_n,{}),o&&e.jsx(t.IconButton,{tooltip:"Visual Docs",onClick:G,children:e.jsx(xs,{className:"size-4"})}),!["table","custom"].includes(a.type)&&o&&e.jsx(On,{})]}),!r&&e.jsxs("div",{className:"flex grow items-center gap-1",children:[e.jsx(t.Button,{className:"h-7 w-fit px-1 font-mono text-xs text-muted-foreground/70",variant:"ghost",size:"icon",onClick:M,children:e.jsx(Rn,{className:"size-4"})}),e.jsx(t.Button,{className:"h-7 w-fit px-1 font-mono text-xs text-muted-foreground/70",variant:"ghost",size:"icon",onClick:D,children:e.jsx(Ds,{strokeWidth:1.5,className:"size-4"})}),e.jsx(t.CopyButton,{text:JSON.stringify(p==null?void 0:p.records,null,2),className:"h-7 w-fit px-1 font-mono text-xs text-muted-foreground/70"})]}),e.jsx(Hn,{}),e.jsx(Un,{})]}),r?q():e.jsxs(t.ResizablePanelGroup,{className:"px-6",direction:"horizontal",children:[i&&e.jsxs(e.Fragment,{children:[e.jsx(t.ResizablePanel,{id:"1",order:1,defaultSize:30,minSize:10,className:"relative flex h-full min-h-0 w-full flex-1 basis-0",children:i&&e.jsx(Gn,{})}),e.jsx(t.ResizableHandle,{})]}),e.jsxs(t.ResizablePanel,{id:"2",order:2,minSize:10,className:"relative flex h-full min-h-0 w-full flex-1 basis-0",children:[(p==null?void 0:p.records)&&(p==null?void 0:p.records.length)>0&&e.jsx(En,{data:(p==null?void 0:p.records)||[]}),(S||(p==null?void 0:p.error))&&e.jsx("span",{className:"font-mono text-xs",children:(S==null?void 0:S.message)||((O=p==null?void 0:p.error)==null?void 0:O.message)})]})]})]})}function Gn(){const s=t.useEditorStore(n=>n.pythonStdOut);if(!s)return null;const a=s.replace(/\n/g,"<br>");return e.jsxs("div",{className:"relative flex w-full flex-col border-r",children:[e.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.jsxs(t.ScrollArea,{className:"overflow-y-auto px-2 pt-1 font-mono text-xs text-foreground/90",children:[e.jsx("div",{dangerouslySetInnerHTML:{__html:a}}),e.jsx(t.ScrollBar,{orientation:"horizontal"})]})]})}function Un(){const s=t.useEditorStore(n=>n.isShowingVisual),a=t.useEditorStore(n=>n.actions.setIsShowingVisual);return e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(t.Label,{htmlFor:"visualize",children:"Chart"}),e.jsx(t.SmallSwitch,{checked:s,onCheckedChange:()=>a(!s),id:"visualize",className:"data-[state=checked]:bg-foreground/50"})]})}function $n(){var p,y;const s=t.useEditorStore(g=>g.card.customCardPreferences),{data:a}=Pt(),n=(a==null?void 0:a.plugins)||[],r=t.useEditorStore(g=>g.card),o=t.useEditorStore(g=>g.frame),c=(s==null?void 0:s.visualType)||"single",{setCustomCardPreferences:i}=t.useEditorActions(),{components:l,manifest:d}=t.useCustomVisual((s==null?void 0:s.url)||""),h=(p=d==null?void 0:d.visuals)==null?void 0:p.find(g=>g.name===(s==null?void 0:s.componentName));function m(g,S){if(!s)return;const I={...(s==null?void 0:s.dataInputCardIds)||{},[g]:{cardId:S,hookRef:null}};i({...s,dataInputCardIds:I})}function x(g){var b,I;const S=(b=o==null?void 0:o.cards)==null?void 0:b.filter(N=>{var T;return((T=N==null?void 0:N.customCardPreferences)==null?void 0:T.visualType)!=="multiple"}).map(N=>({value:N.id,label:N.tabTitle||N.title}));return e.jsx("div",{className:"space-y-2",children:(I=g==null?void 0:g.dataInputs)==null?void 0:I.map((N,T)=>{var _,R;return e.jsxs("div",{className:"grid grid-cols-10 gap-2",children:[e.jsx("div",{className:"col-span-4 flex items-center",children:N}),e.jsx(ee,{className:"col-span-6 h-8 w-full justify-between",label:"",options:S||[],value:((R=(_=s==null?void 0:s.dataInputCardIds)==null?void 0:_[T])==null?void 0:R.cardId)||"",onValueChange:U=>m(T,U)})]},T+Math.random())})})}function f(g,S,b=[],I=""){var N,T;return s?g==="input"?e.jsx(t.Input,{className:`h-8 w-full ${t.removeRing}`,value:((N=s==null?void 0:s.settings)==null?void 0:N[S])||I,onChange:_=>{i({...s,settings:{...s==null?void 0:s.settings,[S]:_.target.value}})}},S):g==="select"?e.jsx(ee,{className:"h-8 w-full",label:"",options:b,value:((T=s==null?void 0:s.settings)==null?void 0:T[S])||I,onValueChange:_=>{i({...s,settings:{...s==null?void 0:s.settings,[S]:_}})}}):null:null}function u(g){const S=Object.entries((g==null?void 0:g.settings)||{});return e.jsx("div",{className:"space-y-3",children:S.map(([b,I])=>e.jsxs("div",{className:"space-y-1",children:[e.jsx(t.Label,{children:I.title}),f(I.ui,b,I.options,I.defaultValue)]},b))})}function C(g){s&&i({...s,visualType:g,componentName:""})}return e.jsxs(t.Accordion,{type:"multiple",defaultValue:["component-settings"],className:"px-6 py-2",children:[e.jsxs(t.AccordionItem,{value:"plugin-settings",children:[e.jsx(t.AccordionTrigger,{children:"Plugin"}),e.jsx(t.AccordionContent,{children:e.jsxs("div",{className:"space-y-4 text-sm",children:[e.jsx("div",{className:"space-y-2",children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(ee,{icon:e.jsx(ps,{className:"h-3.5 w-3.5"}),className:"h-9 w-full",label:"Select Plugin",options:n,value:(s==null?void 0:s.url)||"",onValueChange:g=>i({...s||{url:"",componentName:""},url:g})}),((s==null?void 0:s.type)==="component"||(s==null?void 0:s.type)===void 0)&&e.jsx(t.Tabs,{value:c,onValueChange:C,children:e.jsxs(t.TabsList,{className:"h-9 w-full",children:[e.jsx(t.TabsTrigger,{className:"h-7 w-full",value:"single",children:"Single Visual"}),e.jsx(t.TabsTrigger,{className:"h-7 w-full",value:"multiple",children:"Multi-Visual"})]})})]})}),((s==null?void 0:s.type)==="component"||(s==null?void 0:s.type)===void 0)&&s&&e.jsx(e.Fragment,{children:l&&e.jsx(ee,{icon:e.jsx(vs,{className:"h-3.5 w-3.5"}),className:"h-9 w-full",label:"Select Component",options:(l==null?void 0:l.filter(g=>g.type===c).map(g=>({value:g.name,label:g.name})))||[],value:s.componentName,onValueChange:g=>{console.log("changing value",g),i({...s,componentName:g})}})})]})})]}),((y=r==null?void 0:r.customCardPreferences)==null?void 0:y.componentName)&&e.jsxs(t.AccordionItem,{className:"border-none",value:"component-settings",children:[e.jsx(t.AccordionTrigger,{children:"Settings"}),e.jsxs(t.AccordionContent,{children:[h&&h.dataInputs&&e.jsxs("div",{className:"space-y-3",children:[e.jsx(t.Label,{children:"Input Mapping"}),e.jsx("div",{className:"px-2",children:x(h)})]}),h&&h.settings&&e.jsx("div",{className:"space-y-3",children:e.jsx("div",{className:"px-2",children:u(h)})})]})]})]})}function oe(){const[s,a]=E.useState([]),n=t.useEditorStore(h=>h.card.preferences),{setFilterOnClickColumnIndex:r,setCardPreferences:o}=t.useEditorStore(h=>h.actions),c=t.useEditorStore(h=>h.queryResultColumns);t.useEditorStore(h=>{var m;return(m=h.card.preferences)==null?void 0:m.filterOnClickColumnIndex}),E.useEffect(()=>{c&&a(new Array(c.length).fill(!1))},[c]);function i(h,m){var x,f;m?n!=null&&n.onClickFilter&&((x=n==null?void 0:n.onClickFilter)==null?void 0:x.length)>0?o({...n,onClickFilter:[...n.onClickFilter,{columnIndex:h,expression:""}]}):o({...n,onClickFilter:[{columnIndex:h,expression:""}]}):(o({...n,onClickFilter:(f=n==null?void 0:n.onClickFilter)==null?void 0:f.filter(u=>u.columnIndex!==h)}),a(u=>{const C=[...u];return C[h]=!1,C}))}function l(h,m){var f;const x=(f=n==null?void 0:n.onClickFilter)==null?void 0:f.map(u=>u.columnIndex===h?{...u,expression:m.target.value}:u);o({...n,onClickFilter:x})}function d(h){var m,x,f,u;if(s!=null&&s[h]||(x=(m=n==null?void 0:n.onClickFilter)==null?void 0:m.find(C=>C.columnIndex===h))!=null&&x.expression)return e.jsx(t.Input,{value:(u=(f=n==null?void 0:n.onClickFilter)==null?void 0:f.find(C=>C.columnIndex===h))==null?void 0:u.expression,onChange:C=>l(h,C),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.jsxs("div",{className:"space-y-2",children:[e.jsx(t.Label,{children:"On Click"}),c==null?void 0:c.map((h,m)=>{var x,f;return e.jsx("div",{className:"xbg-red-100 group flex items-center justify-between space-y-2",children:e.jsxs("div",{className:"grow",children:[e.jsxs("div",{className:"flex items-center space-x-2 py-2",children:[e.jsx(t.Checkbox,{checked:!!((x=n==null?void 0:n.onClickFilter)!=null&&x.find(u=>u.columnIndex===m)),onCheckedChange:u=>i(m,u)}),e.jsx("label",{className:"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",children:h}),e.jsx("div",{className:"flex items-center gap-2",children:((f=n==null?void 0:n.onClickFilter)==null?void 0:f.find(u=>u.columnIndex===m))&&e.jsx(t.Pencil,{onClick:()=>{a(u=>{const C=[...u];return C[m]=!u[m],C})},className:"invisible size-3 cursor-pointer text-gray-400 group-hover:visible"})})]}),d(m)]})},h)})]})}function Qn({idx:s}){var l;const a=t.useEditorStore(d=>{var h;return(h=d.card)==null?void 0:h.preferences}),n=t.useEditorStore(d=>{var h;return(h=d.card.preferences)==null?void 0:h.datasetOptions}),r=t.useEditorStore(d=>d.actions.setCardPreferences),o=(l=a==null?void 0:a.chartOptions)==null?void 0:l.indexAxis,c=n==null?void 0:n.find(d=>d.idx===s);function i(d,h){(d==="end"||d==="start")&&t.getContrastColor(t.getCanvasBackgroundColor());const m={display:d!=="none",align:d,anchor:d,clamp:!0};if(!c)r({...a,datasetOptions:[...n||[],{idx:h,datalabels:m}]});else{const x={...c};x.datalabels=m;const f=n==null?void 0:n.map(u=>u.idx===h?x:u);r({...a,datasetOptions:f})}}return e.jsxs(t.Popover,{children:[e.jsx(t.PopoverTrigger,{children:e.jsx(Ys,{className:"invisible size-4 rotate-[135deg] cursor-pointer text-muted-foreground hover:text-foreground group-hover:visible"})}),e.jsx(t.PopoverContent,{className:"w-fit p-1",children:e.jsxs("div",{className:"flex gap-1",children:[e.jsx(t.Button,{onClick:()=>i("none",s),size:"sm",variant:"secondary",className:"h-7 p-1 text-xs font-normal",children:e.jsx(t.X,{className:"size-4"})}),e.jsx(t.Button,{onClick:()=>i("start",s),size:"sm",variant:"secondary",className:"h-7 p-1 text-xs font-normal",children:e.jsx(zs,{className:t.cn("h-4 w-4",{"rotate-90":o==="y"})})}),e.jsx(t.Button,{onClick:()=>i("center",s),size:"sm",variant:"secondary",className:"h-7 p-1 text-xs font-normal",children:e.jsx(Rs,{className:t.cn("h-4 w-4",{"rotate-90":o==="y"})})}),e.jsx(t.Button,{onClick:()=>i("end",s),size:"sm",variant:"secondary",className:"h-7 p-1 text-xs font-normal",children:e.jsx(Fs,{className:t.cn("h-4 w-4",{"rotate-90":o==="y"})})})]})})]})}function Jt(){const s=t.useEditorStore(h=>h.card),a=t.useEditorStore(h=>{var m,x,f;return(f=(x=(m=h==null?void 0:h.card)==null?void 0:m.preferences)==null?void 0:x.chartOptions)==null?void 0:f.indexAxis}),{data:n}=t.useDashboardCardQuery(s),r=a==="y"?"Metric":"Dimension",o=a==="y"?"Dimension":"Metric",{keys:c,metricKeys:i,dimensionKeys:l}=t.getKeys((n==null?void 0:n.records)||[]);let d=i;if(["stackedBar","stackedLine"].includes(s.type)){const h=t.pivotData({dataArray:(n==null?void 0:n.records)||[],groupKey:l[0],pivotKey:l[1],valueKey:d[0]}),{metricKeys:m}=t.getKeys(h);d=m}return c.length===0?null:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(t.Label,{children:r}),e.jsx("div",{className:"max-h-[125px] space-y-1 overflow-y-auto",children:l.map(h=>e.jsx("p",{className:"rounded-md bg-muted/70 px-3 py-2 hover:bg-muted",title:h,children:Kt(h)},h))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(t.Label,{children:o}),e.jsx("div",{className:"my-1 max-h-[125px] space-y-1 overflow-y-auto",children:d.map((h,m)=>e.jsx(Jn,{col:h,idx:m},h))})]})]})}function Kt(s,a=30){return s.length>a?s.slice(0,a)+"...":s}function Jn({col:s,idx:a}){const n=t.useEditorStore(l=>{var d;return(d=l.card)==null?void 0:d.preferences}),r=t.useEditorStore(l=>{var d;return(d=l.card.preferences)==null?void 0:d.datasetOptions}),o=r==null?void 0:r.find(l=>l.idx===a),{setCardPreferences:c}=t.useEditorStore(l=>l.actions);function i(l){if(!o)c({...n,datasetOptions:[...r||[],{idx:a,type:l==="area"?"line":l,fill:l==="area"?"origin":""}]});else{const d={...o};d.type=l==="area"?"line":l,d.fill=l==="area"?"origin":"";const h=r==null?void 0:r.map(m=>m.idx===a?d:m);c({...n,datasetOptions:h})}}return e.jsxs("div",{className:"group flex items-center justify-between gap-5 rounded-md bg-muted/70 px-3 py-2 hover:bg-muted",children:[e.jsx("p",{title:s,children:Kt(s)}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(qe,{onClick:()=>i("bar"),className:"invisible size-4 cursor-pointer text-muted-foreground hover:text-foreground group-hover:visible"}),e.jsx(Pe,{onClick:()=>i("line"),className:"invisible size-4 cursor-pointer text-muted-foreground hover:text-foreground group-hover:visible"}),e.jsx(ys,{onClick:()=>i("area"),className:"invisible size-4 cursor-pointer text-muted-foreground hover:text-foreground group-hover:visible"}),e.jsx(Qn,{idx:a})]})]})}function Wt(){const s=t.useEditorStore(u=>u.selectedConnectionId),a=t.useEditorStore(u=>u.selectedDatamodelId),n=t.useEditorStore(u=>u.selectedDatabaseName),r=t.useEditorStore(u=>u.selectedSchemaName),o=t.useEditorStore(u=>u.selectedTableName),c=t.useDashboardStore(u=>u.dashboard.filters)||[],i=t.useDashboardStore(u=>u.actions.addFilter),l=t.useDashboardStore(u=>u.actions.removeFilter),{removeFilterValues:d}=t.useDashboardActions(),{modelItems:h,tableName:m,connectionType:x}=te();function f(u,C="dashboard"){var _;const p=t.fmt(u.column_name),y=t.fmt(n||""),g=t.fmt(r||""),S=t.fmt(m);let b=t.getQualifiedTableName({schemaName:g,tableName:S,connectionType:x,databaseName:y}),I=`${b}.${p}`;const N=(_=h==null?void 0:h.find(R=>R.id===a))==null?void 0:_.name;a&&a!=="none"&&(I=`${t.DATAMODEL_NAMESPCACE}.${N}.${p}`,b=`${t.DATAMODEL_NAMESPCACE}.${N}`);const T=c==null?void 0:c.find(R=>R.column===I&&R.table===S&&(R.database===y||R.database===n));if(T)d(T.id),l(T.id);else{const R=t.v4();return m==="api"&&s?(i({location:C,id:R,column:I,title:u.column_name,dataType:u.data_type,table:"api",database:"",connectionId:s,operation:"in",sql:t.getDefaultFilterSql(u.data_type,b,p)}),R):(i({id:R,location:C,column:I,title:u.column_name,dataType:u.data_type,table:o||"",database:n||"",connectionId:s||"",operation:"in",sql:t.getDefaultFilterSql(u.data_type,b,p)}),R)}}return{assignFilter:f}}function pe(){const s=t.useDashboardStore(l=>l.dashboard.filters),a=t.useEditorStore(l=>l.frame),{setFrame:n}=t.useEditorActions(),{columns:r}=te(),{assignFilter:o}=Wt();function c(l){const d=o(l,"frame");n({...a,filterId:d})}const i=s==null?void 0:s.find(l=>l.id===a.filterId);return e.jsxs("div",{className:"space-y-3",children:[e.jsx(t.Label,{children:"Card Filter"}),e.jsx(Kn,{onSelect:c,columns:r}),i&&e.jsx(t.FilterHeader,{filter:i})]})}function Kn({columns:s,onSelect:a}){var i;const[n,r]=ce.useState(!1),[o,c]=ce.useState("");return e.jsxs(t.Popover,{open:n,onOpenChange:r,children:[e.jsx(t.PopoverTrigger,{asChild:!0,children:e.jsxs(t.Button,{size:"sm",variant:"outline",role:"combobox","aria-expanded":n,className:"w-full justify-between font-normal",children:[o?(i=s.find(l=>l.column_name===o))==null?void 0:i.column_name:"Select Column...",e.jsx(t.CaretSortIcon,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(t.PopoverContent,{className:"w-[200px] p-0",children:e.jsxs(t.Command,{children:[e.jsx(t.CommandInput,{placeholder:"Search column",className:"h-9"}),e.jsxs(t.CommandList,{children:[e.jsx(t.CommandEmpty,{children:"No framework found."}),e.jsx(t.CommandGroup,{children:s==null?void 0:s.map(l=>e.jsxs(t.CommandItem,{value:l.column_name,onSelect:d=>{const h=d===o?"":d;c(h),r(!1),h&&a(l)},children:[l.column_name,e.jsx(t.CheckIcon,{className:t.cn("ml-auto h-4 w-4",o===l.column_name?"opacity-100":"opacity-0")})]},l.column_name))})]})]})})]})}function Wn({cardType:s}){return e.jsx("div",{className:"space-y-6 px-6 py-2",children:e.jsxs(t.Accordion,{defaultValue:["item-2"],type:"multiple",children:[e.jsxs(t.AccordionItem,{value:"item-1",children:[e.jsx(t.AccordionTrigger,{children:`${t.titleCase(s)} Chart`}),e.jsxs(t.AccordionContent,{className:"space-y-4 font-mono text-xs",children:[e.jsx("div",{className:"rounded bg-muted px-2 py-1 text-xs",children:"SELECT x-axis, y-axis-1, y-axis-2,... FROM table"}),e.jsxs("ul",{className:"ml-6 list-disc text-xs [&>li]:mt-2",children:[e.jsx("li",{children:"x-axis - category"}),e.jsx("li",{children:"y-axis1 - number"}),e.jsx("li",{children:"y-axis2 - number"})]}),e.jsxs("div",{children:["See ",e.jsx("a",{target:"_blank",onClick:a=>a.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/docs/charts/bar-line-area",children:"example"})," in the docs."]})]})]}),e.jsxs(t.AccordionItem,{value:"item-2",children:[e.jsx(t.AccordionTrigger,{children:"Settings"}),e.jsx(t.AccordionContent,{className:"space-y-4 px-2",children:e.jsx(Jt,{})})]}),e.jsxs(t.AccordionItem,{value:"item-3",children:[e.jsx(t.AccordionTrigger,{children:"Filters"}),e.jsxs(t.AccordionContent,{className:"space-y-4 px-2",children:[e.jsx(oe,{}),e.jsx(pe,{})]})]})]})})}function Je(){var o,c,i;const s=t.useEditorStore(l=>l.card.type),a=t.useEditorStore(l=>l.card.preferences),{setCardPreferences:n}=t.useEditorStore(l=>l.actions);function r(l){var m;const d={datalabels:{display:l!=="none",align:l,anchor:l,clamp:!0}},h={...a,chartOptions:{...a==null?void 0:a.chartOptions,plugins:{...(m=a==null?void 0:a.chartOptions)==null?void 0:m.plugins,...d}}};n(h),console.log(l)}return e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"font-medium",children:"Data Labels"}),e.jsxs(t.Select,{value:((i=(c=(o=a==null?void 0:a.chartOptions)==null?void 0:o.plugins)==null?void 0:c.datalabels)==null?void 0:i.anchor)||"none",onValueChange:r,defaultValue:"none",children:[e.jsx(t.SelectTrigger,{className:"h-8 w-full focus:ring-1 focus:ring-offset-0",children:e.jsx(t.SelectValue,{placeholder:"Select position"})}),e.jsx(t.SelectContent,{children:e.jsxs(t.SelectGroup,{children:[e.jsx(t.SelectLabel,{children:"Data Labels"}),e.jsx(t.SelectItem,{value:"none",children:"None"}),s!=="pyramid"&&e.jsx(t.SelectItem,{value:"start",children:"Start"}),e.jsx(t.SelectItem,{value:"center",children:"Center"}),s!=="pyramid"&&e.jsx(t.SelectItem,{value:"end",children:"End"})]})})]})]})}function Yn({cardType:s}){function a(n){return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"rounded bg-muted px-2 py-1 text-xs",children:n==="bubble"?"SELECT label, [group], x-axis, y-axis, radius FROM table":"SELECT label, [group], x-axis, y-axis FROM table"}),e.jsxs("ul",{className:"ml-6 list-disc text-xs [&>li]:mt-2",children:[e.jsx("li",{children:"label - category"}),e.jsx("li",{children:"group (optional) - category"}),e.jsx("li",{children:"x-axis - number"}),e.jsx("li",{children:"y-axis - number"}),n==="bubble"&&e.jsx("li",{children:"radius - number"})]}),e.jsxs("div",{children:["See ",e.jsx("a",{target:"_blank",onClick:c=>c.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/docs/charts/bubble",children:"example"})," in the docs."]})]})}return e.jsx("div",{className:"space-y-6 px-6 py-2",children:e.jsxs(t.Accordion,{defaultValue:["item-2"],type:"multiple",children:[e.jsxs(t.AccordionItem,{value:"item-1",children:[e.jsx(t.AccordionTrigger,{children:`${t.titleCase(s)} Chart`}),e.jsx(t.AccordionContent,{className:"space-y-4 font-mono text-xs",children:a(s)})]}),e.jsxs(t.AccordionItem,{value:"item-2",children:[e.jsx(t.AccordionTrigger,{children:"Settings"}),e.jsx(t.AccordionContent,{className:"px-2",children:e.jsx(Je,{})})]}),e.jsxs(t.AccordionItem,{value:"item-3",children:[e.jsx(t.AccordionTrigger,{children:"Filters"}),e.jsxs(t.AccordionContent,{className:"space-y-4 px-2",children:[e.jsx(oe,{}),e.jsx(pe,{})]})]})]})})}const Zn={datasets:[{type:"line",label:"Sum_sales",data:[]},{type:"bar",label:"Sum_profit",data:[]}]},Xn={datasets:[{fill:"origin",type:"line",label:"Sum_sales",data:[]}]};function ea(){const s=t.useEditorStore(a=>a.card.type);return e.jsxs("div",{className:"space-y-6 p-6",children:[e.jsx(t.Accordion,{className:" ",type:"single",collapsible:!0,children:ta(s)}),!["kpi"].includes(s)&&e.jsxs("div",{className:"space-y-4",children:[e.jsx(Je,{}),e.jsx(oe,{}),e.jsx(pe,{})]})]})}function ta(s){if(["line","bar"].includes(s))return e.jsxs(e.Fragment,{children:[e.jsxs(t.AccordionItem,{value:"item-1",children:[e.jsx(t.AccordionTrigger,{className:"font-normal",children:e.jsx("p",{children:"Chart Query"})}),e.jsxs(t.AccordionContent,{className:" ",children:[e.jsx("div",{className:"rounded bg-muted px-2 py-1 font-mono text-xs font-semibold",children:"SELECT x-axis, y-axis-1, y-axis-2, y-axis-3,... FROM table"}),e.jsxs("ul",{className:"my-6 ml-6 list-disc text-xs font-normal [&>li]:mt-2",children:[e.jsx("li",{children:"X-axis - Category (ex. city)"}),e.jsx("li",{children:"Y-axis - Number (ex. population)"})]})]})]}),e.jsxs(t.AccordionItem,{value:"item-2",children:[e.jsx(t.AccordionTrigger,{className:"font-normal",children:"Mixed Chart"}),e.jsxs(t.AccordionContent,{className:"space-y-2 text-xs",children:[e.jsxs("p",{children:["Click ",e.jsx("b",{children:"Customize"})," and change the `type` property in the dataset."]}),e.jsx("pre",{children:JSON.stringify(Zn,null,2)})]})]}),e.jsxs(t.AccordionItem,{value:"item-3",children:[e.jsx(t.AccordionTrigger,{className:"font-normal",children:"Area Chart"}),e.jsxs(t.AccordionContent,{className:"space-y-2 text-xs",children:[e.jsxs("p",{children:["Click ",e.jsx("b",{children:"Customize"})," and add `fill` property to the dataset. See",e.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.jsx("pre",{children:JSON.stringify(Xn,null,2)})]})]})]});if(s==="bubble")return e.jsx(e.Fragment,{children:e.jsxs(t.AccordionItem,{value:"item-1",children:[e.jsx(t.AccordionTrigger,{className:"font-normal",children:e.jsxs("p",{children:["How to create a ",e.jsx("span",{children:s})," chart query?"]})}),e.jsxs(t.AccordionContent,{className:" ",children:[e.jsx("div",{className:"rounded bg-muted px-2 py-1 font-mono text-xs font-semibold",children:"SELECT label, x-axis, y-axis, radius FROM table"}),e.jsxs("ul",{className:"my-6 ml-6 list-disc text-xs font-normal [&>li]:mt-2",children:[e.jsx("li",{children:"Label - Category (ex. city)"}),e.jsx("li",{children:"Bubble Group (opt) - Category (ex. state)"}),e.jsx("li",{children:"X-axis - Number (ex. avg. age)"}),e.jsx("li",{children:"Y-axis - Number (ex. avg. weight)"}),e.jsx("li",{children:"Radius - Number (ex. population)"})]})]})]})});if(s==="scatter")return e.jsx(e.Fragment,{children:e.jsxs(t.AccordionItem,{value:"item-1",children:[e.jsx(t.AccordionTrigger,{className:"font-normal",children:e.jsxs("p",{children:["How to create a ",e.jsx("span",{children:s})," chart query?"]})}),e.jsxs(t.AccordionContent,{className:" ",children:[e.jsx("div",{className:"rounded bg-muted px-2 py-1 font-mono text-xs font-semibold",children:"SELECT label, x-axis, y-axis FROM table"}),e.jsxs("ul",{className:"my-6 ml-6 list-disc text-xs font-normal [&>li]:mt-2",children:[e.jsx("li",{children:"Label - Category (ex. city)"}),e.jsx("li",{children:"Group (opt) - Category (ex. state)"}),e.jsx("li",{children:"X-axis - Number (ex. avg. age)"}),e.jsx("li",{children:"Y-axis - Number (ex. avg. weight)"})]})]})]})});if(["pie","doughnut","polarArea"].includes(s))return e.jsx(e.Fragment,{children:e.jsxs(t.AccordionItem,{value:"item-1",children:[e.jsx(t.AccordionTrigger,{className:"font-normal",children:e.jsxs("p",{children:[e.jsx("span",{children:s==="polarArea"?"Polar":s.charAt(0).toUpperCase()+s.slice(1)})," ","chart query"]})}),e.jsxs(t.AccordionContent,{className:" ",children:[e.jsx("div",{className:"rounded bg-muted px-2 py-1 font-mono text-xs font-semibold",children:"SELECT label, measure FROM table"}),e.jsxs("ul",{className:"my-6 ml-6 list-disc text-xs font-normal [&>li]:mt-2",children:[e.jsx("li",{children:"Label - Category (ex. city)"}),e.jsx("li",{children:"Measure - Number (ex. population)"})]})]})]})})}function sa(){var d,h,m,x,f;const s=t.useEditorStore(u=>u.card.preferences),a=t.useEditorStore(u=>u.actions.setCardPreferences),n=t.useEditorStore(u=>u.actions.setNumberFormat);t.useEditorStore(u=>{var C,p;return(p=(C=u.card.preferences)==null?void 0:C.formatNumber)==null?void 0:p.decimalPlaces});const r=t.useEditorStore(u=>{var C,p;return(p=(C=u.card.preferences)==null?void 0:C.formatNumber)==null?void 0:p.locale}),o=t.useEditorStore(u=>{var C,p;return(p=(C=u.card.preferences)==null?void 0:C.formatNumber)==null?void 0:p.currency});t.useEditorStore(u=>u.actions.setFilterOnClickField);const c=t.useEditorStore(u=>{var C,p;return(p=(C=u.card.preferences)==null?void 0:C.formatNumber)==null?void 0:p.colorRanges})||[],i=t.useEditorStore(u=>u.actions.setColorRanges),l=[...new Set(t.LOCALE_CURRENCY_PAIRS.map(u=>u.currency))];return e.jsxs("div",{children:[e.jsxs("div",{className:"mb-3 flex items-center gap-2",children:[e.jsx(t.Checkbox,{checked:!!((d=s==null?void 0:s.formatNumber)!=null&&d.enabled),onCheckedChange:u=>{a({...s,formatNumber:{...s==null?void 0:s.formatNumber,enabled:u}})}}),e.jsx(t.Label,{children:"Format Number"})]}),((h=s==null?void 0:s.formatNumber)==null?void 0:h.enabled)===!0&&e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("div",{children:e.jsxs("div",{className:"space-y-4 p-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"w-full space-y-1",children:[e.jsx(t.Label,{children:"Locale"}),e.jsxs(t.Select,{value:r||"none",onValueChange:u=>{var C,p,y;return n(((C=s==null?void 0:s.formatNumber)==null?void 0:C.decimalPlaces)||0,((p=s==null?void 0:s.formatNumber)==null?void 0:p.currency)||"",u,((y=s==null?void 0:s.formatNumber)==null?void 0:y.suffix)||"")},children:[e.jsx(t.SelectTrigger,{className:"col-span-6 h-8 w-full focus:ring-1 focus:ring-offset-0",children:e.jsx(t.SelectValue,{})}),e.jsx(t.SelectContent,{children:e.jsxs(t.SelectGroup,{children:[e.jsx(t.SelectLabel,{children:"Format"}),e.jsx(t.SelectItem,{value:"none",children:"None"},"none"),t.LOCALE_CURRENCY_PAIRS.map(u=>e.jsx(t.SelectItem,{value:u.locale,children:u.locale},u.locale))]})})]})]}),e.jsxs("div",{className:"w-full space-y-1",children:[e.jsx(t.Label,{children:"Currency"}),e.jsxs(t.Select,{value:o||"none",onValueChange:u=>{var C,p,y;console.log("currency",u),n(((C=s==null?void 0:s.formatNumber)==null?void 0:C.decimalPlaces)||0,u==="none"?"":u,((p=s==null?void 0:s.formatNumber)==null?void 0:p.locale)||"",((y=s==null?void 0:s.formatNumber)==null?void 0:y.suffix)||"")},children:[e.jsx(t.SelectTrigger,{className:"col-span-6 h-8 w-full focus:ring-1 focus:ring-offset-0",children:e.jsx(t.SelectValue,{})}),e.jsx(t.SelectContent,{children:e.jsxs(t.SelectGroup,{children:[e.jsx(t.SelectLabel,{children:"Currency"}),e.jsx(t.SelectItem,{value:"none",children:"None"},"none"),l.map(u=>e.jsx(t.SelectItem,{value:u,children:u},u))]})})]})]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("div",{className:"w-full space-y-1",children:[e.jsx(t.Label,{children:"Decimals"}),e.jsxs(t.Select,{value:((x=(m=s==null?void 0:s.formatNumber)==null?void 0:m.decimalPlaces)==null?void 0:x.toString())||"0",onValueChange:u=>{var C,p,y;return n(Number(u),((C=s==null?void 0:s.formatNumber)==null?void 0:C.currency)||"",((p=s==null?void 0:s.formatNumber)==null?void 0:p.locale)||"",((y=s==null?void 0:s.formatNumber)==null?void 0:y.suffix)||"")},children:[e.jsx(t.SelectTrigger,{className:"col-span-3 h-8 w-full focus:ring-1 focus:ring-offset-0",children:e.jsx(t.SelectValue,{})}),e.jsx(t.SelectContent,{children:["0","1","2","3","4"].map(u=>e.jsx(t.SelectItem,{value:u,children:u},u))})]})]}),e.jsxs("div",{className:"w-full space-y-1",children:[e.jsx(t.Label,{children:"Suffix"}),e.jsx(t.Input,{value:((f=s==null?void 0:s.formatNumber)==null?void 0:f.suffix)||"",className:"h-8 font-mono text-xs focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0",placeholder:"K, M, B, %",onChange:u=>{var C,p,y;return n(((C=s==null?void 0:s.formatNumber)==null?void 0:C.decimalPlaces)||0,((p=s==null?void 0:s.formatNumber)==null?void 0:p.currency)||"",((y=s==null?void 0:s.formatNumber)==null?void 0:y.locale)||"",u.target.value)}})]})]})]})}),e.jsx(t.Separator,{className:"my-3"}),e.jsx(t.ColorFormat,{colorRanges:c,setColorRanges:i})]})]})}function na(){return e.jsxs("div",{className:"space-y-6 px-6 py-2",children:[e.jsx(t.Accordion,{type:"single",collapsible:!0,children:e.jsxs(t.AccordionItem,{value:"item-1",children:[e.jsx(t.AccordionTrigger,{className:"",children:"KPI Query"}),e.jsxs(t.AccordionContent,{className:"font-mono",children:[e.jsx("div",{className:"rounded bg-muted px-2 py-1 font-mono text-xs",children:"SELECT current, previous FROM table"}),e.jsxs("ul",{className:"my-6 ml-6 list-disc text-xs [&>li]:mt-2",children:[e.jsx("li",{children:"current - number"}),e.jsx("li",{children:"previous - number"})]}),e.jsxs("div",{children:["See ",e.jsx("a",{target:"_blank",onClick:s=>s.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/docs/charts/kpi",children:"example"})," in the docs."]})]})]})}),e.jsx("section",{className:"",children:e.jsx(sa,{})}),e.jsx("div",{}),e.jsx("div",{})]})}function Le({children:s,summary:a,open:n,className:r}){return e.jsxs("details",{open:n,className:t.cn("space-y-4 [&_summary>svg]:open:-rotate-180",r),children:[e.jsxs("summary",{className:"flex cursor-pointer list-none items-center justify-between gap-4",children:[e.jsx(t.Label,{children:a}),e.jsx(t.ChevronUp,{className:"h-4 w-4"})]}),e.jsx("div",{className:"transition-all ease-in-out",children:s})]})}const aa=[{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"}],ra=["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"],oa=ra.map(s=>({label:s,value:s}));function ia(){var d,h,m,x,f,u,C,p,y,g,S,b,I,N,T,_,R,U;const s=t.useEditorStore(w=>w.card),a=(h=(d=s==null?void 0:s.preferences)==null?void 0:d.mapVisualOptions)==null?void 0:h.topoJsonUrl,[n,r]=E.useState(((x=(m=s==null?void 0:s.preferences)==null?void 0:m.mapVisualOptions)==null?void 0:x.customTopoJsonUrl)||""),{setCardPreferences:o}=t.useEditorActions(),{data:c}=t.useTopoJson(s),i=Object.keys((c==null?void 0:c.objects)||{}).map(w=>({label:w,value:w}))||[],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.jsxs("div",{className:"p-6",children:[e.jsx(Le,{summary:"Map Chart",children:e.jsx("p",{className:"rounded-md bg-muted p-2 font-mono text-xs",children:"SELECT country, value FROM table"})}),e.jsx(t.Separator,{className:"my-4"}),e.jsx(Le,{open:!0,summary:"Settings",children:e.jsxs("div",{className:"space-y-3 px-2",children:[e.jsx(ee,{className:"h-9",options:l,onValueChange:w=>{console.log("value",w),o({...s.preferences,mapVisualOptions:{topoJsonUrl:w}})},value:a||"",label:"Select Map"}),a==="custom"&&e.jsx(t.Input,{onChange:w=>{r(w.target.value)},onBlur:()=>{var w;console.log("onBlur",n),o({...s.preferences,mapVisualOptions:{...(w=s.preferences)==null?void 0:w.mapVisualOptions,customTopoJsonUrl:n}})},value:n,className:`h-9 w-full ${t.removeRing}`,placeholder:"Custom URL"}),c&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(t.Label,{children:"Map Object"}),e.jsx(ee,{className:"h-9",options:i,value:((u=(f=s.preferences)==null?void 0:f.mapVisualOptions)==null?void 0:u.objectKey)||"",label:"Map Object",onValueChange:w=>{var V;o({...s.preferences,mapVisualOptions:{...(V=s.preferences)==null?void 0:V.mapVisualOptions,objectKey:w}})}})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(t.Label,{children:"Projection"}),e.jsx(ee,{className:"h-9",options:aa,value:((p=(C=s.preferences)==null?void 0:C.mapVisualOptions)==null?void 0:p.projection)||"",label:"Projection",onValueChange:w=>{var V;o({...s.preferences,mapVisualOptions:{...(V=s.preferences)==null?void 0:V.mapVisualOptions,projection:w}})}})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(t.Label,{children:"Colors"}),e.jsx(ee,{className:"h-9",options:oa,value:((g=(y=s.preferences)==null?void 0:y.mapVisualOptions)==null?void 0:g.colorScale)||"",label:"Select Color Scale",onValueChange:w=>{var V;o({...s.preferences,mapVisualOptions:{...(V=s.preferences)==null?void 0:V.mapVisualOptions,colorScale:w}})}})]})]})]})}),e.jsx(t.Separator,{className:"my-4"}),e.jsx(Le,{className:"",summary:"Scale Options",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(t.Input,{className:`h-9 w-full ${t.removeRing}`,type:"number",step:.1,value:((b=(S=s.preferences)==null?void 0:S.mapVisualOptions)==null?void 0:b.projectionScale)||1,onChange:w=>{var V;o({...s.preferences,mapVisualOptions:{...(V=s.preferences)==null?void 0:V.mapVisualOptions,projectionScale:Number(w.target.value)}})}}),e.jsx(t.Label,{children:"X"}),e.jsx(t.Input,{className:`h-9 w-full ${t.removeRing}`,type:"number",step:10,value:((T=(N=(I=s.preferences)==null?void 0:I.mapVisualOptions)==null?void 0:N.projectionOffset)==null?void 0:T[0])||0,onChange:w=>{var V,$,q,j;o({...s.preferences,mapVisualOptions:{...(V=s.preferences)==null?void 0:V.mapVisualOptions,projectionOffset:[Number(w.target.value),((j=(q=($=s.preferences)==null?void 0:$.mapVisualOptions)==null?void 0:q.projectionOffset)==null?void 0:j[1])||0]}})}}),e.jsx(t.Label,{children:"Y"}),e.jsx(t.Input,{className:`h-9 w-full ${t.removeRing}`,type:"number",step:10,value:((U=(R=(_=s.preferences)==null?void 0:_.mapVisualOptions)==null?void 0:R.projectionOffset)==null?void 0:U[1])||0,onChange:w=>{var V,$,q,j;o({...s.preferences,mapVisualOptions:{...(V=s.preferences)==null?void 0:V.mapVisualOptions,projectionOffset:[((j=(q=($=s.preferences)==null?void 0:$.mapVisualOptions)==null?void 0:q.projectionOffset)==null?void 0:j[0])||0,Number(w.target.value)]}})}})]})}),e.jsx(t.Separator,{className:"my-4"}),e.jsx(oe,{})]})}function la(){var r;const s=t.useEditorStore(o=>o.card.preferences),{setCardPreferences:a}=t.useEditorStore(o=>o.actions);function n(o){a({...s,textVisualOptions:{...s==null?void 0:s.textVisualOptions,isDynamicText:o==="dynamic"}})}return e.jsxs(t.RadioGroup,{value:(r=s==null?void 0:s.textVisualOptions)!=null&&r.isDynamicText?"dynamic":"static",onValueChange:n,className:"flex gap-3",defaultValue:"x",children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(t.RadioGroupItem,{value:"static",id:"r1"}),e.jsx("label",{className:"text-sm",htmlFor:"r1",children:"Static"})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(t.RadioGroupItem,{value:"dynamic",id:"r2"}),e.jsx("label",{className:"text-sm",htmlFor:"r2",children:"Dynamic"})]})]})}function be({cardType:s,docContent:a,suffix:n="Chart"}){return e.jsx("div",{className:"space-y-6 px-6 py-2",children:e.jsxs(t.Accordion,{defaultValue:["item-2"],type:"multiple",children:[e.jsxs(t.AccordionItem,{value:"item-1",children:[e.jsx(t.AccordionTrigger,{children:`${t.titleCase(s)} ${n}`}),e.jsx(t.AccordionContent,{children:a||e.jsxs("div",{className:"space-y-4 font-mono text-xs",children:[e.jsx("div",{className:"rounded bg-muted px-2 py-1 text-xs",children:"SELECT label, measure FROM table"}),e.jsxs("ul",{className:"ml-6 list-disc text-xs [&>li]:mt-2",children:[e.jsx("li",{children:"label - category"}),e.jsx("li",{children:"measure - number"})]}),e.jsxs("div",{children:["See ",e.jsx("a",{target:"_blank",onClick:r=>r.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/docs/charts/pie-donut-polar",children:"example"})," in the docs."]})]})})]}),e.jsxs(t.AccordionItem,{value:"item-2",children:[e.jsx(t.AccordionTrigger,{children:"Settings"}),e.jsxs(t.AccordionContent,{className:"space-y-4 px-2",children:[s!=="text"&&e.jsx(Je,{}),s==="text"&&e.jsx(la,{})]})]}),!["range","text"].includes(s)&&e.jsxs(t.AccordionItem,{value:"item-3",children:[e.jsx(t.AccordionTrigger,{children:"Filters"}),e.jsxs(t.AccordionContent,{className:"space-y-4 px-2",children:[e.jsx(oe,{}),e.jsx(pe,{})]})]})]})})}function ca(){const s=t.useEditorStore(r=>{var o,c;return(c=(o=r==null?void 0:r.card)==null?void 0:o.preferences)==null?void 0:c.sortChart}),{setSortChart:a}=t.useEditorActions();function n(){return e.jsxs("div",{className:"space-y-2",children:[e.jsx(t.Label,{children:"Sort"}),e.jsx(ee,{className:"h-8",label:"Sort Chart",options:[{label:"None",value:"none"},{label:"ASC",value:"asc"},{label:"DESC",value:"desc"}],value:s||"none",onValueChange:r=>{a(r)}})]})}return e.jsx("div",{className:"space-y-6 px-6 py-2",children:e.jsxs(t.Accordion,{defaultValue:["item-2"],type:"multiple",children:[e.jsxs(t.AccordionItem,{value:"item-1",children:[e.jsx(t.AccordionTrigger,{children:"Stacked Chart"}),e.jsxs(t.AccordionContent,{className:"space-y-4 font-mono text-xs",children:[e.jsx("div",{className:"rounded bg-muted px-2 py-1 text-xs",children:"SELECT x-axis, stack-by, y-axis FROM table"}),e.jsxs("ul",{className:"ml-6 list-disc text-xs [&>li]:mt-2",children:[e.jsx("li",{children:"x-axis - category"}),e.jsx("li",{children:"stack by - category"}),e.jsx("li",{children:"y-axis - number"})]}),e.jsxs("div",{children:["See ",e.jsx("a",{target:"_blank",onClick:r=>r.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/docs/charts/stacked",children:"example"})," in the docs."]})]})]}),e.jsxs(t.AccordionItem,{value:"item-2",children:[e.jsx(t.AccordionTrigger,{children:"Settings"}),e.jsxs(t.AccordionContent,{className:"space-y-4 px-2",children:[n(),e.jsx(Jt,{})]})]}),e.jsxs(t.AccordionItem,{value:"item-3",children:[e.jsx(t.AccordionTrigger,{children:"Filters"}),e.jsxs(t.AccordionContent,{className:"space-y-4 px-2",children:[e.jsx(oe,{}),e.jsx(pe,{})]})]})]})})}function da({cardType:s="table"}){console.log("cardType",s);const a=t.useEditorStore(o=>{var c;return(c=o.card)==null?void 0:c.preferences}),n=t.useEditorStore(o=>o.actions.setCardPreferences),r=o=>{n({...a,allowDownload:o})};return e.jsxs("div",{className:"space-y-6 px-6 py-2",children:[e.jsx(t.Accordion,{defaultValue:["item-3"],type:"multiple",children:e.jsxs(t.AccordionItem,{value:"item-3",children:[e.jsx(t.AccordionTrigger,{children:"Filters"}),e.jsxs(t.AccordionContent,{className:"space-y-4 px-2",children:[e.jsx(oe,{}),e.jsx(pe,{})]})]})}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(t.Checkbox,{onCheckedChange:r,id:"allow-download"}),e.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 ua=e.jsxs("div",{className:"space-y-4 font-mono text-xs",children:[e.jsx("div",{className:"rounded bg-muted px-2 py-1 text-xs",children:"SELECT dimension, cohort, metric FROM table"}),e.jsxs("div",{children:["See ",e.jsx("a",{target:"_blank",onClick:s=>s.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/docs/charts/tornado",children:"example"})," in the docs."]})]}),ma=e.jsxs("div",{className:"space-y-4 font-mono text-xs",children:[e.jsx("div",{className:"rounded bg-muted px-2 py-1 text-xs",children:"SELECT y-axis, label, range-from, range-to, range-value FROM table"}),e.jsxs("div",{children:["See ",e.jsx("a",{target:"_blank",onClick:s=>s.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/docs/charts/range",children:"example"})," in the docs."]})]}),ha=e.jsxs("div",{className:"space-y-4 font-mono text-xs",children:[e.jsx("div",{className:"rounded bg-muted px-2 py-1 text-xs",children:"SELECT text FROM table limit 1"}),e.jsxs("div",{children:["See ",e.jsx("a",{target:"_blank",onClick:s=>s.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/docs/charts/text",children:"example"})," in the docs."]})]});function pa(){const s=t.useEditorStore(n=>n.card.type);function a(n){switch(n){case"stackedBar":case"stackedLine":return e.jsx(ca,{});case"pyramid":return e.jsx(be,{docContent:ua,cardType:n});case"kpi":return e.jsx(na,{});case"line":case"bar":return e.jsx(Wn,{cardType:n});case"range":return e.jsx(be,{docContent:ma,cardType:n});case"pie":case"doughnut":case"polarArea":case"radar":return e.jsx(be,{cardType:n});case"bubble":case"scatter":return e.jsx(Yn,{cardType:n});case"table":return e.jsx(da,{cardType:n});case"text":return e.jsx(be,{docContent:ha,cardType:n,suffix:"Visual"});case"map":return e.jsx(ia,{});case"custom":return e.jsx($n,{});default:return e.jsx(ea,{})}}return e.jsxs(t.ScrollArea,{className:"h-full w-full text-sm",children:[a(s),e.jsx(t.ScrollBar,{orientation:"horizontal"})]})}function Yt({label:s,column:a,functions:n,onFunctionChange:r}){let o=n[0];"aggregate"in a?o=n.find(i=>i.value===a.aggregate)||n[0]:"granularity"in a&&(o=n.find(i=>i.value===a.granularity)||n[0]);function c(i){r(i)}return e.jsx(ee,{className:"flex h-8 w-8 justify-center overflow-clip rounded-none border-none bg-muted px-0 [&>svg]:hidden",icon:o.logo,options:n,value:o.value,onValueChange:i=>c(i),label:s,showPlaceholderLabel:!1})}const xa=[{label:"Sum",value:"SUM",logo:e.jsx(St,{className:"size-3.5"})},{label:"Count",value:"COUNT",logo:e.jsx(ft,{className:"size-3.5"})},{label:"Unique",value:"DISTINCT",logo:e.jsx(Es,{className:"size-3.5"})},{label:"Average",value:"AVG",logo:e.jsx(ls,{className:"size-3.5"})},{label:"Min",value:"MIN",logo:e.jsx(rs,{className:"size-3.5"})},{label:"Max",value:"MAX",logo:e.jsx(hs,{className:"size-3.5"})}];function fa({column:s}){const{updateMetricColumn:a}=t.useEditorActions();let n=xa;t.isTextDataType(s.type)&&(n=n.filter(o=>["COUNT","DISTINCT"].includes(o.value))),t.isNumberDataType(s.type)&&(n=n.filter(o=>!["DISTINCT"].includes(o.value)));function r(o){const c={...s,aggregate:o,label:fe(s.name,o)};a(s.id,c)}return e.jsx(Yt,{column:s,functions:n,onFunctionChange:o=>r(o),label:"Aggregation"})}const ga=[{label:"Day (D)",value:"day",logo:e.jsx(t.Label,{className:"cursor-pointer text-xs",children:"D"})},{label:"Week (W)",value:"week",logo:e.jsx(t.Label,{className:"cursor-pointer text-xs",children:"W"})},{label:"Month (M)",value:"month",logo:e.jsx(t.Label,{className:"cursor-pointer text-xs",children:"M"})},{label:"Year (Y)",value:"year",logo:e.jsx(t.Label,{className:"cursor-pointer text-xs",children:"Y"})}];function ja({column:s}){const{updateTrendByColumn:a}=t.useEditorActions();function n(r){const o={...s,granularity:r,label:Tt(s.name,r)};a(s.id,o)}return e.jsx(Yt,{column:s,functions:ga,onFunctionChange:r=>n(r),label:"Granularity"})}function ya({col:s,onChange:a,droppableId:n}){const{columns:r}=$e(),o=E.useMemo(()=>{let l=[];n===me&&(l=(r==null?void 0:r.filter(h=>t.isDateDataType(h.data_type)))||[]),(n===de||n===ue)&&(l=r);const d=l==null?void 0:l.filter(h=>h.column_name!==s.name);return d==null?void 0:d.map(h=>({id:h.column_name,value:h.column_name}))},[r,n,s.name]),c=[{id:s.name,value:s.name}];function i(l){const d=r==null?void 0:r.find(h=>{var m;return h.column_name===((m=l[0])==null?void 0:m.id)});d&&a(d)}return o!=null&&o.length?e.jsx(t.ComboBox2,{multiple:!1,options:o,selectedOptions:c,onChange:i,selectAllChecked:!1,onSelectAllCheckedChange:()=>{},inputClassName:"border-none bg-muted px-0"}):e.jsx("input",{disabled:!0,type:"text",className:"overflow-hidden truncate text-ellipsis whitespace-nowrap bg-muted text-sm",value:s.name})}function ba({column:s,type:a,onRemoveColumn:n,droppableId:r}){const[o,c]=E.useState(!1),{updateGroupByColumn:i,updateMetricColumn:l,updateTrendByColumn:d}=t.useEditorActions(),{attributes:h,listeners:m,setNodeRef:x,transform:f,transition:u,isDragging:C}=t.useSortable({id:s.id,data:{type:a}}),p=f?{opacity:C?.5:void 0,transform:t.CSS.Translate.toString(f),transition:u}:void 0;function y(N){const T=t.isNumberDataType(N.data_type),_=t.isTextDataType(N.data_type),R=t.isDateDataType(N.data_type),U=T?"number":_?"string":R?"date":"string";if(r===de){const w={id:s.id,name:N.column_name,type:U,role:"groupby"};i(s.id,w)}if(r===ue){const w={id:s.id,name:N.column_name,type:U,role:"metric",label:fe(N.column_name,"SUM"),aggregate:T?"SUM":"COUNT"};l(s.id,w)}if(r===me&&R){const w={id:s.id,name:N.column_name,type:U,role:"trendby",label:Tt(N.column_name,"month"),granularity:"month"};d(s.id,w)}}function g(){return e.jsx("div",{"data-setting-container":"",className:"mt-1.5 h-32 rounded-md border border-border p-3 text-sm",children:e.jsx(e.Fragment,{})})}function S(){if(r===ue)return e.jsx(fa,{column:s});if(r===me)return e.jsx(ja,{column:s})}function b(){return e.jsx("div",{className:t.cn("grow",{"pl-3":r===de}),children:e.jsx(ya,{col:s,onChange:y,droppableId:r})})}function I(){return e.jsx("div",{"data-setting-actions":"",className:"flex h-full items-center gap-2",children:e.jsx("button",{onClick:()=>c(!o),children:o?e.jsx(Ks,{className:t.cn("size-3 cursor-pointer items-center justify-center rounded-r-sm text-muted-foreground")}):e.jsx(pt,{className:t.cn("size-3 cursor-pointer items-center justify-center rounded-r-sm text-muted-foreground")})})})}return e.jsx("div",{...m,...h,ref:x,style:p,children:e.jsxs("div",{className:"group flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"grow",children:[e.jsxs("div",{className:"flex h-8 grow items-center justify-between rounded-md bg-muted pl-2",children:[I(),S(),b()]}),o&&g()]}),e.jsx("div",{className:t.cn("opacity-0 transition-opacity duration-200 group-hover:opacity-100",{hidden:o}),children:e.jsx("button",{onClick:()=>n(s.id),children:e.jsx(t.X,{className:"size-3 cursor-pointer text-muted-foreground"})})})]})})}function Oe({id:s,label:a,columns:n,previewColumns:r,sortableType:o,onRemoveColumn:c}){const{setNodeRef:i}=t.useDroppable({id:s}),l=t.useDndStore(m=>m.activeId),d={},h=l?r:n;return e.jsx(t.SortableContext,{items:n==null?void 0:n.map(m=>m.id),children:e.jsxs("div",{className:"space-y-2 rounded-md border-2 border-dashed p-4",ref:i,style:d,children:[e.jsx(t.Label,{className:"text-sm",children:a}),e.jsx("div",{className:"space-y-2",children:h==null?void 0:h.map(m=>m.id===Et.id?e.jsx(Sa,{},m.id):e.jsx(ba,{droppableId:s,type:o,column:m,onRemoveColumn:c},m.id))})]})})}function Sa(){return e.jsx("div",{className:"flex h-7 grow items-center space-x-2 rounded-md border border-dashed border-muted-foreground bg-background px-2 py-1 text-sm"})}function Zt({children:s,id:a,type:n}){const{attributes:r,listeners:o,setNodeRef:c,transform:i,transition:l,isDragging:d}=t.useSortable({id:a,data:{type:n}}),h=i?{opacity:d?.5:void 0,transform:t.CSS.Translate.toString(i),transition:l}:void 0;return e.jsx("div",{...o,...r,ref:c,style:h,children:s})}function Ca(){const s=t.useEditorStore(S=>{var b;return(b=S.card.queryConfig)==null?void 0:b.orderBy})||[],a=t.useEditorStore(S=>{var b;return(b=S.card.queryConfig)==null?void 0:b.groupByColumns})||[],n=t.useEditorStore(S=>{var b;return(b=S.card.queryConfig)==null?void 0:b.trendByColumns})||[],r=t.useEditorStore(S=>{var b;return(b=S.card.queryConfig)==null?void 0:b.metricColumns})||[],o=[...a,...n,...r],c=e.jsx(ms,{className:"size-3.5 text-muted-foreground hover:text-foreground"}),i=e.jsx(os,{className:"size-3.5 text-muted-foreground hover:text-foreground"}),l=e.jsx(us,{className:"size-3.5 text-muted-foreground hover:text-foreground"}),d=e.jsx(as,{className:"size-3.5 text-muted-foreground hover:text-foreground"}),{addOrderByColumn:h,removeOrderByColumn:m,updateOrderByColumn:x}=t.useEditorActions(),f=o==null?void 0:o.filter(S=>!s.some(b=>b.columnId===S.id)).map(S=>({id:S.id,value:S.label||S.name}));function u(S,b){const I=C(S);return I?I.role==="metric"?b==="asc"?l:d:b==="asc"?c:i:null}function C(S){return o.find(b=>b.id===S)}function p(S){const b=s.find(I=>I.columnId===S);if(b){const I={...b,direction:b.direction==="asc"?"desc":"asc"};x(I)}}const y=S=>{h({columnId:S.id,direction:"asc"})};function g(S){const b=s.find(I=>I.columnId===S);b&&m(b)}return e.jsx(t.SortableContext,{items:s.map(S=>xe(S.columnId)),children:e.jsxs("div",{className:"space-y-2 rounded-md border border-border p-4 text-sm",children:[e.jsx(t.Label,{className:"text-sm",children:"Order by"}),e.jsx("div",{className:"mr-5",children:e.jsx(t.ComboBox2,{multiple:!1,options:f,selectedOptions:[],onChange:S=>y(S[0]),selectAllChecked:!1,onSelectAllCheckedChange:()=>{},inputClassName:"h-8"})}),s.map(S=>{var b,I;return e.jsx(Zt,{id:xe(S.columnId),type:Qe,children:e.jsx("div",{className:"group flex h-8 items-center gap-2 rounded-sm p-0",children:e.jsxs("div",{className:"flex h-full grow items-center justify-between gap-2",children:[e.jsxs("div",{className:"flex h-full grow items-center justify-between gap-2 rounded-sm bg-muted px-2",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(pt,{className:"size-3 cursor-move text-muted-foreground hover:text-foreground"}),e.jsx("span",{className:"text-sm",children:((b=C(S.columnId))==null?void 0:b.label)||((I=C(S.columnId))==null?void 0:I.name)})]}),e.jsx("button",{title:S.direction==="asc"?"Ascending":"Descending",onClick:()=>p(S.columnId),className:"rounded-sm p-0",children:u(S.columnId,S.direction)})]}),e.jsx("div",{children:e.jsx("button",{onClick:()=>g(S.columnId),className:"rounded-sm p-0",children:e.jsx(t.X,{className:"size-3 text-muted-foreground opacity-0 transition-opacity duration-200 hover:text-foreground group-hover:opacity-100"})})})]})},S.columnId)},xe(S.columnId))})]})})}function ot(){const s=t.useEditorStore(y=>{var g;return((g=y.card.queryConfig)==null?void 0:g.groupByColumns)||[]}),a=t.useEditorStore(y=>y.card.type),n=t.useDndStore(y=>y.previewGroupByColumns),r=t.useEditorStore(y=>{var g;return((g=y.card.queryConfig)==null?void 0:g.metricColumns)||[]}),o=t.useDndStore(y=>y.previewMetricColumns),c=t.useEditorStore(y=>{var g;return((g=y.card.queryConfig)==null?void 0:g.trendByColumns)||[]}),i=t.useDndStore(y=>y.previewTrendByColumns),{removeColumnFromGroupBy:l,removeColumnFromMetricColumns:d,removeColumnFromTrendByColumns:h}=t.useEditorActions();function m(y){l(y)}function x(y){h(y)}function f(y){d(y)}let u="Group By",C="Trend By",p="Metrics";return a==="table"&&(u="Rows",C="Rows (Date)",p="Values"),e.jsxs("div",{className:"h-full w-full space-y-4 p-4",children:[e.jsx(Qt,{iconClassName:"size-[19px]"}),e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsx(Oe,{onRemoveColumn:m,sortableType:Fe,id:de,label:u,columns:s,previewColumns:n}),e.jsx(Oe,{onRemoveColumn:x,sortableType:Be,id:me,label:C,columns:c,previewColumns:i}),e.jsx(Oe,{onRemoveColumn:f,sortableType:Re,id:ue,label:p,columns:r,previewColumns:o}),e.jsx(Ca,{})]})]})}function Ke({children:s,column:a,id:n,sortableType:r,className:o}){const[c,i]=E.useState(!1),{removeEditorFilter:l}=t.useEditorActions();function d(h){l(h)}return e.jsx(Zt,{id:n,type:r,children:e.jsxs("div",{className:t.cn("group space-y-1 rounded-md bg-muted px-3 py-2",{"border-border":c}),children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(t.Label,{className:"text-sm",children:a.name}),e.jsx("div",{"data-setting-actions":"",className:"invisible flex h-full items-center gap-2 group-hover:visible",children:e.jsx("button",{onClick:()=>d(a),children:e.jsx(t.X,{className:"size-3.5 cursor-pointer items-center justify-center rounded-r-sm text-muted-foreground"})})})]}),e.jsxs("div",{className:t.cn("group flex items-center rounded-t-md text-sm",!c&&"rounded-b-md",c&&"border border-border"),children:[e.jsx("div",{children:e.jsx(t.GripVertical,{className:"mr-2 size-3.5 cursor-move items-center justify-center p-0 text-muted-foreground/60 hover:text-foreground"})}),e.jsx("div",{className:t.cn("grow cursor-pointer overflow-hidden truncate text-ellipsis whitespace-nowrap",o),children:s})]})]})})}function va({column:s,sortableType:a}){const n=t.useDashboardStore(S=>S.themeStyle),r=t.useEditorStore(S=>{var b,I;return(I=(b=S.card)==null?void 0:b.queryConfig)==null?void 0:I.filters}),{selectedConnectionId:o,selectedDatabaseName:c,selectedTableName:i}=te(),l=E.useMemo(()=>{var S;return(S=r==null?void 0:r.find(b=>b.filterColumnName===s.name))==null?void 0:S.filterValue},[r,s.name]),d=E.useMemo(()=>Array.isArray(l)?l.map(S=>({id:S,value:S})):[],[l]),{updateEditorFilterValue:h}=t.useEditorActions(),m={column:s.name,sql:s.sql,id:s.name,connectionId:o,dataType:s.type},{data:x,isLoading:f,isFetching:u,isError:C}=t.useFilterQuery(m),p=E.useMemo(()=>{var b;return m.column?(b=x==null?void 0:x.records)==null?void 0:b.map(I=>{let N=m.column.split(".").slice(-1)[0].replace(/"/g,"");return I[N]===void 0&&(N=N.toLowerCase()),{id:I[N],value:I[N]}}):[]},[x,m.column]);function y(S){const b=S.map(I=>I.id);h(s.name,b)}function g(){return f||u?e.jsx(t.Skeleton,{style:{borderRadius:n==null?void 0:n.controlInputRadius},className:"h-8 min-w-60 bg-foreground/10"}):C?e.jsx("div",{className:"flex h-8 min-w-60 items-center bg-muted px-2 text-sm",children:"Error"}):e.jsx(t.ComboBox2,{options:p,onChange:y,selectedOptions:d,selectAllChecked:!1,onSelectAllCheckedChange:()=>{}})}return e.jsx(Ke,{className:"w-60",id:s.id,sortableType:a,column:s,children:g()})}function Na({column:s,sortableType:a}){const[n,r]=E.useState(!1),{selectedConnectionId:o,selectedDatabaseName:c,selectedTableName:i}=te(),l={column:s.name,sql:s.sql,id:s.name,connectionId:o,title:"",dataType:s.type},{isLoading:d,isFetching:h,isError:m,data:x}=t.useFilterQuery(l),f=x==null?void 0:x.records,{dateRange:u,setDateRange:C,initialDateRange:p}=t.useDateRangeFromRecords(f),{updateEditorFilterValue:y}=t.useEditorActions();function g(I){var T,_;const N={gte:(T=I==null?void 0:I.from)==null?void 0:T.toISOString(),lte:(_=I==null?void 0:I.to)==null?void 0:_.toISOString()};y(s.name,N)}function S(){y(s.name,null,!0),C(p)}function b(){return d||h?e.jsx("div",{children:e.jsx(t.Skeleton,{className:"h-8 w-72 bg-foreground/10"})}):m?e.jsx("div",{className:"h-8 w-72 bg-muted px-2",children:"Error"}):f?e.jsx(t.DateRangePopover,{title:l.title,open:n,inputClassName:"h-8",setOpen:r,dateRange:u,setDateRange:C,onApply:g,onClear:S}):e.jsx(t.Label,{className:"flex h-8 w-72 items-center bg-muted px-2",children:"No Data"})}return e.jsx(Ke,{className:"w-72",id:s.id,sortableType:a,column:s,children:b()})}function wa({id:s,label:a,columns:n,previewColumns:r,sortableType:o}){const{setNodeRef:c}=t.useDroppable({id:s}),i=t.useDndStore(m=>m.activeId),l={};function d(m){const x=t.isDateDataType(m.type);return m.id===Et.id?e.jsx(Ke,{id:m.id,sortableType:o,column:m,children:e.jsx(ka,{})},m.id):x?e.jsx(Na,{droppableId:s,sortableType:o,column:m},m.id):e.jsx(va,{droppableId:s,sortableType:o,column:m},m.id)}const h=i?r:n;return e.jsx(t.SortableContext,{items:n==null?void 0:n.map(m=>m.id),children:e.jsxs("div",{className:"space-y-2 rounded-md border-2 border-dashed p-5",ref:c,style:l,children:[e.jsx(t.Label,{className:"text-sm",children:a}),e.jsx("div",{className:"flex flex-wrap items-center gap-4",children:h==null?void 0:h.map(m=>d(m))})]})})}function ka(){return e.jsx("div",{className:"flex h-8 w-60 items-center space-x-2 rounded-md border border-dashed border-muted-foreground bg-background px-2 py-1 text-sm"})}function Ia(){const s=t.useEditorStore(o=>{var c;return((c=o.card.queryConfig)==null?void 0:c.filterColumns)||[]}),a=t.useDndStore(o=>o.previewFilterColumns),{removeColumnFromFilterColumns:n}=t.useEditorActions();function r(o){n(o)}return e.jsx("section",{className:"size-full px-4 pb-4",children:e.jsx(wa,{onRemoveColumn:r,sortableType:Ve,id:_e,label:"Filters",columns:s,previewColumns:a})})}function Da(){const s=t.useEditorStore(r=>r.card),{data:a,errorMessage:n}=t.useDashboardCardQuery(s);return e.jsxs("section",{className:"flex justify-between gap-2 p-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(_t,{}),e.jsx(At,{sql:a==null?void 0:a.sql,error:n})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Bt,{}),e.jsx(Rt,{variant:"default"})]})]})}function Ea(){const s=E.useRef(null),a=t.useEditorStore(i=>i.isShowingVisual),n=t.useEditorStore(i=>i.showAIDialog),r=t.useEditorStore(i=>i.isDevMode);E.useEffect(()=>{var i,l;n?(i=s.current)==null||i.resize(0):(l=s.current)==null||l.resize(25)},[n]);function o(){return e.jsxs(e.Fragment,{children:[e.jsx(t.ResizablePanel,{role:"query-section",className:"flex",minSize:20,defaultSize:40,children:e.jsx(Dn,{})}),e.jsx(t.ResizableHandle,{withHandle:!0,className:"border"}),e.jsx(t.ResizablePanel,{className:"pb-1",role:"visual-section",minSize:0,defaultSize:60,children:a&&!n?e.jsxs(t.ResizablePanelGroup,{direction:"horizontal",children:[e.jsx(e.Fragment,{children:e.jsx(t.ResizablePanel,{ref:s,className:"flex",defaultSize:25,maxSize:30,children:r?e.jsx(pa,{}):e.jsx(ot,{})})}),!n&&e.jsx(t.ResizableHandle,{className:"border"}),e.jsx(t.ResizablePanel,{minSize:40,defaultSize:75,maxSize:100,children:e.jsx(ye,{})})]}):e.jsx(ye,{})})]})}function c(){return e.jsx(e.Fragment,{children:e.jsx(t.ResizablePanel,{className:"pb-1","data-biz-mode-container":"",minSize:0,defaultSize:100,children:a&&!n?e.jsxs(t.ResizablePanelGroup,{direction:"horizontal",children:[e.jsx(e.Fragment,{children:e.jsx(t.ResizablePanel,{ref:s,className:"flex min-w-[320px]",defaultSize:25,maxSize:30,children:e.jsx(ot,{})})}),!n&&e.jsx(t.ResizableHandle,{className:"border"}),e.jsx(t.ResizablePanel,{minSize:40,defaultSize:75,maxSize:100,children:e.jsxs(t.ResizablePanelGroup,{direction:"vertical",children:[e.jsxs(t.ResizablePanel,{className:"flex min-h-fit flex-col",minSize:10,defaultSize:20,children:[e.jsx(Da,{}),e.jsx(Ia,{})]}),e.jsx(t.ResizableHandle,{className:"border"}),e.jsx(t.ResizablePanel,{minSize:20,defaultSize:80,children:e.jsx(ye,{})})]})})]}):e.jsx(ye,{})})})}return e.jsx(t.ResizablePanelGroup,{direction:"vertical",className:"min-h-[250px] min-w-full max-w-lg",children:r?o():c()})}const Ta=[{title:"Help me write a query for",subtitle:"orders by month"},{title:"Create a bar chart for",subtitle:"sales by category"}];function Ma(){const s=E.useRef(null),a=E.useRef(null),[n,r]=E.useState(!1),[o,c]=E.useState(t.isDevEnv),[i,l]=E.useState(!1),d=t.useEditorStore(O=>O.actions.setCardSql),h=t.useEditorStore(O=>O.actions.setRunSql),m=t.useEditorStore(O=>O.showAIDialog),{setShowAIDialog:x}=t.useEditorActions(),{messages:f,setMessages:u,reload:C,append:p,input:y,setInput:g,isLoading:S,handleAddCurrentTableToScope:b,removeFromCurrentSelections:I,currentAssitantScope:N,handleInputChange:T,handleSubmit:_,stop:R,chatStatus:U,toolStatus:w,llmUsage:V,errorMessage:$}=Ft();t.useAssistantScroll({scrollContainerRef:s,inputRef:a,messages:f}),E.useEffect(()=>{var O;m&&((O=a.current)==null||O.focus())},[m]);function q(O){d(O),h(!0)}function j(O){const k={role:"user",content:O.title+" "+O.subtitle};p(k)}function D(){return e.jsxs(t.DropdownMenu,{children:[e.jsx(t.DropdownMenuTrigger,{asChild:!0,children:e.jsx(t.Button,{className:"h-7 p-2",size:"sm",variant:"ghost",children:e.jsx(ht,{className:"size-3.5 text-muted-foreground/70 hover:text-muted-foreground"})})}),e.jsxs(t.DropdownMenuContent,{align:"end",children:[e.jsx(t.DropdownMenuLabel,{children:"Options"}),e.jsx(t.DropdownMenuSeparator,{}),e.jsx(t.DropdownMenuCheckboxItem,{checked:n,onCheckedChange:r,children:"Token Usage"}),e.jsx(t.DropdownMenuCheckboxItem,{checked:o,onCheckedChange:c,children:"Tool Invocations"}),e.jsx(t.DropdownMenuCheckboxItem,{checked:i,onCheckedChange:l,children:"System Message"})]})]})}function M(){return e.jsxs("div",{"data-role":"header",children:[e.jsx("div",{className:"text-lg font-semibold",children:"Assistant"}),N&&N.length>0&&e.jsx("div",{className:"mt-2 flex flex-wrap items-center gap-2",children:N==null?void 0:N.map((O,k)=>e.jsxs("div",{className:"flex items-center gap-2 rounded-md border border-border bg-muted px-2 py-1 text-xs",children:[t.getFormattedTableNameForQuery({schemaName:O.schemaName||"",tableName:O.tableName||"",modelName:O.datamodelName||"",connectionType:O.connectionType||"",databaseName:O.databaseName||""}),e.jsx("button",{onClick:()=>{I(O)},children:e.jsx(t.X,{className:"size-3 text-muted-foreground hover:text-foreground"})})]},k))}),(N==null?void 0:N.length)===0&&e.jsxs("div",{className:"mt-2 flex items-center gap-2",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:"Context: None"}),e.jsxs(t.Button,{className:"h-6 text-xs",size:"sm",variant:"secondary",onClick:b,children:[e.jsx(t.Plus,{className:"mr-2 size-3"}),"Current Table"]})]})]})}const G=(y==null?void 0:y.length)===0&&(f==null?void 0:f.filter(O=>O.role==="user").length)===0;return e.jsxs("div",{"data-role":"editor-assistant",className:"flex h-full w-full flex-col justify-between gap-2 px-6 py-4",children:[e.jsxs("div",{"data-role":"header-section",className:"flex items-start justify-between gap-2",children:[M(),e.jsxs("div",{"data-role":"header-actions",className:"flex items-center",children:[D(),e.jsx(t.Button,{className:"h-7 p-2",size:"sm",variant:"ghost",onClick:()=>{u([]),C()},children:e.jsx(t.RefreshCcw,{className:"size-3.5 text-muted-foreground"})}),e.jsx(t.Button,{className:"h-7 p-2",size:"sm",variant:"ghost",onClick:()=>{x(!1)},children:e.jsx(t.X,{className:"size-4"})})]})]}),e.jsx(t.CustomScrollArea,{ref:s,className:"flex w-full grow basis-0",children:e.jsxs("div",{className:"space-y-4 py-2 pr-3","data-role":"messages",children:[e.jsx(t.PrintMessages,{messages:f,showTools:o,handleRun:q,showSystemMessage:i}),e.jsx(t.ChatStatus,{status:t.getStatus(U,w),isLoading:S})]})}),G&&e.jsx(t.Placeholders,{onClick:j,placeholders:Ta}),e.jsx(t.ChatInput,{onFocus:()=>{b()},stop:R,ref:a,setInput:g,input:y,handleInputChange:T,handleSubmit:_,isLoading:S}),V&&n&&e.jsx("div",{className:"flex h-8 items-center justify-between",children:e.jsxs("div",{className:"text-xs text-muted-foreground",children:["Usage: ",V.promptTokens," prompt tokens,"," ",V.completionTokens," completion tokens,"," ",V.totalTokens," total tokens"]})}),$&&e.jsx("div",{className:"flex items-center justify-between text-xs text-muted-foreground",children:e.jsx("span",{children:$})})]})}function Aa({authToken:s,onSave:a,onClose:n}){const r=E.useRef(null),o=t.useEditorStore(y=>y.showAIDialog),{setAuthToken:c}=t.useDashboardActions(),{setShowAIDialog:i,setOnSave:l,setOnClose:d}=t.useEditorActions(),{handleDragOver:h,handleDragEnd:m,handleDragStart:x,handleDragCancel:f,sensors:u}=hn();E.useEffect(()=>{a&&l(a),n&&d(n)},[a,l,n,d]),E.useEffect(()=>{s&&s.accessToken&&c(s)},[s,c]),E.useEffect(()=>{var y,g;o?((y=r.current)==null||y.resize(40),i(!0)):(i(!1),(g=r.current)==null||g.resize(0))},[o,i]);function C(y){y<1?i(!1):o||i(!0)}function p(){return e.jsxs(t.ResizablePanelGroup,{"data-content":"editor-main",className:"grow",direction:"horizontal",children:[e.jsx(t.ResizablePanel,{className:"min-w-[510px] rounded-none border-x-[1px]",children:e.jsx(Ea,{})}),e.jsx(t.ResizableHandle,{}),e.jsx(t.ResizablePanel,{"data-role":"editor-assistant-panel",ref:r,onResize:C,defaultSize:0,children:e.jsx(Ma,{})})]})}return e.jsx(t.ErrorBoundary,{FallbackComponent:t.Fallback,children:e.jsx(t.DndContext,{sensors:u,onDragStart:x,onDragEnd:m,onDragOver:h,onDragCancel:f,children:e.jsxs("section",{className:"isolate flex h-full grow","data-content":"editor-panel",children:[e.jsx(Mt,{type:"main"}),p()]})})})}function La(){t.useDashboardStore(i=>i.selectedCardId);const s=t.useDashboardStore(i=>i.selectedSheetId),{setIsVisualEditing:a}=t.useDashboardStore(i=>i.actions),n=t.useDashboardStore(i=>i.isVisualEditing),r=t.useDashboardStore(i=>i.actions.updateFrame);function o(i){s&&(r(s,i),a(!1))}function c(){a(!1)}return e.jsx("div",{role:"editor-container",className:t.cn("flex grow",{"max-h-0 overflow-hidden":!n}),children:e.jsx(Aa,{onSave:o,onClose:c})})}function Oa(){const s=t.useEditorStore(c=>c.selectedDatabaseName),a=t.useEditorStore(c=>c.selectedTableName),n=t.useDashboardStore(c=>c.dashboard.filters)||[],{columns:r}=te(),{assignFilter:o}=Wt();return e.jsx(t.ScrollArea,{className:"flex-1 basis-0 flex-col px-3",children:r==null?void 0:r.map(c=>{const i=n==null?void 0:n.find(l=>l.column===t.fmt(c.column_name)&&l.table===a&&l.database===s);return e.jsx("div",{onClick:()=>o(c),className:t.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":i}),children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ue,{column:c}),e.jsx("span",{children:c.column_name})]})},c.column_name)})})}function za(){t.useDashboardStore(a=>a.showFilters);const s=t.useDashboardStore(a=>a.actions.setShowFilters);return e.jsxs("section",{className:"relative flex min-w-[320px] grow flex-col border-l px-1",children:[e.jsxs("div",{className:"mt-4 flex items-center justify-between gap-2 px-3",children:[e.jsx(t.Label,{className:"px-2 text-lg",children:"Filters"}),e.jsx(t.Button,{onClick:()=>s(!1),className:"h-7 w-7 p-0",variant:"ghost",children:e.jsx(t.Cross2Icon,{})})]}),e.jsx("div",{className:"flex grow",children:e.jsx(Mt,{type:"filter",ColumnsComponent:()=>e.jsx(Oa,{})})})]})}function Fa(){const s=t.useDashboardStore(r=>r.dashboard.filters),a=t.useDashboardStore(r=>r.theme),n=s==null?void 0:s.filter(r=>r.hide);return n!=null&&n.length?e.jsx("div",{className:t.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)]":a==="light","bg-[repeating-linear-gradient(45deg,_#18171d_0_3px,_#272729_3px_6px)]":a==="dark"}),children:n==null?void 0:n.map(r=>e.jsxs("div",{className:"flex min-w-[250px] max-w-fit flex-col gap-1 p-2",children:[e.jsx(t.FilterHeader,{filter:r}),e.jsx(t.FilterComponent,{filter:r})]},r.id))}):null}function Ra(){const s=t.useDashboardStore(r=>r.showFilters),a=t.useDashboardStore(r=>r.isVisualEditing),n=t.useDashboardStore(r=>r.isDashboardEditing);return e.jsxs("div",{role:"dashboard-plus-main",className:t.cn("",{"max-h-0 overflow-hidden":a,"flex grow overflow-auto":!a}),children:[e.jsxs("section",{className:"flex grow flex-col",children:[n&&e.jsx(Fa,{}),e.jsx(t.DashboardTabs,{})]}),s&&e.jsx("div",{role:"filter-aside-container",className:"flex",children:e.jsx(za,{})})]})}function Ba(){const s=t.useDashboardStore(o=>o.dashboard),a=t.useDashboardStore(o=>o.actions.setDashboard),n=t.useDashboardStore(o=>o.showDashboardJSON),r=t.useDashboardStore(o=>o.actions.setShowDashboardJSON);return e.jsxs("div",{className:t.cn("relative p-2",{hidden:!n}),children:[e.jsxs(t.Button,{variant:"secondary",size:"sm",className:"absolute right-2 top-2 z-10 h-8",onClick:()=>r(!1),children:[e.jsx(t.X,{className:"mr-2 h-4 w-4"}),"Close"]}),e.jsx(t.de,{onChange:o=>{if(o)try{JSON.parse(o),a(JSON.parse(o))}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 _a({showControls:s=!1,showFooter:a=!0,...n}){return e.jsx(t.ErrorBoundary,{FallbackComponent:t.Fallback,children:e.jsxs(t.SemaphorContextProvider,{dashboardProps:n,children:[e.jsx(t.$e,{}),e.jsxs(t.UXProvider,{children:[e.jsx(Ba,{}),e.jsxs(t.DashboardPanel,{...n,children:[s&&e.jsx(ln,{}),e.jsx(La,{}),e.jsx(Ra,{})]})]})]})})}exports.Dashboard=t.Dashboard;exports.DashboardWC=t.DashboardWC;exports.SemaphorDataProvider=t.SemaphorQueryClient;exports.SemaphorQueryClient=t.SemaphorQueryClient;exports.createSqlGenConfig=t.createSqlGenConfig;exports.fmt=t.fmt;exports.getColumnDataType=t.getColumnDataType;exports.getFilterValueType=t.getFilterValueType;exports.getFormattedTableNameForQuery=t.getFormattedTableNameForQuery;exports.getQualifiedTableName=t.getQualifiedTableName;exports.getSql=t.getSql;exports.invalidateToken=t.invalidateToken;exports.isBooleanDataType=t.isBooleanDataType;exports.isColumnInSqlGen=t.isColumnInSqlGen;exports.isDateDataType=t.isDateDataType;exports.isNumberDataType=t.isNumberDataType;exports.isTextDataType=t.isTextDataType;exports.resolveDataType=t.resolveDataType;exports.resolveDatamodelName=t.resolveDatamodelName;exports.useCard=t.useCard;exports.useDashboardActions=t.useDashboardActions;exports.useDashboardStore=t.useDashboardStore;exports.useDateFilterHook=t.useDateFilterHook;exports.useEditorActions=t.useEditorActions;exports.useEditorStore=t.useEditorStore;exports.useTextFilterHook=t.useTextFilterHook;exports.ScheduleDashboard=It;exports.SelectComponent=le;exports.Surfboard=_a;exports.cleanCard=Nt;exports.downloadPdf=kt;exports.getDashbaordStateWithoutData=Ge;exports.useEditorAside=te;
381
+ `;g(v)}function G(){return e.jsxs(e.Fragment,{children:[r&&e.jsx("div",{className:"relative flex w-1/3 min-w-0 grow overflow-hidden text-xs",role:"editor-filter-container",children:e.jsx("div",{className:"mt-2 w-[99%]",children:e.jsx(In,{jsonString:JSON.stringify(d,null,2)})})}),d&&d.length>0&&e.jsx(t.Button,{variant:"ghost",onClick:()=>o(!r),className:"absolute bottom-0 right-6 size-7 p-1",children:r?e.jsx(t.X,{className:"size-3.5 text-muted-foreground"}):e.jsx(pt,{className:"size-3.5 text-muted-foreground"})})]})}function O(){return e.jsxs(t.ResizablePanelGroup,{className:"flex grow pb-1",direction:"vertical",role:"editor-resizable-group",children:[e.jsxs(t.ResizablePanel,{id:"1",order:1,defaultSize:a?20:100,className:"relative flex grow",children:[e.jsx("div",{id:"sql-container",className:"relative flex w-[99%]",children:e.jsx(wn,{})}),a&&e.jsx("code",{className:"absolute right-6 top-3 text-xs text-muted-foreground/70",children:"sql"})]}),a&&e.jsxs(e.Fragment,{children:[e.jsx(t.ResizableHandle,{withHandle:!0,className:"border"}),e.jsxs(t.ResizablePanel,{id:"2",order:2,defaultSize:80,className:"relative flex grow",children:[e.jsx("div",{id:"python-container",className:"relative flex w-[99%] pt-0",children:e.jsx(kn,{})}),e.jsx("code",{className:"absolute right-6 top-3 text-xs text-muted-foreground/70",children:"python"})]})]})]})}function k(){return e.jsxs("div",{role:"editor-controls",className:"item-center flex flex-wrap justify-between gap-2 px-6 py-4",children:[e.jsxs("div",{className:"flex grow items-center gap-2",children:[e.jsxs(t.Button,{title:"Shift + Enter",disabled:_||R,onClick:()=>{q()},className:"shrink-0",size:"sm",children:[_||R?e.jsx(oe,{className:"mr-2 h-4 w-4 animate-spin"}):e.jsx(t.Play,{className:"mr-2 h-4 w-4"}),"Run"]}),e.jsx(Mt,{sql:T==null?void 0:T.sql,error:j,onClick:M}),e.jsx(Bt,{}),e.jsx(t.Toggle,{pressed:a,onPressedChange:v=>n(v),className:"",size:"sm",children:e.jsx(Nn,{className:"size-4 text-foreground/70"})}),e.jsx("button",{disabled:i,onClick:()=>{D(),S(!0)},className:"h-9 w-full cursor-text px-3 text-left text-sm text-muted-foreground",children:i?"":"Type your question..."})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Rt,{}),e.jsx(Ft,{})]})]})}return e.jsxs("section",{role:"editor-section",className:"flex grow flex-col justify-end",children:[e.jsxs("div",{className:"relative flex grow justify-between overflow-y-scroll",children:[O(),G()]}),k()]})}function Mn({data:s}){var i;const[a,n]=E.useState([]),o=Object.keys(s[0]).map(c=>({accessorKey:c,header:({column:d})=>{const h=d.getIsSorted();return e.jsx("div",{className:"flex gap-2",children:e.jsxs("div",{className:"flex cursor-pointer items-center",onClick:()=>d.toggleSorting(d.getIsSorted()==="asc"),children:[c,h==="asc"?e.jsx(t.TriangleUpIcon,{className:"ml-2 h-5 w-5"}):h==="desc"?e.jsx(t.TriangleDownIcon,{className:"ml-2 h-5 w-5"}):null]})})}})),l=t.useReactTable({data:s,columns:o,getCoreRowModel:t.getCoreRowModel(),getPaginationRowModel:t.getPaginationRowModel(),onSortingChange:n,getSortedRowModel:t.getSortedRowModel(),manualPagination:!0,state:{sorting:a}});return e.jsx(t.CustomScrollArea,{className:"grow overflow-auto font-mono text-xs text-foreground/95",children:e.jsxs("table",{className:"w-full",children:[e.jsx(t.TableHeader,{className:"sticky top-0 z-50 h-0 bg-muted",children:l.getHeaderGroups().map(c=>e.jsx(t.TableRow,{className:"",children:c.headers.map(d=>e.jsx(t.TableHead,{className:"h-11 font-semibold text-foreground",children:d.isPlaceholder?null:t.flexRender(d.column.columnDef.header,d.getContext())},d.id))},c.id))}),e.jsx(t.TableBody,{children:(i=l.getRowModel().rows)!=null&&i.length?l.getRowModel().rows.map(c=>e.jsx(t.TableRow,{className:"h-11 whitespace-nowrap py-2","data-state":c.getIsSelected()&&"selected",children:c.getVisibleCells().map(d=>e.jsx(t.TableCell,{className:"py-2",children:t.flexRender(d.column.columnDef.cell,d.getContext())},d.id))},c.id)):e.jsx(t.TableRow,{children:e.jsx(t.TableCell,{colSpan:o.length,className:"h-24 text-center",children:"No results."})})})]})})}function An({card:s}){var S,b,I,N,T,_,R,U,w,V,$;const[a,n]=E.useState(!1),[r,o]=E.useState([]),{authToken:l}=t.useSemaphorContext(),i=t.getTokenParams(l==null?void 0:l.accessToken),c=t.useDashboardStore(q=>q.themeStyle),d={colors:((b=(S=c==null?void 0:c.chart)==null?void 0:S.dataset)==null?void 0:b.backgroundColor)||[]};(I=s.customCardPreferences)!=null&&I.inputData;const{getCard:h}=t.useCustomVisual(((N=s.customCardPreferences)==null?void 0:N.url)||""),u=((T=s.customCardPreferences)==null?void 0:T.visualType)||"single",x=t.useEditorStore(q=>q.frame),{setCustomCardPreferences:f}=t.useEditorActions(),{data:m}=t.useDashboardCardQuery(s),C=E.useCallback((q,j)=>{o(D=>({...D,[q]:j}))},[]);if(!((_=s.customCardPreferences)!=null&&_.componentName))return null;const p=h((R=s.customCardPreferences)==null?void 0:R.componentName);function y(q){n(q)}const g=Object.keys(((U=s.customCardPreferences)==null?void 0:U.dataInputCardIds)||{}).map(q=>{var M,G,O;const j=(G=(M=s.customCardPreferences)==null?void 0:M.dataInputCardIds)==null?void 0:G[q].cardId,D=(O=x==null?void 0:x.cards)==null?void 0:O.find(k=>k.id===j);return D||null});return e.jsx("div",{className:"semaphor-custom mb-3 flex grow basis-0 flex-col space-y-2 overflow-y-auto",children:e.jsxs(E.Suspense,{fallback:e.jsx(e.Fragment,{}),children:[p&&u==="single"&&e.jsx(p,{params:i,theme:d,settings:(w=s.customCardPreferences)==null?void 0:w.settings,onDataChange:C,data:(m==null?void 0:m.records)||[]}),p&&u==="multiple"&&e.jsxs(e.Fragment,{children:[Object.keys(((V=s.customCardPreferences)==null?void 0:V.dataInputCardIds)||{}).map(q=>{var M,G,O;const j=(G=(M=s.customCardPreferences)==null?void 0:M.dataInputCardIds)==null?void 0:G[q].cardId,D=(O=x==null?void 0:x.cards)==null?void 0:O.find(k=>k.id===j);if(D)return e.jsx(t.MultiInputEmptyRenderer,{onLoadingStatus:y,onDataChange:C,dataInputIndex:q,card:D},D.id+q)}),e.jsx("div",{className:"flex flex-col gap-2",children:e.jsx(p,{theme:d,onDataChange:C,settings:g.map(q=>{var j;return(j=q==null?void 0:q.customCardPreferences)==null?void 0:j.settings}),data:g.map(q=>q!=null&&q.id?r==null?void 0:r[q.id]:[])})})]})]},($=s.customCardPreferences)==null?void 0:$.componentName)})}function _t({className:s,...a}){var y;const n=t.useEditorStore(g=>g.card),r=((y=n.customCardPreferences)==null?void 0:y.showCardHeader)??!0,o=t.useEditorStore(g=>g.frame),l=t.useDashboardStore(g=>g.dashboard.filters);t.useEditorStore(g=>g.actions.setRunSql);const{updateFilter:i}=t.useDashboardActions(),c=l==null?void 0:l.find(g=>g.id===o.filterId),{data:d,isLoading:h,isFetching:u}=t.useDashboardCardQuery(n),{setCard:x}=t.useEditorActions(),{data:f}=t.useTopoJson(n),m=E.useMemo(()=>!n.id||!(d!=null&&d.records)?null:t.createChartConfig({data:d==null?void 0:d.records,cardType:n.type,customCfg:n.customCfg,preferences:n.preferences,topoJson:f}),[n.id,d==null?void 0:d.records,n.type,n.customCfg,n.preferences,f]);function C(g){return e.jsx(An,{card:g})}function p(){if(d!=null&&d.records&&(d==null?void 0:d.records.length)===0&&!h&&!u)return e.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-2",children:[e.jsx(t.TreePalm,{className:"size-8 text-muted-foreground"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"No records to display"})]});if(!n.id)return null;if(n.type==="custom")return C(n);if(!["table","custom"].includes(n.type)&&m)return e.jsx(e.Fragment,{children:h||u?e.jsx(e.Fragment,{}):e.jsx(t.ChartJsVisual,{cfg:m})});if(n.type==="table"&&(d!=null&&d.records)&&(d==null?void 0:d.records.length)>0)return e.jsxs(t.ScrollArea,{className:"relative mb-2 flex h-full min-h-0 w-full flex-1 grow basis-0",children:[e.jsx(t.TableVisual,{card:n,data:d==null?void 0:d.records}),e.jsx(t.ScrollBar,{orientation:"horizontal"})]})}return e.jsxs(t.Card,{role:"editor-visual-card",className:t.cn("relative flex h-full flex-col rounded-none",s),...a,children:[r&&e.jsxs(t.CardHeader,{className:"flex flex-row items-start justify-between py-4",children:[e.jsxs("div",{children:[e.jsx(t.Editable,{text:n.title,onSave:g=>x({...n,title:g}),children:e.jsx("div",{className:"flex items-center gap-5",children:e.jsx(t.CardTitle,{className:"text-base",children:n.title||"Edit title..."})})},n.title),e.jsx(t.Editable,{text:n.description||"",onSave:g=>x({...n,description:g}),children:e.jsx(t.CardDescription,{children:n.description||"Edit description..."})},n.description)]}),c&&e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(t.Editable,{className:"my-1",text:c.title||c.column,onSave:g=>i({...c,title:g}),children:e.jsx(t.Label,{children:c.title})}),e.jsx(t.FilterComponent,{filter:c})]})]}),e.jsx(t.CardContent,{className:"flex grow flex-col",children:p()})]})}const Ae=({language:s,value:a,onChange:n,readonly:r})=>e.jsx(t.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",readOnly:r},defaultLanguage:s,value:a,onChange:n}),Ln=()=>e.jsxs(t.DialogHeader,{children:[e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(t.DialogTitle,{children:"Customize Card"})}),e.jsxs(t.DialogDescription,{children:["See the configuration options and documentation",e.jsx("a",{target:"_blank",className:"ml-1 text-blue-500 underline",href:"https://www.chartjs.org/docs/latest/samples/bar/vertical.html",children:"here."})]})]}),On=({customCode:s,cardCustomCfgString:a,mergedConfig:n,onConfigChange:r,onCodeChange:o})=>e.jsxs(t.Tabs,{defaultValue:"final-config",className:"flex w-1/2 flex-col",children:[e.jsxs(t.TabsList,{className:"justify-start rounded-sm rounded-b-none border border-b-0",children:[e.jsx(t.TabsTrigger,{value:"final-config",children:"Config"}),e.jsx(t.TabsTrigger,{value:"custom-config",children:"Changes"}),e.jsx(t.TabsTrigger,{value:"custom-code",children:"Custom Code"})]}),e.jsx(t.TabsContent,{value:"final-config",className:"mt-0 grow rounded-b border border-t-0",children:e.jsx(Ae,{language:"json",value:n,onChange:r})}),e.jsx(t.TabsContent,{value:"custom-config",className:"mt-0 grow rounded-b border border-t-0",children:e.jsx(Ae,{readonly:!0,language:"json",value:a,onChange:()=>{}})}),e.jsx(t.TabsContent,{value:"custom-code",className:"mt-0 grow rounded-b border border-t-0",children:e.jsx(Ae,{language:"javascript",value:s,onChange:o})})]}),zn=({error:s,hasCardCustomConfig:a,onReset:n,onApply:r,onClose:o})=>e.jsxs(t.DialogFooter,{className:"flex items-center",children:[e.jsx(t.Label,{className:"mr-2 text-red-500",children:s}),e.jsx(t.Button,{disabled:!a,onClick:n,variant:"outline",children:"Reset"}),e.jsx(t.Button,{onClick:r,variant:"outline",children:"Apply"}),e.jsx(t.Button,{onClick:o,variant:"outline",children:"Close"})]});function Fn(){const[s,a]=E.useState(!1),[n,r]=E.useState(""),[o,l]=E.useState(""),[i,c]=E.useState(""),[d,h]=E.useState(""),u=t.useEditorStore(N=>N.card),x=t.useEditorStore(N=>N.card.customCfg),f=x?JSON.stringify(x,null,2):"",{data:m}=t.useDashboardCardQuery(u),{data:C}=t.useTopoJson(u),{setCardCustomCfg:p,setCustomVisualCode:y}=t.useEditorActions(),g=N=>{var T,_;return JSON.stringify({...N,data:{...N.data,datasets:(_=(T=N.data)==null?void 0:T.datasets)==null?void 0:_.map(R=>({...R,data:[]}))}},null,2)},S=()=>{var T,_;if(!((T=m==null?void 0:m.records)!=null&&T.length))return;const N=t.createChartConfig({data:m.records,cardType:u.type,preferences:u.preferences,topoJson:C});if(N){r(g(N)),c(((_=u.preferences)==null?void 0:_.customVisualCode)||"");const R=t.merge(N,x);l(g(R))}},b=()=>{try{if(i&&y(i),o){const N=JSON.parse(o),T=t.getObjectDiff(JSON.parse(n),N);p(T),h("")}}catch{h("Invalid JSON configuration")}},I=Object.keys(x||{}).length===0;return e.jsxs(t.Dialog,{open:s,onOpenChange:a,children:[e.jsx(t.DialogTrigger,{asChild:!0,children:e.jsx(t.IconButton,{tooltip:"Customize Visual",onClick:S,className:I?"":"text-green-600 hover:text-green-700",children:e.jsx(t.Settings,{className:"h-4 w-4"})})}),e.jsxs(t.DialogContent,{className:"flex h-[600px] grow flex-col overflow-auto sm:min-w-[900px] lg:min-w-[1200px]",children:[e.jsx(Ln,{}),e.jsxs("div",{className:"flex grow gap-2",children:[e.jsx(t.ErrorBoundary,{FallbackComponent:t.FallbackEditorCard,children:e.jsx(_t,{className:"w-1/2 rounded shadow-none"})}),e.jsx(On,{customCode:i,cardCustomCfgString:f,mergedConfig:o,onConfigChange:N=>l(N??""),onCodeChange:N=>c(N??"")})]}),e.jsx(zn,{error:d,hasCardCustomConfig:!!x,onReset:()=>{l(n),p(null)},onApply:b,onClose:()=>a(!1)})]})]})}function Vt(s){const[a,n]=E.useState(null);return a}function qt(){const{authToken:s}=t.useSemaphorContext(),{data:a,isLoading:n,isFetching:r,isError:o}=t.useQuery({queryKey:["plugins",s==null?void 0:s.accessToken],queryFn:()=>t.getPlugins(s==null?void 0:s.accessToken)});return{data:a,isLoading:n,isFetching:r,isError:o}}function Rn({onChartTypeChange:s}){const[a,n]=E.useState([]),{setCardCustomCfg:r,setCardPreferences:o,setCardType:l,setCustomCardPreferences:i}=t.useEditorActions(),{data:c}=qt();function d(h,u){r(null),o({}),l(h),u&&i({type:"component",visualType:"single",url:u.url,componentName:u.name,icon:u.icon}),s==null||s()}return E.useEffect(()=>{(async()=>{var u;if(c){const f=(await Promise.all((u=c==null?void 0:c.plugins)==null?void 0:u.map(async m=>(await t.loadManifest(m.value)).visuals.map(y=>({name:y.name,icon:y.icon,url:m.value}))))).flat();n(f)}})()},[c]),a.length===0?null:e.jsxs(e.Fragment,{children:[e.jsx(t.Separator,{className:"my-2"}),e.jsx("div",{className:"grid grid-cols-4 place-items-center",children:a.map((h,u)=>e.jsx(Bn,{text:h.name,onClick:()=>d("custom",h),icon:h.icon},h.url+h.name+u))})]})}const Bn=({text:s,icon:a,onClick:n})=>{const r=Vt(),o=s.charAt(0).toUpperCase();return e.jsx(t.IconButton,{onClick:n,tooltip:s,children:r?e.jsx(r,{className:"h-4 w-4"}):o})};function Pt(s){return he({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 _n(s){return he({attr:{viewBox:"0 0 256 256",fill:"currentColor"},child:[{tag:"path",attr:{d:"M48,180c0,11,7.18,20,16,20a14.24,14.24,0,0,0,10.22-4.66A8,8,0,0,1,85.78,206.4,30.06,30.06,0,0,1,64,216c-17.65,0-32-16.15-32-36s14.35-36,32-36a30.06,30.06,0,0,1,21.78,9.6,8,8,0,0,1-11.56,11.06A14.24,14.24,0,0,0,64,160C55.18,160,48,169,48,180Zm79.6-8.69c-4-1.16-8.14-2.35-10.45-3.84-1.25-.81-1.23-1-1.12-1.9a4.57,4.57,0,0,1,2-3.67c4.6-3.12,15.34-1.73,19.82-.56A8,8,0,0,0,142,145.86c-2.12-.55-21-5.22-32.84,2.76a20.58,20.58,0,0,0-9,14.95c-2,15.88,13.65,20.41,23,23.11,12.06,3.49,13.12,4.92,12.78,7.59-.31,2.41-1.26,3.34-2.14,3.93-4.6,3.06-15.17,1.56-19.55.36A8,8,0,0,0,109.94,214a61.34,61.34,0,0,0,15.19,2c5.82,0,12.3-1,17.49-4.46a20.82,20.82,0,0,0,9.19-15.23C154,179,137.49,174.17,127.6,171.31Zm83.09-26.84a8,8,0,0,0-10.23,4.84L188,184.21l-12.47-34.9a8,8,0,0,0-15.07,5.38l20,56a8,8,0,0,0,15.07,0l20-56A8,8,0,0,0,210.69,144.47ZM216,88v24a8,8,0,0,1-16,0V96H152a8,8,0,0,1-8-8V40H56v72a8,8,0,0,1-16,0V40A16,16,0,0,1,56,24h96a8,8,0,0,1,5.66,2.34l56,56A8,8,0,0,1,216,88Zm-27.31-8L160,51.31V80Z"},child:[]}]})(s)}function Ht(s){return he({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 Gt(s){return he({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 Ut(s){return he({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 $t({onChartTypeChange:s,iconClassName:a}){const{setCardType:n,setCardPreferences:r,setChartOrientation:o}=t.useEditorStore(h=>h.actions),{setCardCustomCfg:l,setCustomCardPreferences:i}=t.useEditorActions();function c(h,u){l(null),r({}),n(h),s==null||s()}const d=1e3;return e.jsxs("div",{className:"grid grid-cols-4 place-items-center",children:[e.jsx(t.IconButton,{openDelay:d,tooltip:"Table",onClick:()=>c("table"),className:"h-10 p-4",children:e.jsx(He,{className:t.cn("size-5",a)})}),e.jsx(t.IconButton,{openDelay:d,tooltip:"Bar Chart",onClick:()=>c("bar"),className:"h-10 p-4",children:e.jsx(qe,{className:t.cn("size-5",a)})}),e.jsx(t.IconButton,{openDelay:d,tooltip:"Line Chart",onClick:()=>c("line"),className:"h-10 p-4",children:e.jsx(Pe,{className:t.cn("size-5",a)})}),e.jsx(t.IconButton,{openDelay:d,tooltip:"Stacked Bar Chart",onClick:()=>c("stackedBar"),className:"h-10 p-4",children:e.jsx(ot,{className:t.cn("size-5",a)})}),e.jsx(t.IconButton,{openDelay:d,tooltip:"Stacked Line Chart",onClick:()=>c("stackedLine"),className:"h-10 p-4",children:e.jsx(Gt,{className:t.cn("size-5",a),strokeWidth:0})}),e.jsx(t.IconButton,{openDelay:d,tooltip:"Scatter Chart",onClick:()=>c("scatter"),className:"h-10 p-4",children:e.jsx(ct,{className:t.cn("size-5",a)})}),e.jsx(t.IconButton,{openDelay:d,tooltip:"Bubble Chart",onClick:()=>c("bubble"),className:"h-10 p-4",children:e.jsx(Ht,{className:t.cn("size-5",a)})}),e.jsx(t.IconButton,{openDelay:d,tooltip:"Pie Chart",onClick:()=>c("pie"),className:"h-10 p-4",children:e.jsx(lt,{className:t.cn("size-5",a)})}),e.jsx(t.IconButton,{openDelay:d,tooltip:"Doughnut Chart",onClick:()=>c("doughnut"),className:"h-10 p-4",children:e.jsx(ut,{className:t.cn("size-5",a)})}),e.jsx(t.IconButton,{openDelay:d,tooltip:"Radar Chart",onClick:()=>c("radar"),className:"h-10 p-4",children:e.jsx(gt,{className:t.cn("size-5",a)})}),e.jsx(t.IconButton,{openDelay:d,tooltip:"Polar Area Chart",onClick:()=>c("polarArea"),className:"h-10 p-4",children:e.jsx(Pt,{className:t.cn("size-5",a)})}),e.jsx(t.IconButton,{openDelay:d,tooltip:"Pyramid Chart",onClick:()=>c("pyramid"),className:"h-10 p-4",children:e.jsx(St,{className:t.cn("size-5",a)})}),e.jsx(t.IconButton,{tooltip:"Range Chart",onClick:()=>c("range"),className:"h-10 p-4",children:e.jsx(it,{className:t.cn("size-5",a)})}),e.jsx(t.IconButton,{openDelay:d,tooltip:"KPI",onClick:()=>c("kpi"),className:"h-10 p-4",children:e.jsx(Ut,{className:t.cn("size-5",a)})}),e.jsx(t.IconButton,{openDelay:d,tooltip:"Text",onClick:()=>c("text"),className:"h-10 p-4",children:e.jsx(js,{className:t.cn("size-5",a)})}),e.jsx(t.IconButton,{tooltip:"Map",onClick:()=>c("map"),className:"h-10 p-4",children:e.jsx(ft,{className:t.cn("size-5",a)})}),e.jsx(t.IconButton,{openDelay:d,tooltip:"Custom",onClick:()=>c("custom"),className:"h-10 p-4",children:e.jsx(yt,{className:t.cn("size-5",a)})})]})}function Vn({chartType:s,className:a,customIcon:n,componentName:r}){const o=Vt();switch(s){case"bar":return e.jsx(qe,{className:a});case"line":return e.jsx(Pe,{className:a});case"pie":return e.jsx(lt,{className:a});case"radar":return e.jsx(gt,{className:a});case"scatter":return e.jsx(ct,{className:a});case"bubble":return e.jsx(Ht,{className:a});case"doughnut":return e.jsx(ut,{className:a});case"stackedBar":return e.jsx(ot,{className:a});case"stackedLine":return e.jsx(Gt,{className:a});case"polarArea":return e.jsx(Pt,{className:a});case"pyramid":return e.jsx(St,{className:a});case"range":return e.jsx(it,{className:a});case"kpi":return e.jsx(Ut,{className:a});case"text":return e.jsx(Ct,{className:a});case"map":return e.jsx(ft,{className:a});case"custom":return n&&o?e.jsx(o,{className:a}):r?r==null?void 0:r.charAt(0).toUpperCase():e.jsx(yt,{className:a});default:return e.jsx(He,{className:a})}}function qn(){var l,i;const[s,a]=E.useState(!1),n=t.useEditorStore(c=>c.card),r=n.type,o=t.useDashboardStore(c=>c.isVisualEditing);return e.jsxs(t.Popover,{open:s,onOpenChange:a,children:[e.jsx(t.PopoverTrigger,{asChild:!0,children:e.jsx(t.Button,{size:"sm",variant:o?"ghost":"outline",children:e.jsx(Vn,{className:"size-4",chartType:r,customIcon:(l=n.customCardPreferences)==null?void 0:l.icon,componentName:(i=n.customCardPreferences)==null?void 0:i.componentName})})}),e.jsxs(t.PopoverContentCustom,{onOpenAutoFocus:c=>c.preventDefault(),className:"w-50",children:[e.jsx($t,{onChartTypeChange:()=>a(!1)}),e.jsx(Rn,{onChartTypeChange:()=>a(!1)})]})]})}const je="focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0";function rt(s,a){var r,o,l;const n=t.getNumberAxis(s,a);return((l=(o=(r=s==null?void 0:s.chartOptions)==null?void 0:r.scales)==null?void 0:o[n])==null?void 0:l.type)||"linear"}function Pn(){var D,M,G,O,k,v;const[s,a]=E.useState(!1),n=t.useEditorStore(A=>{var L;return(L=A.card)==null?void 0:L.preferences}),r=t.getNumberAxis(n,{}),[o,l]=E.useState(rt(n)),[i,c]=E.useState(((G=(M=(D=n==null?void 0:n.chartOptions)==null?void 0:D.scales)==null?void 0:M[r])==null?void 0:G.min)||""),[d,h]=E.useState(((v=(k=(O=n==null?void 0:n.chartOptions)==null?void 0:O.scales)==null?void 0:k[r])==null?void 0:v.max)||""),[u,x]=E.useState(i||d?"custom":"auto"),[f,m]=E.useState(""),[C,p]=E.useState(0),[y,g]=E.useState(""),[S,b]=E.useState(""),[I,N]=E.useState(""),T=t.useEditorStore(A=>A.actions.setCardPreferences),{updateCardInFrame:_}=t.useEditorActions(),R=t.useEditorStore(A=>A.card),U=t.useEditorStore(A=>{var L;return(L=A.card)==null?void 0:L.type}),w=["pie","doughnut","polarArea"].includes(U);E.useEffect(()=>{var A,L,J,P,W,B,K,H,Z,z,Q,X,ne,le;l(rt(n)),c(((J=(L=(A=n==null?void 0:n.chartOptions)==null?void 0:A.scales)==null?void 0:L[r])==null?void 0:J.min)===0?0:""),h(((B=(W=(P=n==null?void 0:n.chartOptions)==null?void 0:P.scales)==null?void 0:W[r])==null?void 0:B.max)||""),m(((z=(Z=(H=(K=n==null?void 0:n.chartOptions)==null?void 0:K.scales)==null?void 0:H[r])==null?void 0:Z.ticks)==null?void 0:z.stepSize)||""),p(((Q=n==null?void 0:n.numberAxisFormat)==null?void 0:Q.decimalPlaces)||0),g(((X=n==null?void 0:n.numberAxisFormat)==null?void 0:X.suffix)||""),b(((ne=n==null?void 0:n.numberAxisFormat)==null?void 0:ne.currency)||""),N(((le=n==null?void 0:n.numberAxisFormat)==null?void 0:le.locale)||"")},[s,n,r]);function V(A,L){return L===""||/^[0-9\b]+$/.test(L)?Number(L):Number(A)}function $(){const A=[...new Set(t.LOCALE_CURRENCY_PAIRS.map(L=>L.currency))];return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-6 items-center gap-2",children:[e.jsx(t.Label,{className:"col-span-2 hover:cursor-pointer hover:underline",htmlFor:"currency",children:e.jsx("a",{target:"_blank",href:"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat",children:"Currency"})}),e.jsxs(t.Select,{value:S||"none",onValueChange:L=>b(L==="none"?"":L),children:[e.jsx(t.SelectTrigger,{className:"col-span-2 h-8 w-full focus:ring-1 focus:ring-offset-0",children:e.jsx(t.SelectValue,{})}),e.jsx(t.SelectContent,{children:e.jsxs(t.SelectGroup,{children:[e.jsx(t.SelectLabel,{children:"Currency"}),e.jsx(t.SelectItem,{value:"none",children:"None"}),A.map(L=>e.jsx(t.SelectItem,{value:L,children:L},L))]})})]}),e.jsxs(t.Select,{value:I,onValueChange:L=>N(L),children:[e.jsx(t.SelectTrigger,{className:"col-span-2 h-8 w-full focus:ring-1 focus:ring-offset-0",children:e.jsx(t.SelectValue,{})}),e.jsx(t.SelectContent,{children:e.jsxs(t.SelectGroup,{children:[e.jsx(t.SelectLabel,{children:"Locale"}),t.LOCALE_CURRENCY_PAIRS.map(L=>e.jsx(t.SelectItem,{value:L.locale,children:L.locale},L.locale))]})})]})]}),e.jsxs("div",{className:"grid grid-cols-9 items-center gap-2",children:[e.jsx(t.Label,{className:"col-span-3",htmlFor:"format",children:"Decimals"}),e.jsx(t.Input,{value:C,onChange:L=>p(Number(L.target.value)),id:"format",className:`col-span-6 h-8 w-full tracking-wide ${je}`})]})]})}function q(){return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-3 items-center gap-2",children:[e.jsx(t.Label,{htmlFor:"range",children:"Range"}),e.jsx(t.Input,{id:"min",value:i,onChange:A=>c(L=>V(L,A.target.value)),className:`col-span-1 h-8 w-full ${je}`}),e.jsx(t.Input,{value:d,onChange:A=>h(L=>V(L,A.target.value)),id:"max",className:`col-span-1 h-8 w-full ${je}`})]}),e.jsxs("div",{className:"grid grid-cols-3 items-center gap-2",children:[e.jsx(t.Label,{htmlFor:"step-size",children:"Step Size"}),e.jsx(t.Input,{value:f,onChange:A=>m(L=>V(L,A.target.value)),id:"step-size",className:`col-span-1 h-8 w-full ${je}`})]})]})}function j(){var P;let A={};u==="custom"&&(A={min:i,max:d,ticks:{stepSize:f}});const L={...n||{},chartOptions:{...n==null?void 0:n.chartOptions,scales:{...(P=n==null?void 0:n.chartOptions)==null?void 0:P.scales,[r]:{type:o,...o==="linear"?A:{}}}},numberAxisFormat:{decimalPlaces:C,suffix:y,currency:S,locale:I}};console.log(L),T(L);const J={...R,preferences:L};_(J)}return e.jsxs(t.Popover,{onOpenChange:A=>a(A),children:[e.jsx(t.PopoverTrigger,{asChild:!0,children:e.jsx(t.IconButton,{tooltip:"Scale Options",children:e.jsx(Ks,{className:"size-4 rotate-45"})})}),e.jsx(t.PopoverContentCustom,{align:"center",className:"max-w-65",children:e.jsxs("div",{className:"grid gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("h4",{className:"font-medium leading-none",children:"Scale Options"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Set the scale for the number axis"})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsxs("div",{className:"grid grid-cols-3 items-center gap-2",children:[e.jsx(t.Label,{htmlFor:"scale",children:"Type"}),e.jsxs(t.Select,{disabled:w,value:o,onValueChange:A=>l(A),children:[e.jsx(t.SelectTrigger,{className:"col-span-2 h-8 w-full focus:ring-1 focus:ring-offset-0",children:e.jsx(t.SelectValue,{})}),e.jsx(t.SelectContent,{id:"type",children:e.jsxs(t.SelectGroup,{children:[e.jsx(t.SelectLabel,{children:"Option"}),e.jsx(t.SelectItem,{value:"linear",children:"Linear"}),e.jsx(t.SelectItem,{value:"logarithmic",children:"Logarithmic"})]})})]})]}),o=="linear"&&e.jsxs("div",{className:"grid grid-cols-3 items-center gap-2 py-1",children:[e.jsx(t.Label,{htmlFor:"scale-option",children:"Setup"}),e.jsxs(t.RadioGroup,{disabled:w,id:"scale-option",value:u,onValueChange:A=>x(A),className:"col-span-2 flex gap-3",defaultValue:"x",children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(t.RadioGroupItem,{value:"auto",id:"r1"}),e.jsx("label",{className:"text-sm",htmlFor:"r1",children:"Auto"})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(t.RadioGroupItem,{value:"custom",id:"r2"}),e.jsx("label",{className:"text-sm",htmlFor:"r2",children:"Custom"})]})]})]}),u==="custom"&&o=="linear"&&q(),$(),e.jsx(t.SelectSeparator,{}),e.jsx("div",{className:"grid grid-cols-3",children:e.jsx(t.Button,{onClick:j,variant:"secondary",className:"col-span-1 col-start-3 h-8 w-full",children:"Apply"})})]})]})})]})}function Hn(){const s=t.useEditorStore(c=>{var d,h,u,x;return(x=(u=(h=(d=c.card.preferences)==null?void 0:d.chartOptions)==null?void 0:h.plugins)==null?void 0:u.legend)==null?void 0:x.position}),a=t.useEditorStore(c=>{var d,h,u,x;return(x=(u=(h=(d=c.card.preferences)==null?void 0:d.chartOptions)==null?void 0:h.plugins)==null?void 0:u.legend)==null?void 0:x.align}),n=t.useEditorStore(c=>{var d,h,u,x;return(x=(u=(h=(d=c.card.preferences)==null?void 0:d.chartOptions)==null?void 0:h.plugins)==null?void 0:u.legend)==null?void 0:x.display}),{setLegendOptions:r}=t.useEditorActions(),o=c=>{r({display:c,position:s,align:a})},l=c=>{r({display:n,position:c,align:a})},i=c=>{r({display:n,position:s,align:c})};return e.jsxs(t.Popover,{children:[e.jsx(t.PopoverTrigger,{asChild:!0,children:e.jsx(t.IconButton,{tooltip:"Legend Settings",children:e.jsx(Fs,{className:"size-4"})})}),e.jsx(t.PopoverContentCustom,{className:"w-72",children:e.jsxs("div",{className:"grid gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("h4",{className:"font-medium leading-none",children:"Legend Options"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Set the legend options for the chart."})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsxs("div",{className:"grid grid-cols-3 items-center gap-4",children:[e.jsx(t.Label,{htmlFor:"displayLegend",children:"Display"}),e.jsx("div",{className:"col-span-2 flex h-8 items-center",children:e.jsx(t.SmallSwitch,{checked:n,onCheckedChange:o,defaultChecked:!0,id:"displayLegend"})})]}),e.jsxs("div",{className:"grid grid-cols-3 items-center gap-4",children:[e.jsx(t.Label,{htmlFor:"position",children:"Position"}),e.jsxs("div",{className:"col-span-2 flex h-8 items-center",children:[e.jsx(t.IconButton,{tooltip:"Top",onClick:()=>l("top"),children:e.jsx(t.ArrowUp,{className:"size-4"})}),e.jsx(t.IconButton,{tooltip:"Left",onClick:()=>l("left"),children:e.jsx(us,{className:"size-4"})}),e.jsx(t.IconButton,{tooltip:"Bottom",onClick:()=>l("bottom"),children:e.jsx(cs,{className:"size-4"})}),e.jsx(t.IconButton,{tooltip:"Right",onClick:()=>l("right"),children:e.jsx(ms,{className:"size-4"})})]})]}),e.jsxs("div",{className:"grid grid-cols-3 items-center gap-4",children:[e.jsx(t.Label,{htmlFor:"align",children:"Align"}),e.jsxs("div",{className:"col-span-2 flex h-8 items-center",children:[e.jsx(t.IconButton,{tooltip:"Start",onClick:()=>i("start"),children:e.jsx(as,{className:"size-4"})}),e.jsx(t.IconButton,{tooltip:"Center",onClick:()=>i("center"),children:e.jsx(ns,{className:"size-4"})}),e.jsx(t.IconButton,{tooltip:"End",onClick:()=>i("end"),children:e.jsx(rs,{className:"size-4"})})]})]})]})]})})]})}function Gn(){var l;const s=t.useEditorStore(i=>i.card.preferences),{setCardPreferences:a,setChartOrientation:n}=t.useEditorStore(i=>i.actions);function r(i){n(i)}const o=((l=s==null?void 0:s.chartOptions)==null?void 0:l.indexAxis)||"x";return e.jsx(t.IconButton,{onClick:()=>r(o==="y"?"x":"y"),tooltip:"Chart Orientation",children:o==="y"?e.jsx(Gs,{className:"size-4"}):e.jsx(Hs,{className:"size-4"})})}function Un(){const s=t.useEditorStore(i=>i.card),a=t.useEditorStore(i=>i.isShowingVisual),n=t.useEditorStore(i=>{var c,d;return(d=(c=i.card)==null?void 0:c.preferences)==null?void 0:d.chartOptions}),r=t.getChartGridStyle(n),{setChartGrid:o}=t.useEditorActions();function l(){const i=["xy","none","x","y"],d=(i.indexOf(r)+1)%i.length;o(i[d])}return a?e.jsxs("div",{"data-info":"visual-settings",className:"flex items-center",children:[["line","bar","range","stackedBar","stackedLine","horizontalBar"].includes(s.type)&&e.jsx(Gn,{}),!["kpi","text","custom","table"].includes(s.type)&&e.jsxs(e.Fragment,{children:[e.jsx(Pn,{}),e.jsx(Hn,{})]}),!["pie","doughnut","radar","polarArea","table","custom","kpi","text","map"].includes(s.type)&&e.jsxs(t.IconButton,{tooltip:"Grid Style",onClick:l,children:[(r==="xy"||!r)&&e.jsx(Ls,{className:"size-4"}),r==="x"&&e.jsx(Ns,{className:"size-4"}),r==="y"&&e.jsx(Qs,{className:"size-4"}),r==="none"&&e.jsx(Zs,{className:"size-4"})]})]}):null}function ye(){var O;const s=t.useEditorStore(k=>k.frame),a=t.useEditorStore(k=>k.card),n=t.useEditorStore(k=>k.isDevMode),r=t.useEditorStore(k=>k.isShowingVisual),o=t.useDashboardStore(k=>k.isVisualEditing),l=t.useEditorStore(k=>k.isSqlRunning),i=t.useEditorStore(k=>k.pythonStdOut),c=t.useEditorStore(k=>{var v;return(v=k.card.preferences)==null?void 0:v.chartOptions}),d=t.useEditorStore(k=>k.actions.setRunSql);t.getChartGridStyle(c);const{setFrame:h,setCard:u,updateCardInFrame:x,setActiveTabCardId:f,runAssistant:m,setChartGrid:C}=t.useEditorActions(),{data:p,isLoading:y,isFetching:g,error:S}=t.useDashboardCardQuery(a);if(!a)return e.jsx(e.Fragment,{children:"No Active Card"});function b(){const k={connectionId:a.connectionId,lastSelectedDatabase:a.lastSelectedDatabase,lastSelectedSchema:a.lastSelectedSchema,lastSelectedTable:a.lastSelectedTable,lastSelectedDatamodelId:a.lastSelectedDatamodelId,id:t.v4(),title:"Title",description:"Description",preferences:{onClickFilter:[{columnIndex:0,expression:""}]},type:"bar",sql:"",data:[]};I(k)}function I(k){const v={...s,cards:[...s.cards,k],activeCardId:k.id};h(v),u(k),f(k.id)}function N(){const k={...a,id:t.v4(),title:`${a.title} Copy`,tabTitle:`${a.tabTitle||a.title} Copy`};I(k)}function T(k){const v=s.cards.filter(J=>J.id!==k),A=v[0],L={...s,cards:v,activeCardId:A.id};h(L),f(A.id),u(A)}function _(k){n||R(k),f(k)}function R(k){const v={...s,cards:s.cards.map(L=>L.id===a.id?a:L),activeCardId:k};h(v);const A=v.cards.find(L=>L.id===k);A.sql&&d(!0),u(A)}const U=(k,v)=>{console.log("handleDragStart",v),k.dataTransfer.setData("tabIndex",v.toString())},w=k=>{k.preventDefault()},V=(k,v)=>{const A=k.dataTransfer.getData("tabIndex");if(A===v.toString())return;const L=Array.from(s.cards),[J]=L.splice(parseInt(A),1);L.splice(v,0,J),h({...s,cards:L})};function $(k,v){return k.cards.length===1&&(v.displayTab===!0||v.displayTab===void 0)||k.activeCardId!==v.id&&(v.displayTab===!0||v.displayTab===void 0)?null:e.jsx("div",{onClick:()=>{const A=v.displayTab===void 0?!1:!v.displayTab;u({...v,displayTab:A}),x({...v,displayTab:A})},children:v.displayTab===!0||v.displayTab===void 0?e.jsx(t.Eye,{className:"mr-2 size-3.5 text-muted-foreground hover:text-foreground"}):e.jsx(Es,{className:"mr-2 size-3.5 text-muted-foreground hover:text-foreground"})})}function q(){return e.jsxs(t.Tabs,{onValueChange:_,value:s.activeCardId,className:"flex grow flex-col",children:[s.cards.map(k=>e.jsx(t.TabsContent,{className:"mt-0 grow",value:k.id,children:j()},k.id)),e.jsx(t.TabsList,{className:"group mx-6 justify-between overflow-x-auto",children:e.jsxs("div",{className:"flex items-center",children:[s.cards.map((k,v)=>e.jsx(t.Editable,{text:k.tabTitle||k.title,onSave:A=>{u({...a,tabTitle:A}),x({...a,tabTitle:A})},children:e.jsxs(t.TabsTrigger,{draggable:!0,onDragStart:A=>U(A,v),onDragOver:w,onDrop:A=>V(A,v),className:"",value:k.id,children:[$(s,k),k.tabTitle||k.title,s.activeCardId===k.id&&s.cards.length>1&&e.jsx(t.X,{className:"ml-2 size-3.5 text-muted-foreground hover:text-foreground",onClick:()=>T(k.id)})]})},k.id)),e.jsx(t.Button,{className:"ml-1 h-8 px-2 hover:bg-muted-foreground/50",variant:"outline",onClick:b,children:e.jsx(t.Plus,{className:"h-4 w-4"})}),e.jsx(t.Button,{className:"invisible ml-1 h-8 px-2 hover:bg-muted-foreground/50 group-hover:visible",variant:"outline",onClick:N,children:e.jsx(ks,{className:"h-4 w-4"})})]})})]})}function j(){return a.type==="kpi"?e.jsx("div",{className:"flex h-full items-center justify-center",children:e.jsx("div",{className:"w-1/2 rounded-md border",children:e.jsx(t.KPICard,{card:a,data:p==null?void 0:p.records})})}):a.type==="text"?e.jsx("div",{className:"flex h-full items-center justify-center",children:e.jsx("div",{className:"w-1/2 rounded-md border",children:e.jsx(t.ScrollArea,{className:"mx-3 my-6 h-[300px] overflow-y-auto break-words px-3",children:e.jsx(t.TextCard,{isLoading:l,card:a,data:p==null?void 0:p.records})})})}):e.jsx(t.ErrorBoundary,{FallbackComponent:t.FallbackEditorCard,children:e.jsx(_t,{className:"grow border-none shadow-none"})})}function D(){const k=JSON.stringify(p==null?void 0:p.records,null,2),v=new Blob([k],{type:"application/json"}),A=URL.createObjectURL(v),L=document.createElement("a");L.href=A,L.download=`${a.title}.json`,L.click()}function M(){const v=[Object.keys(p==null?void 0:p.records.reduce((P,W)=>({...P,...W}),{})).join(","),...((p==null?void 0:p.records)||[]).map(P=>Object.values(P).join(","))].join(`
382
+ `),A=new Blob([v],{type:"text/csv"}),L=URL.createObjectURL(A),J=document.createElement("a");J.href=L,J.download=`${a.title}.csv`,J.click()}function G(){const k=`Can you get the documentation for ${a.type} chart?`;m(k)}return e.jsxs("div",{className:"relative isolate flex h-full flex-col py-3",children:[(y||g)&&e.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.jsx(oe,{className:"h-8 w-8 animate-spin text-muted-foreground"})}),e.jsxs("div",{className:"z-10 mb-0 flex min-h-10 items-center justify-end gap-2 px-6",children:[r&&e.jsxs("div",{className:"flex grow items-center",children:[e.jsx(qn,{}),o&&e.jsx(t.IconButton,{tooltip:"Visual Docs",onClick:G,children:e.jsx(gs,{className:"size-4"})}),!["table","custom"].includes(a.type)&&o&&e.jsx(Fn,{})]}),!r&&e.jsxs("div",{className:"flex grow items-center gap-1",children:[e.jsx(t.Button,{className:"h-7 w-fit px-1 font-mono text-xs text-muted-foreground/70",variant:"ghost",size:"icon",onClick:M,children:e.jsx(_n,{className:"size-4"})}),e.jsx(t.Button,{className:"h-7 w-fit px-1 font-mono text-xs text-muted-foreground/70",variant:"ghost",size:"icon",onClick:D,children:e.jsx(Ts,{strokeWidth:1.5,className:"size-4"})}),e.jsx(t.CopyButton,{text:JSON.stringify(p==null?void 0:p.records,null,2),className:"h-7 w-fit px-1 font-mono text-xs text-muted-foreground/70"})]}),e.jsx(Un,{}),n&&e.jsx(Qn,{})]}),r?q():e.jsxs(t.ResizablePanelGroup,{className:"px-6",direction:"horizontal",children:[i&&e.jsxs(e.Fragment,{children:[e.jsx(t.ResizablePanel,{id:"1",order:1,defaultSize:30,minSize:10,className:"relative flex h-full min-h-0 w-full flex-1 basis-0",children:i&&e.jsx($n,{})}),e.jsx(t.ResizableHandle,{})]}),e.jsxs(t.ResizablePanel,{id:"2",order:2,minSize:10,className:"relative flex h-full min-h-0 w-full flex-1 basis-0",children:[(p==null?void 0:p.records)&&(p==null?void 0:p.records.length)>0&&e.jsx(Mn,{data:(p==null?void 0:p.records)||[]}),(S||(p==null?void 0:p.error))&&e.jsx("span",{className:"font-mono text-xs",children:(S==null?void 0:S.message)||((O=p==null?void 0:p.error)==null?void 0:O.message)})]})]})]})}function $n(){const s=t.useEditorStore(n=>n.pythonStdOut);if(!s)return null;const a=s.replace(/\n/g,"<br>");return e.jsxs("div",{className:"relative flex w-full flex-col border-r",children:[e.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.jsxs(t.ScrollArea,{className:"overflow-y-auto px-2 pt-1 font-mono text-xs text-foreground/90",children:[e.jsx("div",{dangerouslySetInnerHTML:{__html:a}}),e.jsx(t.ScrollBar,{orientation:"horizontal"})]})]})}function Qn(){const s=t.useEditorStore(n=>n.isShowingVisual),a=t.useEditorStore(n=>n.actions.setIsShowingVisual);return e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(t.Label,{htmlFor:"visualize",children:"Chart"}),e.jsx(t.SmallSwitch,{checked:s,onCheckedChange:()=>a(!s),id:"visualize",className:"data-[state=checked]:bg-foreground/50"})]})}function Kn(){var p,y;const s=t.useEditorStore(g=>g.card.customCardPreferences),{data:a}=qt(),n=(a==null?void 0:a.plugins)||[],r=t.useEditorStore(g=>g.card),o=t.useEditorStore(g=>g.frame),l=(s==null?void 0:s.visualType)||"single",{setCustomCardPreferences:i}=t.useEditorActions(),{components:c,manifest:d}=t.useCustomVisual((s==null?void 0:s.url)||""),h=(p=d==null?void 0:d.visuals)==null?void 0:p.find(g=>g.name===(s==null?void 0:s.componentName));function u(g,S){if(!s)return;const I={...(s==null?void 0:s.dataInputCardIds)||{},[g]:{cardId:S,hookRef:null}};i({...s,dataInputCardIds:I})}function x(g){var b,I;const S=(b=o==null?void 0:o.cards)==null?void 0:b.filter(N=>{var T;return((T=N==null?void 0:N.customCardPreferences)==null?void 0:T.visualType)!=="multiple"}).map(N=>({value:N.id,label:N.tabTitle||N.title}));return e.jsx("div",{className:"space-y-2",children:(I=g==null?void 0:g.dataInputs)==null?void 0:I.map((N,T)=>{var _,R;return e.jsxs("div",{className:"grid grid-cols-10 gap-2",children:[e.jsx("div",{className:"col-span-4 flex items-center",children:N}),e.jsx(ee,{className:"col-span-6 h-8 w-full justify-between",label:"",options:S||[],value:((R=(_=s==null?void 0:s.dataInputCardIds)==null?void 0:_[T])==null?void 0:R.cardId)||"",onValueChange:U=>u(T,U)})]},T+Math.random())})})}function f(g,S,b=[],I=""){var N,T;return s?g==="input"?e.jsx(t.Input,{className:`h-8 w-full ${t.removeRing}`,value:((N=s==null?void 0:s.settings)==null?void 0:N[S])||I,onChange:_=>{i({...s,settings:{...s==null?void 0:s.settings,[S]:_.target.value}})}},S):g==="select"?e.jsx(ee,{className:"h-8 w-full",label:"",options:b,value:((T=s==null?void 0:s.settings)==null?void 0:T[S])||I,onValueChange:_=>{i({...s,settings:{...s==null?void 0:s.settings,[S]:_}})}}):null:null}function m(g){const S=Object.entries((g==null?void 0:g.settings)||{});return e.jsx("div",{className:"space-y-3",children:S.map(([b,I])=>e.jsxs("div",{className:"space-y-1",children:[e.jsx(t.Label,{children:I.title}),f(I.ui,b,I.options,I.defaultValue)]},b))})}function C(g){s&&i({...s,visualType:g,componentName:""})}return e.jsxs(t.Accordion,{type:"multiple",defaultValue:["component-settings"],className:"px-6 py-2",children:[e.jsxs(t.AccordionItem,{value:"plugin-settings",children:[e.jsx(t.AccordionTrigger,{children:"Plugin"}),e.jsx(t.AccordionContent,{children:e.jsxs("div",{className:"space-y-4 text-sm",children:[e.jsx("div",{className:"space-y-2",children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(ee,{icon:e.jsx(fs,{className:"h-3.5 w-3.5"}),className:"h-9 w-full",label:"Select Plugin",options:n,value:(s==null?void 0:s.url)||"",onValueChange:g=>i({...s||{url:"",componentName:""},url:g})}),((s==null?void 0:s.type)==="component"||(s==null?void 0:s.type)===void 0)&&e.jsx(t.Tabs,{value:l,onValueChange:C,children:e.jsxs(t.TabsList,{className:"h-9 w-full",children:[e.jsx(t.TabsTrigger,{className:"h-7 w-full",value:"single",children:"Single Visual"}),e.jsx(t.TabsTrigger,{className:"h-7 w-full",value:"multiple",children:"Multi-Visual"})]})})]})}),((s==null?void 0:s.type)==="component"||(s==null?void 0:s.type)===void 0)&&s&&e.jsx(e.Fragment,{children:c&&e.jsx(ee,{icon:e.jsx(ws,{className:"h-3.5 w-3.5"}),className:"h-9 w-full",label:"Select Component",options:(c==null?void 0:c.filter(g=>g.type===l).map(g=>({value:g.name,label:g.name})))||[],value:s.componentName,onValueChange:g=>{console.log("changing value",g),i({...s,componentName:g})}})})]})})]}),((y=r==null?void 0:r.customCardPreferences)==null?void 0:y.componentName)&&e.jsxs(t.AccordionItem,{className:"border-none",value:"component-settings",children:[e.jsx(t.AccordionTrigger,{children:"Settings"}),e.jsxs(t.AccordionContent,{children:[h&&h.dataInputs&&e.jsxs("div",{className:"space-y-3",children:[e.jsx(t.Label,{children:"Input Mapping"}),e.jsx("div",{className:"px-2",children:x(h)})]}),h&&h.settings&&e.jsx("div",{className:"space-y-3",children:e.jsx("div",{className:"px-2",children:m(h)})})]})]})]})}function ie(){const[s,a]=E.useState([]),n=t.useEditorStore(h=>h.card.preferences),{setFilterOnClickColumnIndex:r,setCardPreferences:o}=t.useEditorStore(h=>h.actions),l=t.useEditorStore(h=>h.queryResultColumns);t.useEditorStore(h=>{var u;return(u=h.card.preferences)==null?void 0:u.filterOnClickColumnIndex}),E.useEffect(()=>{l&&a(new Array(l.length).fill(!1))},[l]);function i(h,u){var x,f;u?n!=null&&n.onClickFilter&&((x=n==null?void 0:n.onClickFilter)==null?void 0:x.length)>0?o({...n,onClickFilter:[...n.onClickFilter,{columnIndex:h,expression:""}]}):o({...n,onClickFilter:[{columnIndex:h,expression:""}]}):(o({...n,onClickFilter:(f=n==null?void 0:n.onClickFilter)==null?void 0:f.filter(m=>m.columnIndex!==h)}),a(m=>{const C=[...m];return C[h]=!1,C}))}function c(h,u){var f;const x=(f=n==null?void 0:n.onClickFilter)==null?void 0:f.map(m=>m.columnIndex===h?{...m,expression:u.target.value}:m);o({...n,onClickFilter:x})}function d(h){var u,x,f,m;if(s!=null&&s[h]||(x=(u=n==null?void 0:n.onClickFilter)==null?void 0:u.find(C=>C.columnIndex===h))!=null&&x.expression)return e.jsx(t.Input,{value:(m=(f=n==null?void 0:n.onClickFilter)==null?void 0:f.find(C=>C.columnIndex===h))==null?void 0:m.expression,onChange:C=>c(h,C),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.jsxs("div",{className:"space-y-2",children:[e.jsx(t.Label,{children:"On Click"}),l==null?void 0:l.map((h,u)=>{var x,f;return e.jsx("div",{className:"xbg-red-100 group flex items-center justify-between space-y-2",children:e.jsxs("div",{className:"grow",children:[e.jsxs("div",{className:"flex items-center space-x-2 py-2",children:[e.jsx(t.Checkbox,{checked:!!((x=n==null?void 0:n.onClickFilter)!=null&&x.find(m=>m.columnIndex===u)),onCheckedChange:m=>i(u,m)}),e.jsx("label",{className:"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",children:h}),e.jsx("div",{className:"flex items-center gap-2",children:((f=n==null?void 0:n.onClickFilter)==null?void 0:f.find(m=>m.columnIndex===u))&&e.jsx(t.Pencil,{onClick:()=>{a(m=>{const C=[...m];return C[u]=!m[u],C})},className:"invisible size-3 cursor-pointer text-gray-400 group-hover:visible"})})]}),d(u)]})},h)})]})}function Jn({idx:s}){var c;const a=t.useEditorStore(d=>{var h;return(h=d.card)==null?void 0:h.preferences}),n=t.useEditorStore(d=>{var h;return(h=d.card.preferences)==null?void 0:h.datasetOptions}),r=t.useEditorStore(d=>d.actions.setCardPreferences),o=(c=a==null?void 0:a.chartOptions)==null?void 0:c.indexAxis,l=n==null?void 0:n.find(d=>d.idx===s);function i(d,h){(d==="end"||d==="start")&&t.getContrastColor(t.getCanvasBackgroundColor());const u={display:d!=="none",align:d,anchor:d,clamp:!0};if(!l)r({...a,datasetOptions:[...n||[],{idx:h,datalabels:u}]});else{const x={...l};x.datalabels=u;const f=n==null?void 0:n.map(m=>m.idx===h?x:m);r({...a,datasetOptions:f})}}return e.jsxs(t.Popover,{children:[e.jsx(t.PopoverTrigger,{children:e.jsx(Xs,{className:"size-4 rotate-[135deg] cursor-pointer text-muted-foreground hover:text-foreground"})}),e.jsx(t.PopoverContent,{className:"w-fit px-2 py-1",children:e.jsxs("div",{className:"flex gap-1",children:[e.jsx("button",{onClick:()=>i("none",s),className:"h-7 p-1 text-xs font-normal",children:e.jsx(t.X,{className:"size-3.5"})}),e.jsx("button",{onClick:()=>i("start",s),className:"h-7 p-1 text-xs font-normal",children:e.jsx(Rs,{className:t.cn("h-4 w-4",{"rotate-90":o==="y"})})}),e.jsx("button",{onClick:()=>i("center",s),className:"h-7 p-1 text-xs font-normal",children:e.jsx(_s,{className:t.cn("h-4 w-4",{"rotate-90":o==="y"})})}),e.jsx("button",{onClick:()=>i("end",s),className:"h-7 p-1 text-xs font-normal",children:e.jsx(Bs,{className:t.cn("h-4 w-4",{"rotate-90":o==="y"})})})]})})]})}function Qt(){const s=t.useEditorStore(i=>i.card),{data:a}=t.useDashboardCardQuery(s),{metricKeys:n,dimensionKeys:r,keys:o}=t.getKeys((a==null?void 0:a.records)||[]);let l=n;if(["stackedBar","stackedLine"].includes(s.type)){const i=t.pivotData({dataArray:(a==null?void 0:a.records)||[],groupKey:r[0],pivotKey:r[1],valueKey:l[0]}),{metricKeys:c}=t.getKeys(i);l=c}return{transformedMetricKeys:l,dimensionKeys:r,keys:o,defaultMetricKeys:n}}function Kt(){const s=t.useEditorStore(d=>d.card),a=t.useEditorStore(d=>{var h,u,x;return(x=(u=(h=d==null?void 0:d.card)==null?void 0:h.preferences)==null?void 0:u.chartOptions)==null?void 0:x.indexAxis}),{data:n}=t.useDashboardCardQuery(s),r=a==="y"?"Metric":"Dimension",o=a==="y"?"Dimension":"Metric",{dimensionKeys:l,transformedMetricKeys:i,keys:c}=Qt();return c.length===0?null:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(t.Label,{children:r}),e.jsx("div",{className:"max-h-[125px] space-y-1 overflow-y-auto",children:l.map(d=>e.jsx("p",{className:"rounded-md bg-muted/70 px-3 py-2 hover:bg-muted",title:d,children:Jt(d)},d))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(t.Label,{children:o}),e.jsx("div",{className:"my-1 max-h-[125px] space-y-1 overflow-y-auto",children:i.map((d,h)=>e.jsx(Wt,{className:"bg-muted/70 px-3 py-2 hover:bg-muted",iconClassName:"invisible group-hover:visible",col:d,idx:h},d))})]})]})}function Jt(s,a=30){return s.length>a?s.slice(0,a)+"...":s}function Wt({col:s,idx:a,className:n,iconClassName:r,children:o}){const l=t.useEditorStore(u=>{var x;return(x=u.card)==null?void 0:x.preferences}),i=t.useEditorStore(u=>{var x,f;return(f=(x=u.card)==null?void 0:x.preferences)==null?void 0:f.datasetOptions}),c=i==null?void 0:i.find(u=>u.idx===a),{setCardPreferences:d}=t.useEditorStore(u=>u.actions);function h(u){if(!c)d({...l,datasetOptions:[...i||[],{idx:a,type:u==="area"?"line":u,fill:u==="area"?"origin":""}]});else{const x={...c};x.type=u==="area"?"line":u,x.fill=u==="area"?"origin":"";const f=i==null?void 0:i.map(m=>m.idx===a?x:m);d({...l,datasetOptions:f})}}return e.jsxs("div",{className:t.cn("group flex items-center justify-between gap-5 rounded-md",n),children:[o||e.jsx("p",{title:s,children:Jt(s)}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(qe,{onClick:()=>h("bar"),className:t.cn("size-4 cursor-pointer text-muted-foreground hover:text-foreground",r)}),e.jsx(Pe,{onClick:()=>h("line"),className:t.cn("size-4 cursor-pointer text-muted-foreground hover:text-foreground",r)}),e.jsx(Ss,{onClick:()=>h("area"),className:t.cn("size-4 cursor-pointer text-muted-foreground hover:text-foreground",r)}),e.jsx(Jn,{idx:a})]})]})}function Yt(){const s=t.useEditorStore(m=>m.selectedConnectionId),a=t.useEditorStore(m=>m.selectedDatamodelId),n=t.useEditorStore(m=>m.selectedDatabaseName),r=t.useEditorStore(m=>m.selectedSchemaName),o=t.useEditorStore(m=>m.selectedTableName),l=t.useDashboardStore(m=>m.dashboard.filters)||[],i=t.useDashboardStore(m=>m.actions.addFilter),c=t.useDashboardStore(m=>m.actions.removeFilter),{removeFilterValues:d}=t.useDashboardActions(),{modelItems:h,tableName:u,connectionType:x}=te();function f(m,C="dashboard"){var _;const p=t.fmt(m.column_name),y=t.fmt(n||""),g=t.fmt(r||""),S=t.fmt(u);let b=t.getQualifiedTableName({schemaName:g,tableName:S,connectionType:x,databaseName:y}),I=`${b}.${p}`;const N=(_=h==null?void 0:h.find(R=>R.id===a))==null?void 0:_.name;a&&a!=="none"&&(I=`${t.DATAMODEL_NAMESPCACE}.${N}.${p}`,b=`${t.DATAMODEL_NAMESPCACE}.${N}`);const T=l==null?void 0:l.find(R=>R.column===I&&R.table===S&&(R.database===y||R.database===n));if(T)d(T.id),c(T.id);else{const R=t.v4();return u==="api"&&s?(i({location:C,id:R,column:I,title:m.column_name,dataType:m.data_type,table:"api",database:"",connectionId:s,operation:"in",sql:t.getDefaultFilterSql(m.data_type,b,p)}),R):(i({id:R,location:C,column:I,title:m.column_name,dataType:m.data_type,table:o||"",database:n||"",connectionId:s||"",operation:"in",sql:t.getDefaultFilterSql(m.data_type,b,p)}),R)}}return{assignFilter:f}}function pe(){const s=t.useDashboardStore(c=>c.dashboard.filters),a=t.useEditorStore(c=>c.frame),{setFrame:n}=t.useEditorActions(),{columns:r}=te(),{assignFilter:o}=Yt();function l(c){const d=o(c,"frame");n({...a,filterId:d})}const i=s==null?void 0:s.find(c=>c.id===a.filterId);return e.jsxs("div",{className:"space-y-3",children:[e.jsx(t.Label,{children:"Card Filter"}),e.jsx(Wn,{onSelect:l,columns:r}),i&&e.jsx(t.FilterHeader,{filter:i})]})}function Wn({columns:s,onSelect:a}){var i;const[n,r]=de.useState(!1),[o,l]=de.useState("");return e.jsxs(t.Popover,{open:n,onOpenChange:r,children:[e.jsx(t.PopoverTrigger,{asChild:!0,children:e.jsxs(t.Button,{size:"sm",variant:"outline",role:"combobox","aria-expanded":n,className:"w-full justify-between font-normal",children:[o?(i=s.find(c=>c.column_name===o))==null?void 0:i.column_name:"Select Column...",e.jsx(t.CaretSortIcon,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(t.PopoverContent,{className:"w-[200px] p-0",children:e.jsxs(t.Command,{children:[e.jsx(t.CommandInput,{placeholder:"Search column",className:"h-9"}),e.jsxs(t.CommandList,{children:[e.jsx(t.CommandEmpty,{children:"No framework found."}),e.jsx(t.CommandGroup,{children:s==null?void 0:s.map(c=>e.jsxs(t.CommandItem,{value:c.column_name,onSelect:d=>{const h=d===o?"":d;l(h),r(!1),h&&a(c)},children:[c.column_name,e.jsx(t.CheckIcon,{className:t.cn("ml-auto h-4 w-4",o===c.column_name?"opacity-100":"opacity-0")})]},c.column_name))})]})]})})]})}function Yn({cardType:s}){return e.jsx("div",{className:"space-y-6 px-6 py-2",children:e.jsxs(t.Accordion,{defaultValue:["item-2"],type:"multiple",children:[e.jsxs(t.AccordionItem,{value:"item-1",children:[e.jsx(t.AccordionTrigger,{children:`${t.titleCase(s)} Chart`}),e.jsxs(t.AccordionContent,{className:"space-y-4 font-mono text-xs",children:[e.jsx("div",{className:"rounded bg-muted px-2 py-1 text-xs",children:"SELECT x-axis, y-axis-1, y-axis-2,... FROM table"}),e.jsxs("ul",{className:"ml-6 list-disc text-xs [&>li]:mt-2",children:[e.jsx("li",{children:"x-axis - category"}),e.jsx("li",{children:"y-axis1 - number"}),e.jsx("li",{children:"y-axis2 - number"})]}),e.jsxs("div",{children:["See ",e.jsx("a",{target:"_blank",onClick:a=>a.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/docs/charts/bar-line-area",children:"example"})," in the docs."]})]})]}),e.jsxs(t.AccordionItem,{value:"item-2",children:[e.jsx(t.AccordionTrigger,{children:"Settings"}),e.jsx(t.AccordionContent,{className:"space-y-4 px-2",children:e.jsx(Kt,{})})]}),e.jsxs(t.AccordionItem,{value:"item-3",children:[e.jsx(t.AccordionTrigger,{children:"Filters"}),e.jsxs(t.AccordionContent,{className:"space-y-4 px-2",children:[e.jsx(ie,{}),e.jsx(pe,{})]})]})]})})}function Ke(){var o,l,i;const s=t.useEditorStore(c=>c.card.type),a=t.useEditorStore(c=>c.card.preferences),{setCardPreferences:n}=t.useEditorStore(c=>c.actions);function r(c){var u;const d={datalabels:{display:c!=="none",align:c,anchor:c,clamp:!0}},h={...a,chartOptions:{...a==null?void 0:a.chartOptions,plugins:{...(u=a==null?void 0:a.chartOptions)==null?void 0:u.plugins,...d}}};n(h),console.log(c)}return e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"font-medium",children:"Data Labels"}),e.jsxs(t.Select,{value:((i=(l=(o=a==null?void 0:a.chartOptions)==null?void 0:o.plugins)==null?void 0:l.datalabels)==null?void 0:i.anchor)||"none",onValueChange:r,defaultValue:"none",children:[e.jsx(t.SelectTrigger,{className:"h-8 w-full focus:ring-1 focus:ring-offset-0",children:e.jsx(t.SelectValue,{placeholder:"Select position"})}),e.jsx(t.SelectContent,{children:e.jsxs(t.SelectGroup,{children:[e.jsx(t.SelectLabel,{children:"Data Labels"}),e.jsx(t.SelectItem,{value:"none",children:"None"}),s!=="pyramid"&&e.jsx(t.SelectItem,{value:"start",children:"Start"}),e.jsx(t.SelectItem,{value:"center",children:"Center"}),s!=="pyramid"&&e.jsx(t.SelectItem,{value:"end",children:"End"})]})})]})]})}function Zn({cardType:s}){function a(n){return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"rounded bg-muted px-2 py-1 text-xs",children:n==="bubble"?"SELECT label, [group], x-axis, y-axis, radius FROM table":"SELECT label, [group], x-axis, y-axis FROM table"}),e.jsxs("ul",{className:"ml-6 list-disc text-xs [&>li]:mt-2",children:[e.jsx("li",{children:"label - category"}),e.jsx("li",{children:"group (optional) - category"}),e.jsx("li",{children:"x-axis - number"}),e.jsx("li",{children:"y-axis - number"}),n==="bubble"&&e.jsx("li",{children:"radius - number"})]}),e.jsxs("div",{children:["See ",e.jsx("a",{target:"_blank",onClick:l=>l.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/docs/charts/bubble",children:"example"})," in the docs."]})]})}return e.jsx("div",{className:"space-y-6 px-6 py-2",children:e.jsxs(t.Accordion,{defaultValue:["item-2"],type:"multiple",children:[e.jsxs(t.AccordionItem,{value:"item-1",children:[e.jsx(t.AccordionTrigger,{children:`${t.titleCase(s)} Chart`}),e.jsx(t.AccordionContent,{className:"space-y-4 font-mono text-xs",children:a(s)})]}),e.jsxs(t.AccordionItem,{value:"item-2",children:[e.jsx(t.AccordionTrigger,{children:"Settings"}),e.jsx(t.AccordionContent,{className:"px-2",children:e.jsx(Ke,{})})]}),e.jsxs(t.AccordionItem,{value:"item-3",children:[e.jsx(t.AccordionTrigger,{children:"Filters"}),e.jsxs(t.AccordionContent,{className:"space-y-4 px-2",children:[e.jsx(ie,{}),e.jsx(pe,{})]})]})]})})}const Xn={datasets:[{type:"line",label:"Sum_sales",data:[]},{type:"bar",label:"Sum_profit",data:[]}]},ea={datasets:[{fill:"origin",type:"line",label:"Sum_sales",data:[]}]};function ta(){const s=t.useEditorStore(a=>a.card.type);return e.jsxs("div",{className:"space-y-6 p-6",children:[e.jsx(t.Accordion,{className:" ",type:"single",collapsible:!0,children:sa(s)}),!["kpi"].includes(s)&&e.jsxs("div",{className:"space-y-4",children:[e.jsx(Ke,{}),e.jsx(ie,{}),e.jsx(pe,{})]})]})}function sa(s){if(["line","bar"].includes(s))return e.jsxs(e.Fragment,{children:[e.jsxs(t.AccordionItem,{value:"item-1",children:[e.jsx(t.AccordionTrigger,{className:"font-normal",children:e.jsx("p",{children:"Chart Query"})}),e.jsxs(t.AccordionContent,{className:" ",children:[e.jsx("div",{className:"rounded bg-muted px-2 py-1 font-mono text-xs font-semibold",children:"SELECT x-axis, y-axis-1, y-axis-2, y-axis-3,... FROM table"}),e.jsxs("ul",{className:"my-6 ml-6 list-disc text-xs font-normal [&>li]:mt-2",children:[e.jsx("li",{children:"X-axis - Category (ex. city)"}),e.jsx("li",{children:"Y-axis - Number (ex. population)"})]})]})]}),e.jsxs(t.AccordionItem,{value:"item-2",children:[e.jsx(t.AccordionTrigger,{className:"font-normal",children:"Mixed Chart"}),e.jsxs(t.AccordionContent,{className:"space-y-2 text-xs",children:[e.jsxs("p",{children:["Click ",e.jsx("b",{children:"Customize"})," and change the `type` property in the dataset."]}),e.jsx("pre",{children:JSON.stringify(Xn,null,2)})]})]}),e.jsxs(t.AccordionItem,{value:"item-3",children:[e.jsx(t.AccordionTrigger,{className:"font-normal",children:"Area Chart"}),e.jsxs(t.AccordionContent,{className:"space-y-2 text-xs",children:[e.jsxs("p",{children:["Click ",e.jsx("b",{children:"Customize"})," and add `fill` property to the dataset. See",e.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.jsx("pre",{children:JSON.stringify(ea,null,2)})]})]})]});if(s==="bubble")return e.jsx(e.Fragment,{children:e.jsxs(t.AccordionItem,{value:"item-1",children:[e.jsx(t.AccordionTrigger,{className:"font-normal",children:e.jsxs("p",{children:["How to create a ",e.jsx("span",{children:s})," chart query?"]})}),e.jsxs(t.AccordionContent,{className:" ",children:[e.jsx("div",{className:"rounded bg-muted px-2 py-1 font-mono text-xs font-semibold",children:"SELECT label, x-axis, y-axis, radius FROM table"}),e.jsxs("ul",{className:"my-6 ml-6 list-disc text-xs font-normal [&>li]:mt-2",children:[e.jsx("li",{children:"Label - Category (ex. city)"}),e.jsx("li",{children:"Bubble Group (opt) - Category (ex. state)"}),e.jsx("li",{children:"X-axis - Number (ex. avg. age)"}),e.jsx("li",{children:"Y-axis - Number (ex. avg. weight)"}),e.jsx("li",{children:"Radius - Number (ex. population)"})]})]})]})});if(s==="scatter")return e.jsx(e.Fragment,{children:e.jsxs(t.AccordionItem,{value:"item-1",children:[e.jsx(t.AccordionTrigger,{className:"font-normal",children:e.jsxs("p",{children:["How to create a ",e.jsx("span",{children:s})," chart query?"]})}),e.jsxs(t.AccordionContent,{className:" ",children:[e.jsx("div",{className:"rounded bg-muted px-2 py-1 font-mono text-xs font-semibold",children:"SELECT label, x-axis, y-axis FROM table"}),e.jsxs("ul",{className:"my-6 ml-6 list-disc text-xs font-normal [&>li]:mt-2",children:[e.jsx("li",{children:"Label - Category (ex. city)"}),e.jsx("li",{children:"Group (opt) - Category (ex. state)"}),e.jsx("li",{children:"X-axis - Number (ex. avg. age)"}),e.jsx("li",{children:"Y-axis - Number (ex. avg. weight)"})]})]})]})});if(["pie","doughnut","polarArea"].includes(s))return e.jsx(e.Fragment,{children:e.jsxs(t.AccordionItem,{value:"item-1",children:[e.jsx(t.AccordionTrigger,{className:"font-normal",children:e.jsxs("p",{children:[e.jsx("span",{children:s==="polarArea"?"Polar":s.charAt(0).toUpperCase()+s.slice(1)})," ","chart query"]})}),e.jsxs(t.AccordionContent,{className:" ",children:[e.jsx("div",{className:"rounded bg-muted px-2 py-1 font-mono text-xs font-semibold",children:"SELECT label, measure FROM table"}),e.jsxs("ul",{className:"my-6 ml-6 list-disc text-xs font-normal [&>li]:mt-2",children:[e.jsx("li",{children:"Label - Category (ex. city)"}),e.jsx("li",{children:"Measure - Number (ex. population)"})]})]})]})})}function na(){var d,h,u,x,f;const s=t.useEditorStore(m=>m.card.preferences),a=t.useEditorStore(m=>m.actions.setCardPreferences),n=t.useEditorStore(m=>m.actions.setNumberFormat);t.useEditorStore(m=>{var C,p;return(p=(C=m.card.preferences)==null?void 0:C.formatNumber)==null?void 0:p.decimalPlaces});const r=t.useEditorStore(m=>{var C,p;return(p=(C=m.card.preferences)==null?void 0:C.formatNumber)==null?void 0:p.locale}),o=t.useEditorStore(m=>{var C,p;return(p=(C=m.card.preferences)==null?void 0:C.formatNumber)==null?void 0:p.currency});t.useEditorStore(m=>m.actions.setFilterOnClickField);const l=t.useEditorStore(m=>{var C,p;return(p=(C=m.card.preferences)==null?void 0:C.formatNumber)==null?void 0:p.colorRanges})||[],i=t.useEditorStore(m=>m.actions.setColorRanges),c=[...new Set(t.LOCALE_CURRENCY_PAIRS.map(m=>m.currency))];return e.jsxs("div",{children:[e.jsxs("div",{className:"mb-3 flex items-center gap-2",children:[e.jsx(t.Checkbox,{checked:!!((d=s==null?void 0:s.formatNumber)!=null&&d.enabled),onCheckedChange:m=>{a({...s,formatNumber:{...s==null?void 0:s.formatNumber,enabled:m}})}}),e.jsx(t.Label,{children:"Format Number"})]}),((h=s==null?void 0:s.formatNumber)==null?void 0:h.enabled)===!0&&e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("div",{children:e.jsxs("div",{className:"space-y-4 p-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"w-full space-y-1",children:[e.jsx(t.Label,{children:"Locale"}),e.jsxs(t.Select,{value:r||"none",onValueChange:m=>{var C,p,y;return n(((C=s==null?void 0:s.formatNumber)==null?void 0:C.decimalPlaces)||0,((p=s==null?void 0:s.formatNumber)==null?void 0:p.currency)||"",m,((y=s==null?void 0:s.formatNumber)==null?void 0:y.suffix)||"")},children:[e.jsx(t.SelectTrigger,{className:"col-span-6 h-8 w-full focus:ring-1 focus:ring-offset-0",children:e.jsx(t.SelectValue,{})}),e.jsx(t.SelectContent,{children:e.jsxs(t.SelectGroup,{children:[e.jsx(t.SelectLabel,{children:"Format"}),e.jsx(t.SelectItem,{value:"none",children:"None"},"none"),t.LOCALE_CURRENCY_PAIRS.map(m=>e.jsx(t.SelectItem,{value:m.locale,children:m.locale},m.locale))]})})]})]}),e.jsxs("div",{className:"w-full space-y-1",children:[e.jsx(t.Label,{children:"Currency"}),e.jsxs(t.Select,{value:o||"none",onValueChange:m=>{var C,p,y;console.log("currency",m),n(((C=s==null?void 0:s.formatNumber)==null?void 0:C.decimalPlaces)||0,m==="none"?"":m,((p=s==null?void 0:s.formatNumber)==null?void 0:p.locale)||"",((y=s==null?void 0:s.formatNumber)==null?void 0:y.suffix)||"")},children:[e.jsx(t.SelectTrigger,{className:"col-span-6 h-8 w-full focus:ring-1 focus:ring-offset-0",children:e.jsx(t.SelectValue,{})}),e.jsx(t.SelectContent,{children:e.jsxs(t.SelectGroup,{children:[e.jsx(t.SelectLabel,{children:"Currency"}),e.jsx(t.SelectItem,{value:"none",children:"None"},"none"),c.map(m=>e.jsx(t.SelectItem,{value:m,children:m},m))]})})]})]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("div",{className:"w-full space-y-1",children:[e.jsx(t.Label,{children:"Decimals"}),e.jsxs(t.Select,{value:((x=(u=s==null?void 0:s.formatNumber)==null?void 0:u.decimalPlaces)==null?void 0:x.toString())||"0",onValueChange:m=>{var C,p,y;return n(Number(m),((C=s==null?void 0:s.formatNumber)==null?void 0:C.currency)||"",((p=s==null?void 0:s.formatNumber)==null?void 0:p.locale)||"",((y=s==null?void 0:s.formatNumber)==null?void 0:y.suffix)||"")},children:[e.jsx(t.SelectTrigger,{className:"col-span-3 h-8 w-full focus:ring-1 focus:ring-offset-0",children:e.jsx(t.SelectValue,{})}),e.jsx(t.SelectContent,{children:["0","1","2","3","4"].map(m=>e.jsx(t.SelectItem,{value:m,children:m},m))})]})]}),e.jsxs("div",{className:"w-full space-y-1",children:[e.jsx(t.Label,{children:"Suffix"}),e.jsx(t.Input,{value:((f=s==null?void 0:s.formatNumber)==null?void 0:f.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:m=>{var C,p,y;return n(((C=s==null?void 0:s.formatNumber)==null?void 0:C.decimalPlaces)||0,((p=s==null?void 0:s.formatNumber)==null?void 0:p.currency)||"",((y=s==null?void 0:s.formatNumber)==null?void 0:y.locale)||"",m.target.value)}})]})]})]})}),e.jsx(t.Separator,{className:"my-3"}),e.jsx(t.ColorFormat,{colorRanges:l,setColorRanges:i})]})]})}function aa(){return e.jsxs("div",{className:"space-y-6 px-6 py-2",children:[e.jsx(t.Accordion,{type:"single",collapsible:!0,children:e.jsxs(t.AccordionItem,{value:"item-1",children:[e.jsx(t.AccordionTrigger,{className:"",children:"KPI Query"}),e.jsxs(t.AccordionContent,{className:"font-mono",children:[e.jsx("div",{className:"rounded bg-muted px-2 py-1 font-mono text-xs",children:"SELECT current, previous FROM table"}),e.jsxs("ul",{className:"my-6 ml-6 list-disc text-xs [&>li]:mt-2",children:[e.jsx("li",{children:"current - number"}),e.jsx("li",{children:"previous - number"})]}),e.jsxs("div",{children:["See ",e.jsx("a",{target:"_blank",onClick:s=>s.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/docs/charts/kpi",children:"example"})," in the docs."]})]})]})}),e.jsx("section",{className:"",children:e.jsx(na,{})}),e.jsx("div",{}),e.jsx("div",{})]})}function Le({children:s,summary:a,open:n,className:r}){return e.jsxs("details",{open:n,className:t.cn("space-y-4 [&_summary>svg]:open:-rotate-180",r),children:[e.jsxs("summary",{className:"flex cursor-pointer list-none items-center justify-between gap-4",children:[e.jsx(t.Label,{children:a}),e.jsx(t.ChevronUp,{className:"h-4 w-4"})]}),e.jsx("div",{className:"transition-all ease-in-out",children:s})]})}const ra=[{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"}],oa=["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"],ia=oa.map(s=>({label:s,value:s}));function la(){var d,h,u,x,f,m,C,p,y,g,S,b,I,N,T,_,R,U;const s=t.useEditorStore(w=>w.card),a=(h=(d=s==null?void 0:s.preferences)==null?void 0:d.mapVisualOptions)==null?void 0:h.topoJsonUrl,[n,r]=E.useState(((x=(u=s==null?void 0:s.preferences)==null?void 0:u.mapVisualOptions)==null?void 0:x.customTopoJsonUrl)||""),{setCardPreferences:o}=t.useEditorActions(),{data:l}=t.useTopoJson(s),i=Object.keys((l==null?void 0:l.objects)||{}).map(w=>({label:w,value:w}))||[],c=[{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.jsxs("div",{className:"p-6",children:[e.jsx(Le,{summary:"Map Chart",children:e.jsx("p",{className:"rounded-md bg-muted p-2 font-mono text-xs",children:"SELECT country, value FROM table"})}),e.jsx(t.Separator,{className:"my-4"}),e.jsx(Le,{open:!0,summary:"Settings",children:e.jsxs("div",{className:"space-y-3 px-2",children:[e.jsx(ee,{className:"h-9",options:c,onValueChange:w=>{console.log("value",w),o({...s.preferences,mapVisualOptions:{topoJsonUrl:w}})},value:a||"",label:"Select Map"}),a==="custom"&&e.jsx(t.Input,{onChange:w=>{r(w.target.value)},onBlur:()=>{var w;console.log("onBlur",n),o({...s.preferences,mapVisualOptions:{...(w=s.preferences)==null?void 0:w.mapVisualOptions,customTopoJsonUrl:n}})},value:n,className:`h-9 w-full ${t.removeRing}`,placeholder:"Custom URL"}),l&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(t.Label,{children:"Map Object"}),e.jsx(ee,{className:"h-9",options:i,value:((m=(f=s.preferences)==null?void 0:f.mapVisualOptions)==null?void 0:m.objectKey)||"",label:"Map Object",onValueChange:w=>{var V;o({...s.preferences,mapVisualOptions:{...(V=s.preferences)==null?void 0:V.mapVisualOptions,objectKey:w}})}})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(t.Label,{children:"Projection"}),e.jsx(ee,{className:"h-9",options:ra,value:((p=(C=s.preferences)==null?void 0:C.mapVisualOptions)==null?void 0:p.projection)||"",label:"Projection",onValueChange:w=>{var V;o({...s.preferences,mapVisualOptions:{...(V=s.preferences)==null?void 0:V.mapVisualOptions,projection:w}})}})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(t.Label,{children:"Colors"}),e.jsx(ee,{className:"h-9",options:ia,value:((g=(y=s.preferences)==null?void 0:y.mapVisualOptions)==null?void 0:g.colorScale)||"",label:"Select Color Scale",onValueChange:w=>{var V;o({...s.preferences,mapVisualOptions:{...(V=s.preferences)==null?void 0:V.mapVisualOptions,colorScale:w}})}})]})]})]})}),e.jsx(t.Separator,{className:"my-4"}),e.jsx(Le,{className:"",summary:"Scale Options",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(t.Input,{className:`h-9 w-full ${t.removeRing}`,type:"number",step:.1,value:((b=(S=s.preferences)==null?void 0:S.mapVisualOptions)==null?void 0:b.projectionScale)||1,onChange:w=>{var V;o({...s.preferences,mapVisualOptions:{...(V=s.preferences)==null?void 0:V.mapVisualOptions,projectionScale:Number(w.target.value)}})}}),e.jsx(t.Label,{children:"X"}),e.jsx(t.Input,{className:`h-9 w-full ${t.removeRing}`,type:"number",step:10,value:((T=(N=(I=s.preferences)==null?void 0:I.mapVisualOptions)==null?void 0:N.projectionOffset)==null?void 0:T[0])||0,onChange:w=>{var V,$,q,j;o({...s.preferences,mapVisualOptions:{...(V=s.preferences)==null?void 0:V.mapVisualOptions,projectionOffset:[Number(w.target.value),((j=(q=($=s.preferences)==null?void 0:$.mapVisualOptions)==null?void 0:q.projectionOffset)==null?void 0:j[1])||0]}})}}),e.jsx(t.Label,{children:"Y"}),e.jsx(t.Input,{className:`h-9 w-full ${t.removeRing}`,type:"number",step:10,value:((U=(R=(_=s.preferences)==null?void 0:_.mapVisualOptions)==null?void 0:R.projectionOffset)==null?void 0:U[1])||0,onChange:w=>{var V,$,q,j;o({...s.preferences,mapVisualOptions:{...(V=s.preferences)==null?void 0:V.mapVisualOptions,projectionOffset:[((j=(q=($=s.preferences)==null?void 0:$.mapVisualOptions)==null?void 0:q.projectionOffset)==null?void 0:j[0])||0,Number(w.target.value)]}})}})]})}),e.jsx(t.Separator,{className:"my-4"}),e.jsx(ie,{})]})}function ca(){var r;const s=t.useEditorStore(o=>o.card.preferences),{setCardPreferences:a}=t.useEditorStore(o=>o.actions);function n(o){a({...s,textVisualOptions:{...s==null?void 0:s.textVisualOptions,isDynamicText:o==="dynamic"}})}return e.jsxs(t.RadioGroup,{value:(r=s==null?void 0:s.textVisualOptions)!=null&&r.isDynamicText?"dynamic":"static",onValueChange:n,className:"flex gap-3",defaultValue:"x",children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(t.RadioGroupItem,{value:"static",id:"r1"}),e.jsx("label",{className:"text-sm",htmlFor:"r1",children:"Static"})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(t.RadioGroupItem,{value:"dynamic",id:"r2"}),e.jsx("label",{className:"text-sm",htmlFor:"r2",children:"Dynamic"})]})]})}function be({cardType:s,docContent:a,suffix:n="Chart"}){return e.jsx("div",{className:"space-y-6 px-6 py-2",children:e.jsxs(t.Accordion,{defaultValue:["item-2"],type:"multiple",children:[e.jsxs(t.AccordionItem,{value:"item-1",children:[e.jsx(t.AccordionTrigger,{children:`${t.titleCase(s)} ${n}`}),e.jsx(t.AccordionContent,{children:a||e.jsxs("div",{className:"space-y-4 font-mono text-xs",children:[e.jsx("div",{className:"rounded bg-muted px-2 py-1 text-xs",children:"SELECT label, measure FROM table"}),e.jsxs("ul",{className:"ml-6 list-disc text-xs [&>li]:mt-2",children:[e.jsx("li",{children:"label - category"}),e.jsx("li",{children:"measure - number"})]}),e.jsxs("div",{children:["See ",e.jsx("a",{target:"_blank",onClick:r=>r.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/docs/charts/pie-donut-polar",children:"example"})," in the docs."]})]})})]}),e.jsxs(t.AccordionItem,{value:"item-2",children:[e.jsx(t.AccordionTrigger,{children:"Settings"}),e.jsxs(t.AccordionContent,{className:"space-y-4 px-2",children:[s!=="text"&&e.jsx(Ke,{}),s==="text"&&e.jsx(ca,{})]})]}),!["range","text"].includes(s)&&e.jsxs(t.AccordionItem,{value:"item-3",children:[e.jsx(t.AccordionTrigger,{children:"Filters"}),e.jsxs(t.AccordionContent,{className:"space-y-4 px-2",children:[e.jsx(ie,{}),e.jsx(pe,{})]})]})]})})}function da(){const s=t.useEditorStore(r=>{var o,l;return(l=(o=r==null?void 0:r.card)==null?void 0:o.preferences)==null?void 0:l.sortChart}),{setSortChart:a}=t.useEditorActions();function n(){return e.jsxs("div",{className:"space-y-2",children:[e.jsx(t.Label,{children:"Sort"}),e.jsx(ee,{className:"h-8",label:"Sort Chart",options:[{label:"None",value:"none"},{label:"ASC",value:"asc"},{label:"DESC",value:"desc"}],value:s||"none",onValueChange:r=>{a(r)}})]})}return e.jsx("div",{className:"space-y-6 px-6 py-2",children:e.jsxs(t.Accordion,{defaultValue:["item-2"],type:"multiple",children:[e.jsxs(t.AccordionItem,{value:"item-1",children:[e.jsx(t.AccordionTrigger,{children:"Stacked Chart"}),e.jsxs(t.AccordionContent,{className:"space-y-4 font-mono text-xs",children:[e.jsx("div",{className:"rounded bg-muted px-2 py-1 text-xs",children:"SELECT x-axis, stack-by, y-axis FROM table"}),e.jsxs("ul",{className:"ml-6 list-disc text-xs [&>li]:mt-2",children:[e.jsx("li",{children:"x-axis - category"}),e.jsx("li",{children:"stack by - category"}),e.jsx("li",{children:"y-axis - number"})]}),e.jsxs("div",{children:["See ",e.jsx("a",{target:"_blank",onClick:r=>r.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/docs/charts/stacked",children:"example"})," in the docs."]})]})]}),e.jsxs(t.AccordionItem,{value:"item-2",children:[e.jsx(t.AccordionTrigger,{children:"Settings"}),e.jsxs(t.AccordionContent,{className:"space-y-4 px-2",children:[n(),e.jsx(Kt,{})]})]}),e.jsxs(t.AccordionItem,{value:"item-3",children:[e.jsx(t.AccordionTrigger,{children:"Filters"}),e.jsxs(t.AccordionContent,{className:"space-y-4 px-2",children:[e.jsx(ie,{}),e.jsx(pe,{})]})]})]})})}function ua({cardType:s="table"}){console.log("cardType",s);const a=t.useEditorStore(o=>{var l;return(l=o.card)==null?void 0:l.preferences}),n=t.useEditorStore(o=>o.actions.setCardPreferences),r=o=>{n({...a,allowDownload:o})};return e.jsxs("div",{className:"space-y-6 px-6 py-2",children:[e.jsx(t.Accordion,{defaultValue:["item-3"],type:"multiple",children:e.jsxs(t.AccordionItem,{value:"item-3",children:[e.jsx(t.AccordionTrigger,{children:"Filters"}),e.jsxs(t.AccordionContent,{className:"space-y-4 px-2",children:[e.jsx(ie,{}),e.jsx(pe,{})]})]})}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(t.Checkbox,{onCheckedChange:r,id:"allow-download"}),e.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 ma=e.jsxs("div",{className:"space-y-4 font-mono text-xs",children:[e.jsx("div",{className:"rounded bg-muted px-2 py-1 text-xs",children:"SELECT dimension, cohort, metric FROM table"}),e.jsxs("div",{children:["See ",e.jsx("a",{target:"_blank",onClick:s=>s.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/docs/charts/tornado",children:"example"})," in the docs."]})]}),ha=e.jsxs("div",{className:"space-y-4 font-mono text-xs",children:[e.jsx("div",{className:"rounded bg-muted px-2 py-1 text-xs",children:"SELECT y-axis, label, range-from, range-to, range-value FROM table"}),e.jsxs("div",{children:["See ",e.jsx("a",{target:"_blank",onClick:s=>s.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/docs/charts/range",children:"example"})," in the docs."]})]}),pa=e.jsxs("div",{className:"space-y-4 font-mono text-xs",children:[e.jsx("div",{className:"rounded bg-muted px-2 py-1 text-xs",children:"SELECT text FROM table limit 1"}),e.jsxs("div",{children:["See ",e.jsx("a",{target:"_blank",onClick:s=>s.stopPropagation(),className:"text-blue-700",href:"https://docs.semaphor.cloud/docs/charts/text",children:"example"})," in the docs."]})]});function xa(){const s=t.useEditorStore(n=>n.card.type);function a(n){switch(n){case"stackedBar":case"stackedLine":return e.jsx(da,{});case"pyramid":return e.jsx(be,{docContent:ma,cardType:n});case"kpi":return e.jsx(aa,{});case"line":case"bar":return e.jsx(Yn,{cardType:n});case"range":return e.jsx(be,{docContent:ha,cardType:n});case"pie":case"doughnut":case"polarArea":case"radar":return e.jsx(be,{cardType:n});case"bubble":case"scatter":return e.jsx(Zn,{cardType:n});case"table":return e.jsx(ua,{cardType:n});case"text":return e.jsx(be,{docContent:pa,cardType:n,suffix:"Visual"});case"map":return e.jsx(la,{});case"custom":return e.jsx(Kn,{});default:return e.jsx(ta,{})}}return e.jsxs(t.ScrollArea,{className:"h-full w-full text-sm",children:[a(s),e.jsx(t.ScrollBar,{orientation:"horizontal"})]})}function Zt({label:s,column:a,functions:n,onFunctionChange:r}){let o=n[0];"aggregate"in a?o=n.find(i=>i.value===a.aggregate)||n[0]:"granularity"in a&&(o=n.find(i=>i.value===a.granularity)||n[0]);function l(i){r(i)}return e.jsx(ee,{className:"flex h-8 w-8 justify-center overflow-clip rounded-none border-none bg-muted px-0 [&>svg]:hidden",icon:o.logo,options:n,value:o.value,onValueChange:i=>l(i),label:s,showPlaceholderLabel:!1})}const fa=[{label:"Sum",value:"SUM",logo:e.jsx(bt,{className:"size-3.5"})},{label:"Count",value:"COUNT",logo:e.jsx(xt,{className:"size-3.5"})},{label:"Unique",value:"DISTINCT",logo:e.jsx(Ms,{className:"size-3.5"})},{label:"Average",value:"AVG",logo:e.jsx(ds,{className:"size-3.5"})},{label:"Min",value:"MIN",logo:e.jsx(is,{className:"size-3.5"})},{label:"Max",value:"MAX",logo:e.jsx(xs,{className:"size-3.5"})}];function ga({column:s}){const{updateMetricColumn:a}=t.useEditorActions();let n=fa;t.isTextDataType(s.type)&&(n=n.filter(o=>["COUNT","DISTINCT"].includes(o.value))),t.isNumberDataType(s.type)&&(n=n.filter(o=>!["DISTINCT"].includes(o.value)));function r(o){const l={...s,aggregate:o,label:fe(s.name,o)};a(s.id,l)}return e.jsx(Zt,{column:s,functions:n,onFunctionChange:o=>r(o),label:"Aggregation"})}const ja=[{label:"Day (D)",value:"day",logo:e.jsx(t.Label,{className:"cursor-pointer text-xs",children:"D"})},{label:"Week (W)",value:"week",logo:e.jsx(t.Label,{className:"cursor-pointer text-xs",children:"W"})},{label:"Month (M)",value:"month",logo:e.jsx(t.Label,{className:"cursor-pointer text-xs",children:"M"})},{label:"Year (Y)",value:"year",logo:e.jsx(t.Label,{className:"cursor-pointer text-xs",children:"Y"})}];function ya({column:s}){const{updateTrendByColumn:a}=t.useEditorActions();function n(r){const o={...s,granularity:r,label:Et(s.name,r)};a(s.id,o)}return e.jsx(Zt,{column:s,functions:ja,onFunctionChange:r=>n(r),label:"Granularity"})}function ba({col:s,onChange:a,droppableId:n}){const{columns:r}=$e(),o=E.useMemo(()=>{let c=[];n===me&&(c=(r==null?void 0:r.filter(h=>t.isDateDataType(h.data_type)))||[]),(n===ue||n===re)&&(c=r);const d=c==null?void 0:c.filter(h=>h.column_name!==s.name);return d==null?void 0:d.map(h=>({id:h.column_name,value:h.column_name}))},[r,n,s.name]),l=[{id:s.name,value:s.name}];function i(c){const d=r==null?void 0:r.find(h=>{var u;return h.column_name===((u=c[0])==null?void 0:u.id)});d&&a(d)}return o!=null&&o.length?e.jsx(t.ComboBox2,{multiple:!1,options:o,selectedOptions:l,onChange:i,selectAllChecked:!1,onSelectAllCheckedChange:()=>{},inputClassName:"border-none bg-muted px-0"}):e.jsx("input",{disabled:!0,type:"text",className:"overflow-hidden truncate text-ellipsis whitespace-nowrap bg-muted text-sm",value:s.name})}function Xt({children:s,className:a,delayDuration:n}){return e.jsx(t.TooltipProvider$1,{children:e.jsxs(t.Tooltip,{delayDuration:n,children:[e.jsx(t.TooltipTrigger,{asChild:!0,children:e.jsx("span",{className:t.cn("overflow-hidden text-ellipsis whitespace-nowrap",a),children:s})}),e.jsx(t.TooltipContent,{children:s})]})})}function Sa({column:s}){const{updateMetricColumn:a}=t.useEditorActions(),{transformedMetricKeys:n,dimensionKeys:r}=Qt();console.log(n,r);const o=n.find(i=>i===s.label||i===s.name),l=o?n.indexOf(o):-1;return e.jsx("div",{className:"space-y-2",children:o&&e.jsx(Wt,{idx:l,col:o,children:e.jsx(t.Editable,{className:"w-[130px]",text:s.label||"",placeholder:"Enter label",onSave:i=>{a(s.id,{...s,label:i||s.name})},children:e.jsx(Xt,{className:"w-[130px]",children:s.label||s.name})})})})}function Ca({column:s,type:a,onRemoveColumn:n,droppableId:r}){const[o,l]=E.useState(!1),{updateGroupByColumn:i,updateMetricColumn:c,updateTrendByColumn:d}=t.useEditorActions(),{attributes:h,listeners:u,setNodeRef:x,transform:f,transition:m,isDragging:C}=t.useSortable({id:s.id,data:{type:a}}),p=f?{opacity:C?.5:void 0,transform:t.CSS.Translate.toString(f),transition:m}:void 0;function y(N){const T=t.isNumberDataType(N.data_type),_=t.isTextDataType(N.data_type),R=t.isDateDataType(N.data_type),U=T?"number":_?"string":R?"date":"string";if(r===ue){const w={id:s.id,name:N.column_name,type:U,role:"groupby"};i(s.id,w)}if(r===re){const w={id:s.id,name:N.column_name,type:U,role:"metric",label:fe(N.column_name,"SUM"),aggregate:T?"SUM":"COUNT"};c(s.id,w)}if(r===me&&R){const w={id:s.id,name:N.column_name,type:U,role:"trendby",label:Et(N.column_name,"month"),granularity:"month"};d(s.id,w)}}function g(){if(r===re)return e.jsx("div",{"data-setting-container":"",className:"mt-1.5 max-h-32 overflow-y-auto rounded-md border border-border p-3 text-sm",children:e.jsx(Sa,{column:s})})}function S(){if(r===re)return e.jsx(ga,{column:s});if(r===me)return e.jsx(ya,{column:s})}function b(){return e.jsx("div",{className:t.cn("grow",{"pl-3":r===ue}),children:e.jsx(ba,{col:s,onChange:y,droppableId:r})})}function I(){return e.jsx("div",{"data-setting-actions":"",className:"flex h-full items-center gap-2",children:e.jsx("button",{onClick:()=>l(!o),children:o?e.jsx(Ys,{className:t.cn("size-3 cursor-pointer items-center justify-center rounded-r-sm text-muted-foreground")}):e.jsx(ht,{className:t.cn("size-3 cursor-pointer items-center justify-center rounded-r-sm text-muted-foreground")})})})}return e.jsx("div",{...u,...h,ref:x,style:p,children:e.jsxs("div",{className:"group flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"grow",children:[e.jsxs("div",{className:"flex h-8 grow items-center justify-between rounded-md bg-muted pl-2",children:[I(),S(),b()]}),o&&g()]}),e.jsx("div",{className:t.cn("opacity-0 transition-opacity duration-200 group-hover:opacity-100",{hidden:o}),children:e.jsx("button",{onClick:()=>n(s.id),children:e.jsx(t.X,{className:"size-3 cursor-pointer text-muted-foreground"})})})]})})}function Oe({id:s,label:a,columns:n,previewColumns:r,sortableType:o,onRemoveColumn:l}){const{setNodeRef:i}=t.useDroppable({id:s}),c=t.useDndStore(u=>u.activeId),d={},h=c?r:n;return e.jsx(t.SortableContext,{items:n==null?void 0:n.map(u=>u.id),children:e.jsxs("div",{className:"space-y-2 rounded-md border-2 border-dashed p-4",ref:i,style:d,children:[e.jsx(t.Label,{className:"text-sm",children:a}),e.jsx("div",{className:"space-y-2",children:h==null?void 0:h.map(u=>u.id===Dt.id?e.jsx(va,{},u.id):e.jsx(Ca,{droppableId:s,type:o,column:u,onRemoveColumn:l},u.id))})]})})}function va(){return e.jsx("div",{className:"flex h-7 grow items-center space-x-2 rounded-md border border-dashed border-muted-foreground bg-background px-2 py-1 text-sm"})}function es({children:s,id:a,type:n}){const{attributes:r,listeners:o,setNodeRef:l,transform:i,transition:c,isDragging:d}=t.useSortable({id:a,data:{type:n}}),h=i?{opacity:d?.5:void 0,transform:t.CSS.Translate.toString(i),transition:c}:void 0;return e.jsx("div",{...o,...r,ref:l,style:h,children:s})}function Na(){const s=t.useEditorStore(S=>{var b;return(b=S.card.queryConfig)==null?void 0:b.orderBy})||[],a=t.useEditorStore(S=>{var b;return(b=S.card.queryConfig)==null?void 0:b.groupByColumns})||[],n=t.useEditorStore(S=>{var b;return(b=S.card.queryConfig)==null?void 0:b.trendByColumns})||[],r=t.useEditorStore(S=>{var b;return(b=S.card.queryConfig)==null?void 0:b.metricColumns})||[],{addOrderByColumn:o,removeOrderByColumn:l,updateOrderByColumn:i}=t.useEditorActions(),c=[...a,...n,...r];if(c.length===0)return e.jsx(e.Fragment,{});const d=e.jsx(ps,{className:"size-3.5 text-muted-foreground hover:text-foreground"}),h=e.jsx(ls,{className:"size-3.5 text-muted-foreground hover:text-foreground"}),u=e.jsx(hs,{className:"size-3.5 text-muted-foreground hover:text-foreground"}),x=e.jsx(os,{className:"size-3.5 text-muted-foreground hover:text-foreground"}),f=c==null?void 0:c.filter(S=>!s.some(b=>b.columnId===S.id)).map(S=>({id:S.id,value:S.label||S.name}));function m(S,b){const I=C(S);return I?I.role==="metric"?b==="asc"?u:x:b==="asc"?d:h:null}function C(S){return c.find(b=>b.id===S)}function p(S){const b=s.find(I=>I.columnId===S);if(b){const I={...b,direction:b.direction==="asc"?"desc":"asc"};i(I)}}const y=S=>{o({columnId:S.id,direction:"asc"})};function g(S){const b=s.find(I=>I.columnId===S);b&&l(b)}return e.jsx(t.SortableContext,{items:s.map(S=>xe(S.columnId)),children:e.jsxs("div",{className:"space-y-2 rounded-md border border-border p-4 text-sm",children:[e.jsx(t.Label,{className:"text-sm",children:"Order by"}),f.length>0&&e.jsx("div",{className:"mr-5",children:e.jsx(t.ComboBox2,{multiple:!1,options:f,selectedOptions:[],onChange:S=>y(S[0]),selectAllChecked:!1,onSelectAllCheckedChange:()=>{},inputClassName:"h-8"})}),s.map(S=>{var b,I;return e.jsx(es,{id:xe(S.columnId),type:Qe,children:e.jsx("div",{className:"group flex h-8 items-center gap-2 rounded-sm p-0",children:e.jsxs("div",{className:"flex h-full grow items-center justify-between gap-2",children:[e.jsxs("div",{className:"flex h-full grow items-center justify-between gap-2 rounded-sm bg-muted px-2",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(ht,{className:"size-3 cursor-move text-muted-foreground hover:text-foreground"}),e.jsx(Xt,{className:"w-[175px] text-sm",children:((b=C(S.columnId))==null?void 0:b.label)||((I=C(S.columnId))==null?void 0:I.name)})]}),e.jsx("button",{title:S.direction==="asc"?"Ascending":"Descending",onClick:()=>p(S.columnId),className:"rounded-sm p-0",children:m(S.columnId,S.direction)})]}),e.jsx("div",{children:e.jsx("button",{onClick:()=>g(S.columnId),className:"rounded-sm p-0",children:e.jsx(t.X,{className:"size-3 text-muted-foreground opacity-0 transition-opacity duration-200 hover:text-foreground group-hover:opacity-100"})})})]})},S.columnId)},xe(S.columnId))})]})})}function wa(){const s=t.useEditorStore(y=>{var g;return((g=y.card.queryConfig)==null?void 0:g.groupByColumns)||[]}),a=t.useEditorStore(y=>y.card.type),n=t.useDndStore(y=>y.previewGroupByColumns),r=t.useEditorStore(y=>{var g;return((g=y.card.queryConfig)==null?void 0:g.metricColumns)||[]}),o=t.useDndStore(y=>y.previewMetricColumns),l=t.useEditorStore(y=>{var g;return((g=y.card.queryConfig)==null?void 0:g.trendByColumns)||[]}),i=t.useDndStore(y=>y.previewTrendByColumns),{removeColumnFromGroupBy:c,removeColumnFromMetricColumns:d,removeColumnFromTrendByColumns:h}=t.useEditorActions();function u(y){c(y)}function x(y){h(y)}function f(y){d(y)}let m="Group By",C="Trend By",p="Metrics";return a==="table"&&(m="Rows",C="Trend By",p="Columns"),e.jsxs("div",{className:"flex h-full w-full flex-col gap-4 py-4",children:[e.jsx($t,{iconClassName:"size-[19px]"}),e.jsxs(t.CustomScrollArea,{className:"flex min-h-0 grow basis-0 flex-col gap-4 overflow-y-auto",children:[e.jsxs("div",{className:"flex flex-col gap-4 p-4",children:[e.jsx(Oe,{onRemoveColumn:u,sortableType:Fe,id:ue,label:m,columns:s,previewColumns:n}),e.jsx(Oe,{onRemoveColumn:x,sortableType:Be,id:me,label:C,columns:l,previewColumns:i}),e.jsx(Oe,{onRemoveColumn:f,sortableType:Re,id:re,label:p,columns:r,previewColumns:o}),e.jsx(Na,{})]}),e.jsx(t.ScrollBar,{orientation:"horizontal"})]})]})}function Je({children:s,column:a,id:n,sortableType:r,className:o}){const[l,i]=E.useState(!1),{removeEditorFilter:c}=t.useEditorActions();function d(h){c(h)}return e.jsx(es,{id:n,type:r,children:e.jsxs("div",{className:t.cn("group space-y-1 rounded-md bg-muted px-3 py-2",{"border-border":l}),children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(t.Label,{className:"text-sm",children:a.name}),e.jsx("div",{"data-setting-actions":"",className:"invisible flex h-full items-center gap-2 group-hover:visible",children:e.jsx("button",{onClick:()=>d(a),children:e.jsx(t.X,{className:"size-3.5 cursor-pointer items-center justify-center rounded-r-sm text-muted-foreground"})})})]}),e.jsxs("div",{className:t.cn("group flex items-center rounded-t-md text-sm",!l&&"rounded-b-md",l&&"border border-border"),children:[e.jsx("div",{children:e.jsx(t.GripVertical,{className:"mr-2 size-3.5 cursor-move items-center justify-center p-0 text-muted-foreground/60 hover:text-foreground"})}),e.jsx("div",{className:t.cn("grow cursor-pointer overflow-hidden truncate text-ellipsis whitespace-nowrap",o),children:s})]})]})})}function ka({column:s,sortableType:a}){const n=t.useDashboardStore(S=>S.themeStyle),r=t.useEditorStore(S=>{var b,I;return(I=(b=S.card)==null?void 0:b.queryConfig)==null?void 0:I.filters}),{selectedConnectionId:o,selectedDatabaseName:l,selectedTableName:i}=te(),c=E.useMemo(()=>{var S;return(S=r==null?void 0:r.find(b=>b.filterColumnName===s.name))==null?void 0:S.filterValue},[r,s.name]),d=E.useMemo(()=>Array.isArray(c)?c.map(S=>({id:S,value:S})):[],[c]),{updateEditorFilterValue:h}=t.useEditorActions(),u={column:s.name,sql:s.sql,id:s.name,connectionId:o,dataType:s.type},{data:x,isLoading:f,isFetching:m,isError:C}=t.useFilterQuery(u),p=E.useMemo(()=>{var b;return u.column?(b=x==null?void 0:x.records)==null?void 0:b.map(I=>{let N=u.column.split(".").slice(-1)[0].replace(/"/g,"");return I[N]===void 0&&(N=N.toLowerCase()),{id:I[N],value:I[N]}}):[]},[x,u.column]);function y(S){const b=S.map(I=>I.id);h(s.name,b)}function g(){return f||m?e.jsx(t.Skeleton,{style:{borderRadius:n==null?void 0:n.controlInputRadius},className:"h-8 min-w-60 bg-foreground/10"}):C?e.jsx("div",{className:"flex h-8 min-w-60 items-center bg-muted px-2 text-sm",children:"Error"}):e.jsx(t.ComboBox2,{options:p,onChange:y,selectedOptions:d,selectAllChecked:!1,onSelectAllCheckedChange:()=>{}})}return e.jsx(Je,{className:"w-60",id:s.id,sortableType:a,column:s,children:g()})}function Ia({column:s,sortableType:a}){const[n,r]=E.useState(!1),{selectedConnectionId:o,selectedDatabaseName:l,selectedTableName:i}=te(),c={column:s.name,sql:s.sql,id:s.name,connectionId:o,title:"",dataType:s.type},{isLoading:d,isFetching:h,isError:u,data:x}=t.useFilterQuery(c),f=x==null?void 0:x.records,{dateRange:m,setDateRange:C,initialDateRange:p}=t.useDateRangeFromRecords(f),{updateEditorFilterValue:y}=t.useEditorActions();function g(I){var T,_;const N={gte:(T=I==null?void 0:I.from)==null?void 0:T.toISOString(),lte:(_=I==null?void 0:I.to)==null?void 0:_.toISOString()};y(s.name,N)}function S(){y(s.name,null,!0),C(p)}function b(){return d||h?e.jsx("div",{children:e.jsx(t.Skeleton,{className:"h-8 w-72 bg-foreground/10"})}):u?e.jsx("div",{className:"h-8 w-72 bg-muted px-2",children:"Error"}):f?e.jsx(t.DateRangePopover,{title:c.title,open:n,inputClassName:"h-8",setOpen:r,dateRange:m,setDateRange:C,onApply:g,onClear:S}):e.jsx(t.Label,{className:"flex h-8 w-72 items-center bg-muted px-2",children:"No Data"})}return e.jsx(Je,{className:"w-72",id:s.id,sortableType:a,column:s,children:b()})}function Da({id:s,label:a,columns:n,previewColumns:r,sortableType:o}){const{setNodeRef:l}=t.useDroppable({id:s}),i=t.useDndStore(u=>u.activeId),c={};function d(u){const x=t.isDateDataType(u.type);return u.id===Dt.id?e.jsx(Je,{id:u.id,sortableType:o,column:u,children:e.jsx(Ea,{})},u.id):x?e.jsx(Ia,{droppableId:s,sortableType:o,column:u},u.id):e.jsx(ka,{droppableId:s,sortableType:o,column:u},u.id)}const h=i?r:n;return e.jsx(t.SortableContext,{items:n==null?void 0:n.map(u=>u.id),children:e.jsxs("div",{className:"space-y-2 rounded-md border-2 border-dashed p-5",ref:l,style:c,children:[e.jsx(t.Label,{className:"text-sm",children:a}),e.jsx("div",{className:"flex flex-wrap items-center gap-4",children:h==null?void 0:h.map(u=>d(u))})]})})}function Ea(){return e.jsx("div",{className:"flex h-8 w-60 items-center space-x-2 rounded-md border border-dashed border-muted-foreground bg-background px-2 py-1 text-sm"})}function Ta(){const s=t.useEditorStore(o=>{var l;return((l=o.card.queryConfig)==null?void 0:l.filterColumns)||[]}),a=t.useDndStore(o=>o.previewFilterColumns),{removeColumnFromFilterColumns:n}=t.useEditorActions();function r(o){n(o)}return e.jsx("section",{className:"size-full px-4 pb-4",children:e.jsx(Da,{onRemoveColumn:r,sortableType:Ve,id:_e,label:"Filters",columns:s,previewColumns:a})})}function Ma(){const s=t.useEditorStore(r=>r.card),{data:a,errorMessage:n}=t.useDashboardCardQuery(s);return e.jsxs("section",{className:"flex justify-between gap-2 p-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Bt,{}),e.jsx(Mt,{sql:a==null?void 0:a.sql,error:n})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Rt,{}),e.jsx(Ft,{variant:"default"})]})]})}function Aa(){const s=E.useRef(null),a=t.useEditorStore(i=>i.isShowingVisual),n=t.useEditorStore(i=>i.showAIDialog),r=t.useEditorStore(i=>i.isDevMode);E.useEffect(()=>{var i,c;n?(i=s.current)==null||i.resize(0):(c=s.current)==null||c.resize(25)},[n]);function o(){return e.jsxs(e.Fragment,{children:[e.jsx(t.ResizablePanel,{role:"query-section",className:"flex",minSize:20,defaultSize:40,children:e.jsx(Tn,{})}),e.jsx(t.ResizableHandle,{withHandle:!0,className:"border"}),e.jsx(t.ResizablePanel,{className:"pb-1",role:"visual-section",minSize:0,defaultSize:60,children:a&&!n?e.jsxs(t.ResizablePanelGroup,{direction:"horizontal",children:[e.jsx(e.Fragment,{children:e.jsx(t.ResizablePanel,{ref:s,className:"flex",defaultSize:25,maxSize:30,children:e.jsx(xa,{})})}),!n&&e.jsx(t.ResizableHandle,{className:"border"}),e.jsx(t.ResizablePanel,{minSize:40,defaultSize:75,maxSize:100,children:e.jsx(ye,{})})]}):e.jsx(ye,{})})]})}function l(){return e.jsx(e.Fragment,{children:e.jsx(t.ResizablePanel,{className:"pb-1","data-biz-mode-container":"",minSize:0,defaultSize:100,children:a&&!n?e.jsxs(t.ResizablePanelGroup,{direction:"horizontal",children:[e.jsx(e.Fragment,{children:e.jsx(t.ResizablePanel,{ref:s,className:"flex min-w-[320px]",defaultSize:25,maxSize:30,children:e.jsx(wa,{})})}),!n&&e.jsx(t.ResizableHandle,{}),e.jsx(t.ResizablePanel,{minSize:40,defaultSize:75,maxSize:100,children:e.jsxs(t.ResizablePanelGroup,{direction:"vertical",children:[e.jsxs(t.ResizablePanel,{className:"flex min-h-fit flex-col",minSize:10,defaultSize:20,children:[e.jsx(Ma,{}),e.jsx(Ta,{})]}),e.jsx(t.ResizableHandle,{}),e.jsx(t.ResizablePanel,{minSize:20,defaultSize:80,children:e.jsx(ye,{})})]})})]}):e.jsx(ye,{})})})}return e.jsx(t.ResizablePanelGroup,{direction:"vertical",className:"min-h-[250px] min-w-full max-w-lg",children:r?o():l()})}const La=[{title:"Help me write a query for",subtitle:"orders by month"},{title:"Create a bar chart for",subtitle:"sales by category"}];function Oa(){const s=E.useRef(null),a=E.useRef(null),[n,r]=E.useState(!1),[o,l]=E.useState(t.isDevEnv),[i,c]=E.useState(!1),d=t.useEditorStore(O=>O.actions.setCardSql),h=t.useEditorStore(O=>O.actions.setRunSql),u=t.useEditorStore(O=>O.showAIDialog),{setShowAIDialog:x}=t.useEditorActions(),{messages:f,setMessages:m,reload:C,append:p,input:y,setInput:g,isLoading:S,handleAddCurrentTableToScope:b,removeFromCurrentSelections:I,currentAssitantScope:N,handleInputChange:T,handleSubmit:_,stop:R,chatStatus:U,toolStatus:w,llmUsage:V,errorMessage:$}=zt();t.useAssistantScroll({scrollContainerRef:s,inputRef:a,messages:f}),E.useEffect(()=>{var O;u&&((O=a.current)==null||O.focus())},[u]);function q(O){d(O),h(!0)}function j(O){const k={role:"user",content:O.title+" "+O.subtitle};p(k)}function D(){return e.jsxs(t.DropdownMenu,{children:[e.jsx(t.DropdownMenuTrigger,{asChild:!0,children:e.jsx(t.Button,{className:"h-7 p-2",size:"sm",variant:"ghost",children:e.jsx(mt,{className:"size-3.5 text-muted-foreground/70 hover:text-muted-foreground"})})}),e.jsxs(t.DropdownMenuContent,{align:"end",children:[e.jsx(t.DropdownMenuLabel,{children:"Options"}),e.jsx(t.DropdownMenuSeparator,{}),e.jsx(t.DropdownMenuCheckboxItem,{checked:n,onCheckedChange:r,children:"Token Usage"}),e.jsx(t.DropdownMenuCheckboxItem,{checked:o,onCheckedChange:l,children:"Tool Invocations"}),e.jsx(t.DropdownMenuCheckboxItem,{checked:i,onCheckedChange:c,children:"System Message"})]})]})}function M(){return e.jsxs("div",{"data-role":"header",children:[e.jsx("div",{className:"text-lg font-semibold",children:"Assistant"}),N&&N.length>0&&e.jsx("div",{className:"mt-2 flex flex-wrap items-center gap-2",children:N==null?void 0:N.map((O,k)=>e.jsxs("div",{className:"flex items-center gap-2 rounded-md border border-border bg-muted px-2 py-1 text-xs",children:[t.getFormattedTableNameForQuery({schemaName:O.schemaName||"",tableName:O.tableName||"",modelName:O.datamodelName||"",connectionType:O.connectionType||"",databaseName:O.databaseName||""}),e.jsx("button",{onClick:()=>{I(O)},children:e.jsx(t.X,{className:"size-3 text-muted-foreground hover:text-foreground"})})]},k))}),(N==null?void 0:N.length)===0&&e.jsxs("div",{className:"mt-2 flex items-center gap-2",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:"Context: None"}),e.jsxs(t.Button,{className:"h-6 text-xs",size:"sm",variant:"secondary",onClick:b,children:[e.jsx(t.Plus,{className:"mr-2 size-3"}),"Current Table"]})]})]})}const G=(y==null?void 0:y.length)===0&&(f==null?void 0:f.filter(O=>O.role==="user").length)===0;return e.jsxs("div",{"data-role":"editor-assistant",className:"flex h-full w-full flex-col justify-between gap-2 px-6 py-4",children:[e.jsxs("div",{"data-role":"header-section",className:"flex items-start justify-between gap-2",children:[M(),e.jsxs("div",{"data-role":"header-actions",className:"flex items-center",children:[D(),e.jsx(t.Button,{className:"h-7 p-2",size:"sm",variant:"ghost",onClick:()=>{m([]),C()},children:e.jsx(t.RefreshCcw,{className:"size-3.5 text-muted-foreground"})}),e.jsx(t.Button,{className:"h-7 p-2",size:"sm",variant:"ghost",onClick:()=>{x(!1)},children:e.jsx(t.X,{className:"size-4"})})]})]}),e.jsx(t.CustomScrollArea,{ref:s,className:"flex w-full grow basis-0",children:e.jsxs("div",{className:"space-y-4 py-2 pr-3","data-role":"messages",children:[e.jsx(t.PrintMessages,{messages:f,showTools:o,handleRun:q,showSystemMessage:i}),e.jsx(t.ChatStatus,{status:t.getStatus(U,w),isLoading:S})]})}),G&&e.jsx(t.Placeholders,{onClick:j,placeholders:La}),e.jsx(t.ChatInput,{onFocus:()=>{b()},stop:R,ref:a,setInput:g,input:y,handleInputChange:T,handleSubmit:_,isLoading:S}),V&&n&&e.jsx("div",{className:"flex h-8 items-center justify-between",children:e.jsxs("div",{className:"text-xs text-muted-foreground",children:["Usage: ",V.promptTokens," prompt tokens,"," ",V.completionTokens," completion tokens,"," ",V.totalTokens," total tokens"]})}),$&&e.jsx("div",{className:"flex items-center justify-between text-xs text-muted-foreground",children:e.jsx("span",{children:$})})]})}function za({authToken:s,onSave:a,onClose:n}){const r=E.useRef(null),o=t.useEditorStore(y=>y.showAIDialog),{setAuthToken:l}=t.useDashboardActions(),{setShowAIDialog:i,setOnSave:c,setOnClose:d}=t.useEditorActions(),{handleDragOver:h,handleDragEnd:u,handleDragStart:x,handleDragCancel:f,sensors:m}=xn();E.useEffect(()=>{a&&c(a),n&&d(n)},[a,c,n,d]),E.useEffect(()=>{s&&s.accessToken&&l(s)},[s,l]),E.useEffect(()=>{var y,g;o?((y=r.current)==null||y.resize(40),i(!0)):(i(!1),(g=r.current)==null||g.resize(0))},[o,i]);function C(y){y<1?i(!1):o||i(!0)}function p(){return e.jsxs(t.ResizablePanelGroup,{"data-content":"editor-main",className:"grow",direction:"horizontal",children:[e.jsx(t.ResizablePanel,{className:"min-w-[510px] rounded-none border-x-[1px]",children:e.jsx(Aa,{})}),e.jsx(t.ResizableHandle,{}),e.jsx(t.ResizablePanel,{"data-role":"editor-assistant-panel",ref:r,onResize:C,defaultSize:0,children:e.jsx(Oa,{})})]})}return e.jsx(t.ErrorBoundary,{FallbackComponent:t.Fallback,children:e.jsx(t.DndContext,{sensors:m,onDragStart:x,onDragEnd:u,onDragOver:h,onDragCancel:f,children:e.jsxs("section",{className:"isolate flex h-full grow","data-content":"editor-panel",children:[e.jsx(Tt,{type:"main"}),p()]})})})}function Fa(){t.useDashboardStore(i=>i.selectedCardId);const s=t.useDashboardStore(i=>i.selectedSheetId),{setIsVisualEditing:a}=t.useDashboardStore(i=>i.actions),n=t.useDashboardStore(i=>i.isVisualEditing),r=t.useDashboardStore(i=>i.actions.updateFrame);function o(i){s&&(r(s,i),a(!1))}function l(){a(!1)}return e.jsx("div",{role:"editor-container",className:t.cn("flex grow",{"max-h-0 overflow-hidden":!n}),children:e.jsx(za,{onSave:o,onClose:l})})}function Ra(){const s=t.useEditorStore(l=>l.selectedDatabaseName),a=t.useEditorStore(l=>l.selectedTableName),n=t.useDashboardStore(l=>l.dashboard.filters)||[],{columns:r}=te(),{assignFilter:o}=Yt();return e.jsx(t.ScrollArea,{className:"flex-1 basis-0 flex-col px-3",children:r==null?void 0:r.map(l=>{const i=n==null?void 0:n.find(c=>c.column===t.fmt(l.column_name)&&c.table===a&&c.database===s);return e.jsx("div",{onClick:()=>o(l),className:t.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":i}),children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ue,{column:l}),e.jsx("span",{children:l.column_name})]})},l.column_name)})})}function Ba(){t.useDashboardStore(a=>a.showFilters);const s=t.useDashboardStore(a=>a.actions.setShowFilters);return e.jsxs("section",{className:"relative flex min-w-[320px] grow flex-col border-l px-1",children:[e.jsxs("div",{className:"mt-4 flex items-center justify-between gap-2 px-3",children:[e.jsx(t.Label,{className:"px-2 text-lg",children:"Filters"}),e.jsx(t.Button,{onClick:()=>s(!1),className:"h-7 w-7 p-0",variant:"ghost",children:e.jsx(t.Cross2Icon,{})})]}),e.jsx("div",{className:"flex grow",children:e.jsx(Tt,{type:"filter",ColumnsComponent:()=>e.jsx(Ra,{})})})]})}function _a(){const s=t.useDashboardStore(r=>r.dashboard.filters),a=t.useDashboardStore(r=>r.theme),n=s==null?void 0:s.filter(r=>r.hide);return n!=null&&n.length?e.jsx("div",{className:t.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)]":a==="light","bg-[repeating-linear-gradient(45deg,_#18171d_0_3px,_#272729_3px_6px)]":a==="dark"}),children:n==null?void 0:n.map(r=>e.jsxs("div",{className:"flex min-w-[250px] max-w-fit flex-col gap-1 p-2",children:[e.jsx(t.FilterHeader,{filter:r}),e.jsx(t.FilterComponent,{filter:r})]},r.id))}):null}function Va(){const s=t.useDashboardStore(r=>r.showFilters),a=t.useDashboardStore(r=>r.isVisualEditing),n=t.useDashboardStore(r=>r.isDashboardEditing);return e.jsxs("div",{role:"dashboard-plus-main",className:t.cn("",{"max-h-0 overflow-hidden":a,"flex grow overflow-auto":!a}),children:[e.jsxs("section",{className:"flex grow flex-col",children:[n&&e.jsx(_a,{}),e.jsx(t.DashboardTabs,{})]}),s&&e.jsx("div",{role:"filter-aside-container",className:"flex",children:e.jsx(Ba,{})})]})}function qa(){const s=t.useDashboardStore(o=>o.dashboard),a=t.useDashboardStore(o=>o.actions.setDashboard),n=t.useDashboardStore(o=>o.showDashboardJSON),r=t.useDashboardStore(o=>o.actions.setShowDashboardJSON);return e.jsxs("div",{className:t.cn("relative p-2",{hidden:!n}),children:[e.jsxs(t.Button,{variant:"secondary",size:"sm",className:"absolute right-2 top-2 z-10 h-8",onClick:()=>r(!1),children:[e.jsx(t.X,{className:"mr-2 h-4 w-4"}),"Close"]}),e.jsx(t.de,{onChange:o=>{if(o)try{JSON.parse(o),a(JSON.parse(o))}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 Pa({showControls:s=!1,showFooter:a=!0,...n}){return e.jsx(t.ErrorBoundary,{FallbackComponent:t.Fallback,children:e.jsxs(t.SemaphorContextProvider,{dashboardProps:n,children:[e.jsx(t.$e,{}),e.jsxs(t.UXProvider,{children:[e.jsx(qa,{}),e.jsxs(t.DashboardPanel,{...n,children:[s&&e.jsx(dn,{}),e.jsx(Fa,{}),e.jsx(Va,{})]})]})]})})}exports.Dashboard=t.Dashboard;exports.DashboardWC=t.DashboardWC;exports.SemaphorDataProvider=t.SemaphorQueryClient;exports.SemaphorQueryClient=t.SemaphorQueryClient;exports.createSqlGenConfig=t.createSqlGenConfig;exports.fmt=t.fmt;exports.getColumnDataType=t.getColumnDataType;exports.getFilterValueType=t.getFilterValueType;exports.getFormattedTableNameForQuery=t.getFormattedTableNameForQuery;exports.getQualifiedTableName=t.getQualifiedTableName;exports.getSql=t.getSql;exports.invalidateToken=t.invalidateToken;exports.isBooleanDataType=t.isBooleanDataType;exports.isColumnInSqlGen=t.isColumnInSqlGen;exports.isDateDataType=t.isDateDataType;exports.isNumberDataType=t.isNumberDataType;exports.isTextDataType=t.isTextDataType;exports.resolveDataType=t.resolveDataType;exports.resolveDatamodelName=t.resolveDatamodelName;exports.useCard=t.useCard;exports.useDashboardActions=t.useDashboardActions;exports.useDashboardStore=t.useDashboardStore;exports.useDateFilterHook=t.useDateFilterHook;exports.useEditorActions=t.useEditorActions;exports.useEditorStore=t.useEditorStore;exports.useTextFilterHook=t.useTextFilterHook;exports.ScheduleDashboard=kt;exports.SelectComponent=ce;exports.Surfboard=Pa;exports.cleanCard=vt;exports.downloadPdf=wt;exports.getDashbaordStateWithoutData=Ge;exports.useEditorAside=te;