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