react-semaphor 0.0.442 → 0.0.443

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,89 +1,89 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./chunks/index-FRYWDG03.js"),e=require("react/jsx-runtime"),I=require("react");require("react-dom");function ns(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 me=ns(I);/**
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./chunks/index-BncyO_fn.js"),e=require("react/jsx-runtime"),D=require("react");require("react-dom");function os(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 pe=os(D);/**
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 as=t.createLucideIcon("AlignCenter",[["path",{d:"M17 12H7",key:"16if0g"}],["path",{d:"M19 18H5",key:"18s9l3"}],["path",{d:"M21 6H3",key:"1jwq7v"}]]);/**
6
+ */const is=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 rs=t.createLucideIcon("AlignLeft",[["path",{d:"M15 12H3",key:"6jk70r"}],["path",{d:"M17 18H3",key:"1amg6g"}],["path",{d:"M21 6H3",key:"1jwq7v"}]]);/**
11
+ */const ls=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 os=t.createLucideIcon("AlignRight",[["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M21 18H7",key:"1ygte8"}],["path",{d:"M21 6H3",key:"1jwq7v"}]]);/**
16
+ */const cs=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 is=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 ds=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 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"}]]);/**
26
+ */const us=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"}]]);/**
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 lt=t.createLucideIcon("ArrowDown",[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]]);/**
31
+ */const dt=t.createLucideIcon("ArrowDown",[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]]);/**
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 cs=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"}]]);/**
36
+ */const ms=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"}]]);/**
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 ds=t.createLucideIcon("ArrowLeft",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]);/**
41
+ */const hs=t.createLucideIcon("ArrowLeft",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]);/**
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 us=t.createLucideIcon("ArrowRight",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]]);/**
46
+ */const ps=t.createLucideIcon("ArrowRight",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]]);/**
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 ms=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"}]]);/**
51
+ */const xs=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"}]]);/**
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 hs=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"}]]);/**
56
+ */const fs=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"}]]);/**
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 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"}]]);/**
61
+ */const gs=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"}]]);/**
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 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"}]]);/**
66
+ */const js=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"}]]);/**
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 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"}]]);/**
71
+ */const ys=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"}]]);/**
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 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"}]]);/**
76
+ */const bs=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"}]]);/**
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 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"}]]);/**
81
+ */const Ss=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"}]]);/**
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 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"}]]);/**
86
+ */const Cs=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"}]]);/**
87
87
  * @license lucide-react v0.453.0 - ISC
88
88
  *
89
89
  * This source code is licensed under the ISC license.
@@ -93,7 +93,7 @@
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 ct=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"}]]);/**
96
+ */const ut=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"}]]);/**
97
97
  * @license lucide-react v0.453.0 - ISC
98
98
  *
99
99
  * This source code is licensed under the ISC license.
@@ -103,147 +103,147 @@
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 dt=t.createLucideIcon("ChartNoAxesGantt",[["path",{d:"M8 6h10",key:"9lnwnk"}],["path",{d:"M6 12h9",key:"1g9pqf"}],["path",{d:"M11 18h7",key:"c8dzvl"}]]);/**
106
+ */const mt=t.createLucideIcon("ChartNoAxesGantt",[["path",{d:"M8 6h10",key:"9lnwnk"}],["path",{d:"M6 12h9",key:"1g9pqf"}],["path",{d:"M11 18h7",key:"c8dzvl"}]]);/**
107
107
  * @license lucide-react v0.453.0 - ISC
108
108
  *
109
109
  * This source code is licensed under the ISC license.
110
110
  * See the LICENSE file in the root directory of this source tree.
111
- */const ut=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"}]]);/**
111
+ */const ht=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"}]]);/**
112
112
  * @license lucide-react v0.453.0 - ISC
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 mt=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"}]]);/**
116
+ */const pt=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"}]]);/**
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 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"}]]);/**
121
+ */const vs=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"}]]);/**
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 ht=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"}]]);/**
126
+ */const xt=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"}]]);/**
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 Ss=t.createLucideIcon("Clock",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16 14",key:"68esgv"}]]);/**
131
+ */const Ns=t.createLucideIcon("Clock",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16 14",key:"68esgv"}]]);/**
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 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"}]]);/**
136
+ */const ws=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"}]]);/**
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 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"}]]);/**
141
+ */const ks=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"}]]);/**
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 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"}]]);/**
146
+ */const Is=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"}]]);/**
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 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"}]]);/**
151
+ */const Ds=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"}]]);/**
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 ks=t.createLucideIcon("DollarSign",[["line",{x1:"12",x2:"12",y1:"2",y2:"22",key:"7eqyqh"}],["path",{d:"M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6",key:"1b0p4s"}]]);/**
156
+ */const Es=t.createLucideIcon("DollarSign",[["line",{x1:"12",x2:"12",y1:"2",y2:"22",key:"7eqyqh"}],["path",{d:"M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6",key:"1b0p4s"}]]);/**
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 pt=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"}]]);/**
161
+ */const ft=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"}]]);/**
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 xt=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"}]]);/**
166
+ */const gt=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"}]]);/**
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 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"}]]);/**
171
+ */const Ts=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"}]]);/**
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 ft=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"}]]);/**
176
+ */const jt=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"}]]);/**
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 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"}]]);/**
181
+ */const Ms=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"}]]);/**
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 Es=t.createLucideIcon("FileCode2",[["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:"m5 12-3 3 3 3",key:"oke12k"}],["path",{d:"m9 18 3-3-3-3",key:"112psh"}]]);/**
186
+ */const As=t.createLucideIcon("FileCode2",[["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:"m5 12-3 3 3 3",key:"oke12k"}],["path",{d:"m9 18 3-3-3-3",key:"112psh"}]]);/**
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 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"}]]);/**
191
+ */const Ls=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 gt=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 yt=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 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"}]]);/**
201
+ */const Os=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 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"}]]);/**
206
+ */const zs=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 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"}]]);/**
211
+ */const Fs=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 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"}]]);/**
216
+ */const Rs=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 jt=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 bt=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 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"}]]);/**
226
+ */const _s=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 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"}]]);/**
231
+ */const Bs=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 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"}]]);/**
236
+ */const Vs=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 _s=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 qs=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 Bs=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 Ps=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.
@@ -253,87 +253,87 @@
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 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"}]]);/**
256
+ */const Hs=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 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"}]]);/**
261
+ */const Gs=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 yt=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 St=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 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"}]]);/**
271
+ */const Us=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 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"}]]);/**
276
+ */const nt=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 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"}]]);/**
281
+ */const at=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 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"}]]);/**
286
+ */const $s=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 $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"}]]);/**
291
+ */const Qs=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 bt=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 Ct=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 St=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 vt=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 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"}]]);/**
306
+ */const Ks=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 Ks=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"}]]);/**
311
+ */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"}]]);/**
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 Ct=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"}]]);/**
316
+ */const Nt=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"}]]);/**
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 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"}]]);/**
321
+ */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"}]]);/**
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 Ws=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"}]]);/**
326
+ */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"}]]);/**
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 vt=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"}]]);/**
331
+ */const wt=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"}]]);/**
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 Ys=t.createLucideIcon("Square",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]);/**
336
+ */const Zs=t.createLucideIcon("Square",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]);/**
337
337
  * @license lucide-react v0.453.0 - ISC
338
338
  *
339
339
  * This source code is licensed under the ISC license.
@@ -343,35 +343,35 @@
343
343
  *
344
344
  * This source code is licensed under the ISC license.
345
345
  * See the LICENSE file in the root directory of this source tree.
346
- */const Zs=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"}]]);/**
346
+ */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"}]]);/**
347
347
  * @license lucide-react v0.453.0 - ISC
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 Xs=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"}]]);/**
351
+ */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"}]]);/**
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 Nt=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"}]]);/**
356
+ */const kt=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"}]]);/**
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 en=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"}]]);/**
361
+ */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"}]]);/**
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 wt=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 $e(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=>kt(i))}})}})}}function kt(s){return{...s,customCfg:tn(s.customCfg),data:[]}}function tn(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 sn(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 _e(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 nn(s,a){return a?await t.postRequest("https://semaphor.cloud/api/v1/lens",a,{operation:"delete",lensId:s}):null}function an(){const[s,a]=I.useState(""),[n,r]=I.useState(!1),o=t.useDashboardStore(p=>p.lenses),{setLenses:l,setSelectedLensId:i}=t.useDashboardActions(),[u,c]=I.useState(!1),[h,d]=I.useState(!1),f=t.useDashboardStore(p=>p.dashboard),y=t.useDashboardStore(p=>p.filterValues),{authToken:m}=t.useSemaphorContext();async function b(){c(!0);const p=$e(f),j=await sn(s,p,y,m==null?void 0:m.accessToken);j&&(l([...o||[],j]),i(j.id),d(!1)),c(!1)}return e.jsxs(t.Dialog,{open:h,onOpenChange:d,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:b,disabled:u,children:u?"Creating...":"Add"})})]})]})}function rn(){const[s,a]=I.useState(!1),n=t.useDashboardStore(d=>d.lenses),r=t.useDashboardStore(d=>d.selectedLensId),{setLenses:o,setSelectedLensId:l}=t.useDashboardActions(),{authToken:i}=t.useSemaphorContext();async function u(d){l(d)}async function c(d){if(await nn(d,i==null?void 0:i.accessToken)){const y=n==null?void 0:n.filter(m=>m.id!==d);o(y||[]),l("original")}}async function h(d){const f=n==null?void 0:n.map(b=>b.id===d.id?{...b,isDefault:!d.isDefault}:{...b,isDefault:!1});o(f||[]);const y={...d,isDefault:!d.isDefault};await _e(y,i==null?void 0:i.accessToken);const m=n==null?void 0:n.find(b=>b.isDefault);if(m&&m.id!==d.id){const b={...m,isDefault:!1};await _e(b,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:u,children:[e.jsx(t.DropdownMenuRadioItem,{value:"original",children:"Original"}),n==null?void 0:n.map(d=>e.jsxs(t.DropdownMenuRadioItem,{className:"group flex justify-between gap-2",value:d.id,children:[e.jsx("p",{children:d.name}),e.jsxs("span",{className:"flex items-center gap-3",children:[e.jsx(zs,{onClick:f=>{f.preventDefault(),h(d)},className:t.cn("size-3.5 text-muted-foreground hover:cursor-pointer hover:text-foreground group-hover:visible",{invisible:!d.isDefault,"text-green-500":d.isDefault}),strokeWidth:1.5}),e.jsx(t.Cross2Icon,{onClick:f=>{f.preventDefault(),c(d.id)},className:"invisible size-3.5 text-muted-foreground hover:cursor-pointer hover:text-foreground group-hover:visible",strokeWidth:1.5})]})]},d.id))]})]})]})}function Dt(){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 It(){const s=t.useDashboardStore.getState().isDownloadingPdf,{authToken:a,theme:n,filterValues:r,dashboardTitle:o,selectedSheetId:l}=Dt();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 u=`https://semaphor.cloud/api/v1/generate-pdf?params=${encodeURIComponent(i.toString())}`;t.useDashboardStore.setState({isDownloadingPdf:!0});const d=(await(await fetch(u,{method:"GET",headers:{Authorization:`Bearer ${a==null?void 0:a.accessToken}`}})).json()).url,f=document.createElement("a");f.href=d;const y=`${o}-${new Date().toISOString()}.pdf`;f.download=y,f.click(),t.useDashboardStore.setState({isDownloadingPdf:!1})}function on({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 It()}return e.jsx(t.IconButton,{tooltip:"Download PDF",className:"h-7 p-2",onClick:r,children:n?e.jsx(le,{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:u=!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}),u&&e.jsx(t.SelectValue,{placeholder:a})]})}),e.jsx(t.SelectContent,{children:e.jsxs(t.SelectGroup,{children:[e.jsx(t.SelectLabel,{children:a}),n.map(c=>e.jsx(t.SelectItem,{value:c.value,children:c.label},c.value))]})})]})}const nt=[{value:"daily",label:"Daily"},{value:"weekly",label:"Weekly"},{value:"biweekly",label:"Bi-Weekly"},{value:"monthly",label:"Monthly"}];function Et({triggerButtonClassName:s}){const{data:a,handleScheduleSubscription:n,handleDeleteSubscription:r,status:o,error:l,isDeleting:i}=ln(),[u,c]=I.useState(""),[h,d]=I.useState(nt[0].value),[f,y]=I.useState("06:00"),[m,b]=I.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:u,onChange:p=>c(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=>{b(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:nt,value:h,onValueChange:p=>d(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:f,onChange:p=>y(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:u,frequency:h,time:f,subject:m}),y("00:00"),c(""),b("")},className:"h-8 p-2",disabled:o==="loading"||!u,children:[o==="loading"&&e.jsx(le,{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(ht,{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(at,{tooltip:`Next Run: ${new Date(p.nextRun).toLocaleString()} ${p.timezone}`,children:e.jsx(bs,{className:"size-3.5"})}),e.jsx(at,{tooltip:`${p.endUserEmail}`,children:e.jsx(qs,{className:"size-3.5"})}),i===p.id?e.jsx(le,{className:"size-3.5 animate-spin"}):e.jsx(en,{onClick:()=>r(p.id),className:"size-3.5 cursor-pointer"})]})]},p.id))})]})]})]})})]})})}const at=({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 ln(){const[s,a]=I.useState("idle"),[n,r]=I.useState(""),[o,l]=I.useState(null),i=t.useDashboardStore(C=>C.authToken),u=t.useDashboardStore(C=>C.dashboard.id),c=t.useDashboardStore(C=>C.dashboard.title),{endUserId:h}=t.getTenantAndEndUserId((i==null?void 0:i.accessToken)||""),d="https://semaphor.cloud/api/v1/subscriptions/get",f={dashboardId:u,endUserId:h},{data:y,isLoading:m,isError:b,isFetching:p,refetch:j}=t.useQuery({queryKey:["subscriptions",u,h],queryFn:()=>t.getRequest(d,(i==null?void 0:i.accessToken)||"",f),enabled:!!(i!=null&&i.accessToken)&&!!u&&!!h});async function x({email:C,subject:M,frequency:N,time:E}){const{authToken:R,..._}=Dt(),U=Intl.DateTimeFormat().resolvedOptions().timeZone,w={email:C,frequency:N,time:E,timezone:U,endUserId:h,endUserEmail:C,subject:M||c||"Scheduled Dashboard",dashboardId:u,dashboardParams:_};a("loading");const z="https://semaphor.cloud/api/v1/subscriptions/create";try{const $=await t.postRequestRegular(z,(R==null?void 0:R.accessToken)||"",{...w});a("success"),r(""),j(),setTimeout(()=>{a("idle")},2e3)}catch($){console.error($),a("error"),r($.message)}}async function S(C){const M="https://semaphor.cloud/api/v1/subscriptions/delete";l(C);try{await t.postRequestRegular(M,(i==null?void 0:i.accessToken)||"",{id:C}),j(),setTimeout(()=>{l(null)},2e3)}catch(N){console.error(N),l(null),a("error"),r(N.message)}}return{data:y,isLoading:m,isFetching:p,isError:b,isDeleting:o,refetch:j,handleScheduleSubscription:x,handleDeleteSubscription:S,status:s,error:n}}function cn(){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),[u,c]=I.useState(!1),h=t.useDashboardStore(w=>w.filterValues),d=t.useDashboardStore(w=>w.isVisualEditing),f=t.useDashboardStore(w=>w.showFilters);t.useDashboardStore(w=>w.showDashboardJSON);const y=t.useDashboardStore(w=>w.onSaveFunction),m=t.useDashboardStore(w=>w.actions.setShowFilters),{addFrame:b,setSelectedFrameId:p}=t.useDashboardStore(w=>w.actions),{getSelectedSheet:j,setIsDashboardEditing:x,setShowDashboardJSON:S}=t.useDashboardStore(w=>w.actions),C=j(),{tenantId:M,endUserId:N}=I.useMemo(()=>t.getTenantAndEndUserId(s==null?void 0:s.accessToken),[s==null?void 0:s.accessToken]),E=I.useMemo(()=>M||N,[M,N]),R=()=>{if(!l||!C)return;const w={connectionId:i,id:t.v4(),title:"Title",description:"Description",preferences:{onClickFilter:[{columnIndex:0,expression:""}]},type:"bar",sql:"",data:[]},z={id:t.v4(),cards:[w],activeCardId:w.id};b(C.id,z),p(z.id)},_=()=>{x(!0)};async function U(){if(c(!0),!n||!r)return;const w=$e(o),z=JSON.stringify(w),$={...r,template:z,filterValues:h};await _e($,s==null?void 0:s.accessToken),t.ue.success("Lens saved"),y==null||y(w),c(!1)}return d?null:e.jsxs("div",{className:"flex items-center justify-between gap-2 border-b py-1 pl-3 pr-2",role:"dashboard-controls",children:[!d&&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,!d&&e.jsx(on,{}),!d&&e.jsx(Et,{}),l&&!d&&E&&e.jsx(an,{}),!d&&E&&e.jsx(rn,{}),l&&!d&&e.jsxs(t.Button,{variant:"secondary",className:"h-7 p-2",size:"sm",disabled:!l,onClick:R,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:_,size:"sm",children:e.jsx(t.Pencil,{className:"h-4 w-4"})}),l&&!d&&e.jsx(t.IconButton,{className:"h-7 p-2",onClick:()=>{x(!1),S(!1)},children:e.jsx(t.Cross2Icon,{className:"h-4 w-4"})}),l&&!d&&E&&e.jsx(t.Button,{className:"h-7 p-2",variant:"ghost",disabled:u,onClick:U,size:"sm",children:e.jsx(Ks,{className:"h-4 w-4"})}),!f&&!d&&l&&e.jsx(t.Button,{className:"h-7 p-2",variant:"ghost",onClick:()=>m(!0),size:"sm",children:e.jsx(gt,{className:"h-4 w-4"})}),!d&&l&&!1,!d&&!1]})]})}function dn({name:s,items:a,value:n,onChange:r,isLoading:o,isError:l,refetch:i,className:u,icon:c,showNone:h=!1}){const d=me.useRef(null),[f,y]=me.useState(!1),[m,b]=me.useState("100%"),p=h?[...a||[],{id:"none",name:"None"}]:a;me.useLayoutEffect(()=>{d.current&&b(d.current.offsetWidth)},[]);function j(){var S;return o?"Loading...":l?"Error":n?(S=a==null?void 0:a.find(C=>C.id===n))==null?void 0:S.name:`Select ${s}`}function x(S,C){r(C),y(!1)}return e.jsxs(t.Popover,{open:f,onOpenChange:y,children:[e.jsx(t.PopoverTrigger,{asChild:!0,children:e.jsxs(t.Button,{ref:d,variant:"outline",role:"combobox","aria-expanded":f,className:t.cn("flex h-9 w-full justify-between",u),children:[e.jsxs("div",{className:"flex items-center gap-2",children:[c&&e.jsx("div",{className:"mr-2",children:c}),e.jsx("span",{className:"max-w-[150px] overflow-hidden truncate text-ellipsis whitespace-nowrap",children:j()})]}),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(St,{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:C=>x(C,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 ue({title:s,items:a,value:n,isLoading:r,isError:o,refetch:l,onChange:i,showNone:u=!1,className:c,disabled:h=!1,type:d="combobox"}){const f=r?"Loading...":o?"Error":n;function y(){if(s==="Connection")return e.jsx($s,{className:"size-4"});if(s==="Database")return e.jsx(ws,{className:"size-4"});if(s==="Schema")return e.jsx(Us,{className:"size-4"});if(s==="Table")return e.jsx(Ue,{className:"size-4"});if(s==="Model")return e.jsx(gs,{className:"size-4"})}function m(){return e.jsxs(t.Select,{disabled:h,value:f,onValueChange:i,children:[e.jsx(t.SelectTrigger,{className:t.cn("h-9 w-full border-muted focus:ring-1 focus:ring-offset-0",c),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(St,{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:[u&&e.jsx(t.SelectItem,{value:"none",children:"None"},"none"),a&&a.map((p,j)=>e.jsx(t.SelectItem,{value:p.id,children:p.name},j))]}),(r||o)&&e.jsx(t.SelectItem,{value:f,children:f})]})})]})}function b(){return e.jsx(dn,{icon:y(),items:a,value:f,onChange:i||(()=>{}),isLoading:r,isError:o,refetch:l,name:s,showNone:u})}return e.jsx(t.TooltipProvider$1,{delayDuration:0,children:e.jsx("div",{className:"flex items-center gap-2",children:d==="select"?m():b()})})}function un({column:s}){const[a,n]=I.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),u=t.useEditorStore(p=>p.sqlGen),{modelItems:c,connectionType:h}=te(),d=t.useEditorStore(p=>p.actions.setSqlGen),f=t.useEditorStore(p=>p.actions.setCardSql),y=t.useEditorStore(p=>p.actions.setRunSql);function m(p,j){var M;const x=t.createSqlGenConfig(p,u,j),S=(M=c==null?void 0:c.find(N=>N.id===i))==null?void 0:M.name;d(x);const C=t.getSql(x,t.fmt(o||""),t.fmt(r),S,h,l||"");C&&(f(C),y(!0)),n(!1)}function b(){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(xt,{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:b()})]})}function Qe({column:s}){return e.jsxs(t.Tooltip,{children:[e.jsx(t.TooltipTrigger$1,{className:"shrink-0",asChild:!0,children:t.isTextDataType(s.data_type)?e.jsx(wt,{className:"size-3 text-muted-foreground"}):t.isNumberDataType(s.data_type)?e.jsx(jt,{className:"size-3 text-muted-foreground"}):t.isDateDataType(s.data_type)?e.jsx(t.Calendar,{className:"size-3 text-muted-foreground"}):t.isBooleanDataType(s.data_type)?e.jsx(Xs,{className:"size-3 text-muted-foreground"}):s.data_type.startsWith("json")?e.jsx(js,{className:"size-3 text-muted-foreground"}):e.jsx(Js,{className:"size-3 text-muted-foreground"})}),e.jsx(t.TooltipContent,{children:e.jsx("p",{className:"text-xs",children:s.data_type})})]})}function Te({column:s,className:a}){return e.jsxs("div",{className:t.cn("flex min-h-8 grow items-center space-x-2 px-2 text-sm",a),children:[e.jsx(Qe,{column:s}),e.jsx("span",{children:s.column_name})]})}function mn({id:s,children:a,type:n="column"}){const{attributes:r,listeners:o,setNodeRef:l,transform:i}=t.useDraggable({id:s,data:{type:n}}),u=i?{translate:t.CSS.Translate.toString(i),transform:t.CSS.Transform.toString(i)}:void 0;return e.jsx("div",{ref:l,style:u,...o,...r,children:a})}function hn({onClick:s,column:a}){const n=t.useDndStore(d=>d.activeId),r=t.useEditorStore(d=>{var f;return(f=d.card.queryConfig)==null?void 0:f.groupByColumns}),o=t.useEditorStore(d=>{var f;return(f=d.card.queryConfig)==null?void 0:f.metricColumns}),l=t.useEditorStore(d=>{var f;return(f=d.card.queryConfig)==null?void 0:f.filterColumns});function i(d){return u(d)||c(d)||h(d)}function u(d){return r==null?void 0:r.some(f=>f.name===d.column_name)}function c(d){return o==null?void 0:o.some(f=>f.name===d.column_name)}function h(d){return l==null?void 0:l.some(f=>f.name===d.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":i(a)}),children:[n===a.column_name&&e.jsx(t.DragOverlay,{children:e.jsx(Te,{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(Te,{column:a})}),e.jsx(mn,{id:a.column_name,type:"column",children:e.jsx(Te,{column:a})})]})}function Tt(s){const a=t.useDashboardStore(c=>c.authToken)||s,n=t.useEditorStore(c=>c.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)}),u=o==null?void 0:o.connections.find(c=>c.id===n);return{connectionsData:o,isConnectionsLoading:l,isConnectionsError:i,refetchConnections:r,currentConnection:u}}function Ke(s){var j;const a=t.useDashboardStore(x=>x.authToken)||s,n=t.useEditorStore(x=>x.selectedConnectionId),r=t.useEditorStore(x=>x.selectedDatabaseName),o=t.useEditorStore(x=>x.selectedDatamodelId),l=t.useEditorStore(x=>x.selectedSchemaName),i=t.useEditorStore(x=>x.selectedTableName),{currentConnection:u}=Tt(),c=u==null?void 0:u.type,{data:h,isLoading:d,isFetching:f,isError:y,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:b(c)});function b(x){return a!=null&&a.accessToken?!!(n&&r&&r!=="NA"&&l&&i||n&&(x==="S3"||x==="API")||o&&o):!1}return{columns:(j=h==null?void 0:h.columns)==null?void 0:j.map(x=>({...x,data_type:x.data_type.toLowerCase()})),isColumnsLoading:d,isColumnsFetching:f,isColumnsError:y,refetchColumns:m}}function te(s,a){var Ze,Xe,et,tt,st;const n=t.useSemaphorContext().authToken||s,r=t.useEditorStore(B=>B.selectedConnectionId),o=t.useEditorStore(B=>B.selectedDatamodelId),l=t.useEditorStore(B=>B.selectedDatabaseName),i=t.useEditorStore(B=>B.selectedSchemaName),u=t.useEditorStore(B=>B.selectedTableName),c=t.useEditorStore(B=>B.actions.setSelectedConnectionId),h=t.useEditorStore(B=>B.actions.setSelectedDatamodelId),d=t.useEditorStore(B=>B.actions.setSelectedDatabaseName),f=t.useEditorStore(B=>B.actions.setSelectedSchemaName),y=t.useEditorStore(B=>B.actions.setSelectedTableName);t.useEditorStore(B=>B.actions.setCardSql);function m(B){return r&&l&&i&&l!=="NA"?!0:r&&B==="API"?!1:!!(r&&B==="S3")}function b(B){return r&&B?!(B==="API"||B==="S3"):!1}const{refetchConnections:p,connectionsData:j,isConnectionsLoading:x,isConnectionsError:S,currentConnection:C}=Tt(s),{refetch:M,data:N,isLoading:E,isError:R}=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}),_=C==null?void 0:C.type,U=(C==null?void 0:C.type)==="API"||(C==null?void 0:C.type)==="S3",{data:w,isLoading:z,isFetching:$,isError:P,refetch:D}=t.useQuery({queryKey:["databases",r],queryFn:()=>t.getRequest("https://semaphor.cloud/api/v1/databases",(n==null?void 0:n.accessToken)||"",{connection_id:r}),enabled:b(_)}),{data:g,isLoading:T,isFetching:q,isError:A,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:L,isFetching:O,isError:J,refetch:H}=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(_)}),{columns:W,isColumnsLoading:V,isColumnsFetching:K,isColumnsError:G,refetchColumns:Z}=Ke(s);I.useEffect(()=>{(_==="S3"||_==="API")&&(d(""),f(""),h(""),_==="API"&&y("api"))},[_,y,d,f,h]);const F=(C==null?void 0:C.type)==="API"?(Ze=C==null?void 0:C.type)==null?void 0:Ze.toLowerCase():u||"",Q=U?"":i||"";function X(B){f(B),y("")}function ae(B){d(B==="none"?"":B),f(""),y(""),B!=="none"&&B!==""&&h("")}function de(B){c(B)}function ke(B){h(B==="none"?"":B),B!=="none"&&B!==""&&d("")}w&&((Xe=w==null?void 0:w.databases)==null?void 0:Xe.length)>0,g&&((et=g==null?void 0:g.schemas)==null?void 0:et.length)>0;const De=j==null?void 0:j.connections.map(B=>({id:B.id,name:B.name,type:B.type})),Ie=(tt=N==null?void 0:N.datamodels)==null?void 0:tt.map(B=>({id:B.id,name:B.name})),Ee=w==null?void 0:w.databases.map(B=>({id:B.database_name,name:B.database_name})),je=g==null?void 0:g.schemas.map(B=>({id:B.schema_name,name:B.schema_name})),Y=v==null?void 0:v.tables.map(B=>({id:B.table_name,name:B.table_name})),se=(st=N==null?void 0:N.datamodels.find(B=>B.id===o))==null?void 0:st.name,ss=t.getFormattedTableNameForQuery({schemaName:Q,tableName:F,modelName:se,connectionType:_,databaseName:l||""});return{connectionItems:De,selectedConnectionId:r,isConnectionsLoading:x,isConnectionsError:S,modelItems:Ie,selectedDatamodelId:o,selectedDatamodelName:se,isModelsLoading:E,isModelsError:R,selectedDatabaseName:l,databaseItems:Ee,isDatabasesLoadingOrFetching:z||$,isDatabaseError:P,schemaItems:je,selectedSchemaName:i,isSchemaLoadingOrFetching:T||q,isSchemaError:A,tableItems:Y,selectedTableName:u,isTableLoadingOrFetching:L||O,isTableError:J,columns:W,isColumnsLoadingOrFetching:V||K,isColumnsError:G,isNonDbConnection:U,connectionType:_,tableName:F,formattedTableName:ss,schemaName:Q,refetchConnections:p,refetchModels:M,refetchDatabases:D,refetchSchemas:k,refetchTables:H,refetchColumns:Z,handleConnectionChange:de,handleDatamodelChange:ke,handleDatabaseChange:ae,handleSchemaChange:X}}const Me={id:"__placeholder__",role:"groupby",type:"string"},Ae={id:"__placeholder__",role:"groupby",type:"string"},Le={id:"__placeholder__",role:"metric",type:"number"},Oe={name:"Filter",id:"__placeholder__",role:"filter",type:"string"},Mt={id:"__placeholder__"},re="droppable-group-by",oe="droppable-metrics",ie="droppable-pivot-by",Ce="sortable-group-by",Be="sortable-metrics",ve="sortable-pivot-by",Ve="droppable-filters",qe="sortable-filters",Je="sortable-order-by";function pn(){const s=t.useDndStore(D=>D.insertIndex),a=t.useEditorStore(D=>{var g;return((g=D.card.queryConfig)==null?void 0:g.groupByColumns)||[]}),n=t.useEditorStore(D=>{var g;return((g=D.card.queryConfig)==null?void 0:g.metricColumns)||[]}),r=t.useEditorStore(D=>{var g;return((g=D.card.queryConfig)==null?void 0:g.filterColumns)||[]}),o=t.useEditorStore(D=>{var g;return((g=D.card.queryConfig)==null?void 0:g.orderBy)||[]}),l=t.useEditorStore(D=>{var g;return((g=D.card.queryConfig)==null?void 0:g.pivotColumns)||[]}),{setInsertIndex:i,setActiveId:u,setPreviewGroupByColumns:c,setPreviewMetricColumns:h,setPreviewFilterColumns:d,setPreviewPivotColumns:f}=t.useDndActions(),{setGroupByColumns:y,setMetricColumns:m,setFilterColumns:b,setOrderByColumns:p,setPivotByColumns:j}=t.useEditorActions(),{columns:x}=Ke(),{formattedTableName:S}=te(),C=t.useSensors(t.useSensor(t.MouseSensor,{activationConstraint:{distance:1}})),M=D=>{var q;const{active:g,over:T}=D;if(((q=g.data.current)==null?void 0:q.type)==="column"&&T){const A=T.id,k=x.find(J=>J.column_name===g.id);if(!k)return;const v=t.isNumberDataType(k.data_type),L=t.isTextDataType(k.data_type),O=t.isDateDataType(k.data_type);if(L||O){if(a.some(H=>H.id===A)){const H=a.findIndex(V=>V.id===A);i(H);const W=a.filter(V=>V.id!==Me.id);W.splice(H,0,Me),c(W)}else if(T.id===re){i(a.length);const H=[...a,Me];c(H),h(n),d(r)}}if(L||O){if(l.some(H=>H.id===A)){const H=l.findIndex(V=>V.id===A);i(H);const W=l.filter(V=>V.id!==Ae.id);W.splice(H,0,Ae),f(W)}else if(T.id===ie){i(l.length);const H=[...l,Ae];f(H),c(a),h(n),d(r)}}if(v||L){if(n.some(H=>H.id===A)){console.log("isOverMetricSortable",A);const H=n.findIndex(V=>V.id===A);i(H);const W=n.filter(V=>V.id!==Le.id);W.splice(H,0,Le),h(W)}else if(T.id===oe){i(n.length);const H=[...n,Le];h(H),d(r),c(a),f(l)}}if(E(k)){if(r.some(H=>H.id===A)){const H=r.findIndex(V=>V.id===A);i(H);const W=r.filter(V=>V.id!==Oe.id);W.splice(H,0,Oe),d(W)}else if(T.id===Ve){i(r.length);const H=[...r,Oe];d(H),h(n),c(a),f(l)}}}else c(a),h(n),d(r),f(l)};function N(D){u(D.active.id),i(null),c(a),h(n),d(r),f(l)}function E(D){return!r.some(g=>g.name===D.column_name)}function R(D,g="SUM"){const{column_name:T,data_type:q}=D,A=[...n],k=s!==null?s:n.length,v={...D,id:ne(T),name:T,label:ge(T,g),type:q,role:"metric",aggregate:g};A.splice(k,0,v),m(A)}function _(D){const g=t.isTextDataType(D.data_type);t.isDateDataType(D.data_type);const T=[...l],q=s!==null?s:l.length;let A;g?A={...D,id:ne(D.column_name),name:D.column_name,type:D.data_type,role:"groupby"}:A={...D,id:ne(D.column_name),name:D.column_name,type:D.data_type,role:"groupby",label:he(D.column_name,"month"),granularity:"month"},T.splice(q,0,A),j(T)}function U(D){const g=t.isTextDataType(D.data_type);t.isDateDataType(D.data_type);const T=[...a],q=s!==null?s:a.length;let A;g?A={...D,id:ne(D.column_name),name:D.column_name,type:D.data_type,role:"groupby"}:A={...D,id:ne(D.column_name),name:D.column_name,type:D.data_type,role:"groupby",label:he(D.column_name,"month"),granularity:"month"},T.splice(q,0,A),y(T)}function w(D){const g=[...r],T=s!==null?s:r.length,q={...D,id:ne(D.column_name),name:D.column_name,type:D.data_type,sql:t.getDefaultFilterSql(D.data_type,S,t.fmt(D.column_name)),role:"filter"};g.splice(T,0,q),b(g)}function z(D){var A,k,v,L,O,J,H,W;const{active:g,over:T}=D,q=g.data.current;if((q==null?void 0:q.type)==="column"&&T){const V=x.find(F=>F.column_name===g.id);if(!V)return;const K=t.isNumberDataType(V.data_type),G=t.isTextDataType(V.data_type),Z=t.isDateDataType(V.data_type);(G||Z)&&(T.id===re||((A=T.data.current)==null?void 0:A.type)===Ce)&&U(V),(G||Z)&&(T.id===ie||((k=T.data.current)==null?void 0:k.type)===ve)?_(V):(K||G)&&(T.id===oe||((v=T.data.current)==null?void 0:v.type)===Be)?(K&&R(V),G&&R(V,"COUNT")):E(V)&&(T.id===Ve||((L=T.data.current)==null?void 0:L.type)===qe)&&w(V)}if(T&&((O=T.data.current)==null?void 0:O.type)===Ce&&a.some(V=>V.id===g.id)){const V=a.findIndex(G=>G.id===g.id),K=a.findIndex(G=>G.id===T.id);if(V!==-1&&K!==-1&&V!==K){const G=[...a],[Z]=G.splice(V,1);G.splice(K,0,Z),y(G)}}if(T&&((J=T.data.current)==null?void 0:J.type)===ve&&l.some(V=>V.id===g.id)){const V=l.findIndex(G=>G.id===g.id),K=l.findIndex(G=>G.id===T.id);if(V!==-1&&K!==-1&&V!==K){const G=[...l],[Z]=G.splice(V,1);G.splice(K,0,Z),j(G)}}if(T&&((H=T.data.current)==null?void 0:H.type)===Be&&n.some(V=>V.id===g.id)){const V=n.findIndex(G=>G.id===g.id),K=n.findIndex(G=>G.id===T.id);if(V!==-1&&K!==-1&&V!==K){const G=[...n],[Z]=G.splice(V,1);G.splice(K,0,Z),m(G)}}if(T&&((W=T.data.current)==null?void 0:W.type)===qe&&r.some(V=>V.id===g.id)){const V=r.findIndex(G=>G.id===g.id),K=r.findIndex(G=>G.id===T.id);if(V!==-1&&K!==-1&&V!==K){const G=[...r],[Z]=G.splice(V,1);G.splice(K,0,Z),b(G)}}$(D),u(null),i(null),c(a),h(n),d(r),f(l)}function $(D){const{active:g,over:T}=D,q=g.data.current;if((q==null?void 0:q.type)===Je&&T){const A=o.findIndex(v=>fe(v.columnId)===g.id),k=o.findIndex(v=>fe(v.columnId)===T.id);if(A!==-1&&k!==-1&&A!==k){const v=[...o],[L]=v.splice(A,1);v.splice(k,0,L),p(v)}}}function P(){u(null),i(null),c(a),h(n),d(r)}return{handleDragOver:M,handleDragEnd:z,handleDragStart:N,handleDragCancel:P,sensors:C}}function ne(s){return`${s}-${t.v4()}`}function ge(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 fe(s){return`${Je}-${s}`}function he(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 xn({schemaName:s,tableName:a,columns:n,status:r}){const o=t.useEditorStore(g=>g.sqlGen),l=t.useEditorStore(g=>g.isDevMode),i=t.useEditorStore(g=>g.selectedConnectionId),u=t.useEditorStore(g=>{var T,q;return(q=(T=g.card)==null?void 0:T.queryConfig)==null?void 0:q.metricColumns});t.useEditorStore(g=>{var T,q;return(q=(T=g.card)==null?void 0:T.queryConfig)==null?void 0:q.groupByColumns});const c=t.useEditorStore(g=>g.selectedDatabaseName),h=t.useEditorStore(g=>g.selectedSchemaName),d=t.useEditorStore(g=>g.selectedTableName),f=t.useEditorStore(g=>g.selectedDatamodelId),y=t.useDashboardStore(g=>g.dashboard.aiScopeTables),{addToAIScope:m,removeFromAIScope:b}=t.useDashboardActions(),{addColumnToMetricColumns:p,addColumnToGroupBy:j,setCardSql:x,setRunSql:S,setSqlGen:C,setIsShowingVisual:M}=t.useEditorActions(),{connectionType:N,modelItems:E,selectedDatamodelName:R}=te();function _(g){var T;if(l){const q=t.createSqlGenConfig(g,o);C(q);const A=(T=E==null?void 0:E.find(v=>v.id===f))==null?void 0:T.name,k=t.getSql(q,t.fmt(s),t.fmt(a),A,N,c||"");k&&(x(k),S(!0))}if(!l){if(t.isTextDataType(g.data_type))if(u&&u.length>0){const q={...g,role:"groupby",id:ne(g.column_name),name:g.column_name,type:g.data_type};j(q)}else{const q={...g,role:"metric",id:ne(g.column_name),name:g.column_name,label:ge(g.column_name,"COUNT"),type:g.data_type,aggregate:"COUNT"};p(q)}if(t.isDateDataType(g.data_type)){const q={...g,role:"groupby",id:ne(g.column_name),name:g.column_name,type:g.data_type,label:he(g.column_name,"month"),granularity:"month"};j(q)}if(t.isNumberDataType(g.data_type)){const q={...g,role:"metric",id:ne(g.column_name),name:g.column_name,label:ge(g.column_name,"SUM"),type:g.data_type,aggregate:"SUM"};p(q)}}}function U(g){g===!0&&(d||R)&&i?(m({connectionId:i,connectionType:N==="S3"||N==="API"?"DuckDb":N,databaseName:c||"",schemaName:h||"",tableName:d||"",datamodelName:t.resolveDatamodelName(R),datamodelId:f||""}),t.ue.success("Added to Assistant Scope",{position:"top-right",duration:2500,richColors:!0})):(b({connectionId:i||"",connectionType:N||"",tableName:d||"",datamodelName:t.resolveDatamodelName(R),datamodelId:f||"",databaseName:c||"",schemaName:h||""}),t.ue("Removed from Assistant Scope",{position:"top-right",duration:2e3,richColors:!0}))}function w(){const g=t.getFormattedTableNameForQuery({schemaName:s,tableName:a,modelName:R,connectionType:N,databaseName:c||""});M(!1);const T=N==="MSSQL"?`SELECT top 10 * FROM ${g}`:`SELECT * FROM ${g} LIMIT 10`;x(T),S(!0)}function z(){const g=t.getFormattedTableNameForQuery({schemaName:s,tableName:a,modelName:R,connectionType:N,databaseName:c||""});x(`SELECT COUNT(*) as count FROM ${g}`),S(!0)}function $(){return(y==null?void 0:y.find(g=>g.connectionId===i&&(g.tableName===d||g.datamodelName===R)))!==void 0}function P(g){return l?e.jsxs("div",{className:"flex grow items-center justify-between space-x-2 rounded-md px-2 py-1",onClick:()=>_(g),children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Qe,{column:g}),e.jsx("span",{children:g.column_name})]}),e.jsx("div",{onClick:T=>T.stopPropagation(),className:"flex items-center justify-end",children:t.isNumberDataType(g.data_type)&&e.jsx(un,{column:g})})]}):e.jsx(hn,{onClick:_,column:g})}function D(){return e.jsxs(e.Fragment,{children:[e.jsxs(t.Toggle,{title:`${$()?"Remove from":"Add to"} Assistant Scope`,pressed:$(),onPressedChange:U,variant:"outline",className:t.cn("h-9 px-2",{}),children:[e.jsx(t.Plus,{className:t.cn("mr-1 size-4",{"text-green-400":$(),"text-muted-foreground":!$()})}),"AI"]}),e.jsxs(t.Button,{disabled:r!=="Success",onClick:w,size:"sm",variant:"secondary",className:"flex",children:[r!=="Success"?e.jsx(le,{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:z,size:"sm",variant:"secondary",className:"w-full",children:[r!=="Success"?e.jsx(le,{className:"mr-2 h-4 w-4 animate-spin text-foreground/50"}):e.jsx(vt,{className:"mr-2 size-4"}),"Count"]})]})}return r!=="Success"?e.jsx("div",{className:"flex grow flex-col justify-start gap-2 px-6",children:Array.from({length:3}).map((g,T)=>e.jsx(t.Skeleton,{className:"h-7 w-full"},T))}):e.jsxs("div",{className:"flex grow flex-col space-y-4 px-4",children:[l&&e.jsx("div",{className:"mx-2 flex items-center justify-center gap-2",children:D()}),e.jsxs(t.CustomScrollArea,{className:"flex-1 basis-0 overflow-y-auto px-2 py-0",children:[e.jsx("div",{className:"flex flex-col gap-1",children:n==null?void 0:n.map(g=>e.jsx("div",{className:t.cn("mr-2 cursor-pointer rounded-md text-sm transition-colors hover:bg-muted"),children:P(g)},g.column_name))}),e.jsx(t.ScrollBar,{orientation:"vertical"}),e.jsx(t.ScrollBar,{orientation:"horizontal"})]})]})}function At({ColumnsComponent:s,type:a}){var je;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),u=t.useEditorStore(Y=>Y.selectedSchemaName),c=t.useEditorStore(Y=>Y.selectedTableName),h=t.useEditorStore(Y=>Y.isDevMode),{setSelectedTableName:d,setIsDevMode:f,setCardSql:y}=t.useEditorActions(),{connectionItems:m,modelItems:b,schemaItems:p,databaseItems:j,tableItems:x,columns:S,isConnectionsLoading:C,isModelsLoading:M,isConnectionsError:N,isModelsError:E,isDatabasesLoadingOrFetching:R,isDatabaseError:_,isSchemaLoadingOrFetching:U,isSchemaError:w,isColumnsError:z,isColumnsLoadingOrFetching:$,isTableLoadingOrFetching:P,isTableError:D,connectionType:g,isNonDbConnection:T,refetchDatabases:q,refetchModels:A,refetchSchemas:k,refetchTables:v,refetchColumns:L,refetchConnections:O,handleConnectionChange:J,handleDatabaseChange:H,handleSchemaChange:W,handleDatamodelChange:V,tableName:K,schemaName:G}=te(),{data:Z,refetch:F}=t.useDashboardCardQuery(n);function Q(){return s?s(G,K,S):e.jsx(xn,{schemaName:G,tableName:K,columns:S,status:$?"Loading...":z?"Error":"Success"})}function X(){window.location.href="mailto:support@semaphor.cloud?subject=Help&body=I need help with..."}function ae(Y){Y===!0?Z&&(y(Z.userSql),setTimeout(()=>{F()},100)):y(""),f(Y)}function de(){if(!r||g==="S3"||g==="API")return null;if(!l||l==="none")return e.jsx(ue,{refetch:q,showNone:!0,onChange:H,isError:_,isLoading:R,items:j,value:i||"",title:"Database",type:"combobox"})}function ke(){if(r&&!T&&(!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 De(){if(!r||g==="S3"||g==="API")return null;if(!i||i==="none")return e.jsx(ue,{refetch:A,showNone:!0,onChange:V,isError:E,isLoading:M,items:b,value:l||"",title:"Model",type:"combobox"})}function Ie(){return!r||g==="S3"||g==="API"||!i||i==="none"?null:e.jsx(ue,{refetch:k,onChange:W,isError:w,isLoading:U,items:p,value:u||"",title:"Schema",type:"combobox"})}function Ee(){function Y(){let se=!1;return g==="API"?(se=!1,se):((g==="S3"||r&&i&&i!=="none"&&u)&&(se=!0),se)}return Y()?e.jsx(ue,{refetch:v,onChange:d,isError:D,items:x,isLoading:P,value:c||"",title:"Table",type:"combobox"}):null}return e.jsxs("aside",{className:t.cn("flex h-full min-w-[310px] max-w-[310px] 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(ue,{refetch:O,items:m,title:"Connection",value:r||"",onChange:J,isLoading:C,isError:N,type:"combobox",connectionTooltip:((je=m==null?void 0:m.find(Y=>Y.id===r))==null?void 0:je.type)||""}),de(),ke(),De(),Ie(),Ee()]}),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:ae,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 Lt({sql:s,error:a,onClick:n}){const r=t.useEditorStore(c=>c.isDevMode);t.useEditorStore(c=>c.card);const{setIsDevMode:o,setCardSql:l,setRunSql:i}=t.useEditorActions();if(!s&&!a)return null;function u(){o(!r),l(s),setTimeout(()=>{i(!0)},100)}return 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(ht,{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"})})]})]}),!r&&e.jsxs(t.Button,{onClick:u,variant:"secondary",size:"sm",children:[e.jsx(Es,{className:"mr-2 h-4 w-4"}),"View in SQL Editor"]}),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 Ot={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},rt=I.createContext&&I.createContext(Ot),fn=["attr","size","title"];function gn(s,a){if(s==null)return{};var n=jn(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 jn(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 Ne(){return Ne=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},Ne.apply(this,arguments)}function ot(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 we(s){for(var a=1;a<arguments.length;a++){var n=arguments[a]!=null?arguments[a]:{};a%2?ot(Object(n),!0).forEach(function(r){yn(s,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(s,Object.getOwnPropertyDescriptors(n)):ot(Object(n)).forEach(function(r){Object.defineProperty(s,r,Object.getOwnPropertyDescriptor(n,r))})}return s}function yn(s,a,n){return a=bn(a),a in s?Object.defineProperty(s,a,{value:n,enumerable:!0,configurable:!0,writable:!0}):s[a]=n,s}function bn(s){var a=Sn(s,"string");return typeof a=="symbol"?a:a+""}function Sn(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 zt(s){return s&&s.map((a,n)=>I.createElement(a.tag,we({key:n},a.attr),zt(a.child)))}function pe(s){return a=>I.createElement(Cn,Ne({attr:we({},s.attr)},a),zt(s.child))}function Cn(s){var a=n=>{var{attr:r,size:o,title:l}=s,i=gn(s,fn),u=o||n.size||"1em",c;return n.className&&(c=n.className),s.className&&(c=(c?c+" ":"")+s.className),I.createElement("svg",Ne({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},n.attr,r,i,{className:c,style:we(we({color:s.color||n.color},n.style),s.style),height:u,width:u,xmlns:"http://www.w3.org/2000/svg"}),l&&I.createElement("title",null,l),s.children)};return rt!==void 0?I.createElement(rt.Consumer,null,n=>a(n)):a(Ot)}function vn(s){return pe({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 Ft(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:u}=t.useDashboardCardQuery(o),{updateCardTab:c,setRunSql:h}=t.useEditorActions(),d=I.useRef(),f=I.useRef({}),y=r.cards.find(p=>p.id===l),m=I.useCallback(()=>{let p="";return s==="python"&&(p=(y==null?void 0:y.python)||t.PYTHON_DEFAULT_CODE),s==="sql"&&(p=(y==null?void 0:y.sql)||""),p},[s,y]);I.useEffect(()=>{if(l&&o.id&&o.id!==l){if(d.current&&i){const p=d.current.getModel();p&&(f.current[o.id]=p);let j=f.current[l];if(!j){const x=m();j=i.editor.createModel(x,s),f.current[l]=j}d.current.setModel(j)}c(l,o),h(!0)}},[l,o,c,i,h,s,m]),I.useEffect(()=>{if(!i)return;const p=window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light",j=n==="system"?p:n;i.editor.defineTheme("default",{base:j==="light"?"vs":"vs-dark",inherit:!0,rules:[],colors:{"editor.background":j==="light"?"#ffffff":t.hslStringToHex("240 10% 10%")}}),i.editor.setTheme("default")},[a,n,i]),I.useEffect(()=>{const p=d.current;p&&i&&o&&p.addCommand(i.KeyMod.Shift|i.KeyCode.Enter,function(){return u(),!1})},[i,u,o]);function b(p,j){if(d.current=p,!f.current[o.id]){const x=p.getModel(),S=m();f.current[o.id]=x||(j==null?void 0:j.editor.createModel(S,s))||p.getModel()}p.setModel(f.current[o.id])}return{handleEditorDidMount:b}}function Nn(){const s=t.useEditorStore(i=>i.card.sql),a=t.useEditorStore(i=>i.sqlGen),{setCardSql:n,setSqlGen:r}=t.useEditorActions(),{handleEditorDidMount:o}=Ft("sql");function l(i){n(i),t.isObjectEmpty(a)||r({})}return e.jsxs("div",{className:"relative h-full w-full",children:[!s&&e.jsx("div",{className:"pointer-events-none absolute left-[65px] top-3 z-10 font-mono text-sm text-muted-foreground",children:"Write your SQL here"}),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 wn(){const s=t.useEditorStore(o=>o.card.python),{setCardPython:a}=t.useEditorActions(),{handleEditorDidMount:n}=Ft("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 kn({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 Rt(s){var K,G,Z;const[a,n]=I.useState(""),[r,o]=I.useState(null),{authToken:l}=t.useSemaphorContext(),i=t.useEditorStore(F=>{var Q;return(Q=F==null?void 0:F.card)==null?void 0:Q.sql}),u=t.useEditorStore(F=>{var Q;return(Q=F==null?void 0:F.card)==null?void 0:Q.python}),c=t.useEditorStore(F=>F.actions.setCardSql),h=t.useEditorStore(F=>F.actions.setRunSql),d=t.useEditorStore(F=>F.actions.switchCardType),f=t.useEditorStore(F=>F.currentAssitantScope)||[],y=t.useEditorStore(F=>F.userInputForAI),m=t.useEditorStore(F=>F.triggerAIRun),b=t.useEditorStore(F=>F.selectedDatabaseName),p=t.useEditorStore(F=>F.selectedTableName),j=t.useEditorStore(F=>F.selectedConnectionId),x=t.useEditorStore(F=>F.selectedSchemaName),S=t.useDashboardStore(F=>F.dashboard.aiScopeTables),{setTriggerAIRun:C,setCurrentAssitantScope:M}=t.useEditorActions(),{selectedDatamodelName:N,connectionType:E,selectedDatamodelId:R}=te(),{messages:_,setMessages:U,reload:w,error:z,append:$,input:P,setInput:D,status:g,handleInputChange:T,handleSubmit:q,stop:A}=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(F,Q){v(Q.usage),n(""),Q.finishReason==="stop"&&n("")}});I.useEffect(()=>{m&&y&&(T({target:{value:y}}),setTimeout(()=>{q(),C(!1)},100))},[m,q,y,C,T]);async function k({toolCall:F}){if(F.toolName==="createChartFromSql"){const Q=F.args.sql,X=F.args.chartType;return d(X),c(Q),h(!0),{status:"success",message:"Let the user know that chart is created"}}else if(F.toolName==="getTableColumns")n("Getting table columns...");else{if(F.toolName==="getUserSql")return i?{status:"success",sql:i,python:u||""}:{status:"error",message:"No SQL found"};if(F.toolName==="getCurrentTableScope")return n("Getting table scope..."),H(),{status:"success",tables:f};n("Analyzing...")}}function v(F){o(Q=>Q?{promptTokens:Q.promptTokens+F.promptTokens,completionTokens:Q.completionTokens+F.completionTokens,totalTokens:Q.totalTokens+F.totalTokens}:F)}function L(F){const Q=t.removeFromScopeArray(f,F);O(Q)}function O(F){const Q=t.sanitizeAIScope(F);M(Q),U(X=>[...X,{id:crypto.randomUUID(),role:"system",content:`Current scope of tables | ${JSON.stringify(Q)}`}])}function J(){const F={databaseName:b||"",schemaName:x||"",tableName:p||"",datamodelId:R||"",datamodelName:t.resolveDatamodelName(N),connectionId:j||"",connectionType:E||""},Q=t.dedup([...f,F]);O(Q)}function H(){const F={databaseName:b||"",schemaName:x||"",tableName:p||"",datamodelName:t.resolveDatamodelName(N),connectionId:j||"",connectionType:E||"",datamodelId:R||""};if(!t.isInAiScopeArray([...S||[],...f],F)||f.length===0){const X=t.dedup([...S||[],...f,F]).filter(ae=>ae.connectionId===F.connectionId);O(X)}}const W=!["ready","error"].includes(g),V=(Z=(G=(K=JSON.parse((z==null?void 0:z.message)||"{}"))==null?void 0:K.error)==null?void 0:G.lastError)==null?void 0:Z.message;return{messages:_,setMessages:U,reload:w,append:$,input:P,setInput:D,isLoading:W,handleSetAIScope:H,handleAddCurrentTableToScope:J,removeFromCurrentSelections:L,currentAssitantScope:f,setCurrentAssitantScope:M,handleInputChange:T,handleSubmit:q,stop:A,chatStatus:g,toolStatus:a,llmUsage:r,onFinish:s,errorMessage:V}}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),u=s.substring(a);return`${i} {{ filters | where }} AND ${u.substring(6)}`}else if(n!==-1){const i=s.substring(0,n),u=s.substring(n);return`${i} {{ filters | where }} ${u}`}else{const i=s.substring(0,l),u=s.substring(l);return console.log("beforeClause",i),console.log("afterClause",u),u?`${i} {{ filters | where }} ${u}`:`${i.replace(/;$/,"")} {{ filters | where }}`}}function _t({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),u=t.useEditorStore(m=>m.selectedTableName),c=t.useEditorStore(m=>m.selectedConnectionId),h=t.useEditorStore(m=>m.isShowingVisual),d=r.sql,f=t.useEditorStore(m=>m.onSave);function y(){let m=d;d&&!d.includes("{{")&&(m=Dn(d),a(m));const b={...r,lastSelectedSchema:o,lastSelectedDatamodelId:l,lastSelectedDatabase:i,lastSelectedTable:u,connectionId:c,type:h?r.type:"table",sql:m,customCfg:h?r.customCfg:null},p=n.cards.map(x=>x.id===r.id?b:x),j={...n,cards:p,activeCardId:In(p,n.activeCardId)};f==null||f(j)}return e.jsxs(t.Button,{onClick:y,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(c=>c.tempQueryData),o=t.useEditorStore(c=>c.onClose),l=t.useEditorStore(c=>c.card),{queryKey:i}=t.useDashboardCardQuery(l);function u(){if(r){const{queryKey:c,queryData:h}=r;c&&h&&n.setQueryData(c,h)}a({}),o==null||o()}return e.jsxs(t.Button,{onClick:u,size:"sm",variant:"secondary",children:[e.jsx(t.X,{className:"mr-2 size-4"}),"Close"]})}function Vt(){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:u,setCardCustomCfg:c,setCardPreferences:h,setCardType:d,clearQueryConfig:f}=t.useEditorActions();function y(){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({}),f(),u(""),c(""),h({})}return e.jsxs(t.Button,{onClick:y,className:"",size:"sm",variant:"secondary",children:[e.jsx(Ds,{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 l=r.split("__")[0],i=s.find(u=>u.tabTitle===l);return i?i.id:s[0].id}return a}}return s[0].id}function En(){const s=t.useQueryClient(),[a,n]=I.useState(!1),[r,o]=I.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 u=t.useEditorStore(v=>{var L;return(L=v==null?void 0:v.card)==null?void 0:L.sql}),{sheetFilterValues:c}=t.useSheetFilterValues(),{setCardCustomCfg:h,setQueryResultColumns:d,setCardSql:f,setTempQueryData:y,setPythonStdOut:m,setCardPreferences:b,setCardType:p,setCardPython:j,runAssistant:x,setShowAIDialog:S}=t.useEditorActions();t.useEditorStore(v=>v.onSave),t.useEditorStore(v=>v.onClose),t.useEditorStore(v=>v.actions.setSqlGen);const C=t.useEditorStore(v=>v.runSql),M=t.useEditorStore(v=>v.actions.setRunSql),N=t.useEditorStore(v=>v.actions.setIsSqlRunning),{data:E,isLoading:R,isFetching:_,isSuccess:U,isError:w,error:z,queryKey:$,refetch:P,errorMessage:D}=t.useDashboardCardQuery(l),{handleSetAIScope:g}=Rt();I.useEffect(()=>{if(E&&(E.rowLimitExceeded&&t.ue.error("Row limit (10,000) exceeded. Refine your query.",{position:"top-center",richColors:!0}),m((E==null?void 0:E.output)||""),E.records.length>0)){const{dimensionKeys:v}=t.getKeys(E.records);d(v)}},[E,d,m]),I.useEffect(()=>{(R||_)&&N(!0),(w||U)&&N(!1),w&&(d([]),m(""))},[R,_,E,m,w,U,N,d,z]),I.useEffect(()=>{C&&(s.getQueryData($)||P(),M(!1))},[C,P,M,$,s]);async function T(){const v=`Can you help me debug this query in the current table scope?
366
+ */const It=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 $e(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=>Dt(i))}})}})}}function Dt(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 _e(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]=D.useState(""),[n,r]=D.useState(!1),o=t.useDashboardStore(p=>p.lenses),{setLenses:l,setSelectedLensId:i}=t.useDashboardActions(),[d,c]=D.useState(!1),[h,u]=D.useState(!1),f=t.useDashboardStore(p=>p.dashboard),y=t.useDashboardStore(p=>p.filterValues),{authToken:m}=t.useSemaphorContext();async function b(){c(!0);const p=$e(f),j=await nn(s,p,y,m==null?void 0:m.accessToken);j&&(l([...o||[],j]),i(j.id),u(!1)),c(!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:b,disabled:d,children:d?"Creating...":"Add"})})]})]})}function on(){const[s,a]=D.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 d(u){l(u)}async function c(u){if(await an(u,i==null?void 0:i.accessToken)){const y=n==null?void 0:n.filter(m=>m.id!==u);o(y||[]),l("original")}}async function h(u){const f=n==null?void 0:n.map(b=>b.id===u.id?{...b,isDefault:!u.isDefault}:{...b,isDefault:!1});o(f||[]);const y={...u,isDefault:!u.isDefault};await _e(y,i==null?void 0:i.accessToken);const m=n==null?void 0:n.find(b=>b.isDefault);if(m&&m.id!==u.id){const b={...m,isDefault:!1};await _e(b,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(zs,{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:d,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(_s,{onClick:f=>{f.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:f=>{f.preventDefault(),c(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 Et(){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 Tt(){const s=t.useDashboardStore.getState().isDownloadingPdf,{authToken:a,theme:n,filterValues:r,dashboardTitle:o,selectedSheetId:l}=Et();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 d=`https://semaphor.cloud/api/v1/generate-pdf?params=${encodeURIComponent(i.toString())}`;t.useDashboardStore.setState({isDownloadingPdf:!0});const u=(await(await fetch(d,{method:"GET",headers:{Authorization:`Bearer ${a==null?void 0:a.accessToken}`}})).json()).url,f=document.createElement("a");f.href=u;const y=`${o}-${new Date().toISOString()}.pdf`;f.download=y,f.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 Tt()}return e.jsx(t.IconButton,{tooltip:"Download PDF",className:"h-7 p-2",onClick:r,children:n?e.jsx(le,{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:d=!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}),d&&e.jsx(t.SelectValue,{placeholder:a})]})}),e.jsx(t.SelectContent,{children:e.jsxs(t.SelectGroup,{children:[e.jsx(t.SelectLabel,{children:a}),n.map(c=>e.jsx(t.SelectItem,{value:c.value,children:c.label},c.value))]})})]})}const rt=[{value:"daily",label:"Daily"},{value:"weekly",label:"Weekly"},{value:"biweekly",label:"Bi-Weekly"},{value:"monthly",label:"Monthly"}];function Mt({triggerButtonClassName:s}){const{data:a,handleScheduleSubscription:n,handleDeleteSubscription:r,status:o,error:l,isDeleting:i}=cn(),[d,c]=D.useState(""),[h,u]=D.useState(rt[0].value),[f,y]=D.useState("06:00"),[m,b]=D.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(Ns,{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:d,onChange:p=>c(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=>{b(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:rt,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:f,onChange:p=>y(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:d,frequency:h,time:f,subject:m}),y("00:00"),c(""),b("")},className:"h-8 p-2",disabled:o==="loading"||!d,children:[o==="loading"&&e.jsx(le,{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(xt,{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(ot,{tooltip:`Next Run: ${new Date(p.nextRun).toLocaleString()} ${p.timezone}`,children:e.jsx(vs,{className:"size-3.5"})}),e.jsx(ot,{tooltip:`${p.endUserEmail}`,children:e.jsx(Gs,{className:"size-3.5"})}),i===p.id?e.jsx(le,{className:"size-3.5 animate-spin"}):e.jsx(tn,{onClick:()=>r(p.id),className:"size-3.5 cursor-pointer"})]})]},p.id))})]})]})]})})]})})}const ot=({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]=D.useState("idle"),[n,r]=D.useState(""),[o,l]=D.useState(null),i=t.useDashboardStore(C=>C.authToken),d=t.useDashboardStore(C=>C.dashboard.id),c=t.useDashboardStore(C=>C.dashboard.title),{endUserId:h}=t.getTenantAndEndUserId((i==null?void 0:i.accessToken)||""),u="https://semaphor.cloud/api/v1/subscriptions/get",f={dashboardId:d,endUserId:h},{data:y,isLoading:m,isError:b,isFetching:p,refetch:j}=t.useQuery({queryKey:["subscriptions",d,h],queryFn:()=>t.getRequest(u,(i==null?void 0:i.accessToken)||"",f),enabled:!!(i!=null&&i.accessToken)&&!!d&&!!h});async function x({email:C,subject:M,frequency:N,time:E}){const{authToken:F,...R}=Et(),$=Intl.DateTimeFormat().resolvedOptions().timeZone,k={email:C,frequency:N,time:E,timezone:$,endUserId:h,endUserEmail:C,subject:M||c||"Scheduled Dashboard",dashboardId:d,dashboardParams:R};a("loading");const L="https://semaphor.cloud/api/v1/subscriptions/create";try{const Q=await t.postRequestRegular(L,(F==null?void 0:F.accessToken)||"",{...k});a("success"),r(""),j(),setTimeout(()=>{a("idle")},2e3)}catch(Q){console.error(Q),a("error"),r(Q.message)}}async function S(C){const M="https://semaphor.cloud/api/v1/subscriptions/delete";l(C);try{await t.postRequestRegular(M,(i==null?void 0:i.accessToken)||"",{id:C}),j(),setTimeout(()=>{l(null)},2e3)}catch(N){console.error(N),l(null),a("error"),r(N.message)}}return{data:y,isLoading:m,isFetching:p,isError:b,isDeleting:o,refetch:j,handleScheduleSubscription:x,handleDeleteSubscription:S,status:s,error:n}}function dn(){const{authToken:s}=t.useSemaphorContext();t.useDashboardStore(k=>k.theme);const a=t.useDashboardStore(k=>k.lenses),n=t.useDashboardStore(k=>k.selectedLensId),r=a==null?void 0:a.find(k=>k.id===n),o=t.useDashboardStore(k=>k.dashboard);t.useDashboardStore(k=>k.selectedSheetId);const l=t.useDashboardStore(k=>k.isDashboardEditing),i=t.useEditorStore(k=>k.selectedConnectionId),[d,c]=D.useState(!1),h=t.useDashboardStore(k=>k.filterValues),u=t.useDashboardStore(k=>k.isVisualEditing),f=t.useDashboardStore(k=>k.showFilters);t.useDashboardStore(k=>k.showDashboardJSON);const y=t.useDashboardStore(k=>k.onSaveFunction),m=t.useDashboardStore(k=>k.actions.setShowFilters),{addFrame:b,setSelectedFrameId:p}=t.useDashboardStore(k=>k.actions),{getSelectedSheet:j,setIsDashboardEditing:x,setShowDashboardJSON:S}=t.useDashboardStore(k=>k.actions),C=j(),{tenantId:M,endUserId:N}=D.useMemo(()=>t.getTenantAndEndUserId(s==null?void 0:s.accessToken),[s==null?void 0:s.accessToken]),E=D.useMemo(()=>M||N,[M,N]),F=()=>{if(!l||!C)return;const k={connectionId:i,id:t.v4(),title:"Title",description:"Description",preferences:{onClickFilter:[{columnIndex:0,expression:""}]},type:"bar",sql:"",data:[]},L={id:t.v4(),cards:[k],activeCardId:k.id};b(C.id,L),p(L.id)},R=()=>{x(!0)};async function $(){if(c(!0),!n||!r)return;const k=$e(o),L=JSON.stringify(k),Q={...r,template:L,filterValues:h};await _e(Q,s==null?void 0:s.accessToken),t.ue.success("Lens saved"),y==null||y(k),c(!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(Mt,{}),l&&!u&&E&&e.jsx(rn,{}),!u&&E&&e.jsx(on,{}),l&&!u&&e.jsxs(t.Button,{variant:"secondary",className:"h-7 p-2",size:"sm",disabled:!l,onClick:F,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:()=>{x(!1),S(!1)},children:e.jsx(t.Cross2Icon,{className:"h-4 w-4"})}),l&&!u&&E&&e.jsx(t.Button,{className:"h-7 p-2",variant:"ghost",disabled:d,onClick:$,size:"sm",children:e.jsx(Js,{className:"h-4 w-4"})}),!f&&!u&&l&&e.jsx(t.Button,{className:"h-7 p-2",variant:"ghost",onClick:()=>m(!0),size:"sm",children:e.jsx(yt,{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:d,icon:c,showNone:h=!1}){const u=pe.useRef(null),[f,y]=pe.useState(!1),[m,b]=pe.useState("100%"),p=h?[...a||[],{id:"none",name:"None"}]:a;pe.useLayoutEffect(()=>{u.current&&b(u.current.offsetWidth)},[]);function j(){var S;return o?"Loading...":l?"Error":n?(S=a==null?void 0:a.find(C=>C.id===n))==null?void 0:S.name:`Select ${s}`}function x(S,C){r(C),y(!1)}return e.jsxs(t.Popover,{open:f,onOpenChange:y,children:[e.jsx(t.PopoverTrigger,{asChild:!0,children:e.jsxs(t.Button,{ref:u,variant:"outline",role:"combobox","aria-expanded":f,className:t.cn("flex h-9 w-full justify-between",d),children:[e.jsxs("div",{className:"flex items-center gap-2",children:[c&&e.jsx("div",{className:"mr-2",children:c}),e.jsx("span",{className:"max-w-[150px] overflow-hidden truncate text-ellipsis whitespace-nowrap",children:j()})]}),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(vt,{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:C=>x(C,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 he({title:s,items:a,value:n,isLoading:r,isError:o,refetch:l,onChange:i,showNone:d=!1,className:c,disabled:h=!1,type:u="combobox"}){const f=r?"Loading...":o?"Error":n;function y(){if(s==="Connection")return e.jsx(Qs,{className:"size-4"});if(s==="Database")return e.jsx(Ds,{className:"size-4"});if(s==="Schema")return e.jsx($s,{className:"size-4"});if(s==="Table")return e.jsx(Ue,{className:"size-4"});if(s==="Model")return e.jsx(bs,{className:"size-4"})}function m(){return e.jsxs(t.Select,{disabled:h,value:f,onValueChange:i,children:[e.jsx(t.SelectTrigger,{className:t.cn("h-9 w-full border-muted focus:ring-1 focus:ring-offset-0",c),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(vt,{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:[d&&e.jsx(t.SelectItem,{value:"none",children:"None"},"none"),a&&a.map((p,j)=>e.jsx(t.SelectItem,{value:p.id,children:p.name},j))]}),(r||o)&&e.jsx(t.SelectItem,{value:f,children:f})]})})]})}function b(){return e.jsx(un,{icon:y(),items:a,value:f,onChange:i||(()=>{}),isLoading:r,isError:o,refetch:l,name:s,showNone:d})}return e.jsx(t.TooltipProvider$1,{delayDuration:0,children:e.jsx("div",{className:"flex items-center gap-2",children:u==="select"?m():b()})})}function mn({column:s}){const[a,n]=D.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),d=t.useEditorStore(p=>p.sqlGen),{modelItems:c,connectionType:h}=te(),u=t.useEditorStore(p=>p.actions.setSqlGen),f=t.useEditorStore(p=>p.actions.setCardSql),y=t.useEditorStore(p=>p.actions.setRunSql);function m(p,j){var M;const x=t.createSqlGenConfig(p,d,j),S=(M=c==null?void 0:c.find(N=>N.id===i))==null?void 0:M.name;u(x);const C=t.getSql(x,t.fmt(o||""),t.fmt(r),S,h,l||"");C&&(f(C),y(!0)),n(!1)}function b(){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(gt,{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:b()})]})}function Qe({column:s}){return e.jsxs(t.Tooltip,{children:[e.jsx(t.TooltipTrigger$1,{className:"shrink-0",asChild:!0,children:t.isTextDataType(s.data_type)?e.jsx(It,{className:"size-3 text-muted-foreground"}):t.isNumberDataType(s.data_type)?e.jsx(bt,{className:"size-3 text-muted-foreground"}):t.isDateDataType(s.data_type)?e.jsx(t.Calendar,{className:"size-3 text-muted-foreground"}):t.isBooleanDataType(s.data_type)?e.jsx(en,{className:"size-3 text-muted-foreground"}):s.data_type.startsWith("json")?e.jsx(Ss,{className:"size-3 text-muted-foreground"}):e.jsx(Ws,{className:"size-3 text-muted-foreground"})}),e.jsx(t.TooltipContent,{children:e.jsx("p",{className:"text-xs",children:s.data_type})})]})}function Te({column:s,className:a}){return e.jsxs("div",{className:t.cn("flex min-h-8 grow items-center space-x-2 px-2 text-sm",a),children:[e.jsx(Qe,{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}}),d=i?{translate:t.CSS.Translate.toString(i),transform:t.CSS.Transform.toString(i)}:void 0;return e.jsx("div",{ref:l,style:d,...o,...r,children:a})}function pn({onClick:s,column:a}){const n=t.useDndStore(u=>u.activeId),r=t.useEditorStore(u=>{var f;return(f=u.card.queryConfig)==null?void 0:f.groupByColumns}),o=t.useEditorStore(u=>{var f;return(f=u.card.queryConfig)==null?void 0:f.metricColumns}),l=t.useEditorStore(u=>{var f;return(f=u.card.queryConfig)==null?void 0:f.filterColumns});function i(u){return d(u)||c(u)||h(u)}function d(u){return r==null?void 0:r.some(f=>f.name===u.column_name)}function c(u){return o==null?void 0:o.some(f=>f.name===u.column_name)}function h(u){return l==null?void 0:l.some(f=>f.name===u.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":i(a)}),children:[n===a.column_name&&e.jsx(t.DragOverlay,{children:e.jsx(Te,{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(Te,{column:a})}),e.jsx(hn,{id:a.column_name,type:"column",children:e.jsx(Te,{column:a})})]})}function At(s){const a=t.useDashboardStore(c=>c.authToken)||s,n=t.useEditorStore(c=>c.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)}),d=o==null?void 0:o.connections.find(c=>c.id===n);return{connectionsData:o,isConnectionsLoading:l,isConnectionsError:i,refetchConnections:r,currentConnection:d}}function Ke(s){var j;const a=t.useDashboardStore(x=>x.authToken)||s,n=t.useEditorStore(x=>x.selectedConnectionId),r=t.useEditorStore(x=>x.selectedDatabaseName),o=t.useEditorStore(x=>x.selectedDatamodelId),l=t.useEditorStore(x=>x.selectedSchemaName),i=t.useEditorStore(x=>x.selectedTableName),{currentConnection:d}=At(),c=d==null?void 0:d.type,{data:h,isLoading:u,isFetching:f,isError:y,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:b(c)});function b(x){return a!=null&&a.accessToken?!!(n&&r&&r!=="NA"&&l&&i||n&&(x==="S3"||x==="API")||o&&o):!1}return{columns:(j=h==null?void 0:h.columns)==null?void 0:j.map(x=>({...x,data_type:x.data_type.toLowerCase()})),isColumnsLoading:u,isColumnsFetching:f,isColumnsError:y,refetchColumns:m}}function te(s,a){var Ze,Xe,et,tt,st;const n=t.useSemaphorContext().authToken||s,r=t.useEditorStore(B=>B.selectedConnectionId),o=t.useEditorStore(B=>B.selectedDatamodelId),l=t.useEditorStore(B=>B.selectedDatabaseName),i=t.useEditorStore(B=>B.selectedSchemaName),d=t.useEditorStore(B=>B.selectedTableName),c=t.useEditorStore(B=>B.actions.setSelectedConnectionId),h=t.useEditorStore(B=>B.actions.setSelectedDatamodelId),u=t.useEditorStore(B=>B.actions.setSelectedDatabaseName),f=t.useEditorStore(B=>B.actions.setSelectedSchemaName),y=t.useEditorStore(B=>B.actions.setSelectedTableName);t.useEditorStore(B=>B.actions.setCardSql);function m(B){return r&&l&&i&&l!=="NA"?!0:r&&B==="API"?!1:!!(r&&B==="S3")}function b(B){return r&&B?!(B==="API"||B==="S3"):!1}const{refetchConnections:p,connectionsData:j,isConnectionsLoading:x,isConnectionsError:S,currentConnection:C}=At(s),{refetch:M,data:N,isLoading:E,isError:F}=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=C==null?void 0:C.type,$=(C==null?void 0:C.type)==="API"||(C==null?void 0:C.type)==="S3",{data:k,isLoading:L,isFetching:Q,isError:P,refetch:I}=t.useQuery({queryKey:["databases",r],queryFn:()=>t.getRequest("https://semaphor.cloud/api/v1/databases",(n==null?void 0:n.accessToken)||"",{connection_id:r}),enabled:b(R)}),{data:g,isLoading:T,isFetching:q,isError:A,refetch:w}=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&&!$&&l!=="NA"}),{data:v,isLoading:U,isFetching:_,isError:O,refetch:G}=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:V,isColumnsFetching:J,isColumnsError:H,refetchColumns:Z}=Ke(s);D.useEffect(()=>{(R==="S3"||R==="API")&&(u(""),f(""),h(""),R==="API"&&y("api"))},[R,y,u,f,h]);const z=(C==null?void 0:C.type)==="API"?(Ze=C==null?void 0:C.type)==null?void 0:Ze.toLowerCase():d||"",K=$?"":i||"";function X(B){f(B),y("")}function ae(B){u(B==="none"?"":B),f(""),y(""),B!=="none"&&B!==""&&h("")}function ue(B){c(B)}function me(B){h(B==="none"?"":B),B!=="none"&&B!==""&&u("")}k&&((Xe=k==null?void 0:k.databases)==null?void 0:Xe.length)>0,g&&((et=g==null?void 0:g.schemas)==null?void 0:et.length)>0;const Ie=j==null?void 0:j.connections.map(B=>({id:B.id,name:B.name,type:B.type})),De=(tt=N==null?void 0:N.datamodels)==null?void 0:tt.map(B=>({id:B.id,name:B.name})),Ee=k==null?void 0:k.databases.map(B=>({id:B.database_name,name:B.database_name})),ye=g==null?void 0:g.schemas.map(B=>({id:B.schema_name,name:B.schema_name})),Y=v==null?void 0:v.tables.map(B=>({id:B.table_name,name:B.table_name})),se=(st=N==null?void 0:N.datamodels.find(B=>B.id===o))==null?void 0:st.name,rs=t.getFormattedTableNameForQuery({schemaName:K,tableName:z,modelName:se,connectionType:R,databaseName:l||""});return{connectionItems:Ie,selectedConnectionId:r,isConnectionsLoading:x,isConnectionsError:S,modelItems:De,selectedDatamodelId:o,selectedDatamodelName:se,isModelsLoading:E,isModelsError:F,selectedDatabaseName:l,databaseItems:Ee,isDatabasesLoadingOrFetching:L||Q,isDatabaseError:P,schemaItems:ye,selectedSchemaName:i,isSchemaLoadingOrFetching:T||q,isSchemaError:A,tableItems:Y,selectedTableName:d,isTableLoadingOrFetching:U||_,isTableError:O,columns:W,isColumnsLoadingOrFetching:V||J,isColumnsError:H,isNonDbConnection:$,connectionType:R,tableName:z,formattedTableName:rs,schemaName:K,refetchConnections:p,refetchModels:M,refetchDatabases:I,refetchSchemas:w,refetchTables:G,refetchColumns:Z,handleConnectionChange:ue,handleDatamodelChange:me,handleDatabaseChange:ae,handleSchemaChange:X}}const Me={id:"__placeholder__",role:"groupby",type:"string"},Ae={id:"__placeholder__",role:"groupby",type:"string"},Le={id:"__placeholder__",role:"metric",type:"number"},Oe={name:"Filter",id:"__placeholder__",role:"filter",type:"string"},Lt={id:"__placeholder__"},re="droppable-group-by",oe="droppable-metrics",ie="droppable-pivot-by",ve="sortable-group-by",Be="sortable-metrics",Ne="sortable-pivot-by",Ve="droppable-filters",qe="sortable-filters",Je="sortable-order-by";function xn(){const s=t.useDndStore(I=>I.insertIndex),a=t.useEditorStore(I=>{var g;return((g=I.card.queryConfig)==null?void 0:g.groupByColumns)||[]}),n=t.useEditorStore(I=>{var g;return((g=I.card.queryConfig)==null?void 0:g.metricColumns)||[]}),r=t.useEditorStore(I=>{var g;return((g=I.card.queryConfig)==null?void 0:g.filterColumns)||[]}),o=t.useEditorStore(I=>{var g;return((g=I.card.queryConfig)==null?void 0:g.orderBy)||[]}),l=t.useEditorStore(I=>{var g;return((g=I.card.queryConfig)==null?void 0:g.pivotColumns)||[]}),{setInsertIndex:i,setActiveId:d,setPreviewGroupByColumns:c,setPreviewMetricColumns:h,setPreviewFilterColumns:u,setPreviewPivotColumns:f}=t.useDndActions(),{setGroupByColumns:y,setMetricColumns:m,setFilterColumns:b,setOrderByColumns:p,setPivotByColumns:j}=t.useEditorActions(),{columns:x}=Ke(),{formattedTableName:S}=te(),C=t.useSensors(t.useSensor(t.MouseSensor,{activationConstraint:{distance:1}})),M=I=>{var q;const{active:g,over:T}=I;if(((q=g.data.current)==null?void 0:q.type)==="column"&&T){const A=T.id,w=x.find(O=>O.column_name===g.id);if(!w)return;const v=t.isNumberDataType(w.data_type),U=t.isTextDataType(w.data_type),_=t.isDateDataType(w.data_type);if(U||_){if(a.some(G=>G.id===A)){const G=a.findIndex(V=>V.id===A);i(G);const W=a.filter(V=>V.id!==Me.id);W.splice(G,0,Me),c(W)}else if(T.id===re){i(a.length);const G=[...a,Me];c(G),h(n),u(r)}}if(U||_){if(l.some(G=>G.id===A)){const G=l.findIndex(V=>V.id===A);i(G);const W=l.filter(V=>V.id!==Ae.id);W.splice(G,0,Ae),f(W)}else if(T.id===ie){i(l.length);const G=[...l,Ae];f(G),c(a),h(n),u(r)}}if(v||U){if(n.some(G=>G.id===A)){console.log("isOverMetricSortable",A);const G=n.findIndex(V=>V.id===A);i(G);const W=n.filter(V=>V.id!==Le.id);W.splice(G,0,Le),h(W)}else if(T.id===oe){i(n.length);const G=[...n,Le];h(G),u(r),c(a),f(l)}}if(E(w)){if(r.some(G=>G.id===A)){const G=r.findIndex(V=>V.id===A);i(G);const W=r.filter(V=>V.id!==Oe.id);W.splice(G,0,Oe),u(W)}else if(T.id===Ve){i(r.length);const G=[...r,Oe];u(G),h(n),c(a),f(l)}}}else c(a),h(n),u(r),f(l)};function N(I){d(I.active.id),i(null),c(a),h(n),u(r),f(l)}function E(I){return!r.some(g=>g.name===I.column_name)}function F(I,g="SUM"){const{column_name:T,data_type:q}=I,A=[...n],w=s!==null?s:n.length,v={...I,id:ne(T),name:T,label:je(T,g),type:q,role:"metric",aggregate:g};A.splice(w,0,v),m(A)}function R(I){const g=t.isTextDataType(I.data_type);t.isDateDataType(I.data_type);const T=[...l],q=s!==null?s:l.length;let A;g?A={...I,id:ne(I.column_name),name:I.column_name,type:I.data_type,role:"groupby"}:A={...I,id:ne(I.column_name),name:I.column_name,type:I.data_type,role:"groupby",label:xe(I.column_name,"month"),granularity:"month"},T.splice(q,0,A),j(T)}function $(I){const g=t.isTextDataType(I.data_type);t.isDateDataType(I.data_type);const T=[...a],q=s!==null?s:a.length;let A;g?A={...I,id:ne(I.column_name),name:I.column_name,type:I.data_type,role:"groupby"}:A={...I,id:ne(I.column_name),name:I.column_name,type:I.data_type,role:"groupby",label:xe(I.column_name,"month"),granularity:"month"},T.splice(q,0,A),y(T)}function k(I){const g=[...r],T=s!==null?s:r.length,q={...I,id:ne(I.column_name),name:I.column_name,type:I.data_type,sql:t.getDefaultFilterSql(I.data_type,S,t.fmt(I.column_name)),role:"filter"};g.splice(T,0,q),b(g)}function L(I){var A,w,v,U,_,O,G,W;const{active:g,over:T}=I,q=g.data.current;if((q==null?void 0:q.type)==="column"&&T){const V=x.find(z=>z.column_name===g.id);if(!V)return;const J=t.isNumberDataType(V.data_type),H=t.isTextDataType(V.data_type),Z=t.isDateDataType(V.data_type);(H||Z)&&(T.id===re||((A=T.data.current)==null?void 0:A.type)===ve)&&$(V),(H||Z)&&(T.id===ie||((w=T.data.current)==null?void 0:w.type)===Ne)?R(V):(J||H)&&(T.id===oe||((v=T.data.current)==null?void 0:v.type)===Be)?(J&&F(V),H&&F(V,"COUNT")):E(V)&&(T.id===Ve||((U=T.data.current)==null?void 0:U.type)===qe)&&k(V)}if(T&&((_=T.data.current)==null?void 0:_.type)===ve&&a.some(V=>V.id===g.id)){const V=a.findIndex(H=>H.id===g.id),J=a.findIndex(H=>H.id===T.id);if(V!==-1&&J!==-1&&V!==J){const H=[...a],[Z]=H.splice(V,1);H.splice(J,0,Z),y(H)}}if(T&&((O=T.data.current)==null?void 0:O.type)===Ne&&l.some(V=>V.id===g.id)){const V=l.findIndex(H=>H.id===g.id),J=l.findIndex(H=>H.id===T.id);if(V!==-1&&J!==-1&&V!==J){const H=[...l],[Z]=H.splice(V,1);H.splice(J,0,Z),j(H)}}if(T&&((G=T.data.current)==null?void 0:G.type)===Be&&n.some(V=>V.id===g.id)){const V=n.findIndex(H=>H.id===g.id),J=n.findIndex(H=>H.id===T.id);if(V!==-1&&J!==-1&&V!==J){const H=[...n],[Z]=H.splice(V,1);H.splice(J,0,Z),m(H)}}if(T&&((W=T.data.current)==null?void 0:W.type)===qe&&r.some(V=>V.id===g.id)){const V=r.findIndex(H=>H.id===g.id),J=r.findIndex(H=>H.id===T.id);if(V!==-1&&J!==-1&&V!==J){const H=[...r],[Z]=H.splice(V,1);H.splice(J,0,Z),b(H)}}Q(I),d(null),i(null),c(a),h(n),u(r),f(l)}function Q(I){const{active:g,over:T}=I,q=g.data.current;if((q==null?void 0:q.type)===Je&&T){const A=o.findIndex(v=>ge(v.columnId)===g.id),w=o.findIndex(v=>ge(v.columnId)===T.id);if(A!==-1&&w!==-1&&A!==w){const v=[...o],[U]=v.splice(A,1);v.splice(w,0,U),p(v)}}}function P(){d(null),i(null),c(a),h(n),u(r)}return{handleDragOver:M,handleDragEnd:L,handleDragStart:N,handleDragCancel:P,sensors:C}}function ne(s){return`${s}-${t.v4()}`}function je(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 ge(s){return`${Je}-${s}`}function xe(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(g=>g.sqlGen),l=t.useEditorStore(g=>g.isDevMode),i=t.useEditorStore(g=>g.selectedConnectionId),d=t.useEditorStore(g=>{var T,q;return(q=(T=g.card)==null?void 0:T.queryConfig)==null?void 0:q.metricColumns});t.useEditorStore(g=>{var T,q;return(q=(T=g.card)==null?void 0:T.queryConfig)==null?void 0:q.groupByColumns});const c=t.useEditorStore(g=>g.selectedDatabaseName),h=t.useEditorStore(g=>g.selectedSchemaName),u=t.useEditorStore(g=>g.selectedTableName),f=t.useEditorStore(g=>g.selectedDatamodelId),y=t.useDashboardStore(g=>g.dashboard.aiScopeTables),{addToAIScope:m,removeFromAIScope:b}=t.useDashboardActions(),{addColumnToMetricColumns:p,addColumnToGroupBy:j,setCardSql:x,setRunSql:S,setSqlGen:C,setIsShowingVisual:M}=t.useEditorActions(),{connectionType:N,modelItems:E,selectedDatamodelName:F}=te();function R(g){var T;if(l){const q=t.createSqlGenConfig(g,o);C(q);const A=(T=E==null?void 0:E.find(v=>v.id===f))==null?void 0:T.name,w=t.getSql(q,t.fmt(s),t.fmt(a),A,N,c||"");w&&(x(w),S(!0))}if(!l){if(t.isTextDataType(g.data_type))if(d&&d.length>0){const q={...g,role:"groupby",id:ne(g.column_name),name:g.column_name,type:g.data_type};j(q)}else{const q={...g,role:"metric",id:ne(g.column_name),name:g.column_name,label:je(g.column_name,"COUNT"),type:g.data_type,aggregate:"COUNT"};p(q)}if(t.isDateDataType(g.data_type)){const q={...g,role:"groupby",id:ne(g.column_name),name:g.column_name,type:g.data_type,label:xe(g.column_name,"month"),granularity:"month"};j(q)}if(t.isNumberDataType(g.data_type)){const q={...g,role:"metric",id:ne(g.column_name),name:g.column_name,label:je(g.column_name,"SUM"),type:g.data_type,aggregate:"SUM"};p(q)}}}function $(g){g===!0&&(u||F)&&i?(m({connectionId:i,connectionType:N==="S3"||N==="API"?"DuckDb":N,databaseName:c||"",schemaName:h||"",tableName:u||"",datamodelName:t.resolveDatamodelName(F),datamodelId:f||""}),t.ue.success("Added to Assistant Scope",{position:"top-right",duration:2500,richColors:!0})):(b({connectionId:i||"",connectionType:N||"",tableName:u||"",datamodelName:t.resolveDatamodelName(F),datamodelId:f||"",databaseName:c||"",schemaName:h||""}),t.ue("Removed from Assistant Scope",{position:"top-right",duration:2e3,richColors:!0}))}function k(){const g=t.getFormattedTableNameForQuery({schemaName:s,tableName:a,modelName:F,connectionType:N,databaseName:c||""});M(!1);const T=N==="MSSQL"?`SELECT top 10 * FROM ${g}`:`SELECT * FROM ${g} LIMIT 10`;x(T),S(!0)}function L(){const g=t.getFormattedTableNameForQuery({schemaName:s,tableName:a,modelName:F,connectionType:N,databaseName:c||""});x(`SELECT COUNT(*) as count FROM ${g}`),S(!0)}function Q(){return(y==null?void 0:y.find(g=>g.connectionId===i&&(g.tableName===u||g.datamodelName===F)))!==void 0}function P(g){return l?e.jsxs("div",{className:"flex grow items-center justify-between space-x-2 rounded-md px-2 py-1",onClick:()=>R(g),children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Qe,{column:g}),e.jsx("span",{children:g.column_name})]}),e.jsx("div",{onClick:T=>T.stopPropagation(),className:"flex items-center justify-end",children:t.isNumberDataType(g.data_type)&&e.jsx(mn,{column:g})})]}):e.jsx(pn,{onClick:R,column:g})}function I(){return e.jsxs(e.Fragment,{children:[e.jsxs(t.Toggle,{title:`${Q()?"Remove from":"Add to"} Assistant Scope`,pressed:Q(),onPressedChange:$,variant:"outline",className:t.cn("h-9 px-2",{}),children:[e.jsx(t.Plus,{className:t.cn("mr-1 size-4",{"text-green-400":Q(),"text-muted-foreground":!Q()})}),"AI"]}),e.jsxs(t.Button,{disabled:r!=="Success",onClick:k,size:"sm",variant:"secondary",className:"flex",children:[r!=="Success"?e.jsx(le,{className:"mr-2 h-4 w-4 animate-spin text-foreground/50"}):e.jsx(Hs,{className:"mr-2 size-4"}),"Top 10"]}),e.jsxs(t.Button,{disabled:r!=="Success",onClick:L,size:"sm",variant:"secondary",className:"w-full",children:[r!=="Success"?e.jsx(le,{className:"mr-2 h-4 w-4 animate-spin text-foreground/50"}):e.jsx(wt,{className:"mr-2 size-4"}),"Count"]})]})}return r!=="Success"?e.jsx("div",{className:"flex grow flex-col justify-start gap-2 px-6",children:Array.from({length:3}).map((g,T)=>e.jsx(t.Skeleton,{className:"h-7 w-full"},T))}):e.jsxs("div",{className:"flex grow flex-col space-y-4 px-4",children:[l&&e.jsx("div",{className:"mx-2 flex items-center justify-center gap-2",children:I()}),e.jsxs(t.CustomScrollArea,{className:"flex-1 basis-0 overflow-y-auto px-2 py-0",children:[e.jsx("div",{className:"flex flex-col gap-1",children:n==null?void 0:n.map(g=>e.jsx("div",{className:t.cn("mr-2 cursor-pointer rounded-md text-sm transition-colors hover:bg-muted"),children:P(g)},g.column_name))}),e.jsx(t.ScrollBar,{orientation:"vertical"}),e.jsx(t.ScrollBar,{orientation:"horizontal"})]})]})}function Ot({ColumnsComponent:s,type:a}){var ye;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),d=t.useEditorStore(Y=>Y.selectedSchemaName),c=t.useEditorStore(Y=>Y.selectedTableName),h=t.useEditorStore(Y=>Y.isDevMode),{setSelectedTableName:u,setIsDevMode:f,setCardSql:y}=t.useEditorActions(),{connectionItems:m,modelItems:b,schemaItems:p,databaseItems:j,tableItems:x,columns:S,isConnectionsLoading:C,isModelsLoading:M,isConnectionsError:N,isModelsError:E,isDatabasesLoadingOrFetching:F,isDatabaseError:R,isSchemaLoadingOrFetching:$,isSchemaError:k,isColumnsError:L,isColumnsLoadingOrFetching:Q,isTableLoadingOrFetching:P,isTableError:I,connectionType:g,isNonDbConnection:T,refetchDatabases:q,refetchModels:A,refetchSchemas:w,refetchTables:v,refetchColumns:U,refetchConnections:_,handleConnectionChange:O,handleDatabaseChange:G,handleSchemaChange:W,handleDatamodelChange:V,tableName:J,schemaName:H}=te(),{data:Z,refetch:z}=t.useDashboardCardQuery(n);function K(){return s?s(H,J,S):e.jsx(fn,{schemaName:H,tableName:J,columns:S,status:Q?"Loading...":L?"Error":"Success"})}function X(){window.location.href="mailto:support@semaphor.cloud?subject=Help&body=I need help with..."}function ae(Y){Y===!0?Z&&(y(Z.userSql),setTimeout(()=>{z()},100)):y(""),f(Y)}function ue(){if(!r||g==="S3"||g==="API")return null;if(!l||l==="none")return e.jsx(he,{refetch:q,showNone:!0,onChange:G,isError:R,isLoading:F,items:j,value:i||"",title:"Database",type:"combobox"})}function me(){if(r&&!T&&(!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 Ie(){if(!r||g==="S3"||g==="API")return null;if(!i||i==="none")return e.jsx(he,{refetch:A,showNone:!0,onChange:V,isError:E,isLoading:M,items:b,value:l||"",title:"Model",type:"combobox"})}function De(){return!r||g==="S3"||g==="API"||!i||i==="none"?null:e.jsx(he,{refetch:w,onChange:W,isError:k,isLoading:$,items:p,value:d||"",title:"Schema",type:"combobox"})}function Ee(){function Y(){let se=!1;return g==="API"?(se=!1,se):((g==="S3"||r&&i&&i!=="none"&&d)&&(se=!0),se)}return Y()?e.jsx(he,{refetch:v,onChange:u,isError:I,items:x,isLoading:P,value:c||"",title:"Table",type:"combobox"}):null}return e.jsxs("aside",{className:t.cn("flex h-full min-w-[310px] max-w-[310px] 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(he,{refetch:_,items:m,title:"Connection",value:r||"",onChange:O,isLoading:C,isError:N,type:"combobox",connectionTooltip:((ye=m==null?void 0:m.find(Y=>Y.id===r))==null?void 0:ye.type)||""}),ue(),me(),Ie(),De(),Ee()]}),K(),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:ae,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(Us,{className:"size-4"}),e.jsx("span",{className:"hidden group-hover:block",children:"Help"})]})]})})]})}function zt({sql:s,error:a,onClick:n}){const r=t.useEditorStore(c=>c.isDevMode);t.useEditorStore(c=>c.card);const{setIsDevMode:o,setCardSql:l,setRunSql:i}=t.useEditorActions();if(!s&&!a)return null;function d(){o(!r),l(s),setTimeout(()=>{i(!0)},100)}return 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(xt,{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"})})]})]}),!r&&e.jsxs(t.Button,{onClick:d,variant:"secondary",size:"sm",children:[e.jsx(As,{className:"mr-2 h-4 w-4"}),"View in SQL Editor"]}),a&&n&&e.jsxs(t.Button,{onClick:n,size:"sm",variant:"secondary",children:[e.jsx(Rs,{className:"mr-2 h-4 w-4"}),"Debug with Assistant"]})]})})})]})}var Ft={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},it=D.createContext&&D.createContext(Ft),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 we(){return we=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},we.apply(this,arguments)}function lt(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 ke(s){for(var a=1;a<arguments.length;a++){var n=arguments[a]!=null?arguments[a]:{};a%2?lt(Object(n),!0).forEach(function(r){bn(s,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(s,Object.getOwnPropertyDescriptors(n)):lt(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 Rt(s){return s&&s.map((a,n)=>D.createElement(a.tag,ke({key:n},a.attr),Rt(a.child)))}function ce(s){return a=>D.createElement(vn,we({attr:ke({},s.attr)},a),Rt(s.child))}function vn(s){var a=n=>{var{attr:r,size:o,title:l}=s,i=jn(s,gn),d=o||n.size||"1em",c;return n.className&&(c=n.className),s.className&&(c=(c?c+" ":"")+s.className),D.createElement("svg",we({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},n.attr,r,i,{className:c,style:ke(ke({color:s.color||n.color},n.style),s.style),height:d,width:d,xmlns:"http://www.w3.org/2000/svg"}),l&&D.createElement("title",null,l),s.children)};return it!==void 0?D.createElement(it.Consumer,null,n=>a(n)):a(Ft)}function Nn(s){return ce({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 _t(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:d}=t.useDashboardCardQuery(o),{updateCardTab:c,setRunSql:h}=t.useEditorActions(),u=D.useRef(),f=D.useRef({}),y=r.cards.find(p=>p.id===l),m=D.useCallback(()=>{let p="";return s==="python"&&(p=(y==null?void 0:y.python)||t.PYTHON_DEFAULT_CODE),s==="sql"&&(p=(y==null?void 0:y.sql)||""),p},[s,y]);D.useEffect(()=>{if(l&&o.id&&o.id!==l){if(u.current&&i){const p=u.current.getModel();p&&(f.current[o.id]=p);let j=f.current[l];if(!j){const x=m();j=i.editor.createModel(x,s),f.current[l]=j}u.current.setModel(j)}c(l,o),h(!0)}},[l,o,c,i,h,s,m]),D.useEffect(()=>{if(!i)return;const p=window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light",j=n==="system"?p:n;i.editor.defineTheme("default",{base:j==="light"?"vs":"vs-dark",inherit:!0,rules:[],colors:{"editor.background":j==="light"?"#ffffff":t.hslStringToHex("240 10% 10%")}}),i.editor.setTheme("default")},[a,n,i]),D.useEffect(()=>{const p=u.current;p&&i&&o&&p.addCommand(i.KeyMod.Shift|i.KeyCode.Enter,function(){return d(),!1})},[i,d,o]);function b(p,j){if(u.current=p,!f.current[o.id]){const x=p.getModel(),S=m();f.current[o.id]=x||(j==null?void 0:j.editor.createModel(S,s))||p.getModel()}p.setModel(f.current[o.id])}return{handleEditorDidMount:b}}function wn(){const s=t.useEditorStore(i=>i.card.sql),a=t.useEditorStore(i=>i.sqlGen),{setCardSql:n,setSqlGen:r}=t.useEditorActions(),{handleEditorDidMount:o}=_t("sql");function l(i){n(i),t.isObjectEmpty(a)||r({})}return e.jsxs("div",{className:"relative h-full w-full",children:[!s&&e.jsx("div",{className:"pointer-events-none absolute left-[65px] top-3 z-10 font-mono text-sm text-muted-foreground",children:"Write your SQL here"}),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}=_t("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 Bt(s){var J,H,Z;const[a,n]=D.useState(""),[r,o]=D.useState(null),{authToken:l}=t.useSemaphorContext(),i=t.useEditorStore(z=>{var K;return(K=z==null?void 0:z.card)==null?void 0:K.sql}),d=t.useEditorStore(z=>{var K;return(K=z==null?void 0:z.card)==null?void 0:K.python}),c=t.useEditorStore(z=>z.actions.setCardSql),h=t.useEditorStore(z=>z.actions.setRunSql),u=t.useEditorStore(z=>z.actions.switchCardType),f=t.useEditorStore(z=>z.currentAssitantScope)||[],y=t.useEditorStore(z=>z.userInputForAI),m=t.useEditorStore(z=>z.triggerAIRun),b=t.useEditorStore(z=>z.selectedDatabaseName),p=t.useEditorStore(z=>z.selectedTableName),j=t.useEditorStore(z=>z.selectedConnectionId),x=t.useEditorStore(z=>z.selectedSchemaName),S=t.useDashboardStore(z=>z.dashboard.aiScopeTables),{setTriggerAIRun:C,setCurrentAssitantScope:M}=t.useEditorActions(),{selectedDatamodelName:N,connectionType:E,selectedDatamodelId:F}=te(),{messages:R,setMessages:$,reload:k,error:L,append:Q,input:P,setInput:I,status:g,handleInputChange:T,handleSubmit:q,stop:A}=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:w,onFinish(z,K){v(K.usage),n(""),K.finishReason==="stop"&&n("")}});D.useEffect(()=>{m&&y&&(T({target:{value:y}}),setTimeout(()=>{q(),C(!1)},100))},[m,q,y,C,T]);async function w({toolCall:z}){if(z.toolName==="createChartFromSql"){const K=z.args.sql,X=z.args.chartType;return u(X),c(K),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:d||""}:{status:"error",message:"No SQL found"};if(z.toolName==="getCurrentTableScope")return n("Getting table scope..."),G(),{status:"success",tables:f};n("Analyzing...")}}function v(z){o(K=>K?{promptTokens:K.promptTokens+z.promptTokens,completionTokens:K.completionTokens+z.completionTokens,totalTokens:K.totalTokens+z.totalTokens}:z)}function U(z){const K=t.removeFromScopeArray(f,z);_(K)}function _(z){const K=t.sanitizeAIScope(z);M(K),$(X=>[...X,{id:crypto.randomUUID(),role:"system",content:`Current scope of tables | ${JSON.stringify(K)}`}])}function O(){const z={databaseName:b||"",schemaName:x||"",tableName:p||"",datamodelId:F||"",datamodelName:t.resolveDatamodelName(N),connectionId:j||"",connectionType:E||""},K=t.dedup([...f,z]);_(K)}function G(){const z={databaseName:b||"",schemaName:x||"",tableName:p||"",datamodelName:t.resolveDatamodelName(N),connectionId:j||"",connectionType:E||"",datamodelId:F||""};if(!t.isInAiScopeArray([...S||[],...f],z)||f.length===0){const X=t.dedup([...S||[],...f,z]).filter(ae=>ae.connectionId===z.connectionId);_(X)}}const W=!["ready","error"].includes(g),V=(Z=(H=(J=JSON.parse((L==null?void 0:L.message)||"{}"))==null?void 0:J.error)==null?void 0:H.lastError)==null?void 0:Z.message;return{messages:R,setMessages:$,reload:k,append:Q,input:P,setInput:I,isLoading:W,handleSetAIScope:G,handleAddCurrentTableToScope:O,removeFromCurrentSelections:U,currentAssitantScope:f,setCurrentAssitantScope:M,handleInputChange:T,handleSubmit:q,stop:A,chatStatus:g,toolStatus:a,llmUsage:r,onFinish:s,errorMessage:V}}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),d=s.substring(a);return`${i} {{ filters | where }} AND ${d.substring(6)}`}else if(n!==-1){const i=s.substring(0,n),d=s.substring(n);return`${i} {{ filters | where }} ${d}`}else{const i=s.substring(0,l),d=s.substring(l);return console.log("beforeClause",i),console.log("afterClause",d),d?`${i} {{ filters | where }} ${d}`:`${i.replace(/;$/,"")} {{ filters | where }}`}}function Vt({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),d=t.useEditorStore(m=>m.selectedTableName),c=t.useEditorStore(m=>m.selectedConnectionId),h=t.useEditorStore(m=>m.isShowingVisual),u=r.sql,f=t.useEditorStore(m=>m.onSave);function y(){let m=u;u&&!u.includes("{{")&&(m=Dn(u),a(m));const b={...r,lastSelectedSchema:o,lastSelectedDatamodelId:l,lastSelectedDatabase:i,lastSelectedTable:d,connectionId:c,type:h?r.type:"table",sql:m,customCfg:h?r.customCfg:null},p=n.cards.map(x=>x.id===r.id?b:x),j={...n,cards:p,activeCardId:En(p,n.activeCardId)};f==null||f(j)}return e.jsxs(t.Button,{onClick:y,size:"sm",variant:s,children:[e.jsx(t.Check,{className:"mr-2 size-4 font-bold"}),"Accept"]})}function qt(){const{setTempQueryData:s,setSqlGen:a}=t.useEditorActions(),n=t.useQueryClient(),r=t.useEditorStore(c=>c.tempQueryData),o=t.useEditorStore(c=>c.onClose),l=t.useEditorStore(c=>c.card),{queryKey:i}=t.useDashboardCardQuery(l);function d(){if(r){const{queryKey:c,queryData:h}=r;c&&h&&n.setQueryData(c,h)}a({}),o==null||o()}return e.jsxs(t.Button,{onClick:d,size:"sm",variant:"secondary",children:[e.jsx(t.X,{className:"mr-2 size-4"}),"Close"]})}function Pt(){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:d,setCardCustomCfg:c,setCardPreferences:h,setCardType:u,clearQueryConfig:f}=t.useEditorActions();function y(){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({}),f(),d(""),c(""),h({})}return e.jsxs(t.Button,{onClick:y,className:"",size:"sm",variant:"secondary",children:[e.jsx(Ts,{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(d=>d.tabTitle===l);return i?i.id:s[0].id}return a}}return s[0].id}function Tn(){const s=t.useQueryClient(),[a,n]=D.useState(!1),[r,o]=D.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 d=t.useEditorStore(v=>{var U;return(U=v==null?void 0:v.card)==null?void 0:U.sql}),{sheetFilterValues:c}=t.useSheetFilterValues(),{setCardCustomCfg:h,setQueryResultColumns:u,setCardSql:f,setTempQueryData:y,setPythonStdOut:m,setCardPreferences:b,setCardType:p,setCardPython:j,runAssistant:x,setShowAIDialog:S}=t.useEditorActions();t.useEditorStore(v=>v.onSave),t.useEditorStore(v=>v.onClose),t.useEditorStore(v=>v.actions.setSqlGen);const C=t.useEditorStore(v=>v.runSql),M=t.useEditorStore(v=>v.actions.setRunSql),N=t.useEditorStore(v=>v.actions.setIsSqlRunning),{data:E,isLoading:F,isFetching:R,isSuccess:$,isError:k,error:L,queryKey:Q,refetch:P,errorMessage:I}=t.useDashboardCardQuery(l),{handleSetAIScope:g}=Bt();D.useEffect(()=>{if(E&&(E.rowLimitExceeded&&t.ue.error("Row limit (10,000) exceeded. Refine your query.",{position:"top-center",richColors:!0}),m((E==null?void 0:E.output)||""),E.records.length>0)){const{dimensionKeys:v}=t.getKeys(E.records);u(v)}},[E,u,m]),D.useEffect(()=>{(F||R)&&N(!0),(k||$)&&N(!1),k&&(u([]),m(""))},[F,R,E,m,k,$,N,u,L]),D.useEffect(()=>{C&&(s.getQueryData(Q)||P(),M(!1))},[C,P,M,Q,s]);async function T(){const v=`Can you help me debug this query in the current table scope?
367
367
 
368
368
  Error:
369
369
 
370
- ${D}
370
+ ${I}
371
371
 
372
372
  Query:
373
373
 
374
- ${u}
374
+ ${d}
375
375
 
376
- `;x(v)}function q(){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(kn,{jsonString:JSON.stringify(c,null,2)})})}),c&&c.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(gt,{className:"size-3.5 text-muted-foreground"})})]})}function A(){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(Nn,{})}),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(wn,{})}),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:()=>{P()},className:"shrink-0",size:"sm",children:[R||_?e.jsx(le,{className:"mr-2 h-4 w-4 animate-spin"}):e.jsx(t.Play,{className:"mr-2 h-4 w-4"}),"Run"]}),e.jsx(Lt,{sql:E==null?void 0:E.sql,error:D,onClick:T}),e.jsx(Vt,{}),e.jsx(t.Toggle,{pressed:a,onPressedChange:v=>n(v),className:"",size:"sm",children:e.jsx(vn,{className:"size-4 text-foreground/70"})}),e.jsx("button",{disabled:i,onClick:()=>{g(),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(_t,{})]})]})}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:[A(),q()]}),k()]})}function Tn({data:s}){var i;const[a,n]=I.useState([]),o=Object.keys(s[0]).map(u=>({accessorKey:u,header:({column:c})=>{const h=c.getIsSorted();return e.jsx("div",{className:"flex gap-2",children:e.jsxs("div",{className:"flex cursor-pointer items-center",onClick:()=>c.toggleSorting(c.getIsSorted()==="asc"),children:[u,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.jsxs(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(u=>e.jsx(t.TableRow,{className:"",children:u.headers.map(c=>e.jsx(t.TableHead,{className:"h-11 font-semibold text-foreground",children:c.isPlaceholder?null:t.flexRender(c.column.columnDef.header,c.getContext())},c.id))},u.id))}),e.jsx(t.TableBody,{children:(i=l.getRowModel().rows)!=null&&i.length?l.getRowModel().rows.map(u=>e.jsx(t.TableRow,{className:"h-11 whitespace-nowrap py-2","data-state":u.getIsSelected()&&"selected",children:u.getVisibleCells().map(c=>e.jsx(t.TableCell,{className:"py-2",children:t.flexRender(c.column.columnDef.cell,c.getContext())},c.id))},u.id)):e.jsx(t.TableRow,{children:e.jsx(t.TableCell,{colSpan:o.length,className:"h-24 text-center",children:"No results."})})})]}),e.jsx(t.ScrollBar,{orientation:"horizontal"})]})}function Mn({card:s}){var S,C,M,N,E,R,_,U,w,z,$;const[a,n]=I.useState(!1),[r,o]=I.useState([]),{authToken:l}=t.useSemaphorContext(),i=t.getTokenParams(l==null?void 0:l.accessToken),u=t.useDashboardStore(P=>P.themeStyle),c={colors:((C=(S=u==null?void 0:u.chart)==null?void 0:S.dataset)==null?void 0:C.backgroundColor)||[]};(M=s.customCardPreferences)!=null&&M.inputData;const{getCard:h}=t.useCustomVisual(((N=s.customCardPreferences)==null?void 0:N.url)||""),d=((E=s.customCardPreferences)==null?void 0:E.visualType)||"single",f=t.useEditorStore(P=>P.frame),{setCustomCardPreferences:y}=t.useEditorActions(),{data:m}=t.useDashboardCardQuery(s),b=I.useCallback((P,D)=>{o(g=>({...g,[P]:D}))},[]);if(!((R=s.customCardPreferences)!=null&&R.componentName))return null;const p=h((_=s.customCardPreferences)==null?void 0:_.componentName);function j(P){n(P)}const x=Object.keys(((U=s.customCardPreferences)==null?void 0:U.dataInputCardIds)||{}).map(P=>{var T,q,A;const D=(q=(T=s.customCardPreferences)==null?void 0:T.dataInputCardIds)==null?void 0:q[P].cardId,g=(A=f==null?void 0:f.cards)==null?void 0:A.find(k=>k.id===D);return g||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(I.Suspense,{fallback:e.jsx(e.Fragment,{}),children:[p&&d==="single"&&e.jsx(p,{params:i,theme:c,settings:(w=s.customCardPreferences)==null?void 0:w.settings,onDataChange:b,data:(m==null?void 0:m.records)||[]}),p&&d==="multiple"&&e.jsxs(e.Fragment,{children:[Object.keys(((z=s.customCardPreferences)==null?void 0:z.dataInputCardIds)||{}).map(P=>{var T,q,A;const D=(q=(T=s.customCardPreferences)==null?void 0:T.dataInputCardIds)==null?void 0:q[P].cardId,g=(A=f==null?void 0:f.cards)==null?void 0:A.find(k=>k.id===D);if(g)return e.jsx(t.MultiInputEmptyRenderer,{onLoadingStatus:j,onDataChange:b,dataInputIndex:P,card:g},g.id+P)}),e.jsx("div",{className:"flex flex-col gap-2",children:e.jsx(p,{theme:c,onDataChange:b,settings:x.map(P=>{var D;return(D=P==null?void 0:P.customCardPreferences)==null?void 0:D.settings}),data:x.map(P=>P!=null&&P.id?r==null?void 0:r[P.id]:[])})})]})]},($=s.customCardPreferences)==null?void 0:$.componentName)})}function qt({className:s,...a}){var j;const n=t.useEditorStore(x=>x.card),r=((j=n.customCardPreferences)==null?void 0:j.showCardHeader)??!0,o=t.useEditorStore(x=>x.frame),l=t.useDashboardStore(x=>x.dashboard.filters);t.useEditorStore(x=>x.actions.setRunSql);const{updateFilter:i}=t.useDashboardActions(),u=l==null?void 0:l.find(x=>x.id===o.filterId),{data:c,isLoading:h,isFetching:d}=t.useDashboardCardQuery(n),{setCard:f}=t.useEditorActions(),{data:y}=t.useTopoJson(n),m=I.useMemo(()=>!n.id||!(c!=null&&c.records)?null:t.createChartConfig({data:c==null?void 0:c.records,cardType:n.type,queryConfig:n.queryConfig,customCfg:n.customCfg,preferences:n.preferences,topoJson:y}),[n.id,c==null?void 0:c.records,n.type,n.queryConfig,n.customCfg,n.preferences,y]);function b(x){return e.jsx(Mn,{card:x})}function p(){if(c!=null&&c.records&&(c==null?void 0:c.records.length)===0&&!h&&!d)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 b(n);if(!["table","custom"].includes(n.type)&&m)return e.jsx(e.Fragment,{children:h||d?e.jsx(e.Fragment,{}):e.jsx(t.ChartJsVisual,{cfg:m})});if(n.type==="table"&&(c!=null&&c.records)&&(c==null?void 0:c.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:c==null?void 0:c.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,{enabled:!0,text:n.title,onSave:x=>f({...n,title:x}),children:e.jsx("div",{className:"flex items-center gap-5",children:e.jsx(t.CardTitle,{className:"text-base",children:n.title||"Add title"})})},n.title),e.jsx(t.Editable,{enabled:!0,text:n.description||"",onSave:x=>f({...n,description:x}),children:e.jsx(t.CardDescription,{children:n.description||"Add description"})},n.description)]}),u&&e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(t.Editable,{enabled:!0,className:"my-1",text:u.title||u.column,onSave:x=>i({...u,title:x}),children:e.jsx(t.Label,{children:u.title})}),e.jsx(t.FilterComponent,{filter:u})]})]}),e.jsx(t.CardContent,{className:"flex grow flex-col",children:p()})]})}const ze=({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}),An=()=>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."})]})]}),Ln=({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(ze,{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(ze,{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(ze,{language:"javascript",value:s,onChange:o})})]}),On=({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 zn(){const[s,a]=I.useState(!1),[n,r]=I.useState(""),[o,l]=I.useState(""),[i,u]=I.useState(""),[c,h]=I.useState(""),d=t.useEditorStore(N=>N.card),f=t.useEditorStore(N=>N.card.customCfg),y=f?JSON.stringify(f,null,2):"",{data:m}=t.useDashboardCardQuery(d),{data:b}=t.useTopoJson(d),{setCardCustomCfg:p,setCustomVisualCode:j}=t.useEditorActions(),x=N=>{var E,R;return JSON.stringify({...N,data:{...N.data,datasets:(R=(E=N.data)==null?void 0:E.datasets)==null?void 0:R.map(_=>({..._,data:[]}))}},null,2)},S=()=>{var E,R;if(!((E=m==null?void 0:m.records)!=null&&E.length))return;const N=t.createChartConfig({data:m.records,cardType:d.type,queryConfig:d.queryConfig,preferences:d.preferences,topoJson:b});if(N){r(x(N)),u(((R=d.preferences)==null?void 0:R.customVisualCode)||"");const _=t.merge(N,f);l(x(_))}},C=()=>{try{if(i&&j(i),o){const N=JSON.parse(o),E=t.getObjectDiff(JSON.parse(n),N);p(E),h("")}}catch{h("Invalid JSON configuration")}},M=Object.keys(f||{}).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:M?"":"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(An,{}),e.jsxs("div",{className:"flex grow gap-2",children:[e.jsx(t.ErrorBoundary,{FallbackComponent:t.FallbackEditorCard,children:e.jsx(qt,{className:"w-1/2 rounded shadow-none"})}),e.jsx(Ln,{customCode:i,cardCustomCfgString:y,mergedConfig:o,onConfigChange:N=>l(N??""),onCodeChange:N=>u(N??"")})]}),e.jsx(On,{error:c,hasCardCustomConfig:!!f,onReset:()=>{l(n),p(null)},onApply:C,onClose:()=>a(!1)})]})]})}function Pt(s){const[a,n]=I.useState(null);return a}function Ht(){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 Fn({onChartTypeChange:s}){const[a,n]=I.useState([]),{setCardCustomCfg:r,setCardPreferences:o,setCardType:l,setCustomCardPreferences:i}=t.useEditorActions(),{data:u}=Ht();function c(h,d){r(null),o({}),l(h),d&&i({type:"component",visualType:"single",url:d.url,componentName:d.name,icon:d.icon}),s==null||s()}return I.useEffect(()=>{(async()=>{var d;if(u){const y=(await Promise.all((d=u==null?void 0:u.plugins)==null?void 0:d.map(async m=>(await t.loadManifest(m.value)).visuals.map(j=>({name:j.name,icon:j.icon,url:m.value}))))).flat();n(y)}})()},[u]),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,d)=>e.jsx(Rn,{text:h.name,onClick:()=>c("custom",h),icon:h.icon},h.url+h.name+d))})]})}const Rn=({text:s,icon:a,onClick:n})=>{const r=Pt(),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 Gt(s){return pe({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 pe({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 Ut(s){return pe({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 $t(s){return pe({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 Qt(s){return pe({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 Kt({onChartTypeChange:s,iconClassName:a}){const{setCardType:n,setCardPreferences:r,setIsDevMode:o}=t.useEditorStore(d=>d.actions),{setCardCustomCfg:l,setCustomCardPreferences:i,setQueryConfig:u}=t.useEditorActions();function c(d,f){l(null),r({}),n(d),["kpi","custom","text","map"].includes(d)&&(o(!0),u(void 0)),s==null||s()}const h=1e3;return e.jsxs("div",{className:"grid grid-cols-4 place-items-center",children:[e.jsx(t.IconButton,{openDelay:h,tooltip:"Table",onClick:()=>c("table"),className:"h-10 p-4",children:e.jsx(Ue,{className:t.cn("size-5",a)})}),e.jsx(t.IconButton,{openDelay:h,tooltip:"Bar Chart",onClick:()=>c("bar"),className:"h-10 p-4",children:e.jsx(He,{className:t.cn("size-5",a)})}),e.jsx(t.IconButton,{openDelay:h,tooltip:"Line Chart",onClick:()=>c("line"),className:"h-10 p-4",children:e.jsx(Ge,{className:t.cn("size-5",a)})}),e.jsx(t.IconButton,{openDelay:h,tooltip:"Stacked Bar Chart",onClick:()=>c("stackedBar"),className:"h-10 p-4",children:e.jsx(ct,{className:t.cn("size-5",a)})}),e.jsx(t.IconButton,{openDelay:h,tooltip:"Stacked Line Chart",onClick:()=>c("stackedLine"),className:"h-10 p-4",children:e.jsx($t,{className:t.cn("size-5",a),strokeWidth:0})}),e.jsx(t.IconButton,{openDelay:h,tooltip:"Scatter Chart",onClick:()=>c("scatter"),className:"h-10 p-4",children:e.jsx(mt,{className:t.cn("size-5",a)})}),e.jsx(t.IconButton,{openDelay:h,tooltip:"Bubble Chart",onClick:()=>c("bubble"),className:"h-10 p-4",children:e.jsx(Ut,{className:t.cn("size-5",a)})}),e.jsx(t.IconButton,{openDelay:h,tooltip:"Pie Chart",onClick:()=>c("pie"),className:"h-10 p-4",children:e.jsx(ut,{className:t.cn("size-5",a)})}),e.jsx(t.IconButton,{openDelay:h,tooltip:"Doughnut Chart",onClick:()=>c("doughnut"),className:"h-10 p-4",children:e.jsx(pt,{className:t.cn("size-5",a)})}),e.jsx(t.IconButton,{openDelay:h,tooltip:"Radar Chart",onClick:()=>c("radar"),className:"h-10 p-4",children:e.jsx(bt,{className:t.cn("size-5",a)})}),e.jsx(t.IconButton,{openDelay:h,tooltip:"Polar Area Chart",onClick:()=>c("polarArea"),className:"h-10 p-4",children:e.jsx(Gt,{className:t.cn("size-5",a)})}),e.jsx(t.IconButton,{openDelay:h,tooltip:"Pyramid Chart",onClick:()=>c("pyramid"),className:"h-10 p-4",children:e.jsx(Nt,{className:t.cn("size-5",a)})}),e.jsx(t.IconButton,{tooltip:"Range Chart",onClick:()=>c("range"),className:"h-10 p-4",children:e.jsx(dt,{className:t.cn("size-5",a)})}),e.jsx(t.IconButton,{openDelay:h,tooltip:"KPI",onClick:()=>c("kpi"),className:"h-10 p-4",children:e.jsx(Qt,{className:t.cn("size-5",a)})}),e.jsx(t.IconButton,{openDelay:h,tooltip:"Text",onClick:()=>c("text"),className:"h-10 p-4",children:e.jsx(fs,{className:t.cn("size-5",a)})}),e.jsx(t.IconButton,{tooltip:"Map",onClick:()=>c("map"),className:"h-10 p-4",children:e.jsx(yt,{className:t.cn("size-5",a)})}),e.jsx(t.IconButton,{openDelay:h,tooltip:"Custom",onClick:()=>c("custom"),className:"h-10 p-4",children:e.jsx(Ct,{className:t.cn("size-5",a)})})]})}function Bn({chartType:s,className:a,customIcon:n,componentName:r}){const o=Pt();switch(s){case"bar":return e.jsx(He,{className:a});case"line":return e.jsx(Ge,{className:a});case"pie":return e.jsx(ut,{className:a});case"radar":return e.jsx(bt,{className:a});case"scatter":return e.jsx(mt,{className:a});case"bubble":return e.jsx(Ut,{className:a});case"doughnut":return e.jsx(pt,{className:a});case"stackedBar":return e.jsx(ct,{className:a});case"stackedLine":return e.jsx($t,{className:a});case"polarArea":return e.jsx(Gt,{className:a});case"pyramid":return e.jsx(Nt,{className:a});case"range":return e.jsx(dt,{className:a});case"kpi":return e.jsx(Qt,{className:a});case"text":return e.jsx(wt,{className:a});case"map":return e.jsx(yt,{className:a});case"custom":return n&&o?e.jsx(o,{className:a}):r?r==null?void 0:r.charAt(0).toUpperCase():e.jsx(Ct,{className:a});default:return e.jsx(Ue,{className:a})}}function Vn(){var l,i;const[s,a]=I.useState(!1),n=t.useEditorStore(u=>u.card),r=n.type,o=t.useDashboardStore(u=>u.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:(l=n.customCardPreferences)==null?void 0:l.icon,componentName:(i=n.customCardPreferences)==null?void 0:i.componentName})})}),e.jsxs(t.PopoverContentCustom,{onOpenAutoFocus:u=>u.preventDefault(),className:"w-50",children:[e.jsx(Kt,{onChartTypeChange:()=>a(!1)}),e.jsx(Fn,{onChartTypeChange:()=>a(!1)})]})]})}const ye="focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0";function it(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 qn(){var g,T,q,A,k,v;const[s,a]=I.useState(!1),n=t.useEditorStore(L=>{var O;return(O=L.card)==null?void 0:O.preferences}),r=t.getNumberAxis(n,{}),[o,l]=I.useState(it(n)),[i,u]=I.useState(((q=(T=(g=n==null?void 0:n.chartOptions)==null?void 0:g.scales)==null?void 0:T[r])==null?void 0:q.min)||""),[c,h]=I.useState(((v=(k=(A=n==null?void 0:n.chartOptions)==null?void 0:A.scales)==null?void 0:k[r])==null?void 0:v.max)||""),[d,f]=I.useState(i||c?"custom":"auto"),[y,m]=I.useState(""),[b,p]=I.useState(0),[j,x]=I.useState(""),[S,C]=I.useState(""),[M,N]=I.useState(""),E=t.useEditorStore(L=>L.actions.setCardPreferences),{updateCardInFrame:R}=t.useEditorActions(),_=t.useEditorStore(L=>L.card),U=t.useEditorStore(L=>{var O;return(O=L.card)==null?void 0:O.type}),w=["pie","doughnut","polarArea"].includes(U);I.useEffect(()=>{var L,O,J,H,W,V,K,G,Z,F,Q,X,ae,de;l(it(n)),u(((J=(O=(L=n==null?void 0:n.chartOptions)==null?void 0:L.scales)==null?void 0:O[r])==null?void 0:J.min)===0?0:""),h(((V=(W=(H=n==null?void 0:n.chartOptions)==null?void 0:H.scales)==null?void 0:W[r])==null?void 0:V.max)||""),m(((F=(Z=(G=(K=n==null?void 0:n.chartOptions)==null?void 0:K.scales)==null?void 0:G[r])==null?void 0:Z.ticks)==null?void 0:F.stepSize)||""),p(((Q=n==null?void 0:n.numberAxisFormat)==null?void 0:Q.decimalPlaces)||0),x(((X=n==null?void 0:n.numberAxisFormat)==null?void 0:X.suffix)||""),C(((ae=n==null?void 0:n.numberAxisFormat)==null?void 0:ae.currency)||""),N(((de=n==null?void 0:n.numberAxisFormat)==null?void 0:de.locale)||"")},[s,n,r]);function z(L,O){return O===""||/^[0-9\b]+$/.test(O)?Number(O):Number(L)}function $(){const L=[...new Set(t.LOCALE_CURRENCY_PAIRS.map(O=>O.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:O=>C(O==="none"?"":O),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"}),L.map(O=>e.jsx(t.SelectItem,{value:O,children:O},O))]})})]}),e.jsxs(t.Select,{value:M,onValueChange:O=>N(O),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(O=>e.jsx(t.SelectItem,{value:O.locale,children:O.locale},O.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:b,onChange:O=>p(Number(O.target.value)),id:"format",className:`col-span-6 h-8 w-full tracking-wide ${ye}`})]})]})}function P(){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:L=>u(O=>z(O,L.target.value)),className:`col-span-1 h-8 w-full ${ye}`}),e.jsx(t.Input,{value:c,onChange:L=>h(O=>z(O,L.target.value)),id:"max",className:`col-span-1 h-8 w-full ${ye}`})]}),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:y,onChange:L=>m(O=>z(O,L.target.value)),id:"step-size",className:`col-span-1 h-8 w-full ${ye}`})]})]})}function D(){var H;let L={};d==="custom"&&(L={min:i,max:c,ticks:{stepSize:y}});const O={...n||{},chartOptions:{...n==null?void 0:n.chartOptions,scales:{...(H=n==null?void 0:n.chartOptions)==null?void 0:H.scales,[r]:{type:o,...o==="linear"?L:{}}}},numberAxisFormat:{decimalPlaces:b,suffix:j,currency:S,locale:M}};console.log(O),E(O);const J={..._,preferences:O};R(J)}return e.jsxs(t.Popover,{onOpenChange:L=>a(L),children:[e.jsx(t.PopoverTrigger,{asChild:!0,children:e.jsx(t.IconButton,{tooltip:"Format Number",children:e.jsx(ks,{className:"size-4"})})}),e.jsx(t.PopoverContentCustom,{align:"end",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:"Format Options"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Set the format for number axis"})]}),e.jsxs("div",{className:"grid gap-2",children:[$(),e.jsx("div",{className:"mt-4 space-y-2",children:e.jsx("p",{className:"text-sm text-muted-foreground",children:"Set the scale for number axis"})}),e.jsxs("div",{className:"mt-2 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:L=>l(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,{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:d,onValueChange:L=>f(L),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"})]})]})]}),d==="custom"&&o=="linear"&&P(),e.jsx(t.SelectSeparator,{}),e.jsx("div",{className:"grid grid-cols-3",children:e.jsx(t.Button,{onClick:D,variant:"secondary",className:"col-span-1 col-start-3 h-8 w-full",children:"Apply"})})]})]})})]})}function Pn(){const s=t.useEditorStore(u=>{var c,h,d,f;return(f=(d=(h=(c=u.card.preferences)==null?void 0:c.chartOptions)==null?void 0:h.plugins)==null?void 0:d.legend)==null?void 0:f.position}),a=t.useEditorStore(u=>{var c,h,d,f;return(f=(d=(h=(c=u.card.preferences)==null?void 0:c.chartOptions)==null?void 0:h.plugins)==null?void 0:d.legend)==null?void 0:f.align}),n=t.useEditorStore(u=>{var c,h,d,f;return(f=(d=(h=(c=u.card.preferences)==null?void 0:c.chartOptions)==null?void 0:h.plugins)==null?void 0:d.legend)==null?void 0:f.display}),{setLegendOptions:r}=t.useEditorActions(),o=u=>{r({display:u,position:s,align:a})},l=u=>{r({display:n,position:u,align:a})},i=u=>{r({display:n,position:s,align:u})};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,{align:"end",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,id:"displayLegend"})})]}),n&&e.jsxs(e.Fragment,{children:[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(ds,{className:"size-4"})}),e.jsx(t.IconButton,{tooltip:"Bottom",onClick:()=>l("bottom"),children:e.jsx(lt,{className:"size-4"})}),e.jsx(t.IconButton,{tooltip:"Right",onClick:()=>l("right"),children:e.jsx(us,{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(rs,{className:"size-4"})}),e.jsx(t.IconButton,{tooltip:"Center",onClick:()=>i("center"),children:e.jsx(as,{className:"size-4"})}),e.jsx(t.IconButton,{tooltip:"End",onClick:()=>i("end"),children:e.jsx(os,{className:"size-4"})})]})]})]})]})]})})]})}function Hn(){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 Gn(){const s=t.useEditorStore(i=>i.card),a=t.useEditorStore(i=>i.isShowingVisual),n=t.useEditorStore(i=>{var u,c;return(c=(u=i.card)==null?void 0:u.preferences)==null?void 0:c.chartOptions}),r=t.getChartGridStyle(n),{setChartGrid:o}=t.useEditorActions();function l(){const i=["xy","none","x","y"],c=(i.indexOf(r)+1)%i.length;o(i[c])}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(Hn,{}),!["kpi","text","custom","table"].includes(s.type)&&e.jsxs(e.Fragment,{children:[e.jsx(qn,{}),e.jsx(Pn,{})]}),!["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(Cs,{className:"size-4"}),r==="y"&&e.jsx(Qs,{className:"size-4"}),r==="none"&&e.jsx(Ys,{className:"size-4"})]})]}):null}function be(){var A;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),u=t.useEditorStore(k=>{var v;return(v=k.card.preferences)==null?void 0:v.chartOptions}),c=t.useEditorStore(k=>k.actions.setRunSql);t.getChartGridStyle(u);const{setFrame:h,setCard:d,updateCardInFrame:f,setActiveTabCardId:y,runAssistant:m,setChartGrid:b}=t.useEditorActions(),{data:p,isLoading:j,isFetching:x,error:S}=t.useDashboardCardQuery(a);if(!a)return e.jsx(e.Fragment,{children:"No Active Card"});function C(){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:[]};M(k)}function M(k){const v={...s,cards:[...s.cards,k],activeCardId:k.id};h(v),d(k),y(k.id)}function N(){const k={...a,id:t.v4(),title:`${a.title} Copy`,tabTitle:`${a.tabTitle||a.title} Copy`};M(k)}function E(k){const v=s.cards.filter(J=>J.id!==k),L=v[0],O={...s,cards:v,activeCardId:L.id};h(O),y(L.id),d(L)}function R(k){n||_(k),y(k)}function _(k){const v={...s,cards:s.cards.map(O=>O.id===a.id?a:O),activeCardId:k};h(v);const L=v.cards.find(O=>O.id===k);L.sql&&c(!0),d(L)}const U=(k,v)=>{console.log("handleDragStart",v),k.dataTransfer.setData("tabIndex",v.toString())},w=k=>{k.preventDefault()},z=(k,v)=>{const L=k.dataTransfer.getData("tabIndex");if(L===v.toString())return;const O=Array.from(s.cards),[J]=O.splice(parseInt(L),1);O.splice(v,0,J),h({...s,cards:O})};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 L=v.displayTab===void 0?!1:!v.displayTab;d({...v,displayTab:L}),f({...v,displayTab:L})},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 P(){return e.jsxs(t.Tabs,{onValueChange:R,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:D()},k.id)),e.jsx(t.TabsList,{className:"group mx-4 justify-between overflow-x-auto",children:e.jsxs("div",{className:"flex items-center",children:[s.cards.map((k,v)=>e.jsxs(t.TabsTrigger,{draggable:!0,onDragStart:L=>U(L,v),onDragOver:w,onDrop:L=>z(L,v),className:"",value:k.id,children:[$(s,k),e.jsx(t.Editable,{enabled:s.activeCardId===k.id,text:k.tabTitle||k.title,onSave:L=>{d({...a,tabTitle:L}),f({...a,tabTitle:L})},children:k.tabTitle||k.title},k.id),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:()=>E(k.id)})]})),e.jsx(t.Button,{className:"ml-1 h-8 px-2 hover:bg-muted-foreground/50",variant:"outline",onClick:C,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 D(){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(qt,{className:"grow border-none shadow-none"})})}function g(){const k=JSON.stringify(p==null?void 0:p.records,null,2),v=new Blob([k],{type:"application/json"}),L=URL.createObjectURL(v),O=document.createElement("a");O.href=L,O.download=`${a.title}.json`,O.click()}function T(){const v=[Object.keys(p==null?void 0:p.records.reduce((H,W)=>({...H,...W}),{})).join(","),...((p==null?void 0:p.records)||[]).map(H=>Object.values(H).join(","))].join(`
377
- `),L=new Blob([v],{type:"text/csv"}),O=URL.createObjectURL(L),J=document.createElement("a");J.href=O,J.download=`${a.title}.csv`,J.click()}function q(){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-2 pb-3",children:[(j||x)&&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(le,{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(Vn,{}),o&&e.jsx(t.IconButton,{tooltip:"Visual Docs",onClick:q,children:e.jsx(xs,{className:"size-4"})}),!["table","custom"].includes(a.type)&&o&&e.jsx(zn,{})]}),!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:T,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:g,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(Gn,{}),n&&e.jsx($n,{})]}),r?P():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(Un,{})}),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(Tn,{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)||((A=p==null?void 0:p.error)==null?void 0:A.message)})]})]})]})}function Un(){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 $n(){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 Qn(){var p,j;const s=t.useEditorStore(x=>x.card.customCardPreferences),{data:a}=Ht(),n=(a==null?void 0:a.plugins)||[],r=t.useEditorStore(x=>x.card),o=t.useEditorStore(x=>x.frame),l=(s==null?void 0:s.visualType)||"single",{setCustomCardPreferences:i}=t.useEditorActions(),{components:u,manifest:c}=t.useCustomVisual((s==null?void 0:s.url)||""),h=(p=c==null?void 0:c.visuals)==null?void 0:p.find(x=>x.name===(s==null?void 0:s.componentName));function d(x,S){if(!s)return;const M={...(s==null?void 0:s.dataInputCardIds)||{},[x]:{cardId:S,hookRef:null}};i({...s,dataInputCardIds:M})}function f(x){var C,M;const S=(C=o==null?void 0:o.cards)==null?void 0:C.filter(N=>{var E;return((E=N==null?void 0:N.customCardPreferences)==null?void 0:E.visualType)!=="multiple"}).map(N=>({value:N.id,label:N.tabTitle||N.title}));return e.jsx("div",{className:"space-y-2",children:(M=x==null?void 0:x.dataInputs)==null?void 0:M.map((N,E)=>{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:R[E])==null?void 0:_.cardId)||"",onValueChange:U=>d(E,U)})]},E+Math.random())})})}function y(x,S,C=[],M=""){var N,E;return s?x==="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])||M,onChange:R=>{i({...s,settings:{...s==null?void 0:s.settings,[S]:R.target.value}})}},S):x==="select"?e.jsx(ee,{className:"h-8 w-full",label:"",options:C,value:((E=s==null?void 0:s.settings)==null?void 0:E[S])||M,onValueChange:R=>{i({...s,settings:{...s==null?void 0:s.settings,[S]:R}})}}):null:null}function m(x){const S=Object.entries((x==null?void 0:x.settings)||{});return e.jsx("div",{className:"space-y-3",children:S.map(([C,M])=>e.jsxs("div",{className:"space-y-1",children:[e.jsx(t.Label,{children:M.title}),y(M.ui,C,M.options,M.defaultValue)]},C))})}function b(x){s&&i({...s,visualType:x,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:x=>i({...s||{url:"",componentName:""},url:x})}),((s==null?void 0:s.type)==="component"||(s==null?void 0:s.type)===void 0)&&e.jsx(t.Tabs,{value:l,onValueChange:b,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:u&&e.jsx(ee,{icon:e.jsx(vs,{className:"h-3.5 w-3.5"}),className:"h-9 w-full",label:"Select Component",options:(u==null?void 0:u.filter(x=>x.type===l).map(x=>({value:x.name,label:x.name})))||[],value:s.componentName,onValueChange:x=>{console.log("changing value",x),i({...s,componentName:x})}})})]})})]}),((j=r==null?void 0:r.customCardPreferences)==null?void 0:j.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:f(h)})]}),h&&h.settings&&e.jsx("div",{className:"space-y-3",children:e.jsx("div",{className:"px-2",children:m(h)})})]})]})]})}function ce(){const[s,a]=I.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 d;return(d=h.card.preferences)==null?void 0:d.filterOnClickColumnIndex}),I.useEffect(()=>{l&&a(new Array(l.length).fill(!1))},[l]);function i(h,d){var f,y;d?n!=null&&n.onClickFilter&&((f=n==null?void 0:n.onClickFilter)==null?void 0:f.length)>0?o({...n,onClickFilter:[...n.onClickFilter,{columnIndex:h,expression:""}]}):o({...n,onClickFilter:[{columnIndex:h,expression:""}]}):(o({...n,onClickFilter:(y=n==null?void 0:n.onClickFilter)==null?void 0:y.filter(m=>m.columnIndex!==h)}),a(m=>{const b=[...m];return b[h]=!1,b}))}function u(h,d){var y;const f=(y=n==null?void 0:n.onClickFilter)==null?void 0:y.map(m=>m.columnIndex===h?{...m,expression:d.target.value}:m);o({...n,onClickFilter:f})}function c(h){var d,f,y,m;if(s!=null&&s[h]||(f=(d=n==null?void 0:n.onClickFilter)==null?void 0:d.find(b=>b.columnIndex===h))!=null&&f.expression)return e.jsx(t.Input,{value:(m=(y=n==null?void 0:n.onClickFilter)==null?void 0:y.find(b=>b.columnIndex===h))==null?void 0:m.expression,onChange:b=>u(h,b),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,d)=>{var f,y;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:!!((f=n==null?void 0:n.onClickFilter)!=null&&f.find(m=>m.columnIndex===d)),onCheckedChange:m=>i(d,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:((y=n==null?void 0:n.onClickFilter)==null?void 0:y.find(m=>m.columnIndex===d))&&e.jsx(t.Pencil,{onClick:()=>{a(m=>{const b=[...m];return b[d]=!m[d],b})},className:"invisible size-3 cursor-pointer text-gray-400 group-hover:visible"})})]}),c(d)]})},h)})]})}function Kn({idx:s}){var u;const a=t.useEditorStore(c=>{var h;return(h=c.card)==null?void 0:h.preferences}),n=t.useEditorStore(c=>{var h;return(h=c.card.preferences)==null?void 0:h.datasetOptions}),r=t.useEditorStore(c=>c.actions.setCardPreferences),o=(u=a==null?void 0:a.chartOptions)==null?void 0:u.indexAxis,l=n==null?void 0:n.find(c=>c.idx===s);function i(c,h){(c==="end"||c==="start")&&t.getContrastColor(t.getCanvasBackgroundColor());const d={display:c!=="none",align:c,anchor:c,clamp:!0};if(!l)r({...a,datasetOptions:[...n||[],{idx:h,datalabels:d}]});else{const f={...l};f.datalabels=d;const y=n==null?void 0:n.map(m=>m.idx===h?f:m);r({...a,datasetOptions:y})}}return e.jsxs(t.Popover,{children:[e.jsx(t.PopoverTrigger,{children:e.jsx(Zs,{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(Bs,{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(_s,{className:t.cn("h-4 w-4",{"rotate-90":o==="y"})})})]})})]})}function Jt(){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:u}=t.getKeys(i);l=u}return{transformedMetricKeys:l,dimensionKeys:r,keys:o,defaultMetricKeys:n}}function Wt(){const s=t.useEditorStore(c=>c.card),a=t.useEditorStore(c=>{var h,d,f;return(f=(d=(h=c==null?void 0:c.card)==null?void 0:h.preferences)==null?void 0:d.chartOptions)==null?void 0:f.indexAxis}),{data:n}=t.useDashboardCardQuery(s),r=a==="y"?"Metric":"Dimension",o=a==="y"?"Dimension":"Metric",{dimensionKeys:l,transformedMetricKeys:i,keys:u}=Jt();return u.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(c=>e.jsx("p",{className:"rounded-md bg-muted/70 px-3 py-2 hover:bg-muted",title:c,children:Yt(c)},c))})]}),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((c,h)=>e.jsx(Zt,{className:"bg-muted/70 px-3 py-2 hover:bg-muted",iconClassName:"invisible group-hover:visible",col:c,idx:h},c))})]})]})}function Yt(s,a=30){return s.length>a?s.slice(0,a)+"...":s}function Zt({col:s,idx:a,className:n,iconClassName:r,children:o}){const l=t.useEditorStore(d=>{var f;return(f=d.card)==null?void 0:f.preferences}),i=t.useEditorStore(d=>{var f,y;return(y=(f=d.card)==null?void 0:f.preferences)==null?void 0:y.datasetOptions}),u=i==null?void 0:i.find(d=>d.idx===a),{setCardPreferences:c}=t.useEditorStore(d=>d.actions);function h(d){if(!u)c({...l,datasetOptions:[...i||[],{idx:a,type:d==="area"?"line":d,fill:d==="area"?"origin":""}]});else{const f={...u};f.type=d==="area"?"line":d,f.fill=d==="area"?"origin":"";const y=i==null?void 0:i.map(m=>m.idx===a?f:m);c({...l,datasetOptions:y})}}return e.jsxs("div",{className:t.cn("group flex items-center justify-between gap-2 rounded-md",n),children:[o||e.jsx("p",{title:s,children:Yt(s)}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(He,{onClick:()=>h("bar"),className:t.cn("size-4 cursor-pointer text-muted-foreground hover:text-foreground",r)}),e.jsx(Ge,{onClick:()=>h("line"),className:t.cn("size-4 cursor-pointer text-muted-foreground hover:text-foreground",r)}),e.jsx(ys,{onClick:()=>h("area"),className:t.cn("size-4 cursor-pointer text-muted-foreground hover:text-foreground",r)}),e.jsx(Kn,{idx:a})]})]})}function Xt(){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),u=t.useDashboardStore(m=>m.actions.removeFilter),{removeFilterValues:c}=t.useDashboardActions(),{modelItems:h,tableName:d,connectionType:f}=te();function y(m,b="dashboard"){var R;const p=t.fmt(m.column_name),j=t.fmt(n||""),x=t.fmt(r||""),S=t.fmt(d);let C=t.getQualifiedTableName({schemaName:x,tableName:S,connectionType:f,databaseName:j}),M=`${C}.${p}`;const N=(R=h==null?void 0:h.find(_=>_.id===a))==null?void 0:R.name;a&&a!=="none"&&(M=`${t.DATAMODEL_NAMESPCACE}.${N}.${p}`,C=`${t.DATAMODEL_NAMESPCACE}.${N}`);const E=l==null?void 0:l.find(_=>_.column===M&&_.table===S&&(_.database===j||_.database===n));if(E)c(E.id),u(E.id);else{const _=t.v4();return d==="api"&&s?(i({location:b,id:_,column:M,title:m.column_name,dataType:m.data_type,table:"api",database:"",connectionId:s,operation:"in",sql:t.getDefaultFilterSql(m.data_type,C,p)}),_):(i({id:_,location:b,column:M,title:m.column_name,dataType:m.data_type,table:o||"",database:n||"",connectionId:s||"",operation:"in",sql:t.getDefaultFilterSql(m.data_type,C,p)}),_)}}return{assignFilter:y}}function xe(){const s=t.useDashboardStore(u=>u.dashboard.filters),a=t.useEditorStore(u=>u.frame),{setFrame:n}=t.useEditorActions(),{columns:r}=te(),{assignFilter:o}=Xt();function l(u){const c=o(u,"frame");n({...a,filterId:c})}const i=s==null?void 0:s.find(u=>u.id===a.filterId);return e.jsxs("div",{className:"space-y-3",children:[e.jsx(t.Label,{children:"Card Filter"}),e.jsx(Jn,{onSelect:l,columns:r}),i&&e.jsx(t.FilterHeader,{filter:i})]})}function Jn({columns:s,onSelect:a}){var i;const[n,r]=me.useState(!1),[o,l]=me.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(u=>u.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(u=>e.jsxs(t.CommandItem,{value:u.column_name,onSelect:c=>{const h=c===o?"":c;l(h),r(!1),h&&a(u)},children:[u.column_name,e.jsx(t.CheckIcon,{className:t.cn("ml-auto h-4 w-4",o===u.column_name?"opacity-100":"opacity-0")})]},u.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(Wt,{})})]}),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(ce,{}),e.jsx(xe,{})]})]})]})})}function We(){var o,l,i;const s=t.useEditorStore(u=>u.card.type),a=t.useEditorStore(u=>u.card.preferences),{setCardPreferences:n}=t.useEditorStore(u=>u.actions);function r(u){var d;const c={datalabels:{display:u!=="none",align:u,anchor:u,clamp:!0}},h={...a,chartOptions:{...a==null?void 0:a.chartOptions,plugins:{...(d=a==null?void 0:a.chartOptions)==null?void 0:d.plugins,...c}}};n(h),console.log(u)}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 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: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(We,{})})]}),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(ce,{}),e.jsx(xe,{})]})]})]})})}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(We,{}),e.jsx(ce,{}),e.jsx(xe,{})]})]})}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 c,h,d,f,y;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 b,p;return(p=(b=m.card.preferences)==null?void 0:b.formatNumber)==null?void 0:p.decimalPlaces});const r=t.useEditorStore(m=>{var b,p;return(p=(b=m.card.preferences)==null?void 0:b.formatNumber)==null?void 0:p.locale}),o=t.useEditorStore(m=>{var b,p;return(p=(b=m.card.preferences)==null?void 0:b.formatNumber)==null?void 0:p.currency});t.useEditorStore(m=>m.actions.setFilterOnClickField);const l=t.useEditorStore(m=>{var b,p;return(p=(b=m.card.preferences)==null?void 0:b.formatNumber)==null?void 0:p.colorRanges})||[],i=t.useEditorStore(m=>m.actions.setColorRanges),u=[...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:!!((c=s==null?void 0:s.formatNumber)!=null&&c.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 b,p,j;return n(((b=s==null?void 0:s.formatNumber)==null?void 0:b.decimalPlaces)||0,((p=s==null?void 0:s.formatNumber)==null?void 0:p.currency)||"",m,((j=s==null?void 0:s.formatNumber)==null?void 0:j.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 b,p,j;console.log("currency",m),n(((b=s==null?void 0:s.formatNumber)==null?void 0:b.decimalPlaces)||0,m==="none"?"":m,((p=s==null?void 0:s.formatNumber)==null?void 0:p.locale)||"",((j=s==null?void 0:s.formatNumber)==null?void 0:j.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"),u.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:((f=(d=s==null?void 0:s.formatNumber)==null?void 0:d.decimalPlaces)==null?void 0:f.toString())||"0",onValueChange:m=>{var b,p,j;return n(Number(m),((b=s==null?void 0:s.formatNumber)==null?void 0:b.currency)||"",((p=s==null?void 0:s.formatNumber)==null?void 0:p.locale)||"",((j=s==null?void 0:s.formatNumber)==null?void 0:j.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:((y=s==null?void 0:s.formatNumber)==null?void 0:y.suffix)||"",className:"h-8 font-mono text-xs focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0",placeholder:"K, M, B, %",onChange:m=>{var b,p,j;return n(((b=s==null?void 0:s.formatNumber)==null?void 0:b.decimalPlaces)||0,((p=s==null?void 0:s.formatNumber)==null?void 0:p.currency)||"",((j=s==null?void 0:s.formatNumber)==null?void 0:j.locale)||"",m.target.value)}})]})]})]})}),e.jsx(t.Separator,{className:"my-3"}),e.jsx(t.ColorFormat,{colorRanges:l,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 Fe({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 c,h,d,f,y,m,b,p,j,x,S,C,M,N,E,R,_,U;const s=t.useEditorStore(w=>w.card),a=(h=(c=s==null?void 0:s.preferences)==null?void 0:c.mapVisualOptions)==null?void 0:h.topoJsonUrl,[n,r]=I.useState(((f=(d=s==null?void 0:s.preferences)==null?void 0:d.mapVisualOptions)==null?void 0:f.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}))||[],u=[{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(Fe,{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(Fe,{open:!0,summary:"Settings",children:e.jsxs("div",{className:"space-y-3 px-2",children:[e.jsx(ee,{className:"h-9",options:u,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=(y=s.preferences)==null?void 0:y.mapVisualOptions)==null?void 0:m.objectKey)||"",label:"Map Object",onValueChange:w=>{var z;o({...s.preferences,mapVisualOptions:{...(z=s.preferences)==null?void 0:z.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=(b=s.preferences)==null?void 0:b.mapVisualOptions)==null?void 0:p.projection)||"",label:"Projection",onValueChange:w=>{var z;o({...s.preferences,mapVisualOptions:{...(z=s.preferences)==null?void 0:z.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:((x=(j=s.preferences)==null?void 0:j.mapVisualOptions)==null?void 0:x.colorScale)||"",label:"Select Color Scale",onValueChange:w=>{var z;o({...s.preferences,mapVisualOptions:{...(z=s.preferences)==null?void 0:z.mapVisualOptions,colorScale:w}})}})]})]})]})}),e.jsx(t.Separator,{className:"my-4"}),e.jsx(Fe,{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:((C=(S=s.preferences)==null?void 0:S.mapVisualOptions)==null?void 0:C.projectionScale)||1,onChange:w=>{var z;o({...s.preferences,mapVisualOptions:{...(z=s.preferences)==null?void 0:z.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:((E=(N=(M=s.preferences)==null?void 0:M.mapVisualOptions)==null?void 0:N.projectionOffset)==null?void 0:E[0])||0,onChange:w=>{var z,$,P,D;o({...s.preferences,mapVisualOptions:{...(z=s.preferences)==null?void 0:z.mapVisualOptions,projectionOffset:[Number(w.target.value),((D=(P=($=s.preferences)==null?void 0:$.mapVisualOptions)==null?void 0:P.projectionOffset)==null?void 0:D[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:R.mapVisualOptions)==null?void 0:_.projectionOffset)==null?void 0:U[1])||0,onChange:w=>{var z,$,P,D;o({...s.preferences,mapVisualOptions:{...(z=s.preferences)==null?void 0:z.mapVisualOptions,projectionOffset:[((D=(P=($=s.preferences)==null?void 0:$.mapVisualOptions)==null?void 0:P.projectionOffset)==null?void 0:D[0])||0,Number(w.target.value)]}})}})]})}),e.jsx(t.Separator,{className:"my-4"}),e.jsx(ce,{})]})}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 Se({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(We,{}),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(ce,{}),e.jsx(xe,{})]})]})]})})}function ca(){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(Wt,{})]})]}),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(ce,{}),e.jsx(xe,{})]})]})]})})}function da({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(ce,{}),e.jsx(xe,{})]})]})}),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(Se,{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(Se,{docContent:ma,cardType:n});case"pie":case"doughnut":case"polarArea":case"radar":return e.jsx(Se,{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(Se,{docContent:ha,cardType:n,suffix:"Visual"});case"map":return e.jsx(ia,{});case"custom":return e.jsx(Qn,{});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 es({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 xa=[{label:"Sum",value:"SUM",logo:e.jsx(vt,{className:"size-3.5"})},{label:"Count",value:"COUNT",logo:e.jsx(jt,{className:"size-3.5"})},{label:"Unique",value:"DISTINCT",logo:e.jsx(Ms,{className:"size-3.5"})},{label:"Average",value:"AVG",logo:e.jsx(cs,{className:"size-3.5"})},{label:"Min",value:"MIN",logo:e.jsx(lt,{className:"size-3.5"})},{label:"Max",value:"MAX",logo:e.jsx(t.ArrowUp,{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 l={...s,aggregate:o,label:ge(s.name,o)};a(s.id,l)}return e.jsx(es,{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{updateGroupByColumn:a}=t.useEditorActions();function n(r){const o={...s,granularity:r,label:he(s.name,r)};a(s.id,o)}return e.jsx(es,{column:s,functions:ga,onFunctionChange:r=>n(r),label:"Granularity"})}function ya({col:s,onChange:a,droppableId:n}){const{columns:r}=Ke(),o=I.useMemo(()=>{let u=[];(n===re||n===oe||n===ie)&&(u=r);const c=u==null?void 0:u.filter(h=>h.column_name!==s.name);return c==null?void 0:c.map(h=>({id:h.column_name,value:h.column_name}))},[r,n,s.name]),l=[{id:s.name,value:s.name}];function i(u){const c=r==null?void 0:r.find(h=>{var d;return h.column_name===((d=u[0])==null?void 0:d.id)});c&&a(c)}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 pl-0 pr-8"}):e.jsx("input",{disabled:!0,type:"text",className:"overflow-hidden truncate text-ellipsis whitespace-nowrap bg-muted text-sm",value:s.name})}function Pe({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 ba({column:s}){const{updateMetricColumn:a}=t.useEditorActions(),{transformedMetricKeys:n,dimensionKeys:r}=Jt();console.log(n,r);const o=t.useEditorStore(c=>{var h;return(h=c.card.queryConfig)==null?void 0:h.pivotColumns}),l=!!(o&&o.length>0),i=n.find(c=>c===s.label||c===s.name),u=i?n.indexOf(i):-1;return e.jsxs("div",{className:"space-y-3",children:[i&&e.jsx(Zt,{idx:u,col:i,children:e.jsx(t.Editable,{enabled:!0,className:"w-[130px]",text:s.label||"",placeholder:"Enter label",onSave:c=>{a(s.id,{...s,label:c||s.name})},children:e.jsx(Pe,{className:"w-[130px]",children:s.label||s.name})})}),l&&e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx(t.Label,{children:"Pivot Header"}),e.jsx(t.Editable,{enabled:!0,text:s.aliasTemplate||"",placeholder:"{label} ({pivot})",onSave:c=>{a(s.id,{...s,aliasTemplate:c||""})},children:e.jsx(Pe,{className:"font-mono text-xs text-muted-foreground",children:s.aliasTemplate||"{label} ({pivot})"})})]})]})}function Sa({column:s,type:a,onRemoveColumn:n,droppableId:r}){const[o,l]=I.useState(!1),{updateGroupByColumn:i,updateMetricColumn:u,updatePivotByColumn:c}=t.useEditorActions(),{attributes:h,listeners:d,setNodeRef:f,transform:y,transition:m,isDragging:b}=t.useSortable({id:s.id,data:{type:a}}),p=y?{opacity:b?.5:void 0,transform:t.CSS.Translate.toString(y),transition:m}:void 0,j=t.isTextDataType(s.type);function x(E){const R=t.isNumberDataType(E.data_type),_=t.isTextDataType(E.data_type),U=t.isDateDataType(E.data_type),w=R?"number":_?"string":U?"date":"string";if(r===re){if(_){const z={id:s.id,name:E.column_name,type:w,role:"groupby"};i(s.id,z)}if(U){const z={id:s.id,name:E.column_name,type:w,role:"groupby",label:he(E.column_name,"month"),granularity:"month"};i(s.id,z)}}if(r===ie){if(_){const z={id:s.id,name:E.column_name,type:w,role:"groupby"};c(s.id,z)}if(U){const z={id:s.id,name:E.column_name,type:w,label:he(E.column_name,"month"),granularity:"month",role:"groupby"};c(s.id,z)}}if(r===oe){const z={id:s.id,name:E.column_name,type:w,role:"metric",label:ge(E.column_name,"SUM"),aggregate:R?"SUM":"COUNT"};u(s.id,z)}}function S(){if(r===oe)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(ba,{column:s})})}function C(){const E=t.isDateDataType(s.type);if(r===oe)return e.jsx(fa,{column:s});if((r===re||r===ie)&&E)return e.jsx(ja,{column:s})}function M(){return e.jsx("div",{className:t.cn("grow",{"pl-3":(r===re||r===ie)&&j}),children:e.jsx(ya,{col:s,onChange:x,droppableId:r})})}function N(){return e.jsx("div",{"data-setting-actions":"",className:"flex h-full items-center gap-2",children:e.jsx("button",{className:"h-full pl-2",onClick:()=>l(!o),children:o?e.jsx(Ws,{className:t.cn("size-3 cursor-pointer items-center justify-center rounded-r-sm text-muted-foreground")}):e.jsx(ft,{className:t.cn("size-3 cursor-pointer items-center justify-center rounded-r-sm text-muted-foreground")})})})}return e.jsx("div",{...d,...h,ref:f,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",children:[N(),C(),M()]}),o&&S()]}),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 Re({id:s,label:a,columns:n,previewColumns:r,sortableType:o,onRemoveColumn:l}){var p,j;const{setNodeRef:i,isOver:u,over:c}=t.useDroppable({id:s}),h=t.useDndStore(x=>x.activeId),d=t.useEditorStore(x=>{var S;return(S=x.card)==null?void 0:S.type}),f=u||((j=(p=c==null?void 0:c.data)==null?void 0:p.current)==null?void 0:j.type)===o,y=h?r:n,m=o===Ce?"Rows":o===ve?"Pivot Columns":"Columns";function b(){if(!y||y.length===0)return e.jsx("div",{className:"mr-5 flex h-8 grow items-center space-x-2 rounded-md border border-dashed border-muted-foreground/80 bg-background px-2 py-1 text-sm text-muted-foreground",children:e.jsx("span",{className:"invisible text-muted-foreground/70 group-hover:visible",children:"Drag here"})})}return e.jsx(t.SortableContext,{items:n==null?void 0:n.map(x=>x.id),children:e.jsxs("div",{className:t.cn("group space-y-2 rounded-md p-4",f&&"border border-muted-foreground/50"),ref:i,children:[e.jsxs("div",{className:"flex items-center justify-between pr-5",children:[e.jsx(t.Label,{className:"text-sm",children:a}),d!=="table"&&e.jsx("span",{className:"text-xs text-muted-foreground/50",children:m})]}),b(),e.jsx("div",{className:"space-y-2",children:y==null?void 0:y.map(x=>x.id===Mt.id?e.jsx(Ca,{},x.id):e.jsx(Sa,{droppableId:s,type:o,column:x,onRemoveColumn:l},x.id))})]})})}function Ca(){return e.jsx("div",{className:"mr-5 flex h-8 grow items-center space-x-2 rounded-md border border-dashed border-muted-foreground bg-background px-2 py-1 text-sm",children:e.jsx("span",{className:"text-muted-foreground/70",children:"Drop here"})})}function ts({children:s,id:a,type:n}){const{attributes:r,listeners:o,setNodeRef:l,transform:i,transition:u,isDragging:c}=t.useSortable({id:a,data:{type:n}}),h=i?{opacity:c?.5:void 0,transform:t.CSS.Translate.toString(i),transition:u}:void 0;return e.jsx("div",{...o,...r,ref:l,style:h,children:s})}function va(){const s=t.useEditorStore(x=>{var S;return(S=x.card.queryConfig)==null?void 0:S.orderBy})||[],a=t.useEditorStore(x=>{var S;return(S=x.card.queryConfig)==null?void 0:S.groupByColumns})||[],n=t.useEditorStore(x=>{var S;return(S=x.card.queryConfig)==null?void 0:S.metricColumns})||[],{addOrderByColumn:r,removeOrderByColumn:o,updateOrderByColumn:l}=t.useEditorActions(),i=[...a,...n];if(i.length===0)return e.jsx(e.Fragment,{});const u=e.jsx(hs,{className:"size-3.5 text-muted-foreground hover:text-foreground"}),c=e.jsx(ls,{className:"size-3.5 text-muted-foreground hover:text-foreground"}),h=e.jsx(ms,{className:"size-3.5 text-muted-foreground hover:text-foreground"}),d=e.jsx(is,{className:"size-3.5 text-muted-foreground hover:text-foreground"}),f=i==null?void 0:i.filter(x=>!s.some(S=>S.columnId===x.id)).map(x=>({id:x.id,value:x.label||x.name}));function y(x,S){const C=m(x);return C?C.role==="metric"?S==="asc"?h:d:S==="asc"?u:c:null}function m(x){return i.find(S=>S.id===x)}function b(x){const S=s.find(C=>C.columnId===x);if(S){const C={...S,direction:S.direction==="asc"?"desc":"asc"};l(C)}}const p=x=>{r({columnId:x.id,direction:"asc"})};function j(x){const S=s.find(C=>C.columnId===x);S&&o(S)}return e.jsx(t.SortableContext,{items:s.map(x=>fe(x.columnId)),children:e.jsxs("div",{className:"space-y-2 rounded-md p-4 text-sm",children:[e.jsx(t.Label,{className:"text-sm",children:"Sort By"}),f.length>0&&e.jsx("div",{className:"mr-5",children:e.jsx(t.ComboBox2,{multiple:!1,options:f,selectedOptions:[],onChange:x=>p(x[0]),selectAllChecked:!1,onSelectAllCheckedChange:()=>{},inputClassName:"h-8 bg-muted border-none"})}),s.map(x=>{var S,C;return e.jsx(ts,{id:fe(x.columnId),type:Je,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(ft,{className:"size-3 cursor-move text-muted-foreground hover:text-foreground"}),e.jsx(Pe,{className:"w-[175px] text-sm",children:((S=m(x.columnId))==null?void 0:S.label)||((C=m(x.columnId))==null?void 0:C.name)})]}),e.jsx("button",{title:x.direction==="asc"?"Ascending":"Descending",onClick:()=>b(x.columnId),className:"rounded-sm p-0",children:y(x.columnId,x.direction)})]}),e.jsx("div",{children:e.jsx("button",{onClick:()=>j(x.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"})})})]})},x.columnId)},fe(x.columnId))})]})})}function Na(){const s=t.useEditorStore(j=>{var x;return((x=j.card.queryConfig)==null?void 0:x.groupByColumns)||[]}),a=t.useEditorStore(j=>j.card.type),n=t.useDndStore(j=>j.previewGroupByColumns),r=t.useEditorStore(j=>{var x;return((x=j.card.queryConfig)==null?void 0:x.metricColumns)||[]}),o=t.useDndStore(j=>j.previewMetricColumns),l=t.useEditorStore(j=>{var x;return((x=j.card.queryConfig)==null?void 0:x.pivotColumns)||[]}),i=t.useDndStore(j=>j.previewPivotColumns),{removeColumnFromGroupBy:u,removeColumnFromMetricColumns:c,removeColumnFromPivotBy:h}=t.useEditorActions();function d(j){u(j)}function f(j){c(j)}function y(j){h(j)}let m="Group By",b="Metrics",p="Stack By";return a==="table"&&(m="Rows",b="Metrics",p="Columns"),e.jsxs("div",{className:"flex h-full w-full flex-col gap-3 py-4",children:[e.jsx(Kt,{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(Re,{onRemoveColumn:d,sortableType:Ce,id:re,label:m,columns:s,previewColumns:n}),e.jsx(Re,{onRemoveColumn:y,sortableType:ve,id:ie,label:p,columns:l,previewColumns:i}),e.jsx(Re,{onRemoveColumn:f,sortableType:Be,id:oe,label:b,columns:r,previewColumns:o}),e.jsx(va,{})]}),e.jsx(t.ScrollBar,{orientation:"horizontal"})]})]})}function Ye({children:s,column:a,id:n,sortableType:r,className:o}){const[l,i]=I.useState(!1),{removeEditorFilter:u}=t.useEditorActions();function c(h){u(h)}return e.jsx(ts,{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:()=>c(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 wa({column:s,sortableType:a}){const n=t.useDashboardStore(S=>S.themeStyle),r=t.useEditorStore(S=>{var C,M;return(M=(C=S.card)==null?void 0:C.queryConfig)==null?void 0:M.filters}),{selectedConnectionId:o,selectedDatabaseName:l,selectedTableName:i}=te(),u=I.useMemo(()=>{var S;return(S=r==null?void 0:r.find(C=>C.filterColumnName===s.name))==null?void 0:S.filterValue},[r,s.name]),c=I.useMemo(()=>Array.isArray(u)?u.map(S=>({id:S,value:S})):[],[u]),{updateEditorFilterValue:h}=t.useEditorActions(),d={column:s.name,sql:s.sql,id:s.name,connectionId:o,dataType:s.type},{data:f,isLoading:y,isFetching:m,isError:b}=t.useFilterQuery(d),p=I.useMemo(()=>{var C;return d.column?(C=f==null?void 0:f.records)==null?void 0:C.map(M=>{let N=d.column.split(".").slice(-1)[0].replace(/"/g,"");return M[N]===void 0&&(N=N.toLowerCase()),{id:M[N],value:M[N]}}):[]},[f,d.column]);function j(S){const C=S.map(M=>M.id);h(s.name,C)}function x(){return y||m?e.jsx(t.Skeleton,{style:{borderRadius:n==null?void 0:n.controlInputRadius},className:"h-8 min-w-60 bg-foreground/10"}):b?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:j,selectedOptions:c,selectAllChecked:!1,onSelectAllCheckedChange:()=>{}})}return e.jsx(Ye,{className:"w-60",id:s.id,sortableType:a,column:s,children:x()})}function ka({column:s,sortableType:a}){const[n,r]=I.useState(!1),{selectedConnectionId:o,selectedDatabaseName:l,selectedTableName:i}=te(),u={column:s.name,sql:s.sql,id:s.name,connectionId:o,title:"",dataType:s.type},{isLoading:c,isFetching:h,isError:d,data:f}=t.useFilterQuery(u),y=f==null?void 0:f.records,{dateRange:m,setDateRange:b,initialDateRange:p}=t.useDateRangeFromRecords(y),{updateEditorFilterValue:j}=t.useEditorActions();function x(M){var E,R;const N={gte:(E=M==null?void 0:M.from)==null?void 0:E.toISOString(),lte:(R=M==null?void 0:M.to)==null?void 0:R.toISOString()};j(s.name,N)}function S(){j(s.name,null,!0),b(p)}function C(){return c||h?e.jsx("div",{children:e.jsx(t.Skeleton,{className:"h-8 w-72 bg-foreground/10"})}):d?e.jsx("div",{className:"h-8 w-72 bg-muted px-2",children:"Error"}):y?e.jsx(t.DateRangePopover,{title:u.title,open:n,inputClassName:"h-8",setOpen:r,dateRange:m,setDateRange:b,onApply:x,onClear:S}):e.jsx(t.Label,{className:"flex h-8 w-72 items-center bg-muted px-2",children:"No Data"})}return e.jsx(Ye,{className:"w-72",id:s.id,sortableType:a,column:s,children:C()})}function Da({id:s,label:a,columns:n,previewColumns:r,sortableType:o}){var b,p;const{setNodeRef:l,isOver:i,over:u}=t.useDroppable({id:s}),c=t.useDndStore(j=>j.activeId),h={},d=i||((p=(b=u==null?void 0:u.data)==null?void 0:b.current)==null?void 0:p.type)===o;function f(){if(!m||m.length===0)return e.jsx("div",{className:"flex h-8 grow items-center space-x-2 rounded-md border border-dashed border-muted-foreground/80 bg-background px-2 py-1 text-sm text-muted-foreground",children:e.jsx("span",{className:"invisible text-muted-foreground/70 group-hover:visible",children:"Drag here"})})}function y(j){const x=t.isDateDataType(j.type);return j.id===Mt.id?e.jsx(Ye,{id:j.id,sortableType:o,column:j,children:e.jsx(Ia,{})},j.id):x?e.jsx(ka,{droppableId:s,sortableType:o,column:j},j.id):e.jsx(wa,{droppableId:s,sortableType:o,column:j},j.id)}const m=c?r:n;return e.jsx(t.SortableContext,{items:n==null?void 0:n.map(j=>j.id),children:e.jsxs("div",{className:t.cn("group space-y-2 rounded-md border-muted-foreground/50 p-4",d&&"border border-muted-foreground/50"),ref:l,style:h,children:[e.jsx(t.Label,{className:"text-sm",children:a}),f(),e.jsx("div",{className:"flex flex-wrap items-center gap-4",children:m==null?void 0:m.map(j=>y(j))})]})})}function Ia(){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 text-muted-foreground",children:"Drop here"})}function Ea(){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:qe,id:Ve,label:"Filters",columns:s,previewColumns:a})})}function Ta(){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(Vt,{}),e.jsx(Lt,{sql:a==null?void 0:a.sql,error:n})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"rounded-full bg-green-300 px-3 py-1 text-xs font-medium text-black",children:"Preview"}),e.jsx(Bt,{}),e.jsx(_t,{variant:"default"})]})]})}function Ma(){const s=I.useRef(null),a=t.useEditorStore(i=>i.isShowingVisual),n=t.useEditorStore(i=>i.showAIDialog),r=t.useEditorStore(i=>i.isDevMode);I.useEffect(()=>{var i,u;n?(i=s.current)==null||i.resize(0):(u=s.current)==null||u.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(En,{})}),e.jsx(t.ResizableHandle,{withHandle:!0}),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(pa,{})})}),!n&&e.jsx(t.ResizableHandle,{}),e.jsx(t.ResizablePanel,{minSize:40,defaultSize:75,maxSize:100,children:e.jsx(be,{})})]}):e.jsx(be,{})})]})}function l(){return e.jsx(e.Fragment,{children:e.jsx("div",{className:"grow","data-biz-mode-container":"",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(Na,{})})}),!n&&e.jsx(t.ResizableHandle,{}),e.jsx(t.ResizablePanel,{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(Ta,{}),e.jsx(Ea,{})]}),e.jsx(t.ResizableHandle,{}),e.jsx(t.ResizablePanel,{minSize:60,defaultSize:80,children:e.jsx(be,{})})]})})]}):e.jsx(be,{})})})}return e.jsx(t.ResizablePanelGroup,{direction:"vertical",className:"min-h-[250px] min-w-full max-w-lg",children:r?o():l()})}const Aa=[{title:"Help me write a query for",subtitle:"orders by month"},{title:"Create a bar chart for",subtitle:"sales by category"}];function La(){const s=I.useRef(null),a=I.useRef(null),[n,r]=I.useState(!1),[o,l]=I.useState(t.isDevEnv),[i,u]=I.useState(!1),c=t.useEditorStore(A=>A.actions.setCardSql),h=t.useEditorStore(A=>A.actions.setRunSql),d=t.useEditorStore(A=>A.showAIDialog),{setShowAIDialog:f}=t.useEditorActions(),{messages:y,setMessages:m,reload:b,append:p,input:j,setInput:x,isLoading:S,handleAddCurrentTableToScope:C,removeFromCurrentSelections:M,currentAssitantScope:N,handleInputChange:E,handleSubmit:R,stop:_,chatStatus:U,toolStatus:w,llmUsage:z,errorMessage:$}=Rt();t.useAssistantScroll({scrollContainerRef:s,inputRef:a,messages:y}),I.useEffect(()=>{var A;d&&((A=a.current)==null||A.focus())},[d]);function P(A){c(A),h(!0)}function D(A){const k={role:"user",content:A.title+" "+A.subtitle};p(k)}function g(){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(xt,{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:u,children:"System Message"})]})]})}function T(){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((A,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:A.schemaName||"",tableName:A.tableName||"",modelName:A.datamodelName||"",connectionType:A.connectionType||"",databaseName:A.databaseName||""}),e.jsx("button",{onClick:()=>{M(A)},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:C,children:[e.jsx(t.Plus,{className:"mr-2 size-3"}),"Current Table"]})]})]})}const q=(j==null?void 0:j.length)===0&&(y==null?void 0:y.filter(A=>A.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:[T(),e.jsxs("div",{"data-role":"header-actions",className:"flex items-center",children:[g(),e.jsx(t.Button,{className:"h-7 p-2",size:"sm",variant:"ghost",onClick:()=>{m([]),b()},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:()=>{f(!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:y,showTools:o,handleRun:P,showSystemMessage:i}),e.jsx(t.ChatStatus,{status:t.getStatus(U,w),isLoading:S})]})}),q&&e.jsx(t.Placeholders,{onClick:D,placeholders:Aa}),e.jsx(t.ChatInput,{onFocus:()=>{C()},stop:_,ref:a,setInput:x,input:j,handleInputChange:E,handleSubmit:R,isLoading:S}),z&&n&&e.jsx("div",{className:"flex h-8 items-center justify-between",children:e.jsxs("div",{className:"text-xs text-muted-foreground",children:["Usage: ",z.promptTokens," prompt tokens,"," ",z.completionTokens," completion tokens,"," ",z.totalTokens," total tokens"]})}),$&&e.jsx("div",{className:"flex items-center justify-between text-xs text-muted-foreground",children:e.jsx("span",{children:$})})]})}function Oa({authToken:s,onSave:a,onClose:n}){const r=I.useRef(null),o=t.useEditorStore(j=>j.showAIDialog),{setAuthToken:l}=t.useDashboardActions(),{setShowAIDialog:i,setOnSave:u,setOnClose:c}=t.useEditorActions(),{handleDragOver:h,handleDragEnd:d,handleDragStart:f,handleDragCancel:y,sensors:m}=pn();I.useEffect(()=>{a&&u(a),n&&c(n)},[a,u,n,c]),I.useEffect(()=>{s&&s.accessToken&&l(s)},[s,l]),I.useEffect(()=>{var j,x;o?((j=r.current)==null||j.resize(40),i(!0)):(i(!1),(x=r.current)==null||x.resize(0))},[o,i]);function b(j){j<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",children:e.jsx(Ma,{})}),e.jsx(t.ResizableHandle,{}),e.jsx(t.ResizablePanel,{"data-role":"editor-assistant-panel",ref:r,onResize:b,defaultSize:0,children:e.jsx(La,{})})]})}return e.jsx(t.ErrorBoundary,{FallbackComponent:t.Fallback,children:e.jsx(t.DndContext,{sensors:m,onDragStart:f,onDragEnd:d,onDragOver:h,onDragCancel:y,children:e.jsxs("section",{className:"isolate flex h-full grow","data-content":"editor-panel",children:[e.jsx(At,{type:"main"}),p()]})})})}function za(){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(Oa,{onSave:o,onClose:l})})}function Fa(){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}=Xt();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(u=>u.column===t.fmt(l.column_name)&&u.table===a&&u.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(Qe,{column:l}),e.jsx("span",{children:l.column_name})]})},l.column_name)})})}function Ra(){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(At,{type:"filter",ColumnsComponent:()=>e.jsx(Fa,{})})})]})}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 Ba(){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(Ra,{})})]})}function Va(){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 qa({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(Va,{}),e.jsxs(t.DashboardPanel,{...n,children:[s&&e.jsx(cn,{}),e.jsx(za,{}),e.jsx(Ba,{})]})]})]})})}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=Et;exports.SelectComponent=ue;exports.Surfboard=qa;exports.cleanCard=kt;exports.downloadPdf=It;exports.getDashbaordStateWithoutData=$e;exports.useEditorAside=te;
376
+ `;x(v)}function q(){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(c,null,2)})})}),c&&c.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(yt,{className:"size-3.5 text-muted-foreground"})})]})}function A(){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 w(){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:F||R,onClick:()=>{P()},className:"shrink-0",size:"sm",children:[F||R?e.jsx(le,{className:"mr-2 h-4 w-4 animate-spin"}):e.jsx(t.Play,{className:"mr-2 h-4 w-4"}),"Run"]}),e.jsx(zt,{sql:E==null?void 0:E.sql,error:I,onClick:T}),e.jsx(Pt,{}),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:()=>{g(),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(qt,{}),e.jsx(Vt,{})]})]})}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:[A(),q()]}),w()]})}function Mn({data:s}){var i;const[a,n]=D.useState([]),o=Object.keys(s[0]).map(d=>({accessorKey:d,header:({column:c})=>{const h=c.getIsSorted();return e.jsx("div",{className:"flex gap-2",children:e.jsxs("div",{className:"flex cursor-pointer items-center",onClick:()=>c.toggleSorting(c.getIsSorted()==="asc"),children:[d,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.jsxs(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(d=>e.jsx(t.TableRow,{className:"",children:d.headers.map(c=>e.jsx(t.TableHead,{className:"h-11 font-semibold text-foreground",children:c.isPlaceholder?null:t.flexRender(c.column.columnDef.header,c.getContext())},c.id))},d.id))}),e.jsx(t.TableBody,{children:(i=l.getRowModel().rows)!=null&&i.length?l.getRowModel().rows.map(d=>e.jsx(t.TableRow,{className:"h-11 whitespace-nowrap py-2","data-state":d.getIsSelected()&&"selected",children:d.getVisibleCells().map(c=>e.jsx(t.TableCell,{className:"py-2",children:t.flexRender(c.column.columnDef.cell,c.getContext())},c.id))},d.id)):e.jsx(t.TableRow,{children:e.jsx(t.TableCell,{colSpan:o.length,className:"h-24 text-center",children:"No results."})})})]}),e.jsx(t.ScrollBar,{orientation:"horizontal"})]})}function An({card:s}){var S,C,M,N,E,F,R,$,k,L,Q;const[a,n]=D.useState(!1),[r,o]=D.useState([]),{authToken:l}=t.useSemaphorContext(),i=t.getTokenParams(l==null?void 0:l.accessToken),d=t.useDashboardStore(P=>P.themeStyle),c={colors:((C=(S=d==null?void 0:d.chart)==null?void 0:S.dataset)==null?void 0:C.backgroundColor)||[]};(M=s.customCardPreferences)!=null&&M.inputData;const{getCard:h}=t.useCustomVisual(((N=s.customCardPreferences)==null?void 0:N.url)||""),u=((E=s.customCardPreferences)==null?void 0:E.visualType)||"single",f=t.useEditorStore(P=>P.frame),{setCustomCardPreferences:y}=t.useEditorActions(),{data:m}=t.useDashboardCardQuery(s),b=D.useCallback((P,I)=>{o(g=>({...g,[P]:I}))},[]);if(!((F=s.customCardPreferences)!=null&&F.componentName))return null;const p=h((R=s.customCardPreferences)==null?void 0:R.componentName);function j(P){n(P)}const x=Object.keys((($=s.customCardPreferences)==null?void 0:$.dataInputCardIds)||{}).map(P=>{var T,q,A;const I=(q=(T=s.customCardPreferences)==null?void 0:T.dataInputCardIds)==null?void 0:q[P].cardId,g=(A=f==null?void 0:f.cards)==null?void 0:A.find(w=>w.id===I);return g||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(D.Suspense,{fallback:e.jsx(e.Fragment,{}),children:[p&&u==="single"&&e.jsx(p,{params:i,theme:c,settings:(k=s.customCardPreferences)==null?void 0:k.settings,onDataChange:b,data:(m==null?void 0:m.records)||[]}),p&&u==="multiple"&&e.jsxs(e.Fragment,{children:[Object.keys(((L=s.customCardPreferences)==null?void 0:L.dataInputCardIds)||{}).map(P=>{var T,q,A;const I=(q=(T=s.customCardPreferences)==null?void 0:T.dataInputCardIds)==null?void 0:q[P].cardId,g=(A=f==null?void 0:f.cards)==null?void 0:A.find(w=>w.id===I);if(g)return e.jsx(t.MultiInputEmptyRenderer,{onLoadingStatus:j,onDataChange:b,dataInputIndex:P,card:g},g.id+P)}),e.jsx("div",{className:"flex flex-col gap-2",children:e.jsx(p,{theme:c,onDataChange:b,settings:x.map(P=>{var I;return(I=P==null?void 0:P.customCardPreferences)==null?void 0:I.settings}),data:x.map(P=>P!=null&&P.id?r==null?void 0:r[P.id]:[])})})]})]},(Q=s.customCardPreferences)==null?void 0:Q.componentName)})}function Ht({className:s,...a}){var j;const n=t.useEditorStore(x=>x.card),r=((j=n.customCardPreferences)==null?void 0:j.showCardHeader)??!0,o=t.useEditorStore(x=>x.frame),l=t.useDashboardStore(x=>x.dashboard.filters);t.useEditorStore(x=>x.actions.setRunSql);const{updateFilter:i}=t.useDashboardActions(),d=l==null?void 0:l.find(x=>x.id===o.filterId),{data:c,isLoading:h,isFetching:u}=t.useDashboardCardQuery(n),{setCard:f}=t.useEditorActions(),{data:y}=t.useTopoJson(n),m=D.useMemo(()=>!n.id||!(c!=null&&c.records)?null:t.createChartConfig({data:c==null?void 0:c.records,cardType:n.type,queryConfig:n.queryConfig,customCfg:n.customCfg,preferences:n.preferences,topoJson:y}),[n.id,c==null?void 0:c.records,n.type,n.queryConfig,n.customCfg,n.preferences,y]);function b(x){return e.jsx(An,{card:x})}function p(){if(c!=null&&c.records&&(c==null?void 0:c.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 b(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"&&(c!=null&&c.records)&&(c==null?void 0:c.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:c==null?void 0:c.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,{enabled:!0,text:n.title,onSave:x=>f({...n,title:x}),children:e.jsx("div",{className:"flex items-center gap-5",children:e.jsx(t.CardTitle,{className:"text-base",children:n.title||"Add title"})})},n.title),e.jsx(t.Editable,{enabled:!0,text:n.description||"",onSave:x=>f({...n,description:x}),children:e.jsx(t.CardDescription,{children:n.description||"Add description"})},n.description)]}),d&&e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(t.Editable,{enabled:!0,className:"my-1",text:d.title||d.column,onSave:x=>i({...d,title:x}),children:e.jsx(t.Label,{children:d.title})}),e.jsx(t.FilterComponent,{filter:d})]})]}),e.jsx(t.CardContent,{className:"flex grow flex-col",children:p()})]})}const ze=({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(ze,{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(ze,{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(ze,{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]=D.useState(!1),[n,r]=D.useState(""),[o,l]=D.useState(""),[i,d]=D.useState(""),[c,h]=D.useState(""),u=t.useEditorStore(N=>N.card),f=t.useEditorStore(N=>N.card.customCfg),y=f?JSON.stringify(f,null,2):"",{data:m}=t.useDashboardCardQuery(u),{data:b}=t.useTopoJson(u),{setCardCustomCfg:p,setCustomVisualCode:j}=t.useEditorActions(),x=N=>{var E,F;return JSON.stringify({...N,data:{...N.data,datasets:(F=(E=N.data)==null?void 0:E.datasets)==null?void 0:F.map(R=>({...R,data:[]}))}},null,2)},S=()=>{var E,F;if(!((E=m==null?void 0:m.records)!=null&&E.length))return;const N=t.createChartConfig({data:m.records,cardType:u.type,queryConfig:u.queryConfig,preferences:u.preferences,topoJson:b});if(N){r(x(N)),d(((F=u.preferences)==null?void 0:F.customVisualCode)||"");const R=t.merge(N,f);l(x(R))}},C=()=>{try{if(i&&j(i),o){const N=JSON.parse(o),E=t.getObjectDiff(JSON.parse(n),N);p(E),h("")}}catch{h("Invalid JSON configuration")}},M=Object.keys(f||{}).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:M?"":"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(Ht,{className:"w-1/2 rounded shadow-none"})}),e.jsx(On,{customCode:i,cardCustomCfgString:y,mergedConfig:o,onConfigChange:N=>l(N??""),onCodeChange:N=>d(N??"")})]}),e.jsx(zn,{error:c,hasCardCustomConfig:!!f,onReset:()=>{l(n),p(null)},onApply:C,onClose:()=>a(!1)})]})]})}function Gt(s){const[a,n]=D.useState(null);return a}function Ut(){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]=D.useState([]),{setCardCustomCfg:r,setCardPreferences:o,setCardType:l,setCustomCardPreferences:i}=t.useEditorActions(),{data:d}=Ut();function c(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 D.useEffect(()=>{(async()=>{var u;if(d){const y=(await Promise.all((u=d==null?void 0:d.plugins)==null?void 0:u.map(async m=>(await t.loadManifest(m.value)).visuals.map(j=>({name:j.name,icon:j.icon,url:m.value}))))).flat();n(y)}})()},[d]),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(_n,{text:h.name,onClick:()=>c("custom",h),icon:h.icon},h.url+h.name+u))})]})}const _n=({text:s,icon:a,onClick:n})=>{const r=Gt(),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 $t(s){return ce({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 Bn(s){return ce({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 Qt(s){return ce({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 Kt(s){return ce({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M4.387 3h15.226a1 1 0 0 1 .948 1.316l-5.105 15.316a2 2 0 0 1 -1.898 1.368h-3.116a2 2 0 0 1 -1.898 -1.368l-5.104 -15.316a1 1 0 0 1 .947 -1.316"},child:[]},{tag:"path",attr:{d:"M5 9h14"},child:[]},{tag:"path",attr:{d:"M7 15h10"},child:[]}]})(s)}function Jt(s){return ce({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 Wt(s){return ce({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 Yt({onChartTypeChange:s,iconClassName:a}){const{setCardType:n,setCardPreferences:r,setIsDevMode:o}=t.useEditorStore(u=>u.actions),{setCardCustomCfg:l,setCustomCardPreferences:i,setQueryConfig:d}=t.useEditorActions();function c(u,f){l(null),r({}),n(u),["kpi","custom","text","map"].includes(u)&&(o(!0),d(void 0)),s==null||s()}const h=1e3;return e.jsxs("div",{className:"grid grid-cols-4 place-items-center",children:[e.jsx(t.IconButton,{openDelay:h,tooltip:"Table",onClick:()=>c("table"),className:"h-10 p-4",children:e.jsx(Ue,{className:t.cn("size-5",a)})}),e.jsx(t.IconButton,{openDelay:h,tooltip:"Bar Chart",onClick:()=>c("bar"),className:"h-10 p-4",children:e.jsx(He,{className:t.cn("size-5",a)})}),e.jsx(t.IconButton,{openDelay:h,tooltip:"Line Chart",onClick:()=>c("line"),className:"h-10 p-4",children:e.jsx(Ge,{className:t.cn("size-5",a)})}),e.jsx(t.IconButton,{openDelay:h,tooltip:"Stacked Bar Chart",onClick:()=>c("stackedBar"),className:"h-10 p-4",children:e.jsx(ut,{className:t.cn("size-5",a)})}),e.jsx(t.IconButton,{openDelay:h,tooltip:"Stacked Line Chart",onClick:()=>c("stackedLine"),className:"h-10 p-4",children:e.jsx(Jt,{className:t.cn("size-5",a),strokeWidth:0})}),e.jsx(t.IconButton,{openDelay:h,tooltip:"Scatter Chart",onClick:()=>c("scatter"),className:"h-10 p-4",children:e.jsx(pt,{className:t.cn("size-5",a)})}),e.jsx(t.IconButton,{openDelay:h,tooltip:"Bubble Chart",onClick:()=>c("bubble"),className:"h-10 p-4",children:e.jsx(Qt,{className:t.cn("size-5",a)})}),e.jsx(t.IconButton,{openDelay:h,tooltip:"Pie Chart",onClick:()=>c("pie"),className:"h-10 p-4",children:e.jsx(ht,{className:t.cn("size-5",a)})}),e.jsx(t.IconButton,{openDelay:h,tooltip:"Doughnut Chart",onClick:()=>c("doughnut"),className:"h-10 p-4",children:e.jsx(ft,{className:t.cn("size-5",a)})}),e.jsx(t.IconButton,{openDelay:h,tooltip:"Funnel Chart",onClick:()=>c("funnel"),className:"h-10 p-4",children:e.jsx(Kt,{className:t.cn("size-5",a)})}),e.jsx(t.IconButton,{openDelay:h,tooltip:"Radar Chart",onClick:()=>c("radar"),className:"h-10 p-4",children:e.jsx(Ct,{className:t.cn("size-5",a)})}),e.jsx(t.IconButton,{openDelay:h,tooltip:"Polar Area Chart",onClick:()=>c("polarArea"),className:"h-10 p-4",children:e.jsx($t,{className:t.cn("size-5",a)})}),e.jsx(t.IconButton,{openDelay:h,tooltip:"Pyramid Chart",onClick:()=>c("pyramid"),className:"h-10 p-4",children:e.jsx(kt,{className:t.cn("size-5",a)})}),e.jsx(t.IconButton,{tooltip:"Range Chart",onClick:()=>c("range"),className:"h-10 p-4",children:e.jsx(mt,{className:t.cn("size-5",a)})}),e.jsx(t.IconButton,{openDelay:h,tooltip:"KPI",onClick:()=>c("kpi"),className:"h-10 p-4",children:e.jsx(Wt,{className:t.cn("size-5",a)})}),e.jsx(t.IconButton,{openDelay:h,tooltip:"Text",onClick:()=>c("text"),className:"h-10 p-4",children:e.jsx(ys,{className:t.cn("size-5",a)})}),e.jsx(t.IconButton,{tooltip:"Map",onClick:()=>c("map"),className:"h-10 p-4",children:e.jsx(St,{className:t.cn("size-5",a)})}),e.jsx(t.IconButton,{openDelay:h,tooltip:"Custom",onClick:()=>c("custom"),className:"h-10 p-4",children:e.jsx(Nt,{className:t.cn("size-5",a)})})]})}function Vn({chartType:s,className:a,customIcon:n,componentName:r}){const o=Gt();switch(s){case"bar":return e.jsx(He,{className:a});case"line":return e.jsx(Ge,{className:a});case"pie":return e.jsx(ht,{className:a});case"radar":return e.jsx(Ct,{className:a});case"scatter":return e.jsx(pt,{className:a});case"bubble":return e.jsx(Qt,{className:a});case"doughnut":return e.jsx(ft,{className:a});case"stackedBar":return e.jsx(ut,{className:a});case"stackedLine":return e.jsx(Jt,{className:a});case"polarArea":return e.jsx($t,{className:a});case"funnel":return e.jsx(Kt,{className:a});case"pyramid":return e.jsx(kt,{className:a});case"range":return e.jsx(mt,{className:a});case"kpi":return e.jsx(Wt,{className:a});case"text":return e.jsx(It,{className:a});case"map":return e.jsx(St,{className:a});case"custom":return n&&o?e.jsx(o,{className:a}):r?r==null?void 0:r.charAt(0).toUpperCase():e.jsx(Nt,{className:a});default:return e.jsx(Ue,{className:a})}}function qn(){var l,i;const[s,a]=D.useState(!1),n=t.useEditorStore(d=>d.card),r=n.type,o=t.useDashboardStore(d=>d.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:d=>d.preventDefault(),className:"w-50",children:[e.jsx(Yt,{onChartTypeChange:()=>a(!1)}),e.jsx(Rn,{onChartTypeChange:()=>a(!1)})]})]})}const be="focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0";function ct(s,a){var r,o,l;const n=t.getNumberAxis(s,{});return["pie","doughnut","polarArea","funnel"].includes(a)?"category":((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 T,q,A,w,v,U;const[s,a]=D.useState(!1),n=t.useEditorStore(_=>{var O;return(O=_.card)==null?void 0:O.preferences}),r=t.useEditorStore(_=>{var O;return(O=_.card)==null?void 0:O.type}),o=t.getNumberAxis(n,{}),[l,i]=D.useState(ct(n,r)),[d,c]=D.useState(((A=(q=(T=n==null?void 0:n.chartOptions)==null?void 0:T.scales)==null?void 0:q[o])==null?void 0:A.min)||""),[h,u]=D.useState(((U=(v=(w=n==null?void 0:n.chartOptions)==null?void 0:w.scales)==null?void 0:v[o])==null?void 0:U.max)||""),[f,y]=D.useState(d||h?"custom":"auto"),[m,b]=D.useState(""),[p,j]=D.useState(0),[x,S]=D.useState(""),[C,M]=D.useState(""),[N,E]=D.useState(""),F=t.useEditorStore(_=>_.actions.setCardPreferences),{updateCardInFrame:R}=t.useEditorActions(),$=t.useEditorStore(_=>_.card),k=["pie","doughnut","polarArea","funnel"].includes(r);D.useEffect(()=>{var _,O,G,W,V,J,H,Z,z,K,X,ae,ue,me;i(ct(n,r)),c(((G=(O=(_=n==null?void 0:n.chartOptions)==null?void 0:_.scales)==null?void 0:O[o])==null?void 0:G.min)===0?0:""),u(((J=(V=(W=n==null?void 0:n.chartOptions)==null?void 0:W.scales)==null?void 0:V[o])==null?void 0:J.max)||""),b(((K=(z=(Z=(H=n==null?void 0:n.chartOptions)==null?void 0:H.scales)==null?void 0:Z[o])==null?void 0:z.ticks)==null?void 0:K.stepSize)||""),j(((X=n==null?void 0:n.numberAxisFormat)==null?void 0:X.decimalPlaces)||0),S(((ae=n==null?void 0:n.numberAxisFormat)==null?void 0:ae.suffix)||""),M(((ue=n==null?void 0:n.numberAxisFormat)==null?void 0:ue.currency)||""),E(((me=n==null?void 0:n.numberAxisFormat)==null?void 0:me.locale)||"")},[s,n,o,r]);function L(_,O){return O===""||/^[0-9\b]+$/.test(O)?Number(O):Number(_)}function Q(){const _=[...new Set(t.LOCALE_CURRENCY_PAIRS.map(O=>O.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:C||"none",onValueChange:O=>M(O==="none"?"":O),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"}),_.map(O=>e.jsx(t.SelectItem,{value:O,children:O},O))]})})]}),e.jsxs(t.Select,{value:N,onValueChange:O=>E(O),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(O=>e.jsx(t.SelectItem,{value:O.locale,children:O.locale},O.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:p,onChange:O=>j(Number(O.target.value)),id:"format",className:`col-span-6 h-8 w-full tracking-wide ${be}`})]})]})}function P(){return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"mt-4 space-y-2",children:e.jsx("p",{className:"text-sm text-muted-foreground",children:"Set the scale for number axis"})}),e.jsxs("div",{className:"mt-2 grid grid-cols-3 items-center gap-2",children:[e.jsx(t.Label,{htmlFor:"scale",children:"Type"}),e.jsxs(t.Select,{disabled:k,value:l,onValueChange:_=>i(_),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"}),e.jsx(t.SelectItem,{value:"category",children:"Category"})]})})]})]}),l=="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:k,id:"scale-option",value:f,onValueChange:_=>y(_),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"})]})]})]}),f==="custom"&&l=="linear"&&I()]})}function I(){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:d,onChange:_=>c(O=>L(O,_.target.value)),className:`col-span-1 h-8 w-full ${be}`}),e.jsx(t.Input,{value:h,onChange:_=>u(O=>L(O,_.target.value)),id:"max",className:`col-span-1 h-8 w-full ${be}`})]}),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:m,onChange:_=>b(O=>L(O,_.target.value)),id:"step-size",className:`col-span-1 h-8 w-full ${be}`})]})]})}function g(){var W;let _={};f==="custom"&&(_={min:d,max:h,ticks:{stepSize:m}});const O={...n||{},chartOptions:{...n==null?void 0:n.chartOptions,scales:{...(W=n==null?void 0:n.chartOptions)==null?void 0:W.scales,[o]:{type:l,...l==="linear"?_:{}}}},numberAxisFormat:{decimalPlaces:p,suffix:x,currency:C,locale:N}};console.log(O),F(O);const G={...$,preferences:O};R(G)}return e.jsxs(t.Popover,{onOpenChange:_=>a(_),children:[e.jsx(t.PopoverTrigger,{asChild:!0,children:e.jsx(t.IconButton,{tooltip:"Format Number",children:e.jsx(Es,{className:"size-4"})})}),e.jsx(t.PopoverContentCustom,{align:"end",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:"Format Options"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Set the format for number axis"})]}),e.jsxs("div",{className:"grid gap-2",children:[Q(),P(),e.jsx(t.SelectSeparator,{}),e.jsx("div",{className:"grid grid-cols-3",children:e.jsx(t.Button,{onClick:g,variant:"secondary",className:"col-span-1 col-start-3 h-8 w-full",children:"Apply"})})]})]})})]})}function Hn(){const s=t.useEditorStore(d=>{var c,h,u,f;return(f=(u=(h=(c=d.card.preferences)==null?void 0:c.chartOptions)==null?void 0:h.plugins)==null?void 0:u.legend)==null?void 0:f.position}),a=t.useEditorStore(d=>{var c,h,u,f;return(f=(u=(h=(c=d.card.preferences)==null?void 0:c.chartOptions)==null?void 0:h.plugins)==null?void 0:u.legend)==null?void 0:f.align}),n=t.useEditorStore(d=>{var c,h,u,f;return(f=(u=(h=(c=d.card.preferences)==null?void 0:c.chartOptions)==null?void 0:h.plugins)==null?void 0:u.legend)==null?void 0:f.display}),{setLegendOptions:r}=t.useEditorActions(),o=d=>{r({display:d,position:s,align:a})},l=d=>{r({display:n,position:d,align:a})},i=d=>{r({display:n,position:s,align:d})};return e.jsxs(t.Popover,{children:[e.jsx(t.PopoverTrigger,{asChild:!0,children:e.jsx(t.IconButton,{tooltip:"Legend Settings",children:e.jsx(Bs,{className:"size-4"})})}),e.jsx(t.PopoverContentCustom,{align:"end",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,id:"displayLegend"})})]}),n&&e.jsxs(e.Fragment,{children:[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(hs,{className:"size-4"})}),e.jsx(t.IconButton,{tooltip:"Bottom",onClick:()=>l("bottom"),children:e.jsx(dt,{className:"size-4"})}),e.jsx(t.IconButton,{tooltip:"Right",onClick:()=>l("right"),children:e.jsx(ps,{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(ls,{className:"size-4"})}),e.jsx(t.IconButton,{tooltip:"Center",onClick:()=>i("center"),children:e.jsx(is,{className:"size-4"})}),e.jsx(t.IconButton,{tooltip:"End",onClick:()=>i("end"),children:e.jsx(cs,{className:"size-4"})})]})]})]})]})]})})]})}function Gn(){const s=t.useEditorStore(l=>{var i,d;return(d=(i=l.card.preferences)==null?void 0:i.chartOptions)==null?void 0:d.indexAxis}),a=t.useEditorStore(l=>l.card.type),{setChartOrientation:n}=t.useEditorStore(l=>l.actions);function r(){return e.jsx(t.IconButton,{onClick:()=>{n(s==="x"||s===void 0?"y":"x")},tooltip:"Chart Orientation",children:s==="x"||s===void 0?e.jsx(at,{className:"size-4"}):e.jsx(nt,{className:"size-4"})})}function o(){return e.jsx(t.IconButton,{onClick:()=>{n(s==="y"||s===void 0?"x":"y")},tooltip:"Chart Orientation",children:s==="y"||s===void 0?e.jsx(at,{className:"size-4"}):e.jsx(nt,{className:"size-4"})})}return e.jsx(e.Fragment,{children:a==="funnel"?o():r()})}function Un(){const s=t.useEditorStore(i=>i.card),a=t.useEditorStore(i=>i.isShowingVisual),n=t.useEditorStore(i=>{var d,c;return(c=(d=i.card)==null?void 0:d.preferences)==null?void 0:c.chartOptions}),r=t.getChartGridStyle(n),{setChartGrid:o}=t.useEditorActions();function l(){const i=["xy","none","x","y"],c=(i.indexOf(r)+1)%i.length;o(i[c])}return a?e.jsxs("div",{"data-info":"visual-settings",className:"flex items-center",children:[["line","bar","range","stackedBar","stackedLine","horizontalBar","funnel"].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","funnel","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(Fs,{className:"size-4"}),r==="x"&&e.jsx(ws,{className:"size-4"}),r==="y"&&e.jsx(Ks,{className:"size-4"}),r==="none"&&e.jsx(Zs,{className:"size-4"})]})]}):null}function Se(){var A;const s=t.useEditorStore(w=>w.frame),a=t.useEditorStore(w=>w.card),n=t.useEditorStore(w=>w.isDevMode),r=t.useEditorStore(w=>w.isShowingVisual),o=t.useDashboardStore(w=>w.isVisualEditing),l=t.useEditorStore(w=>w.isSqlRunning),i=t.useEditorStore(w=>w.pythonStdOut),d=t.useEditorStore(w=>{var v;return(v=w.card.preferences)==null?void 0:v.chartOptions}),c=t.useEditorStore(w=>w.actions.setRunSql);t.getChartGridStyle(d);const{setFrame:h,setCard:u,updateCardInFrame:f,setActiveTabCardId:y,runAssistant:m,setChartGrid:b}=t.useEditorActions(),{data:p,isLoading:j,isFetching:x,error:S}=t.useDashboardCardQuery(a);if(!a)return e.jsx(e.Fragment,{children:"No Active Card"});function C(){const w={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:[]};M(w)}function M(w){const v={...s,cards:[...s.cards,w],activeCardId:w.id};h(v),u(w),y(w.id)}function N(){const w={...a,id:t.v4(),title:`${a.title} Copy`,tabTitle:`${a.tabTitle||a.title} Copy`};M(w)}function E(w){const v=s.cards.filter(O=>O.id!==w),U=v[0],_={...s,cards:v,activeCardId:U.id};h(_),y(U.id),u(U)}function F(w){n||R(w),y(w)}function R(w){const v={...s,cards:s.cards.map(_=>_.id===a.id?a:_),activeCardId:w};h(v);const U=v.cards.find(_=>_.id===w);U.sql&&c(!0),u(U)}const $=(w,v)=>{console.log("handleDragStart",v),w.dataTransfer.setData("tabIndex",v.toString())},k=w=>{w.preventDefault()},L=(w,v)=>{const U=w.dataTransfer.getData("tabIndex");if(U===v.toString())return;const _=Array.from(s.cards),[O]=_.splice(parseInt(U),1);_.splice(v,0,O),h({...s,cards:_})};function Q(w,v){return w.cards.length===1&&(v.displayTab===!0||v.displayTab===void 0)||w.activeCardId!==v.id&&(v.displayTab===!0||v.displayTab===void 0)?null:e.jsx("div",{onClick:()=>{const U=v.displayTab===void 0?!1:!v.displayTab;u({...v,displayTab:U}),f({...v,displayTab:U})},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(Ms,{className:"mr-2 size-3.5 text-muted-foreground hover:text-foreground"})})}function P(){return e.jsxs(t.Tabs,{onValueChange:F,value:s.activeCardId,className:"flex grow flex-col",children:[s.cards.map(w=>e.jsx(t.TabsContent,{className:"mt-0 grow",value:w.id,children:I()},w.id)),e.jsx(t.TabsList,{className:"group mx-4 justify-between overflow-x-auto",children:e.jsxs("div",{className:"flex items-center",children:[s.cards.map((w,v)=>e.jsxs(t.TabsTrigger,{draggable:!0,onDragStart:U=>$(U,v),onDragOver:k,onDrop:U=>L(U,v),className:"",value:w.id,children:[Q(s,w),e.jsx(t.Editable,{enabled:s.activeCardId===w.id,text:w.tabTitle||w.title,onSave:U=>{u({...a,tabTitle:U}),f({...a,tabTitle:U})},children:w.tabTitle||w.title},w.id),s.activeCardId===w.id&&s.cards.length>1&&e.jsx(t.X,{className:"ml-2 size-3.5 text-muted-foreground hover:text-foreground",onClick:()=>E(w.id)})]},w.id)),e.jsx(t.Button,{className:"ml-1 h-8 px-2 hover:bg-muted-foreground/50",variant:"outline",onClick:C,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(Is,{className:"h-4 w-4"})})]})})]})}function I(){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(Ht,{className:"grow border-none shadow-none"})})}function g(){const w=JSON.stringify(p==null?void 0:p.records,null,2),v=new Blob([w],{type:"application/json"}),U=URL.createObjectURL(v),_=document.createElement("a");_.href=U,_.download=`${a.title}.json`,_.click()}function T(){const v=[Object.keys(p==null?void 0:p.records.reduce((G,W)=>({...G,...W}),{})).join(","),...((p==null?void 0:p.records)||[]).map(G=>Object.values(G).join(","))].join(`
377
+ `),U=new Blob([v],{type:"text/csv"}),_=URL.createObjectURL(U),O=document.createElement("a");O.href=_,O.download=`${a.title}.csv`,O.click()}function q(){const w=`Can you get the documentation for ${a.type} chart?`;m(w)}return e.jsxs("div",{className:"relative isolate flex h-full flex-col py-2 pb-3",children:[(j||x)&&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(le,{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:q,children:e.jsx(js,{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:T,children:e.jsx(Bn,{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:g,children:e.jsx(Ls,{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?P():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)||((A=p==null?void 0:p.error)==null?void 0:A.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,j;const s=t.useEditorStore(x=>x.card.customCardPreferences),{data:a}=Ut(),n=(a==null?void 0:a.plugins)||[],r=t.useEditorStore(x=>x.card),o=t.useEditorStore(x=>x.frame),l=(s==null?void 0:s.visualType)||"single",{setCustomCardPreferences:i}=t.useEditorActions(),{components:d,manifest:c}=t.useCustomVisual((s==null?void 0:s.url)||""),h=(p=c==null?void 0:c.visuals)==null?void 0:p.find(x=>x.name===(s==null?void 0:s.componentName));function u(x,S){if(!s)return;const M={...(s==null?void 0:s.dataInputCardIds)||{},[x]:{cardId:S,hookRef:null}};i({...s,dataInputCardIds:M})}function f(x){var C,M;const S=(C=o==null?void 0:o.cards)==null?void 0:C.filter(N=>{var E;return((E=N==null?void 0:N.customCardPreferences)==null?void 0:E.visualType)!=="multiple"}).map(N=>({value:N.id,label:N.tabTitle||N.title}));return e.jsx("div",{className:"space-y-2",children:(M=x==null?void 0:x.dataInputs)==null?void 0:M.map((N,E)=>{var F,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=(F=s==null?void 0:s.dataInputCardIds)==null?void 0:F[E])==null?void 0:R.cardId)||"",onValueChange:$=>u(E,$)})]},E+Math.random())})})}function y(x,S,C=[],M=""){var N,E;return s?x==="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])||M,onChange:F=>{i({...s,settings:{...s==null?void 0:s.settings,[S]:F.target.value}})}},S):x==="select"?e.jsx(ee,{className:"h-8 w-full",label:"",options:C,value:((E=s==null?void 0:s.settings)==null?void 0:E[S])||M,onValueChange:F=>{i({...s,settings:{...s==null?void 0:s.settings,[S]:F}})}}):null:null}function m(x){const S=Object.entries((x==null?void 0:x.settings)||{});return e.jsx("div",{className:"space-y-3",children:S.map(([C,M])=>e.jsxs("div",{className:"space-y-1",children:[e.jsx(t.Label,{children:M.title}),y(M.ui,C,M.options,M.defaultValue)]},C))})}function b(x){s&&i({...s,visualType:x,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(gs,{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:x=>i({...s||{url:"",componentName:""},url:x})}),((s==null?void 0:s.type)==="component"||(s==null?void 0:s.type)===void 0)&&e.jsx(t.Tabs,{value:l,onValueChange:b,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:d&&e.jsx(ee,{icon:e.jsx(ks,{className:"h-3.5 w-3.5"}),className:"h-9 w-full",label:"Select Component",options:(d==null?void 0:d.filter(x=>x.type===l).map(x=>({value:x.name,label:x.name})))||[],value:s.componentName,onValueChange:x=>{console.log("changing value",x),i({...s,componentName:x})}})})]})})]}),((j=r==null?void 0:r.customCardPreferences)==null?void 0:j.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:f(h)})]}),h&&h.settings&&e.jsx("div",{className:"space-y-3",children:e.jsx("div",{className:"px-2",children:m(h)})})]})]})]})}function de(){const[s,a]=D.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}),D.useEffect(()=>{l&&a(new Array(l.length).fill(!1))},[l]);function i(h,u){var f,y;u?n!=null&&n.onClickFilter&&((f=n==null?void 0:n.onClickFilter)==null?void 0:f.length)>0?o({...n,onClickFilter:[...n.onClickFilter,{columnIndex:h,expression:""}]}):o({...n,onClickFilter:[{columnIndex:h,expression:""}]}):(o({...n,onClickFilter:(y=n==null?void 0:n.onClickFilter)==null?void 0:y.filter(m=>m.columnIndex!==h)}),a(m=>{const b=[...m];return b[h]=!1,b}))}function d(h,u){var y;const f=(y=n==null?void 0:n.onClickFilter)==null?void 0:y.map(m=>m.columnIndex===h?{...m,expression:u.target.value}:m);o({...n,onClickFilter:f})}function c(h){var u,f,y,m;if(s!=null&&s[h]||(f=(u=n==null?void 0:n.onClickFilter)==null?void 0:u.find(b=>b.columnIndex===h))!=null&&f.expression)return e.jsx(t.Input,{value:(m=(y=n==null?void 0:n.onClickFilter)==null?void 0:y.find(b=>b.columnIndex===h))==null?void 0:m.expression,onChange:b=>d(h,b),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 f,y;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:!!((f=n==null?void 0:n.onClickFilter)!=null&&f.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:((y=n==null?void 0:n.onClickFilter)==null?void 0:y.find(m=>m.columnIndex===u))&&e.jsx(t.Pencil,{onClick:()=>{a(m=>{const b=[...m];return b[u]=!m[u],b})},className:"invisible size-3 cursor-pointer text-gray-400 group-hover:visible"})})]}),c(u)]})},h)})]})}function Jn({idx:s}){var d;const a=t.useEditorStore(c=>{var h;return(h=c.card)==null?void 0:h.preferences}),n=t.useEditorStore(c=>{var h;return(h=c.card.preferences)==null?void 0:h.datasetOptions}),r=t.useEditorStore(c=>c.actions.setCardPreferences),o=(d=a==null?void 0:a.chartOptions)==null?void 0:d.indexAxis,l=n==null?void 0:n.find(c=>c.idx===s);function i(c,h){(c==="end"||c==="start")&&t.getContrastColor(t.getCanvasBackgroundColor());const u={display:c!=="none",align:c,anchor:c,clamp:!0};if(!l)r({...a,datasetOptions:[...n||[],{idx:h,datalabels:u}]});else{const f={...l};f.datalabels=u;const y=n==null?void 0:n.map(m=>m.idx===h?f:m);r({...a,datasetOptions:y})}}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(Vs,{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(Ps,{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(qs,{className:t.cn("h-4 w-4",{"rotate-90":o==="y"})})})]})})]})}function Zt(){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:d}=t.getKeys(i);l=d}return{transformedMetricKeys:l,dimensionKeys:r,keys:o,defaultMetricKeys:n}}function Xt(){const s=t.useEditorStore(c=>c.card),a=t.useEditorStore(c=>{var h,u,f;return(f=(u=(h=c==null?void 0:c.card)==null?void 0:h.preferences)==null?void 0:u.chartOptions)==null?void 0:f.indexAxis}),{data:n}=t.useDashboardCardQuery(s),r=a==="y"?"Metric":"Dimension",o=a==="y"?"Dimension":"Metric",{dimensionKeys:l,transformedMetricKeys:i,keys:d}=Zt();return d.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(c=>e.jsx("p",{className:"rounded-md bg-muted/70 px-3 py-2 hover:bg-muted",title:c,children:es(c)},c))})]}),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((c,h)=>e.jsx(ts,{className:"bg-muted/70 px-3 py-2 hover:bg-muted",iconClassName:"invisible group-hover:visible",col:c,idx:h},c))})]})]})}function es(s,a=30){return s.length>a?s.slice(0,a)+"...":s}function ts({col:s,idx:a,className:n,iconClassName:r,children:o}){const l=t.useEditorStore(u=>{var f;return(f=u.card)==null?void 0:f.preferences}),i=t.useEditorStore(u=>{var f,y;return(y=(f=u.card)==null?void 0:f.preferences)==null?void 0:y.datasetOptions}),d=i==null?void 0:i.find(u=>u.idx===a),{setCardPreferences:c}=t.useEditorStore(u=>u.actions);function h(u){if(!d)c({...l,datasetOptions:[...i||[],{idx:a,type:u==="area"?"line":u,fill:u==="area"?"origin":""}]});else{const f={...d};f.type=u==="area"?"line":u,f.fill=u==="area"?"origin":"";const y=i==null?void 0:i.map(m=>m.idx===a?f:m);c({...l,datasetOptions:y})}}return e.jsxs("div",{className:t.cn("group flex items-center justify-between gap-2 rounded-md",n),children:[o||e.jsx("p",{title:s,children:es(s)}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(He,{onClick:()=>h("bar"),className:t.cn("size-4 cursor-pointer text-muted-foreground hover:text-foreground",r)}),e.jsx(Ge,{onClick:()=>h("line"),className:t.cn("size-4 cursor-pointer text-muted-foreground hover:text-foreground",r)}),e.jsx(Cs,{onClick:()=>h("area"),className:t.cn("size-4 cursor-pointer text-muted-foreground hover:text-foreground",r)}),e.jsx(Jn,{idx:a})]})]})}function ss(){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),d=t.useDashboardStore(m=>m.actions.removeFilter),{removeFilterValues:c}=t.useDashboardActions(),{modelItems:h,tableName:u,connectionType:f}=te();function y(m,b="dashboard"){var F;const p=t.fmt(m.column_name),j=t.fmt(n||""),x=t.fmt(r||""),S=t.fmt(u);let C=t.getQualifiedTableName({schemaName:x,tableName:S,connectionType:f,databaseName:j}),M=`${C}.${p}`;const N=(F=h==null?void 0:h.find(R=>R.id===a))==null?void 0:F.name;a&&a!=="none"&&(M=`${t.DATAMODEL_NAMESPCACE}.${N}.${p}`,C=`${t.DATAMODEL_NAMESPCACE}.${N}`);const E=l==null?void 0:l.find(R=>R.column===M&&R.table===S&&(R.database===j||R.database===n));if(E)c(E.id),d(E.id);else{const R=t.v4();return u==="api"&&s?(i({location:b,id:R,column:M,title:m.column_name,dataType:m.data_type,table:"api",database:"",connectionId:s,operation:"in",sql:t.getDefaultFilterSql(m.data_type,C,p)}),R):(i({id:R,location:b,column:M,title:m.column_name,dataType:m.data_type,table:o||"",database:n||"",connectionId:s||"",operation:"in",sql:t.getDefaultFilterSql(m.data_type,C,p)}),R)}}return{assignFilter:y}}function fe(){const s=t.useDashboardStore(d=>d.dashboard.filters),a=t.useEditorStore(d=>d.frame),{setFrame:n}=t.useEditorActions(),{columns:r}=te(),{assignFilter:o}=ss();function l(d){const c=o(d,"frame");n({...a,filterId:c})}const i=s==null?void 0:s.find(d=>d.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]=pe.useState(!1),[o,l]=pe.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(d=>d.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(d=>e.jsxs(t.CommandItem,{value:d.column_name,onSelect:c=>{const h=c===o?"":c;l(h),r(!1),h&&a(d)},children:[d.column_name,e.jsx(t.CheckIcon,{className:t.cn("ml-auto h-4 w-4",o===d.column_name?"opacity-100":"opacity-0")})]},d.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(Xt,{})})]}),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(de,{}),e.jsx(fe,{})]})]})]})})}function We(){var o,l,i;const s=t.useEditorStore(d=>d.card.type),a=t.useEditorStore(d=>d.card.preferences),{setCardPreferences:n}=t.useEditorStore(d=>d.actions);function r(d){var u;const c={datalabels:{display:d!=="none",align:d,anchor:d,clamp:!0}},h={...a,chartOptions:{...a==null?void 0:a.chartOptions,plugins:{...(u=a==null?void 0:a.chartOptions)==null?void 0:u.plugins,...c}}};n(h),console.log(d)}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"}),!["pyramid","funnel"].includes(s)&&e.jsx(t.SelectItem,{value:"start",children:"Start"}),e.jsx(t.SelectItem,{value:"center",children:"Center"}),!["pyramid","funnel"].includes(s)&&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(We,{})})]}),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(de,{}),e.jsx(fe,{})]})]})]})})}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(We,{}),e.jsx(de,{}),e.jsx(fe,{})]})]})}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","funnel"].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 c,h,u,f,y;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 b,p;return(p=(b=m.card.preferences)==null?void 0:b.formatNumber)==null?void 0:p.decimalPlaces});const r=t.useEditorStore(m=>{var b,p;return(p=(b=m.card.preferences)==null?void 0:b.formatNumber)==null?void 0:p.locale}),o=t.useEditorStore(m=>{var b,p;return(p=(b=m.card.preferences)==null?void 0:b.formatNumber)==null?void 0:p.currency});t.useEditorStore(m=>m.actions.setFilterOnClickField);const l=t.useEditorStore(m=>{var b,p;return(p=(b=m.card.preferences)==null?void 0:b.formatNumber)==null?void 0:p.colorRanges})||[],i=t.useEditorStore(m=>m.actions.setColorRanges),d=[...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:!!((c=s==null?void 0:s.formatNumber)!=null&&c.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 b,p,j;return n(((b=s==null?void 0:s.formatNumber)==null?void 0:b.decimalPlaces)||0,((p=s==null?void 0:s.formatNumber)==null?void 0:p.currency)||"",m,((j=s==null?void 0:s.formatNumber)==null?void 0:j.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 b,p,j;console.log("currency",m),n(((b=s==null?void 0:s.formatNumber)==null?void 0:b.decimalPlaces)||0,m==="none"?"":m,((p=s==null?void 0:s.formatNumber)==null?void 0:p.locale)||"",((j=s==null?void 0:s.formatNumber)==null?void 0:j.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"),d.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:((f=(u=s==null?void 0:s.formatNumber)==null?void 0:u.decimalPlaces)==null?void 0:f.toString())||"0",onValueChange:m=>{var b,p,j;return n(Number(m),((b=s==null?void 0:s.formatNumber)==null?void 0:b.currency)||"",((p=s==null?void 0:s.formatNumber)==null?void 0:p.locale)||"",((j=s==null?void 0:s.formatNumber)==null?void 0:j.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:((y=s==null?void 0:s.formatNumber)==null?void 0:y.suffix)||"",className:"h-8 font-mono text-xs focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0",placeholder:"K, M, B, %",onChange:m=>{var b,p,j;return n(((b=s==null?void 0:s.formatNumber)==null?void 0:b.decimalPlaces)||0,((p=s==null?void 0:s.formatNumber)==null?void 0:p.currency)||"",((j=s==null?void 0:s.formatNumber)==null?void 0:j.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 Fe({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 c,h,u,f,y,m,b,p,j,x,S,C,M,N,E,F,R,$;const s=t.useEditorStore(k=>k.card),a=(h=(c=s==null?void 0:s.preferences)==null?void 0:c.mapVisualOptions)==null?void 0:h.topoJsonUrl,[n,r]=D.useState(((f=(u=s==null?void 0:s.preferences)==null?void 0:u.mapVisualOptions)==null?void 0:f.customTopoJsonUrl)||""),{setCardPreferences:o}=t.useEditorActions(),{data:l}=t.useTopoJson(s),i=Object.keys((l==null?void 0:l.objects)||{}).map(k=>({label:k,value:k}))||[],d=[{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(Fe,{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(Fe,{open:!0,summary:"Settings",children:e.jsxs("div",{className:"space-y-3 px-2",children:[e.jsx(ee,{className:"h-9",options:d,onValueChange:k=>{console.log("value",k),o({...s.preferences,mapVisualOptions:{topoJsonUrl:k}})},value:a||"",label:"Select Map"}),a==="custom"&&e.jsx(t.Input,{onChange:k=>{r(k.target.value)},onBlur:()=>{var k;console.log("onBlur",n),o({...s.preferences,mapVisualOptions:{...(k=s.preferences)==null?void 0:k.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=(y=s.preferences)==null?void 0:y.mapVisualOptions)==null?void 0:m.objectKey)||"",label:"Map Object",onValueChange:k=>{var L;o({...s.preferences,mapVisualOptions:{...(L=s.preferences)==null?void 0:L.mapVisualOptions,objectKey:k}})}})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(t.Label,{children:"Projection"}),e.jsx(ee,{className:"h-9",options:ra,value:((p=(b=s.preferences)==null?void 0:b.mapVisualOptions)==null?void 0:p.projection)||"",label:"Projection",onValueChange:k=>{var L;o({...s.preferences,mapVisualOptions:{...(L=s.preferences)==null?void 0:L.mapVisualOptions,projection:k}})}})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(t.Label,{children:"Colors"}),e.jsx(ee,{className:"h-9",options:ia,value:((x=(j=s.preferences)==null?void 0:j.mapVisualOptions)==null?void 0:x.colorScale)||"",label:"Select Color Scale",onValueChange:k=>{var L;o({...s.preferences,mapVisualOptions:{...(L=s.preferences)==null?void 0:L.mapVisualOptions,colorScale:k}})}})]})]})]})}),e.jsx(t.Separator,{className:"my-4"}),e.jsx(Fe,{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:((C=(S=s.preferences)==null?void 0:S.mapVisualOptions)==null?void 0:C.projectionScale)||1,onChange:k=>{var L;o({...s.preferences,mapVisualOptions:{...(L=s.preferences)==null?void 0:L.mapVisualOptions,projectionScale:Number(k.target.value)}})}}),e.jsx(t.Label,{children:"X"}),e.jsx(t.Input,{className:`h-9 w-full ${t.removeRing}`,type:"number",step:10,value:((E=(N=(M=s.preferences)==null?void 0:M.mapVisualOptions)==null?void 0:N.projectionOffset)==null?void 0:E[0])||0,onChange:k=>{var L,Q,P,I;o({...s.preferences,mapVisualOptions:{...(L=s.preferences)==null?void 0:L.mapVisualOptions,projectionOffset:[Number(k.target.value),((I=(P=(Q=s.preferences)==null?void 0:Q.mapVisualOptions)==null?void 0:P.projectionOffset)==null?void 0:I[1])||0]}})}}),e.jsx(t.Label,{children:"Y"}),e.jsx(t.Input,{className:`h-9 w-full ${t.removeRing}`,type:"number",step:10,value:(($=(R=(F=s.preferences)==null?void 0:F.mapVisualOptions)==null?void 0:R.projectionOffset)==null?void 0:$[1])||0,onChange:k=>{var L,Q,P,I;o({...s.preferences,mapVisualOptions:{...(L=s.preferences)==null?void 0:L.mapVisualOptions,projectionOffset:[((I=(P=(Q=s.preferences)==null?void 0:Q.mapVisualOptions)==null?void 0:P.projectionOffset)==null?void 0:I[0])||0,Number(k.target.value)]}})}})]})}),e.jsx(t.Separator,{className:"my-4"}),e.jsx(de,{})]})}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 Ce({cardType:s,docContent:a,suffix:n="Chart"}){let r="pie-donut-polar";return s==="funnel"&&(r="funnel"),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:o=>o.stopPropagation(),className:"text-blue-700",href:`https://docs.semaphor.cloud/docs/charts/${r}`,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(We,{}),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(de,{}),e.jsx(fe,{})]})]})]})})}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(Xt,{})]})]}),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(de,{}),e.jsx(fe,{})]})]})]})})}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(de,{}),e.jsx(fe,{})]})]})}),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(Ce,{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(Ce,{docContent:ha,cardType:n});case"pie":case"doughnut":case"polarArea":case"radar":case"funnel":return e.jsx(Ce,{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(Ce,{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 ns({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(wt,{className:"size-3.5"})},{label:"Count",value:"COUNT",logo:e.jsx(bt,{className:"size-3.5"})},{label:"Unique",value:"DISTINCT",logo:e.jsx(Os,{className:"size-3.5"})},{label:"Average",value:"AVG",logo:e.jsx(ms,{className:"size-3.5"})},{label:"Min",value:"MIN",logo:e.jsx(dt,{className:"size-3.5"})},{label:"Max",value:"MAX",logo:e.jsx(t.ArrowUp,{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:je(s.name,o)};a(s.id,l)}return e.jsx(ns,{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{updateGroupByColumn:a}=t.useEditorActions();function n(r){const o={...s,granularity:r,label:xe(s.name,r)};a(s.id,o)}return e.jsx(ns,{column:s,functions:ja,onFunctionChange:r=>n(r),label:"Granularity"})}function ba({col:s,onChange:a,droppableId:n}){const{columns:r}=Ke(),o=D.useMemo(()=>{let d=[];(n===re||n===oe||n===ie)&&(d=r);const c=d==null?void 0:d.filter(h=>h.column_name!==s.name);return c==null?void 0:c.map(h=>({id:h.column_name,value:h.column_name}))},[r,n,s.name]),l=[{id:s.name,value:s.name}];function i(d){const c=r==null?void 0:r.find(h=>{var u;return h.column_name===((u=d[0])==null?void 0:u.id)});c&&a(c)}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 pl-0 pr-8"}):e.jsx("input",{disabled:!0,type:"text",className:"overflow-hidden truncate text-ellipsis whitespace-nowrap bg-muted text-sm",value:s.name})}function Pe({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}=Zt();console.log(n,r);const o=t.useEditorStore(c=>{var h;return(h=c.card.queryConfig)==null?void 0:h.pivotColumns}),l=!!(o&&o.length>0),i=n.find(c=>c===s.label||c===s.name),d=i?n.indexOf(i):-1;return e.jsxs("div",{className:"space-y-3",children:[i&&e.jsx(ts,{idx:d,col:i,children:e.jsx(t.Editable,{enabled:!0,className:"w-[130px]",text:s.label||"",placeholder:"Enter label",onSave:c=>{a(s.id,{...s,label:c||s.name})},children:e.jsx(Pe,{className:"w-[130px]",children:s.label||s.name})})}),l&&e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx(t.Label,{children:"Pivot Header"}),e.jsx(t.Editable,{enabled:!0,text:s.aliasTemplate||"",placeholder:"{label} ({pivot})",onSave:c=>{a(s.id,{...s,aliasTemplate:c||""})},children:e.jsx(Pe,{className:"font-mono text-xs text-muted-foreground",children:s.aliasTemplate||"{label} ({pivot})"})})]})]})}function Ca({column:s,type:a,onRemoveColumn:n,droppableId:r}){const[o,l]=D.useState(!1),{updateGroupByColumn:i,updateMetricColumn:d,updatePivotByColumn:c}=t.useEditorActions(),{attributes:h,listeners:u,setNodeRef:f,transform:y,transition:m,isDragging:b}=t.useSortable({id:s.id,data:{type:a}}),p=y?{opacity:b?.5:void 0,transform:t.CSS.Translate.toString(y),transition:m}:void 0,j=t.isTextDataType(s.type);function x(E){const F=t.isNumberDataType(E.data_type),R=t.isTextDataType(E.data_type),$=t.isDateDataType(E.data_type),k=F?"number":R?"string":$?"date":"string";if(r===re){if(R){const L={id:s.id,name:E.column_name,type:k,role:"groupby"};i(s.id,L)}if($){const L={id:s.id,name:E.column_name,type:k,role:"groupby",label:xe(E.column_name,"month"),granularity:"month"};i(s.id,L)}}if(r===ie){if(R){const L={id:s.id,name:E.column_name,type:k,role:"groupby"};c(s.id,L)}if($){const L={id:s.id,name:E.column_name,type:k,label:xe(E.column_name,"month"),granularity:"month",role:"groupby"};c(s.id,L)}}if(r===oe){const L={id:s.id,name:E.column_name,type:k,role:"metric",label:je(E.column_name,"SUM"),aggregate:F?"SUM":"COUNT"};d(s.id,L)}}function S(){if(r===oe)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 C(){const E=t.isDateDataType(s.type);if(r===oe)return e.jsx(ga,{column:s});if((r===re||r===ie)&&E)return e.jsx(ya,{column:s})}function M(){return e.jsx("div",{className:t.cn("grow",{"pl-3":(r===re||r===ie)&&j}),children:e.jsx(ba,{col:s,onChange:x,droppableId:r})})}function N(){return e.jsx("div",{"data-setting-actions":"",className:"flex h-full items-center gap-2",children:e.jsx("button",{className:"h-full pl-2",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(jt,{className:t.cn("size-3 cursor-pointer items-center justify-center rounded-r-sm text-muted-foreground")})})})}return e.jsx("div",{...u,...h,ref:f,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",children:[N(),C(),M()]}),o&&S()]}),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 Re({id:s,label:a,columns:n,previewColumns:r,sortableType:o,onRemoveColumn:l}){var p,j;const{setNodeRef:i,isOver:d,over:c}=t.useDroppable({id:s}),h=t.useDndStore(x=>x.activeId),u=t.useEditorStore(x=>{var S;return(S=x.card)==null?void 0:S.type}),f=d||((j=(p=c==null?void 0:c.data)==null?void 0:p.current)==null?void 0:j.type)===o,y=h?r:n,m=o===ve?"Rows":o===Ne?"Pivot Columns":"Columns";function b(){if(!y||y.length===0)return e.jsx("div",{className:"mr-5 flex h-8 grow items-center space-x-2 rounded-md border border-dashed border-muted-foreground/80 bg-background px-2 py-1 text-sm text-muted-foreground",children:e.jsx("span",{className:"invisible text-muted-foreground/70 group-hover:visible",children:"Drag here"})})}return e.jsx(t.SortableContext,{items:n==null?void 0:n.map(x=>x.id),children:e.jsxs("div",{className:t.cn("group space-y-2 rounded-md p-4",f&&"border border-muted-foreground/50"),ref:i,children:[e.jsxs("div",{className:"flex items-center justify-between pr-5",children:[e.jsx(t.Label,{className:"text-sm",children:a}),u!=="table"&&e.jsx("span",{className:"text-xs text-muted-foreground/50",children:m})]}),b(),e.jsx("div",{className:"space-y-2",children:y==null?void 0:y.map(x=>x.id===Lt.id?e.jsx(va,{},x.id):e.jsx(Ca,{droppableId:s,type:o,column:x,onRemoveColumn:l},x.id))})]})})}function va(){return e.jsx("div",{className:"mr-5 flex h-8 grow items-center space-x-2 rounded-md border border-dashed border-muted-foreground bg-background px-2 py-1 text-sm",children:e.jsx("span",{className:"text-muted-foreground/70",children:"Drop here"})})}function as({children:s,id:a,type:n}){const{attributes:r,listeners:o,setNodeRef:l,transform:i,transition:d,isDragging:c}=t.useSortable({id:a,data:{type:n}}),h=i?{opacity:c?.5:void 0,transform:t.CSS.Translate.toString(i),transition:d}:void 0;return e.jsx("div",{...o,...r,ref:l,style:h,children:s})}function Na(){const s=t.useEditorStore(x=>{var S;return(S=x.card.queryConfig)==null?void 0:S.orderBy})||[],a=t.useEditorStore(x=>{var S;return(S=x.card.queryConfig)==null?void 0:S.groupByColumns})||[],n=t.useEditorStore(x=>{var S;return(S=x.card.queryConfig)==null?void 0:S.metricColumns})||[],{addOrderByColumn:r,removeOrderByColumn:o,updateOrderByColumn:l}=t.useEditorActions(),i=[...a,...n];if(i.length===0)return e.jsx(e.Fragment,{});const d=e.jsx(fs,{className:"size-3.5 text-muted-foreground hover:text-foreground"}),c=e.jsx(us,{className:"size-3.5 text-muted-foreground hover:text-foreground"}),h=e.jsx(xs,{className:"size-3.5 text-muted-foreground hover:text-foreground"}),u=e.jsx(ds,{className:"size-3.5 text-muted-foreground hover:text-foreground"}),f=i==null?void 0:i.filter(x=>!s.some(S=>S.columnId===x.id)).map(x=>({id:x.id,value:x.label||x.name}));function y(x,S){const C=m(x);return C?C.role==="metric"?S==="asc"?h:u:S==="asc"?d:c:null}function m(x){return i.find(S=>S.id===x)}function b(x){const S=s.find(C=>C.columnId===x);if(S){const C={...S,direction:S.direction==="asc"?"desc":"asc"};l(C)}}const p=x=>{r({columnId:x.id,direction:"asc"})};function j(x){const S=s.find(C=>C.columnId===x);S&&o(S)}return e.jsx(t.SortableContext,{items:s.map(x=>ge(x.columnId)),children:e.jsxs("div",{className:"space-y-2 rounded-md p-4 text-sm",children:[e.jsx(t.Label,{className:"text-sm",children:"Sort By"}),f.length>0&&e.jsx("div",{className:"mr-5",children:e.jsx(t.ComboBox2,{multiple:!1,options:f,selectedOptions:[],onChange:x=>p(x[0]),selectAllChecked:!1,onSelectAllCheckedChange:()=>{},inputClassName:"h-8 bg-muted border-none"})}),s.map(x=>{var S,C;return e.jsx(as,{id:ge(x.columnId),type:Je,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(jt,{className:"size-3 cursor-move text-muted-foreground hover:text-foreground"}),e.jsx(Pe,{className:"w-[175px] text-sm",children:((S=m(x.columnId))==null?void 0:S.label)||((C=m(x.columnId))==null?void 0:C.name)})]}),e.jsx("button",{title:x.direction==="asc"?"Ascending":"Descending",onClick:()=>b(x.columnId),className:"rounded-sm p-0",children:y(x.columnId,x.direction)})]}),e.jsx("div",{children:e.jsx("button",{onClick:()=>j(x.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"})})})]})},x.columnId)},ge(x.columnId))})]})})}function wa(){const s=t.useEditorStore(j=>{var x;return((x=j.card.queryConfig)==null?void 0:x.groupByColumns)||[]}),a=t.useEditorStore(j=>j.card.type),n=t.useDndStore(j=>j.previewGroupByColumns),r=t.useEditorStore(j=>{var x;return((x=j.card.queryConfig)==null?void 0:x.metricColumns)||[]}),o=t.useDndStore(j=>j.previewMetricColumns),l=t.useEditorStore(j=>{var x;return((x=j.card.queryConfig)==null?void 0:x.pivotColumns)||[]}),i=t.useDndStore(j=>j.previewPivotColumns),{removeColumnFromGroupBy:d,removeColumnFromMetricColumns:c,removeColumnFromPivotBy:h}=t.useEditorActions();function u(j){d(j)}function f(j){c(j)}function y(j){h(j)}let m="Group By",b="Metrics",p="Stack By";return a==="table"&&(m="Rows",b="Metrics",p="Columns"),e.jsxs("div",{className:"flex h-full w-full flex-col gap-3 py-4",children:[e.jsx(Yt,{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(Re,{onRemoveColumn:u,sortableType:ve,id:re,label:m,columns:s,previewColumns:n}),e.jsx(Re,{onRemoveColumn:y,sortableType:Ne,id:ie,label:p,columns:l,previewColumns:i}),e.jsx(Re,{onRemoveColumn:f,sortableType:Be,id:oe,label:b,columns:r,previewColumns:o}),e.jsx(Na,{})]}),e.jsx(t.ScrollBar,{orientation:"horizontal"})]})]})}function Ye({children:s,column:a,id:n,sortableType:r,className:o}){const[l,i]=D.useState(!1),{removeEditorFilter:d}=t.useEditorActions();function c(h){d(h)}return e.jsx(as,{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:()=>c(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 C,M;return(M=(C=S.card)==null?void 0:C.queryConfig)==null?void 0:M.filters}),{selectedConnectionId:o,selectedDatabaseName:l,selectedTableName:i}=te(),d=D.useMemo(()=>{var S;return(S=r==null?void 0:r.find(C=>C.filterColumnName===s.name))==null?void 0:S.filterValue},[r,s.name]),c=D.useMemo(()=>Array.isArray(d)?d.map(S=>({id:S,value:S})):[],[d]),{updateEditorFilterValue:h}=t.useEditorActions(),u={column:s.name,sql:s.sql,id:s.name,connectionId:o,dataType:s.type},{data:f,isLoading:y,isFetching:m,isError:b}=t.useFilterQuery(u),p=D.useMemo(()=>{var C;return u.column?(C=f==null?void 0:f.records)==null?void 0:C.map(M=>{let N=u.column.split(".").slice(-1)[0].replace(/"/g,"");return M[N]===void 0&&(N=N.toLowerCase()),{id:M[N],value:M[N]}}):[]},[f,u.column]);function j(S){const C=S.map(M=>M.id);h(s.name,C)}function x(){return y||m?e.jsx(t.Skeleton,{style:{borderRadius:n==null?void 0:n.controlInputRadius},className:"h-8 min-w-60 bg-foreground/10"}):b?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:j,selectedOptions:c,selectAllChecked:!1,onSelectAllCheckedChange:()=>{}})}return e.jsx(Ye,{className:"w-60",id:s.id,sortableType:a,column:s,children:x()})}function Ia({column:s,sortableType:a}){const[n,r]=D.useState(!1),{selectedConnectionId:o,selectedDatabaseName:l,selectedTableName:i}=te(),d={column:s.name,sql:s.sql,id:s.name,connectionId:o,title:"",dataType:s.type},{isLoading:c,isFetching:h,isError:u,data:f}=t.useFilterQuery(d),y=f==null?void 0:f.records,{dateRange:m,setDateRange:b,initialDateRange:p}=t.useDateRangeFromRecords(y),{updateEditorFilterValue:j}=t.useEditorActions();function x(M){var E,F;const N={gte:(E=M==null?void 0:M.from)==null?void 0:E.toISOString(),lte:(F=M==null?void 0:M.to)==null?void 0:F.toISOString()};j(s.name,N)}function S(){j(s.name,null,!0),b(p)}function C(){return c||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"}):y?e.jsx(t.DateRangePopover,{title:d.title,open:n,inputClassName:"h-8",setOpen:r,dateRange:m,setDateRange:b,onApply:x,onClear:S}):e.jsx(t.Label,{className:"flex h-8 w-72 items-center bg-muted px-2",children:"No Data"})}return e.jsx(Ye,{className:"w-72",id:s.id,sortableType:a,column:s,children:C()})}function Da({id:s,label:a,columns:n,previewColumns:r,sortableType:o}){var b,p;const{setNodeRef:l,isOver:i,over:d}=t.useDroppable({id:s}),c=t.useDndStore(j=>j.activeId),h={},u=i||((p=(b=d==null?void 0:d.data)==null?void 0:b.current)==null?void 0:p.type)===o;function f(){if(!m||m.length===0)return e.jsx("div",{className:"flex h-8 grow items-center space-x-2 rounded-md border border-dashed border-muted-foreground/80 bg-background px-2 py-1 text-sm text-muted-foreground",children:e.jsx("span",{className:"invisible text-muted-foreground/70 group-hover:visible",children:"Drag here"})})}function y(j){const x=t.isDateDataType(j.type);return j.id===Lt.id?e.jsx(Ye,{id:j.id,sortableType:o,column:j,children:e.jsx(Ea,{})},j.id):x?e.jsx(Ia,{droppableId:s,sortableType:o,column:j},j.id):e.jsx(ka,{droppableId:s,sortableType:o,column:j},j.id)}const m=c?r:n;return e.jsx(t.SortableContext,{items:n==null?void 0:n.map(j=>j.id),children:e.jsxs("div",{className:t.cn("group space-y-2 rounded-md border-muted-foreground/50 p-4",u&&"border border-muted-foreground/50"),ref:l,style:h,children:[e.jsx(t.Label,{className:"text-sm",children:a}),f(),e.jsx("div",{className:"flex flex-wrap items-center gap-4",children:m==null?void 0:m.map(j=>y(j))})]})})}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 text-muted-foreground",children:"Drop here"})}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:qe,id:Ve,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(Pt,{}),e.jsx(zt,{sql:a==null?void 0:a.sql,error:n})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"rounded-full bg-green-300 px-3 py-1 text-xs font-medium text-black",children:"Preview"}),e.jsx(qt,{}),e.jsx(Vt,{variant:"default"})]})]})}function Aa(){const s=D.useRef(null),a=t.useEditorStore(i=>i.isShowingVisual),n=t.useEditorStore(i=>i.showAIDialog),r=t.useEditorStore(i=>i.isDevMode);D.useEffect(()=>{var i,d;n?(i=s.current)==null||i.resize(0):(d=s.current)==null||d.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}),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,{}),e.jsx(t.ResizablePanel,{minSize:40,defaultSize:75,maxSize:100,children:e.jsx(Se,{})})]}):e.jsx(Se,{})})]})}function l(){return e.jsx(e.Fragment,{children:e.jsx("div",{className:"grow","data-biz-mode-container":"",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,{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:60,defaultSize:80,children:e.jsx(Se,{})})]})})]}):e.jsx(Se,{})})})}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=D.useRef(null),a=D.useRef(null),[n,r]=D.useState(!1),[o,l]=D.useState(t.isDevEnv),[i,d]=D.useState(!1),c=t.useEditorStore(A=>A.actions.setCardSql),h=t.useEditorStore(A=>A.actions.setRunSql),u=t.useEditorStore(A=>A.showAIDialog),{setShowAIDialog:f}=t.useEditorActions(),{messages:y,setMessages:m,reload:b,append:p,input:j,setInput:x,isLoading:S,handleAddCurrentTableToScope:C,removeFromCurrentSelections:M,currentAssitantScope:N,handleInputChange:E,handleSubmit:F,stop:R,chatStatus:$,toolStatus:k,llmUsage:L,errorMessage:Q}=Bt();t.useAssistantScroll({scrollContainerRef:s,inputRef:a,messages:y}),D.useEffect(()=>{var A;u&&((A=a.current)==null||A.focus())},[u]);function P(A){c(A),h(!0)}function I(A){const w={role:"user",content:A.title+" "+A.subtitle};p(w)}function g(){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(gt,{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:d,children:"System Message"})]})]})}function T(){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((A,w)=>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:A.schemaName||"",tableName:A.tableName||"",modelName:A.datamodelName||"",connectionType:A.connectionType||"",databaseName:A.databaseName||""}),e.jsx("button",{onClick:()=>{M(A)},children:e.jsx(t.X,{className:"size-3 text-muted-foreground hover:text-foreground"})})]},w))}),(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:C,children:[e.jsx(t.Plus,{className:"mr-2 size-3"}),"Current Table"]})]})]})}const q=(j==null?void 0:j.length)===0&&(y==null?void 0:y.filter(A=>A.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:[T(),e.jsxs("div",{"data-role":"header-actions",className:"flex items-center",children:[g(),e.jsx(t.Button,{className:"h-7 p-2",size:"sm",variant:"ghost",onClick:()=>{m([]),b()},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:()=>{f(!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:y,showTools:o,handleRun:P,showSystemMessage:i}),e.jsx(t.ChatStatus,{status:t.getStatus($,k),isLoading:S})]})}),q&&e.jsx(t.Placeholders,{onClick:I,placeholders:La}),e.jsx(t.ChatInput,{onFocus:()=>{C()},stop:R,ref:a,setInput:x,input:j,handleInputChange:E,handleSubmit:F,isLoading:S}),L&&n&&e.jsx("div",{className:"flex h-8 items-center justify-between",children:e.jsxs("div",{className:"text-xs text-muted-foreground",children:["Usage: ",L.promptTokens," prompt tokens,"," ",L.completionTokens," completion tokens,"," ",L.totalTokens," total tokens"]})}),Q&&e.jsx("div",{className:"flex items-center justify-between text-xs text-muted-foreground",children:e.jsx("span",{children:Q})})]})}function za({authToken:s,onSave:a,onClose:n}){const r=D.useRef(null),o=t.useEditorStore(j=>j.showAIDialog),{setAuthToken:l}=t.useDashboardActions(),{setShowAIDialog:i,setOnSave:d,setOnClose:c}=t.useEditorActions(),{handleDragOver:h,handleDragEnd:u,handleDragStart:f,handleDragCancel:y,sensors:m}=xn();D.useEffect(()=>{a&&d(a),n&&c(n)},[a,d,n,c]),D.useEffect(()=>{s&&s.accessToken&&l(s)},[s,l]),D.useEffect(()=>{var j,x;o?((j=r.current)==null||j.resize(40),i(!0)):(i(!1),(x=r.current)==null||x.resize(0))},[o,i]);function b(j){j<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",children:e.jsx(Aa,{})}),e.jsx(t.ResizableHandle,{}),e.jsx(t.ResizablePanel,{"data-role":"editor-assistant-panel",ref:r,onResize:b,defaultSize:0,children:e.jsx(Oa,{})})]})}return e.jsx(t.ErrorBoundary,{FallbackComponent:t.Fallback,children:e.jsx(t.DndContext,{sensors:m,onDragStart:f,onDragEnd:u,onDragOver:h,onDragCancel:y,children:e.jsxs("section",{className:"isolate flex h-full grow","data-content":"editor-panel",children:[e.jsx(Ot,{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}=ss();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(d=>d.column===t.fmt(l.column_name)&&d.table===a&&d.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(Qe,{column:l}),e.jsx("span",{children:l.column_name})]})},l.column_name)})})}function _a(){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(Ot,{type:"filter",ColumnsComponent:()=>e.jsx(Ra,{})})})]})}function Ba(){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(Ba,{}),e.jsx(t.DashboardTabs,{})]}),s&&e.jsx("div",{role:"filter-aside-container",className:"flex",children:e.jsx(_a,{})})]})}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=Mt;exports.SelectComponent=he;exports.Surfboard=Pa;exports.cleanCard=Dt;exports.downloadPdf=Tt;exports.getDashbaordStateWithoutData=$e;exports.useEditorAside=te;