react-semaphor 0.1.284 → 0.1.286

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