react-semaphor 0.1.301 → 0.1.302

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 (66) hide show
  1. package/dist/appearance/index.cjs +1 -0
  2. package/dist/appearance/index.js +9 -0
  3. package/dist/brand-studio/index.cjs +21 -0
  4. package/dist/brand-studio/index.js +1512 -0
  5. package/dist/chunks/{braces-BwK7fWd_.js → braces-CpOcaBNm.js} +1 -1
  6. package/dist/chunks/{braces-Bhqo4iW1.js → braces-TYclg8Hl.js} +1 -1
  7. package/dist/chunks/dashboard-controls-BkuB9TQX.js +47 -0
  8. package/dist/chunks/dashboard-controls-CZuC_QjN.js +2227 -0
  9. package/dist/chunks/dashboard-filter-controls-button-2I1ltWQ9.js +11 -0
  10. package/dist/chunks/{dashboard-filter-controls-button-DjALRkvg.js → dashboard-filter-controls-button-kfb_T18o.js} +205 -216
  11. package/dist/chunks/dashboard-json-C3v6rBdp.js +1 -0
  12. package/dist/chunks/{dashboard-json-D-zIG46N.js → dashboard-json-Df6v2Jem.js} +14 -12
  13. package/dist/chunks/dashboard-summary-settings-dialog-BBALEHJQ.js +1 -0
  14. package/dist/chunks/{dashboard-summary-settings-dialog-D-F1eEJI.js → dashboard-summary-settings-dialog-DKAaWq-G.js} +64 -63
  15. package/dist/chunks/date-formatter-D9Bvw5Qk.js +1 -0
  16. package/dist/chunks/date-formatter-DyIOb6uC.js +333 -0
  17. package/dist/chunks/edit-dashboard-visual-CGBYahAK.js +183 -0
  18. package/dist/chunks/{edit-dashboard-visual-BjflrL8w.js → edit-dashboard-visual-D8L0cl_U.js} +6691 -6679
  19. package/dist/chunks/{index-DDA12yqV.js → index-BmoR3VQT.js} +48608 -66300
  20. package/dist/chunks/index-Cxb9UUro.js +4 -0
  21. package/dist/chunks/index-D7KJindZ.js +1 -0
  22. package/dist/chunks/index-DFOb_6HB.js +1657 -0
  23. package/dist/chunks/index-eM6MU4q_.js +1361 -0
  24. package/dist/chunks/index-uRJmUpof.js +2555 -0
  25. package/dist/chunks/palette-326-dgn0.js +6 -0
  26. package/dist/chunks/palette-jd7xiGTg.js +23 -0
  27. package/dist/chunks/{resource-management-panel-B2558XA1.js → resource-management-panel-C_c-BwrC.js} +116 -115
  28. package/dist/chunks/resource-management-panel-DrcEEARD.js +6 -0
  29. package/dist/chunks/rotate-ccw-BugHcM1w.js +6 -0
  30. package/dist/chunks/rotate-ccw-yFwqBFJZ.js +14 -0
  31. package/dist/chunks/save-CaybXtdd.js +6 -0
  32. package/dist/chunks/save-DU0FXUlM.js +21 -0
  33. package/dist/chunks/switch-AmoR1YIA.js +163 -0
  34. package/dist/chunks/switch-CZtMtqEj.js +19725 -0
  35. package/dist/chunks/{use-create-flow-overlay-state-BUw_JtLs.js → use-create-flow-overlay-state-84Xe8VrP.js} +396 -412
  36. package/dist/chunks/use-create-flow-overlay-state-CiKVJGWF.js +16 -0
  37. package/dist/chunks/use-visual-utils-lp5DfmvL.js +1 -0
  38. package/dist/chunks/{use-visual-utils-C45OxsOf.js → use-visual-utils-z3ifg6Fd.js} +54 -53
  39. package/dist/dashboard/index.cjs +1 -1
  40. package/dist/dashboard/index.js +1 -1
  41. package/dist/format-utils/index.cjs +1 -1
  42. package/dist/format-utils/index.js +2 -2
  43. package/dist/index.cjs +1 -1
  44. package/dist/index.js +210 -207
  45. package/dist/style.css +1 -1
  46. package/dist/surfboard/index.cjs +1 -1
  47. package/dist/surfboard/index.js +2 -2
  48. package/dist/types/appearance.d.ts +176 -0
  49. package/dist/types/brand-studio.d.ts +245 -0
  50. package/dist/types/dashboard.d.ts +134 -0
  51. package/dist/types/main.d.ts +141 -1
  52. package/dist/types/surfboard.d.ts +134 -0
  53. package/dist/types/types.d.ts +139 -0
  54. package/package.json +13 -1
  55. package/dist/chunks/dashboard-controls-BIRiWCUK.js +0 -47
  56. package/dist/chunks/dashboard-controls-DIlnYo96.js +0 -2219
  57. package/dist/chunks/dashboard-filter-controls-button-CK1-mKQh.js +0 -11
  58. package/dist/chunks/dashboard-json-DK4mQ1gS.js +0 -1
  59. package/dist/chunks/dashboard-summary-settings-dialog-DSxNqxFI.js +0 -1
  60. package/dist/chunks/date-formatter-CqXdM6JO.js +0 -1
  61. package/dist/chunks/date-formatter-vkCj9Ct-.js +0 -1982
  62. package/dist/chunks/edit-dashboard-visual-DCsrtJr_.js +0 -193
  63. package/dist/chunks/index-8GnvL1_L.js +0 -1523
  64. package/dist/chunks/resource-management-panel-CKp4_aem.js +0 -6
  65. package/dist/chunks/use-create-flow-overlay-state-CWcCdPbC.js +0 -21
  66. package/dist/chunks/use-visual-utils-DyaThRzf.js +0 -1
@@ -1,2219 +0,0 @@
1
- import { jsx as e, jsxs as c, Fragment as k } from "react/jsx-runtime";
2
- import { c as Z, dt as ls, u as D, B as L, du as Nt, Q as wt, d as j, e as Fe, dv as cs, cx as dt, f as Re, g as Ge, h as $e, i as St, L as ut, I as de, w as ds, dw as ce, cO as Pe, dx as us, dy as ta, dz as da, b as Y, dA as ua, dB as ms, d3 as Dt, dC as hs, dD as ps, dE as fs, dF as gs, dG as vs, dH as bs, J as Ve, Z as ze, y as I, dI as qe, dJ as ma, dK as ha, dc as ys, dL as xs, x as X, dM as Ns, dN as ws, dO as mt, dP as Ss, dQ as Ds, dR as pa, dS as fa, dT as Te, dU as _e, d8 as ht, cT as pt, dV as ft, cN as Ct, cl as ga, dW as gt, cg as va, dX as Cs, cW as ba, cX as ya, cY as xa, cZ as Na, c_ as wa, c$ as Sa, d0 as Da, d1 as vt, dY as Ca, dZ as Es, cF as Is, d_ as Ls, aj as Ms, d$ as As, W as aa, ai as Oe, e0 as Os, ap as ks, ak as nt, e1 as Ps, e2 as Ts, e3 as _s, aE as Us, e4 as Fs, aa as rt, e5 as Rs, bV as Gs, bW as $s, bX as Vs, e6 as zs, bY as qs, e7 as Hs, ds as Bs, e8 as js, cG as Ks, cH as Qs, cI as Ws, cJ as Js, cK as V, di as Ys, ac as Xs, cQ as Zs, e9 as en, cL as sa, av as tn, ea as an, eb as sn, ec as nn, ao as rn, ad as on, ed as ln, a8 as bt, ee as cn } from "./index-DDA12yqV.js";
3
- import * as M from "react";
4
- import Ea, { useState as N, useMemo as F, useCallback as Ue, useEffect as ot } from "react";
5
- import "react-dom";
6
- import { b as dn, u as un, A as mn, V as hn, c as pn, D as fn, N as gn, U as vn } from "./dashboard-filter-controls-button-DjALRkvg.js";
7
- import { l as bn } from "./date-formatter-vkCj9Ct-.js";
8
- import { C as yn, D as xn } from "./dashboard-summary-settings-dialog-D-F1eEJI.js";
9
- import { u as Nn } from "./use-debounced-dirty-check-BwAbnX_5.js";
10
- import { s as it } from "./normalize-dashboard-for-dirty-check-5KpZN8xr.js";
11
- import { u as wn, e as Sn, S as na } from "./use-create-flow-overlay-state-BUw_JtLs.js";
12
- import { B as Dn } from "./braces-Bhqo4iW1.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 Cn = Z("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 En = Z("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 In = Z("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 Ln = Z("Moon", [
55
- ["path", { d: "M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z", key: "a7tn18" }]
56
- ]);
57
- /**
58
- * @license lucide-react v0.453.0 - ISC
59
- *
60
- * This source code is licensed under the ISC license.
61
- * See the LICENSE file in the root directory of this source tree.
62
- */
63
- const Mn = Z("ShieldX", [
64
- [
65
- "path",
66
- {
67
- d: "M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",
68
- key: "oel41y"
69
- }
70
- ],
71
- ["path", { d: "m14.5 9.5-5 5", key: "17q4r4" }],
72
- ["path", { d: "m9.5 9.5 5 5", key: "18nt4w" }]
73
- ]);
74
- /**
75
- * @license lucide-react v0.453.0 - ISC
76
- *
77
- * This source code is licensed under the ISC license.
78
- * See the LICENSE file in the root directory of this source tree.
79
- */
80
- const An = Z("Sun", [
81
- ["circle", { cx: "12", cy: "12", r: "4", key: "4exip2" }],
82
- ["path", { d: "M12 2v2", key: "tus03m" }],
83
- ["path", { d: "M12 20v2", key: "1lh1kg" }],
84
- ["path", { d: "m4.93 4.93 1.41 1.41", key: "149t6j" }],
85
- ["path", { d: "m17.66 17.66 1.41 1.41", key: "ptbguv" }],
86
- ["path", { d: "M2 12h2", key: "1t8f8n" }],
87
- ["path", { d: "M20 12h2", key: "1q8mjw" }],
88
- ["path", { d: "m6.34 17.66-1.41 1.41", key: "1m8zz5" }],
89
- ["path", { d: "m19.07 4.93-1.41 1.41", key: "1shlcs" }]
90
- ]);
91
- var yt = { exports: {} }, lt = {};
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 ra;
102
- function On() {
103
- if (ra) return lt;
104
- ra = 1;
105
- var t = Ea;
106
- function s(f, h) {
107
- return f === h && (f !== 0 || 1 / f === 1 / h) || f !== f && h !== h;
108
- }
109
- var n = typeof Object.is == "function" ? Object.is : s, a = t.useState, o = t.useEffect, l = t.useLayoutEffect, u = t.useDebugValue;
110
- function d(f, h) {
111
- var r = h(), g = a({ inst: { value: r, getSnapshot: h } }), y = g[0].inst, w = g[1];
112
- return l(
113
- function() {
114
- y.value = r, y.getSnapshot = h, p(y) && w({ inst: y });
115
- },
116
- [f, r, h]
117
- ), o(
118
- function() {
119
- return p(y) && w({ inst: y }), f(function() {
120
- p(y) && w({ inst: y });
121
- });
122
- },
123
- [f]
124
- ), u(r), r;
125
- }
126
- function p(f) {
127
- var h = f.getSnapshot;
128
- f = f.value;
129
- try {
130
- var r = h();
131
- return !n(f, r);
132
- } catch {
133
- return !0;
134
- }
135
- }
136
- function v(f, h) {
137
- return h();
138
- }
139
- var m = typeof window > "u" || typeof window.document > "u" || typeof window.document.createElement > "u" ? v : d;
140
- return lt.useSyncExternalStore = t.useSyncExternalStore !== void 0 ? t.useSyncExternalStore : m, lt;
141
- }
142
- var ct = {};
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 oa;
153
- function kn() {
154
- return oa || (oa = 1, process.env.NODE_ENV !== "production" && function() {
155
- function t(r, g) {
156
- return r === g && (r !== 0 || 1 / r === 1 / g) || r !== r && g !== g;
157
- }
158
- function s(r, g) {
159
- m || o.startTransition === void 0 || (m = !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 (!f) {
164
- var w = g();
165
- l(y, w) || (console.error(
166
- "The result of getSnapshot should be cached to avoid an infinite loop"
167
- ), f = !0);
168
- }
169
- w = u({
170
- inst: { value: y, getSnapshot: g }
171
- });
172
- var x = w[0].inst, C = w[1];
173
- return p(
174
- function() {
175
- x.value = y, x.getSnapshot = g, n(x) && C({ inst: x });
176
- },
177
- [r, y, g]
178
- ), d(
179
- function() {
180
- return n(x) && C({ inst: x }), r(function() {
181
- n(x) && C({ inst: x });
182
- });
183
- },
184
- [r]
185
- ), v(y), y;
186
- }
187
- function n(r) {
188
- var g = r.getSnapshot;
189
- r = r.value;
190
- try {
191
- var y = g();
192
- return !l(r, y);
193
- } catch {
194
- return !0;
195
- }
196
- }
197
- function a(r, 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 o = Ea, l = typeof Object.is == "function" ? Object.is : t, u = o.useState, d = o.useEffect, p = o.useLayoutEffect, v = o.useDebugValue, m = !1, f = !1, h = typeof window > "u" || typeof window.document > "u" || typeof window.document.createElement > "u" ? a : s;
202
- ct.useSyncExternalStore = o.useSyncExternalStore !== void 0 ? o.useSyncExternalStore : h, typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ < "u" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop == "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());
203
- }()), ct;
204
- }
205
- process.env.NODE_ENV === "production" ? yt.exports = On() : yt.exports = kn();
206
- var Pn = yt.exports;
207
- const ke = ["light", "dark", "system"];
208
- function Tn() {
209
- const { theme: t, setTheme: s } = ls(), n = D(
210
- (u) => u.actions.setDashboardTheme
211
- );
212
- function a() {
213
- const u = ke.includes(t) ? t : "system", d = ke[(ke.indexOf(u) + 1) % ke.length];
214
- s(d), n(d);
215
- }
216
- const o = t === "light" ? An : t === "dark" ? Ln : In, l = t === "light" ? "Theme: light (click for dark)" : t === "dark" ? "Theme: dark (click for system)" : "Theme: system (click for light)";
217
- return /* @__PURE__ */ e(
218
- L,
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: a,
225
- "aria-label": l,
226
- title: l,
227
- children: /* @__PURE__ */ e(o, { className: "h-3.5 w-3.5", strokeWidth: 1.5 })
228
- }
229
- );
230
- }
231
- async function _n(t, s, n, a, o) {
232
- if (!o)
233
- return null;
234
- const l = JSON.stringify(n), u = `${t}/v1/lens`;
235
- return await Nt(u, o, {
236
- name: s,
237
- template: l,
238
- filterValues: a,
239
- operation: "create"
240
- });
241
- }
242
- async function xt(t, s, n) {
243
- if (!n)
244
- return null;
245
- const { id: a, template: o, filterValues: l, isDefault: u, shared: d } = s, p = `${t}/v1/lens`;
246
- return await Nt(p, n, {
247
- lensId: a,
248
- template: o,
249
- filterValues: l,
250
- isDefault: u,
251
- shared: d,
252
- operation: "update"
253
- });
254
- }
255
- async function Un(t, s, n) {
256
- if (!n)
257
- return null;
258
- const a = `${t}/v1/lens`;
259
- return await Nt(a, n, {
260
- operation: "delete",
261
- lensId: s
262
- });
263
- }
264
- const Fn = "text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground";
265
- function Rn({
266
- open: t,
267
- onOpenChange: s
268
- } = {}) {
269
- const [n, a] = N(""), [o, l] = N(!1), u = D((E) => E.lenses), { setLenses: d, setSelectedLensId: p } = wt(), [v, m] = N(!1), [f, h] = N(!1), r = t !== void 0, g = r ? t : f, y = (E) => {
270
- r || h(E), s == null || s(E);
271
- }, w = D((E) => E.dashboard), x = D((E) => E.filterValues), { authToken: C, tokenProps: T } = j();
272
- async function A() {
273
- m(!0);
274
- const E = await _n(
275
- T.apiServiceUrl,
276
- n,
277
- w,
278
- x,
279
- C == null ? void 0 : C.accessToken
280
- );
281
- E && (d([...u || [], E]), p(E.id), y(!1)), m(!1);
282
- }
283
- return /* @__PURE__ */ c(Fe, { open: g, onOpenChange: y, children: [
284
- r ? null : /* @__PURE__ */ e(cs, { asChild: !0, children: /* @__PURE__ */ c(L, { variant: "secondary", size: "xs", children: [
285
- /* @__PURE__ */ e(dt, { className: "h-3.5 w-3.5" }),
286
- "Lens"
287
- ] }) }),
288
- /* @__PURE__ */ c(Re, { className: "rounded-[6px] border-border/60 sm:max-w-[420px] sm:rounded-[6px]", children: [
289
- /* @__PURE__ */ c(Ge, { children: [
290
- /* @__PURE__ */ e($e, { className: "text-[15px]", children: "Create lens" }),
291
- /* @__PURE__ */ e(St, { 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(ut, { htmlFor: "lens-name", className: Fn, children: "Name" }),
295
- /* @__PURE__ */ e(
296
- de,
297
- {
298
- id: "lens-name",
299
- size: "xs",
300
- value: n,
301
- placeholder: "Monthly review, West region, …",
302
- onChange: (E) => a(E.target.value)
303
- }
304
- ),
305
- o && /* @__PURE__ */ e("p", { className: "text-[12px] text-destructive", children: "A lens with this name already exists. Pick a different one." })
306
- ] }),
307
- /* @__PURE__ */ c(ds, { children: [
308
- /* @__PURE__ */ e(L, { variant: "outline", size: "xs", onClick: () => y(!1), children: "Cancel" }),
309
- /* @__PURE__ */ e(
310
- L,
311
- {
312
- size: "xs",
313
- type: "submit",
314
- onClick: A,
315
- disabled: v || !n.trim(),
316
- children: v ? "Creating…" : "Create"
317
- }
318
- )
319
- ] })
320
- ] })
321
- ] });
322
- }
323
- function Gn({ includeLabel: t = !1 } = {}) {
324
- const s = D((m) => m.lenses), n = D((m) => m.selectedLensId), { setLenses: a, setSelectedLensId: o } = wt(), { authToken: l, tokenProps: u } = j();
325
- async function d(m) {
326
- o(m);
327
- }
328
- async function p(m) {
329
- if (await Un(u.apiServiceUrl, m, l == null ? void 0 : l.accessToken)) {
330
- const h = s == null ? void 0 : s.filter((r) => r.id !== m);
331
- a(h || []), o("original");
332
- }
333
- }
334
- async function v(m) {
335
- const f = s == null ? void 0 : s.map((g) => g.id === m.id ? {
336
- ...g,
337
- isDefault: !m.isDefault
338
- } : {
339
- ...g,
340
- isDefault: !1
341
- });
342
- a(f || []);
343
- const h = {
344
- ...m,
345
- isDefault: !m.isDefault
346
- };
347
- await xt(u.apiServiceUrl, h, l == null ? void 0 : l.accessToken);
348
- const r = s == null ? void 0 : s.find((g) => g.isDefault);
349
- if (r && r.id !== m.id) {
350
- const g = {
351
- ...r,
352
- isDefault: !1
353
- };
354
- await xt(u.apiServiceUrl, g, l == null ? void 0 : l.accessToken);
355
- }
356
- }
357
- return /* @__PURE__ */ c(k, { children: [
358
- t ? /* @__PURE__ */ c(k, { children: [
359
- /* @__PURE__ */ e(ce, { className: "px-3", children: "Lenses" }),
360
- /* @__PURE__ */ e(Pe, {})
361
- ] }) : null,
362
- /* @__PURE__ */ c(
363
- us,
364
- {
365
- value: n,
366
- onValueChange: d,
367
- children: [
368
- /* @__PURE__ */ e(ta, { value: "original", children: "Original" }),
369
- s == null ? void 0 : s.map((m) => /* @__PURE__ */ c(
370
- ta,
371
- {
372
- className: "group flex justify-between gap-2",
373
- value: m.id,
374
- children: [
375
- /* @__PURE__ */ e("p", { children: m.name }),
376
- /* @__PURE__ */ c("span", { className: "flex items-center gap-3", children: [
377
- /* @__PURE__ */ e(
378
- da,
379
- {
380
- onClick: (f) => {
381
- f.preventDefault(), v(m);
382
- },
383
- className: Y(
384
- "size-3.5 text-muted-foreground hover:cursor-pointer hover:text-foreground group-hover:visible",
385
- {
386
- invisible: !m.isDefault,
387
- "text-green-500": m.isDefault
388
- }
389
- ),
390
- strokeWidth: 1.5
391
- }
392
- ),
393
- /* @__PURE__ */ e(
394
- ua,
395
- {
396
- onClick: (f) => {
397
- f.preventDefault(), p(m.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
- m.id
407
- ))
408
- ]
409
- }
410
- )
411
- ] });
412
- }
413
- function $n() {
414
- const { displayPreferences: t, shouldShowElement: s } = ms(), { currentUser: n, userContext: a } = Dt(), o = F(
415
- () => hs(n),
416
- [n]
417
- ), l = F(() => (d) => o && o[d] !== void 0 && o[d] === !1 ? !1 : s(d), [o, s, t]), u = F(
418
- () => {
419
- var d, p, v, m, f;
420
- return {
421
- canEdit: ((d = a == null ? void 0 : a.permissions) == null ? void 0 : d.canEdit) ?? bs(n),
422
- canUseFilters: ((p = a == null ? void 0 : a.permissions) == null ? void 0 : p.canEdit) ?? vs(n),
423
- canManageDashboards: ((v = a == null ? void 0 : a.permissions) == null ? void 0 : v.canCreateDashboard) ?? gs(n),
424
- canCreateDashboards: ((m = a == null ? void 0 : a.permissions) == null ? void 0 : m.canCreateDashboard) ?? fs(n),
425
- canAccessVisuals: ((f = a == null ? void 0 : a.permissions) == null ? void 0 : f.canEdit) ?? ps(n)
426
- };
427
- },
428
- [n, a]
429
- );
430
- return {
431
- displayPreferences: t,
432
- shouldShowElement: l,
433
- permissions: u,
434
- currentUser: n
435
- };
436
- }
437
- const Vn = async (t, s, n) => {
438
- const a = `${t}/management/v1/groups`;
439
- return await ha(a, s, n);
440
- }, zn = async (t, s, n) => {
441
- const a = `${t}/management/v1/groups/${n}`;
442
- await ma(a, s, "DELETE");
443
- }, qn = async (t, s, n, a) => {
444
- const o = `${t}/management/v1/groups/${n}/members`;
445
- return await ha(o, s, a);
446
- }, Hn = async (t, s, n, a) => {
447
- const o = `${t}/management/v1/groups/${n}/members`;
448
- await ma(o, s, "DELETE", a);
449
- };
450
- function Bn() {
451
- const { authToken: t, tokenProps: s } = j(), n = Ve();
452
- return ze({
453
- mutationFn: (a) => Vn(s.apiServiceUrl, (t == null ? void 0 : t.accessToken) || "", a),
454
- onSuccess: () => {
455
- n.invalidateQueries({ queryKey: ["groups"] }), I.success("Group created successfully");
456
- },
457
- onError: (a) => {
458
- console.error("Failed to create group:", a), I.error("Failed to create group", {
459
- description: qe(a, "Failed to create group")
460
- });
461
- }
462
- });
463
- }
464
- function jn() {
465
- const { authToken: t, tokenProps: s } = j(), n = Ve();
466
- return ze({
467
- mutationFn: (a) => zn(s.apiServiceUrl, (t == null ? void 0 : t.accessToken) || "", a),
468
- onSuccess: (a, o) => {
469
- n.invalidateQueries({ queryKey: ["groups"] }), n.removeQueries({ queryKey: ["group", o] }), I.success("Group deleted successfully");
470
- },
471
- onError: (a) => {
472
- console.error("Failed to delete group:", a), I.error("Failed to delete group", {
473
- description: qe(a, "Failed to delete group")
474
- });
475
- }
476
- });
477
- }
478
- function Kn() {
479
- const { authToken: t, tokenProps: s } = j(), n = Ve();
480
- return ze({
481
- mutationFn: ({
482
- groupId: a,
483
- data: o
484
- }) => qn(s.apiServiceUrl, (t == null ? void 0 : t.accessToken) || "", a, o),
485
- onSuccess: (a, o) => {
486
- n.invalidateQueries({ queryKey: ["group", o.groupId] }), n.invalidateQueries({
487
- queryKey: ["group-members", o.groupId]
488
- }), n.invalidateQueries({ queryKey: ["groups"] }), I.success("Members added successfully");
489
- },
490
- onError: (a) => {
491
- console.error("Failed to add group members:", a), I.error("Failed to add members", {
492
- description: qe(a, "Failed to add members")
493
- });
494
- }
495
- });
496
- }
497
- function Qn() {
498
- const { authToken: t, tokenProps: s } = j(), n = Ve();
499
- return ze({
500
- mutationFn: ({
501
- groupId: a,
502
- data: o
503
- }) => Hn(s.apiServiceUrl, (t == null ? void 0 : t.accessToken) || "", a, o),
504
- onSuccess: (a, o) => {
505
- n.invalidateQueries({ queryKey: ["group", o.groupId] }), n.invalidateQueries({
506
- queryKey: ["group-members", o.groupId]
507
- }), n.invalidateQueries({ queryKey: ["groups"] }), I.success("Members removed successfully");
508
- },
509
- onError: (a) => {
510
- console.error("Failed to remove group members:", a), I.error("Failed to remove members", {
511
- description: qe(a, "Failed to remove members")
512
- });
513
- }
514
- });
515
- }
516
- const ia = "text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground";
517
- function Wn({
518
- onSuccess: t,
519
- tenantId: s,
520
- isTenantUser: n
521
- }) {
522
- const [a, o] = N(""), [l, u] = N(""), [d, p] = N({}), v = Bn(), m = () => {
523
- const h = {};
524
- return a.trim() ? a.length < 3 ? h.name = "Group name must be at least 3 characters" : a.length > 50 && (h.name = "Group name must be less than 50 characters") : h.name = "Group name is required", l && l.length > 200 && (h.description = "Description must be less than 200 characters"), p(h), Object.keys(h).length === 0;
525
- };
526
- return /* @__PURE__ */ c("form", { onSubmit: async (h) => {
527
- if (h.preventDefault(), !m()) return;
528
- const r = {
529
- name: a.trim(),
530
- description: l.trim() || void 0,
531
- type: n ? "TENANT_GROUP" : "ORG_GROUP",
532
- ...n && s ? { tenantId: s } : {}
533
- };
534
- try {
535
- await v.mutateAsync(r), o(""), u(""), p({}), t();
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(ut, { htmlFor: "group-name", className: ia, children: [
542
- "Group name ",
543
- /* @__PURE__ */ e("span", { className: "text-destructive", children: "*" })
544
- ] }),
545
- /* @__PURE__ */ e(
546
- de,
547
- {
548
- id: "group-name",
549
- size: "xs",
550
- placeholder: "e.g., Marketing Team, Engineering Squad",
551
- value: a,
552
- onChange: (h) => {
553
- o(h.target.value), d.name && p((r) => ({ ...r, name: "" }));
554
- },
555
- className: d.name ? "border-destructive" : "",
556
- disabled: v.isPending
557
- }
558
- ),
559
- d.name && /* @__PURE__ */ e("p", { className: "text-[12px] text-destructive", children: d.name })
560
- ] }),
561
- /* @__PURE__ */ c("div", { className: "space-y-1.5", children: [
562
- /* @__PURE__ */ e(ut, { htmlFor: "group-description", className: ia, children: "Description (optional)" }),
563
- /* @__PURE__ */ e(
564
- ys,
565
- {
566
- id: "group-description",
567
- placeholder: "Describe the purpose of this group…",
568
- value: l,
569
- onChange: (h) => {
570
- u(h.target.value), d.description && p((r) => ({ ...r, description: "" }));
571
- },
572
- className: `text-[13px] ${d.description ? "border-destructive" : ""}`,
573
- disabled: v.isPending,
574
- rows: 3
575
- }
576
- ),
577
- d.description ? /* @__PURE__ */ e("p", { className: "text-[12px] text-destructive", children: d.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(xs, { 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
- L,
589
- {
590
- type: "button",
591
- variant: "outline",
592
- size: "xs",
593
- onClick: () => {
594
- o(""), u(""), p({});
595
- },
596
- disabled: v.isPending,
597
- children: "Clear"
598
- }
599
- ),
600
- /* @__PURE__ */ e(
601
- L,
602
- {
603
- type: "submit",
604
- size: "xs",
605
- disabled: v.isPending || !a.trim(),
606
- children: v.isPending ? /* @__PURE__ */ c(k, { 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 Jn(t, s = []) {
616
- let n = [];
617
- function a(l, u) {
618
- const d = M.createContext(u);
619
- d.displayName = l + "Context";
620
- const p = n.length;
621
- n = [...n, u];
622
- const v = (f) => {
623
- var x;
624
- const { scope: h, children: r, ...g } = f, y = ((x = h == null ? void 0 : h[t]) == null ? void 0 : x[p]) || d, w = M.useMemo(() => g, Object.values(g));
625
- return /* @__PURE__ */ e(y.Provider, { value: w, children: r });
626
- };
627
- v.displayName = l + "Provider";
628
- function m(f, h) {
629
- var y;
630
- const r = ((y = h == null ? void 0 : h[t]) == null ? void 0 : y[p]) || d, g = M.useContext(r);
631
- if (g) return g;
632
- if (u !== void 0) return u;
633
- throw new Error(`\`${f}\` must be used within \`${l}\``);
634
- }
635
- return [v, m];
636
- }
637
- const o = () => {
638
- const l = n.map((u) => M.createContext(u));
639
- return function(d) {
640
- const p = (d == null ? void 0 : d[t]) || l;
641
- return M.useMemo(
642
- () => ({ [`__scope${t}`]: { ...d, [t]: p } }),
643
- [d, p]
644
- );
645
- };
646
- };
647
- return o.scopeName = t, [a, Yn(o, ...s)];
648
- }
649
- function Yn(...t) {
650
- const s = t[0];
651
- if (t.length === 1) return s;
652
- const n = () => {
653
- const a = t.map((o) => ({
654
- useScope: o(),
655
- scopeName: o.scopeName
656
- }));
657
- return function(l) {
658
- const u = a.reduce((d, { useScope: p, scopeName: v }) => {
659
- const f = p(l)[`__scope${v}`];
660
- return { ...d, ...f };
661
- }, {});
662
- return M.useMemo(() => ({ [`__scope${s.scopeName}`]: u }), [u]);
663
- };
664
- };
665
- return n.scopeName = s.scopeName, n;
666
- }
667
- var Xn = [
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
- ], Et = Xn.reduce((t, s) => {
686
- const n = Ns(`Primitive.${s}`), a = M.forwardRef((o, l) => {
687
- const { asChild: u, ...d } = o, p = u ? n : s;
688
- return typeof window < "u" && (window[Symbol.for("radix-ui")] = !0), /* @__PURE__ */ e(p, { ...d, ref: l });
689
- });
690
- return a.displayName = `Primitive.${s}`, { ...t, [s]: a };
691
- }, {});
692
- function Zn() {
693
- return Pn.useSyncExternalStore(
694
- er,
695
- () => !0,
696
- () => !1
697
- );
698
- }
699
- function er() {
700
- return () => {
701
- };
702
- }
703
- var It = "Avatar", [tr] = Jn(It), [ar, Ia] = tr(It), La = M.forwardRef(
704
- (t, s) => {
705
- const { __scopeAvatar: n, ...a } = t, [o, l] = M.useState("idle");
706
- return /* @__PURE__ */ e(
707
- ar,
708
- {
709
- scope: n,
710
- imageLoadingStatus: o,
711
- onImageLoadingStatusChange: l,
712
- children: /* @__PURE__ */ e(Et.span, { ...a, ref: s })
713
- }
714
- );
715
- }
716
- );
717
- La.displayName = It;
718
- var Ma = "AvatarImage", Aa = M.forwardRef(
719
- (t, s) => {
720
- const { __scopeAvatar: n, src: a, onLoadingStatusChange: o = () => {
721
- }, ...l } = t, u = Ia(Ma, n), d = sr(a, l), p = ws((v) => {
722
- o(v), u.onImageLoadingStatusChange(v);
723
- });
724
- return mt(() => {
725
- d !== "idle" && p(d);
726
- }, [d, p]), d === "loaded" ? /* @__PURE__ */ e(Et.img, { ...l, ref: s, src: a }) : null;
727
- }
728
- );
729
- Aa.displayName = Ma;
730
- var Oa = "AvatarFallback", ka = M.forwardRef(
731
- (t, s) => {
732
- const { __scopeAvatar: n, delayMs: a, ...o } = t, l = Ia(Oa, n), [u, d] = M.useState(a === void 0);
733
- return M.useEffect(() => {
734
- if (a !== void 0) {
735
- const p = window.setTimeout(() => d(!0), a);
736
- return () => window.clearTimeout(p);
737
- }
738
- }, [a]), u && l.imageLoadingStatus !== "loaded" ? /* @__PURE__ */ e(Et.span, { ...o, ref: s }) : null;
739
- }
740
- );
741
- ka.displayName = Oa;
742
- function la(t, s) {
743
- return t ? s ? (t.src !== s && (t.src = s), t.complete && t.naturalWidth > 0 ? "loaded" : "loading") : "error" : "idle";
744
- }
745
- function sr(t, { referrerPolicy: s, crossOrigin: n }) {
746
- const a = Zn(), o = M.useRef(null), l = a ? (o.current || (o.current = new window.Image()), o.current) : null, [u, d] = M.useState(
747
- () => la(l, t)
748
- );
749
- return mt(() => {
750
- d(la(l, t));
751
- }, [l, t]), mt(() => {
752
- const p = (f) => () => {
753
- d(f);
754
- };
755
- if (!l) return;
756
- const v = p("loaded"), m = p("error");
757
- return l.addEventListener("load", v), l.addEventListener("error", m), s && (l.referrerPolicy = s), typeof n == "string" && (l.crossOrigin = n), () => {
758
- l.removeEventListener("load", v), l.removeEventListener("error", m);
759
- };
760
- }, [l, n, s]), u;
761
- }
762
- var Pa = La, Ta = Aa, _a = ka;
763
- const Lt = M.forwardRef(({ className: t, ...s }, n) => /* @__PURE__ */ e(
764
- Pa,
765
- {
766
- ref: n,
767
- className: Y(
768
- "relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full",
769
- t
770
- ),
771
- ...s
772
- }
773
- ));
774
- Lt.displayName = Pa.displayName;
775
- const nr = M.forwardRef(({ className: t, ...s }, n) => /* @__PURE__ */ e(
776
- Ta,
777
- {
778
- ref: n,
779
- className: Y("aspect-square h-full w-full", t),
780
- ...s
781
- }
782
- ));
783
- nr.displayName = Ta.displayName;
784
- const Mt = M.forwardRef(({ className: t, ...s }, n) => /* @__PURE__ */ e(
785
- _a,
786
- {
787
- ref: n,
788
- className: Y(
789
- "flex h-full w-full items-center justify-center rounded-full bg-muted",
790
- t
791
- ),
792
- ...s
793
- }
794
- ));
795
- Mt.displayName = _a.displayName;
796
- function rr({
797
- open: t,
798
- onOpenChange: s,
799
- group: n,
800
- onUpdate: a
801
- }) {
802
- const [o, l] = N("members"), [u, d] = N(""), [p, v] = N([]), [m, f] = N([]), { data: h, isLoading: r, refetch: g } = Ss(n.id), y = n.type === "TENANT_GROUP" ? "tenant" : "organization", { users: w, isLoading: x } = Ds({
803
- type: y,
804
- tenantId: n.tenantId || void 0,
805
- active: !0,
806
- limit: 100
807
- }), C = Kn(), T = Qn(), A = (h == null ? void 0 : h.members) || [], E = F(() => new Set(A.map((b) => b.userId)), [A]), H = F(() => w.filter((b) => !E.has(b.id)), [w, E]), $ = F(() => {
808
- if (!u) return H;
809
- const b = u.toLowerCase();
810
- return H.filter(
811
- (P) => {
812
- var R, Q;
813
- return ((R = P.name) == null ? void 0 : R.toLowerCase().includes(b)) || ((Q = P.email) == null ? void 0 : Q.toLowerCase().includes(b));
814
- }
815
- );
816
- }, [H, u]), S = F(() => {
817
- if (!u) return A;
818
- const b = u.toLowerCase();
819
- return A.filter(
820
- (P) => {
821
- var R, Q, ee, ue;
822
- return ((Q = (R = P.user) == null ? void 0 : R.name) == null ? void 0 : Q.toLowerCase().includes(b)) || ((ue = (ee = P.user) == null ? void 0 : ee.email) == null ? void 0 : ue.toLowerCase().includes(b));
823
- }
824
- );
825
- }, [A, u]), z = async () => {
826
- if (p.length !== 0)
827
- try {
828
- await C.mutateAsync({
829
- groupId: n.id,
830
- data: {
831
- userIds: p,
832
- userType: y === "tenant" ? "tenant" : "org"
833
- }
834
- }), v([]), l("members"), g(), a == null || a();
835
- } catch (b) {
836
- console.error("Failed to add members:", b);
837
- }
838
- }, K = async () => {
839
- if (m.length !== 0)
840
- try {
841
- await T.mutateAsync({
842
- groupId: n.id,
843
- data: {
844
- userIds: m
845
- }
846
- }), f([]), g(), a == null || a();
847
- } catch (b) {
848
- console.error("Failed to remove members:", b);
849
- }
850
- }, B = (b) => {
851
- v(
852
- (P) => P.includes(b) ? P.filter((R) => R !== b) : [...P, b]
853
- );
854
- }, He = (b) => {
855
- f(
856
- (P) => P.includes(b) ? P.filter((R) => R !== b) : [...P, b]
857
- );
858
- };
859
- return /* @__PURE__ */ e(k, { children: /* @__PURE__ */ e(Fe, { open: t, onOpenChange: s, children: /* @__PURE__ */ c(Re, { className: "max-w-3xl max-h-[80vh]", "aria-describedby": "group-members-description", children: [
860
- /* @__PURE__ */ c(Ge, { children: [
861
- /* @__PURE__ */ e($e, { children: n.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
- A.length,
864
- " ",
865
- A.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
- n.name,
870
- " group"
871
- ] })
872
- ] }),
873
- /* @__PURE__ */ c(pa, { value: o, onValueChange: (b) => {
874
- l(b), d(""), f([]);
875
- }, className: "mt-4", children: [
876
- /* @__PURE__ */ c(fa, { className: "grid w-full grid-cols-2", children: [
877
- /* @__PURE__ */ e(Te, { value: "members", children: "Current Members" }),
878
- /* @__PURE__ */ e(Te, { value: "add", children: "Add Members" })
879
- ] }),
880
- /* @__PURE__ */ c(_e, { value: "members", className: "mt-4 space-y-4", children: [
881
- /* @__PURE__ */ c("div", { className: "relative", children: [
882
- /* @__PURE__ */ e(ht, { className: "absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground" }),
883
- /* @__PURE__ */ e(
884
- de,
885
- {
886
- placeholder: "Search members...",
887
- value: u,
888
- onChange: (b) => d(b.target.value),
889
- className: "pl-10"
890
- }
891
- )
892
- ] }),
893
- /* @__PURE__ */ e(pt, { className: m.length > 0 ? "h-[300px]" : "h-[350px]", children: r ? /* @__PURE__ */ e("div", { className: "space-y-2", children: [1, 2, 3].map((b) => /* @__PURE__ */ e(ft, { className: "h-16 w-full" }, b)) }) : S.length === 0 ? /* @__PURE__ */ c("div", { className: "flex flex-col items-center justify-center py-12 text-muted-foreground", children: [
894
- /* @__PURE__ */ e(Ct, { className: "h-12 w-12 mb-3 opacity-50" }),
895
- /* @__PURE__ */ e("p", { className: "text-sm font-medium", children: u ? "No members found" : "No members yet" }),
896
- /* @__PURE__ */ e("p", { className: "text-xs mt-1", children: u ? "Try a different search" : 'Switch to the "Add Members" tab to add people to this group' })
897
- ] }) : /* @__PURE__ */ e("div", { className: "space-y-2", children: S.map((b) => /* @__PURE__ */ e(
898
- or,
899
- {
900
- member: b,
901
- selected: m.includes(b.userId),
902
- onToggle: () => He(b.userId)
903
- },
904
- b.id
905
- )) }) }),
906
- m.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
- m.length,
909
- " member",
910
- m.length !== 1 ? "s" : "",
911
- " selected"
912
- ] }),
913
- /* @__PURE__ */ e(
914
- L,
915
- {
916
- variant: "destructive",
917
- size: "sm",
918
- onClick: K,
919
- disabled: T.isPending,
920
- children: T.isPending ? /* @__PURE__ */ c(k, { children: [
921
- /* @__PURE__ */ e(X, { className: "mr-2 h-4 w-4 animate-spin" }),
922
- "Removing..."
923
- ] }) : /* @__PURE__ */ c(k, { children: [
924
- /* @__PURE__ */ e(ga, { className: "mr-2 h-4 w-4" }),
925
- "Remove Selected"
926
- ] })
927
- }
928
- )
929
- ] })
930
- ] }),
931
- /* @__PURE__ */ c(_e, { value: "add", className: "mt-4 space-y-4", children: [
932
- /* @__PURE__ */ c("div", { className: "relative", children: [
933
- /* @__PURE__ */ e(ht, { className: "absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground" }),
934
- /* @__PURE__ */ e(
935
- de,
936
- {
937
- placeholder: "Search users to add...",
938
- value: u,
939
- onChange: (b) => d(b.target.value),
940
- className: "pl-10"
941
- }
942
- )
943
- ] }),
944
- /* @__PURE__ */ e(pt, { className: "h-[300px]", children: x ? /* @__PURE__ */ e("div", { className: "space-y-2", children: [1, 2, 3].map((b) => /* @__PURE__ */ e(ft, { className: "h-16 w-full" }, b)) }) : $.length === 0 ? /* @__PURE__ */ c("div", { className: "flex flex-col items-center justify-center py-12 text-muted-foreground", children: [
945
- /* @__PURE__ */ e(gt, { 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: u ? "Try a different search" : "All eligible users are already members" })
948
- ] }) : /* @__PURE__ */ e("div", { className: "space-y-2", children: $.map((b) => /* @__PURE__ */ e(
949
- ir,
950
- {
951
- user: b,
952
- selected: p.includes(b.id),
953
- onToggle: () => B(b.id)
954
- },
955
- b.id
956
- )) }) }),
957
- p.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
- p.length,
960
- " user",
961
- p.length !== 1 ? "s" : "",
962
- " selected"
963
- ] }),
964
- /* @__PURE__ */ e(
965
- L,
966
- {
967
- onClick: z,
968
- disabled: C.isPending,
969
- children: C.isPending ? /* @__PURE__ */ c(k, { children: [
970
- /* @__PURE__ */ e(X, { className: "mr-2 h-4 w-4 animate-spin" }),
971
- "Adding..."
972
- ] }) : /* @__PURE__ */ c(k, { children: [
973
- /* @__PURE__ */ e(gt, { className: "mr-2 h-4 w-4" }),
974
- "Add Members"
975
- ] })
976
- }
977
- )
978
- ] })
979
- ] })
980
- ] })
981
- ] }) }) });
982
- }
983
- function or({
984
- member: t,
985
- selected: s,
986
- onToggle: n
987
- }) {
988
- var o, l, u, d;
989
- const a = ((l = (o = t.user) == null ? void 0 : o.name) == null ? void 0 : l.split(" ").map((p) => p[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: n,
995
- children: [
996
- /* @__PURE__ */ e(va, { checked: s }),
997
- /* @__PURE__ */ e(Lt, { className: "h-8 w-8", children: /* @__PURE__ */ e(Mt, { className: "text-xs", children: a }) }),
998
- /* @__PURE__ */ c("div", { className: "flex-1", children: [
999
- /* @__PURE__ */ e("p", { className: "text-sm font-medium", children: ((u = t.user) == null ? void 0 : u.name) || "Unknown User" }),
1000
- /* @__PURE__ */ e("p", { className: "text-xs text-muted-foreground", children: (d = t.user) == null ? void 0 : d.email })
1001
- ] })
1002
- ]
1003
- }
1004
- );
1005
- }
1006
- function ir({
1007
- user: t,
1008
- selected: s,
1009
- onToggle: n
1010
- }) {
1011
- var o;
1012
- const a = ((o = t.name) == null ? void 0 : o.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: n,
1018
- children: [
1019
- /* @__PURE__ */ e(va, { checked: s }),
1020
- /* @__PURE__ */ e(Lt, { className: "h-8 w-8", children: /* @__PURE__ */ e(Mt, { className: "text-xs", children: a }) }),
1021
- /* @__PURE__ */ c("div", { className: "flex-1", children: [
1022
- /* @__PURE__ */ e("p", { className: "text-sm font-medium", children: t.name }),
1023
- /* @__PURE__ */ e("p", { className: "text-xs text-muted-foreground", children: t.email })
1024
- ] })
1025
- ]
1026
- }
1027
- );
1028
- }
1029
- function lr({
1030
- open: t,
1031
- onOpenChange: s
1032
- }) {
1033
- const [n, a] = N("groups"), [o, l] = N(""), [u, d] = N(null), [p, v] = N(!1), [m, f] = N(null), { tokenProps: h } = j(), { currentUser: r } = Dt(), g = jn(), y = (r == null ? void 0 : r.type) === "tenant", w = h == null ? void 0 : h.tenantId, { groups: x, isLoading: C, refetch: T } = Cs({
1034
- type: y ? "TENANT_GROUP" : "all",
1035
- tenantId: y ? w : void 0,
1036
- includeMembers: !1
1037
- }), A = x.filter(
1038
- (S) => {
1039
- var z;
1040
- return S.name.toLowerCase().includes(o.toLowerCase()) || ((z = S.description) == null ? void 0 : z.toLowerCase().includes(o.toLowerCase()));
1041
- }
1042
- ), E = async () => {
1043
- if (m)
1044
- try {
1045
- await g.mutateAsync(m.id), f(null), T();
1046
- } catch (S) {
1047
- console.error("Failed to delete group:", S);
1048
- }
1049
- }, H = (S) => {
1050
- d(S), v(!0);
1051
- }, $ = () => {
1052
- a("groups"), T();
1053
- };
1054
- return /* @__PURE__ */ c(k, { children: [
1055
- /* @__PURE__ */ e(Fe, { open: t, onOpenChange: s, children: /* @__PURE__ */ c(Re, { className: "max-h-[80vh] max-w-3xl rounded-[6px] border-border/60 sm:rounded-[6px]", children: [
1056
- /* @__PURE__ */ c(Ge, { children: [
1057
- /* @__PURE__ */ e($e, { className: "text-[15px]", children: "Group management" }),
1058
- /* @__PURE__ */ e(St, { className: "text-[13px] leading-5", children: "Manage groups, create new ones, and control membership." })
1059
- ] }),
1060
- /* @__PURE__ */ c(
1061
- pa,
1062
- {
1063
- value: n,
1064
- onValueChange: a,
1065
- className: "mt-2",
1066
- children: [
1067
- /* @__PURE__ */ c(fa, { 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
- Te,
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
- Te,
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(_e, { value: "groups", className: "mt-4", children: /* @__PURE__ */ c("div", { className: "space-y-3", children: [
1086
- /* @__PURE__ */ c("div", { className: "relative", children: [
1087
- /* @__PURE__ */ e(ht, { className: "absolute left-2 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground" }),
1088
- /* @__PURE__ */ e(
1089
- de,
1090
- {
1091
- size: "xs",
1092
- placeholder: "Search groups…",
1093
- value: o,
1094
- onChange: (S) => l(S.target.value),
1095
- className: "pl-7"
1096
- }
1097
- )
1098
- ] }),
1099
- /* @__PURE__ */ e(pt, { className: "h-[400px]", children: C ? /* @__PURE__ */ e("div", { className: "space-y-2", children: [1, 2, 3].map((S) => /* @__PURE__ */ e(
1100
- ft,
1101
- {
1102
- className: "h-16 w-full rounded-[6px]"
1103
- },
1104
- S
1105
- )) }) : A.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: o ? "Try a different search." : "Create your first group to get started." })
1108
- ] }) : /* @__PURE__ */ e("div", { className: "space-y-2 pr-2", children: A.map((S) => /* @__PURE__ */ e(
1109
- cr,
1110
- {
1111
- group: S,
1112
- onManageMembers: () => H(S),
1113
- onDelete: () => f(S),
1114
- currentUserId: r == null ? void 0 : r.id
1115
- },
1116
- S.id
1117
- )) }) })
1118
- ] }) }),
1119
- /* @__PURE__ */ e(_e, { value: "create", className: "mt-4", children: /* @__PURE__ */ e(
1120
- Wn,
1121
- {
1122
- onSuccess: $,
1123
- tenantId: w,
1124
- isTenantUser: y
1125
- }
1126
- ) })
1127
- ]
1128
- }
1129
- )
1130
- ] }) }),
1131
- u && /* @__PURE__ */ e(
1132
- rr,
1133
- {
1134
- open: p,
1135
- onOpenChange: v,
1136
- group: u,
1137
- onUpdate: () => T()
1138
- }
1139
- ),
1140
- /* @__PURE__ */ e(
1141
- ba,
1142
- {
1143
- open: !!m,
1144
- onOpenChange: () => f(null),
1145
- children: /* @__PURE__ */ c(ya, { children: [
1146
- /* @__PURE__ */ c(xa, { children: [
1147
- /* @__PURE__ */ e(Na, { children: "Delete group" }),
1148
- /* @__PURE__ */ c(wa, { children: [
1149
- 'Delete "',
1150
- m == null ? void 0 : m.name,
1151
- `"? This removes all members and can't be undone.`
1152
- ] })
1153
- ] }),
1154
- /* @__PURE__ */ c(Sa, { children: [
1155
- /* @__PURE__ */ e(Da, { children: "Cancel" }),
1156
- /* @__PURE__ */ e(
1157
- vt,
1158
- {
1159
- onClick: E,
1160
- disabled: g.isPending,
1161
- className: "bg-destructive text-destructive-foreground hover:bg-destructive/90",
1162
- children: g.isPending ? /* @__PURE__ */ c(k, { 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 cr({
1175
- group: t,
1176
- onManageMembers: s,
1177
- onDelete: n,
1178
- currentUserId: a
1179
- }) {
1180
- const o = t.createdBy === a;
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: t.name }),
1184
- t.description && /* @__PURE__ */ e("p", { className: "text-[12px] text-muted-foreground", children: t.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(Ct, { className: "h-3 w-3" }),
1188
- t.memberCount,
1189
- " ",
1190
- t.memberCount === 1 ? "member" : "members"
1191
- ] }),
1192
- /* @__PURE__ */ c("span", { children: [
1193
- "Created ",
1194
- bn(new Date(t.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
- L,
1201
- {
1202
- variant: "ghost",
1203
- size: "xs",
1204
- className: "h-7 w-7 p-0 text-muted-foreground hover:text-foreground",
1205
- onClick: s,
1206
- title: "Manage members",
1207
- "aria-label": "Manage members",
1208
- children: /* @__PURE__ */ e(gt, { className: "h-3.5 w-3.5" })
1209
- }
1210
- ),
1211
- o && /* @__PURE__ */ e(
1212
- L,
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: n,
1218
- title: "Delete group",
1219
- "aria-label": "Delete group",
1220
- children: /* @__PURE__ */ e(ga, { className: "h-3.5 w-3.5" })
1221
- }
1222
- )
1223
- ] })
1224
- ] }) });
1225
- }
1226
- function ie(t, s, n) {
1227
- var l, u;
1228
- const a = (t.controls || []).find(
1229
- (d) => d.id === n
1230
- );
1231
- if (a)
1232
- return a.label;
1233
- const o = (u = (l = Ca(t, s)) == null ? void 0 : l.controls) == null ? void 0 : u.find(
1234
- (d) => d.id === n
1235
- );
1236
- return (o == null ? void 0 : o.label) || n;
1237
- }
1238
- function le(t, s) {
1239
- var n;
1240
- return ((n = Ca(t, s)) == null ? void 0 : n.title) || s;
1241
- }
1242
- function dr(t) {
1243
- const { errors: s, dashboard: n } = t;
1244
- if (!n)
1245
- return s;
1246
- const a = /* @__PURE__ */ new Map();
1247
- for (const o of s) {
1248
- const l = o.match(
1249
- /^Card '(.+)' binding for control '(.+)' maps to missing metric '(.+)'\.$/
1250
- );
1251
- if (l) {
1252
- const [, m, f] = l, h = `${m}:${f}:missing-metric`;
1253
- a.has(h) || a.set(
1254
- h,
1255
- `"${le(n, m)}" has an outdated "${ie(
1256
- n,
1257
- m,
1258
- f
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 u = o.match(
1264
- /^Card '(.+)' binding for control '(.+)' maps to missing group-by field '(.+)'\.$/
1265
- );
1266
- if (u) {
1267
- const [, m, f] = u, h = `${m}:${f}:missing-group-by`;
1268
- a.has(h) || a.set(
1269
- h,
1270
- `"${le(n, m)}" has an outdated "${ie(
1271
- n,
1272
- m,
1273
- f
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 d = o.match(
1279
- /^Card '(.+)' binding for control '(.+)' maps to an invalid metric target\.$/
1280
- );
1281
- if (d) {
1282
- const [, m, f] = d, h = `${m}:${f}:invalid-metric`;
1283
- a.has(h) || a.set(
1284
- h,
1285
- `"${le(n, m)}" has an invalid "${ie(
1286
- n,
1287
- m,
1288
- f
1289
- )}" metric mapping. Open the card controls and choose a valid metric for each option.`
1290
- );
1291
- continue;
1292
- }
1293
- const p = o.match(
1294
- /^Card '(.+)' binding for control '(.+)' maps to an invalid group-by target\.$/
1295
- );
1296
- if (p) {
1297
- const [, m, f] = p, h = `${m}:${f}:invalid-group-by`;
1298
- a.has(h) || a.set(
1299
- h,
1300
- `"${le(n, m)}" has an invalid "${ie(
1301
- n,
1302
- m,
1303
- f
1304
- )}" field mapping. Open the card controls and choose a valid field for each option.`
1305
- );
1306
- continue;
1307
- }
1308
- const v = o.match(
1309
- /^Card '(.+)' binding for control '(.+)' requires at least one temporal group-by field\.$/
1310
- );
1311
- if (v) {
1312
- const [, m, f] = v, h = `${m}:${f}:missing-temporal-group-by`;
1313
- a.has(h) || a.set(
1314
- h,
1315
- `"${le(n, m)}" can no longer use "${ie(
1316
- n,
1317
- m,
1318
- f
1319
- )}" for time grain because the card does not currently group by a date field.`
1320
- );
1321
- continue;
1322
- }
1323
- a.set(o, o);
1324
- }
1325
- return Array.from(a.values());
1326
- }
1327
- const ur = [
1328
- "enum",
1329
- "multi_enum",
1330
- "text",
1331
- "number",
1332
- "boolean",
1333
- "date"
1334
- ];
1335
- function mr({
1336
- open: t,
1337
- onOpenChange: s,
1338
- initialMode: n = "manage"
1339
- }) {
1340
- var $;
1341
- const a = n === "create", {
1342
- forceClose: o,
1343
- handleOpenChange: l,
1344
- isCreateFlowActive: u,
1345
- preventPassiveDismissDuringCreate: d,
1346
- resolvedOpen: p,
1347
- setIsCreateFlowActive: v
1348
- } = wn({
1349
- open: t,
1350
- onOpenChange: s,
1351
- initialCreateFlowActive: n === "create",
1352
- dismissMode: "explicit-only"
1353
- }), m = D((S) => S.dashboard), f = D((S) => S.selectedSheetId), { updateSheetDocument: h } = wt(), r = ($ = m.sheets) == null ? void 0 : $.find(
1354
- (S) => S.id === f
1355
- ), g = (r == null ? void 0 : r.kind) === "document" && !!r.document, y = F(
1356
- () => g && (r != null && r.document) ? r.document.inputs || [] : [],
1357
- [g, r == null ? void 0 : r.document]
1358
- ), w = F(
1359
- () => y.filter(
1360
- (S) => S.kind === "control"
1361
- ),
1362
- [y]
1363
- ), x = F(
1364
- () => w.map((S) => S.control),
1365
- [w]
1366
- ), C = F(
1367
- () => pr(x),
1368
- [x]
1369
- ), T = F(
1370
- () => hr(m),
1371
- [m]
1372
- ), A = Ue(() => {
1373
- if (a) {
1374
- o();
1375
- return;
1376
- }
1377
- v(!1);
1378
- }, [a, o, v]), E = Ue(
1379
- (S, z, K) => {
1380
- !g || !(r != null && r.document) || h(r.id, (B) => ({
1381
- ...B,
1382
- inputs: gr({
1383
- currentInputs: B.inputs || [],
1384
- nextControls: S,
1385
- nextDefaultValues: z,
1386
- change: K
1387
- })
1388
- }));
1389
- },
1390
- [g, r, h]
1391
- );
1392
- return !g || !(r != null && r.document) ? null : /* @__PURE__ */ e(Fe, { open: p, onOpenChange: l, children: /* @__PURE__ */ c(
1393
- Re,
1394
- {
1395
- className: "flex max-h-[88vh] flex-col overflow-hidden sm:max-w-[600px]",
1396
- onEscapeKeyDown: d,
1397
- onPointerDownOutside: d,
1398
- children: [
1399
- /* @__PURE__ */ c(Ge, { className: u ? "space-y-0" : void 0, children: [
1400
- /* @__PURE__ */ e($e, { className: "text-[15px]", children: u ? "Add document control" : "Document Controls" }),
1401
- /* @__PURE__ */ e(
1402
- St,
1403
- {
1404
- className: u ? "sr-only" : "text-[13px]",
1405
- children: u ? "Configure and add a document-local control input." : "Add document-local control inputs. They are stored on this document sheet and are not dashboard controls."
1406
- }
1407
- )
1408
- ] }),
1409
- /* @__PURE__ */ e("div", { className: "min-h-0 overflow-y-auto pr-1", children: /* @__PURE__ */ e(
1410
- Sn,
1411
- {
1412
- scope: "dashboard",
1413
- controls: x,
1414
- reservedControlIds: T,
1415
- defaultValues: C,
1416
- usageByControlId: {},
1417
- availableFieldChoices: [],
1418
- availableMetricChoices: [],
1419
- structuralParticipants: [],
1420
- structuralParticipantIdsByControlId: {},
1421
- allowedControlTypes: ur,
1422
- initialCreateFlow: n === "create",
1423
- onCreateFlowActiveChange: v,
1424
- onCreateFlowComplete: A,
1425
- onChange: E,
1426
- emptyMessage: "No document controls yet."
1427
- }
1428
- ) })
1429
- ]
1430
- }
1431
- ) });
1432
- }
1433
- function hr(t) {
1434
- return (t.controls || []).map((s) => s.id);
1435
- }
1436
- function pr(t) {
1437
- const s = {};
1438
- for (const n of t)
1439
- n.defaultValue !== void 0 && (s[n.id] = n.defaultValue);
1440
- return s;
1441
- }
1442
- function fr(t, s) {
1443
- return s ? Object.prototype.hasOwnProperty.call(s, t.id) ? {
1444
- ...t,
1445
- defaultValue: s[t.id]
1446
- } : t.defaultValue === void 0 ? t : { ...t, defaultValue: void 0 } : t.defaultValue === void 0 ? t : { ...t, defaultValue: void 0 };
1447
- }
1448
- function gr({
1449
- currentInputs: t,
1450
- nextControls: s,
1451
- nextDefaultValues: n,
1452
- change: a
1453
- }) {
1454
- const o = new Map(
1455
- s.map((p) => [
1456
- p.id,
1457
- fr(p, n)
1458
- ])
1459
- ), l = (a == null ? void 0 : a.type) === "rename" ? { oldId: a.oldId, newId: a.newId } : null, u = /* @__PURE__ */ new Set(), d = [];
1460
- for (const p of t) {
1461
- if (p.kind !== "control") {
1462
- d.push(p);
1463
- continue;
1464
- }
1465
- const v = o.get(p.control.id) || ((l == null ? void 0 : l.oldId) === p.control.id ? o.get(l.newId) : void 0);
1466
- v && (u.add(v.id), d.push({
1467
- ...p,
1468
- label: v.label,
1469
- requiredAtExecution: v.requiredAtExecution,
1470
- control: v
1471
- }));
1472
- }
1473
- for (const p of o.values())
1474
- u.has(p.id) || d.push(
1475
- Es({
1476
- control: p,
1477
- existingInputs: d
1478
- })
1479
- );
1480
- return d;
1481
- }
1482
- function ca(t, s) {
1483
- return {
1484
- dashboard: bt(t),
1485
- semanticExecutionPayload: bt(s)
1486
- };
1487
- }
1488
- function Mr() {
1489
- var Qt, Wt, Jt, Yt, Xt, Zt;
1490
- dn(), un();
1491
- const {
1492
- authToken: t,
1493
- tokenProps: s,
1494
- id: n
1495
- } = j(), { isLocalDev: a } = Is(), { permissions: o } = $n(), l = Ls(), { isLoading: u } = Ms(), d = D((i) => i.theme), p = D((i) => i.isDownloadingPdf), v = D(
1496
- (i) => i.dashboardAssistantDraftScopeKey
1497
- ), m = D((i) => i.lenses), f = D((i) => i.selectedLensId), h = m == null ? void 0 : m.find((i) => i.id === f), r = D((i) => i.dashboard), g = D((i) => i.selectedSheetId), y = (Qt = r == null ? void 0 : r.sheets) == null ? void 0 : Qt.find(
1498
- (i) => i.id === g
1499
- ), w = As(y), x = w ? (Wt = y == null ? void 0 : y.document) == null ? void 0 : Wt.page : void 0, C = D(
1500
- (i) => i.isDashboardEditing
1501
- ), { setDashboardTitle: T } = D((i) => i.actions), [A, E] = N(!1), [H, $] = N(!1), [S, z] = N(!1), [K, B] = N(!1), [He, b] = N(!1), [P, R] = N(!1), [Q, ee] = N(!1), [ue, At] = N(!1), [Be, me] = N(null), [Ua, he] = N(!1), [pe, fe] = N(null), [Ot, ge] = N([]), [kt, ve] = N(!1), Fa = D((i) => i.isDashboardPanelOpen), Ra = D(
1502
- (i) => i.actions.setIsDashboardPanelOpen
1503
- ), Ga = D((i) => i.filterValues), _ = D((i) => i.isVisualEditing);
1504
- aa((i) => i.card);
1505
- const te = Oe(
1506
- (i) => i.selectedDashboard
1507
- ), be = Oe(
1508
- (i) => i.initialDashboard
1509
- );
1510
- Oe((i) => i.selectedVisual), D((i) => i.selectedFrameId), aa((i) => i.frame);
1511
- const ye = te ? (Yt = te == null ? void 0 : te.permissions) == null ? void 0 : Yt.canEdit : (Jt = be == null ? void 0 : be.permissions) == null ? void 0 : Jt.canEdit, xe = D((i) => i.showFilters), Pt = Os((i) => i.setPanelOpen), Tt = D(
1512
- (i) => i.showDashboardJSON
1513
- ), je = D((i) => i.onSaveFunction), _t = D(
1514
- (i) => i.actions.setShowFilters
1515
- ), {
1516
- setDocumentInspectorTab: Ut,
1517
- setIsDashboardEditing: Ft,
1518
- setShowDashboardJSON: Rt
1519
- } = D((i) => i.actions), { setInitialDashboard: Gt, clearSelectedDashboard: Ke } = Oe(
1520
- (i) => i.actions
1521
- ), { resources: Ne } = ks(nt.DASHBOARD), { data: Qe } = Ps(), $a = ((Xt = Qe == null ? void 0 : Qe.preference) == null ? void 0 : Xt.defaultDashboardId) || null, { mutate: Va, isPending: za } = Ts(), { currentUser: qa } = Dt(), Ha = _s(qa), J = te || be, $t = J ? {
1522
- id: J.id,
1523
- title: (r == null ? void 0 : r.title) || J.title || "Dashboard"
1524
- } : null, { handleAddNewFrame: Ba } = Us(), [We, Je] = N(!1), [ja, ae] = N(!1), [Ye, we] = N("close"), se = Fs(nt.DASHBOARD), [G, Se] = N(null), Vt = Ue((i) => {
1525
- window.setTimeout(() => {
1526
- me(i);
1527
- }, 0);
1528
- }, []), Ka = async (i, O) => {
1529
- if (!(r != null && r.id)) {
1530
- console.log("No dashboard ID found");
1531
- return;
1532
- }
1533
- console.log("Updating dashboard title:", {
1534
- dashboardId: r.id,
1535
- newTitle: i,
1536
- previousTitle: O
1537
- }), se.mutate(
1538
- {
1539
- resourceId: r.id,
1540
- data: { title: i }
1541
- },
1542
- {
1543
- onSuccess: () => {
1544
- console.log("Dashboard title updated successfully"), I.success("Dashboard title updated");
1545
- },
1546
- onError: (q) => {
1547
- console.error("Failed to update dashboard title:", q), I.error("Failed to update dashboard title"), T(O);
1548
- }
1549
- }
1550
- );
1551
- };
1552
- ot(() => {
1553
- if (Ne && Ne.length > 0) {
1554
- const i = r == null ? void 0 : r.id;
1555
- if (i) {
1556
- const O = Ne.find(
1557
- (q) => q.id === i
1558
- );
1559
- O && Gt(O);
1560
- }
1561
- }
1562
- }, [Ne, r == null ? void 0 : r.id, Gt]);
1563
- const ne = s.orgUserId || s.tenantId, Xe = F(
1564
- () => vr({
1565
- accessToken: t == null ? void 0 : t.accessToken,
1566
- dashboardId: (r == null ? void 0 : r.id) || n || s.dashboard_id,
1567
- selectedSheetId: w ? g : void 0,
1568
- pageSize: x == null ? void 0 : x.size,
1569
- orientation: x == null ? void 0 : x.orientation,
1570
- theme: d
1571
- }),
1572
- [
1573
- t == null ? void 0 : t.accessToken,
1574
- n,
1575
- r == null ? void 0 : r.id,
1576
- w,
1577
- x == null ? void 0 : x.orientation,
1578
- x == null ? void 0 : x.size,
1579
- g,
1580
- d,
1581
- s.dashboard_id
1582
- ]
1583
- ), zt = C && !_ && ne && ye, { setDashboard: Ze } = D((i) => i.actions), et = D(
1584
- (i) => i.semanticExecutionPayload
1585
- ), Qa = () => {
1586
- Ft(!0);
1587
- }, tt = () => {
1588
- Ft(!1), Rt(!1), Se(null), me(null);
1589
- };
1590
- ot(() => {
1591
- if (!C) {
1592
- G && Se(null);
1593
- return;
1594
- }
1595
- G || !r || u || Se(
1596
- ca(
1597
- r,
1598
- et
1599
- )
1600
- );
1601
- }, [
1602
- r,
1603
- G,
1604
- C,
1605
- u,
1606
- et
1607
- ]);
1608
- const De = (G == null ? void 0 : G.dashboard) ?? null, { isDirty: qt, isDirtyPending: Wa, resetDirty: Ce } = Nn(
1609
- r,
1610
- De,
1611
- 300,
1612
- 1e3,
1613
- it
1614
- ), Ht = Ue(() => De ? it(r) !== it(De) : !1, [r, De]), Bt = qt || Wa, Ee = We || se.isPending, Ja = () => {
1615
- Ht() ? (we("close"), ae(!0)) : (tt(), Ce());
1616
- }, Ya = async () => {
1617
- await at({
1618
- closeAfterSave: !0,
1619
- navigateHomeAfterSave: Ye === "home"
1620
- });
1621
- }, Xa = () => {
1622
- G && Ze(G.dashboard, {
1623
- semanticExecutionPayload: G.semanticExecutionPayload
1624
- }), tt(), Ye === "home" && Ke(), we("close"), ae(!1), Ce();
1625
- }, Za = () => {
1626
- G && (Ze(G.dashboard, {
1627
- semanticExecutionPayload: G.semanticExecutionPayload
1628
- }), Ce());
1629
- }, es = () => {
1630
- if (C && Ht()) {
1631
- we("home"), ae(!0);
1632
- return;
1633
- }
1634
- Ke();
1635
- };
1636
- async function at(i) {
1637
- const O = D.getState().dashboard;
1638
- if (!O)
1639
- return;
1640
- const q = (i == null ? void 0 : i.closeAfterSave) ?? kt, rs = (i == null ? void 0 : i.navigateHomeAfterSave) ?? !1;
1641
- ve(q), q && ae(!1);
1642
- const os = bt(O);
1643
- he(!0), fe(null), ge([]), Je(!0);
1644
- const is = {
1645
- template: O
1646
- };
1647
- se.mutate(
1648
- {
1649
- resourceId: O.id,
1650
- data: is
1651
- },
1652
- {
1653
- onSuccess: (U) => {
1654
- var Le, Me, ea;
1655
- const W = (U == null ? void 0 : U.id) || ((Le = U == null ? void 0 : U.dashboard) == null ? void 0 : Le.id) || ((Me = U == null ? void 0 : U.resource) == null ? void 0 : Me.id) || ((ea = U == null ? void 0 : U.template) == null ? void 0 : ea.id) || null;
1656
- if (!O.id && W) {
1657
- const st = cn.getState(), Ae = st.pendingDashboardDraftMigration;
1658
- (Ae == null ? void 0 : Ae.scopeKey) === v ? st.actions.setPendingDashboardDraftMigrationExpectedDashboardId(
1659
- W
1660
- ) : Ae && st.actions.clearPendingDashboardDraftMigration();
1661
- }
1662
- Je(!1), I.success("Dashboard saved!"), Se(
1663
- ca(
1664
- os,
1665
- D.getState().semanticExecutionPayload
1666
- )
1667
- ), he(!1), ve(!1), q && (tt(), Ce(), rs && Ke()), we("close");
1668
- },
1669
- onError: (U) => {
1670
- Je(!1), fe("Failed to save dashboard. Please try again.");
1671
- const W = U.details, Le = Array.isArray(
1672
- W == null ? void 0 : W.errors
1673
- ) ? (W.errors || []).filter(
1674
- (Me) => typeof Me == "string"
1675
- ) : [];
1676
- ge(
1677
- dr({
1678
- errors: Le,
1679
- dashboard: O || void 0
1680
- })
1681
- ), I.error("Failed to save dashboard");
1682
- }
1683
- }
1684
- );
1685
- }
1686
- async function ts() {
1687
- if (E(!0), !f || !h) return;
1688
- const i = D.getState().dashboard;
1689
- if (!i) {
1690
- E(!1);
1691
- return;
1692
- }
1693
- const O = JSON.stringify(i), q = {
1694
- ...h,
1695
- template: O,
1696
- filterValues: Ga
1697
- };
1698
- await xt(
1699
- s.apiServiceUrl,
1700
- q,
1701
- t == null ? void 0 : t.accessToken
1702
- ), I.success("Lens saved"), je == null || je(i), E(!1);
1703
- }
1704
- const jt = (h == null ? void 0 : h.name) || r.title, re = !!(r != null && r.id);
1705
- se.isPending && console.log("Title during update:", {
1706
- title: jt,
1707
- dashboardStateTitle: r.title,
1708
- dashboardId: r == null ? void 0 : r.id,
1709
- currentLensName: h == null ? void 0 : h.name
1710
- });
1711
- const Kt = s.orgUserId || s.tenantId && s.endUserId && s.endUserEmail, as = !!Kt && !!(t != null && t.accessToken) && !!(s != null && s.apiServiceUrl);
1712
- ot(() => {
1713
- !re && K && B(!1);
1714
- }, [re, K]);
1715
- const ss = l, oe = (r == null ? void 0 : r.id) || null, Ie = !!oe && $a === oe, ns = () => {
1716
- oe && Va({
1717
- dashboardId: Ie ? null : oe
1718
- });
1719
- };
1720
- return /* @__PURE__ */ c(
1721
- "div",
1722
- {
1723
- className: "flex h-11 shrink-0 items-center justify-between gap-2 overflow-x-auto border-b px-4 py-2",
1724
- role: "dashboard-controls",
1725
- children: [
1726
- /* @__PURE__ */ c("div", { className: "flex items-center gap-2", children: [
1727
- Kt && /* @__PURE__ */ c(k, { children: [
1728
- /* @__PURE__ */ e(
1729
- rt,
1730
- {
1731
- "aria-label": "Manage Dashboards",
1732
- tooltip: "Manage Dashboards",
1733
- onClick: () => {
1734
- Ra(!Fa);
1735
- },
1736
- className: "h-7 w-7 px-0",
1737
- buttonProps: { size: "xs" },
1738
- children: /* @__PURE__ */ e(En, { className: "h-3.5 w-3.5" })
1739
- }
1740
- ),
1741
- ss && !_ && /* @__PURE__ */ e(
1742
- rt,
1743
- {
1744
- "aria-label": "Dashboard Hub",
1745
- tooltip: "Dashboard Hub",
1746
- onClick: es,
1747
- className: "h-7 w-7 px-0",
1748
- buttonProps: { size: "xs" },
1749
- children: /* @__PURE__ */ e(da, { className: "h-3.5 w-3.5" })
1750
- }
1751
- )
1752
- ] }),
1753
- !_ && l && (u ? /* @__PURE__ */ e(
1754
- "div",
1755
- {
1756
- className: "h-4 w-28 animate-pulse rounded-md bg-muted/70",
1757
- "aria-label": "Loading dashboard title",
1758
- role: "status",
1759
- children: /* @__PURE__ */ e("span", { className: "sr-only", children: "Loading dashboard title" })
1760
- }
1761
- ) : /* @__PURE__ */ c(k, { children: [
1762
- /* @__PURE__ */ e(
1763
- Rs,
1764
- {
1765
- value: jt || "Untitled Dashboard",
1766
- onSave: (i) => {
1767
- console.log("EditableText onSave called:", {
1768
- newTitle: i,
1769
- canEditDashboard: ye,
1770
- dashboardId: r == null ? void 0 : r.id
1771
- });
1772
- const O = (r == null ? void 0 : r.title) || "";
1773
- T(i), Ka(i, O);
1774
- },
1775
- isEditable: ye && !h,
1776
- displayClassName: "text-[13px] font-medium",
1777
- inputClassName: "text-[13px] font-medium",
1778
- placeholder: "Dashboard Title",
1779
- isPending: se.isPending
1780
- }
1781
- ),
1782
- as && oe && /* @__PURE__ */ e(Gs, { children: /* @__PURE__ */ c($s, { children: [
1783
- /* @__PURE__ */ e(Vs, { asChild: !0, children: /* @__PURE__ */ e(
1784
- L,
1785
- {
1786
- variant: "ghost",
1787
- size: "xs",
1788
- onClick: ns,
1789
- disabled: za || !(t != null && t.accessToken) || !(s != null && s.apiServiceUrl),
1790
- className: "w-7 px-0",
1791
- "aria-label": Ie ? "Remove as default dashboard" : "Make this a default dashboard",
1792
- children: /* @__PURE__ */ e(
1793
- zs,
1794
- {
1795
- className: Y(
1796
- "h-3.5 w-3.5 transition-colors",
1797
- Ie ? "fill-foreground text-foreground" : "text-muted-foreground hover:text-foreground"
1798
- )
1799
- }
1800
- )
1801
- }
1802
- ) }),
1803
- /* @__PURE__ */ e(qs, { children: /* @__PURE__ */ e("p", { children: Ie ? "Remove as default dashboard" : "Make this a default dashboard" }) })
1804
- ] }) })
1805
- ] }))
1806
- ] }),
1807
- /* @__PURE__ */ c("div", { className: "flex items-center gap-2", children: [
1808
- _ && /* @__PURE__ */ c(k, { children: [
1809
- /* @__PURE__ */ e(mn, {}),
1810
- /* @__PURE__ */ e(hn, {})
1811
- ] }),
1812
- !_ && l && ((Zt = J == null ? void 0 : J.permissions) == null ? void 0 : Zt.canShare) && /* @__PURE__ */ c(
1813
- L,
1814
- {
1815
- variant: "outline",
1816
- size: "xs",
1817
- onClick: () => $(!0),
1818
- children: [
1819
- /* @__PURE__ */ e(Hs, { className: "h-3.5 w-3.5" }),
1820
- "Share"
1821
- ]
1822
- }
1823
- ),
1824
- !_ && C && o.canUseFilters && l && /* @__PURE__ */ e(
1825
- pn,
1826
- {
1827
- showFilters: w ? !1 : xe,
1828
- onToggleFilters: () => {
1829
- if (w && g) {
1830
- Ut(g, "inputs");
1831
- return;
1832
- }
1833
- xe || Pt("dashboard", !1), _t(!xe);
1834
- },
1835
- onAddFilter: () => {
1836
- if (w && g) {
1837
- Ut(g, "inputs");
1838
- return;
1839
- }
1840
- xe || (Pt("dashboard", !1), _t(!0));
1841
- },
1842
- onAddControl: () => {
1843
- Vt("create");
1844
- },
1845
- onManageControls: () => Vt("manage")
1846
- }
1847
- ),
1848
- C && !_ && l && Be ? w ? /* @__PURE__ */ e(
1849
- mr,
1850
- {
1851
- open: !0,
1852
- onOpenChange: (i) => {
1853
- i || me(null);
1854
- },
1855
- initialMode: Be
1856
- }
1857
- ) : /* @__PURE__ */ e(
1858
- fn,
1859
- {
1860
- open: !0,
1861
- onOpenChange: (i) => {
1862
- i || me(null);
1863
- },
1864
- showTrigger: !1,
1865
- initialMode: Be
1866
- }
1867
- ) : null,
1868
- C && !_ && ne && h && a && l && /* @__PURE__ */ c(
1869
- L,
1870
- {
1871
- variant: "secondary",
1872
- size: "xs",
1873
- disabled: A,
1874
- onClick: ts,
1875
- children: [
1876
- /* @__PURE__ */ e(na, { className: "h-3.5 w-3.5" }),
1877
- "Save Lens"
1878
- ]
1879
- }
1880
- ),
1881
- C && !_ && l && !w && /* @__PURE__ */ c(
1882
- L,
1883
- {
1884
- variant: "outline",
1885
- size: "xs",
1886
- disabled: !C,
1887
- onClick: () => Ba(),
1888
- children: [
1889
- /* @__PURE__ */ e(dt, { className: "h-3.5 w-3.5" }),
1890
- "Visual"
1891
- ]
1892
- }
1893
- ),
1894
- !_ && !C && ye && l && /* @__PURE__ */ c(L, { size: "xs", onClick: Qa, children: [
1895
- /* @__PURE__ */ e(Bs, { className: "h-3.5 w-3.5" }),
1896
- "Edit"
1897
- ] }),
1898
- zt && l && qt && /* @__PURE__ */ c(
1899
- L,
1900
- {
1901
- variant: "outline",
1902
- size: "xs",
1903
- onClick: Za,
1904
- disabled: Ee,
1905
- children: [
1906
- /* @__PURE__ */ e(js, { className: "h-3.5 w-3.5" }),
1907
- "Undo"
1908
- ]
1909
- }
1910
- ),
1911
- zt && l && /* @__PURE__ */ c(
1912
- L,
1913
- {
1914
- size: "xs",
1915
- className: Y(!Bt && "opacity-60"),
1916
- disabled: Ee || !Bt,
1917
- onClick: () => at(),
1918
- children: [
1919
- Ee ? /* @__PURE__ */ e(X, { className: "h-3.5 w-3.5 animate-spin" }) : /* @__PURE__ */ e(na, { className: "h-3.5 w-3.5" }),
1920
- Ee ? "Saving..." : "Save"
1921
- ]
1922
- }
1923
- ),
1924
- C && !_ && l && /* @__PURE__ */ c(L, { variant: "outline", size: "xs", onClick: Ja, children: [
1925
- /* @__PURE__ */ e(ua, { className: "h-3.5 w-3.5" }),
1926
- "Close"
1927
- ] }),
1928
- !_ && l && /* @__PURE__ */ e("div", { className: "ml-2", children: /* @__PURE__ */ e(gn, {}) }),
1929
- !_ && a && /* @__PURE__ */ e(Tn, {}),
1930
- !_ && l && /* @__PURE__ */ c(Ks, { children: [
1931
- /* @__PURE__ */ e(Qs, { asChild: !0, children: /* @__PURE__ */ e(
1932
- rt,
1933
- {
1934
- tooltip: "More Options",
1935
- className: "w-7 px-0 text-muted-foreground hover:text-foreground",
1936
- buttonProps: {
1937
- size: "xs",
1938
- variant: "ghost",
1939
- "aria-label": "More dashboard options"
1940
- },
1941
- children: /* @__PURE__ */ e(Ws, { className: "h-3.5 w-3.5" })
1942
- }
1943
- ) }),
1944
- /* @__PURE__ */ c(
1945
- Js,
1946
- {
1947
- align: "end",
1948
- className: "w-56 rounded-[6px] border border-border/60 p-1 shadow-sm",
1949
- children: [
1950
- /* @__PURE__ */ e(ce, { children: "Reports" }),
1951
- /* @__PURE__ */ c(
1952
- V,
1953
- {
1954
- disabled: p,
1955
- onSelect: () => At(!0),
1956
- children: [
1957
- /* @__PURE__ */ e(Ys, { className: "h-3.5 w-3.5" }),
1958
- "Export"
1959
- ]
1960
- }
1961
- ),
1962
- /* @__PURE__ */ c(
1963
- V,
1964
- {
1965
- disabled: !re,
1966
- onSelect: () => {
1967
- re && B(!0);
1968
- },
1969
- children: [
1970
- /* @__PURE__ */ e(Xs, { className: "h-3.5 w-3.5" }),
1971
- "Schedule"
1972
- ]
1973
- }
1974
- ),
1975
- /* @__PURE__ */ e(Pe, {}),
1976
- Ha && /* @__PURE__ */ c(k, { children: [
1977
- /* @__PURE__ */ e(ce, { children: "Access" }),
1978
- /* @__PURE__ */ c(
1979
- V,
1980
- {
1981
- onClick: () => z(!0),
1982
- children: [
1983
- /* @__PURE__ */ e(Ct, { className: "h-3.5 w-3.5" }),
1984
- "Manage Groups"
1985
- ]
1986
- }
1987
- ),
1988
- /* @__PURE__ */ e(Pe, {})
1989
- ] }),
1990
- /* @__PURE__ */ e(ce, { children: "Preferences" }),
1991
- /* @__PURE__ */ c(V, { onClick: () => b(!0), children: [
1992
- /* @__PURE__ */ e(Zs, { className: "h-3.5 w-3.5" }),
1993
- "Calendar Preferences"
1994
- ] }),
1995
- /* @__PURE__ */ c(V, { onClick: () => R(!0), children: [
1996
- /* @__PURE__ */ e(en, { className: "h-3.5 w-3.5" }),
1997
- "Summary Settings"
1998
- ] }),
1999
- a && l && /* @__PURE__ */ c(k, { children: [
2000
- /* @__PURE__ */ e(Pe, {}),
2001
- /* @__PURE__ */ e(ce, { children: "Developer" }),
2002
- /* @__PURE__ */ c(
2003
- V,
2004
- {
2005
- onSelect: () => {
2006
- var i;
2007
- t != null && t.accessToken && ((i = navigator == null ? void 0 : navigator.clipboard) != null && i.writeText ? navigator.clipboard.writeText(t.accessToken).then(
2008
- () => I.success("Token copied to clipboard")
2009
- ).catch(() => I.error("Unable to copy token")) : I.error("Clipboard not available"));
2010
- },
2011
- children: [
2012
- /* @__PURE__ */ e(sa, { className: "h-3.5 w-3.5" }),
2013
- "Copy token"
2014
- ]
2015
- }
2016
- ),
2017
- w && /* @__PURE__ */ c(
2018
- V,
2019
- {
2020
- disabled: !Xe,
2021
- onSelect: () => {
2022
- var i;
2023
- if (!Xe) {
2024
- I.error(
2025
- "Open a document sheet with a token to copy the local PDF URL"
2026
- );
2027
- return;
2028
- }
2029
- (i = navigator == null ? void 0 : navigator.clipboard) != null && i.writeText ? navigator.clipboard.writeText(Xe).then(
2030
- () => I.success(
2031
- "Local document PDF URL copied to clipboard"
2032
- )
2033
- ).catch(
2034
- () => I.error(
2035
- "Unable to copy local document PDF URL"
2036
- )
2037
- ) : I.error("Clipboard not available");
2038
- },
2039
- children: [
2040
- /* @__PURE__ */ e(sa, { className: "h-3.5 w-3.5" }),
2041
- "Copy local document PDF URL"
2042
- ]
2043
- }
2044
- ),
2045
- /* @__PURE__ */ c(
2046
- V,
2047
- {
2048
- onSelect: () => tn(s.apiServiceUrl),
2049
- children: [
2050
- /* @__PURE__ */ e(Mn, { className: "h-3.5 w-3.5" }),
2051
- "Invalidate token"
2052
- ]
2053
- }
2054
- ),
2055
- C && /* @__PURE__ */ c(
2056
- V,
2057
- {
2058
- onSelect: () => Rt(!Tt),
2059
- children: [
2060
- /* @__PURE__ */ e(Dn, { className: "h-3.5 w-3.5" }),
2061
- Tt ? "Hide dashboard JSON" : "Show dashboard JSON"
2062
- ]
2063
- }
2064
- ),
2065
- ne && C && /* @__PURE__ */ c(V, { onSelect: () => ee(!0), children: [
2066
- /* @__PURE__ */ e(dt, { className: "h-3.5 w-3.5" }),
2067
- "Add lens"
2068
- ] }),
2069
- ne && /* @__PURE__ */ c(an, { children: [
2070
- /* @__PURE__ */ c(sn, { children: [
2071
- /* @__PURE__ */ e(Cn, { className: "h-3.5 w-3.5" }),
2072
- "Lenses"
2073
- ] }),
2074
- /* @__PURE__ */ e(nn, { className: "w-60", children: /* @__PURE__ */ e(Gn, {}) })
2075
- ] })
2076
- ] })
2077
- ]
2078
- }
2079
- )
2080
- ] }),
2081
- H && $t && /* @__PURE__ */ e(
2082
- rn,
2083
- {
2084
- resource: $t,
2085
- resourceType: nt.DASHBOARD,
2086
- onClose: () => $(!1)
2087
- }
2088
- ),
2089
- /* @__PURE__ */ e(
2090
- lr,
2091
- {
2092
- open: S,
2093
- onOpenChange: z
2094
- }
2095
- ),
2096
- re && (r == null ? void 0 : r.id) && /* @__PURE__ */ e(
2097
- on,
2098
- {
2099
- open: K,
2100
- onOpenChange: B,
2101
- dashboardId: r.id,
2102
- dashboardName: r == null ? void 0 : r.title
2103
- }
2104
- ),
2105
- /* @__PURE__ */ e(
2106
- yn,
2107
- {
2108
- open: He,
2109
- onOpenChange: b
2110
- }
2111
- ),
2112
- /* @__PURE__ */ e(
2113
- xn,
2114
- {
2115
- open: P,
2116
- onOpenChange: R,
2117
- dashboard: r,
2118
- disabled: !C,
2119
- onApply: (i) => Ze(
2120
- {
2121
- ...r,
2122
- summary: i
2123
- },
2124
- {
2125
- semanticExecutionPayload: et
2126
- }
2127
- )
2128
- }
2129
- ),
2130
- a && ne && l && /* @__PURE__ */ e(Rn, { open: Q, onOpenChange: ee }),
2131
- l && /* @__PURE__ */ e(
2132
- ln,
2133
- {
2134
- open: ue,
2135
- onOpenChange: At
2136
- }
2137
- ),
2138
- /* @__PURE__ */ e(
2139
- ba,
2140
- {
2141
- open: Ua,
2142
- onOpenChange: (i) => {
2143
- !i && We && !pe || (he(i), i || (fe(null), ge([]), ve(!1)));
2144
- },
2145
- children: /* @__PURE__ */ c(ya, { className: "max-w-sm", children: [
2146
- /* @__PURE__ */ c(xa, { children: [
2147
- /* @__PURE__ */ e(Na, { children: pe ? "Save failed" : "Saving dashboard" }),
2148
- /* @__PURE__ */ e(wa, { className: "pt-2", children: pe ? "We could not save the dashboard. Please try again." : "Please wait while we save your changes." }),
2149
- Ot.length > 0 && /* @__PURE__ */ c("div", { className: "space-y-1 rounded-md border border-destructive/20 bg-destructive/5 p-3 text-left", children: [
2150
- /* @__PURE__ */ e("div", { className: "text-sm font-medium text-destructive", children: "What needs attention" }),
2151
- /* @__PURE__ */ e("ul", { className: "list-disc space-y-1 pl-4 text-xs text-muted-foreground", children: Ot.slice(0, 5).map((i) => /* @__PURE__ */ e("li", { children: i }, i)) })
2152
- ] })
2153
- ] }),
2154
- /* @__PURE__ */ e(Sa, { className: "flex-col gap-2 sm:flex-row sm:justify-end", children: pe ? /* @__PURE__ */ c(k, { children: [
2155
- /* @__PURE__ */ e(
2156
- Da,
2157
- {
2158
- onClick: () => {
2159
- he(!1), fe(null), ge([]), ve(!1);
2160
- },
2161
- className: "m-0",
2162
- children: "Close"
2163
- }
2164
- ),
2165
- /* @__PURE__ */ e(
2166
- vt,
2167
- {
2168
- onClick: () => at({
2169
- closeAfterSave: kt,
2170
- navigateHomeAfterSave: Ye === "home"
2171
- }),
2172
- className: "m-0",
2173
- children: "Retry"
2174
- }
2175
- )
2176
- ] }) : /* @__PURE__ */ c(vt, { disabled: !0, className: "m-0 cursor-default", children: [
2177
- /* @__PURE__ */ e(X, { className: "mr-2 h-4 w-4 animate-spin" }),
2178
- "Saving..."
2179
- ] }) })
2180
- ] })
2181
- }
2182
- ),
2183
- /* @__PURE__ */ e(
2184
- vn,
2185
- {
2186
- open: ja,
2187
- onOpenChange: (i) => {
2188
- ae(i);
2189
- },
2190
- onSave: Ya,
2191
- onDiscard: Xa,
2192
- isSaving: We,
2193
- saveLabel: "Save",
2194
- discardLabel: "Discard"
2195
- }
2196
- )
2197
- ] })
2198
- ]
2199
- }
2200
- );
2201
- }
2202
- function vr({
2203
- accessToken: t,
2204
- dashboardId: s,
2205
- selectedSheetId: n,
2206
- pageSize: a,
2207
- orientation: o,
2208
- theme: l
2209
- }) {
2210
- if (!t || !n)
2211
- return null;
2212
- const u = new URL("http://localhost:5173/print-document");
2213
- u.searchParams.set("token", t), s && u.searchParams.set("dashboardId", s), u.searchParams.set("selectedSheetId", n), l && u.searchParams.set("theme", l);
2214
- const d = new URL("http://127.0.0.1:3002/");
2215
- return d.searchParams.set("pdfMode", "document"), d.searchParams.set("pageSize", a || "letter"), d.searchParams.set("orientation", o || "portrait"), d.searchParams.set("url", u.toString()), d.toString();
2216
- }
2217
- export {
2218
- Mr as default
2219
- };