react-semaphor 0.1.62 → 0.1.63

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.
Files changed (54) hide show
  1. package/dist/chunks/dashboard-plus-BT1JEFt7.js +17438 -0
  2. package/dist/chunks/dashboard-plus-C7mXurPl.js +235 -0
  3. package/dist/chunks/index-DHzLB6Yx.js +1045 -0
  4. package/dist/chunks/{index--MUeDITx.js → index-Dji-XteI.js} +25747 -28323
  5. package/dist/dashboard/index.cjs +1 -1
  6. package/dist/dashboard/index.js +1 -1
  7. package/dist/index.cjs +2 -2
  8. package/dist/index.js +106 -107
  9. package/dist/style.css +1 -1
  10. package/dist/surfboard/index.cjs +1 -1
  11. package/dist/surfboard/index.js +1 -1
  12. package/dist/types/main.d.ts +0 -8
  13. package/package.json +1 -1
  14. package/dist/chunks/axis-mapping-8ZVwlkl6.js +0 -315
  15. package/dist/chunks/axis-mapping-Cwa3KrDR.js +0 -16
  16. package/dist/chunks/bar-chart-settings-B_WyC-7g.js +0 -52
  17. package/dist/chunks/bar-chart-settings-CvorW7RD.js +0 -1
  18. package/dist/chunks/bubble-chart-settings-BPtESqYK.js +0 -1
  19. package/dist/chunks/bubble-chart-settings-CxFAlErV.js +0 -50
  20. package/dist/chunks/common-chart-settings-CvRrQf-H.js +0 -1
  21. package/dist/chunks/common-chart-settings-D3ww0Xtx.js +0 -147
  22. package/dist/chunks/custom-visual-settings-DXWyN2Dr.js +0 -11
  23. package/dist/chunks/custom-visual-settings-m5o8R5tL.js +0 -243
  24. package/dist/chunks/dashboard-plus-B8-ocT_Z.js +0 -41
  25. package/dist/chunks/dashboard-plus-DSUKhvcv.js +0 -2941
  26. package/dist/chunks/display-labels-BYsRReye.js +0 -1
  27. package/dist/chunks/display-labels-C_jsL0Jo.js +0 -74
  28. package/dist/chunks/editor-C7xQi9Ab.js +0 -105
  29. package/dist/chunks/editor-DqvyBUrl.js +0 -8321
  30. package/dist/chunks/filter-on-click-columns-6dRYhvgz.js +0 -1
  31. package/dist/chunks/filter-on-click-columns-BJUGTE6W.js +0 -120
  32. package/dist/chunks/frame-filters-D9sDN4Vm.js +0 -1
  33. package/dist/chunks/frame-filters-DFgqSoV2.js +0 -75
  34. package/dist/chunks/index-Bvtpj-_R.js +0 -1080
  35. package/dist/chunks/kpi-settings-BONvmfNr.js +0 -1
  36. package/dist/chunks/kpi-settings-CI-9fp4Z.js +0 -286
  37. package/dist/chunks/map-chart-settings-CSxZdu_g.js +0 -1
  38. package/dist/chunks/map-chart-settings-DQIN7Pn8.js +0 -334
  39. package/dist/chunks/pie-chart-settings-CN3JCLdP.js +0 -86
  40. package/dist/chunks/pie-chart-settings-CsErfZOL.js +0 -1
  41. package/dist/chunks/reusable-select-CQbD03nT.js +0 -40
  42. package/dist/chunks/reusable-select-CVRzPWkg.js +0 -1
  43. package/dist/chunks/stacked-chart-settings-BfqHFFqA.js +0 -1
  44. package/dist/chunks/stacked-chart-settings-poYotO6Q.js +0 -90
  45. package/dist/chunks/table-visual-settings-B46pdUra.js +0 -46
  46. package/dist/chunks/table-visual-settings-ZKWuNokZ.js +0 -1
  47. package/dist/chunks/tag-BrxBSbSe.js +0 -20
  48. package/dist/chunks/tag-D9G2kz2B.js +0 -6
  49. package/dist/chunks/use-assign-filter-5gplfsO1.js +0 -83
  50. package/dist/chunks/use-assign-filter-DzmBSsyO.js +0 -1
  51. package/dist/chunks/use-local-storage-state-CBh2HHB9.js +0 -16
  52. package/dist/chunks/use-local-storage-state-CL0JsTZM.js +0 -1745
  53. package/dist/chunks/use-plugin-query-DA6Yrp7P.js +0 -12
  54. package/dist/chunks/use-plugin-query-JdHNPYZS.js +0 -1
@@ -1,11 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react/jsx-runtime"),e=require("./index-Bvtpj-_R.js"),h=require("./reusable-select-CVRzPWkg.js"),R=require("./use-plugin-query-JdHNPYZS.js");/**
2
- * @license lucide-react v0.453.0 - ISC
3
- *
4
- * This source code is licensed under the ISC license.
5
- * See the LICENSE file in the root directory of this source tree.
6
- */const q=e.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"}]]);/**
7
- * @license lucide-react v0.453.0 - ISC
8
- *
9
- * This source code is licensed under the ISC license.
10
- * See the LICENSE file in the root directory of this source tree.
11
- */const L=e.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"}]]);function f(){var N,y;const l=e.useEditorStore(a=>a.card.customCardPreferences),{data:r}=R.usePluginQuery(),I=(r==null?void 0:r.plugins)||[],x=e.useEditorStore(a=>a.card),j=e.useEditorStore(a=>a.frame),v=(l==null?void 0:l.visualType)||"single",{setCustomCardPreferences:c}=e.useEditorActions(),{components:g,manifest:m}=e.useCustomVisual((l==null?void 0:l.url)||""),d=(N=m==null?void 0:m.visuals)==null?void 0:N.find(a=>a.name===(l==null?void 0:l.componentName));function S(a,i){if(!l)return;const t={...(l==null?void 0:l.dataInputCardIds)||{},[a]:{cardId:i,hookRef:null}};c({...l,dataInputCardIds:t})}function T(a){var o,t;const i=(o=j==null?void 0:j.cards)==null?void 0:o.filter(n=>{var u;return((u=n==null?void 0:n.customCardPreferences)==null?void 0:u.visualType)!=="multiple"}).map(n=>({value:n.id,label:n.tabTitle||n.title}));return s.jsx("div",{className:"space-y-2",children:(t=a==null?void 0:a.dataInputs)==null?void 0:t.map((n,u)=>{var p,b;return s.jsxs("div",{className:"grid grid-cols-10 gap-2",children:[s.jsx("div",{className:"col-span-4 flex items-center",children:n}),s.jsx(h.ReusableSelect,{className:"col-span-6 h-8 w-full justify-between",label:"",options:i||[],value:((b=(p=l==null?void 0:l.dataInputCardIds)==null?void 0:p[u])==null?void 0:b.cardId)||"",onValueChange:A=>S(u,A)})]},u+Math.random())})})}function w(a,i,o=[],t=""){var n,u;return l?a==="input"?s.jsx(e.Input,{className:`h-8 w-full ${e.removeRing}`,value:((n=l==null?void 0:l.settings)==null?void 0:n[i])||t,onChange:p=>{c({...l,settings:{...l==null?void 0:l.settings,[i]:p.target.value}})}},i):a==="select"?s.jsx(h.ReusableSelect,{className:"h-8 w-full",label:"",options:o,value:((u=l==null?void 0:l.settings)==null?void 0:u[i])||t,onValueChange:p=>{c({...l,settings:{...l==null?void 0:l.settings,[i]:p}})}}):null:null}function V(a){const i=Object.entries((a==null?void 0:a.settings)||{});return s.jsx("div",{className:"space-y-3",children:i.map(([o,t])=>s.jsxs("div",{className:"space-y-1",children:[s.jsx(e.Label,{children:t.title}),w(t.ui,o,t.options,t.defaultValue)]},o))})}function M(a){l&&c({...l,visualType:a,componentName:""})}return s.jsxs(e.Accordion,{type:"multiple",defaultValue:["component-settings"],className:"px-6 py-2",children:[s.jsxs(e.AccordionItem,{value:"plugin-settings",children:[s.jsx(e.AccordionTrigger,{children:"Plugin"}),s.jsx(e.AccordionContent,{children:s.jsxs("div",{className:"space-y-4 text-sm",children:[s.jsx("div",{className:"space-y-2",children:s.jsxs("div",{className:"space-y-4",children:[s.jsx(h.ReusableSelect,{icon:s.jsx(q,{className:"h-3.5 w-3.5"}),className:"h-9 w-full",label:"Select Plugin",options:I,value:(l==null?void 0:l.url)||"",onValueChange:a=>c({...l||{url:"",componentName:""},url:a})}),((l==null?void 0:l.type)==="component"||(l==null?void 0:l.type)===void 0)&&s.jsx(e.Tabs,{value:v,onValueChange:M,children:s.jsxs(e.TabsList,{className:"h-9 w-full",children:[s.jsx(e.TabsTrigger,{className:"h-7 w-full",value:"single",children:"Single Visual"}),s.jsx(e.TabsTrigger,{className:"h-7 w-full",value:"multiple",children:"Multi-Visual"})]})})]})}),((l==null?void 0:l.type)==="component"||(l==null?void 0:l.type)===void 0)&&l&&s.jsx(s.Fragment,{children:g&&s.jsx(h.ReusableSelect,{icon:s.jsx(L,{className:"h-3.5 w-3.5"}),className:"h-9 w-full",label:"Select Component",options:(g==null?void 0:g.filter(a=>a.type===v).map(a=>({value:a.name,label:a.name})))||[],value:l.componentName,onValueChange:a=>{console.log("changing value",a),c({...l,componentName:a})}})})]})})]}),((y=x==null?void 0:x.customCardPreferences)==null?void 0:y.componentName)&&s.jsxs(e.AccordionItem,{className:"border-none",value:"component-settings",children:[s.jsx(e.AccordionTrigger,{children:"Settings"}),s.jsxs(e.AccordionContent,{children:[d&&d.dataInputs&&s.jsxs("div",{className:"space-y-3",children:[s.jsx(e.Label,{children:"Input Mapping"}),s.jsx("div",{className:"px-2",children:T(d)})]}),d&&d.settings&&s.jsx("div",{className:"space-y-3",children:s.jsx("div",{className:"px-2",children:V(d)})})]})]})]})}exports.CustomVisualSettings=f;
@@ -1,243 +0,0 @@
1
- import { jsxs as e, jsx as n, Fragment as q } from "react/jsx-runtime";
2
- import { E as A, u as y, d as B, a3 as D, A as H, a as T, b as x, c as S, a4 as U, a5 as F, a6 as f, L as M, I as K, X as Q } from "./index--MUeDITx.js";
3
- import { R as g } from "./reusable-select-CQbD03nT.js";
4
- import { u as X } from "./use-plugin-query-DA6Yrp7P.js";
5
- /**
6
- * @license lucide-react v0.453.0 - ISC
7
- *
8
- * This source code is licensed under the ISC license.
9
- * See the LICENSE file in the root directory of this source tree.
10
- */
11
- const $ = A("Blocks", [
12
- ["rect", { width: "7", height: "7", x: "14", y: "3", rx: "1", key: "6d4xhi" }],
13
- [
14
- "path",
15
- {
16
- 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",
17
- key: "1fpvtg"
18
- }
19
- ]
20
- ]);
21
- /**
22
- * @license lucide-react v0.453.0 - ISC
23
- *
24
- * This source code is licensed under the ISC license.
25
- * See the LICENSE file in the root directory of this source tree.
26
- */
27
- const C = A("Component", [
28
- [
29
- "path",
30
- {
31
- 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",
32
- key: "1uwlt4"
33
- }
34
- ],
35
- [
36
- "path",
37
- {
38
- 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",
39
- key: "10291m"
40
- }
41
- ],
42
- [
43
- "path",
44
- {
45
- 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",
46
- key: "1tqoq1"
47
- }
48
- ],
49
- [
50
- "path",
51
- {
52
- 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",
53
- key: "1x6lto"
54
- }
55
- ]
56
- ]);
57
- function Z() {
58
- var b, w;
59
- const a = y(
60
- (l) => l.card.customCardPreferences
61
- ), { data: m } = X(), L = (m == null ? void 0 : m.plugins) || [], v = y((l) => l.card), N = y((l) => l.frame), I = (a == null ? void 0 : a.visualType) || "single", { setCustomCardPreferences: o } = B(), { components: h, manifest: r } = D(
62
- (a == null ? void 0 : a.url) || ""
63
- ), d = (b = r == null ? void 0 : r.visuals) == null ? void 0 : b.find(
64
- (l) => l.name === (a == null ? void 0 : a.componentName)
65
- );
66
- function j(l, s) {
67
- if (!a) return;
68
- const t = {
69
- ...(a == null ? void 0 : a.dataInputCardIds) || {},
70
- [l]: {
71
- cardId: s,
72
- hookRef: null
73
- }
74
- };
75
- o({
76
- ...a,
77
- dataInputCardIds: t
78
- });
79
- }
80
- function k(l) {
81
- var u, t;
82
- const s = (u = N == null ? void 0 : N.cards) == null ? void 0 : u.filter((i) => {
83
- var p;
84
- return ((p = i == null ? void 0 : i.customCardPreferences) == null ? void 0 : p.visualType) !== "multiple";
85
- }).map((i) => ({
86
- value: i.id,
87
- label: i.tabTitle || i.title
88
- }));
89
- return /* @__PURE__ */ n("div", { className: "space-y-2", children: (t = l == null ? void 0 : l.dataInputs) == null ? void 0 : t.map((i, p) => {
90
- var c, V;
91
- return /* @__PURE__ */ e(
92
- "div",
93
- {
94
- className: "grid grid-cols-10 gap-2",
95
- children: [
96
- /* @__PURE__ */ n("div", { className: "col-span-4 flex items-center", children: i }),
97
- /* @__PURE__ */ n(
98
- g,
99
- {
100
- className: "col-span-6 h-8 w-full justify-between",
101
- label: "",
102
- options: s || [],
103
- value: ((V = (c = a == null ? void 0 : a.dataInputCardIds) == null ? void 0 : c[p]) == null ? void 0 : V.cardId) || "",
104
- onValueChange: (O) => j(p, O)
105
- }
106
- )
107
- ]
108
- },
109
- p + Math.random()
110
- );
111
- }) });
112
- }
113
- function z(l, s, u = [], t = "") {
114
- var i, p;
115
- return a ? l === "input" ? /* @__PURE__ */ n(
116
- K,
117
- {
118
- className: `h-8 w-full ${Q}`,
119
- value: ((i = a == null ? void 0 : a.settings) == null ? void 0 : i[s]) || t,
120
- onChange: (c) => {
121
- o({
122
- ...a,
123
- settings: {
124
- ...a == null ? void 0 : a.settings,
125
- [s]: c.target.value
126
- }
127
- });
128
- }
129
- },
130
- s
131
- ) : l === "select" ? /* @__PURE__ */ n(
132
- g,
133
- {
134
- className: "h-8 w-full",
135
- label: "",
136
- options: u,
137
- value: ((p = a == null ? void 0 : a.settings) == null ? void 0 : p[s]) || t,
138
- onValueChange: (c) => {
139
- o({
140
- ...a,
141
- settings: { ...a == null ? void 0 : a.settings, [s]: c }
142
- });
143
- }
144
- }
145
- ) : null : null;
146
- }
147
- function R(l) {
148
- const s = Object.entries((l == null ? void 0 : l.settings) || {});
149
- return /* @__PURE__ */ n("div", { className: "space-y-3", children: s.map(([u, t]) => /* @__PURE__ */ e("div", { className: "space-y-1", children: [
150
- /* @__PURE__ */ n(M, { children: t.title }),
151
- z(
152
- t.ui,
153
- u,
154
- t.options,
155
- t.defaultValue
156
- )
157
- ] }, u)) });
158
- }
159
- function E(l) {
160
- a && o({
161
- ...a,
162
- visualType: l,
163
- componentName: ""
164
- });
165
- }
166
- return /* @__PURE__ */ e(
167
- H,
168
- {
169
- type: "multiple",
170
- defaultValue: ["component-settings"],
171
- className: "px-6 py-2",
172
- children: [
173
- /* @__PURE__ */ e(T, { value: "plugin-settings", children: [
174
- /* @__PURE__ */ n(x, { children: "Plugin" }),
175
- /* @__PURE__ */ n(S, { children: /* @__PURE__ */ e("div", { className: "space-y-4 text-sm", children: [
176
- /* @__PURE__ */ n("div", { className: "space-y-2", children: /* @__PURE__ */ e("div", { className: "space-y-4", children: [
177
- /* @__PURE__ */ n(
178
- g,
179
- {
180
- icon: /* @__PURE__ */ n($, { className: "h-3.5 w-3.5" }),
181
- className: "h-9 w-full",
182
- label: "Select Plugin",
183
- options: L,
184
- value: (a == null ? void 0 : a.url) || "",
185
- onValueChange: (l) => o({
186
- ...a || {
187
- url: "",
188
- componentName: ""
189
- },
190
- url: l
191
- })
192
- }
193
- ),
194
- ((a == null ? void 0 : a.type) === "component" || (a == null ? void 0 : a.type) === void 0) && /* @__PURE__ */ n(
195
- U,
196
- {
197
- value: I,
198
- onValueChange: E,
199
- children: /* @__PURE__ */ e(F, { className: "h-9 w-full", children: [
200
- /* @__PURE__ */ n(f, { className: "h-7 w-full", value: "single", children: "Single Visual" }),
201
- /* @__PURE__ */ n(f, { className: "h-7 w-full", value: "multiple", children: "Multi-Visual" })
202
- ] })
203
- }
204
- )
205
- ] }) }),
206
- ((a == null ? void 0 : a.type) === "component" || (a == null ? void 0 : a.type) === void 0) && a && /* @__PURE__ */ n(q, { children: h && /* @__PURE__ */ n(
207
- g,
208
- {
209
- icon: /* @__PURE__ */ n(C, { className: "h-3.5 w-3.5" }),
210
- className: "h-9 w-full",
211
- label: "Select Component",
212
- options: (h == null ? void 0 : h.filter((l) => l.type === I).map((l) => ({
213
- value: l.name,
214
- label: l.name
215
- }))) || [],
216
- value: a.componentName,
217
- onValueChange: (l) => {
218
- console.log("changing value", l), o({
219
- ...a,
220
- componentName: l
221
- });
222
- }
223
- }
224
- ) })
225
- ] }) })
226
- ] }),
227
- ((w = v == null ? void 0 : v.customCardPreferences) == null ? void 0 : w.componentName) && /* @__PURE__ */ e(T, { className: "border-none", value: "component-settings", children: [
228
- /* @__PURE__ */ n(x, { children: "Settings" }),
229
- /* @__PURE__ */ e(S, { children: [
230
- d && d.dataInputs && /* @__PURE__ */ e("div", { className: "space-y-3", children: [
231
- /* @__PURE__ */ n(M, { children: "Input Mapping" }),
232
- /* @__PURE__ */ n("div", { className: "px-2", children: k(d) })
233
- ] }),
234
- d && d.settings && /* @__PURE__ */ n("div", { className: "space-y-3", children: /* @__PURE__ */ n("div", { className: "px-2", children: R(d) }) })
235
- ] })
236
- ] })
237
- ]
238
- }
239
- );
240
- }
241
- export {
242
- Z as CustomVisualSettings
243
- };
@@ -1,41 +0,0 @@
1
- "use strict";const e=require("react/jsx-runtime"),s=require("./index-Bvtpj-_R.js"),g=require("react");require("react-dom");const U=require("./use-local-storage-state-CBh2HHB9.js");/**
2
- * @license lucide-react v0.453.0 - ISC
3
- *
4
- * This source code is licensed under the ISC license.
5
- * See the LICENSE file in the root directory of this source tree.
6
- */const ye=s.createLucideIcon("CirclePlus",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M8 12h8",key:"1wcyev"}],["path",{d:"M12 8v8",key:"napkw2"}]]);/**
7
- * @license lucide-react v0.453.0 - ISC
8
- *
9
- * This source code is licensed under the ISC license.
10
- * See the LICENSE file in the root directory of this source tree.
11
- */const Se=s.createLucideIcon("FolderOpen",[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]]);/**
12
- * @license lucide-react v0.453.0 - ISC
13
- *
14
- * This source code is licensed under the ISC license.
15
- * See the LICENSE file in the root directory of this source tree.
16
- */const Ce=s.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"}]]);/**
17
- * @license lucide-react v0.453.0 - ISC
18
- *
19
- * This source code is licensed under the ISC license.
20
- * See the LICENSE file in the root directory of this source tree.
21
- */const Me=s.createLucideIcon("Menu",[["line",{x1:"4",x2:"20",y1:"12",y2:"12",key:"1e0a9i"}],["line",{x1:"4",x2:"20",y1:"6",y2:"6",key:"1owob3"}],["line",{x1:"4",x2:"20",y1:"18",y2:"18",key:"yk5zj1"}]]);/**
22
- * @license lucide-react v0.453.0 - ISC
23
- *
24
- * This source code is licensed under the ISC license.
25
- * See the LICENSE file in the root directory of this source tree.
26
- */const Ie=s.createLucideIcon("Moon",[["path",{d:"M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z",key:"a7tn18"}]]);/**
27
- * @license lucide-react v0.453.0 - ISC
28
- *
29
- * This source code is licensed under the ISC license.
30
- * See the LICENSE file in the root directory of this source tree.
31
- */const Pe=s.createLucideIcon("PanelLeft",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}]]);/**
32
- * @license lucide-react v0.453.0 - ISC
33
- *
34
- * This source code is licensed under the ISC license.
35
- * See the LICENSE file in the root directory of this source tree.
36
- */const Ae=s.createLucideIcon("ShieldX",[["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:"m14.5 9.5-5 5",key:"17q4r4"}],["path",{d:"m9.5 9.5 5 5",key:"18nt4w"}]]);/**
37
- * @license lucide-react v0.453.0 - ISC
38
- *
39
- * This source code is licensed under the ISC license.
40
- * See the LICENSE file in the root directory of this source tree.
41
- */const Te=s.createLucideIcon("Sun",[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]]);function Le(){const{setTheme:t}=s.useTheme(),o=s.useDashboardStore(r=>r.actions.setDashboardTheme);return e.jsxs(s.DropdownMenu,{children:[e.jsx(s.DropdownMenuTrigger,{asChild:!0,children:e.jsxs(s.Button,{className:"h-7 p-2",variant:"ghost",size:"sm",children:[e.jsx(Te,{strokeWidth:1.5,className:"h-4 w-4 rotate-0 scale-100 transition-all dark:-rotate-90 dark:scale-0"}),e.jsx(Ie,{strokeWidth:1.5,className:"absolute h-4 w-4 rotate-90 scale-0 transition-all dark:rotate-0 dark:scale-100"}),e.jsx("span",{className:"sr-only",children:"Toggle theme"})]})}),e.jsxs(s.DropdownMenuContent,{align:"end",children:[e.jsx(s.DropdownMenuItem,{onClick:()=>{t("light"),o("light")},children:"Light"}),e.jsx(s.DropdownMenuItem,{onClick:()=>{t("dark"),o("dark")},children:"Dark"}),e.jsx(s.DropdownMenuItem,{onClick:()=>{t("system"),o("system")},children:"System"})]})]})}function ce(t){var o;return{...t,sheets:(o=t==null?void 0:t.sheets)==null?void 0:o.map(r=>{var a;return{...r,frames:(a=r.frames)==null?void 0:a.map(n=>{var d;return{...n,cards:(d=n.cards)==null?void 0:d.map(l=>fe(l))}})}})}}function fe(t){return{...t,customCfg:Ee(t.customCfg),data:[]}}function Ee(t){var o,r;return t?{...t,data:{...t==null?void 0:t.data,labels:[],datasets:(r=(o=t==null?void 0:t.data)==null?void 0:o.datasets)==null?void 0:r.map(a=>({...a,data:[]}))}}:null}async function Fe(t,o,r,a,n){if(!n)return null;const d=JSON.stringify(r),l=`${t}/v1/lens`;return await s.postRequest(l,n,{name:o,template:d,filterValues:a,operation:"create"})}async function xe(t,o,r){if(!r)return null;const{id:a,template:n,filterValues:d,isDefault:l,shared:m}=o,c=`${t}/v1/lens`;return await s.postRequest(c,r,{lensId:a,template:n,filterValues:d,isDefault:l,shared:m,operation:"update"})}async function ke(t,o,r){if(!r)return null;const a=`${t}/v1/lens`;return await s.postRequest(a,r,{operation:"delete",lensId:o})}function Oe(){const[t,o]=g.useState(""),[r,a]=g.useState(!1),n=s.useDashboardStore(S=>S.lenses),{setLenses:d,setSelectedLensId:l}=s.useDashboardActions(),[m,c]=g.useState(!1),[p,x]=g.useState(!1),i=s.useDashboardStore(S=>S.dashboard),h=s.useDashboardStore(S=>S.filterValues),{authToken:D,tokenProps:b}=s.useSemaphorContext();async function y(){c(!0);const S=ce(i),A=await Fe(b.apiServiceUrl,t,S,h,D==null?void 0:D.accessToken);A&&(d([...n||[],A]),l(A.id),x(!1)),c(!1)}return e.jsxs(s.Dialog,{open:p,onOpenChange:x,children:[e.jsx(s.DialogTrigger,{asChild:!0,children:e.jsxs(s.Button,{variant:"secondary",className:"h-7 p-2",size:"sm",children:[e.jsx(s.Plus,{className:"mr-2 h-4 w-4"}),"Lens"]})}),e.jsxs(s.DialogContent,{className:"sm:max-w-[425px]",children:[e.jsxs(s.DialogHeader,{children:[e.jsx(s.DialogTitle,{children:"Create Lens"}),e.jsx(s.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(s.Label,{className:"text-right",children:"Name"}),e.jsx(s.Input,{value:t,onChange:S=>{o(S.target.value)},id:"name",className:"col-span-7 focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0"})]})}),r&&e.jsx("p",{className:"text-sm",children:"The lens name already exists. Use a differnet name."}),e.jsx(s.DialogFooter,{children:e.jsx(s.Button,{size:"sm",variant:"outline",type:"submit",onClick:y,disabled:m,children:m?"Creating...":"Add"})})]})]})}function Ue(){const[t,o]=g.useState(!1),r=s.useDashboardStore(i=>i.lenses),a=s.useDashboardStore(i=>i.selectedLensId),{setLenses:n,setSelectedLensId:d}=s.useDashboardActions(),{authToken:l,tokenProps:m}=s.useSemaphorContext();async function c(i){d(i)}async function p(i){if(await ke(m.apiServiceUrl,i,l==null?void 0:l.accessToken)){const D=r==null?void 0:r.filter(b=>b.id!==i);n(D||[]),d("original")}}async function x(i){const h=r==null?void 0:r.map(y=>y.id===i.id?{...y,isDefault:!i.isDefault}:{...y,isDefault:!1});n(h||[]);const D={...i,isDefault:!i.isDefault};await xe(m.apiServiceUrl,D,l==null?void 0:l.accessToken);const b=r==null?void 0:r.find(y=>y.isDefault);if(b&&b.id!==i.id){const y={...b,isDefault:!1};await xe(m.apiServiceUrl,y,l==null?void 0:l.accessToken)}}return e.jsxs(s.DropdownMenu,{open:t,onOpenChange:o,children:[e.jsx(s.DropdownMenuTrigger,{asChild:!0,children:e.jsx(s.IconButton,{tooltip:"Lenses",className:"h-7 p-2",children:e.jsx(Ce,{className:"h-4 w-4"})})}),e.jsxs(s.DropdownMenuContent,{align:"end",className:"w-60",children:[e.jsx(s.DropdownMenuLabel,{className:"px-3",children:"Lenses"}),e.jsx(s.DropdownMenuSeparator,{}),e.jsxs(s.DropdownMenuRadioGroup,{value:a,onValueChange:c,children:[e.jsx(s.DropdownMenuRadioItem,{value:"original",children:"Original"}),r==null?void 0:r.map(i=>e.jsxs(s.DropdownMenuRadioItem,{className:"group flex justify-between gap-2",value:i.id,children:[e.jsx("p",{children:i.name}),e.jsxs("span",{className:"flex items-center gap-3",children:[e.jsx(s.House,{onClick:h=>{h.preventDefault(),x(i)},className:s.cn("size-3.5 text-muted-foreground hover:cursor-pointer hover:text-foreground group-hover:visible",{invisible:!i.isDefault,"text-green-500":i.isDefault}),strokeWidth:1.5}),e.jsx(s.Cross2Icon,{onClick:h=>{h.preventDefault(),p(i.id)},className:"invisible size-3.5 text-muted-foreground hover:cursor-pointer hover:text-foreground group-hover:visible",strokeWidth:1.5})]})]},i.id))]})]})]})}function Ve({iconClassName:t}){const[o,r]=g.useState(!1),[a,n]=g.useState(""),[d,l]=g.useState(!1),m=s.useDashboardStore(i=>i.isDownloadingPdf),{tokenProps:c}=s.useSemaphorContext();async function p(){const i=s.ue.loading("Generating PDF... may take up to 60 seconds");try{await s.downloadPdf(c.apiServiceUrl),s.ue.dismiss(i),s.ue.success("PDF downloaded successfully!",{duration:2e3})}catch(h){s.ue.dismiss(i),s.ue.error("Failed to download PDF",{description:"Please try again or contact support.",richColors:!0}),console.error("PDF download error:",h)}}async function x(){if(!a)return;r(!1),n(""),l(!1);const i=s.ue.loading("Generating protected PDF... may take up to 60 seconds");try{await s.downloadPdf(c.apiServiceUrl,a),s.ue.dismiss(i),s.ue.success("Protected PDF downloaded successfully!",{duration:2e3,position:"top-right"})}catch(h){s.ue.dismiss(i),s.ue.error("Failed to download protected PDF. Please try again."),console.error("Protected PDF download error:",h)}}return e.jsxs(e.Fragment,{children:[e.jsxs(s.DropdownMenu,{modal:!1,children:[e.jsx(s.DropdownMenuTrigger,{asChild:!0,children:e.jsx(s.Button,{variant:"ghost",size:"sm",className:"h-7 p-2",disabled:m,children:e.jsx(s.Download,{className:s.cn("size-4",t)})})}),e.jsxs(s.DropdownMenuContent,{align:"end",children:[e.jsxs(s.DropdownMenuItem,{onClick:p,children:[e.jsx(s.File,{className:"mr-2 h-4 w-4"}),"Download PDF"]}),e.jsxs(s.DropdownMenuItem,{onClick:()=>r(!0),children:[e.jsx(s.Lock,{className:"mr-2 h-4 w-4"}),"Download Protected PDF"]})]})]}),e.jsx(s.Dialog,{open:o,onOpenChange:r,children:e.jsxs(s.DialogContent,{className:"sm:max-w-[425px]",children:[e.jsxs(s.DialogHeader,{children:[e.jsx(s.DialogTitle,{children:"Download Protected PDF"}),e.jsx(s.DialogDescription,{children:"Enter a password to protect your PDF. The PDF will be encrypted and require this password to open."})]}),e.jsx("div",{className:"grid gap-4 py-4",children:e.jsxs("div",{className:"grid gap-2",children:[e.jsx(s.Label,{htmlFor:"password",children:"Password"}),e.jsxs("div",{className:"relative",children:[e.jsx(s.Input,{id:"password",type:d?"text":"password",value:a,onChange:i=>n(i.target.value),placeholder:"Enter password",className:"pr-10",onKeyDown:i=>{i.key==="Enter"&&a&&x()}}),e.jsx(s.Button,{type:"button",variant:"ghost",size:"sm",className:"absolute right-0 top-0 h-full px-3 py-2 hover:bg-transparent",onClick:()=>l(!d),children:d?e.jsx(s.EyeOff,{className:"h-4 w-4 text-muted-foreground"}):e.jsx(s.Eye,{className:"h-4 w-4 text-muted-foreground"})})]})]})}),e.jsxs(s.DialogFooter,{children:[e.jsx(s.Button,{variant:"outline",onClick:()=>r(!1),children:"Cancel"}),e.jsx(s.Button,{onClick:x,disabled:!a,children:"Download"})]})]})})]})}function je({triggerButtonClassName:t}){const[o,r]=g.useState(!1),a=s.useDashboardStore(m=>{var c;return(c=m.dashboard)==null?void 0:c.id}),n=s.useDashboardStore(m=>{var c;return(c=m.dashboard)==null?void 0:c.title}),d=s.useDashboardStore(m=>{var c;return(c=m.dashboard)==null?void 0:c.sheets}),l=s.useDashboardStore(m=>m.selectedSheetId);return d==null||d.find(m=>m.id===l),a?e.jsxs(e.Fragment,{children:[e.jsx(s.IconButton,{tooltip:"Schedule Dashboard",className:s.cn("h-7 p-2",t),onClick:()=>r(!0),children:e.jsx(s.Clock,{className:"size-4"})}),e.jsx(s.EmailScheduleDialog,{open:o,onOpenChange:r,dashboardId:a,dashboardName:n})]}):null}function be({type:t,isLinked:o,className:r}){const a=s.useDashboardStore(p=>p.selectedFrameId),n=s.useManagementStore(p=>p.selectedVisual),d=s.useEditorStore(p=>p.frame);let l;if(t)l=t;else if(o!==void 0)l=o?"linked":"library";else if(!!!(d!=null&&d.visualId||n!=null&&n.id)&&a)l="local";else if(n&&!a)l="library";else if(d!=null&&d.visualId&&a)l="linked";else if(n!=null&&n.id&&a)l="library";else return null;const m={local:"bg-gray-100 text-gray-700",linked:"bg-purple-100 text-purple-700",library:"bg-blue-100 text-blue-700"},c={local:"Local Visual",linked:"Linked Visual",library:"Library Visual"};return e.jsx("span",{className:s.cn("rounded-full px-2.5 py-0.5 text-xs font-medium",m[l],r),children:c[l]})}const Be=async(t,o,r)=>{const a=`${t}/management/v1/groups`;return await s.postRequestRegular(a,o,r)},Re=async(t,o,r)=>{const a=`${t}/management/v1/groups/${r}`,n=await fetch(a,{method:"DELETE",headers:{Authorization:`Bearer ${o}`}});if(!n.ok){const d=await n.text();throw new Error(d||"Failed to delete group")}},ze=async(t,o,r,a)=>{const n=`${t}/management/v1/groups/${r}/members`;return await s.postRequestRegular(n,o,a)},Ge=async(t,o,r,a)=>{const n=`${t}/management/v1/groups/${r}/members`,d=await fetch(n,{method:"DELETE",headers:{"Content-Type":"application/json",Authorization:`Bearer ${o}`},body:JSON.stringify(a)});if(!d.ok){const l=await d.text();throw new Error(l||"Failed to remove group members")}};function qe(){const{authToken:t,tokenProps:o}=s.useSemaphorContext(),r=s.useQueryClient();return s.useMutation({mutationFn:a=>Be(o.apiServiceUrl,(t==null?void 0:t.accessToken)||"",a),onSuccess:()=>{r.invalidateQueries({queryKey:["groups"]}),s.ue.success("Group created successfully")},onError:a=>{console.error("Failed to create group:",a),s.ue.error("Failed to create group",{description:a.message})}})}function _e(){const{authToken:t,tokenProps:o}=s.useSemaphorContext(),r=s.useQueryClient();return s.useMutation({mutationFn:a=>Re(o.apiServiceUrl,(t==null?void 0:t.accessToken)||"",a),onSuccess:(a,n)=>{r.invalidateQueries({queryKey:["groups"]}),r.removeQueries({queryKey:["group",n]}),s.ue.success("Group deleted successfully")},onError:a=>{console.error("Failed to delete group:",a),s.ue.error("Failed to delete group",{description:a.message})}})}function He(){const{authToken:t,tokenProps:o}=s.useSemaphorContext(),r=s.useQueryClient();return s.useMutation({mutationFn:({groupId:a,data:n})=>ze(o.apiServiceUrl,(t==null?void 0:t.accessToken)||"",a,n),onSuccess:(a,n)=>{r.invalidateQueries({queryKey:["group",n.groupId]}),r.invalidateQueries({queryKey:["group-members",n.groupId]}),r.invalidateQueries({queryKey:["groups"]}),s.ue.success("Members added successfully")},onError:a=>{console.error("Failed to add group members:",a),s.ue.error("Failed to add members",{description:a.message})}})}function Qe(){const{authToken:t,tokenProps:o}=s.useSemaphorContext(),r=s.useQueryClient();return s.useMutation({mutationFn:({groupId:a,data:n})=>Ge(o.apiServiceUrl,(t==null?void 0:t.accessToken)||"",a,n),onSuccess:(a,n)=>{r.invalidateQueries({queryKey:["group",n.groupId]}),r.invalidateQueries({queryKey:["group-members",n.groupId]}),r.invalidateQueries({queryKey:["groups"]}),s.ue.success("Members removed successfully")},onError:a=>{console.error("Failed to remove group members:",a),s.ue.error("Failed to remove members",{description:a.message})}})}function $e({onSuccess:t,tenantId:o,isTenantUser:r}){const[a,n]=g.useState(""),[d,l]=g.useState(""),[m,c]=g.useState({}),p=qe(),x=()=>{const h={};return a.trim()?a.length<3?h.name="Group name must be at least 3 characters":a.length>50&&(h.name="Group name must be less than 50 characters"):h.name="Group name is required",d&&d.length>200&&(h.description="Description must be less than 200 characters"),c(h),Object.keys(h).length===0},i=async h=>{if(h.preventDefault(),!x())return;const D={name:a.trim(),description:d.trim()||void 0,type:r?"TENANT_GROUP":"ORG_GROUP",...r&&o?{tenantId:o}:{}};try{await p.mutateAsync(D),n(""),l(""),c({}),t()}catch(b){console.error("Failed to create group:",b)}};return e.jsxs("form",{onSubmit:i,className:"space-y-6",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs(s.Label,{htmlFor:"group-name",children:["Group Name ",e.jsx("span",{className:"text-destructive",children:"*"})]}),e.jsx(s.Input,{id:"group-name",placeholder:"e.g., Marketing Team, Engineering Squad",value:a,onChange:h=>{n(h.target.value),m.name&&c(D=>({...D,name:""}))},className:m.name?"border-destructive":"",disabled:p.isPending}),m.name&&e.jsx("p",{className:"text-sm text-destructive",children:m.name})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(s.Label,{htmlFor:"group-description",children:["Description",e.jsx("span",{className:"ml-2 text-xs text-muted-foreground",children:"(optional)"})]}),e.jsx(s.Textarea,{id:"group-description",placeholder:"Describe the purpose of this group...",value:d,onChange:h=>{l(h.target.value),m.description&&c(D=>({...D,description:""}))},className:m.description?"border-destructive":"",disabled:p.isPending,rows:3}),m.description&&e.jsx("p",{className:"text-sm text-destructive",children:m.description}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[d.length,"/200 characters"]})]}),e.jsx("div",{className:"rounded-lg border bg-muted/50 p-4",children:e.jsxs("div",{className:"flex gap-3",children:[e.jsx(s.CircleAlert,{className:"h-4 w-4 mt-0.5 text-muted-foreground"}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"This group will be accessible to users in your workspace. You can add members after creating the group."})]})})]}),e.jsxs("div",{className:"flex justify-end gap-3",children:[e.jsx(s.Button,{type:"button",variant:"outline",onClick:()=>{n(""),l(""),c({})},disabled:p.isPending,children:"Clear"}),e.jsx(s.Button,{type:"submit",disabled:p.isPending||!a.trim(),children:p.isPending?e.jsxs(e.Fragment,{children:[e.jsx(s.LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Creating..."]}):e.jsxs(e.Fragment,{children:[e.jsx(s.Users,{className:"mr-2 h-4 w-4"}),"Create Group"]})})]})]})}function Ke({open:t,onOpenChange:o,group:r,onUpdate:a}){const[n,d]=g.useState("members"),[l,m]=g.useState(""),[c,p]=g.useState([]),[x,i]=g.useState([]),{data:h,isLoading:D,refetch:b}=s.useGroupMembers(r.id),y=r.type==="TENANT_GROUP"?"tenant":"organization",{users:S,isLoading:A}=s.useUnifiedUsers({type:y,tenantId:r.tenantId||void 0,active:!0,limit:100}),v=He(),L=Qe(),w=(h==null?void 0:h.members)||[],E=g.useMemo(()=>new Set(w.map(N=>N.userId)),[w]),T=g.useMemo(()=>S.filter(N=>!E.has(N.id)),[S,E]),C=g.useMemo(()=>{if(!l)return T;const N=l.toLowerCase();return T.filter(F=>{var k,q;return((k=F.name)==null?void 0:k.toLowerCase().includes(N))||((q=F.email)==null?void 0:q.toLowerCase().includes(N))})},[T,l]),I=g.useMemo(()=>{if(!l)return w;const N=l.toLowerCase();return w.filter(F=>{var k,q,W,K;return((q=(k=F.user)==null?void 0:k.name)==null?void 0:q.toLowerCase().includes(N))||((K=(W=F.user)==null?void 0:W.email)==null?void 0:K.toLowerCase().includes(N))})},[w,l]),M=async()=>{if(c.length!==0)try{await v.mutateAsync({groupId:r.id,data:{userIds:c,userType:y==="tenant"?"tenant":"org"}}),p([]),d("members"),b(),a==null||a()}catch(N){console.error("Failed to add members:",N)}},Q=async()=>{if(x.length!==0)try{await L.mutateAsync({groupId:r.id,data:{userIds:x}}),i([]),b(),a==null||a()}catch(N){console.error("Failed to remove members:",N)}},O=N=>{p(F=>F.includes(N)?F.filter(k=>k!==N):[...F,N])},$=N=>{i(F=>F.includes(N)?F.filter(k=>k!==N):[...F,N])};return e.jsx(e.Fragment,{children:e.jsx(s.Dialog,{open:t,onOpenChange:o,children:e.jsxs(s.DialogContent,{className:"max-w-3xl max-h-[80vh]","aria-describedby":"group-members-description",children:[e.jsxs(s.DialogHeader,{children:[e.jsx(s.DialogTitle,{children:r.name}),e.jsx("div",{className:"flex items-center gap-2 mt-1",children:e.jsxs("p",{className:"text-sm text-muted-foreground",children:[w.length," ",w.length===1?"member":"members"]})}),e.jsxs("p",{id:"group-members-description",className:"sr-only",children:["Add or remove members from the ",r.name," group"]})]}),e.jsxs(s.Tabs,{value:n,onValueChange:N=>{d(N),m(""),i([])},className:"mt-4",children:[e.jsxs(s.TabsList,{className:"grid w-full grid-cols-2",children:[e.jsx(s.TabsTrigger,{value:"members",children:"Current Members"}),e.jsx(s.TabsTrigger,{value:"add",children:"Add Members"})]}),e.jsxs(s.TabsContent,{value:"members",className:"mt-4 space-y-4",children:[e.jsxs("div",{className:"relative",children:[e.jsx(s.Search,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),e.jsx(s.Input,{placeholder:"Search members...",value:l,onChange:N=>m(N.target.value),className:"pl-10"})]}),e.jsx(s.ScrollArea,{className:x.length>0?"h-[300px]":"h-[350px]",children:D?e.jsx("div",{className:"space-y-2",children:[1,2,3].map(N=>e.jsx(s.Skeleton,{className:"h-16 w-full"},N))}):I.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-muted-foreground",children:[e.jsx(s.Users,{className:"h-12 w-12 mb-3 opacity-50"}),e.jsx("p",{className:"text-sm font-medium",children:l?"No members found":"No members yet"}),e.jsx("p",{className:"text-xs mt-1",children:l?"Try a different search":'Switch to the "Add Members" tab to add people to this group'})]}):e.jsx("div",{className:"space-y-2",children:I.map(N=>e.jsx(We,{member:N,selected:x.includes(N.userId),onToggle:()=>$(N.userId)},N.id))})}),x.length>0&&e.jsxs("div",{className:"flex items-center justify-between pt-4 border-t",children:[e.jsxs("span",{className:"text-sm text-muted-foreground",children:[x.length," member",x.length!==1?"s":""," selected"]}),e.jsx(s.Button,{variant:"destructive",size:"sm",onClick:Q,disabled:L.isPending,children:L.isPending?e.jsxs(e.Fragment,{children:[e.jsx(s.LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Removing..."]}):e.jsxs(e.Fragment,{children:[e.jsx(s.Trash2,{className:"mr-2 h-4 w-4"}),"Remove Selected"]})})]})]}),e.jsxs(s.TabsContent,{value:"add",className:"mt-4 space-y-4",children:[e.jsxs("div",{className:"relative",children:[e.jsx(s.Search,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),e.jsx(s.Input,{placeholder:"Search users to add...",value:l,onChange:N=>m(N.target.value),className:"pl-10"})]}),e.jsx(s.ScrollArea,{className:"h-[300px]",children:A?e.jsx("div",{className:"space-y-2",children:[1,2,3].map(N=>e.jsx(s.Skeleton,{className:"h-16 w-full"},N))}):C.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-muted-foreground",children:[e.jsx(s.UserPlus,{className:"h-12 w-12 mb-3 opacity-50"}),e.jsx("p",{className:"text-sm font-medium",children:"No available users"}),e.jsx("p",{className:"text-xs mt-1",children:l?"Try a different search":"All eligible users are already members"})]}):e.jsx("div",{className:"space-y-2",children:C.map(N=>e.jsx(Je,{user:N,selected:c.includes(N.id),onToggle:()=>O(N.id)},N.id))})}),c.length>0&&e.jsxs("div",{className:"flex items-center justify-between pt-4 border-t",children:[e.jsxs("span",{className:"text-sm text-muted-foreground",children:[c.length," user",c.length!==1?"s":""," selected"]}),e.jsx(s.Button,{onClick:M,disabled:v.isPending,children:v.isPending?e.jsxs(e.Fragment,{children:[e.jsx(s.LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Adding..."]}):e.jsxs(e.Fragment,{children:[e.jsx(s.UserPlus,{className:"mr-2 h-4 w-4"}),"Add Members"]})})]})]})]})]})})})}function We({member:t,selected:o,onToggle:r}){var n,d,l,m;const a=((d=(n=t.user)==null?void 0:n.name)==null?void 0:d.split(" ").map(c=>c[0]).join("").toUpperCase())||"?";return e.jsxs("div",{className:"flex items-center gap-3 p-3 rounded-lg border bg-card hover:bg-muted/50 cursor-pointer",onClick:r,children:[e.jsx(s.Checkbox,{checked:o}),e.jsx(s.Avatar,{className:"h-8 w-8",children:e.jsx(s.AvatarFallback,{className:"text-xs",children:a})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-sm font-medium",children:((l=t.user)==null?void 0:l.name)||"Unknown User"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:(m=t.user)==null?void 0:m.email})]})]})}function Je({user:t,selected:o,onToggle:r}){var n;const a=((n=t.name)==null?void 0:n.split(" ").map(d=>d[0]).join("").toUpperCase())||"?";return e.jsxs("div",{className:"flex items-center gap-3 p-3 rounded-lg border bg-card hover:bg-muted/50 cursor-pointer",onClick:r,children:[e.jsx(s.Checkbox,{checked:o}),e.jsx(s.Avatar,{className:"h-8 w-8",children:e.jsx(s.AvatarFallback,{className:"text-xs",children:a})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-sm font-medium",children:t.name}),e.jsx("p",{className:"text-xs text-muted-foreground",children:t.email})]})]})}function Xe({open:t,onOpenChange:o}){const[r,a]=g.useState("groups"),[n,d]=g.useState(""),[l,m]=g.useState(null),[c,p]=g.useState(!1),[x,i]=g.useState(null),{tokenProps:h}=s.useSemaphorContext(),{currentUser:D}=s.useCurrentUserInfo(),b=_e(),y=(D==null?void 0:D.type)==="tenant",S=h==null?void 0:h.tenantId,{groups:A,isLoading:v,refetch:L}=s.useGroups({type:y?"TENANT_GROUP":"all",tenantId:y?S:void 0,includeMembers:!1}),w=A.filter(I=>{var M;return I.name.toLowerCase().includes(n.toLowerCase())||((M=I.description)==null?void 0:M.toLowerCase().includes(n.toLowerCase()))}),E=async()=>{if(x)try{await b.mutateAsync(x.id),i(null),L()}catch(I){console.error("Failed to delete group:",I)}},T=I=>{m(I),p(!0)},C=()=>{a("groups"),L()};return e.jsxs(e.Fragment,{children:[e.jsx(s.Dialog,{open:t,onOpenChange:o,children:e.jsxs(s.DialogContent,{className:"max-w-4xl max-h-[80vh]",children:[e.jsxs(s.DialogHeader,{children:[e.jsxs(s.DialogTitle,{className:"flex items-center gap-2",children:[e.jsx(s.Users,{className:"h-5 w-5"}),"Group Management"]}),e.jsx(s.DialogDescription,{children:"Manage your groups, create new groups, and control group membership"})]}),e.jsxs(s.Tabs,{value:r,onValueChange:a,className:"mt-4",children:[e.jsxs(s.TabsList,{className:"grid w-full grid-cols-2",children:[e.jsxs(s.TabsTrigger,{value:"groups",className:"flex items-center gap-2",children:[e.jsx(s.Users,{className:"h-4 w-4"}),"Groups"]}),e.jsxs(s.TabsTrigger,{value:"create",className:"flex items-center gap-2",children:[e.jsx(s.Plus,{className:"h-4 w-4"}),"Create Group"]})]}),e.jsx(s.TabsContent,{value:"groups",className:"mt-4",children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"relative",children:[e.jsx(s.Search,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),e.jsx(s.Input,{placeholder:"Search groups...",value:n,onChange:I=>d(I.target.value),className:"pl-10"})]}),e.jsx(s.ScrollArea,{className:"h-[400px]",children:v?e.jsx("div",{className:"space-y-3",children:[1,2,3].map(I=>e.jsx(s.Skeleton,{className:"h-24 w-full"},I))}):w.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-muted-foreground",children:[e.jsx(s.Users,{className:"h-12 w-12 mb-3 opacity-50"}),e.jsx("p",{className:"text-sm font-medium",children:"No groups found"}),e.jsx("p",{className:"text-xs mt-1",children:n?"Try a different search":"Create your first group to get started"})]}):e.jsx("div",{className:"space-y-3",children:w.map(I=>e.jsx(Ze,{group:I,onManageMembers:()=>T(I),onDelete:()=>i(I),currentUserId:D==null?void 0:D.id},I.id))})})]})}),e.jsx(s.TabsContent,{value:"create",className:"mt-4",children:e.jsx($e,{onSuccess:C,tenantId:S,isTenantUser:y})})]})]})}),l&&e.jsx(Ke,{open:c,onOpenChange:p,group:l,onUpdate:()=>L()}),e.jsx(s.AlertDialog,{open:!!x,onOpenChange:()=>i(null),children:e.jsxs(s.AlertDialogContent,{children:[e.jsxs(s.AlertDialogHeader,{children:[e.jsx(s.AlertDialogTitle,{children:"Delete Group"}),e.jsxs(s.AlertDialogDescription,{children:['Are you sure you want to delete "',x==null?void 0:x.name,'"? This action cannot be undone and will remove all members from the group.']})]}),e.jsxs(s.AlertDialogFooter,{children:[e.jsx(s.AlertDialogCancel,{children:"Cancel"}),e.jsx(s.AlertDialogAction,{onClick:E,disabled:b.isPending,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:b.isPending?e.jsxs(e.Fragment,{children:[e.jsx(s.LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Deleting..."]}):"Delete Group"})]})]})})]})}function Ze({group:t,onManageMembers:o,onDelete:r,currentUserId:a}){const n=t.createdBy===a;return e.jsx("div",{className:"rounded-lg border bg-card p-4 transition-colors hover:bg-muted/50",children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"font-medium",children:t.name}),t.description&&e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:t.description})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-3 text-xs text-muted-foreground",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(s.Users,{className:"h-3 w-3"}),t.memberCount," ",t.memberCount===1?"member":"members"]}),e.jsxs("span",{children:["Created ",s.format(new Date(t.createdAt),"MMM d, yyyy")]})]})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(s.Button,{variant:"ghost",size:"sm",onClick:o,title:"Manage members",children:e.jsx(s.UserPlus,{className:"h-4 w-4"})}),n&&e.jsx(s.Button,{variant:"ghost",size:"sm",onClick:r,title:"Delete group",className:"text-destructive hover:text-destructive",children:e.jsx(s.Trash2,{className:"h-4 w-4"})})]})]})})}function Ye({open:t,onOpenChange:o,isLibraryVisual:r,currentVisualName:a,isSaving:n=!1,onConfirm:d}){const[l,m]=g.useState(r&&a?`Copy of ${a}`:a||""),[c,p]=g.useState(""),[x,i]=g.useState(!r),[h,D]=g.useState(!0);g.useEffect(()=>{t&&(m(r&&a?`Copy of ${a}`:a||""),p(""),i(!r),D(!0))},[t,r,a]);const b=()=>{l.trim()&&(!x&&!h||d({name:l.trim(),description:c.trim()||void 0,saveToLibrary:x,saveToCurrentDashboard:h}))},y=l.trim()&&(x||h);return e.jsx(s.Dialog,{open:t,onOpenChange:o,children:e.jsxs(s.DialogContent,{className:"sm:max-w-[425px]",children:[e.jsxs(s.DialogHeader,{children:[e.jsx(s.DialogTitle,{children:"Save Visual As"}),e.jsx(s.DialogDescription,{children:r?"Create a copy of this visual with a new name":"Save this visual to make it reusable"})]}),e.jsxs("div",{className:"grid gap-4 py-4",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(s.Label,{htmlFor:"name",children:"Name"}),e.jsx(s.Input$1,{id:"name",value:l,onChange:S=>m(S.target.value),placeholder:"Enter visual name",disabled:n})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(s.Label,{htmlFor:"description",children:"Description (optional)"}),e.jsx(s.Textarea,{id:"description",value:c,onChange:S=>p(S.target.value),placeholder:"Enter visual description",rows:3,disabled:n})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(s.Label,{children:"Save to:"}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(s.Checkbox,{id:"save-to-dashboard",checked:h,onCheckedChange:S=>D(!!S),disabled:n}),e.jsxs("label",{htmlFor:"save-to-dashboard",className:"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",children:["Current Dashboard",e.jsx("span",{className:"ml-2 text-xs text-muted-foreground",children:r?"(add copy to this dashboard)":"(keep as local visual)"})]})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(s.Checkbox,{id:"save-to-library",checked:x,onCheckedChange:S=>i(!!S),disabled:n}),e.jsxs("label",{htmlFor:"save-to-library",className:"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",children:["Visual Library",e.jsx("span",{className:"ml-2 text-xs text-muted-foreground",children:r?"(save as new reusable visual)":"(make available to all dashboards)"})]})]})]}),!x&&!h&&e.jsx("p",{className:"text-sm text-destructive",children:"Please select at least one destination"})]})]}),e.jsxs(s.DialogFooter,{children:[e.jsx(s.Button,{variant:"outline",onClick:()=>o(!1),disabled:n,children:"Cancel"}),e.jsxs(s.Button,{onClick:b,disabled:!y||n,children:[n&&e.jsx(s.LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),n?"Saving...":"Save"]})]})]})})}function es(){const[t,o]=g.useState(!1),[r,a]=g.useState(!1),[n,d]=g.useState(null),l=s.useEditorStore(w=>w.frame),m=s.useEditorStore(w=>w.card),c=s.useSelectedVisual(),p=s.useDashboardStore(w=>w.selectedSheetId),x=s.useDashboardStore(w=>w.actions.setIsDashboardPanelOpen),{getUpdatedFrame:i}=U.useVisualUtils(),{selectVisual:h}=s.useManagementActions(),{addFrame:D,setSelectedFrameId:b,setIsVisualEditing:y}=s.useDashboardActions(),S=!!(l!=null&&l.visualId),A=(c==null?void 0:c.title)||(m==null?void 0:m.title)||"Untitled Visual",v=s.useCreateVisualWithFrame(w=>{if(w!=null&&w.id){if(h(w),r&&n&&p){const E={...n,id:s.v4(),visualId:w.id};D(p,E,"end"),b(E.id),a(!1),d(null),y(!1)}x(!0),o(!1)}});return{saveAsDialogOpen:t,setSaveAsDialogOpen:o,handleSaveAs:async w=>{if(!p){s.ue.error("No sheet selected");return}const E=i();if(w.saveToLibrary){a(w.saveToCurrentDashboard),d(E);const T={title:w.name,description:w.description,frameObject:E,isPrivate:!1};v.mutate(T)}else if(w.saveToCurrentDashboard){const T={...E,id:s.v4(),visualId:void 0,cards:E.cards.map(C=>({...C,title:C.id===m.id?w.name:C.title}))};D(p,T,"end"),b(T.id),s.ue.success("Visual saved to dashboard"),o(!1),y(!1)}},isLibraryVisual:S,currentVisualName:A,isSaving:v.isPending}}function De({className:t}){const o=s.useEditorStore(v=>v.frame),r=s.useEditorStore(v=>v.card),a=s.useManagementStore(v=>v.selectedVisual),n=s.useDashboardStore(v=>v.selectedFrameId),d=s.useDashboardStore(v=>v.selectedSheetId),{setIsVisualEditing:l}=s.useDashboardActions(),m=!!(o!=null&&o.visualId||a!=null&&a.id),c=!!(o!=null&&o.visualId&&n),p=m&&!c,{saveAsDialogOpen:x,setSaveAsDialogOpen:i,handleSaveAs:h,isLibraryVisual:D,currentVisualName:b,isSaving:y}=es(),{handleAddLibraryVisual:S}=U.useVisualUtils(),A=async()=>{if(!d){s.ue.error("No dashboard sheet selected");return}if(!a){s.ue.error("No visual selected");return}const v=await S(a);v.success?(s.ue.success("Visual added to dashboard"),l(!1)):s.ue.error(v.error||"Failed to add visual to dashboard")};return e.jsxs(e.Fragment,{children:[!m&&e.jsx(U.EditorAcceptButton,{className:t,variant:"default"}),m&&e.jsxs(e.Fragment,{children:[c&&e.jsx(U.VisualApplyLocalButton,{className:t}),p&&d&&r&&(r.sql||s.hasValidCardConfig(r.config))&&e.jsxs(s.Button,{onClick:A,className:s.cn(t),size:"sm",variant:"outline",children:[e.jsx(ye,{className:"mr-2 size-4 font-bold"}),"Add to Dashboard"]}),p&&e.jsx(U.VisualSaveButton,{className:t,variant:"default"}),c&&e.jsx(U.VisualSaveAndApplyButton,{className:t}),e.jsxs(s.DropdownMenu,{modal:!1,children:[e.jsx(s.DropdownMenuTrigger,{asChild:!0,children:e.jsx(s.Button,{variant:"outline",size:"sm",className:s.cn(t,"w-8 p-0"),children:e.jsx(s.EllipsisVertical,{className:"h-4 w-4"})})}),e.jsx(s.DropdownMenuContent,{align:"end",children:e.jsxs(s.DropdownMenuItem,{onClick:v=>{v.stopPropagation(),i(!0)},children:[e.jsx(U.Save,{className:"mr-2 h-4 w-4"}),"Save As..."]})})]})]}),!m&&e.jsxs(s.DropdownMenu,{modal:!1,children:[e.jsx(s.DropdownMenuTrigger,{asChild:!0,children:e.jsx(s.Button,{variant:"outline",size:"sm",className:s.cn(t,"w-8 p-0"),children:e.jsx(s.EllipsisVertical,{className:"h-4 w-4"})})}),e.jsx(s.DropdownMenuContent,{align:"end",children:e.jsxs(s.DropdownMenuItem,{onClick:()=>i(!0),children:[e.jsx(U.Save,{className:"mr-2 h-4 w-4"}),"Save As..."]})})]}),e.jsx(U.EditorCancelButton,{className:t}),e.jsx(Ye,{open:x,onOpenChange:v=>{y||i(v)},isLibraryVisual:D,currentVisualName:b,isSaving:y,onConfirm:h})]})}function ve({className:t,switchClassName:o}){const r=s.useEditorStore(m=>m.isDevMode),a=s.useDashboardStore(m=>m.isVisualEditing),{setIsDevMode:n}=s.useEditorActions(),{config:d}=g.useContext(s.SemaphorContext).tokenProps,l=(d==null?void 0:d.showAdvancedMode)!==!1;return!a||!l?null:e.jsxs("div",{className:s.cn("flex items-center space-x-2",t),children:[e.jsx(s.DevModeSwitch,{className:s.cn("",o),checked:r,onCheckedChange:()=>n(!r),id:"advanced-mode",icon:e.jsx(s.CodeXml,{className:"h-4 w-4"}),tooltip:"Advanced Mode"}),e.jsx("label",{htmlFor:"advanced-mode",className:"sr-only",children:"Advanced Mode"})]})}function ss(){var de,f,R;const{authToken:t,tokenProps:o,id:r}=s.useSemaphorContext(),{isLocalDev:a,isConsoleMode:n}=s.useDashboardPreferences(),{permissions:d}=s.useRoleAwareDisplayPreferences(),l=s.useHasDashboardId(),{isLoading:m}=s.useDashboardQuery();s.useDashboardStore(u=>u.theme);const c=s.useDashboardStore(u=>u.lenses),p=s.useDashboardStore(u=>u.selectedLensId),x=c==null?void 0:c.find(u=>u.id===p),i=s.useDashboardStore(u=>u.dashboard);s.useDashboardStore(u=>u.selectedSheetId);const h=s.useDashboardStore(u=>u.isDashboardEditing),{setDashboardTitle:D}=s.useDashboardStore(u=>u.actions),[b,y]=g.useState(!1),[S,A]=g.useState(!1),[v,L]=g.useState(!1),w=s.useDashboardStore(u=>u.isDashboardPanelOpen),E=s.useDashboardStore(u=>u.actions.setIsDashboardPanelOpen),T=s.useDashboardStore(u=>u.filterValues),C=s.useDashboardStore(u=>u.isVisualEditing),I=s.useEditorStore(u=>u.card),M=s.useManagementStore(u=>u.selectedDashboard),Q=s.useManagementStore(u=>u.initialDashboard),O=s.useManagementStore(u=>u.selectedVisual);s.useDashboardStore(u=>u.selectedFrameId),s.useEditorStore(u=>u.frame);const $=M?(f=M==null?void 0:M.permissions)==null?void 0:f.canEdit:(de=Q==null?void 0:Q.permissions)==null?void 0:de.canEdit,N=s.useDashboardStore(u=>u.showFilters),F=s.useDashboardStore(u=>u.showDashboardJSON),k=s.useDashboardStore(u=>u.onSaveFunction),q=s.useDashboardStore(u=>u.actions.setShowFilters),{setIsDashboardEditing:W,setShowDashboardJSON:K}=s.useDashboardStore(u=>u.actions),{setInitialDashboard:_,clearSelectedDashboard:ie}=s.useManagementStore(u=>u.actions),{resources:z}=s.useResourceManagement(s.ResourceType.DASHBOARD),{currentUser:Z}=s.useCurrentUserInfo(),Y=s.canUserManageGroups(Z),H=M||Q,re=H?{id:H.id,title:(i==null?void 0:i.title)||H.title||"Dashboard"}:null,{handleAddNewFrame:le}=s.useAddNewFrame(),[ee,se]=g.useState(!1),j=s.useUpdateResource(s.ResourceType.DASHBOARD),B=async(u,V)=>{if(!(i!=null&&i.id)){console.log("No dashboard ID found");return}console.log("Updating dashboard title:",{dashboardId:i.id,newTitle:u,previousTitle:V}),j.mutate({resourceId:i.id,data:{title:u}},{onSuccess:()=>{console.log("Dashboard title updated successfully"),s.ue.success("Dashboard title updated")},onError:X=>{console.error("Failed to update dashboard title:",X),s.ue.error("Failed to update dashboard title"),D(V)}})};g.useEffect(()=>{if(z&&z.length>0){const u=i==null?void 0:i.id;if(u){const V=z.find(X=>X.id===u);V&&_(V)}}},[z,i==null?void 0:i.id,_]);const P=o.orgUserId||o.tenantId,J=h&&!C&&P&&$,ne=()=>{W(!0)};async function te(){const u=ce(i);se(!0);const V={template:u};j.mutate({resourceId:u.id,data:V},{onSuccess:()=>{se(!1),s.ue.success("Dashboard saved!")},onError:()=>{se(!1),s.ue.error("Failed to save dashboard")}})}async function oe(){if(y(!0),!p||!x)return;const u=ce(i),V=JSON.stringify(u),X={...x,template:V,filterValues:T};await xe(o.apiServiceUrl,X,t==null?void 0:t.accessToken),s.ue.success("Lens saved"),k==null||k(u),y(!1)}const G=(x==null?void 0:x.name)||i.title;j.isPending&&console.log("Title during update:",{title:G,dashboardStateTitle:i.title,dashboardId:i==null?void 0:i.id,currentLensName:x==null?void 0:x.name});const ue=z&&z.length>0&&(o.orgUserId||o.tenantId&&o.endUserId&&o.endUserEmail),he=M&&!(o!=null&&o.dashboard_id)&&!r;return e.jsxs("div",{className:"flex h-11 items-center justify-between gap-2 border-b px-4 py-2",role:"dashboard-controls",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[ue&&e.jsxs(e.Fragment,{children:[e.jsx(s.IconButton,{"aria-label":"Manage Dashboards",tooltip:"Manage Dashboards",onClick:()=>{E(!w)},className:"h-7 p-2",children:e.jsx(Me,{className:"h-4 w-4"})}),he&&!C&&e.jsx(s.IconButton,{"aria-label":"Dashboard Hub",tooltip:"Dashboard Hub",onClick:()=>ie(),className:"h-7 p-2",children:e.jsx(s.House,{className:"h-4 w-4"})})]}),!C&&l&&(m?e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(s.LoaderCircle,{className:"h-3 w-3 animate-spin text-muted-foreground"}),e.jsx("span",{className:"text-sm text-muted-foreground",children:"Loading..."})]}):e.jsx(s.EditableText,{value:G||"Untitled Dashboard",onSave:u=>{console.log("EditableText onSave called:",{newTitle:u,canEditDashboard:$,dashboardId:i==null?void 0:i.id});const V=(i==null?void 0:i.title)||"";D(u),B(u,V)},isEditable:$&&!x,displayClassName:"text-sm font-medium",inputClassName:"text-sm font-medium",placeholder:"Dashboard Title",isPending:j.isPending})),C&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(s.Label,{className:"text-sm font-medium",children:(O==null?void 0:O.title)||(I==null?void 0:I.title)||"Untitled Visual"}),e.jsx(be,{})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[C&&e.jsxs(e.Fragment,{children:[e.jsx(ve,{className:"mr-2"}),e.jsx(De,{className:"h-7"})]}),a&&!C&&e.jsx(s.IconButton,{tooltip:"Invalidate Token",onClick:()=>s.invalidateToken(o.apiServiceUrl),className:"h-7 p-2",children:e.jsx(Ae,{className:"h-4 w-4"})}),!C&&l&&e.jsx(Ve,{}),!C&&l&&e.jsx(je,{}),!C&&l&&Y&&e.jsx(s.IconButton,{tooltip:"Manage Groups",onClick:()=>L(!0),className:"h-7 p-2",children:e.jsx(s.Users,{className:"h-4 w-4"})}),!C&&l&&((R=H==null?void 0:H.permissions)==null?void 0:R.canShare)&&e.jsx(s.IconButton,{tooltip:"Share Dashboard",onClick:()=>A(!0),className:"h-7 p-2",children:e.jsx(s.Share2,{className:"h-4 w-4"})}),!N&&!C&&h&&d.canUseFilters&&l&&e.jsx(s.Button,{className:"h-7 p-2",variant:"outline",onClick:()=>q(!0),size:"sm",children:e.jsx(s.Filter,{className:"h-4 w-4"})}),h&&!C&&P&&a&&l&&e.jsx(Oe,{}),!C&&P&&a&&l&&e.jsx(Ue,{}),h&&!C&&P&&x&&a&&l&&e.jsxs(s.Button,{className:"h-7 p-2",variant:"secondary",disabled:b,onClick:oe,size:"sm",children:[e.jsx(U.Save,{className:"mr-2 h-4 w-4"}),"Save Lens"]}),h&&!C&&l&&e.jsxs(s.Button,{variant:"outline",className:"h-7 p-2",size:"sm",disabled:!h,onClick:()=>le(),children:[e.jsx(s.Plus,{className:"mr-2 h-4 w-4"}),"Visual"]}),!C&&!h&&d.canEdit&&l&&e.jsxs(s.Button,{variant:"outline",className:"h-7 p-2",onClick:ne,size:"sm",children:[e.jsx(s.Pencil,{className:"mr-2 h-4 w-4"}),"Edit"]}),J&&l&&e.jsxs(s.Button,{className:"h-7 p-2",disabled:ee,onClick:te,size:"sm",children:[ee?e.jsx(s.LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}):e.jsx(U.Save,{className:"mr-2 h-4 w-4"}),ee?"Saving...":"Save"]}),!C&&h&&a&&l&&e.jsx("div",{className:"flex items-center space-x-2",children:e.jsx(s.Button,{className:"h-7 p-2",onClick:()=>K(!F),size:"sm",variant:"ghost",children:e.jsx(s.Code,{className:"h-4 w-4"})})}),!C&&a&&e.jsx(Le,{}),h&&!C&&l&&e.jsxs(s.Button,{variant:"outline",className:"h-7 p-2",onClick:()=>{W(!1),K(!1)},children:[e.jsx(s.Cross2Icon,{className:"mr-2 h-4 w-4"}),"Close"]}),S&&re&&e.jsx(s.ShareDialog,{resource:re,resourceType:s.ResourceType.DASHBOARD,onClose:()=>A(!1)}),e.jsx(Xe,{open:v,onOpenChange:L})]})]})}function ts(){U.useSyncLegacyEditorState();const t=s.useDashboardStore(c=>c.selectedSheetId),o=s.useDashboardStore(c=>c.selectedFrameId),r=s.useDashboardStore(c=>c.dashboard),a=s.useDashboardStore(c=>c.actions.getSelectedFrame),{setSelectedFrameId:n}=s.useDashboardActions(),{setCard:d}=s.useEditorActions(),l=s.useEditorStore(c=>c.card.dataSource);return g.useEffect(()=>{var p,x;let c=a();if(!c){const i=(p=r==null?void 0:r.sheets)==null?void 0:p.find(D=>D.id===t),h=(x=i==null?void 0:i.frames)==null?void 0:x[0];h&&(n(h.id),c=h)}if(c){const i=c.cards.find(h=>h.id===c.activeCardId);i&&d(i)}},[a,t,o,r,n,d]),{hasEntities:!!(l!=null&&l.selectedEntities&&l.selectedEntities.length>0)}}function as(){const t=s.useDashboardStore(r=>r.actions.setShowFilters),{hasEntities:o}=ts();return e.jsxs("section",{className:"relative flex min-w-[320px] grow flex-col border-l",children:[e.jsxs("div",{className:"mt-4 flex items-center justify-between gap-2 px-4",children:[e.jsx(s.Label,{className:"px-2 text-base",children:"Dashboard Filters"}),e.jsx(s.Button,{onClick:()=>t(!1),className:"h-7 w-7 p-0",variant:"ghost",children:e.jsx(s.Cross2Icon,{})})]}),!o&&e.jsxs("div",{className:"flex h-full flex-col items-center justify-center px-6 py-12 text-center",children:[e.jsx(s.Database,{className:"mb-4 h-12 w-12 text-muted-foreground/50"}),e.jsx("h3",{className:"mb-2 text-sm font-medium text-foreground",children:"No fields configured"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Please configure a data source for this card to enable filtering"})]}),o&&e.jsx("div",{className:"flex grow",children:e.jsx(s.DndContext,{collisionDetection:s.closestCenter,children:e.jsx(s.SortableContext,{items:[],strategy:s.verticalListSortingStrategy,children:e.jsx(U.FieldsSection,{context:"filter"})})})})]})}function rs(){const t=s.useDashboardStore(a=>a.dashboard.filters),o=s.useDashboardStore(a=>a.theme),r=t==null?void 0:t.filter(a=>a.hide);return r!=null&&r.length?e.jsx("div",{className:s.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)]":o==="light","bg-[repeating-linear-gradient(45deg,_#18171d_0_3px,_#272729_3px_6px)]":o==="dark"}),children:r==null?void 0:r.map(a=>e.jsxs("div",{className:"flex min-w-[250px] max-w-fit flex-col gap-1 p-2",children:[e.jsx(s.FilterHeader,{filter:a}),e.jsx(s.FilterComponent,{filter:a})]},a.id))}):null}function ns(){const t=s.useDashboardStore(a=>a.showFilters),o=s.useDashboardStore(a=>a.isVisualEditing),r=s.useDashboardStore(a=>a.isDashboardEditing);return e.jsxs("div",{role:"dashboard-plus-main",className:s.cn("",{"max-h-0 overflow-hidden":o,"flex grow overflow-auto":!o}),children:[e.jsxs("section",{className:"flex grow flex-col",children:[r&&e.jsx(rs,{}),e.jsx(s.DashboardTabs,{})]}),t&&e.jsx("div",{role:"filter-aside-container",className:"flex",children:e.jsx(as,{})})]})}function Ne(){return e.jsx(s.ScrollArea,{className:"w-full flex-1",children:e.jsxs("div",{className:"space-y-4 px-4 py-2",children:[e.jsx("div",{className:"h-9 w-full rounded bg-muted animate-pulse"}),e.jsx("div",{className:"h-9 w-full rounded bg-muted animate-pulse"}),e.jsx("div",{className:"space-y-3 pt-2",children:[...Array(3)].map((t,o)=>e.jsxs("div",{className:"flex gap-3 animate-pulse",children:[e.jsx("div",{className:"h-8 w-8 rounded bg-muted flex-shrink-0"}),e.jsxs("div",{className:"flex-1 space-y-1.5",children:[e.jsx("div",{className:"h-4 w-2/3 rounded bg-muted"}),e.jsx("div",{className:"h-3 w-4/5 rounded bg-muted"})]})]},o))})]})})}const os=t=>{const o=s.useDashboardStore(n=>n.isVisualEditing),r=s.useDashboardStore(n=>n.selectedFrameId),a=s.useEditorStore(n=>n.frame);return!!(o&&r&&(a==null?void 0:a.visualId)===t)};function is({visual:t,isDeleting:o,isDuplicating:r,onAddVisual:a,onOpenVisual:n,onEditDetails:d,onDeleteClick:l,onDuplicateVisual:m,onShareVisual:c,formatDate:p}){var E,T,C,I;const{selectVisual:x}=s.useManagementActions(),i=s.useIsVisualSelected(t.id),h=os(t.id),{isConsoleMode:D}=s.useDashboardPreferences(),b=g.useRef(null),[y,S]=g.useState(!1),[A,v]=g.useState(!1);g.useEffect(()=>{r?(S(!0),v(!0)):A&&(S(!1),v(!1))},[r,A]),g.useEffect(()=>{h&&b.current&&b.current.scrollIntoView({behavior:"smooth",block:"center"})},[h]);const L=()=>e.jsx(s.Grid3x3,{className:"h-4 w-4"}),w=()=>{x(t),n==null||n(t)};return e.jsx(s.Card,{ref:b,className:s.cn("group cursor-pointer border border-border/50 p-3 transition-colors hover:bg-accent/50",h?"border-purple-500":i&&"border-primary"),onClick:w,children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"mt-0.5 rounded bg-muted p-1.5",children:L()}),e.jsxs("div",{className:"min-w-0 flex-1 flex flex-col",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("p",{className:"text-sm font-medium text-foreground truncate",title:t.title||"Untitled Visual",children:t.title||"Untitled Visual"}),t.ownership.status==="shared"&&e.jsxs(s.Badge,{variant:"outline",className:"text-xs",children:[e.jsx(s.Users,{className:"mr-1 h-2.5 w-2.5"}),"Shared"]})]}),e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("p",{className:"text-xs text-muted-foreground line-clamp-2 flex-1",title:t.description||"No description",children:(E=t.description)!=null&&E.trim()?t.description:"No description"}),e.jsxs("div",{className:s.cn("invisible flex flex-shrink-0 items-center gap-1 transition-opacity duration-150 group-hover:visible",i&&"visible"),onClick:M=>M.stopPropagation(),children:[e.jsx(s.Button,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0",onClick:M=>{M.stopPropagation(),a(t)},title:"Add to dashboard",children:e.jsx(s.Plus,{className:"h-3.5 w-3.5"})}),t.ownership.isOwner&&e.jsx(s.Button,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0",onClick:M=>{M.stopPropagation(),d==null||d(t)},title:"Edit details",children:e.jsx(s.PenLine,{className:"h-3 w-3"})}),e.jsxs(s.DropdownMenu,{modal:!1,open:y,onOpenChange:S,children:[e.jsx(s.DropdownMenuTrigger,{asChild:!0,children:e.jsx(s.Button,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0",children:e.jsx(s.Ellipsis,{className:"h-3 w-3"})})}),e.jsxs(s.DropdownMenuContent,{align:"end",className:"z-[51] w-40",children:[e.jsxs(s.DropdownMenuItem,{onClick:M=>{M.stopPropagation(),a(t)},children:[e.jsx(s.Plus,{className:"mr-2 h-3 w-3"}),"Add"]}),e.jsxs(s.DropdownMenuItem,{onClick:M=>{M.stopPropagation(),n==null||n(t)},children:[e.jsx(Se,{className:"mr-2 h-3 w-3"}),"Open"]}),e.jsxs(s.DropdownMenuItem,{onClick:M=>{M.preventDefault(),M.stopPropagation(),m(t.id)},disabled:r,children:[r?e.jsx(s.LoaderCircle,{className:"mr-2 h-3 w-3 animate-spin"}):e.jsx(s.Copy,{className:"mr-2 h-3 w-3"}),r?"Duplicating...":"Duplicate"]}),t.ownership.isOwner&&e.jsxs(e.Fragment,{children:[e.jsxs(s.DropdownMenuItem,{onClick:M=>{M.stopPropagation(),d==null||d(t)},children:[e.jsx(s.PenLine,{className:"mr-2 h-3 w-3"}),"Edit details"]}),e.jsxs(s.DropdownMenuItem,{onClick:M=>{M.stopPropagation(),c(t)},children:[e.jsx(s.Users,{className:"mr-2 h-3 w-3"}),"Share"]}),e.jsx(s.DropdownMenuSeparator,{}),e.jsxs(s.DropdownMenuItem,{onClick:M=>{M.stopPropagation(),l(t)},className:"text-destructive",disabled:o,children:[e.jsx(s.Trash2,{className:"mr-2 h-3 w-3"}),o?"Deleting...":"Delete"]})]}),e.jsx(s.DropdownMenuSeparator,{}),e.jsxs("div",{className:"space-y-1 px-2 py-2 text-xs text-slate-500 dark:text-slate-400",children:[(((T=t.ownership.createdBy)==null?void 0:T.type)==="tenant"||((C=t.ownership.createdBy)==null?void 0:C.type)==="organization"&&D)&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(s.User,{className:"h-3 w-3"}),e.jsx("span",{children:((I=t.ownership.createdBy)==null?void 0:I.name)||"Unknown"})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(s.Calendar,{className:"h-3 w-3"}),e.jsx("span",{children:p(t.lastModified)})]})]})]})]})]})]})]})]})},t.id)}function ls({open:t,onOpenChange:o,onSubmit:r,isCreating:a}){const[n,d]=g.useState(""),[l,m]=g.useState("");g.useEffect(()=>{t||(d(""),m(""))},[t]);const c=()=>{n.trim()&&r({title:n,description:l})},p=x=>{o(x)};return e.jsx(s.Dialog,{open:t,onOpenChange:p,children:e.jsxs(s.DialogContent,{children:[e.jsxs(s.DialogHeader,{children:[e.jsx(s.DialogTitle,{children:"Create New Visual"}),e.jsx(s.DialogDescription,{children:"Add a new visual to your library. You can configure it after creation."})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(s.Label,{htmlFor:"title",children:"Visual Title"}),e.jsx(s.Input$1,{id:"title",placeholder:"Enter visual title...",value:n,onChange:x=>d(x.target.value),disabled:a,onKeyDown:x=>{x.key==="Enter"&&!x.shiftKey&&(x.preventDefault(),c())}})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(s.Label,{htmlFor:"description",children:"Description (optional)"}),e.jsx(s.Input$1,{id:"description",placeholder:"Enter visual description...",value:l,onChange:x=>m(x.target.value),disabled:a})]})]}),e.jsxs(s.DialogFooter,{children:[e.jsx(s.Button,{variant:"outline",onClick:()=>p(!1),disabled:a,children:"Cancel"}),e.jsx(s.Button,{onClick:c,disabled:!n.trim()||a,children:a?e.jsxs(e.Fragment,{children:[e.jsx(s.LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Creating..."]}):"Create Visual"})]})]})})}function ds(){const[t,o]=g.useState(""),[r,a]=g.useState(!1),[n,d]=g.useState(!1),[l,m]=g.useState(null),[c,p]=g.useState(!1),[x,i]=g.useState(null),[h,D]=g.useState(null),[b,y]=g.useState(null),{selectVisual:S}=s.useManagementActions(),{handleEditLibraryVisual:A,handleAddLibraryVisual:v}=U.useVisualUtils(),{resources:L,isLoading:w,isError:E,createResource:T,updateResource:C,deleteResource:I,duplicateResource:M,isCreating:Q,isDeleting:O}=s.useVisualManagement(()=>{p(!1),i(null)},j=>{a(!1),j&&(S(j),A(j))});s.useCurrentUserInfo();const $=L.filter(j=>{var B,P;return((B=j==null?void 0:j.title)==null?void 0:B.toLowerCase().includes(t.toLowerCase()))||((P=j==null?void 0:j.description)==null?void 0:P.toLowerCase().includes(t.toLowerCase()))}),N=j=>new Date(j).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}),F=j=>{T({title:j.title,description:j.description,isPrivate:!1})},k=j=>{i(j),p(!0)},q=()=>{x&&I(x.id)},{startUpdating:W,stopUpdating:K,isUpdating:_}=s.useResourceUpdateState(),ie=(j,B,P)=>{var oe;const J=Object.fromEntries(Object.entries(B).filter(([,G])=>G!==void 0));if(Object.keys(J).length===0){(oe=P==null?void 0:P.onSuccess)==null||oe.call(P);return}const ne=Object.keys(J),te=ne.length===1?ne[0]:void 0;W(j,te),C({resourceId:j,data:J},{onSuccess:()=>{var G;K(j,te),(G=P==null?void 0:P.onSuccess)==null||G.call(P)},onError:()=>{var G;K(j,te),(G=P==null?void 0:P.onError)==null||G.call(P)}})},z=j=>{D(j),M(j,{onSettled:()=>D(null)})},Z=j=>{A(j)},Y=j=>{v(j)},H=j=>{const B=L.find(P=>P.id===j);B&&C({resourceId:j,data:{isPrivate:!B.isPrivate}})},re=j=>{m(j),d(!0)},le=j=>{y(j)},ee=()=>{y(null)},se=({title:j,description:B})=>{if(!b)return;const P={};j!==b.title&&(P.title=j),(b.description||"")!==B&&(P.description=B),ie(b.id,P,{onSuccess:()=>{y(null)}})};return w?e.jsx(Ne,{}):E?e.jsx(s.ScrollArea,{className:"w-full flex-1 pr-2",children:e.jsxs("div",{className:"py-8 text-center text-muted-foreground",children:[e.jsx("p",{className:"text-sm text-destructive",children:"Failed to load visuals"}),e.jsx(s.Button,{variant:"outline",size:"sm",className:"mt-2",onClick:()=>window.location.reload(),children:"Retry"})]})}):e.jsxs("div",{className:"relative flex h-full flex-1 flex-col gap-4",children:[L&&L.length>5&&e.jsx("div",{className:"space-y-2",children:e.jsx(s.Input$1,{id:"search",placeholder:"Search by title or description...",value:t,onChange:j=>o(j.target.value),className:"h-9"})}),e.jsx("div",{className:"flex flex-1 flex-col",children:e.jsx("div",{className:"flex flex-1 basis-0 flex-col gap-3 overflow-y-auto",children:$.length===0?e.jsxs("div",{className:"py-8 text-center",children:[e.jsx("div",{className:"mb-3",children:e.jsx(s.Grid3x3,{className:"mx-auto h-12 w-12 text-muted-foreground/50"})}),e.jsx("h3",{className:"mb-1 font-medium text-foreground",children:t?"No visuals found":"No visuals yet"}),e.jsx("p",{className:"mb-4 text-sm text-muted-foreground",children:t?"Try adjusting your search":"Create your first visual component to get started"}),!t&&e.jsxs(s.Button,{size:"sm",className:"bg-primary hover:bg-primary/90",onClick:()=>a(!0),children:[e.jsx(s.Plus,{className:"mr-2 h-4 w-4"}),"Create Visual"]})]}):$.map(j=>e.jsx(is,{visual:j,onAddVisual:Y,onOpenVisual:Z,onEditDetails:le,onDeleteClick:k,onDuplicateVisual:z,onTogglePrivacy:H,onShareVisual:re,isDeleting:O,isDuplicating:h===j.id,formatDate:N},j.id))})}),n&&l&&e.jsx(s.ShareDialog,{resource:l,resourceType:s.ResourceType.VISUAL,onClose:()=>{d(!1),m(null)}}),b&&e.jsx(s.ResourceEditDialog,{open:!!b,resourceLabel:"Visual",initialTitle:b.title||"",initialDescription:b.description||"",onClose:ee,onSave:se,isSaving:_(b.id)}),e.jsx(s.AlertDialog,{open:c,onOpenChange:j=>{!j&&O||(p(j),j||i(null))},children:e.jsxs(s.AlertDialogContent,{children:[e.jsxs(s.AlertDialogHeader,{children:[e.jsx(s.AlertDialogTitle,{children:"Delete Visual"}),e.jsxs(s.AlertDialogDescription,{children:['Are you sure you want to delete "',x==null?void 0:x.title,'"? This action cannot be undone.']})]}),e.jsxs(s.AlertDialogFooter,{children:[e.jsx(s.AlertDialogCancel,{disabled:O,children:"Cancel"}),e.jsxs(s.AlertDialogAction,{onClick:j=>{j.preventDefault(),j.stopPropagation(),q()},className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",disabled:O,children:[O?e.jsx(s.LoaderCircle,{className:"mr-2 h-3.5 w-3.5 animate-spin"}):e.jsx(s.Trash2,{className:"mr-2 h-3.5 w-3.5"}),O?"Deleting...":"Delete"]})]})]})}),e.jsx(ls,{open:r,onOpenChange:a,onSubmit:F,isCreating:Q}),e.jsx(s.Button,{size:"icon",className:"absolute bottom-2 left-2 h-11 w-11 rounded-full shadow-lg shadow-black/15",onClick:()=>a(!0),"aria-label":"Create visual",children:e.jsx(s.Plus,{className:"h-5 w-5"})})]})}function cs({dashboard:t,isDeleting:o,isDuplicating:r,onLoadDashboard:a,onEditDetails:n,onDeleteClick:d,onDuplicateDashboard:l,onShareDashboard:m,formatDate:c,onDashboardItemClick:p}){var v,L;const{selectDashboard:x}=s.useManagementActions(),i=s.useIsDashboardSelected(t.id),{userContext:h,isLoading:D}=s.useCurrentUserInfo(),b=((v=h==null?void 0:h.permissions)==null?void 0:v.canEdit)??!1,y=D||!b,S=()=>e.jsx(s.LayoutDashboard,{className:"h-4 w-4"}),A=()=>{x(t),a(t.id),p==null||p(t.id)};return e.jsx(s.Card,{className:s.cn("group cursor-pointer border border-border/50 p-3 transition-colors hover:bg-accent/50",i&&"border-primary"),onClick:A,children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"mt-0.5 rounded bg-muted p-1.5",children:S()}),e.jsxs("div",{className:"min-w-0 flex-1 flex flex-col",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("p",{className:"text-sm font-medium text-foreground truncate",title:t.title||"Untitled Dashboard",children:t.title||"Untitled Dashboard"}),t.ownership.status==="shared"&&e.jsxs(s.Badge,{variant:"outline",className:"text-xs",children:[e.jsx(s.Users,{className:"mr-1 h-2.5 w-2.5"}),"Shared"]})]}),e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("p",{className:"text-xs text-muted-foreground line-clamp-2 flex-1",title:t.description||"No description",children:(L=t.description)!=null&&L.trim()?t.description:"No description"}),e.jsx(s.DashboardActionsMenu,{dashboard:t,isDeleting:o,isDuplicating:r,shouldHideActions:y,onEditDetails:n,onDeleteClick:d,onDuplicateDashboard:l,onShareDashboard:m,formatDate:c})]})]})]})},t.id)}function us({onRetry:t}){return e.jsx(s.ScrollArea,{className:"w-full flex-1 pr-2",children:e.jsxs("div",{className:"py-8 text-center text-muted-foreground",children:[e.jsx("p",{className:"text-sm text-destructive",children:"Failed to load dashboards"}),e.jsx(s.Button,{variant:"outline",size:"sm",className:"mt-2",onClick:t,children:"Retry"})]})})}function hs(t){var de;const{onLoadDashboard:o,onEditDashboard:r,onDashboardItemClick:a}=t,[n,d]=g.useState(""),[l,m]=g.useState(!1),[c,p]=g.useState(!1),[x,i]=g.useState(null),[h,D]=g.useState(!1),[b,y]=g.useState(null),[S,A]=g.useState(null),[v,L]=g.useState(null),w=s.useManagementStore(f=>f.lastSelectedDashboard),E=s.useManagementStore(f=>f.selectedDashboard),T=s.useManagementStore(f=>f.actions.selectDashboard),C=s.useManagementStore(f=>f.actions.clearSelectedDashboard),{tokenProps:I,id:M}=s.useSemaphorContext();s.useRoleAwareDisplayPreferences();const{onCreateSuccess:Q}=s.useDashboardCreation({onDashboardSelect:a}),{resources:O,isLoading:$,isError:N,createResource:F,updateResource:k,deleteResource:q,duplicateResource:W,isCreating:K,isDeleting:_,refetch:ie}=s.useDashboardManagement(()=>{D(!1);const f=b==null?void 0:b.id;y(null),(E==null?void 0:E.id)===f&&(!(I!=null&&I.dashboard_id)&&!M?C():w&&w.id!==f&&T(w))},f=>{m(!1),Q(f,ie)}),{currentUser:z,userContext:Z}=s.useCurrentUserInfo(),Y=((de=Z==null?void 0:Z.permissions)==null?void 0:de.canCreateDashboard)??!1,H=O.filter(f=>{var R,u;return((R=f==null?void 0:f.title)==null?void 0:R.toLowerCase().includes(n.toLowerCase()))||((u=f==null?void 0:f.description)==null?void 0:u.toLowerCase().includes(n.toLowerCase()))}),re=f=>new Date(f).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}),le=f=>{F({title:f.title,description:f.description,isPrivate:!1})},ee=f=>{o==null||o(f)},se=f=>{y(f),D(!0)},j=()=>{b&&q(b.id)},B=f=>{A(f),W(f,{onSettled:()=>A(null)})},{startUpdating:P,stopUpdating:J,isUpdating:ne}=s.useResourceUpdateState(),te=(f,R,u)=>{var ge;const V=Object.fromEntries(Object.entries(R).filter(([,ae])=>ae!==void 0));if(Object.keys(V).length===0){(ge=u==null?void 0:u.onSuccess)==null||ge.call(u);return}const X=Object.keys(V),me=X.length===1?X[0]:void 0;P(f,me),k({resourceId:f,data:V},{onSuccess:()=>{var ae;J(f,me),(ae=u==null?void 0:u.onSuccess)==null||ae.call(u)},onError:()=>{var ae;J(f,me),(ae=u==null?void 0:u.onError)==null||ae.call(u)}})},oe=f=>{const R=O.find(u=>u.id===f);R&&k({resourceId:f,data:{isPrivate:!R.isPrivate}})},G=f=>{i(f),z==null||z.type,p(!0)},pe=f=>{r==null||r(f.id),L(f)},ue=()=>{L(null)},he=({title:f,description:R})=>{if(!v)return;const u={};f!==v.title&&(u.title=f),(v.description||"")!==R&&(u.description=R),te(v.id,u,{onSuccess:()=>{L(null)}})};return $?e.jsx(Ne,{}):N?e.jsx(us,{onRetry:()=>window.location.reload()}):e.jsxs("div",{className:"relative flex h-full flex-1 flex-col gap-4",children:[O&&O.length>5&&e.jsx("div",{className:"space-y-2",children:e.jsx(s.Input$1,{id:"search",placeholder:"Search by title or description...",value:n,onChange:f=>d(f.target.value),className:"h-9"})}),e.jsx("div",{className:"flex flex-1 flex-col",children:e.jsx("div",{className:"flex flex-1 basis-0 flex-col gap-3 overflow-y-auto",children:H.length===0?e.jsxs("div",{className:"py-8 text-center",children:[e.jsx("div",{className:"mb-3",children:e.jsx(s.ChartColumn,{className:"mx-auto h-12 w-12 text-muted-foreground/50"})}),e.jsx("h3",{className:"mb-1 font-medium text-foreground",children:n?"No dashboards found":"No dashboards yet"}),e.jsx("p",{className:"mb-4 text-sm text-muted-foreground",children:n?"Try adjusting your search":Y?"Create your first dashboard to get started":"No dashboards have been shared with you yet"}),Y&&!n&&e.jsxs(s.Button,{size:"sm",className:"bg-primary hover:bg-primary/90",onClick:()=>m(!0),children:[e.jsx(s.Plus,{className:"mr-2 h-4 w-4"}),"Create Dashboard"]})]}):H.map(f=>e.jsx(cs,{dashboard:f,isDeleting:_,isDuplicating:S===f.id,onLoadDashboard:ee,onEditDetails:pe,onDeleteClick:se,onDuplicateDashboard:B,onTogglePrivacy:oe,onShareDashboard:G,formatDate:re,onDashboardItemClick:a},f.id))})}),c&&x&&e.jsx(s.ShareDialog,{resource:x,resourceType:s.ResourceType.DASHBOARD,onClose:()=>{p(!1),i(null)}}),e.jsx(s.AlertDialog,{open:h,onOpenChange:f=>{!f&&_||(D(f),f||y(null))},children:e.jsxs(s.AlertDialogContent,{children:[e.jsxs(s.AlertDialogHeader,{children:[e.jsx(s.AlertDialogTitle,{children:"Delete Dashboard"}),e.jsxs(s.AlertDialogDescription,{children:['Are you sure you want to delete "',b==null?void 0:b.title,'"? This action cannot be undone.']})]}),e.jsxs(s.AlertDialogFooter,{children:[e.jsx(s.AlertDialogCancel,{disabled:_,children:"Cancel"}),e.jsxs(s.AlertDialogAction,{onClick:f=>{f.preventDefault(),f.stopPropagation(),j()},className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",disabled:_,children:[_?e.jsx(s.LoaderCircle,{className:"mr-2 h-3.5 w-3.5 animate-spin"}):e.jsx(s.Trash2,{className:"mr-2 h-3.5 w-3.5"}),_?"Deleting...":"Delete"]})]})]})}),v&&e.jsx(s.ResourceEditDialog,{open:!!v,resourceLabel:"Dashboard",initialTitle:v.title||"",initialDescription:v.description||"",onClose:ue,onSave:he,isSaving:ne(v.id)}),e.jsx(s.CreateDashboardDialog,{open:l,onOpenChange:m,onSubmit:le,isCreating:K}),Y&&e.jsx(s.Button,{size:"icon",className:"absolute bottom-2 left-2 h-11 w-11 rounded-full shadow-lg shadow-black/15",onClick:()=>m(!0),"aria-label":"Create dashboard",children:e.jsx(s.Plus,{className:"h-5 w-5"})})]})}function we({isOpen:t,onClose:o,className:r,onDashboardItemClick:a,variant:n="inline"}){s.useDashboardStore(T=>T.dashboard);const d=s.useDashboardStore(T=>T.isDashboardEditing),{setDashboard:l,addSheet:m}=s.useDashboardStore(T=>T.actions),{currentUser:c}=s.useCurrentUserInfo(),p=c,{permissions:x}=s.useRoleAwareDisplayPreferences(),h=s.useSelectedDashboard()&&x.canAccessVisuals&&d,D="dashboards",[b,y]=U.useLocalStorageState("resource-management-active-tab",D),S=h?b:"dashboards",A=n==="overlay",v=U.useClickOutside(o,{enabled:t&&A}),L=s.cn("flex h-full flex-col border-r bg-background",A?s.cn("absolute inset-y-0 left-0 z-[51] w-96 shadow-lg transition-transform duration-300 ease-in-out",t?"translate-x-0":"pointer-events-none -translate-x-full"):"w-full max-w-[28rem] min-w-[18rem] overflow-hidden shadow-sm",r),w=T=>{},E=T=>{console.log("Editing dashboard:",T)};return e.jsx(s.TooltipProvider,{children:(!A||t)&&e.jsxs("div",{ref:v,className:L,children:[e.jsxs("div",{className:"flex items-center justify-between border-b border-border p-4",children:[e.jsx("div",{className:"flex items-center gap-2",children:p&&e.jsxs(e.Fragment,{children:[e.jsxs(s.Tooltip,{children:[e.jsx(s.TooltipTrigger,{asChild:!0,children:e.jsx("div",{className:"flex h-8 w-8 cursor-default items-center justify-center rounded-full bg-primary/10",children:e.jsx("span",{className:"text-sm font-medium text-primary",children:p.name.charAt(0).toUpperCase()})})}),e.jsx(s.TooltipContent,{side:"bottom",className:"ml-2 max-w-xs",children:e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"font-medium",children:p.name}),e.jsx("div",{className:"text-xs text-muted-foreground",children:p.email}),p.role&&e.jsxs("div",{className:"text-xs text-muted-foreground",children:["Role:"," ",s.toTitleCase(p.role.replace(/_/g," "))]}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:["ID: ",p.id]})]})})]}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx("span",{className:"text-sm font-medium text-foreground",children:p.name})})]})}),e.jsx(s.IconButton,{className:"h-8 w-8 p-0 text-muted-foreground hover:text-foreground",onClick:o,tooltip:"Close Sidebar",children:e.jsx(Pe,{className:"h-4 w-4"})})]}),e.jsx("div",{className:"flex flex-1 flex-col overflow-hidden",children:e.jsxs(s.Tabs,{value:S,onValueChange:h?y:void 0,className:"flex h-9 grow flex-col",children:[h&&e.jsx("div",{className:"px-4 pt-4",children:e.jsxs(s.TabsList,{className:"grid w-full grid-cols-2",children:[e.jsx(s.TabsTrigger,{value:"dashboards",className:"text-sm",children:"Dashboards"}),e.jsx(s.TabsTrigger,{value:"visuals",className:"text-sm",children:"Visuals"})]})}),e.jsx(s.TabsContent,{value:"dashboards",className:"flex-1 px-4 py-4",children:e.jsx(hs,{onLoadDashboard:w,onEditDashboard:E,onDashboardItemClick:a})}),h&&e.jsx(s.TabsContent,{value:"visuals",className:"flex-1 px-4 py-4",children:e.jsx(ds,{})})]})})]})})}function ms({showControls:t=!1,showFooter:o=!0,...r}){const a=s.useDashboardStore(h=>h.isDashboardPanelOpen);s.useDashboardStore(h=>h.isVisualEditing);const n=s.useDashboardStore(h=>h.actions.setIsDashboardPanelOpen),d=20,l=20,m=30,c=a,p=g.useRef(null),x=g.useRef(null);g.useEffect(()=>{p.current&&x.current&&(a?(p.current.resize(d),x.current.resize(100-d)):(p.current.resize(0),x.current.resize(100)))},[a]);const{preferences:i}=r;return e.jsx(s.ErrorBoundary,{FallbackComponent:s.Fallback,children:e.jsxs(s.SemaphorContextProvider,{dashboardProps:r,children:[e.jsx(s.$e,{}),e.jsx(s.UXProvider,{children:e.jsxs(s.DashboardPreferencesProvider,{preferences:i,children:[e.jsx(s.DashboardJSON,{}),e.jsxs("main",{className:"relative flex h-full w-full flex-col",children:[t&&e.jsx(ss,{}),e.jsxs(s.ResizablePanelGroup,{direction:"horizontal",className:"flex grow overflow-hidden",children:[e.jsx(s.ResizablePanel,{ref:p,className:s.cn("flex h-full max-w-[26rem] overflow-hidden",{"min-w-[20rem]":c}),defaultSize:c?d:0,minSize:c?l:0,maxSize:c?m:0,children:e.jsx(we,{isOpen:a,onClose:()=>n(!1),variant:"inline"})}),e.jsx(s.ResizableHandle,{className:s.cn("",{"w-0":!c})}),e.jsx(s.ResizablePanel,{ref:x,className:"flex min-w-0 flex-1",defaultSize:c?100-d:100,minSize:c?40:100,children:e.jsxs(s.Container,{...r,type:"dashboard",children:[e.jsx(s.EditDashboardVisual,{}),e.jsx(ns,{})]})})]})]})]})})]})})}exports.AdvancedModeToggle=ve;exports.DashboardPlus=ms;exports.ResourceManagementPanel=we;exports.ScheduleDashboard=je;exports.VisualBadge=be;exports.VisualEditingControls=De;exports.cleanCard=fe;exports.getDashbaordStateWithoutData=ce;