react-semaphor 0.1.229 → 0.1.231

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 (32) hide show
  1. package/dist/chunks/dashboard-controls-D5LGwleP.js +47 -0
  2. package/dist/chunks/dashboard-controls-WDfLhTmh.js +1837 -0
  3. package/dist/chunks/{dashboard-json-C6i1R8Wf.js → dashboard-json-BWWfRH2_.js} +1 -1
  4. package/dist/chunks/{dashboard-json-Bb4sPs1-.js → dashboard-json-DXunjBeA.js} +1 -1
  5. package/dist/chunks/{dashboard-summary-settings-dialog-B-EIaEfz.js → dashboard-summary-settings-dialog-BzEEwHOF.js} +1 -1
  6. package/dist/chunks/{dashboard-summary-settings-dialog-B5oZC5Et.js → dashboard-summary-settings-dialog-CB5TScfc.js} +23 -23
  7. package/dist/chunks/{edit-dashboard-visual-BrR2eN_x.js → edit-dashboard-visual-CCQoz0-3.js} +3 -3
  8. package/dist/chunks/{edit-dashboard-visual-BhqnGTNb.js → edit-dashboard-visual-Ct8MHaNG.js} +461 -461
  9. package/dist/chunks/{editor-action-buttons-BuGSShg4.js → editor-action-buttons-TCC22i95.js} +42 -42
  10. package/dist/chunks/{editor-action-buttons-DZHYde-x.js → editor-action-buttons-acRlz-51.js} +1 -1
  11. package/dist/chunks/{index-C_FfPMsT.js → index-BSv9U5tc.js} +5658 -5645
  12. package/dist/chunks/{index--t-xJkFo.js → index-CcysLOA4.js} +161 -161
  13. package/dist/chunks/{notification-bell-BJx5GZ0K.js → notification-bell-a6BxRjVN.js} +60 -60
  14. package/dist/chunks/{notification-bell-BUK6qo6E.js → notification-bell-z7oT5LAh.js} +1 -1
  15. package/dist/chunks/resource-management-panel-6WdgxllK.js +6 -0
  16. package/dist/chunks/resource-management-panel-BacphZKd.js +920 -0
  17. package/dist/chunks/{use-visual-utils-C-1MadD0.js → use-visual-utils-Bgi4-2vL.js} +33 -33
  18. package/dist/chunks/{use-visual-utils-CckIJVB_.js → use-visual-utils-CUrMP3ER.js} +1 -1
  19. package/dist/dashboard/index.cjs +1 -1
  20. package/dist/dashboard/index.js +1 -1
  21. package/dist/index.cjs +1 -1
  22. package/dist/index.js +44 -44
  23. package/dist/style.css +1 -1
  24. package/dist/surfboard/index.cjs +1 -1
  25. package/dist/surfboard/index.js +2 -2
  26. package/package.json +1 -1
  27. package/dist/chunks/dashboard-controls-C4Yq0TiH.js +0 -1764
  28. package/dist/chunks/dashboard-controls-DUVPeEnP.js +0 -47
  29. package/dist/chunks/resource-management-panel-C--Zp8ix.js +0 -6
  30. package/dist/chunks/resource-management-panel-CliUOxsc.js +0 -913
  31. package/dist/chunks/use-role-aware-display-preferences-Dza-JBu0.js +0 -29
  32. package/dist/chunks/use-role-aware-display-preferences-YdbXXiO7.js +0 -1
@@ -0,0 +1,1837 @@
1
+ import { jsxs as r, jsx as e, Fragment as M } from "react/jsx-runtime";
2
+ import { bK as Z, cL as wa, u as w, c0 as Ke, c1 as Qe, B as E, c3 as We, c4 as j, cM as Je, N as Es, b as G, e as Xe, cN as xa, b$ as Ye, f as Ze, g as es, h as ss, i as Ls, L as Re, I as oe, v as Da, a4 as V, cO as fe, c8 as Ge, cP as Ca, cQ as Ns, cR as As, c as X, cS as ks, cT as Ea, cq as as, cU as La, cV as Aa, cW as ka, cX as Ma, cY as Oa, cZ as Ia, H as be, c_ as ye, x as k, c$ as Ms, cA as Ta, d0 as _a, w as Y, c7 as H, d1 as Pa, d2 as Ua, d3 as Fe, d4 as Ra, d5 as Ga, d6 as Os, d7 as Is, d8 as ge, d9 as ve, cw as Ve, ce as je, da as qe, c9 as Ts, db as He, dc as _s, dd as Fa, ch as Ps, ci as Us, cj as Rs, ck as Gs, cl as Fs, cm as Vs, cn as js, co as $e, b_ as Va, de as ja, aa as qa, U as Ss, a9 as pe, df as Ha, ag as $a, ab as Te, dg as za, dh as Ba, di as Ka, av as Qa, dj as Wa, dk as Ja, bR as Xa, bS as Ya, bT as Za, dl as et, bV as st, c5 as at, an as tt, dm as rt, dn as nt, dp as ot, dq as it, dr as lt, ds as ct, c2 as dt, a6 as ut, cb as mt, dt as ht, af as pt, a7 as ft, am as gt } from "./index-BSv9U5tc.js";
3
+ import * as L from "react";
4
+ import qs, { useState as S, useMemo as q, useEffect as vt, useCallback as bt } from "react";
5
+ import "react-dom";
6
+ import { b as yt, u as Nt, c as St, A as wt, V as xt, N as Dt, U as Ct } from "./notification-bell-a6BxRjVN.js";
7
+ import { d as Et } from "./date-formatter-Y8Za1ib3.js";
8
+ import { C as Lt, D as At } from "./dashboard-summary-settings-dialog-CB5TScfc.js";
9
+ import { u as kt } from "./use-debounced-dirty-check-BwAbnX_5.js";
10
+ import { s as _e } from "./normalize-dashboard-for-dirty-check-Bn27S0PN.js";
11
+ import { S as ws } from "./editor-action-buttons-TCC22i95.js";
12
+ /**
13
+ * @license lucide-react v0.453.0 - ISC
14
+ *
15
+ * This source code is licensed under the ISC license.
16
+ * See the LICENSE file in the root directory of this source tree.
17
+ */
18
+ const Mt = Z("FilterX", [
19
+ ["path", { d: "M13.013 3H2l8 9.46V19l4 2v-8.54l.9-1.055", key: "1fi1da" }],
20
+ ["path", { d: "m22 3-5 5", key: "12jva0" }],
21
+ ["path", { d: "m17 3 5 5", key: "k36vhe" }]
22
+ ]);
23
+ /**
24
+ * @license lucide-react v0.453.0 - ISC
25
+ *
26
+ * This source code is licensed under the ISC license.
27
+ * See the LICENSE file in the root directory of this source tree.
28
+ */
29
+ const Ot = Z("Glasses", [
30
+ ["circle", { cx: "6", cy: "15", r: "4", key: "vux9w4" }],
31
+ ["circle", { cx: "18", cy: "15", r: "4", key: "18o8ve" }],
32
+ ["path", { d: "M14 15a2 2 0 0 0-2-2 2 2 0 0 0-2 2", key: "1ag4bs" }],
33
+ ["path", { d: "M2.5 13 5 7c.7-1.3 1.4-2 3-2", key: "1hm1gs" }],
34
+ ["path", { d: "M21.5 13 19 7c-.7-1.3-1.5-2-3-2", key: "1r31ai" }]
35
+ ]);
36
+ /**
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
+ */
42
+ const It = Z("Menu", [
43
+ ["line", { x1: "4", x2: "20", y1: "12", y2: "12", key: "1e0a9i" }],
44
+ ["line", { x1: "4", x2: "20", y1: "6", y2: "6", key: "1owob3" }],
45
+ ["line", { x1: "4", x2: "20", y1: "18", y2: "18", key: "yk5zj1" }]
46
+ ]);
47
+ /**
48
+ * @license lucide-react v0.453.0 - ISC
49
+ *
50
+ * This source code is licensed under the ISC license.
51
+ * See the LICENSE file in the root directory of this source tree.
52
+ */
53
+ const Tt = Z("Moon", [
54
+ ["path", { d: "M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z", key: "a7tn18" }]
55
+ ]);
56
+ /**
57
+ * @license lucide-react v0.453.0 - ISC
58
+ *
59
+ * This source code is licensed under the ISC license.
60
+ * See the LICENSE file in the root directory of this source tree.
61
+ */
62
+ const _t = Z("ShieldX", [
63
+ [
64
+ "path",
65
+ {
66
+ 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",
67
+ key: "oel41y"
68
+ }
69
+ ],
70
+ ["path", { d: "m14.5 9.5-5 5", key: "17q4r4" }],
71
+ ["path", { d: "m9.5 9.5 5 5", key: "18nt4w" }]
72
+ ]);
73
+ /**
74
+ * @license lucide-react v0.453.0 - ISC
75
+ *
76
+ * This source code is licensed under the ISC license.
77
+ * See the LICENSE file in the root directory of this source tree.
78
+ */
79
+ const Pt = Z("Sun", [
80
+ ["circle", { cx: "12", cy: "12", r: "4", key: "4exip2" }],
81
+ ["path", { d: "M12 2v2", key: "tus03m" }],
82
+ ["path", { d: "M12 20v2", key: "1lh1kg" }],
83
+ ["path", { d: "m4.93 4.93 1.41 1.41", key: "149t6j" }],
84
+ ["path", { d: "m17.66 17.66 1.41 1.41", key: "ptbguv" }],
85
+ ["path", { d: "M2 12h2", key: "1t8f8n" }],
86
+ ["path", { d: "M20 12h2", key: "1q8mjw" }],
87
+ ["path", { d: "m6.34 17.66-1.41 1.41", key: "1m8zz5" }],
88
+ ["path", { d: "m19.07 4.93-1.41 1.41", key: "1shlcs" }]
89
+ ]);
90
+ var ze = { exports: {} }, Pe = {};
91
+ /**
92
+ * @license React
93
+ * use-sync-external-store-shim.production.js
94
+ *
95
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
96
+ *
97
+ * This source code is licensed under the MIT license found in the
98
+ * LICENSE file in the root directory of this source tree.
99
+ */
100
+ var xs;
101
+ function Ut() {
102
+ if (xs) return Pe;
103
+ xs = 1;
104
+ var s = qs;
105
+ function n(d, h) {
106
+ return d === h && (d !== 0 || 1 / d === 1 / h) || d !== d && h !== h;
107
+ }
108
+ var t = typeof Object.is == "function" ? Object.is : n, a = s.useState, o = s.useEffect, l = s.useLayoutEffect, u = s.useDebugValue;
109
+ function m(d, h) {
110
+ var f = h(), v = a({ inst: { value: f, getSnapshot: h } }), y = v[0].inst, N = v[1];
111
+ return l(
112
+ function() {
113
+ y.value = f, y.getSnapshot = h, p(y) && N({ inst: y });
114
+ },
115
+ [d, f, h]
116
+ ), o(
117
+ function() {
118
+ return p(y) && N({ inst: y }), d(function() {
119
+ p(y) && N({ inst: y });
120
+ });
121
+ },
122
+ [d]
123
+ ), u(f), f;
124
+ }
125
+ function p(d) {
126
+ var h = d.getSnapshot;
127
+ d = d.value;
128
+ try {
129
+ var f = h();
130
+ return !t(d, f);
131
+ } catch {
132
+ return !0;
133
+ }
134
+ }
135
+ function g(d, h) {
136
+ return h();
137
+ }
138
+ var c = typeof window > "u" || typeof window.document > "u" || typeof window.document.createElement > "u" ? g : m;
139
+ return Pe.useSyncExternalStore = s.useSyncExternalStore !== void 0 ? s.useSyncExternalStore : c, Pe;
140
+ }
141
+ var Ue = {};
142
+ /**
143
+ * @license React
144
+ * use-sync-external-store-shim.development.js
145
+ *
146
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
147
+ *
148
+ * This source code is licensed under the MIT license found in the
149
+ * LICENSE file in the root directory of this source tree.
150
+ */
151
+ var Ds;
152
+ function Rt() {
153
+ return Ds || (Ds = 1, process.env.NODE_ENV !== "production" && function() {
154
+ function s(f, v) {
155
+ return f === v && (f !== 0 || 1 / f === 1 / v) || f !== f && v !== v;
156
+ }
157
+ function n(f, v) {
158
+ c || o.startTransition === void 0 || (c = !0, console.error(
159
+ "You are using an outdated, pre-release alpha of React 18 that does not support useSyncExternalStore. The use-sync-external-store shim will not work correctly. Upgrade to a newer pre-release."
160
+ ));
161
+ var y = v();
162
+ if (!d) {
163
+ var N = v();
164
+ l(y, N) || (console.error(
165
+ "The result of getSnapshot should be cached to avoid an infinite loop"
166
+ ), d = !0);
167
+ }
168
+ N = u({
169
+ inst: { value: y, getSnapshot: v }
170
+ });
171
+ var A = N[0].inst, T = N[1];
172
+ return p(
173
+ function() {
174
+ A.value = y, A.getSnapshot = v, t(A) && T({ inst: A });
175
+ },
176
+ [f, y, v]
177
+ ), m(
178
+ function() {
179
+ return t(A) && T({ inst: A }), f(function() {
180
+ t(A) && T({ inst: A });
181
+ });
182
+ },
183
+ [f]
184
+ ), g(y), y;
185
+ }
186
+ function t(f) {
187
+ var v = f.getSnapshot;
188
+ f = f.value;
189
+ try {
190
+ var y = v();
191
+ return !l(f, y);
192
+ } catch {
193
+ return !0;
194
+ }
195
+ }
196
+ function a(f, v) {
197
+ return v();
198
+ }
199
+ typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ < "u" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart == "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
200
+ var o = qs, l = typeof Object.is == "function" ? Object.is : s, u = o.useState, m = o.useEffect, p = o.useLayoutEffect, g = o.useDebugValue, c = !1, d = !1, h = typeof window > "u" || typeof window.document > "u" || typeof window.document.createElement > "u" ? a : n;
201
+ Ue.useSyncExternalStore = o.useSyncExternalStore !== void 0 ? o.useSyncExternalStore : h, typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ < "u" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop == "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());
202
+ }()), Ue;
203
+ }
204
+ process.env.NODE_ENV === "production" ? ze.exports = Ut() : ze.exports = Rt();
205
+ var Gt = ze.exports;
206
+ function Ft() {
207
+ const { setTheme: s } = wa(), n = w(
208
+ (t) => t.actions.setDashboardTheme
209
+ );
210
+ return /* @__PURE__ */ r(Ke, { children: [
211
+ /* @__PURE__ */ e(Qe, { asChild: !0, children: /* @__PURE__ */ r(E, { className: "h-7 p-2", variant: "ghost", size: "sm", children: [
212
+ /* @__PURE__ */ e(
213
+ Pt,
214
+ {
215
+ strokeWidth: 1.5,
216
+ className: "h-4 w-4 rotate-0 scale-100 transition-all dark:-rotate-90 dark:scale-0"
217
+ }
218
+ ),
219
+ /* @__PURE__ */ e(
220
+ Tt,
221
+ {
222
+ strokeWidth: 1.5,
223
+ className: "absolute h-4 w-4 rotate-90 scale-0 transition-all dark:rotate-0 dark:scale-100"
224
+ }
225
+ ),
226
+ /* @__PURE__ */ e("span", { className: "sr-only", children: "Toggle theme" })
227
+ ] }) }),
228
+ /* @__PURE__ */ r(We, { align: "end", children: [
229
+ /* @__PURE__ */ e(
230
+ j,
231
+ {
232
+ onClick: () => {
233
+ s("light"), n("light");
234
+ },
235
+ children: "Light"
236
+ }
237
+ ),
238
+ /* @__PURE__ */ e(
239
+ j,
240
+ {
241
+ onClick: () => {
242
+ s("dark"), n("dark");
243
+ },
244
+ children: "Dark"
245
+ }
246
+ ),
247
+ /* @__PURE__ */ e(
248
+ j,
249
+ {
250
+ onClick: () => {
251
+ s("system"), n("system");
252
+ },
253
+ children: "System"
254
+ }
255
+ )
256
+ ] })
257
+ ] });
258
+ }
259
+ async function Vt(s, n, t, a, o) {
260
+ if (!o)
261
+ return null;
262
+ const l = JSON.stringify(t), u = `${s}/v1/lens`;
263
+ return await Je(u, o, {
264
+ name: n,
265
+ template: l,
266
+ filterValues: a,
267
+ operation: "create"
268
+ });
269
+ }
270
+ async function Be(s, n, t) {
271
+ if (!t)
272
+ return null;
273
+ const { id: a, template: o, filterValues: l, isDefault: u, shared: m } = n, p = `${s}/v1/lens`;
274
+ return await Je(p, t, {
275
+ lensId: a,
276
+ template: o,
277
+ filterValues: l,
278
+ isDefault: u,
279
+ shared: m,
280
+ operation: "update"
281
+ });
282
+ }
283
+ async function jt(s, n, t) {
284
+ if (!t)
285
+ return null;
286
+ const a = `${s}/v1/lens`;
287
+ return await Je(a, t, {
288
+ operation: "delete",
289
+ lensId: n
290
+ });
291
+ }
292
+ function qt() {
293
+ const [s, n] = S(""), [t, a] = S(!1), o = w((N) => N.lenses), { setLenses: l, setSelectedLensId: u } = Es(), [m, p] = S(!1), [g, c] = S(!1), d = w((N) => N.dashboard), h = w((N) => N.filterValues), { authToken: f, tokenProps: v } = G();
294
+ async function y() {
295
+ p(!0);
296
+ const N = await Vt(
297
+ v.apiServiceUrl,
298
+ s,
299
+ d,
300
+ h,
301
+ f == null ? void 0 : f.accessToken
302
+ );
303
+ N && (l([...o || [], N]), u(N.id), c(!1)), p(!1);
304
+ }
305
+ return /* @__PURE__ */ r(Xe, { open: g, onOpenChange: c, children: [
306
+ /* @__PURE__ */ e(xa, { asChild: !0, children: /* @__PURE__ */ r(
307
+ E,
308
+ {
309
+ variant: "secondary",
310
+ className: "h-7 p-2",
311
+ size: "sm",
312
+ children: [
313
+ /* @__PURE__ */ e(Ye, { className: "mr-2 h-4 w-4" }),
314
+ "Lens"
315
+ ]
316
+ }
317
+ ) }),
318
+ /* @__PURE__ */ r(Ze, { className: "sm:max-w-[425px]", children: [
319
+ /* @__PURE__ */ r(es, { children: [
320
+ /* @__PURE__ */ e(ss, { children: "Create Lens" }),
321
+ /* @__PURE__ */ e(Ls, { children: "Lenses are private by default and are only visible to you." })
322
+ ] }),
323
+ /* @__PURE__ */ e("div", { className: "grid gap-4 py-4", children: /* @__PURE__ */ r("div", { className: "grid grid-cols-8 items-center gap-4", children: [
324
+ /* @__PURE__ */ e(Re, { className: "text-right", children: "Name" }),
325
+ /* @__PURE__ */ e(
326
+ oe,
327
+ {
328
+ value: s,
329
+ onChange: (N) => {
330
+ n(N.target.value);
331
+ },
332
+ id: "name",
333
+ className: "col-span-7 focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0"
334
+ }
335
+ )
336
+ ] }) }),
337
+ t && /* @__PURE__ */ e("p", { className: "text-sm", children: "The lens name already exists. Use a differnet name." }),
338
+ /* @__PURE__ */ e(Da, { children: /* @__PURE__ */ e(
339
+ E,
340
+ {
341
+ size: "sm",
342
+ variant: "outline",
343
+ type: "submit",
344
+ onClick: y,
345
+ disabled: m,
346
+ children: m ? "Creating..." : "Add"
347
+ }
348
+ ) })
349
+ ] })
350
+ ] });
351
+ }
352
+ function Ht() {
353
+ const [s, n] = S(!1), t = w((d) => d.lenses), a = w((d) => d.selectedLensId), { setLenses: o, setSelectedLensId: l } = Es(), { authToken: u, tokenProps: m } = G();
354
+ async function p(d) {
355
+ l(d);
356
+ }
357
+ async function g(d) {
358
+ if (await jt(m.apiServiceUrl, d, u == null ? void 0 : u.accessToken)) {
359
+ const f = t == null ? void 0 : t.filter((v) => v.id !== d);
360
+ o(f || []), l("original");
361
+ }
362
+ }
363
+ async function c(d) {
364
+ const h = t == null ? void 0 : t.map((y) => y.id === d.id ? {
365
+ ...y,
366
+ isDefault: !d.isDefault
367
+ } : {
368
+ ...y,
369
+ isDefault: !1
370
+ });
371
+ o(h || []);
372
+ const f = {
373
+ ...d,
374
+ isDefault: !d.isDefault
375
+ };
376
+ await Be(m.apiServiceUrl, f, u == null ? void 0 : u.accessToken);
377
+ const v = t == null ? void 0 : t.find((y) => y.isDefault);
378
+ if (v && v.id !== d.id) {
379
+ const y = {
380
+ ...v,
381
+ isDefault: !1
382
+ };
383
+ await Be(m.apiServiceUrl, y, u == null ? void 0 : u.accessToken);
384
+ }
385
+ }
386
+ return /* @__PURE__ */ r(Ke, { open: s, onOpenChange: n, children: [
387
+ /* @__PURE__ */ e(Qe, { asChild: !0, children: /* @__PURE__ */ e(V, { tooltip: "Lenses", className: "h-7 p-2", children: /* @__PURE__ */ e(Ot, { className: "h-4 w-4" }) }) }),
388
+ /* @__PURE__ */ r(We, { align: "end", className: "w-60", children: [
389
+ /* @__PURE__ */ e(fe, { className: "px-3", children: "Lenses" }),
390
+ /* @__PURE__ */ e(Ge, {}),
391
+ /* @__PURE__ */ r(
392
+ Ca,
393
+ {
394
+ value: a,
395
+ onValueChange: p,
396
+ children: [
397
+ /* @__PURE__ */ e(Ns, { value: "original", children: "Original" }),
398
+ t == null ? void 0 : t.map((d) => /* @__PURE__ */ r(
399
+ Ns,
400
+ {
401
+ className: "group flex justify-between gap-2",
402
+ value: d.id,
403
+ children: [
404
+ /* @__PURE__ */ e("p", { children: d.name }),
405
+ /* @__PURE__ */ r("span", { className: "flex items-center gap-3", children: [
406
+ /* @__PURE__ */ e(
407
+ As,
408
+ {
409
+ onClick: (h) => {
410
+ h.preventDefault(), c(d);
411
+ },
412
+ className: X(
413
+ "size-3.5 text-muted-foreground hover:cursor-pointer hover:text-foreground group-hover:visible",
414
+ {
415
+ invisible: !d.isDefault,
416
+ "text-green-500": d.isDefault
417
+ }
418
+ ),
419
+ strokeWidth: 1.5
420
+ }
421
+ ),
422
+ /* @__PURE__ */ e(
423
+ ks,
424
+ {
425
+ onClick: (h) => {
426
+ h.preventDefault(), g(d.id);
427
+ },
428
+ className: "invisible size-3.5 text-muted-foreground hover:cursor-pointer hover:text-foreground group-hover:visible",
429
+ strokeWidth: 1.5
430
+ }
431
+ )
432
+ ] })
433
+ ]
434
+ },
435
+ d.id
436
+ ))
437
+ ]
438
+ }
439
+ )
440
+ ] })
441
+ ] });
442
+ }
443
+ function $t() {
444
+ const { displayPreferences: s, shouldShowElement: n } = Ea(), { currentUser: t, userContext: a } = as(), o = q(
445
+ () => La(t),
446
+ [t]
447
+ ), l = q(() => (m) => o && o[m] !== void 0 && o[m] === !1 ? !1 : n(m), [o, n, s]), u = q(
448
+ () => {
449
+ var m, p, g, c, d;
450
+ return {
451
+ canEdit: ((m = a == null ? void 0 : a.permissions) == null ? void 0 : m.canEdit) ?? Ia(t),
452
+ canUseFilters: ((p = a == null ? void 0 : a.permissions) == null ? void 0 : p.canEdit) ?? Oa(t),
453
+ canManageDashboards: ((g = a == null ? void 0 : a.permissions) == null ? void 0 : g.canCreateDashboard) ?? Ma(t),
454
+ canCreateDashboards: ((c = a == null ? void 0 : a.permissions) == null ? void 0 : c.canCreateDashboard) ?? ka(t),
455
+ canAccessVisuals: ((d = a == null ? void 0 : a.permissions) == null ? void 0 : d.canEdit) ?? Aa(t)
456
+ };
457
+ },
458
+ [t, a]
459
+ );
460
+ return {
461
+ displayPreferences: s,
462
+ shouldShowElement: l,
463
+ permissions: u,
464
+ currentUser: t
465
+ };
466
+ }
467
+ const zt = async (s, n, t) => {
468
+ const a = `${s}/management/v1/groups`;
469
+ return await Ms(a, n, t);
470
+ }, Bt = async (s, n, t) => {
471
+ const a = `${s}/management/v1/groups/${t}`, o = await fetch(a, {
472
+ method: "DELETE",
473
+ headers: {
474
+ Authorization: `Bearer ${n}`
475
+ }
476
+ });
477
+ if (!o.ok) {
478
+ const l = await o.text();
479
+ throw new Error(l || "Failed to delete group");
480
+ }
481
+ }, Kt = async (s, n, t, a) => {
482
+ const o = `${s}/management/v1/groups/${t}/members`;
483
+ return await Ms(o, n, a);
484
+ }, Qt = async (s, n, t, a) => {
485
+ const o = `${s}/management/v1/groups/${t}/members`, l = await fetch(o, {
486
+ method: "DELETE",
487
+ headers: {
488
+ "Content-Type": "application/json",
489
+ Authorization: `Bearer ${n}`
490
+ },
491
+ body: JSON.stringify(a)
492
+ });
493
+ if (!l.ok) {
494
+ const u = await l.text();
495
+ throw new Error(u || "Failed to remove group members");
496
+ }
497
+ };
498
+ function Wt() {
499
+ const { authToken: s, tokenProps: n } = G(), t = be();
500
+ return ye({
501
+ mutationFn: (a) => zt(n.apiServiceUrl, (s == null ? void 0 : s.accessToken) || "", a),
502
+ onSuccess: () => {
503
+ t.invalidateQueries({ queryKey: ["groups"] }), k.success("Group created successfully");
504
+ },
505
+ onError: (a) => {
506
+ console.error("Failed to create group:", a), k.error("Failed to create group", {
507
+ description: a.message
508
+ });
509
+ }
510
+ });
511
+ }
512
+ function Jt() {
513
+ const { authToken: s, tokenProps: n } = G(), t = be();
514
+ return ye({
515
+ mutationFn: (a) => Bt(n.apiServiceUrl, (s == null ? void 0 : s.accessToken) || "", a),
516
+ onSuccess: (a, o) => {
517
+ t.invalidateQueries({ queryKey: ["groups"] }), t.removeQueries({ queryKey: ["group", o] }), k.success("Group deleted successfully");
518
+ },
519
+ onError: (a) => {
520
+ console.error("Failed to delete group:", a), k.error("Failed to delete group", {
521
+ description: a.message
522
+ });
523
+ }
524
+ });
525
+ }
526
+ function Xt() {
527
+ const { authToken: s, tokenProps: n } = G(), t = be();
528
+ return ye({
529
+ mutationFn: ({
530
+ groupId: a,
531
+ data: o
532
+ }) => Kt(n.apiServiceUrl, (s == null ? void 0 : s.accessToken) || "", a, o),
533
+ onSuccess: (a, o) => {
534
+ t.invalidateQueries({ queryKey: ["group", o.groupId] }), t.invalidateQueries({
535
+ queryKey: ["group-members", o.groupId]
536
+ }), t.invalidateQueries({ queryKey: ["groups"] }), k.success("Members added successfully");
537
+ },
538
+ onError: (a) => {
539
+ console.error("Failed to add group members:", a), k.error("Failed to add members", {
540
+ description: a.message
541
+ });
542
+ }
543
+ });
544
+ }
545
+ function Yt() {
546
+ const { authToken: s, tokenProps: n } = G(), t = be();
547
+ return ye({
548
+ mutationFn: ({
549
+ groupId: a,
550
+ data: o
551
+ }) => Qt(n.apiServiceUrl, (s == null ? void 0 : s.accessToken) || "", a, o),
552
+ onSuccess: (a, o) => {
553
+ t.invalidateQueries({ queryKey: ["group", o.groupId] }), t.invalidateQueries({
554
+ queryKey: ["group-members", o.groupId]
555
+ }), t.invalidateQueries({ queryKey: ["groups"] }), k.success("Members removed successfully");
556
+ },
557
+ onError: (a) => {
558
+ console.error("Failed to remove group members:", a), k.error("Failed to remove members", {
559
+ description: a.message
560
+ });
561
+ }
562
+ });
563
+ }
564
+ function Zt({
565
+ onSuccess: s,
566
+ tenantId: n,
567
+ isTenantUser: t
568
+ }) {
569
+ const [a, o] = S(""), [l, u] = S(""), [m, p] = S({}), g = Wt(), c = () => {
570
+ const h = {};
571
+ 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", l && l.length > 200 && (h.description = "Description must be less than 200 characters"), p(h), Object.keys(h).length === 0;
572
+ };
573
+ return /* @__PURE__ */ r("form", { onSubmit: async (h) => {
574
+ if (h.preventDefault(), !c()) return;
575
+ const f = {
576
+ name: a.trim(),
577
+ description: l.trim() || void 0,
578
+ type: t ? "TENANT_GROUP" : "ORG_GROUP",
579
+ ...t && n ? { tenantId: n } : {}
580
+ };
581
+ try {
582
+ await g.mutateAsync(f), o(""), u(""), p({}), s();
583
+ } catch (v) {
584
+ console.error("Failed to create group:", v);
585
+ }
586
+ }, className: "space-y-6", children: [
587
+ /* @__PURE__ */ r("div", { className: "space-y-4", children: [
588
+ /* @__PURE__ */ r("div", { className: "space-y-2", children: [
589
+ /* @__PURE__ */ r(Re, { htmlFor: "group-name", children: [
590
+ "Group Name ",
591
+ /* @__PURE__ */ e("span", { className: "text-destructive", children: "*" })
592
+ ] }),
593
+ /* @__PURE__ */ e(
594
+ oe,
595
+ {
596
+ id: "group-name",
597
+ placeholder: "e.g., Marketing Team, Engineering Squad",
598
+ value: a,
599
+ onChange: (h) => {
600
+ o(h.target.value), m.name && p((f) => ({ ...f, name: "" }));
601
+ },
602
+ className: m.name ? "border-destructive" : "",
603
+ disabled: g.isPending
604
+ }
605
+ ),
606
+ m.name && /* @__PURE__ */ e("p", { className: "text-sm text-destructive", children: m.name })
607
+ ] }),
608
+ /* @__PURE__ */ r("div", { className: "space-y-2", children: [
609
+ /* @__PURE__ */ r(Re, { htmlFor: "group-description", children: [
610
+ "Description",
611
+ /* @__PURE__ */ e("span", { className: "ml-2 text-xs text-muted-foreground", children: "(optional)" })
612
+ ] }),
613
+ /* @__PURE__ */ e(
614
+ Ta,
615
+ {
616
+ id: "group-description",
617
+ placeholder: "Describe the purpose of this group...",
618
+ value: l,
619
+ onChange: (h) => {
620
+ u(h.target.value), m.description && p((f) => ({ ...f, description: "" }));
621
+ },
622
+ className: m.description ? "border-destructive" : "",
623
+ disabled: g.isPending,
624
+ rows: 3
625
+ }
626
+ ),
627
+ m.description && /* @__PURE__ */ e("p", { className: "text-sm text-destructive", children: m.description }),
628
+ /* @__PURE__ */ r("p", { className: "text-xs text-muted-foreground", children: [
629
+ l.length,
630
+ "/200 characters"
631
+ ] })
632
+ ] }),
633
+ /* @__PURE__ */ e("div", { className: "rounded-lg border bg-muted/50 p-4", children: /* @__PURE__ */ r("div", { className: "flex gap-3", children: [
634
+ /* @__PURE__ */ e(_a, { className: "h-4 w-4 mt-0.5 text-muted-foreground" }),
635
+ /* @__PURE__ */ e("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." })
636
+ ] }) })
637
+ ] }),
638
+ /* @__PURE__ */ r("div", { className: "flex justify-end gap-3", children: [
639
+ /* @__PURE__ */ e(
640
+ E,
641
+ {
642
+ type: "button",
643
+ variant: "outline",
644
+ onClick: () => {
645
+ o(""), u(""), p({});
646
+ },
647
+ disabled: g.isPending,
648
+ children: "Clear"
649
+ }
650
+ ),
651
+ /* @__PURE__ */ e(
652
+ E,
653
+ {
654
+ type: "submit",
655
+ disabled: g.isPending || !a.trim(),
656
+ children: g.isPending ? /* @__PURE__ */ r(M, { children: [
657
+ /* @__PURE__ */ e(Y, { className: "mr-2 h-4 w-4 animate-spin" }),
658
+ "Creating..."
659
+ ] }) : /* @__PURE__ */ r(M, { children: [
660
+ /* @__PURE__ */ e(H, { className: "mr-2 h-4 w-4" }),
661
+ "Create Group"
662
+ ] })
663
+ }
664
+ )
665
+ ] })
666
+ ] });
667
+ }
668
+ function er(s, n = []) {
669
+ let t = [];
670
+ function a(l, u) {
671
+ const m = L.createContext(u);
672
+ m.displayName = l + "Context";
673
+ const p = t.length;
674
+ t = [...t, u];
675
+ const g = (d) => {
676
+ var A;
677
+ const { scope: h, children: f, ...v } = d, y = ((A = h == null ? void 0 : h[s]) == null ? void 0 : A[p]) || m, N = L.useMemo(() => v, Object.values(v));
678
+ return /* @__PURE__ */ e(y.Provider, { value: N, children: f });
679
+ };
680
+ g.displayName = l + "Provider";
681
+ function c(d, h) {
682
+ var y;
683
+ const f = ((y = h == null ? void 0 : h[s]) == null ? void 0 : y[p]) || m, v = L.useContext(f);
684
+ if (v) return v;
685
+ if (u !== void 0) return u;
686
+ throw new Error(`\`${d}\` must be used within \`${l}\``);
687
+ }
688
+ return [g, c];
689
+ }
690
+ const o = () => {
691
+ const l = t.map((u) => L.createContext(u));
692
+ return function(m) {
693
+ const p = (m == null ? void 0 : m[s]) || l;
694
+ return L.useMemo(
695
+ () => ({ [`__scope${s}`]: { ...m, [s]: p } }),
696
+ [m, p]
697
+ );
698
+ };
699
+ };
700
+ return o.scopeName = s, [a, sr(o, ...n)];
701
+ }
702
+ function sr(...s) {
703
+ const n = s[0];
704
+ if (s.length === 1) return n;
705
+ const t = () => {
706
+ const a = s.map((o) => ({
707
+ useScope: o(),
708
+ scopeName: o.scopeName
709
+ }));
710
+ return function(l) {
711
+ const u = a.reduce((m, { useScope: p, scopeName: g }) => {
712
+ const d = p(l)[`__scope${g}`];
713
+ return { ...m, ...d };
714
+ }, {});
715
+ return L.useMemo(() => ({ [`__scope${n.scopeName}`]: u }), [u]);
716
+ };
717
+ };
718
+ return t.scopeName = n.scopeName, t;
719
+ }
720
+ var ar = [
721
+ "a",
722
+ "button",
723
+ "div",
724
+ "form",
725
+ "h2",
726
+ "h3",
727
+ "img",
728
+ "input",
729
+ "label",
730
+ "li",
731
+ "nav",
732
+ "ol",
733
+ "p",
734
+ "select",
735
+ "span",
736
+ "svg",
737
+ "ul"
738
+ ], ts = ar.reduce((s, n) => {
739
+ const t = Pa(`Primitive.${n}`), a = L.forwardRef((o, l) => {
740
+ const { asChild: u, ...m } = o, p = u ? t : n;
741
+ return typeof window < "u" && (window[Symbol.for("radix-ui")] = !0), /* @__PURE__ */ e(p, { ...m, ref: l });
742
+ });
743
+ return a.displayName = `Primitive.${n}`, { ...s, [n]: a };
744
+ }, {});
745
+ function tr() {
746
+ return Gt.useSyncExternalStore(
747
+ rr,
748
+ () => !0,
749
+ () => !1
750
+ );
751
+ }
752
+ function rr() {
753
+ return () => {
754
+ };
755
+ }
756
+ var rs = "Avatar", [nr] = er(rs), [or, Hs] = nr(rs), $s = L.forwardRef(
757
+ (s, n) => {
758
+ const { __scopeAvatar: t, ...a } = s, [o, l] = L.useState("idle");
759
+ return /* @__PURE__ */ e(
760
+ or,
761
+ {
762
+ scope: t,
763
+ imageLoadingStatus: o,
764
+ onImageLoadingStatusChange: l,
765
+ children: /* @__PURE__ */ e(ts.span, { ...a, ref: n })
766
+ }
767
+ );
768
+ }
769
+ );
770
+ $s.displayName = rs;
771
+ var zs = "AvatarImage", Bs = L.forwardRef(
772
+ (s, n) => {
773
+ const { __scopeAvatar: t, src: a, onLoadingStatusChange: o = () => {
774
+ }, ...l } = s, u = Hs(zs, t), m = ir(a, l), p = Ua((g) => {
775
+ o(g), u.onImageLoadingStatusChange(g);
776
+ });
777
+ return Fe(() => {
778
+ m !== "idle" && p(m);
779
+ }, [m, p]), m === "loaded" ? /* @__PURE__ */ e(ts.img, { ...l, ref: n, src: a }) : null;
780
+ }
781
+ );
782
+ Bs.displayName = zs;
783
+ var Ks = "AvatarFallback", Qs = L.forwardRef(
784
+ (s, n) => {
785
+ const { __scopeAvatar: t, delayMs: a, ...o } = s, l = Hs(Ks, t), [u, m] = L.useState(a === void 0);
786
+ return L.useEffect(() => {
787
+ if (a !== void 0) {
788
+ const p = window.setTimeout(() => m(!0), a);
789
+ return () => window.clearTimeout(p);
790
+ }
791
+ }, [a]), u && l.imageLoadingStatus !== "loaded" ? /* @__PURE__ */ e(ts.span, { ...o, ref: n }) : null;
792
+ }
793
+ );
794
+ Qs.displayName = Ks;
795
+ function Cs(s, n) {
796
+ return s ? n ? (s.src !== n && (s.src = n), s.complete && s.naturalWidth > 0 ? "loaded" : "loading") : "error" : "idle";
797
+ }
798
+ function ir(s, { referrerPolicy: n, crossOrigin: t }) {
799
+ const a = tr(), o = L.useRef(null), l = a ? (o.current || (o.current = new window.Image()), o.current) : null, [u, m] = L.useState(
800
+ () => Cs(l, s)
801
+ );
802
+ return Fe(() => {
803
+ m(Cs(l, s));
804
+ }, [l, s]), Fe(() => {
805
+ const p = (d) => () => {
806
+ m(d);
807
+ };
808
+ if (!l) return;
809
+ const g = p("loaded"), c = p("error");
810
+ return l.addEventListener("load", g), l.addEventListener("error", c), n && (l.referrerPolicy = n), typeof t == "string" && (l.crossOrigin = t), () => {
811
+ l.removeEventListener("load", g), l.removeEventListener("error", c);
812
+ };
813
+ }, [l, t, n]), u;
814
+ }
815
+ var Ws = $s, Js = Bs, Xs = Qs;
816
+ const ns = L.forwardRef(({ className: s, ...n }, t) => /* @__PURE__ */ e(
817
+ Ws,
818
+ {
819
+ ref: t,
820
+ className: X(
821
+ "relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full",
822
+ s
823
+ ),
824
+ ...n
825
+ }
826
+ ));
827
+ ns.displayName = Ws.displayName;
828
+ const lr = L.forwardRef(({ className: s, ...n }, t) => /* @__PURE__ */ e(
829
+ Js,
830
+ {
831
+ ref: t,
832
+ className: X("aspect-square h-full w-full", s),
833
+ ...n
834
+ }
835
+ ));
836
+ lr.displayName = Js.displayName;
837
+ const os = L.forwardRef(({ className: s, ...n }, t) => /* @__PURE__ */ e(
838
+ Xs,
839
+ {
840
+ ref: t,
841
+ className: X(
842
+ "flex h-full w-full items-center justify-center rounded-full bg-muted",
843
+ s
844
+ ),
845
+ ...n
846
+ }
847
+ ));
848
+ os.displayName = Xs.displayName;
849
+ function cr({
850
+ open: s,
851
+ onOpenChange: n,
852
+ group: t,
853
+ onUpdate: a
854
+ }) {
855
+ const [o, l] = S("members"), [u, m] = S(""), [p, g] = S([]), [c, d] = S([]), { data: h, isLoading: f, refetch: v } = Ra(t.id), y = t.type === "TENANT_GROUP" ? "tenant" : "organization", { users: N, isLoading: A } = Ga({
856
+ type: y,
857
+ tenantId: t.tenantId || void 0,
858
+ active: !0,
859
+ limit: 100
860
+ }), T = Xt(), P = Yt(), O = (h == null ? void 0 : h.members) || [], $ = q(() => new Set(O.map((b) => b.userId)), [O]), R = q(() => N.filter((b) => !$.has(b.id)), [N, $]), z = q(() => {
861
+ if (!u) return R;
862
+ const b = u.toLowerCase();
863
+ return R.filter(
864
+ (C) => {
865
+ var _, F;
866
+ return ((_ = C.name) == null ? void 0 : _.toLowerCase().includes(b)) || ((F = C.email) == null ? void 0 : F.toLowerCase().includes(b));
867
+ }
868
+ );
869
+ }, [R, u]), x = q(() => {
870
+ if (!u) return O;
871
+ const b = u.toLowerCase();
872
+ return O.filter(
873
+ (C) => {
874
+ var _, F, ie, D;
875
+ return ((F = (_ = C.user) == null ? void 0 : _.name) == null ? void 0 : F.toLowerCase().includes(b)) || ((D = (ie = C.user) == null ? void 0 : ie.email) == null ? void 0 : D.toLowerCase().includes(b));
876
+ }
877
+ );
878
+ }, [O, u]), B = async () => {
879
+ if (p.length !== 0)
880
+ try {
881
+ await T.mutateAsync({
882
+ groupId: t.id,
883
+ data: {
884
+ userIds: p,
885
+ userType: y === "tenant" ? "tenant" : "org"
886
+ }
887
+ }), g([]), l("members"), v(), a == null || a();
888
+ } catch (b) {
889
+ console.error("Failed to add members:", b);
890
+ }
891
+ }, K = async () => {
892
+ if (c.length !== 0)
893
+ try {
894
+ await P.mutateAsync({
895
+ groupId: t.id,
896
+ data: {
897
+ userIds: c
898
+ }
899
+ }), d([]), v(), a == null || a();
900
+ } catch (b) {
901
+ console.error("Failed to remove members:", b);
902
+ }
903
+ }, Q = (b) => {
904
+ g(
905
+ (C) => C.includes(b) ? C.filter((_) => _ !== b) : [...C, b]
906
+ );
907
+ }, W = (b) => {
908
+ d(
909
+ (C) => C.includes(b) ? C.filter((_) => _ !== b) : [...C, b]
910
+ );
911
+ };
912
+ return /* @__PURE__ */ e(M, { children: /* @__PURE__ */ e(Xe, { open: s, onOpenChange: n, children: /* @__PURE__ */ r(Ze, { className: "max-w-3xl max-h-[80vh]", "aria-describedby": "group-members-description", children: [
913
+ /* @__PURE__ */ r(es, { children: [
914
+ /* @__PURE__ */ e(ss, { children: t.name }),
915
+ /* @__PURE__ */ e("div", { className: "flex items-center gap-2 mt-1", children: /* @__PURE__ */ r("p", { className: "text-sm text-muted-foreground", children: [
916
+ O.length,
917
+ " ",
918
+ O.length === 1 ? "member" : "members"
919
+ ] }) }),
920
+ /* @__PURE__ */ r("p", { id: "group-members-description", className: "sr-only", children: [
921
+ "Add or remove members from the ",
922
+ t.name,
923
+ " group"
924
+ ] })
925
+ ] }),
926
+ /* @__PURE__ */ r(Os, { value: o, onValueChange: (b) => {
927
+ l(b), m(""), d([]);
928
+ }, className: "mt-4", children: [
929
+ /* @__PURE__ */ r(Is, { className: "grid w-full grid-cols-2", children: [
930
+ /* @__PURE__ */ e(ge, { value: "members", children: "Current Members" }),
931
+ /* @__PURE__ */ e(ge, { value: "add", children: "Add Members" })
932
+ ] }),
933
+ /* @__PURE__ */ r(ve, { value: "members", className: "mt-4 space-y-4", children: [
934
+ /* @__PURE__ */ r("div", { className: "relative", children: [
935
+ /* @__PURE__ */ e(Ve, { className: "absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground" }),
936
+ /* @__PURE__ */ e(
937
+ oe,
938
+ {
939
+ placeholder: "Search members...",
940
+ value: u,
941
+ onChange: (b) => m(b.target.value),
942
+ className: "pl-10"
943
+ }
944
+ )
945
+ ] }),
946
+ /* @__PURE__ */ e(je, { className: c.length > 0 ? "h-[300px]" : "h-[350px]", children: f ? /* @__PURE__ */ e("div", { className: "space-y-2", children: [1, 2, 3].map((b) => /* @__PURE__ */ e(qe, { className: "h-16 w-full" }, b)) }) : x.length === 0 ? /* @__PURE__ */ r("div", { className: "flex flex-col items-center justify-center py-12 text-muted-foreground", children: [
947
+ /* @__PURE__ */ e(H, { className: "h-12 w-12 mb-3 opacity-50" }),
948
+ /* @__PURE__ */ e("p", { className: "text-sm font-medium", children: u ? "No members found" : "No members yet" }),
949
+ /* @__PURE__ */ e("p", { className: "text-xs mt-1", children: u ? "Try a different search" : 'Switch to the "Add Members" tab to add people to this group' })
950
+ ] }) : /* @__PURE__ */ e("div", { className: "space-y-2", children: x.map((b) => /* @__PURE__ */ e(
951
+ dr,
952
+ {
953
+ member: b,
954
+ selected: c.includes(b.userId),
955
+ onToggle: () => W(b.userId)
956
+ },
957
+ b.id
958
+ )) }) }),
959
+ c.length > 0 && /* @__PURE__ */ r("div", { className: "flex items-center justify-between pt-4 border-t", children: [
960
+ /* @__PURE__ */ r("span", { className: "text-sm text-muted-foreground", children: [
961
+ c.length,
962
+ " member",
963
+ c.length !== 1 ? "s" : "",
964
+ " selected"
965
+ ] }),
966
+ /* @__PURE__ */ e(
967
+ E,
968
+ {
969
+ variant: "destructive",
970
+ size: "sm",
971
+ onClick: K,
972
+ disabled: P.isPending,
973
+ children: P.isPending ? /* @__PURE__ */ r(M, { children: [
974
+ /* @__PURE__ */ e(Y, { className: "mr-2 h-4 w-4 animate-spin" }),
975
+ "Removing..."
976
+ ] }) : /* @__PURE__ */ r(M, { children: [
977
+ /* @__PURE__ */ e(Ts, { className: "mr-2 h-4 w-4" }),
978
+ "Remove Selected"
979
+ ] })
980
+ }
981
+ )
982
+ ] })
983
+ ] }),
984
+ /* @__PURE__ */ r(ve, { value: "add", className: "mt-4 space-y-4", children: [
985
+ /* @__PURE__ */ r("div", { className: "relative", children: [
986
+ /* @__PURE__ */ e(Ve, { className: "absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground" }),
987
+ /* @__PURE__ */ e(
988
+ oe,
989
+ {
990
+ placeholder: "Search users to add...",
991
+ value: u,
992
+ onChange: (b) => m(b.target.value),
993
+ className: "pl-10"
994
+ }
995
+ )
996
+ ] }),
997
+ /* @__PURE__ */ e(je, { className: "h-[300px]", children: A ? /* @__PURE__ */ e("div", { className: "space-y-2", children: [1, 2, 3].map((b) => /* @__PURE__ */ e(qe, { className: "h-16 w-full" }, b)) }) : z.length === 0 ? /* @__PURE__ */ r("div", { className: "flex flex-col items-center justify-center py-12 text-muted-foreground", children: [
998
+ /* @__PURE__ */ e(He, { className: "h-12 w-12 mb-3 opacity-50" }),
999
+ /* @__PURE__ */ e("p", { className: "text-sm font-medium", children: "No available users" }),
1000
+ /* @__PURE__ */ e("p", { className: "text-xs mt-1", children: u ? "Try a different search" : "All eligible users are already members" })
1001
+ ] }) : /* @__PURE__ */ e("div", { className: "space-y-2", children: z.map((b) => /* @__PURE__ */ e(
1002
+ ur,
1003
+ {
1004
+ user: b,
1005
+ selected: p.includes(b.id),
1006
+ onToggle: () => Q(b.id)
1007
+ },
1008
+ b.id
1009
+ )) }) }),
1010
+ p.length > 0 && /* @__PURE__ */ r("div", { className: "flex items-center justify-between pt-4 border-t", children: [
1011
+ /* @__PURE__ */ r("span", { className: "text-sm text-muted-foreground", children: [
1012
+ p.length,
1013
+ " user",
1014
+ p.length !== 1 ? "s" : "",
1015
+ " selected"
1016
+ ] }),
1017
+ /* @__PURE__ */ e(
1018
+ E,
1019
+ {
1020
+ onClick: B,
1021
+ disabled: T.isPending,
1022
+ children: T.isPending ? /* @__PURE__ */ r(M, { children: [
1023
+ /* @__PURE__ */ e(Y, { className: "mr-2 h-4 w-4 animate-spin" }),
1024
+ "Adding..."
1025
+ ] }) : /* @__PURE__ */ r(M, { children: [
1026
+ /* @__PURE__ */ e(He, { className: "mr-2 h-4 w-4" }),
1027
+ "Add Members"
1028
+ ] })
1029
+ }
1030
+ )
1031
+ ] })
1032
+ ] })
1033
+ ] })
1034
+ ] }) }) });
1035
+ }
1036
+ function dr({
1037
+ member: s,
1038
+ selected: n,
1039
+ onToggle: t
1040
+ }) {
1041
+ var o, l, u, m;
1042
+ const a = ((l = (o = s.user) == null ? void 0 : o.name) == null ? void 0 : l.split(" ").map((p) => p[0]).join("").toUpperCase()) || "?";
1043
+ return /* @__PURE__ */ r(
1044
+ "div",
1045
+ {
1046
+ className: "flex items-center gap-3 p-3 rounded-lg border bg-card hover:bg-muted/50 cursor-pointer",
1047
+ onClick: t,
1048
+ children: [
1049
+ /* @__PURE__ */ e(_s, { checked: n }),
1050
+ /* @__PURE__ */ e(ns, { className: "h-8 w-8", children: /* @__PURE__ */ e(os, { className: "text-xs", children: a }) }),
1051
+ /* @__PURE__ */ r("div", { className: "flex-1", children: [
1052
+ /* @__PURE__ */ e("p", { className: "text-sm font-medium", children: ((u = s.user) == null ? void 0 : u.name) || "Unknown User" }),
1053
+ /* @__PURE__ */ e("p", { className: "text-xs text-muted-foreground", children: (m = s.user) == null ? void 0 : m.email })
1054
+ ] })
1055
+ ]
1056
+ }
1057
+ );
1058
+ }
1059
+ function ur({
1060
+ user: s,
1061
+ selected: n,
1062
+ onToggle: t
1063
+ }) {
1064
+ var o;
1065
+ const a = ((o = s.name) == null ? void 0 : o.split(" ").map((l) => l[0]).join("").toUpperCase()) || "?";
1066
+ return /* @__PURE__ */ r(
1067
+ "div",
1068
+ {
1069
+ className: "flex items-center gap-3 p-3 rounded-lg border bg-card hover:bg-muted/50 cursor-pointer",
1070
+ onClick: t,
1071
+ children: [
1072
+ /* @__PURE__ */ e(_s, { checked: n }),
1073
+ /* @__PURE__ */ e(ns, { className: "h-8 w-8", children: /* @__PURE__ */ e(os, { className: "text-xs", children: a }) }),
1074
+ /* @__PURE__ */ r("div", { className: "flex-1", children: [
1075
+ /* @__PURE__ */ e("p", { className: "text-sm font-medium", children: s.name }),
1076
+ /* @__PURE__ */ e("p", { className: "text-xs text-muted-foreground", children: s.email })
1077
+ ] })
1078
+ ]
1079
+ }
1080
+ );
1081
+ }
1082
+ function mr({
1083
+ open: s,
1084
+ onOpenChange: n
1085
+ }) {
1086
+ const [t, a] = S("groups"), [o, l] = S(""), [u, m] = S(null), [p, g] = S(!1), [c, d] = S(null), { tokenProps: h } = G(), { currentUser: f } = as(), v = Jt(), y = (f == null ? void 0 : f.type) === "tenant", N = h == null ? void 0 : h.tenantId, { groups: A, isLoading: T, refetch: P } = Fa({
1087
+ type: y ? "TENANT_GROUP" : "all",
1088
+ tenantId: y ? N : void 0,
1089
+ includeMembers: !1
1090
+ }), O = A.filter(
1091
+ (x) => {
1092
+ var B;
1093
+ return x.name.toLowerCase().includes(o.toLowerCase()) || ((B = x.description) == null ? void 0 : B.toLowerCase().includes(o.toLowerCase()));
1094
+ }
1095
+ ), $ = async () => {
1096
+ if (c)
1097
+ try {
1098
+ await v.mutateAsync(c.id), d(null), P();
1099
+ } catch (x) {
1100
+ console.error("Failed to delete group:", x);
1101
+ }
1102
+ }, R = (x) => {
1103
+ m(x), g(!0);
1104
+ }, z = () => {
1105
+ a("groups"), P();
1106
+ };
1107
+ return /* @__PURE__ */ r(M, { children: [
1108
+ /* @__PURE__ */ e(Xe, { open: s, onOpenChange: n, children: /* @__PURE__ */ r(Ze, { className: "max-w-4xl max-h-[80vh]", children: [
1109
+ /* @__PURE__ */ r(es, { children: [
1110
+ /* @__PURE__ */ r(ss, { className: "flex items-center gap-2", children: [
1111
+ /* @__PURE__ */ e(H, { className: "h-5 w-5" }),
1112
+ "Group Management"
1113
+ ] }),
1114
+ /* @__PURE__ */ e(Ls, { children: "Manage your groups, create new groups, and control group membership" })
1115
+ ] }),
1116
+ /* @__PURE__ */ r(Os, { value: t, onValueChange: a, className: "mt-4", children: [
1117
+ /* @__PURE__ */ r(Is, { className: "grid w-full grid-cols-2", children: [
1118
+ /* @__PURE__ */ r(ge, { value: "groups", className: "flex items-center gap-2", children: [
1119
+ /* @__PURE__ */ e(H, { className: "h-4 w-4" }),
1120
+ "Groups"
1121
+ ] }),
1122
+ /* @__PURE__ */ r(ge, { value: "create", className: "flex items-center gap-2", children: [
1123
+ /* @__PURE__ */ e(Ye, { className: "h-4 w-4" }),
1124
+ "Create Group"
1125
+ ] })
1126
+ ] }),
1127
+ /* @__PURE__ */ e(ve, { value: "groups", className: "mt-4", children: /* @__PURE__ */ r("div", { className: "space-y-4", children: [
1128
+ /* @__PURE__ */ r("div", { className: "relative", children: [
1129
+ /* @__PURE__ */ e(Ve, { className: "absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground" }),
1130
+ /* @__PURE__ */ e(
1131
+ oe,
1132
+ {
1133
+ placeholder: "Search groups...",
1134
+ value: o,
1135
+ onChange: (x) => l(x.target.value),
1136
+ className: "pl-10"
1137
+ }
1138
+ )
1139
+ ] }),
1140
+ /* @__PURE__ */ e(je, { className: "h-[400px]", children: T ? /* @__PURE__ */ e("div", { className: "space-y-3", children: [1, 2, 3].map((x) => /* @__PURE__ */ e(qe, { className: "h-24 w-full" }, x)) }) : O.length === 0 ? /* @__PURE__ */ r("div", { className: "flex flex-col items-center justify-center py-12 text-muted-foreground", children: [
1141
+ /* @__PURE__ */ e(H, { className: "h-12 w-12 mb-3 opacity-50" }),
1142
+ /* @__PURE__ */ e("p", { className: "text-sm font-medium", children: "No groups found" }),
1143
+ /* @__PURE__ */ e("p", { className: "text-xs mt-1", children: o ? "Try a different search" : "Create your first group to get started" })
1144
+ ] }) : /* @__PURE__ */ e("div", { className: "space-y-3", children: O.map((x) => /* @__PURE__ */ e(
1145
+ hr,
1146
+ {
1147
+ group: x,
1148
+ onManageMembers: () => R(x),
1149
+ onDelete: () => d(x),
1150
+ currentUserId: f == null ? void 0 : f.id
1151
+ },
1152
+ x.id
1153
+ )) }) })
1154
+ ] }) }),
1155
+ /* @__PURE__ */ e(ve, { value: "create", className: "mt-4", children: /* @__PURE__ */ e(
1156
+ Zt,
1157
+ {
1158
+ onSuccess: z,
1159
+ tenantId: N,
1160
+ isTenantUser: y
1161
+ }
1162
+ ) })
1163
+ ] })
1164
+ ] }) }),
1165
+ u && /* @__PURE__ */ e(
1166
+ cr,
1167
+ {
1168
+ open: p,
1169
+ onOpenChange: g,
1170
+ group: u,
1171
+ onUpdate: () => P()
1172
+ }
1173
+ ),
1174
+ /* @__PURE__ */ e(
1175
+ Ps,
1176
+ {
1177
+ open: !!c,
1178
+ onOpenChange: () => d(null),
1179
+ children: /* @__PURE__ */ r(Us, { children: [
1180
+ /* @__PURE__ */ r(Rs, { children: [
1181
+ /* @__PURE__ */ e(Gs, { children: "Delete Group" }),
1182
+ /* @__PURE__ */ r(Fs, { children: [
1183
+ 'Are you sure you want to delete "',
1184
+ c == null ? void 0 : c.name,
1185
+ '"? This action cannot be undone and will remove all members from the group.'
1186
+ ] })
1187
+ ] }),
1188
+ /* @__PURE__ */ r(Vs, { children: [
1189
+ /* @__PURE__ */ e(js, { children: "Cancel" }),
1190
+ /* @__PURE__ */ e(
1191
+ $e,
1192
+ {
1193
+ onClick: $,
1194
+ disabled: v.isPending,
1195
+ className: "bg-destructive text-destructive-foreground hover:bg-destructive/90",
1196
+ children: v.isPending ? /* @__PURE__ */ r(M, { children: [
1197
+ /* @__PURE__ */ e(Y, { className: "mr-2 h-4 w-4 animate-spin" }),
1198
+ "Deleting..."
1199
+ ] }) : "Delete Group"
1200
+ }
1201
+ )
1202
+ ] })
1203
+ ] })
1204
+ }
1205
+ )
1206
+ ] });
1207
+ }
1208
+ function hr({
1209
+ group: s,
1210
+ onManageMembers: n,
1211
+ onDelete: t,
1212
+ currentUserId: a
1213
+ }) {
1214
+ const o = s.createdBy === a;
1215
+ return /* @__PURE__ */ e("div", { className: "rounded-lg border bg-card p-4 transition-colors hover:bg-muted/50", children: /* @__PURE__ */ r("div", { className: "flex items-start justify-between gap-3", children: [
1216
+ /* @__PURE__ */ r("div", { className: "flex-1 space-y-2", children: [
1217
+ /* @__PURE__ */ r("div", { children: [
1218
+ /* @__PURE__ */ e("h4", { className: "font-medium", children: s.name }),
1219
+ s.description && /* @__PURE__ */ e("p", { className: "text-sm text-muted-foreground mt-1", children: s.description })
1220
+ ] }),
1221
+ /* @__PURE__ */ r("div", { className: "flex flex-wrap items-center gap-3 text-xs text-muted-foreground", children: [
1222
+ /* @__PURE__ */ r("span", { className: "flex items-center gap-1", children: [
1223
+ /* @__PURE__ */ e(H, { className: "h-3 w-3" }),
1224
+ s.memberCount,
1225
+ " ",
1226
+ s.memberCount === 1 ? "member" : "members"
1227
+ ] }),
1228
+ /* @__PURE__ */ r("span", { children: [
1229
+ "Created ",
1230
+ Et(new Date(s.createdAt), "MMM d, yyyy")
1231
+ ] })
1232
+ ] })
1233
+ ] }),
1234
+ /* @__PURE__ */ r("div", { className: "flex items-center gap-1", children: [
1235
+ /* @__PURE__ */ e(
1236
+ E,
1237
+ {
1238
+ variant: "ghost",
1239
+ size: "sm",
1240
+ onClick: n,
1241
+ title: "Manage members",
1242
+ children: /* @__PURE__ */ e(He, { className: "h-4 w-4" })
1243
+ }
1244
+ ),
1245
+ o && /* @__PURE__ */ e(
1246
+ E,
1247
+ {
1248
+ variant: "ghost",
1249
+ size: "sm",
1250
+ onClick: t,
1251
+ title: "Delete group",
1252
+ className: "text-destructive hover:text-destructive",
1253
+ children: /* @__PURE__ */ e(Ts, { className: "h-4 w-4" })
1254
+ }
1255
+ )
1256
+ ] })
1257
+ ] }) });
1258
+ }
1259
+ function Dr() {
1260
+ var gs, vs, bs, ys;
1261
+ yt(), Nt();
1262
+ const {
1263
+ authToken: s,
1264
+ tokenProps: n,
1265
+ id: t
1266
+ } = G(), { isLocalDev: a } = Va(), { permissions: o } = $t(), l = ja(), { isLoading: u } = qa();
1267
+ w((i) => i.theme);
1268
+ const m = w((i) => i.lenses), p = w((i) => i.selectedLensId), g = m == null ? void 0 : m.find((i) => i.id === p), c = w((i) => i.dashboard);
1269
+ w((i) => i.selectedSheetId);
1270
+ const d = w(
1271
+ (i) => i.isDashboardEditing
1272
+ ), { setDashboardTitle: h } = w((i) => i.actions), [f, v] = S(!1), [y, N] = S(!1), [A, T] = S(!1), [P, O] = S(!1), [$, R] = S(!1), [z, x] = S(!1), [B, K] = S(!1), [Q, W] = S(null), [b, C] = S(!1), _ = w((i) => i.isDashboardPanelOpen), F = w(
1273
+ (i) => i.actions.setIsDashboardPanelOpen
1274
+ ), ie = w((i) => i.filterValues), D = w((i) => i.isVisualEditing);
1275
+ Ss((i) => i.card);
1276
+ const ee = pe(
1277
+ (i) => i.selectedDashboard
1278
+ ), le = pe(
1279
+ (i) => i.initialDashboard
1280
+ );
1281
+ pe((i) => i.selectedVisual), w((i) => i.selectedFrameId), Ss((i) => i.frame);
1282
+ const ce = ee ? (vs = ee == null ? void 0 : ee.permissions) == null ? void 0 : vs.canEdit : (gs = le == null ? void 0 : le.permissions) == null ? void 0 : gs.canEdit, Ne = w((i) => i.showFilters), Ys = Ha((i) => i.setPanelOpen), Zs = w(
1283
+ (i) => i.showDashboardJSON
1284
+ ), Se = w((i) => i.onSaveFunction), ea = w(
1285
+ (i) => i.actions.setShowFilters
1286
+ ), { setIsDashboardEditing: is, setShowDashboardJSON: ls } = w(
1287
+ (i) => i.actions
1288
+ ), { setInitialDashboard: cs, clearSelectedDashboard: we } = pe(
1289
+ (i) => i.actions
1290
+ ), { resources: de } = $a(Te.DASHBOARD), { data: xe } = za(), sa = ((bs = xe == null ? void 0 : xe.preference) == null ? void 0 : bs.defaultDashboardId) || null, { mutate: aa, isPending: ta } = Ba(), { currentUser: ra } = as(), na = Ka(ra), J = ee || le, ds = J ? {
1291
+ id: J.id,
1292
+ title: (c == null ? void 0 : c.title) || J.title || "Dashboard"
1293
+ } : null, { handleAddNewFrame: oa } = Qa(), [De, Ce] = S(!1), [ia, se] = S(!1), [Ee, ue] = S("close"), ae = Wa(Te.DASHBOARD), [U, Le] = S(
1294
+ null
1295
+ ), la = async (i, I) => {
1296
+ if (!(c != null && c.id)) {
1297
+ console.log("No dashboard ID found");
1298
+ return;
1299
+ }
1300
+ console.log("Updating dashboard title:", {
1301
+ dashboardId: c.id,
1302
+ newTitle: i,
1303
+ previousTitle: I
1304
+ }), ae.mutate(
1305
+ {
1306
+ resourceId: c.id,
1307
+ data: { title: i }
1308
+ },
1309
+ {
1310
+ onSuccess: () => {
1311
+ console.log("Dashboard title updated successfully"), k.success("Dashboard title updated");
1312
+ },
1313
+ onError: (ne) => {
1314
+ console.error("Failed to update dashboard title:", ne), k.error("Failed to update dashboard title"), h(I);
1315
+ }
1316
+ }
1317
+ );
1318
+ };
1319
+ vt(() => {
1320
+ if (de && de.length > 0) {
1321
+ const i = c == null ? void 0 : c.id;
1322
+ if (i) {
1323
+ const I = de.find(
1324
+ (ne) => ne.id === i
1325
+ );
1326
+ I && cs(I);
1327
+ }
1328
+ }
1329
+ }, [de, c == null ? void 0 : c.id, cs]);
1330
+ const me = n.orgUserId || n.tenantId, us = d && !D && me && ce, { setDashboard: Ae } = w((i) => i.actions), ca = () => {
1331
+ is(!0);
1332
+ }, ke = () => {
1333
+ is(!1), ls(!1), Le(null);
1334
+ };
1335
+ St(
1336
+ d,
1337
+ c,
1338
+ U,
1339
+ (i) => Le(i)
1340
+ );
1341
+ const { isDirty: ms, isDirtyPending: da, resetDirty: he } = kt(
1342
+ c,
1343
+ U,
1344
+ 300,
1345
+ 1e3,
1346
+ _e
1347
+ ), hs = bt(() => U ? _e(c) !== _e(U) : !1, [c, U]), Me = ms || da, te = De || ae.isPending, ua = () => {
1348
+ hs() ? (ue("close"), se(!0)) : (ke(), he());
1349
+ }, ma = async () => {
1350
+ await Oe({
1351
+ closeAfterSave: !0,
1352
+ navigateHomeAfterSave: Ee === "home"
1353
+ });
1354
+ }, ha = () => {
1355
+ U && Ae(U), ke(), Ee === "home" && we(), ue("close"), se(!1), he();
1356
+ }, pa = () => {
1357
+ U && (Ae(U), he());
1358
+ }, fa = () => {
1359
+ if (d && hs()) {
1360
+ ue("home"), se(!0);
1361
+ return;
1362
+ }
1363
+ we();
1364
+ };
1365
+ async function Oe(i) {
1366
+ const I = (i == null ? void 0 : i.closeAfterSave) ?? b, ne = (i == null ? void 0 : i.navigateHomeAfterSave) ?? !1;
1367
+ C(I), I && se(!1);
1368
+ const Na = gt(c);
1369
+ K(!0), W(null), Ce(!0);
1370
+ const Sa = {
1371
+ template: c
1372
+ };
1373
+ ae.mutate(
1374
+ {
1375
+ resourceId: c.id,
1376
+ data: Sa
1377
+ },
1378
+ {
1379
+ onSuccess: () => {
1380
+ Ce(!1), k.success("Dashboard saved!"), Le(Na), K(!1), C(!1), I && (ke(), he(), ne && we()), ue("close");
1381
+ },
1382
+ onError: () => {
1383
+ Ce(!1), W("Failed to save dashboard. Please try again."), k.error("Failed to save dashboard");
1384
+ }
1385
+ }
1386
+ );
1387
+ }
1388
+ async function ga() {
1389
+ if (v(!0), !p || !g) return;
1390
+ const i = JSON.stringify(c), I = {
1391
+ ...g,
1392
+ template: i,
1393
+ filterValues: ie
1394
+ };
1395
+ await Be(
1396
+ n.apiServiceUrl,
1397
+ I,
1398
+ s == null ? void 0 : s.accessToken
1399
+ ), k.success("Lens saved"), Se == null || Se(c), v(!1);
1400
+ }
1401
+ const ps = (g == null ? void 0 : g.name) || c.title;
1402
+ ae.isPending && console.log("Title during update:", {
1403
+ title: ps,
1404
+ dashboardStateTitle: c.title,
1405
+ dashboardId: c == null ? void 0 : c.id,
1406
+ currentLensName: g == null ? void 0 : g.name
1407
+ });
1408
+ const fs = n.orgUserId || n.tenantId && n.endUserId && n.endUserEmail, va = !!fs && !!(s != null && s.accessToken) && !!(n != null && n.apiServiceUrl), ba = l, re = (c == null ? void 0 : c.id) || null, Ie = !!re && sa === re, ya = () => {
1409
+ re && aa({
1410
+ dashboardId: Ie ? null : re
1411
+ });
1412
+ };
1413
+ return /* @__PURE__ */ r(
1414
+ "div",
1415
+ {
1416
+ className: "flex h-11 shrink-0 items-center justify-between gap-2 overflow-x-auto border-b px-4 py-2",
1417
+ role: "dashboard-controls",
1418
+ children: [
1419
+ /* @__PURE__ */ r("div", { className: "flex items-center gap-2", children: [
1420
+ fs && /* @__PURE__ */ r(M, { children: [
1421
+ /* @__PURE__ */ e(
1422
+ V,
1423
+ {
1424
+ "aria-label": "Manage Dashboards",
1425
+ tooltip: "Manage Dashboards",
1426
+ onClick: () => {
1427
+ F(!_);
1428
+ },
1429
+ className: "h-7 p-2",
1430
+ children: /* @__PURE__ */ e(It, { className: "h-4 w-4" })
1431
+ }
1432
+ ),
1433
+ ba && !D && /* @__PURE__ */ e(
1434
+ V,
1435
+ {
1436
+ "aria-label": "Dashboard Hub",
1437
+ tooltip: "Dashboard Hub",
1438
+ onClick: fa,
1439
+ className: "h-7 p-2",
1440
+ children: /* @__PURE__ */ e(As, { className: "h-4 w-4" })
1441
+ }
1442
+ )
1443
+ ] }),
1444
+ !D && l && (u ? /* @__PURE__ */ e(
1445
+ "div",
1446
+ {
1447
+ className: "h-4 w-28 rounded-md bg-muted/70 animate-pulse",
1448
+ "aria-label": "Loading dashboard title",
1449
+ role: "status",
1450
+ children: /* @__PURE__ */ e("span", { className: "sr-only", children: "Loading dashboard title" })
1451
+ }
1452
+ ) : /* @__PURE__ */ r(M, { children: [
1453
+ /* @__PURE__ */ e(
1454
+ Ja,
1455
+ {
1456
+ value: ps || "Untitled Dashboard",
1457
+ onSave: (i) => {
1458
+ console.log("EditableText onSave called:", {
1459
+ newTitle: i,
1460
+ canEditDashboard: ce,
1461
+ dashboardId: c == null ? void 0 : c.id
1462
+ });
1463
+ const I = (c == null ? void 0 : c.title) || "";
1464
+ h(i), la(i, I);
1465
+ },
1466
+ isEditable: ce && !g,
1467
+ displayClassName: "text-sm font-medium",
1468
+ inputClassName: "text-sm font-medium",
1469
+ placeholder: "Dashboard Title",
1470
+ isPending: ae.isPending
1471
+ }
1472
+ ),
1473
+ va && re && /* @__PURE__ */ e(Xa, { children: /* @__PURE__ */ r(Ya, { children: [
1474
+ /* @__PURE__ */ e(Za, { asChild: !0, children: /* @__PURE__ */ e(
1475
+ E,
1476
+ {
1477
+ variant: "ghost",
1478
+ size: "icon",
1479
+ onClick: ya,
1480
+ disabled: ta || !(s != null && s.accessToken) || !(n != null && n.apiServiceUrl),
1481
+ className: "h-7 w-7",
1482
+ children: /* @__PURE__ */ e(
1483
+ et,
1484
+ {
1485
+ className: X(
1486
+ "h-4 w-4 transition-colors",
1487
+ Ie ? "fill-yellow-400 text-yellow-400" : "text-muted-foreground hover:text-yellow-400"
1488
+ )
1489
+ }
1490
+ )
1491
+ }
1492
+ ) }),
1493
+ /* @__PURE__ */ e(st, { children: /* @__PURE__ */ e("p", { children: Ie ? "Remove as default dashboard" : "Make this a default dashboard" }) })
1494
+ ] }) })
1495
+ ] }))
1496
+ ] }),
1497
+ /* @__PURE__ */ r("div", { className: "flex items-center gap-2", children: [
1498
+ D && /* @__PURE__ */ r(M, { children: [
1499
+ /* @__PURE__ */ e(wt, { className: "mr-2" }),
1500
+ /* @__PURE__ */ e(xt, { className: "h-7" })
1501
+ ] }),
1502
+ a && !D && /* @__PURE__ */ r(M, { children: [
1503
+ /* @__PURE__ */ e(
1504
+ V,
1505
+ {
1506
+ tooltip: "Copy Token",
1507
+ onClick: () => {
1508
+ var i;
1509
+ s != null && s.accessToken && ((i = navigator == null ? void 0 : navigator.clipboard) != null && i.writeText ? navigator.clipboard.writeText(s.accessToken).then(() => k.success("Token copied to clipboard")).catch(() => k.error("Unable to copy token")) : k.error("Clipboard not available"));
1510
+ },
1511
+ className: "h-7 p-2",
1512
+ children: /* @__PURE__ */ e(at, { className: "h-4 w-4" })
1513
+ }
1514
+ ),
1515
+ /* @__PURE__ */ e(
1516
+ V,
1517
+ {
1518
+ tooltip: "Invalidate Token",
1519
+ onClick: () => tt(n.apiServiceUrl),
1520
+ className: "h-7 p-2",
1521
+ children: /* @__PURE__ */ e(_t, { className: "h-4 w-4" })
1522
+ }
1523
+ )
1524
+ ] }),
1525
+ !D && l && /* @__PURE__ */ e(rt, {}),
1526
+ !D && l && /* @__PURE__ */ e(Dt, {}),
1527
+ !D && l && ((ys = J == null ? void 0 : J.permissions) == null ? void 0 : ys.canShare) && /* @__PURE__ */ e(
1528
+ V,
1529
+ {
1530
+ tooltip: "Share Dashboard",
1531
+ onClick: () => N(!0),
1532
+ className: "h-7 p-2",
1533
+ children: /* @__PURE__ */ e(nt, { className: "h-4 w-4" })
1534
+ }
1535
+ ),
1536
+ !D && d && o.canUseFilters && l && /* @__PURE__ */ r(
1537
+ E,
1538
+ {
1539
+ className: "h-7 px-2",
1540
+ variant: "outline",
1541
+ onClick: () => {
1542
+ Ne || Ys("dashboard", !1), ea(!Ne);
1543
+ },
1544
+ size: "sm",
1545
+ children: [
1546
+ Ne ? /* @__PURE__ */ e(Mt, { className: "mr-2 h-4 w-4" }) : /* @__PURE__ */ e(ot, { className: "mr-2 h-4 w-4" }),
1547
+ "Filter"
1548
+ ]
1549
+ }
1550
+ ),
1551
+ d && !D && me && a && l && /* @__PURE__ */ e(qt, {}),
1552
+ !D && me && a && l && /* @__PURE__ */ e(Ht, {}),
1553
+ d && !D && me && g && a && l && /* @__PURE__ */ r(
1554
+ E,
1555
+ {
1556
+ className: "h-7 p-2",
1557
+ variant: "secondary",
1558
+ disabled: f,
1559
+ onClick: ga,
1560
+ size: "sm",
1561
+ children: [
1562
+ /* @__PURE__ */ e(ws, { className: "mr-2 h-4 w-4" }),
1563
+ "Save Lens"
1564
+ ]
1565
+ }
1566
+ ),
1567
+ d && !D && l && /* @__PURE__ */ r(
1568
+ E,
1569
+ {
1570
+ variant: "outline",
1571
+ className: "h-7 p-2",
1572
+ size: "sm",
1573
+ disabled: !d,
1574
+ onClick: () => oa(),
1575
+ children: [
1576
+ /* @__PURE__ */ e(Ye, { className: "mr-2 h-4 w-4" }),
1577
+ "Visual"
1578
+ ]
1579
+ }
1580
+ ),
1581
+ !D && !d && ce && l && /* @__PURE__ */ r(
1582
+ E,
1583
+ {
1584
+ variant: "outline",
1585
+ className: "h-7 p-2",
1586
+ onClick: ca,
1587
+ size: "sm",
1588
+ children: [
1589
+ /* @__PURE__ */ e(it, { className: "mr-2 h-4 w-4" }),
1590
+ "Edit"
1591
+ ]
1592
+ }
1593
+ ),
1594
+ us && l && ms && /* @__PURE__ */ r(
1595
+ E,
1596
+ {
1597
+ variant: "outline",
1598
+ className: "h-7 p-2",
1599
+ onClick: pa,
1600
+ size: "sm",
1601
+ disabled: te,
1602
+ children: [
1603
+ /* @__PURE__ */ e(lt, { className: "mr-2 h-4 w-4" }),
1604
+ "Undo"
1605
+ ]
1606
+ }
1607
+ ),
1608
+ us && l && /* @__PURE__ */ r("div", { className: "relative inline-flex", children: [
1609
+ /* @__PURE__ */ r(
1610
+ E,
1611
+ {
1612
+ className: X("h-7 p-2", !Me && "opacity-60"),
1613
+ disabled: te || !Me,
1614
+ onClick: () => Oe(),
1615
+ size: "sm",
1616
+ children: [
1617
+ te ? /* @__PURE__ */ e(Y, { className: "mr-2 h-4 w-4 animate-spin" }) : /* @__PURE__ */ e(ws, { className: "mr-2 h-4 w-4" }),
1618
+ te ? "Saving..." : "Save"
1619
+ ]
1620
+ }
1621
+ ),
1622
+ Me && !te && /* @__PURE__ */ e(
1623
+ "span",
1624
+ {
1625
+ "aria-hidden": "true",
1626
+ className: "pointer-events-none absolute -right-1 -top-1 h-2.5 w-2.5 rounded-full bg-orange-500 ring-2 ring-background"
1627
+ }
1628
+ )
1629
+ ] }),
1630
+ !D && d && a && l && /* @__PURE__ */ e("div", { className: "flex items-center space-x-2", children: /* @__PURE__ */ e(
1631
+ E,
1632
+ {
1633
+ className: "h-7 p-2",
1634
+ onClick: () => ls(!Zs),
1635
+ size: "sm",
1636
+ variant: "ghost",
1637
+ children: /* @__PURE__ */ e(ct, { className: "h-4 w-4" })
1638
+ }
1639
+ ) }),
1640
+ !D && a && /* @__PURE__ */ e(Ft, {}),
1641
+ d && !D && l && /* @__PURE__ */ r(
1642
+ E,
1643
+ {
1644
+ variant: "outline",
1645
+ className: "h-7 p-2",
1646
+ onClick: ua,
1647
+ children: [
1648
+ /* @__PURE__ */ e(ks, { className: "mr-2 h-4 w-4" }),
1649
+ "Close"
1650
+ ]
1651
+ }
1652
+ ),
1653
+ !D && l && /* @__PURE__ */ r(Ke, { children: [
1654
+ /* @__PURE__ */ e(Qe, { asChild: !0, children: /* @__PURE__ */ e(
1655
+ V,
1656
+ {
1657
+ tooltip: "More Options",
1658
+ className: "h-8 w-8 rounded-md border border-transparent p-0 text-muted-foreground hover:bg-muted/50 hover:text-foreground",
1659
+ buttonProps: { "aria-label": "More dashboard options" },
1660
+ children: /* @__PURE__ */ e(dt, { className: "h-4 w-4" })
1661
+ }
1662
+ ) }),
1663
+ /* @__PURE__ */ r(
1664
+ We,
1665
+ {
1666
+ align: "end",
1667
+ className: "w-56 rounded-xl border border-border/60 p-1 shadow-sm",
1668
+ children: [
1669
+ /* @__PURE__ */ e(fe, { className: "px-2.5 text-xs font-medium text-muted-foreground", children: "Automation" }),
1670
+ /* @__PURE__ */ r(
1671
+ j,
1672
+ {
1673
+ onClick: () => O(!0),
1674
+ className: "flex items-center gap-2",
1675
+ children: [
1676
+ /* @__PURE__ */ e(ut, { className: "mr-2 h-4 w-4" }),
1677
+ "Schedule Dashboard"
1678
+ ]
1679
+ }
1680
+ ),
1681
+ /* @__PURE__ */ e(Ge, {}),
1682
+ na && /* @__PURE__ */ r(M, { children: [
1683
+ /* @__PURE__ */ e(fe, { className: "px-2.5 text-xs font-medium text-muted-foreground", children: "Access" }),
1684
+ /* @__PURE__ */ r(
1685
+ j,
1686
+ {
1687
+ onClick: () => T(!0),
1688
+ className: "flex items-center gap-2",
1689
+ children: [
1690
+ /* @__PURE__ */ e(H, { className: "mr-2 h-4 w-4" }),
1691
+ "Manage Groups"
1692
+ ]
1693
+ }
1694
+ ),
1695
+ /* @__PURE__ */ e(Ge, {})
1696
+ ] }),
1697
+ /* @__PURE__ */ e(fe, { className: "px-2.5 text-xs font-medium text-muted-foreground", children: "Preferences" }),
1698
+ /* @__PURE__ */ r(
1699
+ j,
1700
+ {
1701
+ onClick: () => R(!0),
1702
+ className: "flex items-center gap-2",
1703
+ children: [
1704
+ /* @__PURE__ */ e(mt, { className: "mr-2 h-4 w-4" }),
1705
+ "Calendar Preferences"
1706
+ ]
1707
+ }
1708
+ ),
1709
+ /* @__PURE__ */ r(
1710
+ j,
1711
+ {
1712
+ onClick: () => x(!0),
1713
+ className: "flex items-center gap-2",
1714
+ children: [
1715
+ /* @__PURE__ */ e(ht, { className: "mr-2 h-4 w-4" }),
1716
+ "Summary Settings"
1717
+ ]
1718
+ }
1719
+ )
1720
+ ]
1721
+ }
1722
+ )
1723
+ ] }),
1724
+ y && ds && /* @__PURE__ */ e(
1725
+ pt,
1726
+ {
1727
+ resource: ds,
1728
+ resourceType: Te.DASHBOARD,
1729
+ onClose: () => N(!1)
1730
+ }
1731
+ ),
1732
+ /* @__PURE__ */ e(
1733
+ mr,
1734
+ {
1735
+ open: A,
1736
+ onOpenChange: T
1737
+ }
1738
+ ),
1739
+ (c == null ? void 0 : c.id) && /* @__PURE__ */ e(
1740
+ ft,
1741
+ {
1742
+ open: P,
1743
+ onOpenChange: O,
1744
+ dashboardId: c.id,
1745
+ dashboardName: c == null ? void 0 : c.title
1746
+ }
1747
+ ),
1748
+ /* @__PURE__ */ e(
1749
+ Lt,
1750
+ {
1751
+ open: $,
1752
+ onOpenChange: R
1753
+ }
1754
+ ),
1755
+ /* @__PURE__ */ e(
1756
+ At,
1757
+ {
1758
+ open: z,
1759
+ onOpenChange: x,
1760
+ dashboard: c,
1761
+ disabled: !d,
1762
+ onApply: (i) => Ae({
1763
+ ...c,
1764
+ summary: i
1765
+ })
1766
+ }
1767
+ ),
1768
+ /* @__PURE__ */ e(
1769
+ Ps,
1770
+ {
1771
+ open: B,
1772
+ onOpenChange: (i) => {
1773
+ !i && De && !Q || (K(i), i || (W(null), C(!1)));
1774
+ },
1775
+ children: /* @__PURE__ */ r(Us, { className: "max-w-sm", children: [
1776
+ /* @__PURE__ */ r(Rs, { children: [
1777
+ /* @__PURE__ */ e(Gs, { children: Q ? "Save failed" : "Saving dashboard" }),
1778
+ /* @__PURE__ */ e(Fs, { className: "pt-2", children: Q ? "We could not save the dashboard. Please try again." : "Please wait while we save your changes." })
1779
+ ] }),
1780
+ /* @__PURE__ */ e(Vs, { className: "flex-col gap-2 sm:flex-row sm:justify-end", children: Q ? /* @__PURE__ */ r(M, { children: [
1781
+ /* @__PURE__ */ e(
1782
+ js,
1783
+ {
1784
+ onClick: () => {
1785
+ K(!1), W(null), C(!1);
1786
+ },
1787
+ className: "m-0",
1788
+ children: "Close"
1789
+ }
1790
+ ),
1791
+ /* @__PURE__ */ e(
1792
+ $e,
1793
+ {
1794
+ onClick: () => Oe({
1795
+ closeAfterSave: b,
1796
+ navigateHomeAfterSave: Ee === "home"
1797
+ }),
1798
+ className: "m-0",
1799
+ children: "Retry"
1800
+ }
1801
+ )
1802
+ ] }) : /* @__PURE__ */ r(
1803
+ $e,
1804
+ {
1805
+ disabled: !0,
1806
+ className: "m-0 cursor-default",
1807
+ children: [
1808
+ /* @__PURE__ */ e(Y, { className: "mr-2 h-4 w-4 animate-spin" }),
1809
+ "Saving..."
1810
+ ]
1811
+ }
1812
+ ) })
1813
+ ] })
1814
+ }
1815
+ ),
1816
+ /* @__PURE__ */ e(
1817
+ Ct,
1818
+ {
1819
+ open: ia,
1820
+ onOpenChange: (i) => {
1821
+ se(i);
1822
+ },
1823
+ onSave: ma,
1824
+ onDiscard: ha,
1825
+ isSaving: De,
1826
+ saveLabel: "Save",
1827
+ discardLabel: "Discard"
1828
+ }
1829
+ )
1830
+ ] })
1831
+ ]
1832
+ }
1833
+ );
1834
+ }
1835
+ export {
1836
+ Dr as default
1837
+ };