drizzle-cube 0.4.20 → 0.4.22

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 (123) hide show
  1. package/dist/adapters/anthropic-BTkjgFpT.cjs +1 -0
  2. package/dist/adapters/anthropic-CTu9E801.js +126 -0
  3. package/dist/adapters/express/index.cjs +6 -6
  4. package/dist/adapters/express/index.js +119 -116
  5. package/dist/adapters/fastify/index.cjs +6 -6
  6. package/dist/adapters/fastify/index.js +113 -110
  7. package/dist/adapters/google-BAK9pnQf.cjs +2 -0
  8. package/dist/adapters/google-DficVAsJ.js +146 -0
  9. package/dist/adapters/{handler-CbDMdSY5.js → handler-9Rdn7zM2.js} +534 -461
  10. package/dist/adapters/handler-B-tEntiU.cjs +39 -0
  11. package/dist/adapters/hono/index.cjs +6 -6
  12. package/dist/adapters/hono/index.js +199 -196
  13. package/dist/adapters/index-BIMhF5KZ.cjs +23 -0
  14. package/dist/adapters/index-BgCeQBuN.cjs +2 -0
  15. package/dist/adapters/index-C45_meK_.js +719 -0
  16. package/dist/adapters/index-CFEJ62GJ.js +5337 -0
  17. package/dist/adapters/nextjs/index.cjs +5 -5
  18. package/dist/adapters/nextjs/index.js +245 -242
  19. package/dist/adapters/openai-CUSRuKTk.js +131 -0
  20. package/dist/adapters/openai-mLo2MCat.cjs +1 -0
  21. package/dist/client/charts.js +12 -12
  22. package/dist/client/chunks/{RetentionCombinedChart-CLq89aOJ.js → RetentionCombinedChart-BK3NPsHP.js} +2 -2
  23. package/dist/client/chunks/{RetentionCombinedChart-CLq89aOJ.js.map → RetentionCombinedChart-BK3NPsHP.js.map} +1 -1
  24. package/dist/client/chunks/{analysis-builder-3z9fHE2F.js → analysis-builder-DVrv9Q4n.js} +9 -9
  25. package/dist/client/chunks/{analysis-builder-3z9fHE2F.js.map → analysis-builder-DVrv9Q4n.js.map} +1 -1
  26. package/dist/client/chunks/{analysis-builder-shared-Da-vlQa_.js → analysis-builder-shared-CrENEvEk.js} +6 -6
  27. package/dist/client/chunks/{analysis-builder-shared-Da-vlQa_.js.map → analysis-builder-shared-CrENEvEk.js.map} +1 -1
  28. package/dist/client/chunks/{chart-activity-grid-CPGcTSuh.js → chart-activity-grid-OG6he4YS.js} +2 -2
  29. package/dist/client/chunks/{chart-activity-grid-CPGcTSuh.js.map → chart-activity-grid-OG6he4YS.js.map} +1 -1
  30. package/dist/client/chunks/{chart-area-ByJQ7NZd.js → chart-area-TawAd2k9.js} +3 -3
  31. package/dist/client/chunks/{chart-area-ByJQ7NZd.js.map → chart-area-TawAd2k9.js.map} +1 -1
  32. package/dist/client/chunks/{chart-bar-dj14frMt.js → chart-bar-D3vtCNQG.js} +2 -2
  33. package/dist/client/chunks/{chart-bar-dj14frMt.js.map → chart-bar-D3vtCNQG.js.map} +1 -1
  34. package/dist/client/chunks/{chart-box-plot-ZatBpatq.js → chart-box-plot-BXwN2rO5.js} +2 -2
  35. package/dist/client/chunks/{chart-box-plot-ZatBpatq.js.map → chart-box-plot-BXwN2rO5.js.map} +1 -1
  36. package/dist/client/chunks/{chart-bubble-CemotLx-.js → chart-bubble-ZfNe8t5k.js} +2 -2
  37. package/dist/client/chunks/{chart-bubble-CemotLx-.js.map → chart-bubble-ZfNe8t5k.js.map} +1 -1
  38. package/dist/client/chunks/{chart-candlestick-BIR4uGGt.js → chart-candlestick-DmF3haFu.js} +2 -2
  39. package/dist/client/chunks/{chart-candlestick-BIR4uGGt.js.map → chart-candlestick-DmF3haFu.js.map} +1 -1
  40. package/dist/client/chunks/{chart-data-table-BsAjHe7o.js → chart-data-table-DJZPkArt.js} +4 -4
  41. package/dist/client/chunks/{chart-data-table-BsAjHe7o.js.map → chart-data-table-DJZPkArt.js.map} +1 -1
  42. package/dist/client/chunks/{chart-funnel-dofnhD24.js → chart-funnel-CE9x0Io9.js} +2 -2
  43. package/dist/client/chunks/{chart-funnel-dofnhD24.js.map → chart-funnel-CE9x0Io9.js.map} +1 -1
  44. package/dist/client/chunks/{chart-gauge-CKJJ8m3b.js → chart-gauge-Djs5FWxB.js} +2 -2
  45. package/dist/client/chunks/{chart-gauge-CKJJ8m3b.js.map → chart-gauge-Djs5FWxB.js.map} +1 -1
  46. package/dist/client/chunks/{chart-heat-map-BVuPUKHT.js → chart-heat-map-CqtMkdxd.js} +2 -2
  47. package/dist/client/chunks/{chart-heat-map-BVuPUKHT.js.map → chart-heat-map-CqtMkdxd.js.map} +1 -1
  48. package/dist/client/chunks/{chart-kpi-delta-DUD3f8vL.js → chart-kpi-delta-DEzA74cL.js} +4 -4
  49. package/dist/client/chunks/{chart-kpi-delta-DUD3f8vL.js.map → chart-kpi-delta-DEzA74cL.js.map} +1 -1
  50. package/dist/client/chunks/{chart-kpi-number-iJh-PzsM.js → chart-kpi-number-Bab-BZtX.js} +3 -3
  51. package/dist/client/chunks/{chart-kpi-number-iJh-PzsM.js.map → chart-kpi-number-Bab-BZtX.js.map} +1 -1
  52. package/dist/client/chunks/{chart-kpi-text-x6pV9v9Q.js → chart-kpi-text-BkTgckDJ.js} +3 -3
  53. package/dist/client/chunks/{chart-kpi-text-x6pV9v9Q.js.map → chart-kpi-text-BkTgckDJ.js.map} +1 -1
  54. package/dist/client/chunks/{chart-line-DzyZkugh.js → chart-line-DhM-Hvu0.js} +3 -3
  55. package/dist/client/chunks/{chart-line-DzyZkugh.js.map → chart-line-DhM-Hvu0.js.map} +1 -1
  56. package/dist/client/chunks/{chart-measure-profile-C2IkBG3V.js → chart-measure-profile-4vQxFm69.js} +3 -3
  57. package/dist/client/chunks/{chart-measure-profile-C2IkBG3V.js.map → chart-measure-profile-4vQxFm69.js.map} +1 -1
  58. package/dist/client/chunks/{chart-pie-akbfRfb9.js → chart-pie-B86KRcHI.js} +2 -2
  59. package/dist/client/chunks/{chart-pie-akbfRfb9.js.map → chart-pie-B86KRcHI.js.map} +1 -1
  60. package/dist/client/chunks/{chart-radar-BaN-Kjww.js → chart-radar-BhDBmJRh.js} +2 -2
  61. package/dist/client/chunks/{chart-radar-BaN-Kjww.js.map → chart-radar-BhDBmJRh.js.map} +1 -1
  62. package/dist/client/chunks/{chart-radial-bar-DpptEL3s.js → chart-radial-bar-Brugya8X.js} +2 -2
  63. package/dist/client/chunks/{chart-radial-bar-DpptEL3s.js.map → chart-radial-bar-Brugya8X.js.map} +1 -1
  64. package/dist/client/chunks/{chart-sankey-CG-3hHmX.js → chart-sankey-D2L8ympI.js} +2 -2
  65. package/dist/client/chunks/{chart-sankey-CG-3hHmX.js.map → chart-sankey-D2L8ympI.js.map} +1 -1
  66. package/dist/client/chunks/{chart-scatter-l_yTVxF3.js → chart-scatter-CAkbBDkK.js} +2 -2
  67. package/dist/client/chunks/{chart-scatter-l_yTVxF3.js.map → chart-scatter-CAkbBDkK.js.map} +1 -1
  68. package/dist/client/chunks/{chart-sunburst-KhDcKhmZ.js → chart-sunburst-DaxJ-cob.js} +2 -2
  69. package/dist/client/chunks/{chart-sunburst-KhDcKhmZ.js.map → chart-sunburst-DaxJ-cob.js.map} +1 -1
  70. package/dist/client/chunks/{chart-tree-map-CBbiaBXV.js → chart-tree-map-CrDJAvZU.js} +2 -2
  71. package/dist/client/chunks/{chart-tree-map-CBbiaBXV.js.map → chart-tree-map-CrDJAvZU.js.map} +1 -1
  72. package/dist/client/chunks/{chart-waterfall-CX3vx_lI.js → chart-waterfall-BBwSfEKT.js} +3 -3
  73. package/dist/client/chunks/{chart-waterfall-CX3vx_lI.js.map → chart-waterfall-BBwSfEKT.js.map} +1 -1
  74. package/dist/client/chunks/{charts-core-CU9u_HtL.js → charts-core-B4Rbfdcn.js} +2 -2
  75. package/dist/client/chunks/{charts-core-CU9u_HtL.js.map → charts-core-B4Rbfdcn.js.map} +1 -1
  76. package/dist/client/chunks/{charts-loader-B3tt5oKG.js → charts-loader-DbrwgvCK.js} +25 -25
  77. package/dist/client/chunks/{charts-loader-B3tt5oKG.js.map → charts-loader-DbrwgvCK.js.map} +1 -1
  78. package/dist/client/chunks/{components-CMGGxqOB.js → components-GzooQM5J.js} +9 -9
  79. package/dist/client/chunks/{components-CMGGxqOB.js.map → components-GzooQM5J.js.map} +1 -1
  80. package/dist/client/chunks/{core-D_8mkGpQ.js → core-Y9e-sNfb.js} +2 -2
  81. package/dist/client/chunks/{core-D_8mkGpQ.js.map → core-Y9e-sNfb.js.map} +1 -1
  82. package/dist/client/chunks/{icons-M7shurcH.js → icons-DFJw-2HU.js} +6 -6
  83. package/dist/client/chunks/{icons-M7shurcH.js.map → icons-DFJw-2HU.js.map} +1 -1
  84. package/dist/client/chunks/{providers-CgxXm6Ll.js → providers-CCw8Kjlc.js} +2 -2
  85. package/dist/client/chunks/{providers-CgxXm6Ll.js.map → providers-CCw8Kjlc.js.map} +1 -1
  86. package/dist/client/chunks/{syntaxHighlighting-BQfjio-i.js → syntaxHighlighting-DAMSW_A6.js} +2 -2
  87. package/dist/client/chunks/{syntaxHighlighting-BQfjio-i.js.map → syntaxHighlighting-DAMSW_A6.js.map} +1 -1
  88. package/dist/client/chunks/{useDirtyStateTracking-Cu1HSjmo.js → useDirtyStateTracking-CjhwBXRw.js} +20 -20
  89. package/dist/client/chunks/{useDirtyStateTracking-Cu1HSjmo.js.map → useDirtyStateTracking-CjhwBXRw.js.map} +1 -1
  90. package/dist/client/chunks/useExplainAI-IiW55BaQ.js +182 -0
  91. package/dist/client/chunks/useExplainAI-IiW55BaQ.js.map +1 -0
  92. package/dist/client/chunks/{vendor-AVsJ2ni0.js → vendor-B2EH3V58.js} +7 -7
  93. package/dist/client/chunks/{vendor-AVsJ2ni0.js.map → vendor-B2EH3V58.js.map} +1 -1
  94. package/dist/client/components/AgenticNotebook/AgentChatPanel.d.ts +3 -0
  95. package/dist/client/components/AgenticNotebook/index.d.ts +6 -0
  96. package/dist/client/components.js +1 -1
  97. package/dist/client/hooks/useAgentChat.d.ts +6 -0
  98. package/dist/client/hooks/useNotebookLayout.d.ts +8 -0
  99. package/dist/client/hooks.d.ts +2 -0
  100. package/dist/client/hooks.js +51 -190
  101. package/dist/client/hooks.js.map +1 -1
  102. package/dist/client/icons.js +1 -1
  103. package/dist/client/index.js +926 -764
  104. package/dist/client/index.js.map +1 -1
  105. package/dist/client/providers.js +1 -1
  106. package/dist/client/styles.css +1 -1
  107. package/dist/client/utils.js +7 -7
  108. package/dist/client-bundle-stats.html +1 -1
  109. package/dist/server/anthropic-BTkjgFpT.cjs +1 -0
  110. package/dist/server/anthropic-CTu9E801.js +126 -0
  111. package/dist/server/google-BAK9pnQf.cjs +2 -0
  112. package/dist/server/google-DficVAsJ.js +146 -0
  113. package/dist/server/index-BIMhF5KZ.cjs +23 -0
  114. package/dist/server/index-BgCeQBuN.cjs +2 -0
  115. package/dist/server/index-C45_meK_.js +719 -0
  116. package/dist/server/index-CFEJ62GJ.js +5337 -0
  117. package/dist/server/index.cjs +48 -46
  118. package/dist/server/index.d.ts +37 -10
  119. package/dist/server/index.js +1974 -1901
  120. package/dist/server/openai-CUSRuKTk.js +131 -0
  121. package/dist/server/openai-mLo2MCat.cjs +1 -0
  122. package/package.json +12 -2
  123. package/dist/adapters/handler-DtdjM1Vx.cjs +0 -37
@@ -1,233 +1,238 @@
1
- import { D as me, A as pe, e as he, P as fe } from "./chunks/components-CMGGxqOB.js";
2
- import { i as bt, a as yt, C as xt, h as vt, g as Ct, b as Nt, j as kt, f as wt, d as St, M as Tt, c as Dt, n as At, T as Mt, R as It, Q as Et, O as Rt, S as Bt, V as Lt, I as Pt, H as Qt, K as Ft, W as _t, G as Vt, J as jt, X as Ut, L as qt, N as Kt, U as Ot, Y as $t, Z as zt, z as Wt, q as Jt, x as Gt, t as Ht, s as Yt, w as Xt, p as Zt, v as es, o as ts, r as ss, y as rs, u as cs, k as as, l as ns, m as os, F as ds, E as is, B as ls } from "./chunks/components-CMGGxqOB.js";
3
- import { jsx as s, jsxs as f, Fragment as te } from "react/jsx-runtime";
4
- import V, { useRef as v, createContext as ge, useContext as be, useState as _, useCallback as h, useEffect as F } from "react";
5
- import { c as ye, d as xe, e as ve, s as Ce, f as z } from "./chunks/vendor-AVsJ2ni0.js";
6
- import { a as j } from "./chunks/icons-M7shurcH.js";
7
- import { D as ms, h as ps, i as hs, b as fs, e as gs, f as bs, g as ys, r as xs, c as vs, s as Cs } from "./chunks/icons-M7shurcH.js";
8
- import { Q as Ne } from "./chunks/chart-markdown-Du4Z2iqK.js";
9
- import { f as ke } from "./chunks/providers-CgxXm6Ll.js";
10
- import { h as ks, a as ws, S as Ss, e as Ts, d as Ds, i as As, b as Ms, g as Is, u as Es, j as Rs, c as Bs, w as Ls } from "./chunks/providers-CgxXm6Ll.js";
11
- import { L as we } from "./chunks/charts-core-CU9u_HtL.js";
12
- import { u as Qs } from "./chunks/charts-core-CU9u_HtL.js";
13
- import { L as _s, g as Vs, c as js, b as Us, i as qs, p as Ks, a as Os } from "./chunks/charts-loader-B3tt5oKG.js";
14
- import { E as zs, a as Ws, p as Js, q as Gs, m as Hs, l as Ys, r as Xs, C as Zs, D as er, o as tr, B as sr, n as rr, w as cr, t as ar, d as nr, f as or, s as dr, e as ir, i as lr, c as ur, h as mr, g as pr, u as hr, b as fr, y as gr, A as br, x as yr, k as xr, v as vr, z as Cr, j as Nr } from "./chunks/analysis-builder-shared-Da-vlQa_.js";
15
- import { u as wr } from "./chunks/chart-bubble-CemotLx-.js";
16
- import { c as Tr, f as Dr } from "./chunks/index-CApFCBF9.js";
17
- import { e as Mr, c as Ir, l as Er, h as Rr, k as Br, j as Lr, i as Pr, m as Qr, g as Fr, f as _r, u as Vr, u as jr, d as Ur, b as qr, a as Kr, v as Or } from "./chunks/useDirtyStateTracking-Cu1HSjmo.js";
18
- import { c as zr, b as Wr, f as Jr, g as Gr, a as Hr, i as Yr, t as Xr } from "./chunks/funnel-utils-CyonoNeC.js";
19
- import { T as ec, c as tc, g as sc, a as rc, i as cc, r as ac, s as nc, b as oc, w as dc } from "./chunks/theme-Dp3hFed1.js";
20
- import { createExplainQueryKey as lc, useDryRunQueries as uc, useDryRunQuery as mc, useExplainAI as pc, useExplainQuery as hc, useMultiDryRunQueries as fc } from "./hooks.js";
21
- import { i as bc, a as yc } from "./chunks/flow-utils-CjQZG5qq.js";
22
- import { h as vc } from "./chunks/syntaxHighlighting-BQfjio-i.js";
23
- const se = () => ({
1
+ import { D as ve, A as Ce, e as we, P as Ne } from "./chunks/components-GzooQM5J.js";
2
+ import { i as Lt, a as Pt, C as Qt, h as Ft, g as _t, b as Vt, j as jt, f as Ut, d as Ot, M as $t, c as qt, n as Kt, T as zt, R as Wt, Q as Jt, O as Xt, S as Yt, V as Gt, I as Ht, H as Zt, K as es, W as ts, G as ss, J as cs, X as rs, L as ns, N as as, U as os, Y as ds, Z as ls, z as is, q as us, x as ms, t as hs, s as fs, w as ps, p as gs, v as bs, o as xs, r as ys, y as vs, u as Cs, k as ws, l as Ns, m as ks, F as Ss, E as Ts, B as Ds } from "./chunks/components-GzooQM5J.js";
3
+ import { jsx as e, jsxs as u, Fragment as ne } from "react/jsx-runtime";
4
+ import Y, { useRef as g, createContext as ke, useContext as Se, useState as j, useCallback as f, useEffect as V } from "react";
5
+ import { e as Te, f as De, h as Ae, s as Ie, i as de } from "./chunks/vendor-B2EH3V58.js";
6
+ import { a as B, b as Me } from "./chunks/icons-DFJw-2HU.js";
7
+ import { D as Is, i as Ms, c as Es, f as Rs, h as Bs, g as Ls, r as Ps, e as Qs, s as Fs } from "./chunks/icons-DFJw-2HU.js";
8
+ import { Q as Ee } from "./chunks/chart-markdown-Du4Z2iqK.js";
9
+ import { f as Re } from "./chunks/providers-CCw8Kjlc.js";
10
+ import { h as Vs, a as js, S as Us, e as Os, d as $s, i as qs, b as Ks, g as zs, u as Ws, j as Js, c as Xs, w as Ys } from "./chunks/providers-CCw8Kjlc.js";
11
+ import { L as me } from "./chunks/charts-core-B4Rbfdcn.js";
12
+ import { u as Hs } from "./chunks/charts-core-B4Rbfdcn.js";
13
+ import { useNotebookLayout as Be } from "./hooks.js";
14
+ import { L as ec, g as tc, c as sc, b as cc, i as rc, p as nc, a as ac } from "./chunks/charts-loader-DbrwgvCK.js";
15
+ import { E as dc, a as lc, p as ic, q as uc, m as mc, l as hc, r as fc, C as pc, D as gc, o as bc, B as xc, n as yc, w as vc, t as Cc, d as wc, f as Nc, s as kc, e as Sc, i as Tc, c as Dc, h as Ac, g as Ic, u as Mc, b as Ec, y as Rc, A as Bc, x as Lc, k as Pc, v as Qc, z as Fc, j as _c } from "./chunks/analysis-builder-shared-CrENEvEk.js";
16
+ import { u as jc } from "./chunks/chart-bubble-ZfNe8t5k.js";
17
+ import { c as Oc, f as $c } from "./chunks/index-CApFCBF9.js";
18
+ import { f as Kc, d as zc, n as Wc, j as Jc, l as Xc, k as Yc, i as Gc, m as Hc, h as Zc, g as er, u as tr, u as sr, e as cr, b as rr, a as nr, v as ar } from "./chunks/useDirtyStateTracking-CjhwBXRw.js";
19
+ import { c as dr, b as lr, f as ir, g as ur, a as mr, i as hr, t as fr } from "./chunks/funnel-utils-CyonoNeC.js";
20
+ import { T as gr, c as br, g as xr, a as yr, i as vr, r as Cr, s as wr, b as Nr, w as kr } from "./chunks/theme-Dp3hFed1.js";
21
+ import { d as Tr, b as Dr, u as Ar, e as Ir, c as Mr, a as Er } from "./chunks/useExplainAI-IiW55BaQ.js";
22
+ import { i as Br, a as Lr } from "./chunks/flow-utils-CjQZG5qq.js";
23
+ import { h as Qr } from "./chunks/syntaxHighlighting-DAMSW_A6.js";
24
+ const he = () => ({
24
25
  blocks: [],
25
26
  messages: [],
26
27
  isStreaming: !1,
27
28
  sessionId: null,
28
29
  inputValue: ""
29
30
  });
30
- function Se(e, t) {
31
+ function Le(t, s) {
31
32
  return {
32
33
  // Block actions
33
- addBlock: (r) => e((n) => ({
34
- blocks: [...n.blocks, r]
34
+ addBlock: (c) => t((a) => ({
35
+ blocks: [...a.blocks, c]
35
36
  })),
36
- removeBlock: (r) => e((n) => ({
37
- blocks: n.blocks.filter((c) => c.id !== r)
37
+ removeBlock: (c) => t((a) => ({
38
+ blocks: a.blocks.filter((n) => n.id !== c)
38
39
  })),
39
- moveBlock: (r, n) => e((c) => {
40
- const a = c.blocks.findIndex((u) => u.id === r);
41
- if (a === -1) return {};
42
- if (n === "up" && a === 0) return {};
43
- if (n === "down" && a === c.blocks.length - 1) return {};
44
- const o = [...c.blocks], p = n === "up" ? a - 1 : a + 1;
45
- return [o[a], o[p]] = [o[p], o[a]], { blocks: o };
40
+ moveBlock: (c, a) => t((n) => {
41
+ const r = n.blocks.findIndex((d) => d.id === c);
42
+ if (r === -1) return {};
43
+ if (a === "up" && r === 0) return {};
44
+ if (a === "down" && r === n.blocks.length - 1) return {};
45
+ const o = [...n.blocks], l = a === "up" ? r - 1 : r + 1;
46
+ return [o[r], o[l]] = [o[l], o[r]], { blocks: o };
46
47
  }),
47
- updateBlock: (r, n) => e((c) => ({
48
- blocks: c.blocks.map(
49
- (a) => a.id === r && a.type === "portlet" ? { ...a, ...n } : a
48
+ updateBlock: (c, a) => t((n) => ({
49
+ blocks: n.blocks.map(
50
+ (r) => r.id === c && r.type === "portlet" ? { ...r, ...a } : r
50
51
  )
51
52
  })),
52
53
  // Chat actions
53
- addMessage: (r) => e((n) => ({
54
- messages: [...n.messages, r]
54
+ addMessage: (c) => t((a) => ({
55
+ messages: [...a.messages, c]
55
56
  })),
56
- appendToLastAssistantMessage: (r) => e((n) => {
57
- const c = [...n.messages], a = c[c.length - 1];
58
- return a && a.role === "assistant" && (c[c.length - 1] = {
59
- ...a,
60
- content: a.content + r
61
- }), { messages: c };
57
+ appendToLastAssistantMessage: (c) => t((a) => {
58
+ const n = [...a.messages], r = n[n.length - 1];
59
+ return r && r.role === "assistant" && (n[n.length - 1] = {
60
+ ...r,
61
+ content: r.content + c
62
+ }), { messages: n };
62
63
  }),
63
- setLastAssistantError: (r) => e((n) => {
64
- const c = [...n.messages], a = c[c.length - 1];
65
- return a && a.role === "assistant" && (c[c.length - 1] = { ...a, error: r }), { messages: c };
64
+ setLastAssistantError: (c) => t((a) => {
65
+ const n = [...a.messages], r = n[n.length - 1];
66
+ return r && r.role === "assistant" && (n[n.length - 1] = { ...r, error: c }), { messages: n };
66
67
  }),
67
- addToolCallToLastAssistant: (r) => e((n) => {
68
- const c = [...n.messages], a = c[c.length - 1];
69
- return a && a.role === "assistant" && (c[c.length - 1] = {
70
- ...a,
71
- toolCalls: [...a.toolCalls || [], r]
72
- }), { messages: c };
68
+ addToolCallToLastAssistant: (c) => t((a) => {
69
+ const n = [...a.messages], r = n[n.length - 1];
70
+ return r && r.role === "assistant" && (n[n.length - 1] = {
71
+ ...r,
72
+ toolCalls: [...r.toolCalls || [], c]
73
+ }), { messages: n };
73
74
  }),
74
- updateLastToolCall: (r) => e((n) => {
75
- const c = [...n.messages], a = c[c.length - 1];
76
- if (a?.role === "assistant" && a.toolCalls?.length) {
77
- const o = [...a.toolCalls], p = r.id ? o.findIndex((u) => u.id === r.id) : o.length - 1;
78
- p !== -1 && (o[p] = { ...o[p], ...r }, c[c.length - 1] = { ...a, toolCalls: o });
75
+ updateLastToolCall: (c) => t((a) => {
76
+ const n = [...a.messages], r = n[n.length - 1];
77
+ if (r?.role === "assistant" && r.toolCalls?.length) {
78
+ const o = [...r.toolCalls], l = c.id ? o.findIndex((d) => d.id === c.id) : o.length - 1;
79
+ l !== -1 && (o[l] = { ...o[l], ...c }, n[n.length - 1] = { ...r, toolCalls: o });
79
80
  }
80
- return { messages: c };
81
+ return { messages: n };
81
82
  }),
82
83
  // Session/UI actions
83
- setIsStreaming: (r) => e({ isStreaming: r }),
84
- setSessionId: (r) => e({ sessionId: r }),
85
- setInputValue: (r) => e({ inputValue: r }),
84
+ setIsStreaming: (c) => t({ isStreaming: c }),
85
+ setSessionId: (c) => t({ sessionId: c }),
86
+ setInputValue: (c) => t({ inputValue: c }),
86
87
  // Persistence
87
88
  save: () => {
88
- const r = t();
89
+ const c = s();
89
90
  return {
90
- blocks: r.blocks,
91
- messages: r.messages
91
+ blocks: c.blocks,
92
+ messages: c.messages
92
93
  };
93
94
  },
94
- load: (r) => e({
95
- blocks: r.blocks || [],
96
- messages: r.messages || []
95
+ load: (c) => t({
96
+ blocks: c.blocks || [],
97
+ messages: c.messages || []
97
98
  }),
98
99
  // Reset
99
- reset: () => e(se())
100
+ reset: () => t(he())
100
101
  };
101
102
  }
102
- function Te() {
103
- const e = se();
104
- return xe()(
105
- ve(
106
- Ce((t, r) => ({
107
- ...e,
108
- ...Se(t, r)
103
+ function Pe() {
104
+ const t = he();
105
+ return De()(
106
+ Ae(
107
+ Ie((s, c) => ({
108
+ ...t,
109
+ ...Le(s, c)
109
110
  })),
110
111
  { name: "NotebookStore" }
111
112
  )
112
113
  );
113
114
  }
114
- const re = ge(null);
115
- function De({
116
- children: e,
117
- initialConfig: t
115
+ const fe = ke(null);
116
+ function Qe({
117
+ children: t,
118
+ initialConfig: s
118
119
  }) {
119
- const r = v(null);
120
- if (!r.current) {
121
- const n = Te();
122
- t && n.getState().load(t), r.current = n;
120
+ const c = g(null);
121
+ if (!c.current) {
122
+ const a = Pe();
123
+ s && a.getState().load(s), c.current = a;
123
124
  }
124
- return /* @__PURE__ */ s(re.Provider, { value: r.current, children: e });
125
+ return /* @__PURE__ */ e(fe.Provider, { value: c.current, children: t });
125
126
  }
126
- function A(e) {
127
- const t = be(re);
128
- if (!t)
127
+ function P(t) {
128
+ const s = Se(fe);
129
+ if (!s)
129
130
  throw new Error("useNotebookStore must be used within NotebookStoreProvider");
130
- return ye(t, e);
131
+ return Te(s, t);
131
132
  }
132
- const Ae = (e) => e.blocks, dt = (e) => e.messages, it = (e) => e.isStreaming, lt = (e) => e.sessionId, ut = (e) => e.inputValue, Me = (e) => ({
133
- messages: e.messages,
134
- isStreaming: e.isStreaming,
135
- inputValue: e.inputValue
136
- }), Ie = (e) => ({
137
- addMessage: e.addMessage,
138
- appendToLastAssistantMessage: e.appendToLastAssistantMessage,
139
- setLastAssistantError: e.setLastAssistantError,
140
- addToolCallToLastAssistant: e.addToolCallToLastAssistant,
141
- updateLastToolCall: e.updateLastToolCall,
142
- setIsStreaming: e.setIsStreaming,
143
- setInputValue: e.setInputValue,
144
- setSessionId: e.setSessionId
145
- }), Ee = (e) => ({
146
- addBlock: e.addBlock,
147
- removeBlock: e.removeBlock,
148
- moveBlock: e.moveBlock,
149
- updateBlock: e.updateBlock
150
- }), O = { width: "16px", height: "16px", color: "currentColor" }, Re = j("chevronUp"), Be = j("chevronDown"), Le = j("edit"), Pe = j("delete"), Qe = V.memo(function({
151
- block: t,
152
- onRemove: r,
153
- onMoveUp: n,
154
- onMoveDown: c,
155
- onEdit: a,
133
+ const Fe = (t) => t.blocks, St = (t) => t.messages, Tt = (t) => t.isStreaming, Dt = (t) => t.sessionId, At = (t) => t.inputValue, _e = (t) => ({
134
+ messages: t.messages,
135
+ isStreaming: t.isStreaming,
136
+ inputValue: t.inputValue
137
+ }), Ve = (t) => ({
138
+ addMessage: t.addMessage,
139
+ appendToLastAssistantMessage: t.appendToLastAssistantMessage,
140
+ setLastAssistantError: t.setLastAssistantError,
141
+ addToolCallToLastAssistant: t.addToolCallToLastAssistant,
142
+ updateLastToolCall: t.updateLastToolCall,
143
+ setIsStreaming: t.setIsStreaming,
144
+ setInputValue: t.setInputValue,
145
+ setSessionId: t.setSessionId
146
+ }), je = (t) => ({
147
+ addBlock: t.addBlock,
148
+ removeBlock: t.removeBlock,
149
+ moveBlock: t.moveBlock,
150
+ updateBlock: t.updateBlock
151
+ }), ce = { width: "16px", height: "16px", color: "currentColor" }, Ue = B("chevronUp"), Oe = B("chevronDown"), $e = B("edit"), qe = B("delete"), Ke = Y.memo(function({
152
+ block: s,
153
+ onRemove: c,
154
+ onMoveUp: a,
155
+ onMoveDown: n,
156
+ onEdit: r,
156
157
  isFirst: o,
157
- isLast: p
158
+ isLast: l
158
159
  }) {
159
- const [u, w] = _(null), x = h((N) => {
160
- w(N);
160
+ const [d, T] = j(null), w = f((A) => {
161
+ T(A);
161
162
  }, []);
162
- return /* @__PURE__ */ f("div", { className: "dc:relative dc:mb-4 bg-dc-surface dc:border border-dc-border dc:rounded-lg dc:flex dc:flex-col", children: [
163
- /* @__PURE__ */ f("div", { className: "dc:flex dc:items-center dc:justify-between dc:px-3 dc:py-1.5 dc:border-b border-dc-border dc:shrink-0 bg-dc-surface-secondary dc:rounded-t-lg", children: [
164
- /* @__PURE__ */ f("div", { className: "dc:flex dc:items-center dc:gap-2 dc:flex-1 dc:min-w-0", children: [
165
- /* @__PURE__ */ s("h3", { className: "dc:font-semibold dc:text-sm text-dc-text dc:truncate", children: t.title || "Untitled" }),
166
- u && /* @__PURE__ */ s(
167
- me,
163
+ return /* @__PURE__ */ u("div", { className: "dc:relative dc:mb-4 bg-dc-surface dc:border border-dc-border dc:rounded-lg dc:flex dc:flex-col", children: [
164
+ /* @__PURE__ */ u("div", { className: "dc:flex dc:items-center dc:justify-between dc:px-3 dc:py-1.5 dc:border-b border-dc-border dc:shrink-0 bg-dc-surface-secondary dc:rounded-t-lg", children: [
165
+ /* @__PURE__ */ u("div", { className: "dc:flex dc:items-center dc:gap-2 dc:flex-1 dc:min-w-0", children: [
166
+ /* @__PURE__ */ e("h3", { className: "dc:font-semibold dc:text-sm text-dc-text dc:truncate", children: s.title || "Untitled" }),
167
+ d && /* @__PURE__ */ e(
168
+ ve,
168
169
  {
169
- chartConfig: u.chartConfig,
170
- displayConfig: u.displayConfig,
171
- queryObject: u.queryObject,
172
- data: u.data,
173
- chartType: u.chartType,
174
- cacheInfo: u.cacheInfo ?? void 0
170
+ chartConfig: d.chartConfig,
171
+ displayConfig: d.displayConfig,
172
+ queryObject: d.queryObject,
173
+ data: d.data,
174
+ chartType: d.chartType,
175
+ cacheInfo: d.cacheInfo ?? void 0
175
176
  }
176
177
  )
177
178
  ] }),
178
- /* @__PURE__ */ f("div", { className: "dc:flex dc:items-center dc:gap-1 dc:shrink-0 dc:ml-4 dc:-mr-2", children: [
179
- !o && /* @__PURE__ */ s(
179
+ /* @__PURE__ */ u("div", { className: "dc:flex dc:items-center dc:gap-1 dc:shrink-0 dc:ml-4 dc:-mr-2", children: [
180
+ !o && /* @__PURE__ */ e(
180
181
  "button",
181
182
  {
182
- onClick: () => n(t.id),
183
+ onClick: () => a(s.id),
183
184
  className: "dc:p-1 dc:bg-transparent dc:border-none dc:rounded-sm text-dc-text-secondary dc:cursor-pointer dc:hover:bg-dc-surface-hover dc:transition-colors",
184
185
  title: "Move up",
185
- children: /* @__PURE__ */ s(Re, { style: O })
186
+ children: /* @__PURE__ */ e(Ue, { style: ce })
186
187
  }
187
188
  ),
188
- !p && /* @__PURE__ */ s(
189
+ !l && /* @__PURE__ */ e(
189
190
  "button",
190
191
  {
191
- onClick: () => c(t.id),
192
+ onClick: () => n(s.id),
192
193
  className: "dc:p-1 dc:bg-transparent dc:border-none dc:rounded-sm text-dc-text-secondary dc:cursor-pointer dc:hover:bg-dc-surface-hover dc:transition-colors",
193
194
  title: "Move down",
194
- children: /* @__PURE__ */ s(Be, { style: O })
195
+ children: /* @__PURE__ */ e(Oe, { style: ce })
195
196
  }
196
197
  ),
197
- /* @__PURE__ */ s(
198
+ /* @__PURE__ */ e(
198
199
  "button",
199
200
  {
200
- onClick: () => a(t),
201
+ onClick: () => r(s),
201
202
  className: "dc:p-1 dc:bg-transparent dc:border-none dc:rounded-sm text-dc-text-secondary dc:cursor-pointer dc:hover:bg-dc-surface-hover dc:transition-colors",
202
203
  title: "Edit visualization",
203
- children: /* @__PURE__ */ s(Le, { style: O })
204
+ children: /* @__PURE__ */ e($e, { style: ce })
204
205
  }
205
206
  ),
206
- /* @__PURE__ */ s(
207
+ /* @__PURE__ */ e(
207
208
  "button",
208
209
  {
209
- onClick: () => r(t.id),
210
+ onClick: () => c(s.id),
210
211
  className: "dc:p-1 dc:mr-0.5 dc:bg-transparent dc:border-none dc:rounded-sm dc:cursor-pointer dc:hover:bg-dc-danger-bg text-dc-danger dc:transition-colors",
211
212
  title: "Remove",
212
- children: /* @__PURE__ */ s(Pe, { style: O })
213
+ children: /* @__PURE__ */ e(qe, { style: ce })
213
214
  }
214
215
  )
215
216
  ] })
216
217
  ] }),
217
- /* @__PURE__ */ s("div", { className: "dc:flex-1 dc:min-h-0", children: /* @__PURE__ */ s(
218
- pe,
218
+ /* @__PURE__ */ e("div", { className: "dc:flex-1 dc:min-h-0", children: /* @__PURE__ */ e(
219
+ Ce,
219
220
  {
220
- query: t.query,
221
- chartType: t.chartType,
222
- chartConfig: t.chartConfig,
223
- displayConfig: t.displayConfig,
221
+ query: s.query,
222
+ chartType: s.chartType,
223
+ chartConfig: s.chartConfig,
224
+ displayConfig: s.displayConfig,
224
225
  height: 400,
225
226
  eagerLoad: !0,
226
- onDebugDataReady: x
227
+ onDebugDataReady: w
227
228
  }
228
229
  ) })
229
230
  ] });
230
- }), Fe = {
231
+ }), re = { width: "16px", height: "16px", color: "currentColor" }, ze = B("documentText"), We = B("chevronUp"), Je = B("chevronDown"), Xe = B("delete");
232
+ function Ye({ children: t, ...s }) {
233
+ return /* @__PURE__ */ e("div", { className: "dc:overflow-x-auto dc:my-2", children: /* @__PURE__ */ e("table", { ...s, children: t }) });
234
+ }
235
+ const Ge = {
231
236
  overrides: {
232
237
  h1: { props: { className: "dc:text-lg dc:font-bold text-dc-text dc:mb-2 dc:mt-3" } },
233
238
  h2: { props: { className: "dc:text-base dc:font-semibold text-dc-text dc:mb-2 dc:mt-3" } },
@@ -242,111 +247,116 @@ const Ae = (e) => e.blocks, dt = (e) => e.messages, it = (e) => e.isStreaming, l
242
247
  li: { props: { className: "dc:text-sm text-dc-text" } },
243
248
  hr: { props: { className: "dc:my-3 border-dc-border" } },
244
249
  blockquote: { props: { className: "dc:border-l-4 border-dc-accent dc:pl-3 dc:my-2 dc:italic text-dc-text-secondary dc:text-sm" } },
245
- table: { props: { className: "dc:w-full dc:border-collapse dc:my-2 dc:text-sm" } },
250
+ table: { component: Ye, props: { className: "dc:w-full dc:border-collapse dc:text-sm" } },
246
251
  thead: { props: { className: "bg-dc-surface-secondary" } },
247
252
  th: { props: { className: "dc:px-3 dc:py-2 dc:text-left dc:font-semibold dc:text-xs text-dc-text-secondary dc:uppercase dc:tracking-wider border-dc-border dc:border-b" } },
248
253
  td: { props: { className: "dc:px-3 dc:py-2 dc:text-sm text-dc-text border-dc-border dc:border-b" } },
249
254
  tr: { props: { className: "dc:hover:opacity-80" } }
250
255
  }
251
- }, _e = V.memo(function({
252
- block: t,
253
- onRemove: r,
254
- onMoveUp: n,
255
- onMoveDown: c,
256
- isFirst: a,
256
+ }, He = Y.memo(function({
257
+ block: s,
258
+ onRemove: c,
259
+ onMoveUp: a,
260
+ onMoveDown: n,
261
+ isFirst: r,
257
262
  isLast: o
258
263
  }) {
259
- return /* @__PURE__ */ f("div", { className: "dc:group dc:relative dc:mb-4", children: [
260
- /* @__PURE__ */ f("div", { className: "dc:absolute dc:right-2 dc:top-2 dc:z-10 dc:flex dc:gap-1 dc:opacity-0 dc:group-hover:opacity-100 dc:transition-opacity", children: [
261
- !a && /* @__PURE__ */ s(
262
- "button",
263
- {
264
- onClick: () => n(t.id),
265
- className: "dc:p-1 dc:rounded dc:text-xs bg-dc-surface text-dc-text-secondary dc:hover:opacity-80 border-dc-border dc:border",
266
- title: "Move up",
267
- children: ""
268
- }
269
- ),
270
- !o && /* @__PURE__ */ s(
271
- "button",
272
- {
273
- onClick: () => c(t.id),
274
- className: "dc:p-1 dc:rounded dc:text-xs bg-dc-surface text-dc-text-secondary dc:hover:opacity-80 border-dc-border dc:border",
275
- title: "Move down",
276
- children: ""
277
- }
278
- ),
279
- /* @__PURE__ */ s(
280
- "button",
281
- {
282
- onClick: () => r(t.id),
283
- className: "dc:p-1 dc:rounded dc:text-xs text-dc-error dc:hover:opacity-80 bg-dc-surface border-dc-border dc:border",
284
- title: "Remove",
285
- children: ""
286
- }
287
- )
264
+ return /* @__PURE__ */ u("div", { className: "dc:relative dc:mb-4 bg-dc-surface dc:border border-dc-border dc:rounded-lg dc:flex dc:flex-col", children: [
265
+ /* @__PURE__ */ u("div", { className: "dc:flex dc:items-center dc:justify-between dc:px-3 dc:py-1.5 dc:border-b border-dc-border dc:shrink-0 bg-dc-surface-secondary dc:rounded-t-lg", children: [
266
+ /* @__PURE__ */ u("div", { className: "dc:flex dc:items-center dc:gap-2 dc:flex-1 dc:min-w-0", children: [
267
+ /* @__PURE__ */ e(ze, { style: re }),
268
+ /* @__PURE__ */ e("h3", { className: "dc:font-semibold dc:text-sm text-dc-text dc:truncate", children: s.title || "Markdown" })
269
+ ] }),
270
+ /* @__PURE__ */ u("div", { className: "dc:flex dc:items-center dc:gap-1 dc:shrink-0 dc:ml-4 dc:-mr-2", children: [
271
+ !r && /* @__PURE__ */ e(
272
+ "button",
273
+ {
274
+ onClick: () => a(s.id),
275
+ className: "dc:p-1 dc:bg-transparent dc:border-none dc:rounded-sm text-dc-text-secondary dc:cursor-pointer dc:hover:bg-dc-surface-hover dc:transition-colors",
276
+ title: "Move up",
277
+ children: /* @__PURE__ */ e(We, { style: re })
278
+ }
279
+ ),
280
+ !o && /* @__PURE__ */ e(
281
+ "button",
282
+ {
283
+ onClick: () => n(s.id),
284
+ className: "dc:p-1 dc:bg-transparent dc:border-none dc:rounded-sm text-dc-text-secondary dc:cursor-pointer dc:hover:bg-dc-surface-hover dc:transition-colors",
285
+ title: "Move down",
286
+ children: /* @__PURE__ */ e(Je, { style: re })
287
+ }
288
+ ),
289
+ /* @__PURE__ */ e(
290
+ "button",
291
+ {
292
+ onClick: () => c(s.id),
293
+ className: "dc:p-1 dc:mr-0.5 dc:bg-transparent dc:border-none dc:rounded-sm dc:cursor-pointer dc:hover:bg-dc-danger-bg text-dc-danger dc:transition-colors",
294
+ title: "Remove",
295
+ children: /* @__PURE__ */ e(Xe, { style: re })
296
+ }
297
+ )
298
+ ] })
288
299
  ] }),
289
- t.title && /* @__PURE__ */ s("h4", { className: "dc:text-sm dc:font-semibold text-dc-text dc:mb-2 dc:px-1", children: t.title }),
290
- /* @__PURE__ */ s("div", { className: "dc:rounded-lg dc:p-4 bg-dc-surface border-dc-border dc:border", children: /* @__PURE__ */ s(Ne, { options: Fe, children: t.content }) })
300
+ /* @__PURE__ */ e("div", { className: "dc:p-4 dc:min-w-0 dc:overflow-hidden", children: /* @__PURE__ */ e(Ee, { options: Ge, children: s.content }) })
291
301
  ] });
292
- }), Ve = V.memo(function() {
293
- const t = A(Ae), { removeBlock: r, moveBlock: n, updateBlock: c } = A(z(Ee)), a = v(null), [o, p] = _(null), u = v(t.length);
294
- F(() => {
295
- t.length > u.current && a.current?.scrollIntoView({ behavior: "smooth" }), u.current = t.length;
296
- }, [t.length]);
297
- const w = h((l) => r(l), [r]), x = h((l) => n(l, "up"), [n]), N = h((l) => n(l, "down"), [n]), y = h((l) => p(l), []), S = h((l) => {
302
+ }), ue = Y.memo(function() {
303
+ const s = P(Fe), { removeBlock: c, moveBlock: a, updateBlock: n } = P(de(je)), r = g(null), [o, l] = j(null), d = g(s.length);
304
+ V(() => {
305
+ s.length > d.current && r.current?.scrollIntoView({ behavior: "smooth" }), d.current = s.length;
306
+ }, [s.length]);
307
+ const T = f((p) => c(p), [c]), w = f((p) => a(p, "up"), [a]), A = f((p) => a(p, "down"), [a]), v = f((p) => l(p), []), I = f((p) => {
298
308
  if (!o) return;
299
- const d = he(l), { analysisConfig: i } = d;
300
- if (i) {
301
- const k = i.charts[i.analysisType];
302
- c(o.id, {
303
- title: l.title,
304
- query: JSON.stringify(i.query),
305
- chartType: k?.chartType || "bar",
306
- chartConfig: k?.chartConfig,
307
- displayConfig: k?.displayConfig
309
+ const D = we(p), { analysisConfig: k } = D;
310
+ if (k) {
311
+ const b = k.charts[k.analysisType];
312
+ n(o.id, {
313
+ title: p.title,
314
+ query: JSON.stringify(k.query),
315
+ chartType: b?.chartType || "bar",
316
+ chartConfig: b?.chartConfig,
317
+ displayConfig: b?.displayConfig
308
318
  });
309
319
  }
310
- p(null);
311
- }, [o, c]);
312
- return t.length === 0 ? /* @__PURE__ */ s("div", { className: "dc:flex dc:items-center dc:justify-center dc:h-full", children: /* @__PURE__ */ f("div", { className: "dc:text-center dc:max-w-sm dc:px-6", children: [
313
- /* @__PURE__ */ s("h3", { className: "dc:text-base dc:font-semibold text-dc-text dc:mb-2", children: "Your notebook is empty" }),
314
- /* @__PURE__ */ s("p", { className: "dc:text-sm text-dc-text-secondary", children: "Ask the AI assistant a question about your data. Charts and insights will appear here as the assistant analyzes your data." })
315
- ] }) }) : /* @__PURE__ */ f("div", { className: "dc:h-full dc:overflow-y-auto dc:p-4", children: [
316
- t.map((l, d) => {
317
- const i = d === 0, k = d === t.length - 1;
318
- return l.type === "portlet" ? /* @__PURE__ */ s(
319
- Qe,
320
+ l(null);
321
+ }, [o, n]);
322
+ return s.length === 0 ? /* @__PURE__ */ e("div", { className: "dc:flex dc:items-center dc:justify-center dc:h-full", children: /* @__PURE__ */ u("div", { className: "dc:text-center dc:max-w-sm dc:px-6", children: [
323
+ /* @__PURE__ */ e("h3", { className: "dc:text-base dc:font-semibold text-dc-text dc:mb-2", children: "Your notebook is empty" }),
324
+ /* @__PURE__ */ e("p", { className: "dc:text-sm text-dc-text-secondary", children: "Ask the AI assistant a question about your data. Charts and insights will appear here as the assistant analyzes your data." })
325
+ ] }) }) : /* @__PURE__ */ u("div", { className: "dc:h-full dc:overflow-y-auto dc:p-4", children: [
326
+ s.map((p, D) => {
327
+ const k = D === 0, b = D === s.length - 1;
328
+ return p.type === "portlet" ? /* @__PURE__ */ e(
329
+ Ke,
320
330
  {
321
- block: l,
322
- onRemove: w,
323
- onMoveUp: x,
324
- onMoveDown: N,
325
- onEdit: y,
326
- isFirst: i,
327
- isLast: k
331
+ block: p,
332
+ onRemove: T,
333
+ onMoveUp: w,
334
+ onMoveDown: A,
335
+ onEdit: v,
336
+ isFirst: k,
337
+ isLast: b
328
338
  },
329
- l.id
330
- ) : l.type === "markdown" ? /* @__PURE__ */ s(
331
- _e,
339
+ p.id
340
+ ) : p.type === "markdown" ? /* @__PURE__ */ e(
341
+ He,
332
342
  {
333
- block: l,
334
- onRemove: w,
335
- onMoveUp: x,
336
- onMoveDown: N,
337
- isFirst: i,
338
- isLast: k
343
+ block: p,
344
+ onRemove: T,
345
+ onMoveUp: w,
346
+ onMoveDown: A,
347
+ isFirst: k,
348
+ isLast: b
339
349
  },
340
- l.id
350
+ p.id
341
351
  ) : null;
342
352
  }),
343
- /* @__PURE__ */ s("div", { ref: a }),
344
- /* @__PURE__ */ s(
345
- fe,
353
+ /* @__PURE__ */ e("div", { ref: r }),
354
+ /* @__PURE__ */ e(
355
+ Ne,
346
356
  {
347
357
  isOpen: !!o,
348
- onClose: () => p(null),
349
- onSave: S,
358
+ onClose: () => l(null),
359
+ onSave: I,
350
360
  portlet: o ? {
351
361
  id: o.id,
352
362
  title: o.title,
@@ -365,413 +375,421 @@ const Ae = (e) => e.blocks, dt = (e) => e.messages, it = (e) => e.isStreaming, l
365
375
  )
366
376
  ] });
367
377
  });
368
- function je(e) {
369
- if (e.startsWith("{") || e.includes('"type":"error"'))
378
+ function Ze(t) {
379
+ if (t.startsWith("{") || t.includes('"type":"error"'))
370
380
  try {
371
- const t = JSON.parse(e.replace(/^Error:\s*/, "")), r = t.error?.type || t.type || "";
381
+ const s = JSON.parse(t.replace(/^Error:\s*/, "")), c = s.error?.type || s.type || "";
372
382
  return {
373
383
  overloaded_error: "The AI service is temporarily busy. Please try again in a moment.",
374
384
  rate_limit_error: "Too many requests. Please wait a moment and try again.",
375
385
  api_error: "The AI service encountered an error. Please try again.",
376
386
  authentication_error: "Authentication failed. Please check your configuration."
377
- }[r] || "The AI service encountered an error. Please try again.";
387
+ }[c] || "The AI service encountered an error. Please try again.";
378
388
  } catch {
379
389
  return "The AI service encountered an error. Please try again.";
380
390
  }
381
- if (e.startsWith("Agent request failed:")) {
382
- const t = e.match(/\d+/)?.[0];
383
- return t === "429" ? "Too many requests. Please wait a moment and try again." : t === "503" || t === "529" ? "The AI service is temporarily busy. Please try again in a moment." : "The AI service is temporarily unavailable. Please try again.";
391
+ if (t.startsWith("Agent request failed:")) {
392
+ const s = t.match(/\d+/)?.[0];
393
+ return s === "429" ? "Too many requests. Please wait a moment and try again." : s === "503" || s === "529" ? "The AI service is temporarily busy. Please try again in a moment." : "The AI service is temporarily unavailable. Please try again.";
384
394
  }
385
- return e;
395
+ return t;
386
396
  }
387
- function Ue(e) {
388
- const { agentEndpoint: t, agentApiKey: r } = e, { cubeApi: n } = ke(), c = v(null), [a, o] = _(!1), p = v(e);
389
- p.current = e;
390
- const u = h(async (x, N, y) => {
391
- function S(d) {
392
- const i = p.current;
393
- switch (d.type) {
397
+ function et(t) {
398
+ const { agentEndpoint: s, agentApiKey: c, agentProvider: a, agentModel: n, agentProviderEndpoint: r } = t, { cubeApi: o } = Re(), l = g(null), [d, T] = j(!1), w = g(t);
399
+ w.current = t;
400
+ const A = f(async (I, p, D) => {
401
+ function k(i) {
402
+ const x = w.current;
403
+ switch (i.type) {
394
404
  case "text_delta":
395
- i.onTextDelta(d.data);
405
+ x.onTextDelta(i.data);
396
406
  break;
397
407
  case "tool_use_start":
398
- i.onToolStart(d.data.id, d.data.name, d.data.input);
408
+ x.onToolStart(i.data.id, i.data.name, i.data.input);
399
409
  break;
400
410
  case "tool_use_result":
401
- i.onToolResult(d.data.id, d.data.name, d.data.result, d.data.isError);
411
+ x.onToolResult(i.data.id, i.data.name, i.data.result, i.data.isError);
402
412
  break;
403
413
  case "add_portlet":
404
- i.onAddPortlet({
405
- ...d.data,
414
+ x.onAddPortlet({
415
+ ...i.data,
406
416
  type: "portlet"
407
417
  });
408
418
  break;
409
419
  case "add_markdown":
410
- i.onAddMarkdown({
411
- ...d.data,
420
+ x.onAddMarkdown({
421
+ ...i.data,
412
422
  type: "markdown"
413
423
  });
414
424
  break;
415
425
  case "dashboard_saved":
416
- i.onDashboardSaved?.(d.data);
426
+ x.onDashboardSaved?.(i.data);
417
427
  break;
418
428
  case "turn_complete":
419
- i.onTurnComplete?.();
429
+ x.onTurnComplete?.();
420
430
  break;
421
431
  case "done":
422
- i.onDone(d.data.sessionId, d.data.traceId);
432
+ x.onDone(i.data.sessionId, i.data.traceId);
423
433
  break;
424
434
  case "error":
425
- i.onError(d.data.message);
435
+ x.onError(i.data.message);
426
436
  break;
427
437
  }
428
438
  }
429
- c.current && c.current.abort();
430
- const l = new AbortController();
431
- c.current = l, o(!0);
439
+ l.current && l.current.abort();
440
+ const b = new AbortController();
441
+ l.current = b, T(!0);
432
442
  try {
433
- const d = n.apiUrl || "/cubejs-api/v1", i = t || `${d}/agent/chat`, k = {
443
+ const i = o.apiUrl || "/cubejs-api/v1", x = s || `${i}/agent/chat`, y = {
434
444
  "Content-Type": "application/json",
435
- ...n.headers
445
+ ...o.headers
436
446
  };
437
- r && (k["X-Agent-Api-Key"] = r);
438
- const b = await fetch(i, {
447
+ c && (y["X-Agent-Api-Key"] = c), a && (y["X-Agent-Provider"] = a), n && (y["X-Agent-Model"] = n), r && (y["X-Agent-Provider-Endpoint"] = r);
448
+ const S = await fetch(x, {
439
449
  method: "POST",
440
- headers: k,
441
- credentials: n.credentials ?? "include",
450
+ headers: y,
451
+ credentials: o.credentials ?? "include",
442
452
  body: JSON.stringify({
443
- message: x,
444
- ...N ? { sessionId: N } : {},
445
- ...y && y.length > 0 ? { history: y } : {}
453
+ message: I,
454
+ ...p ? { sessionId: p } : {},
455
+ ...D && D.length > 0 ? { history: D } : {}
446
456
  }),
447
- signal: l.signal
457
+ signal: b.signal
448
458
  });
449
- if (!b.ok) {
450
- const I = await b.json().catch(() => ({}));
451
- throw new Error(I.error || `Agent request failed: ${b.status}`);
459
+ if (!S.ok) {
460
+ const M = await S.json().catch(() => ({}));
461
+ throw new Error(M.error || `Agent request failed: ${S.status}`);
452
462
  }
453
- if (!b.body)
463
+ if (!S.body)
454
464
  throw new Error("No response body received");
455
- const E = b.body.getReader(), T = new TextDecoder();
456
- let D = "";
465
+ const W = S.body.getReader(), U = new TextDecoder();
466
+ let Q = "";
457
467
  for (; ; ) {
458
- const { done: I, value: C } = await E.read();
459
- if (I) break;
460
- D += T.decode(C, { stream: !0 });
461
- const g = D.split(`
468
+ const { done: M, value: C } = await W.read();
469
+ if (M) break;
470
+ Q += U.decode(C, { stream: !0 });
471
+ const E = Q.split(`
462
472
 
463
473
  `);
464
- D = g.pop() || "";
465
- for (const L of g) {
466
- const P = L.trim().split(`
474
+ Q = E.pop() || "";
475
+ for (const N of E) {
476
+ const L = N.trim().split(`
467
477
  `);
468
- for (const R of P)
469
- if (R.startsWith("data: "))
478
+ for (const q of L)
479
+ if (q.startsWith("data: "))
470
480
  try {
471
- const Q = JSON.parse(R.slice(6));
472
- S(Q);
481
+ const K = JSON.parse(q.slice(6));
482
+ k(K);
473
483
  } catch {
474
484
  }
475
485
  }
476
486
  }
477
- if (D.trim()) {
478
- const I = D.trim().split(`
487
+ if (Q.trim()) {
488
+ const M = Q.trim().split(`
479
489
  `);
480
- for (const C of I)
490
+ for (const C of M)
481
491
  if (C.startsWith("data: "))
482
492
  try {
483
- const g = JSON.parse(C.slice(6));
484
- S(g);
493
+ const E = JSON.parse(C.slice(6));
494
+ k(E);
485
495
  } catch {
486
496
  }
487
497
  }
488
- } catch (d) {
489
- if (d.name !== "AbortError") {
490
- const i = d instanceof Error ? d.message : "Stream failed";
491
- p.current.onError(je(i));
498
+ } catch (i) {
499
+ if (i.name !== "AbortError") {
500
+ const x = i instanceof Error ? i.message : "Stream failed";
501
+ w.current.onError(Ze(x));
492
502
  }
493
503
  } finally {
494
- o(!1), c.current = null;
504
+ T(!1), l.current = null;
495
505
  }
496
- }, [n, t, r]), w = h(() => {
497
- c.current && (c.current.abort(), c.current = null, o(!1));
506
+ }, [o, s, c, a, n, r]), v = f(() => {
507
+ l.current && (l.current.abort(), l.current = null, T(!1));
498
508
  }, []);
499
509
  return {
500
- sendMessage: u,
501
- isStreaming: a,
502
- abort: w
510
+ sendMessage: A,
511
+ isStreaming: d,
512
+ abort: v
503
513
  };
504
514
  }
505
- function qe(e) {
506
- const t = [];
507
- let r = e, n = 0;
508
- for (; r; ) {
509
- const c = r.match(/^(.*?)`([^`]+)`(.*)$/);
510
- if (c) {
511
- const [, o, p, u] = c;
512
- o && t.push(/* @__PURE__ */ s("span", { children: o }, n++)), t.push(
513
- /* @__PURE__ */ s("code", { className: "dc:px-1 dc:py-0.5 dc:rounded dc:text-xs bg-dc-surface dc:font-mono", children: p }, n++)
514
- ), r = u;
515
+ function tt(t) {
516
+ const s = [];
517
+ let c = t, a = 0;
518
+ for (; c; ) {
519
+ const n = c.match(/^(.*?)`([^`]+)`(.*)$/);
520
+ if (n) {
521
+ const [, o, l, d] = n;
522
+ o && s.push(/* @__PURE__ */ e("span", { children: o }, a++)), s.push(
523
+ /* @__PURE__ */ e("code", { className: "dc:px-1 dc:py-0.5 dc:rounded dc:text-xs bg-dc-surface dc:font-mono", children: l }, a++)
524
+ ), c = d;
515
525
  continue;
516
526
  }
517
- const a = r.match(/^(.*?)\*\*([^*]+)\*\*(.*)$/);
518
- if (a) {
519
- const [, o, p, u] = a;
520
- o && t.push(/* @__PURE__ */ s("span", { children: o }, n++)), t.push(/* @__PURE__ */ s("strong", { className: "dc:font-semibold", children: p }, n++)), r = u;
527
+ const r = c.match(/^(.*?)\*\*([^*]+)\*\*(.*)$/);
528
+ if (r) {
529
+ const [, o, l, d] = r;
530
+ o && s.push(/* @__PURE__ */ e("span", { children: o }, a++)), s.push(/* @__PURE__ */ e("strong", { className: "dc:font-semibold", children: l }, a++)), c = d;
521
531
  continue;
522
532
  }
523
- t.push(/* @__PURE__ */ s("span", { children: r }, n));
533
+ s.push(/* @__PURE__ */ e("span", { children: c }, a));
524
534
  break;
525
535
  }
526
- return t;
536
+ return s;
527
537
  }
528
- const Ke = {
538
+ const st = {
529
539
  discover_cubes: "Discovering cubes",
530
540
  get_cube_metadata: "Reading metadata",
531
541
  execute_query: "Executing query",
532
542
  add_portlet: "Adding visualization",
533
543
  add_markdown: "Adding explanation"
534
544
  };
535
- function Oe({ toolCall: e, loadingComponent: t }) {
536
- const [r, n] = _(!1), c = Ke[e.name] || e.name, a = e.status === "running";
537
- return /* @__PURE__ */ f("div", { className: "dc:my-1 dc:text-xs", children: [
538
- /* @__PURE__ */ f(
545
+ function ct({ toolCall: t, loadingComponent: s }) {
546
+ const [c, a] = j(!1), n = st[t.name] || t.name, r = t.status === "running";
547
+ return /* @__PURE__ */ u("div", { className: "dc:my-1 dc:text-xs", children: [
548
+ /* @__PURE__ */ u(
539
549
  "button",
540
550
  {
541
- onClick: () => n(!r),
551
+ onClick: () => a(!c),
542
552
  className: "dc:flex dc:items-center dc:gap-1.5 text-dc-text-secondary dc:hover:opacity-80 dc:transition-opacity",
543
553
  children: [
544
- a ? t ? /* @__PURE__ */ s("span", { className: "dc:inline-flex dc:items-center dc:justify-center dc:h-3 dc:w-3", children: t }) : /* @__PURE__ */ s(we, { size: "xs" }) : /* @__PURE__ */ s("span", { className: "dc:text-xs", children: e.status === "error" ? "✗" : "✓" }),
545
- /* @__PURE__ */ f("span", { children: [
546
- c,
547
- a ? "..." : ""
554
+ r ? s ? /* @__PURE__ */ e("span", { className: "dc:inline-flex dc:items-center dc:justify-center dc:h-3 dc:w-3", children: s }) : /* @__PURE__ */ e(me, { size: "xs" }) : /* @__PURE__ */ e("span", { className: "dc:text-xs", children: t.status === "error" ? "✗" : "✓" }),
555
+ /* @__PURE__ */ u("span", { children: [
556
+ n,
557
+ r ? "..." : ""
548
558
  ] }),
549
- !a && /* @__PURE__ */ s("span", { className: "dc:text-[10px] dc:opacity-60", children: r ? "▲" : "▼" })
559
+ !r && /* @__PURE__ */ e("span", { className: "dc:text-[10px] dc:opacity-60", children: c ? "▲" : "▼" })
550
560
  ]
551
561
  }
552
562
  ),
553
- r && e.result != null && /* @__PURE__ */ s("pre", { className: "dc:mt-1 dc:p-2 dc:rounded dc:text-[11px] dc:overflow-x-auto dc:max-h-32 dc:overflow-y-auto bg-dc-surface-secondary text-dc-text-secondary", children: typeof e.result == "string" ? e.result : JSON.stringify(e.result, null, 2) })
563
+ c && t.result != null && /* @__PURE__ */ e("pre", { className: "dc:mt-1 dc:p-2 dc:rounded dc:text-[11px] dc:overflow-x-auto dc:max-h-32 dc:overflow-y-auto bg-dc-surface-secondary text-dc-text-secondary", children: typeof t.result == "string" ? t.result : JSON.stringify(t.result, null, 2) })
554
564
  ] });
555
565
  }
556
- const $e = {
566
+ const rt = {
557
567
  animation: "dc-msg-in 100ms ease-out"
558
- }, ze = V.memo(function({ message: t, loadingComponent: r }) {
559
- const n = t.role === "user", c = !!t.content?.trim(), a = !!t.error, o = t.toolCalls && t.toolCalls.length > 0;
560
- return !n && !c && !a && !o ? null : /* @__PURE__ */ s(
568
+ }, nt = Y.memo(function({ message: s, loadingComponent: c }) {
569
+ const a = s.role === "user", n = !!s.content?.trim(), r = !!s.error, o = s.toolCalls && s.toolCalls.length > 0;
570
+ return !a && !n && !r && !o ? null : /* @__PURE__ */ e(
561
571
  "div",
562
572
  {
563
- className: `dc:flex dc:mb-3 ${n ? "dc:justify-end" : "dc:justify-start"}`,
564
- style: $e,
565
- children: /* @__PURE__ */ f(
573
+ className: `dc:flex dc:mb-3 ${a ? "dc:justify-end" : "dc:justify-start"}`,
574
+ style: rt,
575
+ children: /* @__PURE__ */ u(
566
576
  "div",
567
577
  {
568
- className: `dc:max-w-[85%] dc:rounded-lg dc:px-3 dc:py-2 dc:text-sm ${n ? "bg-dc-accent text-dc-accent-text dc:rounded-br-sm" : a && !c ? "bg-dc-warning-bg text-dc-text dc:rounded-bl-sm" : "bg-dc-surface-secondary text-dc-text dc:rounded-bl-sm"}`,
578
+ className: `dc:max-w-[85%] dc:rounded-lg dc:px-3 dc:py-2 dc:text-sm ${a ? "bg-dc-accent text-dc-accent-text dc:rounded-br-sm" : r && !n ? "bg-dc-warning-bg text-dc-text dc:rounded-bl-sm" : "bg-dc-surface-secondary text-dc-text dc:rounded-bl-sm"}`,
569
579
  children: [
570
- c && /* @__PURE__ */ s("div", { className: "dc:whitespace-pre-wrap dc:break-words", children: n ? t.content : qe(t.content) }),
571
- a && /* @__PURE__ */ f("div", { className: `dc:flex dc:items-start dc:gap-2 ${c ? "dc:mt-2 dc:pt-2 dc:border-t dc:border-current dc:border-opacity-10" : ""}`, children: [
572
- /* @__PURE__ */ s("span", { className: "dc:text-base dc:leading-none dc:mt-0.5 text-dc-warning dc:flex-shrink-0", children: "⚠" }),
573
- /* @__PURE__ */ s("span", { className: "text-dc-text-secondary", children: t.error })
580
+ n && /* @__PURE__ */ e("div", { className: "dc:whitespace-pre-wrap dc:break-words", children: a ? s.content : tt(s.content) }),
581
+ r && /* @__PURE__ */ u("div", { className: `dc:flex dc:items-start dc:gap-2 ${n ? "dc:mt-2 dc:pt-2 dc:border-t dc:border-current dc:border-opacity-10" : ""}`, children: [
582
+ /* @__PURE__ */ e("span", { className: "dc:text-base dc:leading-none dc:mt-0.5 text-dc-warning dc:flex-shrink-0", children: "⚠" }),
583
+ /* @__PURE__ */ e("span", { className: "text-dc-text-secondary", children: s.error })
574
584
  ] }),
575
- o && /* @__PURE__ */ s("div", { className: c || a ? "dc:mt-1 dc:border-t dc:border-current dc:border-opacity-10 dc:pt-1" : "", children: t.toolCalls.map((p, u) => /* @__PURE__ */ s(Oe, { toolCall: p, loadingComponent: r }, p.id || u)) })
585
+ o && /* @__PURE__ */ e("div", { className: n || r ? "dc:mt-1 dc:border-t dc:border-current dc:border-opacity-10 dc:pt-1" : "", children: s.toolCalls.map((l, d) => /* @__PURE__ */ e(ct, { toolCall: l, loadingComponent: c }, l.id || d)) })
576
586
  ]
577
587
  }
578
588
  )
579
589
  }
580
590
  );
581
- }), We = V.memo(function({
582
- value: t,
583
- onChange: r,
584
- onSend: n,
585
- onStop: c,
586
- onContinue: a,
591
+ }), at = Y.memo(function({
592
+ value: s,
593
+ onChange: c,
594
+ onSend: a,
595
+ onStop: n,
596
+ onContinue: r,
587
597
  isStreaming: o = !1,
588
- showContinue: p = !1,
589
- disabled: u = !1,
590
- placeholder: w = "Ask about your data..."
598
+ showContinue: l = !1,
599
+ disabled: d = !1,
600
+ placeholder: T = "Ask about your data..."
591
601
  }) {
592
- const x = v(null);
593
- F(() => {
594
- const y = x.current;
595
- y && (y.style.height = "auto", y.style.height = `${Math.min(y.scrollHeight, 150)}px`);
596
- }, [t]);
597
- const N = h(
598
- (y) => {
599
- y.key === "Enter" && !y.shiftKey && (y.preventDefault(), !u && t.trim() && n());
602
+ const w = g(null);
603
+ V(() => {
604
+ const v = w.current;
605
+ v && (v.style.height = "auto", v.style.height = `${Math.min(v.scrollHeight, 150)}px`);
606
+ }, [s]);
607
+ const A = f(
608
+ (v) => {
609
+ v.key === "Enter" && !v.shiftKey && (v.preventDefault(), !d && s.trim() && a());
600
610
  },
601
- [u, t, n]
611
+ [d, s, a]
602
612
  );
603
- return /* @__PURE__ */ f("div", { className: "dc:flex dc:gap-2 dc:items-end dc:p-3 border-dc-border dc:border-t", children: [
604
- /* @__PURE__ */ s(
613
+ return /* @__PURE__ */ u("div", { className: "dc:flex dc:gap-2 dc:items-end dc:p-3 border-dc-border dc:border-t", children: [
614
+ /* @__PURE__ */ e(
605
615
  "textarea",
606
616
  {
607
- ref: x,
608
- value: t,
609
- onChange: (y) => r(y.target.value),
610
- onKeyDown: N,
611
- placeholder: w,
612
- disabled: u,
617
+ ref: w,
618
+ value: s,
619
+ onChange: (v) => c(v.target.value),
620
+ onKeyDown: A,
621
+ placeholder: T,
622
+ disabled: d,
613
623
  rows: 1,
614
624
  className: "dc:flex-1 dc:resize-none dc:rounded-lg dc:px-3 dc:py-2 dc:text-sm bg-dc-surface-secondary text-dc-text border-dc-border dc:border dc:outline-none dc:focus:ring-1 focus:ring-dc-accent dc:disabled:opacity-50"
615
625
  }
616
626
  ),
617
- o ? /* @__PURE__ */ s(
627
+ o ? /* @__PURE__ */ e(
618
628
  "button",
619
629
  {
620
- onClick: c,
630
+ onClick: n,
621
631
  className: "dc:px-4 dc:py-2 dc:rounded-lg dc:text-sm dc:font-medium dc:transition-colors text-dc-error border-dc-border dc:border dc:hover:opacity-80 dc:shrink-0",
622
632
  children: "Stop"
623
633
  }
624
- ) : /* @__PURE__ */ f(te, { children: [
625
- p && !t.trim() && /* @__PURE__ */ s(
634
+ ) : /* @__PURE__ */ u(ne, { children: [
635
+ l && !s.trim() && /* @__PURE__ */ e(
626
636
  "button",
627
637
  {
628
638
  onClick: () => {
629
- a?.(), x.current?.focus();
639
+ r?.(), w.current?.focus();
630
640
  },
631
641
  className: "dc:px-4 dc:py-2 dc:rounded-lg dc:text-sm dc:font-medium dc:transition-colors border-dc-border dc:border text-dc-text-secondary dc:hover:opacity-80 dc:shrink-0",
632
642
  children: "Continue"
633
643
  }
634
644
  ),
635
- /* @__PURE__ */ s(
645
+ /* @__PURE__ */ e(
636
646
  "button",
637
647
  {
638
- onClick: n,
639
- disabled: u || !t.trim(),
648
+ onClick: a,
649
+ disabled: d || !s.trim(),
640
650
  className: "dc:px-4 dc:py-2 dc:rounded-lg dc:text-sm dc:font-medium dc:transition-colors bg-dc-accent text-dc-accent-text dc:hover:opacity-90 dc:disabled:opacity-40 dc:disabled:cursor-not-allowed dc:shrink-0",
641
651
  children: "Send"
642
652
  }
643
653
  )
644
654
  ] })
645
655
  ] });
646
- }), Je = j("thumbUp"), Ge = j("thumbDown"), He = V.memo(function({
647
- agentEndpoint: t,
648
- agentApiKey: r,
649
- onClear: n,
650
- onDashboardSaved: c,
651
- onScore: a,
652
- loadingComponent: o,
653
- initialPrompt: p
656
+ }), ot = B("thumbUp"), dt = B("thumbDown"), lt = Y.memo(function({
657
+ agentEndpoint: s,
658
+ agentApiKey: c,
659
+ agentProvider: a,
660
+ agentModel: n,
661
+ agentProviderEndpoint: r,
662
+ onClear: o,
663
+ onDashboardSaved: l,
664
+ onScore: d,
665
+ loadingComponent: T,
666
+ initialPrompt: w
654
667
  }) {
655
- const u = v(null), w = v(!1), [x, N] = _(null), [y, S] = _(/* @__PURE__ */ new Set()), l = v(!1), { messages: d, isStreaming: i, inputValue: k } = A(z(Me)), {
656
- addMessage: b,
657
- appendToLastAssistantMessage: E,
658
- setLastAssistantError: T,
659
- addToolCallToLastAssistant: D,
660
- updateLastToolCall: I,
661
- setIsStreaming: C,
662
- setInputValue: g,
663
- setSessionId: L
664
- } = A(z(Ie)), P = A((m) => m.sessionId), R = A((m) => m.addBlock), Q = A((m) => m.reset), $ = A((m) => m.blocks.filter((M) => M.type === "portlet").length), W = v(d);
665
- W.current = d;
666
- const J = v(i);
667
- J.current = i;
668
- const G = v(P);
669
- G.current = P;
670
- const U = h(() => {
671
- l.current && (l.current = !1, b({
668
+ const A = g(null), v = g(!1), [I, p] = j(null), [D, k] = j(/* @__PURE__ */ new Set()), [b, i] = j(!1), x = g(!1), { messages: y, isStreaming: S, inputValue: W } = P(de(_e)), {
669
+ addMessage: U,
670
+ appendToLastAssistantMessage: Q,
671
+ setLastAssistantError: M,
672
+ addToolCallToLastAssistant: C,
673
+ updateLastToolCall: E,
674
+ setIsStreaming: N,
675
+ setInputValue: L,
676
+ setSessionId: q
677
+ } = P(de(Ve)), K = P((m) => m.sessionId), J = P((m) => m.addBlock), H = P((m) => m.reset), R = P((m) => m.blocks.filter((_) => _.type === "portlet").length), X = g(y);
678
+ X.current = y;
679
+ const O = g(S);
680
+ O.current = S;
681
+ const G = g(K);
682
+ G.current = K;
683
+ const z = f(() => {
684
+ x.current && (x.current = !1, U({
672
685
  id: `msg-${Date.now()}`,
673
686
  role: "assistant",
674
687
  content: "",
675
688
  toolCalls: [],
676
689
  timestamp: Date.now()
677
690
  }));
678
- }, [b]), H = v(d.length);
679
- F(() => {
680
- d.length > H.current && u.current?.scrollIntoView({ behavior: "smooth" }), H.current = d.length;
681
- }, [d]);
682
- const { sendMessage: Y, abort: K } = Ue({
683
- agentEndpoint: t,
684
- agentApiKey: r,
685
- onTextDelta: h((m) => {
686
- U(), E(m);
687
- }, [U, E]),
688
- onToolStart: h((m, M, B) => {
689
- U(), D({ id: m, name: M, input: B, status: "running" });
690
- }, [U, D]),
691
- onToolResult: h((m, M, B, ue) => {
692
- I({ id: m, status: ue ? "error" : "complete", result: B });
693
- }, [I]),
694
- onAddPortlet: h((m) => {
695
- R(m);
696
- }, [R]),
697
- onAddMarkdown: h((m) => {
698
- R(m);
699
- }, [R]),
700
- onDashboardSaved: c,
701
- onTurnComplete: h(() => {
702
- l.current = !0;
691
+ }, [U]), te = g(y.length);
692
+ V(() => {
693
+ y.length > te.current && A.current?.scrollIntoView({ behavior: "smooth" }), te.current = y.length;
694
+ }, [y]), V(() => {
695
+ b && A.current?.scrollIntoView({ behavior: "smooth" });
696
+ }, [b]);
697
+ const { sendMessage: Z, abort: h } = et({
698
+ agentEndpoint: s,
699
+ agentApiKey: c,
700
+ agentProvider: a,
701
+ agentModel: n,
702
+ agentProviderEndpoint: r,
703
+ onTextDelta: f((m) => {
704
+ i(!1), z(), Q(m);
705
+ }, [z, Q]),
706
+ onToolStart: f((m, _, $) => {
707
+ i(!1), z(), C({ id: m, name: _, input: $, status: "running" });
708
+ }, [z, C]),
709
+ onToolResult: f((m, _, $, ye) => {
710
+ E({ id: m, status: ye ? "error" : "complete", result: $ });
711
+ }, [E]),
712
+ onAddPortlet: f((m) => {
713
+ J(m);
714
+ }, [J]),
715
+ onAddMarkdown: f((m) => {
716
+ J(m);
717
+ }, [J]),
718
+ onDashboardSaved: l,
719
+ onTurnComplete: f(() => {
720
+ x.current = !0, i(!0);
703
721
  }, []),
704
- onDone: h((m, M) => {
705
- l.current = !1, L(m), C(!1), M && N(M);
706
- }, [L, C]),
707
- onError: h((m) => {
708
- U(), T(m), C(!1);
709
- }, [U, T, C])
710
- }), q = h((m) => {
711
- if (!m || J.current) return;
712
- l.current = !1;
713
- const M = W.current.map((B) => ({
714
- role: B.role,
715
- content: B.content,
716
- ...B.toolCalls && B.toolCalls.length > 0 ? { toolCalls: B.toolCalls } : {}
722
+ onDone: f((m, _) => {
723
+ x.current = !1, q(m), N(!1), i(!1), _ && p(_);
724
+ }, [q, N]),
725
+ onError: f((m) => {
726
+ i(!1), z(), M(m), N(!1);
727
+ }, [z, M, N])
728
+ }), F = f((m) => {
729
+ if (!m || O.current) return;
730
+ x.current = !1;
731
+ const _ = X.current.map(($) => ({
732
+ role: $.role,
733
+ content: $.content,
734
+ ...$.toolCalls && $.toolCalls.length > 0 ? { toolCalls: $.toolCalls } : {}
717
735
  }));
718
- b({
736
+ U({
719
737
  id: `msg-${Date.now()}`,
720
738
  role: "user",
721
739
  content: m,
722
740
  timestamp: Date.now()
723
- }), b({
741
+ }), U({
724
742
  id: `msg-${Date.now() + 1}`,
725
743
  role: "assistant",
726
744
  content: "",
727
745
  toolCalls: [],
728
746
  timestamp: Date.now()
729
- }), g(""), C(!0), Y(m, G.current, M);
730
- }, [b, g, C, Y]);
731
- F(() => {
732
- if (p && !w.current && d.length === 0) {
733
- w.current = !0;
734
- const m = setTimeout(() => q(p), 100);
747
+ }), L(""), N(!0), i(!0), Z(m, G.current, _);
748
+ }, [U, L, N, Z]);
749
+ V(() => {
750
+ if (w && !v.current && y.length === 0) {
751
+ v.current = !0;
752
+ const m = setTimeout(() => F(w), 100);
735
753
  return () => {
736
- clearTimeout(m), w.current = !1;
754
+ clearTimeout(m), v.current = !1;
737
755
  };
738
756
  }
739
- }, [p, d.length, q]);
740
- const X = v(k);
741
- X.current = k;
742
- const ce = h(() => {
743
- q(X.current.trim());
744
- }, [q]), ae = h(() => {
745
- K(), C(!1);
746
- }, [K, C]), ne = h(() => {
747
- g("");
748
- }, [g]), oe = h(() => {
749
- K(), C(!1), Q(), N(null), S(/* @__PURE__ */ new Set()), n?.();
750
- }, [K, C, Q, n]), de = h(() => {
751
- q(
757
+ }, [w, y.length, F]);
758
+ const ee = g(W);
759
+ ee.current = W;
760
+ const ae = f(() => {
761
+ F(ee.current.trim());
762
+ }, [F]), se = f(() => {
763
+ h(), N(!1);
764
+ }, [h, N]), oe = f(() => {
765
+ L("");
766
+ }, [L]), pe = f(() => {
767
+ h(), N(!1), i(!1), H(), p(null), k(/* @__PURE__ */ new Set()), o?.();
768
+ }, [h, N, H, o]), ge = f(() => {
769
+ F(
752
770
  "Save the current notebook as a dashboard with a professional layout, section headers, and appropriate filters."
753
771
  );
754
- }, [q]), Z = h((m) => {
755
- !x || !a || (a({ traceId: x, value: m }), S((M) => new Set(M).add(x)));
756
- }, [x, a]), ie = !!c && !i && $ > 0 && d.length > 0, le = !!a && !i && x && d.length > 0 && !y.has(x), ee = x ? y.has(x) : !1;
757
- return /* @__PURE__ */ f("div", { className: "dc:flex dc:flex-col dc:h-full bg-dc-surface", children: [
758
- /* @__PURE__ */ f("div", { className: "dc:flex dc:items-center dc:justify-between dc:px-4 dc:py-3 border-dc-border dc:border-b", children: [
759
- /* @__PURE__ */ s("h3", { className: "dc:text-sm dc:font-semibold text-dc-text", children: "AI Assistant" }),
760
- /* @__PURE__ */ f("div", { className: "dc:flex dc:items-center dc:gap-1", children: [
761
- ie && /* @__PURE__ */ s(
772
+ }, [F]), le = f((m) => {
773
+ !I || !d || (d({ traceId: I, value: m }), k((_) => new Set(_).add(I)));
774
+ }, [I, d]), be = !!l && !S && R > 0 && y.length > 0, xe = !!d && !S && I && y.length > 0 && !D.has(I), ie = I ? D.has(I) : !1;
775
+ return /* @__PURE__ */ u("div", { className: "dc:flex dc:flex-col dc:h-full bg-dc-surface", children: [
776
+ /* @__PURE__ */ u("div", { className: "dc:flex dc:items-center dc:justify-between dc:px-4 dc:py-3 border-dc-border dc:border-b", children: [
777
+ /* @__PURE__ */ e("h3", { className: "dc:text-sm dc:font-semibold text-dc-text", children: "AI Assistant" }),
778
+ /* @__PURE__ */ u("div", { className: "dc:flex dc:items-center dc:gap-1", children: [
779
+ be && /* @__PURE__ */ e(
762
780
  "button",
763
781
  {
764
- onClick: de,
782
+ onClick: ge,
765
783
  className: "dc:text-xs dc:px-2 dc:py-1 dc:rounded text-dc-accent dc:hover:opacity-80",
766
784
  title: "Save notebook as a dashboard",
767
785
  children: "Save as Dashboard"
768
786
  }
769
787
  ),
770
- d.length > 0 && /* @__PURE__ */ s(
788
+ y.length > 0 && /* @__PURE__ */ e(
771
789
  "button",
772
790
  {
773
- onClick: oe,
774
- disabled: i,
791
+ onClick: pe,
792
+ disabled: S,
775
793
  className: "dc:text-xs dc:px-2 dc:py-1 dc:rounded text-dc-text-secondary dc:hover:opacity-80 dc:disabled:opacity-40",
776
794
  title: "Clear notebook and chat",
777
795
  children: "Clear"
@@ -779,368 +797,512 @@ const $e = {
779
797
  )
780
798
  ] })
781
799
  ] }),
782
- /* @__PURE__ */ f("div", { className: "dc:flex-1 dc:overflow-y-auto dc:px-4 dc:py-3", children: [
783
- d.length === 0 ? /* @__PURE__ */ s(Ye, {}) : d.map((m) => /* @__PURE__ */ s(
784
- ze,
800
+ /* @__PURE__ */ u("div", { className: "dc:flex-1 dc:overflow-y-auto dc:px-4 dc:py-3", children: [
801
+ y.length === 0 ? /* @__PURE__ */ e(ut, {}) : y.map((m) => /* @__PURE__ */ e(
802
+ nt,
785
803
  {
786
804
  message: m,
787
- loadingComponent: o
805
+ loadingComponent: T
788
806
  },
789
807
  m.id
790
808
  )),
791
- (le || ee) && /* @__PURE__ */ s("div", { className: "dc:flex dc:items-center dc:justify-center dc:gap-3 dc:py-4 dc:mt-2", children: ee ? /* @__PURE__ */ s("span", { className: "dc:text-sm text-dc-text-secondary", children: "Thanks for your feedback!" }) : /* @__PURE__ */ f(te, { children: [
792
- /* @__PURE__ */ s("span", { className: "dc:text-sm text-dc-text-secondary", children: "Was this helpful?" }),
793
- /* @__PURE__ */ f("div", { className: "dc:flex dc:items-center dc:gap-2", children: [
794
- /* @__PURE__ */ f(
809
+ b && /* @__PURE__ */ e(it, { loadingComponent: T }),
810
+ (xe || ie) && /* @__PURE__ */ e("div", { className: "dc:flex dc:items-center dc:justify-center dc:gap-3 dc:py-4 dc:mt-2", children: ie ? /* @__PURE__ */ e("span", { className: "dc:text-sm text-dc-text-secondary", children: "Thanks for your feedback!" }) : /* @__PURE__ */ u(ne, { children: [
811
+ /* @__PURE__ */ e("span", { className: "dc:text-sm text-dc-text-secondary", children: "Was this helpful?" }),
812
+ /* @__PURE__ */ u("div", { className: "dc:flex dc:items-center dc:gap-2", children: [
813
+ /* @__PURE__ */ u(
795
814
  "button",
796
815
  {
797
- onClick: () => Z(1),
816
+ onClick: () => le(1),
798
817
  className: "dc:flex dc:items-center dc:gap-1.5 dc:px-3 dc:py-1.5 dc:rounded-lg dc:text-sm dc:font-medium border-dc-border dc:border text-dc-success hover:bg-dc-success-bg dc:transition-colors bg-dc-surface dc:cursor-pointer",
799
818
  children: [
800
- /* @__PURE__ */ s(Je, { className: "dc:w-4 dc:h-4" }),
819
+ /* @__PURE__ */ e(ot, { className: "dc:w-4 dc:h-4" }),
801
820
  "Yes"
802
821
  ]
803
822
  }
804
823
  ),
805
- /* @__PURE__ */ f(
824
+ /* @__PURE__ */ u(
806
825
  "button",
807
826
  {
808
- onClick: () => Z(0),
827
+ onClick: () => le(0),
809
828
  className: "dc:flex dc:items-center dc:gap-1.5 dc:px-3 dc:py-1.5 dc:rounded-lg dc:text-sm dc:font-medium border-dc-border dc:border text-dc-error hover:bg-dc-danger-bg dc:transition-colors bg-dc-surface dc:cursor-pointer",
810
829
  children: [
811
- /* @__PURE__ */ s(Ge, { className: "dc:w-4 dc:h-4" }),
830
+ /* @__PURE__ */ e(dt, { className: "dc:w-4 dc:h-4" }),
812
831
  "No"
813
832
  ]
814
833
  }
815
834
  )
816
835
  ] })
817
836
  ] }) }),
818
- /* @__PURE__ */ s("div", { ref: u })
837
+ /* @__PURE__ */ e("div", { ref: A })
819
838
  ] }),
820
- /* @__PURE__ */ s(
821
- We,
839
+ /* @__PURE__ */ e(
840
+ at,
822
841
  {
823
- value: k,
824
- onChange: g,
825
- onSend: ce,
826
- onStop: ae,
827
- onContinue: ne,
828
- isStreaming: i,
829
- showContinue: !i && d.length > 0
842
+ value: W,
843
+ onChange: L,
844
+ onSend: ae,
845
+ onStop: se,
846
+ onContinue: oe,
847
+ isStreaming: S,
848
+ showContinue: !S && y.length > 0
830
849
  }
831
850
  )
832
851
  ] });
833
852
  });
834
- function Ye() {
835
- return /* @__PURE__ */ s("div", { className: "dc:flex dc:items-center dc:justify-center dc:h-full", children: /* @__PURE__ */ f("div", { className: "dc:text-center dc:max-w-xs", children: [
836
- /* @__PURE__ */ s("div", { className: "dc:text-lg dc:font-semibold text-dc-text dc:mb-2", children: "Data Analysis Assistant" }),
837
- /* @__PURE__ */ s("p", { className: "dc:text-sm text-dc-text-secondary dc:mb-4", children: "Ask me about your data and I'll create visualizations and insights." }),
838
- /* @__PURE__ */ f("div", { className: "dc:space-y-2 dc:text-xs text-dc-text-muted", children: [
839
- /* @__PURE__ */ s("p", { children: '"Show me employee productivity trends"' }),
840
- /* @__PURE__ */ s("p", { children: '"What are the top departments by headcount?"' }),
841
- /* @__PURE__ */ s("p", { children: '"Compare revenue across product categories"' })
853
+ function it({ loadingComponent: t }) {
854
+ return /* @__PURE__ */ e(
855
+ "div",
856
+ {
857
+ className: "dc:flex dc:mb-3 dc:justify-start",
858
+ style: { animation: "dc-msg-in 100ms ease-out" },
859
+ children: /* @__PURE__ */ u("div", { className: "dc:rounded-lg dc:px-3 dc:py-2 dc:text-sm bg-dc-surface-secondary text-dc-text-secondary dc:rounded-bl-sm dc:flex dc:items-center dc:gap-2", children: [
860
+ t ? /* @__PURE__ */ e("span", { className: "dc:inline-flex dc:items-center dc:justify-center dc:h-4 dc:w-4", children: t }) : /* @__PURE__ */ e(me, { size: "xs" }),
861
+ /* @__PURE__ */ e("span", { children: "Thinking..." })
862
+ ] })
863
+ }
864
+ );
865
+ }
866
+ function ut() {
867
+ return /* @__PURE__ */ e("div", { className: "dc:flex dc:items-center dc:justify-center dc:h-full", children: /* @__PURE__ */ u("div", { className: "dc:text-center dc:max-w-xs", children: [
868
+ /* @__PURE__ */ e("div", { className: "dc:text-lg dc:font-semibold text-dc-text dc:mb-2", children: "Data Analysis Assistant" }),
869
+ /* @__PURE__ */ e("p", { className: "dc:text-sm text-dc-text-secondary dc:mb-4", children: "Ask me about your data and I'll create visualizations and insights." }),
870
+ /* @__PURE__ */ u("div", { className: "dc:space-y-2 dc:text-xs text-dc-text-muted", children: [
871
+ /* @__PURE__ */ e("p", { children: '"Show me employee productivity trends"' }),
872
+ /* @__PURE__ */ e("p", { children: '"What are the top departments by headcount?"' }),
873
+ /* @__PURE__ */ e("p", { children: '"Compare revenue across product categories"' })
842
874
  ] })
843
875
  ] }) });
844
876
  }
845
- function Xe({
846
- agentEndpoint: e,
847
- agentApiKey: t,
877
+ function mt({
878
+ blocks: t,
879
+ pulsingBlockId: s,
880
+ nudge: c,
881
+ onExpand: a
882
+ }) {
883
+ const n = B("bookOpen"), r = B("documentText");
884
+ return /* @__PURE__ */ u(
885
+ "button",
886
+ {
887
+ type: "button",
888
+ onClick: a,
889
+ className: "dc:h-full dc:flex-shrink-0 dc:flex dc:flex-col dc:items-center dc:pt-3 dc:gap-2 bg-dc-surface border-dc-border dc:border-r dc:cursor-pointer dc:hover:bg-dc-surface-hover dc:transition-colors",
890
+ style: c ? { animation: "dc-strip-nudge 0.8s ease-in-out 2", width: 48 } : { width: 48 },
891
+ title: "Expand notebook",
892
+ children: [
893
+ /* @__PURE__ */ e(n, { className: "dc:w-5 dc:h-5 text-dc-text-muted" }),
894
+ /* @__PURE__ */ e(
895
+ "div",
896
+ {
897
+ className: "dc:flex dc:flex-col dc:items-center dc:gap-1.5 dc:flex-1 dc:overflow-y-auto dc:py-1",
898
+ style: { scrollbarWidth: "none" },
899
+ children: t.length === 0 ? /* @__PURE__ */ e(
900
+ "span",
901
+ {
902
+ className: "dc:text-[9px] text-dc-text-disabled dc:writing-vertical-lr dc:mt-2",
903
+ style: { writingMode: "vertical-lr" },
904
+ children: "No blocks"
905
+ }
906
+ ) : t.map((o) => {
907
+ const l = o.id === s;
908
+ let d;
909
+ return o.type === "portlet" ? d = Me(o.chartType) : d = r, /* @__PURE__ */ e(
910
+ "div",
911
+ {
912
+ className: "dc:w-6 dc:h-6 dc:flex dc:items-center dc:justify-center dc:rounded",
913
+ style: l ? { animation: "dc-icon-pulse 0.6s ease-in-out 3" } : void 0,
914
+ title: o.type === "portlet" ? o.title : o.title || "Markdown",
915
+ children: /* @__PURE__ */ e(d, { className: "dc:w-4 dc:h-4 text-dc-text-muted" })
916
+ },
917
+ o.id
918
+ );
919
+ })
920
+ }
921
+ )
922
+ ]
923
+ }
924
+ );
925
+ }
926
+ function ht({ onExpand: t }) {
927
+ const s = B("sparkles");
928
+ return /* @__PURE__ */ u(
929
+ "button",
930
+ {
931
+ type: "button",
932
+ onClick: t,
933
+ className: "dc:w-12 dc:h-full dc:flex-shrink-0 dc:flex dc:flex-col dc:items-center dc:pt-3 dc:gap-2 bg-dc-surface border-dc-border dc:border-l dc:cursor-pointer dc:hover:bg-dc-surface-hover dc:transition-colors",
934
+ title: "Expand AI chat",
935
+ children: [
936
+ /* @__PURE__ */ e(s, { className: "dc:w-5 dc:h-5 text-dc-accent" }),
937
+ /* @__PURE__ */ e(
938
+ "span",
939
+ {
940
+ className: "dc:text-[10px] dc:font-medium text-dc-text-muted",
941
+ style: { writingMode: "vertical-lr" },
942
+ children: "AI Chat"
943
+ }
944
+ )
945
+ ]
946
+ }
947
+ );
948
+ }
949
+ function ft({
950
+ agentEndpoint: t,
951
+ agentApiKey: s,
952
+ agentProvider: c,
953
+ agentModel: a,
954
+ agentProviderEndpoint: n,
848
955
  onSave: r,
849
- onDirtyStateChange: n,
850
- onDashboardSaved: c,
851
- onScore: a,
852
- loadingComponent: o,
853
- className: p,
854
- initialPrompt: u
956
+ onDirtyStateChange: o,
957
+ onDashboardSaved: l,
958
+ onScore: d,
959
+ loadingComponent: T,
960
+ className: w,
961
+ initialPrompt: A
855
962
  }) {
856
- const [w, x] = _(60), N = v(null), y = v(!1), S = A((g) => g.blocks.length), l = A((g) => g.messages.length), d = A((g) => g.isStreaming), i = A((g) => g.save), k = v({ blockCount: S, msgCount: l });
857
- F(() => {
858
- const g = S !== k.current.blockCount || l !== k.current.msgCount;
859
- n?.(g);
860
- }, [S, l, n]);
861
- const b = v(), E = v(!1), T = v(r);
862
- T.current = r;
863
- const D = v(S > 0 || l > 0);
864
- F(() => {
865
- if ((S > 0 || l > 0) && (D.current = !0), !(!T.current || !D.current)) {
866
- if (d) {
867
- E.current = !0, b.current && clearTimeout(b.current);
963
+ const [v, I] = j(60), p = g(null), D = g(!1), { containerRef: k, layoutMode: b } = Be(), [i, x] = j("chat"), [y, S] = j(null), [W, U] = j(!1), Q = g(b), M = P((h) => h.blocks), C = M.length, E = P((h) => h.messages.length), N = P((h) => h.isStreaming), L = P((h) => h.save);
964
+ V(() => {
965
+ Q.current === "narrow" && b === "wide" && x("chat"), Q.current = b;
966
+ }, [b]);
967
+ const q = g(C);
968
+ V(() => {
969
+ if (b === "narrow" && i === "chat" && C > q.current) {
970
+ const h = M[M.length - 1];
971
+ if (h) {
972
+ S(h.id);
973
+ const F = setTimeout(() => S(null), 2e3);
974
+ return () => clearTimeout(F);
975
+ }
976
+ }
977
+ q.current = C;
978
+ }, [C, M, b, i]);
979
+ const K = g(!1);
980
+ V(() => {
981
+ if (N)
982
+ K.current = !0;
983
+ else if (K.current && b === "narrow" && i === "chat" && C > 0) {
984
+ K.current = !1, U(!0);
985
+ const h = setTimeout(() => U(!1), 1700);
986
+ return () => clearTimeout(h);
987
+ }
988
+ }, [N, b, i, C]);
989
+ const J = f(
990
+ (h) => {
991
+ k(h), p.current = h;
992
+ },
993
+ [k]
994
+ ), H = g({ blockCount: C, msgCount: E });
995
+ V(() => {
996
+ const h = C !== H.current.blockCount || E !== H.current.msgCount;
997
+ o?.(h);
998
+ }, [C, E, o]);
999
+ const R = g(), X = g(!1), O = g(r);
1000
+ O.current = r;
1001
+ const G = g(C > 0 || E > 0);
1002
+ V(() => {
1003
+ if ((C > 0 || E > 0) && (G.current = !0), !(!O.current || !G.current)) {
1004
+ if (N) {
1005
+ X.current = !0, R.current && clearTimeout(R.current);
868
1006
  return;
869
1007
  }
870
- return b.current && clearTimeout(b.current), b.current = setTimeout(() => {
871
- E.current = !1;
872
- const g = i();
873
- T.current?.(g);
1008
+ return R.current && clearTimeout(R.current), R.current = setTimeout(() => {
1009
+ X.current = !1;
1010
+ const h = L();
1011
+ O.current?.(h);
874
1012
  }, 1e3), () => {
875
- b.current && clearTimeout(b.current);
1013
+ R.current && clearTimeout(R.current);
876
1014
  };
877
1015
  }
878
- }, [S, l, d, i]), F(() => {
879
- !d && E.current && T.current && D.current && (b.current && clearTimeout(b.current), b.current = setTimeout(() => {
880
- E.current = !1;
881
- const g = i();
882
- T.current?.(g);
1016
+ }, [C, E, N, L]), V(() => {
1017
+ !N && X.current && O.current && G.current && (R.current && clearTimeout(R.current), R.current = setTimeout(() => {
1018
+ X.current = !1;
1019
+ const h = L();
1020
+ O.current?.(h);
883
1021
  }, 1e3));
884
- }, [d, i]);
885
- const I = h(() => {
886
- T.current && (b.current && clearTimeout(b.current), T.current({ blocks: [], messages: [] }));
887
- }, []), C = h((g) => {
888
- g.preventDefault(), y.current = !0;
889
- const L = (R) => {
890
- if (!y.current || !N.current) return;
891
- const Q = N.current.getBoundingClientRect(), $ = (R.clientX - Q.left) / Q.width * 100;
892
- x(Math.min(Math.max($, 30), 80));
893
- }, P = () => {
894
- y.current = !1, document.removeEventListener("mousemove", L), document.removeEventListener("mouseup", P);
1022
+ }, [N, L]);
1023
+ const z = f(() => {
1024
+ O.current && (R.current && clearTimeout(R.current), O.current({ blocks: [], messages: [] }));
1025
+ }, []), te = f((h) => {
1026
+ h.preventDefault(), D.current = !0;
1027
+ const F = (ae) => {
1028
+ if (!D.current || !p.current) return;
1029
+ const se = p.current.getBoundingClientRect(), oe = (ae.clientX - se.left) / se.width * 100;
1030
+ I(Math.min(Math.max(oe, 30), 80));
1031
+ }, ee = () => {
1032
+ D.current = !1, document.removeEventListener("mousemove", F), document.removeEventListener("mouseup", ee);
895
1033
  };
896
- document.addEventListener("mousemove", L), document.addEventListener("mouseup", P);
897
- }, []);
898
- return /* @__PURE__ */ f(
1034
+ document.addEventListener("mousemove", F), document.addEventListener("mouseup", ee);
1035
+ }, []), Z = /* @__PURE__ */ e(
1036
+ lt,
1037
+ {
1038
+ agentEndpoint: t,
1039
+ agentApiKey: s,
1040
+ agentProvider: c,
1041
+ agentModel: a,
1042
+ agentProviderEndpoint: n,
1043
+ onClear: z,
1044
+ onDashboardSaved: l,
1045
+ onScore: d,
1046
+ loadingComponent: T,
1047
+ initialPrompt: A
1048
+ }
1049
+ );
1050
+ return b === "narrow" ? /* @__PURE__ */ e(
1051
+ "div",
1052
+ {
1053
+ ref: J,
1054
+ className: `dc:flex dc:h-full dc:w-full dc:overflow-hidden bg-dc-surface-secondary ${w || ""}`,
1055
+ children: i === "chat" ? /* @__PURE__ */ u(ne, { children: [
1056
+ /* @__PURE__ */ e(
1057
+ mt,
1058
+ {
1059
+ blocks: M,
1060
+ pulsingBlockId: y,
1061
+ nudge: W,
1062
+ onExpand: () => x("notebook")
1063
+ }
1064
+ ),
1065
+ /* @__PURE__ */ e("div", { className: "dc:h-full dc:overflow-hidden dc:flex-1", children: Z })
1066
+ ] }) : /* @__PURE__ */ u(ne, { children: [
1067
+ /* @__PURE__ */ e("div", { className: "dc:h-full dc:overflow-hidden dc:flex-1", children: /* @__PURE__ */ e(ue, {}) }),
1068
+ /* @__PURE__ */ e(ht, { onExpand: () => x("chat") })
1069
+ ] })
1070
+ }
1071
+ ) : /* @__PURE__ */ u(
899
1072
  "div",
900
1073
  {
901
- ref: N,
902
- className: `dc:flex dc:h-full dc:w-full dc:overflow-hidden bg-dc-surface-secondary ${p || ""}`,
1074
+ ref: J,
1075
+ className: `dc:flex dc:h-full dc:w-full dc:overflow-hidden bg-dc-surface-secondary ${w || ""}`,
903
1076
  children: [
904
- /* @__PURE__ */ s(
1077
+ /* @__PURE__ */ e(
905
1078
  "div",
906
1079
  {
907
1080
  className: "dc:h-full dc:overflow-hidden",
908
- style: { width: `${w}%` },
909
- children: /* @__PURE__ */ s(Ve, {})
1081
+ style: { width: `${v}%` },
1082
+ children: /* @__PURE__ */ e(ue, {})
910
1083
  }
911
1084
  ),
912
- /* @__PURE__ */ s(
1085
+ /* @__PURE__ */ e(
913
1086
  "div",
914
1087
  {
915
1088
  className: "dc:w-1 dc:h-full dc:cursor-col-resize dc:flex-shrink-0 dc:transition-colors bg-dc-border dc:hover:bg-dc-accent",
916
- onMouseDown: C
1089
+ onMouseDown: te
917
1090
  }
918
1091
  ),
919
- /* @__PURE__ */ s(
1092
+ /* @__PURE__ */ e(
920
1093
  "div",
921
1094
  {
922
1095
  className: "dc:h-full dc:overflow-hidden",
923
- style: { width: `${100 - w}%` },
924
- children: /* @__PURE__ */ s(
925
- He,
926
- {
927
- agentEndpoint: e,
928
- agentApiKey: t,
929
- onClear: I,
930
- onDashboardSaved: c,
931
- onScore: a,
932
- loadingComponent: o,
933
- initialPrompt: u
934
- }
935
- )
1096
+ style: { width: `${100 - v}%` },
1097
+ children: Z
936
1098
  }
937
1099
  )
938
1100
  ]
939
1101
  }
940
1102
  );
941
1103
  }
942
- const mt = V.memo(function({
943
- config: t,
944
- ...r
1104
+ const It = Y.memo(function({
1105
+ config: s,
1106
+ ...c
945
1107
  }) {
946
- return /* @__PURE__ */ s(De, { initialConfig: t, children: /* @__PURE__ */ s(Xe, { ...r }) });
1108
+ return /* @__PURE__ */ e(Qe, { initialConfig: s, children: /* @__PURE__ */ e(ft, { ...c }) });
947
1109
  });
948
- function pt() {
949
- return /* @__PURE__ */ s("div", { children: "Analytics Page - Coming in Phase 4" });
1110
+ function Mt() {
1111
+ return /* @__PURE__ */ e("div", { children: "Analytics Page - Coming in Phase 4" });
950
1112
  }
951
- const Ze = j("segment");
952
- function ht({
953
- className: e = ""
1113
+ const pt = B("segment");
1114
+ function Et({
1115
+ className: t = ""
954
1116
  }) {
955
- return /* @__PURE__ */ s(
1117
+ return /* @__PURE__ */ e(
956
1118
  "div",
957
1119
  {
958
- className: `dc:flex dc:items-center dc:justify-center bg-dc-bg-secondary ${e}`,
959
- children: /* @__PURE__ */ f("div", { className: "dc:text-center", children: [
960
- /* @__PURE__ */ s(
961
- Ze,
1120
+ className: `dc:flex dc:items-center dc:justify-center bg-dc-bg-secondary ${t}`,
1121
+ children: /* @__PURE__ */ u("div", { className: "dc:text-center", children: [
1122
+ /* @__PURE__ */ e(
1123
+ pt,
962
1124
  {
963
1125
  className: "dc:w-8 dc:h-8 dc:mx-auto dc:mb-2 text-dc-text-muted dc:opacity-50"
964
1126
  }
965
1127
  ),
966
- /* @__PURE__ */ s("span", { className: "dc:text-xs text-dc-text-muted", children: "No preview" })
1128
+ /* @__PURE__ */ e("span", { className: "dc:text-xs text-dc-text-muted", children: "No preview" })
967
1129
  ] })
968
1130
  }
969
1131
  );
970
1132
  }
971
1133
  export {
972
- mt as AgenticNotebook,
973
- bt as AnalysisBuilder,
974
- yt as AnalyticsDashboard,
975
- pt as AnalyticsPage,
976
- pe as AnalyticsPortlet,
977
- xt as ChartErrorBoundary,
978
- vt as ConfirmModal,
979
- ks as CubeClient,
980
- ws as CubeProvider,
981
- ms as DEFAULT_ICONS,
982
- Ct as DashboardEditModal,
983
- Nt as DashboardGrid,
984
- kt as DashboardStoreProvider,
985
- ht as DashboardThumbnailPlaceholder,
986
- wt as DrillBreadcrumb,
987
- St as DrillMenu,
988
- zs as ExecutionPlanPanel,
989
- Ws as ExplainAIPanel,
990
- _s as LazyChart,
991
- we as LoadingIndicator,
992
- Tt as Modal,
993
- De as NotebookStoreProvider,
994
- fe as PortletAnalysisModal,
995
- Dt as PortletContainer,
996
- Ss as ScrollContainerProvider,
997
- ec as THEME_PRESETS,
998
- tc as applyTheme,
999
- zr as buildFunnelConfigFromQueries,
1000
- Wr as buildServerFunnelQuery,
1001
- Ts as captureThumbnail,
1002
- Js as compressAndEncode,
1003
- Ds as createCubeClient,
1004
- Tr as createDashboardLayout,
1005
- At as createDashboardStore,
1006
- Mt as createDefaultConfig,
1007
- It as createDefaultFlowConfig,
1008
- Et as createDefaultFunnelConfig,
1009
- Rt as createDefaultQueryConfig,
1010
- Bt as createDefaultRetentionConfig,
1011
- Lt as createDefaultWorkspace,
1012
- lc as createExplainQueryKey,
1013
- Mr as createFlowQueryKey,
1014
- Ir as createFunnelQueryKey,
1015
- Te as createNotebookStore,
1016
- Gs as decodeAndDecompress,
1017
- Hs as detectAsymmetricDateRanges,
1018
- Ys as detectMeasureCollisions,
1019
- Dr as formatChartData,
1020
- Jr as formatDuration,
1021
- Er as generateQueryLabel,
1022
- Xs as generateShareUrl,
1023
- Zs as getAvailableBindingKeyDimensions,
1024
- Vs as getAvailableChartTypes,
1025
- Gr as getBindingKeyField,
1026
- er as getBindingKeyLabel,
1027
- ps as getChartTypeIcon,
1028
- Rr as getCombinedFields,
1029
- Hr as getCubeNameFromQuery,
1030
- hs as getFieldTypeIcon,
1031
- j as getIcon,
1032
- fs as getIconData,
1033
- gs as getIconRegistry,
1034
- bs as getIconsByCategory,
1035
- ys as getMeasureTypeIcon,
1036
- Br as getQueryIndices,
1037
- Lr as getQueryLabels,
1038
- sc as getTheme,
1039
- rc as getThemeVariable,
1040
- js as getUnavailableChartTypes,
1041
- tr as getValidationSummary,
1042
- vc as highlightCodeBlocks,
1043
- Us as isChartTypeAvailable,
1044
- cc as isDarkMode,
1045
- Pt as isFlowConfig,
1046
- Qt as isFunnelConfig,
1047
- Yr as isFunnelData,
1048
- sr as isMinimumFunnelConfigValid,
1049
- Ft as isMultiQuery,
1050
- _t as isMultiQueryConfig,
1051
- Pr as isMultiQueryData,
1052
- rr as isMultiQueryValid,
1053
- Vt as isQueryConfig,
1054
- jt as isRetentionConfig,
1055
- bc as isSankeyData,
1056
- yc as isServerFlowQuery,
1057
- Ut as isServerFunnelQuery,
1058
- cr as isShareableSize,
1059
- qt as isSingleQuery,
1060
- As as isThumbnailCaptureAvailable,
1061
- Kt as isValidAnalysisConfig,
1062
- Ot as isValidAnalysisWorkspace,
1063
- qs as isValidChartType,
1064
- Qr as mergeQueryResults,
1065
- Fr as mergeResultsByKey,
1066
- _r as mergeResultsConcat,
1067
- $t as migrateConfig,
1068
- zt as migrateLegacyPortlet,
1069
- ar as parseShareUrl,
1070
- Ks as preloadChart,
1071
- Os as preloadCharts,
1072
- xs as registerIcons,
1073
- vs as resetIcons,
1074
- ac as resetTheme,
1075
- Wt as selectAllActions,
1076
- Ee as selectBlockActions,
1077
- Ae as selectBlocks,
1078
- nr as selectBreakdowns,
1079
- or as selectChartConfig,
1080
- Ie as selectChatActions,
1081
- Me as selectChatState,
1082
- dr as selectCurrentState,
1083
- Jt as selectDebugData,
1084
- Gt as selectDebugDataActions,
1085
- Ht as selectEditModeActions,
1086
- Yt as selectEditModeState,
1087
- ir as selectFilters,
1088
- lr as selectFunnelState,
1089
- ut as selectInputValue,
1090
- it as selectIsStreaming,
1091
- Xt as selectLayoutActions,
1092
- Zt as selectLayoutState,
1093
- dt as selectMessages,
1094
- ur as selectMetrics,
1095
- es as selectModalActions,
1096
- ts as selectModalState,
1097
- mr as selectMultiQueryState,
1098
- ss as selectPortletDebugData,
1099
- lt as selectSessionId,
1100
- rs as selectThumbnailDirty,
1101
- pr as selectUIState,
1102
- Cs as setIcon,
1103
- nc as setTheme,
1104
- oc as setThemeVariable,
1105
- Xr as transformServerFunnelResult,
1106
- Ue as useAgentChat,
1107
- hr as useAnalysisBuilder,
1108
- fr as useAnalysisBuilderStore,
1109
- ke as useCubeApi,
1110
- Ms as useCubeContext,
1111
- Is as useCubeFeatures,
1112
- Qs as useCubeFieldLabel,
1113
- Vr as useCubeLoadQuery,
1114
- Es as useCubeMeta,
1115
- Rs as useCubeMetaQuery,
1116
- jr as useCubeQuery,
1117
- cs as useDashboard,
1118
- as as useDashboardStore,
1119
- ns as useDashboardStoreApi,
1120
- os as useDashboardStoreOptional,
1121
- ds as useDrillInteraction,
1122
- uc as useDryRunQueries,
1123
- mc as useDryRunQuery,
1124
- is as useElementVisibility,
1125
- pc as useExplainAI,
1126
- hc as useExplainQuery,
1127
- Ur as useFlowQuery,
1128
- qr as useFunnelQuery,
1129
- Kr as useMultiCubeLoadQuery,
1130
- fc as useMultiDryRunQueries,
1131
- A as useNotebookStore,
1132
- Bs as useScrollContainer,
1133
- ls as useScrollDetection,
1134
- wr as useTheme,
1135
- gr as validateBindingKeyExists,
1136
- br as validateBindingKeyForSteps,
1137
- yr as validateFunnelConfig,
1138
- Or as validateMergeKey,
1139
- xr as validateMergeKeys,
1140
- vr as validateMultiQueryConfig,
1141
- Cr as validateStepQueries,
1142
- Nr as validateTimeDimensionAlignment,
1143
- Ls as warnIfScreenshotLibMissing,
1144
- dc as watchThemeChanges
1134
+ It as AgenticNotebook,
1135
+ Lt as AnalysisBuilder,
1136
+ Pt as AnalyticsDashboard,
1137
+ Mt as AnalyticsPage,
1138
+ Ce as AnalyticsPortlet,
1139
+ Qt as ChartErrorBoundary,
1140
+ Ft as ConfirmModal,
1141
+ Vs as CubeClient,
1142
+ js as CubeProvider,
1143
+ Is as DEFAULT_ICONS,
1144
+ _t as DashboardEditModal,
1145
+ Vt as DashboardGrid,
1146
+ jt as DashboardStoreProvider,
1147
+ Et as DashboardThumbnailPlaceholder,
1148
+ Ut as DrillBreadcrumb,
1149
+ Ot as DrillMenu,
1150
+ dc as ExecutionPlanPanel,
1151
+ lc as ExplainAIPanel,
1152
+ ec as LazyChart,
1153
+ me as LoadingIndicator,
1154
+ $t as Modal,
1155
+ Qe as NotebookStoreProvider,
1156
+ Ne as PortletAnalysisModal,
1157
+ qt as PortletContainer,
1158
+ Us as ScrollContainerProvider,
1159
+ gr as THEME_PRESETS,
1160
+ br as applyTheme,
1161
+ dr as buildFunnelConfigFromQueries,
1162
+ lr as buildServerFunnelQuery,
1163
+ Os as captureThumbnail,
1164
+ ic as compressAndEncode,
1165
+ $s as createCubeClient,
1166
+ Oc as createDashboardLayout,
1167
+ Kt as createDashboardStore,
1168
+ zt as createDefaultConfig,
1169
+ Wt as createDefaultFlowConfig,
1170
+ Jt as createDefaultFunnelConfig,
1171
+ Xt as createDefaultQueryConfig,
1172
+ Yt as createDefaultRetentionConfig,
1173
+ Gt as createDefaultWorkspace,
1174
+ Tr as createExplainQueryKey,
1175
+ Kc as createFlowQueryKey,
1176
+ zc as createFunnelQueryKey,
1177
+ Pe as createNotebookStore,
1178
+ uc as decodeAndDecompress,
1179
+ mc as detectAsymmetricDateRanges,
1180
+ hc as detectMeasureCollisions,
1181
+ $c as formatChartData,
1182
+ ir as formatDuration,
1183
+ Wc as generateQueryLabel,
1184
+ fc as generateShareUrl,
1185
+ pc as getAvailableBindingKeyDimensions,
1186
+ tc as getAvailableChartTypes,
1187
+ ur as getBindingKeyField,
1188
+ gc as getBindingKeyLabel,
1189
+ Me as getChartTypeIcon,
1190
+ Jc as getCombinedFields,
1191
+ mr as getCubeNameFromQuery,
1192
+ Ms as getFieldTypeIcon,
1193
+ B as getIcon,
1194
+ Es as getIconData,
1195
+ Rs as getIconRegistry,
1196
+ Bs as getIconsByCategory,
1197
+ Ls as getMeasureTypeIcon,
1198
+ Xc as getQueryIndices,
1199
+ Yc as getQueryLabels,
1200
+ xr as getTheme,
1201
+ yr as getThemeVariable,
1202
+ sc as getUnavailableChartTypes,
1203
+ bc as getValidationSummary,
1204
+ Qr as highlightCodeBlocks,
1205
+ cc as isChartTypeAvailable,
1206
+ vr as isDarkMode,
1207
+ Ht as isFlowConfig,
1208
+ Zt as isFunnelConfig,
1209
+ hr as isFunnelData,
1210
+ xc as isMinimumFunnelConfigValid,
1211
+ es as isMultiQuery,
1212
+ ts as isMultiQueryConfig,
1213
+ Gc as isMultiQueryData,
1214
+ yc as isMultiQueryValid,
1215
+ ss as isQueryConfig,
1216
+ cs as isRetentionConfig,
1217
+ Br as isSankeyData,
1218
+ Lr as isServerFlowQuery,
1219
+ rs as isServerFunnelQuery,
1220
+ vc as isShareableSize,
1221
+ ns as isSingleQuery,
1222
+ qs as isThumbnailCaptureAvailable,
1223
+ as as isValidAnalysisConfig,
1224
+ os as isValidAnalysisWorkspace,
1225
+ rc as isValidChartType,
1226
+ Hc as mergeQueryResults,
1227
+ Zc as mergeResultsByKey,
1228
+ er as mergeResultsConcat,
1229
+ ds as migrateConfig,
1230
+ ls as migrateLegacyPortlet,
1231
+ Cc as parseShareUrl,
1232
+ nc as preloadChart,
1233
+ ac as preloadCharts,
1234
+ Ps as registerIcons,
1235
+ Qs as resetIcons,
1236
+ Cr as resetTheme,
1237
+ is as selectAllActions,
1238
+ je as selectBlockActions,
1239
+ Fe as selectBlocks,
1240
+ wc as selectBreakdowns,
1241
+ Nc as selectChartConfig,
1242
+ Ve as selectChatActions,
1243
+ _e as selectChatState,
1244
+ kc as selectCurrentState,
1245
+ us as selectDebugData,
1246
+ ms as selectDebugDataActions,
1247
+ hs as selectEditModeActions,
1248
+ fs as selectEditModeState,
1249
+ Sc as selectFilters,
1250
+ Tc as selectFunnelState,
1251
+ At as selectInputValue,
1252
+ Tt as selectIsStreaming,
1253
+ ps as selectLayoutActions,
1254
+ gs as selectLayoutState,
1255
+ St as selectMessages,
1256
+ Dc as selectMetrics,
1257
+ bs as selectModalActions,
1258
+ xs as selectModalState,
1259
+ Ac as selectMultiQueryState,
1260
+ ys as selectPortletDebugData,
1261
+ Dt as selectSessionId,
1262
+ vs as selectThumbnailDirty,
1263
+ Ic as selectUIState,
1264
+ Fs as setIcon,
1265
+ wr as setTheme,
1266
+ Nr as setThemeVariable,
1267
+ fr as transformServerFunnelResult,
1268
+ et as useAgentChat,
1269
+ Mc as useAnalysisBuilder,
1270
+ Ec as useAnalysisBuilderStore,
1271
+ Re as useCubeApi,
1272
+ Ks as useCubeContext,
1273
+ zs as useCubeFeatures,
1274
+ Hs as useCubeFieldLabel,
1275
+ tr as useCubeLoadQuery,
1276
+ Ws as useCubeMeta,
1277
+ Js as useCubeMetaQuery,
1278
+ sr as useCubeQuery,
1279
+ Cs as useDashboard,
1280
+ ws as useDashboardStore,
1281
+ Ns as useDashboardStoreApi,
1282
+ ks as useDashboardStoreOptional,
1283
+ Ss as useDrillInteraction,
1284
+ Dr as useDryRunQueries,
1285
+ Ar as useDryRunQuery,
1286
+ Ts as useElementVisibility,
1287
+ Ir as useExplainAI,
1288
+ Mr as useExplainQuery,
1289
+ cr as useFlowQuery,
1290
+ rr as useFunnelQuery,
1291
+ nr as useMultiCubeLoadQuery,
1292
+ Er as useMultiDryRunQueries,
1293
+ P as useNotebookStore,
1294
+ Xs as useScrollContainer,
1295
+ Ds as useScrollDetection,
1296
+ jc as useTheme,
1297
+ Rc as validateBindingKeyExists,
1298
+ Bc as validateBindingKeyForSteps,
1299
+ Lc as validateFunnelConfig,
1300
+ ar as validateMergeKey,
1301
+ Pc as validateMergeKeys,
1302
+ Qc as validateMultiQueryConfig,
1303
+ Fc as validateStepQueries,
1304
+ _c as validateTimeDimensionAlignment,
1305
+ Ys as warnIfScreenshotLibMissing,
1306
+ kr as watchThemeChanges
1145
1307
  };
1146
1308
  //# sourceMappingURL=index.js.map