react-semaphor 0.1.375 → 0.1.377

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 (67) hide show
  1. package/dist/analytics-protocol/index.cjs +1 -1
  2. package/dist/analytics-protocol/index.js +47 -43
  3. package/dist/brand-studio/index.cjs +4 -9
  4. package/dist/brand-studio/index.js +98 -108
  5. package/dist/chunks/{braces-C3-w6xDL.js → braces-C2uBgj3t.js} +1 -1
  6. package/dist/chunks/{braces-C8QqW4wu.js → braces-CkXyWzRh.js} +1 -1
  7. package/dist/chunks/{calendar-preferences-dialog-DXgi7q5u.js → calendar-preferences-dialog-C55VOTIy.js} +6 -5
  8. package/dist/chunks/calendar-preferences-dialog-DAukJOaP.js +1 -0
  9. package/dist/chunks/catalog-field-grounding-BGW0hnB9.js +1 -0
  10. package/dist/chunks/catalog-field-grounding-DHXEI7cW.js +199 -0
  11. package/dist/chunks/{chevrons-up-down-DSvLu4Ye.js → chevrons-up-down-BnzChFLU.js} +1 -1
  12. package/dist/chunks/{chevrons-up-down-CnCSGY02.js → chevrons-up-down-W0nzHzx0.js} +1 -1
  13. package/dist/chunks/{dashboard-briefing-launcher-Jwbmrcl_.js → dashboard-briefing-launcher-CUyeiL_T.js} +3141 -2372
  14. package/dist/chunks/dashboard-briefing-launcher-DMKfG_z3.js +111 -0
  15. package/dist/chunks/dashboard-controls-B4hxFc3Q.js +2279 -0
  16. package/dist/chunks/dashboard-controls-D4vI0wvU.js +52 -0
  17. package/dist/chunks/dashboard-json-DQnm6daE.js +1 -0
  18. package/dist/chunks/{dashboard-json-Cl1O3uh0.js → dashboard-json-pl1_mFqJ.js} +14 -13
  19. package/dist/chunks/{edit-dashboard-visual-B_0sbc43.js → edit-dashboard-visual-CF4aSsav.js} +4729 -4645
  20. package/dist/chunks/edit-dashboard-visual-CjTXY51a.js +178 -0
  21. package/dist/chunks/{index-BIks0ktd.js → index-B2kPleRS.js} +186 -181
  22. package/dist/chunks/{index-BSkBy5cH.js → index-Bn866BBY.js} +22824 -22664
  23. package/dist/chunks/layout-grid-BFmJ7vmH.js +16 -0
  24. package/dist/chunks/layout-grid-CTOW9oTg.js +6 -0
  25. package/dist/chunks/{palette-DUGktM-M.js → palette-DrhPeer-.js} +1 -1
  26. package/dist/chunks/{palette-D-f4-82S.js → palette-OFaniMPn.js} +1 -1
  27. package/dist/chunks/{save-D3YYinDz.js → save-BxWBiQv1.js} +1 -1
  28. package/dist/chunks/{save-kkBEBeLg.js → save-Dh6gSC4x.js} +1 -1
  29. package/dist/chunks/{switch-Dkx2qEOr.js → switch-C-fGjxjY.js} +2002 -1983
  30. package/dist/chunks/switch-D5xopzFD.js +168 -0
  31. package/dist/chunks/use-create-flow-overlay-state-Dg2ffpCE.js +21 -0
  32. package/dist/chunks/use-create-flow-overlay-state-DrKP0jWE.js +1968 -0
  33. package/dist/chunks/{validation-1V7bWmYw.js → validation-BHFaWDU-.js} +1 -1
  34. package/dist/chunks/{validation-DlrTIf1N.js → validation-bMedDBOo.js} +1 -1
  35. package/dist/dashboard/index.cjs +1 -1
  36. package/dist/dashboard/index.js +1 -1
  37. package/dist/dashboard-authoring/index.cjs +1 -1
  38. package/dist/dashboard-authoring/index.js +1 -1
  39. package/dist/data-app-builder/index.cjs +18 -13
  40. package/dist/data-app-builder/index.js +141 -131
  41. package/dist/data-app-sdk/index.cjs +1 -1
  42. package/dist/data-app-sdk/index.js +22 -21
  43. package/dist/data-app-sdk-validation/index.cjs +1 -1
  44. package/dist/data-app-sdk-validation/index.js +2 -2
  45. package/dist/index.cjs +1 -1
  46. package/dist/index.js +151 -151
  47. package/dist/style.css +1 -1
  48. package/dist/surfboard/index.cjs +1 -1
  49. package/dist/surfboard/index.js +2 -2
  50. package/dist/types/analytics-protocol.d.ts +84 -0
  51. package/dist/types/main.d.ts +8 -12
  52. package/package.json +1 -1
  53. package/dist/chunks/calendar-preferences-dialog-CsRzDpDs.js +0 -1
  54. package/dist/chunks/catalog-field-grounding-DoEBOXQd.js +0 -100
  55. package/dist/chunks/catalog-field-grounding-Du6mKDcF.js +0 -1
  56. package/dist/chunks/dashboard-briefing-launcher-C-G6vQTL.js +0 -106
  57. package/dist/chunks/dashboard-controls-DzGGNQxv.js +0 -2269
  58. package/dist/chunks/dashboard-controls-p7VKzWSb.js +0 -57
  59. package/dist/chunks/dashboard-json-CvPhMpbM.js +0 -1
  60. package/dist/chunks/edit-dashboard-visual-CSrdS10O.js +0 -178
  61. package/dist/chunks/resource-management-panel-IHbUOh2g.js +0 -6
  62. package/dist/chunks/resource-management-panel-tFjbtgPw.js +0 -1018
  63. package/dist/chunks/switch-fIkmwzUt.js +0 -168
  64. package/dist/chunks/use-create-flow-overlay-state-D-yGZTR3.js +0 -1647
  65. package/dist/chunks/use-create-flow-overlay-state-DbaUD5xc.js +0 -26
  66. package/dist/chunks/use-visual-utils-B5hwU_av.js +0 -1
  67. package/dist/chunks/use-visual-utils-Dj82r7DA.js +0 -340
@@ -1,2269 +0,0 @@
1
- import { jsx as t, jsxs as i, Fragment as R } from "react/jsx-runtime";
2
- import { c as B, u as N, B as _, az as dt, E as Vt, L as Hr, a1 as jr, a as te, aA as qr, aB as Vr, aC as rt, aD as me, aE as ct, aF as Kt, f as $e, X as Qt, aG as Wt, aH as Kr, G as Rt, Y as Qr, Z as Wr, _ as Jr, a0 as Yr, j as Xr, aI as Zr } from "./switch-Dkx2qEOr.js";
3
- import { bt as ea, u as G, b as Jt, bu as ta, ay as re, c as Yt, d as ra, e as at, f as nt, n as aa, bv as ue, bg as Fe, bw as na, bx as Ut, by as Xt, bz as Zt, bA as sa, bo as lt, bB as oa, bC as ia, bD as da, bE as ca, bF as la, bG as ua, ae as pe, bH as fe, o as C, bI as ma, bJ as er, aY as ut, aI as pa, bK as fa, bL as ha, bf as tr, bi as rr, aG as ga, b8 as ba, bM as xa, bN as va, y as ya, x as Ue, J as wa, z as Ye, bO as Na, bP as Sa, bQ as Da, _ as ka, bR as Ca, I as Xe, bS as Ea, bT as La, bU as Ia, bV as Aa, b9 as Ma, ba as Pa, bb as Oa, bc as _a, bd as $, bW as Ra, aD as Tt, bX as Ua, bY as Ta, bZ as Fa, H as $a, b_ as Ga, ao as Ba, ar as za, as as Ha, at as ja, au as qa, av as Va, aw as Ka, ax as Ft, v as st } from "./index-BSkBy5cH.js";
4
- import "./index-CuHybtft.js";
5
- import * as I from "react";
6
- import ar, { useState as w, useMemo as K, useEffect as Ge, useRef as $t, useLayoutEffect as Qa, useCallback as Wa } from "react";
7
- import "./index-CJdxSyQq.js";
8
- import { createPortal as Ja } from "react-dom";
9
- import { L as Ya, b as Xa, u as Za, A as en, V as tn, K as rn, e as an, M as nn, N as sn, U as on } from "./dashboard-briefing-launcher-Jwbmrcl_.js";
10
- import { d as nr } from "./index-DFOb_6HB.js";
11
- import { C as dn } from "./calendar-preferences-dialog-DXgi7q5u.js";
12
- import { u as cn } from "./use-debounced-dirty-check-BwAbnX_5.js";
13
- import { s as Ze } from "./normalize-dashboard-for-dirty-check-5KpZN8xr.js";
14
- import { S as Gt } from "./save-kkBEBeLg.js";
15
- import { P as ln } from "./palette-D-f4-82S.js";
16
- import { B as un } from "./braces-C8QqW4wu.js";
17
- /**
18
- * @license lucide-react v0.453.0 - ISC
19
- *
20
- * This source code is licensed under the ISC license.
21
- * See the LICENSE file in the root directory of this source tree.
22
- */
23
- const mn = B("Glasses", [
24
- ["circle", { cx: "6", cy: "15", r: "4", key: "vux9w4" }],
25
- ["circle", { cx: "18", cy: "15", r: "4", key: "18o8ve" }],
26
- ["path", { d: "M14 15a2 2 0 0 0-2-2 2 2 0 0 0-2 2", key: "1ag4bs" }],
27
- ["path", { d: "M2.5 13 5 7c.7-1.3 1.4-2 3-2", key: "1hm1gs" }],
28
- ["path", { d: "M21.5 13 19 7c-.7-1.3-1.5-2-3-2", key: "1r31ai" }]
29
- ]);
30
- /**
31
- * @license lucide-react v0.453.0 - ISC
32
- *
33
- * This source code is licensed under the ISC license.
34
- * See the LICENSE file in the root directory of this source tree.
35
- */
36
- const pn = B("Menu", [
37
- ["line", { x1: "4", x2: "20", y1: "12", y2: "12", key: "1e0a9i" }],
38
- ["line", { x1: "4", x2: "20", y1: "6", y2: "6", key: "1owob3" }],
39
- ["line", { x1: "4", x2: "20", y1: "18", y2: "18", key: "yk5zj1" }]
40
- ]);
41
- /**
42
- * @license lucide-react v0.453.0 - ISC
43
- *
44
- * This source code is licensed under the ISC license.
45
- * See the LICENSE file in the root directory of this source tree.
46
- */
47
- const fn = B("Monitor", [
48
- ["rect", { width: "20", height: "14", x: "2", y: "3", rx: "2", key: "48i651" }],
49
- ["line", { x1: "8", x2: "16", y1: "21", y2: "21", key: "1svkeh" }],
50
- ["line", { x1: "12", x2: "12", y1: "17", y2: "21", key: "vw1qmm" }]
51
- ]);
52
- /**
53
- * @license lucide-react v0.453.0 - ISC
54
- *
55
- * This source code is licensed under the ISC license.
56
- * See the LICENSE file in the root directory of this source tree.
57
- */
58
- const hn = B("Moon", [
59
- ["path", { d: "M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z", key: "a7tn18" }]
60
- ]);
61
- /**
62
- * @license lucide-react v0.453.0 - ISC
63
- *
64
- * This source code is licensed under the ISC license.
65
- * See the LICENSE file in the root directory of this source tree.
66
- */
67
- const gn = B("ShieldX", [
68
- [
69
- "path",
70
- {
71
- 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",
72
- key: "oel41y"
73
- }
74
- ],
75
- ["path", { d: "m14.5 9.5-5 5", key: "17q4r4" }],
76
- ["path", { d: "m9.5 9.5 5 5", key: "18nt4w" }]
77
- ]);
78
- /**
79
- * @license lucide-react v0.453.0 - ISC
80
- *
81
- * This source code is licensed under the ISC license.
82
- * See the LICENSE file in the root directory of this source tree.
83
- */
84
- const bn = B("Sun", [
85
- ["circle", { cx: "12", cy: "12", r: "4", key: "4exip2" }],
86
- ["path", { d: "M12 2v2", key: "tus03m" }],
87
- ["path", { d: "M12 20v2", key: "1lh1kg" }],
88
- ["path", { d: "m4.93 4.93 1.41 1.41", key: "149t6j" }],
89
- ["path", { d: "m17.66 17.66 1.41 1.41", key: "ptbguv" }],
90
- ["path", { d: "M2 12h2", key: "1t8f8n" }],
91
- ["path", { d: "M20 12h2", key: "1q8mjw" }],
92
- ["path", { d: "m6.34 17.66-1.41 1.41", key: "1m8zz5" }],
93
- ["path", { d: "m19.07 4.93-1.41 1.41", key: "1shlcs" }]
94
- ]);
95
- /**
96
- * @license lucide-react v0.453.0 - ISC
97
- *
98
- * This source code is licensed under the ISC license.
99
- * See the LICENSE file in the root directory of this source tree.
100
- */
101
- const xn = B("UserPlus", [
102
- ["path", { d: "M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2", key: "1yyitq" }],
103
- ["circle", { cx: "9", cy: "7", r: "4", key: "nufk8" }],
104
- ["line", { x1: "19", x2: "19", y1: "8", y2: "14", key: "1bvyxn" }],
105
- ["line", { x1: "22", x2: "16", y1: "11", y2: "11", key: "1shjgl" }]
106
- ]);
107
- /**
108
- * @license lucide-react v0.453.0 - ISC
109
- *
110
- * This source code is licensed under the ISC license.
111
- * See the LICENSE file in the root directory of this source tree.
112
- */
113
- const sr = B("UserRound", [
114
- ["circle", { cx: "12", cy: "8", r: "5", key: "1hypcn" }],
115
- ["path", { d: "M20 21a8 8 0 0 0-16 0", key: "rfgkzh" }]
116
- ]);
117
- var ot = { exports: {} }, et = {};
118
- /**
119
- * @license React
120
- * use-sync-external-store-shim.production.js
121
- *
122
- * Copyright (c) Meta Platforms, Inc. and affiliates.
123
- *
124
- * This source code is licensed under the MIT license found in the
125
- * LICENSE file in the root directory of this source tree.
126
- */
127
- var Bt;
128
- function vn() {
129
- if (Bt) return et;
130
- Bt = 1;
131
- var e = ar;
132
- function n(c, f) {
133
- return c === f && (c !== 0 || 1 / c === 1 / f) || c !== c && f !== f;
134
- }
135
- var a = typeof Object.is == "function" ? Object.is : n, r = e.useState, s = e.useEffect, u = e.useLayoutEffect, h = e.useDebugValue;
136
- function l(c, f) {
137
- var m = f(), g = r({ inst: { value: m, getSnapshot: f } }), o = g[0].inst, y = g[1];
138
- return u(
139
- function() {
140
- o.value = m, o.getSnapshot = f, b(o) && y({ inst: o });
141
- },
142
- [c, m, f]
143
- ), s(
144
- function() {
145
- return b(o) && y({ inst: o }), c(function() {
146
- b(o) && y({ inst: o });
147
- });
148
- },
149
- [c]
150
- ), h(m), m;
151
- }
152
- function b(c) {
153
- var f = c.getSnapshot;
154
- c = c.value;
155
- try {
156
- var m = f();
157
- return !a(c, m);
158
- } catch {
159
- return !0;
160
- }
161
- }
162
- function x(c, f) {
163
- return f();
164
- }
165
- var p = typeof window > "u" || typeof window.document > "u" || typeof window.document.createElement > "u" ? x : l;
166
- return et.useSyncExternalStore = e.useSyncExternalStore !== void 0 ? e.useSyncExternalStore : p, et;
167
- }
168
- var tt = {};
169
- /**
170
- * @license React
171
- * use-sync-external-store-shim.development.js
172
- *
173
- * Copyright (c) Meta Platforms, Inc. and affiliates.
174
- *
175
- * This source code is licensed under the MIT license found in the
176
- * LICENSE file in the root directory of this source tree.
177
- */
178
- var zt;
179
- function yn() {
180
- return zt || (zt = 1, process.env.NODE_ENV !== "production" && function() {
181
- function e(m, g) {
182
- return m === g && (m !== 0 || 1 / m === 1 / g) || m !== m && g !== g;
183
- }
184
- function n(m, g) {
185
- p || s.startTransition === void 0 || (p = !0, console.error(
186
- "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."
187
- ));
188
- var o = g();
189
- if (!c) {
190
- var y = g();
191
- u(o, y) || (console.error(
192
- "The result of getSnapshot should be cached to avoid an infinite loop"
193
- ), c = !0);
194
- }
195
- y = h({
196
- inst: { value: o, getSnapshot: g }
197
- });
198
- var S = y[0].inst, k = y[1];
199
- return b(
200
- function() {
201
- S.value = o, S.getSnapshot = g, a(S) && k({ inst: S });
202
- },
203
- [m, o, g]
204
- ), l(
205
- function() {
206
- return a(S) && k({ inst: S }), m(function() {
207
- a(S) && k({ inst: S });
208
- });
209
- },
210
- [m]
211
- ), x(o), o;
212
- }
213
- function a(m) {
214
- var g = m.getSnapshot;
215
- m = m.value;
216
- try {
217
- var o = g();
218
- return !u(m, o);
219
- } catch {
220
- return !0;
221
- }
222
- }
223
- function r(m, g) {
224
- return g();
225
- }
226
- typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ < "u" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart == "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
227
- var s = ar, u = typeof Object.is == "function" ? Object.is : e, h = s.useState, l = s.useEffect, b = s.useLayoutEffect, x = s.useDebugValue, p = !1, c = !1, f = typeof window > "u" || typeof window.document > "u" || typeof window.document.createElement > "u" ? r : n;
228
- tt.useSyncExternalStore = s.useSyncExternalStore !== void 0 ? s.useSyncExternalStore : f, typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ < "u" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop == "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());
229
- }()), tt;
230
- }
231
- process.env.NODE_ENV === "production" ? ot.exports = vn() : ot.exports = yn();
232
- var wn = ot.exports;
233
- const Te = ["light", "dark", "system"];
234
- function Nn() {
235
- const { theme: e, setTheme: n } = ea(), a = N(
236
- (h) => h.actions.setDashboardTheme
237
- );
238
- function r() {
239
- const h = Te.includes(e) ? e : "system", l = Te[(Te.indexOf(h) + 1) % Te.length];
240
- n(l), a(l);
241
- }
242
- const s = e === "light" ? bn : e === "dark" ? hn : fn, u = e === "light" ? "Theme: light (click for dark)" : e === "dark" ? "Theme: dark (click for system)" : "Theme: system (click for light)";
243
- return /* @__PURE__ */ t(
244
- _,
245
- {
246
- type: "button",
247
- variant: "ghost",
248
- size: "xs",
249
- className: "h-7 w-7 p-0 text-muted-foreground hover:text-foreground",
250
- onClick: r,
251
- "aria-label": u,
252
- title: u,
253
- children: /* @__PURE__ */ t(s, { className: "h-3.5 w-3.5", strokeWidth: 1.5 })
254
- }
255
- );
256
- }
257
- async function Sn(e, n, a, r, s) {
258
- if (!s)
259
- return null;
260
- const u = JSON.stringify(a), h = `${e}/v1/lens`;
261
- return await dt(h, s, {
262
- name: n,
263
- template: u,
264
- filterValues: r,
265
- operation: "create"
266
- });
267
- }
268
- async function it(e, n, a) {
269
- if (!a)
270
- return null;
271
- const { id: r, template: s, filterValues: u, isDefault: h, shared: l } = n, b = `${e}/v1/lens`;
272
- return await dt(b, a, {
273
- lensId: r,
274
- template: s,
275
- filterValues: u,
276
- isDefault: h,
277
- shared: l,
278
- operation: "update"
279
- });
280
- }
281
- async function Dn(e, n, a) {
282
- if (!a)
283
- return null;
284
- const r = `${e}/v1/lens`;
285
- return await dt(r, a, {
286
- operation: "delete",
287
- lensId: n
288
- });
289
- }
290
- const kn = "text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground";
291
- function Cn({
292
- open: e,
293
- onOpenChange: n
294
- } = {}) {
295
- const [a, r] = w(""), [s, u] = w(!1), h = N((D) => D.lenses), { setLenses: l, setSelectedLensId: b } = Vt(), [x, p] = w(!1), [c, f] = w(!1), m = e !== void 0, g = m ? e : c, o = (D) => {
296
- m || f(D), n == null || n(D);
297
- }, y = N((D) => D.dashboard), S = N((D) => D.filterValues), { authToken: k, tokenProps: L } = G();
298
- async function E() {
299
- p(!0);
300
- const D = await Sn(
301
- L.apiServiceUrl,
302
- a,
303
- y,
304
- S,
305
- k == null ? void 0 : k.accessToken
306
- );
307
- D && (l([...h || [], D]), b(D.id), o(!1)), p(!1);
308
- }
309
- return /* @__PURE__ */ i(Jt, { open: g, onOpenChange: o, children: [
310
- m ? null : /* @__PURE__ */ t(ta, { asChild: !0, children: /* @__PURE__ */ i(_, { variant: "secondary", size: "xs", children: [
311
- /* @__PURE__ */ t(re, { className: "h-3.5 w-3.5" }),
312
- "Lens"
313
- ] }) }),
314
- /* @__PURE__ */ i(Yt, { className: "rounded-control border-border/60 sm:max-w-[420px] sm:rounded-control", children: [
315
- /* @__PURE__ */ i(ra, { children: [
316
- /* @__PURE__ */ t(at, { className: "text-[15px]", children: "Create lens" }),
317
- /* @__PURE__ */ t(nt, { className: "text-[13px] leading-5", children: "Lenses are private by default and are only visible to you." })
318
- ] }),
319
- /* @__PURE__ */ i("div", { className: "space-y-1.5 py-1", children: [
320
- /* @__PURE__ */ t(Hr, { htmlFor: "lens-name", className: kn, children: "Name" }),
321
- /* @__PURE__ */ t(
322
- jr,
323
- {
324
- id: "lens-name",
325
- size: "xs",
326
- value: a,
327
- placeholder: "Monthly review, West region, …",
328
- onChange: (D) => r(D.target.value)
329
- }
330
- ),
331
- s && /* @__PURE__ */ t("p", { className: "text-[12px] text-destructive", children: "A lens with this name already exists. Pick a different one." })
332
- ] }),
333
- /* @__PURE__ */ i(aa, { children: [
334
- /* @__PURE__ */ t(_, { variant: "outline", size: "xs", onClick: () => o(!1), children: "Cancel" }),
335
- /* @__PURE__ */ t(
336
- _,
337
- {
338
- size: "xs",
339
- type: "submit",
340
- onClick: E,
341
- disabled: x || !a.trim(),
342
- children: x ? "Creating…" : "Create"
343
- }
344
- )
345
- ] })
346
- ] })
347
- ] });
348
- }
349
- function En({ includeLabel: e = !1 } = {}) {
350
- const n = N((p) => p.lenses), a = N((p) => p.selectedLensId), { setLenses: r, setSelectedLensId: s } = Vt(), { authToken: u, tokenProps: h } = G();
351
- async function l(p) {
352
- s(p);
353
- }
354
- async function b(p) {
355
- if (await Dn(h.apiServiceUrl, p, u == null ? void 0 : u.accessToken)) {
356
- const f = n == null ? void 0 : n.filter((m) => m.id !== p);
357
- r(f || []), s("original");
358
- }
359
- }
360
- async function x(p) {
361
- const c = n == null ? void 0 : n.map((g) => g.id === p.id ? {
362
- ...g,
363
- isDefault: !p.isDefault
364
- } : {
365
- ...g,
366
- isDefault: !1
367
- });
368
- r(c || []);
369
- const f = {
370
- ...p,
371
- isDefault: !p.isDefault
372
- };
373
- await it(h.apiServiceUrl, f, u == null ? void 0 : u.accessToken);
374
- const m = n == null ? void 0 : n.find((g) => g.isDefault);
375
- if (m && m.id !== p.id) {
376
- const g = {
377
- ...m,
378
- isDefault: !1
379
- };
380
- await it(h.apiServiceUrl, g, u == null ? void 0 : u.accessToken);
381
- }
382
- }
383
- return /* @__PURE__ */ i(R, { children: [
384
- e ? /* @__PURE__ */ i(R, { children: [
385
- /* @__PURE__ */ t(ue, { className: "px-3", children: "Lenses" }),
386
- /* @__PURE__ */ t(Fe, {})
387
- ] }) : null,
388
- /* @__PURE__ */ i(
389
- na,
390
- {
391
- value: a,
392
- onValueChange: l,
393
- children: [
394
- /* @__PURE__ */ t(Ut, { value: "original", children: "Original" }),
395
- n == null ? void 0 : n.map((p) => /* @__PURE__ */ i(
396
- Ut,
397
- {
398
- className: "group flex justify-between gap-2",
399
- value: p.id,
400
- children: [
401
- /* @__PURE__ */ t("p", { children: p.name }),
402
- /* @__PURE__ */ i("span", { className: "flex items-center gap-3", children: [
403
- /* @__PURE__ */ t(
404
- Xt,
405
- {
406
- onClick: (c) => {
407
- c.preventDefault(), x(p);
408
- },
409
- className: te(
410
- "size-3.5 text-muted-foreground hover:cursor-pointer hover:text-foreground group-hover:visible",
411
- {
412
- invisible: !p.isDefault,
413
- "text-green-500": p.isDefault
414
- }
415
- ),
416
- strokeWidth: 1.5
417
- }
418
- ),
419
- /* @__PURE__ */ t(
420
- Zt,
421
- {
422
- onClick: (c) => {
423
- c.preventDefault(), b(p.id);
424
- },
425
- className: "invisible size-3.5 text-muted-foreground hover:cursor-pointer hover:text-foreground group-hover:visible",
426
- strokeWidth: 1.5
427
- }
428
- )
429
- ] })
430
- ]
431
- },
432
- p.id
433
- ))
434
- ]
435
- }
436
- )
437
- ] });
438
- }
439
- function Ln() {
440
- const { displayPreferences: e, shouldShowElement: n } = sa(), { currentUser: a, userContext: r } = lt(), s = K(
441
- () => oa(a),
442
- [a]
443
- ), u = K(() => (l) => s && s[l] !== void 0 && s[l] === !1 ? !1 : n(l), [s, n, e]), h = K(
444
- () => {
445
- var l, b, x, p, c;
446
- return {
447
- canEdit: ((l = r == null ? void 0 : r.permissions) == null ? void 0 : l.canEdit) ?? ua(a),
448
- canUseFilters: ((b = r == null ? void 0 : r.permissions) == null ? void 0 : b.canEdit) ?? la(a),
449
- canManageDashboards: ((x = r == null ? void 0 : r.permissions) == null ? void 0 : x.canCreateDashboard) ?? ca(a),
450
- canCreateDashboards: ((p = r == null ? void 0 : r.permissions) == null ? void 0 : p.canCreateDashboard) ?? da(a),
451
- canAccessVisuals: ((c = r == null ? void 0 : r.permissions) == null ? void 0 : c.canEdit) ?? ia(a)
452
- };
453
- },
454
- [a, r]
455
- );
456
- return {
457
- displayPreferences: e,
458
- shouldShowElement: u,
459
- permissions: h,
460
- currentUser: a
461
- };
462
- }
463
- function In(e, n = []) {
464
- let a = [];
465
- function r(u, h) {
466
- const l = I.createContext(h);
467
- l.displayName = u + "Context";
468
- const b = a.length;
469
- a = [...a, h];
470
- const x = (c) => {
471
- var S;
472
- const { scope: f, children: m, ...g } = c, o = ((S = f == null ? void 0 : f[e]) == null ? void 0 : S[b]) || l, y = I.useMemo(() => g, Object.values(g));
473
- return /* @__PURE__ */ t(o.Provider, { value: y, children: m });
474
- };
475
- x.displayName = u + "Provider";
476
- function p(c, f) {
477
- var o;
478
- const m = ((o = f == null ? void 0 : f[e]) == null ? void 0 : o[b]) || l, g = I.useContext(m);
479
- if (g) return g;
480
- if (h !== void 0) return h;
481
- throw new Error(`\`${c}\` must be used within \`${u}\``);
482
- }
483
- return [x, p];
484
- }
485
- const s = () => {
486
- const u = a.map((h) => I.createContext(h));
487
- return function(l) {
488
- const b = (l == null ? void 0 : l[e]) || u;
489
- return I.useMemo(
490
- () => ({ [`__scope${e}`]: { ...l, [e]: b } }),
491
- [l, b]
492
- );
493
- };
494
- };
495
- return s.scopeName = e, [r, An(s, ...n)];
496
- }
497
- function An(...e) {
498
- const n = e[0];
499
- if (e.length === 1) return n;
500
- const a = () => {
501
- const r = e.map((s) => ({
502
- useScope: s(),
503
- scopeName: s.scopeName
504
- }));
505
- return function(u) {
506
- const h = r.reduce((l, { useScope: b, scopeName: x }) => {
507
- const c = b(u)[`__scope${x}`];
508
- return { ...l, ...c };
509
- }, {});
510
- return I.useMemo(() => ({ [`__scope${n.scopeName}`]: h }), [h]);
511
- };
512
- };
513
- return a.scopeName = n.scopeName, a;
514
- }
515
- var Mn = [
516
- "a",
517
- "button",
518
- "div",
519
- "form",
520
- "h2",
521
- "h3",
522
- "img",
523
- "input",
524
- "label",
525
- "li",
526
- "nav",
527
- "ol",
528
- "p",
529
- "select",
530
- "span",
531
- "svg",
532
- "ul"
533
- ], mt = Mn.reduce((e, n) => {
534
- const a = qr(`Primitive.${n}`), r = I.forwardRef((s, u) => {
535
- const { asChild: h, ...l } = s, b = h ? a : n;
536
- return typeof window < "u" && (window[Symbol.for("radix-ui")] = !0), /* @__PURE__ */ t(b, { ...l, ref: u });
537
- });
538
- return r.displayName = `Primitive.${n}`, { ...e, [n]: r };
539
- }, {});
540
- function Pn() {
541
- return wn.useSyncExternalStore(
542
- On,
543
- () => !0,
544
- () => !1
545
- );
546
- }
547
- function On() {
548
- return () => {
549
- };
550
- }
551
- var pt = "Avatar", [_n] = In(pt), [Rn, or] = _n(pt), ir = I.forwardRef(
552
- (e, n) => {
553
- const { __scopeAvatar: a, ...r } = e, [s, u] = I.useState("idle");
554
- return /* @__PURE__ */ t(
555
- Rn,
556
- {
557
- scope: a,
558
- imageLoadingStatus: s,
559
- onImageLoadingStatusChange: u,
560
- children: /* @__PURE__ */ t(mt.span, { ...r, ref: n })
561
- }
562
- );
563
- }
564
- );
565
- ir.displayName = pt;
566
- var dr = "AvatarImage", cr = I.forwardRef(
567
- (e, n) => {
568
- const { __scopeAvatar: a, src: r, onLoadingStatusChange: s = () => {
569
- }, ...u } = e, h = or(dr, a), l = Un(r, u), b = Vr((x) => {
570
- s(x), h.onImageLoadingStatusChange(x);
571
- });
572
- return rt(() => {
573
- l !== "idle" && b(l);
574
- }, [l, b]), l === "loaded" ? /* @__PURE__ */ t(mt.img, { ...u, ref: n, src: r }) : null;
575
- }
576
- );
577
- cr.displayName = dr;
578
- var lr = "AvatarFallback", ur = I.forwardRef(
579
- (e, n) => {
580
- const { __scopeAvatar: a, delayMs: r, ...s } = e, u = or(lr, a), [h, l] = I.useState(r === void 0);
581
- return I.useEffect(() => {
582
- if (r !== void 0) {
583
- const b = window.setTimeout(() => l(!0), r);
584
- return () => window.clearTimeout(b);
585
- }
586
- }, [r]), h && u.imageLoadingStatus !== "loaded" ? /* @__PURE__ */ t(mt.span, { ...s, ref: n }) : null;
587
- }
588
- );
589
- ur.displayName = lr;
590
- function Ht(e, n) {
591
- return e ? n ? (e.src !== n && (e.src = n), e.complete && e.naturalWidth > 0 ? "loaded" : "loading") : "error" : "idle";
592
- }
593
- function Un(e, { referrerPolicy: n, crossOrigin: a }) {
594
- const r = Pn(), s = I.useRef(null), u = r ? (s.current || (s.current = new window.Image()), s.current) : null, [h, l] = I.useState(
595
- () => Ht(u, e)
596
- );
597
- return rt(() => {
598
- l(Ht(u, e));
599
- }, [u, e]), rt(() => {
600
- const b = (c) => () => {
601
- l(c);
602
- };
603
- if (!u) return;
604
- const x = b("loaded"), p = b("error");
605
- return u.addEventListener("load", x), u.addEventListener("error", p), n && (u.referrerPolicy = n), typeof a == "string" && (u.crossOrigin = a), () => {
606
- u.removeEventListener("load", x), u.removeEventListener("error", p);
607
- };
608
- }, [u, a, n]), h;
609
- }
610
- var mr = ir, pr = cr, fr = ur;
611
- const hr = I.forwardRef(({ className: e, ...n }, a) => /* @__PURE__ */ t(
612
- mr,
613
- {
614
- ref: a,
615
- className: te(
616
- "relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full",
617
- e
618
- ),
619
- ...n
620
- }
621
- ));
622
- hr.displayName = mr.displayName;
623
- const Tn = I.forwardRef(({ className: e, ...n }, a) => /* @__PURE__ */ t(
624
- pr,
625
- {
626
- ref: a,
627
- className: te("aspect-square h-full w-full", e),
628
- ...n
629
- }
630
- ));
631
- Tn.displayName = pr.displayName;
632
- const gr = I.forwardRef(({ className: e, ...n }, a) => /* @__PURE__ */ t(
633
- fr,
634
- {
635
- ref: a,
636
- className: te(
637
- "flex h-full w-full items-center justify-center rounded-full bg-muted",
638
- e
639
- ),
640
- ...n
641
- }
642
- ));
643
- gr.displayName = fr.displayName;
644
- const Fn = async (e, n, a) => {
645
- const r = `${e}/management/v1/groups`;
646
- return await Kt(r, n, a);
647
- }, $n = async (e, n, a, r) => {
648
- const s = `${e}/management/v1/groups/${a}`;
649
- return ct(s, n, "PATCH", r);
650
- }, Gn = async (e, n, a) => {
651
- const r = `${e}/management/v1/groups/${a}`;
652
- await ct(r, n, "DELETE");
653
- }, Bn = async (e, n, a, r) => {
654
- const s = `${e}/management/v1/groups/${a}/members`;
655
- return await Kt(s, n, r);
656
- }, zn = async (e, n, a, r) => {
657
- const s = `${e}/management/v1/groups/${a}/members`;
658
- await ct(s, n, "DELETE", r);
659
- };
660
- function Hn() {
661
- const { authToken: e, tokenProps: n } = G(), a = pe();
662
- return fe({
663
- mutationFn: (r) => Fn(n.apiServiceUrl, (e == null ? void 0 : e.accessToken) || "", r),
664
- onSuccess: () => {
665
- a.invalidateQueries({ queryKey: ["groups"] }), C.success("Group created successfully");
666
- },
667
- onError: (r) => {
668
- console.error("Failed to create group:", r), C.error("Failed to create group", {
669
- description: me(r, "Failed to create group")
670
- });
671
- }
672
- });
673
- }
674
- function jn() {
675
- const { authToken: e, tokenProps: n } = G(), a = pe();
676
- return fe({
677
- mutationFn: ({
678
- groupId: r,
679
- data: s
680
- }) => $n(n.apiServiceUrl, (e == null ? void 0 : e.accessToken) || "", r, s),
681
- onSuccess: (r, s) => {
682
- a.invalidateQueries({ queryKey: ["group", s.groupId] }), a.invalidateQueries({ queryKey: ["groups"] }), C.success("Group updated successfully");
683
- },
684
- onError: (r) => {
685
- console.error("Failed to update group:", r), C.error("Failed to update group", {
686
- description: me(r, "Failed to update group")
687
- });
688
- }
689
- });
690
- }
691
- function qn() {
692
- const { authToken: e, tokenProps: n } = G(), a = pe();
693
- return fe({
694
- mutationFn: (r) => Gn(n.apiServiceUrl, (e == null ? void 0 : e.accessToken) || "", r),
695
- onSuccess: (r, s) => {
696
- a.invalidateQueries({ queryKey: ["groups"] }), a.removeQueries({ queryKey: ["group", s] }), C.success("Group deleted successfully");
697
- },
698
- onError: (r) => {
699
- console.error("Failed to delete group:", r), C.error("Failed to delete group", {
700
- description: me(r, "Failed to delete group")
701
- });
702
- }
703
- });
704
- }
705
- function Vn() {
706
- const { authToken: e, tokenProps: n } = G(), a = pe();
707
- return fe({
708
- mutationFn: ({
709
- groupId: r,
710
- data: s
711
- }) => Bn(n.apiServiceUrl, (e == null ? void 0 : e.accessToken) || "", r, s),
712
- onSuccess: (r, s) => {
713
- a.invalidateQueries({ queryKey: ["group", s.groupId] }), a.invalidateQueries({
714
- queryKey: ["group-members", s.groupId]
715
- }), a.invalidateQueries({ queryKey: ["groups"] }), C.success("Members added successfully");
716
- },
717
- onError: (r) => {
718
- console.error("Failed to add group members:", r), C.error("Failed to add members", {
719
- description: me(r, "Failed to add members")
720
- });
721
- }
722
- });
723
- }
724
- function Kn() {
725
- const { authToken: e, tokenProps: n } = G(), a = pe();
726
- return fe({
727
- mutationFn: ({
728
- groupId: r,
729
- data: s
730
- }) => zn(n.apiServiceUrl, (e == null ? void 0 : e.accessToken) || "", r, s),
731
- onSuccess: (r, s) => {
732
- a.invalidateQueries({ queryKey: ["group", s.groupId] }), a.invalidateQueries({
733
- queryKey: ["group-members", s.groupId]
734
- }), a.invalidateQueries({ queryKey: ["groups"] }), C.success("Members removed successfully");
735
- },
736
- onError: (r) => {
737
- console.error("Failed to remove group members:", r), C.error("Failed to remove members", {
738
- description: me(r, "Failed to remove members")
739
- });
740
- }
741
- });
742
- }
743
- const Qn = [];
744
- function Wn({
745
- open: e,
746
- onOpenChange: n
747
- }) {
748
- var k, L, E;
749
- const { tokenProps: a } = G(), { currentUser: r } = lt(), s = (r == null ? void 0 : r.type) === "tenant", u = a == null ? void 0 : a.tenantId, {
750
- groups: h,
751
- isLoading: l,
752
- error: b,
753
- refetch: x
754
- } = ma({
755
- type: s ? "TENANT_GROUP" : "all",
756
- tenantId: s ? u : void 0,
757
- includeMembers: !1
758
- }), p = b ? br(b, "Unable to load groups.") : null, [c, f] = w({ kind: "list" }), [m, g] = w(null), o = qn();
759
- Ge(() => {
760
- e || (f({ kind: "list" }), g(null));
761
- }, [e]);
762
- const y = c.kind === "members" && h.find((D) => D.id === c.groupId) || null, S = async () => {
763
- if (m)
764
- try {
765
- await o.mutateAsync(m.id), g(null), f({ kind: "list" }), x();
766
- } catch {
767
- }
768
- };
769
- return /* @__PURE__ */ t(Jt, { open: e, onOpenChange: n, children: /* @__PURE__ */ i(Yt, { className: "flex max-h-[640px] w-[720px] max-w-[92vw] flex-col gap-0 overflow-hidden p-0", children: [
770
- c.kind === "list" ? /* @__PURE__ */ i("div", { className: "shrink-0 border-b border-border px-5 pt-4 pb-3.5", children: [
771
- /* @__PURE__ */ t(at, { className: "text-[15px] font-semibold tracking-tight", children: "Group management" }),
772
- /* @__PURE__ */ t(nt, { className: "mt-1 text-[12px] leading-[1.5] text-muted-foreground", children: "Organize people into groups for shared access." })
773
- ] }) : c.kind === "create" ? /* @__PURE__ */ i("div", { className: "flex h-10 shrink-0 items-center gap-1.5 border-b border-border px-5", children: [
774
- /* @__PURE__ */ t(
775
- "button",
776
- {
777
- type: "button",
778
- onClick: () => f({ kind: "list" }),
779
- "aria-label": "Back",
780
- className: "-ml-1 flex h-6 w-6 items-center justify-center rounded-[3px] text-muted-foreground hover:bg-accent hover:text-foreground",
781
- children: /* @__PURE__ */ t(er, { className: "h-3.5 w-3.5" })
782
- }
783
- ),
784
- /* @__PURE__ */ t(at, { className: "truncate text-[13px] font-medium", children: "New group" }),
785
- /* @__PURE__ */ t(nt, { className: "sr-only", children: "Create a new group to organize members." })
786
- ] }) : null,
787
- c.kind === "list" && /* @__PURE__ */ t(
788
- Jn,
789
- {
790
- groups: h,
791
- isLoading: l,
792
- errorMessage: p,
793
- onRetry: () => x(),
794
- currentUserId: r == null ? void 0 : r.id,
795
- onOpenGroup: (D) => f({ kind: "members", groupId: D }),
796
- onCreate: () => f({ kind: "create" }),
797
- onDeleteRequest: (D) => g(D)
798
- }
799
- ),
800
- c.kind === "members" && y && /* @__PURE__ */ t(
801
- Zn,
802
- {
803
- group: y,
804
- isTenantViewer: s,
805
- canEdit: ((k = y.permissions) == null ? void 0 : k.canEdit) ?? y.createdBy === (r == null ? void 0 : r.id),
806
- canDelete: ((L = y.permissions) == null ? void 0 : L.canDelete) ?? y.createdBy === (r == null ? void 0 : r.id),
807
- canManageMembers: ((E = y.permissions) == null ? void 0 : E.canManageMembers) ?? y.createdBy === (r == null ? void 0 : r.id),
808
- onBack: () => f({ kind: "list" }),
809
- onMembersChanged: x,
810
- onUpdated: x,
811
- onRequestDelete: () => g(y)
812
- },
813
- y.id
814
- ),
815
- c.kind === "create" && /* @__PURE__ */ t(
816
- es,
817
- {
818
- isTenantUser: s,
819
- tenantId: u,
820
- onCancel: () => f({ kind: "list" }),
821
- onCreated: (D) => {
822
- x(), f({ kind: "members", groupId: D });
823
- }
824
- }
825
- ),
826
- m && /* @__PURE__ */ i("div", { className: "flex shrink-0 items-center justify-between gap-3 border-t border-border bg-muted/40 px-5 py-2.5", children: [
827
- /* @__PURE__ */ i("div", { className: "min-w-0 text-[12px] text-foreground", children: [
828
- "Delete ",
829
- /* @__PURE__ */ t("span", { className: "font-medium", children: m.name }),
830
- "?",
831
- /* @__PURE__ */ t("span", { className: "ml-2 text-muted-foreground", children: "Members lose any access granted via this group." })
832
- ] }),
833
- /* @__PURE__ */ i("div", { className: "flex shrink-0 items-center gap-1.5", children: [
834
- /* @__PURE__ */ t(
835
- "button",
836
- {
837
- type: "button",
838
- onClick: () => g(null),
839
- disabled: o.isPending,
840
- className: "h-7 rounded-[5px] px-2.5 text-[12px] font-medium text-foreground/80 hover:bg-background",
841
- children: "Cancel"
842
- }
843
- ),
844
- /* @__PURE__ */ i(
845
- "button",
846
- {
847
- type: "button",
848
- onClick: S,
849
- disabled: o.isPending,
850
- className: "inline-flex h-7 items-center gap-1.5 rounded-[5px] bg-rose-600 px-2.5 text-[12px] font-medium text-white hover:bg-rose-700 disabled:opacity-60",
851
- children: [
852
- o.isPending ? /* @__PURE__ */ t($e, { className: "h-3 w-3 animate-spin" }) : /* @__PURE__ */ t(ut, { className: "h-3 w-3" }),
853
- "Delete group"
854
- ]
855
- }
856
- )
857
- ] })
858
- ] })
859
- ] }) });
860
- }
861
- function Jn({
862
- groups: e,
863
- isLoading: n,
864
- errorMessage: a,
865
- onRetry: r,
866
- currentUserId: s,
867
- onOpenGroup: u,
868
- onCreate: h,
869
- onDeleteRequest: l
870
- }) {
871
- const [b, x] = w(""), p = K(
872
- () => e.filter(
873
- (c) => !b.trim() || c.name.toLowerCase().includes(b.toLowerCase()) || (c.description || "").toLowerCase().includes(b.toLowerCase())
874
- ),
875
- [e, b]
876
- );
877
- return /* @__PURE__ */ i("div", { className: "flex flex-1 flex-col overflow-hidden", children: [
878
- /* @__PURE__ */ i("div", { className: "flex shrink-0 items-center gap-2 border-b border-border px-5 py-2.5", children: [
879
- /* @__PURE__ */ i("div", { className: "flex flex-1 items-center gap-2 rounded-[5px] border border-border bg-background px-2 focus-within:border-foreground/40", children: [
880
- /* @__PURE__ */ t(pa, { className: "h-3 w-3 text-muted-foreground" }),
881
- /* @__PURE__ */ t(
882
- "input",
883
- {
884
- value: b,
885
- onChange: (c) => x(c.target.value),
886
- placeholder: "Search groups…",
887
- className: "h-7 flex-1 bg-transparent text-[12px] text-foreground placeholder:text-muted-foreground focus:outline-none"
888
- }
889
- ),
890
- b && /* @__PURE__ */ t(
891
- "button",
892
- {
893
- type: "button",
894
- onClick: () => x(""),
895
- className: "flex h-4 w-4 items-center justify-center rounded-[3px] text-muted-foreground hover:bg-accent hover:text-foreground",
896
- children: /* @__PURE__ */ t(Qt, { className: "h-2.5 w-2.5" })
897
- }
898
- )
899
- ] }),
900
- /* @__PURE__ */ i(
901
- "button",
902
- {
903
- type: "button",
904
- onClick: h,
905
- className: "inline-flex h-7 items-center gap-1.5 rounded-[5px] bg-foreground px-2.5 text-[12px] font-medium text-background hover:opacity-90",
906
- children: [
907
- /* @__PURE__ */ t(re, { className: "h-3 w-3" }),
908
- "New group"
909
- ]
910
- }
911
- )
912
- ] }),
913
- /* @__PURE__ */ t("div", { className: "flex-1 overflow-y-auto", children: n ? /* @__PURE__ */ t("div", { className: "space-y-px p-3", children: [1, 2, 3].map((c) => /* @__PURE__ */ t(
914
- "div",
915
- {
916
- className: "h-12 animate-pulse rounded-[4px] bg-muted/60"
917
- },
918
- c
919
- )) }) : a ? /* @__PURE__ */ t(
920
- xr,
921
- {
922
- title: "Can't load groups",
923
- message: a,
924
- onRetry: r
925
- }
926
- ) : p.length === 0 && e.length === 0 ? /* @__PURE__ */ t(Xn, { onCreate: h }) : p.length === 0 ? /* @__PURE__ */ i("div", { className: "flex h-full flex-col items-center justify-center gap-1 py-10 text-center", children: [
927
- /* @__PURE__ */ i("div", { className: "text-[12px] text-foreground", children: [
928
- 'No groups match "',
929
- b,
930
- '"'
931
- ] }),
932
- /* @__PURE__ */ t("div", { className: "text-[11px] text-muted-foreground", children: "Try a different search." })
933
- ] }) : p.map((c) => {
934
- var f;
935
- return /* @__PURE__ */ t(
936
- Yn,
937
- {
938
- group: c,
939
- canDelete: ((f = c.permissions) == null ? void 0 : f.canDelete) ?? c.createdBy === s,
940
- onClick: () => u(c.id),
941
- onDelete: () => l(c)
942
- },
943
- c.id
944
- );
945
- }) })
946
- ] });
947
- }
948
- function Yn({
949
- group: e,
950
- canDelete: n,
951
- onClick: a,
952
- onDelete: r
953
- }) {
954
- let s = "";
955
- try {
956
- s = nr(new Date(e.createdAt), "MMM d, yyyy");
957
- } catch {
958
- s = "";
959
- }
960
- return /* @__PURE__ */ i(
961
- "button",
962
- {
963
- type: "button",
964
- onClick: a,
965
- className: "group flex w-full items-center gap-3 border-b border-border/60 px-5 py-2.5 text-left hover:bg-accent/40",
966
- children: [
967
- /* @__PURE__ */ t("div", { className: "flex h-7 w-7 shrink-0 items-center justify-center rounded-[4px] border border-border bg-background text-muted-foreground", children: /* @__PURE__ */ t(Ya, { className: "h-3.5 w-3.5" }) }),
968
- /* @__PURE__ */ i("div", { className: "min-w-0 flex-1", children: [
969
- /* @__PURE__ */ t("div", { className: "truncate text-[13px] font-medium text-foreground", children: e.name }),
970
- /* @__PURE__ */ i("div", { className: "mt-0.5 flex items-center gap-2 text-[11px] text-muted-foreground", children: [
971
- /* @__PURE__ */ i("span", { className: "inline-flex items-center gap-1", children: [
972
- /* @__PURE__ */ t(sr, { className: "h-2.5 w-2.5" }),
973
- e.memberCount,
974
- " member",
975
- e.memberCount === 1 ? "" : "s"
976
- ] }),
977
- s && /* @__PURE__ */ i(R, { children: [
978
- /* @__PURE__ */ t("span", { className: "text-border", children: "·" }),
979
- /* @__PURE__ */ i("span", { className: "inline-flex items-center gap-1", children: [
980
- /* @__PURE__ */ t(rr, { className: "h-2.5 w-2.5" }),
981
- s
982
- ] })
983
- ] }),
984
- e.description && /* @__PURE__ */ i(R, { children: [
985
- /* @__PURE__ */ t("span", { className: "text-border", children: "·" }),
986
- /* @__PURE__ */ t("span", { className: "truncate text-muted-foreground", children: e.description })
987
- ] })
988
- ] })
989
- ] }),
990
- /* @__PURE__ */ i("div", { className: "flex items-center gap-0.5 opacity-0 transition-opacity group-hover:opacity-100", children: [
991
- n && /* @__PURE__ */ t(
992
- "span",
993
- {
994
- role: "button",
995
- tabIndex: 0,
996
- onClick: (u) => {
997
- u.stopPropagation(), r();
998
- },
999
- onKeyDown: (u) => {
1000
- (u.key === "Enter" || u.key === " ") && (u.preventDefault(), u.stopPropagation(), r());
1001
- },
1002
- "aria-label": `Delete ${e.name}`,
1003
- className: "flex h-6 w-6 items-center justify-center rounded-[3px] text-muted-foreground hover:bg-accent hover:text-foreground",
1004
- children: /* @__PURE__ */ t(ut, { className: "h-3 w-3" })
1005
- }
1006
- ),
1007
- /* @__PURE__ */ t(ga, { className: "h-3.5 w-3.5 text-muted-foreground" })
1008
- ] })
1009
- ]
1010
- }
1011
- );
1012
- }
1013
- function Xn({ onCreate: e }) {
1014
- return /* @__PURE__ */ i("div", { className: "flex h-full flex-col items-center justify-center gap-2 py-12 text-center", children: [
1015
- /* @__PURE__ */ t("div", { className: "flex h-9 w-9 items-center justify-center rounded-full border border-border bg-muted/40 text-muted-foreground", children: /* @__PURE__ */ t(tr, { className: "h-4 w-4" }) }),
1016
- /* @__PURE__ */ t("div", { className: "text-[13px] font-medium text-foreground", children: "No groups yet" }),
1017
- /* @__PURE__ */ t("div", { className: "max-w-[320px] text-[11.5px] leading-[1.55] text-muted-foreground", children: "Groups let you grant shared access to dashboards. Create one and add members." }),
1018
- /* @__PURE__ */ i(
1019
- "button",
1020
- {
1021
- type: "button",
1022
- onClick: e,
1023
- className: "mt-1 inline-flex h-7 items-center gap-1.5 rounded-[5px] bg-foreground px-2.5 text-[12px] font-medium text-background hover:opacity-90",
1024
- children: [
1025
- /* @__PURE__ */ t(re, { className: "h-3 w-3" }),
1026
- "New group"
1027
- ]
1028
- }
1029
- )
1030
- ] });
1031
- }
1032
- function Zn({
1033
- group: e,
1034
- isTenantViewer: n,
1035
- canEdit: a,
1036
- canDelete: r,
1037
- canManageMembers: s,
1038
- onBack: u,
1039
- onMembersChanged: h,
1040
- onUpdated: l,
1041
- onRequestDelete: b
1042
- }) {
1043
- const {
1044
- data: x,
1045
- isLoading: p,
1046
- error: c,
1047
- refetch: f
1048
- } = fa(e.id), m = (x == null ? void 0 : x.members) ?? Qn, g = c ? br(c, "Unable to load members for this group.") : null, o = e.type === "TENANT_GROUP" ? "tenant" : "organization", { users: y } = ha({
1049
- type: o,
1050
- tenantId: e.tenantId || void 0,
1051
- active: !0,
1052
- limit: 200
1053
- }), S = K(
1054
- () => new Set(m.map((v) => v.userId)),
1055
- [m]
1056
- ), k = Vn(), L = Kn(), E = jn(), [D, ae] = w(!1), [Q, ne] = w(e.name), [he, W] = w(!1), [J, Y] = w(e.description || ""), [X, ge] = w(""), [be, xe] = w(!1), ve = K(() => {
1057
- const v = X.trim().toLowerCase();
1058
- return y.filter((U) => !S.has(U.id)).filter(
1059
- (U) => !v || (U.name || "").toLowerCase().includes(v) || (U.email || "").toLowerCase().includes(v)
1060
- ).slice(0, 50);
1061
- }, [y, S, X]), ye = async () => {
1062
- const v = Q.trim();
1063
- if (ae(!1), v.length >= 3 && v !== e.name)
1064
- try {
1065
- await E.mutateAsync({
1066
- groupId: e.id,
1067
- data: { name: v }
1068
- }), l();
1069
- } catch {
1070
- }
1071
- }, z = async () => {
1072
- const v = J.trim();
1073
- if (W(!1), v !== (e.description || ""))
1074
- try {
1075
- await E.mutateAsync({
1076
- groupId: e.id,
1077
- data: { description: v }
1078
- }), l();
1079
- } catch {
1080
- }
1081
- }, Z = async (v) => {
1082
- if (s) {
1083
- ge(""), xe(!1);
1084
- try {
1085
- await k.mutateAsync({
1086
- groupId: e.id,
1087
- data: {
1088
- userIds: [v.id],
1089
- userType: o === "tenant" ? "tenant" : "org"
1090
- }
1091
- }), f(), h();
1092
- } catch {
1093
- }
1094
- }
1095
- }, ee = async (v) => {
1096
- if (s)
1097
- try {
1098
- await L.mutateAsync({
1099
- groupId: e.id,
1100
- data: { userIds: [v] }
1101
- }), f(), h();
1102
- } catch {
1103
- }
1104
- };
1105
- let H = "";
1106
- try {
1107
- H = nr(new Date(e.createdAt), "MMM d, yyyy");
1108
- } catch {
1109
- H = "";
1110
- }
1111
- return /* @__PURE__ */ i("div", { className: "flex flex-1 flex-col overflow-hidden", children: [
1112
- /* @__PURE__ */ i("div", { className: "flex h-10 shrink-0 items-center gap-1.5 border-b border-border px-5", children: [
1113
- /* @__PURE__ */ t(
1114
- "button",
1115
- {
1116
- type: "button",
1117
- onClick: u,
1118
- "aria-label": "Back",
1119
- className: "-ml-1 flex h-6 w-6 items-center justify-center rounded-[3px] text-muted-foreground hover:bg-accent hover:text-foreground",
1120
- children: /* @__PURE__ */ t(er, { className: "h-3.5 w-3.5" })
1121
- }
1122
- ),
1123
- D ? /* @__PURE__ */ t(
1124
- "input",
1125
- {
1126
- autoFocus: !0,
1127
- value: Q,
1128
- onChange: (v) => ne(v.target.value),
1129
- onBlur: ye,
1130
- onKeyDown: (v) => {
1131
- v.key === "Enter" && ye(), v.key === "Escape" && (ne(e.name), ae(!1));
1132
- },
1133
- className: "h-6 min-w-0 flex-1 rounded-[3px] border border-border bg-background px-1.5 text-[13px] font-medium text-foreground focus:border-foreground/40 focus:outline-none"
1134
- }
1135
- ) : /* @__PURE__ */ t(
1136
- "button",
1137
- {
1138
- type: "button",
1139
- onClick: () => {
1140
- a && (ne(e.name), ae(!0));
1141
- },
1142
- title: a ? "Click to rename" : e.name,
1143
- disabled: !a,
1144
- className: "truncate rounded-[3px] px-1 text-[13px] font-medium text-foreground enabled:hover:bg-accent disabled:cursor-default",
1145
- children: e.name
1146
- }
1147
- ),
1148
- /* @__PURE__ */ i("span", { className: "ml-1 inline-flex shrink-0 items-center gap-1 text-[10.5px] text-muted-foreground", children: [
1149
- /* @__PURE__ */ t(sr, { className: "h-2.5 w-2.5" }),
1150
- m.length,
1151
- " member",
1152
- m.length === 1 ? "" : "s"
1153
- ] })
1154
- ] }),
1155
- /* @__PURE__ */ t("div", { className: "shrink-0 border-b border-border px-5 py-2.5", children: he ? /* @__PURE__ */ i("div", { children: [
1156
- /* @__PURE__ */ t(
1157
- "textarea",
1158
- {
1159
- autoFocus: !0,
1160
- rows: 2,
1161
- value: J,
1162
- onChange: (v) => Y(v.target.value),
1163
- maxLength: 200,
1164
- onKeyDown: (v) => {
1165
- v.key === "Escape" && (Y(e.description || ""), W(!1)), v.key === "Enter" && (v.metaKey || v.ctrlKey) && z();
1166
- },
1167
- placeholder: "What is this group for?",
1168
- className: "block w-full resize-none rounded-[5px] border border-border bg-background px-2 py-1.5 text-[12px] text-foreground placeholder:text-muted-foreground focus:border-foreground/40 focus:outline-none"
1169
- }
1170
- ),
1171
- /* @__PURE__ */ i("div", { className: "mt-1.5 flex items-center justify-between", children: [
1172
- /* @__PURE__ */ i("span", { className: "text-[10.5px] text-muted-foreground", children: [
1173
- J.length,
1174
- "/200 · Esc to cancel · ⌘↩ to save"
1175
- ] }),
1176
- /* @__PURE__ */ i("div", { className: "flex items-center gap-1.5", children: [
1177
- /* @__PURE__ */ t(
1178
- "button",
1179
- {
1180
- type: "button",
1181
- onClick: () => {
1182
- Y(e.description || ""), W(!1);
1183
- },
1184
- className: "h-6 rounded-[5px] px-2 text-[11px] font-medium text-foreground/80 hover:bg-accent",
1185
- children: "Cancel"
1186
- }
1187
- ),
1188
- /* @__PURE__ */ t(
1189
- "button",
1190
- {
1191
- type: "button",
1192
- onClick: z,
1193
- className: "inline-flex h-6 items-center rounded-[5px] bg-foreground px-2 text-[11px] font-medium text-background hover:opacity-90",
1194
- children: "Save"
1195
- }
1196
- )
1197
- ] })
1198
- ] })
1199
- ] }) : /* @__PURE__ */ i(
1200
- "button",
1201
- {
1202
- type: "button",
1203
- onClick: () => {
1204
- a && (Y(e.description || ""), W(!0));
1205
- },
1206
- disabled: !a,
1207
- title: a ? "Click to edit description" : void 0,
1208
- className: "block w-full rounded-[3px] px-1 py-0.5 text-left enabled:hover:bg-accent/40 disabled:cursor-default",
1209
- children: [
1210
- e.description ? /* @__PURE__ */ t("p", { className: "text-[12px] leading-[1.55] text-foreground/90", children: e.description }) : /* @__PURE__ */ t("p", { className: "text-[12px] leading-[1.55] text-muted-foreground", children: a ? "Add a description…" : "No description" }),
1211
- /* @__PURE__ */ i("p", { className: "mt-1 text-[10.5px] text-muted-foreground", children: [
1212
- H ? `Created ${H}` : "Recently created",
1213
- a ? " · You can edit this group" : ""
1214
- ] })
1215
- ]
1216
- }
1217
- ) }),
1218
- s && /* @__PURE__ */ t(
1219
- ts,
1220
- {
1221
- query: X,
1222
- setQuery: ge,
1223
- open: be,
1224
- setOpen: xe,
1225
- candidates: ve,
1226
- showKindChip: !n,
1227
- onAdd: Z,
1228
- busy: k.isPending
1229
- }
1230
- ),
1231
- /* @__PURE__ */ t("div", { className: "flex-1 overflow-y-auto", children: p ? /* @__PURE__ */ t("div", { className: "space-y-px p-3", children: [1, 2, 3].map((v) => /* @__PURE__ */ t(
1232
- "div",
1233
- {
1234
- className: "h-10 animate-pulse rounded-[4px] bg-muted/60"
1235
- },
1236
- v
1237
- )) }) : g ? /* @__PURE__ */ t(
1238
- xr,
1239
- {
1240
- title: "Can't load members",
1241
- message: g,
1242
- onRetry: () => f()
1243
- }
1244
- ) : m.length === 0 ? /* @__PURE__ */ i("div", { className: "flex h-full flex-col items-center justify-center gap-1 py-10 text-center", children: [
1245
- /* @__PURE__ */ t("div", { className: "text-[12px] text-foreground", children: "No members yet" }),
1246
- /* @__PURE__ */ t("div", { className: "text-[11px] text-muted-foreground", children: s ? "Search above to add people to this group." : "This group does not have any members." })
1247
- ] }) : m.map((v) => {
1248
- var U, j, we, Ne, Se, A;
1249
- return /* @__PURE__ */ i(
1250
- "div",
1251
- {
1252
- className: "group flex items-center gap-2 border-b border-border/60 px-5 py-2",
1253
- children: [
1254
- /* @__PURE__ */ t(vr, { name: ((U = v.user) == null ? void 0 : U.name) || ((j = v.user) == null ? void 0 : j.email) || "?" }),
1255
- /* @__PURE__ */ i("div", { className: "min-w-0 flex-1", children: [
1256
- /* @__PURE__ */ t("div", { className: "truncate text-[12.5px] font-medium text-foreground", children: ((we = v.user) == null ? void 0 : we.name) || ((Ne = v.user) == null ? void 0 : Ne.email) || "Unknown" }),
1257
- ((Se = v.user) == null ? void 0 : Se.email) && v.user.name && /* @__PURE__ */ t("div", { className: "truncate text-[10.5px] text-muted-foreground", children: v.user.email })
1258
- ] }),
1259
- !n && /* @__PURE__ */ t("span", { className: "text-[10px] uppercase tracking-[0.06em] text-muted-foreground", children: v.userType }),
1260
- /* @__PURE__ */ t(
1261
- "button",
1262
- {
1263
- type: "button",
1264
- onClick: () => ee(v.userId),
1265
- disabled: !s || L.isPending,
1266
- "aria-label": `Remove ${((A = v.user) == null ? void 0 : A.name) || "member"}`,
1267
- className: "flex h-6 w-6 items-center justify-center rounded-[3px] text-muted-foreground opacity-0 transition-opacity hover:bg-accent hover:text-foreground group-hover:opacity-100 disabled:opacity-30",
1268
- children: /* @__PURE__ */ t(Qt, { className: "h-3 w-3" })
1269
- }
1270
- )
1271
- ]
1272
- },
1273
- v.id
1274
- );
1275
- }) }),
1276
- r && /* @__PURE__ */ t("div", { className: "flex shrink-0 items-center justify-end gap-1.5 border-t border-border bg-muted/30 px-5 py-2.5", children: /* @__PURE__ */ i(
1277
- "button",
1278
- {
1279
- type: "button",
1280
- onClick: b,
1281
- className: "inline-flex h-7 items-center gap-1.5 rounded-[5px] border border-rose-200 bg-background px-2.5 text-[12px] font-medium text-rose-600 hover:bg-rose-50 dark:border-rose-900/60 dark:text-rose-400 dark:hover:bg-rose-950/30",
1282
- children: [
1283
- /* @__PURE__ */ t(ut, { className: "h-3 w-3" }),
1284
- "Delete group"
1285
- ]
1286
- }
1287
- ) })
1288
- ] });
1289
- }
1290
- function es({
1291
- isTenantUser: e,
1292
- tenantId: n,
1293
- onCancel: a,
1294
- onCreated: r
1295
- }) {
1296
- const [s, u] = w(""), [h, l] = w(""), [b, x] = w(null), p = Hn(), c = s.trim().length >= 3 && s.trim().length <= 50, f = async () => {
1297
- if (!c) return;
1298
- x(null);
1299
- const m = {
1300
- name: s.trim(),
1301
- description: h.trim() || void 0,
1302
- type: e ? "TENANT_GROUP" : "ORG_GROUP",
1303
- ...e && n ? { tenantId: n } : {}
1304
- };
1305
- try {
1306
- const g = await p.mutateAsync(m), o = g == null ? void 0 : g.id;
1307
- o ? r(o) : a();
1308
- } catch (g) {
1309
- x(g instanceof Error ? g.message : "Failed to create group");
1310
- }
1311
- };
1312
- return /* @__PURE__ */ i("div", { className: "flex flex-1 flex-col overflow-hidden", children: [
1313
- /* @__PURE__ */ i("div", { className: "flex-1 overflow-y-auto px-5 py-4", children: [
1314
- /* @__PURE__ */ t(jt, { children: "Name" }),
1315
- /* @__PURE__ */ t(
1316
- "input",
1317
- {
1318
- autoFocus: !0,
1319
- value: s,
1320
- onChange: (m) => u(m.target.value),
1321
- placeholder: "Marketing leads, North America sales, …",
1322
- maxLength: 50,
1323
- className: "mt-1 block h-7 w-full rounded-[5px] border border-border bg-background px-2 text-[12px] text-foreground placeholder:text-muted-foreground focus:border-foreground/40 focus:outline-none"
1324
- }
1325
- ),
1326
- /* @__PURE__ */ t("div", { className: "mt-1 text-[10.5px] text-muted-foreground", children: "3–50 characters." }),
1327
- /* @__PURE__ */ i("div", { className: "mt-4", children: [
1328
- /* @__PURE__ */ t(jt, { children: "Description (optional)" }),
1329
- /* @__PURE__ */ t(
1330
- "textarea",
1331
- {
1332
- rows: 2,
1333
- value: h,
1334
- onChange: (m) => l(m.target.value),
1335
- maxLength: 200,
1336
- placeholder: "What is this group for?",
1337
- className: "mt-1 block w-full resize-none rounded-[5px] border border-border bg-background px-2 py-1.5 text-[12px] text-foreground placeholder:text-muted-foreground focus:border-foreground/40 focus:outline-none"
1338
- }
1339
- ),
1340
- /* @__PURE__ */ i("div", { className: "mt-1 flex justify-end text-[10.5px] text-muted-foreground", children: [
1341
- h.length,
1342
- "/200"
1343
- ] })
1344
- ] }),
1345
- b && /* @__PURE__ */ t("div", { className: "mt-3 rounded-[5px] border border-rose-200 bg-rose-50 px-2 py-1.5 text-[11.5px] text-rose-700 dark:border-rose-900/60 dark:bg-rose-950/30 dark:text-rose-300", children: b })
1346
- ] }),
1347
- /* @__PURE__ */ i("div", { className: "flex shrink-0 items-center justify-end gap-1.5 border-t border-border bg-muted/30 px-5 py-2.5", children: [
1348
- /* @__PURE__ */ t(
1349
- "button",
1350
- {
1351
- type: "button",
1352
- onClick: a,
1353
- disabled: p.isPending,
1354
- className: "h-7 rounded-[5px] px-2.5 text-[12px] font-medium text-foreground/80 hover:bg-accent",
1355
- children: "Cancel"
1356
- }
1357
- ),
1358
- /* @__PURE__ */ t(
1359
- "button",
1360
- {
1361
- type: "button",
1362
- onClick: f,
1363
- disabled: !c || p.isPending,
1364
- className: "inline-flex h-7 items-center gap-1.5 rounded-[5px] bg-foreground px-2.5 text-[12px] font-medium text-background hover:opacity-90 disabled:cursor-not-allowed disabled:opacity-60",
1365
- children: p.isPending ? /* @__PURE__ */ i(R, { children: [
1366
- /* @__PURE__ */ t($e, { className: "h-3 w-3 animate-spin" }),
1367
- "Creating…"
1368
- ] }) : /* @__PURE__ */ i(R, { children: [
1369
- /* @__PURE__ */ t(re, { className: "h-3 w-3" }),
1370
- "Create group"
1371
- ] })
1372
- }
1373
- )
1374
- ] })
1375
- ] });
1376
- }
1377
- function ts({
1378
- query: e,
1379
- setQuery: n,
1380
- open: a,
1381
- setOpen: r,
1382
- candidates: s,
1383
- showKindChip: u,
1384
- onAdd: h,
1385
- busy: l
1386
- }) {
1387
- const b = $t(null), x = $t(null), [p, c] = w(null);
1388
- Qa(() => {
1389
- if (!a) {
1390
- c(null);
1391
- return;
1392
- }
1393
- const m = () => {
1394
- const g = b.current;
1395
- if (!g) return;
1396
- const o = g.getBoundingClientRect(), y = 240, k = window.innerHeight - o.bottom < y + 16 && o.top > y;
1397
- c({
1398
- left: o.left,
1399
- top: k ? o.top - 6 : o.bottom + 6,
1400
- width: o.width,
1401
- above: k
1402
- });
1403
- };
1404
- return m(), window.addEventListener("resize", m), window.addEventListener("scroll", m, !0), () => {
1405
- window.removeEventListener("resize", m), window.removeEventListener("scroll", m, !0);
1406
- };
1407
- }, [a, s.length]), Ge(() => {
1408
- if (!a) return;
1409
- const m = (g) => {
1410
- var y, S;
1411
- const o = g.target;
1412
- (y = b.current) != null && y.contains(o) || (S = x.current) != null && S.contains(o) || r(!1);
1413
- };
1414
- return document.addEventListener("mousedown", m), () => document.removeEventListener("mousedown", m);
1415
- }, [a, r]);
1416
- const f = a && s.length > 0 && p;
1417
- return /* @__PURE__ */ i("div", { className: "shrink-0 border-b border-border px-5 py-2.5", children: [
1418
- /* @__PURE__ */ i(
1419
- "div",
1420
- {
1421
- ref: b,
1422
- className: "flex items-center gap-2 rounded-[5px] border border-border bg-background px-2 focus-within:border-foreground/40",
1423
- children: [
1424
- /* @__PURE__ */ t(xn, { className: "h-3 w-3 text-muted-foreground" }),
1425
- /* @__PURE__ */ t(
1426
- "input",
1427
- {
1428
- value: e,
1429
- onChange: (m) => {
1430
- n(m.target.value), r(!0);
1431
- },
1432
- onFocus: () => r(!0),
1433
- placeholder: "Add a member by name or email…",
1434
- disabled: l,
1435
- className: "h-7 flex-1 bg-transparent text-[12px] text-foreground placeholder:text-muted-foreground focus:outline-none disabled:cursor-not-allowed"
1436
- }
1437
- )
1438
- ]
1439
- }
1440
- ),
1441
- f && typeof document < "u" && Ja(
1442
- /* @__PURE__ */ t(
1443
- "div",
1444
- {
1445
- ref: x,
1446
- style: {
1447
- position: "fixed",
1448
- left: p.left,
1449
- top: p.top,
1450
- width: p.width,
1451
- transform: p.above ? "translateY(-100%)" : void 0
1452
- },
1453
- className: "z-[60] max-h-[240px] overflow-y-auto rounded-[5px] border border-border bg-background shadow-[0_8px_24px_-12px_rgba(0,0,0,0.18)]",
1454
- children: s.map((m) => /* @__PURE__ */ i(
1455
- "button",
1456
- {
1457
- type: "button",
1458
- onClick: () => h(m),
1459
- className: "flex w-full items-center gap-2 border-b border-border/60 px-2.5 py-2 text-left last:border-b-0 hover:bg-accent",
1460
- children: [
1461
- /* @__PURE__ */ t(vr, { name: m.name || m.email || "?" }),
1462
- /* @__PURE__ */ i("div", { className: "min-w-0 flex-1", children: [
1463
- /* @__PURE__ */ t("div", { className: "truncate text-[12px] font-medium text-foreground", children: m.name || m.email || "Unknown" }),
1464
- m.email && m.name && /* @__PURE__ */ t("div", { className: "truncate text-[10.5px] text-muted-foreground", children: m.email })
1465
- ] }),
1466
- u && m.type && /* @__PURE__ */ t("span", { className: "text-[10px] uppercase tracking-[0.06em] text-muted-foreground", children: m.type === "tenant" ? "tenant" : "org" })
1467
- ]
1468
- },
1469
- m.id
1470
- ))
1471
- }
1472
- ),
1473
- document.body
1474
- )
1475
- ] });
1476
- }
1477
- function br(e, n) {
1478
- if (!e) return n;
1479
- if (e instanceof Error) {
1480
- const a = e.message || "", r = a.match(/\{[\s\S]*"error"\s*:\s*"([^"]+)"[\s\S]*\}/);
1481
- return r ? r[1] : a || n;
1482
- }
1483
- return typeof e == "string" ? e : n;
1484
- }
1485
- function xr({
1486
- title: e,
1487
- message: n,
1488
- onRetry: a
1489
- }) {
1490
- return /* @__PURE__ */ i("div", { className: "flex h-full flex-col items-center justify-center gap-2 px-6 py-10 text-center", children: [
1491
- /* @__PURE__ */ t("div", { className: "text-[12.5px] font-medium text-foreground", children: e }),
1492
- /* @__PURE__ */ t("div", { className: "max-w-[360px] text-[11.5px] leading-[1.55] text-muted-foreground", children: n }),
1493
- a && /* @__PURE__ */ t(
1494
- "button",
1495
- {
1496
- type: "button",
1497
- onClick: a,
1498
- className: "mt-1 inline-flex h-7 items-center rounded-[5px] border border-border bg-background px-2.5 text-[11.5px] font-medium text-foreground hover:bg-accent",
1499
- children: "Try again"
1500
- }
1501
- )
1502
- ] });
1503
- }
1504
- function jt({ children: e }) {
1505
- return /* @__PURE__ */ t("label", { className: "text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground", children: e });
1506
- }
1507
- function vr({ name: e }) {
1508
- const n = e.split(" ").map((a) => a[0]).filter(Boolean).slice(0, 2).join("").toUpperCase();
1509
- return /* @__PURE__ */ t(hr, { className: "h-6 w-6 shrink-0", children: /* @__PURE__ */ t(gr, { className: "text-[9px] font-semibold", children: n || "?" }) });
1510
- }
1511
- function ce(e, n, a) {
1512
- var u, h;
1513
- const r = (e.controls || []).find(
1514
- (l) => l.id === a
1515
- );
1516
- if (r)
1517
- return r.label;
1518
- const s = (h = (u = Wt(e, n)) == null ? void 0 : u.controls) == null ? void 0 : h.find(
1519
- (l) => l.id === a
1520
- );
1521
- return (s == null ? void 0 : s.label) || a;
1522
- }
1523
- function le(e, n) {
1524
- var a;
1525
- return ((a = Wt(e, n)) == null ? void 0 : a.title) || n;
1526
- }
1527
- function rs(e) {
1528
- const { errors: n, dashboard: a } = e;
1529
- if (!a)
1530
- return n;
1531
- const r = /* @__PURE__ */ new Map();
1532
- for (const s of n) {
1533
- const u = s.match(
1534
- /^Card '(.+)' binding for control '(.+)' maps to missing metric '(.+)'\.$/
1535
- );
1536
- if (u) {
1537
- const [, p, c] = u, f = `${p}:${c}:missing-metric`;
1538
- r.has(f) || r.set(
1539
- f,
1540
- `"${le(a, p)}" has an outdated "${ce(
1541
- a,
1542
- p,
1543
- c
1544
- )}" mapping. Some choices still point to metrics that are no longer available on this card. Open the card controls and choose replacements.`
1545
- );
1546
- continue;
1547
- }
1548
- const h = s.match(
1549
- /^Card '(.+)' binding for control '(.+)' maps to missing group-by field '(.+)'\.$/
1550
- );
1551
- if (h) {
1552
- const [, p, c] = h, f = `${p}:${c}:missing-group-by`;
1553
- r.has(f) || r.set(
1554
- f,
1555
- `"${le(a, p)}" has an outdated "${ce(
1556
- a,
1557
- p,
1558
- c
1559
- )}" mapping. Some choices still point to fields that are no longer available on this card. Open the card controls and choose replacements.`
1560
- );
1561
- continue;
1562
- }
1563
- const l = s.match(
1564
- /^Card '(.+)' binding for control '(.+)' maps to an invalid metric target\.$/
1565
- );
1566
- if (l) {
1567
- const [, p, c] = l, f = `${p}:${c}:invalid-metric`;
1568
- r.has(f) || r.set(
1569
- f,
1570
- `"${le(a, p)}" has an invalid "${ce(
1571
- a,
1572
- p,
1573
- c
1574
- )}" metric mapping. Open the card controls and choose a valid metric for each option.`
1575
- );
1576
- continue;
1577
- }
1578
- const b = s.match(
1579
- /^Card '(.+)' binding for control '(.+)' maps to an invalid group-by target\.$/
1580
- );
1581
- if (b) {
1582
- const [, p, c] = b, f = `${p}:${c}:invalid-group-by`;
1583
- r.has(f) || r.set(
1584
- f,
1585
- `"${le(a, p)}" has an invalid "${ce(
1586
- a,
1587
- p,
1588
- c
1589
- )}" field mapping. Open the card controls and choose a valid field for each option.`
1590
- );
1591
- continue;
1592
- }
1593
- const x = s.match(
1594
- /^Card '(.+)' binding for control '(.+)' requires at least one temporal group-by field\.$/
1595
- );
1596
- if (x) {
1597
- const [, p, c] = x, f = `${p}:${c}:missing-temporal-group-by`;
1598
- r.has(f) || r.set(
1599
- f,
1600
- `"${le(a, p)}" can no longer use "${ce(
1601
- a,
1602
- p,
1603
- c
1604
- )}" for time grain because the card does not currently group by a date field.`
1605
- );
1606
- continue;
1607
- }
1608
- r.set(s, s);
1609
- }
1610
- return Array.from(r.values());
1611
- }
1612
- function as(e, n) {
1613
- return typeof e == "boolean" ? e : typeof n == "boolean" ? n : !0;
1614
- }
1615
- function qt(e, n) {
1616
- return {
1617
- dashboard: st(e),
1618
- semanticExecutionPayload: st(n)
1619
- };
1620
- }
1621
- function ys() {
1622
- var Et, Lt, It, At, Mt, Pt, Ot;
1623
- Xa(), Za();
1624
- const {
1625
- authToken: e,
1626
- tokenProps: n,
1627
- id: a,
1628
- showBriefings: r
1629
- } = G(), { isLocalDev: s } = ba(), { openBrandStudioPreview: u } = xa(), { permissions: h } = Ln(), l = va(), { isLoading: b } = ya(), x = N((d) => d.theme), p = N((d) => d.isDownloadingPdf), c = N(
1630
- (d) => d.dashboardAssistantDraftScopeKey
1631
- ), f = N((d) => d.lenses), m = N((d) => d.selectedLensId), g = f == null ? void 0 : f.find((d) => d.id === m), o = N((d) => d.dashboard), y = N((d) => d.selectedSheetId), S = (Et = o == null ? void 0 : o.sheets) == null ? void 0 : Et.find(
1632
- (d) => d.id === y
1633
- ), k = Kr(S), L = k ? (Lt = S == null ? void 0 : S.document) == null ? void 0 : Lt.page : void 0, E = N(
1634
- (d) => d.isDashboardEditing
1635
- ), { setDashboardTitle: D } = N((d) => d.actions), [ae, Q] = w(!1), [ne, he] = w(!1), [W, J] = w(!1), [Y, X] = w(!1), [ge, be] = w(!1), [xe, ve] = w(!1), [ye, z] = w(!1), [Z, ee] = w(null), [H, v] = w([]), [U, j] = w(!1), we = N((d) => d.isDashboardPanelOpen), Ne = N(
1636
- (d) => d.actions.setIsDashboardPanelOpen
1637
- ), Se = N((d) => d.filterValues), A = N((d) => d.isVisualEditing);
1638
- Rt((d) => d.card);
1639
- const se = Ue(
1640
- (d) => d.selectedDashboard
1641
- ), De = Ue(
1642
- (d) => d.initialDashboard
1643
- );
1644
- Ue((d) => d.selectedVisual), N((d) => d.selectedFrameId), Rt((d) => d.frame);
1645
- const ke = se ? (At = se == null ? void 0 : se.permissions) == null ? void 0 : At.canEdit : (It = De == null ? void 0 : De.permissions) == null ? void 0 : It.canEdit, ft = N(
1646
- (d) => d.showDashboardJSON
1647
- ), Be = N((d) => d.onSaveFunction), {
1648
- setIsDashboardEditing: ht,
1649
- setShowDashboardJSON: gt
1650
- } = N((d) => d.actions), { setInitialDashboard: bt, clearSelectedDashboard: ze } = Ue(
1651
- (d) => d.actions
1652
- ), { resources: Ce } = wa(Ye.DASHBOARD), { data: He } = Na(), yr = ((Mt = He == null ? void 0 : He.preference) == null ? void 0 : Mt.defaultDashboardId) || null, { mutate: wr, isPending: Nr } = Sa(), { currentUser: Sr } = lt(), Dr = Da(Sr), T = se || De, xt = T ? {
1653
- id: T.id,
1654
- title: (o == null ? void 0 : o.title) || T.title || "Dashboard"
1655
- } : null, { handleAddNewFrame: kr } = ka(), [je, qe] = w(!1), [Cr, oe] = w(!1), [Ve, Ee] = w("close"), ie = Ca(Ye.DASHBOARD), [O, Le] = w(null), Er = async (d, M) => {
1656
- if (!(o != null && o.id)) {
1657
- console.log("No dashboard ID found");
1658
- return;
1659
- }
1660
- console.log("Updating dashboard title:", {
1661
- dashboardId: o.id,
1662
- newTitle: d,
1663
- previousTitle: M
1664
- }), ie.mutate(
1665
- {
1666
- resourceId: o.id,
1667
- data: { title: d }
1668
- },
1669
- {
1670
- onSuccess: () => {
1671
- console.log("Dashboard title updated successfully"), C.success("Dashboard title updated");
1672
- },
1673
- onError: (F) => {
1674
- console.error("Failed to update dashboard title:", F), C.error("Failed to update dashboard title"), D(M);
1675
- }
1676
- }
1677
- );
1678
- };
1679
- Ge(() => {
1680
- if (Ce && Ce.length > 0) {
1681
- const d = o == null ? void 0 : o.id;
1682
- if (d) {
1683
- const M = Ce.find(
1684
- (F) => F.id === d
1685
- );
1686
- M && bt(M);
1687
- }
1688
- }
1689
- }, [Ce, o == null ? void 0 : o.id, bt]);
1690
- const de = n.orgUserId || n.tenantId, Ke = K(
1691
- () => ns({
1692
- accessToken: e == null ? void 0 : e.accessToken,
1693
- dashboardId: (o == null ? void 0 : o.id) || a || n.dashboard_id,
1694
- selectedSheetId: k ? y : void 0,
1695
- pageSize: L == null ? void 0 : L.size,
1696
- orientation: L == null ? void 0 : L.orientation,
1697
- theme: x
1698
- }),
1699
- [
1700
- e == null ? void 0 : e.accessToken,
1701
- a,
1702
- o == null ? void 0 : o.id,
1703
- k,
1704
- L == null ? void 0 : L.orientation,
1705
- L == null ? void 0 : L.size,
1706
- y,
1707
- x,
1708
- n.dashboard_id
1709
- ]
1710
- ), vt = E && !A && de && ke, { setDashboard: yt } = N((d) => d.actions), wt = N(
1711
- (d) => d.semanticExecutionPayload
1712
- ), Lr = () => {
1713
- ht(!0);
1714
- }, Qe = () => {
1715
- ht(!1), gt(!1), Le(null);
1716
- };
1717
- Ge(() => {
1718
- if (!E) {
1719
- O && Le(null);
1720
- return;
1721
- }
1722
- O || !o || b || Le(
1723
- qt(
1724
- o,
1725
- wt
1726
- )
1727
- );
1728
- }, [
1729
- o,
1730
- O,
1731
- E,
1732
- b,
1733
- wt
1734
- ]);
1735
- const Ie = (O == null ? void 0 : O.dashboard) ?? null, { isDirty: Nt, isDirtyPending: Ir, resetDirty: Ae } = cn(
1736
- o,
1737
- Ie,
1738
- 300,
1739
- 1e3,
1740
- Ze
1741
- ), St = Wa(() => Ie ? Ze(o) !== Ze(Ie) : !1, [o, Ie]), Dt = Nt || Ir, Me = je || ie.isPending, Ar = () => {
1742
- St() ? (Ee("close"), oe(!0)) : (Qe(), Ae());
1743
- }, Mr = async () => {
1744
- await We({
1745
- closeAfterSave: !0,
1746
- navigateHomeAfterSave: Ve === "home"
1747
- });
1748
- }, Pr = () => {
1749
- O && yt(O.dashboard, {
1750
- semanticExecutionPayload: O.semanticExecutionPayload
1751
- }), Qe(), Ve === "home" && ze(), Ee("close"), oe(!1), Ae();
1752
- }, Or = () => {
1753
- O && (yt(O.dashboard, {
1754
- semanticExecutionPayload: O.semanticExecutionPayload
1755
- }), Ae());
1756
- }, _r = () => {
1757
- if (E && St()) {
1758
- Ee("home"), oe(!0);
1759
- return;
1760
- }
1761
- ze();
1762
- };
1763
- async function We(d) {
1764
- const M = N.getState().dashboard;
1765
- if (!M)
1766
- return;
1767
- const F = (d == null ? void 0 : d.closeAfterSave) ?? U, Gr = (d == null ? void 0 : d.navigateHomeAfterSave) ?? !1;
1768
- j(F), F && oe(!1);
1769
- const Br = st(M);
1770
- z(!0), ee(null), v([]), qe(!0);
1771
- const zr = {
1772
- template: M
1773
- };
1774
- ie.mutate(
1775
- {
1776
- resourceId: M.id,
1777
- data: zr
1778
- },
1779
- {
1780
- onSuccess: (P) => {
1781
- var Oe, _e, _t;
1782
- const V = (P == null ? void 0 : P.id) || ((Oe = P == null ? void 0 : P.dashboard) == null ? void 0 : Oe.id) || ((_e = P == null ? void 0 : P.resource) == null ? void 0 : _e.id) || ((_t = P == null ? void 0 : P.template) == null ? void 0 : _t.id) || null;
1783
- if (!M.id && V) {
1784
- const Je = Zr.getState(), Re = Je.pendingDashboardDraftMigration;
1785
- (Re == null ? void 0 : Re.scopeKey) === c ? Je.actions.setPendingDashboardDraftMigrationExpectedDashboardId(
1786
- V
1787
- ) : Re && Je.actions.clearPendingDashboardDraftMigration();
1788
- }
1789
- qe(!1), C.success("Dashboard saved!"), Le(
1790
- qt(
1791
- Br,
1792
- N.getState().semanticExecutionPayload
1793
- )
1794
- ), z(!1), j(!1), F && (Qe(), Ae(), Gr && ze()), Ee("close");
1795
- },
1796
- onError: (P) => {
1797
- qe(!1), ee("Failed to save dashboard. Please try again.");
1798
- const V = P.details, Oe = Array.isArray(
1799
- V == null ? void 0 : V.errors
1800
- ) ? (V.errors || []).filter(
1801
- (_e) => typeof _e == "string"
1802
- ) : [];
1803
- v(
1804
- rs({
1805
- errors: Oe,
1806
- dashboard: M || void 0
1807
- })
1808
- ), C.error("Failed to save dashboard");
1809
- }
1810
- }
1811
- );
1812
- }
1813
- async function Rr() {
1814
- if (Q(!0), !m || !g) return;
1815
- const d = N.getState().dashboard;
1816
- if (!d) {
1817
- Q(!1);
1818
- return;
1819
- }
1820
- const M = JSON.stringify(d), F = {
1821
- ...g,
1822
- template: M,
1823
- filterValues: Se
1824
- };
1825
- await it(
1826
- n.apiServiceUrl,
1827
- F,
1828
- e == null ? void 0 : e.accessToken
1829
- ), C.success("Lens saved"), Be == null || Be(d), Q(!1);
1830
- }
1831
- const kt = (g == null ? void 0 : g.name) || o.title;
1832
- ie.isPending && console.log("Title during update:", {
1833
- title: kt,
1834
- dashboardStateTitle: o.title,
1835
- dashboardId: o == null ? void 0 : o.id,
1836
- currentLensName: g == null ? void 0 : g.name
1837
- });
1838
- const Ct = n.orgUserId || n.tenantId && n.endUserId && n.endUserEmail, Ur = !!Ct && !!(e != null && e.accessToken) && !!(n != null && n.apiServiceUrl), Tr = l, q = (o == null ? void 0 : o.id) || null, Fr = as(
1839
- (Pt = n.config) == null ? void 0 : Pt.showBriefings,
1840
- r
1841
- ), Pe = !!q && yr === q, $r = () => {
1842
- q && wr({
1843
- dashboardId: Pe ? null : q
1844
- });
1845
- };
1846
- return /* @__PURE__ */ i(
1847
- "div",
1848
- {
1849
- className: "flex h-11 shrink-0 items-center justify-between gap-2 overflow-x-auto border-b px-4 py-2",
1850
- role: "dashboard-controls",
1851
- children: [
1852
- /* @__PURE__ */ i("div", { className: "flex items-center gap-2", children: [
1853
- Ct && /* @__PURE__ */ i(R, { children: [
1854
- /* @__PURE__ */ t(
1855
- Xe,
1856
- {
1857
- "aria-label": "Manage Dashboards",
1858
- tooltip: "Manage Dashboards",
1859
- onClick: () => {
1860
- Ne(!we);
1861
- },
1862
- className: "h-7 w-7 px-0",
1863
- buttonProps: { size: "xs" },
1864
- children: /* @__PURE__ */ t(pn, { className: "h-3.5 w-3.5" })
1865
- }
1866
- ),
1867
- Tr && !A && /* @__PURE__ */ t(
1868
- Xe,
1869
- {
1870
- "aria-label": "Dashboard Hub",
1871
- tooltip: "Dashboard Hub",
1872
- onClick: _r,
1873
- className: "h-7 w-7 px-0",
1874
- buttonProps: { size: "xs" },
1875
- children: /* @__PURE__ */ t(Xt, { className: "h-3.5 w-3.5" })
1876
- }
1877
- )
1878
- ] }),
1879
- !A && l && (b ? /* @__PURE__ */ t(
1880
- "div",
1881
- {
1882
- className: "h-4 w-28 animate-pulse rounded-md bg-muted/70",
1883
- "aria-label": "Loading dashboard title",
1884
- role: "status",
1885
- children: /* @__PURE__ */ t("span", { className: "sr-only", children: "Loading dashboard title" })
1886
- }
1887
- ) : /* @__PURE__ */ i(R, { children: [
1888
- /* @__PURE__ */ t(
1889
- Ea,
1890
- {
1891
- value: kt || "Untitled Dashboard",
1892
- onSave: (d) => {
1893
- console.log("EditableText onSave called:", {
1894
- newTitle: d,
1895
- canEditDashboard: ke,
1896
- dashboardId: o == null ? void 0 : o.id
1897
- });
1898
- const M = (o == null ? void 0 : o.title) || "";
1899
- D(d), Er(d, M);
1900
- },
1901
- isEditable: ke && !g,
1902
- displayClassName: "text-[13px] font-medium",
1903
- inputClassName: "text-[13px] font-medium",
1904
- placeholder: "Dashboard Title",
1905
- isPending: ie.isPending
1906
- }
1907
- ),
1908
- Ur && q && /* @__PURE__ */ t(Qr, { children: /* @__PURE__ */ i(Wr, { children: [
1909
- /* @__PURE__ */ t(Jr, { asChild: !0, children: /* @__PURE__ */ t(
1910
- _,
1911
- {
1912
- variant: "ghost",
1913
- size: "xs",
1914
- onClick: $r,
1915
- disabled: Nr || !(e != null && e.accessToken) || !(n != null && n.apiServiceUrl),
1916
- className: "w-7 px-0",
1917
- "aria-label": Pe ? "Remove as default dashboard" : "Make this a default dashboard",
1918
- children: /* @__PURE__ */ t(
1919
- La,
1920
- {
1921
- className: te(
1922
- "h-3.5 w-3.5 transition-colors",
1923
- Pe ? "fill-foreground text-foreground" : "text-muted-foreground hover:text-foreground"
1924
- )
1925
- }
1926
- )
1927
- }
1928
- ) }),
1929
- /* @__PURE__ */ t(Yr, { children: /* @__PURE__ */ t("p", { children: Pe ? "Remove as default dashboard" : "Make this a default dashboard" }) })
1930
- ] }) })
1931
- ] }))
1932
- ] }),
1933
- /* @__PURE__ */ i("div", { className: "flex items-center gap-2", children: [
1934
- A && /* @__PURE__ */ i(R, { children: [
1935
- /* @__PURE__ */ t(en, {}),
1936
- /* @__PURE__ */ t(tn, {})
1937
- ] }),
1938
- !A && l && ((Ot = T == null ? void 0 : T.permissions) == null ? void 0 : Ot.canShare) && /* @__PURE__ */ i(
1939
- _,
1940
- {
1941
- variant: "outline",
1942
- size: "xs",
1943
- onClick: () => he(!0),
1944
- children: [
1945
- /* @__PURE__ */ t(Ia, { className: "h-3.5 w-3.5" }),
1946
- "Share"
1947
- ]
1948
- }
1949
- ),
1950
- !A && !E && l && q && Fr && /* @__PURE__ */ t(
1951
- rn,
1952
- {
1953
- dashboardId: q,
1954
- dashboardTitle: (o == null ? void 0 : o.title) || (T == null ? void 0 : T.title)
1955
- }
1956
- ),
1957
- !A && E && h.canUseFilters && l && /* @__PURE__ */ t(an, {}),
1958
- E && !A && de && g && s && l && /* @__PURE__ */ i(
1959
- _,
1960
- {
1961
- variant: "secondary",
1962
- size: "xs",
1963
- disabled: ae,
1964
- onClick: Rr,
1965
- children: [
1966
- /* @__PURE__ */ t(Gt, { className: "h-3.5 w-3.5" }),
1967
- "Save Lens"
1968
- ]
1969
- }
1970
- ),
1971
- E && !A && l && !k && /* @__PURE__ */ i(
1972
- _,
1973
- {
1974
- variant: "outline",
1975
- size: "xs",
1976
- disabled: !E,
1977
- onClick: () => kr(),
1978
- children: [
1979
- /* @__PURE__ */ t(re, { className: "h-3.5 w-3.5" }),
1980
- "Visual"
1981
- ]
1982
- }
1983
- ),
1984
- !A && !E && ke && l && /* @__PURE__ */ i(_, { size: "xs", onClick: Lr, children: [
1985
- /* @__PURE__ */ t(Aa, { className: "h-3.5 w-3.5" }),
1986
- "Edit"
1987
- ] }),
1988
- vt && l && Nt && /* @__PURE__ */ i(
1989
- _,
1990
- {
1991
- variant: "outline",
1992
- size: "xs",
1993
- onClick: Or,
1994
- disabled: Me,
1995
- children: [
1996
- /* @__PURE__ */ t(nn, { className: "h-3.5 w-3.5" }),
1997
- "Undo"
1998
- ]
1999
- }
2000
- ),
2001
- vt && l && /* @__PURE__ */ i(
2002
- _,
2003
- {
2004
- size: "xs",
2005
- className: te(!Dt && "opacity-60"),
2006
- disabled: Me || !Dt,
2007
- onClick: () => We(),
2008
- children: [
2009
- Me ? /* @__PURE__ */ t($e, { className: "h-3.5 w-3.5 animate-spin" }) : /* @__PURE__ */ t(Gt, { className: "h-3.5 w-3.5" }),
2010
- Me ? "Saving..." : "Save"
2011
- ]
2012
- }
2013
- ),
2014
- E && !A && l && /* @__PURE__ */ i(_, { variant: "outline", size: "xs", onClick: Ar, children: [
2015
- /* @__PURE__ */ t(Zt, { className: "h-3.5 w-3.5" }),
2016
- "Close"
2017
- ] }),
2018
- !A && l && /* @__PURE__ */ t("div", { className: "ml-2", children: /* @__PURE__ */ t(sn, {}) }),
2019
- !A && s && /* @__PURE__ */ t(Nn, {}),
2020
- !A && l && /* @__PURE__ */ i(Ma, { children: [
2021
- /* @__PURE__ */ t(Pa, { asChild: !0, children: /* @__PURE__ */ t(
2022
- Xe,
2023
- {
2024
- tooltip: "More Options",
2025
- className: "w-7 px-0 text-muted-foreground hover:text-foreground",
2026
- buttonProps: {
2027
- size: "xs",
2028
- variant: "ghost",
2029
- "aria-label": "More dashboard options"
2030
- },
2031
- children: /* @__PURE__ */ t(Oa, { className: "h-3.5 w-3.5" })
2032
- }
2033
- ) }),
2034
- /* @__PURE__ */ i(
2035
- _a,
2036
- {
2037
- align: "end",
2038
- className: "w-56 rounded-control border border-border/60 p-1 shadow-sm",
2039
- children: [
2040
- /* @__PURE__ */ t(ue, { children: "Reports" }),
2041
- /* @__PURE__ */ i(
2042
- $,
2043
- {
2044
- disabled: p,
2045
- onSelect: () => ve(!0),
2046
- children: [
2047
- /* @__PURE__ */ t(Ra, { className: "h-3.5 w-3.5" }),
2048
- "Export"
2049
- ]
2050
- }
2051
- ),
2052
- /* @__PURE__ */ t(Fe, {}),
2053
- Dr && /* @__PURE__ */ i(R, { children: [
2054
- /* @__PURE__ */ t(ue, { children: "Access" }),
2055
- /* @__PURE__ */ i(
2056
- $,
2057
- {
2058
- onClick: () => J(!0),
2059
- children: [
2060
- /* @__PURE__ */ t(tr, { className: "h-3.5 w-3.5" }),
2061
- "Manage Groups"
2062
- ]
2063
- }
2064
- ),
2065
- /* @__PURE__ */ t(Fe, {})
2066
- ] }),
2067
- /* @__PURE__ */ t(ue, { children: "Preferences" }),
2068
- /* @__PURE__ */ i($, { onClick: () => X(!0), children: [
2069
- /* @__PURE__ */ t(rr, { className: "h-3.5 w-3.5" }),
2070
- "Calendar Preferences"
2071
- ] }),
2072
- s && l && /* @__PURE__ */ i(R, { children: [
2073
- /* @__PURE__ */ t(Fe, {}),
2074
- /* @__PURE__ */ t(ue, { children: "Developer" }),
2075
- /* @__PURE__ */ i(
2076
- $,
2077
- {
2078
- onSelect: () => {
2079
- var d;
2080
- e != null && e.accessToken && ((d = navigator == null ? void 0 : navigator.clipboard) != null && d.writeText ? navigator.clipboard.writeText(e.accessToken).then(
2081
- () => C.success("Token copied to clipboard")
2082
- ).catch(() => C.error("Unable to copy token")) : C.error("Clipboard not available"));
2083
- },
2084
- children: [
2085
- /* @__PURE__ */ t(Tt, { className: "h-3.5 w-3.5" }),
2086
- "Copy token"
2087
- ]
2088
- }
2089
- ),
2090
- k && /* @__PURE__ */ i(
2091
- $,
2092
- {
2093
- disabled: !Ke,
2094
- onSelect: () => {
2095
- var d;
2096
- if (!Ke) {
2097
- C.error(
2098
- "Open a document sheet with a token to copy the local PDF URL"
2099
- );
2100
- return;
2101
- }
2102
- (d = navigator == null ? void 0 : navigator.clipboard) != null && d.writeText ? navigator.clipboard.writeText(Ke).then(
2103
- () => C.success(
2104
- "Local document PDF URL copied to clipboard"
2105
- )
2106
- ).catch(
2107
- () => C.error(
2108
- "Unable to copy local document PDF URL"
2109
- )
2110
- ) : C.error("Clipboard not available");
2111
- },
2112
- children: [
2113
- /* @__PURE__ */ t(Tt, { className: "h-3.5 w-3.5" }),
2114
- "Copy local document PDF URL"
2115
- ]
2116
- }
2117
- ),
2118
- /* @__PURE__ */ i(
2119
- $,
2120
- {
2121
- onSelect: () => Xr(n.apiServiceUrl),
2122
- children: [
2123
- /* @__PURE__ */ t(gn, { className: "h-3.5 w-3.5" }),
2124
- "Invalidate token"
2125
- ]
2126
- }
2127
- ),
2128
- /* @__PURE__ */ i($, { onSelect: u, children: [
2129
- /* @__PURE__ */ t(ln, { className: "h-3.5 w-3.5" }),
2130
- "Brand Studio"
2131
- ] }),
2132
- E && /* @__PURE__ */ i(
2133
- $,
2134
- {
2135
- onSelect: () => gt(!ft),
2136
- children: [
2137
- /* @__PURE__ */ t(un, { className: "h-3.5 w-3.5" }),
2138
- ft ? "Hide dashboard JSON" : "Show dashboard JSON"
2139
- ]
2140
- }
2141
- ),
2142
- de && E && /* @__PURE__ */ i($, { onSelect: () => be(!0), children: [
2143
- /* @__PURE__ */ t(re, { className: "h-3.5 w-3.5" }),
2144
- "Add lens"
2145
- ] }),
2146
- de && /* @__PURE__ */ i(Ua, { children: [
2147
- /* @__PURE__ */ i(Ta, { children: [
2148
- /* @__PURE__ */ t(mn, { className: "h-3.5 w-3.5" }),
2149
- "Lenses"
2150
- ] }),
2151
- /* @__PURE__ */ t(Fa, { className: "w-60", children: /* @__PURE__ */ t(En, {}) })
2152
- ] })
2153
- ] })
2154
- ]
2155
- }
2156
- )
2157
- ] }),
2158
- ne && xt && /* @__PURE__ */ t(
2159
- $a,
2160
- {
2161
- resource: xt,
2162
- resourceType: Ye.DASHBOARD,
2163
- onClose: () => he(!1)
2164
- }
2165
- ),
2166
- /* @__PURE__ */ t(
2167
- Wn,
2168
- {
2169
- open: W,
2170
- onOpenChange: J
2171
- }
2172
- ),
2173
- /* @__PURE__ */ t(
2174
- dn,
2175
- {
2176
- open: Y,
2177
- onOpenChange: X
2178
- }
2179
- ),
2180
- s && de && l && /* @__PURE__ */ t(Cn, { open: ge, onOpenChange: be }),
2181
- l && /* @__PURE__ */ t(
2182
- Ga,
2183
- {
2184
- open: xe,
2185
- onOpenChange: ve
2186
- }
2187
- ),
2188
- /* @__PURE__ */ t(
2189
- Ba,
2190
- {
2191
- open: ye,
2192
- onOpenChange: (d) => {
2193
- !d && je && !Z || (z(d), d || (ee(null), v([]), j(!1)));
2194
- },
2195
- children: /* @__PURE__ */ i(za, { className: "max-w-sm", children: [
2196
- /* @__PURE__ */ i(Ha, { children: [
2197
- /* @__PURE__ */ t(ja, { children: Z ? "Save failed" : "Saving dashboard" }),
2198
- /* @__PURE__ */ t(qa, { className: "pt-2", children: Z ? "We could not save the dashboard. Please try again." : "Please wait while we save your changes." }),
2199
- H.length > 0 && /* @__PURE__ */ i("div", { className: "space-y-1 rounded-md border border-destructive/20 bg-destructive/5 p-3 text-left", children: [
2200
- /* @__PURE__ */ t("div", { className: "text-sm font-medium text-destructive", children: "What needs attention" }),
2201
- /* @__PURE__ */ t("ul", { className: "list-disc space-y-1 pl-4 text-xs text-muted-foreground", children: H.slice(0, 5).map((d) => /* @__PURE__ */ t("li", { children: d }, d)) })
2202
- ] })
2203
- ] }),
2204
- /* @__PURE__ */ t(Va, { className: "flex-col gap-2 sm:flex-row sm:justify-end", children: Z ? /* @__PURE__ */ i(R, { children: [
2205
- /* @__PURE__ */ t(
2206
- Ka,
2207
- {
2208
- onClick: () => {
2209
- z(!1), ee(null), v([]), j(!1);
2210
- },
2211
- className: "m-0",
2212
- children: "Close"
2213
- }
2214
- ),
2215
- /* @__PURE__ */ t(
2216
- Ft,
2217
- {
2218
- onClick: () => We({
2219
- closeAfterSave: U,
2220
- navigateHomeAfterSave: Ve === "home"
2221
- }),
2222
- className: "m-0",
2223
- children: "Retry"
2224
- }
2225
- )
2226
- ] }) : /* @__PURE__ */ i(Ft, { disabled: !0, className: "m-0 cursor-default", children: [
2227
- /* @__PURE__ */ t($e, { className: "mr-2 h-4 w-4 animate-spin" }),
2228
- "Saving..."
2229
- ] }) })
2230
- ] })
2231
- }
2232
- ),
2233
- /* @__PURE__ */ t(
2234
- on,
2235
- {
2236
- open: Cr,
2237
- onOpenChange: (d) => {
2238
- oe(d);
2239
- },
2240
- onSave: Mr,
2241
- onDiscard: Pr,
2242
- isSaving: je,
2243
- saveLabel: "Save",
2244
- discardLabel: "Discard"
2245
- }
2246
- )
2247
- ] })
2248
- ]
2249
- }
2250
- );
2251
- }
2252
- function ns({
2253
- accessToken: e,
2254
- dashboardId: n,
2255
- selectedSheetId: a,
2256
- pageSize: r,
2257
- orientation: s,
2258
- theme: u
2259
- }) {
2260
- if (!e || !a)
2261
- return null;
2262
- const h = new URL("http://localhost:5173/print-document");
2263
- h.searchParams.set("token", e), n && h.searchParams.set("dashboardId", n), h.searchParams.set("selectedSheetId", a), u && h.searchParams.set("theme", u);
2264
- const l = new URL("http://127.0.0.1:3002/");
2265
- return l.searchParams.set("pdfMode", "document"), l.searchParams.set("pageSize", r || "letter"), l.searchParams.set("orientation", s || "portrait"), l.searchParams.set("url", h.toString()), l.toString();
2266
- }
2267
- export {
2268
- ys as default
2269
- };