react-semaphor 0.1.228 → 0.1.230

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