react-semaphor 0.1.294 → 0.1.296

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 (40) hide show
  1. package/dist/chunks/{braces-DfDQiR3J.js → braces-BNXseceK.js} +1 -1
  2. package/dist/chunks/{braces-DR-GdaLC.js → braces-DVrX_3Q_.js} +1 -1
  3. package/dist/chunks/dashboard-controls-CKKZcVA5.js +2219 -0
  4. package/dist/chunks/dashboard-controls-DS2xJxHU.js +47 -0
  5. package/dist/chunks/dashboard-filter-controls-button-nqfmscB7.js +11 -0
  6. package/dist/chunks/{dashboard-filter-controls-button-DxgGUl00.js → dashboard-filter-controls-button-xPaIlNHP.js} +501 -495
  7. package/dist/chunks/{dashboard-json-BvTeHePu.js → dashboard-json-cuj9vYY9.js} +1 -1
  8. package/dist/chunks/{dashboard-json-DQW8TN0I.js → dashboard-json-ovQyHWw6.js} +1 -1
  9. package/dist/chunks/{dashboard-summary-settings-dialog-BsmKiGud.js → dashboard-summary-settings-dialog-BUg3Qyhh.js} +1 -1
  10. package/dist/chunks/{dashboard-summary-settings-dialog-q7fx3YAK.js → dashboard-summary-settings-dialog-DF076HeJ.js} +1 -1
  11. package/dist/chunks/{edit-dashboard-visual-RVl9nbDZ.js → edit-dashboard-visual-32TAM00c.js} +5373 -5302
  12. package/dist/chunks/edit-dashboard-visual-BtiMcO-L.js +183 -0
  13. package/dist/chunks/{index-DerPpfv0.js → index-BDeJH9hO.js} +103982 -88259
  14. package/dist/chunks/index-Dbrs96G8.js +1533 -0
  15. package/dist/chunks/{resource-management-panel-epydPwyM.js → resource-management-panel-2qcXsKwg.js} +2 -2
  16. package/dist/chunks/{resource-management-panel-DnZ1rw1A.js → resource-management-panel-C4qoxy_g.js} +31 -30
  17. package/dist/chunks/use-create-flow-overlay-state-BMD3YRzU.js +21 -0
  18. package/dist/chunks/{use-create-flow-overlay-state-C5vdfXhM.js → use-create-flow-overlay-state-CHeppRNE.js} +572 -568
  19. package/dist/chunks/{use-visual-utils-D9Kknvjl.js → use-visual-utils-BIHLaVwh.js} +70 -68
  20. package/dist/chunks/use-visual-utils-dOYWf6nM.js +1 -0
  21. package/dist/dashboard/index.cjs +1 -1
  22. package/dist/dashboard/index.js +1 -1
  23. package/dist/index.cjs +1 -1
  24. package/dist/index.js +113 -112
  25. package/dist/style.css +1 -1
  26. package/dist/surfboard/index.cjs +1 -1
  27. package/dist/surfboard/index.js +2 -2
  28. package/dist/types/dashboard.d.ts +271 -0
  29. package/dist/types/main.d.ts +324 -0
  30. package/dist/types/shared.d.ts +240 -0
  31. package/dist/types/surfboard.d.ts +271 -0
  32. package/dist/types/types.d.ts +271 -0
  33. package/package.json +7 -1
  34. package/dist/chunks/dashboard-controls-C3Z9bpYE.js +0 -2014
  35. package/dist/chunks/dashboard-controls-DGEVXgP5.js +0 -47
  36. package/dist/chunks/dashboard-filter-controls-button-BIYT1ucX.js +0 -11
  37. package/dist/chunks/edit-dashboard-visual-ChKj-Lzr.js +0 -183
  38. package/dist/chunks/index-BlspGR07.js +0 -1435
  39. package/dist/chunks/use-create-flow-overlay-state-Bcg4EgoD.js +0 -21
  40. package/dist/chunks/use-visual-utils-Dw_yw9zU.js +0 -1
@@ -1,2014 +0,0 @@
1
- import { jsx as e, jsxs as c, Fragment as O } from "react/jsx-runtime";
2
- import { c as Y, ds as Ys, u as S, B as E, dt as ma, Q as Za, d as q, e as ha, du as Zs, cw as aa, f as pa, g as fa, h as ga, i as es, L as sa, I as ce, w as et, dv as ie, cN as Ie, dw as at, dx as Ha, dy as as, b as J, dz as ss, dA as st, d2 as va, dB as tt, dC as nt, dD as rt, dE as ot, dF as it, dG as ct, J as Te, Z as _e, y as I, dH as Ue, dI as ts, dJ as ns, db as lt, dK as dt, x as X, dL as ut, dM as mt, dN as ta, dO as ht, dP as pt, dQ as rs, dR as os, dS as Oe, dT as Pe, d7 as na, cS as ra, dU as oa, cM as ba, ck as is, dV as ia, cf as cs, dW as ft, cV as ls, cW as ds, cX as us, cY as ms, cZ as hs, c_ as ps, c$ as fs, d0 as ca, dX as gs, cE as gt, dY as vt, aj as bt, W as ja, ai as Le, dZ as yt, ap as xt, ak as We, d_ as St, d$ as Nt, e0 as Dt, aD as wt, e1 as Ct, aa as Je, e2 as Et, bU as Mt, bV as At, bW as Lt, e3 as kt, bX as It, e4 as Ot, dr as Pt, e5 as Tt, cF as _t, cG as Ut, cH as Rt, cI as Ft, cJ as V, dh as Gt, ac as $t, cP as zt, e6 as Vt, cK as qt, av as Ht, e7 as jt, e8 as Bt, e9 as Kt, ao as Qt, ad as Wt, ea as Jt, a8 as la, eb as Xt } from "./index-DerPpfv0.js";
3
- import * as M from "react";
4
- import vs, { useState as x, useMemo as B, useCallback as Ba, useEffect as Xe } from "react";
5
- import "react-dom";
6
- import { b as Yt, u as Zt, A as en, V as an, c as sn, D as tn, N as nn, U as rn } from "./dashboard-filter-controls-button-DxgGUl00.js";
7
- import { l as on } from "./date-formatter-vkCj9Ct-.js";
8
- import { C as cn, D as ln } from "./dashboard-summary-settings-dialog-q7fx3YAK.js";
9
- import { u as dn } from "./use-debounced-dirty-check-BwAbnX_5.js";
10
- import { s as Ye } from "./normalize-dashboard-for-dirty-check-5KpZN8xr.js";
11
- import { S as Ka } from "./use-create-flow-overlay-state-C5vdfXhM.js";
12
- import { B as un } from "./braces-DfDQiR3J.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 mn = Y("Glasses", [
20
- ["circle", { cx: "6", cy: "15", r: "4", key: "vux9w4" }],
21
- ["circle", { cx: "18", cy: "15", r: "4", key: "18o8ve" }],
22
- ["path", { d: "M14 15a2 2 0 0 0-2-2 2 2 0 0 0-2 2", key: "1ag4bs" }],
23
- ["path", { d: "M2.5 13 5 7c.7-1.3 1.4-2 3-2", key: "1hm1gs" }],
24
- ["path", { d: "M21.5 13 19 7c-.7-1.3-1.5-2-3-2", key: "1r31ai" }]
25
- ]);
26
- /**
27
- * @license lucide-react v0.453.0 - ISC
28
- *
29
- * This source code is licensed under the ISC license.
30
- * See the LICENSE file in the root directory of this source tree.
31
- */
32
- const hn = Y("Menu", [
33
- ["line", { x1: "4", x2: "20", y1: "12", y2: "12", key: "1e0a9i" }],
34
- ["line", { x1: "4", x2: "20", y1: "6", y2: "6", key: "1owob3" }],
35
- ["line", { x1: "4", x2: "20", y1: "18", y2: "18", key: "yk5zj1" }]
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 pn = Y("Monitor", [
44
- ["rect", { width: "20", height: "14", x: "2", y: "3", rx: "2", key: "48i651" }],
45
- ["line", { x1: "8", x2: "16", y1: "21", y2: "21", key: "1svkeh" }],
46
- ["line", { x1: "12", x2: "12", y1: "17", y2: "21", key: "vw1qmm" }]
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 fn = Y("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 gn = Y("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 vn = Y("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 da = { exports: {} }, Ze = {};
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 Qa;
102
- function bn() {
103
- if (Qa) return Ze;
104
- Qa = 1;
105
- var a = vs;
106
- function n(u, r) {
107
- return u === r && (u !== 0 || 1 / u === 1 / r) || u !== u && r !== r;
108
- }
109
- var t = typeof Object.is == "function" ? Object.is : n, s = a.useState, i = a.useEffect, l = a.useLayoutEffect, h = a.useDebugValue;
110
- function m(u, r) {
111
- var p = r(), g = s({ inst: { value: p, getSnapshot: r } }), y = g[0].inst, N = g[1];
112
- return l(
113
- function() {
114
- y.value = p, y.getSnapshot = r, f(y) && N({ inst: y });
115
- },
116
- [u, p, r]
117
- ), i(
118
- function() {
119
- return f(y) && N({ inst: y }), u(function() {
120
- f(y) && N({ inst: y });
121
- });
122
- },
123
- [u]
124
- ), h(p), p;
125
- }
126
- function f(u) {
127
- var r = u.getSnapshot;
128
- u = u.value;
129
- try {
130
- var p = r();
131
- return !t(u, p);
132
- } catch {
133
- return !0;
134
- }
135
- }
136
- function v(u, r) {
137
- return r();
138
- }
139
- var d = typeof window > "u" || typeof window.document > "u" || typeof window.document.createElement > "u" ? v : m;
140
- return Ze.useSyncExternalStore = a.useSyncExternalStore !== void 0 ? a.useSyncExternalStore : d, Ze;
141
- }
142
- var ea = {};
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 Wa;
153
- function yn() {
154
- return Wa || (Wa = 1, process.env.NODE_ENV !== "production" && function() {
155
- function a(p, g) {
156
- return p === g && (p !== 0 || 1 / p === 1 / g) || p !== p && g !== g;
157
- }
158
- function n(p, g) {
159
- d || i.startTransition === void 0 || (d = !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 (!u) {
164
- var N = g();
165
- l(y, N) || (console.error(
166
- "The result of getSnapshot should be cached to avoid an infinite loop"
167
- ), u = !0);
168
- }
169
- N = h({
170
- inst: { value: y, getSnapshot: g }
171
- });
172
- var C = N[0].inst, A = N[1];
173
- return f(
174
- function() {
175
- C.value = y, C.getSnapshot = g, t(C) && A({ inst: C });
176
- },
177
- [p, y, g]
178
- ), m(
179
- function() {
180
- return t(C) && A({ inst: C }), p(function() {
181
- t(C) && A({ inst: C });
182
- });
183
- },
184
- [p]
185
- ), v(y), y;
186
- }
187
- function t(p) {
188
- var g = p.getSnapshot;
189
- p = p.value;
190
- try {
191
- var y = g();
192
- return !l(p, y);
193
- } catch {
194
- return !0;
195
- }
196
- }
197
- function s(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 i = vs, l = typeof Object.is == "function" ? Object.is : a, h = i.useState, m = i.useEffect, f = i.useLayoutEffect, v = i.useDebugValue, d = !1, u = !1, r = typeof window > "u" || typeof window.document > "u" || typeof window.document.createElement > "u" ? s : n;
202
- ea.useSyncExternalStore = i.useSyncExternalStore !== void 0 ? i.useSyncExternalStore : r, typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ < "u" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop == "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());
203
- }()), ea;
204
- }
205
- process.env.NODE_ENV === "production" ? da.exports = bn() : da.exports = yn();
206
- var xn = da.exports;
207
- const ke = ["light", "dark", "system"];
208
- function Sn() {
209
- const { theme: a, setTheme: n } = Ys(), t = S(
210
- (h) => h.actions.setDashboardTheme
211
- );
212
- function s() {
213
- const h = ke.includes(a) ? a : "system", m = ke[(ke.indexOf(h) + 1) % ke.length];
214
- n(m), t(m);
215
- }
216
- const i = a === "light" ? vn : a === "dark" ? fn : pn, l = a === "light" ? "Theme: light (click for dark)" : a === "dark" ? "Theme: dark (click for system)" : "Theme: system (click for light)";
217
- return /* @__PURE__ */ e(
218
- E,
219
- {
220
- type: "button",
221
- variant: "ghost",
222
- size: "xs",
223
- className: "h-7 w-7 p-0 text-muted-foreground hover:text-foreground",
224
- onClick: s,
225
- "aria-label": l,
226
- title: l,
227
- children: /* @__PURE__ */ e(i, { className: "h-3.5 w-3.5", strokeWidth: 1.5 })
228
- }
229
- );
230
- }
231
- async function Nn(a, n, t, s, i) {
232
- if (!i)
233
- return null;
234
- const l = JSON.stringify(t), h = `${a}/v1/lens`;
235
- return await ma(h, i, {
236
- name: n,
237
- template: l,
238
- filterValues: s,
239
- operation: "create"
240
- });
241
- }
242
- async function ua(a, n, t) {
243
- if (!t)
244
- return null;
245
- const { id: s, template: i, filterValues: l, isDefault: h, shared: m } = n, f = `${a}/v1/lens`;
246
- return await ma(f, t, {
247
- lensId: s,
248
- template: i,
249
- filterValues: l,
250
- isDefault: h,
251
- shared: m,
252
- operation: "update"
253
- });
254
- }
255
- async function Dn(a, n, t) {
256
- if (!t)
257
- return null;
258
- const s = `${a}/v1/lens`;
259
- return await ma(s, t, {
260
- operation: "delete",
261
- lensId: n
262
- });
263
- }
264
- const wn = "text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground";
265
- function Cn({
266
- open: a,
267
- onOpenChange: n
268
- } = {}) {
269
- const [t, s] = x(""), [i, l] = x(!1), h = S((D) => D.lenses), { setLenses: m, setSelectedLensId: f } = Za(), [v, d] = x(!1), [u, r] = x(!1), p = a !== void 0, g = p ? a : u, y = (D) => {
270
- p || r(D), n == null || n(D);
271
- }, N = S((D) => D.dashboard), C = S((D) => D.filterValues), { authToken: A, tokenProps: F } = q();
272
- async function P() {
273
- d(!0);
274
- const D = await Nn(
275
- F.apiServiceUrl,
276
- t,
277
- N,
278
- C,
279
- A == null ? void 0 : A.accessToken
280
- );
281
- D && (m([...h || [], D]), f(D.id), y(!1)), d(!1);
282
- }
283
- return /* @__PURE__ */ c(ha, { open: g, onOpenChange: y, children: [
284
- p ? null : /* @__PURE__ */ e(Zs, { asChild: !0, children: /* @__PURE__ */ c(E, { variant: "secondary", size: "xs", children: [
285
- /* @__PURE__ */ e(aa, { className: "h-3.5 w-3.5" }),
286
- "Lens"
287
- ] }) }),
288
- /* @__PURE__ */ c(pa, { className: "rounded-[6px] border-border/60 sm:max-w-[420px] sm:rounded-[6px]", children: [
289
- /* @__PURE__ */ c(fa, { children: [
290
- /* @__PURE__ */ e(ga, { className: "text-[15px]", children: "Create lens" }),
291
- /* @__PURE__ */ e(es, { className: "text-[13px] leading-5", children: "Lenses are private by default and are only visible to you." })
292
- ] }),
293
- /* @__PURE__ */ c("div", { className: "space-y-1.5 py-1", children: [
294
- /* @__PURE__ */ e(sa, { htmlFor: "lens-name", className: wn, children: "Name" }),
295
- /* @__PURE__ */ e(
296
- ce,
297
- {
298
- id: "lens-name",
299
- size: "xs",
300
- value: t,
301
- placeholder: "Monthly review, West region, …",
302
- onChange: (D) => s(D.target.value)
303
- }
304
- ),
305
- i && /* @__PURE__ */ e("p", { className: "text-[12px] text-destructive", children: "A lens with this name already exists. Pick a different one." })
306
- ] }),
307
- /* @__PURE__ */ c(et, { children: [
308
- /* @__PURE__ */ e(E, { variant: "outline", size: "xs", onClick: () => y(!1), children: "Cancel" }),
309
- /* @__PURE__ */ e(
310
- E,
311
- {
312
- size: "xs",
313
- type: "submit",
314
- onClick: P,
315
- disabled: v || !t.trim(),
316
- children: v ? "Creating…" : "Create"
317
- }
318
- )
319
- ] })
320
- ] })
321
- ] });
322
- }
323
- function En({ includeLabel: a = !1 } = {}) {
324
- const n = S((d) => d.lenses), t = S((d) => d.selectedLensId), { setLenses: s, setSelectedLensId: i } = Za(), { authToken: l, tokenProps: h } = q();
325
- async function m(d) {
326
- i(d);
327
- }
328
- async function f(d) {
329
- if (await Dn(h.apiServiceUrl, d, l == null ? void 0 : l.accessToken)) {
330
- const r = n == null ? void 0 : n.filter((p) => p.id !== d);
331
- s(r || []), i("original");
332
- }
333
- }
334
- async function v(d) {
335
- const u = n == null ? void 0 : n.map((g) => g.id === d.id ? {
336
- ...g,
337
- isDefault: !d.isDefault
338
- } : {
339
- ...g,
340
- isDefault: !1
341
- });
342
- s(u || []);
343
- const r = {
344
- ...d,
345
- isDefault: !d.isDefault
346
- };
347
- await ua(h.apiServiceUrl, r, l == null ? void 0 : l.accessToken);
348
- const p = n == null ? void 0 : n.find((g) => g.isDefault);
349
- if (p && p.id !== d.id) {
350
- const g = {
351
- ...p,
352
- isDefault: !1
353
- };
354
- await ua(h.apiServiceUrl, g, l == null ? void 0 : l.accessToken);
355
- }
356
- }
357
- return /* @__PURE__ */ c(O, { children: [
358
- a ? /* @__PURE__ */ c(O, { children: [
359
- /* @__PURE__ */ e(ie, { className: "px-3", children: "Lenses" }),
360
- /* @__PURE__ */ e(Ie, {})
361
- ] }) : null,
362
- /* @__PURE__ */ c(
363
- at,
364
- {
365
- value: t,
366
- onValueChange: m,
367
- children: [
368
- /* @__PURE__ */ e(Ha, { value: "original", children: "Original" }),
369
- n == null ? void 0 : n.map((d) => /* @__PURE__ */ c(
370
- Ha,
371
- {
372
- className: "group flex justify-between gap-2",
373
- value: d.id,
374
- children: [
375
- /* @__PURE__ */ e("p", { children: d.name }),
376
- /* @__PURE__ */ c("span", { className: "flex items-center gap-3", children: [
377
- /* @__PURE__ */ e(
378
- as,
379
- {
380
- onClick: (u) => {
381
- u.preventDefault(), v(d);
382
- },
383
- className: J(
384
- "size-3.5 text-muted-foreground hover:cursor-pointer hover:text-foreground group-hover:visible",
385
- {
386
- invisible: !d.isDefault,
387
- "text-green-500": d.isDefault
388
- }
389
- ),
390
- strokeWidth: 1.5
391
- }
392
- ),
393
- /* @__PURE__ */ e(
394
- ss,
395
- {
396
- onClick: (u) => {
397
- u.preventDefault(), f(d.id);
398
- },
399
- className: "invisible size-3.5 text-muted-foreground hover:cursor-pointer hover:text-foreground group-hover:visible",
400
- strokeWidth: 1.5
401
- }
402
- )
403
- ] })
404
- ]
405
- },
406
- d.id
407
- ))
408
- ]
409
- }
410
- )
411
- ] });
412
- }
413
- function Mn() {
414
- const { displayPreferences: a, shouldShowElement: n } = st(), { currentUser: t, userContext: s } = va(), i = B(
415
- () => tt(t),
416
- [t]
417
- ), l = B(() => (m) => i && i[m] !== void 0 && i[m] === !1 ? !1 : n(m), [i, n, a]), h = B(
418
- () => {
419
- var m, f, v, d, u;
420
- return {
421
- canEdit: ((m = s == null ? void 0 : s.permissions) == null ? void 0 : m.canEdit) ?? ct(t),
422
- canUseFilters: ((f = s == null ? void 0 : s.permissions) == null ? void 0 : f.canEdit) ?? it(t),
423
- canManageDashboards: ((v = s == null ? void 0 : s.permissions) == null ? void 0 : v.canCreateDashboard) ?? ot(t),
424
- canCreateDashboards: ((d = s == null ? void 0 : s.permissions) == null ? void 0 : d.canCreateDashboard) ?? rt(t),
425
- canAccessVisuals: ((u = s == null ? void 0 : s.permissions) == null ? void 0 : u.canEdit) ?? nt(t)
426
- };
427
- },
428
- [t, s]
429
- );
430
- return {
431
- displayPreferences: a,
432
- shouldShowElement: l,
433
- permissions: h,
434
- currentUser: t
435
- };
436
- }
437
- const An = async (a, n, t) => {
438
- const s = `${a}/management/v1/groups`;
439
- return await ns(s, n, t);
440
- }, Ln = async (a, n, t) => {
441
- const s = `${a}/management/v1/groups/${t}`;
442
- await ts(s, n, "DELETE");
443
- }, kn = async (a, n, t, s) => {
444
- const i = `${a}/management/v1/groups/${t}/members`;
445
- return await ns(i, n, s);
446
- }, In = async (a, n, t, s) => {
447
- const i = `${a}/management/v1/groups/${t}/members`;
448
- await ts(i, n, "DELETE", s);
449
- };
450
- function On() {
451
- const { authToken: a, tokenProps: n } = q(), t = Te();
452
- return _e({
453
- mutationFn: (s) => An(n.apiServiceUrl, (a == null ? void 0 : a.accessToken) || "", s),
454
- onSuccess: () => {
455
- t.invalidateQueries({ queryKey: ["groups"] }), I.success("Group created successfully");
456
- },
457
- onError: (s) => {
458
- console.error("Failed to create group:", s), I.error("Failed to create group", {
459
- description: Ue(s, "Failed to create group")
460
- });
461
- }
462
- });
463
- }
464
- function Pn() {
465
- const { authToken: a, tokenProps: n } = q(), t = Te();
466
- return _e({
467
- mutationFn: (s) => Ln(n.apiServiceUrl, (a == null ? void 0 : a.accessToken) || "", s),
468
- onSuccess: (s, i) => {
469
- t.invalidateQueries({ queryKey: ["groups"] }), t.removeQueries({ queryKey: ["group", i] }), I.success("Group deleted successfully");
470
- },
471
- onError: (s) => {
472
- console.error("Failed to delete group:", s), I.error("Failed to delete group", {
473
- description: Ue(s, "Failed to delete group")
474
- });
475
- }
476
- });
477
- }
478
- function Tn() {
479
- const { authToken: a, tokenProps: n } = q(), t = Te();
480
- return _e({
481
- mutationFn: ({
482
- groupId: s,
483
- data: i
484
- }) => kn(n.apiServiceUrl, (a == null ? void 0 : a.accessToken) || "", s, i),
485
- onSuccess: (s, i) => {
486
- t.invalidateQueries({ queryKey: ["group", i.groupId] }), t.invalidateQueries({
487
- queryKey: ["group-members", i.groupId]
488
- }), t.invalidateQueries({ queryKey: ["groups"] }), I.success("Members added successfully");
489
- },
490
- onError: (s) => {
491
- console.error("Failed to add group members:", s), I.error("Failed to add members", {
492
- description: Ue(s, "Failed to add members")
493
- });
494
- }
495
- });
496
- }
497
- function _n() {
498
- const { authToken: a, tokenProps: n } = q(), t = Te();
499
- return _e({
500
- mutationFn: ({
501
- groupId: s,
502
- data: i
503
- }) => In(n.apiServiceUrl, (a == null ? void 0 : a.accessToken) || "", s, i),
504
- onSuccess: (s, i) => {
505
- t.invalidateQueries({ queryKey: ["group", i.groupId] }), t.invalidateQueries({
506
- queryKey: ["group-members", i.groupId]
507
- }), t.invalidateQueries({ queryKey: ["groups"] }), I.success("Members removed successfully");
508
- },
509
- onError: (s) => {
510
- console.error("Failed to remove group members:", s), I.error("Failed to remove members", {
511
- description: Ue(s, "Failed to remove members")
512
- });
513
- }
514
- });
515
- }
516
- const Ja = "text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground";
517
- function Un({
518
- onSuccess: a,
519
- tenantId: n,
520
- isTenantUser: t
521
- }) {
522
- const [s, i] = x(""), [l, h] = x(""), [m, f] = x({}), v = On(), d = () => {
523
- const r = {};
524
- return s.trim() ? s.length < 3 ? r.name = "Group name must be at least 3 characters" : s.length > 50 && (r.name = "Group name must be less than 50 characters") : r.name = "Group name is required", l && l.length > 200 && (r.description = "Description must be less than 200 characters"), f(r), Object.keys(r).length === 0;
525
- };
526
- return /* @__PURE__ */ c("form", { onSubmit: async (r) => {
527
- if (r.preventDefault(), !d()) return;
528
- const p = {
529
- name: s.trim(),
530
- description: l.trim() || void 0,
531
- type: t ? "TENANT_GROUP" : "ORG_GROUP",
532
- ...t && n ? { tenantId: n } : {}
533
- };
534
- try {
535
- await v.mutateAsync(p), i(""), h(""), f({}), a();
536
- } catch (g) {
537
- console.error("Failed to create group:", g);
538
- }
539
- }, className: "space-y-4", children: [
540
- /* @__PURE__ */ c("div", { className: "space-y-1.5", children: [
541
- /* @__PURE__ */ c(sa, { htmlFor: "group-name", className: Ja, children: [
542
- "Group name ",
543
- /* @__PURE__ */ e("span", { className: "text-destructive", children: "*" })
544
- ] }),
545
- /* @__PURE__ */ e(
546
- ce,
547
- {
548
- id: "group-name",
549
- size: "xs",
550
- placeholder: "e.g., Marketing Team, Engineering Squad",
551
- value: s,
552
- onChange: (r) => {
553
- i(r.target.value), m.name && f((p) => ({ ...p, name: "" }));
554
- },
555
- className: m.name ? "border-destructive" : "",
556
- disabled: v.isPending
557
- }
558
- ),
559
- m.name && /* @__PURE__ */ e("p", { className: "text-[12px] text-destructive", children: m.name })
560
- ] }),
561
- /* @__PURE__ */ c("div", { className: "space-y-1.5", children: [
562
- /* @__PURE__ */ e(sa, { htmlFor: "group-description", className: Ja, children: "Description (optional)" }),
563
- /* @__PURE__ */ e(
564
- lt,
565
- {
566
- id: "group-description",
567
- placeholder: "Describe the purpose of this group…",
568
- value: l,
569
- onChange: (r) => {
570
- h(r.target.value), m.description && f((p) => ({ ...p, description: "" }));
571
- },
572
- className: `text-[13px] ${m.description ? "border-destructive" : ""}`,
573
- disabled: v.isPending,
574
- rows: 3
575
- }
576
- ),
577
- m.description ? /* @__PURE__ */ e("p", { className: "text-[12px] text-destructive", children: m.description }) : /* @__PURE__ */ c("p", { className: "text-[11px] text-muted-foreground", children: [
578
- l.length,
579
- "/200"
580
- ] })
581
- ] }),
582
- /* @__PURE__ */ c("div", { className: "flex gap-2 text-[12px] text-muted-foreground", children: [
583
- /* @__PURE__ */ e(dt, { className: "h-3.5 w-3.5 shrink-0 mt-0.5" }),
584
- /* @__PURE__ */ e("p", { children: "This group will be accessible to users in your workspace. You can add members after creating it." })
585
- ] }),
586
- /* @__PURE__ */ c("div", { className: "flex justify-end gap-1.5 pt-1", children: [
587
- /* @__PURE__ */ e(
588
- E,
589
- {
590
- type: "button",
591
- variant: "outline",
592
- size: "xs",
593
- onClick: () => {
594
- i(""), h(""), f({});
595
- },
596
- disabled: v.isPending,
597
- children: "Clear"
598
- }
599
- ),
600
- /* @__PURE__ */ e(
601
- E,
602
- {
603
- type: "submit",
604
- size: "xs",
605
- disabled: v.isPending || !s.trim(),
606
- children: v.isPending ? /* @__PURE__ */ c(O, { children: [
607
- /* @__PURE__ */ e(X, { className: "h-3.5 w-3.5 animate-spin" }),
608
- "Creating…"
609
- ] }) : "Create group"
610
- }
611
- )
612
- ] })
613
- ] });
614
- }
615
- function Rn(a, n = []) {
616
- let t = [];
617
- function s(l, h) {
618
- const m = M.createContext(h);
619
- m.displayName = l + "Context";
620
- const f = t.length;
621
- t = [...t, h];
622
- const v = (u) => {
623
- var C;
624
- const { scope: r, children: p, ...g } = u, y = ((C = r == null ? void 0 : r[a]) == null ? void 0 : C[f]) || m, N = M.useMemo(() => g, Object.values(g));
625
- return /* @__PURE__ */ e(y.Provider, { value: N, children: p });
626
- };
627
- v.displayName = l + "Provider";
628
- function d(u, r) {
629
- var y;
630
- const p = ((y = r == null ? void 0 : r[a]) == null ? void 0 : y[f]) || m, g = M.useContext(p);
631
- if (g) return g;
632
- if (h !== void 0) return h;
633
- throw new Error(`\`${u}\` must be used within \`${l}\``);
634
- }
635
- return [v, d];
636
- }
637
- const i = () => {
638
- const l = t.map((h) => M.createContext(h));
639
- return function(m) {
640
- const f = (m == null ? void 0 : m[a]) || l;
641
- return M.useMemo(
642
- () => ({ [`__scope${a}`]: { ...m, [a]: f } }),
643
- [m, f]
644
- );
645
- };
646
- };
647
- return i.scopeName = a, [s, Fn(i, ...n)];
648
- }
649
- function Fn(...a) {
650
- const n = a[0];
651
- if (a.length === 1) return n;
652
- const t = () => {
653
- const s = a.map((i) => ({
654
- useScope: i(),
655
- scopeName: i.scopeName
656
- }));
657
- return function(l) {
658
- const h = s.reduce((m, { useScope: f, scopeName: v }) => {
659
- const u = f(l)[`__scope${v}`];
660
- return { ...m, ...u };
661
- }, {});
662
- return M.useMemo(() => ({ [`__scope${n.scopeName}`]: h }), [h]);
663
- };
664
- };
665
- return t.scopeName = n.scopeName, t;
666
- }
667
- var Gn = [
668
- "a",
669
- "button",
670
- "div",
671
- "form",
672
- "h2",
673
- "h3",
674
- "img",
675
- "input",
676
- "label",
677
- "li",
678
- "nav",
679
- "ol",
680
- "p",
681
- "select",
682
- "span",
683
- "svg",
684
- "ul"
685
- ], ya = Gn.reduce((a, n) => {
686
- const t = ut(`Primitive.${n}`), s = M.forwardRef((i, l) => {
687
- const { asChild: h, ...m } = i, f = h ? t : n;
688
- return typeof window < "u" && (window[Symbol.for("radix-ui")] = !0), /* @__PURE__ */ e(f, { ...m, ref: l });
689
- });
690
- return s.displayName = `Primitive.${n}`, { ...a, [n]: s };
691
- }, {});
692
- function $n() {
693
- return xn.useSyncExternalStore(
694
- zn,
695
- () => !0,
696
- () => !1
697
- );
698
- }
699
- function zn() {
700
- return () => {
701
- };
702
- }
703
- var xa = "Avatar", [Vn] = Rn(xa), [qn, bs] = Vn(xa), ys = M.forwardRef(
704
- (a, n) => {
705
- const { __scopeAvatar: t, ...s } = a, [i, l] = M.useState("idle");
706
- return /* @__PURE__ */ e(
707
- qn,
708
- {
709
- scope: t,
710
- imageLoadingStatus: i,
711
- onImageLoadingStatusChange: l,
712
- children: /* @__PURE__ */ e(ya.span, { ...s, ref: n })
713
- }
714
- );
715
- }
716
- );
717
- ys.displayName = xa;
718
- var xs = "AvatarImage", Ss = M.forwardRef(
719
- (a, n) => {
720
- const { __scopeAvatar: t, src: s, onLoadingStatusChange: i = () => {
721
- }, ...l } = a, h = bs(xs, t), m = Hn(s, l), f = mt((v) => {
722
- i(v), h.onImageLoadingStatusChange(v);
723
- });
724
- return ta(() => {
725
- m !== "idle" && f(m);
726
- }, [m, f]), m === "loaded" ? /* @__PURE__ */ e(ya.img, { ...l, ref: n, src: s }) : null;
727
- }
728
- );
729
- Ss.displayName = xs;
730
- var Ns = "AvatarFallback", Ds = M.forwardRef(
731
- (a, n) => {
732
- const { __scopeAvatar: t, delayMs: s, ...i } = a, l = bs(Ns, t), [h, m] = M.useState(s === void 0);
733
- return M.useEffect(() => {
734
- if (s !== void 0) {
735
- const f = window.setTimeout(() => m(!0), s);
736
- return () => window.clearTimeout(f);
737
- }
738
- }, [s]), h && l.imageLoadingStatus !== "loaded" ? /* @__PURE__ */ e(ya.span, { ...i, ref: n }) : null;
739
- }
740
- );
741
- Ds.displayName = Ns;
742
- function Xa(a, n) {
743
- return a ? n ? (a.src !== n && (a.src = n), a.complete && a.naturalWidth > 0 ? "loaded" : "loading") : "error" : "idle";
744
- }
745
- function Hn(a, { referrerPolicy: n, crossOrigin: t }) {
746
- const s = $n(), i = M.useRef(null), l = s ? (i.current || (i.current = new window.Image()), i.current) : null, [h, m] = M.useState(
747
- () => Xa(l, a)
748
- );
749
- return ta(() => {
750
- m(Xa(l, a));
751
- }, [l, a]), ta(() => {
752
- const f = (u) => () => {
753
- m(u);
754
- };
755
- if (!l) return;
756
- const v = f("loaded"), d = f("error");
757
- return l.addEventListener("load", v), l.addEventListener("error", d), n && (l.referrerPolicy = n), typeof t == "string" && (l.crossOrigin = t), () => {
758
- l.removeEventListener("load", v), l.removeEventListener("error", d);
759
- };
760
- }, [l, t, n]), h;
761
- }
762
- var ws = ys, Cs = Ss, Es = Ds;
763
- const Sa = M.forwardRef(({ className: a, ...n }, t) => /* @__PURE__ */ e(
764
- ws,
765
- {
766
- ref: t,
767
- className: J(
768
- "relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full",
769
- a
770
- ),
771
- ...n
772
- }
773
- ));
774
- Sa.displayName = ws.displayName;
775
- const jn = M.forwardRef(({ className: a, ...n }, t) => /* @__PURE__ */ e(
776
- Cs,
777
- {
778
- ref: t,
779
- className: J("aspect-square h-full w-full", a),
780
- ...n
781
- }
782
- ));
783
- jn.displayName = Cs.displayName;
784
- const Na = M.forwardRef(({ className: a, ...n }, t) => /* @__PURE__ */ e(
785
- Es,
786
- {
787
- ref: t,
788
- className: J(
789
- "flex h-full w-full items-center justify-center rounded-full bg-muted",
790
- a
791
- ),
792
- ...n
793
- }
794
- ));
795
- Na.displayName = Es.displayName;
796
- function Bn({
797
- open: a,
798
- onOpenChange: n,
799
- group: t,
800
- onUpdate: s
801
- }) {
802
- const [i, l] = x("members"), [h, m] = x(""), [f, v] = x([]), [d, u] = x([]), { data: r, isLoading: p, refetch: g } = ht(t.id), y = t.type === "TENANT_GROUP" ? "tenant" : "organization", { users: N, isLoading: C } = pt({
803
- type: y,
804
- tenantId: t.tenantId || void 0,
805
- active: !0,
806
- limit: 100
807
- }), A = Tn(), F = _n(), P = (r == null ? void 0 : r.members) || [], D = B(() => new Set(P.map((b) => b.userId)), [P]), G = B(() => N.filter((b) => !D.has(b.id)), [N, D]), K = B(() => {
808
- if (!h) return G;
809
- const b = h.toLowerCase();
810
- return G.filter(
811
- (L) => {
812
- var U, $;
813
- return ((U = L.name) == null ? void 0 : U.toLowerCase().includes(b)) || (($ = L.email) == null ? void 0 : $.toLowerCase().includes(b));
814
- }
815
- );
816
- }, [G, h]), w = B(() => {
817
- if (!h) return P;
818
- const b = h.toLowerCase();
819
- return P.filter(
820
- (L) => {
821
- var U, $, ue, H;
822
- return (($ = (U = L.user) == null ? void 0 : U.name) == null ? void 0 : $.toLowerCase().includes(b)) || ((H = (ue = L.user) == null ? void 0 : ue.email) == null ? void 0 : H.toLowerCase().includes(b));
823
- }
824
- );
825
- }, [P, h]), Q = async () => {
826
- if (f.length !== 0)
827
- try {
828
- await A.mutateAsync({
829
- groupId: t.id,
830
- data: {
831
- userIds: f,
832
- userType: y === "tenant" ? "tenant" : "org"
833
- }
834
- }), v([]), l("members"), g(), s == null || s();
835
- } catch (b) {
836
- console.error("Failed to add members:", b);
837
- }
838
- }, le = async () => {
839
- if (d.length !== 0)
840
- try {
841
- await F.mutateAsync({
842
- groupId: t.id,
843
- data: {
844
- userIds: d
845
- }
846
- }), u([]), g(), s == null || s();
847
- } catch (b) {
848
- console.error("Failed to remove members:", b);
849
- }
850
- }, Re = (b) => {
851
- v(
852
- (L) => L.includes(b) ? L.filter((U) => U !== b) : [...L, b]
853
- );
854
- }, de = (b) => {
855
- u(
856
- (L) => L.includes(b) ? L.filter((U) => U !== b) : [...L, b]
857
- );
858
- };
859
- return /* @__PURE__ */ e(O, { children: /* @__PURE__ */ e(ha, { open: a, onOpenChange: n, children: /* @__PURE__ */ c(pa, { className: "max-w-3xl max-h-[80vh]", "aria-describedby": "group-members-description", children: [
860
- /* @__PURE__ */ c(fa, { children: [
861
- /* @__PURE__ */ e(ga, { children: t.name }),
862
- /* @__PURE__ */ e("div", { className: "flex items-center gap-2 mt-1", children: /* @__PURE__ */ c("p", { className: "text-sm text-muted-foreground", children: [
863
- P.length,
864
- " ",
865
- P.length === 1 ? "member" : "members"
866
- ] }) }),
867
- /* @__PURE__ */ c("p", { id: "group-members-description", className: "sr-only", children: [
868
- "Add or remove members from the ",
869
- t.name,
870
- " group"
871
- ] })
872
- ] }),
873
- /* @__PURE__ */ c(rs, { value: i, onValueChange: (b) => {
874
- l(b), m(""), u([]);
875
- }, className: "mt-4", children: [
876
- /* @__PURE__ */ c(os, { className: "grid w-full grid-cols-2", children: [
877
- /* @__PURE__ */ e(Oe, { value: "members", children: "Current Members" }),
878
- /* @__PURE__ */ e(Oe, { value: "add", children: "Add Members" })
879
- ] }),
880
- /* @__PURE__ */ c(Pe, { value: "members", className: "mt-4 space-y-4", children: [
881
- /* @__PURE__ */ c("div", { className: "relative", children: [
882
- /* @__PURE__ */ e(na, { className: "absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground" }),
883
- /* @__PURE__ */ e(
884
- ce,
885
- {
886
- placeholder: "Search members...",
887
- value: h,
888
- onChange: (b) => m(b.target.value),
889
- className: "pl-10"
890
- }
891
- )
892
- ] }),
893
- /* @__PURE__ */ e(ra, { className: d.length > 0 ? "h-[300px]" : "h-[350px]", children: p ? /* @__PURE__ */ e("div", { className: "space-y-2", children: [1, 2, 3].map((b) => /* @__PURE__ */ e(oa, { className: "h-16 w-full" }, b)) }) : w.length === 0 ? /* @__PURE__ */ c("div", { className: "flex flex-col items-center justify-center py-12 text-muted-foreground", children: [
894
- /* @__PURE__ */ e(ba, { className: "h-12 w-12 mb-3 opacity-50" }),
895
- /* @__PURE__ */ e("p", { className: "text-sm font-medium", children: h ? "No members found" : "No members yet" }),
896
- /* @__PURE__ */ e("p", { className: "text-xs mt-1", children: h ? "Try a different search" : 'Switch to the "Add Members" tab to add people to this group' })
897
- ] }) : /* @__PURE__ */ e("div", { className: "space-y-2", children: w.map((b) => /* @__PURE__ */ e(
898
- Kn,
899
- {
900
- member: b,
901
- selected: d.includes(b.userId),
902
- onToggle: () => de(b.userId)
903
- },
904
- b.id
905
- )) }) }),
906
- d.length > 0 && /* @__PURE__ */ c("div", { className: "flex items-center justify-between pt-4 border-t", children: [
907
- /* @__PURE__ */ c("span", { className: "text-sm text-muted-foreground", children: [
908
- d.length,
909
- " member",
910
- d.length !== 1 ? "s" : "",
911
- " selected"
912
- ] }),
913
- /* @__PURE__ */ e(
914
- E,
915
- {
916
- variant: "destructive",
917
- size: "sm",
918
- onClick: le,
919
- disabled: F.isPending,
920
- children: F.isPending ? /* @__PURE__ */ c(O, { children: [
921
- /* @__PURE__ */ e(X, { className: "mr-2 h-4 w-4 animate-spin" }),
922
- "Removing..."
923
- ] }) : /* @__PURE__ */ c(O, { children: [
924
- /* @__PURE__ */ e(is, { className: "mr-2 h-4 w-4" }),
925
- "Remove Selected"
926
- ] })
927
- }
928
- )
929
- ] })
930
- ] }),
931
- /* @__PURE__ */ c(Pe, { value: "add", className: "mt-4 space-y-4", children: [
932
- /* @__PURE__ */ c("div", { className: "relative", children: [
933
- /* @__PURE__ */ e(na, { className: "absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground" }),
934
- /* @__PURE__ */ e(
935
- ce,
936
- {
937
- placeholder: "Search users to add...",
938
- value: h,
939
- onChange: (b) => m(b.target.value),
940
- className: "pl-10"
941
- }
942
- )
943
- ] }),
944
- /* @__PURE__ */ e(ra, { className: "h-[300px]", children: C ? /* @__PURE__ */ e("div", { className: "space-y-2", children: [1, 2, 3].map((b) => /* @__PURE__ */ e(oa, { className: "h-16 w-full" }, b)) }) : K.length === 0 ? /* @__PURE__ */ c("div", { className: "flex flex-col items-center justify-center py-12 text-muted-foreground", children: [
945
- /* @__PURE__ */ e(ia, { className: "h-12 w-12 mb-3 opacity-50" }),
946
- /* @__PURE__ */ e("p", { className: "text-sm font-medium", children: "No available users" }),
947
- /* @__PURE__ */ e("p", { className: "text-xs mt-1", children: h ? "Try a different search" : "All eligible users are already members" })
948
- ] }) : /* @__PURE__ */ e("div", { className: "space-y-2", children: K.map((b) => /* @__PURE__ */ e(
949
- Qn,
950
- {
951
- user: b,
952
- selected: f.includes(b.id),
953
- onToggle: () => Re(b.id)
954
- },
955
- b.id
956
- )) }) }),
957
- f.length > 0 && /* @__PURE__ */ c("div", { className: "flex items-center justify-between pt-4 border-t", children: [
958
- /* @__PURE__ */ c("span", { className: "text-sm text-muted-foreground", children: [
959
- f.length,
960
- " user",
961
- f.length !== 1 ? "s" : "",
962
- " selected"
963
- ] }),
964
- /* @__PURE__ */ e(
965
- E,
966
- {
967
- onClick: Q,
968
- disabled: A.isPending,
969
- children: A.isPending ? /* @__PURE__ */ c(O, { children: [
970
- /* @__PURE__ */ e(X, { className: "mr-2 h-4 w-4 animate-spin" }),
971
- "Adding..."
972
- ] }) : /* @__PURE__ */ c(O, { children: [
973
- /* @__PURE__ */ e(ia, { className: "mr-2 h-4 w-4" }),
974
- "Add Members"
975
- ] })
976
- }
977
- )
978
- ] })
979
- ] })
980
- ] })
981
- ] }) }) });
982
- }
983
- function Kn({
984
- member: a,
985
- selected: n,
986
- onToggle: t
987
- }) {
988
- var i, l, h, m;
989
- const s = ((l = (i = a.user) == null ? void 0 : i.name) == null ? void 0 : l.split(" ").map((f) => f[0]).join("").toUpperCase()) || "?";
990
- return /* @__PURE__ */ c(
991
- "div",
992
- {
993
- className: "flex items-center gap-3 p-3 rounded-lg border bg-card hover:bg-muted/50 cursor-pointer",
994
- onClick: t,
995
- children: [
996
- /* @__PURE__ */ e(cs, { checked: n }),
997
- /* @__PURE__ */ e(Sa, { className: "h-8 w-8", children: /* @__PURE__ */ e(Na, { className: "text-xs", children: s }) }),
998
- /* @__PURE__ */ c("div", { className: "flex-1", children: [
999
- /* @__PURE__ */ e("p", { className: "text-sm font-medium", children: ((h = a.user) == null ? void 0 : h.name) || "Unknown User" }),
1000
- /* @__PURE__ */ e("p", { className: "text-xs text-muted-foreground", children: (m = a.user) == null ? void 0 : m.email })
1001
- ] })
1002
- ]
1003
- }
1004
- );
1005
- }
1006
- function Qn({
1007
- user: a,
1008
- selected: n,
1009
- onToggle: t
1010
- }) {
1011
- var i;
1012
- const s = ((i = a.name) == null ? void 0 : i.split(" ").map((l) => l[0]).join("").toUpperCase()) || "?";
1013
- return /* @__PURE__ */ c(
1014
- "div",
1015
- {
1016
- className: "flex items-center gap-3 p-3 rounded-lg border bg-card hover:bg-muted/50 cursor-pointer",
1017
- onClick: t,
1018
- children: [
1019
- /* @__PURE__ */ e(cs, { checked: n }),
1020
- /* @__PURE__ */ e(Sa, { className: "h-8 w-8", children: /* @__PURE__ */ e(Na, { className: "text-xs", children: s }) }),
1021
- /* @__PURE__ */ c("div", { className: "flex-1", children: [
1022
- /* @__PURE__ */ e("p", { className: "text-sm font-medium", children: a.name }),
1023
- /* @__PURE__ */ e("p", { className: "text-xs text-muted-foreground", children: a.email })
1024
- ] })
1025
- ]
1026
- }
1027
- );
1028
- }
1029
- function Wn({
1030
- open: a,
1031
- onOpenChange: n
1032
- }) {
1033
- const [t, s] = x("groups"), [i, l] = x(""), [h, m] = x(null), [f, v] = x(!1), [d, u] = x(null), { tokenProps: r } = q(), { currentUser: p } = va(), g = Pn(), y = (p == null ? void 0 : p.type) === "tenant", N = r == null ? void 0 : r.tenantId, { groups: C, isLoading: A, refetch: F } = ft({
1034
- type: y ? "TENANT_GROUP" : "all",
1035
- tenantId: y ? N : void 0,
1036
- includeMembers: !1
1037
- }), P = C.filter(
1038
- (w) => {
1039
- var Q;
1040
- return w.name.toLowerCase().includes(i.toLowerCase()) || ((Q = w.description) == null ? void 0 : Q.toLowerCase().includes(i.toLowerCase()));
1041
- }
1042
- ), D = async () => {
1043
- if (d)
1044
- try {
1045
- await g.mutateAsync(d.id), u(null), F();
1046
- } catch (w) {
1047
- console.error("Failed to delete group:", w);
1048
- }
1049
- }, G = (w) => {
1050
- m(w), v(!0);
1051
- }, K = () => {
1052
- s("groups"), F();
1053
- };
1054
- return /* @__PURE__ */ c(O, { children: [
1055
- /* @__PURE__ */ e(ha, { open: a, onOpenChange: n, children: /* @__PURE__ */ c(pa, { className: "max-h-[80vh] max-w-3xl rounded-[6px] border-border/60 sm:rounded-[6px]", children: [
1056
- /* @__PURE__ */ c(fa, { children: [
1057
- /* @__PURE__ */ e(ga, { className: "text-[15px]", children: "Group management" }),
1058
- /* @__PURE__ */ e(es, { className: "text-[13px] leading-5", children: "Manage groups, create new ones, and control membership." })
1059
- ] }),
1060
- /* @__PURE__ */ c(
1061
- rs,
1062
- {
1063
- value: t,
1064
- onValueChange: s,
1065
- className: "mt-2",
1066
- children: [
1067
- /* @__PURE__ */ c(os, { className: "h-8 w-full justify-start gap-1 bg-transparent p-0 border-b border-border/60 rounded-none", children: [
1068
- /* @__PURE__ */ e(
1069
- Oe,
1070
- {
1071
- value: "groups",
1072
- className: "h-8 rounded-none border-b-2 border-transparent bg-transparent px-3 text-[13px] data-[state=active]:border-foreground data-[state=active]:bg-transparent data-[state=active]:shadow-none",
1073
- children: "Groups"
1074
- }
1075
- ),
1076
- /* @__PURE__ */ e(
1077
- Oe,
1078
- {
1079
- value: "create",
1080
- className: "h-8 rounded-none border-b-2 border-transparent bg-transparent px-3 text-[13px] data-[state=active]:border-foreground data-[state=active]:bg-transparent data-[state=active]:shadow-none",
1081
- children: "Create group"
1082
- }
1083
- )
1084
- ] }),
1085
- /* @__PURE__ */ e(Pe, { value: "groups", className: "mt-4", children: /* @__PURE__ */ c("div", { className: "space-y-3", children: [
1086
- /* @__PURE__ */ c("div", { className: "relative", children: [
1087
- /* @__PURE__ */ e(na, { className: "absolute left-2 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground" }),
1088
- /* @__PURE__ */ e(
1089
- ce,
1090
- {
1091
- size: "xs",
1092
- placeholder: "Search groups…",
1093
- value: i,
1094
- onChange: (w) => l(w.target.value),
1095
- className: "pl-7"
1096
- }
1097
- )
1098
- ] }),
1099
- /* @__PURE__ */ e(ra, { className: "h-[400px]", children: A ? /* @__PURE__ */ e("div", { className: "space-y-2", children: [1, 2, 3].map((w) => /* @__PURE__ */ e(
1100
- oa,
1101
- {
1102
- className: "h-16 w-full rounded-[6px]"
1103
- },
1104
- w
1105
- )) }) : P.length === 0 ? /* @__PURE__ */ c("div", { className: "flex flex-col items-center justify-center py-12 text-muted-foreground", children: [
1106
- /* @__PURE__ */ e("p", { className: "text-[13px]", children: "No groups found." }),
1107
- /* @__PURE__ */ e("p", { className: "mt-1 text-[12px]", children: i ? "Try a different search." : "Create your first group to get started." })
1108
- ] }) : /* @__PURE__ */ e("div", { className: "space-y-2 pr-2", children: P.map((w) => /* @__PURE__ */ e(
1109
- Jn,
1110
- {
1111
- group: w,
1112
- onManageMembers: () => G(w),
1113
- onDelete: () => u(w),
1114
- currentUserId: p == null ? void 0 : p.id
1115
- },
1116
- w.id
1117
- )) }) })
1118
- ] }) }),
1119
- /* @__PURE__ */ e(Pe, { value: "create", className: "mt-4", children: /* @__PURE__ */ e(
1120
- Un,
1121
- {
1122
- onSuccess: K,
1123
- tenantId: N,
1124
- isTenantUser: y
1125
- }
1126
- ) })
1127
- ]
1128
- }
1129
- )
1130
- ] }) }),
1131
- h && /* @__PURE__ */ e(
1132
- Bn,
1133
- {
1134
- open: f,
1135
- onOpenChange: v,
1136
- group: h,
1137
- onUpdate: () => F()
1138
- }
1139
- ),
1140
- /* @__PURE__ */ e(
1141
- ls,
1142
- {
1143
- open: !!d,
1144
- onOpenChange: () => u(null),
1145
- children: /* @__PURE__ */ c(ds, { children: [
1146
- /* @__PURE__ */ c(us, { children: [
1147
- /* @__PURE__ */ e(ms, { children: "Delete group" }),
1148
- /* @__PURE__ */ c(hs, { children: [
1149
- 'Delete "',
1150
- d == null ? void 0 : d.name,
1151
- `"? This removes all members and can't be undone.`
1152
- ] })
1153
- ] }),
1154
- /* @__PURE__ */ c(ps, { children: [
1155
- /* @__PURE__ */ e(fs, { children: "Cancel" }),
1156
- /* @__PURE__ */ e(
1157
- ca,
1158
- {
1159
- onClick: D,
1160
- disabled: g.isPending,
1161
- className: "bg-destructive text-destructive-foreground hover:bg-destructive/90",
1162
- children: g.isPending ? /* @__PURE__ */ c(O, { children: [
1163
- /* @__PURE__ */ e(X, { className: "h-3.5 w-3.5 animate-spin" }),
1164
- "Deleting…"
1165
- ] }) : "Delete group"
1166
- }
1167
- )
1168
- ] })
1169
- ] })
1170
- }
1171
- )
1172
- ] });
1173
- }
1174
- function Jn({
1175
- group: a,
1176
- onManageMembers: n,
1177
- onDelete: t,
1178
- currentUserId: s
1179
- }) {
1180
- const i = a.createdBy === s;
1181
- return /* @__PURE__ */ e("div", { className: "rounded-[6px] border border-border/60 bg-card px-3 py-2.5 transition-colors hover:bg-muted/30", children: /* @__PURE__ */ c("div", { className: "flex items-start justify-between gap-2", children: [
1182
- /* @__PURE__ */ c("div", { className: "min-w-0 flex-1 space-y-1", children: [
1183
- /* @__PURE__ */ e("h4", { className: "text-[13px] font-medium text-foreground", children: a.name }),
1184
- a.description && /* @__PURE__ */ e("p", { className: "text-[12px] text-muted-foreground", children: a.description }),
1185
- /* @__PURE__ */ c("div", { className: "flex flex-wrap items-center gap-3 text-[11px] text-muted-foreground", children: [
1186
- /* @__PURE__ */ c("span", { className: "inline-flex items-center gap-1", children: [
1187
- /* @__PURE__ */ e(ba, { className: "h-3 w-3" }),
1188
- a.memberCount,
1189
- " ",
1190
- a.memberCount === 1 ? "member" : "members"
1191
- ] }),
1192
- /* @__PURE__ */ c("span", { children: [
1193
- "Created ",
1194
- on(new Date(a.createdAt), "MMM d, yyyy")
1195
- ] })
1196
- ] })
1197
- ] }),
1198
- /* @__PURE__ */ c("div", { className: "flex shrink-0 items-center gap-0.5", children: [
1199
- /* @__PURE__ */ e(
1200
- E,
1201
- {
1202
- variant: "ghost",
1203
- size: "xs",
1204
- className: "h-7 w-7 p-0 text-muted-foreground hover:text-foreground",
1205
- onClick: n,
1206
- title: "Manage members",
1207
- "aria-label": "Manage members",
1208
- children: /* @__PURE__ */ e(ia, { className: "h-3.5 w-3.5" })
1209
- }
1210
- ),
1211
- i && /* @__PURE__ */ e(
1212
- E,
1213
- {
1214
- variant: "ghost",
1215
- size: "xs",
1216
- className: "h-7 w-7 p-0 text-muted-foreground hover:bg-destructive/10 hover:text-destructive",
1217
- onClick: t,
1218
- title: "Delete group",
1219
- "aria-label": "Delete group",
1220
- children: /* @__PURE__ */ e(is, { className: "h-3.5 w-3.5" })
1221
- }
1222
- )
1223
- ] })
1224
- ] }) });
1225
- }
1226
- function re(a, n, t) {
1227
- var l, h;
1228
- const s = (a.controls || []).find(
1229
- (m) => m.id === t
1230
- );
1231
- if (s)
1232
- return s.label;
1233
- const i = (h = (l = gs(a, n)) == null ? void 0 : l.controls) == null ? void 0 : h.find(
1234
- (m) => m.id === t
1235
- );
1236
- return (i == null ? void 0 : i.label) || t;
1237
- }
1238
- function oe(a, n) {
1239
- var t;
1240
- return ((t = gs(a, n)) == null ? void 0 : t.title) || n;
1241
- }
1242
- function Xn(a) {
1243
- const { errors: n, dashboard: t } = a;
1244
- if (!t)
1245
- return n;
1246
- const s = /* @__PURE__ */ new Map();
1247
- for (const i of n) {
1248
- const l = i.match(
1249
- /^Card '(.+)' binding for control '(.+)' maps to missing metric '(.+)'\.$/
1250
- );
1251
- if (l) {
1252
- const [, d, u] = l, r = `${d}:${u}:missing-metric`;
1253
- s.has(r) || s.set(
1254
- r,
1255
- `"${oe(t, d)}" has an outdated "${re(
1256
- t,
1257
- d,
1258
- u
1259
- )}" mapping. Some choices still point to metrics that are no longer available on this card. Open the card controls and choose replacements.`
1260
- );
1261
- continue;
1262
- }
1263
- const h = i.match(
1264
- /^Card '(.+)' binding for control '(.+)' maps to missing group-by field '(.+)'\.$/
1265
- );
1266
- if (h) {
1267
- const [, d, u] = h, r = `${d}:${u}:missing-group-by`;
1268
- s.has(r) || s.set(
1269
- r,
1270
- `"${oe(t, d)}" has an outdated "${re(
1271
- t,
1272
- d,
1273
- u
1274
- )}" mapping. Some choices still point to fields that are no longer available on this card. Open the card controls and choose replacements.`
1275
- );
1276
- continue;
1277
- }
1278
- const m = i.match(
1279
- /^Card '(.+)' binding for control '(.+)' maps to an invalid metric target\.$/
1280
- );
1281
- if (m) {
1282
- const [, d, u] = m, r = `${d}:${u}:invalid-metric`;
1283
- s.has(r) || s.set(
1284
- r,
1285
- `"${oe(t, d)}" has an invalid "${re(
1286
- t,
1287
- d,
1288
- u
1289
- )}" metric mapping. Open the card controls and choose a valid metric for each option.`
1290
- );
1291
- continue;
1292
- }
1293
- const f = i.match(
1294
- /^Card '(.+)' binding for control '(.+)' maps to an invalid group-by target\.$/
1295
- );
1296
- if (f) {
1297
- const [, d, u] = f, r = `${d}:${u}:invalid-group-by`;
1298
- s.has(r) || s.set(
1299
- r,
1300
- `"${oe(t, d)}" has an invalid "${re(
1301
- t,
1302
- d,
1303
- u
1304
- )}" field mapping. Open the card controls and choose a valid field for each option.`
1305
- );
1306
- continue;
1307
- }
1308
- const v = i.match(
1309
- /^Card '(.+)' binding for control '(.+)' requires at least one temporal group-by field\.$/
1310
- );
1311
- if (v) {
1312
- const [, d, u] = v, r = `${d}:${u}:missing-temporal-group-by`;
1313
- s.has(r) || s.set(
1314
- r,
1315
- `"${oe(t, d)}" can no longer use "${re(
1316
- t,
1317
- d,
1318
- u
1319
- )}" for time grain because the card does not currently group by a date field.`
1320
- );
1321
- continue;
1322
- }
1323
- s.set(i, i);
1324
- }
1325
- return Array.from(s.values());
1326
- }
1327
- function Ya(a, n) {
1328
- return {
1329
- dashboard: la(a),
1330
- semanticExecutionPayload: la(n)
1331
- };
1332
- }
1333
- function lr() {
1334
- var Ga, $a, za, Va;
1335
- Yt(), Zt();
1336
- const {
1337
- authToken: a,
1338
- tokenProps: n,
1339
- id: t
1340
- } = q(), { isLocalDev: s } = gt(), { permissions: i } = Mn(), l = vt(), { isLoading: h } = bt();
1341
- S((o) => o.theme);
1342
- const m = S((o) => o.isDownloadingPdf), f = S(
1343
- (o) => o.dashboardAssistantDraftScopeKey
1344
- ), v = S((o) => o.lenses), d = S((o) => o.selectedLensId), u = v == null ? void 0 : v.find((o) => o.id === d), r = S((o) => o.dashboard);
1345
- S((o) => o.selectedSheetId);
1346
- const p = S(
1347
- (o) => o.isDashboardEditing
1348
- ), { setDashboardTitle: g } = S((o) => o.actions), [y, N] = x(!1), [C, A] = x(!1), [F, P] = x(!1), [D, G] = x(!1), [K, w] = x(!1), [Q, le] = x(!1), [Re, de] = x(!1), [b, L] = x(!1), [U, $] = x(null), [ue, H] = x(!1), [me, he] = x(null), [Da, pe] = x([]), [wa, fe] = x(!1), Ms = S((o) => o.isDashboardPanelOpen), As = S(
1349
- (o) => o.actions.setIsDashboardPanelOpen
1350
- ), Ls = S((o) => o.filterValues), T = S((o) => o.isVisualEditing);
1351
- ja((o) => o.card);
1352
- const Z = Le(
1353
- (o) => o.selectedDashboard
1354
- ), ge = Le(
1355
- (o) => o.initialDashboard
1356
- );
1357
- Le((o) => o.selectedVisual), S((o) => o.selectedFrameId), ja((o) => o.frame);
1358
- const ve = Z ? ($a = Z == null ? void 0 : Z.permissions) == null ? void 0 : $a.canEdit : (Ga = ge == null ? void 0 : ge.permissions) == null ? void 0 : Ga.canEdit, be = S((o) => o.showFilters), Ca = yt((o) => o.setPanelOpen), Ea = S(
1359
- (o) => o.showDashboardJSON
1360
- ), Fe = S((o) => o.onSaveFunction), Ma = S(
1361
- (o) => o.actions.setShowFilters
1362
- ), { setIsDashboardEditing: Aa, setShowDashboardJSON: La } = S(
1363
- (o) => o.actions
1364
- ), { setInitialDashboard: ka, clearSelectedDashboard: Ge } = Le(
1365
- (o) => o.actions
1366
- ), { resources: ye } = xt(We.DASHBOARD), { data: $e } = St(), ks = ((za = $e == null ? void 0 : $e.preference) == null ? void 0 : za.defaultDashboardId) || null, { mutate: Is, isPending: Os } = Nt(), { currentUser: Ps } = va(), Ts = Dt(Ps), W = Z || ge, Ia = W ? {
1367
- id: W.id,
1368
- title: (r == null ? void 0 : r.title) || W.title || "Dashboard"
1369
- } : null, { handleAddNewFrame: _s } = wt(), [ze, Ve] = x(!1), [Us, ee] = x(!1), [qe, xe] = x("close"), ae = Ct(We.DASHBOARD), [R, Se] = x(null), Oa = Ba(
1370
- (o) => {
1371
- window.setTimeout(() => {
1372
- $(o);
1373
- }, 0);
1374
- },
1375
- []
1376
- ), Rs = async (o, k) => {
1377
- if (!(r != null && r.id)) {
1378
- console.log("No dashboard ID found");
1379
- return;
1380
- }
1381
- console.log("Updating dashboard title:", {
1382
- dashboardId: r.id,
1383
- newTitle: o,
1384
- previousTitle: k
1385
- }), ae.mutate(
1386
- {
1387
- resourceId: r.id,
1388
- data: { title: o }
1389
- },
1390
- {
1391
- onSuccess: () => {
1392
- console.log("Dashboard title updated successfully"), I.success("Dashboard title updated");
1393
- },
1394
- onError: (z) => {
1395
- console.error("Failed to update dashboard title:", z), I.error("Failed to update dashboard title"), g(k);
1396
- }
1397
- }
1398
- );
1399
- };
1400
- Xe(() => {
1401
- if (ye && ye.length > 0) {
1402
- const o = r == null ? void 0 : r.id;
1403
- if (o) {
1404
- const k = ye.find(
1405
- (z) => z.id === o
1406
- );
1407
- k && ka(k);
1408
- }
1409
- }
1410
- }, [ye, r == null ? void 0 : r.id, ka]);
1411
- const se = n.orgUserId || n.tenantId, Pa = p && !T && se && ve, { setDashboard: He } = S((o) => o.actions), je = S(
1412
- (o) => o.semanticExecutionPayload
1413
- ), Fs = () => {
1414
- Aa(!0);
1415
- }, Be = () => {
1416
- Aa(!1), La(!1), Se(null), $(null);
1417
- };
1418
- Xe(() => {
1419
- if (!p) {
1420
- R && Se(null);
1421
- return;
1422
- }
1423
- R || !r || h || Se(
1424
- Ya(
1425
- r,
1426
- je
1427
- )
1428
- );
1429
- }, [
1430
- r,
1431
- R,
1432
- p,
1433
- h,
1434
- je
1435
- ]);
1436
- const Ne = (R == null ? void 0 : R.dashboard) ?? null, { isDirty: Ta, isDirtyPending: Gs, resetDirty: De } = dn(
1437
- r,
1438
- Ne,
1439
- 300,
1440
- 1e3,
1441
- Ye
1442
- ), _a = Ba(() => Ne ? Ye(r) !== Ye(Ne) : !1, [r, Ne]), Ua = Ta || Gs, we = ze || ae.isPending, $s = () => {
1443
- _a() ? (xe("close"), ee(!0)) : (Be(), De());
1444
- }, zs = async () => {
1445
- await Ke({
1446
- closeAfterSave: !0,
1447
- navigateHomeAfterSave: qe === "home"
1448
- });
1449
- }, Vs = () => {
1450
- R && He(R.dashboard, {
1451
- semanticExecutionPayload: R.semanticExecutionPayload
1452
- }), Be(), qe === "home" && Ge(), xe("close"), ee(!1), De();
1453
- }, qs = () => {
1454
- R && (He(R.dashboard, {
1455
- semanticExecutionPayload: R.semanticExecutionPayload
1456
- }), De());
1457
- }, Hs = () => {
1458
- if (p && _a()) {
1459
- xe("home"), ee(!0);
1460
- return;
1461
- }
1462
- Ge();
1463
- };
1464
- async function Ke(o) {
1465
- const k = S.getState().dashboard;
1466
- if (!k)
1467
- return;
1468
- const z = (o == null ? void 0 : o.closeAfterSave) ?? wa, Ws = (o == null ? void 0 : o.navigateHomeAfterSave) ?? !1;
1469
- fe(z), z && ee(!1);
1470
- const Js = la(k);
1471
- H(!0), he(null), pe([]), Ve(!0);
1472
- const Xs = {
1473
- template: k
1474
- };
1475
- ae.mutate(
1476
- {
1477
- resourceId: k.id,
1478
- data: Xs
1479
- },
1480
- {
1481
- onSuccess: (_) => {
1482
- var Ee, Me, qa;
1483
- const j = (_ == null ? void 0 : _.id) || ((Ee = _ == null ? void 0 : _.dashboard) == null ? void 0 : Ee.id) || ((Me = _ == null ? void 0 : _.resource) == null ? void 0 : Me.id) || ((qa = _ == null ? void 0 : _.template) == null ? void 0 : qa.id) || null;
1484
- if (!k.id && j) {
1485
- const Qe = Xt.getState(), Ae = Qe.pendingDashboardDraftMigration;
1486
- (Ae == null ? void 0 : Ae.scopeKey) === f ? Qe.actions.setPendingDashboardDraftMigrationExpectedDashboardId(
1487
- j
1488
- ) : Ae && Qe.actions.clearPendingDashboardDraftMigration();
1489
- }
1490
- Ve(!1), I.success("Dashboard saved!"), Se(
1491
- Ya(
1492
- Js,
1493
- S.getState().semanticExecutionPayload
1494
- )
1495
- ), H(!1), fe(!1), z && (Be(), De(), Ws && Ge()), xe("close");
1496
- },
1497
- onError: (_) => {
1498
- Ve(!1), he("Failed to save dashboard. Please try again.");
1499
- const j = _.details, Ee = Array.isArray(
1500
- j == null ? void 0 : j.errors
1501
- ) ? (j.errors || []).filter(
1502
- (Me) => typeof Me == "string"
1503
- ) : [];
1504
- pe(
1505
- Xn({
1506
- errors: Ee,
1507
- dashboard: k || void 0
1508
- })
1509
- ), I.error("Failed to save dashboard");
1510
- }
1511
- }
1512
- );
1513
- }
1514
- async function js() {
1515
- if (N(!0), !d || !u) return;
1516
- const o = S.getState().dashboard;
1517
- if (!o) {
1518
- N(!1);
1519
- return;
1520
- }
1521
- const k = JSON.stringify(o), z = {
1522
- ...u,
1523
- template: k,
1524
- filterValues: Ls
1525
- };
1526
- await ua(
1527
- n.apiServiceUrl,
1528
- z,
1529
- a == null ? void 0 : a.accessToken
1530
- ), I.success("Lens saved"), Fe == null || Fe(o), N(!1);
1531
- }
1532
- const Ra = (u == null ? void 0 : u.name) || r.title, te = !!(r != null && r.id);
1533
- ae.isPending && console.log("Title during update:", {
1534
- title: Ra,
1535
- dashboardStateTitle: r.title,
1536
- dashboardId: r == null ? void 0 : r.id,
1537
- currentLensName: u == null ? void 0 : u.name
1538
- });
1539
- const Fa = n.orgUserId || n.tenantId && n.endUserId && n.endUserEmail, Bs = !!Fa && !!(a != null && a.accessToken) && !!(n != null && n.apiServiceUrl);
1540
- Xe(() => {
1541
- !te && D && G(!1);
1542
- }, [te, D]);
1543
- const Ks = l, ne = (r == null ? void 0 : r.id) || null, Ce = !!ne && ks === ne, Qs = () => {
1544
- ne && Is({
1545
- dashboardId: Ce ? null : ne
1546
- });
1547
- };
1548
- return /* @__PURE__ */ c(
1549
- "div",
1550
- {
1551
- className: "flex h-11 shrink-0 items-center justify-between gap-2 overflow-x-auto border-b px-4 py-2",
1552
- role: "dashboard-controls",
1553
- children: [
1554
- /* @__PURE__ */ c("div", { className: "flex items-center gap-2", children: [
1555
- Fa && /* @__PURE__ */ c(O, { children: [
1556
- /* @__PURE__ */ e(
1557
- Je,
1558
- {
1559
- "aria-label": "Manage Dashboards",
1560
- tooltip: "Manage Dashboards",
1561
- onClick: () => {
1562
- As(!Ms);
1563
- },
1564
- className: "h-7 w-7 px-0",
1565
- buttonProps: { size: "xs" },
1566
- children: /* @__PURE__ */ e(hn, { className: "h-3.5 w-3.5" })
1567
- }
1568
- ),
1569
- Ks && !T && /* @__PURE__ */ e(
1570
- Je,
1571
- {
1572
- "aria-label": "Dashboard Hub",
1573
- tooltip: "Dashboard Hub",
1574
- onClick: Hs,
1575
- className: "h-7 w-7 px-0",
1576
- buttonProps: { size: "xs" },
1577
- children: /* @__PURE__ */ e(as, { className: "h-3.5 w-3.5" })
1578
- }
1579
- )
1580
- ] }),
1581
- !T && l && (h ? /* @__PURE__ */ e(
1582
- "div",
1583
- {
1584
- className: "h-4 w-28 rounded-md bg-muted/70 animate-pulse",
1585
- "aria-label": "Loading dashboard title",
1586
- role: "status",
1587
- children: /* @__PURE__ */ e("span", { className: "sr-only", children: "Loading dashboard title" })
1588
- }
1589
- ) : /* @__PURE__ */ c(O, { children: [
1590
- /* @__PURE__ */ e(
1591
- Et,
1592
- {
1593
- value: Ra || "Untitled Dashboard",
1594
- onSave: (o) => {
1595
- console.log("EditableText onSave called:", {
1596
- newTitle: o,
1597
- canEditDashboard: ve,
1598
- dashboardId: r == null ? void 0 : r.id
1599
- });
1600
- const k = (r == null ? void 0 : r.title) || "";
1601
- g(o), Rs(o, k);
1602
- },
1603
- isEditable: ve && !u,
1604
- displayClassName: "text-[13px] font-medium",
1605
- inputClassName: "text-[13px] font-medium",
1606
- placeholder: "Dashboard Title",
1607
- isPending: ae.isPending
1608
- }
1609
- ),
1610
- Bs && ne && /* @__PURE__ */ e(Mt, { children: /* @__PURE__ */ c(At, { children: [
1611
- /* @__PURE__ */ e(Lt, { asChild: !0, children: /* @__PURE__ */ e(
1612
- E,
1613
- {
1614
- variant: "ghost",
1615
- size: "xs",
1616
- onClick: Qs,
1617
- disabled: Os || !(a != null && a.accessToken) || !(n != null && n.apiServiceUrl),
1618
- className: "w-7 px-0",
1619
- "aria-label": Ce ? "Remove as default dashboard" : "Make this a default dashboard",
1620
- children: /* @__PURE__ */ e(
1621
- kt,
1622
- {
1623
- className: J(
1624
- "h-3.5 w-3.5 transition-colors",
1625
- Ce ? "fill-foreground text-foreground" : "text-muted-foreground hover:text-foreground"
1626
- )
1627
- }
1628
- )
1629
- }
1630
- ) }),
1631
- /* @__PURE__ */ e(It, { children: /* @__PURE__ */ e("p", { children: Ce ? "Remove as default dashboard" : "Make this a default dashboard" }) })
1632
- ] }) })
1633
- ] }))
1634
- ] }),
1635
- /* @__PURE__ */ c("div", { className: "flex items-center gap-2", children: [
1636
- T && /* @__PURE__ */ c(O, { children: [
1637
- /* @__PURE__ */ e(en, {}),
1638
- /* @__PURE__ */ e(an, {})
1639
- ] }),
1640
- !T && l && ((Va = W == null ? void 0 : W.permissions) == null ? void 0 : Va.canShare) && /* @__PURE__ */ c(
1641
- E,
1642
- {
1643
- variant: "outline",
1644
- size: "xs",
1645
- onClick: () => A(!0),
1646
- children: [
1647
- /* @__PURE__ */ e(Ot, { className: "h-3.5 w-3.5" }),
1648
- "Share"
1649
- ]
1650
- }
1651
- ),
1652
- !T && p && i.canUseFilters && l && /* @__PURE__ */ e(
1653
- sn,
1654
- {
1655
- showFilters: be,
1656
- onToggleFilters: () => {
1657
- be || Ca("dashboard", !1), Ma(!be);
1658
- },
1659
- onAddFilter: () => {
1660
- be || (Ca("dashboard", !1), Ma(!0));
1661
- },
1662
- onAddControl: () => {
1663
- Oa("create");
1664
- },
1665
- onManageControls: () => Oa("manage")
1666
- }
1667
- ),
1668
- p && !T && l && U ? /* @__PURE__ */ e(
1669
- tn,
1670
- {
1671
- open: !0,
1672
- onOpenChange: (o) => {
1673
- o || $(null);
1674
- },
1675
- showTrigger: !1,
1676
- initialMode: U
1677
- }
1678
- ) : null,
1679
- p && !T && se && u && s && l && /* @__PURE__ */ c(
1680
- E,
1681
- {
1682
- variant: "secondary",
1683
- size: "xs",
1684
- disabled: y,
1685
- onClick: js,
1686
- children: [
1687
- /* @__PURE__ */ e(Ka, { className: "h-3.5 w-3.5" }),
1688
- "Save Lens"
1689
- ]
1690
- }
1691
- ),
1692
- p && !T && l && /* @__PURE__ */ c(
1693
- E,
1694
- {
1695
- variant: "outline",
1696
- size: "xs",
1697
- disabled: !p,
1698
- onClick: () => _s(),
1699
- children: [
1700
- /* @__PURE__ */ e(aa, { className: "h-3.5 w-3.5" }),
1701
- "Visual"
1702
- ]
1703
- }
1704
- ),
1705
- !T && !p && ve && l && /* @__PURE__ */ c(E, { size: "xs", onClick: Fs, children: [
1706
- /* @__PURE__ */ e(Pt, { className: "h-3.5 w-3.5" }),
1707
- "Edit"
1708
- ] }),
1709
- Pa && l && Ta && /* @__PURE__ */ c(
1710
- E,
1711
- {
1712
- variant: "outline",
1713
- size: "xs",
1714
- onClick: qs,
1715
- disabled: we,
1716
- children: [
1717
- /* @__PURE__ */ e(Tt, { className: "h-3.5 w-3.5" }),
1718
- "Undo"
1719
- ]
1720
- }
1721
- ),
1722
- Pa && l && /* @__PURE__ */ c(
1723
- E,
1724
- {
1725
- size: "xs",
1726
- className: J(!Ua && "opacity-60"),
1727
- disabled: we || !Ua,
1728
- onClick: () => Ke(),
1729
- children: [
1730
- we ? /* @__PURE__ */ e(X, { className: "h-3.5 w-3.5 animate-spin" }) : /* @__PURE__ */ e(Ka, { className: "h-3.5 w-3.5" }),
1731
- we ? "Saving..." : "Save"
1732
- ]
1733
- }
1734
- ),
1735
- p && !T && l && /* @__PURE__ */ c(
1736
- E,
1737
- {
1738
- variant: "outline",
1739
- size: "xs",
1740
- onClick: $s,
1741
- children: [
1742
- /* @__PURE__ */ e(ss, { className: "h-3.5 w-3.5" }),
1743
- "Close"
1744
- ]
1745
- }
1746
- ),
1747
- !T && l && /* @__PURE__ */ e("div", { className: "ml-2", children: /* @__PURE__ */ e(nn, {}) }),
1748
- !T && s && /* @__PURE__ */ e(Sn, {}),
1749
- !T && l && /* @__PURE__ */ c(_t, { children: [
1750
- /* @__PURE__ */ e(Ut, { asChild: !0, children: /* @__PURE__ */ e(
1751
- Je,
1752
- {
1753
- tooltip: "More Options",
1754
- className: "w-7 px-0 text-muted-foreground hover:text-foreground",
1755
- buttonProps: {
1756
- size: "xs",
1757
- variant: "ghost",
1758
- "aria-label": "More dashboard options"
1759
- },
1760
- children: /* @__PURE__ */ e(Rt, { className: "h-3.5 w-3.5" })
1761
- }
1762
- ) }),
1763
- /* @__PURE__ */ c(
1764
- Ft,
1765
- {
1766
- align: "end",
1767
- className: "w-56 rounded-[6px] border border-border/60 p-1 shadow-sm",
1768
- children: [
1769
- /* @__PURE__ */ e(ie, { children: "Reports" }),
1770
- /* @__PURE__ */ c(
1771
- V,
1772
- {
1773
- disabled: m,
1774
- onSelect: () => L(!0),
1775
- children: [
1776
- /* @__PURE__ */ e(Gt, { className: "h-3.5 w-3.5" }),
1777
- "Export"
1778
- ]
1779
- }
1780
- ),
1781
- /* @__PURE__ */ c(
1782
- V,
1783
- {
1784
- disabled: !te,
1785
- onSelect: () => {
1786
- te && G(!0);
1787
- },
1788
- children: [
1789
- /* @__PURE__ */ e($t, { className: "h-3.5 w-3.5" }),
1790
- "Schedule"
1791
- ]
1792
- }
1793
- ),
1794
- /* @__PURE__ */ e(Ie, {}),
1795
- Ts && /* @__PURE__ */ c(O, { children: [
1796
- /* @__PURE__ */ e(ie, { children: "Access" }),
1797
- /* @__PURE__ */ c(
1798
- V,
1799
- {
1800
- onClick: () => P(!0),
1801
- children: [
1802
- /* @__PURE__ */ e(ba, { className: "h-3.5 w-3.5" }),
1803
- "Manage Groups"
1804
- ]
1805
- }
1806
- ),
1807
- /* @__PURE__ */ e(Ie, {})
1808
- ] }),
1809
- /* @__PURE__ */ e(ie, { children: "Preferences" }),
1810
- /* @__PURE__ */ c(V, { onClick: () => w(!0), children: [
1811
- /* @__PURE__ */ e(zt, { className: "h-3.5 w-3.5" }),
1812
- "Calendar Preferences"
1813
- ] }),
1814
- /* @__PURE__ */ c(V, { onClick: () => le(!0), children: [
1815
- /* @__PURE__ */ e(Vt, { className: "h-3.5 w-3.5" }),
1816
- "Summary Settings"
1817
- ] }),
1818
- s && l && /* @__PURE__ */ c(O, { children: [
1819
- /* @__PURE__ */ e(Ie, {}),
1820
- /* @__PURE__ */ e(ie, { children: "Developer" }),
1821
- /* @__PURE__ */ c(
1822
- V,
1823
- {
1824
- onSelect: () => {
1825
- var o;
1826
- a != null && a.accessToken && ((o = navigator == null ? void 0 : navigator.clipboard) != null && o.writeText ? navigator.clipboard.writeText(a.accessToken).then(
1827
- () => I.success("Token copied to clipboard")
1828
- ).catch(() => I.error("Unable to copy token")) : I.error("Clipboard not available"));
1829
- },
1830
- children: [
1831
- /* @__PURE__ */ e(qt, { className: "h-3.5 w-3.5" }),
1832
- "Copy token"
1833
- ]
1834
- }
1835
- ),
1836
- /* @__PURE__ */ c(
1837
- V,
1838
- {
1839
- onSelect: () => Ht(n.apiServiceUrl),
1840
- children: [
1841
- /* @__PURE__ */ e(gn, { className: "h-3.5 w-3.5" }),
1842
- "Invalidate token"
1843
- ]
1844
- }
1845
- ),
1846
- p && /* @__PURE__ */ c(
1847
- V,
1848
- {
1849
- onSelect: () => La(!Ea),
1850
- children: [
1851
- /* @__PURE__ */ e(un, { className: "h-3.5 w-3.5" }),
1852
- Ea ? "Hide dashboard JSON" : "Show dashboard JSON"
1853
- ]
1854
- }
1855
- ),
1856
- se && p && /* @__PURE__ */ c(
1857
- V,
1858
- {
1859
- onSelect: () => de(!0),
1860
- children: [
1861
- /* @__PURE__ */ e(aa, { className: "h-3.5 w-3.5" }),
1862
- "Add lens"
1863
- ]
1864
- }
1865
- ),
1866
- se && /* @__PURE__ */ c(jt, { children: [
1867
- /* @__PURE__ */ c(Bt, { children: [
1868
- /* @__PURE__ */ e(mn, { className: "h-3.5 w-3.5" }),
1869
- "Lenses"
1870
- ] }),
1871
- /* @__PURE__ */ e(Kt, { className: "w-60", children: /* @__PURE__ */ e(En, {}) })
1872
- ] })
1873
- ] })
1874
- ]
1875
- }
1876
- )
1877
- ] }),
1878
- C && Ia && /* @__PURE__ */ e(
1879
- Qt,
1880
- {
1881
- resource: Ia,
1882
- resourceType: We.DASHBOARD,
1883
- onClose: () => A(!1)
1884
- }
1885
- ),
1886
- /* @__PURE__ */ e(
1887
- Wn,
1888
- {
1889
- open: F,
1890
- onOpenChange: P
1891
- }
1892
- ),
1893
- te && (r == null ? void 0 : r.id) && /* @__PURE__ */ e(
1894
- Wt,
1895
- {
1896
- open: D,
1897
- onOpenChange: G,
1898
- dashboardId: r.id,
1899
- dashboardName: r == null ? void 0 : r.title
1900
- }
1901
- ),
1902
- /* @__PURE__ */ e(
1903
- cn,
1904
- {
1905
- open: K,
1906
- onOpenChange: w
1907
- }
1908
- ),
1909
- /* @__PURE__ */ e(
1910
- ln,
1911
- {
1912
- open: Q,
1913
- onOpenChange: le,
1914
- dashboard: r,
1915
- disabled: !p,
1916
- onApply: (o) => He(
1917
- {
1918
- ...r,
1919
- summary: o
1920
- },
1921
- {
1922
- semanticExecutionPayload: je
1923
- }
1924
- )
1925
- }
1926
- ),
1927
- s && se && l && /* @__PURE__ */ e(
1928
- Cn,
1929
- {
1930
- open: Re,
1931
- onOpenChange: de
1932
- }
1933
- ),
1934
- l && /* @__PURE__ */ e(
1935
- Jt,
1936
- {
1937
- open: b,
1938
- onOpenChange: L
1939
- }
1940
- ),
1941
- /* @__PURE__ */ e(
1942
- ls,
1943
- {
1944
- open: ue,
1945
- onOpenChange: (o) => {
1946
- !o && ze && !me || (H(o), o || (he(null), pe([]), fe(!1)));
1947
- },
1948
- children: /* @__PURE__ */ c(ds, { className: "max-w-sm", children: [
1949
- /* @__PURE__ */ c(us, { children: [
1950
- /* @__PURE__ */ e(ms, { children: me ? "Save failed" : "Saving dashboard" }),
1951
- /* @__PURE__ */ e(hs, { className: "pt-2", children: me ? "We could not save the dashboard. Please try again." : "Please wait while we save your changes." }),
1952
- Da.length > 0 && /* @__PURE__ */ c("div", { className: "space-y-1 rounded-md border border-destructive/20 bg-destructive/5 p-3 text-left", children: [
1953
- /* @__PURE__ */ e("div", { className: "text-sm font-medium text-destructive", children: "What needs attention" }),
1954
- /* @__PURE__ */ e("ul", { className: "list-disc space-y-1 pl-4 text-xs text-muted-foreground", children: Da.slice(0, 5).map((o) => /* @__PURE__ */ e("li", { children: o }, o)) })
1955
- ] })
1956
- ] }),
1957
- /* @__PURE__ */ e(ps, { className: "flex-col gap-2 sm:flex-row sm:justify-end", children: me ? /* @__PURE__ */ c(O, { children: [
1958
- /* @__PURE__ */ e(
1959
- fs,
1960
- {
1961
- onClick: () => {
1962
- H(!1), he(null), pe([]), fe(!1);
1963
- },
1964
- className: "m-0",
1965
- children: "Close"
1966
- }
1967
- ),
1968
- /* @__PURE__ */ e(
1969
- ca,
1970
- {
1971
- onClick: () => Ke({
1972
- closeAfterSave: wa,
1973
- navigateHomeAfterSave: qe === "home"
1974
- }),
1975
- className: "m-0",
1976
- children: "Retry"
1977
- }
1978
- )
1979
- ] }) : /* @__PURE__ */ c(
1980
- ca,
1981
- {
1982
- disabled: !0,
1983
- className: "m-0 cursor-default",
1984
- children: [
1985
- /* @__PURE__ */ e(X, { className: "mr-2 h-4 w-4 animate-spin" }),
1986
- "Saving..."
1987
- ]
1988
- }
1989
- ) })
1990
- ] })
1991
- }
1992
- ),
1993
- /* @__PURE__ */ e(
1994
- rn,
1995
- {
1996
- open: Us,
1997
- onOpenChange: (o) => {
1998
- ee(o);
1999
- },
2000
- onSave: zs,
2001
- onDiscard: Vs,
2002
- isSaving: ze,
2003
- saveLabel: "Save",
2004
- discardLabel: "Discard"
2005
- }
2006
- )
2007
- ] })
2008
- ]
2009
- }
2010
- );
2011
- }
2012
- export {
2013
- lr as default
2014
- };