react-semaphor 0.1.181 → 0.1.182

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (26) hide show
  1. package/dist/chunks/{dashboard-controls-aSc1zv9H.js → dashboard-controls-BnBXzFOj.js} +4 -4
  2. package/dist/chunks/{dashboard-controls-uTcIgnwr.js → dashboard-controls-pGlGtKRR.js} +1 -1
  3. package/dist/chunks/{dashboard-json-Yy1p-xw4.js → dashboard-json-CiIyCwJi.js} +1 -1
  4. package/dist/chunks/{dashboard-json-4ck1yXt7.js → dashboard-json-UVBr47Qj.js} +1 -1
  5. package/dist/chunks/{edit-dashboard-visual-DEedEtg4.js → edit-dashboard-visual-CXvyi_qa.js} +1 -1
  6. package/dist/chunks/{edit-dashboard-visual-K-yosg4h.js → edit-dashboard-visual-DoP_x_tT.js} +2 -2
  7. package/dist/chunks/{editor-action-buttons-D5zidD5p.js → editor-action-buttons-5UEhKl88.js} +2 -2
  8. package/dist/chunks/{editor-action-buttons-WLwpPoSo.js → editor-action-buttons-Bftd6Bfx.js} +1 -1
  9. package/dist/chunks/{index-tt1rwTc8.js → index-D59dkH2b.js} +111 -111
  10. package/dist/chunks/{index-TF2KfLGc.js → index-ahdw_esL.js} +5656 -5614
  11. package/dist/chunks/{notification-bell-DNxWG0YY.js → notification-bell-CKI2j8jH.js} +38 -48
  12. package/dist/chunks/{notification-bell-CWYeyuXL.js → notification-bell-DtWcBdzp.js} +3 -8
  13. package/dist/chunks/{resource-management-panel-CihSUDmt.js → resource-management-panel-BLiCtZZE.js} +1 -1
  14. package/dist/chunks/{resource-management-panel-Dda1VGgq.js → resource-management-panel-qkl060k8.js} +3 -3
  15. package/dist/chunks/{use-role-aware-display-preferences-CpROR4Gx.js → use-role-aware-display-preferences-CLf3yEts.js} +1 -1
  16. package/dist/chunks/{use-role-aware-display-preferences-DgsVnRKz.js → use-role-aware-display-preferences-JstD5WLE.js} +1 -1
  17. package/dist/chunks/{use-visual-utils-Dwmrgj6E.js → use-visual-utils-BbN7rxtD.js} +1 -1
  18. package/dist/chunks/{use-visual-utils-BkmyEMSD.js → use-visual-utils-TGjvLx_R.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 +1 -1
  26. package/package.json +1 -1
@@ -1,8 +1,8 @@
1
1
  import oe, { useState as A, useRef as V, useCallback as M, useEffect as D, useContext as ie } from "react";
2
- import { aF as z, aN as B, a0 as I, aC as $, ay as ae, az as _, a1 as se, ax as le, bu as ce, bv as de, bw as ue, bx as me, by as he, bz as O, bA as pe, bG as fe, bH as j, bB as ge, B as S, aG as H, au as P, aI as ve, u as E, aO as be, as as re, bI as xe, bJ as G, aL as T, A as we, bK as Ce, c as U, aV as X, aW as q, aX as W, aY as Q, aZ as Y, av as Ne, bL as ye, bM as Ae, bN as Se, bb as Ee, bc as De, bd as Ie, bO as ke, be as Te, bf as Ue, bg as Fe, bh as Me, bi as Pe, W as Le, I as Ve, bP as ze, bQ as Re, aE as Oe, X as Be, bR as $e, bS as _e, aA as Z, a3 as He, P as je, p as Ge, bT as Xe, r as qe } from "./index-TF2KfLGc.js";
2
+ import { aF as O, aN as B, a0 as I, aC as $, ay as ae, az as _, a1 as se, ax as le, bu as ce, bv as de, bw as ue, bx as me, by as he, bz as R, bA as pe, bG as fe, bH as j, bB as ge, B as S, aG as H, au as P, aI as ve, u as E, aO as be, as as re, bI as xe, bJ as G, aL as U, A as we, bK as Ce, c as T, aV as X, aW as q, aX as W, aY as Q, aZ as Y, av as Ne, bL as ye, bM as Ae, bN as Se, bb as Ee, bc as De, bd as Ie, bO as ke, be as Ue, bf as Te, bg as Fe, bh as Me, bi as Pe, W as Le, I as Ve, bP as ze, bQ as Re, aE as Oe, X as Be, bR as $e, bS as _e, bT as He, aA as Z, a3 as je, P as Ge, p as Xe, bU as qe, r as We } from "./index-ahdw_esL.js";
3
3
  import { jsx as t, jsxs as r, Fragment as L } from "react/jsx-runtime";
4
- import { E as We, V as Qe, a as Ye, b as Ze, S as J, c as Je, C as Ke } from "./editor-action-buttons-D5zidD5p.js";
5
- import { a as ne } from "./use-visual-utils-Dwmrgj6E.js";
4
+ import { E as Qe, V as Ye, a as Ze, b as Je, S as J, c as Ke, C as et } from "./editor-action-buttons-5UEhKl88.js";
5
+ import { a as ne } from "./use-visual-utils-BbN7rxtD.js";
6
6
  import { a as K } from "./index-B4EhQdS9.js";
7
7
  /**
8
8
  * @license lucide-react v0.453.0 - ISC
@@ -10,17 +10,7 @@ import { a as K } from "./index-B4EhQdS9.js";
10
10
  * This source code is licensed under the ISC license.
11
11
  * See the LICENSE file in the root directory of this source tree.
12
12
  */
13
- const et = z("CircleCheck", [
14
- ["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }],
15
- ["path", { d: "m9 12 2 2 4-4", key: "dzmm74" }]
16
- ]);
17
- /**
18
- * @license lucide-react v0.453.0 - ISC
19
- *
20
- * This source code is licensed under the ISC license.
21
- * See the LICENSE file in the root directory of this source tree.
22
- */
23
- const tt = z("CirclePlus", [
13
+ const tt = O("CirclePlus", [
24
14
  ["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }],
25
15
  ["path", { d: "M8 12h8", key: "1wcyev" }],
26
16
  ["path", { d: "M12 8v8", key: "napkw2" }]
@@ -31,7 +21,7 @@ const tt = z("CirclePlus", [
31
21
  * This source code is licensed under the ISC license.
32
22
  * See the LICENSE file in the root directory of this source tree.
33
23
  */
34
- const ee = z("FileDown", [
24
+ const ee = O("FileDown", [
35
25
  ["path", { d: "M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z", key: "1rqfz7" }],
36
26
  ["path", { d: "M14 2v4a2 2 0 0 0 2 2h4", key: "tnqrlb" }],
37
27
  ["path", { d: "M12 18v-6", key: "17g6i2" }],
@@ -43,7 +33,7 @@ const ee = z("FileDown", [
43
33
  * This source code is licensed under the ISC license.
44
34
  * See the LICENSE file in the root directory of this source tree.
45
35
  */
46
- const at = z("RefreshCw", [
36
+ const at = O("RefreshCw", [
47
37
  ["path", { d: "M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8", key: "v9h5vc" }],
48
38
  ["path", { d: "M21 3v5h-5", key: "1q7to0" }],
49
39
  ["path", { d: "M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16", key: "3uifl3" }],
@@ -252,7 +242,7 @@ function dt({
252
242
  ] }),
253
243
  /* @__PURE__ */ r("div", { className: "grid gap-4 py-4", children: [
254
244
  /* @__PURE__ */ r("div", { className: "grid gap-2", children: [
255
- /* @__PURE__ */ t(O, { htmlFor: "name", children: "Name" }),
245
+ /* @__PURE__ */ t(R, { htmlFor: "name", children: "Name" }),
256
246
  /* @__PURE__ */ t(
257
247
  pe,
258
248
  {
@@ -265,7 +255,7 @@ function dt({
265
255
  )
266
256
  ] }),
267
257
  /* @__PURE__ */ r("div", { className: "grid gap-2", children: [
268
- /* @__PURE__ */ t(O, { htmlFor: "description", children: "Description (optional)" }),
258
+ /* @__PURE__ */ t(R, { htmlFor: "description", children: "Description (optional)" }),
269
259
  /* @__PURE__ */ t(
270
260
  fe,
271
261
  {
@@ -279,7 +269,7 @@ function dt({
279
269
  )
280
270
  ] }),
281
271
  /* @__PURE__ */ r("div", { className: "space-y-4", children: [
282
- /* @__PURE__ */ t(O, { children: "Save to:" }),
272
+ /* @__PURE__ */ t(R, { children: "Save to:" }),
283
273
  /* @__PURE__ */ r("div", { className: "space-y-2", children: [
284
274
  /* @__PURE__ */ r("div", { className: "flex items-center space-x-2", children: [
285
275
  /* @__PURE__ */ t(
@@ -371,10 +361,10 @@ function ut() {
371
361
  setSaveAsDialogOpen: a,
372
362
  handleSaveAs: async (i) => {
373
363
  if (!d) {
374
- T.error("No sheet selected");
364
+ U.error("No sheet selected");
375
365
  return;
376
366
  }
377
- const w = C(), R = w.cards.length === 1 ? {
367
+ const w = C(), z = w.cards.length === 1 ? {
378
368
  ...w,
379
369
  cards: w.cards.map((k) => ({
380
370
  ...k,
@@ -383,24 +373,24 @@ function ut() {
383
373
  }))
384
374
  } : w;
385
375
  if (i.saveToLibrary) {
386
- n(i.saveToCurrentDashboard), l(R);
376
+ n(i.saveToCurrentDashboard), l(z);
387
377
  const k = {
388
378
  title: i.name,
389
379
  description: i.description,
390
- frameObject: R,
380
+ frameObject: z,
391
381
  // Card title synced for single-card frames
392
382
  isPrivate: !1
393
383
  };
394
384
  u.mutate(k);
395
385
  } else if (i.saveToCurrentDashboard) {
396
386
  const k = {
397
- ...R,
387
+ ...z,
398
388
  // Card title already synced
399
389
  id: G(),
400
390
  visualId: void 0
401
391
  // Explicitly no visualId for local visuals
402
392
  };
403
- x(d, k, "end"), y(k.id), T.success("Visual saved to dashboard"), a(!1), f(!1);
393
+ x(d, k, "end"), y(k.id), U.success("Visual saved to dashboard"), a(!1), f(!1);
404
394
  }
405
395
  },
406
396
  isLibraryVisual: b,
@@ -420,25 +410,25 @@ function Nt({
420
410
  isSaving: f
421
411
  } = ut(), { handleAddLibraryVisual: b } = ne(), N = async () => {
422
412
  if (!l) {
423
- T.error("No dashboard sheet selected");
413
+ U.error("No dashboard sheet selected");
424
414
  return;
425
415
  }
426
416
  if (!n) {
427
- T.error("No visual selected");
417
+ U.error("No visual selected");
428
418
  return;
429
419
  }
430
420
  const u = await b(n);
431
- u.success ? (T.success("Visual added to dashboard"), o(!1)) : T.error(u.error || "Failed to add visual to dashboard");
421
+ u.success ? (U.success("Visual added to dashboard"), o(!1)) : U.error(u.error || "Failed to add visual to dashboard");
432
422
  };
433
423
  return /* @__PURE__ */ r(L, { children: [
434
- !s && /* @__PURE__ */ t(We, { className: e, variant: "default" }),
424
+ !s && /* @__PURE__ */ t(Qe, { className: e, variant: "default" }),
435
425
  s && /* @__PURE__ */ r(L, { children: [
436
- h && /* @__PURE__ */ t(Qe, { className: e }),
426
+ h && /* @__PURE__ */ t(Ye, { className: e }),
437
427
  d && l && c && (c.sql || Ce(c.config)) && /* @__PURE__ */ r(
438
428
  S,
439
429
  {
440
430
  onClick: N,
441
- className: U(e),
431
+ className: T(e),
442
432
  size: "sm",
443
433
  variant: "outline",
444
434
  children: [
@@ -447,15 +437,15 @@ function Nt({
447
437
  ]
448
438
  }
449
439
  ),
450
- d && /* @__PURE__ */ t(Ye, { className: e, variant: "default" }),
451
- h && /* @__PURE__ */ t(Ze, { className: e }),
440
+ d && /* @__PURE__ */ t(Ze, { className: e, variant: "default" }),
441
+ h && /* @__PURE__ */ t(Je, { className: e }),
452
442
  /* @__PURE__ */ r(X, { modal: !1, children: [
453
443
  /* @__PURE__ */ t(q, { asChild: !0, children: /* @__PURE__ */ t(
454
444
  S,
455
445
  {
456
446
  variant: "outline",
457
447
  size: "sm",
458
- className: U(e, "w-8 p-0"),
448
+ className: T(e, "w-8 p-0"),
459
449
  children: /* @__PURE__ */ t(W, { className: "h-4 w-4" })
460
450
  }
461
451
  ) }),
@@ -479,7 +469,7 @@ function Nt({
479
469
  {
480
470
  variant: "outline",
481
471
  size: "sm",
482
- className: U(e, "w-8 p-0"),
472
+ className: T(e, "w-8 p-0"),
483
473
  children: /* @__PURE__ */ t(W, { className: "h-4 w-4" })
484
474
  }
485
475
  ) }),
@@ -488,7 +478,7 @@ function Nt({
488
478
  "Save As..."
489
479
  ] }) })
490
480
  ] }),
491
- /* @__PURE__ */ t(Je, { className: e }),
481
+ /* @__PURE__ */ t(Ke, { className: e }),
492
482
  /* @__PURE__ */ t(
493
483
  dt,
494
484
  {
@@ -510,11 +500,11 @@ function yt({
510
500
  switchClassName: a
511
501
  }) {
512
502
  const c = P((s) => s.isDevMode), n = E((s) => s.isVisualEditing), { setIsDevMode: m } = Ne(), { config: l } = ie(ye).tokenProps, o = (l == null ? void 0 : l.showAdvancedMode) !== !1;
513
- return !n || !o ? null : /* @__PURE__ */ r("div", { className: U("flex items-center space-x-2", e), children: [
503
+ return !n || !o ? null : /* @__PURE__ */ r("div", { className: T("flex items-center space-x-2", e), children: [
514
504
  /* @__PURE__ */ t(
515
505
  Ae,
516
506
  {
517
- className: U("", a),
507
+ className: T("", a),
518
508
  checked: c,
519
509
  onCheckedChange: () => m(!c),
520
510
  id: "advanced-mode",
@@ -538,9 +528,9 @@ function At({
538
528
  /* @__PURE__ */ r(Ie, { children: [
539
529
  /* @__PURE__ */ r("div", { className: "flex items-center gap-3", children: [
540
530
  /* @__PURE__ */ t("div", { className: "flex h-10 w-10 items-center justify-center rounded-full bg-amber-100", children: /* @__PURE__ */ t(ke, { className: "h-5 w-5 text-amber-600" }) }),
541
- /* @__PURE__ */ t(Te, { className: "text-xl", children: "Unsaved Changes" })
531
+ /* @__PURE__ */ t(Ue, { className: "text-xl", children: "Unsaved Changes" })
542
532
  ] }),
543
- /* @__PURE__ */ t(Ue, { className: "pt-2 text-base leading-relaxed", children: "You have unsaved changes to this dashboard. What would you like to do?" })
533
+ /* @__PURE__ */ t(Te, { className: "pt-2 text-base leading-relaxed", children: "You have unsaved changes to this dashboard. What would you like to do?" })
544
534
  ] }),
545
535
  /* @__PURE__ */ r(Fe, { className: "flex-col gap-2 sm:flex-row sm:gap-2", children: [
546
536
  /* @__PURE__ */ t(
@@ -598,7 +588,7 @@ function Et({
598
588
  Ve,
599
589
  {
600
590
  tooltip: "Schedule Dashboard",
601
- className: U("h-7 p-2", e),
591
+ className: T("h-7 p-2", e),
602
592
  onClick: () => c(!0),
603
593
  children: /* @__PURE__ */ t(ze, { className: "size-4" })
604
594
  }
@@ -625,9 +615,9 @@ function mt({
625
615
  }, m = () => {
626
616
  switch (e.status) {
627
617
  case "completed":
628
- return /* @__PURE__ */ t(et, { className: "mt-0.5 h-5 w-5 shrink-0 text-green-600" });
618
+ return /* @__PURE__ */ t(He, { className: "mt-0.5 h-5 w-5 shrink-0 text-green-600" });
629
619
  case "failed":
630
- return /* @__PURE__ */ t(Ke, { className: "mt-0.5 h-5 w-5 shrink-0 text-destructive" });
620
+ return /* @__PURE__ */ t(et, { className: "mt-0.5 h-5 w-5 shrink-0 text-destructive" });
631
621
  default:
632
622
  return /* @__PURE__ */ t(H, { className: "text-foreground-muted mt-0.5 h-5 w-5 shrink-0 animate-spin" });
633
623
  }
@@ -846,11 +836,11 @@ function ht() {
846
836
  ] });
847
837
  }
848
838
  function Dt() {
849
- const e = I((s) => s.activeExports), a = He(), c = e.size > 0, n = Array.from(e.values()).some(
839
+ const e = I((s) => s.activeExports), a = je(), c = e.size > 0, n = Array.from(e.values()).some(
850
840
  (s) => s.status === "completed" || s.status === "failed"
851
841
  ), l = a > 0 ? a > 9 ? "9+" : String(a) : null;
852
- return /* @__PURE__ */ r(je, { children: [
853
- /* @__PURE__ */ t(Ge, { asChild: !0, children: /* @__PURE__ */ r(
842
+ return /* @__PURE__ */ r(Ge, { children: [
843
+ /* @__PURE__ */ t(Xe, { asChild: !0, children: /* @__PURE__ */ r(
854
844
  S,
855
845
  {
856
846
  variant: "ghost",
@@ -858,7 +848,7 @@ function Dt() {
858
848
  className: "relative h-8 w-8",
859
849
  "aria-label": "Export notifications",
860
850
  children: [
861
- /* @__PURE__ */ t(Xe, { className: "h-4 w-4" }),
851
+ /* @__PURE__ */ t(qe, { className: "h-4 w-4" }),
862
852
  c && /* @__PURE__ */ t(
863
853
  "span",
864
854
  {
@@ -869,7 +859,7 @@ function Dt() {
869
859
  ]
870
860
  }
871
861
  ) }),
872
- /* @__PURE__ */ t(qe, { className: "w-80 p-0", align: "end", sideOffset: 8, children: /* @__PURE__ */ t(ht, {}) })
862
+ /* @__PURE__ */ t(We, { className: "w-80 p-0", align: "end", sideOffset: 8, children: /* @__PURE__ */ t(ht, {}) })
873
863
  ] });
874
864
  }
875
865
  export {
@@ -1,14 +1,9 @@
1
- "use strict";const f=require("react"),t=require("./index-tt1rwTc8.js"),e=require("react/jsx-runtime"),N=require("./editor-action-buttons-WLwpPoSo.js"),T=require("./use-visual-utils-BkmyEMSD.js"),I=require("./index-8Crk3ROJ.js");/**
1
+ "use strict";const f=require("react"),t=require("./index-D59dkH2b.js"),e=require("react/jsx-runtime"),N=require("./editor-action-buttons-Bftd6Bfx.js"),T=require("./use-visual-utils-TGjvLx_R.js"),I=require("./index-8Crk3ROJ.js");/**
2
2
  * @license lucide-react v0.453.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
5
5
  * See the LICENSE file in the root directory of this source tree.
6
- */const P=t.createLucideIcon("CircleCheck",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);/**
7
- * @license lucide-react v0.453.0 - ISC
8
- *
9
- * This source code is licensed under the ISC license.
10
- * See the LICENSE file in the root directory of this source tree.
11
- */const V=t.createLucideIcon("CirclePlus",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M8 12h8",key:"1wcyev"}],["path",{d:"M12 8v8",key:"napkw2"}]]);/**
6
+ */const P=t.createLucideIcon("CirclePlus",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M8 12h8",key:"1wcyev"}],["path",{d:"M12 8v8",key:"napkw2"}]]);/**
12
7
  * @license lucide-react v0.453.0 - ISC
13
8
  *
14
9
  * This source code is licensed under the ISC license.
@@ -18,4 +13,4 @@
18
13
  *
19
14
  * This source code is licensed under the ISC license.
20
15
  * See the LICENSE file in the root directory of this source tree.
21
- */const M=t.createLucideIcon("RefreshCw",[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]]),R=1e4,B=15e3,z=3e4,O=3e4,$=12e4,U=2*60*60*1e3;function q(s){const r=Date.now()-s.getTime();return r<O?R:r<$?B:z}function H(){const{authToken:s,tokenProps:r}=t.useSemaphorContext(),c=t.useExportStore(g=>g.activeExports),[o,h]=f.useState(typeof document<"u"?!document.hidden:!0),i=f.useRef(null),n=f.useRef(!1),a=f.useRef(void 0),m=r==null?void 0:r.apiServiceUrl,d=s==null?void 0:s.accessToken,v=f.useCallback(()=>{const g=t.useExportStore.getState().activeExports;return Array.from(g.values()).filter(b=>t.isExportInProgress(b.status))},[]);f.useEffect(()=>{if(typeof document>"u")return;const g=()=>{h(!document.hidden)};return document.addEventListener("visibilitychange",g),()=>{document.removeEventListener("visibilitychange",g)}},[]);const C=f.useCallback(async()=>{if(!m||!d){n.current=!1;return}const g=v();if(g.length===0){n.current=!1;return}const b=Date.now(),E=g.filter(x=>b-x.startedAt.getTime()>U);if(E.length>0){const{updateExport:x}=t.useExportStore.getState().actions;for(const l of E)x(l.id,{status:"failed",error:"Export timed out. Please try again or contact support.",lastUpdatedAt:new Date})}const p=g.filter(x=>b-x.startedAt.getTime()<=U);if(p.length===0){n.current=!1;return}const j=await Promise.allSettled(p.map(async x=>{try{const l=await t.getExportStatus(m,d,x.id);let w;if(l.status==="completed")try{w=await t.getDownloadUrl(m,d,x.id)}catch(D){console.error(`[useExportPolling] Failed to get download URL for ${x.id}:`,D)}return{id:x.id,status:l.status,progress:l.progress,completedChunks:l.completedChunks,completedAt:l.completedAt?new Date(l.completedAt):void 0,lastUpdatedAt:new Date,fileSize:l.fileSize,error:l.error,downloadUrl:w}}catch(l){return console.error(`[useExportPolling] Failed to poll export ${x.id}:`,l),null}})),{updateExport:S}=t.useExportStore.getState().actions;for(const x of j)x.status==="fulfilled"&&x.value&&S(x.value.id,x.value);const u=v();if(u.length>0&&!document.hidden){const x=u.reduce((w,D)=>D.startedAt<w?D.startedAt:w,u[0].startedAt),l=q(x);i.current&&clearTimeout(i.current),i.current=setTimeout(()=>{var w;(w=a.current)==null||w.call(a)},l)}else n.current=!1},[m,d,v]);return f.useEffect(()=>{a.current=C},[C]),f.useEffect(()=>{var b;v().length>0&&o&&!n.current&&(n.current=!0,(b=a.current)==null||b.call(a))},[c,o,v]),f.useEffect(()=>{var b;const g=v();o&&g.length>0&&!n.current&&(n.current=!0,(b=a.current)==null||b.call(a))},[o,v]),f.useEffect(()=>{!o&&i.current&&(clearTimeout(i.current),i.current=null,n.current=!1)},[o]),f.useEffect(()=>()=>{i.current&&(clearTimeout(i.current),i.current=null)},[]),{isPolling:n.current,isTabVisible:o,inProgressCount:v().length}}function _(){const{authToken:s,tokenProps:r}=t.useSemaphorContext(),c=t.useExportStore(a=>a.activeExports),{addExport:o}=t.useExportActions(),h=f.useRef(!1),i=r==null?void 0:r.apiServiceUrl,n=s==null?void 0:s.accessToken;f.useEffect(()=>{if(h.current||!i||!n)return;(async()=>{try{const{exports:m}=await t.getExports(i,n,{status:["pending","processing","chunking","compacting","completed","failed"],limit:20});for(const d of m){if(c.has(d.id))continue;const v=d.totalChunks?Math.round(d.completedChunks/d.totalChunks*100):0;let C;if(d.status==="completed")try{C=await t.getDownloadUrl(i,n,d.id)}catch(b){console.error(`[useExportRecovery] Failed to get download URL for ${d.id}:`,b)}const g={id:d.id,status:d.status,progress:v,title:X(d),totalRows:d.totalRows,totalChunks:d.totalChunks,completedChunks:d.completedChunks,startedAt:new Date(d.createdAt),lastUpdatedAt:new Date,completedAt:d.completedAt?new Date(d.completedAt):void 0,fileSize:d.fileSize,error:d.error,expiresAt:new Date(d.expiresAt),downloadUrl:C};o(g)}h.current=!0}catch(m){console.error("[useExportRecovery] Failed to recover exports:",m),h.current=!0}})()},[i,n,o,c])}function X(s){return s.title?s.title:t.isExportInProgress(s.status)?"Export in progress...":s.status==="completed"?"Export completed":s.status==="failed"?"Export failed":"Export"}function G({open:s,onOpenChange:r,isLibraryVisual:c,currentVisualName:o,isSaving:h=!1,onConfirm:i}){const[n,a]=f.useState(c&&o?`Copy of ${o}`:o||""),[m,d]=f.useState(""),[v,C]=f.useState(!c),[g,b]=f.useState(!0);f.useEffect(()=>{s&&(a(c&&o?`Copy of ${o}`:o||""),d(""),C(!c),b(!0))},[s,c,o]);const E=()=>{n.trim()&&(!v&&!g||i({name:n.trim(),description:m.trim()||void 0,saveToLibrary:v,saveToCurrentDashboard:g}))},p=n.trim()&&(v||g);return e.jsx(t.Dialog,{open:s,onOpenChange:r,children:e.jsxs(t.DialogContent,{className:"sm:max-w-[425px]",children:[e.jsxs(t.DialogHeader,{children:[e.jsx(t.DialogTitle,{children:"Save Visual As"}),e.jsx(t.DialogDescription,{children:c?"Create a copy of this visual with a new name":"Save this visual to make it reusable"})]}),e.jsxs("div",{className:"grid gap-4 py-4",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(t.Label,{htmlFor:"name",children:"Name"}),e.jsx(t.Input,{id:"name",value:n,onChange:j=>a(j.target.value),placeholder:"Enter visual name",disabled:h})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(t.Label,{htmlFor:"description",children:"Description (optional)"}),e.jsx(t.Textarea,{id:"description",value:m,onChange:j=>d(j.target.value),placeholder:"Enter visual description",rows:3,disabled:h})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(t.Label,{children:"Save to:"}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(t.Checkbox,{id:"save-to-dashboard",checked:g,onCheckedChange:j=>b(!!j),disabled:h}),e.jsxs("label",{htmlFor:"save-to-dashboard",className:"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",children:["Current Dashboard",e.jsx("span",{className:"ml-2 text-xs text-muted-foreground",children:c?"(add copy to this dashboard)":"(keep as local visual)"})]})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(t.Checkbox,{id:"save-to-library",checked:v,onCheckedChange:j=>C(!!j),disabled:h}),e.jsxs("label",{htmlFor:"save-to-library",className:"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",children:["Visual Library",e.jsx("span",{className:"ml-2 text-xs text-muted-foreground",children:c?"(save as new reusable visual)":"(make available to all dashboards)"})]})]})]}),!v&&!g&&e.jsx("p",{className:"text-sm text-destructive",children:"Please select at least one destination"})]})]}),e.jsxs(t.DialogFooter,{children:[e.jsx(t.Button,{variant:"outline",onClick:()=>r(!1),disabled:h,children:"Cancel"}),e.jsxs(t.Button,{onClick:E,disabled:!p||h,children:[h&&e.jsx(t.LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),h?"Saving...":"Save"]})]})]})})}function W(){const[s,r]=f.useState(!1),[c,o]=f.useState(!1),[h,i]=f.useState(null),n=t.useEditorStore(l=>l.frame),a=t.useEditorStore(l=>l.card),m=t.useSelectedVisual(),d=t.useDashboardStore(l=>l.selectedSheetId),v=t.useDashboardStore(l=>l.actions.setIsDashboardPanelOpen),{getUpdatedFrame:C}=T.useVisualUtils(),{selectVisual:g}=t.useManagementActions(),{addFrame:b,setSelectedFrameId:E,setIsVisualEditing:p}=t.useDashboardActions(),j=!!(n!=null&&n.visualId),S=(()=>{var l,w;return((l=n==null?void 0:n.cards)==null?void 0:l.length)===1&&((w=n.cards[0])!=null&&w.title)?n.cards[0].title:m!=null&&m.title?m.title:(a==null?void 0:a.title)||"Untitled Visual"})(),u=t.useCreateVisualWithFrame(l=>{if(l!=null&&l.id){if(g(l),c&&h&&d){const w={...h,id:t.v4(),visualId:l.id};b(d,w,"end"),E(w.id),o(!1),i(null),p(!1)}v(!0),r(!1)}});return{saveAsDialogOpen:s,setSaveAsDialogOpen:r,handleSaveAs:async l=>{if(!d){t.ue.error("No sheet selected");return}const w=C(),A=w.cards.length===1?{...w,cards:w.cards.map(y=>({...y,title:l.name}))}:w;if(l.saveToLibrary){o(l.saveToCurrentDashboard),i(A);const y={title:l.name,description:l.description,frameObject:A,isPrivate:!1};u.mutate(y)}else if(l.saveToCurrentDashboard){const y={...A,id:t.v4(),visualId:void 0};b(d,y,"end"),E(y.id),t.ue.success("Visual saved to dashboard"),r(!1),p(!1)}},isLibraryVisual:j,currentVisualName:S,isSaving:u.isPending}}function Q({className:s}){const r=t.useEditorStore(u=>u.frame),c=t.useEditorStore(u=>u.card),o=t.useManagementStore(u=>u.selectedVisual),h=t.useDashboardStore(u=>u.selectedFrameId),i=t.useDashboardStore(u=>u.selectedSheetId),{setIsVisualEditing:n}=t.useDashboardActions(),a=!!(r!=null&&r.visualId||o!=null&&o.id),m=!!(r!=null&&r.visualId&&h),d=a&&!m,{saveAsDialogOpen:v,setSaveAsDialogOpen:C,handleSaveAs:g,isLibraryVisual:b,currentVisualName:E,isSaving:p}=W(),{handleAddLibraryVisual:j}=T.useVisualUtils(),S=async()=>{if(!i){t.ue.error("No dashboard sheet selected");return}if(!o){t.ue.error("No visual selected");return}const u=await j(o);u.success?(t.ue.success("Visual added to dashboard"),n(!1)):t.ue.error(u.error||"Failed to add visual to dashboard")};return e.jsxs(e.Fragment,{children:[!a&&e.jsx(N.EditorAcceptButton,{className:s,variant:"default"}),a&&e.jsxs(e.Fragment,{children:[m&&e.jsx(N.VisualApplyLocalButton,{className:s}),d&&i&&c&&(c.sql||t.hasValidCardConfig(c.config))&&e.jsxs(t.Button,{onClick:S,className:t.cn(s),size:"sm",variant:"outline",children:[e.jsx(V,{className:"mr-2 size-4 font-bold"}),"Add to Dashboard"]}),d&&e.jsx(N.VisualSaveButton,{className:s,variant:"default"}),m&&e.jsx(N.VisualSaveAndApplyButton,{className:s}),e.jsxs(t.DropdownMenu,{modal:!1,children:[e.jsx(t.DropdownMenuTrigger,{asChild:!0,children:e.jsx(t.Button,{variant:"outline",size:"sm",className:t.cn(s,"w-8 p-0"),children:e.jsx(t.EllipsisVertical,{className:"h-4 w-4"})})}),e.jsx(t.DropdownMenuContent,{align:"end",children:e.jsxs(t.DropdownMenuItem,{onClick:u=>{u.stopPropagation(),C(!0)},children:[e.jsx(N.Save,{className:"mr-2 h-4 w-4"}),"Save As..."]})})]})]}),!a&&e.jsxs(t.DropdownMenu,{modal:!1,children:[e.jsx(t.DropdownMenuTrigger,{asChild:!0,children:e.jsx(t.Button,{variant:"outline",size:"sm",className:t.cn(s,"w-8 p-0"),children:e.jsx(t.EllipsisVertical,{className:"h-4 w-4"})})}),e.jsx(t.DropdownMenuContent,{align:"end",children:e.jsxs(t.DropdownMenuItem,{onClick:()=>C(!0),children:[e.jsx(N.Save,{className:"mr-2 h-4 w-4"}),"Save As..."]})})]}),e.jsx(N.EditorCancelButton,{className:s}),e.jsx(G,{open:v,onOpenChange:u=>{p||C(u)},isLibraryVisual:b,currentVisualName:E,isSaving:p,onConfirm:g})]})}function Y({className:s,switchClassName:r}){const c=t.useEditorStore(a=>a.isDevMode),o=t.useDashboardStore(a=>a.isVisualEditing),{setIsDevMode:h}=t.useEditorActions(),{config:i}=f.useContext(t.SemaphorContext).tokenProps,n=(i==null?void 0:i.showAdvancedMode)!==!1;return!o||!n?null:e.jsxs("div",{className:t.cn("flex items-center space-x-2",s),children:[e.jsx(t.DevModeSwitch,{className:t.cn("",r),checked:c,onCheckedChange:()=>h(!c),id:"advanced-mode",icon:e.jsx(t.CodeXml,{className:"h-4 w-4"}),tooltip:"Advanced Mode"}),e.jsx("label",{htmlFor:"advanced-mode",className:"sr-only",children:"Advanced Mode"})]})}function Z({open:s,onOpenChange:r,onSave:c,onDiscard:o,isSaving:h}){const i=n=>{!n&&h||r(n)};return e.jsx(t.AlertDialog,{open:s,onOpenChange:i,children:e.jsxs(t.AlertDialogContent,{className:"max-w-md",children:[e.jsxs(t.AlertDialogHeader,{children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-full bg-amber-100",children:e.jsx(t.TriangleAlert,{className:"h-5 w-5 text-amber-600"})}),e.jsx(t.AlertDialogTitle,{className:"text-xl",children:"Unsaved Changes"})]}),e.jsx(t.AlertDialogDescription,{className:"pt-2 text-base leading-relaxed",children:"You have unsaved changes to this dashboard. What would you like to do?"})]}),e.jsxs(t.AlertDialogFooter,{className:"flex-col gap-2 sm:flex-row sm:gap-2",children:[e.jsx(t.AlertDialogCancel,{disabled:h,className:"order-1 m-0 border-border/50 sm:order-1",children:"Cancel"}),e.jsx("button",{onClick:o,disabled:h,className:"order-2 rounded-md border border-destructive/20 bg-destructive/10 px-4 py-2 text-sm font-medium text-destructive transition-colors hover:bg-destructive/20 disabled:pointer-events-none disabled:opacity-50 sm:order-2",children:"Discard"}),e.jsx(t.AlertDialogAction,{onClick:c,disabled:h,className:"order-3 m-0 bg-primary text-primary-foreground hover:bg-primary/90 sm:order-3",children:h?e.jsxs(e.Fragment,{children:[e.jsx(t.LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Saving..."]}):"Save & Close"})]})]})})}function J(s,r,c,o){f.useEffect(()=>{s&&!c&&r&&o(t.cloneDeep(r))},[s,c,r,o])}function K({triggerButtonClassName:s}){const[r,c]=f.useState(!1),o=t.useDashboardStore(a=>{var m;return(m=a.dashboard)==null?void 0:m.id}),h=t.useDashboardStore(a=>{var m;return(m=a.dashboard)==null?void 0:m.title}),i=t.useDashboardStore(a=>{var m;return(m=a.dashboard)==null?void 0:m.sheets}),n=t.useDashboardStore(a=>a.selectedSheetId);return i==null||i.find(a=>a.id===n),o?e.jsxs(e.Fragment,{children:[e.jsx(t.IconButton,{tooltip:"Schedule Dashboard",className:t.cn("h-7 p-2",s),onClick:()=>c(!0),children:e.jsx(t.Clock,{className:"size-4"})}),e.jsx(t.EmailScheduleDialog,{open:r,onOpenChange:c,dashboardId:o,dashboardName:h})]}):null}function F({export:s,onRemove:r}){const c=()=>{s.downloadUrl&&window.open(s.downloadUrl,"_blank")},o=a=>{a.stopPropagation(),r==null||r(s.id)},h=()=>{switch(s.status){case"completed":return e.jsx(P,{className:"mt-0.5 h-5 w-5 shrink-0 text-green-600"});case"failed":return e.jsx(N.CircleX,{className:"mt-0.5 h-5 w-5 shrink-0 text-destructive"});default:return e.jsx(t.LoaderCircle,{className:"text-foreground-muted mt-0.5 h-5 w-5 shrink-0 animate-spin"})}},i=t.isExportInProgress(s.status),n=(()=>{switch(s.status){case"pending":return"Queued...";case"processing":return"Processing...";case"chunking":return"Processing...";case"compacting":return"Finalizing...";default:return"Processing..."}})();return e.jsxs("div",{className:"group p-4 transition-colors hover:bg-muted/50",children:[e.jsxs("div",{className:"mb-2 flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"flex min-w-0 flex-1 items-start gap-3",children:[h(),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("h4",{className:"mb-1 truncate text-sm font-medium",children:s.title}),s.status==="completed"&&e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[e.jsxs("span",{children:[s.totalRows.toLocaleString()," rows"]}),s.fileSize&&e.jsxs(e.Fragment,{children:[e.jsx("span",{children:"•"}),e.jsx("span",{children:t.formatFileSize(s.fileSize)})]})]}),i&&e.jsx("div",{className:"text-xs text-muted-foreground",children:n}),s.status==="failed"&&e.jsx("div",{className:"line-clamp-2 text-xs text-destructive",children:s.error||"Export failed"})]})]}),e.jsx(t.Button,{variant:"ghost",size:"icon",className:"h-6 w-6 shrink-0 opacity-0 transition-opacity group-hover:opacity-100",onClick:o,"aria-label":"Remove notification",children:e.jsx(t.X,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:"ml-8",children:[s.status==="completed"&&e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:I.formatDistanceToNow(s.startedAt,{addSuffix:!0})}),s.downloadUrl&&e.jsxs(t.Button,{size:"sm",variant:"outline",className:"h-8 bg-transparent",onClick:c,children:[e.jsx(t.Download,{className:"mr-1.5 h-3.5 w-3.5"}),"Download"]})]}),i&&e.jsxs("div",{children:[e.jsx(t.Progress,{value:s.progress,className:"h-1.5"}),e.jsxs("span",{className:"mt-1 block text-xs text-muted-foreground",children:[s.progress,"% complete"]})]}),s.status==="failed"&&e.jsx("span",{className:"text-xs text-muted-foreground",children:I.formatDistanceToNow(s.startedAt,{addSuffix:!0})})]})]})}function L(){const{authToken:s,tokenProps:r}=t.useSemaphorContext(),c=t.useExportStore(p=>p.activeExports),{clearCompleted:o,removeExport:h,updateExport:i}=t.useExportActions(),[n,a]=f.useState(!1),[m,d]=f.useState(!1),v=Array.from(c.values()).sort((p,j)=>j.startedAt.getTime()-p.startedAt.getTime()),C=v.some(p=>p.status==="completed"||p.status==="failed"),g=f.useCallback(async()=>{const p=r==null?void 0:r.apiServiceUrl,j=s==null?void 0:s.accessToken;if(!(!p||!j)){a(!0);try{const S=Array.from(c.values());await Promise.all(S.map(async u=>{try{const x=await t.getExportStatus(p,j,u.id);let l;if(x.status==="completed")try{l=await t.getDownloadUrl(p,j,u.id)}catch(w){console.error(`Failed to get download URL for ${u.id}:`,w)}i(u.id,{status:x.status,progress:x.progress,completedChunks:x.completedChunks,completedAt:x.completedAt?new Date(x.completedAt):void 0,lastUpdatedAt:new Date,fileSize:x.fileSize,error:x.error,downloadUrl:l})}catch(x){console.error(`Failed to refresh export ${u.id}:`,x)}}))}finally{a(!1)}}},[c,s==null?void 0:s.accessToken,r==null?void 0:r.apiServiceUrl,i]),b=f.useCallback(async()=>{const p=r==null?void 0:r.apiServiceUrl,j=s==null?void 0:s.accessToken;if(!p||!j){o();return}d(!0);try{const S=v.filter(u=>u.status==="completed"||u.status==="failed");await Promise.all(S.map(u=>t.cancelExport(p,j,u.id).catch(x=>console.error(`Failed to delete export ${u.id}:`,x)))),o()}finally{d(!1)}},[v,r==null?void 0:r.apiServiceUrl,s==null?void 0:s.accessToken,o]),E=f.useCallback(async p=>{const j=r==null?void 0:r.apiServiceUrl,S=s==null?void 0:s.accessToken;if(j&&S)try{await t.cancelExport(j,S,p)}catch(u){console.error(`Failed to cancel export ${p}:`,u)}h(p)},[r==null?void 0:r.apiServiceUrl,s==null?void 0:s.accessToken,h]);return v.length===0?e.jsxs("div",{className:"p-6 text-center",children:[e.jsx(k,{className:"mx-auto mb-2 h-8 w-8 text-muted-foreground"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"No active exports"}),e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"Large exports will appear here"})]}):e.jsxs("div",{className:"flex flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between border-b px-4 py-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(k,{className:"h-5 w-5 text-muted-foreground"}),e.jsx("h4",{className:"font-semibold",children:"Exports"})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(t.Button,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0",onClick:g,disabled:n,title:"Refresh status",children:e.jsx(M,{className:`h-4 w-4 ${n?"animate-spin":""}`})}),C&&e.jsx(t.Button,{variant:"ghost",size:"sm",className:"h-7 px-2 text-sm",onClick:b,disabled:m,children:m?"Clearing...":"Clear all"})]})]}),e.jsx("div",{className:"max-h-[350px] overflow-y-auto",children:e.jsx("div",{className:"divide-y",children:v.map(p=>e.jsx(F,{export:p,onRemove:E},p.id))})})]})}function ee(){const s=t.useExportStore(a=>a.activeExports),r=t.useInProgressExportsCount(),c=s.size>0,o=Array.from(s.values()).some(a=>a.status==="completed"||a.status==="failed"),i=r>0?r>9?"9+":String(r):null,n=c;return e.jsxs(t.Popover,{children:[e.jsx(t.PopoverTrigger,{asChild:!0,children:e.jsxs(t.Button,{variant:"ghost",size:"icon",className:"relative h-8 w-8","aria-label":"Export notifications",children:[e.jsx(t.Bell,{className:"h-4 w-4"}),n&&e.jsx("span",{className:`absolute flex items-center justify-center rounded-full bg-primary text-primary-foreground ${i?"-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"}`,children:i})]})}),e.jsx(t.PopoverContent,{className:"w-80 p-0",align:"end",sideOffset:8,children:e.jsx(L,{})})]})}exports.AdvancedModeToggle=Y;exports.ExportNotificationItem=F;exports.ExportNotificationList=L;exports.NotificationBell=ee;exports.RefreshCw=M;exports.ScheduleDashboard=K;exports.UnsavedChangesAlert=Z;exports.VisualEditingControls=Q;exports.useExportPolling=H;exports.useExportRecovery=_;exports.usePristineSnapshotInitializer=J;
16
+ */const M=t.createLucideIcon("RefreshCw",[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]]),V=1e4,R=15e3,B=3e4,z=3e4,O=12e4,U=2*60*60*1e3;function $(s){const r=Date.now()-s.getTime();return r<z?V:r<O?R:B}function q(){const{authToken:s,tokenProps:r}=t.useSemaphorContext(),c=t.useExportStore(g=>g.activeExports),[o,h]=f.useState(typeof document<"u"?!document.hidden:!0),i=f.useRef(null),n=f.useRef(!1),a=f.useRef(void 0),m=r==null?void 0:r.apiServiceUrl,d=s==null?void 0:s.accessToken,v=f.useCallback(()=>{const g=t.useExportStore.getState().activeExports;return Array.from(g.values()).filter(b=>t.isExportInProgress(b.status))},[]);f.useEffect(()=>{if(typeof document>"u")return;const g=()=>{h(!document.hidden)};return document.addEventListener("visibilitychange",g),()=>{document.removeEventListener("visibilitychange",g)}},[]);const C=f.useCallback(async()=>{if(!m||!d){n.current=!1;return}const g=v();if(g.length===0){n.current=!1;return}const b=Date.now(),E=g.filter(x=>b-x.startedAt.getTime()>U);if(E.length>0){const{updateExport:x}=t.useExportStore.getState().actions;for(const l of E)x(l.id,{status:"failed",error:"Export timed out. Please try again or contact support.",lastUpdatedAt:new Date})}const p=g.filter(x=>b-x.startedAt.getTime()<=U);if(p.length===0){n.current=!1;return}const j=await Promise.allSettled(p.map(async x=>{try{const l=await t.getExportStatus(m,d,x.id);let w;if(l.status==="completed")try{w=await t.getDownloadUrl(m,d,x.id)}catch(y){console.error(`[useExportPolling] Failed to get download URL for ${x.id}:`,y)}return{id:x.id,status:l.status,progress:l.progress,completedChunks:l.completedChunks,completedAt:l.completedAt?new Date(l.completedAt):void 0,lastUpdatedAt:new Date,fileSize:l.fileSize,error:l.error,downloadUrl:w}}catch(l){return console.error(`[useExportPolling] Failed to poll export ${x.id}:`,l),null}})),{updateExport:S}=t.useExportStore.getState().actions;for(const x of j)x.status==="fulfilled"&&x.value&&S(x.value.id,x.value);const u=v();if(u.length>0&&!document.hidden){const x=u.reduce((w,y)=>y.startedAt<w?y.startedAt:w,u[0].startedAt),l=$(x);i.current&&clearTimeout(i.current),i.current=setTimeout(()=>{var w;(w=a.current)==null||w.call(a)},l)}else n.current=!1},[m,d,v]);return f.useEffect(()=>{a.current=C},[C]),f.useEffect(()=>{var b;v().length>0&&o&&!n.current&&(n.current=!0,(b=a.current)==null||b.call(a))},[c,o,v]),f.useEffect(()=>{var b;const g=v();o&&g.length>0&&!n.current&&(n.current=!0,(b=a.current)==null||b.call(a))},[o,v]),f.useEffect(()=>{!o&&i.current&&(clearTimeout(i.current),i.current=null,n.current=!1)},[o]),f.useEffect(()=>()=>{i.current&&(clearTimeout(i.current),i.current=null)},[]),{isPolling:n.current,isTabVisible:o,inProgressCount:v().length}}function H(){const{authToken:s,tokenProps:r}=t.useSemaphorContext(),c=t.useExportStore(a=>a.activeExports),{addExport:o}=t.useExportActions(),h=f.useRef(!1),i=r==null?void 0:r.apiServiceUrl,n=s==null?void 0:s.accessToken;f.useEffect(()=>{if(h.current||!i||!n)return;(async()=>{try{const{exports:m}=await t.getExports(i,n,{status:["pending","processing","chunking","compacting","completed","failed"],limit:20});for(const d of m){if(c.has(d.id))continue;const v=d.totalChunks?Math.round(d.completedChunks/d.totalChunks*100):0;let C;if(d.status==="completed")try{C=await t.getDownloadUrl(i,n,d.id)}catch(b){console.error(`[useExportRecovery] Failed to get download URL for ${d.id}:`,b)}const g={id:d.id,status:d.status,progress:v,title:_(d),totalRows:d.totalRows,totalChunks:d.totalChunks,completedChunks:d.completedChunks,startedAt:new Date(d.createdAt),lastUpdatedAt:new Date,completedAt:d.completedAt?new Date(d.completedAt):void 0,fileSize:d.fileSize,error:d.error,expiresAt:new Date(d.expiresAt),downloadUrl:C};o(g)}h.current=!0}catch(m){console.error("[useExportRecovery] Failed to recover exports:",m),h.current=!0}})()},[i,n,o,c])}function _(s){return s.title?s.title:t.isExportInProgress(s.status)?"Export in progress...":s.status==="completed"?"Export completed":s.status==="failed"?"Export failed":"Export"}function X({open:s,onOpenChange:r,isLibraryVisual:c,currentVisualName:o,isSaving:h=!1,onConfirm:i}){const[n,a]=f.useState(c&&o?`Copy of ${o}`:o||""),[m,d]=f.useState(""),[v,C]=f.useState(!c),[g,b]=f.useState(!0);f.useEffect(()=>{s&&(a(c&&o?`Copy of ${o}`:o||""),d(""),C(!c),b(!0))},[s,c,o]);const E=()=>{n.trim()&&(!v&&!g||i({name:n.trim(),description:m.trim()||void 0,saveToLibrary:v,saveToCurrentDashboard:g}))},p=n.trim()&&(v||g);return e.jsx(t.Dialog,{open:s,onOpenChange:r,children:e.jsxs(t.DialogContent,{className:"sm:max-w-[425px]",children:[e.jsxs(t.DialogHeader,{children:[e.jsx(t.DialogTitle,{children:"Save Visual As"}),e.jsx(t.DialogDescription,{children:c?"Create a copy of this visual with a new name":"Save this visual to make it reusable"})]}),e.jsxs("div",{className:"grid gap-4 py-4",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(t.Label,{htmlFor:"name",children:"Name"}),e.jsx(t.Input,{id:"name",value:n,onChange:j=>a(j.target.value),placeholder:"Enter visual name",disabled:h})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(t.Label,{htmlFor:"description",children:"Description (optional)"}),e.jsx(t.Textarea,{id:"description",value:m,onChange:j=>d(j.target.value),placeholder:"Enter visual description",rows:3,disabled:h})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(t.Label,{children:"Save to:"}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(t.Checkbox,{id:"save-to-dashboard",checked:g,onCheckedChange:j=>b(!!j),disabled:h}),e.jsxs("label",{htmlFor:"save-to-dashboard",className:"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",children:["Current Dashboard",e.jsx("span",{className:"ml-2 text-xs text-muted-foreground",children:c?"(add copy to this dashboard)":"(keep as local visual)"})]})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(t.Checkbox,{id:"save-to-library",checked:v,onCheckedChange:j=>C(!!j),disabled:h}),e.jsxs("label",{htmlFor:"save-to-library",className:"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",children:["Visual Library",e.jsx("span",{className:"ml-2 text-xs text-muted-foreground",children:c?"(save as new reusable visual)":"(make available to all dashboards)"})]})]})]}),!v&&!g&&e.jsx("p",{className:"text-sm text-destructive",children:"Please select at least one destination"})]})]}),e.jsxs(t.DialogFooter,{children:[e.jsx(t.Button,{variant:"outline",onClick:()=>r(!1),disabled:h,children:"Cancel"}),e.jsxs(t.Button,{onClick:E,disabled:!p||h,children:[h&&e.jsx(t.LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),h?"Saving...":"Save"]})]})]})})}function G(){const[s,r]=f.useState(!1),[c,o]=f.useState(!1),[h,i]=f.useState(null),n=t.useEditorStore(l=>l.frame),a=t.useEditorStore(l=>l.card),m=t.useSelectedVisual(),d=t.useDashboardStore(l=>l.selectedSheetId),v=t.useDashboardStore(l=>l.actions.setIsDashboardPanelOpen),{getUpdatedFrame:C}=T.useVisualUtils(),{selectVisual:g}=t.useManagementActions(),{addFrame:b,setSelectedFrameId:E,setIsVisualEditing:p}=t.useDashboardActions(),j=!!(n!=null&&n.visualId),S=(()=>{var l,w;return((l=n==null?void 0:n.cards)==null?void 0:l.length)===1&&((w=n.cards[0])!=null&&w.title)?n.cards[0].title:m!=null&&m.title?m.title:(a==null?void 0:a.title)||"Untitled Visual"})(),u=t.useCreateVisualWithFrame(l=>{if(l!=null&&l.id){if(g(l),c&&h&&d){const w={...h,id:t.v4(),visualId:l.id};b(d,w,"end"),E(w.id),o(!1),i(null),p(!1)}v(!0),r(!1)}});return{saveAsDialogOpen:s,setSaveAsDialogOpen:r,handleSaveAs:async l=>{if(!d){t.ue.error("No sheet selected");return}const w=C(),A=w.cards.length===1?{...w,cards:w.cards.map(D=>({...D,title:l.name}))}:w;if(l.saveToLibrary){o(l.saveToCurrentDashboard),i(A);const D={title:l.name,description:l.description,frameObject:A,isPrivate:!1};u.mutate(D)}else if(l.saveToCurrentDashboard){const D={...A,id:t.v4(),visualId:void 0};b(d,D,"end"),E(D.id),t.ue.success("Visual saved to dashboard"),r(!1),p(!1)}},isLibraryVisual:j,currentVisualName:S,isSaving:u.isPending}}function W({className:s}){const r=t.useEditorStore(u=>u.frame),c=t.useEditorStore(u=>u.card),o=t.useManagementStore(u=>u.selectedVisual),h=t.useDashboardStore(u=>u.selectedFrameId),i=t.useDashboardStore(u=>u.selectedSheetId),{setIsVisualEditing:n}=t.useDashboardActions(),a=!!(r!=null&&r.visualId||o!=null&&o.id),m=!!(r!=null&&r.visualId&&h),d=a&&!m,{saveAsDialogOpen:v,setSaveAsDialogOpen:C,handleSaveAs:g,isLibraryVisual:b,currentVisualName:E,isSaving:p}=G(),{handleAddLibraryVisual:j}=T.useVisualUtils(),S=async()=>{if(!i){t.ue.error("No dashboard sheet selected");return}if(!o){t.ue.error("No visual selected");return}const u=await j(o);u.success?(t.ue.success("Visual added to dashboard"),n(!1)):t.ue.error(u.error||"Failed to add visual to dashboard")};return e.jsxs(e.Fragment,{children:[!a&&e.jsx(N.EditorAcceptButton,{className:s,variant:"default"}),a&&e.jsxs(e.Fragment,{children:[m&&e.jsx(N.VisualApplyLocalButton,{className:s}),d&&i&&c&&(c.sql||t.hasValidCardConfig(c.config))&&e.jsxs(t.Button,{onClick:S,className:t.cn(s),size:"sm",variant:"outline",children:[e.jsx(P,{className:"mr-2 size-4 font-bold"}),"Add to Dashboard"]}),d&&e.jsx(N.VisualSaveButton,{className:s,variant:"default"}),m&&e.jsx(N.VisualSaveAndApplyButton,{className:s}),e.jsxs(t.DropdownMenu,{modal:!1,children:[e.jsx(t.DropdownMenuTrigger,{asChild:!0,children:e.jsx(t.Button,{variant:"outline",size:"sm",className:t.cn(s,"w-8 p-0"),children:e.jsx(t.EllipsisVertical,{className:"h-4 w-4"})})}),e.jsx(t.DropdownMenuContent,{align:"end",children:e.jsxs(t.DropdownMenuItem,{onClick:u=>{u.stopPropagation(),C(!0)},children:[e.jsx(N.Save,{className:"mr-2 h-4 w-4"}),"Save As..."]})})]})]}),!a&&e.jsxs(t.DropdownMenu,{modal:!1,children:[e.jsx(t.DropdownMenuTrigger,{asChild:!0,children:e.jsx(t.Button,{variant:"outline",size:"sm",className:t.cn(s,"w-8 p-0"),children:e.jsx(t.EllipsisVertical,{className:"h-4 w-4"})})}),e.jsx(t.DropdownMenuContent,{align:"end",children:e.jsxs(t.DropdownMenuItem,{onClick:()=>C(!0),children:[e.jsx(N.Save,{className:"mr-2 h-4 w-4"}),"Save As..."]})})]}),e.jsx(N.EditorCancelButton,{className:s}),e.jsx(X,{open:v,onOpenChange:u=>{p||C(u)},isLibraryVisual:b,currentVisualName:E,isSaving:p,onConfirm:g})]})}function Q({className:s,switchClassName:r}){const c=t.useEditorStore(a=>a.isDevMode),o=t.useDashboardStore(a=>a.isVisualEditing),{setIsDevMode:h}=t.useEditorActions(),{config:i}=f.useContext(t.SemaphorContext).tokenProps,n=(i==null?void 0:i.showAdvancedMode)!==!1;return!o||!n?null:e.jsxs("div",{className:t.cn("flex items-center space-x-2",s),children:[e.jsx(t.DevModeSwitch,{className:t.cn("",r),checked:c,onCheckedChange:()=>h(!c),id:"advanced-mode",icon:e.jsx(t.CodeXml,{className:"h-4 w-4"}),tooltip:"Advanced Mode"}),e.jsx("label",{htmlFor:"advanced-mode",className:"sr-only",children:"Advanced Mode"})]})}function Y({open:s,onOpenChange:r,onSave:c,onDiscard:o,isSaving:h}){const i=n=>{!n&&h||r(n)};return e.jsx(t.AlertDialog,{open:s,onOpenChange:i,children:e.jsxs(t.AlertDialogContent,{className:"max-w-md",children:[e.jsxs(t.AlertDialogHeader,{children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-full bg-amber-100",children:e.jsx(t.TriangleAlert,{className:"h-5 w-5 text-amber-600"})}),e.jsx(t.AlertDialogTitle,{className:"text-xl",children:"Unsaved Changes"})]}),e.jsx(t.AlertDialogDescription,{className:"pt-2 text-base leading-relaxed",children:"You have unsaved changes to this dashboard. What would you like to do?"})]}),e.jsxs(t.AlertDialogFooter,{className:"flex-col gap-2 sm:flex-row sm:gap-2",children:[e.jsx(t.AlertDialogCancel,{disabled:h,className:"order-1 m-0 border-border/50 sm:order-1",children:"Cancel"}),e.jsx("button",{onClick:o,disabled:h,className:"order-2 rounded-md border border-destructive/20 bg-destructive/10 px-4 py-2 text-sm font-medium text-destructive transition-colors hover:bg-destructive/20 disabled:pointer-events-none disabled:opacity-50 sm:order-2",children:"Discard"}),e.jsx(t.AlertDialogAction,{onClick:c,disabled:h,className:"order-3 m-0 bg-primary text-primary-foreground hover:bg-primary/90 sm:order-3",children:h?e.jsxs(e.Fragment,{children:[e.jsx(t.LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Saving..."]}):"Save & Close"})]})]})})}function Z(s,r,c,o){f.useEffect(()=>{s&&!c&&r&&o(t.cloneDeep(r))},[s,c,r,o])}function J({triggerButtonClassName:s}){const[r,c]=f.useState(!1),o=t.useDashboardStore(a=>{var m;return(m=a.dashboard)==null?void 0:m.id}),h=t.useDashboardStore(a=>{var m;return(m=a.dashboard)==null?void 0:m.title}),i=t.useDashboardStore(a=>{var m;return(m=a.dashboard)==null?void 0:m.sheets}),n=t.useDashboardStore(a=>a.selectedSheetId);return i==null||i.find(a=>a.id===n),o?e.jsxs(e.Fragment,{children:[e.jsx(t.IconButton,{tooltip:"Schedule Dashboard",className:t.cn("h-7 p-2",s),onClick:()=>c(!0),children:e.jsx(t.Clock,{className:"size-4"})}),e.jsx(t.EmailScheduleDialog,{open:r,onOpenChange:c,dashboardId:o,dashboardName:h})]}):null}function F({export:s,onRemove:r}){const c=()=>{s.downloadUrl&&window.open(s.downloadUrl,"_blank")},o=a=>{a.stopPropagation(),r==null||r(s.id)},h=()=>{switch(s.status){case"completed":return e.jsx(t.CircleCheck,{className:"mt-0.5 h-5 w-5 shrink-0 text-green-600"});case"failed":return e.jsx(N.CircleX,{className:"mt-0.5 h-5 w-5 shrink-0 text-destructive"});default:return e.jsx(t.LoaderCircle,{className:"text-foreground-muted mt-0.5 h-5 w-5 shrink-0 animate-spin"})}},i=t.isExportInProgress(s.status),n=(()=>{switch(s.status){case"pending":return"Queued...";case"processing":return"Processing...";case"chunking":return"Processing...";case"compacting":return"Finalizing...";default:return"Processing..."}})();return e.jsxs("div",{className:"group p-4 transition-colors hover:bg-muted/50",children:[e.jsxs("div",{className:"mb-2 flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"flex min-w-0 flex-1 items-start gap-3",children:[h(),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("h4",{className:"mb-1 truncate text-sm font-medium",children:s.title}),s.status==="completed"&&e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[e.jsxs("span",{children:[s.totalRows.toLocaleString()," rows"]}),s.fileSize&&e.jsxs(e.Fragment,{children:[e.jsx("span",{children:"•"}),e.jsx("span",{children:t.formatFileSize(s.fileSize)})]})]}),i&&e.jsx("div",{className:"text-xs text-muted-foreground",children:n}),s.status==="failed"&&e.jsx("div",{className:"line-clamp-2 text-xs text-destructive",children:s.error||"Export failed"})]})]}),e.jsx(t.Button,{variant:"ghost",size:"icon",className:"h-6 w-6 shrink-0 opacity-0 transition-opacity group-hover:opacity-100",onClick:o,"aria-label":"Remove notification",children:e.jsx(t.X,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:"ml-8",children:[s.status==="completed"&&e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:I.formatDistanceToNow(s.startedAt,{addSuffix:!0})}),s.downloadUrl&&e.jsxs(t.Button,{size:"sm",variant:"outline",className:"h-8 bg-transparent",onClick:c,children:[e.jsx(t.Download,{className:"mr-1.5 h-3.5 w-3.5"}),"Download"]})]}),i&&e.jsxs("div",{children:[e.jsx(t.Progress,{value:s.progress,className:"h-1.5"}),e.jsxs("span",{className:"mt-1 block text-xs text-muted-foreground",children:[s.progress,"% complete"]})]}),s.status==="failed"&&e.jsx("span",{className:"text-xs text-muted-foreground",children:I.formatDistanceToNow(s.startedAt,{addSuffix:!0})})]})]})}function L(){const{authToken:s,tokenProps:r}=t.useSemaphorContext(),c=t.useExportStore(p=>p.activeExports),{clearCompleted:o,removeExport:h,updateExport:i}=t.useExportActions(),[n,a]=f.useState(!1),[m,d]=f.useState(!1),v=Array.from(c.values()).sort((p,j)=>j.startedAt.getTime()-p.startedAt.getTime()),C=v.some(p=>p.status==="completed"||p.status==="failed"),g=f.useCallback(async()=>{const p=r==null?void 0:r.apiServiceUrl,j=s==null?void 0:s.accessToken;if(!(!p||!j)){a(!0);try{const S=Array.from(c.values());await Promise.all(S.map(async u=>{try{const x=await t.getExportStatus(p,j,u.id);let l;if(x.status==="completed")try{l=await t.getDownloadUrl(p,j,u.id)}catch(w){console.error(`Failed to get download URL for ${u.id}:`,w)}i(u.id,{status:x.status,progress:x.progress,completedChunks:x.completedChunks,completedAt:x.completedAt?new Date(x.completedAt):void 0,lastUpdatedAt:new Date,fileSize:x.fileSize,error:x.error,downloadUrl:l})}catch(x){console.error(`Failed to refresh export ${u.id}:`,x)}}))}finally{a(!1)}}},[c,s==null?void 0:s.accessToken,r==null?void 0:r.apiServiceUrl,i]),b=f.useCallback(async()=>{const p=r==null?void 0:r.apiServiceUrl,j=s==null?void 0:s.accessToken;if(!p||!j){o();return}d(!0);try{const S=v.filter(u=>u.status==="completed"||u.status==="failed");await Promise.all(S.map(u=>t.cancelExport(p,j,u.id).catch(x=>console.error(`Failed to delete export ${u.id}:`,x)))),o()}finally{d(!1)}},[v,r==null?void 0:r.apiServiceUrl,s==null?void 0:s.accessToken,o]),E=f.useCallback(async p=>{const j=r==null?void 0:r.apiServiceUrl,S=s==null?void 0:s.accessToken;if(j&&S)try{await t.cancelExport(j,S,p)}catch(u){console.error(`Failed to cancel export ${p}:`,u)}h(p)},[r==null?void 0:r.apiServiceUrl,s==null?void 0:s.accessToken,h]);return v.length===0?e.jsxs("div",{className:"p-6 text-center",children:[e.jsx(k,{className:"mx-auto mb-2 h-8 w-8 text-muted-foreground"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"No active exports"}),e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"Large exports will appear here"})]}):e.jsxs("div",{className:"flex flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between border-b px-4 py-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(k,{className:"h-5 w-5 text-muted-foreground"}),e.jsx("h4",{className:"font-semibold",children:"Exports"})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(t.Button,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0",onClick:g,disabled:n,title:"Refresh status",children:e.jsx(M,{className:`h-4 w-4 ${n?"animate-spin":""}`})}),C&&e.jsx(t.Button,{variant:"ghost",size:"sm",className:"h-7 px-2 text-sm",onClick:b,disabled:m,children:m?"Clearing...":"Clear all"})]})]}),e.jsx("div",{className:"max-h-[350px] overflow-y-auto",children:e.jsx("div",{className:"divide-y",children:v.map(p=>e.jsx(F,{export:p,onRemove:E},p.id))})})]})}function K(){const s=t.useExportStore(a=>a.activeExports),r=t.useInProgressExportsCount(),c=s.size>0,o=Array.from(s.values()).some(a=>a.status==="completed"||a.status==="failed"),i=r>0?r>9?"9+":String(r):null,n=c;return e.jsxs(t.Popover,{children:[e.jsx(t.PopoverTrigger,{asChild:!0,children:e.jsxs(t.Button,{variant:"ghost",size:"icon",className:"relative h-8 w-8","aria-label":"Export notifications",children:[e.jsx(t.Bell,{className:"h-4 w-4"}),n&&e.jsx("span",{className:`absolute flex items-center justify-center rounded-full bg-primary text-primary-foreground ${i?"-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"}`,children:i})]})}),e.jsx(t.PopoverContent,{className:"w-80 p-0",align:"end",sideOffset:8,children:e.jsx(L,{})})]})}exports.AdvancedModeToggle=Q;exports.ExportNotificationItem=F;exports.ExportNotificationList=L;exports.NotificationBell=K;exports.RefreshCw=M;exports.ScheduleDashboard=J;exports.UnsavedChangesAlert=Y;exports.VisualEditingControls=W;exports.useExportPolling=q;exports.useExportRecovery=H;exports.usePristineSnapshotInitializer=Z;
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),t=require("./index-tt1rwTc8.js"),c=require("react"),de=require("./use-visual-utils-BkmyEMSD.js"),pe=require("./use-role-aware-display-preferences-DgsVnRKz.js");/**
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),t=require("./index-D59dkH2b.js"),c=require("react"),de=require("./use-visual-utils-TGjvLx_R.js"),pe=require("./use-role-aware-display-preferences-JstD5WLE.js");/**
2
2
  * @license lucide-react v0.453.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -1,8 +1,8 @@
1
1
  import { jsx as e, jsxs as a, Fragment as ge } from "react/jsx-runtime";
2
- import { aF as Ze, u as me, au as $e, aO as re, aS as Je, aT as Qe, c as J, aU as ke, aV as et, aW as tt, B as _, aX as st, aY as at, aZ as W, a_ as pe, aG as oe, a$ as nt, b0 as it, b1 as rt, b2 as ve, b3 as De, b4 as ot, b5 as lt, I as dt, b6 as ye, e as le, b7 as Se, b8 as Ee, b9 as ct, L as Ve, R as Le, ba as Ae, bb as Te, bc as Oe, bd as Re, be as Pe, bf as Ue, bg as Ie, bh as je, bi as Fe, bj as ut, bk as ht, bl as Me, bm as ze, bn as Be, bo as mt, bp as He, bq as pt, A as ne, aN as ft, br as _e, bs as gt, bt as Dt, bu as xt, bv as bt, bw as Nt, bx as wt, by as vt, bz as Ce, bA as fe, bB as Ct, bC as yt, bD as St, bE as Et, bF as Vt } from "./index-TF2KfLGc.js";
2
+ import { aF as Ze, u as me, au as $e, aO as re, aS as Je, aT as Qe, c as J, aU as ke, aV as et, aW as tt, B as _, aX as st, aY as at, aZ as W, a_ as pe, aG as oe, a$ as nt, b0 as it, b1 as rt, b2 as ve, b3 as De, b4 as ot, b5 as lt, I as dt, b6 as ye, e as le, b7 as Se, b8 as Ee, b9 as ct, L as Ve, R as Le, ba as Ae, bb as Te, bc as Oe, bd as Re, be as Pe, bf as Ue, bg as Ie, bh as je, bi as Fe, bj as ut, bk as ht, bl as Me, bm as ze, bn as Be, bo as mt, bp as He, bq as pt, A as ne, aN as ft, br as _e, bs as gt, bt as Dt, bu as xt, bv as bt, bw as Nt, bx as wt, by as vt, bz as Ce, bA as fe, bB as Ct, bC as yt, bD as St, bE as Et, bF as Vt } from "./index-ahdw_esL.js";
3
3
  import Lt, { useRef as At, useEffect as ie, useState as x } from "react";
4
- import { a as Ge } from "./use-visual-utils-Dwmrgj6E.js";
5
- import { u as Tt } from "./use-role-aware-display-preferences-CpROR4Gx.js";
4
+ import { a as Ge } from "./use-visual-utils-BbN7rxtD.js";
5
+ import { u as Tt } from "./use-role-aware-display-preferences-CLf3yEts.js";
6
6
  /**
7
7
  * @license lucide-react v0.453.0 - ISC
8
8
  *
@@ -1,4 +1,4 @@
1
- import { b as m, e as t, g as D, f as U, h as b, i as u, j as E, k as g } from "./index-TF2KfLGc.js";
1
+ import { b as m, e as t, g as D, f as U, h as b, i as u, j as E, k as g } from "./index-ahdw_esL.js";
2
2
  import { useMemo as i } from "react";
3
3
  function S() {
4
4
  const { displayPreferences: n, shouldShowElement: c } = m(), { currentUser: a, userContext: s } = t(), r = i(
@@ -1 +1 @@
1
- "use strict";const a=require("./index-tt1rwTc8.js"),n=require("react");function f(){const{displayPreferences:c,shouldShowElement:o}=a.useDisplayPreferences(),{currentUser:e,userContext:s}=a.useCurrentUserInfo(),i=n.useMemo(()=>a.getRoleBasedDisplayOverrides(e),[e]),t=n.useMemo(()=>r=>i&&i[r]!==void 0&&i[r]===!1?!1:o(r),[i,o,c]),p=n.useMemo(()=>{var r,d,l,u,h;return{canEdit:((r=s==null?void 0:s.permissions)==null?void 0:r.canEdit)??a.canUserEdit(e),canUseFilters:((d=s==null?void 0:s.permissions)==null?void 0:d.canEdit)??a.canUserUseFilters(e),canManageDashboards:((l=s==null?void 0:s.permissions)==null?void 0:l.canCreateDashboard)??a.canUserManageDashboards(e),canCreateDashboards:((u=s==null?void 0:s.permissions)==null?void 0:u.canCreateDashboard)??a.canUserCreateDashboards(e),canAccessVisuals:((h=s==null?void 0:s.permissions)==null?void 0:h.canEdit)??a.canUserAccessVisuals(e)}},[e,s]);return{displayPreferences:c,shouldShowElement:t,permissions:p,currentUser:e}}exports.useRoleAwareDisplayPreferences=f;
1
+ "use strict";const a=require("./index-D59dkH2b.js"),n=require("react");function f(){const{displayPreferences:c,shouldShowElement:o}=a.useDisplayPreferences(),{currentUser:e,userContext:s}=a.useCurrentUserInfo(),i=n.useMemo(()=>a.getRoleBasedDisplayOverrides(e),[e]),t=n.useMemo(()=>r=>i&&i[r]!==void 0&&i[r]===!1?!1:o(r),[i,o,c]),p=n.useMemo(()=>{var r,d,l,u,h;return{canEdit:((r=s==null?void 0:s.permissions)==null?void 0:r.canEdit)??a.canUserEdit(e),canUseFilters:((d=s==null?void 0:s.permissions)==null?void 0:d.canEdit)??a.canUserUseFilters(e),canManageDashboards:((l=s==null?void 0:s.permissions)==null?void 0:l.canCreateDashboard)??a.canUserManageDashboards(e),canCreateDashboards:((u=s==null?void 0:s.permissions)==null?void 0:u.canCreateDashboard)??a.canUserCreateDashboards(e),canAccessVisuals:((h=s==null?void 0:s.permissions)==null?void 0:h.canEdit)??a.canUserAccessVisuals(e)}},[e,s]);return{displayPreferences:c,shouldShowElement:t,permissions:p,currentUser:e}}exports.useRoleAwareDisplayPreferences=f;
@@ -1,4 +1,4 @@
1
- import { aM as G, aN as Y, aH as J, aI as K, aO as X, av as Q, as as Z, u as v, aP as q, aQ as ee, aL as V, aR as te, au as f } from "./index-TF2KfLGc.js";
1
+ import { aM as G, aN as Y, aH as J, aI as K, aO as X, av as Q, as as Z, u as v, aP as q, aQ as ee, aL as V, aR as te, au as f } from "./index-ahdw_esL.js";
2
2
  import { useState as T, useEffect as re, useCallback as N } from "react";
3
3
  function se(e) {
4
4
  const o = e.toUpperCase().indexOf("WHERE"), t = e.toUpperCase().indexOf("GROUP BY"), r = e.toUpperCase().indexOf("LIMIT"), n = e.toUpperCase().indexOf("ORDER BY");
@@ -1 +1 @@
1
- "use strict";const s=require("./index-tt1rwTc8.js"),g=require("react");function H(e){const a=e.toUpperCase().indexOf("WHERE"),t=e.toUpperCase().indexOf("GROUP BY"),r=e.toUpperCase().indexOf("LIMIT"),c=e.toUpperCase().indexOf("ORDER BY");let d=e.length;if(c!==-1&&(d=c),r!==-1&&r<d&&(d=r),a!==-1){const i=e.substring(0,a),o=e.substring(a);return`${i} {{ filters | where }} AND ${o.substring(6)}`}else if(t!==-1){const i=e.substring(0,t),o=e.substring(t);return`${i} {{ filters | where }} ${o}`}else{const i=e.substring(0,d),o=e.substring(d);return console.log("beforeClause",i),console.log("afterClause",o),o?`${i} {{ filters | where }} ${o}`:`${i.replace(/;$/,"")} {{ filters | where }}`}}function B(e){const[a,t]=g.useState(null),[r,c]=g.useState(null),d=s.useEnsureReactGlobals();return g.useEffect(()=>{if(!e||e.trim()===""){t(null),c(null);return}if(!d)return;(async()=>{try{if(!e.startsWith("http://")&&!e.startsWith("https://"))throw new Error(`Invalid URL format: ${e}`);try{new URL(e)}catch{throw new Error(`Invalid URL: ${e}`)}const l=`${e.endsWith("/")?e:`${e}/`}index.js`;try{if(!(await fetch(l,{method:"HEAD"})).ok)throw new Error(`Module not found at ${l}`)}catch{}const h=await import(l);if(typeof h.useChartStore!="function")throw new Error("useChartStore is not a function");t(()=>h.useChartStore),c(null)}catch(o){const l=o instanceof Error?o.message:"Unknown error";console.error("Failed to load remote chart store:",l),c(l),t(null)}})()},[e,d]),a}function Q(e,a){if(e.length===0)return"";if(a){const t=e.find(r=>r.id===a);if(t){const r=t.tabTitle;if(r=="All__Header")return e[0].id;if(r&&r.endsWith("__Header")){const d=r.split("__")[0],i=e.find(o=>o.tabTitle===d);return i?i.id:e[0].id}return a}}return e[0].id}async function j(e,a,t,r){if(!a||!t)throw new Error("Missing auth token or visual ID");const c=["resource-by-id","visual",t],d=r.getQueryData(c);if(d)return console.log("Using cached visual data for:",t),{data:d,fromCache:!0};console.log("Fetching visual data from network for:",t);const i=s.ue.loading("Loading visual...",{position:"top-center"});try{const o=await fetch(`${e}/management/v1/visuals/${t}`,{headers:{Authorization:`Bearer ${a}`}});if(!o.ok)throw new Error("Failed to load visual");const l=await o.json();return r.setQueryData(c,l),s.ue.dismiss(i),{data:l,fromCache:!1}}catch(o){throw s.ue.dismiss(i),o}}function T(e){if(typeof e=="string")return JSON.parse(e);if(typeof e=="object")return e;throw new Error("Invalid frame object format")}function z(e,a){var d,i;const t=(e==null?void 0:e.frameObject)??((d=e==null?void 0:e.visual)==null?void 0:d.frameObject);if(!t)return!1;const r=T(t);if(!(r!=null&&r.cards)||r.cards.length===0)return!1;const c=(i=r.cards)==null?void 0:i.find(o=>o.id===r.activeCardId);return c?(s.setupEditorWithCard({...a,frame:r,card:c,visualId:(e==null?void 0:e.id)||r.visualId}),!0):!1}function G(){var C;const{setCardSql:e}=s.useEditorActions(),a=s.useEditorStore(n=>n.frame),t=s.useEditorStore(n=>n.card),r=s.useEditorStore(n=>n.isDevMode),c=B(((C=t.customCardPreferences)==null?void 0:C.url)||""),d=s.useEditorStore(n=>n.selectedSchemaName),i=s.useEditorStore(n=>n.selectedDatamodelId),o=s.useEditorStore(n=>n.selectedDatabaseName),l=s.useEditorStore(n=>n.selectedTableName),h=s.useEditorStore(n=>n.selectedConnectionId),m=s.useEditorStore(n=>n.isShowingVisual),S=t.sql;return{getUpdatedFrame:g.useCallback(()=>{var I;let n=S;S&&!S.includes("{{")&&(n=H(S),e(n));const w=(I=c==null?void 0:c.getState())==null?void 0:I.settings,v={...t,dataSource:t.dataSource||{mode:"directSource"},lastSelectedSchema:d,lastSelectedDatamodelId:i,lastSelectedDatabase:o,lastSelectedTable:l,connectionId:h,sql:r?n:void 0,python:r?t.python:void 0,config:r?void 0:t.config,customCfg:m?t.customCfg:null,preferences:t.preferences,...w&&{customCardPreferences:{...t.customCardPreferences,settings:w}}},E=a.cards.map(p=>p.id===t.id?v:p);return{...a,cards:E,activeCardId:Q(E,a.activeCardId)}},[t,a,r,m,d,i,o,l,h,e,c,S])}}function Y(){const{authToken:e,tokenProps:a}=s.useSemaphorContext(),t=s.useQueryClient(),r=s.useSelectedVisual(),{selectVisual:c}=s.useManagementActions(),{setFrame:d,setCard:i,setIsDevMode:o,initializeModeDrafts:l,setActiveTabCardId:h,updateDataSource:m,setQueryResultColumns:S,setSelectedConnectionId:V,setSelectedDatabaseName:C,setSelectedSchemaName:n,setSelectedTableName:w,setSelectedDatamodelId:v,setFilterValues:E,setApplyFilters:I}=s.useEditorActions(),{setIsDashboardEditing:p,setIsVisualEditing:$,setSelectedFrameId:D,clearSelectedFrameId:A,addFrame:N,setIsDashboardPanelOpen:R}=s.useDashboardActions(),y=s.useDashboardStore(u=>u.selectedSheetId),O=s.useDashboardStore(u=>u.selectedFrameId),x=s.useDashboardStore(u=>u.dashboard),W=s.useDashboardStore(u=>u.filterValues),F=s.useVisualById((r==null?void 0:r.id)||"",{enabled:!!(r!=null&&r.id)&&!!(e!=null&&e.accessToken)}),k=g.useCallback(async u=>{try{c(u),A();const{data:b,fromCache:f}=await j(a.apiServiceUrl,(e==null?void 0:e.accessToken)||"",u.id,t);if(!z(b,{setFrame:d,setCard:i,setIsDevMode:o,initializeModeDrafts:l,setActiveTabCardId:h,updateDataSource:m,setQueryResultColumns:S,setSelectedConnectionId:V,setSelectedDatabaseName:C,setSelectedSchemaName:n,setSelectedTableName:w,setSelectedDatamodelId:v,setFilterValues:E,setApplyFilters:I,setIsDashboardEditing:p,setIsVisualEditing:$,dashboard:x,selectedSheetId:y,selectedFrameId:O,filterValues:W}))throw new Error("Failed to setup editor with visual data");return{success:!0,fromCache:f}}catch(b){return console.error("Error editing visual:",b),{success:!1,error:"Failed to load visual for editing"}}},[e==null?void 0:e.accessToken,a.apiServiceUrl,t,c,d,i,p,$,o,l,h,m,S,V,C,n,w,v,E,I,A,x,y,O,W]),_=g.useCallback(async u=>{var b;try{if(c(u),!y)return{success:!1,error:"No sheet selected. Please select a sheet first."};const{data:f,fromCache:M}=await j(a.apiServiceUrl,(e==null?void 0:e.accessToken)||"",u.id,t),L=(f==null?void 0:f.frameObject)??((b=f==null?void 0:f.visual)==null?void 0:b.frameObject);if(!L)return{success:!1,error:"Visual has no frame data"};const U=T(L);if(!(U!=null&&U.cards)||U.cards.length===0)return{success:!1,error:"Visual frame is malformed"};const P={...s.cloneFrameWithNewIds(U),visualId:u.id};return N(y,P,"end"),p(!0),D(P.id),R(!1),{success:!0,fromCache:M}}catch(f){return console.error("Error adding visual:",f),{success:!1,error:"Failed to add visual to dashboard"}}},[e==null?void 0:e.accessToken,a.apiServiceUrl,t,c,y,N,p,D,R]);return{visual:F.data,isLoading:F.isLoading,isError:F.isError,error:F.error,handleEditLibraryVisual:k,handleAddLibraryVisual:_,getUpdatedFrame:G().getUpdatedFrame,refetch:F.refetch}}exports.useRemoteChartStore=B;exports.useVisualUtils=Y;
1
+ "use strict";const s=require("./index-D59dkH2b.js"),g=require("react");function H(e){const a=e.toUpperCase().indexOf("WHERE"),t=e.toUpperCase().indexOf("GROUP BY"),r=e.toUpperCase().indexOf("LIMIT"),c=e.toUpperCase().indexOf("ORDER BY");let d=e.length;if(c!==-1&&(d=c),r!==-1&&r<d&&(d=r),a!==-1){const i=e.substring(0,a),o=e.substring(a);return`${i} {{ filters | where }} AND ${o.substring(6)}`}else if(t!==-1){const i=e.substring(0,t),o=e.substring(t);return`${i} {{ filters | where }} ${o}`}else{const i=e.substring(0,d),o=e.substring(d);return console.log("beforeClause",i),console.log("afterClause",o),o?`${i} {{ filters | where }} ${o}`:`${i.replace(/;$/,"")} {{ filters | where }}`}}function B(e){const[a,t]=g.useState(null),[r,c]=g.useState(null),d=s.useEnsureReactGlobals();return g.useEffect(()=>{if(!e||e.trim()===""){t(null),c(null);return}if(!d)return;(async()=>{try{if(!e.startsWith("http://")&&!e.startsWith("https://"))throw new Error(`Invalid URL format: ${e}`);try{new URL(e)}catch{throw new Error(`Invalid URL: ${e}`)}const l=`${e.endsWith("/")?e:`${e}/`}index.js`;try{if(!(await fetch(l,{method:"HEAD"})).ok)throw new Error(`Module not found at ${l}`)}catch{}const h=await import(l);if(typeof h.useChartStore!="function")throw new Error("useChartStore is not a function");t(()=>h.useChartStore),c(null)}catch(o){const l=o instanceof Error?o.message:"Unknown error";console.error("Failed to load remote chart store:",l),c(l),t(null)}})()},[e,d]),a}function Q(e,a){if(e.length===0)return"";if(a){const t=e.find(r=>r.id===a);if(t){const r=t.tabTitle;if(r=="All__Header")return e[0].id;if(r&&r.endsWith("__Header")){const d=r.split("__")[0],i=e.find(o=>o.tabTitle===d);return i?i.id:e[0].id}return a}}return e[0].id}async function j(e,a,t,r){if(!a||!t)throw new Error("Missing auth token or visual ID");const c=["resource-by-id","visual",t],d=r.getQueryData(c);if(d)return console.log("Using cached visual data for:",t),{data:d,fromCache:!0};console.log("Fetching visual data from network for:",t);const i=s.ue.loading("Loading visual...",{position:"top-center"});try{const o=await fetch(`${e}/management/v1/visuals/${t}`,{headers:{Authorization:`Bearer ${a}`}});if(!o.ok)throw new Error("Failed to load visual");const l=await o.json();return r.setQueryData(c,l),s.ue.dismiss(i),{data:l,fromCache:!1}}catch(o){throw s.ue.dismiss(i),o}}function T(e){if(typeof e=="string")return JSON.parse(e);if(typeof e=="object")return e;throw new Error("Invalid frame object format")}function z(e,a){var d,i;const t=(e==null?void 0:e.frameObject)??((d=e==null?void 0:e.visual)==null?void 0:d.frameObject);if(!t)return!1;const r=T(t);if(!(r!=null&&r.cards)||r.cards.length===0)return!1;const c=(i=r.cards)==null?void 0:i.find(o=>o.id===r.activeCardId);return c?(s.setupEditorWithCard({...a,frame:r,card:c,visualId:(e==null?void 0:e.id)||r.visualId}),!0):!1}function G(){var C;const{setCardSql:e}=s.useEditorActions(),a=s.useEditorStore(n=>n.frame),t=s.useEditorStore(n=>n.card),r=s.useEditorStore(n=>n.isDevMode),c=B(((C=t.customCardPreferences)==null?void 0:C.url)||""),d=s.useEditorStore(n=>n.selectedSchemaName),i=s.useEditorStore(n=>n.selectedDatamodelId),o=s.useEditorStore(n=>n.selectedDatabaseName),l=s.useEditorStore(n=>n.selectedTableName),h=s.useEditorStore(n=>n.selectedConnectionId),m=s.useEditorStore(n=>n.isShowingVisual),S=t.sql;return{getUpdatedFrame:g.useCallback(()=>{var I;let n=S;S&&!S.includes("{{")&&(n=H(S),e(n));const w=(I=c==null?void 0:c.getState())==null?void 0:I.settings,v={...t,dataSource:t.dataSource||{mode:"directSource"},lastSelectedSchema:d,lastSelectedDatamodelId:i,lastSelectedDatabase:o,lastSelectedTable:l,connectionId:h,sql:r?n:void 0,python:r?t.python:void 0,config:r?void 0:t.config,customCfg:m?t.customCfg:null,preferences:t.preferences,...w&&{customCardPreferences:{...t.customCardPreferences,settings:w}}},E=a.cards.map(p=>p.id===t.id?v:p);return{...a,cards:E,activeCardId:Q(E,a.activeCardId)}},[t,a,r,m,d,i,o,l,h,e,c,S])}}function Y(){const{authToken:e,tokenProps:a}=s.useSemaphorContext(),t=s.useQueryClient(),r=s.useSelectedVisual(),{selectVisual:c}=s.useManagementActions(),{setFrame:d,setCard:i,setIsDevMode:o,initializeModeDrafts:l,setActiveTabCardId:h,updateDataSource:m,setQueryResultColumns:S,setSelectedConnectionId:V,setSelectedDatabaseName:C,setSelectedSchemaName:n,setSelectedTableName:w,setSelectedDatamodelId:v,setFilterValues:E,setApplyFilters:I}=s.useEditorActions(),{setIsDashboardEditing:p,setIsVisualEditing:$,setSelectedFrameId:D,clearSelectedFrameId:A,addFrame:N,setIsDashboardPanelOpen:R}=s.useDashboardActions(),y=s.useDashboardStore(u=>u.selectedSheetId),O=s.useDashboardStore(u=>u.selectedFrameId),x=s.useDashboardStore(u=>u.dashboard),W=s.useDashboardStore(u=>u.filterValues),F=s.useVisualById((r==null?void 0:r.id)||"",{enabled:!!(r!=null&&r.id)&&!!(e!=null&&e.accessToken)}),k=g.useCallback(async u=>{try{c(u),A();const{data:b,fromCache:f}=await j(a.apiServiceUrl,(e==null?void 0:e.accessToken)||"",u.id,t);if(!z(b,{setFrame:d,setCard:i,setIsDevMode:o,initializeModeDrafts:l,setActiveTabCardId:h,updateDataSource:m,setQueryResultColumns:S,setSelectedConnectionId:V,setSelectedDatabaseName:C,setSelectedSchemaName:n,setSelectedTableName:w,setSelectedDatamodelId:v,setFilterValues:E,setApplyFilters:I,setIsDashboardEditing:p,setIsVisualEditing:$,dashboard:x,selectedSheetId:y,selectedFrameId:O,filterValues:W}))throw new Error("Failed to setup editor with visual data");return{success:!0,fromCache:f}}catch(b){return console.error("Error editing visual:",b),{success:!1,error:"Failed to load visual for editing"}}},[e==null?void 0:e.accessToken,a.apiServiceUrl,t,c,d,i,p,$,o,l,h,m,S,V,C,n,w,v,E,I,A,x,y,O,W]),_=g.useCallback(async u=>{var b;try{if(c(u),!y)return{success:!1,error:"No sheet selected. Please select a sheet first."};const{data:f,fromCache:M}=await j(a.apiServiceUrl,(e==null?void 0:e.accessToken)||"",u.id,t),L=(f==null?void 0:f.frameObject)??((b=f==null?void 0:f.visual)==null?void 0:b.frameObject);if(!L)return{success:!1,error:"Visual has no frame data"};const U=T(L);if(!(U!=null&&U.cards)||U.cards.length===0)return{success:!1,error:"Visual frame is malformed"};const P={...s.cloneFrameWithNewIds(U),visualId:u.id};return N(y,P,"end"),p(!0),D(P.id),R(!1),{success:!0,fromCache:M}}catch(f){return console.error("Error adding visual:",f),{success:!1,error:"Failed to add visual to dashboard"}}},[e==null?void 0:e.accessToken,a.apiServiceUrl,t,c,y,N,p,D,R]);return{visual:F.data,isLoading:F.isLoading,isError:F.isError,error:F.error,handleEditLibraryVisual:k,handleAddLibraryVisual:_,getUpdatedFrame:G().getUpdatedFrame,refetch:F.refetch}}exports.useRemoteChartStore=B;exports.useVisualUtils=Y;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../chunks/index-tt1rwTc8.js"),r=require("../types/index.cjs");exports.Dashboard=e.Dashboard;exports.EMPTY_SELECTION=r.EMPTY_SELECTION;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../chunks/index-D59dkH2b.js"),r=require("../types/index.cjs");exports.Dashboard=e.Dashboard;exports.EMPTY_SELECTION=r.EMPTY_SELECTION;
@@ -1,4 +1,4 @@
1
- import { D as a } from "../chunks/index-TF2KfLGc.js";
1
+ import { D as a } from "../chunks/index-ahdw_esL.js";
2
2
  import { EMPTY_SELECTION as e } from "../types/index.js";
3
3
  export {
4
4
  a as Dashboard,
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./chunks/index-tt1rwTc8.js"),v=require("./types/index.cjs"),o=require("react/jsx-runtime"),f=require("react"),P=require("./chunks/resource-management-panel-CihSUDmt.js"),i=require("./chunks/notification-bell-CWYeyuXL.js");require("react-dom");function j(t){const r=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const s in t)if(s!=="default"){const l=Object.getOwnPropertyDescriptor(t,s);Object.defineProperty(r,s,l.get?l:{enumerable:!0,get:()=>t[s]})}}return r.default=t,Object.freeze(r)}const x=j(f);function N(t){const{displayPreferences:r,...s}=t,l={...s,id:t.dashboardId};return o.jsx(e.ErrorBoundary,{FallbackComponent:e.Fallback,children:o.jsxs(e.SemaphorContextProvider,{dashboardProps:l,children:[o.jsx(e.SemaphorReadyIndicator,{componentType:"visual",componentId:t.cardId}),o.jsx(e.UXProvider,{children:o.jsx(e.DisplayPreferencesProvider,{displayPreferences:r,children:o.jsx(e.Container,{type:"visual",...l,children:o.jsx(A,{cardId:t.cardId})})})})]})})}function A({cardId:t}){const r=e.useDashboardStore(n=>{var u;return(u=n.dashboard)==null?void 0:u.sheets}),{card:s,frame:l}=f.useMemo(()=>{const n=r==null?void 0:r.flatMap(a=>a.frames),u=n==null?void 0:n.flatMap(a=>a==null?void 0:a.cards),m=u==null?void 0:u.find(a=>(a==null?void 0:a.id)===t),E=n==null?void 0:n.find(a=>{var h;return(h=a==null?void 0:a.cards)==null?void 0:h.find(c=>(c==null?void 0:c.id)===t)});return{card:m,frame:E}},[r,t]);return!s||!l?o.jsx(e.FallbackVisual,{error:new Error("Card not found"),resetErrorBoundary:()=>{},customerFacingMessage:`Card not found with ID: ${t}`}):o.jsx("main",{className:"flex h-full grow flex-col",children:o.jsx(e.ErrorBoundary,{FallbackComponent:({error:n,resetErrorBoundary:u})=>o.jsx(e.FallbackVisual,{error:n,resetErrorBoundary:u,customerFacingMessage:"Error creating visual. Please try again."}),children:o.jsx(e.DashboardCard,{card:s,frame:l})})})}function _({name:t,items:r,value:s,onChange:l,isLoading:n,isError:u,refetch:m,className:E,icon:a,showNone:h=!1}){const c=x.useRef(null),[g,D]=x.useState(!1),[b,S]=x.useState("100%"),C=h?[...r||[],{id:"none",name:"None"}]:r;x.useLayoutEffect(()=>{c.current&&S(c.current.offsetWidth)},[]);function T(){var d;return n?"Loading...":u?"Error":s?(d=r==null?void 0:r.find(p=>p.id===s))==null?void 0:d.name:`Select ${t}`}function y(d,p){l(p),D(!1)}return o.jsxs(e.Popover,{open:g,onOpenChange:D,children:[o.jsx(e.PopoverTrigger,{asChild:!0,children:o.jsxs(e.Button,{ref:c,variant:"outline",role:"combobox","aria-expanded":g,className:e.cn("flex h-9 w-full justify-between",E),children:[o.jsxs("div",{className:"flex items-center gap-2",children:[a&&o.jsx("div",{className:"mr-2",children:a}),o.jsx("span",{className:"max-w-[150px] overflow-hidden truncate text-ellipsis whitespace-nowrap",children:T()})]}),o.jsx(e.ChevronDown,{className:"size-4 opacity-50"})]})}),o.jsx(e.PopoverContent,{className:"w-full p-0",style:{minWidth:b},children:o.jsxs(e.Command,{children:[o.jsxs("div",{className:"flex h-9 items-center justify-between border-b pr-1",children:[o.jsx(e.CommandInput,{className:"h-9",placeholder:"Search..."}),o.jsx(e.IconButton,{className:"h-7",onClick:m,children:o.jsx(i.RefreshCw,{className:e.cn("size-3.5 opacity-50",n&&"animate-spin")})})]}),o.jsxs(e.CommandList,{children:[o.jsxs(e.CommandEmpty,{children:["No ",t==null?void 0:t.toLowerCase()," found."]}),o.jsx(e.CommandGroup,{children:C==null?void 0:C.map(d=>o.jsx(e.CommandItem,{className:"overflow-x-auto",value:d.name,onSelect:p=>y(p,d.id),children:o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(e.Check,{className:e.cn("size-4",s===d.id?"opacity-100":"opacity-0")}),o.jsx("div",{title:d.name,children:d.name})]})},d.id))})]})]})})]})}function M(t,r){f.useEffect(()=>(t&&r&&(window.__SEMAPHOR_PRINT_STATE__={...r}),()=>{t&&window.__SEMAPHOR_PRINT_STATE__&&delete window.__SEMAPHOR_PRINT_STATE__}),[t,r])}exports.CALCULATED_FIELD_ENTITY_MARKER=e.CALCULATED_FIELD_ENTITY_MARKER;exports.DATE_FORMAT_VALUES=e.DATE_FORMAT_VALUES;exports.Dashboard=e.Dashboard;exports.DashboardExportDialog=e.DashboardExportDialog;exports.DashboardWC=e.DashboardWC;exports.ExportError=e.ExportError;exports.PivotMarkerEnum=e.PivotMarkerEnum;exports.ResourceType=e.ResourceType;exports.SemaphorContextProvider=e.SemaphorContextProvider;exports.SemaphorDataProvider=e.SemaphorQueryClient;exports.SemaphorQueryClient=e.SemaphorQueryClient;exports.ShareDialog=e.ShareDialog;exports.Surfboard=e.DashboardPlus;exports.cancelExport=e.cancelExport;exports.cloneDeep=e.cloneDeep;exports.createEmptyKpiConfig=e.createEmptyKpiConfig;exports.createExport=e.createExport;exports.createSqlGenConfig=e.createSqlGenConfig;exports.downloadPdf=e.downloadPdf;exports.emitDashboardLoad=e.emitDashboardLoad;exports.emitDashboardUnload=e.emitDashboardUnload;exports.fmt=e.fmt;exports.formatFileSize=e.formatFileSize;exports.getColumnDataType=e.getColumnDataType;exports.getDownloadUrl=e.getDownloadUrl;exports.getExportStatus=e.getExportStatus;exports.getExports=e.getExports;exports.getFilterValueType=e.getFilterValueType;exports.getFormattedTableNameForQuery=e.getFormattedTableNameForQuery;exports.getQualifiedTableName=e.getQualifiedTableName;exports.getSql=e.getSql;exports.invalidateToken=e.invalidateToken;exports.isBooleanDataType=e.isBooleanDataType;exports.isCalculatedDimension=e.isCalculatedDimension;exports.isCalculatedField=e.isCalculatedField;exports.isCalculatedMetric=e.isCalculatedMetric;exports.isColumnInSqlGen=e.isColumnInSqlGen;exports.isDateDataType=e.isDateDataType;exports.isExportComplete=e.isExportComplete;exports.isExportInProgress=e.isExportInProgress;exports.isNumberDataType=e.isNumberDataType;exports.isTextDataType=e.isTextDataType;exports.resolveDataType=e.resolveDataType;exports.resolveDatamodelName=e.resolveDatamodelName;exports.useActiveExports=e.useActiveExports;exports.useCard=e.useCard;exports.useCurrentActiveCard=e.useCurrentActiveCard;exports.useCurrentCardConfig=e.useCurrentCardConfig;exports.useCurrentSheetActiveCards=e.useCurrentSheetActiveCards;exports.useDashboardActions=e.useDashboardActions;exports.useDashboardById=e.useDashboardById;exports.useDashboardQuery=e.useDashboardQuery;exports.useDashboardStore=e.useDashboardStore;exports.useDataColumns=e.useDataColumns;exports.useDateFilterHook=e.useDateFilterHook;exports.useEditorActions=e.useEditorActions;exports.useEditorAside=e.useEditorAside;exports.useEditorStore=e.useEditorStore;exports.useExportActions=e.useExportActions;exports.useExportStore=e.useExportStore;exports.useInProgressExportsCount=e.useInProgressExportsCount;exports.useManagementStore=e.useManagementStore;exports.useResourceManagement=e.useResourceManagement;exports.useTextFilterHook=e.useTextFilterHook;exports.EMPTY_SELECTION=v.EMPTY_SELECTION;exports.ResourceManagementPanel=P.ResourceManagementPanel;exports.AdvancedModeToggle=i.AdvancedModeToggle;exports.ExportNotificationItem=i.ExportNotificationItem;exports.ExportNotificationList=i.ExportNotificationList;exports.NotificationBell=i.NotificationBell;exports.ScheduleDashboard=i.ScheduleDashboard;exports.UnsavedChangesAlert=i.UnsavedChangesAlert;exports.VisualEditingControls=i.VisualEditingControls;exports.useExportPolling=i.useExportPolling;exports.useExportRecovery=i.useExportRecovery;exports.usePristineSnapshotInitializer=i.usePristineSnapshotInitializer;exports.Combobox=_;exports.Visual=N;exports.useExposePrintState=M;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./chunks/index-D59dkH2b.js"),v=require("./types/index.cjs"),o=require("react/jsx-runtime"),f=require("react"),P=require("./chunks/resource-management-panel-BLiCtZZE.js"),i=require("./chunks/notification-bell-DtWcBdzp.js");require("react-dom");function j(t){const r=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const s in t)if(s!=="default"){const l=Object.getOwnPropertyDescriptor(t,s);Object.defineProperty(r,s,l.get?l:{enumerable:!0,get:()=>t[s]})}}return r.default=t,Object.freeze(r)}const x=j(f);function N(t){const{displayPreferences:r,...s}=t,l={...s,id:t.dashboardId};return o.jsx(e.ErrorBoundary,{FallbackComponent:e.Fallback,children:o.jsxs(e.SemaphorContextProvider,{dashboardProps:l,children:[o.jsx(e.SemaphorReadyIndicator,{componentType:"visual",componentId:t.cardId}),o.jsx(e.UXProvider,{children:o.jsx(e.DisplayPreferencesProvider,{displayPreferences:r,children:o.jsx(e.Container,{type:"visual",...l,children:o.jsx(A,{cardId:t.cardId})})})})]})})}function A({cardId:t}){const r=e.useDashboardStore(n=>{var u;return(u=n.dashboard)==null?void 0:u.sheets}),{card:s,frame:l}=f.useMemo(()=>{const n=r==null?void 0:r.flatMap(a=>a.frames),u=n==null?void 0:n.flatMap(a=>a==null?void 0:a.cards),m=u==null?void 0:u.find(a=>(a==null?void 0:a.id)===t),E=n==null?void 0:n.find(a=>{var h;return(h=a==null?void 0:a.cards)==null?void 0:h.find(c=>(c==null?void 0:c.id)===t)});return{card:m,frame:E}},[r,t]);return!s||!l?o.jsx(e.FallbackVisual,{error:new Error("Card not found"),resetErrorBoundary:()=>{},customerFacingMessage:`Card not found with ID: ${t}`}):o.jsx("main",{className:"flex h-full grow flex-col",children:o.jsx(e.ErrorBoundary,{FallbackComponent:({error:n,resetErrorBoundary:u})=>o.jsx(e.FallbackVisual,{error:n,resetErrorBoundary:u,customerFacingMessage:"Error creating visual. Please try again."}),children:o.jsx(e.DashboardCard,{card:s,frame:l})})})}function _({name:t,items:r,value:s,onChange:l,isLoading:n,isError:u,refetch:m,className:E,icon:a,showNone:h=!1}){const c=x.useRef(null),[g,D]=x.useState(!1),[b,S]=x.useState("100%"),C=h?[...r||[],{id:"none",name:"None"}]:r;x.useLayoutEffect(()=>{c.current&&S(c.current.offsetWidth)},[]);function T(){var d;return n?"Loading...":u?"Error":s?(d=r==null?void 0:r.find(p=>p.id===s))==null?void 0:d.name:`Select ${t}`}function y(d,p){l(p),D(!1)}return o.jsxs(e.Popover,{open:g,onOpenChange:D,children:[o.jsx(e.PopoverTrigger,{asChild:!0,children:o.jsxs(e.Button,{ref:c,variant:"outline",role:"combobox","aria-expanded":g,className:e.cn("flex h-9 w-full justify-between",E),children:[o.jsxs("div",{className:"flex items-center gap-2",children:[a&&o.jsx("div",{className:"mr-2",children:a}),o.jsx("span",{className:"max-w-[150px] overflow-hidden truncate text-ellipsis whitespace-nowrap",children:T()})]}),o.jsx(e.ChevronDown,{className:"size-4 opacity-50"})]})}),o.jsx(e.PopoverContent,{className:"w-full p-0",style:{minWidth:b},children:o.jsxs(e.Command,{children:[o.jsxs("div",{className:"flex h-9 items-center justify-between border-b pr-1",children:[o.jsx(e.CommandInput,{className:"h-9",placeholder:"Search..."}),o.jsx(e.IconButton,{className:"h-7",onClick:m,children:o.jsx(i.RefreshCw,{className:e.cn("size-3.5 opacity-50",n&&"animate-spin")})})]}),o.jsxs(e.CommandList,{children:[o.jsxs(e.CommandEmpty,{children:["No ",t==null?void 0:t.toLowerCase()," found."]}),o.jsx(e.CommandGroup,{children:C==null?void 0:C.map(d=>o.jsx(e.CommandItem,{className:"overflow-x-auto",value:d.name,onSelect:p=>y(p,d.id),children:o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(e.Check,{className:e.cn("size-4",s===d.id?"opacity-100":"opacity-0")}),o.jsx("div",{title:d.name,children:d.name})]})},d.id))})]})]})})]})}function M(t,r){f.useEffect(()=>(t&&r&&(window.__SEMAPHOR_PRINT_STATE__={...r}),()=>{t&&window.__SEMAPHOR_PRINT_STATE__&&delete window.__SEMAPHOR_PRINT_STATE__}),[t,r])}exports.CALCULATED_FIELD_ENTITY_MARKER=e.CALCULATED_FIELD_ENTITY_MARKER;exports.DATE_FORMAT_VALUES=e.DATE_FORMAT_VALUES;exports.Dashboard=e.Dashboard;exports.DashboardExportDialog=e.DashboardExportDialog;exports.DashboardWC=e.DashboardWC;exports.ExportError=e.ExportError;exports.PivotMarkerEnum=e.PivotMarkerEnum;exports.ResourceType=e.ResourceType;exports.SemaphorContextProvider=e.SemaphorContextProvider;exports.SemaphorDataProvider=e.SemaphorQueryClient;exports.SemaphorQueryClient=e.SemaphorQueryClient;exports.ShareDialog=e.ShareDialog;exports.Surfboard=e.DashboardPlus;exports.cancelExport=e.cancelExport;exports.cloneDeep=e.cloneDeep;exports.createEmptyKpiConfig=e.createEmptyKpiConfig;exports.createExport=e.createExport;exports.createSqlGenConfig=e.createSqlGenConfig;exports.downloadPdf=e.downloadPdf;exports.emitDashboardLoad=e.emitDashboardLoad;exports.emitDashboardUnload=e.emitDashboardUnload;exports.fmt=e.fmt;exports.formatFileSize=e.formatFileSize;exports.getColumnDataType=e.getColumnDataType;exports.getDownloadUrl=e.getDownloadUrl;exports.getExportStatus=e.getExportStatus;exports.getExports=e.getExports;exports.getFilterValueType=e.getFilterValueType;exports.getFormattedTableNameForQuery=e.getFormattedTableNameForQuery;exports.getQualifiedTableName=e.getQualifiedTableName;exports.getSql=e.getSql;exports.invalidateToken=e.invalidateToken;exports.isBooleanDataType=e.isBooleanDataType;exports.isCalculatedDimension=e.isCalculatedDimension;exports.isCalculatedField=e.isCalculatedField;exports.isCalculatedMetric=e.isCalculatedMetric;exports.isColumnInSqlGen=e.isColumnInSqlGen;exports.isDateDataType=e.isDateDataType;exports.isExportComplete=e.isExportComplete;exports.isExportInProgress=e.isExportInProgress;exports.isNumberDataType=e.isNumberDataType;exports.isTextDataType=e.isTextDataType;exports.resolveDataType=e.resolveDataType;exports.resolveDatamodelName=e.resolveDatamodelName;exports.useActiveExports=e.useActiveExports;exports.useCard=e.useCard;exports.useCurrentActiveCard=e.useCurrentActiveCard;exports.useCurrentCardConfig=e.useCurrentCardConfig;exports.useCurrentSheetActiveCards=e.useCurrentSheetActiveCards;exports.useDashboardActions=e.useDashboardActions;exports.useDashboardById=e.useDashboardById;exports.useDashboardQuery=e.useDashboardQuery;exports.useDashboardStore=e.useDashboardStore;exports.useDataColumns=e.useDataColumns;exports.useDateFilterHook=e.useDateFilterHook;exports.useEditorActions=e.useEditorActions;exports.useEditorAside=e.useEditorAside;exports.useEditorStore=e.useEditorStore;exports.useExportActions=e.useExportActions;exports.useExportStore=e.useExportStore;exports.useInProgressExportsCount=e.useInProgressExportsCount;exports.useManagementStore=e.useManagementStore;exports.useResourceManagement=e.useResourceManagement;exports.useTextFilterHook=e.useTextFilterHook;exports.EMPTY_SELECTION=v.EMPTY_SELECTION;exports.ResourceManagementPanel=P.ResourceManagementPanel;exports.AdvancedModeToggle=i.AdvancedModeToggle;exports.ExportNotificationItem=i.ExportNotificationItem;exports.ExportNotificationList=i.ExportNotificationList;exports.NotificationBell=i.NotificationBell;exports.ScheduleDashboard=i.ScheduleDashboard;exports.UnsavedChangesAlert=i.UnsavedChangesAlert;exports.VisualEditingControls=i.VisualEditingControls;exports.useExportPolling=i.useExportPolling;exports.useExportRecovery=i.useExportRecovery;exports.usePristineSnapshotInitializer=i.usePristineSnapshotInitializer;exports.Combobox=_;exports.Visual=N;exports.useExposePrintState=M;
package/dist/index.js CHANGED
@@ -1,12 +1,12 @@
1
- import { E as b, F as N, S as P, l as w, U as _, m as A, C as I, u as M, n as D, o as R, P as F, p as k, B as L, c as E, q as B, r as V, s as O, t as U, I as z, v as H, w as W, x as j, y as q, z as Q } from "./chunks/index-TF2KfLGc.js";
2
- import { a4 as ia, a5 as la, D as da, _ as ca, Q as ua, aB as pa, a9 as ha, R as ma, K as fa, K as Ca, L as Ea, a as xa, aA as ga, W as Da, at as ba, aw as va, ag as ya, Z as Ta, T as Sa, V as Na, aa as Pa, aE as wa, ai as _a, az as Aa, ay as Ia, ax as Ma, ah as Ra, al as Fa, am as ka, af as La, Y as Ba, ae as Va, a7 as Oa, a8 as Ua, a6 as za, aj as Ha, ad as Wa, aD as ja, aC as qa, ac as Qa, ab as Ga, an as Ka, ak as Ya, a2 as $a, O as Ja, ap as Xa, ar as Za, aq as ae, as as ee, N as se, G as oe, $ as re, H as te, av as ne, ao as ie, au as le, a1 as de, a0 as ce, a3 as ue, A as pe, M as he, J as me } from "./chunks/index-TF2KfLGc.js";
1
+ import { E as b, F as N, S as P, l as w, U as _, m as A, C as I, u as M, n as D, o as R, P as F, p as k, B as L, c as E, q as B, r as V, s as O, t as U, I as z, v as H, w as W, x as j, y as q, z as Q } from "./chunks/index-ahdw_esL.js";
2
+ import { a4 as ia, a5 as la, D as da, _ as ca, Q as ua, aB as pa, a9 as ha, R as ma, K as fa, K as Ca, L as Ea, a as xa, aA as ga, W as Da, at as ba, aw as va, ag as ya, Z as Ta, T as Sa, V as Na, aa as Pa, aE as wa, ai as _a, az as Aa, ay as Ia, ax as Ma, ah as Ra, al as Fa, am as ka, af as La, Y as Ba, ae as Va, a7 as Oa, a8 as Ua, a6 as za, aj as Ha, ad as Wa, aD as ja, aC as qa, ac as Qa, ab as Ga, an as Ka, ak as Ya, a2 as $a, O as Ja, ap as Xa, ar as Za, aq as ae, as as ee, N as se, G as oe, $ as re, H as te, av as ne, ao as ie, au as le, a1 as de, a0 as ce, a3 as ue, A as pe, M as he, J as me } from "./chunks/index-ahdw_esL.js";
3
3
  import { EMPTY_SELECTION as Ce } from "./types/index.js";
4
4
  import { jsx as a, jsxs as i } from "react/jsx-runtime";
5
5
  import * as h from "react";
6
6
  import { useMemo as G, useEffect as K } from "react";
7
- import { ResourceManagementPanel as xe } from "./chunks/resource-management-panel-Dda1VGgq.js";
8
- import { R as Y } from "./chunks/notification-bell-DNxWG0YY.js";
9
- import { A as De, a as be, E as ve, N as ye, S as Te, U as Se, V as Ne, u as Pe, b as we, c as _e } from "./chunks/notification-bell-DNxWG0YY.js";
7
+ import { ResourceManagementPanel as xe } from "./chunks/resource-management-panel-qkl060k8.js";
8
+ import { R as Y } from "./chunks/notification-bell-CKI2j8jH.js";
9
+ import { A as De, a as be, E as ve, N as ye, S as Te, U as Se, V as Ne, u as Pe, b as we, c as _e } from "./chunks/notification-bell-CKI2j8jH.js";
10
10
  import "react-dom";
11
11
  function sa(e) {
12
12
  const { displayPreferences: s, ...l } = e, d = {