drizzle-cube 0.4.10 → 0.4.11

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.
@@ -1,25 +1,25 @@
1
1
  import { D as J, A as H, e as G, P as X } from "./chunks/components-ClQziOcT.js";
2
- import { i as Je, a as He, C as Ge, h as Xe, g as Ye, b as Ze, j as et, f as tt, d as st, M as at, c as ct, n as ot, T as rt, R as nt, Q as dt, O as it, S as lt, V as ut, I as mt, H as pt, K as ht, W as ft, G as gt, J as bt, X as yt, L as xt, N as Ct, U as vt, Y as kt, Z as Nt, z as wt, q as St, x as Dt, t as Mt, s as At, w as Tt, p as It, v as Et, o as Bt, r as Rt, y as Lt, u as Qt, k as Ft, l as Pt, m as Vt, F as _t, E as jt, B as Kt } from "./chunks/components-ClQziOcT.js";
3
- import { jsx as a, jsxs as y, Fragment as Y } from "react/jsx-runtime";
4
- import L, { useRef as N, createContext as Z, useContext as ee, useState as F, useCallback as p, useEffect as Q } from "react";
5
- import { c as te, d as se, e as ae, s as ce, f as K } from "./chunks/vendor-AVsJ2ni0.js";
6
- import { a as P } from "./chunks/icons-DAeqv1iX.js";
7
- import { D as Ot, h as qt, i as $t, b as zt, e as Wt, f as Jt, g as Ht, r as Gt, c as Xt, s as Yt } from "./chunks/icons-DAeqv1iX.js";
8
- import { Q as oe } from "./chunks/chart-markdown-Du4Z2iqK.js";
9
- import { f as re } from "./chunks/providers-CgxXm6Ll.js";
10
- import { h as es, a as ts, S as ss, e as as, d as cs, i as os, b as rs, g as ns, u as ds, j as is, c as ls, w as us } from "./chunks/providers-CgxXm6Ll.js";
11
- import { L as ps, u as hs } from "./chunks/charts-core-DmGfleFz.js";
12
- import { L as gs, g as bs, c as ys, b as xs, i as Cs, p as vs, a as ks } from "./chunks/charts-loader-CH0_S06T.js";
13
- import { E as ws, a as Ss, p as Ds, q as Ms, m as As, l as Ts, r as Is, C as Es, D as Bs, o as Rs, B as Ls, n as Qs, w as Fs, t as Ps, d as Vs, f as _s, s as js, e as Ks, i as Us, c as Os, h as qs, g as $s, u as zs, b as Ws, y as Js, A as Hs, x as Gs, k as Xs, v as Ys, z as Zs, j as ea } from "./chunks/analysis-builder-shared-D56zYeV0.js";
14
- import { u as sa } from "./chunks/chart-bubble-Bf42A1-B.js";
2
+ import { i as He, a as Ge, C as Xe, h as Ye, g as Ze, b as et, j as tt, f as st, d as at, M as rt, c as ct, n as ot, T as nt, R as dt, Q as it, O as lt, S as ut, V as mt, I as pt, H as ht, K as ft, W as gt, G as bt, J as yt, X as xt, L as vt, N as Ct, U as kt, Y as Nt, Z as wt, z as St, q as At, x as Dt, t as Tt, s as Mt, w as It, p as Et, v as Bt, o as Lt, r as Rt, y as Pt, u as Qt, k as Ft, l as _t, m as Vt, F as jt, E as qt, B as Ut } from "./chunks/components-ClQziOcT.js";
3
+ import { jsx as a, jsxs as b, Fragment as Y } from "react/jsx-runtime";
4
+ import R, { useRef as N, createContext as Z, useContext as ee, useState as F, useCallback as p, useEffect as Q } from "react";
5
+ import { c as te, d as se, e as ae, s as re, f as K } from "./chunks/vendor-AVsJ2ni0.js";
6
+ import { a as _ } from "./chunks/icons-DAeqv1iX.js";
7
+ import { D as Ot, h as $t, i as zt, b as Wt, e as Jt, f as Ht, g as Gt, r as Xt, c as Yt, s as Zt } from "./chunks/icons-DAeqv1iX.js";
8
+ import { Q as ce } from "./chunks/chart-markdown-Du4Z2iqK.js";
9
+ import { f as oe } from "./chunks/providers-CgxXm6Ll.js";
10
+ import { h as ts, a as ss, S as as, e as rs, d as cs, i as os, b as ns, g as ds, u as is, j as ls, c as us, w as ms } from "./chunks/providers-CgxXm6Ll.js";
11
+ import { L as hs, u as fs } from "./chunks/charts-core-DmGfleFz.js";
12
+ import { L as bs, g as ys, c as xs, b as vs, i as Cs, p as ks, a as Ns } from "./chunks/charts-loader-CH0_S06T.js";
13
+ import { E as Ss, a as As, p as Ds, q as Ts, m as Ms, l as Is, r as Es, C as Bs, D as Ls, o as Rs, B as Ps, n as Qs, w as Fs, t as _s, d as Vs, f as js, s as qs, e as Us, i as Ks, c as Os, h as $s, g as zs, u as Ws, b as Js, y as Hs, A as Gs, x as Xs, k as Ys, v as Zs, z as ea, j as ta } from "./chunks/analysis-builder-shared-D56zYeV0.js";
14
+ import { u as aa } from "./chunks/chart-bubble-Bf42A1-B.js";
15
15
  import { c as ca, f as oa } from "./chunks/index-CApFCBF9.js";
16
- import { e as na, c as da, l as ia, h as la, k as ua, j as ma, i as pa, m as ha, g as fa, f as ga, u as ba, u as ya, d as xa, b as Ca, a as va, v as ka } from "./chunks/useDirtyStateTracking-Cu1HSjmo.js";
17
- import { c as wa, b as Sa, f as Da, g as Ma, a as Aa, i as Ta, t as Ia } from "./chunks/funnel-utils-CyonoNeC.js";
18
- import { T as Ba, c as Ra, g as La, a as Qa, i as Fa, r as Pa, s as Va, b as _a, w as ja } from "./chunks/theme-Dp3hFed1.js";
19
- import { createExplainQueryKey as Ua, useDryRunQueries as Oa, useDryRunQuery as qa, useExplainAI as $a, useExplainQuery as za, useMultiDryRunQueries as Wa } from "./hooks.js";
20
- import { i as Ha, a as Ga } from "./chunks/flow-utils-CjQZG5qq.js";
21
- import { h as Ya } from "./chunks/syntaxHighlighting-BQfjio-i.js";
22
- const O = () => ({
16
+ import { e as da, c as ia, l as la, h as ua, k as ma, j as pa, i as ha, m as fa, g as ga, f as ba, u as ya, u as xa, d as va, b as Ca, a as ka, v as Na } from "./chunks/useDirtyStateTracking-Cu1HSjmo.js";
17
+ import { c as Sa, b as Aa, f as Da, g as Ta, a as Ma, i as Ia, t as Ea } from "./chunks/funnel-utils-CyonoNeC.js";
18
+ import { T as La, c as Ra, g as Pa, a as Qa, i as Fa, r as _a, s as Va, b as ja, w as qa } from "./chunks/theme-Dp3hFed1.js";
19
+ import { createExplainQueryKey as Ka, useDryRunQueries as Oa, useDryRunQuery as $a, useExplainAI as za, useExplainQuery as Wa, useMultiDryRunQueries as Ja } from "./hooks.js";
20
+ import { i as Ga, a as Xa } from "./chunks/flow-utils-CjQZG5qq.js";
21
+ import { h as Za } from "./chunks/syntaxHighlighting-BQfjio-i.js";
22
+ const $ = () => ({
23
23
  blocks: [],
24
24
  messages: [],
25
25
  isStreaming: !1,
@@ -36,12 +36,12 @@ function ne(e, t) {
36
36
  blocks: c.blocks.filter((r) => r.id !== s)
37
37
  })),
38
38
  moveBlock: (s, c) => e((r) => {
39
- const o = r.blocks.findIndex((d) => d.id === s);
39
+ const o = r.blocks.findIndex((i) => i.id === s);
40
40
  if (o === -1) return {};
41
41
  if (c === "up" && o === 0) return {};
42
42
  if (c === "down" && o === r.blocks.length - 1) return {};
43
- const n = [...r.blocks], u = c === "up" ? o - 1 : o + 1;
44
- return [n[o], n[u]] = [n[u], n[o]], { blocks: n };
43
+ const n = [...r.blocks], l = c === "up" ? o - 1 : o + 1;
44
+ return [n[o], n[l]] = [n[l], n[o]], { blocks: n };
45
45
  }),
46
46
  updateBlock: (s, c) => e((r) => ({
47
47
  blocks: r.blocks.map(
@@ -59,6 +59,10 @@ function ne(e, t) {
59
59
  content: o.content + s
60
60
  }), { messages: r };
61
61
  }),
62
+ setLastAssistantError: (s) => e((c) => {
63
+ const r = [...c.messages], o = r[r.length - 1];
64
+ return o && o.role === "assistant" && (r[r.length - 1] = { ...o, error: s }), { messages: r };
65
+ }),
62
66
  addToolCallToLastAssistant: (s) => e((c) => {
63
67
  const r = [...c.messages], o = r[r.length - 1];
64
68
  return o && o.role === "assistant" && (r[r.length - 1] = {
@@ -69,8 +73,8 @@ function ne(e, t) {
69
73
  updateLastToolCall: (s) => e((c) => {
70
74
  const r = [...c.messages], o = r[r.length - 1];
71
75
  if (o?.role === "assistant" && o.toolCalls?.length) {
72
- const n = [...o.toolCalls], u = s.id ? n.findIndex((d) => d.id === s.id) : n.length - 1;
73
- u !== -1 && (n[u] = { ...n[u], ...s }, r[r.length - 1] = { ...o, toolCalls: n });
76
+ const n = [...o.toolCalls], l = s.id ? n.findIndex((i) => i.id === s.id) : n.length - 1;
77
+ l !== -1 && (n[l] = { ...n[l], ...s }, r[r.length - 1] = { ...o, toolCalls: n });
74
78
  }
75
79
  return { messages: r };
76
80
  }),
@@ -91,14 +95,14 @@ function ne(e, t) {
91
95
  messages: s.messages || []
92
96
  }),
93
97
  // Reset
94
- reset: () => e(O())
98
+ reset: () => e($())
95
99
  };
96
100
  }
97
101
  function de() {
98
- const e = O();
102
+ const e = $();
99
103
  return se()(
100
104
  ae(
101
- ce((t, s) => ({
105
+ re((t, s) => ({
102
106
  ...e,
103
107
  ...ne(t, s)
104
108
  })),
@@ -106,7 +110,7 @@ function de() {
106
110
  )
107
111
  );
108
112
  }
109
- const q = Z(null);
113
+ const z = Z(null);
110
114
  function ie({
111
115
  children: e,
112
116
  initialConfig: t
@@ -116,21 +120,22 @@ function ie({
116
120
  const c = de();
117
121
  t && c.getState().load(t), s.current = c;
118
122
  }
119
- return /* @__PURE__ */ a(q.Provider, { value: s.current, children: e });
123
+ return /* @__PURE__ */ a(z.Provider, { value: s.current, children: e });
120
124
  }
121
- function D(e) {
122
- const t = ee(q);
125
+ function A(e) {
126
+ const t = ee(z);
123
127
  if (!t)
124
128
  throw new Error("useNotebookStore must be used within NotebookStoreProvider");
125
129
  return te(t, e);
126
130
  }
127
- const le = (e) => e.blocks, _e = (e) => e.messages, je = (e) => e.isStreaming, Ke = (e) => e.sessionId, Ue = (e) => e.inputValue, ue = (e) => ({
131
+ const le = (e) => e.blocks, je = (e) => e.messages, qe = (e) => e.isStreaming, Ue = (e) => e.sessionId, Ke = (e) => e.inputValue, ue = (e) => ({
128
132
  messages: e.messages,
129
133
  isStreaming: e.isStreaming,
130
134
  inputValue: e.inputValue
131
135
  }), me = (e) => ({
132
136
  addMessage: e.addMessage,
133
137
  appendToLastAssistantMessage: e.appendToLastAssistantMessage,
138
+ setLastAssistantError: e.setLastAssistantError,
134
139
  addToolCallToLastAssistant: e.addToolCallToLastAssistant,
135
140
  updateLastToolCall: e.updateLastToolCall,
136
141
  setIsStreaming: e.setIsStreaming,
@@ -141,35 +146,35 @@ const le = (e) => e.blocks, _e = (e) => e.messages, je = (e) => e.isStreaming, K
141
146
  removeBlock: e.removeBlock,
142
147
  moveBlock: e.moveBlock,
143
148
  updateBlock: e.updateBlock
144
- }), V = { width: "16px", height: "16px", color: "currentColor" }, he = P("chevronUp"), fe = P("chevronDown"), ge = P("edit"), be = P("delete"), ye = L.memo(function({
149
+ }), V = { width: "16px", height: "16px", color: "currentColor" }, he = _("chevronUp"), fe = _("chevronDown"), ge = _("edit"), be = _("delete"), ye = R.memo(function({
145
150
  block: t,
146
151
  onRemove: s,
147
152
  onMoveUp: c,
148
153
  onMoveDown: r,
149
154
  onEdit: o,
150
155
  isFirst: n,
151
- isLast: u
156
+ isLast: l
152
157
  }) {
153
- const [d, g] = F(null), h = p((x) => {
154
- g(x);
158
+ const [i, f] = F(null), g = p((x) => {
159
+ f(x);
155
160
  }, []);
156
- return /* @__PURE__ */ y("div", { className: "dc:relative dc:mb-4 bg-dc-surface dc:border border-dc-border dc:rounded-lg dc:flex dc:flex-col", children: [
157
- /* @__PURE__ */ y("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: [
158
- /* @__PURE__ */ y("div", { className: "dc:flex dc:items-center dc:gap-2 dc:flex-1 dc:min-w-0", children: [
161
+ return /* @__PURE__ */ b("div", { className: "dc:relative dc:mb-4 bg-dc-surface dc:border border-dc-border dc:rounded-lg dc:flex dc:flex-col", children: [
162
+ /* @__PURE__ */ b("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: [
163
+ /* @__PURE__ */ b("div", { className: "dc:flex dc:items-center dc:gap-2 dc:flex-1 dc:min-w-0", children: [
159
164
  /* @__PURE__ */ a("h3", { className: "dc:font-semibold dc:text-sm text-dc-text dc:truncate", children: t.title || "Untitled" }),
160
- d && /* @__PURE__ */ a(
165
+ i && /* @__PURE__ */ a(
161
166
  J,
162
167
  {
163
- chartConfig: d.chartConfig,
164
- displayConfig: d.displayConfig,
165
- queryObject: d.queryObject,
166
- data: d.data,
167
- chartType: d.chartType,
168
- cacheInfo: d.cacheInfo ?? void 0
168
+ chartConfig: i.chartConfig,
169
+ displayConfig: i.displayConfig,
170
+ queryObject: i.queryObject,
171
+ data: i.data,
172
+ chartType: i.chartType,
173
+ cacheInfo: i.cacheInfo ?? void 0
169
174
  }
170
175
  )
171
176
  ] }),
172
- /* @__PURE__ */ y("div", { className: "dc:flex dc:items-center dc:gap-1 dc:shrink-0 dc:ml-4 dc:-mr-2", children: [
177
+ /* @__PURE__ */ b("div", { className: "dc:flex dc:items-center dc:gap-1 dc:shrink-0 dc:ml-4 dc:-mr-2", children: [
173
178
  !n && /* @__PURE__ */ a(
174
179
  "button",
175
180
  {
@@ -179,7 +184,7 @@ const le = (e) => e.blocks, _e = (e) => e.messages, je = (e) => e.isStreaming, K
179
184
  children: /* @__PURE__ */ a(he, { style: V })
180
185
  }
181
186
  ),
182
- !u && /* @__PURE__ */ a(
187
+ !l && /* @__PURE__ */ a(
183
188
  "button",
184
189
  {
185
190
  onClick: () => r(t.id),
@@ -217,7 +222,7 @@ const le = (e) => e.blocks, _e = (e) => e.messages, je = (e) => e.isStreaming, K
217
222
  displayConfig: t.displayConfig,
218
223
  height: 400,
219
224
  eagerLoad: !0,
220
- onDebugDataReady: h
225
+ onDebugDataReady: g
221
226
  }
222
227
  ) })
223
228
  ] });
@@ -242,7 +247,7 @@ const le = (e) => e.blocks, _e = (e) => e.messages, je = (e) => e.isStreaming, K
242
247
  td: { props: { className: "dc:px-3 dc:py-2 dc:text-sm text-dc-text border-dc-border dc:border-b" } },
243
248
  tr: { props: { className: "dc:hover:opacity-80" } }
244
249
  }
245
- }, Ce = L.memo(function({
250
+ }, ve = R.memo(function({
246
251
  block: t,
247
252
  onRemove: s,
248
253
  onMoveUp: c,
@@ -250,8 +255,8 @@ const le = (e) => e.blocks, _e = (e) => e.messages, je = (e) => e.isStreaming, K
250
255
  isFirst: o,
251
256
  isLast: n
252
257
  }) {
253
- return /* @__PURE__ */ y("div", { className: "dc:group dc:relative dc:mb-4", children: [
254
- /* @__PURE__ */ y("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: [
258
+ return /* @__PURE__ */ b("div", { className: "dc:group dc:relative dc:mb-4", children: [
259
+ /* @__PURE__ */ b("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: [
255
260
  !o && /* @__PURE__ */ a(
256
261
  "button",
257
262
  {
@@ -281,57 +286,57 @@ const le = (e) => e.blocks, _e = (e) => e.messages, je = (e) => e.isStreaming, K
281
286
  )
282
287
  ] }),
283
288
  t.title && /* @__PURE__ */ a("h4", { className: "dc:text-sm dc:font-semibold text-dc-text dc:mb-2 dc:px-1", children: t.title }),
284
- /* @__PURE__ */ a("div", { className: "dc:rounded-lg dc:p-4 bg-dc-surface border-dc-border dc:border", children: /* @__PURE__ */ a(oe, { options: xe, children: t.content }) })
289
+ /* @__PURE__ */ a("div", { className: "dc:rounded-lg dc:p-4 bg-dc-surface border-dc-border dc:border", children: /* @__PURE__ */ a(ce, { options: xe, children: t.content }) })
285
290
  ] });
286
- }), ve = L.memo(function() {
287
- const t = D(le), { removeBlock: s, moveBlock: c, updateBlock: r } = D(K(pe)), o = N(null), [n, u] = F(null), d = N(t.length);
291
+ }), Ce = R.memo(function() {
292
+ const t = A(le), { removeBlock: s, moveBlock: c, updateBlock: r } = A(K(pe)), o = N(null), [n, l] = F(null), i = N(t.length);
288
293
  Q(() => {
289
- t.length > d.current && o.current?.scrollIntoView({ behavior: "smooth" }), d.current = t.length;
294
+ t.length > i.current && o.current?.scrollIntoView({ behavior: "smooth" }), i.current = t.length;
290
295
  }, [t.length]);
291
- const g = p((i) => s(i), [s]), h = p((i) => c(i, "up"), [c]), x = p((i) => c(i, "down"), [c]), m = p((i) => u(i), []), b = p((i) => {
296
+ const f = p((d) => s(d), [s]), g = p((d) => c(d, "up"), [c]), x = p((d) => c(d, "down"), [c]), m = p((d) => l(d), []), C = p((d) => {
292
297
  if (!n) return;
293
- const w = G(i), { analysisConfig: k } = w;
298
+ const v = G(d), { analysisConfig: k } = v;
294
299
  if (k) {
295
- const v = k.charts[k.analysisType];
300
+ const w = k.charts[k.analysisType];
296
301
  r(n.id, {
297
- title: i.title,
302
+ title: d.title,
298
303
  query: JSON.stringify(k.query),
299
- chartType: v?.chartType || "bar",
300
- chartConfig: v?.chartConfig,
301
- displayConfig: v?.displayConfig
304
+ chartType: w?.chartType || "bar",
305
+ chartConfig: w?.chartConfig,
306
+ displayConfig: w?.displayConfig
302
307
  });
303
308
  }
304
- u(null);
309
+ l(null);
305
310
  }, [n, r]);
306
- return t.length === 0 ? /* @__PURE__ */ a("div", { className: "dc:flex dc:items-center dc:justify-center dc:h-full", children: /* @__PURE__ */ y("div", { className: "dc:text-center dc:max-w-sm dc:px-6", children: [
311
+ return t.length === 0 ? /* @__PURE__ */ a("div", { className: "dc:flex dc:items-center dc:justify-center dc:h-full", children: /* @__PURE__ */ b("div", { className: "dc:text-center dc:max-w-sm dc:px-6", children: [
307
312
  /* @__PURE__ */ a("h3", { className: "dc:text-base dc:font-semibold text-dc-text dc:mb-2", children: "Your notebook is empty" }),
308
313
  /* @__PURE__ */ a("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." })
309
- ] }) }) : /* @__PURE__ */ y("div", { className: "dc:h-full dc:overflow-y-auto dc:p-4", children: [
310
- t.map((i, w) => {
311
- const k = w === 0, v = w === t.length - 1;
312
- return i.type === "portlet" ? /* @__PURE__ */ a(
314
+ ] }) }) : /* @__PURE__ */ b("div", { className: "dc:h-full dc:overflow-y-auto dc:p-4", children: [
315
+ t.map((d, v) => {
316
+ const k = v === 0, w = v === t.length - 1;
317
+ return d.type === "portlet" ? /* @__PURE__ */ a(
313
318
  ye,
314
319
  {
315
- block: i,
316
- onRemove: g,
317
- onMoveUp: h,
320
+ block: d,
321
+ onRemove: f,
322
+ onMoveUp: g,
318
323
  onMoveDown: x,
319
324
  onEdit: m,
320
325
  isFirst: k,
321
- isLast: v
326
+ isLast: w
322
327
  },
323
- i.id
324
- ) : i.type === "markdown" ? /* @__PURE__ */ a(
325
- Ce,
328
+ d.id
329
+ ) : d.type === "markdown" ? /* @__PURE__ */ a(
330
+ ve,
326
331
  {
327
- block: i,
328
- onRemove: g,
329
- onMoveUp: h,
332
+ block: d,
333
+ onRemove: f,
334
+ onMoveUp: g,
330
335
  onMoveDown: x,
331
336
  isFirst: k,
332
- isLast: v
337
+ isLast: w
333
338
  },
334
- i.id
339
+ d.id
335
340
  ) : null;
336
341
  }),
337
342
  /* @__PURE__ */ a("div", { ref: o }),
@@ -339,8 +344,8 @@ const le = (e) => e.blocks, _e = (e) => e.messages, je = (e) => e.isStreaming, K
339
344
  X,
340
345
  {
341
346
  isOpen: !!n,
342
- onClose: () => u(null),
343
- onSave: b,
347
+ onClose: () => l(null),
348
+ onSave: C,
344
349
  portlet: n ? {
345
350
  id: n.id,
346
351
  title: n.title,
@@ -360,6 +365,25 @@ const le = (e) => e.blocks, _e = (e) => e.messages, je = (e) => e.isStreaming, K
360
365
  ] });
361
366
  });
362
367
  function ke(e) {
368
+ if (e.startsWith("{") || e.includes('"type":"error"'))
369
+ try {
370
+ const t = JSON.parse(e.replace(/^Error:\s*/, "")), s = t.error?.type || t.type || "";
371
+ return {
372
+ overloaded_error: "The AI service is temporarily busy. Please try again in a moment.",
373
+ rate_limit_error: "Too many requests. Please wait a moment and try again.",
374
+ api_error: "The AI service encountered an error. Please try again.",
375
+ authentication_error: "Authentication failed. Please check your configuration."
376
+ }[s] || "The AI service encountered an error. Please try again.";
377
+ } catch {
378
+ return "The AI service encountered an error. Please try again.";
379
+ }
380
+ if (e.startsWith("Agent request failed:")) {
381
+ const t = e.match(/\d+/)?.[0];
382
+ 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.";
383
+ }
384
+ return e;
385
+ }
386
+ function Ne(e) {
363
387
  const {
364
388
  agentEndpoint: t,
365
389
  agentApiKey: s,
@@ -367,133 +391,136 @@ function ke(e) {
367
391
  onAddMarkdown: r,
368
392
  onTextDelta: o,
369
393
  onToolStart: n,
370
- onToolResult: u,
371
- onTurnComplete: d,
372
- onDone: g,
373
- onError: h
374
- } = e, { cubeApi: x } = re(), m = N(null), [b, i] = F(!1), w = p(async (v, C) => {
375
- function S(f) {
376
- switch (f.type) {
394
+ onToolResult: l,
395
+ onTurnComplete: i,
396
+ onDone: f,
397
+ onError: g
398
+ } = e, { cubeApi: x } = oe(), m = N(null), [C, d] = F(!1), v = p(async (w, y) => {
399
+ function M(h) {
400
+ switch (h.type) {
377
401
  case "text_delta":
378
- o(f.data);
402
+ o(h.data);
379
403
  break;
380
404
  case "tool_use_start":
381
- n(f.data.id, f.data.name, f.data.input);
405
+ n(h.data.id, h.data.name, h.data.input);
382
406
  break;
383
407
  case "tool_use_result":
384
- u(f.data.id, f.data.name, f.data.result);
408
+ l(h.data.id, h.data.name, h.data.result, h.data.isError);
385
409
  break;
386
410
  case "add_portlet":
387
411
  c({
388
- ...f.data,
412
+ ...h.data,
389
413
  type: "portlet"
390
414
  });
391
415
  break;
392
416
  case "add_markdown":
393
417
  r({
394
- ...f.data,
418
+ ...h.data,
395
419
  type: "markdown"
396
420
  });
397
421
  break;
398
422
  case "turn_complete":
399
- d?.();
423
+ i?.();
400
424
  break;
401
425
  case "done":
402
- g(f.data.sessionId);
426
+ f(h.data.sessionId);
403
427
  break;
404
428
  case "error":
405
- h(f.data.message);
429
+ g(h.data.message);
406
430
  break;
407
431
  }
408
432
  }
409
433
  m.current && m.current.abort();
410
- const A = new AbortController();
411
- m.current = A, i(!0);
434
+ const S = new AbortController();
435
+ m.current = S, d(!0);
412
436
  try {
413
- const f = x.apiUrl || "/cubejs-api/v1", M = t || `${f}/agent/chat`, I = {
437
+ const h = x.apiUrl || "/cubejs-api/v1", D = t || `${h}/agent/chat`, T = {
414
438
  "Content-Type": "application/json",
415
439
  ...x.headers
416
440
  };
417
- s && (I["X-Agent-Api-Key"] = s);
418
- const E = await fetch(M, {
441
+ s && (T["X-Agent-Api-Key"] = s);
442
+ const I = await fetch(D, {
419
443
  method: "POST",
420
- headers: I,
444
+ headers: T,
421
445
  credentials: x.credentials ?? "include",
422
446
  body: JSON.stringify({
423
- message: v,
424
- ...C ? { sessionId: C } : {}
447
+ message: w,
448
+ ...y ? { sessionId: y } : {}
425
449
  }),
426
- signal: A.signal
450
+ signal: S.signal
427
451
  });
428
- if (!E.ok) {
429
- const l = await E.json().catch(() => ({}));
430
- throw new Error(l.error || `Agent request failed: ${E.status}`);
452
+ if (!I.ok) {
453
+ const B = await I.json().catch(() => ({}));
454
+ throw new Error(B.error || `Agent request failed: ${I.status}`);
431
455
  }
432
- if (!E.body)
456
+ if (!I.body)
433
457
  throw new Error("No response body received");
434
- const _ = E.body.getReader(), j = new TextDecoder();
435
- let B = "";
458
+ const j = I.body.getReader(), q = new TextDecoder();
459
+ let E = "";
436
460
  for (; ; ) {
437
- const { done: l, value: R } = await _.read();
438
- if (l) break;
439
- B += j.decode(R, { stream: !0 });
440
- const T = B.split(`
461
+ const { done: B, value: u } = await j.read();
462
+ if (B) break;
463
+ E += q.decode(u, { stream: !0 });
464
+ const L = E.split(`
441
465
 
442
466
  `);
443
- B = T.pop() || "";
444
- for (const $ of T) {
445
- const z = $.trim().split(`
467
+ E = L.pop() || "";
468
+ for (const P of L) {
469
+ const U = P.trim().split(`
446
470
  `);
447
- for (const U of z)
448
- if (U.startsWith("data: "))
471
+ for (const O of U)
472
+ if (O.startsWith("data: "))
449
473
  try {
450
- const W = JSON.parse(U.slice(6));
451
- S(W);
474
+ const W = JSON.parse(O.slice(6));
475
+ M(W);
452
476
  } catch {
453
477
  }
454
478
  }
455
479
  }
456
- if (B.trim()) {
457
- const l = B.trim().split(`
480
+ if (E.trim()) {
481
+ const B = E.trim().split(`
458
482
  `);
459
- for (const R of l)
460
- if (R.startsWith("data: "))
483
+ for (const u of B)
484
+ if (u.startsWith("data: "))
461
485
  try {
462
- const T = JSON.parse(R.slice(6));
463
- S(T);
486
+ const L = JSON.parse(u.slice(6));
487
+ M(L);
464
488
  } catch {
465
489
  }
466
490
  }
467
- } catch (f) {
468
- f.name !== "AbortError" && h(f instanceof Error ? f.message : "Stream failed");
491
+ } catch (h) {
492
+ if (h.name !== "AbortError") {
493
+ const D = h instanceof Error ? h.message : "Stream failed";
494
+ g(ke(D));
495
+ }
469
496
  } finally {
470
- i(!1), m.current = null;
497
+ d(!1), m.current = null;
471
498
  }
472
- }, [x, t, s, c, r, o, n, u, d, g, h]), k = p(() => {
473
- m.current && (m.current.abort(), m.current = null, i(!1));
499
+ }, [x, t, s, c, r, o, n, l, i, f, g]), k = p(() => {
500
+ m.current && (m.current.abort(), m.current = null, d(!1));
474
501
  }, []);
475
502
  return {
476
- sendMessage: w,
477
- isStreaming: b,
503
+ sendMessage: v,
504
+ isStreaming: C,
478
505
  abort: k
479
506
  };
480
507
  }
481
- function Ne(e) {
508
+ function we(e) {
482
509
  const t = [];
483
510
  let s = e, c = 0;
484
511
  for (; s; ) {
485
512
  const r = s.match(/^(.*?)`([^`]+)`(.*)$/);
486
513
  if (r) {
487
- const [, n, u, d] = r;
514
+ const [, n, l, i] = r;
488
515
  n && t.push(/* @__PURE__ */ a("span", { children: n }, c++)), t.push(
489
- /* @__PURE__ */ a("code", { className: "dc:px-1 dc:py-0.5 dc:rounded dc:text-xs bg-dc-surface dc:font-mono", children: u }, c++)
490
- ), s = d;
516
+ /* @__PURE__ */ a("code", { className: "dc:px-1 dc:py-0.5 dc:rounded dc:text-xs bg-dc-surface dc:font-mono", children: l }, c++)
517
+ ), s = i;
491
518
  continue;
492
519
  }
493
520
  const o = s.match(/^(.*?)\*\*([^*]+)\*\*(.*)$/);
494
521
  if (o) {
495
- const [, n, u, d] = o;
496
- n && t.push(/* @__PURE__ */ a("span", { children: n }, c++)), t.push(/* @__PURE__ */ a("strong", { className: "dc:font-semibold", children: u }, c++)), s = d;
522
+ const [, n, l, i] = o;
523
+ n && t.push(/* @__PURE__ */ a("span", { children: n }, c++)), t.push(/* @__PURE__ */ a("strong", { className: "dc:font-semibold", children: l }, c++)), s = i;
497
524
  continue;
498
525
  }
499
526
  t.push(/* @__PURE__ */ a("span", { children: s }, c));
@@ -501,24 +528,24 @@ function Ne(e) {
501
528
  }
502
529
  return t;
503
530
  }
504
- const we = {
531
+ const Se = {
505
532
  discover_cubes: "Discovering cubes",
506
533
  get_cube_metadata: "Reading metadata",
507
534
  execute_query: "Executing query",
508
535
  add_portlet: "Adding visualization",
509
536
  add_markdown: "Adding explanation"
510
537
  };
511
- function Se({ toolCall: e }) {
512
- const [t, s] = F(!1), c = we[e.name] || e.name, r = e.status === "running";
513
- return /* @__PURE__ */ y("div", { className: "dc:my-1 dc:text-xs", children: [
514
- /* @__PURE__ */ y(
538
+ function Ae({ toolCall: e }) {
539
+ const [t, s] = F(!1), c = Se[e.name] || e.name, r = e.status === "running";
540
+ return /* @__PURE__ */ b("div", { className: "dc:my-1 dc:text-xs", children: [
541
+ /* @__PURE__ */ b(
515
542
  "button",
516
543
  {
517
544
  onClick: () => s(!t),
518
545
  className: "dc:flex dc:items-center dc:gap-1.5 text-dc-text-secondary dc:hover:opacity-80 dc:transition-opacity",
519
546
  children: [
520
547
  r ? /* @__PURE__ */ a("span", { className: "dc:inline-block dc:w-3 dc:h-3 dc:border-2 border-dc-accent dc:border-t-transparent dc:rounded-full dc:animate-spin" }) : /* @__PURE__ */ a("span", { className: "dc:text-xs", children: e.status === "error" ? "✗" : "✓" }),
521
- /* @__PURE__ */ y("span", { children: [
548
+ /* @__PURE__ */ b("span", { children: [
522
549
  c,
523
550
  r ? "..." : ""
524
551
  ] }),
@@ -529,50 +556,54 @@ function Se({ toolCall: e }) {
529
556
  t && e.result != null && /* @__PURE__ */ a("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) })
530
557
  ] });
531
558
  }
532
- const De = L.memo(function({ message: t }) {
533
- const s = t.role === "user", c = !!t.content?.trim(), r = t.toolCalls && t.toolCalls.length > 0;
534
- return !s && !c && !r ? null : /* @__PURE__ */ a("div", { className: `dc:flex dc:mb-3 ${s ? "dc:justify-end" : "dc:justify-start"}`, children: /* @__PURE__ */ y(
559
+ const De = R.memo(function({ message: t }) {
560
+ const s = t.role === "user", c = !!t.content?.trim(), r = !!t.error, o = t.toolCalls && t.toolCalls.length > 0;
561
+ return !s && !c && !r && !o ? null : /* @__PURE__ */ a("div", { className: `dc:flex dc:mb-3 ${s ? "dc:justify-end" : "dc:justify-start"}`, children: /* @__PURE__ */ b(
535
562
  "div",
536
563
  {
537
- className: `dc:max-w-[85%] dc:rounded-lg dc:px-3 dc:py-2 dc:text-sm ${s ? "bg-dc-accent text-dc-accent-text dc:rounded-br-sm" : "bg-dc-surface-secondary text-dc-text dc:rounded-bl-sm"}`,
564
+ className: `dc:max-w-[85%] dc:rounded-lg dc:px-3 dc:py-2 dc:text-sm ${s ? "bg-dc-accent text-dc-accent-text dc:rounded-br-sm" : r && !c ? "bg-dc-warning-bg text-dc-text dc:rounded-bl-sm" : "bg-dc-surface-secondary text-dc-text dc:rounded-bl-sm"}`,
538
565
  children: [
539
- c && /* @__PURE__ */ a("div", { className: "dc:whitespace-pre-wrap dc:break-words", children: s ? t.content : Ne(t.content) }),
540
- r && /* @__PURE__ */ a("div", { className: c ? "dc:mt-1 dc:border-t dc:border-current dc:border-opacity-10 dc:pt-1" : "", children: t.toolCalls.map((o, n) => /* @__PURE__ */ a(Se, { toolCall: o }, o.id || n)) })
566
+ c && /* @__PURE__ */ a("div", { className: "dc:whitespace-pre-wrap dc:break-words", children: s ? t.content : we(t.content) }),
567
+ r && /* @__PURE__ */ b("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: [
568
+ /* @__PURE__ */ a("span", { className: "dc:text-base dc:leading-none dc:mt-0.5 text-dc-warning dc:flex-shrink-0", children: "⚠" }),
569
+ /* @__PURE__ */ a("span", { className: "text-dc-text-secondary", children: t.error })
570
+ ] }),
571
+ o && /* @__PURE__ */ a("div", { className: c || r ? "dc:mt-1 dc:border-t dc:border-current dc:border-opacity-10 dc:pt-1" : "", children: t.toolCalls.map((n, l) => /* @__PURE__ */ a(Ae, { toolCall: n }, n.id || l)) })
541
572
  ]
542
573
  }
543
574
  ) });
544
- }), Me = L.memo(function({
575
+ }), Te = R.memo(function({
545
576
  value: t,
546
577
  onChange: s,
547
578
  onSend: c,
548
579
  onStop: r,
549
580
  onContinue: o,
550
581
  isStreaming: n = !1,
551
- showContinue: u = !1,
552
- disabled: d = !1,
553
- placeholder: g = "Ask about your data..."
582
+ showContinue: l = !1,
583
+ disabled: i = !1,
584
+ placeholder: f = "Ask about your data..."
554
585
  }) {
555
- const h = N(null);
586
+ const g = N(null);
556
587
  Q(() => {
557
- const m = h.current;
588
+ const m = g.current;
558
589
  m && (m.style.height = "auto", m.style.height = `${Math.min(m.scrollHeight, 150)}px`);
559
590
  }, [t]);
560
591
  const x = p(
561
592
  (m) => {
562
- m.key === "Enter" && !m.shiftKey && (m.preventDefault(), !d && t.trim() && c());
593
+ m.key === "Enter" && !m.shiftKey && (m.preventDefault(), !i && t.trim() && c());
563
594
  },
564
- [d, t, c]
595
+ [i, t, c]
565
596
  );
566
- return /* @__PURE__ */ y("div", { className: "dc:flex dc:gap-2 dc:items-end dc:p-3 border-dc-border dc:border-t", children: [
597
+ return /* @__PURE__ */ b("div", { className: "dc:flex dc:gap-2 dc:items-end dc:p-3 border-dc-border dc:border-t", children: [
567
598
  /* @__PURE__ */ a(
568
599
  "textarea",
569
600
  {
570
- ref: h,
601
+ ref: g,
571
602
  value: t,
572
603
  onChange: (m) => s(m.target.value),
573
604
  onKeyDown: x,
574
- placeholder: g,
575
- disabled: d,
605
+ placeholder: f,
606
+ disabled: i,
576
607
  rows: 1,
577
608
  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"
578
609
  }
@@ -584,12 +615,12 @@ const De = L.memo(function({ message: t }) {
584
615
  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",
585
616
  children: "Stop"
586
617
  }
587
- ) : /* @__PURE__ */ y(Y, { children: [
588
- u && !t.trim() && /* @__PURE__ */ a(
618
+ ) : /* @__PURE__ */ b(Y, { children: [
619
+ l && !t.trim() && /* @__PURE__ */ a(
589
620
  "button",
590
621
  {
591
622
  onClick: () => {
592
- o?.(), h.current?.focus();
623
+ o?.(), g.current?.focus();
593
624
  },
594
625
  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",
595
626
  children: "Continue"
@@ -599,173 +630,172 @@ const De = L.memo(function({ message: t }) {
599
630
  "button",
600
631
  {
601
632
  onClick: c,
602
- disabled: d || !t.trim(),
633
+ disabled: i || !t.trim(),
603
634
  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",
604
635
  children: "Send"
605
636
  }
606
637
  )
607
638
  ] })
608
639
  ] });
609
- }), Ae = L.memo(function({
640
+ }), Me = R.memo(function({
610
641
  agentEndpoint: t,
611
642
  agentApiKey: s,
612
643
  onClear: c
613
644
  }) {
614
- const r = N(null), o = N(!1), { messages: n, isStreaming: u, inputValue: d } = D(K(ue)), {
615
- addMessage: g,
616
- appendToLastAssistantMessage: h,
617
- addToolCallToLastAssistant: x,
618
- updateLastToolCall: m,
619
- setIsStreaming: b,
620
- setInputValue: i,
621
- setSessionId: w
622
- } = D(K(me)), k = D((l) => l.sessionId), v = D((l) => l.addBlock), C = D((l) => l.reset), S = p(() => {
623
- o.current && (o.current = !1, g({
645
+ const r = N(null), o = N(!1), { messages: n, isStreaming: l, inputValue: i } = A(K(ue)), {
646
+ addMessage: f,
647
+ appendToLastAssistantMessage: g,
648
+ setLastAssistantError: x,
649
+ addToolCallToLastAssistant: m,
650
+ updateLastToolCall: C,
651
+ setIsStreaming: d,
652
+ setInputValue: v,
653
+ setSessionId: k
654
+ } = A(K(me)), w = A((u) => u.sessionId), y = A((u) => u.addBlock), M = A((u) => u.reset), S = p(() => {
655
+ o.current && (o.current = !1, f({
624
656
  id: `msg-${Date.now()}`,
625
657
  role: "assistant",
626
658
  content: "",
627
659
  toolCalls: [],
628
660
  timestamp: Date.now()
629
661
  }));
630
- }, [g]), A = N(n.length);
662
+ }, [f]), h = N(n.length);
631
663
  Q(() => {
632
- n.length > A.current && r.current?.scrollIntoView({ behavior: "smooth" }), A.current = n.length;
664
+ n.length > h.current && r.current?.scrollIntoView({ behavior: "smooth" }), h.current = n.length;
633
665
  }, [n]);
634
- const { sendMessage: f, abort: M } = ke({
666
+ const { sendMessage: D, abort: T } = Ne({
635
667
  agentEndpoint: t,
636
668
  agentApiKey: s,
637
- onTextDelta: p((l) => {
638
- S(), h(l);
639
- }, [S, h]),
640
- onToolStart: p((l, R, T) => {
641
- S(), x({ id: l, name: R, input: T, status: "running" });
642
- }, [S, x]),
643
- onToolResult: p((l, R, T) => {
644
- m({ id: l, status: "complete", result: T });
645
- }, [m]),
646
- onAddPortlet: p((l) => {
647
- v(l);
648
- }, [v]),
649
- onAddMarkdown: p((l) => {
650
- v(l);
651
- }, [v]),
669
+ onTextDelta: p((u) => {
670
+ S(), g(u);
671
+ }, [S, g]),
672
+ onToolStart: p((u, L, P) => {
673
+ S(), m({ id: u, name: L, input: P, status: "running" });
674
+ }, [S, m]),
675
+ onToolResult: p((u, L, P, U) => {
676
+ C({ id: u, status: U ? "error" : "complete", result: P });
677
+ }, [C]),
678
+ onAddPortlet: p((u) => {
679
+ y(u);
680
+ }, [y]),
681
+ onAddMarkdown: p((u) => {
682
+ y(u);
683
+ }, [y]),
652
684
  onTurnComplete: p(() => {
653
685
  o.current = !0;
654
686
  }, []),
655
- onDone: p((l) => {
656
- o.current = !1, w(l), b(!1);
657
- }, [w, b]),
658
- onError: p((l) => {
659
- S(), h(`
660
-
661
- Error: ${l}`), b(!1);
662
- }, [S, h, b])
663
- }), I = p((l) => {
664
- !l || u || (o.current = !1, g({
687
+ onDone: p((u) => {
688
+ o.current = !1, k(u), d(!1);
689
+ }, [k, d]),
690
+ onError: p((u) => {
691
+ S(), x(u), d(!1);
692
+ }, [S, x, d])
693
+ }), I = p((u) => {
694
+ !u || l || (o.current = !1, f({
665
695
  id: `msg-${Date.now()}`,
666
696
  role: "user",
667
- content: l,
697
+ content: u,
668
698
  timestamp: Date.now()
669
- }), g({
699
+ }), f({
670
700
  id: `msg-${Date.now() + 1}`,
671
701
  role: "assistant",
672
702
  content: "",
673
703
  toolCalls: [],
674
704
  timestamp: Date.now()
675
- }), i(""), b(!0), f(l, k));
676
- }, [u, g, i, b, f, k]), E = p(() => {
677
- I(d.trim());
678
- }, [d, I]), _ = p(() => {
679
- M(), b(!1);
680
- }, [M, b]), j = p(() => {
681
- i("");
682
- }, [i]), B = p(() => {
683
- M(), b(!1), C(), c?.();
684
- }, [M, b, C, c]);
685
- return /* @__PURE__ */ y("div", { className: "dc:flex dc:flex-col dc:h-full bg-dc-surface", children: [
686
- /* @__PURE__ */ y("div", { className: "dc:flex dc:items-center dc:justify-between dc:px-4 dc:py-3 border-dc-border dc:border-b", children: [
705
+ }), v(""), d(!0), D(u, w));
706
+ }, [l, f, v, d, D, w]), j = p(() => {
707
+ I(i.trim());
708
+ }, [i, I]), q = p(() => {
709
+ T(), d(!1);
710
+ }, [T, d]), E = p(() => {
711
+ v("");
712
+ }, [v]), B = p(() => {
713
+ T(), d(!1), M(), c?.();
714
+ }, [T, d, M, c]);
715
+ return /* @__PURE__ */ b("div", { className: "dc:flex dc:flex-col dc:h-full bg-dc-surface", children: [
716
+ /* @__PURE__ */ b("div", { className: "dc:flex dc:items-center dc:justify-between dc:px-4 dc:py-3 border-dc-border dc:border-b", children: [
687
717
  /* @__PURE__ */ a("h3", { className: "dc:text-sm dc:font-semibold text-dc-text", children: "AI Assistant" }),
688
718
  n.length > 0 && /* @__PURE__ */ a(
689
719
  "button",
690
720
  {
691
721
  onClick: B,
692
- disabled: u,
722
+ disabled: l,
693
723
  className: "dc:text-xs dc:px-2 dc:py-1 dc:rounded text-dc-text-secondary dc:hover:opacity-80 dc:disabled:opacity-40",
694
724
  title: "Clear notebook and chat",
695
725
  children: "Clear"
696
726
  }
697
727
  )
698
728
  ] }),
699
- /* @__PURE__ */ y("div", { className: "dc:flex-1 dc:overflow-y-auto dc:px-4 dc:py-3", children: [
700
- n.length === 0 ? /* @__PURE__ */ a(Te, {}) : n.map((l) => /* @__PURE__ */ a(De, { message: l }, l.id)),
729
+ /* @__PURE__ */ b("div", { className: "dc:flex-1 dc:overflow-y-auto dc:px-4 dc:py-3", children: [
730
+ n.length === 0 ? /* @__PURE__ */ a(Ie, {}) : n.map((u) => /* @__PURE__ */ a(De, { message: u }, u.id)),
701
731
  /* @__PURE__ */ a("div", { ref: r })
702
732
  ] }),
703
733
  /* @__PURE__ */ a(
704
- Me,
734
+ Te,
705
735
  {
706
- value: d,
707
- onChange: i,
708
- onSend: E,
709
- onStop: _,
710
- onContinue: j,
711
- isStreaming: u,
712
- showContinue: !u && n.length > 0
736
+ value: i,
737
+ onChange: v,
738
+ onSend: j,
739
+ onStop: q,
740
+ onContinue: E,
741
+ isStreaming: l,
742
+ showContinue: !l && n.length > 0
713
743
  }
714
744
  )
715
745
  ] });
716
746
  });
717
- function Te() {
718
- return /* @__PURE__ */ a("div", { className: "dc:flex dc:items-center dc:justify-center dc:h-full", children: /* @__PURE__ */ y("div", { className: "dc:text-center dc:max-w-xs", children: [
747
+ function Ie() {
748
+ return /* @__PURE__ */ a("div", { className: "dc:flex dc:items-center dc:justify-center dc:h-full", children: /* @__PURE__ */ b("div", { className: "dc:text-center dc:max-w-xs", children: [
719
749
  /* @__PURE__ */ a("div", { className: "dc:text-lg dc:font-semibold text-dc-text dc:mb-2", children: "Data Analysis Assistant" }),
720
750
  /* @__PURE__ */ a("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." }),
721
- /* @__PURE__ */ y("div", { className: "dc:space-y-2 dc:text-xs text-dc-text-muted", children: [
751
+ /* @__PURE__ */ b("div", { className: "dc:space-y-2 dc:text-xs text-dc-text-muted", children: [
722
752
  /* @__PURE__ */ a("p", { children: '"Show me employee productivity trends"' }),
723
753
  /* @__PURE__ */ a("p", { children: '"What are the top departments by headcount?"' }),
724
754
  /* @__PURE__ */ a("p", { children: '"Compare revenue across product categories"' })
725
755
  ] })
726
756
  ] }) });
727
757
  }
728
- function Ie({
758
+ function Ee({
729
759
  agentEndpoint: e,
730
760
  agentApiKey: t,
731
761
  onSave: s,
732
762
  onDirtyStateChange: c,
733
763
  className: r
734
764
  }) {
735
- const [o, n] = F(60), u = N(null), d = N(!1), g = D((C) => C.blocks.length), h = D((C) => C.messages.length), x = D((C) => C.save), m = N({ blockCount: g, msgCount: h });
765
+ const [o, n] = F(60), l = N(null), i = N(!1), f = A((y) => y.blocks.length), g = A((y) => y.messages.length), x = A((y) => y.save), m = N({ blockCount: f, msgCount: g });
736
766
  Q(() => {
737
- const C = g !== m.current.blockCount || h !== m.current.msgCount;
738
- c?.(C);
739
- }, [g, h, c]);
740
- const b = N(), i = N(s);
741
- i.current = s;
742
- const w = N(g > 0 || h > 0);
767
+ const y = f !== m.current.blockCount || g !== m.current.msgCount;
768
+ c?.(y);
769
+ }, [f, g, c]);
770
+ const C = N(), d = N(s);
771
+ d.current = s;
772
+ const v = N(f > 0 || g > 0);
743
773
  Q(() => {
744
- if ((g > 0 || h > 0) && (w.current = !0), !(!i.current || !w.current))
745
- return b.current && clearTimeout(b.current), b.current = setTimeout(() => {
746
- const C = x();
747
- i.current?.(C);
774
+ if ((f > 0 || g > 0) && (v.current = !0), !(!d.current || !v.current))
775
+ return C.current && clearTimeout(C.current), C.current = setTimeout(() => {
776
+ const y = x();
777
+ d.current?.(y);
748
778
  }, 1e3), () => {
749
- b.current && clearTimeout(b.current);
779
+ C.current && clearTimeout(C.current);
750
780
  };
751
- }, [g, h, x]);
781
+ }, [f, g, x]);
752
782
  const k = p(() => {
753
- i.current && (b.current && clearTimeout(b.current), i.current({ blocks: [], messages: [] }));
754
- }, []), v = p((C) => {
755
- C.preventDefault(), d.current = !0;
756
- const S = (f) => {
757
- if (!d.current || !u.current) return;
758
- const M = u.current.getBoundingClientRect(), I = (f.clientX - M.left) / M.width * 100;
759
- n(Math.min(Math.max(I, 30), 80));
760
- }, A = () => {
761
- d.current = !1, document.removeEventListener("mousemove", S), document.removeEventListener("mouseup", A);
783
+ d.current && (C.current && clearTimeout(C.current), d.current({ blocks: [], messages: [] }));
784
+ }, []), w = p((y) => {
785
+ y.preventDefault(), i.current = !0;
786
+ const M = (h) => {
787
+ if (!i.current || !l.current) return;
788
+ const D = l.current.getBoundingClientRect(), T = (h.clientX - D.left) / D.width * 100;
789
+ n(Math.min(Math.max(T, 30), 80));
790
+ }, S = () => {
791
+ i.current = !1, document.removeEventListener("mousemove", M), document.removeEventListener("mouseup", S);
762
792
  };
763
- document.addEventListener("mousemove", S), document.addEventListener("mouseup", A);
793
+ document.addEventListener("mousemove", M), document.addEventListener("mouseup", S);
764
794
  }, []);
765
- return /* @__PURE__ */ y(
795
+ return /* @__PURE__ */ b(
766
796
  "div",
767
797
  {
768
- ref: u,
798
+ ref: l,
769
799
  className: `dc:flex dc:h-full dc:w-full dc:overflow-hidden bg-dc-surface-secondary ${r || ""}`,
770
800
  children: [
771
801
  /* @__PURE__ */ a(
@@ -773,14 +803,14 @@ function Ie({
773
803
  {
774
804
  className: "dc:h-full dc:overflow-hidden",
775
805
  style: { width: `${o}%` },
776
- children: /* @__PURE__ */ a(ve, {})
806
+ children: /* @__PURE__ */ a(Ce, {})
777
807
  }
778
808
  ),
779
809
  /* @__PURE__ */ a(
780
810
  "div",
781
811
  {
782
812
  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",
783
- onMouseDown: v
813
+ onMouseDown: w
784
814
  }
785
815
  ),
786
816
  /* @__PURE__ */ a(
@@ -789,7 +819,7 @@ function Ie({
789
819
  className: "dc:h-full dc:overflow-hidden",
790
820
  style: { width: `${100 - o}%` },
791
821
  children: /* @__PURE__ */ a(
792
- Ae,
822
+ Me,
793
823
  {
794
824
  agentEndpoint: e,
795
825
  agentApiKey: t,
@@ -802,26 +832,26 @@ function Ie({
802
832
  }
803
833
  );
804
834
  }
805
- const Oe = L.memo(function({
835
+ const Oe = R.memo(function({
806
836
  config: t,
807
837
  ...s
808
838
  }) {
809
- return /* @__PURE__ */ a(ie, { initialConfig: t, children: /* @__PURE__ */ a(Ie, { ...s }) });
839
+ return /* @__PURE__ */ a(ie, { initialConfig: t, children: /* @__PURE__ */ a(Ee, { ...s }) });
810
840
  });
811
- function qe() {
841
+ function $e() {
812
842
  return /* @__PURE__ */ a("div", { children: "Analytics Page - Coming in Phase 4" });
813
843
  }
814
- const Ee = P("segment");
815
- function $e({
844
+ const Be = _("segment");
845
+ function ze({
816
846
  className: e = ""
817
847
  }) {
818
848
  return /* @__PURE__ */ a(
819
849
  "div",
820
850
  {
821
851
  className: `dc:flex dc:items-center dc:justify-center bg-dc-bg-secondary ${e}`,
822
- children: /* @__PURE__ */ y("div", { className: "dc:text-center", children: [
852
+ children: /* @__PURE__ */ b("div", { className: "dc:text-center", children: [
823
853
  /* @__PURE__ */ a(
824
- Ee,
854
+ Be,
825
855
  {
826
856
  className: "dc:w-8 dc:h-8 dc:mx-auto dc:mb-2 text-dc-text-muted dc:opacity-50"
827
857
  }
@@ -833,177 +863,177 @@ function $e({
833
863
  }
834
864
  export {
835
865
  Oe as AgenticNotebook,
836
- Je as AnalysisBuilder,
837
- He as AnalyticsDashboard,
838
- qe as AnalyticsPage,
866
+ He as AnalysisBuilder,
867
+ Ge as AnalyticsDashboard,
868
+ $e as AnalyticsPage,
839
869
  H as AnalyticsPortlet,
840
- Ge as ChartErrorBoundary,
841
- Xe as ConfirmModal,
842
- es as CubeClient,
843
- ts as CubeProvider,
870
+ Xe as ChartErrorBoundary,
871
+ Ye as ConfirmModal,
872
+ ts as CubeClient,
873
+ ss as CubeProvider,
844
874
  Ot as DEFAULT_ICONS,
845
- Ye as DashboardEditModal,
846
- Ze as DashboardGrid,
847
- et as DashboardStoreProvider,
848
- $e as DashboardThumbnailPlaceholder,
849
- tt as DrillBreadcrumb,
850
- st as DrillMenu,
851
- ws as ExecutionPlanPanel,
852
- Ss as ExplainAIPanel,
853
- gs as LazyChart,
854
- ps as LoadingIndicator,
855
- at as Modal,
875
+ Ze as DashboardEditModal,
876
+ et as DashboardGrid,
877
+ tt as DashboardStoreProvider,
878
+ ze as DashboardThumbnailPlaceholder,
879
+ st as DrillBreadcrumb,
880
+ at as DrillMenu,
881
+ Ss as ExecutionPlanPanel,
882
+ As as ExplainAIPanel,
883
+ bs as LazyChart,
884
+ hs as LoadingIndicator,
885
+ rt as Modal,
856
886
  ie as NotebookStoreProvider,
857
887
  X as PortletAnalysisModal,
858
888
  ct as PortletContainer,
859
- ss as ScrollContainerProvider,
860
- Ba as THEME_PRESETS,
889
+ as as ScrollContainerProvider,
890
+ La as THEME_PRESETS,
861
891
  Ra as applyTheme,
862
- wa as buildFunnelConfigFromQueries,
863
- Sa as buildServerFunnelQuery,
864
- as as captureThumbnail,
892
+ Sa as buildFunnelConfigFromQueries,
893
+ Aa as buildServerFunnelQuery,
894
+ rs as captureThumbnail,
865
895
  Ds as compressAndEncode,
866
896
  cs as createCubeClient,
867
897
  ca as createDashboardLayout,
868
898
  ot as createDashboardStore,
869
- rt as createDefaultConfig,
870
- nt as createDefaultFlowConfig,
871
- dt as createDefaultFunnelConfig,
872
- it as createDefaultQueryConfig,
873
- lt as createDefaultRetentionConfig,
874
- ut as createDefaultWorkspace,
875
- Ua as createExplainQueryKey,
876
- na as createFlowQueryKey,
877
- da as createFunnelQueryKey,
899
+ nt as createDefaultConfig,
900
+ dt as createDefaultFlowConfig,
901
+ it as createDefaultFunnelConfig,
902
+ lt as createDefaultQueryConfig,
903
+ ut as createDefaultRetentionConfig,
904
+ mt as createDefaultWorkspace,
905
+ Ka as createExplainQueryKey,
906
+ da as createFlowQueryKey,
907
+ ia as createFunnelQueryKey,
878
908
  de as createNotebookStore,
879
- Ms as decodeAndDecompress,
880
- As as detectAsymmetricDateRanges,
881
- Ts as detectMeasureCollisions,
909
+ Ts as decodeAndDecompress,
910
+ Ms as detectAsymmetricDateRanges,
911
+ Is as detectMeasureCollisions,
882
912
  oa as formatChartData,
883
913
  Da as formatDuration,
884
- ia as generateQueryLabel,
885
- Is as generateShareUrl,
886
- Es as getAvailableBindingKeyDimensions,
887
- bs as getAvailableChartTypes,
888
- Ma as getBindingKeyField,
889
- Bs as getBindingKeyLabel,
890
- qt as getChartTypeIcon,
891
- la as getCombinedFields,
892
- Aa as getCubeNameFromQuery,
893
- $t as getFieldTypeIcon,
894
- P as getIcon,
895
- zt as getIconData,
896
- Wt as getIconRegistry,
897
- Jt as getIconsByCategory,
898
- Ht as getMeasureTypeIcon,
899
- ua as getQueryIndices,
900
- ma as getQueryLabels,
901
- La as getTheme,
914
+ la as generateQueryLabel,
915
+ Es as generateShareUrl,
916
+ Bs as getAvailableBindingKeyDimensions,
917
+ ys as getAvailableChartTypes,
918
+ Ta as getBindingKeyField,
919
+ Ls as getBindingKeyLabel,
920
+ $t as getChartTypeIcon,
921
+ ua as getCombinedFields,
922
+ Ma as getCubeNameFromQuery,
923
+ zt as getFieldTypeIcon,
924
+ _ as getIcon,
925
+ Wt as getIconData,
926
+ Jt as getIconRegistry,
927
+ Ht as getIconsByCategory,
928
+ Gt as getMeasureTypeIcon,
929
+ ma as getQueryIndices,
930
+ pa as getQueryLabels,
931
+ Pa as getTheme,
902
932
  Qa as getThemeVariable,
903
- ys as getUnavailableChartTypes,
933
+ xs as getUnavailableChartTypes,
904
934
  Rs as getValidationSummary,
905
- Ya as highlightCodeBlocks,
906
- xs as isChartTypeAvailable,
935
+ Za as highlightCodeBlocks,
936
+ vs as isChartTypeAvailable,
907
937
  Fa as isDarkMode,
908
- mt as isFlowConfig,
909
- pt as isFunnelConfig,
910
- Ta as isFunnelData,
911
- Ls as isMinimumFunnelConfigValid,
912
- ht as isMultiQuery,
913
- ft as isMultiQueryConfig,
914
- pa as isMultiQueryData,
938
+ pt as isFlowConfig,
939
+ ht as isFunnelConfig,
940
+ Ia as isFunnelData,
941
+ Ps as isMinimumFunnelConfigValid,
942
+ ft as isMultiQuery,
943
+ gt as isMultiQueryConfig,
944
+ ha as isMultiQueryData,
915
945
  Qs as isMultiQueryValid,
916
- gt as isQueryConfig,
917
- bt as isRetentionConfig,
918
- Ha as isSankeyData,
919
- Ga as isServerFlowQuery,
920
- yt as isServerFunnelQuery,
946
+ bt as isQueryConfig,
947
+ yt as isRetentionConfig,
948
+ Ga as isSankeyData,
949
+ Xa as isServerFlowQuery,
950
+ xt as isServerFunnelQuery,
921
951
  Fs as isShareableSize,
922
- xt as isSingleQuery,
952
+ vt as isSingleQuery,
923
953
  os as isThumbnailCaptureAvailable,
924
954
  Ct as isValidAnalysisConfig,
925
- vt as isValidAnalysisWorkspace,
955
+ kt as isValidAnalysisWorkspace,
926
956
  Cs as isValidChartType,
927
- ha as mergeQueryResults,
928
- fa as mergeResultsByKey,
929
- ga as mergeResultsConcat,
930
- kt as migrateConfig,
931
- Nt as migrateLegacyPortlet,
932
- Ps as parseShareUrl,
933
- vs as preloadChart,
934
- ks as preloadCharts,
935
- Gt as registerIcons,
936
- Xt as resetIcons,
937
- Pa as resetTheme,
938
- wt as selectAllActions,
957
+ fa as mergeQueryResults,
958
+ ga as mergeResultsByKey,
959
+ ba as mergeResultsConcat,
960
+ Nt as migrateConfig,
961
+ wt as migrateLegacyPortlet,
962
+ _s as parseShareUrl,
963
+ ks as preloadChart,
964
+ Ns as preloadCharts,
965
+ Xt as registerIcons,
966
+ Yt as resetIcons,
967
+ _a as resetTheme,
968
+ St as selectAllActions,
939
969
  pe as selectBlockActions,
940
970
  le as selectBlocks,
941
971
  Vs as selectBreakdowns,
942
- _s as selectChartConfig,
972
+ js as selectChartConfig,
943
973
  me as selectChatActions,
944
974
  ue as selectChatState,
945
- js as selectCurrentState,
946
- St as selectDebugData,
975
+ qs as selectCurrentState,
976
+ At as selectDebugData,
947
977
  Dt as selectDebugDataActions,
948
- Mt as selectEditModeActions,
949
- At as selectEditModeState,
950
- Ks as selectFilters,
951
- Us as selectFunnelState,
952
- Ue as selectInputValue,
953
- je as selectIsStreaming,
954
- Tt as selectLayoutActions,
955
- It as selectLayoutState,
956
- _e as selectMessages,
978
+ Tt as selectEditModeActions,
979
+ Mt as selectEditModeState,
980
+ Us as selectFilters,
981
+ Ks as selectFunnelState,
982
+ Ke as selectInputValue,
983
+ qe as selectIsStreaming,
984
+ It as selectLayoutActions,
985
+ Et as selectLayoutState,
986
+ je as selectMessages,
957
987
  Os as selectMetrics,
958
- Et as selectModalActions,
959
- Bt as selectModalState,
960
- qs as selectMultiQueryState,
988
+ Bt as selectModalActions,
989
+ Lt as selectModalState,
990
+ $s as selectMultiQueryState,
961
991
  Rt as selectPortletDebugData,
962
- Ke as selectSessionId,
963
- Lt as selectThumbnailDirty,
964
- $s as selectUIState,
965
- Yt as setIcon,
992
+ Ue as selectSessionId,
993
+ Pt as selectThumbnailDirty,
994
+ zs as selectUIState,
995
+ Zt as setIcon,
966
996
  Va as setTheme,
967
- _a as setThemeVariable,
968
- Ia as transformServerFunnelResult,
969
- ke as useAgentChat,
970
- zs as useAnalysisBuilder,
971
- Ws as useAnalysisBuilderStore,
972
- re as useCubeApi,
973
- rs as useCubeContext,
974
- ns as useCubeFeatures,
975
- hs as useCubeFieldLabel,
976
- ba as useCubeLoadQuery,
977
- ds as useCubeMeta,
978
- is as useCubeMetaQuery,
979
- ya as useCubeQuery,
997
+ ja as setThemeVariable,
998
+ Ea as transformServerFunnelResult,
999
+ Ne as useAgentChat,
1000
+ Ws as useAnalysisBuilder,
1001
+ Js as useAnalysisBuilderStore,
1002
+ oe as useCubeApi,
1003
+ ns as useCubeContext,
1004
+ ds as useCubeFeatures,
1005
+ fs as useCubeFieldLabel,
1006
+ ya as useCubeLoadQuery,
1007
+ is as useCubeMeta,
1008
+ ls as useCubeMetaQuery,
1009
+ xa as useCubeQuery,
980
1010
  Qt as useDashboard,
981
1011
  Ft as useDashboardStore,
982
- Pt as useDashboardStoreApi,
1012
+ _t as useDashboardStoreApi,
983
1013
  Vt as useDashboardStoreOptional,
984
- _t as useDrillInteraction,
1014
+ jt as useDrillInteraction,
985
1015
  Oa as useDryRunQueries,
986
- qa as useDryRunQuery,
987
- jt as useElementVisibility,
988
- $a as useExplainAI,
989
- za as useExplainQuery,
990
- xa as useFlowQuery,
1016
+ $a as useDryRunQuery,
1017
+ qt as useElementVisibility,
1018
+ za as useExplainAI,
1019
+ Wa as useExplainQuery,
1020
+ va as useFlowQuery,
991
1021
  Ca as useFunnelQuery,
992
- va as useMultiCubeLoadQuery,
993
- Wa as useMultiDryRunQueries,
994
- D as useNotebookStore,
995
- ls as useScrollContainer,
996
- Kt as useScrollDetection,
997
- sa as useTheme,
998
- Js as validateBindingKeyExists,
999
- Hs as validateBindingKeyForSteps,
1000
- Gs as validateFunnelConfig,
1001
- ka as validateMergeKey,
1002
- Xs as validateMergeKeys,
1003
- Ys as validateMultiQueryConfig,
1004
- Zs as validateStepQueries,
1005
- ea as validateTimeDimensionAlignment,
1006
- us as warnIfScreenshotLibMissing,
1007
- ja as watchThemeChanges
1022
+ ka as useMultiCubeLoadQuery,
1023
+ Ja as useMultiDryRunQueries,
1024
+ A as useNotebookStore,
1025
+ us as useScrollContainer,
1026
+ Ut as useScrollDetection,
1027
+ aa as useTheme,
1028
+ Hs as validateBindingKeyExists,
1029
+ Gs as validateBindingKeyForSteps,
1030
+ Xs as validateFunnelConfig,
1031
+ Na as validateMergeKey,
1032
+ Ys as validateMergeKeys,
1033
+ Zs as validateMultiQueryConfig,
1034
+ ea as validateStepQueries,
1035
+ ta as validateTimeDimensionAlignment,
1036
+ ms as warnIfScreenshotLibMissing,
1037
+ qa as watchThemeChanges
1008
1038
  };
1009
1039
  //# sourceMappingURL=index.js.map