react-semaphor 0.1.114 → 0.1.115

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 (26) hide show
  1. package/dist/chunks/{dashboard-controls-Dx3SP8_O.js → dashboard-controls-BQDmKxxN.js} +51 -51
  2. package/dist/chunks/{dashboard-controls-BdvApPn1.js → dashboard-controls-YDGnMyyK.js} +1 -1
  3. package/dist/chunks/{dashboard-json-CLmj5Xgn.js → dashboard-json-BHAPV0Eh.js} +1 -1
  4. package/dist/chunks/{dashboard-json-BBUvHSx-.js → dashboard-json-D-gw81va.js} +1 -1
  5. package/dist/chunks/{edit-dashboard-visual-DYXisS8S.js → edit-dashboard-visual-CadUC2o0.js} +1 -1
  6. package/dist/chunks/{edit-dashboard-visual-F01R1pb1.js → edit-dashboard-visual-D8DmYTKj.js} +165 -165
  7. package/dist/chunks/{editor-action-buttons-D-aEUYpS.js → editor-action-buttons-CJ1R-8qC.js} +1 -1
  8. package/dist/chunks/{editor-action-buttons-CCki6g0i.js → editor-action-buttons-Cz-qv-g3.js} +2 -2
  9. package/dist/chunks/{index-BB_Q9BeP.js → index-Bf4pgVkQ.js} +9740 -9779
  10. package/dist/chunks/{index-C2IITrDh.js → index-WFJ2bdm0.js} +166 -166
  11. package/dist/chunks/resource-management-panel-BXzn0kHW.js +6 -0
  12. package/dist/chunks/resource-management-panel-ByY6ZxCb.js +878 -0
  13. package/dist/chunks/{schedule-dashboard-Bcu7Wcl2.js → schedule-dashboard-BJ0PeQTb.js} +3 -3
  14. package/dist/chunks/{schedule-dashboard-CNmepTOh.js → schedule-dashboard-DlYi6cPQ.js} +1 -1
  15. package/dist/chunks/{use-visual-utils-VFO0nbRa.js → use-visual-utils-DlurLDVv.js} +1 -1
  16. package/dist/chunks/{use-visual-utils-CQb_-z3Z.js → use-visual-utils-DlzVpKYl.js} +1 -1
  17. package/dist/dashboard/index.cjs +1 -1
  18. package/dist/dashboard/index.js +1 -1
  19. package/dist/index.cjs +1 -1
  20. package/dist/index.js +4 -4
  21. package/dist/style.css +1 -1
  22. package/dist/surfboard/index.cjs +1 -1
  23. package/dist/surfboard/index.js +1 -1
  24. package/package.json +1 -1
  25. package/dist/chunks/resource-management-panel-BWpWiCnv.js +0 -11
  26. package/dist/chunks/resource-management-panel-C6G5vwpR.js +0 -924
@@ -1,924 +0,0 @@
1
- import { jsx as e, jsxs as t, Fragment as ve } from "react/jsx-runtime";
2
- import { b as Ce, aM as pe, u as de, f as Ge, ak as $, aN as Ke, aO as We, aP as ye, c as q, aQ as Se, aR as ce, B as j, aS as xe, aC as Ye, aD as qe, aT as Je, aF as Qe, aG as G, aU as ue, L as k, aV as Xe, aW as be, aX as fe, aY as Ze, aZ as $e, I as ke, a_ as Ve, a$ as ee, b0 as Le, b1 as et, J as Ee, R as Te, b2 as Oe, b3 as Ae, b4 as Pe, b5 as Ue, b6 as Re, b7 as Ie, b8 as Me, b9 as je, ba as Fe, bb as tt, bc as st, bd as at, aA as Z, aj as nt, be as it, bf as ze, bg as rt, ao as ot, ap as lt, aq as dt, ar as ct, as as ut, at as we, au as he, ax as ht, bh as mt, bi as pt, bj as ft, bk as gt, bl as Dt, bm as Nt, bn as xt, bo as bt } from "./index-BB_Q9BeP.js";
3
- import wt, { useState as D, useEffect as me } from "react";
4
- import { a as Be } from "./use-visual-utils-CQb_-z3Z.js";
5
- import { u as vt } from "./use-click-outside-CMeO_QFI.js";
6
- /**
7
- * @license lucide-react v0.453.0 - ISC
8
- *
9
- * This source code is licensed under the ISC license.
10
- * See the LICENSE file in the root directory of this source tree.
11
- */
12
- const Ct = Ce("ChartSpline", [
13
- ["path", { d: "M3 3v16a2 2 0 0 0 2 2h16", key: "c24i48" }],
14
- ["path", { d: "M7 16c.5-2 1.5-7 4-7 2 0 2 3 4 3 2.5 0 4.5-5 5-7", key: "lw07rv" }]
15
- ]);
16
- /**
17
- * @license lucide-react v0.453.0 - ISC
18
- *
19
- * This source code is licensed under the ISC license.
20
- * See the LICENSE file in the root directory of this source tree.
21
- */
22
- const yt = Ce("FolderOpen", [
23
- [
24
- "path",
25
- {
26
- d: "m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",
27
- key: "usdka0"
28
- }
29
- ]
30
- ]);
31
- function He() {
32
- return /* @__PURE__ */ e(pe, { className: "w-full flex-1", children: /* @__PURE__ */ t("div", { className: "space-y-4 px-4 py-2", children: [
33
- /* @__PURE__ */ e("div", { className: "h-9 w-full rounded bg-muted animate-pulse" }),
34
- /* @__PURE__ */ e("div", { className: "h-9 w-full rounded bg-muted animate-pulse" }),
35
- /* @__PURE__ */ e("div", { className: "space-y-3 pt-2", children: [...Array(3)].map((s, g) => /* @__PURE__ */ t("div", { className: "flex gap-3 animate-pulse", children: [
36
- /* @__PURE__ */ e("div", { className: "h-8 w-8 rounded bg-muted flex-shrink-0" }),
37
- /* @__PURE__ */ t("div", { className: "flex-1 space-y-1.5", children: [
38
- /* @__PURE__ */ e("div", { className: "h-4 w-2/3 rounded bg-muted" }),
39
- /* @__PURE__ */ e("div", { className: "h-3 w-4/5 rounded bg-muted" })
40
- ] })
41
- ] }, g)) })
42
- ] }) });
43
- }
44
- const St = (s) => {
45
- const g = de((i) => i.isVisualEditing), p = de((i) => i.selectedFrameId), l = Ge((i) => i.frame);
46
- return !!(g && p && (l == null ? void 0 : l.visualId) === s);
47
- };
48
- function Vt({
49
- visual: s,
50
- isDeleting: g,
51
- isDuplicating: p,
52
- onAddVisual: l,
53
- onOpenVisual: i,
54
- onEditDetails: f,
55
- onDeleteClick: x,
56
- onDuplicateVisual: m,
57
- // onTogglePrivacy,
58
- onShareVisual: b,
59
- formatDate: v
60
- }) {
61
- var U, S, T, M;
62
- const { selectVisual: h } = $(), o = Ke(s.id), d = St(s.id), { isConsoleMode: P } = We(), L = wt.useRef(null), [w, C] = D(!1), [E, y] = D(!1);
63
- me(() => {
64
- p ? (C(!0), y(!0)) : E && (C(!1), y(!1));
65
- }, [p, E]), me(() => {
66
- d && L.current && L.current.scrollIntoView({
67
- behavior: "smooth",
68
- block: "center"
69
- });
70
- }, [d]);
71
- const O = () => /* @__PURE__ */ e(Ct, { className: "h-4 w-4" }), F = () => {
72
- h(s), i == null || i(s);
73
- };
74
- return /* @__PURE__ */ e(
75
- ye,
76
- {
77
- ref: L,
78
- className: q(
79
- "group cursor-pointer border border-border/50 p-2 shadow-none transition-colors hover:bg-muted/50",
80
- d ? "border-purple-500/50 bg-purple-500/10" : o && "border-primary/50 bg-muted/30"
81
- ),
82
- onClick: F,
83
- children: /* @__PURE__ */ t("div", { className: "flex items-start gap-3", children: [
84
- /* @__PURE__ */ e("div", { className: "mt-0.5 rounded bg-muted p-1.5", children: O() }),
85
- /* @__PURE__ */ t("div", { className: "flex min-w-0 flex-1 flex-col", children: [
86
- /* @__PURE__ */ t("div", { className: "flex items-center gap-2", children: [
87
- /* @__PURE__ */ e(
88
- "p",
89
- {
90
- className: "truncate text-sm font-medium text-foreground",
91
- title: s.title || "Untitled Visual",
92
- children: s.title || "Untitled Visual"
93
- }
94
- ),
95
- s.ownership.status === "shared" && /* @__PURE__ */ t(Se, { variant: "outline", className: "text-xs", children: [
96
- /* @__PURE__ */ e(ce, { className: "mr-1 h-2.5 w-2.5" }),
97
- "Shared"
98
- ] })
99
- ] }),
100
- /* @__PURE__ */ t("div", { className: "flex items-center justify-between gap-2", children: [
101
- /* @__PURE__ */ e(
102
- "p",
103
- {
104
- className: "line-clamp-2 flex-1 text-xs text-muted-foreground",
105
- title: s.description || "No description",
106
- children: (U = s.description) != null && U.trim() ? s.description : "No description"
107
- }
108
- ),
109
- /* @__PURE__ */ t(
110
- "div",
111
- {
112
- className: "flex flex-shrink-0 items-center gap-1",
113
- onClick: (c) => c.stopPropagation(),
114
- children: [
115
- /* @__PURE__ */ t(
116
- "div",
117
- {
118
- className: q(
119
- "invisible flex items-center gap-1 transition-opacity duration-150 group-hover:visible",
120
- o && "visible"
121
- ),
122
- children: [
123
- s.ownership.isOwner && /* @__PURE__ */ e(
124
- j,
125
- {
126
- size: "sm",
127
- variant: "ghost",
128
- className: "h-6 w-6 p-0",
129
- onClick: (c) => {
130
- c.stopPropagation(), f == null || f(s);
131
- },
132
- title: "Edit details",
133
- children: /* @__PURE__ */ e(xe, { className: "h-3 w-3" })
134
- }
135
- ),
136
- /* @__PURE__ */ t(
137
- Ye,
138
- {
139
- modal: !1,
140
- open: w,
141
- onOpenChange: C,
142
- children: [
143
- /* @__PURE__ */ e(qe, { asChild: !0, children: /* @__PURE__ */ e(j, { size: "sm", variant: "ghost", className: "h-6 w-6 p-0", children: /* @__PURE__ */ e(Je, { className: "h-3 w-3" }) }) }),
144
- /* @__PURE__ */ t(Qe, { align: "end", className: "z-[51] w-40", children: [
145
- /* @__PURE__ */ t(
146
- G,
147
- {
148
- onClick: (c) => {
149
- c.stopPropagation(), l(s);
150
- },
151
- children: [
152
- /* @__PURE__ */ e(ue, { className: "mr-2 h-3 w-3" }),
153
- "Add"
154
- ]
155
- }
156
- ),
157
- /* @__PURE__ */ t(
158
- G,
159
- {
160
- onClick: (c) => {
161
- c.stopPropagation(), i == null || i(s);
162
- },
163
- children: [
164
- /* @__PURE__ */ e(yt, { className: "mr-2 h-3 w-3" }),
165
- "Open"
166
- ]
167
- }
168
- ),
169
- /* @__PURE__ */ t(
170
- G,
171
- {
172
- onClick: (c) => {
173
- c.preventDefault(), c.stopPropagation(), m(s.id);
174
- },
175
- disabled: p,
176
- children: [
177
- p ? /* @__PURE__ */ e(k, { className: "mr-2 h-3 w-3 animate-spin" }) : /* @__PURE__ */ e(Xe, { className: "mr-2 h-3 w-3" }),
178
- p ? "Duplicating..." : "Duplicate"
179
- ]
180
- }
181
- ),
182
- s.ownership.isOwner && /* @__PURE__ */ t(ve, { children: [
183
- /* @__PURE__ */ t(
184
- G,
185
- {
186
- onClick: (c) => {
187
- c.stopPropagation(), f == null || f(s);
188
- },
189
- children: [
190
- /* @__PURE__ */ e(xe, { className: "mr-2 h-3 w-3" }),
191
- "Edit details"
192
- ]
193
- }
194
- ),
195
- /* @__PURE__ */ t(
196
- G,
197
- {
198
- onClick: (c) => {
199
- c.stopPropagation(), b(s);
200
- },
201
- children: [
202
- /* @__PURE__ */ e(ce, { className: "mr-2 h-3 w-3" }),
203
- "Share"
204
- ]
205
- }
206
- ),
207
- /* @__PURE__ */ e(be, {}),
208
- /* @__PURE__ */ t(
209
- G,
210
- {
211
- onClick: (c) => {
212
- c.stopPropagation(), x(s);
213
- },
214
- className: "text-destructive",
215
- disabled: g,
216
- children: [
217
- /* @__PURE__ */ e(fe, { className: "mr-2 h-3 w-3" }),
218
- g ? "Deleting..." : "Delete"
219
- ]
220
- }
221
- )
222
- ] }),
223
- /* @__PURE__ */ e(be, {}),
224
- /* @__PURE__ */ t("div", { className: "space-y-1 px-2 py-2 text-xs text-slate-500 dark:text-slate-400", children: [
225
- (((S = s.ownership.createdBy) == null ? void 0 : S.type) === "tenant" || ((T = s.ownership.createdBy) == null ? void 0 : T.type) === "organization" && P) && /* @__PURE__ */ t("div", { className: "flex items-center gap-1", children: [
226
- /* @__PURE__ */ e(Ze, { className: "h-3 w-3" }),
227
- /* @__PURE__ */ e("span", { children: ((M = s.ownership.createdBy) == null ? void 0 : M.name) || "Unknown" })
228
- ] }),
229
- /* @__PURE__ */ t("div", { className: "flex items-center gap-1", children: [
230
- /* @__PURE__ */ e($e, { className: "h-3 w-3" }),
231
- /* @__PURE__ */ e("span", { children: v(s.lastModified) })
232
- ] })
233
- ] })
234
- ] })
235
- ]
236
- }
237
- )
238
- ]
239
- }
240
- ),
241
- /* @__PURE__ */ e(
242
- ke,
243
- {
244
- tooltip: "Add to dashboard",
245
- buttonProps: {
246
- variant: "outline",
247
- size: "sm",
248
- onClick: (c) => {
249
- c.stopPropagation(), l(s);
250
- }
251
- },
252
- className: "h-6 px-2",
253
- children: /* @__PURE__ */ e(ue, { className: "h-3.5 w-3.5" })
254
- }
255
- )
256
- ]
257
- }
258
- )
259
- ] })
260
- ] })
261
- ] })
262
- },
263
- s.id
264
- );
265
- }
266
- function Lt({ searchQuery: s }) {
267
- const [g, p] = D(!1), [l, i] = D(
268
- null
269
- ), [f, x] = D(!1), [m, b] = D(null), [v, h] = D(null), [o, d] = D(
270
- null
271
- ), { selectVisual: P } = $(), { handleEditLibraryVisual: L, handleAddLibraryVisual: w } = Be(), {
272
- resources: C,
273
- isLoading: E,
274
- isError: y,
275
- updateResource: O,
276
- deleteResource: F,
277
- duplicateResource: U,
278
- isDeleting: S
279
- } = Ve(() => {
280
- x(!1), b(null);
281
- });
282
- ee();
283
- const T = C.filter(
284
- (n) => {
285
- var V, r;
286
- return ((V = n == null ? void 0 : n.title) == null ? void 0 : V.toLowerCase().includes(s.toLowerCase())) || ((r = n == null ? void 0 : n.description) == null ? void 0 : r.toLowerCase().includes(s.toLowerCase()));
287
- }
288
- ), M = (n) => new Date(n).toLocaleDateString("en-US", {
289
- month: "short",
290
- day: "numeric",
291
- year: "numeric"
292
- }), c = (n) => {
293
- b(n), x(!0);
294
- }, H = () => {
295
- m && F(m.id);
296
- }, {
297
- startUpdating: K,
298
- stopUpdating: _,
299
- isUpdating: A
300
- } = Le(), N = (n, V, r) => {
301
- var X;
302
- const W = Object.fromEntries(
303
- Object.entries(V).filter(([, I]) => I !== void 0)
304
- );
305
- if (Object.keys(W).length === 0) {
306
- (X = r == null ? void 0 : r.onSuccess) == null || X.call(r);
307
- return;
308
- }
309
- const Q = Object.keys(W), Y = Q.length === 1 ? Q[0] : void 0;
310
- K(n, Y), O(
311
- {
312
- resourceId: n,
313
- data: W
314
- },
315
- {
316
- onSuccess: () => {
317
- var I;
318
- _(n, Y), (I = r == null ? void 0 : r.onSuccess) == null || I.call(r);
319
- },
320
- onError: () => {
321
- var I;
322
- _(n, Y), (I = r == null ? void 0 : r.onError) == null || I.call(r);
323
- }
324
- }
325
- );
326
- }, z = (n) => {
327
- h(n), U(n, {
328
- onSettled: () => h(null)
329
- });
330
- }, te = (n) => {
331
- L(n);
332
- }, J = (n) => {
333
- w(n);
334
- }, se = (n) => {
335
- const V = C.find((r) => r.id === n);
336
- V && O({
337
- resourceId: n,
338
- data: {
339
- isPrivate: !V.isPrivate
340
- }
341
- });
342
- }, ae = (n) => {
343
- i(n), p(!0);
344
- }, ne = (n) => {
345
- d(n);
346
- }, ie = () => {
347
- d(null);
348
- }, re = ({
349
- title: n,
350
- description: V
351
- }) => {
352
- if (!o)
353
- return;
354
- const r = {};
355
- n !== o.title && (r.title = n), (o.description || "") !== V && (r.description = V), N(o.id, r, {
356
- onSuccess: () => {
357
- d(null);
358
- }
359
- });
360
- };
361
- return E ? /* @__PURE__ */ e(He, {}) : y ? /* @__PURE__ */ e(pe, { className: "w-full flex-1 pr-2", children: /* @__PURE__ */ t("div", { className: "py-8 text-center text-muted-foreground", children: [
362
- /* @__PURE__ */ e("p", { className: "text-sm text-destructive", children: "Failed to load visuals" }),
363
- /* @__PURE__ */ e(
364
- j,
365
- {
366
- variant: "outline",
367
- size: "sm",
368
- className: "mt-2",
369
- onClick: () => window.location.reload(),
370
- children: "Retry"
371
- }
372
- )
373
- ] }) }) : /* @__PURE__ */ t("div", { className: "flex h-full flex-1 flex-col", children: [
374
- /* @__PURE__ */ e("div", { className: "flex flex-1 basis-0 flex-col gap-3 overflow-y-auto", children: T.length === 0 ? /* @__PURE__ */ t("div", { className: "py-8 text-center", children: [
375
- /* @__PURE__ */ e("div", { className: "mb-3", children: /* @__PURE__ */ e(et, { className: "mx-auto h-12 w-12 text-muted-foreground/50" }) }),
376
- /* @__PURE__ */ e("h3", { className: "mb-1 font-medium text-foreground", children: s ? "No visuals found" : "No visuals yet" }),
377
- /* @__PURE__ */ e("p", { className: "text-sm text-muted-foreground", children: s ? "Try adjusting your search" : 'Click "Create" above to add your first visual' })
378
- ] }) : T.map((n) => /* @__PURE__ */ e(
379
- Vt,
380
- {
381
- visual: n,
382
- onAddVisual: J,
383
- onOpenVisual: te,
384
- onEditDetails: ne,
385
- onDeleteClick: c,
386
- onDuplicateVisual: z,
387
- onTogglePrivacy: se,
388
- onShareVisual: ae,
389
- isDeleting: S,
390
- isDuplicating: v === n.id,
391
- formatDate: M
392
- },
393
- n.id
394
- )) }),
395
- g && l && /* @__PURE__ */ e(
396
- Ee,
397
- {
398
- resource: l,
399
- resourceType: Te.VISUAL,
400
- onClose: () => {
401
- p(!1), i(null);
402
- }
403
- }
404
- ),
405
- o && /* @__PURE__ */ e(
406
- Oe,
407
- {
408
- open: !!o,
409
- resourceLabel: "Visual",
410
- initialTitle: o.title || "",
411
- initialDescription: o.description || "",
412
- onClose: ie,
413
- onSave: re,
414
- isSaving: A(o.id)
415
- }
416
- ),
417
- /* @__PURE__ */ e(
418
- Ae,
419
- {
420
- open: f,
421
- onOpenChange: (n) => {
422
- !n && S || (x(n), n || b(null));
423
- },
424
- children: /* @__PURE__ */ t(Pe, { children: [
425
- /* @__PURE__ */ t(Ue, { children: [
426
- /* @__PURE__ */ e(Re, { children: "Delete Visual" }),
427
- /* @__PURE__ */ t(Ie, { children: [
428
- 'Are you sure you want to delete "',
429
- m == null ? void 0 : m.title,
430
- '"? This action cannot be undone.'
431
- ] })
432
- ] }),
433
- /* @__PURE__ */ t(Me, { children: [
434
- /* @__PURE__ */ e(je, { disabled: S, children: "Cancel" }),
435
- /* @__PURE__ */ t(
436
- Fe,
437
- {
438
- onClick: (n) => {
439
- n.preventDefault(), n.stopPropagation(), H();
440
- },
441
- className: "bg-destructive text-destructive-foreground hover:bg-destructive/90",
442
- disabled: S,
443
- children: [
444
- S ? /* @__PURE__ */ e(k, { className: "mr-2 h-3.5 w-3.5 animate-spin" }) : /* @__PURE__ */ e(fe, { className: "mr-2 h-3.5 w-3.5" }),
445
- S ? "Deleting..." : "Delete"
446
- ]
447
- }
448
- )
449
- ] })
450
- ] })
451
- }
452
- )
453
- ] });
454
- }
455
- function Et({
456
- dashboard: s,
457
- isDeleting: g,
458
- isDuplicating: p,
459
- onLoadDashboard: l,
460
- onEditDetails: i,
461
- onDeleteClick: f,
462
- onDuplicateDashboard: x,
463
- onShareDashboard: m,
464
- formatDate: b,
465
- onDashboardItemClick: v
466
- }) {
467
- var y, O;
468
- const { selectDashboard: h } = $(), o = tt(s.id), { userContext: d, isLoading: P } = ee(), L = ((y = d == null ? void 0 : d.permissions) == null ? void 0 : y.canEdit) ?? !1, w = P || !L, C = () => /* @__PURE__ */ e(at, { className: "h-4 w-4" }), E = () => {
469
- h(s), l(s.id), v == null || v(s.id);
470
- };
471
- return /* @__PURE__ */ e(
472
- ye,
473
- {
474
- className: q(
475
- "group cursor-pointer border border-border/50 p-2 shadow-none transition-colors hover:bg-muted/50",
476
- o && "border-primary/50 bg-muted/30"
477
- ),
478
- onClick: E,
479
- children: /* @__PURE__ */ t("div", { className: "flex items-start gap-3", children: [
480
- /* @__PURE__ */ e("div", { className: "mt-0.5 rounded bg-muted p-1.5", children: C() }),
481
- /* @__PURE__ */ t("div", { className: "min-w-0 flex-1 flex flex-col", children: [
482
- /* @__PURE__ */ t("div", { className: "flex items-center gap-2", children: [
483
- /* @__PURE__ */ e(
484
- "p",
485
- {
486
- className: "text-sm font-medium text-foreground truncate",
487
- title: s.title || "Untitled Dashboard",
488
- children: s.title || "Untitled Dashboard"
489
- }
490
- ),
491
- s.ownership.status === "shared" && /* @__PURE__ */ t(Se, { variant: "outline", className: "text-xs", children: [
492
- /* @__PURE__ */ e(ce, { className: "mr-1 h-2.5 w-2.5" }),
493
- "Shared"
494
- ] })
495
- ] }),
496
- /* @__PURE__ */ t("div", { className: "flex items-center justify-between gap-2", children: [
497
- /* @__PURE__ */ e(
498
- "p",
499
- {
500
- className: "text-xs text-muted-foreground line-clamp-2 flex-1",
501
- title: s.description || "No description",
502
- children: (O = s.description) != null && O.trim() ? s.description : "No description"
503
- }
504
- ),
505
- /* @__PURE__ */ e(
506
- st,
507
- {
508
- dashboard: s,
509
- isDeleting: g,
510
- isDuplicating: p,
511
- shouldHideActions: w,
512
- onEditDetails: i,
513
- onDeleteClick: f,
514
- onDuplicateDashboard: x,
515
- onShareDashboard: m,
516
- formatDate: b
517
- }
518
- )
519
- ] })
520
- ] })
521
- ] })
522
- },
523
- s.id
524
- );
525
- }
526
- function Tt({ onRetry: s }) {
527
- return /* @__PURE__ */ e(pe, { className: "w-full flex-1 pr-2", children: /* @__PURE__ */ t("div", { className: "py-8 text-center text-muted-foreground", children: [
528
- /* @__PURE__ */ e("p", { className: "text-sm text-destructive", children: "Failed to load dashboards" }),
529
- /* @__PURE__ */ e(j, { variant: "outline", size: "sm", className: "mt-2", onClick: s, children: "Retry" })
530
- ] }) });
531
- }
532
- function Ot(s) {
533
- var ge;
534
- const { searchQuery: g, onLoadDashboard: p, onEditDashboard: l, onDashboardItemClick: i } = s, [f, x] = D(!1), [m, b] = D(
535
- null
536
- ), [v, h] = D(!1), [o, d] = D(null), [P, L] = D(null), [w, C] = D(null), E = Z(
537
- (a) => a.lastSelectedDashboard
538
- ), y = Z(
539
- (a) => a.selectedDashboard
540
- ), O = Z(
541
- (a) => a.actions.selectDashboard
542
- ), F = Z(
543
- (a) => a.actions.clearSelectedDashboard
544
- ), { tokenProps: U, id: S } = nt();
545
- it();
546
- const {
547
- resources: T,
548
- isLoading: M,
549
- isError: c,
550
- updateResource: H,
551
- deleteResource: K,
552
- duplicateResource: _,
553
- isDeleting: A
554
- } = ze(() => {
555
- h(!1);
556
- const a = o == null ? void 0 : o.id;
557
- d(null), (y == null ? void 0 : y.id) === a && (!(U != null && U.dashboard_id) && !S ? F() : E && E.id !== a && O(E));
558
- }), { currentUser: N, userContext: z } = ee(), te = ((ge = z == null ? void 0 : z.permissions) == null ? void 0 : ge.canCreateDashboard) ?? !1, J = T.filter(
559
- (a) => {
560
- var R, u;
561
- return ((R = a == null ? void 0 : a.title) == null ? void 0 : R.toLowerCase().includes(g.toLowerCase())) || ((u = a == null ? void 0 : a.description) == null ? void 0 : u.toLowerCase().includes(g.toLowerCase()));
562
- }
563
- ), se = (a) => new Date(a).toLocaleDateString("en-US", {
564
- month: "short",
565
- day: "numeric",
566
- year: "numeric"
567
- }), ae = (a) => {
568
- p == null || p(a);
569
- }, ne = (a) => {
570
- d(a), h(!0);
571
- }, ie = () => {
572
- o && K(o.id);
573
- }, re = (a) => {
574
- L(a), _(a, {
575
- onSettled: () => L(null)
576
- });
577
- }, {
578
- startUpdating: n,
579
- stopUpdating: V,
580
- isUpdating: r
581
- } = Le(), W = (a, R, u) => {
582
- var Ne;
583
- const oe = Object.fromEntries(
584
- Object.entries(R).filter(([, B]) => B !== void 0)
585
- );
586
- if (Object.keys(oe).length === 0) {
587
- (Ne = u == null ? void 0 : u.onSuccess) == null || Ne.call(u);
588
- return;
589
- }
590
- const De = Object.keys(oe), le = De.length === 1 ? De[0] : void 0;
591
- n(a, le), H(
592
- {
593
- resourceId: a,
594
- data: oe
595
- },
596
- {
597
- onSuccess: () => {
598
- var B;
599
- V(a, le), (B = u == null ? void 0 : u.onSuccess) == null || B.call(u);
600
- },
601
- onError: () => {
602
- var B;
603
- V(a, le), (B = u == null ? void 0 : u.onError) == null || B.call(u);
604
- }
605
- }
606
- );
607
- }, Q = (a) => {
608
- const R = T.find(
609
- (u) => u.id === a
610
- );
611
- R && H({
612
- resourceId: a,
613
- data: {
614
- isPrivate: !R.isPrivate
615
- }
616
- });
617
- }, Y = (a) => {
618
- b(a), N == null || N.type, x(!0);
619
- }, X = (a) => {
620
- l == null || l(a.id), C(a);
621
- }, I = () => {
622
- C(null);
623
- }, _e = ({
624
- title: a,
625
- description: R
626
- }) => {
627
- if (!w)
628
- return;
629
- const u = {};
630
- a !== w.title && (u.title = a), (w.description || "") !== R && (u.description = R), W(w.id, u, {
631
- onSuccess: () => {
632
- C(null);
633
- }
634
- });
635
- };
636
- return M ? /* @__PURE__ */ e(He, {}) : c ? /* @__PURE__ */ e(Tt, { onRetry: () => window.location.reload() }) : /* @__PURE__ */ t("div", { className: "flex h-full flex-1 flex-col", children: [
637
- /* @__PURE__ */ e("div", { className: "flex flex-1 basis-0 flex-col gap-3 overflow-y-auto", children: J.length === 0 ? /* @__PURE__ */ t("div", { className: "py-8 text-center", children: [
638
- /* @__PURE__ */ e("div", { className: "mb-3", children: /* @__PURE__ */ e(rt, { className: "mx-auto h-12 w-12 text-muted-foreground/50" }) }),
639
- /* @__PURE__ */ e("h3", { className: "mb-1 font-medium text-foreground", children: g ? "No dashboards found" : "No dashboards yet" }),
640
- /* @__PURE__ */ e("p", { className: "text-sm text-muted-foreground", children: g ? "Try adjusting your search" : te ? 'Click "Create" above to add your first dashboard' : "No dashboards have been shared with you yet" })
641
- ] }) : J.map((a) => /* @__PURE__ */ e(
642
- Et,
643
- {
644
- dashboard: a,
645
- isDeleting: A,
646
- isDuplicating: P === a.id,
647
- onLoadDashboard: ae,
648
- onEditDetails: X,
649
- onDeleteClick: ne,
650
- onDuplicateDashboard: re,
651
- onTogglePrivacy: Q,
652
- onShareDashboard: Y,
653
- formatDate: se,
654
- onDashboardItemClick: i
655
- },
656
- a.id
657
- )) }),
658
- f && m && /* @__PURE__ */ e(
659
- Ee,
660
- {
661
- resource: m,
662
- resourceType: Te.DASHBOARD,
663
- onClose: () => {
664
- x(!1), b(null);
665
- }
666
- }
667
- ),
668
- /* @__PURE__ */ e(
669
- Ae,
670
- {
671
- open: v,
672
- onOpenChange: (a) => {
673
- !a && A || (h(a), a || d(null));
674
- },
675
- children: /* @__PURE__ */ t(Pe, { children: [
676
- /* @__PURE__ */ t(Ue, { children: [
677
- /* @__PURE__ */ e(Re, { children: "Delete Dashboard" }),
678
- /* @__PURE__ */ t(Ie, { children: [
679
- 'Are you sure you want to delete "',
680
- o == null ? void 0 : o.title,
681
- '"? This action cannot be undone.'
682
- ] })
683
- ] }),
684
- /* @__PURE__ */ t(Me, { children: [
685
- /* @__PURE__ */ e(je, { disabled: A, children: "Cancel" }),
686
- /* @__PURE__ */ t(
687
- Fe,
688
- {
689
- onClick: (a) => {
690
- a.preventDefault(), a.stopPropagation(), ie();
691
- },
692
- className: "bg-destructive text-destructive-foreground hover:bg-destructive/90",
693
- disabled: A,
694
- children: [
695
- A ? /* @__PURE__ */ e(k, { className: "mr-2 h-3.5 w-3.5 animate-spin" }) : /* @__PURE__ */ e(fe, { className: "mr-2 h-3.5 w-3.5" }),
696
- A ? "Deleting..." : "Delete"
697
- ]
698
- }
699
- )
700
- ] })
701
- ] })
702
- }
703
- ),
704
- w && /* @__PURE__ */ e(
705
- Oe,
706
- {
707
- open: !!w,
708
- resourceLabel: "Dashboard",
709
- initialTitle: w.title || "",
710
- initialDescription: w.description || "",
711
- onClose: I,
712
- onSave: _e,
713
- isSaving: r(w.id)
714
- }
715
- )
716
- ] });
717
- }
718
- function At({
719
- open: s,
720
- onOpenChange: g,
721
- onSubmit: p,
722
- isCreating: l
723
- }) {
724
- const [i, f] = D(""), [x, m] = D("");
725
- me(() => {
726
- s || (f(""), m(""));
727
- }, [s]);
728
- const b = () => {
729
- i.trim() && p({ title: i, description: x });
730
- }, v = (h) => {
731
- g(h);
732
- };
733
- return /* @__PURE__ */ e(ot, { open: s, onOpenChange: v, children: /* @__PURE__ */ t(lt, { children: [
734
- /* @__PURE__ */ t(dt, { children: [
735
- /* @__PURE__ */ e(ct, { children: "Create New Visual" }),
736
- /* @__PURE__ */ e(ut, { children: "Add a new visual to your library. You can configure it after creation." })
737
- ] }),
738
- /* @__PURE__ */ t("div", { className: "space-y-4 py-4", children: [
739
- /* @__PURE__ */ t("div", { className: "space-y-2", children: [
740
- /* @__PURE__ */ e(we, { htmlFor: "title", children: "Visual Title" }),
741
- /* @__PURE__ */ e(
742
- he,
743
- {
744
- id: "title",
745
- placeholder: "Enter visual title...",
746
- value: i,
747
- onChange: (h) => f(h.target.value),
748
- disabled: l,
749
- onKeyDown: (h) => {
750
- h.key === "Enter" && !h.shiftKey && (h.preventDefault(), b());
751
- }
752
- }
753
- )
754
- ] }),
755
- /* @__PURE__ */ t("div", { className: "space-y-2", children: [
756
- /* @__PURE__ */ e(we, { htmlFor: "description", children: "Description (optional)" }),
757
- /* @__PURE__ */ e(
758
- he,
759
- {
760
- id: "description",
761
- placeholder: "Enter visual description...",
762
- value: x,
763
- onChange: (h) => m(h.target.value),
764
- disabled: l
765
- }
766
- )
767
- ] })
768
- ] }),
769
- /* @__PURE__ */ t(ht, { children: [
770
- /* @__PURE__ */ e(
771
- j,
772
- {
773
- variant: "outline",
774
- onClick: () => v(!1),
775
- disabled: l,
776
- children: "Cancel"
777
- }
778
- ),
779
- /* @__PURE__ */ e(
780
- j,
781
- {
782
- onClick: b,
783
- disabled: !i.trim() || l,
784
- children: l ? /* @__PURE__ */ t(ve, { children: [
785
- /* @__PURE__ */ e(k, { className: "mr-2 h-4 w-4 animate-spin" }),
786
- "Creating..."
787
- ] }) : "Create Visual"
788
- }
789
- )
790
- ] })
791
- ] }) });
792
- }
793
- function jt({
794
- isOpen: s,
795
- onClose: g,
796
- className: p,
797
- onDashboardItemClick: l,
798
- variant: i = "inline"
799
- }) {
800
- var A;
801
- const f = de(
802
- (N) => N.isDashboardEditing
803
- ), [x, m] = D(!1), [b, v] = D(""), [h, o] = D(!1), { currentUser: d, userContext: P } = ee(), L = ((A = P == null ? void 0 : P.permissions) == null ? void 0 : A.canCreateDashboard) ?? !1, { onCreateSuccess: w } = mt({
804
- onDashboardSelect: l
805
- }), { selectVisual: C } = $(), { handleEditLibraryVisual: E } = Be(), {
806
- createResource: y,
807
- isCreating: O,
808
- refetch: F
809
- } = ze(), { createResource: U, isCreating: S } = Ve(
810
- void 0,
811
- // onDeleteSuccess (not needed here)
812
- (N) => {
813
- m(!1), N && (C(N), E(N));
814
- }
815
- ), T = i === "overlay", M = vt(g, {
816
- enabled: s && T
817
- }), c = q(
818
- "flex h-full flex-col border-r bg-background",
819
- T ? q(
820
- "absolute inset-y-0 left-0 z-[51] w-96 shadow-lg transition-transform duration-300 ease-in-out",
821
- s ? "translate-x-0" : "pointer-events-none -translate-x-full"
822
- ) : "w-full max-w-[28rem] min-w-[18rem] overflow-hidden shadow-sm",
823
- p
824
- ), H = (N) => {
825
- }, K = (N) => {
826
- console.log("Editing dashboard:", N);
827
- }, _ = (N) => {
828
- y(N, {
829
- onSuccess: (z) => {
830
- m(!1), w(z, F);
831
- }
832
- });
833
- };
834
- return /* @__PURE__ */ e(pt, { children: (!T || s) && /* @__PURE__ */ t("div", { ref: M, className: c, children: [
835
- /* @__PURE__ */ t("div", { className: "border-b border-border", children: [
836
- /* @__PURE__ */ t("div", { className: "flex items-center justify-between px-4 py-1.5", children: [
837
- /* @__PURE__ */ t("div", { className: "flex items-center gap-2", children: [
838
- /* @__PURE__ */ e("h2", { className: "whitespace-nowrap pl-2 text-sm font-semibold", children: f ? "Library Visuals" : "Dashboards" }),
839
- /* @__PURE__ */ e(
840
- j,
841
- {
842
- size: "sm",
843
- variant: "ghost",
844
- onClick: () => o(!h),
845
- className: "h-8 w-8 p-0",
846
- children: /* @__PURE__ */ e(ft, { className: "h-3.5 w-3.5 text-muted-foreground" })
847
- }
848
- )
849
- ] }),
850
- /* @__PURE__ */ e("div", { className: "flex items-center gap-2", children: (f || L) && /* @__PURE__ */ t(
851
- j,
852
- {
853
- size: "sm",
854
- variant: "ghost",
855
- className: "h-8 whitespace-nowrap px-3",
856
- onClick: () => m(!0),
857
- children: [
858
- /* @__PURE__ */ e(ue, { className: "mr-1 h-4 w-4" }),
859
- "Create"
860
- ]
861
- }
862
- ) })
863
- ] }),
864
- h && /* @__PURE__ */ e("div", { className: "bg-muted/30 px-4 pb-3", children: /* @__PURE__ */ e(
865
- he,
866
- {
867
- placeholder: "Search...",
868
- value: b,
869
- onChange: (N) => v(N.target.value),
870
- className: "h-8 border-muted-foreground/20 bg-background text-sm focus-visible:border-muted-foreground/40 focus-visible:ring-0 focus-visible:ring-offset-0",
871
- autoFocus: !0
872
- }
873
- ) })
874
- ] }),
875
- /* @__PURE__ */ e("div", { className: "flex flex-1 flex-col overflow-auto px-4 py-4", children: f ? /* @__PURE__ */ e(Lt, { searchQuery: b }) : /* @__PURE__ */ e(
876
- Ot,
877
- {
878
- searchQuery: b,
879
- onLoadDashboard: H,
880
- onEditDashboard: K,
881
- onDashboardItemClick: l
882
- }
883
- ) }),
884
- d && /* @__PURE__ */ e("div", { className: "border-t border-border px-4 py-3", children: /* @__PURE__ */ t("div", { className: "flex items-center gap-2", children: [
885
- /* @__PURE__ */ t(gt, { children: [
886
- /* @__PURE__ */ e(Dt, { asChild: !0, children: /* @__PURE__ */ e("div", { className: "flex h-8 w-8 cursor-default items-center justify-center rounded-full bg-primary/10", children: /* @__PURE__ */ e("span", { className: "text-sm font-medium text-primary", children: d.name.charAt(0).toUpperCase() }) }) }),
887
- /* @__PURE__ */ e(Nt, { side: "top", className: "max-w-xs", children: /* @__PURE__ */ t("div", { className: "space-y-1", children: [
888
- /* @__PURE__ */ e("div", { className: "font-medium", children: d.name }),
889
- /* @__PURE__ */ e("div", { className: "text-xs text-muted-foreground", children: d.email }),
890
- d.role && /* @__PURE__ */ t("div", { className: "text-xs text-muted-foreground", children: [
891
- "Role:",
892
- " ",
893
- xt(d.role.replace(/_/g, " "))
894
- ] }),
895
- /* @__PURE__ */ t("div", { className: "text-xs text-muted-foreground", children: [
896
- "ID: ",
897
- d.id
898
- ] })
899
- ] }) })
900
- ] }),
901
- /* @__PURE__ */ e("span", { className: "truncate text-sm font-medium text-foreground", children: d.name })
902
- ] }) }),
903
- f ? /* @__PURE__ */ e(
904
- At,
905
- {
906
- open: x,
907
- onOpenChange: m,
908
- onSubmit: U,
909
- isCreating: S
910
- }
911
- ) : /* @__PURE__ */ e(
912
- bt,
913
- {
914
- open: x,
915
- onOpenChange: m,
916
- onSubmit: _,
917
- isCreating: O
918
- }
919
- )
920
- ] }) });
921
- }
922
- export {
923
- jt as ResourceManagementPanel
924
- };