drizzle-cube 0.4.8 → 0.4.9

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 (28) hide show
  1. package/dist/adapters/express/index.cjs +1 -1
  2. package/dist/adapters/express/index.js +1 -1
  3. package/dist/adapters/fastify/index.cjs +1 -1
  4. package/dist/adapters/fastify/index.js +1 -1
  5. package/dist/adapters/{handler-odjn7MIB.js → handler-CSHsefnC.js} +270 -185
  6. package/dist/adapters/{handler-BLcxTuwi.cjs → handler-Xe_2ItOo.cjs} +13 -13
  7. package/dist/adapters/hono/index.cjs +1 -1
  8. package/dist/adapters/hono/index.js +1 -1
  9. package/dist/adapters/nextjs/index.cjs +1 -1
  10. package/dist/adapters/nextjs/index.js +1 -1
  11. package/dist/client/chunks/{analysis-builder-Bov_gLsf.js → analysis-builder-DFt9p8tj.js} +137 -137
  12. package/dist/client/chunks/{analysis-builder-Bov_gLsf.js.map → analysis-builder-DFt9p8tj.js.map} +1 -1
  13. package/dist/client/chunks/{analysis-builder-shared-NBk6y0md.js → analysis-builder-shared-DOHV2W8A.js} +713 -787
  14. package/dist/client/chunks/analysis-builder-shared-DOHV2W8A.js.map +1 -0
  15. package/dist/client/chunks/{components-O0hh7ooo.js → components-8FAXo62Z.js} +1495 -1416
  16. package/dist/client/chunks/components-8FAXo62Z.js.map +1 -0
  17. package/dist/client/components/AgenticNotebook/NotebookPortletBlock.d.ts +1 -0
  18. package/dist/client/components.js +8 -8
  19. package/dist/client/index.js +655 -584
  20. package/dist/client/index.js.map +1 -1
  21. package/dist/client/stores/notebookStore.d.ts +2 -0
  22. package/dist/client/styles.css +1 -1
  23. package/dist/client-bundle-stats.html +1 -1
  24. package/dist/server/index.cjs +13 -13
  25. package/dist/server/index.js +1775 -1690
  26. package/package.json +1 -1
  27. package/dist/client/chunks/analysis-builder-shared-NBk6y0md.js.map +0 -1
  28. package/dist/client/chunks/components-O0hh7ooo.js.map +0 -1
@@ -1,116 +1,114 @@
1
- import { jsxs as b, jsx as p, Fragment as G } from "react/jsx-runtime";
2
- import Pe, { useState as Ce, useRef as ae, useEffect as se, memo as kn, useContext as yt, createContext as In, useMemo as A, useCallback as U } from "react";
3
- import { l as qn, g as Bn } from "./syntaxHighlighting-BQfjio-i.js";
4
- import { a as nt } from "./icons-DAeqv1iX.js";
5
- import { u as Nn, g as Vn } from "./providers-CgxXm6Ll.js";
6
- import { c as En, d as rt, e as it, s as st, p as Pn, f as Un, l as gt } from "./vendor-AVsJ2ni0.js";
1
+ import { jsxs as S, jsx as C, Fragment as z } from "react/jsx-runtime";
2
+ import Ee, { memo as Rn, useState as Pe, useContext as mt, createContext as kn, useRef as Se, useMemo as A, useCallback as U, useEffect as he } from "react";
3
+ import { _ as In, $ as Ue, a0 as $, a1 as pe, a2 as W, a3 as J, a4 as X, U as qn, N as yt, a5 as Bn } from "./components-8FAXo62Z.js";
4
+ import { u as Vn, g as Nn } from "./providers-CgxXm6Ll.js";
5
+ import { c as En, d as nt, e as rt, s as it, p as Pn, f as Un, l as gt } from "./vendor-AVsJ2ni0.js";
7
6
  import { d as _n, R as Ln, a as Kn, g as $n, D as Gn } from "./retention-CzCo8262.js";
8
- import { Y as Hn, Z as $, _ as we, $ as W, a0 as J, a1 as Y, S as On, K as ht, a2 as jn } from "./components-O0hh7ooo.js";
9
- import { F as at, b as ot } from "./flow-utils-CjQZG5qq.js";
10
- import { n as zn, u as Wn, a as Jn, b as Yn, d as Xn, o as Zn } from "./useDirtyStateTracking-Cu1HSjmo.js";
11
- import { c as er, a as pt } from "./funnel-utils-CyonoNeC.js";
12
- import { useDryRunQueries as tr, useDryRunQuery as Ne } from "../hooks.js";
13
- function nr(t) {
7
+ import { F as st, b as at } from "./flow-utils-CjQZG5qq.js";
8
+ import { n as On, u as Hn, a as jn, b as zn, d as Wn, o as Jn } from "./useDirtyStateTracking-Cu1HSjmo.js";
9
+ import { c as Xn, a as ht } from "./funnel-utils-CyonoNeC.js";
10
+ import { useDryRunQueries as Yn, useDryRunQuery as Be } from "../hooks.js";
11
+ function Zn(t) {
14
12
  const i = /* @__PURE__ */ new Date(), e = t.toLowerCase().trim(), n = i.getUTCFullYear(), r = i.getUTCMonth(), s = i.getUTCDate(), o = i.getUTCDay();
15
13
  if (e === "today") {
16
14
  const y = new Date(i);
17
15
  y.setUTCHours(0, 0, 0, 0);
18
- const u = new Date(i);
19
- return u.setUTCHours(23, 59, 59, 999), { start: y, end: u };
16
+ const d = new Date(i);
17
+ return d.setUTCHours(23, 59, 59, 999), { start: y, end: d };
20
18
  }
21
19
  if (e === "yesterday") {
22
20
  const y = new Date(i);
23
21
  y.setUTCDate(s - 1), y.setUTCHours(0, 0, 0, 0);
24
- const u = new Date(i);
25
- return u.setUTCDate(s - 1), u.setUTCHours(23, 59, 59, 999), { start: y, end: u };
22
+ const d = new Date(i);
23
+ return d.setUTCDate(s - 1), d.setUTCHours(23, 59, 59, 999), { start: y, end: d };
26
24
  }
27
25
  if (e === "this week") {
28
- const y = o === 0 ? -6 : 1 - o, u = new Date(i);
29
- u.setUTCDate(s + y), u.setUTCHours(0, 0, 0, 0);
30
- const g = new Date(u);
31
- return g.setUTCDate(u.getUTCDate() + 6), g.setUTCHours(23, 59, 59, 999), { start: u, end: g };
26
+ const y = o === 0 ? -6 : 1 - o, d = new Date(i);
27
+ d.setUTCDate(s + y), d.setUTCHours(0, 0, 0, 0);
28
+ const p = new Date(d);
29
+ return p.setUTCDate(d.getUTCDate() + 6), p.setUTCHours(23, 59, 59, 999), { start: d, end: p };
32
30
  }
33
31
  if (e === "this month") {
34
- const y = new Date(Date.UTC(n, r, 1, 0, 0, 0, 0)), u = new Date(Date.UTC(n, r + 1, 0, 23, 59, 59, 999));
35
- return { start: y, end: u };
32
+ const y = new Date(Date.UTC(n, r, 1, 0, 0, 0, 0)), d = new Date(Date.UTC(n, r + 1, 0, 23, 59, 59, 999));
33
+ return { start: y, end: d };
36
34
  }
37
35
  if (e === "this quarter") {
38
- const y = Math.floor(r / 3), u = new Date(Date.UTC(n, y * 3, 1, 0, 0, 0, 0)), g = new Date(Date.UTC(n, y * 3 + 3, 0, 23, 59, 59, 999));
39
- return { start: u, end: g };
36
+ const y = Math.floor(r / 3), d = new Date(Date.UTC(n, y * 3, 1, 0, 0, 0, 0)), p = new Date(Date.UTC(n, y * 3 + 3, 0, 23, 59, 59, 999));
37
+ return { start: d, end: p };
40
38
  }
41
39
  if (e === "this year") {
42
- const y = new Date(Date.UTC(n, 0, 1, 0, 0, 0, 0)), u = new Date(Date.UTC(n, 11, 31, 23, 59, 59, 999));
43
- return { start: y, end: u };
40
+ const y = new Date(Date.UTC(n, 0, 1, 0, 0, 0, 0)), d = new Date(Date.UTC(n, 11, 31, 23, 59, 59, 999));
41
+ return { start: y, end: d };
44
42
  }
45
43
  const l = e.match(/^last\s+(\d+)\s+days?$/);
46
44
  if (l) {
47
- const y = parseInt(l[1], 10), u = new Date(i);
48
- u.setUTCDate(s - y + 1), u.setUTCHours(0, 0, 0, 0);
49
- const g = new Date(i);
50
- return g.setUTCHours(23, 59, 59, 999), { start: u, end: g };
45
+ const y = parseInt(l[1], 10), d = new Date(i);
46
+ d.setUTCDate(s - y + 1), d.setUTCHours(0, 0, 0, 0);
47
+ const p = new Date(i);
48
+ return p.setUTCHours(23, 59, 59, 999), { start: d, end: p };
51
49
  }
52
- const d = e.match(/^last\s+(\d+)\s+weeks?$/);
53
- if (d) {
54
- const u = parseInt(d[1], 10) * 7, g = new Date(i);
55
- g.setUTCDate(s - u + 1), g.setUTCHours(0, 0, 0, 0);
56
- const S = new Date(i);
57
- return S.setUTCHours(23, 59, 59, 999), { start: g, end: S };
50
+ const u = e.match(/^last\s+(\d+)\s+weeks?$/);
51
+ if (u) {
52
+ const d = parseInt(u[1], 10) * 7, p = new Date(i);
53
+ p.setUTCDate(s - d + 1), p.setUTCHours(0, 0, 0, 0);
54
+ const b = new Date(i);
55
+ return b.setUTCHours(23, 59, 59, 999), { start: p, end: b };
58
56
  }
59
57
  if (e === "last week") {
60
- const y = o === 0 ? -13 : -6 - o, u = new Date(i);
61
- u.setUTCDate(s + y), u.setUTCHours(0, 0, 0, 0);
62
- const g = new Date(u);
63
- return g.setUTCDate(u.getUTCDate() + 6), g.setUTCHours(23, 59, 59, 999), { start: u, end: g };
58
+ const y = o === 0 ? -13 : -6 - o, d = new Date(i);
59
+ d.setUTCDate(s + y), d.setUTCHours(0, 0, 0, 0);
60
+ const p = new Date(d);
61
+ return p.setUTCDate(d.getUTCDate() + 6), p.setUTCHours(23, 59, 59, 999), { start: d, end: p };
64
62
  }
65
63
  if (e === "last month") {
66
- const y = new Date(Date.UTC(n, r - 1, 1, 0, 0, 0, 0)), u = new Date(Date.UTC(n, r, 0, 23, 59, 59, 999));
67
- return { start: y, end: u };
64
+ const y = new Date(Date.UTC(n, r - 1, 1, 0, 0, 0, 0)), d = new Date(Date.UTC(n, r, 0, 23, 59, 59, 999));
65
+ return { start: y, end: d };
68
66
  }
69
67
  if (e === "last quarter") {
70
- const y = Math.floor(r / 3), u = y === 0 ? 3 : y - 1, g = y === 0 ? n - 1 : n, S = new Date(Date.UTC(g, u * 3, 1, 0, 0, 0, 0)), w = new Date(Date.UTC(g, u * 3 + 3, 0, 23, 59, 59, 999));
71
- return { start: S, end: w };
68
+ const y = Math.floor(r / 3), d = y === 0 ? 3 : y - 1, p = y === 0 ? n - 1 : n, b = new Date(Date.UTC(p, d * 3, 1, 0, 0, 0, 0)), w = new Date(Date.UTC(p, d * 3 + 3, 0, 23, 59, 59, 999));
69
+ return { start: b, end: w };
72
70
  }
73
71
  if (e === "last year") {
74
- const y = new Date(Date.UTC(n - 1, 0, 1, 0, 0, 0, 0)), u = new Date(Date.UTC(n - 1, 11, 31, 23, 59, 59, 999));
75
- return { start: y, end: u };
72
+ const y = new Date(Date.UTC(n - 1, 0, 1, 0, 0, 0, 0)), d = new Date(Date.UTC(n - 1, 11, 31, 23, 59, 59, 999));
73
+ return { start: y, end: d };
76
74
  }
77
75
  if (e === "last 12 months") {
78
- const y = new Date(Date.UTC(n, r - 11, 1, 0, 0, 0, 0)), u = new Date(i);
79
- return u.setUTCHours(23, 59, 59, 999), { start: y, end: u };
76
+ const y = new Date(Date.UTC(n, r - 11, 1, 0, 0, 0, 0)), d = new Date(i);
77
+ return d.setUTCHours(23, 59, 59, 999), { start: y, end: d };
80
78
  }
81
79
  const f = e.match(/^last\s+(\d+)\s+months?$/);
82
80
  if (f) {
83
- const y = parseInt(f[1], 10), u = new Date(Date.UTC(n, r - y + 1, 1, 0, 0, 0, 0)), g = new Date(i);
84
- return g.setUTCHours(23, 59, 59, 999), { start: u, end: g };
81
+ const y = parseInt(f[1], 10), d = new Date(Date.UTC(n, r - y + 1, 1, 0, 0, 0, 0)), p = new Date(i);
82
+ return p.setUTCHours(23, 59, 59, 999), { start: d, end: p };
85
83
  }
86
84
  const m = e.match(/^last\s+(\d+)\s+years?$/);
87
85
  if (m) {
88
- const y = parseInt(m[1], 10), u = new Date(Date.UTC(n - y, 0, 1, 0, 0, 0, 0)), g = new Date(i);
89
- return g.setUTCHours(23, 59, 59, 999), { start: u, end: g };
86
+ const y = parseInt(m[1], 10), d = new Date(Date.UTC(n - y, 0, 1, 0, 0, 0, 0)), p = new Date(i);
87
+ return p.setUTCHours(23, 59, 59, 999), { start: d, end: p };
90
88
  }
91
89
  return null;
92
90
  }
93
- function rr(t) {
91
+ function er(t) {
94
92
  if (Array.isArray(t)) {
95
93
  if (t.length < 2) return null;
96
94
  const i = new Date(t[0]), e = new Date(t[1]);
97
95
  return isNaN(i.getTime()) || isNaN(e.getTime()) ? null : (e.setUTCHours(23, 59, 59, 999), { start: i, end: e });
98
96
  }
99
- return nr(t);
97
+ return Zn(t);
100
98
  }
101
- function pe(t) {
99
+ function ge(t) {
102
100
  return t.toISOString().split("T")[0];
103
101
  }
104
- function ir(t, i) {
102
+ function tr(t, i) {
105
103
  const e = i.getTime() - t.getTime(), n = Math.ceil(e / (1e3 * 60 * 60 * 24)), r = new Date(t);
106
104
  r.setUTCDate(r.getUTCDate() - 1), r.setUTCHours(23, 59, 59, 999);
107
105
  const s = new Date(r);
108
106
  return s.setUTCDate(s.getUTCDate() - n + 1), s.setUTCHours(0, 0, 0, 0), { start: s, end: r };
109
107
  }
110
- function Ct(t, i) {
108
+ function pt(t, i) {
111
109
  for (const e of t)
112
110
  if ("type" in e && "filters" in e) {
113
- const r = Ct(e.filters, i);
111
+ const r = pt(e.filters, i);
114
112
  if (r) return r;
115
113
  } else if ("member" in e) {
116
114
  const n = e;
@@ -118,21 +116,21 @@ function Ct(t, i) {
118
116
  return { dateRange: n.dateRange };
119
117
  }
120
118
  }
121
- function wt(t, i) {
122
- const e = Ct(i, t);
119
+ function Ct(t, i) {
120
+ const e = pt(i, t);
123
121
  if (!e?.dateRange) return;
124
- const n = rr(e.dateRange);
122
+ const n = er(e.dateRange);
125
123
  if (!n) return;
126
- const r = ir(n.start, n.end);
124
+ const r = tr(n.start, n.end);
127
125
  return [
128
- [pe(n.start), pe(n.end)],
129
- [pe(r.start), pe(r.end)]
126
+ [ge(n.start), ge(n.end)],
127
+ [ge(r.start), ge(r.end)]
130
128
  ];
131
129
  }
132
- function bt(t, i) {
130
+ function wt(t, i) {
133
131
  return t.reduce((e, n) => {
134
132
  if ("type" in n && "filters" in n) {
135
- const r = n, s = bt(r.filters, i);
133
+ const r = n, s = wt(r.filters, i);
136
134
  s.length > 0 && e.push({ type: r.type, filters: s });
137
135
  } else if ("member" in n) {
138
136
  const r = n;
@@ -142,23 +140,23 @@ function bt(t, i) {
142
140
  return e;
143
141
  }, []);
144
142
  }
145
- function be(t, i, e, n, r = !1) {
146
- const s = i.filter((d) => d.isTimeDimension && d.enableComparison).map((d) => d.field);
143
+ function Ce(t, i, e, n, r = !1) {
144
+ const s = i.filter((u) => u.isTimeDimension && u.enableComparison).map((u) => u.field);
147
145
  let o = e;
148
146
  if (!r)
149
- for (const d of s)
150
- o = bt(o, d);
151
- o = o.filter((d) => Hn(d));
147
+ for (const u of s)
148
+ o = wt(o, u);
149
+ o = o.filter((u) => In(u));
152
150
  const l = {
153
- measures: t.map((d) => d.field),
154
- dimensions: i.filter((d) => !d.isTimeDimension).map((d) => d.field),
155
- timeDimensions: i.filter((d) => d.isTimeDimension).map((d) => {
151
+ measures: t.map((u) => u.field),
152
+ dimensions: i.filter((u) => !u.isTimeDimension).map((u) => u.field),
153
+ timeDimensions: i.filter((u) => u.isTimeDimension).map((u) => {
156
154
  const f = {
157
- dimension: d.field,
158
- granularity: d.granularity || "day"
155
+ dimension: u.field,
156
+ granularity: u.granularity || "day"
159
157
  };
160
- if (d.enableComparison) {
161
- const m = wt(d.field, e);
158
+ if (u.enableComparison) {
159
+ const m = Ct(u.field, e);
162
160
  m && (f.compareDateRange = m);
163
161
  }
164
162
  return f;
@@ -168,7 +166,7 @@ function be(t, i, e, n, r = !1) {
168
166
  };
169
167
  return l.measures?.length === 0 && delete l.measures, l.dimensions?.length === 0 && delete l.dimensions, l.timeDimensions?.length === 0 && delete l.timeDimensions, l;
170
168
  }
171
- const sr = "drizzle-cube-analysis-builder-v3";
169
+ const nr = "drizzle-cube-analysis-builder-v3";
172
170
  function R() {
173
171
  return {
174
172
  metrics: [],
@@ -179,94 +177,23 @@ function R() {
179
177
  validationError: null
180
178
  };
181
179
  }
182
- const Ue = ({
183
- code: t,
184
- language: i,
185
- title: e,
186
- maxHeight: n = "16rem",
187
- height: r,
188
- className: s = "",
189
- headerRight: o
190
- }) => {
191
- const [l, d] = Ce(!1), f = ae(null), m = nt("copy"), y = nt("check");
192
- se(() => {
193
- if (!f.current) return;
194
- const g = f.current;
195
- let S = !0;
196
- return g.textContent = t, qn().then(() => {
197
- if (!S) return;
198
- const w = Bn();
199
- w && (g.innerHTML = w.highlight(t, { language: i }).value);
200
- }).catch(() => {
201
- S && (g.textContent = t);
202
- }), () => {
203
- S = !1;
204
- };
205
- }, [t, i]);
206
- const u = async () => {
207
- try {
208
- await navigator.clipboard.writeText(t), d(!0), setTimeout(() => d(!1), 2e3);
209
- } catch {
210
- const g = document.createElement("textarea");
211
- g.value = t, g.style.position = "fixed", g.style.left = "-999999px", document.body.appendChild(g), g.select(), document.execCommand("copy"), document.body.removeChild(g), d(!0), setTimeout(() => d(!1), 2e3);
212
- }
213
- };
214
- return /* @__PURE__ */ b("div", { className: `dc:relative ${s}`, children: [
215
- /* @__PURE__ */ b("div", { className: "dc:flex dc:items-center dc:justify-between dc:mb-2 dc:gap-2", children: [
216
- e && /* @__PURE__ */ p("h4", { className: "dc:text-sm dc:font-semibold text-dc-text", children: e }),
217
- /* @__PURE__ */ b("div", { className: "dc:flex dc:items-center dc:gap-2 dc:ml-auto", children: [
218
- o,
219
- /* @__PURE__ */ p(
220
- "button",
221
- {
222
- onClick: u,
223
- className: "dc:px-2 dc:py-1 dc:text-xs dc:rounded hover:bg-dc-surface-secondary dc:border border-dc-border dc:transition-colors dc:flex dc:items-center dc:gap-1.5",
224
- title: l ? "Copied!" : "Copy to clipboard",
225
- children: l ? /* @__PURE__ */ b(G, { children: [
226
- /* @__PURE__ */ p(y, { className: "dc:w-3.5 dc:h-3.5 text-dc-success" }),
227
- /* @__PURE__ */ p("span", { className: "text-dc-success", children: "Copied" })
228
- ] }) : /* @__PURE__ */ b(G, { children: [
229
- /* @__PURE__ */ p(m, { className: "dc:w-3.5 dc:h-3.5 text-dc-text-secondary" }),
230
- /* @__PURE__ */ p("span", { className: "text-dc-text-secondary", children: "Copy" })
231
- ] })
232
- }
233
- )
234
- ] })
235
- ] }),
236
- /* @__PURE__ */ p(
237
- "div",
238
- {
239
- className: "bg-dc-surface-secondary dc:border border-dc-border dc:rounded dc:overflow-auto",
240
- style: r ? { height: r, minHeight: r, maxHeight: r } : { maxHeight: n },
241
- children: /* @__PURE__ */ p("pre", { className: "dc:p-3 dc:text-xs dc:m-0", children: /* @__PURE__ */ p(
242
- "code",
243
- {
244
- ref: f,
245
- className: `hljs language-${i}`,
246
- children: t
247
- }
248
- ) })
249
- }
250
- )
251
- ] });
252
- };
253
180
  function St(t) {
254
181
  return t.isTimeDimension;
255
182
  }
256
- function ar(t) {
183
+ function rr(t) {
257
184
  return t.find(St);
258
185
  }
259
- function or(t) {
186
+ function ir(t) {
260
187
  return t.find((i) => !i.isTimeDimension);
261
188
  }
262
189
  function je(t) {
263
190
  return t.filter((i) => !i.isTimeDimension);
264
191
  }
265
- function vt(t) {
192
+ function bt(t) {
266
193
  return t.filter(St);
267
194
  }
268
195
  function ze(t, i, e) {
269
- const n = i.length, r = je(e).length, s = vt(e).length, o = e.length;
196
+ const n = i.length, r = je(e).length, s = bt(e).length, o = e.length;
270
197
  switch (t) {
271
198
  // Always available charts
272
199
  case "table":
@@ -311,7 +238,7 @@ function ze(t, i, e) {
311
238
  return { available: !0 };
312
239
  }
313
240
  }
314
- function lr(t, i) {
241
+ function sr(t, i) {
315
242
  const e = [
316
243
  "activityGrid",
317
244
  "area",
@@ -333,18 +260,18 @@ function lr(t, i) {
333
260
  n[r] = ze(r, t, i);
334
261
  return n;
335
262
  }
336
- function xt(t, i, e) {
263
+ function vt(t, i, e) {
337
264
  if (ze(e, t, i).available || t.length === 0 && i.length === 0)
338
265
  return e;
339
- const r = vt(i).length > 0, s = je(i).length > 0, o = t.length > 0;
266
+ const r = bt(i).length > 0, s = je(i).length > 0, o = t.length > 0;
340
267
  return r && o ? "line" : s && o ? "bar" : o && !s && !r ? "kpiNumber" : "table";
341
268
  }
342
269
  function Ve(t, i, e) {
343
- const n = xt(t, i, e), r = cr(n, t, i);
270
+ const n = vt(t, i, e), r = ar(n, t, i);
344
271
  return { chartType: n, chartConfig: r };
345
272
  }
346
- function cr(t, i, e) {
347
- const n = ar(e), r = or(e), s = je(e), o = e;
273
+ function ar(t, i, e) {
274
+ const n = rr(e), r = ir(e), s = je(e), o = e;
348
275
  switch (t) {
349
276
  case "line":
350
277
  case "area":
@@ -415,57 +342,57 @@ function cr(t, i, e) {
415
342
  };
416
343
  }
417
344
  }
418
- function dr(t, i, e, n) {
345
+ function or(t, i, e, n) {
419
346
  if (n && ze(e, t, i).available)
420
347
  return null;
421
- const r = xt(t, i, e);
348
+ const r = vt(t, i, e);
422
349
  return r !== e ? r : null;
423
350
  }
424
- function j(t) {
351
+ function H(t) {
425
352
  return typeof t == "string" ? t : typeof t == "object" && t !== null ? JSON.stringify(t) : String(t ?? "");
426
353
  }
427
- const ur = {
354
+ const lr = {
428
355
  good: "bg-dc-success-bg text-dc-success border-dc-success",
429
356
  warning: "bg-dc-warning-bg text-dc-warning border-dc-warning",
430
357
  critical: "bg-dc-danger-bg text-dc-error border-dc-error"
431
- }, fr = {
358
+ }, cr = {
432
359
  critical: "bg-dc-danger-bg text-dc-error",
433
360
  warning: "bg-dc-warning-bg text-dc-warning",
434
361
  suggestion: "bg-dc-accent-bg text-dc-accent"
435
- }, mr = {
362
+ }, dr = {
436
363
  high: "text-dc-error",
437
364
  medium: "text-dc-warning",
438
365
  low: "text-dc-text-muted"
439
366
  };
440
- function yr({ assessment: t, reason: i }) {
367
+ function ur({ assessment: t, reason: i }) {
441
368
  const e = {
442
369
  good: "Good",
443
370
  warning: "Warning",
444
371
  critical: "Critical"
445
372
  };
446
- return /* @__PURE__ */ b("div", { className: `dc:p-4 dc:rounded-lg dc:border ${ur[t]}`, children: [
447
- /* @__PURE__ */ p("div", { className: "dc:flex dc:items-center dc:gap-2 dc:mb-1", children: /* @__PURE__ */ b("span", { className: "dc:font-semibold dc:uppercase dc:text-base", children: [
373
+ return /* @__PURE__ */ S("div", { className: `dc:p-4 dc:rounded-lg dc:border ${lr[t]}`, children: [
374
+ /* @__PURE__ */ C("div", { className: "dc:flex dc:items-center dc:gap-2 dc:mb-1", children: /* @__PURE__ */ S("span", { className: "dc:font-semibold dc:uppercase dc:text-base", children: [
448
375
  t === "good" && "✓ ",
449
376
  t === "warning" && "⚠ ",
450
377
  t === "critical" && "✕ ",
451
378
  e[t]
452
379
  ] }) }),
453
- /* @__PURE__ */ p("p", { className: "dc:text-sm", children: j(i) })
380
+ /* @__PURE__ */ C("p", { className: "dc:text-sm", children: H(i) })
454
381
  ] });
455
382
  }
456
- function gr({ issue: t }) {
457
- return /* @__PURE__ */ b("div", { className: "dc:flex dc:items-start dc:gap-2 dc:py-2", children: [
458
- /* @__PURE__ */ b("span", { className: `dc:text-sm ${mr[t.severity]}`, children: [
383
+ function fr({ issue: t }) {
384
+ return /* @__PURE__ */ S("div", { className: "dc:flex dc:items-start dc:gap-2 dc:py-2", children: [
385
+ /* @__PURE__ */ S("span", { className: `dc:text-sm ${dr[t.severity]}`, children: [
459
386
  t.severity === "high" && "●",
460
387
  t.severity === "medium" && "○",
461
388
  t.severity === "low" && "○"
462
389
  ] }),
463
- /* @__PURE__ */ p("span", { className: "dc:text-sm text-dc-text-secondary", children: j(t.description) })
390
+ /* @__PURE__ */ C("span", { className: "dc:text-sm text-dc-text-secondary", children: H(t.description) })
464
391
  ] });
465
392
  }
466
- function lt({ text: t }) {
467
- const [i, e] = Pe.useState(!1);
468
- return /* @__PURE__ */ p(
393
+ function ot({ text: t }) {
394
+ const [i, e] = Ee.useState(!1);
395
+ return /* @__PURE__ */ C(
469
396
  "button",
470
397
  {
471
398
  onClick: async () => {
@@ -481,62 +408,62 @@ function lt({ text: t }) {
481
408
  }
482
409
  );
483
410
  }
484
- function hr({ rec: t }) {
411
+ function mr({ rec: t }) {
485
412
  const i = {
486
413
  index: "INDEX",
487
414
  table: "TABLE",
488
415
  cube: "CUBE",
489
416
  general: "TIP"
490
417
  };
491
- return /* @__PURE__ */ b("div", { className: "dc:p-4 dc:border border-dc-border dc:rounded-lg bg-dc-surface", children: [
492
- /* @__PURE__ */ b("div", { className: "dc:flex dc:items-center dc:gap-2 dc:mb-2", children: [
493
- /* @__PURE__ */ p(
418
+ return /* @__PURE__ */ S("div", { className: "dc:p-4 dc:border border-dc-border dc:rounded-lg bg-dc-surface", children: [
419
+ /* @__PURE__ */ S("div", { className: "dc:flex dc:items-center dc:gap-2 dc:mb-2", children: [
420
+ /* @__PURE__ */ C(
494
421
  "span",
495
422
  {
496
- className: `dc:px-2 dc:py-0.5 dc:text-xs dc:font-medium dc:rounded ${fr[t.severity]}`,
423
+ className: `dc:px-2 dc:py-0.5 dc:text-xs dc:font-medium dc:rounded ${cr[t.severity]}`,
497
424
  children: i[t.type]
498
425
  }
499
426
  ),
500
- /* @__PURE__ */ p("h5", { className: "dc:font-medium text-dc-text", children: j(t.title) })
427
+ /* @__PURE__ */ C("h5", { className: "dc:font-medium text-dc-text", children: H(t.title) })
501
428
  ] }),
502
- /* @__PURE__ */ p("p", { className: "dc:text-sm text-dc-text-secondary dc:mb-3", children: j(t.description) }),
503
- t.sql && /* @__PURE__ */ p("div", { className: "dc:mt-2", children: /* @__PURE__ */ p(
429
+ /* @__PURE__ */ C("p", { className: "dc:text-sm text-dc-text-secondary dc:mb-3", children: H(t.description) }),
430
+ t.sql && /* @__PURE__ */ C("div", { className: "dc:mt-2", children: /* @__PURE__ */ C(
504
431
  Ue,
505
432
  {
506
433
  code: t.sql,
507
434
  language: "sql",
508
- headerRight: /* @__PURE__ */ p(lt, { text: t.sql })
435
+ headerRight: /* @__PURE__ */ C(ot, { text: t.sql })
509
436
  }
510
437
  ) }),
511
- t.cubeCode && /* @__PURE__ */ b("div", { className: "dc:mt-2", children: [
512
- t.cubeName && /* @__PURE__ */ b("p", { className: "dc:text-xs text-dc-text-muted dc:mb-1", children: [
438
+ t.cubeCode && /* @__PURE__ */ S("div", { className: "dc:mt-2", children: [
439
+ t.cubeName && /* @__PURE__ */ S("p", { className: "dc:text-xs text-dc-text-muted dc:mb-1", children: [
513
440
  "Add to ",
514
- /* @__PURE__ */ p("code", { className: "bg-dc-surface-secondary dc:px-1 dc:rounded", children: t.cubeName }),
441
+ /* @__PURE__ */ C("code", { className: "bg-dc-surface-secondary dc:px-1 dc:rounded", children: t.cubeName }),
515
442
  " cube:"
516
443
  ] }),
517
- /* @__PURE__ */ b("div", { className: "dc:relative", children: [
518
- /* @__PURE__ */ p("pre", { className: "dc:p-3 dc:text-xs bg-dc-surface-secondary dc:rounded dc:overflow-x-auto dc:font-mono text-dc-text", children: t.cubeCode }),
519
- /* @__PURE__ */ p("div", { className: "dc:absolute dc:top-1 dc:right-1", children: /* @__PURE__ */ p(lt, { text: t.cubeCode }) })
444
+ /* @__PURE__ */ S("div", { className: "dc:relative", children: [
445
+ /* @__PURE__ */ C("pre", { className: "dc:p-3 dc:text-xs bg-dc-surface-secondary dc:rounded dc:overflow-x-auto dc:font-mono text-dc-text", children: t.cubeCode }),
446
+ /* @__PURE__ */ C("div", { className: "dc:absolute dc:top-1 dc:right-1", children: /* @__PURE__ */ C(ot, { text: t.cubeCode }) })
520
447
  ] })
521
448
  ] }),
522
- t.estimatedImpact && /* @__PURE__ */ b("p", { className: "dc:text-xs text-dc-text-muted dc:mt-2", children: [
523
- /* @__PURE__ */ p("strong", { children: "Expected impact:" }),
449
+ t.estimatedImpact && /* @__PURE__ */ S("p", { className: "dc:text-xs text-dc-text-muted dc:mt-2", children: [
450
+ /* @__PURE__ */ C("strong", { children: "Expected impact:" }),
524
451
  " ",
525
- j(t.estimatedImpact)
452
+ H(t.estimatedImpact)
526
453
  ] })
527
454
  ] });
528
455
  }
529
- function pr({ analysis: t, onClose: i, onClear: e }) {
456
+ function yr({ analysis: t, onClose: i, onClear: e }) {
530
457
  const n = i || e;
531
- return Pe.useEffect(() => {
458
+ return Ee.useEffect(() => {
532
459
  const r = (s) => {
533
460
  s.key === "Escape" && n && n();
534
461
  };
535
462
  return window.addEventListener("keydown", r), () => window.removeEventListener("keydown", r);
536
- }, [n]), Pe.useEffect(() => (document.body.style.overflow = "hidden", () => {
463
+ }, [n]), Ee.useEffect(() => (document.body.style.overflow = "hidden", () => {
537
464
  document.body.style.overflow = "";
538
- }), []), /* @__PURE__ */ b("div", { className: "dc:fixed dc:inset-0 dc:z-50 dc:flex dc:items-center dc:justify-center dc:p-4 bg-black/50", children: [
539
- /* @__PURE__ */ p(
465
+ }), []), /* @__PURE__ */ S("div", { className: "dc:fixed dc:inset-0 dc:z-50 dc:flex dc:items-center dc:justify-center dc:p-4 bg-black/50", children: [
466
+ /* @__PURE__ */ C(
540
467
  "div",
541
468
  {
542
469
  className: "dc:absolute dc:inset-0",
@@ -544,63 +471,63 @@ function pr({ analysis: t, onClose: i, onClear: e }) {
544
471
  "aria-hidden": "true"
545
472
  }
546
473
  ),
547
- /* @__PURE__ */ b("div", { className: "dc:relative dc:w-full dc:max-w-4xl dc:max-h-[90vh] bg-dc-surface dc:rounded-lg dc:shadow-xl dc:flex dc:flex-col", children: [
548
- /* @__PURE__ */ b("div", { className: "dc:flex dc:items-center dc:justify-between dc:px-6 dc:py-4 dc:border-b border-dc-border dc:flex-shrink-0", children: [
549
- /* @__PURE__ */ b("div", { className: "dc:flex dc:items-center dc:gap-3", children: [
550
- /* @__PURE__ */ p("span", { className: "dc:text-lg", children: "✨" }),
551
- /* @__PURE__ */ p("h3", { className: "dc:text-lg dc:font-semibold text-dc-text", children: "AI Performance Analysis" })
474
+ /* @__PURE__ */ S("div", { className: "dc:relative dc:w-full dc:max-w-4xl dc:max-h-[90vh] bg-dc-surface dc:rounded-lg dc:shadow-xl dc:flex dc:flex-col", children: [
475
+ /* @__PURE__ */ S("div", { className: "dc:flex dc:items-center dc:justify-between dc:px-6 dc:py-4 dc:border-b border-dc-border dc:flex-shrink-0", children: [
476
+ /* @__PURE__ */ S("div", { className: "dc:flex dc:items-center dc:gap-3", children: [
477
+ /* @__PURE__ */ C("span", { className: "dc:text-lg", children: "✨" }),
478
+ /* @__PURE__ */ C("h3", { className: "dc:text-lg dc:font-semibold text-dc-text", children: "AI Performance Analysis" })
552
479
  ] }),
553
- /* @__PURE__ */ p(
480
+ /* @__PURE__ */ C(
554
481
  "button",
555
482
  {
556
483
  onClick: n,
557
484
  className: "dc:p-2 dc:rounded-lg hover:bg-dc-surface-hover text-dc-text-secondary hover:text-dc-text dc:transition-colors",
558
485
  "aria-label": "Close",
559
- children: /* @__PURE__ */ p("svg", { className: "dc:w-5 dc:h-5", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ p("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M6 18L18 6M6 6l12 12" }) })
486
+ children: /* @__PURE__ */ C("svg", { className: "dc:w-5 dc:h-5", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ C("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M6 18L18 6M6 6l12 12" }) })
560
487
  }
561
488
  )
562
489
  ] }),
563
- /* @__PURE__ */ b("div", { className: "dc:flex-1 dc:overflow-y-auto dc:px-6 dc:py-4 dc:space-y-6", children: [
564
- /* @__PURE__ */ p(
565
- yr,
490
+ /* @__PURE__ */ S("div", { className: "dc:flex-1 dc:overflow-y-auto dc:px-6 dc:py-4 dc:space-y-6", children: [
491
+ /* @__PURE__ */ C(
492
+ ur,
566
493
  {
567
494
  assessment: t.assessment,
568
495
  reason: t.assessmentReason
569
496
  }
570
497
  ),
571
- /* @__PURE__ */ b("div", { children: [
572
- /* @__PURE__ */ p("h4", { className: "dc:text-sm dc:font-semibold text-dc-text-muted dc:uppercase dc:mb-2", children: "Summary" }),
573
- /* @__PURE__ */ p("p", { className: "text-dc-text", children: j(t.summary) })
498
+ /* @__PURE__ */ S("div", { children: [
499
+ /* @__PURE__ */ C("h4", { className: "dc:text-sm dc:font-semibold text-dc-text-muted dc:uppercase dc:mb-2", children: "Summary" }),
500
+ /* @__PURE__ */ C("p", { className: "text-dc-text", children: H(t.summary) })
574
501
  ] }),
575
- t.queryUnderstanding && /* @__PURE__ */ b("div", { children: [
576
- /* @__PURE__ */ p("h4", { className: "dc:text-sm dc:font-semibold text-dc-text-muted dc:uppercase dc:mb-2", children: "Query Analysis" }),
577
- /* @__PURE__ */ p("p", { className: "text-dc-text-secondary", children: j(t.queryUnderstanding) })
502
+ t.queryUnderstanding && /* @__PURE__ */ S("div", { children: [
503
+ /* @__PURE__ */ C("h4", { className: "dc:text-sm dc:font-semibold text-dc-text-muted dc:uppercase dc:mb-2", children: "Query Analysis" }),
504
+ /* @__PURE__ */ C("p", { className: "text-dc-text-secondary", children: H(t.queryUnderstanding) })
578
505
  ] }),
579
- t.issues && t.issues.length > 0 && /* @__PURE__ */ b("div", { children: [
580
- /* @__PURE__ */ b("h4", { className: "dc:text-sm dc:font-semibold text-dc-text-muted dc:uppercase dc:mb-2", children: [
506
+ t.issues && t.issues.length > 0 && /* @__PURE__ */ S("div", { children: [
507
+ /* @__PURE__ */ S("h4", { className: "dc:text-sm dc:font-semibold text-dc-text-muted dc:uppercase dc:mb-2", children: [
581
508
  "Issues Found (",
582
509
  t.issues.length,
583
510
  ")"
584
511
  ] }),
585
- /* @__PURE__ */ p("div", { className: "dc:space-y-1 bg-dc-surface-secondary dc:rounded-lg dc:p-3", children: t.issues.map((r, s) => /* @__PURE__ */ p(gr, { issue: r }, s)) })
512
+ /* @__PURE__ */ C("div", { className: "dc:space-y-1 bg-dc-surface-secondary dc:rounded-lg dc:p-3", children: t.issues.map((r, s) => /* @__PURE__ */ C(fr, { issue: r }, s)) })
586
513
  ] }),
587
- t.recommendations && t.recommendations.length > 0 && /* @__PURE__ */ b("div", { children: [
588
- /* @__PURE__ */ b("h4", { className: "dc:text-sm dc:font-semibold text-dc-text-muted dc:uppercase dc:mb-3", children: [
514
+ t.recommendations && t.recommendations.length > 0 && /* @__PURE__ */ S("div", { children: [
515
+ /* @__PURE__ */ S("h4", { className: "dc:text-sm dc:font-semibold text-dc-text-muted dc:uppercase dc:mb-3", children: [
589
516
  "Recommendations (",
590
517
  t.recommendations.length,
591
518
  ")"
592
519
  ] }),
593
- /* @__PURE__ */ p("div", { className: "dc:space-y-4", children: t.recommendations.map((r, s) => /* @__PURE__ */ p(hr, { rec: r }, s)) })
520
+ /* @__PURE__ */ C("div", { className: "dc:space-y-4", children: t.recommendations.map((r, s) => /* @__PURE__ */ C(mr, { rec: r }, s)) })
594
521
  ] }),
595
- (!t.recommendations || t.recommendations.length === 0) && /* @__PURE__ */ p("div", { className: "text-dc-text-muted dc:italic dc:p-4 bg-dc-surface-secondary dc:rounded-lg", children: "No specific recommendations. The query appears to be well-optimized." })
522
+ (!t.recommendations || t.recommendations.length === 0) && /* @__PURE__ */ C("div", { className: "text-dc-text-muted dc:italic dc:p-4 bg-dc-surface-secondary dc:rounded-lg", children: "No specific recommendations. The query appears to be well-optimized." })
596
523
  ] }),
597
- /* @__PURE__ */ b("div", { className: "dc:flex dc:items-center dc:justify-between dc:px-6 dc:py-3 dc:border-t border-dc-border dc:flex-shrink-0 bg-dc-surface-secondary", children: [
598
- t._meta && /* @__PURE__ */ b("div", { className: "dc:text-xs text-dc-text-muted", children: [
524
+ /* @__PURE__ */ S("div", { className: "dc:flex dc:items-center dc:justify-between dc:px-6 dc:py-3 dc:border-t border-dc-border dc:flex-shrink-0 bg-dc-surface-secondary", children: [
525
+ t._meta && /* @__PURE__ */ S("div", { className: "dc:text-xs text-dc-text-muted", children: [
599
526
  "Model: ",
600
527
  t._meta.model,
601
528
  t._meta.usingUserKey && " (using your API key)"
602
529
  ] }),
603
- /* @__PURE__ */ p(
530
+ /* @__PURE__ */ C(
604
531
  "button",
605
532
  {
606
533
  onClick: n,
@@ -612,7 +539,7 @@ function pr({ analysis: t, onClose: i, onClear: e }) {
612
539
  ] })
613
540
  ] });
614
541
  }
615
- const gi = kn(function({
542
+ const di = Rn(function({
616
543
  sql: i,
617
544
  sqlLoading: e = !1,
618
545
  sqlError: n,
@@ -620,68 +547,68 @@ const gi = kn(function({
620
547
  explainResult: s,
621
548
  explainLoading: o = !1,
622
549
  explainHasRun: l = !1,
623
- explainError: d,
550
+ explainError: u,
624
551
  runExplain: f,
625
552
  aiAnalysis: m,
626
553
  aiAnalysisLoading: y = !1,
627
- aiAnalysisError: u,
628
- runAIAnalysis: g,
629
- clearAIAnalysis: S,
554
+ aiAnalysisError: d,
555
+ runAIAnalysis: p,
556
+ clearAIAnalysis: b,
630
557
  enableAI: w = !1,
631
- query: D,
558
+ query: x,
632
559
  title: v = "Generated SQL",
633
- height: h = "16rem"
560
+ height: g = "16rem"
634
561
  }) {
635
- const [x, B] = Ce(!1), [_, Q] = Ce(!1), M = i ? i.sql + (i.params && i.params.length > 0 ? `
562
+ const [D, B] = Pe(!1), [_, Q] = Pe(!1), M = i ? i.sql + (i.params && i.params.length > 0 ? `
636
563
 
637
564
  -- Parameters:
638
565
  ` + JSON.stringify(i.params, null, 2) : "") : "", T = () => {
639
- g && s && D && (g(s, D), Q(!0));
640
- }, C = () => {
566
+ p && s && x && (p(s, x), Q(!0));
567
+ }, h = () => {
641
568
  Q(!1);
642
- }, F = w && s ? /* @__PURE__ */ p(
569
+ }, F = w && s ? /* @__PURE__ */ C(
643
570
  "button",
644
571
  {
645
572
  onClick: T,
646
573
  disabled: y,
647
574
  className: "dc:px-2 dc:py-1 dc:text-xs dc:font-medium dc:rounded bg-dc-accent text-white hover:bg-dc-accent-hover dc:disabled:opacity-50 dc:disabled:cursor-not-allowed dc:flex dc:items-center dc:gap-1",
648
- children: y ? /* @__PURE__ */ b(G, { children: [
649
- /* @__PURE__ */ p("span", { className: "dc:animate-spin", children: "⟳" }),
575
+ children: y ? /* @__PURE__ */ S(z, { children: [
576
+ /* @__PURE__ */ C("span", { className: "dc:animate-spin", children: "⟳" }),
650
577
  "Analyzing..."
651
- ] }) : /* @__PURE__ */ p(G, { children: "✨ AI Analysis" })
578
+ ] }) : /* @__PURE__ */ C(z, { children: "✨ AI Analysis" })
652
579
  }
653
580
  ) : null;
654
- return /* @__PURE__ */ b("div", { className: "dc:space-y-3", children: [
655
- e ? /* @__PURE__ */ b(G, { children: [
656
- /* @__PURE__ */ p("h4", { className: "dc:text-sm dc:font-semibold text-dc-text dc:mb-2", children: v }),
657
- /* @__PURE__ */ p("div", { className: "bg-dc-surface-secondary dc:border border-dc-border dc:rounded dc:p-3 text-dc-text-muted dc:text-sm dc:animate-pulse", style: { height: h }, children: "Loading SQL..." })
658
- ] }) : n ? /* @__PURE__ */ b(G, { children: [
659
- /* @__PURE__ */ p("h4", { className: "dc:text-sm dc:font-semibold text-dc-text dc:mb-2", children: v }),
660
- /* @__PURE__ */ p("div", { className: "text-dc-error dc:text-sm bg-dc-danger-bg dc:p-3 dc:rounded dc:border border-dc-error", style: { height: h }, children: n.message })
661
- ] }) : i ? /* @__PURE__ */ p(
581
+ return /* @__PURE__ */ S("div", { className: "dc:space-y-3", children: [
582
+ e ? /* @__PURE__ */ S(z, { children: [
583
+ /* @__PURE__ */ C("h4", { className: "dc:text-sm dc:font-semibold text-dc-text dc:mb-2", children: v }),
584
+ /* @__PURE__ */ C("div", { className: "bg-dc-surface-secondary dc:border border-dc-border dc:rounded dc:p-3 text-dc-text-muted dc:text-sm dc:animate-pulse", style: { height: g }, children: "Loading SQL..." })
585
+ ] }) : n ? /* @__PURE__ */ S(z, { children: [
586
+ /* @__PURE__ */ C("h4", { className: "dc:text-sm dc:font-semibold text-dc-text dc:mb-2", children: v }),
587
+ /* @__PURE__ */ C("div", { className: "text-dc-error dc:text-sm bg-dc-danger-bg dc:p-3 dc:rounded dc:border border-dc-error", style: { height: g }, children: n.message })
588
+ ] }) : i ? /* @__PURE__ */ C(
662
589
  Ue,
663
590
  {
664
591
  code: M,
665
592
  language: "sql",
666
593
  title: v,
667
- height: h,
668
- headerRight: /* @__PURE__ */ b(G, { children: [
669
- /* @__PURE__ */ b("label", { className: "dc:flex dc:items-center dc:gap-1 dc:text-xs text-dc-text-secondary dc:cursor-pointer", children: [
670
- /* @__PURE__ */ p(
594
+ height: g,
595
+ headerRight: /* @__PURE__ */ S(z, { children: [
596
+ /* @__PURE__ */ S("label", { className: "dc:flex dc:items-center dc:gap-1 dc:text-xs text-dc-text-secondary dc:cursor-pointer", children: [
597
+ /* @__PURE__ */ C(
671
598
  "input",
672
599
  {
673
600
  type: "checkbox",
674
- checked: x,
601
+ checked: D,
675
602
  onChange: (P) => B(P.target.checked),
676
603
  className: "dc:w-3 dc:h-3 dc:rounded border-dc-border text-dc-accent focus:ring-dc-accent"
677
604
  }
678
605
  ),
679
606
  "Include timing"
680
607
  ] }),
681
- /* @__PURE__ */ p(
608
+ /* @__PURE__ */ C(
682
609
  "button",
683
610
  {
684
- onClick: () => f({ analyze: x }),
611
+ onClick: () => f({ analyze: D }),
685
612
  disabled: o,
686
613
  className: "dc:px-2 dc:py-1 dc:text-xs dc:font-medium dc:rounded dc:border border-dc-border bg-dc-surface hover:bg-dc-surface-hover text-dc-text-secondary hover:text-dc-text dc:transition-colors dc:disabled:opacity-50 dc:disabled:cursor-not-allowed",
687
614
  children: o ? "Running..." : "Explain Plan"
@@ -689,49 +616,49 @@ const gi = kn(function({
689
616
  )
690
617
  ] })
691
618
  }
692
- ) : /* @__PURE__ */ b(G, { children: [
693
- /* @__PURE__ */ p("h4", { className: "dc:text-sm dc:font-semibold text-dc-text dc:mb-2", children: v }),
694
- /* @__PURE__ */ p("div", { className: "bg-dc-surface-secondary dc:border border-dc-border dc:rounded dc:p-3 text-dc-text-muted dc:text-sm", style: { height: h }, children: r })
619
+ ) : /* @__PURE__ */ S(z, { children: [
620
+ /* @__PURE__ */ C("h4", { className: "dc:text-sm dc:font-semibold text-dc-text dc:mb-2", children: v }),
621
+ /* @__PURE__ */ C("div", { className: "bg-dc-surface-secondary dc:border border-dc-border dc:rounded dc:p-3 text-dc-text-muted dc:text-sm", style: { height: g }, children: r })
695
622
  ] }),
696
- l && /* @__PURE__ */ p("div", { children: o ? /* @__PURE__ */ b("div", { className: "bg-dc-surface-secondary dc:border border-dc-border dc:rounded dc:p-3 text-dc-text-muted dc:text-sm dc:animate-pulse", children: [
623
+ l && /* @__PURE__ */ C("div", { children: o ? /* @__PURE__ */ S("div", { className: "bg-dc-surface-secondary dc:border border-dc-border dc:rounded dc:p-3 text-dc-text-muted dc:text-sm dc:animate-pulse", children: [
697
624
  "Running EXPLAIN",
698
- x ? " ANALYZE" : "",
625
+ D ? " ANALYZE" : "",
699
626
  "..."
700
- ] }) : d ? /* @__PURE__ */ b("div", { className: "text-dc-error dc:text-sm bg-dc-danger-bg dc:p-3 dc:rounded dc:border border-dc-error", children: [
701
- /* @__PURE__ */ p("strong", { children: "Explain Error:" }),
627
+ ] }) : u ? /* @__PURE__ */ S("div", { className: "text-dc-error dc:text-sm bg-dc-danger-bg dc:p-3 dc:rounded dc:border border-dc-error", children: [
628
+ /* @__PURE__ */ C("strong", { children: "Explain Error:" }),
702
629
  " ",
703
- d.message
704
- ] }) : s ? /* @__PURE__ */ b("div", { className: "dc:space-y-3", children: [
705
- /* @__PURE__ */ b("div", { className: "dc:flex dc:flex-wrap dc:items-center dc:gap-2", children: [
706
- /* @__PURE__ */ p("span", { className: "dc:px-2 dc:py-1 dc:text-xs dc:font-medium bg-dc-accent text-white dc:rounded", children: s.summary.database.toUpperCase() }),
707
- s.summary.hasSequentialScans && /* @__PURE__ */ p("span", { className: "dc:px-2 dc:py-1 dc:text-xs dc:font-medium bg-dc-warning-bg text-dc-warning dc:border border-dc-warning dc:rounded", children: "Sequential Scans Detected" }),
708
- s.summary.usedIndexes.length > 0 && /* @__PURE__ */ b("span", { className: "dc:px-2 dc:py-1 dc:text-xs dc:font-medium bg-dc-success-bg text-dc-success dc:border border-dc-success dc:rounded", children: [
630
+ u.message
631
+ ] }) : s ? /* @__PURE__ */ S("div", { className: "dc:space-y-3", children: [
632
+ /* @__PURE__ */ S("div", { className: "dc:flex dc:flex-wrap dc:items-center dc:gap-2", children: [
633
+ /* @__PURE__ */ C("span", { className: "dc:px-2 dc:py-1 dc:text-xs dc:font-medium bg-dc-accent text-white dc:rounded", children: s.summary.database.toUpperCase() }),
634
+ s.summary.hasSequentialScans && /* @__PURE__ */ C("span", { className: "dc:px-2 dc:py-1 dc:text-xs dc:font-medium bg-dc-warning-bg text-dc-warning dc:border border-dc-warning dc:rounded", children: "Sequential Scans Detected" }),
635
+ s.summary.usedIndexes.length > 0 && /* @__PURE__ */ S("span", { className: "dc:px-2 dc:py-1 dc:text-xs dc:font-medium bg-dc-success-bg text-dc-success dc:border border-dc-success dc:rounded", children: [
709
636
  s.summary.usedIndexes.length,
710
637
  " Index",
711
638
  s.summary.usedIndexes.length !== 1 ? "es" : "",
712
639
  " Used"
713
640
  ] }),
714
- s.summary.executionTime !== void 0 && /* @__PURE__ */ b("span", { className: "dc:px-2 dc:py-1 dc:text-xs dc:font-medium bg-dc-surface-secondary text-dc-text-secondary dc:border border-dc-border dc:rounded", children: [
641
+ s.summary.executionTime !== void 0 && /* @__PURE__ */ S("span", { className: "dc:px-2 dc:py-1 dc:text-xs dc:font-medium bg-dc-surface-secondary text-dc-text-secondary dc:border border-dc-border dc:rounded", children: [
715
642
  "Execution: ",
716
643
  s.summary.executionTime.toFixed(2),
717
644
  "ms"
718
645
  ] }),
719
- s.summary.planningTime !== void 0 && /* @__PURE__ */ b("span", { className: "dc:px-2 dc:py-1 dc:text-xs dc:font-medium bg-dc-surface-secondary text-dc-text-secondary dc:border border-dc-border dc:rounded", children: [
646
+ s.summary.planningTime !== void 0 && /* @__PURE__ */ S("span", { className: "dc:px-2 dc:py-1 dc:text-xs dc:font-medium bg-dc-surface-secondary text-dc-text-secondary dc:border border-dc-border dc:rounded", children: [
720
647
  "Planning: ",
721
648
  s.summary.planningTime.toFixed(2),
722
649
  "ms"
723
650
  ] }),
724
- s.summary.totalCost !== void 0 && /* @__PURE__ */ b("span", { className: "dc:px-2 dc:py-1 dc:text-xs dc:font-medium bg-dc-surface-secondary text-dc-text-secondary dc:border border-dc-border dc:rounded", children: [
651
+ s.summary.totalCost !== void 0 && /* @__PURE__ */ S("span", { className: "dc:px-2 dc:py-1 dc:text-xs dc:font-medium bg-dc-surface-secondary text-dc-text-secondary dc:border border-dc-border dc:rounded", children: [
725
652
  "Cost: ",
726
653
  s.summary.totalCost.toFixed(2)
727
654
  ] })
728
655
  ] }),
729
- s.summary.usedIndexes.length > 0 && /* @__PURE__ */ b("div", { className: "dc:text-xs text-dc-text-muted", children: [
730
- /* @__PURE__ */ p("strong", { children: "Indexes:" }),
656
+ s.summary.usedIndexes.length > 0 && /* @__PURE__ */ S("div", { className: "dc:text-xs text-dc-text-muted", children: [
657
+ /* @__PURE__ */ C("strong", { children: "Indexes:" }),
731
658
  " ",
732
659
  s.summary.usedIndexes.join(", ")
733
660
  ] }),
734
- /* @__PURE__ */ p(
661
+ /* @__PURE__ */ C(
735
662
  Ue,
736
663
  {
737
664
  code: s.raw,
@@ -742,21 +669,21 @@ const gi = kn(function({
742
669
  }
743
670
  )
744
671
  ] }) : null }),
745
- u && /* @__PURE__ */ b("div", { className: "text-dc-error dc:text-sm bg-dc-danger-bg dc:p-3 dc:rounded dc:border border-dc-error", children: [
746
- /* @__PURE__ */ p("strong", { children: "AI Analysis Error:" }),
672
+ d && /* @__PURE__ */ S("div", { className: "text-dc-error dc:text-sm bg-dc-danger-bg dc:p-3 dc:rounded dc:border border-dc-error", children: [
673
+ /* @__PURE__ */ C("strong", { children: "AI Analysis Error:" }),
747
674
  " ",
748
- u.message
675
+ d.message
749
676
  ] }),
750
- _ && m && /* @__PURE__ */ p(
751
- pr,
677
+ _ && m && /* @__PURE__ */ C(
678
+ yr,
752
679
  {
753
680
  analysis: m,
754
- onClose: C
681
+ onClose: h
755
682
  }
756
683
  )
757
684
  ] });
758
685
  });
759
- function ct() {
686
+ function lt() {
760
687
  return {
761
688
  metrics: [],
762
689
  breakdowns: [],
@@ -766,10 +693,10 @@ function ct() {
766
693
  validationError: null
767
694
  };
768
695
  }
769
- function Cr(t) {
696
+ function gr(t) {
770
697
  return t.map((i) => i.field);
771
698
  }
772
- function wr(t, i) {
699
+ function hr(t, i) {
773
700
  const e = [], n = [];
774
701
  for (const r of t)
775
702
  if (r.isTimeDimension) {
@@ -778,7 +705,7 @@ function wr(t, i) {
778
705
  granularity: r.granularity || "day"
779
706
  };
780
707
  if (r.enableComparison) {
781
- const o = wt(r.field, i);
708
+ const o = Ct(r.field, i);
782
709
  o && (s.compareDateRange = o);
783
710
  }
784
711
  n.push(s);
@@ -786,24 +713,24 @@ function wr(t, i) {
786
713
  e.push(r.field);
787
714
  return { dimensions: e, timeDimensions: n };
788
715
  }
789
- function br(t) {
790
- const { dimensions: i, timeDimensions: e } = wr(
716
+ function pr(t) {
717
+ const { dimensions: i, timeDimensions: e } = hr(
791
718
  t.breakdowns,
792
719
  t.filters
793
720
  ), n = {
794
- measures: Cr(t.metrics),
721
+ measures: gr(t.metrics),
795
722
  dimensions: i
796
723
  };
797
724
  return e.length > 0 && (n.timeDimensions = e), t.filters.length > 0 && (n.filters = t.filters), t.order && Object.keys(t.order).length > 0 && (n.order = t.order), n;
798
725
  }
799
- function Sr(t) {
726
+ function Cr(t) {
800
727
  return t.map((i, e) => ({
801
728
  id: $(),
802
729
  field: i,
803
- label: we(e)
730
+ label: pe(e)
804
731
  }));
805
732
  }
806
- function vr(t) {
733
+ function wr(t) {
807
734
  const i = [];
808
735
  if (t.dimensions)
809
736
  for (const e of t.dimensions)
@@ -825,24 +752,24 @@ function vr(t) {
825
752
  }
826
753
  return i;
827
754
  }
828
- function dt(t) {
755
+ function ct(t) {
829
756
  return {
830
- metrics: Sr(t.measures || []),
831
- breakdowns: vr(t),
757
+ metrics: Cr(t.measures || []),
758
+ breakdowns: wr(t),
832
759
  filters: t.filters || [],
833
760
  order: t.order,
834
761
  validationStatus: "idle",
835
762
  validationError: null
836
763
  };
837
764
  }
838
- function xr(t) {
765
+ function Sr(t) {
839
766
  return typeof t == "object" && t !== null && "queries" in t && Array.isArray(t.queries);
840
767
  }
841
768
  const K = {
842
769
  type: "query",
843
770
  createInitial() {
844
771
  return {
845
- queryStates: [ct()],
772
+ queryStates: [lt()],
846
773
  activeQueryIndex: 0,
847
774
  mergeStrategy: "concat"
848
775
  };
@@ -865,22 +792,22 @@ const K = {
865
792
  `Cannot load ${t.analysisType} config with query adapter`
866
793
  );
867
794
  const i = t;
868
- if (xr(i.query)) {
869
- const e = i.query, n = e.queries.map(dt);
870
- return n.length === 0 && n.push(ct()), {
795
+ if (Sr(i.query)) {
796
+ const e = i.query, n = e.queries.map(ct);
797
+ return n.length === 0 && n.push(lt()), {
871
798
  queryStates: n,
872
799
  activeQueryIndex: 0,
873
800
  mergeStrategy: e.mergeStrategy || "concat"
874
801
  };
875
802
  }
876
803
  return {
877
- queryStates: [dt(i.query)],
804
+ queryStates: [ct(i.query)],
878
805
  activeQueryIndex: 0,
879
806
  mergeStrategy: "concat"
880
807
  };
881
808
  },
882
809
  save(t, i, e) {
883
- const n = t.queryStates.map(br), s = n.length === 1 && t.mergeStrategy === "concat" ? n[0] : {
810
+ const n = t.queryStates.map(pr), s = n.length === 1 && t.mergeStrategy === "concat" ? n[0] : {
884
811
  queries: n,
885
812
  mergeStrategy: t.mergeStrategy
886
813
  };
@@ -904,8 +831,8 @@ const K = {
904
831
  (o) => o.field
905
832
  );
906
833
  t.queryStates.every((o) => {
907
- const l = o.breakdowns.map((d) => d.field);
908
- return l.length === r.length && l.every((d) => r.includes(d));
834
+ const l = o.breakdowns.map((u) => u.field);
835
+ return l.length === r.length && l.every((u) => r.includes(u));
909
836
  }) || e.push(
910
837
  "Queries have different breakdowns - merge results may be unexpected"
911
838
  );
@@ -928,8 +855,8 @@ const K = {
928
855
  }
929
856
  }, E = /* @__PURE__ */ new Map();
930
857
  let _e = !1;
931
- function Ee() {
932
- _e || (E.has("query") || E.set("query", K), E.has("funnel") || E.set("funnel", W), E.has("flow") || E.set("flow", J), E.has("retention") || E.set("retention", Y), _e = !0);
858
+ function Ne() {
859
+ _e || (E.has("query") || E.set("query", K), E.has("funnel") || E.set("funnel", W), E.has("flow") || E.set("flow", J), E.has("retention") || E.set("retention", X), _e = !0);
933
860
  }
934
861
  const L = {
935
862
  /**
@@ -952,7 +879,7 @@ const L = {
952
879
  * @throws Error if no adapter is registered for the type
953
880
  */
954
881
  get(t) {
955
- Ee();
882
+ Ne();
956
883
  const i = E.get(t);
957
884
  if (!i)
958
885
  throw new Error(
@@ -968,7 +895,7 @@ const L = {
968
895
  * @returns True if an adapter is registered
969
896
  */
970
897
  has(t) {
971
- return Ee(), E.has(t);
898
+ return Ne(), E.has(t);
972
899
  },
973
900
  /**
974
901
  * Get all registered analysis types.
@@ -977,7 +904,7 @@ const L = {
977
904
  * @returns Array of registered types
978
905
  */
979
906
  getRegisteredTypes() {
980
- return Ee(), Array.from(E.keys());
907
+ return Ne(), Array.from(E.keys());
981
908
  },
982
909
  /**
983
910
  * Clear all registered adapters.
@@ -994,7 +921,7 @@ const L = {
994
921
  query: K.getDefaultChartConfig(),
995
922
  funnel: W.getDefaultChartConfig(),
996
923
  flow: J.getDefaultChartConfig(),
997
- retention: Y.getDefaultChartConfig()
924
+ retention: X.getDefaultChartConfig()
998
925
  },
999
926
  // Per-mode active view preference
1000
927
  activeViews: {
@@ -1005,7 +932,7 @@ const L = {
1005
932
  },
1006
933
  userManuallySelectedChart: !1,
1007
934
  localPaletteName: "default"
1008
- }), Dr = (t, i) => ({
935
+ }), br = (t, i) => ({
1009
936
  ...Dt(),
1010
937
  setAnalysisType: (e) => {
1011
938
  t((n) => {
@@ -1185,18 +1112,18 @@ const L = {
1185
1112
  s,
1186
1113
  e.charts,
1187
1114
  o
1188
- ), d = L.get("funnel"), f = d.extractState(n), m = e.activeViews.funnel ?? e.activeView ?? "chart", y = d.save(
1115
+ ), u = L.get("funnel"), f = u.extractState(n), m = e.activeViews.funnel ?? e.activeView ?? "chart", y = u.save(
1189
1116
  f,
1190
1117
  e.charts,
1191
1118
  m
1192
- ), u = L.get("flow"), g = u.extractState(n), S = e.activeViews.flow ?? e.activeView ?? "chart", w = u.save(
1193
- g,
1119
+ ), d = L.get("flow"), p = d.extractState(n), b = e.activeViews.flow ?? e.activeView ?? "chart", w = d.save(
1120
+ p,
1194
1121
  e.charts,
1195
- S
1196
- ), D = L.get("retention"), v = D.extractState(n), h = e.activeViews.retention ?? e.activeView ?? "chart", x = D.save(
1122
+ b
1123
+ ), x = L.get("retention"), v = x.extractState(n), g = e.activeViews.retention ?? e.activeView ?? "chart", D = x.save(
1197
1124
  v,
1198
1125
  e.charts,
1199
- h
1126
+ g
1200
1127
  );
1201
1128
  return {
1202
1129
  version: 1,
@@ -1205,22 +1132,22 @@ const L = {
1205
1132
  query: l,
1206
1133
  funnel: y,
1207
1134
  flow: w,
1208
- retention: x
1135
+ retention: D
1209
1136
  }
1210
1137
  };
1211
1138
  },
1212
1139
  loadWorkspace: (e) => {
1213
1140
  const n = L.get("query"), r = L.get("funnel"), s = L.get("flow"), o = L.get("retention");
1214
- let l = {}, d = {}, f = {}, m = {}, y = { ...i().charts }, u = { ...i().activeViews };
1215
- e.modes.query && n.canLoad(e.modes.query) && (l = n.load(e.modes.query), y = { ...y, ...e.modes.query.charts }, u.query = e.modes.query.activeView ?? "chart"), e.modes.funnel && r.canLoad(e.modes.funnel) && (d = r.load(e.modes.funnel), y = { ...y, ...e.modes.funnel.charts }, u.funnel = e.modes.funnel.activeView ?? "chart"), e.modes.flow && s.canLoad(e.modes.flow) && (f = s.load(e.modes.flow), y = { ...y, ...e.modes.flow.charts }, u.flow = e.modes.flow.activeView ?? "chart"), e.modes.retention && o.canLoad(e.modes.retention) && (m = o.load(e.modes.retention), y = { ...y, ...e.modes.retention.charts }, u.retention = e.modes.retention.activeView ?? "chart");
1216
- const S = e.modes[e.activeType]?.activeView ?? "chart";
1141
+ let l = {}, u = {}, f = {}, m = {}, y = { ...i().charts }, d = { ...i().activeViews };
1142
+ e.modes.query && n.canLoad(e.modes.query) && (l = n.load(e.modes.query), y = { ...y, ...e.modes.query.charts }, d.query = e.modes.query.activeView ?? "chart"), e.modes.funnel && r.canLoad(e.modes.funnel) && (u = r.load(e.modes.funnel), y = { ...y, ...e.modes.funnel.charts }, d.funnel = e.modes.funnel.activeView ?? "chart"), e.modes.flow && s.canLoad(e.modes.flow) && (f = s.load(e.modes.flow), y = { ...y, ...e.modes.flow.charts }, d.flow = e.modes.flow.activeView ?? "chart"), e.modes.retention && o.canLoad(e.modes.retention) && (m = o.load(e.modes.retention), y = { ...y, ...e.modes.retention.charts }, d.retention = e.modes.retention.activeView ?? "chart");
1143
+ const b = e.modes[e.activeType]?.activeView ?? "chart";
1217
1144
  t({
1218
1145
  analysisType: e.activeType,
1219
1146
  charts: y,
1220
- activeViews: u,
1221
- activeView: S,
1147
+ activeViews: d,
1148
+ activeView: b,
1222
1149
  ...l,
1223
- ...d,
1150
+ ...u,
1224
1151
  ...f,
1225
1152
  ...m
1226
1153
  });
@@ -1229,7 +1156,7 @@ const L = {
1229
1156
  queryStates: [R()],
1230
1157
  activeQueryIndex: 0,
1231
1158
  mergeStrategy: "concat"
1232
- }), Tr = (t, i) => ({
1159
+ }), vr = (t, i) => ({
1233
1160
  ...Le(),
1234
1161
  // ==========================================================================
1235
1162
  // Query State Management
@@ -1266,58 +1193,58 @@ const L = {
1266
1193
  // Metrics Actions
1267
1194
  // ==========================================================================
1268
1195
  addMetric: (e, n) => t((r) => {
1269
- const s = r.activeQueryIndex, o = [...r.queryStates], l = o[s] || R(), d = {
1196
+ const s = r.activeQueryIndex, o = [...r.queryStates], l = o[s] || R(), u = {
1270
1197
  id: $(),
1271
1198
  field: e,
1272
- label: n || we(l.metrics.length)
1199
+ label: n || pe(l.metrics.length)
1273
1200
  };
1274
1201
  return o[s] = {
1275
1202
  ...l,
1276
- metrics: [...l.metrics, d]
1203
+ metrics: [...l.metrics, u]
1277
1204
  }, { queryStates: o };
1278
1205
  }),
1279
1206
  removeMetric: (e) => t((n) => {
1280
- const r = n.activeQueryIndex, s = [...n.queryStates], o = s[r] || R(), l = o.metrics.find((m) => m.id === e)?.field, d = o.metrics.filter((m) => m.id !== e);
1207
+ const r = n.activeQueryIndex, s = [...n.queryStates], o = s[r] || R(), l = o.metrics.find((m) => m.id === e)?.field, u = o.metrics.filter((m) => m.id !== e);
1281
1208
  let f = o.order;
1282
1209
  return l && f && f[l] && (f = { ...f }, delete f[l], Object.keys(f).length === 0 && (f = void 0)), s[r] = {
1283
1210
  ...o,
1284
- metrics: d,
1211
+ metrics: u,
1285
1212
  order: f
1286
1213
  }, { queryStates: s };
1287
1214
  }),
1288
1215
  toggleMetric: (e) => t((n) => {
1289
- const r = n.activeQueryIndex, s = [...n.queryStates], o = s[r] || R(), l = o.metrics.findIndex((d) => d.field === e);
1216
+ const r = n.activeQueryIndex, s = [...n.queryStates], o = s[r] || R(), l = o.metrics.findIndex((u) => u.field === e);
1290
1217
  if (l >= 0)
1291
1218
  s[r] = {
1292
1219
  ...o,
1293
- metrics: o.metrics.filter((d, f) => f !== l)
1220
+ metrics: o.metrics.filter((u, f) => f !== l)
1294
1221
  };
1295
1222
  else {
1296
- const d = {
1223
+ const u = {
1297
1224
  id: $(),
1298
1225
  field: e,
1299
- label: we(o.metrics.length)
1226
+ label: pe(o.metrics.length)
1300
1227
  };
1301
1228
  s[r] = {
1302
1229
  ...o,
1303
- metrics: [...o.metrics, d]
1230
+ metrics: [...o.metrics, u]
1304
1231
  };
1305
1232
  }
1306
1233
  return { queryStates: s };
1307
1234
  }),
1308
1235
  reorderMetrics: (e, n) => t((r) => {
1309
- const s = r.activeQueryIndex, o = [...r.queryStates], l = o[s] || R(), d = [...l.metrics], [f] = d.splice(e, 1);
1310
- return d.splice(n, 0, f), o[s] = {
1236
+ const s = r.activeQueryIndex, o = [...r.queryStates], l = o[s] || R(), u = [...l.metrics], [f] = u.splice(e, 1);
1237
+ return u.splice(n, 0, f), o[s] = {
1311
1238
  ...l,
1312
- metrics: d
1239
+ metrics: u
1313
1240
  }, { queryStates: o };
1314
1241
  }),
1315
1242
  // ==========================================================================
1316
1243
  // Breakdowns Actions
1317
1244
  // ==========================================================================
1318
1245
  addBreakdown: (e, n, r) => t((s) => {
1319
- const o = s.activeQueryIndex, l = [...s.queryStates], d = l[o] || R();
1320
- if (n && d.breakdowns.some((y) => y.isTimeDimension))
1246
+ const o = s.activeQueryIndex, l = [...s.queryStates], u = l[o] || R();
1247
+ if (n && u.breakdowns.some((y) => y.isTimeDimension))
1321
1248
  return s;
1322
1249
  const f = {
1323
1250
  id: $(),
@@ -1326,28 +1253,28 @@ const L = {
1326
1253
  granularity: n ? r || "month" : void 0
1327
1254
  };
1328
1255
  return l[o] = {
1329
- ...d,
1330
- breakdowns: [...d.breakdowns, f]
1256
+ ...u,
1257
+ breakdowns: [...u.breakdowns, f]
1331
1258
  }, { queryStates: l };
1332
1259
  }),
1333
1260
  removeBreakdown: (e) => t((n) => {
1334
- const r = n.activeQueryIndex, s = [...n.queryStates], o = s[r] || R(), l = o.breakdowns.find((m) => m.id === e)?.field, d = o.breakdowns.filter((m) => m.id !== e);
1261
+ const r = n.activeQueryIndex, s = [...n.queryStates], o = s[r] || R(), l = o.breakdowns.find((m) => m.id === e)?.field, u = o.breakdowns.filter((m) => m.id !== e);
1335
1262
  let f = o.order;
1336
1263
  return l && f && f[l] && (f = { ...f }, delete f[l], Object.keys(f).length === 0 && (f = void 0)), s[r] = {
1337
1264
  ...o,
1338
- breakdowns: d,
1265
+ breakdowns: u,
1339
1266
  order: f
1340
1267
  }, { queryStates: s };
1341
1268
  }),
1342
1269
  toggleBreakdown: (e, n, r) => t((s) => {
1343
- const o = s.activeQueryIndex, l = [...s.queryStates], d = l[o] || R(), f = d.breakdowns.findIndex((m) => m.field === e);
1270
+ const o = s.activeQueryIndex, l = [...s.queryStates], u = l[o] || R(), f = u.breakdowns.findIndex((m) => m.field === e);
1344
1271
  if (f >= 0)
1345
1272
  l[o] = {
1346
- ...d,
1347
- breakdowns: d.breakdowns.filter((m, y) => y !== f)
1273
+ ...u,
1274
+ breakdowns: u.breakdowns.filter((m, y) => y !== f)
1348
1275
  };
1349
1276
  else {
1350
- if (n && d.breakdowns.some((u) => u.isTimeDimension))
1277
+ if (n && u.breakdowns.some((d) => d.isTimeDimension))
1351
1278
  return s;
1352
1279
  const m = {
1353
1280
  id: $(),
@@ -1356,67 +1283,67 @@ const L = {
1356
1283
  granularity: n ? r || "month" : void 0
1357
1284
  };
1358
1285
  l[o] = {
1359
- ...d,
1360
- breakdowns: [...d.breakdowns, m]
1286
+ ...u,
1287
+ breakdowns: [...u.breakdowns, m]
1361
1288
  };
1362
1289
  }
1363
1290
  return { queryStates: l };
1364
1291
  }),
1365
1292
  setBreakdownGranularity: (e, n) => t((r) => {
1366
- const { mergeStrategy: s, activeQueryIndex: o, queryStates: l } = r, d = [...l], f = s === "merge" && o > 0 ? 0 : o;
1367
- return d[f] = {
1368
- ...d[f],
1369
- breakdowns: d[f].breakdowns.map(
1293
+ const { mergeStrategy: s, activeQueryIndex: o, queryStates: l } = r, u = [...l], f = s === "merge" && o > 0 ? 0 : o;
1294
+ return u[f] = {
1295
+ ...u[f],
1296
+ breakdowns: u[f].breakdowns.map(
1370
1297
  (m) => m.id === e ? { ...m, granularity: n } : m
1371
1298
  )
1372
- }, { queryStates: d };
1299
+ }, { queryStates: u };
1373
1300
  }),
1374
1301
  toggleBreakdownComparison: (e) => t((n) => {
1375
- const { mergeStrategy: r, activeQueryIndex: s, queryStates: o, charts: l, analysisType: d } = n, f = [...o], m = r === "merge" && s > 0 ? 0 : s, y = f[m].breakdowns.find((w) => w.id === e), u = y && !y.enableComparison, g = f[m].breakdowns.map((w) => w.id === e ? { ...w, enableComparison: !w.enableComparison } : w.isTimeDimension && w.enableComparison ? { ...w, enableComparison: !1 } : w);
1302
+ const { mergeStrategy: r, activeQueryIndex: s, queryStates: o, charts: l, analysisType: u } = n, f = [...o], m = r === "merge" && s > 0 ? 0 : s, y = f[m].breakdowns.find((w) => w.id === e), d = y && !y.enableComparison, p = f[m].breakdowns.map((w) => w.id === e ? { ...w, enableComparison: !w.enableComparison } : w.isTimeDimension && w.enableComparison ? { ...w, enableComparison: !1 } : w);
1376
1303
  f[m] = {
1377
1304
  ...f[m],
1378
- breakdowns: g
1305
+ breakdowns: p
1379
1306
  };
1380
- const S = { queryStates: f };
1381
- if (u && y?.isTimeDimension && y.field) {
1307
+ const b = { queryStates: f };
1308
+ if (d && y?.isTimeDimension && y.field) {
1382
1309
  const w = f[m].filters || [];
1383
- if (!w.some((h) => {
1384
- if ("member" in h) {
1385
- const x = h;
1386
- return x.member === y.field && x.operator === "inDateRange";
1310
+ if (!w.some((g) => {
1311
+ if ("member" in g) {
1312
+ const D = g;
1313
+ return D.member === y.field && D.operator === "inDateRange";
1387
1314
  }
1388
1315
  return !1;
1389
1316
  })) {
1390
- const h = {
1317
+ const g = {
1391
1318
  member: y.field,
1392
1319
  operator: "inDateRange",
1393
1320
  values: [],
1394
- dateRange: zn("last_n_months", 3)
1321
+ dateRange: On("last_n_months", 3)
1395
1322
  };
1396
1323
  f[m] = {
1397
1324
  ...f[m],
1398
- filters: [...w, h]
1399
- }, S.queryStates = f;
1325
+ filters: [...w, g]
1326
+ }, b.queryStates = f;
1400
1327
  }
1401
- const v = l[d];
1402
- v && v.chartType !== "line" && (S.charts = {
1328
+ const v = l[u];
1329
+ v && v.chartType !== "line" && (b.charts = {
1403
1330
  ...l,
1404
- [d]: {
1331
+ [u]: {
1405
1332
  ...v,
1406
1333
  chartType: "line"
1407
1334
  }
1408
- }, S.userManuallySelectedChart = !1, S.activeView = "chart", S.activeViews = {
1335
+ }, b.userManuallySelectedChart = !1, b.activeView = "chart", b.activeViews = {
1409
1336
  ...n.activeViews,
1410
- [d]: "chart"
1337
+ [u]: "chart"
1411
1338
  });
1412
1339
  }
1413
- return S;
1340
+ return b;
1414
1341
  }),
1415
1342
  reorderBreakdowns: (e, n) => t((r) => {
1416
- const s = r.activeQueryIndex, o = [...r.queryStates], l = o[s] || R(), d = [...l.breakdowns], [f] = d.splice(e, 1);
1417
- return d.splice(n, 0, f), o[s] = {
1343
+ const s = r.activeQueryIndex, o = [...r.queryStates], l = o[s] || R(), u = [...l.breakdowns], [f] = u.splice(e, 1);
1344
+ return u.splice(n, 0, f), o[s] = {
1418
1345
  ...l,
1419
- breakdowns: d
1346
+ breakdowns: u
1420
1347
  }, { queryStates: o };
1421
1348
  }),
1422
1349
  // ==========================================================================
@@ -1451,10 +1378,10 @@ const L = {
1451
1378
  }, { queryStates: s };
1452
1379
  }),
1453
1380
  setOrder: (e, n) => t((r) => {
1454
- const s = r.activeQueryIndex, o = [...r.queryStates], l = o[s] || R(), d = { ...l.order || {} };
1455
- return n === null ? delete d[e] : d[e] = n, o[s] = {
1381
+ const s = r.activeQueryIndex, o = [...r.queryStates], l = o[s] || R(), u = { ...l.order || {} };
1382
+ return n === null ? delete u[e] : u[e] = n, o[s] = {
1456
1383
  ...l,
1457
- order: Object.keys(d).length > 0 ? d : void 0
1384
+ order: Object.keys(u).length > 0 ? u : void 0
1458
1385
  }, { queryStates: o };
1459
1386
  }),
1460
1387
  // ==========================================================================
@@ -1480,13 +1407,13 @@ const L = {
1480
1407
  },
1481
1408
  buildCurrentQuery: () => {
1482
1409
  const e = i(), n = e.queryStates[e.activeQueryIndex] || R();
1483
- return be(n.metrics, n.breakdowns, n.filters, n.order);
1410
+ return Ce(n.metrics, n.breakdowns, n.filters, n.order);
1484
1411
  },
1485
1412
  buildAllQueries: () => {
1486
1413
  const e = i(), n = e.queryStates[0]?.breakdowns || [];
1487
1414
  return e.queryStates.map((r, s) => {
1488
1415
  const o = e.mergeStrategy === "merge" && s > 0 ? n : r.breakdowns;
1489
- return be(r.metrics, o, r.filters, r.order);
1416
+ return Ce(r.metrics, o, r.filters, r.order);
1490
1417
  });
1491
1418
  },
1492
1419
  buildMultiQueryConfig: () => {
@@ -1508,7 +1435,7 @@ const L = {
1508
1435
  funnelBindingKey: null,
1509
1436
  stepTimeToConvert: []
1510
1437
  // Deprecated - kept for backward compat
1511
- }), Fr = (t, i) => ({
1438
+ }), Dr = (t, i) => ({
1512
1439
  ...Ke(),
1513
1440
  addFunnelStep: () => t((e) => {
1514
1441
  const n = e.funnelSteps[e.funnelSteps.length - 1], r = {
@@ -1600,7 +1527,7 @@ const L = {
1600
1527
  stepsAfter: 3,
1601
1528
  eventDimension: null,
1602
1529
  joinStrategy: "auto"
1603
- }), Ar = (t, i) => ({
1530
+ }), xr = (t, i) => ({
1604
1531
  ...$e(),
1605
1532
  setFlowCube: (e) => t(() => ({
1606
1533
  flowCube: e,
@@ -1651,10 +1578,10 @@ const L = {
1651
1578
  };
1652
1579
  }),
1653
1580
  setStepsBefore: (e) => t({
1654
- stepsBefore: Math.max(at, Math.min(ot, e))
1581
+ stepsBefore: Math.max(st, Math.min(at, e))
1655
1582
  }),
1656
1583
  setStepsAfter: (e) => t({
1657
- stepsAfter: Math.max(at, Math.min(ot, e))
1584
+ stepsAfter: Math.max(st, Math.min(at, e))
1658
1585
  }),
1659
1586
  setJoinStrategy: (e) => t(() => ({
1660
1587
  joinStrategy: e
@@ -1671,9 +1598,9 @@ const L = {
1671
1598
  if (typeof e.flowBindingKey.dimension == "string")
1672
1599
  n = e.flowBindingKey.dimension;
1673
1600
  else if (Array.isArray(e.flowBindingKey.dimension))
1674
- n = e.flowBindingKey.dimension.map((d) => ({
1675
- cube: d.cube,
1676
- dimension: d.dimension
1601
+ n = e.flowBindingKey.dimension.map((u) => ({
1602
+ cube: u.cube,
1603
+ dimension: u.dimension
1677
1604
  }));
1678
1605
  else
1679
1606
  return null;
@@ -1696,7 +1623,7 @@ const L = {
1696
1623
  }
1697
1624
  }), Ge = () => ({
1698
1625
  ..._n
1699
- }), Qr = (t, i) => ({
1626
+ }), Tr = (t, i) => ({
1700
1627
  ...Ge(),
1701
1628
  setRetentionCube: (e) => t(() => ({
1702
1629
  retentionCube: e,
@@ -1797,22 +1724,22 @@ const L = {
1797
1724
  warnings: r
1798
1725
  };
1799
1726
  }
1800
- }), Tt = {
1727
+ }), xt = {
1801
1728
  isOpen: !1,
1802
1729
  userPrompt: "",
1803
1730
  isGenerating: !1,
1804
1731
  error: null,
1805
1732
  hasGeneratedQuery: !1,
1806
1733
  previousState: null
1807
- }, Mr = () => ({
1734
+ }, Fr = () => ({
1808
1735
  activeTab: "query",
1809
1736
  activeView: "chart",
1810
1737
  displayLimit: 100,
1811
1738
  showFieldModal: !1,
1812
1739
  fieldModalMode: "metrics",
1813
- aiState: Tt
1814
- }), Rr = (t, i) => ({
1815
- ...Mr(),
1740
+ aiState: xt
1741
+ }), Ar = (t, i) => ({
1742
+ ...Fr(),
1816
1743
  // ==========================================================================
1817
1744
  // Tab/View Actions
1818
1745
  // ==========================================================================
@@ -1891,11 +1818,11 @@ const L = {
1891
1818
  displayConfig: n.displayConfig
1892
1819
  }
1893
1820
  },
1894
- aiState: { ...Tt }
1821
+ aiState: { ...xt }
1895
1822
  };
1896
1823
  })
1897
1824
  });
1898
- function ut(t) {
1825
+ function dt(t) {
1899
1826
  const i = t.filters ? [...t.filters] : [], e = t.timeDimensions || [], n = [
1900
1827
  ...(t.dimensions || []).map((s) => ({
1901
1828
  id: $(),
@@ -1915,8 +1842,8 @@ function ut(t) {
1915
1842
  if (!s.compareDateRange || s.compareDateRange.length === 0) continue;
1916
1843
  const o = r.some(
1917
1844
  (f) => "member" in f && f.member === s.dimension && f.operator === "inDateRange"
1918
- ), l = s.compareDateRange[0], d = Array.isArray(l) || typeof l == "string" ? l : void 0;
1919
- if (d) {
1845
+ ), l = s.compareDateRange[0], u = Array.isArray(l) || typeof l == "string" ? l : void 0;
1846
+ if (u) {
1920
1847
  if (!o) {
1921
1848
  r = [
1922
1849
  ...r,
@@ -1924,12 +1851,12 @@ function ut(t) {
1924
1851
  member: s.dimension,
1925
1852
  operator: "inDateRange",
1926
1853
  values: [],
1927
- dateRange: d
1854
+ dateRange: u
1928
1855
  }
1929
1856
  ];
1930
1857
  continue;
1931
1858
  }
1932
- r = r.map((f) => "member" in f && f.member === s.dimension && f.operator === "inDateRange" && !f.dateRange ? { ...f, dateRange: d } : f);
1859
+ r = r.map((f) => "member" in f && f.member === s.dimension && f.operator === "inDateRange" && !f.dateRange ? { ...f, dateRange: u } : f);
1933
1860
  }
1934
1861
  }
1935
1862
  return {
@@ -1937,17 +1864,17 @@ function ut(t) {
1937
1864
  metrics: (t.measures || []).map((s, o) => ({
1938
1865
  id: $(),
1939
1866
  field: s,
1940
- label: we(o)
1867
+ label: pe(o)
1941
1868
  })),
1942
1869
  breakdowns: n,
1943
1870
  filters: r,
1944
1871
  order: t.order
1945
1872
  };
1946
1873
  }
1947
- function kr(t) {
1874
+ function Qr(t) {
1948
1875
  return "queries" in t && Array.isArray(t.queries);
1949
1876
  }
1950
- function Ir(t) {
1877
+ function Mr(t) {
1951
1878
  if (t.initialAnalysisType === "funnel" && t.initialFunnelState) {
1952
1879
  const i = W.getDefaultChartConfig(), e = {
1953
1880
  chartType: t.initialChartConfig?.chartType || i.chartType,
@@ -1988,7 +1915,7 @@ function Ir(t) {
1988
1915
  );
1989
1916
  }
1990
1917
  if (t.initialAnalysisType === "retention" && t.initialRetentionState) {
1991
- const i = Y.getDefaultChartConfig(), e = {
1918
+ const i = X.getDefaultChartConfig(), e = {
1992
1919
  chartType: t.initialChartConfig?.chartType || i.chartType,
1993
1920
  chartConfig: t.initialChartConfig?.chartConfig || i.chartConfig,
1994
1921
  displayConfig: t.initialChartConfig?.displayConfig || i.displayConfig
@@ -2004,7 +1931,7 @@ function Ir(t) {
2004
1931
  retentionPeriods: t.initialRetentionState.retentionPeriods ?? 12,
2005
1932
  retentionType: t.initialRetentionState.retentionType ?? "classic"
2006
1933
  };
2007
- return Y.save(
1934
+ return X.save(
2008
1935
  r,
2009
1936
  { retention: e },
2010
1937
  t.initialActiveView || "chart"
@@ -2013,7 +1940,7 @@ function Ir(t) {
2013
1940
  if (t.initialQuery) {
2014
1941
  const i = t.initialQuery;
2015
1942
  let e, n = "concat";
2016
- kr(i) ? (e = i.queries.map(ut), i.mergeStrategy && (n = i.mergeStrategy)) : e = [ut(i)];
1943
+ Qr(i) ? (e = i.queries.map(dt), i.mergeStrategy && (n = i.mergeStrategy)) : e = [dt(i)];
2017
1944
  const r = K.getDefaultChartConfig(), s = {
2018
1945
  chartType: t.initialChartConfig?.chartType || r.chartType,
2019
1946
  chartConfig: t.initialChartConfig?.chartConfig || r.chartConfig,
@@ -2043,7 +1970,7 @@ function Ir(t) {
2043
1970
  t.initialActiveView
2044
1971
  ) : null;
2045
1972
  }
2046
- function qr(t, i) {
1973
+ function Rr(t, i) {
2047
1974
  return {
2048
1975
  reset: () => {
2049
1976
  t({
@@ -2057,7 +1984,7 @@ function qr(t, i) {
2057
1984
  query: K.getDefaultChartConfig(),
2058
1985
  funnel: W.getDefaultChartConfig(),
2059
1986
  flow: J.getDefaultChartConfig(),
2060
- retention: Y.getDefaultChartConfig()
1987
+ retention: X.getDefaultChartConfig()
2061
1988
  },
2062
1989
  activeViews: {
2063
1990
  query: "chart",
@@ -2090,7 +2017,7 @@ function qr(t, i) {
2090
2017
  ...Ge(),
2091
2018
  charts: {
2092
2019
  ...e.charts,
2093
- retention: Y.getDefaultChartConfig()
2020
+ retention: X.getDefaultChartConfig()
2094
2021
  }
2095
2022
  };
2096
2023
  default:
@@ -2121,37 +2048,37 @@ function qr(t, i) {
2121
2048
  }
2122
2049
  };
2123
2050
  }
2124
- function Br(t = {}) {
2125
- const i = Ir(t), e = (n, r, s) => ({
2051
+ function kr(t = {}) {
2052
+ const i = Mr(t), e = (n, r, s) => ({
2126
2053
  // Compose slices - they provide default state and actions
2054
+ ...br(n, r),
2055
+ ...vr(n, r),
2127
2056
  ...Dr(n, r),
2057
+ ...xr(n, r),
2128
2058
  ...Tr(n, r),
2129
- ...Fr(n, r),
2130
- ...Ar(n, r),
2131
- ...Qr(n, r),
2132
- ...Rr(n),
2059
+ ...Ar(n),
2133
2060
  // Cross-slice actions
2134
- ...qr(n, r)
2061
+ ...Rr(n, r)
2135
2062
  });
2136
2063
  if (t.disableLocalStorage) {
2137
- const n = rt()(
2138
- it(st(e), {
2064
+ const n = nt()(
2065
+ rt(it(e), {
2139
2066
  name: "AnalysisBuilderStore (no-persist)"
2140
2067
  })
2141
2068
  );
2142
2069
  return i && n.getState().load(i), n;
2143
2070
  }
2144
- return rt()(
2145
- it(
2146
- st(
2071
+ return nt()(
2072
+ rt(
2073
+ it(
2147
2074
  Pn(e, {
2148
- name: sr,
2075
+ name: nr,
2149
2076
  // Use workspace format to preserve ALL modes' state
2150
2077
  partialize: (n) => n.saveWorkspace(),
2151
- merge: (n, r) => n && On(n) ? {
2078
+ merge: (n, r) => n && qn(n) ? {
2152
2079
  ...r,
2153
2080
  _persistedWorkspace: n
2154
- } : n && ht(n) ? {
2081
+ } : n && yt(n) ? {
2155
2082
  ...r,
2156
2083
  _persistedConfig: n
2157
2084
  } : i ? {
@@ -2178,8 +2105,8 @@ function Br(t = {}) {
2178
2105
  )
2179
2106
  );
2180
2107
  }
2181
- const We = In(null);
2182
- function hi({
2108
+ const We = kn(null);
2109
+ function ui({
2183
2110
  children: t,
2184
2111
  initialQuery: i,
2185
2112
  initialChartConfig: e,
@@ -2188,10 +2115,10 @@ function hi({
2188
2115
  initialFunnelState: s,
2189
2116
  initialFlowState: o,
2190
2117
  initialRetentionState: l,
2191
- initialActiveView: d
2118
+ initialActiveView: u
2192
2119
  }) {
2193
- const f = ae(null);
2194
- return f.current || (f.current = Br({
2120
+ const f = Se(null);
2121
+ return f.current || (f.current = kr({
2195
2122
  initialQuery: i,
2196
2123
  initialChartConfig: e,
2197
2124
  disableLocalStorage: n,
@@ -2199,22 +2126,22 @@ function hi({
2199
2126
  initialFunnelState: s,
2200
2127
  initialFlowState: o,
2201
2128
  initialRetentionState: l,
2202
- initialActiveView: d
2203
- })), /* @__PURE__ */ p(We.Provider, { value: f.current, children: t });
2129
+ initialActiveView: u
2130
+ })), /* @__PURE__ */ C(We.Provider, { value: f.current, children: t });
2204
2131
  }
2205
2132
  function c(t) {
2206
- const i = yt(We);
2133
+ const i = mt(We);
2207
2134
  if (!i)
2208
2135
  throw new Error("useAnalysisBuilderStore must be used within AnalysisBuilderStoreProvider");
2209
2136
  return En(i, t);
2210
2137
  }
2211
- function Nr() {
2212
- const t = yt(We);
2138
+ function Ir() {
2139
+ const t = mt(We);
2213
2140
  if (!t)
2214
2141
  throw new Error("useAnalysisBuilderStoreApi must be used within AnalysisBuilderStoreProvider");
2215
2142
  return t;
2216
2143
  }
2217
- const Je = (t) => t.queryStates[t.activeQueryIndex] || R(), pi = (t) => Je(t).metrics, Ci = (t) => Je(t).breakdowns, wi = (t) => Je(t).filters, Vr = (t) => {
2144
+ const Je = (t) => t.queryStates[t.activeQueryIndex] || R(), fi = (t) => Je(t).metrics, mi = (t) => Je(t).breakdowns, yi = (t) => Je(t).filters, qr = (t) => {
2218
2145
  const i = t.charts[t.analysisType];
2219
2146
  return i ? {
2220
2147
  chartType: i.chartType,
@@ -2225,19 +2152,19 @@ const Je = (t) => t.queryStates[t.activeQueryIndex] || R(), pi = (t) => Je(t).me
2225
2152
  chartConfig: {},
2226
2153
  displayConfig: { showLegend: !0, showGrid: !0, showTooltip: !0 }
2227
2154
  };
2228
- }, bi = (t) => ({
2155
+ }, gi = (t) => ({
2229
2156
  activeTab: t.activeTab,
2230
2157
  activeView: t.activeView,
2231
2158
  displayLimit: t.displayLimit,
2232
2159
  showFieldModal: t.showFieldModal,
2233
2160
  fieldModalMode: t.fieldModalMode
2234
- }), Si = (t) => ({
2161
+ }), hi = (t) => ({
2235
2162
  queryStates: t.queryStates,
2236
2163
  activeQueryIndex: t.activeQueryIndex,
2237
2164
  mergeStrategy: t.mergeStrategy,
2238
2165
  // Multi-query mode is when we have more than one query in 'query' analysis type
2239
2166
  isMultiQueryMode: t.analysisType === "query" && t.queryStates.length > 1
2240
- }), vi = (t) => ({
2167
+ }), pi = (t) => ({
2241
2168
  funnelCube: t.funnelCube,
2242
2169
  funnelSteps: t.funnelSteps,
2243
2170
  activeFunnelStepIndex: t.activeFunnelStepIndex,
@@ -2247,16 +2174,16 @@ const Je = (t) => t.queryStates[t.activeQueryIndex] || R(), pi = (t) => Je(t).me
2247
2174
  // Deprecated field kept for backward compat
2248
2175
  stepTimeToConvert: t.stepTimeToConvert
2249
2176
  });
2250
- function ft(t) {
2177
+ function ut(t) {
2251
2178
  return t.timeDimensions || [];
2252
2179
  }
2253
- function Er(t) {
2180
+ function Br(t) {
2254
2181
  const i = [];
2255
2182
  if (t.length < 2) return i;
2256
- const e = ft(t[0]);
2183
+ const e = ut(t[0]);
2257
2184
  if (e.length === 0) return i;
2258
2185
  for (let n = 1; n < t.length; n++) {
2259
- const r = ft(t[n]);
2186
+ const r = ut(t[n]);
2260
2187
  if (r.length === 0 && e.length > 0) {
2261
2188
  i.push({
2262
2189
  type: "missing_time_dimension",
@@ -2282,7 +2209,7 @@ function Er(t) {
2282
2209
  }
2283
2210
  return i;
2284
2211
  }
2285
- function Pr(t, i) {
2212
+ function Vr(t, i) {
2286
2213
  const e = [];
2287
2214
  if (t.length < 2 || i.length === 0) return e;
2288
2215
  for (let n = 0; n < t.length; n++) {
@@ -2300,7 +2227,7 @@ function Pr(t, i) {
2300
2227
  }
2301
2228
  return e;
2302
2229
  }
2303
- function Ur(t) {
2230
+ function Nr(t) {
2304
2231
  const i = [];
2305
2232
  if (t.length < 2) return i;
2306
2233
  const e = /* @__PURE__ */ new Map();
@@ -2319,7 +2246,7 @@ function Ur(t) {
2319
2246
  affectedMeasures: n
2320
2247
  }), i;
2321
2248
  }
2322
- function _r(t) {
2249
+ function Er(t) {
2323
2250
  const i = [];
2324
2251
  if (t.length < 2) return i;
2325
2252
  const e = t.map((r) => r.timeDimensions?.[0]?.dateRange);
@@ -2329,56 +2256,56 @@ function _r(t) {
2329
2256
  message: "Queries have different date ranges - some data points may be missing in merged results"
2330
2257
  }), i;
2331
2258
  }
2332
- function Lr(t, i, e = []) {
2259
+ function Pr(t, i, e = []) {
2333
2260
  const n = [], r = [];
2334
- return t.length < 2 ? { isValid: !0, errors: n, warnings: r } : (r.push(...Ur(t)), r.push(..._r(t)), i === "merge" && (n.push(...Er(t)), e.length > 0 && n.push(...Pr(t, e))), {
2261
+ return t.length < 2 ? { isValid: !0, errors: n, warnings: r } : (r.push(...Nr(t)), r.push(...Er(t)), i === "merge" && (n.push(...Br(t)), e.length > 0 && n.push(...Vr(t, e))), {
2335
2262
  isValid: n.length === 0,
2336
2263
  errors: n,
2337
2264
  warnings: r
2338
2265
  });
2339
2266
  }
2340
- function xi(t) {
2267
+ function Ci(t) {
2341
2268
  return t.filter(
2342
2269
  (i) => (i.measures?.length || 0) + (i.dimensions?.length || 0) + (i.timeDimensions?.length || 0) > 0
2343
2270
  ).length >= 2;
2344
2271
  }
2345
- function Di(t) {
2272
+ function wi(t) {
2346
2273
  if (t.isValid && t.warnings.length === 0)
2347
2274
  return "Configuration is valid";
2348
2275
  const i = [];
2349
2276
  return t.errors.length > 0 && i.push(`${t.errors.length} error${t.errors.length > 1 ? "s" : ""}`), t.warnings.length > 0 && i.push(`${t.warnings.length} warning${t.warnings.length > 1 ? "s" : ""}`), i.join(", ");
2350
2277
  }
2351
- function Kr() {
2352
- const t = c((h) => h.queryStates), i = c((h) => h.activeQueryIndex), e = c((h) => h.mergeStrategy), n = c((h) => h.setActiveQueryIndex), r = c((h) => h.setMergeStrategy), s = c((h) => h.addQuery), o = c((h) => h.removeQuery), l = c((h) => h.getCurrentState), d = c((h) => h.getMergeKeys), f = c((h) => h.isMultiQueryMode), m = l(), y = f(), u = d(), g = A(() => {
2353
- const h = t[i] || m;
2354
- return be(h.metrics, h.breakdowns, h.filters, h.order);
2355
- }, [t, i, m]), S = A(() => {
2356
- const h = t[0]?.breakdowns || [];
2357
- return t.map((x, B) => {
2358
- const _ = e === "merge" && B > 0 ? h : x.breakdowns;
2359
- return be(x.metrics, _, x.filters, x.order);
2278
+ function Ur() {
2279
+ const t = c((g) => g.queryStates), i = c((g) => g.activeQueryIndex), e = c((g) => g.mergeStrategy), n = c((g) => g.setActiveQueryIndex), r = c((g) => g.setMergeStrategy), s = c((g) => g.addQuery), o = c((g) => g.removeQuery), l = c((g) => g.getCurrentState), u = c((g) => g.getMergeKeys), f = c((g) => g.isMultiQueryMode), m = l(), y = f(), d = u(), p = A(() => {
2280
+ const g = t[i] || m;
2281
+ return Ce(g.metrics, g.breakdowns, g.filters, g.order);
2282
+ }, [t, i, m]), b = A(() => {
2283
+ const g = t[0]?.breakdowns || [];
2284
+ return t.map((D, B) => {
2285
+ const _ = e === "merge" && B > 0 ? g : D.breakdowns;
2286
+ return Ce(D.metrics, _, D.filters, D.order);
2360
2287
  });
2361
2288
  }, [t, e]), w = A(() => {
2362
2289
  if (t.length <= 1) return null;
2363
- const h = S.filter((x) => x.measures && x.measures.length > 0 || x.dimensions && x.dimensions.length > 0 || x.timeDimensions && x.timeDimensions.length > 0);
2364
- return h.length < 2 ? null : {
2365
- queries: h,
2290
+ const g = b.filter((D) => D.measures && D.measures.length > 0 || D.dimensions && D.dimensions.length > 0 || D.timeDimensions && D.timeDimensions.length > 0);
2291
+ return g.length < 2 ? null : {
2292
+ queries: g,
2366
2293
  mergeStrategy: e,
2367
- mergeKeys: u,
2368
- queryLabels: h.map((x, B) => `Q${B + 1}`)
2294
+ mergeKeys: d,
2295
+ queryLabels: g.map((D, B) => `Q${B + 1}`)
2369
2296
  };
2370
- }, [S, t.length, e, u]), D = A(() => y ? Lr(S, e, u || []) : null, [y, S, e, u]), v = A(() => g.measures && g.measures.length > 0 || g.dimensions && g.dimensions.length > 0 || g.timeDimensions && g.timeDimensions.length > 0, [g]);
2297
+ }, [b, t.length, e, d]), x = A(() => y ? Pr(b, e, d || []) : null, [y, b, e, d]), v = A(() => p.measures && p.measures.length > 0 || p.dimensions && p.dimensions.length > 0 || p.timeDimensions && p.timeDimensions.length > 0, [p]);
2371
2298
  return {
2372
2299
  queryState: m,
2373
2300
  queryStates: t,
2374
2301
  activeQueryIndex: i,
2375
2302
  mergeStrategy: e,
2376
2303
  isMultiQueryMode: y,
2377
- mergeKeys: u,
2378
- currentQuery: g,
2379
- allQueries: S,
2304
+ mergeKeys: d,
2305
+ currentQuery: p,
2306
+ allQueries: b,
2380
2307
  multiQueryConfig: w,
2381
- multiQueryValidation: D,
2308
+ multiQueryValidation: x,
2382
2309
  isValidQuery: v,
2383
2310
  // Actions
2384
2311
  setActiveQueryIndex: n,
@@ -2387,17 +2314,17 @@ function Kr() {
2387
2314
  removeQuery: o
2388
2315
  };
2389
2316
  }
2390
- function $r(t) {
2317
+ function _r(t) {
2391
2318
  const { queryState: i, queryStates: e, isMultiQueryMode: n, mergeStrategy: r, activeQueryIndex: s } = t, o = A(() => {
2392
2319
  if (!n) return i.metrics;
2393
2320
  const f = /* @__PURE__ */ new Set(), m = [];
2394
2321
  for (let y = 0; y < e.length; y++) {
2395
- const u = e[y];
2396
- for (const g of u.metrics) {
2397
- const S = `Q${y + 1}:${g.field}`;
2398
- f.has(S) || (f.add(S), m.push({
2399
- ...g,
2400
- label: `${g.label} (Q${y + 1})`
2322
+ const d = e[y];
2323
+ for (const p of d.metrics) {
2324
+ const b = `Q${y + 1}:${p.field}`;
2325
+ f.has(b) || (f.add(b), m.push({
2326
+ ...p,
2327
+ label: `${p.label} (Q${y + 1})`
2401
2328
  }));
2402
2329
  }
2403
2330
  }
@@ -2406,17 +2333,17 @@ function $r(t) {
2406
2333
  if (!n) return i.breakdowns;
2407
2334
  const f = /* @__PURE__ */ new Set(), m = [];
2408
2335
  for (const y of e)
2409
- for (const u of y.breakdowns)
2410
- f.has(u.field) || (f.add(u.field), m.push(u));
2336
+ for (const d of y.breakdowns)
2337
+ f.has(d.field) || (f.add(d.field), m.push(d));
2411
2338
  return m;
2412
- }, [n, e, i.breakdowns]), d = A(() => r === "merge" && s > 0 ? e[0]?.breakdowns || [] : i.breakdowns, [r, s, e, i.breakdowns]);
2339
+ }, [n, e, i.breakdowns]), u = A(() => r === "merge" && s > 0 ? e[0]?.breakdowns || [] : i.breakdowns, [r, s, e, i.breakdowns]);
2413
2340
  return {
2414
2341
  combinedMetrics: o,
2415
2342
  combinedBreakdowns: l,
2416
- effectiveBreakdowns: d
2343
+ effectiveBreakdowns: u
2417
2344
  };
2418
2345
  }
2419
- function Gr(t) {
2346
+ function Lr(t) {
2420
2347
  const {
2421
2348
  currentQuery: i,
2422
2349
  allQueries: e,
@@ -2426,135 +2353,135 @@ function Gr(t) {
2426
2353
  initialData: o,
2427
2354
  // Unused - legacy mergeStrategy === 'funnel' is no longer supported
2428
2355
  funnelBindingKey: l,
2429
- isFunnelModeEnabled: d,
2356
+ isFunnelModeEnabled: u,
2430
2357
  analysisType: f,
2431
2358
  serverFunnelQuery: m,
2432
2359
  serverFlowQuery: y,
2433
- serverRetentionQuery: u,
2434
- retentionValidation: g
2435
- } = t, { getFieldLabel: S } = Nn(), w = f === "funnel" || d, D = f === "flow", v = f === "retention", h = f === "query" && r, x = f === "query" && !r, B = f === "funnel" && !!m, _ = A(() => B || !w || !l || e.length < 2 ? null : er(e, l), [B, w, l, e]), Q = Wn(i, {
2436
- skip: !s || !x,
2360
+ serverRetentionQuery: d,
2361
+ retentionValidation: p
2362
+ } = t, { getFieldLabel: b } = Vn(), w = f === "funnel" || u, x = f === "flow", v = f === "retention", g = f === "query" && r, D = f === "query" && !r, B = f === "funnel" && !!m, _ = A(() => B || !w || !l || e.length < 2 ? null : Xn(e, l), [B, w, l, e]), Q = Hn(i, {
2363
+ skip: !s || !D,
2437
2364
  debounceMs: 300
2438
- }), M = Jn(n, {
2439
- skip: !n || !h,
2365
+ }), M = jn(n, {
2366
+ skip: !n || !g,
2440
2367
  debounceMs: 300
2441
- }), T = Yn(_, {
2368
+ }), T = zn(_, {
2442
2369
  skip: !w || !_ && !m,
2443
2370
  debounceMs: 300,
2444
2371
  prebuiltServerQuery: B ? m : void 0
2445
- }), C = Xn(y ?? null, {
2446
- skip: !D || !y,
2372
+ }), h = Wn(y ?? null, {
2373
+ skip: !x || !y,
2447
2374
  debounceMs: 300
2448
- }), F = Zn(u ?? null, {
2449
- skip: !v || !u,
2375
+ }), F = Jn(d ?? null, {
2376
+ skip: !v || !d,
2450
2377
  debounceMs: 300,
2451
- getFieldLabel: S
2378
+ getFieldLabel: b
2452
2379
  // Pass label resolver for human-readable binding key display
2453
- }), P = tr({
2380
+ }), P = Yn({
2454
2381
  queries: r ? e : [i],
2455
2382
  isMultiQueryMode: r,
2456
- skip: !s || w || D || v
2457
- }), X = Ne(
2383
+ skip: !s || w || x || v
2384
+ }), Y = Be(
2458
2385
  T.serverQuery,
2459
2386
  { skip: !w || !T.serverQuery }
2460
- ), ve = Ne(
2461
- C.serverQuery,
2462
- { skip: !D || !C.serverQuery }
2463
- ), oe = Ne(
2464
- u,
2465
- { skip: !v || !u }
2466
- ), H = v ? F.isLoading || F.isDebouncing : D ? C.isLoading || C.isDebouncing : w ? T.isExecuting || T.isDebouncing : h ? M.isLoading : Q.isLoading, z = v ? F.isFetching : D ? C.isFetching : w ? T.isExecuting : h ? M.isFetching : Q.isFetching, O = v ? F.error : D ? C.error : w ? T.error : h ? M.error : Q.error, Z = !!(Q.debouncedQuery || M.debouncedConfig || !T.isDebouncing || // Funnel has debounced when not debouncing
2467
- !C.isDebouncing || // Flow has debounced when not debouncing
2387
+ ), be = Be(
2388
+ h.serverQuery,
2389
+ { skip: !x || !h.serverQuery }
2390
+ ), se = Be(
2391
+ d,
2392
+ { skip: !v || !d }
2393
+ ), G = v ? F.isLoading || F.isDebouncing : x ? h.isLoading || h.isDebouncing : w ? T.isExecuting || T.isDebouncing : g ? M.isLoading : Q.isLoading, j = v ? F.isFetching : x ? h.isFetching : w ? T.isExecuting : g ? M.isFetching : Q.isFetching, O = v ? F.error : x ? h.error : w ? T.error : g ? M.error : Q.error, Z = !!(Q.debouncedQuery || M.debouncedConfig || !T.isDebouncing || // Funnel has debounced when not debouncing
2394
+ !h.isDebouncing || // Flow has debounced when not debouncing
2468
2395
  !F.isDebouncing), ee = U((k) => {
2469
- v ? F.execute(k) : D ? C.refetch(k) : w ? T.execute(k) : h ? M.refetch(k) : Q.refetch(k);
2470
- }, [v, D, w, h, F, C, T, M, Q]), te = A(() => {
2471
- const k = v ? F.chartData : D ? C.data : w ? T.chartData : h ? M.data : Q.rawData;
2472
- return o && o.length > 0 && !k ? "success" : s ? H && !k ? "loading" : z && k ? "refreshing" : O ? "error" : k ? "success" : "idle" : "idle";
2473
- }, [s, H, z, O, Q.rawData, M.data, T.chartData, C.data, F.chartData, o, h, w, D, v]), ne = A(() => v && F.chartData ? F.chartData.rows.map((k) => ({
2396
+ v ? F.execute(k) : x ? h.refetch(k) : w ? T.execute(k) : g ? M.refetch(k) : Q.refetch(k);
2397
+ }, [v, x, w, g, F, h, T, M, Q]), te = A(() => {
2398
+ const k = v ? F.chartData : x ? h.data : w ? T.chartData : g ? M.data : Q.rawData;
2399
+ return o && o.length > 0 && !k ? "success" : s ? G && !k ? "loading" : j && k ? "refreshing" : O ? "error" : k ? "success" : "idle" : "idle";
2400
+ }, [s, G, j, O, Q.rawData, M.data, T.chartData, h.data, F.chartData, o, g, w, x, v]), ne = A(() => v && F.chartData ? F.chartData.rows.map((k) => ({
2474
2401
  "Retention.period": `P${k.period}`,
2475
2402
  "Retention.rate": k.retentionRate,
2476
2403
  "Retention.retained": k.retainedUsers,
2477
2404
  "Retention.cohortSize": k.cohortSize,
2478
2405
  "Retention.segment": k.breakdownValue || "All Users"
2479
- })) : D && C.data ? [C.data] : w && T.chartData ? T.chartData : h && M.data ? M.data : Q.rawData ? Q.rawData : o && o.length > 0 ? o : null, [Q.rawData, M.data, T.chartData, C.data, F.chartData, o, h, w, D, v]), le = A(() => w && T.stepResults ? T.stepResults.map((k) => k.data) : !h || !M.perQueryData ? null : M.perQueryData, [h, w, M.perQueryData, T.stepResults]), ce = w && T.executedQueries?.length > 0 ? T.executedQueries : null, de = w ? T.serverQuery : null, ue = w ? X.debugData : null, fe = D ? C.serverQuery : null, me = D ? C.data : null, ye = D ? ve.debugData : null, ge = v ? u ?? null : null, xe = v ? F.chartData : null, De = v ? oe.debugData : null, Te = A(() => v ? F.needsRefresh : D ? C.needsRefresh : w ? T.needsRefresh : h ? !1 : Q.needsRefresh, [v, D, w, h, F.needsRefresh, C.needsRefresh, T.needsRefresh, Q.needsRefresh]), Fe = A(() => {
2480
- if (x && Q.warnings)
2406
+ })) : x && h.data ? [h.data] : w && T.chartData ? T.chartData : g && M.data ? M.data : Q.rawData ? Q.rawData : o && o.length > 0 ? o : null, [Q.rawData, M.data, T.chartData, h.data, F.chartData, o, g, w, x, v]), ae = A(() => w && T.stepResults ? T.stepResults.map((k) => k.data) : !g || !M.perQueryData ? null : M.perQueryData, [g, w, M.perQueryData, T.stepResults]), oe = w && T.executedQueries?.length > 0 ? T.executedQueries : null, le = w ? T.serverQuery : null, ce = w ? Y.debugData : null, de = x ? h.serverQuery : null, ue = x ? h.data : null, fe = x ? be.debugData : null, me = v ? d ?? null : null, ve = v ? F.chartData : null, De = v ? se.debugData : null, xe = A(() => v ? F.needsRefresh : x ? h.needsRefresh : w ? T.needsRefresh : g ? !1 : Q.needsRefresh, [v, x, w, g, F.needsRefresh, h.needsRefresh, T.needsRefresh, Q.needsRefresh]), Te = A(() => {
2407
+ if (D && Q.warnings)
2481
2408
  return Q.warnings;
2482
- }, [x, Q.warnings]);
2409
+ }, [D, Q.warnings]);
2483
2410
  return {
2484
2411
  executionStatus: te,
2485
2412
  executionResults: ne,
2486
- perQueryResults: le,
2487
- isLoading: H,
2488
- isFetching: z,
2413
+ perQueryResults: ae,
2414
+ isLoading: G,
2415
+ isFetching: j,
2489
2416
  error: O,
2490
2417
  debugDataPerQuery: P.debugDataPerQuery,
2491
2418
  hasDebounced: Z,
2492
2419
  refetch: ee,
2493
- funnelExecutedQueries: ce,
2494
- funnelServerQuery: de,
2495
- funnelDebugData: ue,
2496
- flowServerQuery: fe,
2497
- flowChartData: me,
2498
- flowDebugData: ye,
2499
- retentionServerQuery: ge,
2500
- retentionChartData: xe,
2420
+ funnelExecutedQueries: oe,
2421
+ funnelServerQuery: le,
2422
+ funnelDebugData: ce,
2423
+ flowServerQuery: de,
2424
+ flowChartData: ue,
2425
+ flowDebugData: fe,
2426
+ retentionServerQuery: me,
2427
+ retentionChartData: ve,
2501
2428
  retentionDebugData: De,
2502
- retentionValidation: g ?? null,
2503
- needsRefresh: Te,
2504
- warnings: Fe
2429
+ retentionValidation: p ?? null,
2430
+ needsRefresh: xe,
2431
+ warnings: Te
2505
2432
  };
2506
2433
  }
2507
- function Hr(t) {
2508
- const { externalColorPalette: i, combinedMetrics: e, combinedBreakdowns: n, hasDebounced: r } = t, s = c((C) => C.analysisType), { chartType: o, chartConfig: l, displayConfig: d } = c(Un(Vr)), f = c((C) => C.userManuallySelectedChart), m = c((C) => C.localPaletteName), y = c((C) => C.setChartTypeManual), u = c((C) => C.setChartConfig), g = c((C) => C.setDisplayConfig), S = c((C) => C.setFunnelChartType), w = c((C) => C.setFunnelChartConfig), D = c((C) => C.setFunnelDisplayConfig), v = c((C) => C.setLocalPaletteName), h = c((C) => C.setUserManuallySelectedChart), x = U(
2509
- (C) => {
2434
+ function Kr(t) {
2435
+ const { externalColorPalette: i, combinedMetrics: e, combinedBreakdowns: n, hasDebounced: r } = t, s = c((h) => h.analysisType), { chartType: o, chartConfig: l, displayConfig: u } = c(Un(qr)), f = c((h) => h.userManuallySelectedChart), m = c((h) => h.localPaletteName), y = c((h) => h.setChartTypeManual), d = c((h) => h.setChartConfig), p = c((h) => h.setDisplayConfig), b = c((h) => h.setFunnelChartType), w = c((h) => h.setFunnelChartConfig), x = c((h) => h.setFunnelDisplayConfig), v = c((h) => h.setLocalPaletteName), g = c((h) => h.setUserManuallySelectedChart), D = U(
2436
+ (h) => {
2510
2437
  if (s === "funnel")
2511
- S(C);
2438
+ b(h);
2512
2439
  else {
2513
- y(C);
2440
+ y(h);
2514
2441
  const { chartConfig: F } = Ve(
2515
2442
  e,
2516
2443
  n,
2517
- C
2444
+ h
2518
2445
  );
2519
- u(F);
2446
+ d(F);
2520
2447
  }
2521
2448
  },
2522
2449
  [
2523
2450
  s,
2524
2451
  e,
2525
2452
  n,
2526
- S,
2453
+ b,
2527
2454
  y,
2528
- u
2455
+ d
2529
2456
  ]
2530
2457
  ), B = U(
2531
- (C) => {
2532
- s === "funnel" ? w(C) : u(C);
2458
+ (h) => {
2459
+ s === "funnel" ? w(h) : d(h);
2533
2460
  },
2534
- [s, w, u]
2461
+ [s, w, d]
2535
2462
  ), _ = U(
2536
- (C) => {
2537
- s === "funnel" ? D(C) : g(C);
2463
+ (h) => {
2464
+ s === "funnel" ? x(h) : p(h);
2538
2465
  },
2539
- [s, D, g]
2466
+ [s, x, p]
2540
2467
  ), Q = A(
2541
- () => lr(e, n),
2468
+ () => sr(e, n),
2542
2469
  [e, n]
2543
2470
  ), M = A(() => i ? Array.isArray(i) && typeof i[0] == "string" ? {
2544
2471
  name: "custom",
2545
2472
  label: "Custom",
2546
2473
  colors: i,
2547
2474
  gradient: i
2548
- } : i : jn(m), [i, m]), T = ae("");
2549
- return se(() => {
2475
+ } : i : Bn(m), [i, m]), T = Se("");
2476
+ return he(() => {
2550
2477
  if (!r || e.length === 0 && n.length === 0) return;
2551
- const C = JSON.stringify({
2478
+ const h = JSON.stringify({
2552
2479
  metrics: e.map((P) => P.field),
2553
2480
  breakdowns: n.map((P) => ({ field: P.field, isTime: P.isTimeDimension }))
2554
2481
  });
2555
- if (C === T.current) return;
2556
- T.current = C;
2557
- const F = dr(
2482
+ if (h === T.current) return;
2483
+ T.current = h;
2484
+ const F = or(
2558
2485
  e,
2559
2486
  n,
2560
2487
  o,
@@ -2566,14 +2493,14 @@ function Hr(t) {
2566
2493
  n,
2567
2494
  F
2568
2495
  );
2569
- x(F), B(P), h(!1);
2496
+ D(F), B(P), g(!1);
2570
2497
  } else if ((e.length > 0 || n.length > 0) && !l.xAxis?.length && !l.yAxis?.length && !l.series?.length) {
2571
- const { chartConfig: X } = Ve(
2498
+ const { chartConfig: Y } = Ve(
2572
2499
  e,
2573
2500
  n,
2574
2501
  o
2575
2502
  );
2576
- B(X);
2503
+ B(Y);
2577
2504
  }
2578
2505
  }, [
2579
2506
  r,
@@ -2582,26 +2509,26 @@ function Hr(t) {
2582
2509
  o,
2583
2510
  f,
2584
2511
  l,
2585
- x,
2512
+ D,
2586
2513
  B,
2587
- h
2514
+ g
2588
2515
  ]), {
2589
2516
  chartType: o,
2590
2517
  chartConfig: l,
2591
- displayConfig: d,
2518
+ displayConfig: u,
2592
2519
  colorPalette: M,
2593
2520
  localPaletteName: m,
2594
2521
  chartAvailability: Q,
2595
2522
  userManuallySelectedChart: f,
2596
2523
  // Actions - mode-aware setters route to appropriate store fields
2597
- setChartType: x,
2524
+ setChartType: D,
2598
2525
  setChartConfig: B,
2599
2526
  setDisplayConfig: _,
2600
2527
  setLocalPaletteName: v
2601
2528
  };
2602
2529
  }
2603
- function Or() {
2604
- const t = c((u) => u.activeTab), i = c((u) => u.activeView), e = c((u) => u.displayLimit), n = c((u) => u.showFieldModal), r = c((u) => u.fieldModalMode), s = c((u) => u.userManuallySelectedChart), o = c((u) => u.setActiveTab), l = c((u) => u.setActiveView), d = c((u) => u.setDisplayLimit), f = c((u) => u.closeFieldModal), [m, y] = Ce(0);
2530
+ function $r() {
2531
+ const t = c((d) => d.activeTab), i = c((d) => d.activeView), e = c((d) => d.displayLimit), n = c((d) => d.showFieldModal), r = c((d) => d.fieldModalMode), s = c((d) => d.userManuallySelectedChart), o = c((d) => d.setActiveTab), l = c((d) => d.setActiveView), u = c((d) => d.setDisplayLimit), f = c((d) => d.closeFieldModal), [m, y] = Pe(0);
2605
2532
  return {
2606
2533
  // State
2607
2534
  activeTab: t,
@@ -2614,37 +2541,37 @@ function Or() {
2614
2541
  // Actions
2615
2542
  setActiveTab: o,
2616
2543
  setActiveView: l,
2617
- setDisplayLimit: d,
2544
+ setDisplayLimit: u,
2618
2545
  closeFieldModal: f,
2619
2546
  setActiveTableIndex: y
2620
2547
  };
2621
2548
  }
2622
- const Se = 1800, He = "share=";
2623
- function Oe(t) {
2549
+ const we = 1800, Oe = "share=";
2550
+ function He(t) {
2624
2551
  const i = JSON.stringify(t);
2625
2552
  return gt.compressToEncodedURIComponent(i);
2626
2553
  }
2627
- function jr(t) {
2554
+ function Gr(t) {
2628
2555
  try {
2629
2556
  const i = gt.decompressFromEncodedURIComponent(t);
2630
2557
  if (!i) return null;
2631
2558
  const e = JSON.parse(i);
2632
- return ht(e) ? e : (console.warn("[shareUtils] Invalid AnalysisConfig in share URL"), null);
2559
+ return yt(e) ? e : (console.warn("[shareUtils] Invalid AnalysisConfig in share URL"), null);
2633
2560
  } catch {
2634
2561
  return null;
2635
2562
  }
2636
2563
  }
2637
- function Ti(t) {
2638
- const i = Oe(t);
2564
+ function Si(t) {
2565
+ const i = He(t);
2639
2566
  return {
2640
- ok: i.length <= Se,
2567
+ ok: i.length <= we,
2641
2568
  size: i.length,
2642
- maxSize: Se
2569
+ maxSize: we
2643
2570
  };
2644
2571
  }
2645
- function zr(t) {
2646
- const i = Oe(t);
2647
- if (i.length <= Se)
2572
+ function Or(t) {
2573
+ const i = He(t);
2574
+ if (i.length <= we)
2648
2575
  return { encoded: i, queryOnly: !1 };
2649
2576
  const e = {
2650
2577
  version: t.version,
@@ -2653,28 +2580,28 @@ function zr(t) {
2653
2580
  charts: {},
2654
2581
  // Drop chart config to save space
2655
2582
  query: t.query
2656
- }, n = Oe(e);
2657
- return n.length <= Se ? { encoded: n, queryOnly: !0 } : { encoded: null, queryOnly: !0 };
2583
+ }, n = He(e);
2584
+ return n.length <= we ? { encoded: n, queryOnly: !0 } : { encoded: null, queryOnly: !0 };
2658
2585
  }
2659
- function Fi(t) {
2660
- const { encoded: i } = zr(t);
2661
- return i ? `${window.location.origin}${window.location.pathname}#${He}${i}` : null;
2586
+ function bi(t) {
2587
+ const { encoded: i } = Or(t);
2588
+ return i ? `${window.location.origin}${window.location.pathname}#${Oe}${i}` : null;
2662
2589
  }
2663
- function Wr() {
2590
+ function Hr() {
2664
2591
  if (typeof window > "u") return null;
2665
2592
  const t = window.location.hash;
2666
- return !t || !t.startsWith(`#${He}`) ? null : t.slice(He.length + 1);
2593
+ return !t || !t.startsWith(`#${Oe}`) ? null : t.slice(Oe.length + 1);
2667
2594
  }
2668
- function Jr() {
2595
+ function jr() {
2669
2596
  if (typeof window > "u") return;
2670
2597
  const t = new URL(window.location.href);
2671
2598
  t.hash = "", window.history.replaceState(null, "", t.toString());
2672
2599
  }
2673
- function Yr() {
2674
- const t = Wr();
2675
- return t ? jr(t) : null;
2600
+ function zr() {
2601
+ const t = Hr();
2602
+ return t ? Gr(t) : null;
2676
2603
  }
2677
- function Xr(t) {
2604
+ function Wr(t) {
2678
2605
  const {
2679
2606
  currentQuery: i,
2680
2607
  isValidQuery: e,
@@ -2683,15 +2610,15 @@ function Xr(t) {
2683
2610
  displayConfig: s,
2684
2611
  onQueryChange: o,
2685
2612
  onChartConfigChange: l
2686
- } = t, d = c((m) => m.load), f = ae(!1);
2687
- se(() => {
2613
+ } = t, u = c((m) => m.load), f = Se(!1);
2614
+ he(() => {
2688
2615
  if (f.current) return;
2689
2616
  f.current = !0;
2690
- const m = Yr();
2691
- m && (d(m), Jr());
2692
- }, [d]), se(() => {
2617
+ const m = zr();
2618
+ m && (u(m), jr());
2619
+ }, [u]), he(() => {
2693
2620
  o && e && o(i);
2694
- }, [i, e, o]), se(() => {
2621
+ }, [i, e, o]), he(() => {
2695
2622
  l && l({
2696
2623
  chartType: n,
2697
2624
  chartConfig: r,
@@ -2699,61 +2626,61 @@ function Xr(t) {
2699
2626
  });
2700
2627
  }, [n, r, s, l]);
2701
2628
  }
2702
- function Ai(t = {}) {
2703
- const { initialData: i, externalColorPalette: e, onQueryChange: n, onChartConfigChange: r } = t, { features: s } = Vn(), o = Nr(), l = Kr(), d = $r({
2629
+ function vi(t = {}) {
2630
+ const { initialData: i, externalColorPalette: e, onQueryChange: n, onChartConfigChange: r } = t, { features: s } = Nn(), o = Ir(), l = Ur(), u = _r({
2704
2631
  queryState: l.queryState,
2705
2632
  queryStates: l.queryStates,
2706
2633
  isMultiQueryMode: l.isMultiQueryMode,
2707
2634
  mergeStrategy: l.mergeStrategy,
2708
2635
  activeQueryIndex: l.activeQueryIndex
2709
- }), f = c((a) => a.funnelBindingKey), m = c((a) => a.analysisType), y = c((a) => a.funnelCube), u = c((a) => a.funnelSteps), g = c((a) => a.activeFunnelStepIndex), S = c((a) => a.funnelTimeDimension), w = A(() => m !== "funnel" || !f?.dimension || !S || !u || u.length < 2 ? !1 : u.every((a) => a.filters.length > 0), [m, f, S, u]), D = c((a) => a.charts.funnel?.chartType) || "funnel", v = c((a) => a.charts.funnel?.chartConfig), h = A(() => v || {}, [v]), x = c((a) => a.flowCube), B = c((a) => a.flowBindingKey), _ = c((a) => a.flowTimeDimension), Q = c((a) => a.eventDimension), M = c((a) => a.startingStep), T = c((a) => a.stepsBefore), C = c((a) => a.stepsAfter), F = c((a) => a.joinStrategy), P = c((a) => a.charts.flow?.displayConfig), X = A(
2636
+ }), f = c((a) => a.funnelBindingKey), m = c((a) => a.analysisType), y = c((a) => a.funnelCube), d = c((a) => a.funnelSteps), p = c((a) => a.activeFunnelStepIndex), b = c((a) => a.funnelTimeDimension), w = A(() => m !== "funnel" || !f?.dimension || !b || !d || d.length < 2 ? !1 : d.every((a) => a.filters.length > 0), [m, f, b, d]), x = c((a) => a.charts.funnel?.chartType) || "funnel", v = c((a) => a.charts.funnel?.chartConfig), g = A(() => v || {}, [v]), D = c((a) => a.flowCube), B = c((a) => a.flowBindingKey), _ = c((a) => a.flowTimeDimension), Q = c((a) => a.eventDimension), M = c((a) => a.startingStep), T = c((a) => a.stepsBefore), h = c((a) => a.stepsAfter), F = c((a) => a.joinStrategy), P = c((a) => a.charts.flow?.displayConfig), Y = A(
2710
2637
  () => P || { showLegend: !0, showGrid: !0, showTooltip: !0 },
2711
2638
  [P]
2712
- ), ve = c((a) => a.charts.flow?.chartType) || "sankey", oe = c((a) => a.buildFunnelQueryFromSteps), H = A(() => m !== "funnel" ? null : oe(), [m, oe, u]), z = c((a) => a.buildFlowQuery), O = A(() => m !== "flow" ? null : z(), [m, z, x, B, _, Q, M, T, C, ve, F]), Z = c((a) => a.retentionCube), ee = c((a) => a.retentionBindingKey), te = c((a) => a.retentionTimeDimension), ne = c((a) => a.retentionDateRange), le = c((a) => a.retentionCohortFilters), ce = c((a) => a.retentionActivityFilters), de = c((a) => a.retentionBreakdowns), ue = c((a) => a.retentionViewGranularity), fe = c((a) => a.retentionPeriods), me = c((a) => a.retentionType), ye = c((a) => a.buildRetentionQuery), ge = c((a) => a.getRetentionValidation), xe = c((a) => a.charts.retention?.displayConfig), De = c((a) => a.setRetentionCube), Te = c((a) => a.setRetentionBindingKey), Fe = c((a) => a.setRetentionTimeDimension), k = c((a) => a.setRetentionDateRange), Ft = c((a) => a.setRetentionCohortFilters), At = c((a) => a.setRetentionActivityFilters), Qt = c((a) => a.setRetentionBreakdowns), Ae = c((a) => a.addRetentionBreakdown), Mt = c((a) => a.removeRetentionBreakdown), Rt = c((a) => a.setRetentionViewGranularity), kt = c((a) => a.setRetentionPeriods), It = c((a) => a.setRetentionType), Qe = A(() => m !== "retention" ? null : ye(), [
2639
+ ), be = c((a) => a.charts.flow?.chartType) || "sankey", se = c((a) => a.buildFunnelQueryFromSteps), G = A(() => m !== "funnel" ? null : se(), [m, se, d]), j = c((a) => a.buildFlowQuery), O = A(() => m !== "flow" ? null : j(), [m, j, D, B, _, Q, M, T, h, be, F]), Z = c((a) => a.retentionCube), ee = c((a) => a.retentionBindingKey), te = c((a) => a.retentionTimeDimension), ne = c((a) => a.retentionDateRange), ae = c((a) => a.retentionCohortFilters), oe = c((a) => a.retentionActivityFilters), le = c((a) => a.retentionBreakdowns), ce = c((a) => a.retentionViewGranularity), de = c((a) => a.retentionPeriods), ue = c((a) => a.retentionType), fe = c((a) => a.buildRetentionQuery), me = c((a) => a.getRetentionValidation), ve = c((a) => a.charts.retention?.displayConfig), De = c((a) => a.setRetentionCube), xe = c((a) => a.setRetentionBindingKey), Te = c((a) => a.setRetentionTimeDimension), k = c((a) => a.setRetentionDateRange), Tt = c((a) => a.setRetentionCohortFilters), Ft = c((a) => a.setRetentionActivityFilters), At = c((a) => a.setRetentionBreakdowns), Fe = c((a) => a.addRetentionBreakdown), Qt = c((a) => a.removeRetentionBreakdown), Mt = c((a) => a.setRetentionViewGranularity), Rt = c((a) => a.setRetentionPeriods), kt = c((a) => a.setRetentionType), Ae = A(() => m !== "retention" ? null : fe(), [
2713
2640
  m,
2714
- ye,
2641
+ fe,
2715
2642
  Z,
2716
2643
  ee,
2717
2644
  te,
2718
2645
  ne,
2646
+ le,
2647
+ ce,
2719
2648
  de,
2720
2649
  ue,
2721
- fe,
2722
- me,
2723
- le,
2724
- ce
2725
- ]), qt = A(() => m !== "retention" ? null : ge(), [
2650
+ ae,
2651
+ oe
2652
+ ]), It = A(() => m !== "retention" ? null : me(), [
2726
2653
  m,
2727
- ge,
2654
+ me,
2728
2655
  Z,
2729
2656
  ee,
2730
2657
  te,
2731
2658
  ne
2732
- ]), Me = A(() => m === "retention" ? Qe !== null : m === "flow" ? O !== null : m === "funnel" ? H !== null : l.isValidQuery ?? !1, [m, Qe, O, H, l.isValidQuery]), I = Gr({
2659
+ ]), Qe = A(() => m === "retention" ? Ae !== null : m === "flow" ? O !== null : m === "funnel" ? G !== null : l.isValidQuery ?? !1, [m, Ae, O, G, l.isValidQuery]), I = Lr({
2733
2660
  currentQuery: l.currentQuery,
2734
2661
  allQueries: l.allQueries,
2735
2662
  multiQueryConfig: l.multiQueryConfig,
2736
2663
  isMultiQueryMode: l.isMultiQueryMode,
2737
- isValidQuery: Me,
2664
+ isValidQuery: Qe,
2738
2665
  initialData: i,
2739
2666
  funnelBindingKey: f,
2740
2667
  isFunnelModeEnabled: w,
2741
2668
  // New: pass analysisType and serverFunnelQuery for explicit mode routing
2742
2669
  analysisType: m,
2743
- serverFunnelQuery: H,
2670
+ serverFunnelQuery: G,
2744
2671
  // Flow mode: pass serverFlowQuery
2745
2672
  serverFlowQuery: O,
2746
2673
  // Retention mode: pass serverRetentionQuery
2747
- serverRetentionQuery: Qe,
2674
+ serverRetentionQuery: Ae,
2748
2675
  // Retention mode: pass validation for debug panel
2749
- retentionValidation: qt
2750
- }), q = Hr({
2676
+ retentionValidation: It
2677
+ }), q = Kr({
2751
2678
  externalColorPalette: e,
2752
- combinedMetrics: d.combinedMetrics,
2753
- combinedBreakdowns: d.combinedBreakdowns,
2679
+ combinedMetrics: u.combinedMetrics,
2680
+ combinedBreakdowns: u.combinedBreakdowns,
2754
2681
  hasDebounced: I.hasDebounced
2755
- }), V = Or();
2756
- Xr({
2682
+ }), N = $r();
2683
+ Wr({
2757
2684
  currentQuery: l.currentQuery,
2758
2685
  isValidQuery: l.isValidQuery ?? !1,
2759
2686
  chartType: q.chartType,
@@ -2762,36 +2689,36 @@ function Ai(t = {}) {
2762
2689
  onQueryChange: n,
2763
2690
  onChartConfigChange: r
2764
2691
  });
2765
- const Bt = c((a) => a.openMetricsModal), Nt = c((a) => a.addMetric), Vt = c((a) => a.removeMetric), Re = c((a) => a.toggleMetric), Et = c((a) => a.reorderMetrics), Pt = c((a) => a.openBreakdownsModal), Ut = c((a) => a.addBreakdown), _t = c((a) => a.removeBreakdown), ke = c((a) => a.toggleBreakdown), Lt = c((a) => a.setBreakdownGranularity), Kt = c((a) => a.toggleBreakdownComparison), $t = c((a) => a.reorderBreakdowns), Gt = c((a) => a.setFilters), Ht = c((a) => a.dropFieldToFilter), Ot = c((a) => a.setOrder), jt = c((a) => a.clearQuery), zt = c((a) => a.clearCurrentMode), Wt = c((a) => a.setFunnelBindingKey), Jt = c((a) => a.setAnalysisType), Yt = c((a) => a.setFunnelCube), Xt = c((a) => a.addFunnelStep), Zt = c((a) => a.removeFunnelStep), en = c((a) => a.updateFunnelStep), tn = c((a) => a.setActiveFunnelStepIndex), nn = c((a) => a.reorderFunnelSteps), rn = c((a) => a.setFunnelTimeDimension), Ye = c((a) => a.charts.funnel?.displayConfig), sn = A(
2766
- () => Ye || { showLegend: !0, showGrid: !0, showTooltip: !0 },
2767
- [Ye]
2768
- ), an = c((a) => a.setFunnelDisplayConfig), on = c((a) => a.setFlowCube), ln = c((a) => a.setFlowBindingKey), cn = c((a) => a.setFlowTimeDimension), dn = c((a) => a.setEventDimension), un = c((a) => a.setStartingStepName), fn = c((a) => a.setStartingStepFilters), mn = c((a) => a.setStepsBefore), yn = c((a) => a.setStepsAfter), gn = c((a) => a.setJoinStrategy), hn = U(
2692
+ const qt = c((a) => a.openMetricsModal), Bt = c((a) => a.addMetric), Vt = c((a) => a.removeMetric), Me = c((a) => a.toggleMetric), Nt = c((a) => a.reorderMetrics), Et = c((a) => a.openBreakdownsModal), Pt = c((a) => a.addBreakdown), Ut = c((a) => a.removeBreakdown), Re = c((a) => a.toggleBreakdown), _t = c((a) => a.setBreakdownGranularity), Lt = c((a) => a.toggleBreakdownComparison), Kt = c((a) => a.reorderBreakdowns), $t = c((a) => a.setFilters), Gt = c((a) => a.dropFieldToFilter), Ot = c((a) => a.setOrder), Ht = c((a) => a.clearQuery), jt = c((a) => a.clearCurrentMode), zt = c((a) => a.setFunnelBindingKey), Wt = c((a) => a.setAnalysisType), Jt = c((a) => a.setFunnelCube), Xt = c((a) => a.addFunnelStep), Yt = c((a) => a.removeFunnelStep), Zt = c((a) => a.updateFunnelStep), en = c((a) => a.setActiveFunnelStepIndex), tn = c((a) => a.reorderFunnelSteps), nn = c((a) => a.setFunnelTimeDimension), Xe = c((a) => a.charts.funnel?.displayConfig), rn = A(
2693
+ () => Xe || { showLegend: !0, showGrid: !0, showTooltip: !0 },
2694
+ [Xe]
2695
+ ), sn = c((a) => a.setFunnelDisplayConfig), an = c((a) => a.setFlowCube), on = c((a) => a.setFlowBindingKey), ln = c((a) => a.setFlowTimeDimension), cn = c((a) => a.setEventDimension), dn = c((a) => a.setStartingStepName), un = c((a) => a.setStartingStepFilters), fn = c((a) => a.setStepsBefore), mn = c((a) => a.setStepsAfter), yn = c((a) => a.setJoinStrategy), gn = U(
2769
2696
  (a) => {
2770
- o.setState((N) => ({
2697
+ o.setState((V) => ({
2771
2698
  charts: {
2772
- ...N.charts,
2699
+ ...V.charts,
2773
2700
  flow: {
2774
- ...N.charts.flow || { chartType: "sankey", chartConfig: {}, displayConfig: {} },
2701
+ ...V.charts.flow || { chartType: "sankey", chartConfig: {}, displayConfig: {} },
2775
2702
  displayConfig: a
2776
2703
  }
2777
2704
  }
2778
2705
  }));
2779
2706
  },
2780
2707
  [o]
2781
- ), pn = U(
2708
+ ), hn = U(
2782
2709
  (a) => {
2783
- o.setState((N) => ({
2710
+ o.setState((V) => ({
2784
2711
  charts: {
2785
- ...N.charts,
2712
+ ...V.charts,
2786
2713
  retention: {
2787
- ...N.charts.retention || { chartType: "retentionCombined", chartConfig: {}, displayConfig: {} },
2714
+ ...V.charts.retention || { chartType: "retentionCombined", chartConfig: {}, displayConfig: {} },
2788
2715
  displayConfig: a
2789
2716
  }
2790
2717
  }
2791
2718
  }));
2792
2719
  },
2793
2720
  [o]
2794
- ), re = c((a) => a.aiState), Cn = c((a) => a.openAI), ie = c((a) => a.closeAI), wn = c((a) => a.setAIPrompt), Ie = c((a) => a.setAIGenerating), qe = c((a) => a.setAIError), he = c((a) => a.setAIHasGeneratedQuery), Xe = c((a) => a.saveAIPreviousState), Ze = c((a) => a.restoreAIPreviousState), Be = ae("idle"), bn = Me, et = c((a) => a.getValidation), Sn = A(
2721
+ ), re = c((a) => a.aiState), pn = c((a) => a.openAI), ie = c((a) => a.closeAI), Cn = c((a) => a.setAIPrompt), ke = c((a) => a.setAIGenerating), Ie = c((a) => a.setAIError), ye = c((a) => a.setAIHasGeneratedQuery), Ye = c((a) => a.saveAIPreviousState), Ze = c((a) => a.restoreAIPreviousState), qe = Se("idle"), wn = Qe, et = c((a) => a.getValidation), Sn = A(
2795
2722
  () => et(),
2796
2723
  // eslint-disable-next-line react-hooks/exhaustive-deps
2797
2724
  [
@@ -2799,70 +2726,70 @@ function Ai(t = {}) {
2799
2726
  l.queryStates,
2800
2727
  m,
2801
2728
  // Funnel deps
2802
- u,
2729
+ d,
2803
2730
  f,
2804
- S,
2731
+ b,
2805
2732
  // Flow deps
2806
- x,
2733
+ D,
2807
2734
  B,
2808
2735
  _,
2809
2736
  Q,
2810
2737
  M,
2811
2738
  T,
2812
- C,
2739
+ h,
2813
2740
  F
2814
2741
  ]
2815
- ), vn = U(
2816
- (a, N, tt, Rn) => {
2817
- V.fieldModalMode === "metrics" && N === "measure" ? Re(a.name) : V.fieldModalMode === "breakdown" && (m === "retention" && N === "dimension" ? Ae({ field: a.name }) : ke(a.name, N === "timeDimension")), Rn || V.closeFieldModal();
2742
+ ), bn = U(
2743
+ (a, V, tt, Mn) => {
2744
+ N.fieldModalMode === "metrics" && V === "measure" ? Me(a.name) : N.fieldModalMode === "breakdown" && (m === "retention" && V === "dimension" ? Fe({ field: a.name }) : Re(a.name, V === "timeDimension")), Mn || N.closeFieldModal();
2818
2745
  },
2819
- [V, Re, ke, Ae, m]
2820
- ), xn = U(async () => {
2746
+ [N, Me, Re, Fe, m]
2747
+ ), vn = U(async () => {
2821
2748
  if (s?.aiEndpoint) {
2822
- Xe(), Ie(!0), qe(null);
2749
+ Ye(), ke(!0), Ie(null);
2823
2750
  try {
2824
- await new Promise((a) => setTimeout(a, 1e3)), he(!0);
2751
+ await new Promise((a) => setTimeout(a, 1e3)), ye(!0);
2825
2752
  } catch (a) {
2826
- qe(a instanceof Error ? a.message : "Failed to generate query");
2753
+ Ie(a instanceof Error ? a.message : "Failed to generate query");
2827
2754
  } finally {
2828
- Ie(!1);
2755
+ ke(!1);
2829
2756
  }
2830
2757
  }
2831
- }, [s?.aiEndpoint, Xe, Ie, qe, he]), Dn = U(() => {
2832
- ie(), he(!1);
2833
- }, [ie, he]), Tn = U(() => {
2758
+ }, [s?.aiEndpoint, Ye, ke, Ie, ye]), Dn = U(() => {
2759
+ ie(), ye(!1);
2760
+ }, [ie, ye]), xn = U(() => {
2834
2761
  Ze(), ie();
2835
- }, [Ze, ie]), Fn = U(async () => {
2836
- Be.current = "copied", setTimeout(() => {
2837
- Be.current = "idle";
2762
+ }, [Ze, ie]), Tn = U(async () => {
2763
+ qe.current = "copied", setTimeout(() => {
2764
+ qe.current = "idle";
2838
2765
  }, 2e3);
2839
- }, []), An = U(() => {
2766
+ }, []), Fn = U(() => {
2840
2767
  const a = o.getState();
2841
2768
  if (a.analysisType === "funnel") {
2842
- const N = a.buildFunnelQueryFromSteps();
2843
- return N || a.buildCurrentQuery();
2769
+ const V = a.buildFunnelQueryFromSteps();
2770
+ return V || a.buildCurrentQuery();
2844
2771
  }
2845
2772
  return a.queryStates.length > 1 ? {
2846
2773
  queries: a.buildAllQueries(),
2847
2774
  mergeStrategy: a.mergeStrategy,
2848
2775
  mergeKeys: a.getMergeKeys(),
2849
- queryLabels: a.queryStates.map((N, tt) => `Q${tt + 1}`),
2776
+ queryLabels: a.queryStates.map((V, tt) => `Q${tt + 1}`),
2850
2777
  // Include funnel-specific config when in funnel mode
2851
2778
  funnelBindingKey: a.funnelBindingKey,
2852
2779
  stepTimeToConvert: a.stepTimeToConvert
2853
2780
  } : a.buildCurrentQuery();
2854
- }, [o]), Qn = U(() => {
2855
- const a = o.getState(), N = a.charts[a.analysisType];
2856
- return N ? {
2857
- chartType: N.chartType,
2858
- chartConfig: N.chartConfig,
2859
- displayConfig: N.displayConfig
2781
+ }, [o]), An = U(() => {
2782
+ const a = o.getState(), V = a.charts[a.analysisType];
2783
+ return V ? {
2784
+ chartType: V.chartType,
2785
+ chartConfig: V.chartConfig,
2786
+ displayConfig: V.displayConfig
2860
2787
  } : {
2861
2788
  chartType: q.chartType,
2862
2789
  chartConfig: q.chartConfig,
2863
2790
  displayConfig: q.displayConfig
2864
2791
  };
2865
- }, [o, q.chartType, q.chartConfig, q.displayConfig]), Mn = U(() => o.getState().analysisType, [o]);
2792
+ }, [o, q.chartType, q.chartConfig, q.displayConfig]), Qn = U(() => o.getState().analysisType, [o]);
2866
2793
  return {
2867
2794
  // Query state (from queryBuilder)
2868
2795
  queryState: l.queryState,
@@ -2881,34 +2808,34 @@ function Ai(t = {}) {
2881
2808
  // Analysis Type state (new)
2882
2809
  analysisType: m,
2883
2810
  funnelCube: y,
2884
- funnelSteps: u,
2885
- activeFunnelStepIndex: g,
2886
- funnelTimeDimension: S,
2887
- funnelChartType: D,
2888
- funnelChartConfig: h,
2889
- funnelDisplayConfig: sn,
2811
+ funnelSteps: d,
2812
+ activeFunnelStepIndex: p,
2813
+ funnelTimeDimension: b,
2814
+ funnelChartType: x,
2815
+ funnelChartConfig: g,
2816
+ funnelDisplayConfig: rn,
2890
2817
  // Flow state (new)
2891
- flowCube: x,
2818
+ flowCube: D,
2892
2819
  flowBindingKey: B,
2893
2820
  flowTimeDimension: _,
2894
2821
  eventDimension: Q,
2895
2822
  startingStep: M,
2896
2823
  stepsBefore: T,
2897
- stepsAfter: C,
2824
+ stepsAfter: h,
2898
2825
  joinStrategy: F,
2899
- flowDisplayConfig: X,
2826
+ flowDisplayConfig: Y,
2900
2827
  // Retention state (simplified Mixpanel-style)
2901
2828
  retentionCube: Z,
2902
2829
  retentionBindingKey: ee,
2903
2830
  retentionTimeDimension: te,
2904
2831
  retentionDateRange: ne,
2905
- retentionCohortFilters: le,
2906
- retentionActivityFilters: ce,
2907
- retentionBreakdowns: de,
2908
- retentionViewGranularity: ue,
2909
- retentionPeriods: fe,
2910
- retentionType: me,
2911
- retentionDisplayConfig: xe,
2832
+ retentionCohortFilters: ae,
2833
+ retentionActivityFilters: oe,
2834
+ retentionBreakdowns: le,
2835
+ retentionViewGranularity: ce,
2836
+ retentionPeriods: de,
2837
+ retentionType: ue,
2838
+ retentionDisplayConfig: ve,
2912
2839
  // Data fetching (from queryExecution)
2913
2840
  executionStatus: I.executionStatus,
2914
2841
  executionResults: I.executionResults,
@@ -2916,7 +2843,7 @@ function Ai(t = {}) {
2916
2843
  isLoading: I.isLoading,
2917
2844
  isFetching: I.isFetching,
2918
2845
  error: I.error,
2919
- isValidQuery: Me,
2846
+ isValidQuery: Qe,
2920
2847
  debugDataPerQuery: I.debugDataPerQuery,
2921
2848
  needsRefresh: I.needsRefresh,
2922
2849
  warnings: I.warnings,
@@ -2937,17 +2864,17 @@ function Ai(t = {}) {
2937
2864
  colorPalette: q.colorPalette,
2938
2865
  localPaletteName: q.localPaletteName,
2939
2866
  chartAvailability: q.chartAvailability,
2940
- combinedMetrics: d.combinedMetrics,
2941
- combinedBreakdowns: d.combinedBreakdowns,
2942
- effectiveBreakdowns: d.effectiveBreakdowns,
2867
+ combinedMetrics: u.combinedMetrics,
2868
+ combinedBreakdowns: u.combinedBreakdowns,
2869
+ effectiveBreakdowns: u.effectiveBreakdowns,
2943
2870
  // UI state (from uiState)
2944
- activeTab: V.activeTab,
2945
- activeView: V.activeView,
2946
- displayLimit: V.displayLimit,
2947
- showFieldModal: V.showFieldModal,
2948
- fieldModalMode: V.fieldModalMode,
2949
- activeTableIndex: V.activeTableIndex,
2950
- userManuallySelectedChart: V.userManuallySelectedChart,
2871
+ activeTab: N.activeTab,
2872
+ activeView: N.activeView,
2873
+ displayLimit: N.displayLimit,
2874
+ showFieldModal: N.showFieldModal,
2875
+ fieldModalMode: N.fieldModalMode,
2876
+ activeTableIndex: N.activeTableIndex,
2877
+ userManuallySelectedChart: N.userManuallySelectedChart,
2951
2878
  // AI state
2952
2879
  aiState: {
2953
2880
  isOpen: re.isOpen,
@@ -2957,8 +2884,8 @@ function Ai(t = {}) {
2957
2884
  hasGeneratedQuery: re.hasGeneratedQuery
2958
2885
  },
2959
2886
  // Share state
2960
- shareButtonState: Be.current,
2961
- canShare: bn,
2887
+ shareButtonState: qe.current,
2888
+ canShare: wn,
2962
2889
  // Adapter validation (NEW - Phase 5)
2963
2890
  adapterValidation: Sn,
2964
2891
  // Actions
@@ -2967,97 +2894,97 @@ function Ai(t = {}) {
2967
2894
  setActiveQueryIndex: l.setActiveQueryIndex,
2968
2895
  setMergeStrategy: l.setMergeStrategy,
2969
2896
  // Metrics
2970
- openMetricsModal: Bt,
2971
- addMetric: Nt,
2897
+ openMetricsModal: qt,
2898
+ addMetric: Bt,
2972
2899
  removeMetric: Vt,
2973
- toggleMetric: Re,
2974
- reorderMetrics: Et,
2900
+ toggleMetric: Me,
2901
+ reorderMetrics: Nt,
2975
2902
  // Breakdowns
2976
- openBreakdownsModal: Pt,
2977
- addBreakdown: Ut,
2978
- removeBreakdown: _t,
2979
- toggleBreakdown: ke,
2980
- setBreakdownGranularity: Lt,
2981
- toggleBreakdownComparison: Kt,
2982
- reorderBreakdowns: $t,
2903
+ openBreakdownsModal: Et,
2904
+ addBreakdown: Pt,
2905
+ removeBreakdown: Ut,
2906
+ toggleBreakdown: Re,
2907
+ setBreakdownGranularity: _t,
2908
+ toggleBreakdownComparison: Lt,
2909
+ reorderBreakdowns: Kt,
2983
2910
  // Filters
2984
- setFilters: Gt,
2985
- dropFieldToFilter: Ht,
2911
+ setFilters: $t,
2912
+ dropFieldToFilter: Gt,
2986
2913
  setOrder: Ot,
2987
2914
  // Multi-query (from queryBuilder)
2988
2915
  addQuery: l.addQuery,
2989
2916
  removeQuery: l.removeQuery,
2990
2917
  // Funnel (legacy)
2991
- setFunnelBindingKey: Wt,
2918
+ setFunnelBindingKey: zt,
2992
2919
  // Analysis Type (new)
2993
- setAnalysisType: Jt,
2920
+ setAnalysisType: Wt,
2994
2921
  // Funnel Mode (new dedicated state)
2995
- setFunnelCube: Yt,
2922
+ setFunnelCube: Jt,
2996
2923
  addFunnelStep: Xt,
2997
- removeFunnelStep: Zt,
2998
- updateFunnelStep: en,
2999
- setActiveFunnelStepIndex: tn,
3000
- reorderFunnelSteps: nn,
3001
- setFunnelTimeDimension: rn,
3002
- setFunnelDisplayConfig: an,
2924
+ removeFunnelStep: Yt,
2925
+ updateFunnelStep: Zt,
2926
+ setActiveFunnelStepIndex: en,
2927
+ reorderFunnelSteps: tn,
2928
+ setFunnelTimeDimension: nn,
2929
+ setFunnelDisplayConfig: sn,
3003
2930
  // Flow Mode actions
3004
- setFlowCube: on,
3005
- setFlowBindingKey: ln,
3006
- setFlowTimeDimension: cn,
3007
- setEventDimension: dn,
3008
- setStartingStepName: un,
3009
- setStartingStepFilters: fn,
3010
- setStepsBefore: mn,
3011
- setStepsAfter: yn,
3012
- setJoinStrategy: gn,
3013
- setFlowDisplayConfig: hn,
2931
+ setFlowCube: an,
2932
+ setFlowBindingKey: on,
2933
+ setFlowTimeDimension: ln,
2934
+ setEventDimension: cn,
2935
+ setStartingStepName: dn,
2936
+ setStartingStepFilters: un,
2937
+ setStepsBefore: fn,
2938
+ setStepsAfter: mn,
2939
+ setJoinStrategy: yn,
2940
+ setFlowDisplayConfig: gn,
3014
2941
  // Retention Mode actions (simplified Mixpanel-style)
3015
2942
  setRetentionCube: De,
3016
- setRetentionBindingKey: Te,
3017
- setRetentionTimeDimension: Fe,
2943
+ setRetentionBindingKey: xe,
2944
+ setRetentionTimeDimension: Te,
3018
2945
  setRetentionDateRange: k,
3019
- setRetentionCohortFilters: Ft,
3020
- setRetentionActivityFilters: At,
3021
- setRetentionBreakdowns: Qt,
3022
- addRetentionBreakdown: Ae,
3023
- removeRetentionBreakdown: Mt,
3024
- setRetentionViewGranularity: Rt,
3025
- setRetentionPeriods: kt,
3026
- setRetentionType: It,
3027
- setRetentionDisplayConfig: pn,
2946
+ setRetentionCohortFilters: Tt,
2947
+ setRetentionActivityFilters: Ft,
2948
+ setRetentionBreakdowns: At,
2949
+ addRetentionBreakdown: Fe,
2950
+ removeRetentionBreakdown: Qt,
2951
+ setRetentionViewGranularity: Mt,
2952
+ setRetentionPeriods: Rt,
2953
+ setRetentionType: kt,
2954
+ setRetentionDisplayConfig: hn,
3028
2955
  // Chart (from chartDefaults)
3029
2956
  setChartType: q.setChartType,
3030
2957
  setChartConfig: q.setChartConfig,
3031
2958
  setDisplayConfig: q.setDisplayConfig,
3032
2959
  setLocalPaletteName: q.setLocalPaletteName,
3033
2960
  // UI (from uiState)
3034
- setActiveTab: V.setActiveTab,
3035
- setActiveView: V.setActiveView,
3036
- setDisplayLimit: V.setDisplayLimit,
3037
- closeFieldModal: V.closeFieldModal,
3038
- setActiveTableIndex: V.setActiveTableIndex,
2961
+ setActiveTab: N.setActiveTab,
2962
+ setActiveView: N.setActiveView,
2963
+ setDisplayLimit: N.setDisplayLimit,
2964
+ closeFieldModal: N.closeFieldModal,
2965
+ setActiveTableIndex: N.setActiveTableIndex,
3039
2966
  // AI
3040
- openAI: Cn,
2967
+ openAI: pn,
3041
2968
  closeAI: ie,
3042
- setAIPrompt: wn,
3043
- generateAI: xn,
2969
+ setAIPrompt: Cn,
2970
+ generateAI: vn,
3044
2971
  acceptAI: Dn,
3045
- cancelAI: Tn,
2972
+ cancelAI: xn,
3046
2973
  // Share
3047
- share: Fn,
2974
+ share: Tn,
3048
2975
  // Utility
3049
- clearQuery: jt,
3050
- clearCurrentMode: zt,
2976
+ clearQuery: Ht,
2977
+ clearCurrentMode: jt,
3051
2978
  refetch: I.refetch,
3052
- handleFieldSelected: vn
2979
+ handleFieldSelected: bn
3053
2980
  },
3054
2981
  // Refs
3055
- getQueryConfig: An,
3056
- getChartConfig: Qn,
3057
- getAnalysisType: Mn
2982
+ getQueryConfig: Fn,
2983
+ getChartConfig: An,
2984
+ getAnalysisType: Qn
3058
2985
  };
3059
2986
  }
3060
- function Zr(t, i) {
2987
+ function Jr(t, i) {
3061
2988
  const e = [];
3062
2989
  if (!i?.cubes)
3063
2990
  return e;
@@ -3083,7 +3010,7 @@ function Zr(t, i) {
3083
3010
  }
3084
3011
  return e;
3085
3012
  }
3086
- function ei(t) {
3013
+ function Xr(t) {
3087
3014
  const i = [];
3088
3015
  for (let e = 0; e < t.length; e++) {
3089
3016
  const n = t[e], r = n.query;
@@ -3095,18 +3022,18 @@ function ei(t) {
3095
3022
  }
3096
3023
  return i;
3097
3024
  }
3098
- function ti(t, i) {
3025
+ function Yr(t, i) {
3099
3026
  if (typeof t.dimension == "string")
3100
3027
  return !0;
3101
- const e = pt(i);
3028
+ const e = ht(i);
3102
3029
  return e ? t.dimension.some((n) => n.cube === e) : !1;
3103
3030
  }
3104
- function ni(t, i) {
3031
+ function Zr(t, i) {
3105
3032
  const e = [];
3106
3033
  for (let n = 0; n < i.length; n++) {
3107
3034
  const r = i[n];
3108
- if (!ti(t, r.query)) {
3109
- const s = pt(r.query) || "unknown";
3035
+ if (!Yr(t, r.query)) {
3036
+ const s = ht(r.query) || "unknown";
3110
3037
  e.push({
3111
3038
  type: "cross_cube",
3112
3039
  message: `Step ${n + 1} uses cube "${s}" but no binding key mapping exists for it`,
@@ -3116,26 +3043,26 @@ function ni(t, i) {
3116
3043
  }
3117
3044
  return e;
3118
3045
  }
3119
- function mt(t) {
3046
+ function ft(t) {
3120
3047
  return t ? /^P(?:\d+Y)?(?:\d+M)?(?:\d+W)?(?:\d+D)?(?:T(?:\d+H)?(?:\d+M)?(?:\d+S)?)?$/.test(t) ? null : {
3121
3048
  type: "time_window",
3122
3049
  message: `Invalid time window format "${t}". Expected ISO 8601 duration (e.g., P7D, PT1H)`
3123
3050
  } : null;
3124
3051
  }
3125
- function Qi(t, i) {
3052
+ function Di(t, i) {
3126
3053
  const e = [], n = [];
3127
3054
  t.steps.length < 2 && e.push({
3128
3055
  type: "general",
3129
3056
  message: "Funnel requires at least 2 steps"
3130
- }), t.bindingKey?.dimension ? (e.push(...Zr(t.bindingKey, i)), e.push(...ni(t.bindingKey, t.steps))) : e.push({
3057
+ }), t.bindingKey?.dimension ? (e.push(...Jr(t.bindingKey, i)), e.push(...Zr(t.bindingKey, t.steps))) : e.push({
3131
3058
  type: "binding_key",
3132
3059
  message: "Binding key dimension is required"
3133
- }), e.push(...ei(t.steps));
3060
+ }), e.push(...Xr(t.steps));
3134
3061
  for (let s = 0; s < t.steps.length; s++) {
3135
- const o = t.steps[s], l = mt(o.timeToConvert);
3062
+ const o = t.steps[s], l = ft(o.timeToConvert);
3136
3063
  l && (l.stepIndex = s, e.push(l));
3137
3064
  }
3138
- const r = mt(t.globalTimeWindow);
3065
+ const r = ft(t.globalTimeWindow);
3139
3066
  return r && e.push(r), t.steps.length > 5 && n.push({
3140
3067
  type: "general",
3141
3068
  message: "Funnels with more than 5 steps may have reduced performance"
@@ -3145,10 +3072,10 @@ function Qi(t, i) {
3145
3072
  warnings: n
3146
3073
  };
3147
3074
  }
3148
- function Mi(t, i) {
3075
+ function xi(t, i) {
3149
3076
  return i < 2 ? { isValid: !1, message: "Add at least 2 steps for funnel" } : t?.dimension ? typeof t.dimension == "string" && !t.dimension ? { isValid: !1, message: "Select a binding key dimension" } : Array.isArray(t.dimension) && t.dimension.length === 0 ? { isValid: !1, message: "Select a binding key dimension" } : { isValid: !0 } : { isValid: !1, message: "Select a binding key dimension" };
3150
3077
  }
3151
- function Ri(t) {
3078
+ function Ti(t) {
3152
3079
  if (!t?.cubes) return [];
3153
3080
  const i = [];
3154
3081
  for (const e of t.cubes)
@@ -3161,7 +3088,7 @@ function Ri(t) {
3161
3088
  });
3162
3089
  return i;
3163
3090
  }
3164
- function ki(t) {
3091
+ function Fi(t) {
3165
3092
  if (!t?.dimension) return "Select binding key...";
3166
3093
  if (typeof t.dimension == "string")
3167
3094
  return t.dimension.split(".")[1] || t.dimension;
@@ -3172,41 +3099,40 @@ function ki(t) {
3172
3099
  return "Select binding key...";
3173
3100
  }
3174
3101
  export {
3175
- ni as A,
3176
- Mi as B,
3177
- Ri as C,
3178
- ki as D,
3179
- gi as E,
3180
- zr as F,
3181
- Ue as G,
3182
- Wr as H,
3183
- hi as I,
3184
- Nr as J,
3185
- pr as a,
3102
+ Zr as A,
3103
+ xi as B,
3104
+ Ti as C,
3105
+ Fi as D,
3106
+ di as E,
3107
+ Or as F,
3108
+ Hr as G,
3109
+ ui as H,
3110
+ Ir as I,
3111
+ yr as a,
3186
3112
  c as b,
3187
- pi as c,
3188
- Ci as d,
3189
- wi as e,
3190
- Vr as f,
3191
- bi as g,
3192
- Si as h,
3193
- vi as i,
3194
- Er as j,
3195
- Pr as k,
3196
- Ur as l,
3197
- _r as m,
3198
- xi as n,
3199
- Di as o,
3200
- Oe as p,
3201
- jr as q,
3202
- Fi as r,
3113
+ fi as c,
3114
+ mi as d,
3115
+ yi as e,
3116
+ qr as f,
3117
+ gi as g,
3118
+ hi as h,
3119
+ pi as i,
3120
+ Br as j,
3121
+ Vr as k,
3122
+ Nr as l,
3123
+ Er as m,
3124
+ Ci as n,
3125
+ wi as o,
3126
+ He as p,
3127
+ Gr as q,
3128
+ bi as r,
3203
3129
  Je as s,
3204
- Yr as t,
3205
- Ai as u,
3206
- Lr as v,
3207
- Ti as w,
3208
- Qi as x,
3209
- Zr as y,
3210
- ei as z
3130
+ zr as t,
3131
+ vi as u,
3132
+ Pr as v,
3133
+ Si as w,
3134
+ Di as x,
3135
+ Jr as y,
3136
+ Xr as z
3211
3137
  };
3212
- //# sourceMappingURL=analysis-builder-shared-NBk6y0md.js.map
3138
+ //# sourceMappingURL=analysis-builder-shared-DOHV2W8A.js.map