react-semaphor 0.1.293 → 0.1.294

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 (40) hide show
  1. package/dist/chunks/{braces-C7GP95Fp.js → braces-DR-GdaLC.js} +1 -1
  2. package/dist/chunks/{braces-BwW2HFlB.js → braces-DfDQiR3J.js} +1 -1
  3. package/dist/chunks/{dashboard-controls-jrkoCSY_.js → dashboard-controls-C3Z9bpYE.js} +504 -472
  4. package/dist/chunks/{dashboard-controls-DgUc38Tn.js → dashboard-controls-DGEVXgP5.js} +9 -9
  5. package/dist/chunks/dashboard-filter-controls-button-BIYT1ucX.js +11 -0
  6. package/dist/chunks/dashboard-filter-controls-button-DxgGUl00.js +1152 -0
  7. package/dist/chunks/{dashboard-json-COjT-zjQ.js → dashboard-json-BvTeHePu.js} +1 -1
  8. package/dist/chunks/{dashboard-json-C0NiRL-A.js → dashboard-json-DQW8TN0I.js} +1 -1
  9. package/dist/chunks/{dashboard-summary-settings-dialog-CXqaN_zj.js → dashboard-summary-settings-dialog-BsmKiGud.js} +1 -1
  10. package/dist/chunks/{dashboard-summary-settings-dialog-CGuFl7Xe.js → dashboard-summary-settings-dialog-q7fx3YAK.js} +1 -1
  11. package/dist/chunks/edit-dashboard-visual-ChKj-Lzr.js +183 -0
  12. package/dist/chunks/{edit-dashboard-visual-ppdXk86H.js → edit-dashboard-visual-RVl9nbDZ.js} +2175 -2160
  13. package/dist/chunks/index-BlspGR07.js +1435 -0
  14. package/dist/chunks/{index-9z-jMqN8.js → index-DerPpfv0.js} +32720 -31308
  15. package/dist/chunks/{resource-management-panel-CP8cegZP.js → resource-management-panel-DnZ1rw1A.js} +64 -64
  16. package/dist/chunks/{resource-management-panel-os6AuEKT.js → resource-management-panel-epydPwyM.js} +1 -1
  17. package/dist/chunks/use-create-flow-overlay-state-Bcg4EgoD.js +21 -0
  18. package/dist/chunks/{use-create-flow-overlay-state-wpuqRZX5.js → use-create-flow-overlay-state-C5vdfXhM.js} +430 -425
  19. package/dist/chunks/use-visual-utils-D9Kknvjl.js +337 -0
  20. package/dist/chunks/use-visual-utils-Dw_yw9zU.js +1 -0
  21. package/dist/dashboard/index.cjs +1 -1
  22. package/dist/dashboard/index.js +1 -1
  23. package/dist/index.cjs +1 -1
  24. package/dist/index.js +258 -253
  25. package/dist/style.css +1 -1
  26. package/dist/surfboard/index.cjs +1 -1
  27. package/dist/surfboard/index.js +2 -2
  28. package/dist/types/dashboard.d.ts +28 -0
  29. package/dist/types/main.d.ts +42 -4
  30. package/dist/types/shared.d.ts +3 -0
  31. package/dist/types/surfboard.d.ts +28 -0
  32. package/dist/types/types.d.ts +28 -0
  33. package/package.json +1 -1
  34. package/dist/chunks/dashboard-filter-controls-button-B19UWmsK.js +0 -11
  35. package/dist/chunks/dashboard-filter-controls-button-DGH4DxJ8.js +0 -1109
  36. package/dist/chunks/edit-dashboard-visual-CDOz4LWO.js +0 -183
  37. package/dist/chunks/index-K25f5Rqr.js +0 -1435
  38. package/dist/chunks/use-create-flow-overlay-state-CecnMS_v.js +0 -21
  39. package/dist/chunks/use-visual-utils-BTfG-ppd.js +0 -1
  40. package/dist/chunks/use-visual-utils-BhRKGJql.js +0 -334
@@ -1,1109 +0,0 @@
1
- import ge, { useState as L, useRef as O, useCallback as M, useEffect as T, useContext as be } from "react";
2
- import { c as ee, d as _, aD as k, bK as $, bG as te, bH as H, aE as ae, bF as xe, e as se, f as re, g as oe, h as ne, i as ie, L as K, I as Ce, d8 as we, w as ye, B as S, x as j, V as R, K as Ne, u as z, M as De, O as X, d9 as Ae, da as W, y as P, b_ as le, ag as Se, cC as de, cD as ce, a7 as ue, cF as he, cG as U, t as Ee, cK as Ie, ct as Le, N as Te, db as Fe, b as V, dc as G, dd as ke, cS as Ue, cT as Ve, cU as Me, cV as Pe, cW as ze, cX as Be, cY as Oe, at as Re, bM as _e, X as $e, de as He, df as je, cz as Xe, bI as q, a9 as Ge, aG as Ke, P as me, k as pe, dg as We, m as fe, dh as qe, di as Qe, dj as Ye, dk as Ze, dl as Je, dm as Q, dn as et } from "./index-9z-jMqN8.js";
3
- import { jsx as t, jsxs as s, Fragment as B } from "react/jsx-runtime";
4
- import { V as tt, E as at, a as st, b as rt, L as ot, c as nt, d as it, C as lt, u as dt, e as ct } from "./use-create-flow-overlay-state-wpuqRZX5.js";
5
- import { u as ve } from "./use-visual-utils-BhRKGJql.js";
6
- import { k as Y } from "./date-formatter-vkCj9Ct-.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 Z = ee("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
- ]);
19
- /**
20
- * @license lucide-react v0.453.0 - ISC
21
- *
22
- * This source code is licensed under the ISC license.
23
- * See the LICENSE file in the root directory of this source tree.
24
- */
25
- const ut = ee("FilterX", [
26
- ["path", { d: "M13.013 3H2l8 9.46V19l4 2v-8.54l.9-1.055", key: "1fi1da" }],
27
- ["path", { d: "m22 3-5 5", key: "12jva0" }],
28
- ["path", { d: "m17 3 5 5", key: "k36vhe" }]
29
- ]), ht = 1e4, mt = 15e3, pt = 3e4, ft = 3e4, vt = 12e4, J = 2 * 60 * 60 * 1e3;
30
- function gt(e) {
31
- const a = Date.now() - e.getTime();
32
- return a < ft ? ht : a < vt ? mt : pt;
33
- }
34
- function Tt() {
35
- const { authToken: e, tokenProps: a } = _(), p = k((m) => m.activeExports), [d, l] = L(
36
- typeof document < "u" ? !document.hidden : !0
37
- ), h = O(null), o = O(!1), c = O(void 0), u = a == null ? void 0 : a.apiServiceUrl, n = e == null ? void 0 : e.accessToken, v = M(() => {
38
- const m = k.getState().activeExports;
39
- return Array.from(m.values()).filter(
40
- (x) => $(x.status)
41
- );
42
- }, []);
43
- T(() => {
44
- if (typeof document > "u") return;
45
- const m = () => {
46
- l(!document.hidden);
47
- };
48
- return document.addEventListener("visibilitychange", m), () => {
49
- document.removeEventListener("visibilitychange", m);
50
- };
51
- }, []);
52
- const b = M(async () => {
53
- if (!u || !n) {
54
- o.current = !1;
55
- return;
56
- }
57
- const m = v();
58
- if (m.length === 0) {
59
- o.current = !1;
60
- return;
61
- }
62
- const x = Date.now(), N = m.filter(
63
- (r) => x - r.startedAt.getTime() > J
64
- );
65
- if (N.length > 0) {
66
- const { updateExport: r } = k.getState().actions;
67
- for (const i of N)
68
- r(i.id, {
69
- status: "failed",
70
- error: "Export timed out. Please try again or contact support.",
71
- lastUpdatedAt: /* @__PURE__ */ new Date()
72
- });
73
- }
74
- const f = m.filter(
75
- (r) => x - r.startedAt.getTime() <= J
76
- );
77
- if (f.length === 0) {
78
- o.current = !1;
79
- return;
80
- }
81
- const w = await Promise.allSettled(
82
- f.map(async (r) => {
83
- try {
84
- const i = await te(u, n, r.id);
85
- let g;
86
- if (i.status === "completed")
87
- try {
88
- g = await H(u, n, r.id);
89
- } catch (I) {
90
- console.error(
91
- `[useExportPolling] Failed to get download URL for ${r.id}:`,
92
- I
93
- );
94
- }
95
- return {
96
- id: r.id,
97
- status: i.status,
98
- progress: i.progress,
99
- completedChunks: i.completedChunks,
100
- completedAt: i.completedAt ? new Date(i.completedAt) : void 0,
101
- lastUpdatedAt: /* @__PURE__ */ new Date(),
102
- fileSize: i.fileSize,
103
- error: i.error,
104
- downloadUrl: g
105
- };
106
- } catch (i) {
107
- return console.error(
108
- `[useExportPolling] Failed to poll export ${r.id}:`,
109
- i
110
- ), null;
111
- }
112
- })
113
- ), { updateExport: E } = k.getState().actions;
114
- for (const r of w)
115
- r.status === "fulfilled" && r.value && E(r.value.id, r.value);
116
- const C = v();
117
- if (C.length > 0 && !document.hidden) {
118
- const r = C.reduce(
119
- (g, I) => I.startedAt < g ? I.startedAt : g,
120
- C[0].startedAt
121
- ), i = gt(r);
122
- h.current && clearTimeout(h.current), h.current = setTimeout(() => {
123
- var g;
124
- (g = c.current) == null || g.call(c);
125
- }, i);
126
- } else
127
- o.current = !1;
128
- }, [u, n, v]);
129
- return T(() => {
130
- c.current = b;
131
- }, [b]), T(() => {
132
- var x;
133
- v().length > 0 && d && !o.current && (o.current = !0, (x = c.current) == null || x.call(c));
134
- }, [p, d, v]), T(() => {
135
- var x;
136
- const m = v();
137
- d && m.length > 0 && !o.current && (o.current = !0, (x = c.current) == null || x.call(c));
138
- }, [d, v]), T(() => {
139
- !d && h.current && (clearTimeout(h.current), h.current = null, o.current = !1);
140
- }, [d]), T(() => () => {
141
- h.current && (clearTimeout(h.current), h.current = null);
142
- }, []), {
143
- isPolling: o.current,
144
- isTabVisible: d,
145
- inProgressCount: v().length
146
- };
147
- }
148
- function Ft() {
149
- const { authToken: e, tokenProps: a } = _(), p = k((c) => c.activeExports), { addExport: d } = ae(), l = O(!1), h = a == null ? void 0 : a.apiServiceUrl, o = e == null ? void 0 : e.accessToken;
150
- T(() => {
151
- if (l.current || !h || !o) return;
152
- (async () => {
153
- try {
154
- const { exports: u } = await xe(h, o, {
155
- status: ["pending", "processing", "chunking", "compacting", "completed", "failed"],
156
- limit: 20
157
- // Limit to recent exports
158
- });
159
- for (const n of u) {
160
- if (p.has(n.id)) continue;
161
- const v = n.totalChunks ? Math.round(n.completedChunks / n.totalChunks * 100) : 0;
162
- let b;
163
- if (n.status === "completed")
164
- try {
165
- b = await H(h, o, n.id);
166
- } catch (x) {
167
- console.error(
168
- `[useExportRecovery] Failed to get download URL for ${n.id}:`,
169
- x
170
- );
171
- }
172
- const m = {
173
- id: n.id,
174
- status: n.status,
175
- progress: v,
176
- title: bt(n),
177
- totalRows: n.totalRows,
178
- totalChunks: n.totalChunks,
179
- completedChunks: n.completedChunks,
180
- startedAt: new Date(n.createdAt),
181
- lastUpdatedAt: /* @__PURE__ */ new Date(),
182
- completedAt: n.completedAt ? new Date(n.completedAt) : void 0,
183
- fileSize: n.fileSize,
184
- error: n.error,
185
- expiresAt: new Date(n.expiresAt),
186
- downloadUrl: b
187
- };
188
- d(m);
189
- }
190
- l.current = !0;
191
- } catch (u) {
192
- console.error("[useExportRecovery] Failed to recover exports:", u), l.current = !0;
193
- }
194
- })();
195
- }, [h, o, d, p]);
196
- }
197
- function bt(e) {
198
- return e.title ? e.title : $(
199
- e.status
200
- ) ? "Export in progress..." : e.status === "completed" ? "Export completed" : e.status === "failed" ? "Export failed" : "Export";
201
- }
202
- function xt({
203
- open: e,
204
- onOpenChange: a,
205
- isLibraryVisual: p,
206
- currentVisualName: d,
207
- isSaving: l = !1,
208
- destinationMode: h = "both",
209
- onConfirm: o
210
- }) {
211
- const [c, u] = L(
212
- p && d ? `Copy of ${d}` : d || ""
213
- ), [n, v] = L("");
214
- ge.useEffect(() => {
215
- e && (u(
216
- p && d ? `Copy of ${d}` : d || ""
217
- ), v(""));
218
- }, [e, p, d]);
219
- const b = !!c.trim(), m = h === "local" ? {
220
- saveToLibrary: !1,
221
- saveToCurrentDashboard: !0,
222
- badgeType: "local",
223
- description: "Creates a local copy on the current dashboard.",
224
- actionLabel: "Add to Dashboard (Local)"
225
- } : h === "library" ? {
226
- saveToLibrary: !0,
227
- saveToCurrentDashboard: !1,
228
- badgeType: "library",
229
- description: "Creates a reusable visual in Visual Library.",
230
- actionLabel: "Save as Library Visual"
231
- } : {
232
- saveToLibrary: !0,
233
- saveToCurrentDashboard: !0,
234
- badgeType: "linked",
235
- description: "Creates a new library visual and adds a linked copy to this dashboard.",
236
- actionLabel: "Save Copy as Linked Visual"
237
- }, x = () => {
238
- !b || l || o({
239
- name: c.trim(),
240
- description: n.trim() || void 0,
241
- saveToLibrary: m.saveToLibrary,
242
- saveToCurrentDashboard: m.saveToCurrentDashboard
243
- });
244
- };
245
- return /* @__PURE__ */ t(se, { open: e, onOpenChange: a, children: /* @__PURE__ */ s(re, { className: "sm:max-w-[500px]", children: [
246
- /* @__PURE__ */ s(oe, { children: [
247
- /* @__PURE__ */ s(ne, { className: "flex items-center gap-2", children: [
248
- /* @__PURE__ */ t("span", { children: "Save Visual As" }),
249
- m.badgeType !== "local" && /* @__PURE__ */ t(
250
- tt,
251
- {
252
- type: m.badgeType,
253
- showLabel: !0,
254
- className: "px-2 py-0.5"
255
- }
256
- )
257
- ] }),
258
- /* @__PURE__ */ t(ie, { children: m.description })
259
- ] }),
260
- /* @__PURE__ */ s("div", { className: "grid gap-4 py-4", children: [
261
- /* @__PURE__ */ s("div", { className: "grid gap-2", children: [
262
- /* @__PURE__ */ t(K, { htmlFor: "name", children: "Name" }),
263
- /* @__PURE__ */ t(
264
- Ce,
265
- {
266
- id: "name",
267
- value: c,
268
- onChange: (N) => u(N.target.value),
269
- placeholder: "Enter visual name",
270
- disabled: l
271
- }
272
- )
273
- ] }),
274
- /* @__PURE__ */ s("div", { className: "grid gap-2", children: [
275
- /* @__PURE__ */ t(K, { htmlFor: "description", children: "Description (optional)" }),
276
- /* @__PURE__ */ t(
277
- we,
278
- {
279
- id: "description",
280
- value: n,
281
- onChange: (N) => v(N.target.value),
282
- placeholder: "Enter visual description",
283
- rows: 3,
284
- disabled: l
285
- }
286
- )
287
- ] })
288
- ] }),
289
- /* @__PURE__ */ s(ye, { children: [
290
- /* @__PURE__ */ t(
291
- S,
292
- {
293
- variant: "outline",
294
- onClick: () => a(!1),
295
- disabled: l,
296
- children: "Cancel"
297
- }
298
- ),
299
- /* @__PURE__ */ s(S, { onClick: x, disabled: !b || l, children: [
300
- l && /* @__PURE__ */ t(j, { className: "mr-2 h-4 w-4 animate-spin" }),
301
- m.actionLabel
302
- ] })
303
- ] })
304
- ] }) });
305
- }
306
- function Ct() {
307
- const [e, a] = L(!1), [p, d] = L(!1), [l, h] = L(null), o = R((i) => i.frame), c = R((i) => i.card), u = Ne(), n = z((i) => i.selectedSheetId), v = z(
308
- (i) => i.actions.setIsDashboardPanelOpen
309
- ), { getUpdatedFrame: b } = ve(), { selectVisual: m } = De(), { addFrame: x, setSelectedFrameId: N, setIsVisualEditing: f } = X(), w = !!(o != null && o.visualId), E = (() => {
310
- var i, g;
311
- return ((i = o == null ? void 0 : o.cards) == null ? void 0 : i.length) === 1 && ((g = o.cards[0]) != null && g.title) ? o.cards[0].title : u != null && u.title ? u.title : (c == null ? void 0 : c.title) || "Untitled Visual";
312
- })(), C = Ae((i) => {
313
- if (i != null && i.id) {
314
- if (m(i), p && l && n) {
315
- const g = {
316
- ...l,
317
- id: W(),
318
- visualId: i.id
319
- // Link to the newly created library visual
320
- };
321
- x(n, g, "end"), N(g.id), d(!1), h(null), f(!1);
322
- }
323
- v(!0), a(!1);
324
- }
325
- });
326
- return {
327
- saveAsDialogOpen: e,
328
- setSaveAsDialogOpen: a,
329
- handleSaveAs: async (i) => {
330
- if (!n) {
331
- P.error("No sheet selected");
332
- return;
333
- }
334
- const g = b(), I = le(g);
335
- if (I) {
336
- P.error(I);
337
- return;
338
- }
339
- const A = g.cards.length === 1 ? {
340
- ...g,
341
- cards: g.cards.map((y) => ({
342
- ...y,
343
- title: i.name
344
- // Use visual name as card title
345
- }))
346
- } : g;
347
- if (i.saveToLibrary) {
348
- d(i.saveToCurrentDashboard), h(A);
349
- const y = {
350
- title: i.name,
351
- description: i.description,
352
- frameObject: A,
353
- // Card title synced for single-card frames
354
- isPrivate: !1
355
- };
356
- C.mutate(y);
357
- } else if (i.saveToCurrentDashboard) {
358
- const y = {
359
- ...A,
360
- // Card title already synced
361
- id: W(),
362
- visualId: void 0
363
- // Explicitly no visualId for local visuals
364
- };
365
- x(n, y, "end"), N(y.id), P.success("Visual saved to dashboard"), a(!1), f(!1);
366
- }
367
- },
368
- isLibraryVisual: w,
369
- currentVisualName: E,
370
- isSaving: C.isPending
371
- };
372
- }
373
- function kt(e = {}) {
374
- const a = R((D) => D.frame), p = Se((D) => D.selectedVisual), d = z((D) => D.selectedFrameId), l = z((D) => D.selectedSheetId), { setIsVisualEditing: h, updateFrame: o } = X(), [c, u] = L(!1), [n, v] = L("both"), b = !!(a != null && a.visualId || p != null && p.id), m = !!(a != null && a.visualId && d), x = b && !m, {
375
- saveAsDialogOpen: N,
376
- setSaveAsDialogOpen: f,
377
- handleSaveAs: w,
378
- isLibraryVisual: E,
379
- currentVisualName: C,
380
- isSaving: r
381
- } = Ct(), { getUpdatedFrame: i } = ve(), g = () => {
382
- if (!l) {
383
- P.error("No sheet selected");
384
- return;
385
- }
386
- if (c) return;
387
- u(!0);
388
- const D = i(), A = le(D);
389
- if (A) {
390
- u(!1), P.error(A);
391
- return;
392
- }
393
- const y = {
394
- ...D,
395
- visualId: void 0
396
- };
397
- o(l, y), setTimeout(() => {
398
- u(!1), P.success("Changes applied. Visual is now local to this dashboard"), h(!1);
399
- }, 300);
400
- }, I = (D) => {
401
- v(D), f(!0);
402
- };
403
- return /* @__PURE__ */ s(B, { children: [
404
- /* @__PURE__ */ s("div", { className: "inline-flex items-center overflow-hidden rounded-[5px]", children: [
405
- !b && /* @__PURE__ */ t(
406
- at,
407
- {
408
- className: "rounded-none",
409
- variant: "default"
410
- }
411
- ),
412
- b && x && /* @__PURE__ */ t(
413
- st,
414
- {
415
- className: "rounded-none",
416
- variant: "default"
417
- }
418
- ),
419
- b && m && /* @__PURE__ */ t(rt, { className: "rounded-none" }),
420
- /* @__PURE__ */ s(de, { modal: !1, children: [
421
- /* @__PURE__ */ t(ce, { asChild: !0, children: /* @__PURE__ */ t(
422
- S,
423
- {
424
- variant: "default",
425
- size: "xs",
426
- className: "w-7 rounded-none border-l border-primary-foreground/20 px-0",
427
- "aria-label": "Open visual save options",
428
- disabled: r || c,
429
- children: /* @__PURE__ */ t(ue, { className: "h-3.5 w-3.5" })
430
- }
431
- ) }),
432
- /* @__PURE__ */ s(
433
- he,
434
- {
435
- align: "end",
436
- className: "min-w-[220px] rounded-[6px] border border-border/60 p-1 shadow-sm",
437
- children: [
438
- m && /* @__PURE__ */ s(B, { children: [
439
- /* @__PURE__ */ s(
440
- U,
441
- {
442
- onClick: g,
443
- disabled: c,
444
- children: [
445
- /* @__PURE__ */ t(Ee, { className: "h-3.5 w-3.5" }),
446
- c ? "Applying..." : "Apply Locally"
447
- ]
448
- }
449
- ),
450
- /* @__PURE__ */ t(Ie, {})
451
- ] }),
452
- /* @__PURE__ */ s(
453
- U,
454
- {
455
- onClick: () => I("local"),
456
- disabled: r,
457
- children: [
458
- /* @__PURE__ */ t(Le, { className: "h-3.5 w-3.5" }),
459
- "Add to Dashboard (Local)"
460
- ]
461
- }
462
- ),
463
- /* @__PURE__ */ s(
464
- U,
465
- {
466
- onClick: () => I("library"),
467
- disabled: r,
468
- children: [
469
- /* @__PURE__ */ t(ot, { className: "h-3.5 w-3.5" }),
470
- "Save as Library Visual"
471
- ]
472
- }
473
- ),
474
- /* @__PURE__ */ s(
475
- U,
476
- {
477
- onClick: () => I("both"),
478
- disabled: r,
479
- children: [
480
- /* @__PURE__ */ t(nt, { className: "h-3.5 w-3.5" }),
481
- "Save Copy as Linked Visual"
482
- ]
483
- }
484
- )
485
- ]
486
- }
487
- )
488
- ] })
489
- ] }),
490
- /* @__PURE__ */ t(it, {}),
491
- /* @__PURE__ */ t(
492
- xt,
493
- {
494
- open: N,
495
- onOpenChange: (D) => {
496
- r || f(D);
497
- },
498
- isLibraryVisual: E,
499
- currentVisualName: C,
500
- isSaving: r,
501
- destinationMode: n,
502
- onConfirm: w
503
- }
504
- )
505
- ] });
506
- }
507
- function Ut({ className: e }) {
508
- const a = R((u) => u.isDevMode), p = z((u) => u.isVisualEditing), { setIsDevMode: d } = Te(), { config: l } = be(Fe).tokenProps, h = (l == null ? void 0 : l.showAdvancedMode) !== !1;
509
- if (!p || !h)
510
- return null;
511
- const o = "h-full rounded-none border-0 bg-transparent px-2.5 shadow-none text-muted-foreground hover:bg-accent/50 hover:text-foreground", c = "bg-muted text-foreground hover:bg-muted";
512
- return /* @__PURE__ */ s(
513
- "div",
514
- {
515
- role: "radiogroup",
516
- "aria-label": "Editor mode",
517
- className: V(
518
- "inline-flex h-7 items-stretch overflow-hidden rounded-[5px] border border-input bg-background",
519
- e
520
- ),
521
- children: [
522
- /* @__PURE__ */ s(
523
- S,
524
- {
525
- type: "button",
526
- variant: "ghost",
527
- size: "xs",
528
- role: "radio",
529
- "aria-checked": !a,
530
- className: V(o, !a && c),
531
- onClick: () => d(!1),
532
- children: [
533
- /* @__PURE__ */ t(G, { className: "h-3.5 w-3.5" }),
534
- "Drag & drop"
535
- ]
536
- }
537
- ),
538
- /* @__PURE__ */ s(
539
- S,
540
- {
541
- type: "button",
542
- variant: "ghost",
543
- size: "xs",
544
- role: "radio",
545
- "aria-checked": a,
546
- className: V(
547
- o,
548
- "border-l border-border/60",
549
- a && c
550
- ),
551
- onClick: () => d(!0),
552
- children: [
553
- /* @__PURE__ */ t(ke, { className: "h-3.5 w-3.5" }),
554
- "SQL"
555
- ]
556
- }
557
- )
558
- ]
559
- }
560
- );
561
- }
562
- function Vt({
563
- open: e,
564
- onOpenChange: a,
565
- onSave: p,
566
- onDiscard: d,
567
- isSaving: l,
568
- title: h = "Unsaved changes",
569
- description: o = "You have unsaved changes to this dashboard. What would you like to do?",
570
- cancelLabel: c = "Cancel",
571
- discardLabel: u = "Discard",
572
- saveLabel: n = "Save"
573
- }) {
574
- return /* @__PURE__ */ t(Ue, { open: e, onOpenChange: (b) => {
575
- !b && l || a(b);
576
- }, children: /* @__PURE__ */ s(Ve, { children: [
577
- /* @__PURE__ */ s(Me, { children: [
578
- /* @__PURE__ */ t(Pe, { children: h }),
579
- /* @__PURE__ */ t(ze, { children: o })
580
- ] }),
581
- /* @__PURE__ */ s(Be, { children: [
582
- /* @__PURE__ */ t(
583
- S,
584
- {
585
- type: "button",
586
- size: "xs",
587
- onClick: d,
588
- disabled: l,
589
- variant: "ghost",
590
- className: "mr-auto text-muted-foreground hover:bg-destructive/10 hover:text-destructive focus-visible:bg-destructive/10 focus-visible:text-destructive",
591
- children: u
592
- }
593
- ),
594
- /* @__PURE__ */ t(Oe, { disabled: l, children: c }),
595
- /* @__PURE__ */ t(S, { type: "button", size: "xs", onClick: p, disabled: l, children: l ? /* @__PURE__ */ s(B, { children: [
596
- /* @__PURE__ */ t(j, { className: "mr-2 h-3.5 w-3.5 animate-spin" }),
597
- "Saving..."
598
- ] }) : n })
599
- ] })
600
- ] }) });
601
- }
602
- function Mt(e, a, p, d) {
603
- T(() => {
604
- e && !p && a && d(Re(a));
605
- }, [e, p, a, d]);
606
- }
607
- function wt({
608
- export: e,
609
- onRemove: a
610
- }) {
611
- const p = () => {
612
- e.downloadUrl && window.open(e.downloadUrl, "_blank");
613
- }, d = (c) => {
614
- c.stopPropagation(), a == null || a(e.id);
615
- }, l = () => {
616
- switch (e.status) {
617
- case "completed":
618
- return /* @__PURE__ */ t(Xe, { className: "mt-0.5 h-5 w-5 shrink-0 text-green-600" });
619
- case "failed":
620
- return /* @__PURE__ */ t(lt, { className: "mt-0.5 h-5 w-5 shrink-0 text-destructive" });
621
- default:
622
- return /* @__PURE__ */ t(j, { className: "text-foreground-muted mt-0.5 h-5 w-5 shrink-0 animate-spin" });
623
- }
624
- }, h = $(e.status), o = (() => {
625
- switch (e.status) {
626
- case "pending":
627
- return "Queued...";
628
- case "processing":
629
- return "Processing...";
630
- case "chunking":
631
- return "Processing...";
632
- case "compacting":
633
- return "Finalizing...";
634
- default:
635
- return "Processing...";
636
- }
637
- })();
638
- return /* @__PURE__ */ s("div", { className: "group p-4 transition-colors hover:bg-muted/50", children: [
639
- /* @__PURE__ */ s("div", { className: "mb-2 flex items-start justify-between gap-3", children: [
640
- /* @__PURE__ */ s("div", { className: "flex min-w-0 flex-1 items-start gap-3", children: [
641
- l(),
642
- /* @__PURE__ */ s("div", { className: "min-w-0 flex-1", children: [
643
- /* @__PURE__ */ t("h4", { className: "mb-1 truncate text-sm font-medium", children: e.title }),
644
- e.status === "completed" && /* @__PURE__ */ s("div", { className: "flex items-center gap-2 text-xs text-muted-foreground", children: [
645
- /* @__PURE__ */ s("span", { children: [
646
- e.totalRows.toLocaleString(),
647
- " rows"
648
- ] }),
649
- e.fileSize && /* @__PURE__ */ s(B, { children: [
650
- /* @__PURE__ */ t("span", { children: "•" }),
651
- /* @__PURE__ */ t("span", { children: _e(e.fileSize) })
652
- ] })
653
- ] }),
654
- h && /* @__PURE__ */ t("div", { className: "text-xs text-muted-foreground", children: o }),
655
- e.status === "failed" && /* @__PURE__ */ t("div", { className: "line-clamp-2 text-xs text-destructive", children: e.error || "Export failed" })
656
- ] })
657
- ] }),
658
- /* @__PURE__ */ t(
659
- S,
660
- {
661
- variant: "ghost",
662
- size: "icon",
663
- className: "h-6 w-6 shrink-0 opacity-0 transition-opacity group-hover:opacity-100",
664
- onClick: d,
665
- "aria-label": "Remove notification",
666
- children: /* @__PURE__ */ t($e, { className: "h-4 w-4" })
667
- }
668
- )
669
- ] }),
670
- /* @__PURE__ */ s("div", { className: "ml-8", children: [
671
- e.status === "completed" && /* @__PURE__ */ s("div", { className: "flex items-center justify-between", children: [
672
- /* @__PURE__ */ t("span", { className: "text-xs text-muted-foreground", children: Y(e.startedAt, { addSuffix: !0 }) }),
673
- e.downloadUrl && /* @__PURE__ */ s(
674
- S,
675
- {
676
- size: "sm",
677
- variant: "outline",
678
- className: "h-8 bg-transparent",
679
- onClick: p,
680
- children: [
681
- /* @__PURE__ */ t(He, { className: "mr-1.5 h-3.5 w-3.5" }),
682
- "Download"
683
- ]
684
- }
685
- )
686
- ] }),
687
- h && /* @__PURE__ */ s("div", { children: [
688
- /* @__PURE__ */ t(je, { value: e.progress, className: "h-1.5" }),
689
- /* @__PURE__ */ s("span", { className: "mt-1 block text-xs text-muted-foreground", children: [
690
- e.progress,
691
- "% complete"
692
- ] })
693
- ] }),
694
- e.status === "failed" && /* @__PURE__ */ t("span", { className: "text-xs text-muted-foreground", children: Y(e.startedAt, { addSuffix: !0 }) })
695
- ] })
696
- ] });
697
- }
698
- function yt() {
699
- const { authToken: e, tokenProps: a } = _(), p = k((f) => f.activeExports), { clearCompleted: d, removeExport: l, updateExport: h } = ae(), [o, c] = L(!1), [u, n] = L(!1), v = Array.from(p.values()).sort(
700
- (f, w) => w.startedAt.getTime() - f.startedAt.getTime()
701
- ), b = v.some(
702
- (f) => f.status === "completed" || f.status === "failed"
703
- ), m = M(async () => {
704
- const f = a == null ? void 0 : a.apiServiceUrl, w = e == null ? void 0 : e.accessToken;
705
- if (!(!f || !w)) {
706
- c(!0);
707
- try {
708
- const E = Array.from(p.values());
709
- await Promise.all(
710
- E.map(async (C) => {
711
- try {
712
- const r = await te(f, w, C.id);
713
- let i;
714
- if (r.status === "completed")
715
- try {
716
- i = await H(
717
- f,
718
- w,
719
- C.id
720
- );
721
- } catch (g) {
722
- console.error(`Failed to get download URL for ${C.id}:`, g);
723
- }
724
- h(C.id, {
725
- status: r.status,
726
- progress: r.progress,
727
- completedChunks: r.completedChunks,
728
- completedAt: r.completedAt ? new Date(r.completedAt) : void 0,
729
- lastUpdatedAt: /* @__PURE__ */ new Date(),
730
- fileSize: r.fileSize,
731
- error: r.error,
732
- downloadUrl: i
733
- });
734
- } catch (r) {
735
- console.error(`Failed to refresh export ${C.id}:`, r);
736
- }
737
- })
738
- );
739
- } finally {
740
- c(!1);
741
- }
742
- }
743
- }, [
744
- p,
745
- e == null ? void 0 : e.accessToken,
746
- a == null ? void 0 : a.apiServiceUrl,
747
- h
748
- ]), x = M(async () => {
749
- const f = a == null ? void 0 : a.apiServiceUrl, w = e == null ? void 0 : e.accessToken;
750
- if (!f || !w) {
751
- d();
752
- return;
753
- }
754
- n(!0);
755
- try {
756
- const E = v.filter(
757
- (r) => r.status === "completed" || r.status === "failed"
758
- ), C = await Promise.allSettled(
759
- E.map(async (r) => (await q(f, w, r.id), r.id))
760
- );
761
- for (const r of C)
762
- r.status === "fulfilled" ? l(r.value) : console.error("Failed to delete export:", r.reason);
763
- } finally {
764
- n(!1);
765
- }
766
- }, [
767
- v,
768
- a == null ? void 0 : a.apiServiceUrl,
769
- e == null ? void 0 : e.accessToken,
770
- d,
771
- l
772
- ]), N = M(
773
- async (f) => {
774
- const w = a == null ? void 0 : a.apiServiceUrl, E = e == null ? void 0 : e.accessToken;
775
- if (w && E)
776
- try {
777
- await q(w, E, f), l(f);
778
- return;
779
- } catch (C) {
780
- console.error(`Failed to cancel export ${f}:`, C);
781
- }
782
- l(f);
783
- },
784
- [a == null ? void 0 : a.apiServiceUrl, e == null ? void 0 : e.accessToken, l]
785
- );
786
- return v.length === 0 ? /* @__PURE__ */ s("div", { className: "p-6 text-center", children: [
787
- /* @__PURE__ */ t(Z, { className: "mx-auto mb-2 h-8 w-8 text-muted-foreground" }),
788
- /* @__PURE__ */ t("p", { className: "text-sm text-muted-foreground", children: "No active exports" }),
789
- /* @__PURE__ */ t("p", { className: "mt-1 text-xs text-muted-foreground", children: "Large exports will appear here" })
790
- ] }) : /* @__PURE__ */ s("div", { className: "flex flex-col", children: [
791
- /* @__PURE__ */ s("div", { className: "flex items-center justify-between border-b px-4 py-3", children: [
792
- /* @__PURE__ */ s("div", { className: "flex items-center gap-2", children: [
793
- /* @__PURE__ */ t(Z, { className: "h-5 w-5 text-muted-foreground" }),
794
- /* @__PURE__ */ t("h4", { className: "font-semibold", children: "Exports" })
795
- ] }),
796
- /* @__PURE__ */ s("div", { className: "flex items-center gap-1", children: [
797
- /* @__PURE__ */ t(
798
- S,
799
- {
800
- variant: "ghost",
801
- size: "sm",
802
- className: "h-7 w-7 p-0",
803
- onClick: m,
804
- disabled: o,
805
- title: "Refresh status",
806
- children: /* @__PURE__ */ t(
807
- Ge,
808
- {
809
- className: `h-4 w-4 ${o ? "animate-spin" : ""}`
810
- }
811
- )
812
- }
813
- ),
814
- b && /* @__PURE__ */ t(
815
- S,
816
- {
817
- variant: "ghost",
818
- size: "sm",
819
- className: "h-7 px-2 text-sm",
820
- onClick: x,
821
- disabled: u,
822
- children: u ? "Clearing..." : "Clear all"
823
- }
824
- )
825
- ] })
826
- ] }),
827
- /* @__PURE__ */ t("div", { className: "max-h-[350px] overflow-y-auto", children: /* @__PURE__ */ t("div", { className: "divide-y", children: v.map((f) => /* @__PURE__ */ t(
828
- wt,
829
- {
830
- export: f,
831
- onRemove: N
832
- },
833
- f.id
834
- )) }) })
835
- ] });
836
- }
837
- function Pt({
838
- variant: e
839
- }) {
840
- const a = k((u) => u.activeExports), p = Ke(), d = a.size > 0, l = Array.from(a.values()).some(
841
- (u) => u.status === "completed" || u.status === "failed"
842
- ), o = p > 0 ? p > 9 ? "9+" : String(p) : null;
843
- return /* @__PURE__ */ s(me, { children: [
844
- /* @__PURE__ */ t(pe, { asChild: !0, children: /* @__PURE__ */ s(
845
- S,
846
- {
847
- variant: e ?? "ghost",
848
- size: "xs",
849
- className: "relative w-7 px-0 text-muted-foreground hover:text-foreground",
850
- "aria-label": "Export notifications",
851
- children: [
852
- /* @__PURE__ */ t(We, { className: "h-3.5 w-3.5" }),
853
- d && /* @__PURE__ */ t(
854
- "span",
855
- {
856
- className: `absolute flex items-center justify-center rounded-full bg-primary text-primary-foreground ${o ? "-right-0.5 -top-0.5 h-3.5 min-w-3.5 px-0.5 text-[9px] font-semibold" : "right-1 top-1 h-1.5 w-1.5"}`,
857
- children: o
858
- }
859
- )
860
- ]
861
- }
862
- ) }),
863
- /* @__PURE__ */ t(fe, { className: "w-80 p-0", align: "end", sideOffset: 8, children: /* @__PURE__ */ t(yt, {}) })
864
- ] });
865
- }
866
- function Nt(e) {
867
- if (e)
868
- return {
869
- renamed: e.type === "rename" ? { oldId: e.oldId, newId: e.newId } : void 0,
870
- removedControlId: e.type === "remove" ? e.controlId : void 0,
871
- cardBindingsById: e.type === "add" || e.type === "update" ? e.cardBindingsById : void 0,
872
- affectedBindingControlIds: e.type === "add" || e.type === "update" ? e.affectedBindingControlIds : void 0
873
- };
874
- }
875
- function zt({
876
- open: e,
877
- onOpenChange: a,
878
- trigger: p,
879
- showTrigger: d = !0,
880
- initialMode: l = "manage"
881
- }) {
882
- const h = l === "create", {
883
- forceClose: o,
884
- handleOpenChange: c,
885
- isCreateFlowActive: u,
886
- preventPassiveDismissDuringCreate: n,
887
- resolvedOpen: v,
888
- setIsCreateFlowActive: b
889
- } = dt({
890
- open: e,
891
- onOpenChange: a,
892
- initialCreateFlowActive: l === "create",
893
- // Dialog mode renders a built-in X close button — allow explicit
894
- // closes through `handleOpenChange`. Popover mode has no X; its
895
- // only close-via-trigger path is a re-click that would silently
896
- // wipe the in-progress create flow, so block everything during
897
- // create and make consumers use `forceClose()` from a dedicated
898
- // button.
899
- dismissMode: d ? "passive" : "explicit-only"
900
- }), m = z((A) => A.dashboard), { setDashboardControlsModel: x } = X(), { participants: N } = qe(Qe(m)), f = Array.from(
901
- new Map(
902
- N.flatMap(
903
- (A) => A.fieldChoices.map((y) => {
904
- var F;
905
- return [
906
- y.value,
907
- {
908
- option: y,
909
- target: (F = A.fieldTargetMap) == null ? void 0 : F[y.value]
910
- }
911
- ];
912
- })
913
- )
914
- ).values()
915
- ), w = Array.from(
916
- new Map(
917
- N.flatMap(
918
- (A) => A.metricChoices.map((y) => {
919
- var F;
920
- return [
921
- y.value,
922
- {
923
- option: y,
924
- target: (F = A.metricTargetMap) == null ? void 0 : F[y.value]
925
- }
926
- ];
927
- })
928
- )
929
- ).values()
930
- ), E = Ye({
931
- ...m || {},
932
- controls: []
933
- }), C = Ze(m), r = (A, y, F) => {
934
- x(
935
- A,
936
- y,
937
- Nt(F)
938
- );
939
- }, i = M(() => {
940
- if (h) {
941
- o();
942
- return;
943
- }
944
- b(!1);
945
- }, [h, o, b]), g = /* @__PURE__ */ t(
946
- ct,
947
- {
948
- scope: "dashboard",
949
- controls: m.controls || [],
950
- reservedControlIds: E,
951
- defaultValues: m.defaultControlValues || {},
952
- usageByControlId: Je(m),
953
- availableFieldChoices: f,
954
- availableMetricChoices: w,
955
- structuralParticipants: N,
956
- structuralParticipantIdsByControlId: C,
957
- initialCreateFlow: l === "create",
958
- onCreateFlowActiveChange: b,
959
- onCreateFlowComplete: i,
960
- onChange: r,
961
- emptyMessage: "No dashboard controls yet."
962
- }
963
- ), I = u ? "Add dashboard control" : "Dashboard Controls", D = /* @__PURE__ */ s(B, { children: [
964
- /* @__PURE__ */ s("div", { className: "space-y-1", children: [
965
- /* @__PURE__ */ t("h4", { className: "text-sm font-medium", children: "Dashboard Controls" }),
966
- /* @__PURE__ */ t("p", { className: "text-xs text-muted-foreground", children: "Add shared controls viewers can use across the dashboard. Each card can decide how to respond to the same control." })
967
- ] }),
968
- g
969
- ] });
970
- return d ? /* @__PURE__ */ s(me, { open: v, onOpenChange: c, children: [
971
- /* @__PURE__ */ t(pe, { asChild: !0, children: p || /* @__PURE__ */ s(S, { variant: "outline", className: "h-7 px-2", size: "sm", children: [
972
- /* @__PURE__ */ t(G, { className: "mr-2 h-4 w-4" }),
973
- "Controls"
974
- ] }) }),
975
- /* @__PURE__ */ t(
976
- fe,
977
- {
978
- className: "w-[620px] max-w-[95vw] space-y-4",
979
- align: "end",
980
- onEscapeKeyDown: n,
981
- onPointerDownOutside: n,
982
- children: D
983
- }
984
- )
985
- ] }) : /* @__PURE__ */ t(se, { open: v, onOpenChange: c, children: /* @__PURE__ */ s(
986
- re,
987
- {
988
- className: "flex max-h-[88vh] flex-col overflow-hidden sm:max-w-[600px]",
989
- onEscapeKeyDown: n,
990
- onPointerDownOutside: n,
991
- children: [
992
- /* @__PURE__ */ s(
993
- oe,
994
- {
995
- className: u ? "space-y-0" : void 0,
996
- children: [
997
- /* @__PURE__ */ t(ne, { className: "text-[15px]", children: I }),
998
- /* @__PURE__ */ t(
999
- ie,
1000
- {
1001
- className: u ? "sr-only" : "text-[13px]",
1002
- children: u ? "Configure and add a shared dashboard control." : "Add shared controls viewers can use across the dashboard. Each card can decide how to respond to the same control."
1003
- }
1004
- )
1005
- ]
1006
- }
1007
- ),
1008
- /* @__PURE__ */ t("div", { className: "min-h-0 overflow-y-auto pr-1", children: g })
1009
- ]
1010
- }
1011
- ) });
1012
- }
1013
- function Bt({
1014
- showFilters: e,
1015
- onToggleFilters: a,
1016
- onAddFilter: p,
1017
- onAddControl: d,
1018
- onManageControls: l,
1019
- size: h = "default",
1020
- className: o,
1021
- primaryButtonClassName: c,
1022
- secondaryButtonClassName: u,
1023
- dropdownContentClassName: n
1024
- }) {
1025
- return /* @__PURE__ */ s(
1026
- "div",
1027
- {
1028
- className: V(
1029
- // Height lives on the shell so the outer border is part of the
1030
- // h-7 box (matches regular `size="xs"` buttons). Inner buttons
1031
- // stretch to fill via `h-full`, avoiding the 2px stack-up that
1032
- // makes the combo taller than a sibling `<Button size="xs">`.
1033
- "relative inline-flex items-stretch overflow-hidden rounded-[5px] border border-input bg-background",
1034
- h === "toolbar" ? "h-8" : "h-7",
1035
- o
1036
- ),
1037
- children: [
1038
- /* @__PURE__ */ s(
1039
- S,
1040
- {
1041
- variant: "ghost",
1042
- size: "xs",
1043
- className: V(
1044
- "h-full rounded-none border-0 bg-transparent pl-2.5 pr-2 shadow-none hover:bg-accent/50",
1045
- c
1046
- ),
1047
- onClick: a,
1048
- children: [
1049
- e ? /* @__PURE__ */ t(ut, { className: "h-3.5 w-3.5" }) : /* @__PURE__ */ t(Q, { className: "h-3.5 w-3.5" }),
1050
- "Filter"
1051
- ]
1052
- }
1053
- ),
1054
- /* @__PURE__ */ s(de, { children: [
1055
- /* @__PURE__ */ t(ce, { asChild: !0, children: /* @__PURE__ */ t(
1056
- S,
1057
- {
1058
- variant: "ghost",
1059
- size: "xs",
1060
- className: V(
1061
- "h-full w-7 rounded-none border-0 border-l border-border/60 bg-transparent px-0 shadow-none hover:bg-accent/50",
1062
- u
1063
- ),
1064
- "aria-label": "Filter and control actions",
1065
- children: /* @__PURE__ */ t(ue, { className: "h-3.5 w-3.5" })
1066
- }
1067
- ) }),
1068
- /* @__PURE__ */ s(
1069
- he,
1070
- {
1071
- align: "start",
1072
- className: V(
1073
- "min-w-[180px] rounded-[6px] border border-border/60 p-1 shadow-sm",
1074
- n
1075
- ),
1076
- children: [
1077
- /* @__PURE__ */ s(U, { onSelect: p, children: [
1078
- /* @__PURE__ */ t(Q, { className: "h-3.5 w-3.5" }),
1079
- "Add filter"
1080
- ] }),
1081
- /* @__PURE__ */ s(U, { onSelect: d, children: [
1082
- /* @__PURE__ */ t(G, { className: "h-3.5 w-3.5" }),
1083
- "Add control"
1084
- ] }),
1085
- /* @__PURE__ */ s(U, { onSelect: l, children: [
1086
- /* @__PURE__ */ t(et, { className: "h-3.5 w-3.5" }),
1087
- "Manage controls"
1088
- ] })
1089
- ]
1090
- }
1091
- )
1092
- ] })
1093
- ]
1094
- }
1095
- );
1096
- }
1097
- export {
1098
- Ut as A,
1099
- zt as D,
1100
- yt as E,
1101
- Pt as N,
1102
- Vt as U,
1103
- kt as V,
1104
- wt as a,
1105
- Ft as b,
1106
- Bt as c,
1107
- Mt as d,
1108
- Tt as u
1109
- };