react-semaphor 0.1.209 → 0.1.210

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 (41) hide show
  1. package/dist/chunks/dashboard-controls-BAOrAMV9.js +42 -0
  2. package/dist/chunks/{dashboard-controls-BNTI4r0_.js → dashboard-controls-C08300Wi.js} +504 -456
  3. package/dist/chunks/{dashboard-json-kIoBtmBF.js → dashboard-json-DlEE5-WA.js} +1 -1
  4. package/dist/chunks/{dashboard-json-BjOqpGbW.js → dashboard-json-GjDBGO26.js} +1 -1
  5. package/dist/chunks/{dashboard-summary-settings-dialog-BoX18wiA.js → dashboard-summary-settings-dialog-QUuhhXU9.js} +1 -1
  6. package/dist/chunks/{dashboard-summary-settings-dialog-CO1SwHHD.js → dashboard-summary-settings-dialog-THx-gjnG.js} +1 -1
  7. package/dist/chunks/{edit-dashboard-visual-DG4VLoJF.js → edit-dashboard-visual-Bsmow1Pa.js} +3422 -3536
  8. package/dist/chunks/edit-dashboard-visual-PfWJXb2-.js +164 -0
  9. package/dist/chunks/editor-action-buttons-DNbp_ZWy.js +404 -0
  10. package/dist/chunks/editor-action-buttons-FPyaC09X.js +21 -0
  11. package/dist/chunks/{index-D0TdW88i.js → index-CAVrkf9d.js} +2196 -2180
  12. package/dist/chunks/{index-DSA80lEg.js → index-CXKjmjfB.js} +67 -67
  13. package/dist/chunks/normalize-dashboard-for-dirty-check-D9x96J2F.js +1 -0
  14. package/dist/chunks/normalize-dashboard-for-dirty-check-XKgH3GFX.js +119 -0
  15. package/dist/chunks/notification-bell-BqvKQSw9.js +6 -0
  16. package/dist/chunks/notification-bell-C3a7wC1u.js +871 -0
  17. package/dist/chunks/{resource-management-panel-DS_WEv1x.js → resource-management-panel-BVTgbma8.js} +343 -332
  18. package/dist/chunks/resource-management-panel-C5NjrVsA.js +6 -0
  19. package/dist/chunks/{use-role-aware-display-preferences-DfihB5pN.js → use-role-aware-display-preferences-DxCPoCgr.js} +1 -1
  20. package/dist/chunks/{use-role-aware-display-preferences-D8j5_cnK.js → use-role-aware-display-preferences-l7NFLYnn.js} +1 -1
  21. package/dist/chunks/{use-visual-utils-CzcVz3zB.js → use-visual-utils-B82Q-Ytl.js} +1 -1
  22. package/dist/chunks/{use-visual-utils-BfLXO_vi.js → use-visual-utils-D9IJz9R0.js} +1 -1
  23. package/dist/dashboard/index.cjs +1 -1
  24. package/dist/dashboard/index.js +1 -1
  25. package/dist/index.cjs +1 -1
  26. package/dist/index.js +44 -40
  27. package/dist/shared/index.cjs +1 -0
  28. package/dist/shared/index.js +6 -0
  29. package/dist/style.css +1 -1
  30. package/dist/surfboard/index.cjs +1 -1
  31. package/dist/surfboard/index.js +2 -2
  32. package/dist/types/main.d.ts +39 -1
  33. package/dist/types/shared.d.ts +1762 -0
  34. package/package.json +6 -1
  35. package/dist/chunks/dashboard-controls-Dcpx9_an.js +0 -42
  36. package/dist/chunks/edit-dashboard-visual-B9HuGExj.js +0 -179
  37. package/dist/chunks/editor-action-buttons-CDTIx_Jc.js +0 -11
  38. package/dist/chunks/editor-action-buttons-CszdZ4Fw.js +0 -345
  39. package/dist/chunks/notification-bell-D2V1-ARa.js +0 -11
  40. package/dist/chunks/notification-bell-DFiRaeJQ.js +0 -862
  41. package/dist/chunks/resource-management-panel-BhiWNPcw.js +0 -6
@@ -0,0 +1,871 @@
1
+ import Z, { useState as D, useRef as M, useCallback as F, useEffect as L, useContext as ee } from "react";
2
+ import { bP as te, l as z, bC as T, aW as B, aH as K, aG as $, bB as Q, aI as ae, m as se, n as re, o as oe, p as ne, q as ie, L as _, cy as le, cE as ce, G as de, B as I, H, bA as O, bK as ue, u as U, bL as me, bs as J, cF as he, cG as j, I as R, bE as pe, c as k, c5 as fe, c6 as ge, a1 as ve, c8 as be, c9 as P, E as xe, cd as we, c4 as ye, by as Ce, cH as Ne, cI as Ae, cJ as De, cm as Ee, cn as Se, co as Le, cK as Ie, cp as Te, cq as ke, cr as Ue, cs as Fe, ct as Ve, am as Pe, a2 as Me, cL as Oe, cM as Re, aw as ze, X as Be, cN as $e, cO as He, cP as _e, al as G, a3 as je, bD as Ge, P as qe, s as Xe, cQ as We, t as Ke } from "./index-CAVrkf9d.js";
3
+ import { jsx as t, jsxs as n, Fragment as V } from "react/jsx-runtime";
4
+ import { V as Qe, E as Je, a as Ye, b as Ze, L as et, c as tt, d as at, C as st } from "./editor-action-buttons-DNbp_ZWy.js";
5
+ import { a as Y } from "./use-visual-utils-D9IJz9R0.js";
6
+ import { c as q } from "./date-formatter-Y8Za1ib3.js";
7
+ /**
8
+ * @license lucide-react v0.453.0 - ISC
9
+ *
10
+ * This source code is licensed under the ISC license.
11
+ * See the LICENSE file in the root directory of this source tree.
12
+ */
13
+ const X = te("FileDown", [
14
+ ["path", { d: "M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z", key: "1rqfz7" }],
15
+ ["path", { d: "M14 2v4a2 2 0 0 0 2 2h4", key: "tnqrlb" }],
16
+ ["path", { d: "M12 18v-6", key: "17g6i2" }],
17
+ ["path", { d: "m9 15 3 3 3-3", key: "1npd3o" }]
18
+ ]), rt = 1e4, ot = 15e3, nt = 3e4, it = 3e4, lt = 12e4, W = 2 * 60 * 60 * 1e3;
19
+ function ct(e) {
20
+ const a = Date.now() - e.getTime();
21
+ return a < it ? rt : a < lt ? ot : nt;
22
+ }
23
+ function yt() {
24
+ const { authToken: e, tokenProps: a } = z(), m = T((h) => h.activeExports), [l, u] = D(
25
+ typeof document < "u" ? !document.hidden : !0
26
+ ), c = M(null), i = M(!1), s = M(void 0), f = a == null ? void 0 : a.apiServiceUrl, d = e == null ? void 0 : e.accessToken, g = F(() => {
27
+ const h = T.getState().activeExports;
28
+ return Array.from(h.values()).filter(
29
+ (b) => B(b.status)
30
+ );
31
+ }, []);
32
+ L(() => {
33
+ if (typeof document > "u") return;
34
+ const h = () => {
35
+ u(!document.hidden);
36
+ };
37
+ return document.addEventListener("visibilitychange", h), () => {
38
+ document.removeEventListener("visibilitychange", h);
39
+ };
40
+ }, []);
41
+ const x = F(async () => {
42
+ if (!f || !d) {
43
+ i.current = !1;
44
+ return;
45
+ }
46
+ const h = g();
47
+ if (h.length === 0) {
48
+ i.current = !1;
49
+ return;
50
+ }
51
+ const b = Date.now(), N = h.filter(
52
+ (r) => b - r.startedAt.getTime() > W
53
+ );
54
+ if (N.length > 0) {
55
+ const { updateExport: r } = T.getState().actions;
56
+ for (const o of N)
57
+ r(o.id, {
58
+ status: "failed",
59
+ error: "Export timed out. Please try again or contact support.",
60
+ lastUpdatedAt: /* @__PURE__ */ new Date()
61
+ });
62
+ }
63
+ const p = h.filter(
64
+ (r) => b - r.startedAt.getTime() <= W
65
+ );
66
+ if (p.length === 0) {
67
+ i.current = !1;
68
+ return;
69
+ }
70
+ const y = await Promise.allSettled(
71
+ p.map(async (r) => {
72
+ try {
73
+ const o = await K(f, d, r.id);
74
+ let v;
75
+ if (o.status === "completed")
76
+ try {
77
+ v = await $(f, d, r.id);
78
+ } catch (E) {
79
+ console.error(
80
+ `[useExportPolling] Failed to get download URL for ${r.id}:`,
81
+ E
82
+ );
83
+ }
84
+ return {
85
+ id: r.id,
86
+ status: o.status,
87
+ progress: o.progress,
88
+ completedChunks: o.completedChunks,
89
+ completedAt: o.completedAt ? new Date(o.completedAt) : void 0,
90
+ lastUpdatedAt: /* @__PURE__ */ new Date(),
91
+ fileSize: o.fileSize,
92
+ error: o.error,
93
+ downloadUrl: v
94
+ };
95
+ } catch (o) {
96
+ return console.error(
97
+ `[useExportPolling] Failed to poll export ${r.id}:`,
98
+ o
99
+ ), null;
100
+ }
101
+ })
102
+ ), { updateExport: A } = T.getState().actions;
103
+ for (const r of y)
104
+ r.status === "fulfilled" && r.value && A(r.value.id, r.value);
105
+ const w = g();
106
+ if (w.length > 0 && !document.hidden) {
107
+ const r = w.reduce(
108
+ (v, E) => E.startedAt < v ? E.startedAt : v,
109
+ w[0].startedAt
110
+ ), o = ct(r);
111
+ c.current && clearTimeout(c.current), c.current = setTimeout(() => {
112
+ var v;
113
+ (v = s.current) == null || v.call(s);
114
+ }, o);
115
+ } else
116
+ i.current = !1;
117
+ }, [f, d, g]);
118
+ return L(() => {
119
+ s.current = x;
120
+ }, [x]), L(() => {
121
+ var b;
122
+ g().length > 0 && l && !i.current && (i.current = !0, (b = s.current) == null || b.call(s));
123
+ }, [m, l, g]), L(() => {
124
+ var b;
125
+ const h = g();
126
+ l && h.length > 0 && !i.current && (i.current = !0, (b = s.current) == null || b.call(s));
127
+ }, [l, g]), L(() => {
128
+ !l && c.current && (clearTimeout(c.current), c.current = null, i.current = !1);
129
+ }, [l]), L(() => () => {
130
+ c.current && (clearTimeout(c.current), c.current = null);
131
+ }, []), {
132
+ isPolling: i.current,
133
+ isTabVisible: l,
134
+ inProgressCount: g().length
135
+ };
136
+ }
137
+ function Ct() {
138
+ const { authToken: e, tokenProps: a } = z(), m = T((s) => s.activeExports), { addExport: l } = Q(), u = M(!1), c = a == null ? void 0 : a.apiServiceUrl, i = e == null ? void 0 : e.accessToken;
139
+ L(() => {
140
+ if (u.current || !c || !i) return;
141
+ (async () => {
142
+ try {
143
+ const { exports: f } = await ae(c, i, {
144
+ status: ["pending", "processing", "chunking", "compacting", "completed", "failed"],
145
+ limit: 20
146
+ // Limit to recent exports
147
+ });
148
+ for (const d of f) {
149
+ if (m.has(d.id)) continue;
150
+ const g = d.totalChunks ? Math.round(d.completedChunks / d.totalChunks * 100) : 0;
151
+ let x;
152
+ if (d.status === "completed")
153
+ try {
154
+ x = await $(c, i, d.id);
155
+ } catch (b) {
156
+ console.error(
157
+ `[useExportRecovery] Failed to get download URL for ${d.id}:`,
158
+ b
159
+ );
160
+ }
161
+ const h = {
162
+ id: d.id,
163
+ status: d.status,
164
+ progress: g,
165
+ title: dt(d),
166
+ totalRows: d.totalRows,
167
+ totalChunks: d.totalChunks,
168
+ completedChunks: d.completedChunks,
169
+ startedAt: new Date(d.createdAt),
170
+ lastUpdatedAt: /* @__PURE__ */ new Date(),
171
+ completedAt: d.completedAt ? new Date(d.completedAt) : void 0,
172
+ fileSize: d.fileSize,
173
+ error: d.error,
174
+ expiresAt: new Date(d.expiresAt),
175
+ downloadUrl: x
176
+ };
177
+ l(h);
178
+ }
179
+ u.current = !0;
180
+ } catch (f) {
181
+ console.error("[useExportRecovery] Failed to recover exports:", f), u.current = !0;
182
+ }
183
+ })();
184
+ }, [c, i, l, m]);
185
+ }
186
+ function dt(e) {
187
+ return e.title ? e.title : B(
188
+ e.status
189
+ ) ? "Export in progress..." : e.status === "completed" ? "Export completed" : e.status === "failed" ? "Export failed" : "Export";
190
+ }
191
+ function ut({
192
+ open: e,
193
+ onOpenChange: a,
194
+ isLibraryVisual: m,
195
+ currentVisualName: l,
196
+ isSaving: u = !1,
197
+ destinationMode: c = "both",
198
+ onConfirm: i
199
+ }) {
200
+ const [s, f] = D(
201
+ m && l ? `Copy of ${l}` : l || ""
202
+ ), [d, g] = D("");
203
+ Z.useEffect(() => {
204
+ e && (f(
205
+ m && l ? `Copy of ${l}` : l || ""
206
+ ), g(""));
207
+ }, [e, m, l]);
208
+ const x = !!s.trim(), h = c === "local" ? {
209
+ saveToLibrary: !1,
210
+ saveToCurrentDashboard: !0,
211
+ badgeType: "local",
212
+ description: "Creates a local copy on the current dashboard.",
213
+ actionLabel: "Add to Dashboard (Local)"
214
+ } : c === "library" ? {
215
+ saveToLibrary: !0,
216
+ saveToCurrentDashboard: !1,
217
+ badgeType: "library",
218
+ description: "Creates a reusable visual in Visual Library.",
219
+ actionLabel: "Save as Library Visual"
220
+ } : {
221
+ saveToLibrary: !0,
222
+ saveToCurrentDashboard: !0,
223
+ badgeType: "linked",
224
+ description: "Creates a new library visual and adds a linked copy to this dashboard.",
225
+ actionLabel: "Save Copy as Linked Visual"
226
+ }, b = () => {
227
+ !x || u || i({
228
+ name: s.trim(),
229
+ description: d.trim() || void 0,
230
+ saveToLibrary: h.saveToLibrary,
231
+ saveToCurrentDashboard: h.saveToCurrentDashboard
232
+ });
233
+ };
234
+ return /* @__PURE__ */ t(se, { open: e, onOpenChange: a, children: /* @__PURE__ */ n(re, { className: "sm:max-w-[500px]", children: [
235
+ /* @__PURE__ */ n(oe, { children: [
236
+ /* @__PURE__ */ n(ne, { className: "flex items-center gap-2", children: [
237
+ /* @__PURE__ */ t("span", { children: "Save Visual As" }),
238
+ h.badgeType !== "local" && /* @__PURE__ */ t(
239
+ Qe,
240
+ {
241
+ type: h.badgeType,
242
+ showLabel: !0,
243
+ className: "px-2 py-0.5"
244
+ }
245
+ )
246
+ ] }),
247
+ /* @__PURE__ */ t(ie, { children: h.description })
248
+ ] }),
249
+ /* @__PURE__ */ n("div", { className: "grid gap-4 py-4", children: [
250
+ /* @__PURE__ */ n("div", { className: "grid gap-2", children: [
251
+ /* @__PURE__ */ t(_, { htmlFor: "name", children: "Name" }),
252
+ /* @__PURE__ */ t(
253
+ le,
254
+ {
255
+ id: "name",
256
+ value: s,
257
+ onChange: (N) => f(N.target.value),
258
+ placeholder: "Enter visual name",
259
+ disabled: u
260
+ }
261
+ )
262
+ ] }),
263
+ /* @__PURE__ */ n("div", { className: "grid gap-2", children: [
264
+ /* @__PURE__ */ t(_, { htmlFor: "description", children: "Description (optional)" }),
265
+ /* @__PURE__ */ t(
266
+ ce,
267
+ {
268
+ id: "description",
269
+ value: d,
270
+ onChange: (N) => g(N.target.value),
271
+ placeholder: "Enter visual description",
272
+ rows: 3,
273
+ disabled: u
274
+ }
275
+ )
276
+ ] })
277
+ ] }),
278
+ /* @__PURE__ */ n(de, { children: [
279
+ /* @__PURE__ */ t(
280
+ I,
281
+ {
282
+ variant: "outline",
283
+ onClick: () => a(!1),
284
+ disabled: u,
285
+ children: "Cancel"
286
+ }
287
+ ),
288
+ /* @__PURE__ */ n(I, { onClick: b, disabled: !x || u, children: [
289
+ u && /* @__PURE__ */ t(H, { className: "mr-2 h-4 w-4 animate-spin" }),
290
+ h.actionLabel
291
+ ] })
292
+ ] })
293
+ ] }) });
294
+ }
295
+ function mt() {
296
+ const [e, a] = D(!1), [m, l] = D(!1), [u, c] = D(null), i = O((o) => o.frame), s = O((o) => o.card), f = ue(), d = U((o) => o.selectedSheetId), g = U(
297
+ (o) => o.actions.setIsDashboardPanelOpen
298
+ ), { getUpdatedFrame: x } = Y(), { selectVisual: h } = me(), { addFrame: b, setSelectedFrameId: N, setIsVisualEditing: p } = J(), y = !!(i != null && i.visualId), A = (() => {
299
+ var o, v;
300
+ return ((o = i == null ? void 0 : i.cards) == null ? void 0 : o.length) === 1 && ((v = i.cards[0]) != null && v.title) ? i.cards[0].title : f != null && f.title ? f.title : (s == null ? void 0 : s.title) || "Untitled Visual";
301
+ })(), w = he((o) => {
302
+ if (o != null && o.id) {
303
+ if (h(o), m && u && d) {
304
+ const v = {
305
+ ...u,
306
+ id: j(),
307
+ visualId: o.id
308
+ // Link to the newly created library visual
309
+ };
310
+ b(d, v, "end"), N(v.id), l(!1), c(null), p(!1);
311
+ }
312
+ g(!0), a(!1);
313
+ }
314
+ });
315
+ return {
316
+ saveAsDialogOpen: e,
317
+ setSaveAsDialogOpen: a,
318
+ handleSaveAs: async (o) => {
319
+ if (!d) {
320
+ R.error("No sheet selected");
321
+ return;
322
+ }
323
+ const v = x(), C = v.cards.length === 1 ? {
324
+ ...v,
325
+ cards: v.cards.map((S) => ({
326
+ ...S,
327
+ title: o.name
328
+ // Use visual name as card title
329
+ }))
330
+ } : v;
331
+ if (o.saveToLibrary) {
332
+ l(o.saveToCurrentDashboard), c(C);
333
+ const S = {
334
+ title: o.name,
335
+ description: o.description,
336
+ frameObject: C,
337
+ // Card title synced for single-card frames
338
+ isPrivate: !1
339
+ };
340
+ w.mutate(S);
341
+ } else if (o.saveToCurrentDashboard) {
342
+ const S = {
343
+ ...C,
344
+ // Card title already synced
345
+ id: j(),
346
+ visualId: void 0
347
+ // Explicitly no visualId for local visuals
348
+ };
349
+ b(d, S, "end"), N(S.id), R.success("Visual saved to dashboard"), a(!1), p(!1);
350
+ }
351
+ },
352
+ isLibraryVisual: y,
353
+ currentVisualName: A,
354
+ isSaving: w.isPending
355
+ };
356
+ }
357
+ function Nt({
358
+ className: e
359
+ }) {
360
+ const a = O((C) => C.frame), m = pe((C) => C.selectedVisual), l = U((C) => C.selectedFrameId), u = U((C) => C.selectedSheetId), { setIsVisualEditing: c, updateFrame: i } = J(), [s, f] = D(!1), [d, g] = D("both"), x = !!(a != null && a.visualId || m != null && m.id), h = !!(a != null && a.visualId && l), b = x && !h, {
361
+ saveAsDialogOpen: N,
362
+ setSaveAsDialogOpen: p,
363
+ handleSaveAs: y,
364
+ isLibraryVisual: A,
365
+ currentVisualName: w,
366
+ isSaving: r
367
+ } = mt(), { getUpdatedFrame: o } = Y(), v = () => {
368
+ if (!u) {
369
+ R.error("No sheet selected");
370
+ return;
371
+ }
372
+ if (s) return;
373
+ f(!0);
374
+ const S = {
375
+ ...o(),
376
+ visualId: void 0
377
+ };
378
+ i(u, S), setTimeout(() => {
379
+ f(!1), R.success("Changes applied. Visual is now local to this dashboard"), c(!1);
380
+ }, 300);
381
+ }, E = (C) => {
382
+ g(C), p(!0);
383
+ };
384
+ return /* @__PURE__ */ n(V, { children: [
385
+ /* @__PURE__ */ n("div", { className: "inline-flex items-center overflow-hidden rounded-md border border-input", children: [
386
+ !x && /* @__PURE__ */ t(
387
+ Je,
388
+ {
389
+ className: k(e, "rounded-none border-0"),
390
+ variant: "default"
391
+ }
392
+ ),
393
+ x && b && /* @__PURE__ */ t(
394
+ Ye,
395
+ {
396
+ className: k(e, "rounded-none border-0"),
397
+ variant: "default"
398
+ }
399
+ ),
400
+ x && h && /* @__PURE__ */ t(
401
+ Ze,
402
+ {
403
+ className: k(e, "rounded-none border-0")
404
+ }
405
+ ),
406
+ /* @__PURE__ */ n(fe, { modal: !1, children: [
407
+ /* @__PURE__ */ t(ge, { className: "h-8", asChild: !0, children: /* @__PURE__ */ t(
408
+ I,
409
+ {
410
+ variant: "default",
411
+ size: "sm",
412
+ className: k(
413
+ e,
414
+ "w-8 rounded-none border-0 border-l border-primary-foreground/30 px-2"
415
+ ),
416
+ "aria-label": "Open visual save options",
417
+ disabled: r || s,
418
+ children: /* @__PURE__ */ t(ve, { className: "h-4 w-4" })
419
+ }
420
+ ) }),
421
+ /* @__PURE__ */ n(be, { align: "end", children: [
422
+ h && /* @__PURE__ */ n(V, { children: [
423
+ /* @__PURE__ */ n(
424
+ P,
425
+ {
426
+ onClick: v,
427
+ disabled: s,
428
+ children: [
429
+ /* @__PURE__ */ t(xe, { className: "mr-2 h-4 w-4" }),
430
+ s ? "Applying..." : "Apply Locally"
431
+ ]
432
+ }
433
+ ),
434
+ /* @__PURE__ */ t(we, {})
435
+ ] }),
436
+ /* @__PURE__ */ n(
437
+ P,
438
+ {
439
+ onClick: () => E("local"),
440
+ disabled: r,
441
+ children: [
442
+ /* @__PURE__ */ t(ye, { className: "mr-2 h-4 w-4" }),
443
+ "Add to Dashboard (Local)"
444
+ ]
445
+ }
446
+ ),
447
+ /* @__PURE__ */ n(
448
+ P,
449
+ {
450
+ onClick: () => E("library"),
451
+ disabled: r,
452
+ children: [
453
+ /* @__PURE__ */ t(et, { className: "mr-2 h-4 w-4" }),
454
+ "Save as Library Visual"
455
+ ]
456
+ }
457
+ ),
458
+ /* @__PURE__ */ n(
459
+ P,
460
+ {
461
+ onClick: () => E("both"),
462
+ disabled: r,
463
+ children: [
464
+ /* @__PURE__ */ t(tt, { className: "mr-2 h-4 w-4" }),
465
+ "Save Copy as Linked Visual"
466
+ ]
467
+ }
468
+ )
469
+ ] })
470
+ ] })
471
+ ] }),
472
+ /* @__PURE__ */ t(at, { className: e }),
473
+ /* @__PURE__ */ t(
474
+ ut,
475
+ {
476
+ open: N,
477
+ onOpenChange: (C) => {
478
+ r || p(C);
479
+ },
480
+ isLibraryVisual: A,
481
+ currentVisualName: w,
482
+ isSaving: r,
483
+ destinationMode: d,
484
+ onConfirm: y
485
+ }
486
+ )
487
+ ] });
488
+ }
489
+ function At({
490
+ className: e,
491
+ //labelClassName,
492
+ switchClassName: a
493
+ }) {
494
+ const m = O((s) => s.isDevMode), l = U((s) => s.isVisualEditing), { setIsDevMode: u } = Ce(), { config: c } = ee(Ne).tokenProps, i = (c == null ? void 0 : c.showAdvancedMode) !== !1;
495
+ return !l || !i ? null : /* @__PURE__ */ n("div", { className: k("flex items-center space-x-2", e), children: [
496
+ /* @__PURE__ */ t(
497
+ Ae,
498
+ {
499
+ className: k("", a),
500
+ checked: m,
501
+ onCheckedChange: () => u(!m),
502
+ id: "advanced-mode",
503
+ icon: /* @__PURE__ */ t(De, { className: "h-4 w-4" }),
504
+ tooltip: "Advanced Mode"
505
+ }
506
+ ),
507
+ /* @__PURE__ */ t("label", { htmlFor: "advanced-mode", className: "sr-only", children: "Advanced Mode" })
508
+ ] });
509
+ }
510
+ function Dt({
511
+ open: e,
512
+ onOpenChange: a,
513
+ onSave: m,
514
+ onDiscard: l,
515
+ isSaving: u,
516
+ title: c = "Unsaved Changes",
517
+ description: i = "You have unsaved changes to this dashboard. What would you like to do?",
518
+ cancelLabel: s = "Cancel",
519
+ discardLabel: f = "Discard",
520
+ saveLabel: d = "Save & Close"
521
+ }) {
522
+ return /* @__PURE__ */ t(Ee, { open: e, onOpenChange: (x) => {
523
+ !x && u || a(x);
524
+ }, children: /* @__PURE__ */ n(Se, { className: "max-w-[520px] border-border/70 p-6", children: [
525
+ /* @__PURE__ */ n(Le, { className: "space-y-3", children: [
526
+ /* @__PURE__ */ n("div", { className: "flex items-center gap-3", children: [
527
+ /* @__PURE__ */ t("div", { className: "flex h-9 w-9 items-center justify-center rounded-full bg-amber-50 ring-1 ring-amber-200/70", children: /* @__PURE__ */ t(Ie, { className: "h-[18px] w-[18px] text-amber-600" }) }),
528
+ /* @__PURE__ */ t(Te, { className: "text-lg font-semibold tracking-tight", children: c })
529
+ ] }),
530
+ /* @__PURE__ */ t(ke, { className: "text-sm leading-6 text-muted-foreground", children: i })
531
+ ] }),
532
+ /* @__PURE__ */ n(Ue, { className: "mt-2 flex-col gap-1.5 sm:flex-row sm:justify-end", children: [
533
+ /* @__PURE__ */ t(
534
+ Fe,
535
+ {
536
+ disabled: u,
537
+ className: "order-1 m-0 h-9 border-border/60 px-4 sm:order-1",
538
+ children: s
539
+ }
540
+ ),
541
+ /* @__PURE__ */ t(
542
+ "button",
543
+ {
544
+ onClick: l,
545
+ disabled: u,
546
+ className: "order-2 h-9 rounded-md border border-destructive/30 bg-destructive/10 px-4 text-sm font-medium text-destructive transition-colors hover:bg-destructive/20 disabled:pointer-events-none disabled:opacity-50 sm:order-2",
547
+ children: f
548
+ }
549
+ ),
550
+ /* @__PURE__ */ t(
551
+ Ve,
552
+ {
553
+ onClick: m,
554
+ disabled: u,
555
+ className: "order-3 m-0 h-9 px-4 sm:order-3",
556
+ children: u ? /* @__PURE__ */ n(V, { children: [
557
+ /* @__PURE__ */ t(H, { className: "mr-2 h-4 w-4 animate-spin" }),
558
+ "Saving..."
559
+ ] }) : d
560
+ }
561
+ )
562
+ ] })
563
+ ] }) });
564
+ }
565
+ function Et(e, a, m, l) {
566
+ L(() => {
567
+ e && !m && a && l(Pe(a));
568
+ }, [e, m, a, l]);
569
+ }
570
+ function St({
571
+ triggerButtonClassName: e,
572
+ variant: a = "ghost"
573
+ }) {
574
+ const [m, l] = D(!1), u = U((i) => {
575
+ var s;
576
+ return (s = i.dashboard) == null ? void 0 : s.id;
577
+ }), c = U((i) => {
578
+ var s;
579
+ return (s = i.dashboard) == null ? void 0 : s.title;
580
+ });
581
+ return u ? /* @__PURE__ */ n(V, { children: [
582
+ /* @__PURE__ */ t(
583
+ Me,
584
+ {
585
+ tooltip: "Schedule Dashboard",
586
+ className: k("h-7 p-2", e),
587
+ buttonProps: { variant: a },
588
+ onClick: () => l(!0),
589
+ children: /* @__PURE__ */ t(Oe, { className: "size-4" })
590
+ }
591
+ ),
592
+ /* @__PURE__ */ t(
593
+ Re,
594
+ {
595
+ open: m,
596
+ onOpenChange: l,
597
+ dashboardId: u,
598
+ dashboardName: c
599
+ }
600
+ )
601
+ ] }) : null;
602
+ }
603
+ function ht({
604
+ export: e,
605
+ onRemove: a
606
+ }) {
607
+ const m = () => {
608
+ e.downloadUrl && window.open(e.downloadUrl, "_blank");
609
+ }, l = (s) => {
610
+ s.stopPropagation(), a == null || a(e.id);
611
+ }, u = () => {
612
+ switch (e.status) {
613
+ case "completed":
614
+ return /* @__PURE__ */ t(_e, { className: "mt-0.5 h-5 w-5 shrink-0 text-green-600" });
615
+ case "failed":
616
+ return /* @__PURE__ */ t(st, { className: "mt-0.5 h-5 w-5 shrink-0 text-destructive" });
617
+ default:
618
+ return /* @__PURE__ */ t(H, { className: "text-foreground-muted mt-0.5 h-5 w-5 shrink-0 animate-spin" });
619
+ }
620
+ }, c = B(e.status), i = (() => {
621
+ switch (e.status) {
622
+ case "pending":
623
+ return "Queued...";
624
+ case "processing":
625
+ return "Processing...";
626
+ case "chunking":
627
+ return "Processing...";
628
+ case "compacting":
629
+ return "Finalizing...";
630
+ default:
631
+ return "Processing...";
632
+ }
633
+ })();
634
+ return /* @__PURE__ */ n("div", { className: "group p-4 transition-colors hover:bg-muted/50", children: [
635
+ /* @__PURE__ */ n("div", { className: "mb-2 flex items-start justify-between gap-3", children: [
636
+ /* @__PURE__ */ n("div", { className: "flex min-w-0 flex-1 items-start gap-3", children: [
637
+ u(),
638
+ /* @__PURE__ */ n("div", { className: "min-w-0 flex-1", children: [
639
+ /* @__PURE__ */ t("h4", { className: "mb-1 truncate text-sm font-medium", children: e.title }),
640
+ e.status === "completed" && /* @__PURE__ */ n("div", { className: "flex items-center gap-2 text-xs text-muted-foreground", children: [
641
+ /* @__PURE__ */ n("span", { children: [
642
+ e.totalRows.toLocaleString(),
643
+ " rows"
644
+ ] }),
645
+ e.fileSize && /* @__PURE__ */ n(V, { children: [
646
+ /* @__PURE__ */ t("span", { children: "•" }),
647
+ /* @__PURE__ */ t("span", { children: ze(e.fileSize) })
648
+ ] })
649
+ ] }),
650
+ c && /* @__PURE__ */ t("div", { className: "text-xs text-muted-foreground", children: i }),
651
+ e.status === "failed" && /* @__PURE__ */ t("div", { className: "line-clamp-2 text-xs text-destructive", children: e.error || "Export failed" })
652
+ ] })
653
+ ] }),
654
+ /* @__PURE__ */ t(
655
+ I,
656
+ {
657
+ variant: "ghost",
658
+ size: "icon",
659
+ className: "h-6 w-6 shrink-0 opacity-0 transition-opacity group-hover:opacity-100",
660
+ onClick: l,
661
+ "aria-label": "Remove notification",
662
+ children: /* @__PURE__ */ t(Be, { className: "h-4 w-4" })
663
+ }
664
+ )
665
+ ] }),
666
+ /* @__PURE__ */ n("div", { className: "ml-8", children: [
667
+ e.status === "completed" && /* @__PURE__ */ n("div", { className: "flex items-center justify-between", children: [
668
+ /* @__PURE__ */ t("span", { className: "text-xs text-muted-foreground", children: q(e.startedAt, { addSuffix: !0 }) }),
669
+ e.downloadUrl && /* @__PURE__ */ n(
670
+ I,
671
+ {
672
+ size: "sm",
673
+ variant: "outline",
674
+ className: "h-8 bg-transparent",
675
+ onClick: m,
676
+ children: [
677
+ /* @__PURE__ */ t($e, { className: "mr-1.5 h-3.5 w-3.5" }),
678
+ "Download"
679
+ ]
680
+ }
681
+ )
682
+ ] }),
683
+ c && /* @__PURE__ */ n("div", { children: [
684
+ /* @__PURE__ */ t(He, { value: e.progress, className: "h-1.5" }),
685
+ /* @__PURE__ */ n("span", { className: "mt-1 block text-xs text-muted-foreground", children: [
686
+ e.progress,
687
+ "% complete"
688
+ ] })
689
+ ] }),
690
+ e.status === "failed" && /* @__PURE__ */ t("span", { className: "text-xs text-muted-foreground", children: q(e.startedAt, { addSuffix: !0 }) })
691
+ ] })
692
+ ] });
693
+ }
694
+ function pt() {
695
+ const { authToken: e, tokenProps: a } = z(), m = T((p) => p.activeExports), { clearCompleted: l, removeExport: u, updateExport: c } = Q(), [i, s] = D(!1), [f, d] = D(!1), g = Array.from(m.values()).sort(
696
+ (p, y) => y.startedAt.getTime() - p.startedAt.getTime()
697
+ ), x = g.some(
698
+ (p) => p.status === "completed" || p.status === "failed"
699
+ ), h = F(async () => {
700
+ const p = a == null ? void 0 : a.apiServiceUrl, y = e == null ? void 0 : e.accessToken;
701
+ if (!(!p || !y)) {
702
+ s(!0);
703
+ try {
704
+ const A = Array.from(m.values());
705
+ await Promise.all(
706
+ A.map(async (w) => {
707
+ try {
708
+ const r = await K(p, y, w.id);
709
+ let o;
710
+ if (r.status === "completed")
711
+ try {
712
+ o = await $(
713
+ p,
714
+ y,
715
+ w.id
716
+ );
717
+ } catch (v) {
718
+ console.error(`Failed to get download URL for ${w.id}:`, v);
719
+ }
720
+ c(w.id, {
721
+ status: r.status,
722
+ progress: r.progress,
723
+ completedChunks: r.completedChunks,
724
+ completedAt: r.completedAt ? new Date(r.completedAt) : void 0,
725
+ lastUpdatedAt: /* @__PURE__ */ new Date(),
726
+ fileSize: r.fileSize,
727
+ error: r.error,
728
+ downloadUrl: o
729
+ });
730
+ } catch (r) {
731
+ console.error(`Failed to refresh export ${w.id}:`, r);
732
+ }
733
+ })
734
+ );
735
+ } finally {
736
+ s(!1);
737
+ }
738
+ }
739
+ }, [
740
+ m,
741
+ e == null ? void 0 : e.accessToken,
742
+ a == null ? void 0 : a.apiServiceUrl,
743
+ c
744
+ ]), b = F(async () => {
745
+ const p = a == null ? void 0 : a.apiServiceUrl, y = e == null ? void 0 : e.accessToken;
746
+ if (!p || !y) {
747
+ l();
748
+ return;
749
+ }
750
+ d(!0);
751
+ try {
752
+ const A = g.filter(
753
+ (r) => r.status === "completed" || r.status === "failed"
754
+ ), w = await Promise.allSettled(
755
+ A.map(async (r) => (await G(p, y, r.id), r.id))
756
+ );
757
+ for (const r of w)
758
+ r.status === "fulfilled" ? u(r.value) : console.error("Failed to delete export:", r.reason);
759
+ } finally {
760
+ d(!1);
761
+ }
762
+ }, [
763
+ g,
764
+ a == null ? void 0 : a.apiServiceUrl,
765
+ e == null ? void 0 : e.accessToken,
766
+ l,
767
+ u
768
+ ]), N = F(
769
+ async (p) => {
770
+ const y = a == null ? void 0 : a.apiServiceUrl, A = e == null ? void 0 : e.accessToken;
771
+ if (y && A)
772
+ try {
773
+ await G(y, A, p), u(p);
774
+ return;
775
+ } catch (w) {
776
+ console.error(`Failed to cancel export ${p}:`, w);
777
+ }
778
+ u(p);
779
+ },
780
+ [a == null ? void 0 : a.apiServiceUrl, e == null ? void 0 : e.accessToken, u]
781
+ );
782
+ return g.length === 0 ? /* @__PURE__ */ n("div", { className: "p-6 text-center", children: [
783
+ /* @__PURE__ */ t(X, { className: "mx-auto mb-2 h-8 w-8 text-muted-foreground" }),
784
+ /* @__PURE__ */ t("p", { className: "text-sm text-muted-foreground", children: "No active exports" }),
785
+ /* @__PURE__ */ t("p", { className: "mt-1 text-xs text-muted-foreground", children: "Large exports will appear here" })
786
+ ] }) : /* @__PURE__ */ n("div", { className: "flex flex-col", children: [
787
+ /* @__PURE__ */ n("div", { className: "flex items-center justify-between border-b px-4 py-3", children: [
788
+ /* @__PURE__ */ n("div", { className: "flex items-center gap-2", children: [
789
+ /* @__PURE__ */ t(X, { className: "h-5 w-5 text-muted-foreground" }),
790
+ /* @__PURE__ */ t("h4", { className: "font-semibold", children: "Exports" })
791
+ ] }),
792
+ /* @__PURE__ */ n("div", { className: "flex items-center gap-1", children: [
793
+ /* @__PURE__ */ t(
794
+ I,
795
+ {
796
+ variant: "ghost",
797
+ size: "sm",
798
+ className: "h-7 w-7 p-0",
799
+ onClick: h,
800
+ disabled: i,
801
+ title: "Refresh status",
802
+ children: /* @__PURE__ */ t(
803
+ je,
804
+ {
805
+ className: `h-4 w-4 ${i ? "animate-spin" : ""}`
806
+ }
807
+ )
808
+ }
809
+ ),
810
+ x && /* @__PURE__ */ t(
811
+ I,
812
+ {
813
+ variant: "ghost",
814
+ size: "sm",
815
+ className: "h-7 px-2 text-sm",
816
+ onClick: b,
817
+ disabled: f,
818
+ children: f ? "Clearing..." : "Clear all"
819
+ }
820
+ )
821
+ ] })
822
+ ] }),
823
+ /* @__PURE__ */ t("div", { className: "max-h-[350px] overflow-y-auto", children: /* @__PURE__ */ t("div", { className: "divide-y", children: g.map((p) => /* @__PURE__ */ t(
824
+ ht,
825
+ {
826
+ export: p,
827
+ onRemove: N
828
+ },
829
+ p.id
830
+ )) }) })
831
+ ] });
832
+ }
833
+ function Lt() {
834
+ const e = T((s) => s.activeExports), a = Ge(), m = e.size > 0, l = Array.from(e.values()).some(
835
+ (s) => s.status === "completed" || s.status === "failed"
836
+ ), c = a > 0 ? a > 9 ? "9+" : String(a) : null;
837
+ return /* @__PURE__ */ n(qe, { children: [
838
+ /* @__PURE__ */ t(Xe, { asChild: !0, children: /* @__PURE__ */ n(
839
+ I,
840
+ {
841
+ variant: "ghost",
842
+ size: "icon",
843
+ className: "relative h-8 w-8",
844
+ "aria-label": "Export notifications",
845
+ children: [
846
+ /* @__PURE__ */ t(We, { className: "h-4 w-4" }),
847
+ m && /* @__PURE__ */ t(
848
+ "span",
849
+ {
850
+ className: `absolute flex items-center justify-center rounded-full bg-primary text-primary-foreground ${c ? "-right-0.5 -top-0.5 h-4 min-w-4 px-0.5 text-[10px] font-semibold" : "right-0.5 top-0.5 h-2 w-2"}`,
851
+ children: c
852
+ }
853
+ )
854
+ ]
855
+ }
856
+ ) }),
857
+ /* @__PURE__ */ t(Ke, { className: "w-80 p-0", align: "end", sideOffset: 8, children: /* @__PURE__ */ t(pt, {}) })
858
+ ] });
859
+ }
860
+ export {
861
+ At as A,
862
+ ht as E,
863
+ Lt as N,
864
+ St as S,
865
+ Dt as U,
866
+ Nt as V,
867
+ pt as a,
868
+ Ct as b,
869
+ Et as c,
870
+ yt as u
871
+ };