react-semaphor 0.1.164 → 0.1.166

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 (33) hide show
  1. package/dist/chunks/dashboard-controls-B9UPzyO5.js +26 -0
  2. package/dist/chunks/{dashboard-controls-CWQ_gUsq.js → dashboard-controls-CixEPYYv.js} +260 -285
  3. package/dist/chunks/{dashboard-json-05FNu5_c.js → dashboard-json-BYNwk3YG.js} +1 -1
  4. package/dist/chunks/{dashboard-json-BnUM90on.js → dashboard-json-LXUW-x_7.js} +1 -1
  5. package/dist/chunks/{edit-dashboard-visual-BQyiGFIJ.js → edit-dashboard-visual-CyW3aGrM.js} +1 -1
  6. package/dist/chunks/{edit-dashboard-visual-DvcXroC3.js → edit-dashboard-visual-DtiYOHX5.js} +2 -2
  7. package/dist/chunks/{editor-action-buttons-0lhAtWvK.js → editor-action-buttons-C2VJa0cF.js} +2 -2
  8. package/dist/chunks/{editor-action-buttons-DChxrcx_.js → editor-action-buttons-CFZZpeDq.js} +1 -1
  9. package/dist/chunks/index-CQ7RRL9U.js +1108 -0
  10. package/dist/chunks/{index-Ba7cbkS0.js → index-DYeBGt71.js} +19247 -18898
  11. package/dist/chunks/{resource-management-panel-BDDrOqYt.js → resource-management-panel-DJOLQsLL.js} +141 -141
  12. package/dist/chunks/{resource-management-panel-Dw5GP_kj.js → resource-management-panel-qqHHN4xT.js} +1 -1
  13. package/dist/chunks/schedule-dashboard-B5cLQ2sk.js +6 -0
  14. package/dist/chunks/schedule-dashboard-B9Y23qK6.js +416 -0
  15. package/dist/chunks/{use-role-aware-display-preferences-C9ydHtPN.js → use-role-aware-display-preferences-8gWJAMO3.js} +1 -1
  16. package/dist/chunks/{use-role-aware-display-preferences-Dk-fULeQ.js → use-role-aware-display-preferences-BJCLNjn8.js} +1 -1
  17. package/dist/chunks/{use-visual-utils-BOMHKg6C.js → use-visual-utils-Bsvc2KNu.js} +1 -1
  18. package/dist/chunks/{use-visual-utils-DfO9gvaA.js → use-visual-utils-DA9bk0Rh.js} +20 -20
  19. package/dist/dashboard/index.cjs +1 -1
  20. package/dist/dashboard/index.js +1 -1
  21. package/dist/index.cjs +2 -2
  22. package/dist/index.js +111 -108
  23. package/dist/surfboard/index.cjs +1 -1
  24. package/dist/surfboard/index.js +1 -1
  25. package/dist/types/dashboard.d.ts +5 -0
  26. package/dist/types/main.d.ts +5 -0
  27. package/dist/types/surfboard.d.ts +5 -0
  28. package/dist/types/types.d.ts +5 -0
  29. package/package.json +1 -1
  30. package/dist/chunks/dashboard-controls-Czfs9TsO.js +0 -26
  31. package/dist/chunks/dashboard-export-dialog-DiJIOI6i.js +0 -602
  32. package/dist/chunks/dashboard-export-dialog-zge97BYd.js +0 -6
  33. package/dist/chunks/index-SZ7sy6nw.js +0 -1103
package/dist/index.js CHANGED
@@ -1,11 +1,11 @@
1
- import { l as T, E as g, F as w, S as M, U as P, v as k, w as A, u as F, x as y, y as L, P as R, z as I, B as V, c as v, A as _, G as B, H as U, I as W, J as j, K as q, M as z, N as O, O as Q, C as G } from "./chunks/index-Ba7cbkS0.js";
2
- import { a8 as oa, a9 as na, D as ta, a1 as ia, ad as da, T as la, Y as ca, Y as ua, Z as ha, a as pa, a4 as ma, aw as fa, ak as Ca, a6 as va, a2 as Da, a3 as ba, ae as ya, am as ga, al as xa, ap as Ea, aq as Na, aj as Sa, a5 as Ta, ai as wa, ab as Ma, ac as Pa, aa as ka, an as Aa, ah as Fa, ag as La, af as Ra, ar as Ia, ao as Va, a0 as _a, at as Ba, av as Ua, au as Wa, o as ja, $ as qa, R as za, a7 as Oa, V as Qa, m as Ga, as as Ha, n as Ya, Q as Ka, _ as $a, W as Ja } from "./chunks/index-Ba7cbkS0.js";
3
- import { EMPTY_SELECTION as Za } from "./types/index.js";
4
- import { jsx as a, jsxs as d } from "react/jsx-runtime";
1
+ import { l as N, E as g, F as w, S as M, v as P, U as k, w as A, x as I, u as R, y as D, z as F, P as L, A as V, B as _, c as v, G as B, H as U, I as W, J as j, K as q, M as z, N as O, O as Q, Q as G, C as H } from "./chunks/index-DYeBGt71.js";
2
+ import { aa as na, ab as ta, D as ia, a8 as da, a2 as la, af as ca, V as ua, Z as ha, Z as pa, _ as ma, a as fa, a5 as Ca, ay as va, am as ya, a7 as ba, a3 as Da, a4 as ga, ag as xa, ao as Ea, an as Sa, ar as Ta, as as Na, al as wa, a6 as Ma, ak as Pa, ad as ka, ae as Aa, ac as Ia, ap as Ra, aj as Fa, ai as La, ah as Va, at as _a, aq as Ba, a1 as Ua, av as Wa, ax as ja, aw as qa, o as za, a0 as Oa, T as Qa, a9 as Ga, W as Ha, m as Ka, au as Ya, n as $a, R as Za, $ as Ja, Y as Xa } from "./chunks/index-DYeBGt71.js";
3
+ import { EMPTY_SELECTION as ee } from "./types/index.js";
4
+ import { jsx as a, jsxs as i } from "react/jsx-runtime";
5
5
  import * as p from "react";
6
- import { useMemo as H } from "react";
7
- import { ResourceManagementPanel as ee } from "./chunks/resource-management-panel-BDDrOqYt.js";
8
- import { A as re, D as oe, S as ne, U as te, V as ie, u as de } from "./chunks/dashboard-export-dialog-DiJIOI6i.js";
6
+ import { useMemo as K } from "react";
7
+ import { ResourceManagementPanel as oe } from "./chunks/resource-management-panel-DJOLQsLL.js";
8
+ import { A as ne, S as te, U as ie, V as de, u as le } from "./chunks/schedule-dashboard-B9Y23qK6.js";
9
9
  import "react-dom";
10
10
  /**
11
11
  * @license lucide-react v0.453.0 - ISC
@@ -13,35 +13,38 @@ import "react-dom";
13
13
  * This source code is licensed under the ISC license.
14
14
  * See the LICENSE file in the root directory of this source tree.
15
15
  */
16
- const Y = T("RefreshCw", [
16
+ const Y = N("RefreshCw", [
17
17
  ["path", { d: "M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8", key: "v9h5vc" }],
18
18
  ["path", { d: "M21 3v5h-5", key: "1q7to0" }],
19
19
  ["path", { d: "M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16", key: "3uifl3" }],
20
20
  ["path", { d: "M8 16H3v5", key: "1cv678" }]
21
21
  ]);
22
- function aa(s) {
23
- const { displayPreferences: o, ...i } = s, l = {
24
- ...i,
22
+ function ea(s) {
23
+ const { displayPreferences: r, ...d } = s, l = {
24
+ ...d,
25
25
  id: s.dashboardId
26
26
  // override the id to the dashboard id so that the dashboard is not loaded
27
27
  };
28
- return /* @__PURE__ */ a(g, { FallbackComponent: w, children: /* @__PURE__ */ a(M, { dashboardProps: l, children: /* @__PURE__ */ a(P, { children: /* @__PURE__ */ a(k, { displayPreferences: o, children: /* @__PURE__ */ a(A, { type: "visual", ...l, children: /* @__PURE__ */ a(K, { cardId: s.cardId }) }) }) }) }) });
28
+ return /* @__PURE__ */ a(g, { FallbackComponent: w, children: /* @__PURE__ */ i(M, { dashboardProps: l, children: [
29
+ /* @__PURE__ */ a(P, { componentType: "visual", componentId: s.cardId }),
30
+ /* @__PURE__ */ a(k, { children: /* @__PURE__ */ a(A, { displayPreferences: r, children: /* @__PURE__ */ a(I, { type: "visual", ...l, children: /* @__PURE__ */ a($, { cardId: s.cardId }) }) }) })
31
+ ] }) });
29
32
  }
30
- function K({ cardId: s }) {
31
- const o = F((r) => {
33
+ function $({ cardId: s }) {
34
+ const r = R((o) => {
32
35
  var n;
33
- return (n = r.dashboard) == null ? void 0 : n.sheets;
34
- }), { card: i, frame: l } = H(() => {
35
- const r = o == null ? void 0 : o.flatMap((e) => e.frames), n = r == null ? void 0 : r.flatMap((e) => e == null ? void 0 : e.cards), m = n == null ? void 0 : n.find((e) => (e == null ? void 0 : e.id) === s), f = r == null ? void 0 : r.find(
36
+ return (n = o.dashboard) == null ? void 0 : n.sheets;
37
+ }), { card: d, frame: l } = K(() => {
38
+ const o = r == null ? void 0 : r.flatMap((e) => e.frames), n = o == null ? void 0 : o.flatMap((e) => e == null ? void 0 : e.cards), m = n == null ? void 0 : n.find((e) => (e == null ? void 0 : e.id) === s), f = o == null ? void 0 : o.find(
36
39
  (e) => {
37
40
  var h;
38
41
  return (h = e == null ? void 0 : e.cards) == null ? void 0 : h.find((c) => (c == null ? void 0 : c.id) === s);
39
42
  }
40
43
  );
41
44
  return { card: m, frame: f };
42
- }, [o, s]);
43
- return !i || !l ? /* @__PURE__ */ a(
44
- y,
45
+ }, [r, s]);
46
+ return !d || !l ? /* @__PURE__ */ a(
47
+ D,
45
48
  {
46
49
  error: new Error("Card not found"),
47
50
  resetErrorBoundary: () => {
@@ -52,98 +55,98 @@ function K({ cardId: s }) {
52
55
  g,
53
56
  {
54
57
  FallbackComponent: ({
55
- error: r,
58
+ error: o,
56
59
  resetErrorBoundary: n
57
60
  }) => /* @__PURE__ */ a(
58
- y,
61
+ D,
59
62
  {
60
- error: r,
63
+ error: o,
61
64
  resetErrorBoundary: n,
62
65
  customerFacingMessage: "Error creating visual. Please try again."
63
66
  }
64
67
  ),
65
- children: /* @__PURE__ */ a(L, { card: i, frame: l })
68
+ children: /* @__PURE__ */ a(F, { card: d, frame: l })
66
69
  }
67
70
  ) });
68
71
  }
69
- function ea({
72
+ function sa({
70
73
  name: s,
71
- items: o,
72
- value: i,
74
+ items: r,
75
+ value: d,
73
76
  onChange: l,
74
- isLoading: r,
77
+ isLoading: o,
75
78
  isError: n,
76
79
  refetch: m,
77
80
  className: f,
78
81
  icon: e,
79
82
  showNone: h = !1
80
83
  }) {
81
- const c = p.useRef(null), [D, b] = p.useState(!1), [x, E] = p.useState("100%"), C = h ? [...o || [], { id: "none", name: "None" }] : o;
84
+ const c = p.useRef(null), [y, b] = p.useState(!1), [x, E] = p.useState("100%"), C = h ? [...r || [], { id: "none", name: "None" }] : r;
82
85
  p.useLayoutEffect(() => {
83
86
  c.current && E(c.current.offsetWidth);
84
87
  }, []);
85
- function N() {
88
+ function S() {
86
89
  var t;
87
- return r ? "Loading..." : n ? "Error" : i ? (t = o == null ? void 0 : o.find((u) => u.id === i)) == null ? void 0 : t.name : `Select ${s}`;
90
+ return o ? "Loading..." : n ? "Error" : d ? (t = r == null ? void 0 : r.find((u) => u.id === d)) == null ? void 0 : t.name : `Select ${s}`;
88
91
  }
89
- function S(t, u) {
92
+ function T(t, u) {
90
93
  l(u), b(!1);
91
94
  }
92
- return /* @__PURE__ */ d(R, { open: D, onOpenChange: b, children: [
93
- /* @__PURE__ */ a(I, { asChild: !0, children: /* @__PURE__ */ d(
94
- V,
95
+ return /* @__PURE__ */ i(L, { open: y, onOpenChange: b, children: [
96
+ /* @__PURE__ */ a(V, { asChild: !0, children: /* @__PURE__ */ i(
97
+ _,
95
98
  {
96
99
  ref: c,
97
100
  variant: "outline",
98
101
  role: "combobox",
99
- "aria-expanded": D,
102
+ "aria-expanded": y,
100
103
  className: v("flex h-9 w-full justify-between", f),
101
104
  children: [
102
- /* @__PURE__ */ d("div", { className: "flex items-center gap-2", children: [
105
+ /* @__PURE__ */ i("div", { className: "flex items-center gap-2", children: [
103
106
  e && /* @__PURE__ */ a("div", { className: "mr-2", children: e }),
104
- /* @__PURE__ */ a("span", { className: "max-w-[150px] overflow-hidden truncate text-ellipsis whitespace-nowrap", children: N() })
107
+ /* @__PURE__ */ a("span", { className: "max-w-[150px] overflow-hidden truncate text-ellipsis whitespace-nowrap", children: S() })
105
108
  ] }),
106
- /* @__PURE__ */ a(_, { className: "size-4 opacity-50" })
109
+ /* @__PURE__ */ a(B, { className: "size-4 opacity-50" })
107
110
  ]
108
111
  }
109
112
  ) }),
110
113
  /* @__PURE__ */ a(
111
- B,
114
+ U,
112
115
  {
113
116
  className: "w-full p-0",
114
117
  style: { minWidth: x },
115
- children: /* @__PURE__ */ d(U, { children: [
116
- /* @__PURE__ */ d("div", { className: "flex h-9 items-center justify-between border-b pr-1", children: [
117
- /* @__PURE__ */ a(W, { className: "h-9", placeholder: "Search..." }),
118
- /* @__PURE__ */ a(j, { className: "h-7", onClick: m, children: /* @__PURE__ */ a(
118
+ children: /* @__PURE__ */ i(W, { children: [
119
+ /* @__PURE__ */ i("div", { className: "flex h-9 items-center justify-between border-b pr-1", children: [
120
+ /* @__PURE__ */ a(j, { className: "h-9", placeholder: "Search..." }),
121
+ /* @__PURE__ */ a(q, { className: "h-7", onClick: m, children: /* @__PURE__ */ a(
119
122
  Y,
120
123
  {
121
124
  className: v(
122
125
  "size-3.5 opacity-50",
123
- r && "animate-spin"
126
+ o && "animate-spin"
124
127
  )
125
128
  }
126
129
  ) })
127
130
  ] }),
128
- /* @__PURE__ */ d(q, { children: [
129
- /* @__PURE__ */ d(z, { children: [
131
+ /* @__PURE__ */ i(z, { children: [
132
+ /* @__PURE__ */ i(O, { children: [
130
133
  "No ",
131
134
  s == null ? void 0 : s.toLowerCase(),
132
135
  " found."
133
136
  ] }),
134
- /* @__PURE__ */ a(O, { children: C == null ? void 0 : C.map((t) => /* @__PURE__ */ a(
135
- Q,
137
+ /* @__PURE__ */ a(Q, { children: C == null ? void 0 : C.map((t) => /* @__PURE__ */ a(
138
+ G,
136
139
  {
137
140
  className: "overflow-x-auto",
138
141
  value: t.name,
139
- onSelect: (u) => S(u, t.id),
140
- children: /* @__PURE__ */ d("div", { className: "flex items-center gap-2", children: [
142
+ onSelect: (u) => T(u, t.id),
143
+ children: /* @__PURE__ */ i("div", { className: "flex items-center gap-2", children: [
141
144
  /* @__PURE__ */ a(
142
- G,
145
+ H,
143
146
  {
144
147
  className: v(
145
148
  "size-4",
146
- i === t.id ? "opacity-100" : "opacity-0"
149
+ d === t.id ? "opacity-100" : "opacity-0"
147
150
  )
148
151
  }
149
152
  ),
@@ -159,64 +162,64 @@ function ea({
159
162
  ] });
160
163
  }
161
164
  export {
162
- re as AdvancedModeToggle,
163
- oa as CALCULATED_FIELD_ENTITY_MARKER,
164
- ea as Combobox,
165
- na as DATE_FORMAT_VALUES,
166
- ta as Dashboard,
167
- oe as DashboardExportDialog,
168
- ia as DashboardWC,
169
- Za as EMPTY_SELECTION,
170
- da as PivotMarkerEnum,
171
- ee as ResourceManagementPanel,
172
- la as ResourceType,
173
- ne as ScheduleDashboard,
165
+ ne as AdvancedModeToggle,
166
+ na as CALCULATED_FIELD_ENTITY_MARKER,
167
+ sa as Combobox,
168
+ ta as DATE_FORMAT_VALUES,
169
+ ia as Dashboard,
170
+ da as DashboardExportDialog,
171
+ la as DashboardWC,
172
+ ee as EMPTY_SELECTION,
173
+ ca as PivotMarkerEnum,
174
+ oe as ResourceManagementPanel,
175
+ ua as ResourceType,
176
+ te as ScheduleDashboard,
174
177
  M as SemaphorContextProvider,
175
- ca as SemaphorDataProvider,
176
- ua as SemaphorQueryClient,
177
- ha as ShareDialog,
178
- pa as Surfboard,
179
- te as UnsavedChangesAlert,
180
- aa as Visual,
181
- ie as VisualEditingControls,
182
- ma as cloneDeep,
183
- fa as createEmptyKpiConfig,
184
- Ca as createSqlGenConfig,
185
- va as downloadPdf,
178
+ ha as SemaphorDataProvider,
179
+ pa as SemaphorQueryClient,
180
+ ma as ShareDialog,
181
+ fa as Surfboard,
182
+ ie as UnsavedChangesAlert,
183
+ ea as Visual,
184
+ de as VisualEditingControls,
185
+ Ca as cloneDeep,
186
+ va as createEmptyKpiConfig,
187
+ ya as createSqlGenConfig,
188
+ ba as downloadPdf,
186
189
  Da as emitDashboardLoad,
187
- ba as emitDashboardUnload,
188
- ya as fmt,
189
- ga as getColumnDataType,
190
- xa as getFilterValueType,
191
- Ea as getFormattedTableNameForQuery,
190
+ ga as emitDashboardUnload,
191
+ xa as fmt,
192
+ Ea as getColumnDataType,
193
+ Sa as getFilterValueType,
194
+ Ta as getFormattedTableNameForQuery,
192
195
  Na as getQualifiedTableName,
193
- Sa as getSql,
194
- Ta as invalidateToken,
195
- wa as isBooleanDataType,
196
- Ma as isCalculatedDimension,
197
- Pa as isCalculatedField,
198
- ka as isCalculatedMetric,
199
- Aa as isColumnInSqlGen,
196
+ wa as getSql,
197
+ Ma as invalidateToken,
198
+ Pa as isBooleanDataType,
199
+ ka as isCalculatedDimension,
200
+ Aa as isCalculatedField,
201
+ Ia as isCalculatedMetric,
202
+ Ra as isColumnInSqlGen,
200
203
  Fa as isDateDataType,
201
204
  La as isNumberDataType,
202
- Ra as isTextDataType,
203
- Ia as resolveDataType,
204
- Va as resolveDatamodelName,
205
- _a as useCard,
206
- Ba as useCurrentActiveCard,
207
- Ua as useCurrentCardConfig,
208
- Wa as useCurrentSheetActiveCards,
209
- ja as useDashboardActions,
210
- qa as useDashboardById,
211
- za as useDashboardQuery,
212
- F as useDashboardStore,
213
- Oa as useDataColumns,
214
- Qa as useDateFilterHook,
215
- Ga as useEditorActions,
216
- Ha as useEditorAside,
217
- Ya as useEditorStore,
218
- Ka as useManagementStore,
219
- de as usePristineSnapshotInitializer,
220
- $a as useResourceManagement,
221
- Ja as useTextFilterHook
205
+ Va as isTextDataType,
206
+ _a as resolveDataType,
207
+ Ba as resolveDatamodelName,
208
+ Ua as useCard,
209
+ Wa as useCurrentActiveCard,
210
+ ja as useCurrentCardConfig,
211
+ qa as useCurrentSheetActiveCards,
212
+ za as useDashboardActions,
213
+ Oa as useDashboardById,
214
+ Qa as useDashboardQuery,
215
+ R as useDashboardStore,
216
+ Ga as useDataColumns,
217
+ Ha as useDateFilterHook,
218
+ Ka as useEditorActions,
219
+ Ya as useEditorAside,
220
+ $a as useEditorStore,
221
+ Za as useManagementStore,
222
+ le as usePristineSnapshotInitializer,
223
+ Ja as useResourceManagement,
224
+ Xa as useTextFilterHook
222
225
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../chunks/index-SZ7sy6nw.js"),r=require("../types/index.cjs");exports.Surfboard=e.DashboardPlus;exports.EMPTY_SELECTION=r.EMPTY_SELECTION;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../chunks/index-CQ7RRL9U.js"),r=require("../types/index.cjs");exports.Surfboard=e.DashboardPlus;exports.EMPTY_SELECTION=r.EMPTY_SELECTION;
@@ -1,4 +1,4 @@
1
- import { a } from "../chunks/index-Ba7cbkS0.js";
1
+ import { a } from "../chunks/index-DYeBGt71.js";
2
2
  import { EMPTY_SELECTION as E } from "../types/index.js";
3
3
  export {
4
4
  E as EMPTY_SELECTION,
@@ -715,6 +715,11 @@ export declare type FilterLayoutSettings = {
715
715
  * - true: Wrap to multiple lines
716
716
  */
717
717
  toolbarWrap?: boolean;
718
+ /**
719
+ * Whether to show a download button in the filter toolbar
720
+ * Useful when embedding Dashboard component without Surfboard's controls
721
+ */
722
+ showDownloadButton?: boolean;
718
723
  };
719
724
 
720
725
  declare type FilterLocation = 'dashboard' | 'frame' | 'sheet' | undefined;
@@ -1419,6 +1419,11 @@ export declare type FilterLayoutSettings = {
1419
1419
  * - true: Wrap to multiple lines
1420
1420
  */
1421
1421
  toolbarWrap?: boolean;
1422
+ /**
1423
+ * Whether to show a download button in the filter toolbar
1424
+ * Useful when embedding Dashboard component without Surfboard's controls
1425
+ */
1426
+ showDownloadButton?: boolean;
1422
1427
  };
1423
1428
 
1424
1429
  declare type FilterLocation = 'dashboard' | 'frame' | 'sheet' | undefined;
@@ -718,6 +718,11 @@ export declare type FilterLayoutSettings = {
718
718
  * - true: Wrap to multiple lines
719
719
  */
720
720
  toolbarWrap?: boolean;
721
+ /**
722
+ * Whether to show a download button in the filter toolbar
723
+ * Useful when embedding Dashboard component without Surfboard's controls
724
+ */
725
+ showDownloadButton?: boolean;
721
726
  };
722
727
 
723
728
  declare type FilterLocation = 'dashboard' | 'frame' | 'sheet' | undefined;
@@ -712,6 +712,11 @@ export declare type FilterLayoutSettings = {
712
712
  * - true: Wrap to multiple lines
713
713
  */
714
714
  toolbarWrap?: boolean;
715
+ /**
716
+ * Whether to show a download button in the filter toolbar
717
+ * Useful when embedding Dashboard component without Surfboard's controls
718
+ */
719
+ showDownloadButton?: boolean;
715
720
  };
716
721
 
717
722
  declare type FilterLocation = 'dashboard' | 'frame' | 'sheet' | undefined;
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "email": "support@semaphor.cloud"
6
6
  },
7
7
  "license": "MIT",
8
- "version": "0.1.164",
8
+ "version": "0.1.166",
9
9
  "description": "Fully interactive and customizable dashboards for your apps.",
10
10
  "keywords": [
11
11
  "react",
@@ -1,26 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),s=require("./index-SZ7sy6nw.js"),f=require("react");require("react-dom");const G=require("./dashboard-export-dialog-zge97BYd.js"),$e=require("./use-role-aware-display-preferences-C9ydHtPN.js"),he=require("./editor-action-buttons-DChxrcx_.js");function ze(t){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const a in t)if(a!=="default"){const r=Object.getOwnPropertyDescriptor(t,a);Object.defineProperty(n,a,r.get?r:{enumerable:!0,get:()=>t[a]})}}return n.default=t,Object.freeze(n)}const w=ze(f);/**
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 _e=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"}]]);/**
7
- * @license lucide-react v0.453.0 - ISC
8
- *
9
- * This source code is licensed under the ISC license.
10
- * See the LICENSE file in the root directory of this source tree.
11
- */const Qe=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"}]]);/**
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 He=s.createLucideIcon("Moon",[["path",{d:"M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z",key:"a7tn18"}]]);/**
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 Ve=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"}]]);/**
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 Ke=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"}]]);var Je=s.requireShim();function We(){const{setTheme:t}=s.useTheme(),n=s.useDashboardStore(a=>a.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(Ke,{strokeWidth:1.5,className:"h-4 w-4 rotate-0 scale-100 transition-all dark:-rotate-90 dark:scale-0"}),e.jsx(He,{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"),n("light")},children:"Light"}),e.jsx(s.DropdownMenuItem,{onClick:()=>{t("dark"),n("dark")},children:"Dark"}),e.jsx(s.DropdownMenuItem,{onClick:()=>{t("system"),n("system")},children:"System"})]})]})}async function Xe(t,n,a,r,l){if(!l)return null;const o=JSON.stringify(a),c=`${t}/v1/lens`;return await s.postRequest(c,l,{name:n,template:o,filterValues:r,operation:"create"})}async function ee(t,n,a){if(!a)return null;const{id:r,template:l,filterValues:o,isDefault:c,shared:u}=n,p=`${t}/v1/lens`;return await s.postRequest(p,a,{lensId:r,template:l,filterValues:o,isDefault:c,shared:u,operation:"update"})}async function Ye(t,n,a){if(!a)return null;const r=`${t}/v1/lens`;return await s.postRequest(r,a,{operation:"delete",lensId:n})}function Ze(){const[t,n]=f.useState(""),[a,r]=f.useState(!1),l=s.useDashboardStore(y=>y.lenses),{setLenses:o,setSelectedLensId:c}=s.useDashboardActions(),[u,p]=f.useState(!1),[g,d]=f.useState(!1),m=s.useDashboardStore(y=>y.dashboard),x=s.useDashboardStore(y=>y.filterValues),{authToken:j,tokenProps:v}=s.useSemaphorContext();async function b(){p(!0);const y=await Xe(v.apiServiceUrl,t,m,x,j==null?void 0:j.accessToken);y&&(o([...l||[],y]),c(y.id),d(!1)),p(!1)}return e.jsxs(s.Dialog,{open:g,onOpenChange:d,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$1,{value:t,onChange:y=>{n(y.target.value)},id:"name",className:"col-span-7 focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0"})]})}),a&&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:b,disabled:u,children:u?"Creating...":"Add"})})]})]})}function es(){const[t,n]=f.useState(!1),a=s.useDashboardStore(m=>m.lenses),r=s.useDashboardStore(m=>m.selectedLensId),{setLenses:l,setSelectedLensId:o}=s.useDashboardActions(),{authToken:c,tokenProps:u}=s.useSemaphorContext();async function p(m){o(m)}async function g(m){if(await Ye(u.apiServiceUrl,m,c==null?void 0:c.accessToken)){const j=a==null?void 0:a.filter(v=>v.id!==m);l(j||[]),o("original")}}async function d(m){const x=a==null?void 0:a.map(b=>b.id===m.id?{...b,isDefault:!m.isDefault}:{...b,isDefault:!1});l(x||[]);const j={...m,isDefault:!m.isDefault};await ee(u.apiServiceUrl,j,c==null?void 0:c.accessToken);const v=a==null?void 0:a.find(b=>b.isDefault);if(v&&v.id!==m.id){const b={...v,isDefault:!1};await ee(u.apiServiceUrl,b,c==null?void 0:c.accessToken)}}return e.jsxs(s.DropdownMenu,{open:t,onOpenChange:n,children:[e.jsx(s.DropdownMenuTrigger,{asChild:!0,children:e.jsx(s.IconButton,{tooltip:"Lenses",className:"h-7 p-2",children:e.jsx(_e,{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:r,onValueChange:p,children:[e.jsx(s.DropdownMenuRadioItem,{value:"original",children:"Original"}),a==null?void 0:a.map(m=>e.jsxs(s.DropdownMenuRadioItem,{className:"group flex justify-between gap-2",value:m.id,children:[e.jsx("p",{children:m.name}),e.jsxs("span",{className:"flex items-center gap-3",children:[e.jsx(s.House,{onClick:x=>{x.preventDefault(),d(m)},className:s.cn("size-3.5 text-muted-foreground hover:cursor-pointer hover:text-foreground group-hover:visible",{invisible:!m.isDefault,"text-green-500":m.isDefault}),strokeWidth:1.5}),e.jsx(s.Cross2Icon,{onClick:x=>{x.preventDefault(),g(m.id)},className:"invisible size-3.5 text-muted-foreground hover:cursor-pointer hover:text-foreground group-hover:visible",strokeWidth:1.5})]})]},m.id))]})]})]})}function ss({iconClassName:t}){const[n,a]=f.useState(!1),r=s.useDashboardStore(l=>l.isDownloadingPdf);return e.jsxs(e.Fragment,{children:[e.jsx(s.Button,{variant:"ghost",size:"sm",className:"h-7 p-2",disabled:r,onClick:()=>a(!0),children:e.jsx(s.Download,{className:s.cn("size-4",t)})}),e.jsx(G.DashboardExportDialog,{open:n,onOpenChange:a})]})}const ts=async(t,n,a)=>{const r=`${t}/management/v1/groups`;return await s.postRequestRegular(r,n,a)},as=async(t,n,a)=>{const r=`${t}/management/v1/groups/${a}`,l=await fetch(r,{method:"DELETE",headers:{Authorization:`Bearer ${n}`}});if(!l.ok){const o=await l.text();throw new Error(o||"Failed to delete group")}},rs=async(t,n,a,r)=>{const l=`${t}/management/v1/groups/${a}/members`;return await s.postRequestRegular(l,n,r)},ns=async(t,n,a,r)=>{const l=`${t}/management/v1/groups/${a}/members`,o=await fetch(l,{method:"DELETE",headers:{"Content-Type":"application/json",Authorization:`Bearer ${n}`},body:JSON.stringify(r)});if(!o.ok){const c=await o.text();throw new Error(c||"Failed to remove group members")}};function os(){const{authToken:t,tokenProps:n}=s.useSemaphorContext(),a=s.useQueryClient();return s.useMutation({mutationFn:r=>ts(n.apiServiceUrl,(t==null?void 0:t.accessToken)||"",r),onSuccess:()=>{a.invalidateQueries({queryKey:["groups"]}),s.ue.success("Group created successfully")},onError:r=>{console.error("Failed to create group:",r),s.ue.error("Failed to create group",{description:r.message})}})}function is(){const{authToken:t,tokenProps:n}=s.useSemaphorContext(),a=s.useQueryClient();return s.useMutation({mutationFn:r=>as(n.apiServiceUrl,(t==null?void 0:t.accessToken)||"",r),onSuccess:(r,l)=>{a.invalidateQueries({queryKey:["groups"]}),a.removeQueries({queryKey:["group",l]}),s.ue.success("Group deleted successfully")},onError:r=>{console.error("Failed to delete group:",r),s.ue.error("Failed to delete group",{description:r.message})}})}function ls(){const{authToken:t,tokenProps:n}=s.useSemaphorContext(),a=s.useQueryClient();return s.useMutation({mutationFn:({groupId:r,data:l})=>rs(n.apiServiceUrl,(t==null?void 0:t.accessToken)||"",r,l),onSuccess:(r,l)=>{a.invalidateQueries({queryKey:["group",l.groupId]}),a.invalidateQueries({queryKey:["group-members",l.groupId]}),a.invalidateQueries({queryKey:["groups"]}),s.ue.success("Members added successfully")},onError:r=>{console.error("Failed to add group members:",r),s.ue.error("Failed to add members",{description:r.message})}})}function cs(){const{authToken:t,tokenProps:n}=s.useSemaphorContext(),a=s.useQueryClient();return s.useMutation({mutationFn:({groupId:r,data:l})=>ns(n.apiServiceUrl,(t==null?void 0:t.accessToken)||"",r,l),onSuccess:(r,l)=>{a.invalidateQueries({queryKey:["group",l.groupId]}),a.invalidateQueries({queryKey:["group-members",l.groupId]}),a.invalidateQueries({queryKey:["groups"]}),s.ue.success("Members removed successfully")},onError:r=>{console.error("Failed to remove group members:",r),s.ue.error("Failed to remove members",{description:r.message})}})}function ds({onSuccess:t,tenantId:n,isTenantUser:a}){const[r,l]=f.useState(""),[o,c]=f.useState(""),[u,p]=f.useState({}),g=os(),d=()=>{const x={};return r.trim()?r.length<3?x.name="Group name must be at least 3 characters":r.length>50&&(x.name="Group name must be less than 50 characters"):x.name="Group name is required",o&&o.length>200&&(x.description="Description must be less than 200 characters"),p(x),Object.keys(x).length===0},m=async x=>{if(x.preventDefault(),!d())return;const j={name:r.trim(),description:o.trim()||void 0,type:a?"TENANT_GROUP":"ORG_GROUP",...a&&n?{tenantId:n}:{}};try{await g.mutateAsync(j),l(""),c(""),p({}),t()}catch(v){console.error("Failed to create group:",v)}};return e.jsxs("form",{onSubmit:m,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$1,{id:"group-name",placeholder:"e.g., Marketing Team, Engineering Squad",value:r,onChange:x=>{l(x.target.value),u.name&&p(j=>({...j,name:""}))},className:u.name?"border-destructive":"",disabled:g.isPending}),u.name&&e.jsx("p",{className:"text-sm text-destructive",children:u.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:o,onChange:x=>{c(x.target.value),u.description&&p(j=>({...j,description:""}))},className:u.description?"border-destructive":"",disabled:g.isPending,rows:3}),u.description&&e.jsx("p",{className:"text-sm text-destructive",children:u.description}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[o.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:()=>{l(""),c(""),p({})},disabled:g.isPending,children:"Clear"}),e.jsx(s.Button,{type:"submit",disabled:g.isPending||!r.trim(),children:g.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 us(t,n=[]){let a=[];function r(o,c){const u=w.createContext(c);u.displayName=o+"Context";const p=a.length;a=[...a,c];const g=m=>{var T;const{scope:x,children:j,...v}=m,b=((T=x==null?void 0:x[t])==null?void 0:T[p])||u,y=w.useMemo(()=>v,Object.values(v));return e.jsx(b.Provider,{value:y,children:j})};g.displayName=o+"Provider";function d(m,x){var b;const j=((b=x==null?void 0:x[t])==null?void 0:b[p])||u,v=w.useContext(j);if(v)return v;if(c!==void 0)return c;throw new Error(`\`${m}\` must be used within \`${o}\``)}return[g,d]}const l=()=>{const o=a.map(c=>w.createContext(c));return function(u){const p=(u==null?void 0:u[t])||o;return w.useMemo(()=>({[`__scope${t}`]:{...u,[t]:p}}),[u,p])}};return l.scopeName=t,[r,ms(l,...n)]}function ms(...t){const n=t[0];if(t.length===1)return n;const a=()=>{const r=t.map(l=>({useScope:l(),scopeName:l.scopeName}));return function(o){const c=r.reduce((u,{useScope:p,scopeName:g})=>{const m=p(o)[`__scope${g}`];return{...u,...m}},{});return w.useMemo(()=>({[`__scope${n.scopeName}`]:c}),[c])}};return a.scopeName=n.scopeName,a}var hs=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],se=hs.reduce((t,n)=>{const a=s.createSlot(`Primitive.${n}`),r=w.forwardRef((l,o)=>{const{asChild:c,...u}=l,p=c?a:n;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),e.jsx(p,{...u,ref:o})});return r.displayName=`Primitive.${n}`,{...t,[n]:r}},{});function ps(){return Je.useSyncExternalStore(xs,()=>!0,()=>!1)}function xs(){return()=>{}}var te="Avatar",[gs]=us(te),[fs,xe]=gs(te),ge=w.forwardRef((t,n)=>{const{__scopeAvatar:a,...r}=t,[l,o]=w.useState("idle");return e.jsx(fs,{scope:a,imageLoadingStatus:l,onImageLoadingStatusChange:o,children:e.jsx(se.span,{...r,ref:n})})});ge.displayName=te;var fe="AvatarImage",je=w.forwardRef((t,n)=>{const{__scopeAvatar:a,src:r,onLoadingStatusChange:l=()=>{},...o}=t,c=xe(fe,a),u=js(r,o),p=s.useCallbackRef(g=>{l(g),c.onImageLoadingStatusChange(g)});return s.useLayoutEffect2(()=>{u!=="idle"&&p(u)},[u,p]),u==="loaded"?e.jsx(se.img,{...o,ref:n,src:r}):null});je.displayName=fe;var ve="AvatarFallback",be=w.forwardRef((t,n)=>{const{__scopeAvatar:a,delayMs:r,...l}=t,o=xe(ve,a),[c,u]=w.useState(r===void 0);return w.useEffect(()=>{if(r!==void 0){const p=window.setTimeout(()=>u(!0),r);return()=>window.clearTimeout(p)}},[r]),c&&o.imageLoadingStatus!=="loaded"?e.jsx(se.span,{...l,ref:n}):null});be.displayName=ve;function pe(t,n){return t?n?(t.src!==n&&(t.src=n),t.complete&&t.naturalWidth>0?"loaded":"loading"):"error":"idle"}function js(t,{referrerPolicy:n,crossOrigin:a}){const r=ps(),l=w.useRef(null),o=r?(l.current||(l.current=new window.Image),l.current):null,[c,u]=w.useState(()=>pe(o,t));return s.useLayoutEffect2(()=>{u(pe(o,t))},[o,t]),s.useLayoutEffect2(()=>{const p=m=>()=>{u(m)};if(!o)return;const g=p("loaded"),d=p("error");return o.addEventListener("load",g),o.addEventListener("error",d),n&&(o.referrerPolicy=n),typeof a=="string"&&(o.crossOrigin=a),()=>{o.removeEventListener("load",g),o.removeEventListener("error",d)}},[o,a,n]),c}var Ne=ge,ye=je,Se=be;const ae=w.forwardRef(({className:t,...n},a)=>e.jsx(Ne,{ref:a,className:s.cn("relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full",t),...n}));ae.displayName=Ne.displayName;const vs=w.forwardRef(({className:t,...n},a)=>e.jsx(ye,{ref:a,className:s.cn("aspect-square h-full w-full",t),...n}));vs.displayName=ye.displayName;const re=w.forwardRef(({className:t,...n},a)=>e.jsx(Se,{ref:a,className:s.cn("flex h-full w-full items-center justify-center rounded-full bg-muted",t),...n}));re.displayName=Se.displayName;function bs({open:t,onOpenChange:n,group:a,onUpdate:r}){const[l,o]=f.useState("members"),[c,u]=f.useState(""),[p,g]=f.useState([]),[d,m]=f.useState([]),{data:x,isLoading:j,refetch:v}=s.useGroupMembers(a.id),b=a.type==="TENANT_GROUP"?"tenant":"organization",{users:y,isLoading:T}=s.useUnifiedUsers({type:b,tenantId:a.tenantId||void 0,active:!0,limit:100}),P=ls(),k=cs(),C=(x==null?void 0:x.members)||[],I=f.useMemo(()=>new Set(C.map(h=>h.userId)),[C]),L=f.useMemo(()=>y.filter(h=>!I.has(h.id)),[y,I]),F=f.useMemo(()=>{if(!c)return L;const h=c.toLowerCase();return L.filter(D=>{var M,E;return((M=D.name)==null?void 0:M.toLowerCase().includes(h))||((E=D.email)==null?void 0:E.toLowerCase().includes(h))})},[L,c]),N=f.useMemo(()=>{if(!c)return C;const h=c.toLowerCase();return C.filter(D=>{var M,E,z,O;return((E=(M=D.user)==null?void 0:M.name)==null?void 0:E.toLowerCase().includes(h))||((O=(z=D.user)==null?void 0:z.email)==null?void 0:O.toLowerCase().includes(h))})},[C,c]),R=async()=>{if(p.length!==0)try{await P.mutateAsync({groupId:a.id,data:{userIds:p,userType:b==="tenant"?"tenant":"org"}}),g([]),o("members"),v(),r==null||r()}catch(h){console.error("Failed to add members:",h)}},K=async()=>{if(d.length!==0)try{await k.mutateAsync({groupId:a.id,data:{userIds:d}}),m([]),v(),r==null||r()}catch(h){console.error("Failed to remove members:",h)}},J=h=>{g(D=>D.includes(h)?D.filter(M=>M!==h):[...D,h])},S=h=>{m(D=>D.includes(h)?D.filter(M=>M!==h):[...D,h])};return e.jsx(e.Fragment,{children:e.jsx(s.Dialog,{open:t,onOpenChange:n,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:a.name}),e.jsx("div",{className:"flex items-center gap-2 mt-1",children:e.jsxs("p",{className:"text-sm text-muted-foreground",children:[C.length," ",C.length===1?"member":"members"]})}),e.jsxs("p",{id:"group-members-description",className:"sr-only",children:["Add or remove members from the ",a.name," group"]})]}),e.jsxs(s.Tabs,{value:l,onValueChange:h=>{o(h),u(""),m([])},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$1,{placeholder:"Search members...",value:c,onChange:h=>u(h.target.value),className:"pl-10"})]}),e.jsx(s.ScrollArea,{className:d.length>0?"h-[300px]":"h-[350px]",children:j?e.jsx("div",{className:"space-y-2",children:[1,2,3].map(h=>e.jsx(s.Skeleton,{className:"h-16 w-full"},h))}):N.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:c?"No members found":"No members yet"}),e.jsx("p",{className:"text-xs mt-1",children:c?"Try a different search":'Switch to the "Add Members" tab to add people to this group'})]}):e.jsx("div",{className:"space-y-2",children:N.map(h=>e.jsx(Ns,{member:h,selected:d.includes(h.userId),onToggle:()=>S(h.userId)},h.id))})}),d.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:[d.length," member",d.length!==1?"s":""," selected"]}),e.jsx(s.Button,{variant:"destructive",size:"sm",onClick:K,disabled:k.isPending,children:k.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$1,{placeholder:"Search users to add...",value:c,onChange:h=>u(h.target.value),className:"pl-10"})]}),e.jsx(s.ScrollArea,{className:"h-[300px]",children:T?e.jsx("div",{className:"space-y-2",children:[1,2,3].map(h=>e.jsx(s.Skeleton,{className:"h-16 w-full"},h))}):F.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:c?"Try a different search":"All eligible users are already members"})]}):e.jsx("div",{className:"space-y-2",children:F.map(h=>e.jsx(ys,{user:h,selected:p.includes(h.id),onToggle:()=>J(h.id)},h.id))})}),p.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:[p.length," user",p.length!==1?"s":""," selected"]}),e.jsx(s.Button,{onClick:R,disabled:P.isPending,children:P.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 Ns({member:t,selected:n,onToggle:a}){var l,o,c,u;const r=((o=(l=t.user)==null?void 0:l.name)==null?void 0:o.split(" ").map(p=>p[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:a,children:[e.jsx(s.Checkbox,{checked:n}),e.jsx(ae,{className:"h-8 w-8",children:e.jsx(re,{className:"text-xs",children:r})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-sm font-medium",children:((c=t.user)==null?void 0:c.name)||"Unknown User"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:(u=t.user)==null?void 0:u.email})]})]})}function ys({user:t,selected:n,onToggle:a}){var l;const r=((l=t.name)==null?void 0:l.split(" ").map(o=>o[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:a,children:[e.jsx(s.Checkbox,{checked:n}),e.jsx(ae,{className:"h-8 w-8",children:e.jsx(re,{className:"text-xs",children:r})}),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 Ss({open:t,onOpenChange:n}){const[a,r]=f.useState("groups"),[l,o]=f.useState(""),[c,u]=f.useState(null),[p,g]=f.useState(!1),[d,m]=f.useState(null),{tokenProps:x}=s.useSemaphorContext(),{currentUser:j}=s.useCurrentUserInfo(),v=is(),b=(j==null?void 0:j.type)==="tenant",y=x==null?void 0:x.tenantId,{groups:T,isLoading:P,refetch:k}=s.useGroups({type:b?"TENANT_GROUP":"all",tenantId:b?y:void 0,includeMembers:!1}),C=T.filter(N=>{var R;return N.name.toLowerCase().includes(l.toLowerCase())||((R=N.description)==null?void 0:R.toLowerCase().includes(l.toLowerCase()))}),I=async()=>{if(d)try{await v.mutateAsync(d.id),m(null),k()}catch(N){console.error("Failed to delete group:",N)}},L=N=>{u(N),g(!0)},F=()=>{r("groups"),k()};return e.jsxs(e.Fragment,{children:[e.jsx(s.Dialog,{open:t,onOpenChange:n,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:a,onValueChange:r,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$1,{placeholder:"Search groups...",value:l,onChange:N=>o(N.target.value),className:"pl-10"})]}),e.jsx(s.ScrollArea,{className:"h-[400px]",children:P?e.jsx("div",{className:"space-y-3",children:[1,2,3].map(N=>e.jsx(s.Skeleton,{className:"h-24 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.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:l?"Try a different search":"Create your first group to get started"})]}):e.jsx("div",{className:"space-y-3",children:C.map(N=>e.jsx(Ds,{group:N,onManageMembers:()=>L(N),onDelete:()=>m(N),currentUserId:j==null?void 0:j.id},N.id))})})]})}),e.jsx(s.TabsContent,{value:"create",className:"mt-4",children:e.jsx(ds,{onSuccess:F,tenantId:y,isTenantUser:b})})]})]})}),c&&e.jsx(bs,{open:p,onOpenChange:g,group:c,onUpdate:()=>k()}),e.jsx(s.AlertDialog,{open:!!d,onOpenChange:()=>m(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 "',d==null?void 0:d.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:I,disabled:v.isPending,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:v.isPending?e.jsxs(e.Fragment,{children:[e.jsx(s.LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Deleting..."]}):"Delete Group"})]})]})})]})}function Ds({group:t,onManageMembers:n,onDelete:a,currentUserId:r}){const l=t.createdBy===r;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:n,title:"Manage members",children:e.jsx(s.UserPlus,{className:"h-4 w-4"})}),l&&e.jsx(s.Button,{variant:"ghost",size:"sm",onClick:a,title:"Delete group",className:"text-destructive hover:text-destructive",children:e.jsx(s.Trash2,{className:"h-4 w-4"})})]})]})})}function ws(){var de,ue,me;const{authToken:t,tokenProps:n,id:a}=s.useSemaphorContext(),{isLocalDev:r}=s.useDashboardPreferences(),{permissions:l}=$e.useRoleAwareDisplayPreferences(),o=s.useHasDashboardId(),{isLoading:c}=s.useDashboardQuery();s.useDashboardStore(i=>i.theme);const u=s.useDashboardStore(i=>i.lenses),p=s.useDashboardStore(i=>i.selectedLensId),g=u==null?void 0:u.find(i=>i.id===p),d=s.useDashboardStore(i=>i.dashboard);s.useDashboardStore(i=>i.selectedSheetId);const m=s.useDashboardStore(i=>i.isDashboardEditing),{setDashboardTitle:x}=s.useDashboardStore(i=>i.actions),[j,v]=f.useState(!1),[b,y]=f.useState(!1),[T,P]=f.useState(!1),[k,C]=f.useState(!1),[I,L]=f.useState(null),[F,N]=f.useState(!1),R=s.useDashboardStore(i=>i.isDashboardPanelOpen),K=s.useDashboardStore(i=>i.actions.setIsDashboardPanelOpen),J=s.useDashboardStore(i=>i.filterValues),S=s.useDashboardStore(i=>i.isVisualEditing);s.useEditorStore(i=>i.card);const h=s.useManagementStore(i=>i.selectedDashboard),D=s.useManagementStore(i=>i.initialDashboard);s.useManagementStore(i=>i.selectedVisual),s.useDashboardStore(i=>i.selectedFrameId),s.useEditorStore(i=>i.frame);const M=h?(ue=h==null?void 0:h.permissions)==null?void 0:ue.canEdit:(de=D==null?void 0:D.permissions)==null?void 0:de.canEdit,E=s.useDashboardStore(i=>i.showFilters),z=s.useDashboardStore(i=>i.showDashboardJSON),O=s.useDashboardStore(i=>i.onSaveFunction),De=s.useDashboardStore(i=>i.actions.setShowFilters),{setIsDashboardEditing:ne,setShowDashboardJSON:oe}=s.useDashboardStore(i=>i.actions),{setInitialDashboard:ie,clearSelectedDashboard:we}=s.useManagementStore(i=>i.actions),{resources:_}=s.useResourceManagement(s.ResourceType.DASHBOARD),{currentUser:Ce}=s.useCurrentUserInfo(),Me=s.canUserManageGroups(Ce),U=h||D,le=U?{id:U.id,title:(d==null?void 0:d.title)||U.title||"Dashboard"}:null,{handleAddNewFrame:Ae}=s.useAddNewFrame(),[q,W]=f.useState(!1),[Le,Q]=f.useState(!1),H=s.useUpdateResource(s.ResourceType.DASHBOARD),[B,X]=f.useState(null),ke=async(i,A)=>{if(!(d!=null&&d.id)){console.log("No dashboard ID found");return}console.log("Updating dashboard title:",{dashboardId:d.id,newTitle:i,previousTitle:A}),H.mutate({resourceId:d.id,data:{title:i}},{onSuccess:()=>{console.log("Dashboard title updated successfully"),s.ue.success("Dashboard title updated")},onError:$=>{console.error("Failed to update dashboard title:",$),s.ue.error("Failed to update dashboard title"),x(A)}})};f.useEffect(()=>{if(_&&_.length>0){const i=d==null?void 0:d.id;if(i){const A=_.find($=>$.id===i);A&&ie(A)}}},[_,d==null?void 0:d.id,ie]);const V=n.orgUserId||n.tenantId,Ie=m&&!S&&V&&M,{setDashboard:Te}=s.useDashboardStore(i=>i.actions),Pe=()=>{ne(!0)},Y=()=>{ne(!1),oe(!1),X(null)};G.usePristineSnapshotInitializer(m,d,B,i=>X(i));const Ee=()=>B?JSON.stringify(d)!==JSON.stringify(B):!1,Fe=()=>{Ee()?Q(!0):Y()},Re=async()=>{await Z({closeAfterSave:!0})},Oe=()=>{B&&Te(B),Y(),Q(!1)};async function Z(i){const A=(i==null?void 0:i.closeAfterSave)??F;N(A),A&&Q(!1);const $=s.cloneDeep(d);C(!0),L(null),W(!0);const Be={template:d};H.mutate({resourceId:d.id,data:Be},{onSuccess:()=>{W(!1),s.ue.success("Dashboard saved!"),X($),C(!1),N(!1),A&&Y()},onError:()=>{W(!1),L("Failed to save dashboard. Please try again."),s.ue.error("Failed to save dashboard")}})}async function Ue(){if(v(!0),!p||!g)return;const i=JSON.stringify(d),A={...g,template:i,filterValues:J};await ee(n.apiServiceUrl,A,t==null?void 0:t.accessToken),s.ue.success("Lens saved"),O==null||O(d),v(!1)}const ce=(g==null?void 0:g.name)||d.title;H.isPending&&console.log("Title during update:",{title:ce,dashboardStateTitle:d.title,dashboardId:d==null?void 0:d.id,currentLensName:g==null?void 0:g.name});const Ge=n.orgUserId||n.tenantId&&n.endUserId&&n.endUserEmail,qe=o;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:[Ge&&e.jsxs(e.Fragment,{children:[e.jsx(s.IconButton,{"aria-label":"Manage Dashboards",tooltip:"Manage Dashboards",onClick:()=>{K(!R)},className:"h-7 p-2",children:e.jsx(Qe,{className:"h-4 w-4"})}),qe&&!S&&e.jsx(s.IconButton,{"aria-label":"Dashboard Hub",tooltip:"Dashboard Hub",onClick:()=>we(),className:"h-7 p-2",children:e.jsx(s.House,{className:"h-4 w-4"})})]}),!S&&o&&(c?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:ce||"Untitled Dashboard",onSave:i=>{console.log("EditableText onSave called:",{newTitle:i,canEditDashboard:M,dashboardId:d==null?void 0:d.id});const A=(d==null?void 0:d.title)||"";x(i),ke(i,A)},isEditable:M&&!g,displayClassName:"text-sm font-medium",inputClassName:"text-sm font-medium",placeholder:"Dashboard Title",isPending:H.isPending}))]}),e.jsxs("div",{className:"flex items-center gap-2",children:[S&&e.jsxs(e.Fragment,{children:[e.jsx(G.AdvancedModeToggle,{className:"mr-2"}),e.jsx(G.VisualEditingControls,{className:"h-7"})]}),r&&!S&&e.jsxs(e.Fragment,{children:[e.jsx(s.IconButton,{tooltip:"Copy Token",onClick:()=>{var i;t!=null&&t.accessToken&&((i=navigator==null?void 0:navigator.clipboard)!=null&&i.writeText?navigator.clipboard.writeText(t.accessToken).then(()=>s.ue.success("Token copied to clipboard")).catch(()=>s.ue.error("Unable to copy token")):s.ue.error("Clipboard not available"))},className:"h-7 p-2",children:e.jsx(s.Copy,{className:"h-4 w-4"})}),e.jsx(s.IconButton,{tooltip:"Invalidate Token",onClick:()=>s.invalidateToken(n.apiServiceUrl),className:"h-7 p-2",children:e.jsx(Ve,{className:"h-4 w-4"})})]}),!S&&o&&e.jsx(ss,{}),!S&&o&&e.jsx(G.ScheduleDashboard,{}),!S&&o&&Me&&e.jsx(s.IconButton,{tooltip:"Manage Groups",onClick:()=>P(!0),className:"h-7 p-2",children:e.jsx(s.Users,{className:"h-4 w-4"})}),!S&&o&&((me=U==null?void 0:U.permissions)==null?void 0:me.canShare)&&e.jsx(s.IconButton,{tooltip:"Share Dashboard",onClick:()=>y(!0),className:"h-7 p-2",children:e.jsx(s.Share2,{className:"h-4 w-4"})}),!E&&!S&&m&&l.canUseFilters&&o&&e.jsx(s.Button,{className:"h-7 p-2",variant:"outline",onClick:()=>De(!0),size:"sm",children:e.jsx(s.Filter,{className:"h-4 w-4"})}),m&&!S&&V&&r&&o&&e.jsx(Ze,{}),!S&&V&&r&&o&&e.jsx(es,{}),m&&!S&&V&&g&&r&&o&&e.jsxs(s.Button,{className:"h-7 p-2",variant:"secondary",disabled:j,onClick:Ue,size:"sm",children:[e.jsx(he.Save,{className:"mr-2 h-4 w-4"}),"Save Lens"]}),m&&!S&&o&&e.jsxs(s.Button,{variant:"outline",className:"h-7 p-2",size:"sm",disabled:!m,onClick:()=>Ae(),children:[e.jsx(s.Plus,{className:"mr-2 h-4 w-4"}),"Visual"]}),!S&&!m&&M&&o&&e.jsxs(s.Button,{variant:"outline",className:"h-7 p-2",onClick:Pe,size:"sm",children:[e.jsx(s.Pencil,{className:"mr-2 h-4 w-4"}),"Edit"]}),Ie&&o&&e.jsxs(s.Button,{className:"h-7 p-2",disabled:q,onClick:()=>Z(),size:"sm",children:[q?e.jsx(s.LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}):e.jsx(he.Save,{className:"mr-2 h-4 w-4"}),q?"Saving...":"Save"]}),!S&&m&&r&&o&&e.jsx("div",{className:"flex items-center space-x-2",children:e.jsx(s.Button,{className:"h-7 p-2",onClick:()=>oe(!z),size:"sm",variant:"ghost",children:e.jsx(s.Code,{className:"h-4 w-4"})})}),!S&&r&&e.jsx(We,{}),m&&!S&&o&&e.jsxs(s.Button,{variant:"outline",className:"h-7 p-2",onClick:Fe,children:[e.jsx(s.Cross2Icon,{className:"mr-2 h-4 w-4"}),"Close"]}),b&&le&&e.jsx(s.ShareDialog,{resource:le,resourceType:s.ResourceType.DASHBOARD,onClose:()=>y(!1)}),e.jsx(Ss,{open:T,onOpenChange:P}),e.jsx(s.AlertDialog,{open:k,onOpenChange:i=>{!i&&q&&!I||(C(i),i||(L(null),N(!1)))},children:e.jsxs(s.AlertDialogContent,{className:"max-w-sm",children:[e.jsxs(s.AlertDialogHeader,{children:[e.jsx(s.AlertDialogTitle,{children:I?"Save failed":"Saving dashboard"}),e.jsx(s.AlertDialogDescription,{className:"pt-2",children:I?"We could not save the dashboard. Please try again.":"Please wait while we save your changes."})]}),e.jsx(s.AlertDialogFooter,{className:"flex-col gap-2 sm:flex-row sm:justify-end",children:I?e.jsxs(e.Fragment,{children:[e.jsx(s.AlertDialogCancel,{onClick:()=>{C(!1),L(null),N(!1)},className:"m-0",children:"Close"}),e.jsx(s.AlertDialogAction,{onClick:()=>Z(),className:"m-0",children:"Retry"})]}):e.jsxs(s.AlertDialogAction,{disabled:!0,className:"m-0 cursor-default",children:[e.jsx(s.LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Saving..."]})})]})}),e.jsx(G.UnsavedChangesAlert,{open:Le,onOpenChange:Q,onSave:Re,onDiscard:Oe,isSaving:q})]})]})}exports.default=ws;