react-semaphor 0.1.126 → 0.1.128

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 (33) hide show
  1. package/dist/chunks/dashboard-controls-Dd27T34x.js +26 -0
  2. package/dist/chunks/dashboard-controls-I6kqudDF.js +1539 -0
  3. package/dist/chunks/dashboard-export-dialog-CiZbDQ5t.js +6 -0
  4. package/dist/chunks/dashboard-export-dialog-DEOlAtvs.js +601 -0
  5. package/dist/chunks/{dashboard-json-DpgglXTM.js → dashboard-json-A6ShtMJP.js} +1 -1
  6. package/dist/chunks/{dashboard-json-B7_R2nwz.js → dashboard-json-D_muUlA0.js} +1 -1
  7. package/dist/chunks/edit-dashboard-visual-BgRPk31F.js +195 -0
  8. package/dist/chunks/{edit-dashboard-visual-Dfdl-K74.js → edit-dashboard-visual-KhJjpeit.js} +5966 -4980
  9. package/dist/chunks/{editor-action-buttons-CsV8nUOI.js → editor-action-buttons-cJ_lq4jv.js} +1 -1
  10. package/dist/chunks/{editor-action-buttons-CMKMrnww.js → editor-action-buttons-umPHWm3K.js} +2 -2
  11. package/dist/chunks/{index-BdiWSBWd.js → index-Bko2LZ3Y.js} +5816 -5795
  12. package/dist/chunks/{index-GG6fcfuj.js → index-CM_yfKlN.js} +192 -187
  13. package/dist/chunks/{resource-management-panel-CdC7mFhx.js → resource-management-panel-DAdIhRme.js} +88 -88
  14. package/dist/chunks/{resource-management-panel-3Q8phtkW.js → resource-management-panel-DvgyBS2t.js} +1 -1
  15. package/dist/chunks/{use-visual-utils-BE_5Rl3X.js → use-visual-utils-80E0OR0x.js} +1 -1
  16. package/dist/chunks/{use-visual-utils-CxVLCLOf.js → use-visual-utils-C7QMpNLz.js} +8 -8
  17. package/dist/dashboard/index.cjs +1 -1
  18. package/dist/dashboard/index.js +1 -1
  19. package/dist/index.cjs +2 -2
  20. package/dist/index.js +88 -87
  21. package/dist/style.css +1 -1
  22. package/dist/surfboard/index.cjs +1 -1
  23. package/dist/surfboard/index.js +1 -1
  24. package/dist/types/dashboard.d.ts +1 -1
  25. package/dist/types/main.d.ts +19 -43
  26. package/dist/types/surfboard.d.ts +1 -1
  27. package/dist/types/types.d.ts +1 -1
  28. package/package.json +1 -1
  29. package/dist/chunks/dashboard-controls-BktHa763.js +0 -1473
  30. package/dist/chunks/dashboard-controls-DucLNOji.js +0 -26
  31. package/dist/chunks/dashboard-export-dialog-BNjL5KSw.js +0 -600
  32. package/dist/chunks/dashboard-export-dialog-M318NGd7.js +0 -6
  33. package/dist/chunks/edit-dashboard-visual-BaNXGTU-.js +0 -170
@@ -1,7 +1,7 @@
1
1
  import { jsx as e, jsxs as a, Fragment as me } from "react/jsx-runtime";
2
- import { b as Ke, u as de, f as We, am as ne, aW as Ye, aX as Je, c as ee, aY as Xe, aE as Ze, aF as $e, B as G, aG as Qe, aH as ke, aI as J, aZ as ce, L as ie, a_ as et, a$ as tt, b0 as st, b1 as Ne, b2 as pe, b3 as at, b4 as nt, I as it, b5 as we, b6 as re, b7 as Ce, b8 as ve, b9 as rt, J as ye, R as Se, ba as Ve, bb as Ee, bc as Le, bd as Te, be as Ae, bf as Oe, bg as Pe, bh as Re, bi as Ie, bj as ot, bk as lt, bl as Ue, bm as je, bn as Me, bo as dt, bp as Fe, bq as ct, aC as ae, al as ut, br as ht, bs as ze, bt as mt, bu as pt, aq as ft, ar as gt, as as Dt, at as xt, au as Nt, av as be, aw as ue, az as bt, bv as wt, bw as Ct, bx as vt, by as yt } from "./index-BdiWSBWd.js";
2
+ import { b as Ke, u as de, f as qe, an as ne, b4 as We, b5 as Ye, c as ee, b6 as Qe, aF as Xe, aG as Ze, B as J, aH as $e, aI as ke, aJ as Y, b7 as ce, L as ie, b8 as et, b9 as tt, ba as st, bb as Ne, bc as pe, bd as at, be as nt, I as it, bf as we, bg as re, bh as Ce, bi as ve, bj as rt, J as ye, R as Se, bk as Ve, aN as Ee, aO as Le, aP as Ae, aR as Te, aS as Oe, aT as Pe, aU as Re, aV as Ie, bl as ot, bm as lt, bn as Ue, bo as je, bp as Me, bq as dt, br as Fe, bs as ct, aD as ae, am as ut, bt as ht, bu as ze, bv as mt, bw as pt, ar as ft, as as gt, at as Dt, au as xt, av as Nt, aw as be, ax as ue, aA as bt, bx as wt, by as Ct, bz as vt, bA as yt } from "./index-Bko2LZ3Y.js";
3
3
  import St, { useState as g, useEffect as he } from "react";
4
- import { a as Be } from "./use-visual-utils-CxVLCLOf.js";
4
+ import { a as Be } from "./use-visual-utils-C7QMpNLz.js";
5
5
  import { u as Vt } from "./use-click-outside-CMeO_QFI.js";
6
6
  /**
7
7
  * @license lucide-react v0.453.0 - ISC
@@ -35,10 +35,10 @@ function He() {
35
35
  )) });
36
36
  }
37
37
  const Lt = (t) => {
38
- const f = de((r) => r.isVisualEditing), p = de((r) => r.selectedFrameId), i = We((r) => r.frame);
38
+ const f = de((r) => r.isVisualEditing), p = de((r) => r.selectedFrameId), i = qe((r) => r.frame);
39
39
  return !!(f && p && (i == null ? void 0 : i.visualId) === t);
40
40
  };
41
- function Tt({
41
+ function At({
42
42
  visual: t,
43
43
  isDeleting: f,
44
44
  isDuplicating: p,
@@ -51,10 +51,10 @@ function Tt({
51
51
  onShareVisual: N,
52
52
  formatDate: S
53
53
  }) {
54
- var P, y, C, A;
55
- const { selectVisual: l } = ne(), d = Ye(t.id), h = Lt(t.id), { isConsoleMode: V } = Je(), E = St.useRef(null), [b, v] = g(!1), [L, T] = g(!1);
54
+ var P, y, C, T;
55
+ const { selectVisual: l } = ne(), d = We(t.id), h = Lt(t.id), { isConsoleMode: V } = Ye(), E = St.useRef(null), [b, v] = g(!1), [L, A] = g(!1);
56
56
  he(() => {
57
- p ? (v(!0), T(!0)) : L && (v(!1), T(!1));
57
+ p ? (v(!0), A(!0)) : L && (v(!1), A(!1));
58
58
  }, [p, L]), he(() => {
59
59
  h && E.current && E.current.scrollIntoView({
60
60
  behavior: "smooth",
@@ -74,7 +74,7 @@ function Tt({
74
74
  ),
75
75
  onClick: I,
76
76
  children: [
77
- /* @__PURE__ */ e(Xe, { className: "mt-0.5 h-4 w-4 flex-shrink-0 text-muted-foreground/50" }),
77
+ /* @__PURE__ */ e(Qe, { className: "mt-0.5 h-4 w-4 flex-shrink-0 text-muted-foreground/50" }),
78
78
  /* @__PURE__ */ e("div", { className: "min-w-0 flex-1", children: /* @__PURE__ */ a("div", { className: "flex items-start justify-between gap-2", children: [
79
79
  /* @__PURE__ */ a("div", { className: "min-w-0 flex-1", children: [
80
80
  /* @__PURE__ */ e(
@@ -101,16 +101,16 @@ function Tt({
101
101
  onClick: (c) => c.stopPropagation(),
102
102
  children: [
103
103
  /* @__PURE__ */ e("div", { className: "opacity-0 transition-opacity group-hover:opacity-100", children: /* @__PURE__ */ a(
104
- Ze,
104
+ Xe,
105
105
  {
106
106
  modal: !1,
107
107
  open: b,
108
108
  onOpenChange: v,
109
109
  children: [
110
- /* @__PURE__ */ e($e, { asChild: !0, children: /* @__PURE__ */ e(G, { size: "sm", variant: "ghost", className: "h-6 w-6 p-0", children: /* @__PURE__ */ e(Qe, { className: "h-3 w-3" }) }) }),
110
+ /* @__PURE__ */ e(Ze, { asChild: !0, children: /* @__PURE__ */ e(J, { size: "sm", variant: "ghost", className: "h-6 w-6 p-0", children: /* @__PURE__ */ e($e, { className: "h-3 w-3" }) }) }),
111
111
  /* @__PURE__ */ a(ke, { align: "end", className: "z-[51] w-40", children: [
112
112
  /* @__PURE__ */ a(
113
- J,
113
+ Y,
114
114
  {
115
115
  onClick: (c) => {
116
116
  c.stopPropagation(), i(t);
@@ -122,7 +122,7 @@ function Tt({
122
122
  }
123
123
  ),
124
124
  /* @__PURE__ */ a(
125
- J,
125
+ Y,
126
126
  {
127
127
  onClick: (c) => {
128
128
  c.stopPropagation(), r == null || r(t);
@@ -134,7 +134,7 @@ function Tt({
134
134
  }
135
135
  ),
136
136
  /* @__PURE__ */ a(
137
- J,
137
+ Y,
138
138
  {
139
139
  onClick: (c) => {
140
140
  c.preventDefault(), c.stopPropagation(), m(t.id);
@@ -148,7 +148,7 @@ function Tt({
148
148
  ),
149
149
  t.ownership.isOwner && /* @__PURE__ */ a(me, { children: [
150
150
  /* @__PURE__ */ a(
151
- J,
151
+ Y,
152
152
  {
153
153
  onClick: (c) => {
154
154
  c.stopPropagation(), D == null || D(t);
@@ -160,7 +160,7 @@ function Tt({
160
160
  }
161
161
  ),
162
162
  /* @__PURE__ */ a(
163
- J,
163
+ Y,
164
164
  {
165
165
  onClick: (c) => {
166
166
  c.stopPropagation(), N(t);
@@ -173,7 +173,7 @@ function Tt({
173
173
  ),
174
174
  /* @__PURE__ */ e(Ne, {}),
175
175
  /* @__PURE__ */ a(
176
- J,
176
+ Y,
177
177
  {
178
178
  onClick: (c) => {
179
179
  c.stopPropagation(), x(t);
@@ -191,7 +191,7 @@ function Tt({
191
191
  /* @__PURE__ */ a("div", { className: "space-y-1 px-2 py-2 text-xs text-slate-500 dark:text-slate-400", children: [
192
192
  (((y = t.ownership.createdBy) == null ? void 0 : y.type) === "tenant" || ((C = t.ownership.createdBy) == null ? void 0 : C.type) === "organization" && V) && /* @__PURE__ */ a("div", { className: "flex items-center gap-1", children: [
193
193
  /* @__PURE__ */ e(at, { className: "h-3 w-3" }),
194
- /* @__PURE__ */ e("span", { children: ((A = t.ownership.createdBy) == null ? void 0 : A.name) || "Unknown" })
194
+ /* @__PURE__ */ e("span", { children: ((T = t.ownership.createdBy) == null ? void 0 : T.name) || "Unknown" })
195
195
  ] }),
196
196
  /* @__PURE__ */ a("div", { className: "flex items-center gap-1", children: [
197
197
  /* @__PURE__ */ e(nt, { className: "h-3 w-3" }),
@@ -226,7 +226,7 @@ function Tt({
226
226
  t.id
227
227
  );
228
228
  }
229
- function At({ searchQuery: t }) {
229
+ function Tt({ searchQuery: t }) {
230
230
  const [f, p] = g(!1), [i, r] = g(
231
231
  null
232
232
  ), [D, x] = g(!1), [m, N] = g(null), [S, l] = g(null), [d, h] = g(
@@ -234,7 +234,7 @@ function At({ searchQuery: t }) {
234
234
  ), { selectVisual: V } = ne(), { handleEditLibraryVisual: E, handleAddLibraryVisual: b } = Be(), {
235
235
  resources: v,
236
236
  isLoading: L,
237
- isError: T,
237
+ isError: A,
238
238
  updateResource: I,
239
239
  deleteResource: P,
240
240
  duplicateResource: y,
@@ -243,7 +243,7 @@ function At({ searchQuery: t }) {
243
243
  x(!1), N(null);
244
244
  });
245
245
  re();
246
- const A = v.filter(
246
+ const T = v.filter(
247
247
  (n) => {
248
248
  var O, o;
249
249
  return ((O = n == null ? void 0 : n.title) == null ? void 0 : O.toLowerCase().includes(t.toLowerCase())) || ((o = n == null ? void 0 : n.description) == null ? void 0 : o.toLowerCase().includes(t.toLowerCase()));
@@ -254,7 +254,7 @@ function At({ searchQuery: t }) {
254
254
  year: "numeric"
255
255
  }), M = (n) => {
256
256
  N(n), x(!0);
257
- }, X = () => {
257
+ }, Q = () => {
258
258
  m && P(m.id);
259
259
  }, {
260
260
  startUpdating: F,
@@ -262,18 +262,18 @@ function At({ searchQuery: t }) {
262
262
  isUpdating: R
263
263
  } = Ce(), z = (n, O, o) => {
264
264
  var se;
265
- const Y = Object.fromEntries(
265
+ const W = Object.fromEntries(
266
266
  Object.entries(O).filter(([, j]) => j !== void 0)
267
267
  );
268
- if (Object.keys(Y).length === 0) {
268
+ if (Object.keys(W).length === 0) {
269
269
  (se = o == null ? void 0 : o.onSuccess) == null || se.call(o);
270
270
  return;
271
271
  }
272
- const te = Object.keys(Y), k = te.length === 1 ? te[0] : void 0;
272
+ const te = Object.keys(W), k = te.length === 1 ? te[0] : void 0;
273
273
  F(n, k), I(
274
274
  {
275
275
  resourceId: n,
276
- data: Y
276
+ data: W
277
277
  },
278
278
  {
279
279
  onSuccess: () => {
@@ -290,11 +290,11 @@ function At({ searchQuery: t }) {
290
290
  l(n), y(n, {
291
291
  onSettled: () => l(null)
292
292
  });
293
- }, Z = (n) => {
293
+ }, X = (n) => {
294
294
  E(n);
295
295
  }, H = (n) => {
296
296
  b(n);
297
- }, $ = (n) => {
297
+ }, Z = (n) => {
298
298
  const O = v.find((o) => o.id === n);
299
299
  O && I({
300
300
  resourceId: n,
@@ -304,11 +304,11 @@ function At({ searchQuery: t }) {
304
304
  });
305
305
  }, _ = (n) => {
306
306
  r(n), p(!0);
307
- }, W = (n) => {
307
+ }, q = (n) => {
308
308
  h(n);
309
309
  }, w = () => {
310
310
  h(null);
311
- }, Q = ({
311
+ }, $ = ({
312
312
  title: n,
313
313
  description: O
314
314
  }) => {
@@ -321,10 +321,10 @@ function At({ searchQuery: t }) {
321
321
  }
322
322
  });
323
323
  };
324
- return L ? /* @__PURE__ */ e(He, {}) : T ? /* @__PURE__ */ e(ve, { className: "w-full flex-1 pr-2", children: /* @__PURE__ */ a("div", { className: "py-8 text-center text-muted-foreground", children: [
324
+ return L ? /* @__PURE__ */ e(He, {}) : A ? /* @__PURE__ */ e(ve, { className: "w-full flex-1 pr-2", children: /* @__PURE__ */ a("div", { className: "py-8 text-center text-muted-foreground", children: [
325
325
  /* @__PURE__ */ e("p", { className: "text-sm text-destructive", children: "Failed to load visuals" }),
326
326
  /* @__PURE__ */ e(
327
- G,
327
+ J,
328
328
  {
329
329
  variant: "outline",
330
330
  size: "sm",
@@ -334,20 +334,20 @@ function At({ searchQuery: t }) {
334
334
  }
335
335
  )
336
336
  ] }) }) : /* @__PURE__ */ a("div", { className: "flex h-full flex-1 flex-col", children: [
337
- /* @__PURE__ */ e("div", { className: "flex flex-1 basis-0 flex-col gap-3 overflow-y-auto", children: A.length === 0 ? /* @__PURE__ */ a("div", { className: "py-8 text-center", children: [
337
+ /* @__PURE__ */ e("div", { className: "flex flex-1 basis-0 flex-col gap-3 overflow-y-auto", children: T.length === 0 ? /* @__PURE__ */ a("div", { className: "py-8 text-center", children: [
338
338
  /* @__PURE__ */ e("div", { className: "mb-3", children: /* @__PURE__ */ e(rt, { className: "mx-auto h-12 w-12 text-muted-foreground/50" }) }),
339
339
  /* @__PURE__ */ e("h3", { className: "mb-1 font-medium text-foreground", children: t ? "No visuals found" : "No visuals yet" }),
340
340
  /* @__PURE__ */ e("p", { className: "text-sm text-muted-foreground", children: t ? "Try adjusting your search" : 'Click "Create" above to add your first visual' })
341
- ] }) : A.map((n) => /* @__PURE__ */ e(
342
- Tt,
341
+ ] }) : T.map((n) => /* @__PURE__ */ e(
342
+ At,
343
343
  {
344
344
  visual: n,
345
345
  onAddVisual: H,
346
- onOpenVisual: Z,
347
- onEditDetails: W,
346
+ onOpenVisual: X,
347
+ onEditDetails: q,
348
348
  onDeleteClick: M,
349
349
  onDuplicateVisual: B,
350
- onTogglePrivacy: $,
350
+ onTogglePrivacy: Z,
351
351
  onShareVisual: _,
352
352
  isDeleting: C,
353
353
  isDuplicating: S === n.id,
@@ -373,7 +373,7 @@ function At({ searchQuery: t }) {
373
373
  initialTitle: d.title || "",
374
374
  initialDescription: d.description || "",
375
375
  onClose: w,
376
- onSave: Q,
376
+ onSave: $,
377
377
  isSaving: R(d.id)
378
378
  }
379
379
  ),
@@ -385,8 +385,8 @@ function At({ searchQuery: t }) {
385
385
  !n && C || (x(n), n || N(null));
386
386
  },
387
387
  children: /* @__PURE__ */ a(Le, { children: [
388
- /* @__PURE__ */ a(Te, { children: [
389
- /* @__PURE__ */ e(Ae, { children: "Delete Visual" }),
388
+ /* @__PURE__ */ a(Ae, { children: [
389
+ /* @__PURE__ */ e(Te, { children: "Delete Visual" }),
390
390
  /* @__PURE__ */ a(Oe, { children: [
391
391
  'Are you sure you want to delete "',
392
392
  m == null ? void 0 : m.title,
@@ -399,7 +399,7 @@ function At({ searchQuery: t }) {
399
399
  Ie,
400
400
  {
401
401
  onClick: (n) => {
402
- n.preventDefault(), n.stopPropagation(), X();
402
+ n.preventDefault(), n.stopPropagation(), Q();
403
403
  },
404
404
  className: "bg-destructive text-destructive-foreground hover:bg-destructive/90",
405
405
  disabled: C,
@@ -429,7 +429,7 @@ function Ot({
429
429
  onDashboardItemClick: l
430
430
  }) {
431
431
  var P, y;
432
- const { selectDashboard: d } = ne(), h = ot(t.id), { userContext: V, isLoading: E } = re(), { mutate: b } = lt(), v = ((P = V == null ? void 0 : V.permissions) == null ? void 0 : P.canEdit) ?? !1, L = E || !v, T = () => {
432
+ const { selectDashboard: d } = ne(), h = ot(t.id), { userContext: V, isLoading: E } = re(), { mutate: b } = lt(), v = ((P = V == null ? void 0 : V.permissions) == null ? void 0 : P.canEdit) ?? !1, L = E || !v, A = () => {
433
433
  d(t), r(t.id), l == null || l(t.id);
434
434
  }, I = (C) => {
435
435
  C.stopPropagation(), b({ dashboardId: i ? null : t.id });
@@ -441,7 +441,7 @@ function Ot({
441
441
  "group flex cursor-pointer items-start gap-3 rounded-md px-2 py-2 transition-colors hover:bg-muted",
442
442
  h && "bg-muted/80"
443
443
  ),
444
- onClick: T,
444
+ onClick: A,
445
445
  children: [
446
446
  /* @__PURE__ */ a(je, { children: [
447
447
  /* @__PURE__ */ e(Me, { asChild: !0, children: /* @__PURE__ */ e(
@@ -504,7 +504,7 @@ function Ot({
504
504
  function Pt({ onRetry: t }) {
505
505
  return /* @__PURE__ */ e(ve, { className: "w-full flex-1 pr-2", children: /* @__PURE__ */ a("div", { className: "py-8 text-center text-muted-foreground", children: [
506
506
  /* @__PURE__ */ e("p", { className: "text-sm text-destructive", children: "Failed to load dashboards" }),
507
- /* @__PURE__ */ e(G, { variant: "outline", size: "sm", className: "mt-2", onClick: t, children: "Retry" })
507
+ /* @__PURE__ */ e(J, { variant: "outline", size: "sm", className: "mt-2", onClick: t, children: "Retry" })
508
508
  ] }) });
509
509
  }
510
510
  function Rt(t) {
@@ -513,7 +513,7 @@ function Rt(t) {
513
513
  null
514
514
  ), [S, l] = g(!1), [d, h] = g(null), [V, E] = g(null), [b, v] = g(null), L = ae(
515
515
  (s) => s.lastSelectedDashboard
516
- ), T = ae(
516
+ ), A = ae(
517
517
  (s) => s.selectedDashboard
518
518
  ), I = ae(
519
519
  (s) => s.actions.selectDashboard
@@ -522,29 +522,29 @@ function Rt(t) {
522
522
  ), { tokenProps: y, id: C } = ut();
523
523
  ht();
524
524
  const {
525
- resources: A,
525
+ resources: T,
526
526
  isLoading: c,
527
527
  isError: M,
528
- updateResource: X,
528
+ updateResource: Q,
529
529
  deleteResource: F,
530
530
  duplicateResource: K,
531
531
  isDeleting: R
532
532
  } = ze(() => {
533
533
  l(!1);
534
534
  const s = d == null ? void 0 : d.id;
535
- h(null), (T == null ? void 0 : T.id) === s && (!(y != null && y.dashboard_id) && !C ? P() : L && L.id !== s && I(L));
536
- }), { currentUser: z, userContext: B } = re(), Z = ((fe = B == null ? void 0 : B.permissions) == null ? void 0 : fe.canCreateDashboard) ?? !1, { data: H } = mt(), $ = ((ge = H == null ? void 0 : H.preference) == null ? void 0 : ge.defaultDashboardId) || null, _ = A.filter(
535
+ h(null), (A == null ? void 0 : A.id) === s && (!(y != null && y.dashboard_id) && !C ? P() : L && L.id !== s && I(L));
536
+ }), { currentUser: z, userContext: B } = re(), X = ((fe = B == null ? void 0 : B.permissions) == null ? void 0 : fe.canCreateDashboard) ?? !1, { data: H } = mt(), Z = ((ge = H == null ? void 0 : H.preference) == null ? void 0 : ge.defaultDashboardId) || null, _ = T.filter(
537
537
  (s) => {
538
538
  var U, u;
539
539
  return ((U = s == null ? void 0 : s.title) == null ? void 0 : U.toLowerCase().includes(f.toLowerCase())) || ((u = s == null ? void 0 : s.description) == null ? void 0 : u.toLowerCase().includes(f.toLowerCase()));
540
540
  }
541
- ), W = (s) => new Date(s).toLocaleDateString("en-US", {
541
+ ), q = (s) => new Date(s).toLocaleDateString("en-US", {
542
542
  month: "short",
543
543
  day: "numeric",
544
544
  year: "numeric"
545
545
  }), w = (s) => {
546
546
  p == null || p(s);
547
- }, Q = (s) => {
547
+ }, $ = (s) => {
548
548
  h(s), l(!0);
549
549
  }, n = () => {
550
550
  d && F(d.id);
@@ -554,39 +554,39 @@ function Rt(t) {
554
554
  });
555
555
  }, {
556
556
  startUpdating: o,
557
- stopUpdating: Y,
557
+ stopUpdating: W,
558
558
  isUpdating: te
559
559
  } = Ce(), k = (s, U, u) => {
560
560
  var xe;
561
561
  const oe = Object.fromEntries(
562
- Object.entries(U).filter(([, q]) => q !== void 0)
562
+ Object.entries(U).filter(([, G]) => G !== void 0)
563
563
  );
564
564
  if (Object.keys(oe).length === 0) {
565
565
  (xe = u == null ? void 0 : u.onSuccess) == null || xe.call(u);
566
566
  return;
567
567
  }
568
568
  const De = Object.keys(oe), le = De.length === 1 ? De[0] : void 0;
569
- o(s, le), X(
569
+ o(s, le), Q(
570
570
  {
571
571
  resourceId: s,
572
572
  data: oe
573
573
  },
574
574
  {
575
575
  onSuccess: () => {
576
- var q;
577
- Y(s, le), (q = u == null ? void 0 : u.onSuccess) == null || q.call(u);
576
+ var G;
577
+ W(s, le), (G = u == null ? void 0 : u.onSuccess) == null || G.call(u);
578
578
  },
579
579
  onError: () => {
580
- var q;
581
- Y(s, le), (q = u == null ? void 0 : u.onError) == null || q.call(u);
580
+ var G;
581
+ W(s, le), (G = u == null ? void 0 : u.onError) == null || G.call(u);
582
582
  }
583
583
  }
584
584
  );
585
585
  }, se = (s) => {
586
- const U = A.find(
586
+ const U = T.find(
587
587
  (u) => u.id === s
588
588
  );
589
- U && X({
589
+ U && Q({
590
590
  resourceId: s,
591
591
  data: {
592
592
  isPrivate: !U.isPrivate
@@ -596,9 +596,9 @@ function Rt(t) {
596
596
  N(s), z == null || z.type, x(!0);
597
597
  }, _e = (s) => {
598
598
  i == null || i(s.id), v(s);
599
- }, qe = () => {
599
+ }, Ge = () => {
600
600
  v(null);
601
- }, Ge = ({
601
+ }, Je = ({
602
602
  title: s,
603
603
  description: U
604
604
  }) => {
@@ -615,21 +615,21 @@ function Rt(t) {
615
615
  /* @__PURE__ */ e("div", { className: "flex flex-1 basis-0 flex-col gap-3 overflow-y-auto", children: _.length === 0 ? /* @__PURE__ */ a("div", { className: "py-8 text-center", children: [
616
616
  /* @__PURE__ */ e("div", { className: "mb-3", children: /* @__PURE__ */ e(pt, { className: "mx-auto h-12 w-12 text-muted-foreground/50" }) }),
617
617
  /* @__PURE__ */ e("h3", { className: "mb-1 font-medium text-foreground", children: f ? "No dashboards found" : "No dashboards yet" }),
618
- /* @__PURE__ */ e("p", { className: "text-sm text-muted-foreground", children: f ? "Try adjusting your search" : Z ? 'Click "Create" above to add your first dashboard' : "No dashboards have been shared with you yet" })
618
+ /* @__PURE__ */ e("p", { className: "text-sm text-muted-foreground", children: f ? "Try adjusting your search" : X ? 'Click "Create" above to add your first dashboard' : "No dashboards have been shared with you yet" })
619
619
  ] }) : _.map((s) => /* @__PURE__ */ e(
620
620
  Ot,
621
621
  {
622
622
  dashboard: s,
623
623
  isDeleting: R,
624
624
  isDuplicating: V === s.id,
625
- isDefault: s.id === $,
625
+ isDefault: s.id === Z,
626
626
  onLoadDashboard: w,
627
627
  onEditDetails: _e,
628
- onDeleteClick: Q,
628
+ onDeleteClick: $,
629
629
  onDuplicateDashboard: O,
630
630
  onTogglePrivacy: se,
631
631
  onShareDashboard: j,
632
- formatDate: W,
632
+ formatDate: q,
633
633
  onDashboardItemClick: r
634
634
  },
635
635
  s.id
@@ -652,8 +652,8 @@ function Rt(t) {
652
652
  !s && R || (l(s), s || h(null));
653
653
  },
654
654
  children: /* @__PURE__ */ a(Le, { children: [
655
- /* @__PURE__ */ a(Te, { children: [
656
- /* @__PURE__ */ e(Ae, { children: "Delete Dashboard" }),
655
+ /* @__PURE__ */ a(Ae, { children: [
656
+ /* @__PURE__ */ e(Te, { children: "Delete Dashboard" }),
657
657
  /* @__PURE__ */ a(Oe, { children: [
658
658
  'Are you sure you want to delete "',
659
659
  d == null ? void 0 : d.title,
@@ -687,8 +687,8 @@ function Rt(t) {
687
687
  resourceLabel: "Dashboard",
688
688
  initialTitle: b.title || "",
689
689
  initialDescription: b.description || "",
690
- onClose: qe,
691
- onSave: Ge,
690
+ onClose: Ge,
691
+ onSave: Je,
692
692
  isSaving: te(b.id)
693
693
  }
694
694
  )
@@ -747,7 +747,7 @@ function It({
747
747
  ] }),
748
748
  /* @__PURE__ */ a(bt, { children: [
749
749
  /* @__PURE__ */ e(
750
- G,
750
+ J,
751
751
  {
752
752
  variant: "outline",
753
753
  onClick: () => S(!1),
@@ -756,7 +756,7 @@ function It({
756
756
  }
757
757
  ),
758
758
  /* @__PURE__ */ e(
759
- G,
759
+ J,
760
760
  {
761
761
  onClick: N,
762
762
  disabled: !r.trim() || i,
@@ -776,13 +776,13 @@ function Bt({
776
776
  onDashboardItemClick: i,
777
777
  variant: r = "inline"
778
778
  }) {
779
- var _, W;
779
+ var _, q;
780
780
  const D = de(
781
781
  (w) => w.isDashboardEditing
782
782
  ), [x, m] = g(!1), [N, S] = g(""), [l, d] = g(!1), { currentUser: h, userContext: V } = re(), E = ((_ = V == null ? void 0 : V.permissions) == null ? void 0 : _.canCreateDashboard) ?? !1, { onCreateSuccess: b } = wt({
783
783
  onDashboardSelect: i
784
784
  }), { selectVisual: v } = ne(), { handleEditLibraryVisual: L } = Be(), {
785
- createResource: T,
785
+ createResource: A,
786
786
  isCreating: I,
787
787
  refetch: P
788
788
  } = ze(), { createResource: y, isCreating: C } = we(
@@ -791,32 +791,32 @@ function Bt({
791
791
  (w) => {
792
792
  m(!1), w && (v(w), L(w));
793
793
  }
794
- ), A = r === "overlay", c = ((h == null ? void 0 : h.name) ?? "").trim(), M = ((h == null ? void 0 : h.email) ?? "").trim(), F = c && c.toLowerCase() !== "undefined" ? c : M || "Current user", K = ((W = F.charAt(0)) == null ? void 0 : W.toUpperCase()) || "?", R = M && M.toLowerCase() !== "undefined" ? M : "", z = Vt(f, {
795
- enabled: t && A
794
+ ), T = r === "overlay", c = ((h == null ? void 0 : h.name) ?? "").trim(), M = ((h == null ? void 0 : h.email) ?? "").trim(), F = c && c.toLowerCase() !== "undefined" ? c : M || "Current user", K = ((q = F.charAt(0)) == null ? void 0 : q.toUpperCase()) || "?", R = M && M.toLowerCase() !== "undefined" ? M : "", z = Vt(f, {
795
+ enabled: t && T
796
796
  }), B = ee(
797
797
  "flex h-full flex-col border-r bg-background",
798
- A ? ee(
798
+ T ? ee(
799
799
  "absolute inset-y-0 left-0 z-[51] w-60 shadow-lg transition-transform duration-300 ease-in-out",
800
800
  t ? "translate-x-0" : "pointer-events-none -translate-x-full"
801
801
  ) : "w-full max-w-[17rem] min-w-[11rem] overflow-hidden shadow-sm",
802
802
  p
803
- ), Z = (w) => {
803
+ ), X = (w) => {
804
804
  }, H = (w) => {
805
805
  console.log("Editing dashboard:", w);
806
- }, $ = (w) => {
807
- T(w, {
808
- onSuccess: (Q) => {
809
- m(!1), b(Q, P);
806
+ }, Z = (w) => {
807
+ A(w, {
808
+ onSuccess: ($) => {
809
+ m(!1), b($, P);
810
810
  }
811
811
  });
812
812
  };
813
- return /* @__PURE__ */ e(me, { children: (!A || t) && /* @__PURE__ */ a("div", { ref: z, className: B, children: [
813
+ return /* @__PURE__ */ e(me, { children: (!T || t) && /* @__PURE__ */ a("div", { ref: z, className: B, children: [
814
814
  /* @__PURE__ */ a("div", { className: "border-b border-border", children: [
815
815
  /* @__PURE__ */ a("div", { className: "flex items-center justify-between px-4 py-1.5", children: [
816
816
  /* @__PURE__ */ e("div", { className: "flex items-center gap-2", children: /* @__PURE__ */ e("h2", { className: "whitespace-nowrap text-sm font-semibold", children: D ? "Visuals" : "Dashboards" }) }),
817
817
  /* @__PURE__ */ a("div", { className: "flex items-center gap-0", children: [
818
818
  /* @__PURE__ */ e(
819
- G,
819
+ J,
820
820
  {
821
821
  size: "sm",
822
822
  variant: "ghost",
@@ -826,7 +826,7 @@ function Bt({
826
826
  }
827
827
  ),
828
828
  (D || E) && /* @__PURE__ */ e(
829
- G,
829
+ J,
830
830
  {
831
831
  size: "sm",
832
832
  variant: "ghost",
@@ -848,11 +848,11 @@ function Bt({
848
848
  }
849
849
  ) })
850
850
  ] }),
851
- /* @__PURE__ */ e("div", { className: "flex flex-1 flex-col overflow-auto px-2 py-2", children: D ? /* @__PURE__ */ e(At, { searchQuery: N }) : /* @__PURE__ */ e(
851
+ /* @__PURE__ */ e("div", { className: "flex flex-1 flex-col overflow-auto px-2 py-2", children: D ? /* @__PURE__ */ e(Tt, { searchQuery: N }) : /* @__PURE__ */ e(
852
852
  Rt,
853
853
  {
854
854
  searchQuery: N,
855
- onLoadDashboard: Z,
855
+ onLoadDashboard: X,
856
856
  onEditDashboard: H,
857
857
  onDashboardItemClick: i
858
858
  }
@@ -884,7 +884,7 @@ function Bt({
884
884
  {
885
885
  open: x,
886
886
  onOpenChange: m,
887
- onSubmit: $,
887
+ onSubmit: Z,
888
888
  isCreating: I
889
889
  }
890
890
  )
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),s=require("./index-GG6fcfuj.js"),m=require("react"),re=require("./use-visual-utils-BE_5Rl3X.js"),ue=require("./use-click-outside-B9T3lmcw.js");/**
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),s=require("./index-CM_yfKlN.js"),m=require("react"),re=require("./use-visual-utils-80E0OR0x.js"),ue=require("./use-click-outside-B9T3lmcw.js");/**
2
2
  * @license lucide-react v0.453.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -1 +1 @@
1
- "use strict";const o=require("./index-GG6fcfuj.js"),b=require("react");function _(e){const a=e.toUpperCase().indexOf("WHERE"),r=e.toUpperCase().indexOf("GROUP BY"),t=e.toUpperCase().indexOf("LIMIT"),d=e.toUpperCase().indexOf("ORDER BY");let c=e.length;if(d!==-1&&(c=d),t!==-1&&t<c&&(c=t),a!==-1){const n=e.substring(0,a),s=e.substring(a);return`${n} {{ filters | where }} AND ${s.substring(6)}`}else if(r!==-1){const n=e.substring(0,r),s=e.substring(r);return`${n} {{ filters | where }} ${s}`}else{const n=e.substring(0,c),s=e.substring(c);return console.log("beforeClause",n),console.log("afterClause",s),s?`${n} {{ filters | where }} ${s}`:`${n.replace(/;$/,"")} {{ filters | where }}`}}function B(e){const[a,r]=b.useState(null),[t,d]=b.useState(null),c=o.useEnsureReactGlobals();return b.useEffect(()=>{if(!e||e.trim()===""){r(null),d(null);return}if(!c)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 m=await import(l);if(typeof m.useChartStore!="function")throw new Error("useChartStore is not a function");r(()=>m.useChartStore),d(null)}catch(s){const l=s instanceof Error?s.message:"Unknown error";console.error("Failed to load remote chart store:",l),d(l),r(null)}})()},[e,c]),a}function H(e,a){if(e.length===0)return"";if(a){const r=e.find(t=>t.id===a);if(r){const t=r.tabTitle;if(t=="All__Header")return e[0].id;if(t&&t.endsWith("__Header")){const c=t.split("__")[0],n=e.find(s=>s.tabTitle===c);return n?n.id:e[0].id}return a}}return e[0].id}async function j(e,a,r,t){if(!a||!r)throw new Error("Missing auth token or visual ID");const d=["resource-by-id","visual",r],c=t.getQueryData(d);if(c)return console.log("Using cached visual data for:",r),{data:c,fromCache:!0};console.log("Fetching visual data from network for:",r);const n=o.ue.loading("Loading visual...",{position:"top-center"});try{const s=await fetch(`${e}/management/v1/visuals/${r}`,{headers:{Authorization:`Bearer ${a}`}});if(!s.ok)throw new Error("Failed to load visual");const l=await s.json();return t.setQueryData(d,l),o.ue.dismiss(n),{data:l,fromCache:!1}}catch(s){throw o.ue.dismiss(n),s}}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 Q(e,a){var c,n;const r=(e==null?void 0:e.frameObject)??((c=e==null?void 0:e.visual)==null?void 0:c.frameObject);if(!r)return!1;const t=T(r);if(!(t!=null&&t.cards)||t.cards.length===0)return!1;const d=(n=t.cards)==null?void 0:n.find(s=>s.id===t.activeCardId);return d?(o.setupEditorWithCard({...a,frame:t,card:d,visualId:(e==null?void 0:e.id)||t.visualId}),!0):!1}function G(){var g;const{setCardSql:e}=o.useEditorActions(),a=o.useEditorStore(i=>i.frame),r=o.useEditorStore(i=>i.card),t=B(((g=r.customCardPreferences)==null?void 0:g.url)||""),d=o.useEditorStore(i=>i.selectedSchemaName),c=o.useEditorStore(i=>i.selectedDatamodelId),n=o.useEditorStore(i=>i.selectedDatabaseName),s=o.useEditorStore(i=>i.selectedTableName),l=o.useEditorStore(i=>i.selectedConnectionId),m=o.useEditorStore(i=>i.isShowingVisual),f=r.sql;return{getUpdatedFrame:b.useCallback(()=>{var E;let i=f;f&&!f.includes("{{")&&(i=_(f),e(i));const C=(E=t==null?void 0:t.getState())==null?void 0:E.settings,U={...r,dataSource:r.dataSource||{mode:"directSource"},lastSelectedSchema:d,lastSelectedDatamodelId:c,lastSelectedDatabase:n,lastSelectedTable:s,connectionId:l,sql:i,customCfg:m?r.customCfg:null,preferences:r.preferences,...C&&{customCardPreferences:{...r.customCardPreferences,settings:C}}},w=a.cards.map(S=>S.id===r.id?U:S);return{...a,cards:w,activeCardId:H(w,a.activeCardId)}},[r,a,m,d,c,n,s,l,e,t,f])}}function z(){const{authToken:e,tokenProps:a}=o.useSemaphorContext(),r=o.useQueryClient(),t=o.useSelectedVisual(),{selectVisual:d}=o.useManagementActions(),{setFrame:c,setCard:n,setIsDevMode:s,setActiveTabCardId:l,updateDataSource:m,setQueryResultColumns:f,setSelectedConnectionId:V,setSelectedDatabaseName:g,setSelectedSchemaName:i,setSelectedTableName:C,setSelectedDatamodelId:U,setFilterValues:w,setApplyFilters:E}=o.useEditorActions(),{setIsDashboardEditing:S,setIsVisualEditing:$,setSelectedFrameId:v,clearSelectedFrameId:A,addFrame:N,setIsDashboardPanelOpen:R}=o.useDashboardActions(),I=o.useDashboardStore(u=>u.selectedSheetId),D=o.useDashboardStore(u=>u.selectedFrameId),O=o.useDashboardStore(u=>u.dashboard),x=o.useDashboardStore(u=>u.filterValues),y=o.useVisualById((t==null?void 0:t.id)||"",{enabled:!!(t!=null&&t.id)&&!!(e!=null&&e.accessToken)}),M=b.useCallback(async u=>{try{d(u),A();const{data:p,fromCache:h}=await j(a.apiServiceUrl,(e==null?void 0:e.accessToken)||"",u.id,r);if(!Q(p,{setFrame:c,setCard:n,setIsDevMode:s,setActiveTabCardId:l,updateDataSource:m,setQueryResultColumns:f,setSelectedConnectionId:V,setSelectedDatabaseName:g,setSelectedSchemaName:i,setSelectedTableName:C,setSelectedDatamodelId:U,setFilterValues:w,setApplyFilters:E,setIsDashboardEditing:S,setIsVisualEditing:$,dashboard:O,selectedSheetId:I,selectedFrameId:D,filterValues:x}))throw new Error("Failed to setup editor with visual data");return{success:!0,fromCache:h}}catch(p){return console.error("Error editing visual:",p),{success:!1,error:"Failed to load visual for editing"}}},[e==null?void 0:e.accessToken,a.apiServiceUrl,r,d,c,n,S,$,s,l,m,f,V,g,i,C,U,w,E,A,O,I,D,x]),k=b.useCallback(async u=>{var p;try{if(d(u),!I)return{success:!1,error:"No sheet selected. Please select a sheet first."};const{data:h,fromCache:W}=await j(a.apiServiceUrl,(e==null?void 0:e.accessToken)||"",u.id,r),L=(h==null?void 0:h.frameObject)??((p=h==null?void 0:h.visual)==null?void 0:p.frameObject);if(!L)return{success:!1,error:"Visual has no frame data"};const F=T(L);if(!(F!=null&&F.cards)||F.cards.length===0)return{success:!1,error:"Visual frame is malformed"};const P={...o.cloneFrameWithNewIds(F),visualId:u.id};return N(I,P,"end"),S(!0),v(P.id),R(!1),{success:!0,fromCache:W}}catch(h){return console.error("Error adding visual:",h),{success:!1,error:"Failed to add visual to dashboard"}}},[e==null?void 0:e.accessToken,a.apiServiceUrl,r,d,I,N,S,v,R]);return{visual:y.data,isLoading:y.isLoading,isError:y.isError,error:y.error,handleEditLibraryVisual:M,handleAddLibraryVisual:k,getUpdatedFrame:G().getUpdatedFrame,refetch:y.refetch}}exports.useRemoteChartStore=B;exports.useVisualUtils=z;
1
+ "use strict";const o=require("./index-CM_yfKlN.js"),b=require("react");function _(e){const a=e.toUpperCase().indexOf("WHERE"),r=e.toUpperCase().indexOf("GROUP BY"),t=e.toUpperCase().indexOf("LIMIT"),d=e.toUpperCase().indexOf("ORDER BY");let c=e.length;if(d!==-1&&(c=d),t!==-1&&t<c&&(c=t),a!==-1){const n=e.substring(0,a),s=e.substring(a);return`${n} {{ filters | where }} AND ${s.substring(6)}`}else if(r!==-1){const n=e.substring(0,r),s=e.substring(r);return`${n} {{ filters | where }} ${s}`}else{const n=e.substring(0,c),s=e.substring(c);return console.log("beforeClause",n),console.log("afterClause",s),s?`${n} {{ filters | where }} ${s}`:`${n.replace(/;$/,"")} {{ filters | where }}`}}function B(e){const[a,r]=b.useState(null),[t,d]=b.useState(null),c=o.useEnsureReactGlobals();return b.useEffect(()=>{if(!e||e.trim()===""){r(null),d(null);return}if(!c)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 m=await import(l);if(typeof m.useChartStore!="function")throw new Error("useChartStore is not a function");r(()=>m.useChartStore),d(null)}catch(s){const l=s instanceof Error?s.message:"Unknown error";console.error("Failed to load remote chart store:",l),d(l),r(null)}})()},[e,c]),a}function H(e,a){if(e.length===0)return"";if(a){const r=e.find(t=>t.id===a);if(r){const t=r.tabTitle;if(t=="All__Header")return e[0].id;if(t&&t.endsWith("__Header")){const c=t.split("__")[0],n=e.find(s=>s.tabTitle===c);return n?n.id:e[0].id}return a}}return e[0].id}async function j(e,a,r,t){if(!a||!r)throw new Error("Missing auth token or visual ID");const d=["resource-by-id","visual",r],c=t.getQueryData(d);if(c)return console.log("Using cached visual data for:",r),{data:c,fromCache:!0};console.log("Fetching visual data from network for:",r);const n=o.ue.loading("Loading visual...",{position:"top-center"});try{const s=await fetch(`${e}/management/v1/visuals/${r}`,{headers:{Authorization:`Bearer ${a}`}});if(!s.ok)throw new Error("Failed to load visual");const l=await s.json();return t.setQueryData(d,l),o.ue.dismiss(n),{data:l,fromCache:!1}}catch(s){throw o.ue.dismiss(n),s}}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 Q(e,a){var c,n;const r=(e==null?void 0:e.frameObject)??((c=e==null?void 0:e.visual)==null?void 0:c.frameObject);if(!r)return!1;const t=T(r);if(!(t!=null&&t.cards)||t.cards.length===0)return!1;const d=(n=t.cards)==null?void 0:n.find(s=>s.id===t.activeCardId);return d?(o.setupEditorWithCard({...a,frame:t,card:d,visualId:(e==null?void 0:e.id)||t.visualId}),!0):!1}function G(){var g;const{setCardSql:e}=o.useEditorActions(),a=o.useEditorStore(i=>i.frame),r=o.useEditorStore(i=>i.card),t=B(((g=r.customCardPreferences)==null?void 0:g.url)||""),d=o.useEditorStore(i=>i.selectedSchemaName),c=o.useEditorStore(i=>i.selectedDatamodelId),n=o.useEditorStore(i=>i.selectedDatabaseName),s=o.useEditorStore(i=>i.selectedTableName),l=o.useEditorStore(i=>i.selectedConnectionId),m=o.useEditorStore(i=>i.isShowingVisual),f=r.sql;return{getUpdatedFrame:b.useCallback(()=>{var E;let i=f;f&&!f.includes("{{")&&(i=_(f),e(i));const C=(E=t==null?void 0:t.getState())==null?void 0:E.settings,U={...r,dataSource:r.dataSource||{mode:"directSource"},lastSelectedSchema:d,lastSelectedDatamodelId:c,lastSelectedDatabase:n,lastSelectedTable:s,connectionId:l,sql:i,customCfg:m?r.customCfg:null,preferences:r.preferences,...C&&{customCardPreferences:{...r.customCardPreferences,settings:C}}},w=a.cards.map(S=>S.id===r.id?U:S);return{...a,cards:w,activeCardId:H(w,a.activeCardId)}},[r,a,m,d,c,n,s,l,e,t,f])}}function z(){const{authToken:e,tokenProps:a}=o.useSemaphorContext(),r=o.useQueryClient(),t=o.useSelectedVisual(),{selectVisual:d}=o.useManagementActions(),{setFrame:c,setCard:n,setIsDevMode:s,setActiveTabCardId:l,updateDataSource:m,setQueryResultColumns:f,setSelectedConnectionId:V,setSelectedDatabaseName:g,setSelectedSchemaName:i,setSelectedTableName:C,setSelectedDatamodelId:U,setFilterValues:w,setApplyFilters:E}=o.useEditorActions(),{setIsDashboardEditing:S,setIsVisualEditing:$,setSelectedFrameId:v,clearSelectedFrameId:A,addFrame:N,setIsDashboardPanelOpen:R}=o.useDashboardActions(),I=o.useDashboardStore(u=>u.selectedSheetId),D=o.useDashboardStore(u=>u.selectedFrameId),O=o.useDashboardStore(u=>u.dashboard),x=o.useDashboardStore(u=>u.filterValues),y=o.useVisualById((t==null?void 0:t.id)||"",{enabled:!!(t!=null&&t.id)&&!!(e!=null&&e.accessToken)}),M=b.useCallback(async u=>{try{d(u),A();const{data:p,fromCache:h}=await j(a.apiServiceUrl,(e==null?void 0:e.accessToken)||"",u.id,r);if(!Q(p,{setFrame:c,setCard:n,setIsDevMode:s,setActiveTabCardId:l,updateDataSource:m,setQueryResultColumns:f,setSelectedConnectionId:V,setSelectedDatabaseName:g,setSelectedSchemaName:i,setSelectedTableName:C,setSelectedDatamodelId:U,setFilterValues:w,setApplyFilters:E,setIsDashboardEditing:S,setIsVisualEditing:$,dashboard:O,selectedSheetId:I,selectedFrameId:D,filterValues:x}))throw new Error("Failed to setup editor with visual data");return{success:!0,fromCache:h}}catch(p){return console.error("Error editing visual:",p),{success:!1,error:"Failed to load visual for editing"}}},[e==null?void 0:e.accessToken,a.apiServiceUrl,r,d,c,n,S,$,s,l,m,f,V,g,i,C,U,w,E,A,O,I,D,x]),k=b.useCallback(async u=>{var p;try{if(d(u),!I)return{success:!1,error:"No sheet selected. Please select a sheet first."};const{data:h,fromCache:W}=await j(a.apiServiceUrl,(e==null?void 0:e.accessToken)||"",u.id,r),L=(h==null?void 0:h.frameObject)??((p=h==null?void 0:h.visual)==null?void 0:p.frameObject);if(!L)return{success:!1,error:"Visual has no frame data"};const F=T(L);if(!(F!=null&&F.cards)||F.cards.length===0)return{success:!1,error:"Visual frame is malformed"};const P={...o.cloneFrameWithNewIds(F),visualId:u.id};return N(I,P,"end"),S(!0),v(P.id),R(!1),{success:!0,fromCache:W}}catch(h){return console.error("Error adding visual:",h),{success:!1,error:"Failed to add visual to dashboard"}}},[e==null?void 0:e.accessToken,a.apiServiceUrl,r,d,I,N,S,v,R]);return{visual:y.data,isLoading:y.isLoading,isError:y.isError,error:y.error,handleEditLibraryVisual:M,handleAddLibraryVisual:k,getUpdatedFrame:G().getUpdatedFrame,refetch:y.refetch}}exports.useRemoteChartStore=B;exports.useVisualUtils=z;
@@ -1,4 +1,4 @@
1
- import { ak as G, al as z, h as Y, i as J, am as K, e as _, g as X, u as U, an as Z, ao as q, l as v, ap as ee, f as h } from "./index-BdiWSBWd.js";
1
+ import { al as G, am as z, h as Y, i as J, an as K, e as _, g as X, u as U, ao as Z, ap as q, l as v, aq as ee, f as h } from "./index-Bko2LZ3Y.js";
2
2
  import { useState as T, useEffect as te, useCallback as V } from "react";
3
3
  function re(e) {
4
4
  const o = e.toUpperCase().indexOf("WHERE"), r = e.toUpperCase().indexOf("GROUP BY"), t = e.toUpperCase().indexOf("LIMIT"), i = e.toUpperCase().indexOf("ORDER BY");
@@ -102,7 +102,7 @@ async function M(e, o, r, t) {
102
102
  throw v.dismiss(a), s;
103
103
  }
104
104
  }
105
- function k(e) {
105
+ function H(e) {
106
106
  if (typeof e == "string")
107
107
  return JSON.parse(e);
108
108
  if (typeof e == "object")
@@ -114,7 +114,7 @@ function ae(e, o) {
114
114
  const r = (e == null ? void 0 : e.frameObject) ?? ((n = e == null ? void 0 : e.visual) == null ? void 0 : n.frameObject);
115
115
  if (!r)
116
116
  return !1;
117
- const t = k(r);
117
+ const t = H(r);
118
118
  if (!(t != null && t.cards) || t.cards.length === 0)
119
119
  return !1;
120
120
  const i = (a = t.cards) == null ? void 0 : a.find(
@@ -209,7 +209,7 @@ function de() {
209
209
  setIsDashboardPanelOpen: R
210
210
  } = X(), I = U((l) => l.selectedSheetId), W = U((l) => l.selectedFrameId), D = U((l) => l.dashboard), L = U((l) => l.filterValues), y = Z((t == null ? void 0 : t.id) || "", {
211
211
  enabled: !!(t != null && t.id) && !!(e != null && e.accessToken)
212
- }), H = V(
212
+ }), Q = V(
213
213
  async (l) => {
214
214
  try {
215
215
  i(l), O();
@@ -272,7 +272,7 @@ function de() {
272
272
  W,
273
273
  L
274
274
  ]
275
- ), Q = V(
275
+ ), k = V(
276
276
  async (l) => {
277
277
  var g;
278
278
  try {
@@ -289,7 +289,7 @@ function de() {
289
289
  ), j = (f == null ? void 0 : f.frameObject) ?? ((g = f == null ? void 0 : f.visual) == null ? void 0 : g.frameObject);
290
290
  if (!j)
291
291
  return { success: !1, error: "Visual has no frame data" };
292
- const E = k(j);
292
+ const E = H(j);
293
293
  if (!(E != null && E.cards) || E.cards.length === 0)
294
294
  return { success: !1, error: "Visual frame is malformed" };
295
295
  const B = {
@@ -319,8 +319,8 @@ function de() {
319
319
  isLoading: y.isLoading,
320
320
  isError: y.isError,
321
321
  error: y.error,
322
- handleEditLibraryVisual: H,
323
- handleAddLibraryVisual: Q,
322
+ handleEditLibraryVisual: Q,
323
+ handleAddLibraryVisual: k,
324
324
  getUpdatedFrame: ne().getUpdatedFrame,
325
325
  refetch: y.refetch
326
326
  };