@aintela/bi 0.2.1 → 0.2.3

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 (50) hide show
  1. package/README.md +32 -1
  2. package/dist/ChartCardDefaultsContext-BDRsVljO.js +34 -0
  3. package/dist/ChartCardDefaultsContext-BDRsVljO.js.map +1 -0
  4. package/dist/{GridLayout-BgPzzPiP.js → GridLayout-1gWuIKeZ.js} +3 -4
  5. package/dist/GridLayout-1gWuIKeZ.js.map +1 -0
  6. package/dist/{ScriptDashboardViewerVertical-DKaHcL1o.js → ScriptDashboardViewerVertical-Rr_4adpH.js} +4 -4
  7. package/dist/{ScriptDashboardViewerVertical-DKaHcL1o.js.map → ScriptDashboardViewerVertical-Rr_4adpH.js.map} +1 -1
  8. package/dist/{biModuleSurface-dtnpBMtT.js → biModuleSurface-BdJK7sSL.js} +6 -6
  9. package/dist/{biModuleSurface-dtnpBMtT.js.map → biModuleSurface-BdJK7sSL.js.map} +1 -1
  10. package/dist/cards.js +1 -1
  11. package/dist/composer/index.d.ts +3 -1
  12. package/dist/composer/view/ComposerView.d.ts +20 -1
  13. package/dist/composer/view/SessionVisualizationsPanel.d.ts +19 -0
  14. package/dist/composer.js +73 -71
  15. package/dist/data/ChartCardDefaultsContext.d.ts +9 -0
  16. package/dist/data.js +1 -1
  17. package/dist/grid.js +16 -17
  18. package/dist/grid.js.map +1 -1
  19. package/dist/{index-DeiweWw8.js → index-9LcZjCK0.js} +54 -50
  20. package/dist/index-9LcZjCK0.js.map +1 -0
  21. package/dist/{index-Dz2ulBiy.js → index-BzUugG0A.js} +4 -5
  22. package/dist/{index-Dz2ulBiy.js.map → index-BzUugG0A.js.map} +1 -1
  23. package/dist/index-C4_VSDeU.js +3856 -0
  24. package/dist/index-C4_VSDeU.js.map +1 -0
  25. package/dist/{index-CPHaT2or.js → index-DChE_l-p.js} +2 -2
  26. package/dist/index-DChE_l-p.js.map +1 -0
  27. package/dist/{index-DOpx0R4Y.js → index-Dy6hwDjs.js} +2 -2
  28. package/dist/index-Dy6hwDjs.js.map +1 -0
  29. package/dist/index.js +228 -223
  30. package/dist/index.js.map +1 -1
  31. package/dist/runtime/index.d.ts +2 -0
  32. package/dist/runtime/sessionVisualizations.d.ts +61 -0
  33. package/dist/runtime/version.d.ts +1 -1
  34. package/dist/runtime.js +16 -11
  35. package/dist/runtime.js.map +1 -1
  36. package/dist/style.css +1 -1
  37. package/dist/version-BTc4ElDG.js +122 -0
  38. package/dist/version-BTc4ElDG.js.map +1 -0
  39. package/dist/viewer.js +1 -1
  40. package/package.json +1 -1
  41. package/dist/ChartCardDefaultsContext-Cl5T25H0.js +0 -32
  42. package/dist/ChartCardDefaultsContext-Cl5T25H0.js.map +0 -1
  43. package/dist/GridLayout-BgPzzPiP.js.map +0 -1
  44. package/dist/index-7p-ogAPK.js +0 -3631
  45. package/dist/index-7p-ogAPK.js.map +0 -1
  46. package/dist/index-CPHaT2or.js.map +0 -1
  47. package/dist/index-DOpx0R4Y.js.map +0 -1
  48. package/dist/index-DeiweWw8.js.map +0 -1
  49. package/dist/version-BgIpi4UM.js +0 -84
  50. package/dist/version-BgIpi4UM.js.map +0 -1
@@ -0,0 +1,3856 @@
1
+ var li = Object.defineProperty;
2
+ var a = (e, n) => li(e, "name", { value: n, configurable: !0 });
3
+ import { jsx as t, jsxs as b, Fragment as Te } from "react/jsx-runtime";
4
+ import He, { useState as N, useEffect as q, useContext as Ae, createContext as Ct, useMemo as ve, useRef as ee, forwardRef as wt, useCallback as W, useImperativeHandle as Qt } from "react";
5
+ import { useStore as en } from "zustand";
6
+ import { useShallow as si } from "zustand/react/shallow";
7
+ import { a as et } from "./BiClientProvider-CWJochvi.js";
8
+ import { createStore as di } from "zustand/vanilla";
9
+ import { C as Oe, S as _e, a as ci } from "./ScriptDashboardViewerVertical-Rr_4adpH.js";
10
+ import S from "@mui/material/Box";
11
+ import { SpeedOutlined as tn, GridViewOutlined as nn, MapOutlined as pi, BarChartOutlined as ut, TableChartOutlined as an, TagOutlined as on, DashboardOutlined as Tt, ManageSearchOutlined as hi, CalendarTodayOutlined as ui, DateRangeOutlined as mi, TimelineOutlined as fi, BubbleChartOutlined as gi, DonutLargeOutlined as xi, ScatterPlotOutlined as yi, PieChartOutlined as bi, MultilineChartOutlined as vi, StackedBarChartOutlined as Si, StackedLineChartOutlined as Ci, AreaChartOutlined as wi, AlignHorizontalLeftOutlined as Ti, ShowChartOutlined as Di, TableRowsOutlined as ki, HeatPumpOutlined as Ii, ViewColumnOutlined as zi, DeleteOutline as rn, CheckCircle as Oi, Pending as Pi, ViewQuiltOutlined as Ei, BorderClearOutlined as $i, DragIndicatorOutlined as Ai, AddOutlined as Mi, ArrowDropDownOutlined as mt, FilterListOutlined as Ri, PreviewRounded as _i, FolderOpenOutlined as Fi, ArrowBack as Ni, NoteAddOutlined as Bi, SaveOutlined as Hi, RefreshOutlined as ln, StartRounded as Li, Close as Gi, Add as Wi, InsertDriveFileOutlined as Vi, Fullscreen as ji } from "@mui/icons-material";
12
+ import { Box as j, Stack as se, IconButton as Pe, CircularProgress as ft, Typography as ie, Popper as Ve, Grow as je, Paper as Fe, ClickAwayListener as Ue, MenuList as gt, Divider as Ke, MenuItem as Ee, ListItemIcon as qe, ListItemText as Ye, TextField as Ne, Tooltip as Ie, Switch as xt, ToggleButtonGroup as sn, ToggleButton as Je, Button as Ft, Menu as Ui, Select as Nt, Grid as Xe } from "@mui/material";
13
+ import { alpha as Ce, useTheme as le } from "@mui/material/styles";
14
+ import { e as Ki } from "./GridLayout-1gWuIKeZ.js";
15
+ import { G as qi } from "./GridCardPlaceHolder-DVVT3pqn.js";
16
+ import { useEnvironment as dn, DashboardIcon as ke, PanelIcon as Le, CloseIcon as Dt, PromptV2 as Yi, PlusIcon as yt, SearchIcon as Ji, useAiChatSessionStore as Xi, useAiChatServices as Zi, ChevronIcon as Qi, EnvironmentProvider as ea, InertEnvironmentProvider as ta, useEnvironmentOptional as na } from "@aintela/chat/components";
17
+ import Bt from "@mui/material/Stack";
18
+ import { AnimatePresence as tt, motion as re, useReducedMotion as ia } from "framer-motion";
19
+ import cn from "@mui/material/Dialog";
20
+ import be from "@mui/material/IconButton";
21
+ import ce from "@mui/material/Tooltip";
22
+ import X from "@mui/material/Typography";
23
+ import Ht from "@mui/material/Divider";
24
+ import lt from "@mui/material/ListItemIcon";
25
+ import st from "@mui/material/ListItemText";
26
+ import dt from "@mui/material/MenuItem";
27
+ import Lt from "@mui/material/MenuList";
28
+ import Gt from "@mui/material/Popover";
29
+ import Wt from "@mui/material/ToggleButton";
30
+ import aa from "@mui/material/ToggleButtonGroup";
31
+ import oa from "@mui/icons-material/EditOutlined";
32
+ import { createPortal as ra } from "react-dom";
33
+ function $e(e) {
34
+ if (!(e != null && e.trim())) return "_";
35
+ const n = e.normalize("NFD").replace(new RegExp("\\p{Mn}", "gu"), "").replace(new RegExp("(?<=[a-zA-Z0-9_$])[^a-zA-Z0-9_$]+([a-zA-Z_$])", "g"), (i, l) => l.toUpperCase()).replace(/[^a-zA-Z0-9_$]+/g, "");
36
+ return n ? /^\d/.test(n) ? `_${n}` : n : "_";
37
+ }
38
+ a($e, "sanitizeToJsVariable");
39
+ function ze() {
40
+ const e = typeof globalThis.crypto < "u" ? globalThis.crypto : void 0;
41
+ if (e && typeof e.randomUUID == "function") return e.randomUUID();
42
+ let n = "";
43
+ for (let i = 0; i < 32; i++) n += Math.floor(Math.random() * 16).toString(16);
44
+ return n;
45
+ }
46
+ a(ze, "randomId");
47
+ const nt = 300;
48
+ function kt(e) {
49
+ if (!e) return;
50
+ const n = Object.values(e).filter((i) => i && i.trim().length > 0);
51
+ if (n.length !== 0)
52
+ return n.map((i) => `- ${i}`).join(`
53
+ `);
54
+ }
55
+ a(kt, "joinClientSideChanges");
56
+ const we = [
57
+ { label: "Métrica (Comparação)", category: "Métrica", specificType: "MetricComparison" },
58
+ { label: "Tabela (Auto)", category: "Tabela", specificType: "TableAuto" },
59
+ { label: "Tabela (Com barras)", category: "Tabela", specificType: "TableBars" },
60
+ { label: "Tabela (Com mapa de calor)", category: "Tabela", specificType: "TableHeatmap" },
61
+ { label: "Tabela (Grande)", category: "Tabela", specificType: "TableLarge" },
62
+ { label: "Gráfico (Auto)", category: "Gráfico", specificType: "ChartAuto" },
63
+ { label: "Gráfico (Linhas)", category: "Gráfico", specificType: "ChartLine" },
64
+ { label: "Gráfico (Barras) (H)", category: "Gráfico", specificType: "ChartBarH" },
65
+ { label: "Gráfico (Barras) (V)", category: "Gráfico", specificType: "ChartBarV" },
66
+ { label: "Gráfico (Area)", category: "Gráfico", specificType: "ChartArea" },
67
+ { label: "Gráfico (Area Empilhada)", category: "Gráfico", specificType: "ChartStackedArea" },
68
+ { label: "Gráfico (Barras Empilhadas)", category: "Gráfico", specificType: "ChartStackedBar" },
69
+ { label: "Gráfico (Combo)", category: "Gráfico", specificType: "ChartCombo" },
70
+ { label: "Gráfico (Pizza)", category: "Gráfico", specificType: "ChartPie" },
71
+ { label: "Gráfico (Donnut)", category: "Gráfico", specificType: "ChartDonut" },
72
+ { label: "Mapa (Bubbles)", category: "Mapa", specificType: "MapBubbles" },
73
+ { label: "Mapa (Conexões)", category: "Mapa", specificType: "MapConnections" },
74
+ { label: "Árvore (Distribuição)", category: "Árvore", specificType: "Treemap" },
75
+ { label: "Medidor (Gauge)", category: "Medidor", specificType: "Gauge" }
76
+ ];
77
+ function it(e = we) {
78
+ return e.reduce((n, i) => {
79
+ var l;
80
+ return (n[l = i.category] ?? (n[l] = [])).push(i), n;
81
+ }, {});
82
+ }
83
+ a(it, "groupCardCatalog");
84
+ const It = [
85
+ { label: "Período (Date Range)", filterType: "DateRangePicker" },
86
+ { label: "Data (Date Picker)", filterType: "DatePicker" },
87
+ { label: "Auto Complete", filterType: "AutoComplete" }
88
+ ], la = /* @__PURE__ */ a((e, n) => e.actionDescription == n.actionDescription && e.category == n.category && e.name == n.name && e.color == n.color && e.specificType == n.specificType, "sketchCardItemComparer"), sa = /* @__PURE__ */ a((e, n) => JSON.stringify(e) == JSON.stringify(n), "sketchFilterComparer");
89
+ function bt(e) {
90
+ var o;
91
+ const n = /* @__PURE__ */ new Set();
92
+ let i = !1;
93
+ for (const r of e.cards ?? [])
94
+ r.todoItem = void 0, n.has(r.name) ? i = !0 : n.add(r.name);
95
+ let l = null;
96
+ return i && (l = "Os nomes dos cards precisam ser únicos"), (((o = e.cards) == null ? void 0 : o.length) ?? 0) == 0 && (l = "Inclua pelo menos um card no rascunho"), l;
97
+ }
98
+ a(bt, "validateSketch");
99
+ const da = 20;
100
+ function pn(e) {
101
+ var g, h, x;
102
+ const n = [];
103
+ let i = 0, l = 0, o = 0, r = 0;
104
+ for (const d of e.config) {
105
+ const { size: v, height: s, card: c } = d, u = Math.max(1, Math.round((s ?? nt) / da));
106
+ i + v > 12 && (i = 0, l += o, o = 0);
107
+ let p = d.description, f = d.name, y = d.specificType, R = d.id, H;
108
+ if (He.isValidElement(c)) {
109
+ const L = c.props ?? {};
110
+ p = p ?? L.description ?? "", f = f ?? L.name, R = R ?? L.id ?? $e(`${f ?? ""}${r}`), y = y ?? L.specificType, H = L.category ?? ((g = we.find((P) => P.specificType === y)) == null ? void 0 : g.category);
111
+ } else {
112
+ if (f === void 0 && y === void 0)
113
+ continue;
114
+ R = R ?? $e(`${f}${r}`), H = (h = we.find((L) => L.specificType === y)) == null ? void 0 : h.category;
115
+ }
116
+ n.push({
117
+ i: R ?? "not_defined",
118
+ x: i,
119
+ y: l,
120
+ w: v,
121
+ h: u,
122
+ name: f ?? ((x = we.find((L) => L.specificType === y)) == null ? void 0 : x.label),
123
+ actionDescription: p,
124
+ specificType: y,
125
+ category: H
126
+ }), i += v, o = Math.max(o, u), r++;
127
+ }
128
+ return {
129
+ id: e.id,
130
+ name: e.name,
131
+ cards: n,
132
+ filters: e.filters ?? []
133
+ };
134
+ }
135
+ a(pn, "padConfigToDashboard");
136
+ function hn(e) {
137
+ return typeof e == "object" && e !== null && "config" in e && Array.isArray(e.config);
138
+ }
139
+ a(hn, "isSimplePadDefinition");
140
+ function ca(e) {
141
+ return Oe[e] ?? Oe.Generic;
142
+ }
143
+ a(ca, "categoryPrefix");
144
+ const Ze = "llm-env-highlight-active";
145
+ function un() {
146
+ return typeof document > "u" ? null : document;
147
+ }
148
+ a(un, "defaultRoot");
149
+ function Vt(e) {
150
+ return typeof CSS < "u" && CSS.escape ? CSS.escape(e) : e.replace(/["\\]/g, "\\$&");
151
+ }
152
+ a(Vt, "escapeCssValue");
153
+ function mn(e) {
154
+ return e.startsWith(".") || e.startsWith("#") || e.startsWith("[") || e.includes(" ") || e.includes(":") || e.includes(">");
155
+ }
156
+ a(mn, "looksLikeSelector");
157
+ function fn(e) {
158
+ var o, r, g;
159
+ const n = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ a((h) => {
160
+ const x = Vt(h);
161
+ n.add(`[data-env-id="${x}"]`), n.add(`[data-env-key="${x}"]`), n.add(`[data-env-name="${x}"]`), n.add(`#${x}`), n.add(`.${x}`);
162
+ }, "appendByIdentifier"), l = /* @__PURE__ */ a((h) => {
163
+ h.split(/\s+/).map((x) => x.trim()).filter(Boolean).forEach((x) => n.add(`.${Vt(x)}`));
164
+ }, "appendByClassName");
165
+ if (typeof e == "string") {
166
+ const h = e.trim();
167
+ return h ? (mn(h) ? n.add(h) : i(h), [...n]) : [];
168
+ }
169
+ return (o = e.selector) != null && o.trim() && n.add(e.selector.trim()), (r = e.className) != null && r.trim() && l(e.className), (g = e.identifier) != null && g.trim() && i(e.identifier.trim()), [...n];
170
+ }
171
+ a(fn, "toSelectorList");
172
+ function Qe(e, n = un()) {
173
+ if (!n) return { selectors: [], elements: [] };
174
+ const i = fn(e), l = /* @__PURE__ */ new Set();
175
+ return i.forEach((o) => {
176
+ try {
177
+ n.querySelectorAll(o).forEach((r) => l.add(r));
178
+ } catch (r) {
179
+ console.warn("[@aintela/bi composer] Invalid selector:", o, r);
180
+ }
181
+ }), { selectors: i, elements: [...l] };
182
+ }
183
+ a(Qe, "resolveEnvironmentElements");
184
+ function zt(e) {
185
+ const n = e.getBoundingClientRect();
186
+ if (!(n.width > 0 && n.height > 0)) return !1;
187
+ if (typeof window > "u" || !window.getComputedStyle) return !0;
188
+ const i = window.getComputedStyle(e);
189
+ return i.display !== "none" && i.visibility !== "hidden";
190
+ }
191
+ a(zt, "isElementVisible");
192
+ function gn(e, n = !1) {
193
+ if (e.length === 0) return null;
194
+ if (n) return e[0];
195
+ for (const i of e) if (zt(i)) return i;
196
+ return e[0];
197
+ }
198
+ a(gn, "pickBestElement");
199
+ function Ot(e, n = un()) {
200
+ const { elements: i } = Qe(e, n);
201
+ for (const l of i) if (zt(l)) return l;
202
+ return null;
203
+ }
204
+ a(Ot, "resolveGuideElement");
205
+ const xn = /* @__PURE__ */ new Set([
206
+ "dashboardpad-add-card",
207
+ "dashboardpad-add-card-dropdown",
208
+ "dashboardpad-add-filter",
209
+ "dashboard-pad-layout-toggle",
210
+ "dashboard-pad-layout-boxed",
211
+ "dashboard-pad-layout-naked"
212
+ ]), yn = /* @__PURE__ */ new Set([
213
+ "llm-env-card",
214
+ "llm-env-filter",
215
+ "llm-env-layout-toggle",
216
+ "llm-env-card-sketch",
217
+ "llm-env-card-sketch-wrapper",
218
+ "llm-env-filter-sketch"
219
+ ]), pa = /^[0-9a-fA-F]{8,}(-[0-9a-fA-F]{4,})+$/;
220
+ function bn(e) {
221
+ const n = /* @__PURE__ */ a((l) => {
222
+ const o = l.trim();
223
+ return o ? xn.has(o) ? !0 : pa.test(o) : !1;
224
+ }, "checkId"), i = /* @__PURE__ */ a((l) => l.split(/\s+/).filter(Boolean).some((o) => yn.has(o)), "checkClass");
225
+ if (typeof e == "string") {
226
+ const l = e.trim();
227
+ return mn(l) ? !1 : n(l);
228
+ }
229
+ return !!(e.identifier && n(e.identifier) || e.className && i(e.className));
230
+ }
231
+ a(bn, "targetSuggestsPadInternal");
232
+ function vn(e) {
233
+ return e.some((n) => bn(n.target));
234
+ }
235
+ a(vn, "guideStepsRequireSketch");
236
+ const Sn = /* @__PURE__ */ a(({ entry: e, onHover: n }) => {
237
+ var i;
238
+ return /* @__PURE__ */ t(
239
+ S,
240
+ {
241
+ onClick: /* @__PURE__ */ a(() => {
242
+ var l;
243
+ return (l = e.source) == null ? void 0 : l.click();
244
+ }, "onClick"),
245
+ onMouseOver: /* @__PURE__ */ a(() => n == null ? void 0 : n(e.sourceSelector), "onMouseOver"),
246
+ sx: { "& :hover": { cursor: "pointer" } },
247
+ children: /* @__PURE__ */ t(
248
+ "div",
249
+ {
250
+ style: { width: `${e.width}px`, height: `${e.height}px` },
251
+ dangerouslySetInnerHTML: { __html: ((i = e.html) == null ? void 0 : i.replaceAll(Ze, "")) ?? "" }
252
+ }
253
+ )
254
+ }
255
+ );
256
+ }, "ClonedComponent");
257
+ function Cn(e) {
258
+ const {
259
+ cards: n,
260
+ filters: i,
261
+ layoutType: l,
262
+ remarks: o,
263
+ userPrompt: r,
264
+ grid_definition: g,
265
+ updated_grid_definition: h,
266
+ filter_components: x,
267
+ // Parameterised-dataset fields live on `Dashboard.Draft` server-side;
268
+ // at the top level the deserialiser drops them on the floor.
269
+ isDatasetParameterized: d,
270
+ defaultDatasetName: v,
271
+ clientSideChanges: s,
272
+ ...c
273
+ } = e;
274
+ return {
275
+ ...c,
276
+ draft: {
277
+ cards: n ?? [],
278
+ filters: i ?? [],
279
+ remarks: o,
280
+ userPrompt: r,
281
+ layoutType: l,
282
+ grid_definition: g ?? null,
283
+ updated_grid_definition: h ?? null,
284
+ filter_components: x ?? [],
285
+ isDatasetParameterized: d ?? !1,
286
+ defaultDatasetName: v
287
+ }
288
+ };
289
+ }
290
+ a(Cn, "toDraftPayload");
291
+ function Be(e) {
292
+ const n = e ?? {}, i = n.draft ?? n.committed;
293
+ return {
294
+ ...n,
295
+ cards: (i == null ? void 0 : i.cards) ?? n.cards ?? [],
296
+ filters: (i == null ? void 0 : i.filters) ?? n.filters ?? [],
297
+ remarks: (i == null ? void 0 : i.remarks) ?? n.remarks,
298
+ userPrompt: (i == null ? void 0 : i.userPrompt) ?? n.userPrompt,
299
+ layoutType: (i == null ? void 0 : i.layoutType) ?? n.layoutType,
300
+ grid_definition: (i == null ? void 0 : i.gridDefinition) ?? (i == null ? void 0 : i.grid_definition) ?? n.grid_definition ?? null,
301
+ updated_grid_definition: (i == null ? void 0 : i.upadatedGridDefinition) ?? (i == null ? void 0 : i.updated_grid_definition) ?? n.updated_grid_definition ?? null,
302
+ filter_components: (i == null ? void 0 : i.filterComponents) ?? (i == null ? void 0 : i.filter_components) ?? n.filter_components ?? [],
303
+ isDatasetParameterized: (i == null ? void 0 : i.isDatasetParameterized) ?? n.isDatasetParameterized,
304
+ defaultDatasetName: (i == null ? void 0 : i.defaultDatasetName) ?? n.defaultDatasetName
305
+ };
306
+ }
307
+ a(Be, "fromUpsertResponse");
308
+ async function at(e, n) {
309
+ const i = await e.upsertDashboard(Cn(n));
310
+ return Be(i);
311
+ }
312
+ a(at, "upsertDashboardDraft");
313
+ async function Pt(e, n, i) {
314
+ return at(e, {
315
+ name: (i == null ? void 0 : i.name) ?? "Sem título",
316
+ filters: (i == null ? void 0 : i.filters) ?? [],
317
+ cards: (i == null ? void 0 : i.cards) ?? [],
318
+ ...i,
319
+ id: void 0,
320
+ originalSessionId: n
321
+ });
322
+ }
323
+ a(Pt, "createDashboardDraft");
324
+ const wn = 3e3, Tn = 800, Dn = 500, ha = 1800;
325
+ function kn(e = {}) {
326
+ const n = e.viewerCommitDebounceMs ?? wn, i = e.draftSaveDebounceMs ?? Tn, l = e.onDraftSaveError ?? ((o) => console.warn("[@aintela/bi composer] draft save failed:", o));
327
+ return di()((o, r) => {
328
+ const g = /* @__PURE__ */ a(async () => {
329
+ const s = r()._client, c = r().dashboardDefinition;
330
+ if (!s || !(c != null && c.id) || !c.originalSessionId) return;
331
+ const u = at(s, c).then(() => {
332
+ }).catch(l);
333
+ o({ _draftSavePromise: u }), await u, o((p) => p._draftSavePromise === u ? { _draftSavePromise: null } : {});
334
+ }, "_saveDraft"), h = /* @__PURE__ */ a(() => {
335
+ const s = r()._draftSaveTimer;
336
+ s && clearTimeout(s);
337
+ const c = setTimeout(() => {
338
+ g();
339
+ }, i);
340
+ o({ _draftSaveTimer: c });
341
+ }, "_scheduleDraftSave"), x = /* @__PURE__ */ a(() => {
342
+ if (r().turnOpen) return;
343
+ const s = r()._viewerCommitTimer;
344
+ s && clearTimeout(s);
345
+ const c = setTimeout(() => {
346
+ if (r().turnOpen) return;
347
+ const u = r().dashboardDefinition;
348
+ o((p) => ({ publishedDashboard: u, llmCounter: p.llmCounter + 1, _viewerCommitTimer: null }));
349
+ }, n);
350
+ o({ _viewerCommitTimer: c });
351
+ }, "_scheduleViewerCommit"), d = /* @__PURE__ */ a(() => {
352
+ const s = r()._viewerCommitTimer;
353
+ s && (clearTimeout(s), o({ _viewerCommitTimer: null }));
354
+ }, "_cancelViewerCommit"), v = /* @__PURE__ */ a(async (s) => {
355
+ var H;
356
+ await Promise.resolve();
357
+ const c = r().dashboardDefinition, u = r().currentSessionId || null, p = r().turnOpen, f = s.id;
358
+ if (!p && (c != null && c.id) && f && c.id === f && (((H = c.cards) == null ? void 0 : H.length) ?? 0) > 0)
359
+ return;
360
+ const y = hn(s) ? pn(s) : { ...s };
361
+ y.originalSessionId = u;
362
+ const R = {
363
+ ...c,
364
+ ...y,
365
+ id: f ?? (c == null ? void 0 : c.id),
366
+ originalSessionId: y.originalSessionId,
367
+ jsFileName: y.jsFileName ?? (c == null ? void 0 : c.jsFileName),
368
+ name: y.name || (c == null ? void 0 : c.name) || "",
369
+ layoutType: "Naked"
370
+ };
371
+ r().updateDashboard(R), o((L) => ({ viewType: "Sketch", llmCounter: L.llmCounter + 1, agentPulseTick: L.agentPulseTick + 1 }));
372
+ }, "internalUpdateDashboardPad");
373
+ return {
374
+ dashboardDefinition: null,
375
+ publishedDashboard: null,
376
+ lastSentDashboard: null,
377
+ dashboardId: null,
378
+ viewType: "Sketch",
379
+ scriptLoadOnMount: !1,
380
+ renderGeneration: 0,
381
+ turnOpen: !1,
382
+ currentSessionId: null,
383
+ llmCounter: 0,
384
+ agentPulseTick: 0,
385
+ todosByCardKey: {},
386
+ sketchExpanded: !1,
387
+ hasCompletedOnce: !1,
388
+ producedDashboardId: null,
389
+ viewport: { width: 0, height: 0 },
390
+ guideSteps: null,
391
+ guideOptions: null,
392
+ _client: e.client ?? null,
393
+ _draftSaveTimer: null,
394
+ _draftSavePromise: null,
395
+ _viewerCommitTimer: null,
396
+ _guideShowTimer: null,
397
+ setClient: /* @__PURE__ */ a((s) => o({ _client: s }), "setClient"),
398
+ flushDraft: /* @__PURE__ */ a(async () => {
399
+ const s = r()._draftSaveTimer;
400
+ s && (clearTimeout(s), o({ _draftSaveTimer: null }));
401
+ const c = r()._draftSavePromise;
402
+ c && await c, await g();
403
+ }, "flushDraft"),
404
+ ingestToolEvent: /* @__PURE__ */ a((s, c) => {
405
+ if (s === "dashboardGenerated") {
406
+ const u = r().dashboardDefinition, p = {
407
+ ...u,
408
+ name: (u == null ? void 0 : u.name) || "Untitled",
409
+ jsFileName: c
410
+ };
411
+ d(), o((f) => ({
412
+ dashboardDefinition: p,
413
+ publishedDashboard: p,
414
+ lastSentDashboard: p,
415
+ viewType: "Generated",
416
+ scriptLoadOnMount: !1,
417
+ renderGeneration: f.renderGeneration + 1,
418
+ llmCounter: f.llmCounter + 1,
419
+ agentPulseTick: f.agentPulseTick + 1
420
+ })), h();
421
+ return;
422
+ }
423
+ if (s === "todolistUpdated")
424
+ try {
425
+ const u = JSON.parse(c);
426
+ o((p) => {
427
+ const f = { ...p.todosByCardKey };
428
+ let y = !1;
429
+ for (const R of u.items ?? [])
430
+ f[R.key] = { todo: R, turnOpen: p.turnOpen }, y = !0;
431
+ return y ? { todosByCardKey: f } : {};
432
+ });
433
+ } catch {
434
+ console.warn("[@aintela/bi composer] Failed to parse todolistUpdated:", c);
435
+ }
436
+ }, "ingestToolEvent"),
437
+ setTurnOpen: /* @__PURE__ */ a((s) => o({ turnOpen: s }), "setTurnOpen"),
438
+ onTurnOpened: /* @__PURE__ */ a(() => o({ turnOpen: !0, viewType: "Sketch" }), "onTurnOpened"),
439
+ onTurnClosed: /* @__PURE__ */ a(() => {
440
+ o({ turnOpen: !1, todosByCardKey: {} }), h();
441
+ }, "onTurnClosed"),
442
+ setDashboardId: /* @__PURE__ */ a((s) => o({ dashboardId: s }), "setDashboardId"),
443
+ setCurrentSessionId: /* @__PURE__ */ a((s) => o({ currentSessionId: s }), "setCurrentSessionId"),
444
+ setViewType: /* @__PURE__ */ a((s) => o({ viewType: s }), "setViewType"),
445
+ updateDashboard: /* @__PURE__ */ a((s) => {
446
+ if (!s) {
447
+ d(), o({ dashboardDefinition: null, publishedDashboard: null, lastSentDashboard: null });
448
+ return;
449
+ }
450
+ const u = { ...r().dashboardDefinition ?? { name: "" }, ...s }, p = !r().publishedDashboard && !r().lastSentDashboard;
451
+ o({
452
+ dashboardDefinition: u,
453
+ ...p ? { publishedDashboard: u, lastSentDashboard: u } : {}
454
+ }), p || x(), h();
455
+ }, "updateDashboard"),
456
+ loadDashboard: /* @__PURE__ */ a((s) => {
457
+ const c = !!s.jsFileName, u = { ...s };
458
+ d(), o({
459
+ dashboardDefinition: u,
460
+ publishedDashboard: u,
461
+ lastSentDashboard: u,
462
+ dashboardId: s.id ?? null,
463
+ currentSessionId: s.originalSessionId ?? null,
464
+ viewType: c ? "Generated" : "Sketch",
465
+ scriptLoadOnMount: c,
466
+ renderGeneration: r().renderGeneration + 1
467
+ });
468
+ }, "loadDashboard"),
469
+ recordSketchChange: /* @__PURE__ */ a((s, c) => {
470
+ const u = s.trim(), p = c.trim();
471
+ !u || !p || o((f) => {
472
+ const y = f.dashboardDefinition;
473
+ if (!y) return {};
474
+ const R = y.clientSideChanges ?? {};
475
+ return R[u] === p ? {} : { dashboardDefinition: { ...y, clientSideChanges: { ...R, [u]: p } } };
476
+ });
477
+ }, "recordSketchChange"),
478
+ clearClientSideChanges: /* @__PURE__ */ a(() => {
479
+ o((s) => {
480
+ const c = s.dashboardDefinition, u = c == null ? void 0 : c.clientSideChanges;
481
+ return !c || !u || Object.keys(u).length === 0 ? {} : { dashboardDefinition: { ...c, clientSideChanges: void 0 } };
482
+ });
483
+ }, "clearClientSideChanges"),
484
+ commitForSend: /* @__PURE__ */ a(() => {
485
+ d();
486
+ const s = r().dashboardDefinition;
487
+ o({ publishedDashboard: s, lastSentDashboard: s });
488
+ }, "commitForSend"),
489
+ commitDashboardLayout: /* @__PURE__ */ a(() => {
490
+ d(), o({ publishedDashboard: r().dashboardDefinition });
491
+ }, "commitDashboardLayout"),
492
+ setSketchExpanded: /* @__PURE__ */ a((s) => o((c) => ({ sketchExpanded: typeof s == "function" ? s(c.sketchExpanded) : s })), "setSketchExpanded"),
493
+ setHasCompletedOnce: /* @__PURE__ */ a((s) => o({ hasCompletedOnce: s }), "setHasCompletedOnce"),
494
+ setProducedDashboardId: /* @__PURE__ */ a((s) => o({ producedDashboardId: s }), "setProducedDashboardId"),
495
+ setViewport: /* @__PURE__ */ a((s) => o((c) => c.viewport.width === s.width && c.viewport.height === s.height ? {} : { viewport: s }), "setViewport"),
496
+ highlightComponent: /* @__PURE__ */ a((s, c) => {
497
+ const u = (c == null ? void 0 : c.durationMs) ?? ha, { elements: p } = Qe(s);
498
+ return p.length === 0 ? 0 : (p.forEach((f, y) => {
499
+ f.classList.add(Ze), setTimeout(() => f.classList.remove(Ze), u), y === 0 && (c != null && c.scrollIntoView) && typeof f.scrollIntoView == "function" && f.scrollIntoView({ behavior: "smooth", block: "center", inline: "center" });
500
+ }), p.length);
501
+ }, "highlightComponent"),
502
+ cloneComponent: /* @__PURE__ */ a((s, c) => {
503
+ const { selectors: u, elements: p } = Qe(s), f = gn(p, (c == null ? void 0 : c.includeHidden) ?? !1);
504
+ if (!f) return null;
505
+ const y = f.getBoundingClientRect(), R = {
506
+ id: ze(),
507
+ sourceSelector: u.join(",") || (typeof s == "string" ? s : s.identifier ?? ""),
508
+ html: f.outerHTML.replaceAll("data-env-id", "d-env-id").replaceAll("data-env-key", "d-env-key").replaceAll("data-env-name", "d-env-name").replaceAll("llm-env-target", "").replaceAll("llm-env-dashboard-action", ""),
509
+ width: Math.max(1, Math.round(y.width)),
510
+ height: Math.max(1, Math.round(y.height))
511
+ }, H = {
512
+ cloneId: R.id,
513
+ width: R.width,
514
+ height: R.height,
515
+ sourceSelector: R.sourceSelector,
516
+ html: R.html,
517
+ source: f
518
+ };
519
+ return H.component = /* @__PURE__ */ t(Sn, { entry: H, onHover: /* @__PURE__ */ a((L) => r().highlightComponent(L), "onHover") }), H;
520
+ }, "cloneComponent"),
521
+ createDashboardPad: /* @__PURE__ */ a((s) => {
522
+ v(s);
523
+ }, "createDashboardPad"),
524
+ updateDashboardPad: /* @__PURE__ */ a((s) => {
525
+ v(s);
526
+ }, "updateDashboardPad"),
527
+ showGuide: /* @__PURE__ */ a((s, c) => {
528
+ if (!Array.isArray(s) || s.length === 0) {
529
+ console.warn("[@aintela/bi composer] showGuide called with empty or non-array `steps`; tour will not be shown.", { steps: s, guideOptions: c });
530
+ return;
531
+ }
532
+ const u = s.findIndex((y) => !y || y.target === void 0 || y.target === null);
533
+ if (u >= 0) {
534
+ console.warn(`[@aintela/bi composer] showGuide: step ${u} is missing \`target\`; tour will not be shown.`, { steps: s });
535
+ return;
536
+ }
537
+ const p = r()._guideShowTimer;
538
+ p && clearTimeout(p);
539
+ const f = setTimeout(() => {
540
+ o({ guideSteps: s, guideOptions: c ?? null, _guideShowTimer: null });
541
+ }, Dn);
542
+ o({ _guideShowTimer: f });
543
+ }, "showGuide"),
544
+ dismissGuide: /* @__PURE__ */ a(() => {
545
+ var u;
546
+ const s = r()._guideShowTimer;
547
+ s && clearTimeout(s);
548
+ const c = r().guideOptions;
549
+ o({ guideSteps: null, guideOptions: null, _guideShowTimer: null }), (u = c == null ? void 0 : c.onComplete) == null || u.call(c);
550
+ }, "dismissGuide"),
551
+ refreshDashboard: /* @__PURE__ */ a(() => {
552
+ const s = r().dashboardDefinition;
553
+ if (!(s != null && s.id)) return;
554
+ const c = {
555
+ ...s,
556
+ name: s.name || "Untitled",
557
+ jsFileName: s.jsFileName ?? `${s.id}.js`
558
+ };
559
+ d(), o((u) => ({
560
+ dashboardDefinition: c,
561
+ publishedDashboard: c,
562
+ lastSentDashboard: c,
563
+ viewType: "Generated",
564
+ scriptLoadOnMount: !1,
565
+ renderGeneration: u.renderGeneration + 1,
566
+ llmCounter: u.llmCounter + 1
567
+ }));
568
+ }, "refreshDashboard"),
569
+ openComposer: /* @__PURE__ */ a((s) => {
570
+ if (d(), s) {
571
+ const c = !!s.jsFileName, u = { ...s };
572
+ o({
573
+ dashboardDefinition: u,
574
+ publishedDashboard: u,
575
+ lastSentDashboard: u,
576
+ dashboardId: s.id ?? null,
577
+ currentSessionId: s.originalSessionId ?? null,
578
+ viewType: c ? "Generated" : "Sketch",
579
+ scriptLoadOnMount: c,
580
+ renderGeneration: r().renderGeneration + 1,
581
+ turnOpen: !1,
582
+ todosByCardKey: {}
583
+ });
584
+ } else
585
+ o({
586
+ dashboardDefinition: null,
587
+ publishedDashboard: null,
588
+ lastSentDashboard: null,
589
+ dashboardId: null,
590
+ currentSessionId: null,
591
+ viewType: "Sketch",
592
+ scriptLoadOnMount: !1,
593
+ renderGeneration: r().renderGeneration + 1,
594
+ turnOpen: !1,
595
+ todosByCardKey: {}
596
+ });
597
+ }, "openComposer")
598
+ };
599
+ });
600
+ }
601
+ a(kn, "createComposerStore");
602
+ const Et = Ct(null), ua = /* @__PURE__ */ a(({ client: e, store: n, children: i, ...l }) => {
603
+ const o = et(), r = e === void 0 ? o : e, [g] = N(() => n ?? kn({ ...l, client: r }));
604
+ return q(() => {
605
+ g.getState()._client !== r && g.getState().setClient(r);
606
+ }, [g, r]), /* @__PURE__ */ t(Et.Provider, { value: g, children: i });
607
+ }, "ComposerProvider");
608
+ function he() {
609
+ const e = Ae(Et);
610
+ if (!e)
611
+ throw new Error("[@aintela/bi] No composer store in scope. Wrap the composer surface in <ComposerProvider>.");
612
+ return e;
613
+ }
614
+ a(he, "useComposerStore");
615
+ function ma() {
616
+ return Ae(Et);
617
+ }
618
+ a(ma, "useComposerStoreOptional");
619
+ function B(e) {
620
+ const n = he();
621
+ return en(n, e ?? ((i) => i));
622
+ }
623
+ a(B, "useComposer");
624
+ function In() {
625
+ const e = he();
626
+ return en(
627
+ e,
628
+ si((n) => ({
629
+ highlightComponent: n.highlightComponent,
630
+ cloneComponent: n.cloneComponent,
631
+ createDashboardPad: n.createDashboardPad,
632
+ updateDashboardPad: n.updateDashboardPad,
633
+ refreshDashboard: n.refreshDashboard,
634
+ showGuide: n.showGuide,
635
+ dismissGuide: n.dismissGuide
636
+ }))
637
+ );
638
+ }
639
+ a(In, "useComposerEnvironment");
640
+ function fa(e) {
641
+ const n = e.getState();
642
+ return {
643
+ highlightComponent: n.highlightComponent,
644
+ cloneComponent: n.cloneComponent,
645
+ createDashboardPad: n.createDashboardPad,
646
+ updateDashboardPad: n.updateDashboardPad,
647
+ refreshDashboard: n.refreshDashboard,
648
+ showGuide: n.showGuide,
649
+ dismissGuide: n.dismissGuide
650
+ };
651
+ }
652
+ a(fa, "environmentFromStore");
653
+ const zn = {
654
+ Generic: Tt,
655
+ Métrica: on,
656
+ Tabela: an,
657
+ Gráfico: ut,
658
+ Mapa: pi,
659
+ Árvore: nn,
660
+ Medidor: tn
661
+ }, On = {
662
+ Generic: "info",
663
+ Métrica: "kpi",
664
+ Tabela: "table",
665
+ Gráfico: "chart",
666
+ Mapa: "map",
667
+ Árvore: "chart",
668
+ Medidor: "chart"
669
+ }, Pn = {
670
+ Generic: Tt,
671
+ MetricComparison: on,
672
+ TableAuto: an,
673
+ TableBars: zi,
674
+ TableHeatmap: Ii,
675
+ TableLarge: ki,
676
+ ChartAuto: ut,
677
+ ChartLine: Di,
678
+ ChartBarH: Ti,
679
+ ChartBarV: ut,
680
+ ChartArea: wi,
681
+ ChartStackedArea: Ci,
682
+ ChartStackedBar: Si,
683
+ ChartCombo: vi,
684
+ ChartPie: bi,
685
+ Scatter: yi,
686
+ ChartDonut: xi,
687
+ MapBubbles: gi,
688
+ MapConnections: fi,
689
+ Treemap: nn,
690
+ Gauge: tn
691
+ }, En = {
692
+ Generic: "DashboardOutlined",
693
+ MetricComparison: "TagOutlined",
694
+ TableAuto: "TableChartOutlined",
695
+ TableBars: "ViewColumnOutlined",
696
+ TableHeatmap: "HeatPumpOutlined",
697
+ TableLarge: "TableRowsOutlined",
698
+ ChartAuto: "BarChartOutlined",
699
+ ChartLine: "ShowChartOutlined",
700
+ ChartBarH: "AlignHorizontalLeftOutlined",
701
+ ChartBarV: "BarChartOutlined",
702
+ ChartArea: "AreaChartOutlined",
703
+ ChartStackedArea: "StackedLineChartOutlined",
704
+ ChartStackedBar: "StackedBarChartOutlined",
705
+ ChartCombo: "MultilineChartOutlined",
706
+ ChartPie: "PieChartOutlined",
707
+ Scatter: "ScatterPlotOutlined",
708
+ ChartDonut: "DonutLargeOutlined",
709
+ MapBubbles: "BubbleChartOutlined",
710
+ MapConnections: "TimelineOutlined",
711
+ Treemap: "GridViewOutlined",
712
+ Gauge: "SpeedOutlined"
713
+ }, $n = {
714
+ DateRangePicker: mi,
715
+ DatePicker: ui,
716
+ AutoComplete: hi
717
+ }, An = {
718
+ category: zn,
719
+ specificType: Pn,
720
+ filterType: $n
721
+ }, vt = Ct(An), ga = /* @__PURE__ */ a(({ icons: e, children: n }) => {
722
+ const i = Ae(vt), l = ve(
723
+ () => ({
724
+ category: { ...i.category, ...e.category ?? {} },
725
+ specificType: { ...i.specificType, ...e.specificType ?? {} },
726
+ filterType: { ...i.filterType, ...e.filterType ?? {} }
727
+ }),
728
+ [i, e]
729
+ );
730
+ return /* @__PURE__ */ t(vt.Provider, { value: l, children: n });
731
+ }, "CardTypeIconsProvider");
732
+ function Me() {
733
+ return Ae(vt);
734
+ }
735
+ a(Me, "useCardTypeIcons");
736
+ const xa = 60, ya = it(we);
737
+ function ba(e) {
738
+ const [n, i] = N(0);
739
+ return q(() => {
740
+ const l = e.current;
741
+ if (!l) return;
742
+ const o = /* @__PURE__ */ a(() => i(l.getBoundingClientRect().height), "measure");
743
+ if (o(), typeof ResizeObserver > "u") return;
744
+ const r = new ResizeObserver(o);
745
+ return r.observe(l), () => r.disconnect();
746
+ }, [e]), n;
747
+ }
748
+ a(ba, "useElementHeight");
749
+ const $t = /* @__PURE__ */ a((e) => {
750
+ var F;
751
+ const n = Me(), [i, l] = N(e.cellConfig.name ?? "[Card Name]"), [o, r] = N(e.cellConfig.actionDescription ?? "[Card Description]"), [g, h] = N(!1), [x, d] = N(e.cellConfig), [v, s] = N(!1), [c, u] = N(!1), p = ee(null), f = ee(null), y = ee(null), R = ba(y), H = e.cellConfig.specificType ?? "Generic", L = e.cellConfig.category ?? "Generic", P = n.specificType[H] ?? n.specificType.Generic;
752
+ q(() => {
753
+ d(e.cellConfig);
754
+ }, [e.cellConfig]), q(() => {
755
+ const D = setTimeout(() => {
756
+ if (!p.current) return;
757
+ let z = p.current.getElementsByTagName("input").item(0);
758
+ z || (z = p.current.getElementsByTagName("textarea").item(0)), z && (z.focus(), z.selectionStart = 0, z.selectionEnd = z.value.length);
759
+ }, 50);
760
+ return () => clearTimeout(D);
761
+ }, [g, v]);
762
+ const _ = /* @__PURE__ */ a((D) => {
763
+ (!D.shiftKey && D.key === "Enter" || D.key === "Escape") && (s(!1), h(!1), e.onDataEdit(x));
764
+ }, "handleKeyPress"), $ = /* @__PURE__ */ a((D, z) => {
765
+ const I = z.target.value;
766
+ if (D === l && $e(I).length > xa) return;
767
+ D(I);
768
+ const U = { ...e.cellConfig };
769
+ D === l ? U.name = I : U.actionDescription = I, d(U);
770
+ }, "handleChange"), V = /* @__PURE__ */ a((D, z) => {
771
+ u(!1);
772
+ const I = { ...e.cellConfig, category: D, specificType: z };
773
+ I.muiIconName = En[z], I.color = On[D];
774
+ const U = Oe[D];
775
+ (!I.name || I.name.startsWith("[Card") || Object.values(Oe).some((J) => {
776
+ var Q;
777
+ return (Q = I.name) == null ? void 0 : Q.match(new RegExp(`^${J}\\d+$`));
778
+ })) && (I.name = U, l(U)), e.onDataEdit(I);
779
+ }, "handleTypeChange"), K = (F = e.todoItem) == null ? void 0 : F.status, M = { onMouseDown: /* @__PURE__ */ a((D) => D.stopPropagation(), "onMouseDown"), onTouchStart: /* @__PURE__ */ a((D) => D.stopPropagation(), "onTouchStart") }, w = e.renderDescription ?? ((D) => /* @__PURE__ */ t("span", { style: { whiteSpace: "pre-wrap" }, children: D }));
780
+ return /* @__PURE__ */ b(
781
+ j,
782
+ {
783
+ className: "llm-env-target llm-env-card llm-env-card-sketch",
784
+ "data-env-id": e.cellConfig.i,
785
+ "data-env-key": e.cellConfig.i,
786
+ "data-env-name": e.cellConfig.name ?? "",
787
+ "data-env-kind": "sketch-card",
788
+ sx: { height: "100%", position: "relative", overflow: "hidden" },
789
+ children: [
790
+ !(e.todoItem && e.turnOpen) && /* @__PURE__ */ t(
791
+ j,
792
+ {
793
+ "aria-hidden": !0,
794
+ sx: {
795
+ position: "absolute",
796
+ inset: 0,
797
+ display: "flex",
798
+ alignItems: "center",
799
+ justifyContent: "center",
800
+ pointerEvents: "none",
801
+ color: "text.primary",
802
+ opacity: 0.06,
803
+ zIndex: 0,
804
+ "& > svg": { width: "70%", height: "70%", maxWidth: "180px", maxHeight: "180px" }
805
+ },
806
+ children: /* @__PURE__ */ t(P, {})
807
+ }
808
+ ),
809
+ /* @__PURE__ */ t(j, { sx: { position: "absolute", top: "15px", right: "-5px", display: "flex", gap: 0, zIndex: 2 }, children: /* @__PURE__ */ t(se, { ...M, children: /* @__PURE__ */ t(Pe, { size: "small", onClick: /* @__PURE__ */ a(() => {
810
+ var D;
811
+ return (D = e.onDelete) == null ? void 0 : D.call(e, e.cellConfig.i);
812
+ }, "onClick"), "aria-label": "Remover card", children: /* @__PURE__ */ t(rn, { fontSize: "small" }) }) }) }),
813
+ e.todoItem && e.turnOpen && /* @__PURE__ */ b(
814
+ j,
815
+ {
816
+ sx: /* @__PURE__ */ a((D) => ({
817
+ position: "absolute",
818
+ display: "flex",
819
+ alignItems: "center",
820
+ justifyContent: "center",
821
+ minHeight: "calc(100% + 11px)",
822
+ minWidth: "calc(100% + 10px)",
823
+ top: -6,
824
+ left: -7,
825
+ gap: 2,
826
+ py: 0.4,
827
+ borderRadius: "10px",
828
+ backgroundColor: Ce(D.palette.common.black, 0.4),
829
+ opacity: K == "completed" ? 0.6 : 1
830
+ }), "sx"),
831
+ children: [
832
+ /* @__PURE__ */ t(j, { sx: { mt: "1px", flexShrink: 0, color: K == "completed" ? "success.main" : K === "in_progress" ? "primary.main" : "text.disabled" }, children: K == "completed" ? /* @__PURE__ */ t(Oi, { sx: { fontSize: "0.95rem" } }) : K === "in_progress" ? /* @__PURE__ */ t(Pi, { sx: { fontSize: "0.95rem" } }) : /* @__PURE__ */ t(ft, { size: 20, sx: { fontSize: "0.95rem" } }) }),
833
+ /* @__PURE__ */ b(j, { sx: { textAlign: "left" }, children: [
834
+ /* @__PURE__ */ t(ie, { variant: "caption", sx: { display: "block", fontSize: "0.78rem", lineHeight: 1.3, textDecoration: K === "completed" ? "line-through" : "none" }, children: e.todoItem.label }),
835
+ e.todoItem.detail && /* @__PURE__ */ t(ie, { variant: "caption", sx: { display: "block", fontSize: "0.7rem", color: "text.secondary", lineHeight: 1.3 }, children: e.todoItem.detail })
836
+ ] })
837
+ ]
838
+ }
839
+ ),
840
+ /* @__PURE__ */ t(Ve, { open: c, anchorEl: f.current, placement: "bottom-start", transition: !0, sx: { zIndex: 1300 }, children: /* @__PURE__ */ a(({ TransitionProps: D }) => /* @__PURE__ */ t(je, { ...D, children: /* @__PURE__ */ t(Fe, { elevation: 8, sx: { maxHeight: 380, overflow: "auto", minWidth: 240 }, children: /* @__PURE__ */ t(Ue, { onClickAway: /* @__PURE__ */ a(() => u(!1), "onClickAway"), children: /* @__PURE__ */ t(gt, { dense: !0, children: Object.entries(ya).map(([z, I], U) => {
841
+ const J = n.category[z];
842
+ return /* @__PURE__ */ b(j, { children: [
843
+ U > 0 && /* @__PURE__ */ t(Ke, {}),
844
+ /* @__PURE__ */ b(ie, { variant: "overline", sx: { px: 2, pt: 1, display: "flex", alignItems: "center", gap: 0.5 }, children: [
845
+ /* @__PURE__ */ t(J, { fontSize: "inherit" }),
846
+ z
847
+ ] }),
848
+ I.map((Q) => {
849
+ const ne = n.specificType[Q.specificType];
850
+ return /* @__PURE__ */ b(Ee, { selected: Q.specificType === H, onClick: /* @__PURE__ */ a(() => V(Q.category, Q.specificType), "onClick"), children: [
851
+ /* @__PURE__ */ t(qe, { children: /* @__PURE__ */ t(ne, { fontSize: "small" }) }),
852
+ /* @__PURE__ */ t(Ye, { children: Q.label })
853
+ ] }, Q.specificType);
854
+ })
855
+ ] }, z);
856
+ }) }) }) }) }), "children") }),
857
+ /* @__PURE__ */ t(j, { sx: { minHeight: "20%", textAlign: "left", position: "relative", zIndex: 1 }, children: /* @__PURE__ */ b(se, { direction: "row", children: [
858
+ /* @__PURE__ */ t(
859
+ Pe,
860
+ {
861
+ ...M,
862
+ ref: f,
863
+ size: "small",
864
+ onClick: /* @__PURE__ */ a(() => u((D) => !D), "onClick"),
865
+ title: `Tipo: ${L} / ${H}`,
866
+ sx: { color: "primary.main", mr: 0 },
867
+ children: /* @__PURE__ */ t(P, { fontSize: "small" })
868
+ }
869
+ ),
870
+ !g && /* @__PURE__ */ t(
871
+ j,
872
+ {
873
+ ...M,
874
+ onClick: /* @__PURE__ */ a(() => {
875
+ h(!0), s(!1);
876
+ }, "onClick"),
877
+ sx: { color: "text.primary", minWidth: "50%", maxWidth: "80%", maxHeight: "30px", cursor: "pointer", display: "inline-flex", alignItems: "center", gap: 0.5, overflow: "clip", textWrap: "nowrap" },
878
+ children: i
879
+ }
880
+ ),
881
+ g && /* @__PURE__ */ t(
882
+ Ne,
883
+ {
884
+ size: "small",
885
+ ref: p,
886
+ ...M,
887
+ onChange: /* @__PURE__ */ a((D) => $(l, D), "onChange"),
888
+ onBlur: /* @__PURE__ */ a((D) => $(l, D), "onBlur"),
889
+ onKeyDown: _,
890
+ value: i,
891
+ sx: /* @__PURE__ */ a((D) => ({
892
+ fontSize: "0.75rem",
893
+ width: "82%",
894
+ "& .MuiOutlinedInput-root:hover .MuiOutlinedInput-notchedOutline": { border: "0px" },
895
+ "& .MuiOutlinedInput-root.Mui-focused .MuiOutlinedInput-notchedOutline": { border: "0px", pl: 3, p: 0, backgroundColor: Ce(D.palette.text.primary, 0.08) }
896
+ }), "sx"),
897
+ slotProps: {
898
+ root: { style: { padding: "2px 0px 0px 0px", border: "0px" } },
899
+ input: { style: { padding: "2px 0px 0px 0px", border: "0px" } }
900
+ }
901
+ }
902
+ )
903
+ ] }) }),
904
+ /* @__PURE__ */ b(j, { ref: y, sx: { textAlign: "left", position: "relative", zIndex: 1, minHeight: "80%" }, ...M, children: [
905
+ !v && /* @__PURE__ */ t(
906
+ j,
907
+ {
908
+ ...M,
909
+ onClick: /* @__PURE__ */ a(() => {
910
+ s(!0), h(!1);
911
+ }, "onClick"),
912
+ sx: { fontSize: "0.85rem", cursor: "pointer", color: "text.primary", width: "100%", minHeight: "30%", pb: "20px" },
913
+ children: w(o)
914
+ }
915
+ ),
916
+ v && /* @__PURE__ */ t(
917
+ Ne,
918
+ {
919
+ slotProps: {
920
+ root: { style: { padding: "0px", border: "0px" } },
921
+ input: { style: { padding: "0px 0px 5px 0px", border: "0px", height: Math.max(0, R - 2.5), alignContent: "start", flexWrap: "wrap", fontSize: "0.8rem" } }
922
+ },
923
+ multiline: !0,
924
+ ref: p,
925
+ sx: /* @__PURE__ */ a((D) => ({
926
+ minHeight: "100%",
927
+ alignContent: "start",
928
+ width: "92%",
929
+ "& .MuiOutlinedInput-root:hover .MuiOutlinedInput-notchedOutline": { border: "0px" },
930
+ "& .MuiOutlinedInput-root.Mui-focused .MuiOutlinedInput-notchedOutline": { border: "0px", backgroundColor: Ce(D.palette.text.primary, 0.08) }
931
+ }), "sx"),
932
+ onChange: /* @__PURE__ */ a((D) => {
933
+ D.stopPropagation(), $(r, D);
934
+ }, "onChange"),
935
+ onBlur: /* @__PURE__ */ a((D) => $(r, D), "onBlur"),
936
+ onKeyDown: _,
937
+ value: o
938
+ }
939
+ )
940
+ ] })
941
+ ]
942
+ }
943
+ );
944
+ }, "CardSketch"), va = $t, At = /* @__PURE__ */ a(({ filter: e, onEdit: n, onDelete: i }) => {
945
+ const [l, o] = N(!1), [r, g] = N(e.name), h = ee(null), x = Me().filterType[e.filterType];
946
+ q(() => {
947
+ l && h.current && (h.current.focus(), h.current.select());
948
+ }, [l]), q(() => {
949
+ g(e.name);
950
+ }, [e.name]);
951
+ const d = /* @__PURE__ */ a(() => {
952
+ const s = r.trim();
953
+ s && s !== e.name ? n({ ...e, name: s }) : g(e.name), o(!1);
954
+ }, "commitName"), v = /* @__PURE__ */ a((s) => {
955
+ s.key === "Enter" && d(), s.key === "Escape" && (g(e.name), o(!1));
956
+ }, "handleKeyDown");
957
+ return /* @__PURE__ */ b(
958
+ j,
959
+ {
960
+ className: "llm-env-target llm-env-filter llm-env-filter-sketch",
961
+ "data-env-id": e.i,
962
+ "data-env-key": e.i,
963
+ "data-env-name": e.name,
964
+ "data-env-kind": "sketch-filter",
965
+ sx: /* @__PURE__ */ a((s) => ({
966
+ display: "inline-flex",
967
+ alignItems: "center",
968
+ gap: 0.5,
969
+ flexWrap: "wrap",
970
+ border: `1px dashed ${s.palette.divider}`,
971
+ borderRadius: "10px",
972
+ maxHeight: "90%",
973
+ px: 1,
974
+ py: 0.5,
975
+ backgroundColor: s.palette.background.default,
976
+ maxWidth: 260
977
+ }), "sx"),
978
+ children: [
979
+ /* @__PURE__ */ t(x, { sx: { fontSize: 16, color: "primary.main", flexShrink: 0 } }),
980
+ l ? /* @__PURE__ */ t(
981
+ Ne,
982
+ {
983
+ inputRef: h,
984
+ value: r,
985
+ onChange: /* @__PURE__ */ a((s) => g(s.target.value), "onChange"),
986
+ onBlur: d,
987
+ onKeyDown: v,
988
+ variant: "standard",
989
+ size: "small",
990
+ slotProps: {
991
+ input: { disableUnderline: !0, sx: { fontSize: "0.75rem", pl: 1, height: 20 } },
992
+ root: { style: { width: "80%" } }
993
+ }
994
+ }
995
+ ) : /* @__PURE__ */ t(
996
+ ie,
997
+ {
998
+ variant: "caption",
999
+ noWrap: !0,
1000
+ onClick: /* @__PURE__ */ a(() => o(!0), "onClick"),
1001
+ sx: {
1002
+ cursor: "pointer",
1003
+ fontSize: "0.75rem",
1004
+ color: "text.primary",
1005
+ pl: 1,
1006
+ width: "80%",
1007
+ minWidth: "90px",
1008
+ "&:hover": { textDecoration: "underline" }
1009
+ },
1010
+ children: e.name
1011
+ }
1012
+ ),
1013
+ e.filterType !== "AutoComplete" && /* @__PURE__ */ t(Ie, { title: e.mandatory ? "Mandatory filter" : "Optional filter", arrow: !0, children: /* @__PURE__ */ b(j, { sx: { display: "inline-flex", alignItems: "center", gap: 0 }, children: [
1014
+ /* @__PURE__ */ t(ie, { variant: "caption", sx: { fontSize: "0.6rem", color: "text.secondary", minWidth: "55px", whiteSpace: "nowrap" }, children: e.mandatory ? "Obrigatório" : "Opcional" }),
1015
+ /* @__PURE__ */ t(
1016
+ xt,
1017
+ {
1018
+ size: "small",
1019
+ checked: e.mandatory,
1020
+ onChange: /* @__PURE__ */ a((s, c) => n({ ...e, mandatory: c }), "onChange"),
1021
+ sx: { transform: "scale(0.7)", ml: -0.5, mr: -1 }
1022
+ }
1023
+ )
1024
+ ] }) }),
1025
+ e.filterType === "AutoComplete" && /* @__PURE__ */ t(Ie, { title: e.multipleSelection ? "Multiple selection" : "Single selection", arrow: !0, children: /* @__PURE__ */ b(j, { sx: { display: "inline-flex", alignItems: "center", gap: 0 }, children: [
1026
+ /* @__PURE__ */ t(ie, { variant: "caption", sx: { fontSize: "0.6rem", color: "text.secondary", whiteSpace: "wrap", minWidth: "43px" }, children: e.multipleSelection ? "Multiple" : "Single" }),
1027
+ /* @__PURE__ */ t(
1028
+ xt,
1029
+ {
1030
+ size: "small",
1031
+ checked: e.multipleSelection ?? !1,
1032
+ onChange: /* @__PURE__ */ a((s, c) => n({ ...e, multipleSelection: c }), "onChange"),
1033
+ sx: { transform: "scale(0.7)", ml: -0.5, mr: -1 }
1034
+ }
1035
+ )
1036
+ ] }) }),
1037
+ /* @__PURE__ */ t(Pe, { size: "small", onClick: /* @__PURE__ */ a(() => i(e.i), "onClick"), sx: { p: 0.2, ml: "auto" }, "aria-label": "Remover filtro", children: /* @__PURE__ */ t(rn, { sx: { fontSize: 14 } }) })
1038
+ ]
1039
+ }
1040
+ );
1041
+ }, "FilterSketch"), Ge = /* @__PURE__ */ a((e) => {
1042
+ const [n, i] = N(!1), [l, o] = N(e.text), r = ee(null), g = e.fontSize ?? 12;
1043
+ q(() => {
1044
+ n && r.current && (r.current.focus(), r.current.select()), o(e.text);
1045
+ }, [n, e.text]);
1046
+ const h = /* @__PURE__ */ a(() => {
1047
+ const d = (l == null ? void 0 : l.trim()) ?? "";
1048
+ d !== e.text && e.onEdit(d), o(d), i(!1);
1049
+ }, "commit");
1050
+ return /* @__PURE__ */ t(
1051
+ j,
1052
+ {
1053
+ sx: /* @__PURE__ */ a((d) => ({
1054
+ display: "inline-flex",
1055
+ alignItems: "center",
1056
+ gap: 0.5,
1057
+ px: 1,
1058
+ py: 0.5,
1059
+ mb: 0.5,
1060
+ backgroundColor: d.palette.background.paper,
1061
+ width: "100%"
1062
+ }), "sx"),
1063
+ children: n ? /* @__PURE__ */ t(
1064
+ Ne,
1065
+ {
1066
+ inputRef: r,
1067
+ value: l,
1068
+ onChange: /* @__PURE__ */ a((d) => o(d.target.value), "onChange"),
1069
+ onBlur: h,
1070
+ onKeyDown: /* @__PURE__ */ a((d) => {
1071
+ d.key === "Enter" && !(e.multiline && d.shiftKey) && h(), d.key === "Escape" && (o(e.text), i(!1));
1072
+ }, "handleKeyDown"),
1073
+ multiline: e.multiline,
1074
+ variant: "standard",
1075
+ size: "small",
1076
+ sx: { width: "100%", overflow: "hidden" },
1077
+ slotProps: {
1078
+ input: {
1079
+ disableUnderline: !0,
1080
+ sx: /* @__PURE__ */ a((d) => ({ minWidth: "100px", color: d.palette.text.primary, fontSize: g, margin: 0, padding: 0, pl: 1 }), "sx")
1081
+ },
1082
+ root: {
1083
+ sx: {
1084
+ overflow: "hidden",
1085
+ alignContent: "center",
1086
+ padding: "0px",
1087
+ width: e.multiline ? "90%" : "unset",
1088
+ margin: 0,
1089
+ height: e.multiline ? "35px" : "unset"
1090
+ }
1091
+ }
1092
+ }
1093
+ }
1094
+ ) : /* @__PURE__ */ t(
1095
+ j,
1096
+ {
1097
+ onClick: /* @__PURE__ */ a(() => i(!0), "onClick"),
1098
+ sx: /* @__PURE__ */ a((d) => ({
1099
+ cursor: "pointer",
1100
+ fontFamily: d.typography.fontFamily,
1101
+ fontSize: g,
1102
+ color: d.palette.text.primary,
1103
+ pl: 1,
1104
+ minWidth: "100px",
1105
+ height: "100%",
1106
+ minHeight: "20px",
1107
+ overflow: "clip",
1108
+ whiteSpace: e.multiline ? "pre-wrap" : "nowrap",
1109
+ "&:hover": { textDecoration: "underline" }
1110
+ }), "sx"),
1111
+ children: !l || l.length == 0 ? e.placeHolderText : l
1112
+ }
1113
+ )
1114
+ }
1115
+ );
1116
+ }, "TitleSketch"), Sa = Ge, Ca = Ge, wa = { Large: 4, Desktop: 4, Tablet: 4, Mobile: 4 }, Ta = { Large: 12, Desktop: 12, Tablet: 12, Mobile: 12 }, ct = 6;
1117
+ function Da(e, n, i = 0) {
1118
+ const [l, o] = N(i);
1119
+ return q(() => {
1120
+ const r = e.current;
1121
+ if (!r || (o(r.getBoundingClientRect().width), typeof ResizeObserver > "u")) return;
1122
+ const g = new ResizeObserver((h) => {
1123
+ const x = h[0];
1124
+ x && o(x.contentRect.width);
1125
+ });
1126
+ return g.observe(r), () => g.disconnect();
1127
+ }, [e, n]), l;
1128
+ }
1129
+ a(Da, "useContainerWidth");
1130
+ const ka = /* @__PURE__ */ a((e) => {
1131
+ const n = Math.round(Date.now() * Math.pow(10, -6));
1132
+ return `${$e(e)}_${n}`;
1133
+ }, "makeNameUnique"), ot = wt((e, n) => {
1134
+ const i = he(), l = B((m) => {
1135
+ var k;
1136
+ return (k = m.dashboardDefinition) == null ? void 0 : k.cards;
1137
+ }) ?? Ia, o = B((m) => {
1138
+ var k;
1139
+ return (k = m.dashboardDefinition) == null ? void 0 : k.filters;
1140
+ }) ?? za, r = B((m) => {
1141
+ var k;
1142
+ return ((k = m.dashboardDefinition) == null ? void 0 : k.name) ?? "";
1143
+ }), g = B((m) => {
1144
+ var k;
1145
+ return ((k = m.dashboardDefinition) == null ? void 0 : k.layoutType) ?? "Boxed";
1146
+ }), h = B((m) => {
1147
+ var k;
1148
+ return (k = m.dashboardDefinition) == null ? void 0 : k.id;
1149
+ }), x = B((m) => m.turnOpen), d = B((m) => m.todosByCardKey), [v, s] = N([]), c = ee(null), u = Da(c, e.renderId), [p, f] = N(null), [y, R] = N(0), H = ee({}), L = ee(0), P = ee(void 0), _ = le(), $ = e.zoomLevel ?? 0.8, V = W((m, k) => {
1150
+ k && (i.getState().recordSketchChange("dashboard:layoutType", `Set layout type to ${k}`), i.getState().updateDashboard({ layoutType: k }));
1151
+ }, [i]);
1152
+ q(() => {
1153
+ if (h === P.current || (P.current = h, !h)) return;
1154
+ const m = i.getState().dashboardDefinition, k = (m == null ? void 0 : m.cards) ?? [];
1155
+ H.current = {}, k.forEach((E) => {
1156
+ const G = Oe[E.category ?? "Generic"];
1157
+ H.current[G] = (H.current[G] ?? 0) + 1;
1158
+ }), L.current = ((m == null ? void 0 : m.filters) ?? []).length, s(k);
1159
+ }, [h, i]);
1160
+ const K = W((m) => {
1161
+ const k = Oe[m], E = (H.current[k] ?? 0) + 1;
1162
+ return H.current[k] = E, ka(`${k}${E}`);
1163
+ }, []), M = W((m, k) => {
1164
+ s(m);
1165
+ }, []), w = W((m, k, E) => {
1166
+ var pe;
1167
+ if (!k || !E) return;
1168
+ const G = ((pe = i.getState().dashboardDefinition) == null ? void 0 : pe.cards) ?? [];
1169
+ let Z = !1;
1170
+ const te = G.map((xe) => {
1171
+ const ye = m.find((ri) => ri.i === xe.i);
1172
+ return ye && (xe.w !== ye.w || xe.h !== ye.h || xe.x !== ye.x || xe.y !== ye.y) ? (Z = !0, { ...xe, w: ye.w, h: ye.h, x: ye.x, y: ye.y }) : xe;
1173
+ });
1174
+ if (!Z) return;
1175
+ const T = G.find((xe) => xe.i === E.i), O = (T == null ? void 0 : T.name) ?? E.i, ae = k.w !== E.w || k.h !== E.h, fe = k.x !== E.x || k.y !== E.y, Se = `card:${E.i}:layout`;
1176
+ ae && fe ? i.getState().recordSketchChange(Se, `Resized and moved card '${O}' to (w:${E.w}, h:${E.h}, x:${E.x}, y:${E.y})`) : ae ? i.getState().recordSketchChange(Se, `Resized card '${O}' to (w:${E.w}, h:${E.h})`) : fe && i.getState().recordSketchChange(Se, `Moved card '${O}' to (x:${E.x}, y:${E.y})`), i.getState().updateDashboard({ cards: te });
1177
+ }, [i]), F = W((m) => {
1178
+ var G;
1179
+ const k = ((G = i.getState().dashboardDefinition) == null ? void 0 : G.cards) ?? [], E = k.find((Z) => Z.i === m);
1180
+ i.getState().recordSketchChange(`card:${m}:delete`, `Deleted card '${(E == null ? void 0 : E.name) ?? m}'`), i.getState().updateDashboard({ cards: k.filter((Z) => Z.i !== m) });
1181
+ }, [i]), D = W((m = "Generic", k = "Generic") => {
1182
+ const E = K(m);
1183
+ return {
1184
+ i: $e(E),
1185
+ h: ct,
1186
+ w: y,
1187
+ y: 1 / 0,
1188
+ x: 0,
1189
+ isDraggable: void 0,
1190
+ isResizable: !0,
1191
+ category: m,
1192
+ specificType: k,
1193
+ name: E
1194
+ };
1195
+ }, [y, K]), z = W((m) => {
1196
+ const k = m.length === 0 ? "Untitled Dashboard" : m;
1197
+ i.getState().recordSketchChange("dashboard:name", `Renamed dashboard to '${k}'`), i.getState().updateDashboard({ name: k });
1198
+ }, [i]), I = W((m) => {
1199
+ var T;
1200
+ const k = ((T = i.getState().dashboardDefinition) == null ? void 0 : T.cards) ?? [], E = v.find((O) => O.i === m.i), G = k.find((O) => O.i === m.i), Z = k.map((O) => O.i !== m.i ? O : {
1201
+ ...O,
1202
+ ...E ? { w: E.w, h: E.h, x: E.x, y: E.y } : {},
1203
+ name: m.name,
1204
+ actionDescription: m.actionDescription,
1205
+ category: m.category,
1206
+ specificType: m.specificType,
1207
+ muiIconName: m.muiIconName
1208
+ }), te = [];
1209
+ G && (G.name !== m.name && te.push(`name → '${m.name}'`), G.actionDescription !== m.actionDescription && te.push("description"), G.category !== m.category && te.push(`category → '${m.category}'`), G.specificType !== m.specificType && te.push(`type → '${m.specificType}'`), G.muiIconName !== m.muiIconName && te.push("icon")), te.length > 0 && i.getState().recordSketchChange(`card:${m.i}:edit`, `Edited card '${(G == null ? void 0 : G.name) ?? m.name}' (${te.join(", ")})`), i.getState().updateDashboard({ cards: Z });
1210
+ }, [v, i]), U = W(() => {
1211
+ const m = p ? Ta[p] : 10, k = v.length > 0 ? v[v.length - 1] : null;
1212
+ let E = 0, G = 0;
1213
+ return k && (G = k.y, k.x + k.w > m - y ? (G += 1, E = 0) : E = k.x + k.w), { x: E, y: G };
1214
+ }, [p, v, y]), J = W((m, k) => {
1215
+ var G;
1216
+ const E = ((G = i.getState().dashboardDefinition) == null ? void 0 : G.cards) ?? [];
1217
+ i.getState().recordSketchChange(`card:${m.i}:add`, k), i.getState().updateDashboard({ cards: [...E, m] });
1218
+ }, [i]), Q = W((m, k) => {
1219
+ const E = (m == null ? void 0 : m.category) ?? "Generic", G = (m == null ? void 0 : m.specificType) ?? "Generic", Z = D(E, G);
1220
+ Z.actionDescription = m == null ? void 0 : m.description, k && (Z.h = ct, Z.w = y, Z.y = k.y, Z.x = k.x), J(Z, `Added card '${Z.name}' (category: ${E}, type: ${G})`);
1221
+ }, [D, y, J]), ne = W(() => {
1222
+ if (y === 0) return;
1223
+ const m = D("Generic", "Generic"), k = U();
1224
+ m.x = k.x, m.y = k.y, J(m, `Added card '${m.name}'`);
1225
+ }, [y, D, U, J]), de = W((m, k, E) => {
1226
+ const G = D(m, k), Z = U();
1227
+ G.x = Z.x, G.y = Z.y, G.w = y, G.h = ct, J(G, `Added card '${G.name}' (category: ${m}, type: ${k})`);
1228
+ }, [y, D, U, J]);
1229
+ q(() => {
1230
+ if (u == 0) return;
1231
+ let m = "Desktop";
1232
+ u >= 920 && (m = "Large"), u < 920 && (m = "Desktop"), u < 750 && (m = "Tablet"), u < 600 && (m = "Mobile"), f(m), R(wa[m]);
1233
+ }, [u]);
1234
+ const me = W((m) => {
1235
+ var T;
1236
+ L.current += 1;
1237
+ const k = `Filter${L.current}`;
1238
+ let E = !1;
1239
+ m == "DateRangePicker" && (E = !0);
1240
+ const G = ze(), Z = { i: G, name: k, filterType: m, mandatory: E, multipleSelection: !0 }, te = ((T = i.getState().dashboardDefinition) == null ? void 0 : T.filters) ?? [];
1241
+ i.getState().recordSketchChange(`filter:${G}:add`, `Added filter '${Z.name}' (type: ${m})`), i.getState().updateDashboard({ filters: [...te, Z] });
1242
+ }, [i]), ge = W((m) => {
1243
+ var E;
1244
+ const k = ((E = i.getState().dashboardDefinition) == null ? void 0 : E.filters) ?? [];
1245
+ i.getState().recordSketchChange(
1246
+ `filter:${m.i}:edit`,
1247
+ `Edited filter '${m.name}' - ${m.mandatory ? "Mandatório" : "Opcional"} - ${m.multipleSelection ? "MultipleSelection" : "SingleValue"}`
1248
+ ), i.getState().updateDashboard({ filters: k.map((G) => G.i === m.i ? { ...m } : G) });
1249
+ }, [i]), C = W((m) => {
1250
+ var G;
1251
+ const k = ((G = i.getState().dashboardDefinition) == null ? void 0 : G.filters) ?? [], E = k.find((Z) => Z.i === m);
1252
+ i.getState().recordSketchChange(`filter:${m}:delete`, `Deleted filter '${(E == null ? void 0 : E.name) ?? m}'`), i.getState().updateDashboard({ filters: k.filter((Z) => Z.i !== m) });
1253
+ }, [i]);
1254
+ Qt(n, () => ({ addGenericCell: ne, addTypedCell: de, handleAddFilter: me }), [ne, de, me]);
1255
+ const A = /* @__PURE__ */ a((m) => ({ border: m ? "0px" : `1px solid ${_.palette.divider}`, px: 1, py: 0, gap: 0.5, textTransform: "none" }), "toggleSx"), Y = /* @__PURE__ */ a((m) => ({
1256
+ fontSize: "0.75rem",
1257
+ lineHeight: 1,
1258
+ maxWidth: m ? 60 : 0,
1259
+ overflow: "hidden",
1260
+ opacity: m ? 1 : 0,
1261
+ whiteSpace: "nowrap",
1262
+ transition: "max-width 0.25s ease, opacity 0.2s ease"
1263
+ }), "toggleLabelSx");
1264
+ return /* @__PURE__ */ b(se, { ref: c, className: "bi-dashboard-pad-sketch", sx: { height: "100%", overflow: "hidden" }, children: [
1265
+ !e.hideInternalHeader && /* @__PURE__ */ b(j, { sx: { display: "inline-flex", alignItems: "center", flexWrap: "nowrap", gap: 1, pt: 0.5, pb: 0, pr: 1, pl: 1, borderBottom: `1px solid ${_.palette.divider}` }, children: [
1266
+ /* @__PURE__ */ t(j, { sx: { display: "inline-flex", width: "75%" }, children: /* @__PURE__ */ t(j, { sx: { width: "75%" }, children: /* @__PURE__ */ t(Ge, { placeHolderText: "Untitled Dashboard", onEdit: z, text: r, fontSize: 14.4 }) }) }),
1267
+ /* @__PURE__ */ b(j, { sx: { position: "relative", display: "inline-flex", width: "25%", gap: 1, top: -2, justifyContent: "center", alignItems: "center" }, children: [
1268
+ /* @__PURE__ */ t(ie, { component: "span", sx: { color: "text.secondary" }, children: "Layout:" }),
1269
+ /* @__PURE__ */ b(
1270
+ sn,
1271
+ {
1272
+ value: g,
1273
+ exclusive: !0,
1274
+ onChange: V,
1275
+ size: "small",
1276
+ className: "llm-env-target llm-env-layout-toggle",
1277
+ "data-env-id": "dashboard-pad-layout-toggle",
1278
+ sx: { height: 24, border: "0px", "& .Mui-selected": { border: `1px solid ${_.palette.divider}` } },
1279
+ children: [
1280
+ /* @__PURE__ */ b(Je, { value: "Boxed", "data-env-id": "dashboard-pad-layout-boxed", sx: A(g === "Boxed"), children: [
1281
+ /* @__PURE__ */ t(Ei, { sx: { fontSize: 18 } }),
1282
+ /* @__PURE__ */ t(ie, { component: "span", sx: Y(g === "Boxed"), children: "Boxed" })
1283
+ ] }),
1284
+ /* @__PURE__ */ b(Je, { value: "Naked", "data-env-id": "dashboard-pad-layout-naked", sx: A(g === "Naked"), children: [
1285
+ /* @__PURE__ */ t($i, { sx: { fontSize: 18 } }),
1286
+ /* @__PURE__ */ t(ie, { component: "span", sx: Y(g === "Naked"), children: "Naked" })
1287
+ ] })
1288
+ ]
1289
+ }
1290
+ ),
1291
+ e.headerExtra
1292
+ ] })
1293
+ ] }),
1294
+ o.length > 0 && !e.hideFiltersInSketch && /* @__PURE__ */ t(j, { sx: { display: "inline-flex", justifyContent: "flex-end", flexWrap: "wrap", gap: 1, pt: 0.5, pb: 0, pr: 1, pl: 1, borderBottom: `1px solid ${_.palette.divider}` }, children: o.map((m) => /* @__PURE__ */ t(At, { filter: m, onEdit: ge, onDelete: C }, m.i)) }),
1295
+ /* @__PURE__ */ b("div", { style: { maxHeight: "100%", height: "100%", overflow: "auto" }, children: [
1296
+ u !== 0 && l.length > 0 && /* @__PURE__ */ t("div", { style: { display: "inline-flex", flex: 1, alignItems: "center", justifyContent: "center", paddingBottom: e.hideInternalHeader ? "50px" : "80px", overflow: "auto", width: "100%" }, children: /* @__PURE__ */ t(
1297
+ Ki,
1298
+ {
1299
+ rowAwareResize: { defaultOn: !0 },
1300
+ onLayoutChange: M,
1301
+ onResizeStop: w,
1302
+ onDragStop: w,
1303
+ onDrop: Q,
1304
+ config: {},
1305
+ cols: { lg: 10, md: 8, sm: 4, xs: 4, xxs: 4 },
1306
+ breakpoints: { lg: 920, md: 600, sm: 400, xs: 400, xxs: 0 },
1307
+ rowHeight: 10,
1308
+ dragLocked: !1,
1309
+ zoomLevel: $,
1310
+ responsive: !1,
1311
+ maxRows: 200,
1312
+ rowMultiplier: 1,
1313
+ manualWidth: u,
1314
+ layouts: l,
1315
+ children: l.map((m) => {
1316
+ var k;
1317
+ return /* @__PURE__ */ t(
1318
+ qi,
1319
+ {
1320
+ className: "llm-env-target llm-env-card llm-env-card-sketch-wrapper",
1321
+ "data-env-id": m.i,
1322
+ naked: g == "Naked",
1323
+ "data-env-key": m.i,
1324
+ "data-env-name": m.name ?? "",
1325
+ "data-env-kind": "sketch-card-wrapper",
1326
+ children: /* @__PURE__ */ t(
1327
+ $t,
1328
+ {
1329
+ turnOpen: x ?? !1,
1330
+ todoItem: (k = d[m.i]) == null ? void 0 : k.todo,
1331
+ cellConfig: m,
1332
+ onDataEdit: I,
1333
+ onDelete: F,
1334
+ renderDescription: e.renderDescription
1335
+ }
1336
+ )
1337
+ },
1338
+ m.i
1339
+ );
1340
+ })
1341
+ },
1342
+ h
1343
+ ) }),
1344
+ u !== 0 && l.length == 0 && /* @__PURE__ */ t(
1345
+ j,
1346
+ {
1347
+ sx: /* @__PURE__ */ a((m) => ({
1348
+ background: "transparent",
1349
+ border: "none",
1350
+ textAlign: "left",
1351
+ padding: "6px 0",
1352
+ height: "100%",
1353
+ color: m.palette.text.secondary,
1354
+ fontFamily: m.typography.fontFamily,
1355
+ display: "inline-flex",
1356
+ width: "100%",
1357
+ justifyContent: "center",
1358
+ alignItems: "center",
1359
+ "&:hover": { color: m.palette.text.primary }
1360
+ }), "sx"),
1361
+ children: /* @__PURE__ */ b(se, { direction: "row", gap: 1, sx: { "&:hover": { cursor: "pointer" } }, onClick: /* @__PURE__ */ a(() => {
1362
+ var m;
1363
+ return (m = e.onAddCard) == null ? void 0 : m.call(e);
1364
+ }, "onClick"), children: [
1365
+ /* @__PURE__ */ t(j, { component: "span", sx: /* @__PURE__ */ a((m) => ({ color: m.palette.text.disabled }), "sx"), children: "↗" }),
1366
+ /* @__PURE__ */ t(ie, { sx: /* @__PURE__ */ a((m) => ({ fontSize: 20, fontWeight: 600, color: m.palette.text.primary, margin: 0, lineHeight: 1.2, letterSpacing: -0.4 }), "sx"), children: "Clique aqui para adicionar um novo card" })
1367
+ ] })
1368
+ }
1369
+ )
1370
+ ] })
1371
+ ] });
1372
+ });
1373
+ ot.displayName = "DashboardPadSketch";
1374
+ const Ia = [], za = [], De = /* @__PURE__ */ a((e) => {
1375
+ const n = le(), i = e.maxWidth ?? 30;
1376
+ return /* @__PURE__ */ t(
1377
+ j,
1378
+ {
1379
+ sx: {
1380
+ "& .action-btn": {
1381
+ display: "inline-flex",
1382
+ alignItems: "center",
1383
+ height: 28,
1384
+ borderRadius: 1,
1385
+ px: 0.75,
1386
+ cursor: "pointer",
1387
+ overflow: "hidden",
1388
+ transition: "background-color 0.2s",
1389
+ "&:hover": { borderRadius: 1, px: 1.5, backgroundColor: n.palette.action.hover },
1390
+ "&:hover .action-label": { maxWidth: i, opacity: 1, ml: 0.5 }
1391
+ },
1392
+ "& .action-btn-fixed": {
1393
+ display: "inline-flex",
1394
+ alignItems: "center",
1395
+ height: 28,
1396
+ borderRadius: 1,
1397
+ px: 0.75,
1398
+ cursor: "pointer",
1399
+ "&:hover": { bgcolor: n.palette.success.light }
1400
+ },
1401
+ "& .action-label": {
1402
+ maxWidth: 0,
1403
+ overflow: "hidden",
1404
+ whiteSpace: "nowrap",
1405
+ opacity: 0,
1406
+ ml: 0,
1407
+ transition: "max-width 0.3s ease, opacity 0.15s ease 0.1s, margin 0.3s ease",
1408
+ fontSize: "0.7rem",
1409
+ lineHeight: 1
1410
+ },
1411
+ "& .action-label-fixed": {
1412
+ overflow: "hidden",
1413
+ whiteSpace: "nowrap",
1414
+ ml: 0,
1415
+ fontSize: "0.7rem",
1416
+ lineHeight: 1,
1417
+ marginRight: 1
1418
+ }
1419
+ },
1420
+ children: /* @__PURE__ */ b(j, { className: e.fixed ? "action-btn-fixed" : "action-btn", onClick: /* @__PURE__ */ a((l) => {
1421
+ var o;
1422
+ return (o = e.onClick) == null ? void 0 : o.call(e, l);
1423
+ }, "onClick"), sx: { color: "text.secondary" }, children: [
1424
+ typeof e.icon == "function" ? e.icon() : e.icon,
1425
+ /* @__PURE__ */ t(ie, { className: e.fixed ? "action-label-fixed" : "action-label", component: "span", children: e.label })
1426
+ ] })
1427
+ }
1428
+ );
1429
+ }, "HoverButton"), Oa = it(we);
1430
+ function Pa(e, n, i) {
1431
+ const l = document.createElement("div");
1432
+ return l.style.cssText = [
1433
+ "display:flex",
1434
+ "align-items:center",
1435
+ "gap:6px",
1436
+ "padding:6px 12px",
1437
+ `border:2px dashed ${e.palette.secondary.main}`,
1438
+ "border-radius:6px",
1439
+ `background-color:${e.palette.background.paper}`,
1440
+ `color:${e.palette.secondary.main}`,
1441
+ `font-family:${e.typography.fontFamily ?? "inherit"}`,
1442
+ "font-size:13px",
1443
+ "font-weight:500",
1444
+ "white-space:nowrap",
1445
+ "position:fixed",
1446
+ "top:-200px",
1447
+ "left:-200px",
1448
+ "z-index:99999",
1449
+ "pointer-events:none"
1450
+ ].join(";"), l.innerHTML = `${n}<span>${i}</span>`, document.body.appendChild(l), l;
1451
+ }
1452
+ a(Pa, "createDragPreview");
1453
+ const Mn = /* @__PURE__ */ a(({ onAddGeneric: e, onAddTyped: n, onAddFilter: i }) => {
1454
+ const l = le(), o = Me(), [r, g] = N(!1), [h, x] = N(!1), d = ee(null), v = ee(null), s = ee(null);
1455
+ q(() => () => {
1456
+ var f;
1457
+ return (f = s.current) == null ? void 0 : f.remove();
1458
+ }, []);
1459
+ const c = W(() => {
1460
+ var f;
1461
+ (f = s.current) == null || f.remove(), s.current = null;
1462
+ }, []), u = /* @__PURE__ */ a((f, y) => {
1463
+ const R = y ? { category: y.category, specificType: y.specificType, label: y.label } : { category: "Generic", specificType: "Generic", label: "Generic" };
1464
+ f.dataTransfer.setData("text/json", JSON.stringify(R)), f.dataTransfer.effectAllowed = "copy", c();
1465
+ const H = f.currentTarget.querySelector("svg"), L = H ? H.outerHTML.replace(/width="[^"]*"/, 'width="18"').replace(/height="[^"]*"/, 'height="18"') : "", P = Pa(l, L, (y == null ? void 0 : y.label) ?? "Generic");
1466
+ s.current = P, f.dataTransfer.setDragImage(P, 0, 0);
1467
+ }, "handleDragStart"), p = /* @__PURE__ */ a((f) => {
1468
+ n(f.category, f.specificType, f.label), g(!1);
1469
+ }, "handleMenuItemClick");
1470
+ return /* @__PURE__ */ b(j, { sx: { display: "inline-flex", gap: 0.5, alignItems: "center" }, children: [
1471
+ /* @__PURE__ */ t(Ie, { title: "Drag to add card", children: /* @__PURE__ */ t(
1472
+ j,
1473
+ {
1474
+ className: "action-btn llm-env-target llm-env-dashboard-action",
1475
+ "data-env-id": "dashboardpad-drag-to-add-card",
1476
+ draggable: !0,
1477
+ onDragStart: /* @__PURE__ */ a((f) => u(f), "onDragStart"),
1478
+ onDragEnd: c,
1479
+ sx: {
1480
+ display: "flex",
1481
+ alignItems: "center",
1482
+ justifyContent: "center",
1483
+ width: 28,
1484
+ height: 28,
1485
+ border: "1.5px dashed",
1486
+ borderColor: "secondary.main",
1487
+ borderRadius: 0.5,
1488
+ cursor: "grab",
1489
+ "&:hover": { bgcolor: "action.hover" },
1490
+ "&:active": { cursor: "grabbing" }
1491
+ },
1492
+ children: /* @__PURE__ */ t(Ai, { sx: { fontSize: 16 }, color: "secondary" })
1493
+ }
1494
+ ) }),
1495
+ /* @__PURE__ */ b(j, { sx: { position: "relative", display: "inline-flex", alignItems: "center" }, children: [
1496
+ /* @__PURE__ */ t(Ie, { title: "Add card", children: /* @__PURE__ */ t(
1497
+ Ft,
1498
+ {
1499
+ className: "action-btn llm-env-target llm-env-dashboard-action",
1500
+ "data-env-id": "dashboardpad-add-card",
1501
+ variant: "outlined",
1502
+ size: "small",
1503
+ color: "secondary",
1504
+ startIcon: /* @__PURE__ */ t(Mi, { sx: { m: 0.2, p: 0 } }),
1505
+ onClick: e,
1506
+ sx: { height: 28, fontSize: "0.7rem", pr: 1, gap: 0, minWidth: "80px", textTransform: "none", justifyContent: "left" },
1507
+ children: "Card"
1508
+ }
1509
+ ) }),
1510
+ /* @__PURE__ */ t(
1511
+ Pe,
1512
+ {
1513
+ className: "action-btn llm-env-target llm-env-dashboard-action",
1514
+ "data-env-id": "dashboardpad-add-card-dropdown",
1515
+ ref: d,
1516
+ size: "small",
1517
+ onClick: /* @__PURE__ */ a(() => g((f) => !f), "onClick"),
1518
+ sx: { position: "absolute", right: 0, height: 28, width: 20 },
1519
+ "aria-label": "Tipos de card",
1520
+ children: /* @__PURE__ */ t(mt, { color: "secondary", sx: { fontSize: 18, mr: 0.5 } })
1521
+ }
1522
+ )
1523
+ ] }),
1524
+ /* @__PURE__ */ t(Ve, { open: r, anchorEl: d.current, placement: "bottom-start", transition: !0, sx: { zIndex: 1300 }, children: /* @__PURE__ */ a(({ TransitionProps: f }) => /* @__PURE__ */ t(je, { ...f, children: /* @__PURE__ */ t(Fe, { elevation: 8, sx: { maxHeight: 420, overflow: "auto", minWidth: 260 }, children: /* @__PURE__ */ t(Ue, { onClickAway: /* @__PURE__ */ a(() => g(!1), "onClickAway"), children: /* @__PURE__ */ t(gt, { dense: !0, children: Object.entries(Oa).map(([y, R], H) => {
1525
+ const L = o.category[y];
1526
+ return /* @__PURE__ */ b(j, { children: [
1527
+ H > 0 && /* @__PURE__ */ t(Ke, {}),
1528
+ /* @__PURE__ */ b(j, { component: "span", sx: { px: 2, pt: 1, display: "flex", alignItems: "center", gap: 0.5, typography: "overline" }, children: [
1529
+ /* @__PURE__ */ t(L, { fontSize: "inherit" }),
1530
+ y
1531
+ ] }),
1532
+ R.map((P) => {
1533
+ const _ = o.specificType[P.specificType];
1534
+ return /* @__PURE__ */ b(Ee, { onClick: /* @__PURE__ */ a(() => p(P), "onClick"), draggable: !0, onDragStart: /* @__PURE__ */ a(($) => u($, P), "onDragStart"), onDragEnd: c, children: [
1535
+ /* @__PURE__ */ t(qe, { children: /* @__PURE__ */ t(_, { fontSize: "small" }) }),
1536
+ /* @__PURE__ */ t(Ye, { children: P.label })
1537
+ ] }, P.specificType);
1538
+ })
1539
+ ] }, y);
1540
+ }) }) }) }) }), "children") }),
1541
+ i && /* @__PURE__ */ b(Te, { children: [
1542
+ /* @__PURE__ */ t(Ie, { title: "Add filter", children: /* @__PURE__ */ t(
1543
+ Ft,
1544
+ {
1545
+ className: "action-btn llm-env-target llm-env-dashboard-action",
1546
+ "data-env-id": "dashboardpad-add-filter",
1547
+ ref: v,
1548
+ variant: "outlined",
1549
+ size: "small",
1550
+ color: "secondary",
1551
+ startIcon: /* @__PURE__ */ t(Ri, {}),
1552
+ endIcon: /* @__PURE__ */ t(mt, {}),
1553
+ onClick: /* @__PURE__ */ a(() => x((f) => !f), "onClick"),
1554
+ sx: { height: 28, fontSize: "0.7rem", minWidth: 0, textTransform: "none" },
1555
+ children: "Filtro"
1556
+ }
1557
+ ) }),
1558
+ /* @__PURE__ */ t(Ve, { open: h, anchorEl: v.current, placement: "bottom-start", transition: !0, sx: { zIndex: 1300 }, children: /* @__PURE__ */ a(({ TransitionProps: f }) => /* @__PURE__ */ t(je, { ...f, children: /* @__PURE__ */ t(Fe, { elevation: 8, sx: { minWidth: 220 }, children: /* @__PURE__ */ t(Ue, { onClickAway: /* @__PURE__ */ a(() => x(!1), "onClickAway"), children: /* @__PURE__ */ t(gt, { dense: !0, children: It.map((y) => {
1559
+ const R = o.filterType[y.filterType];
1560
+ return /* @__PURE__ */ b(
1561
+ Ee,
1562
+ {
1563
+ onClick: /* @__PURE__ */ a(() => {
1564
+ i(y.filterType), x(!1);
1565
+ }, "onClick"),
1566
+ children: [
1567
+ /* @__PURE__ */ t(qe, { children: /* @__PURE__ */ t(R, { fontSize: "small" }) }),
1568
+ /* @__PURE__ */ t(Ye, { children: y.label })
1569
+ ]
1570
+ },
1571
+ y.filterType
1572
+ );
1573
+ }) }) }) }) }), "children") })
1574
+ ] })
1575
+ ] });
1576
+ }, "ToolBox"), Rn = /* @__PURE__ */ a((e) => {
1577
+ const n = et(), i = he(), l = B((C) => C.dashboardDefinition), o = B((C) => C.publishedDashboard), r = B((C) => C.viewType), g = B((C) => C.renderGeneration), h = B((C) => C.llmCounter), x = (l == null ? void 0 : l.id) ?? null, [d, v] = N(null), [s, c] = N(), [u, p] = N(!1), [f, y] = N(!1), [R, H] = N(null), [L, P] = N(!1), _ = ee(null), $ = ee(null), V = ee(null), K = ee(null), M = le(), w = ve(() => `pad-${Math.random().toString(36).slice(2)}`, []);
1578
+ q(() => {
1579
+ var A;
1580
+ if (e.turnOpen) return;
1581
+ const C = i.getState().dashboardDefinition;
1582
+ (A = C == null ? void 0 : C.cards) != null && A.some((Y) => Y.todoItem) && i.getState().updateDashboard({ cards: C.cards.map((Y) => ({ ...Y, todoItem: void 0 })) });
1583
+ }, [e.turnOpen, i]);
1584
+ const F = W(() => {
1585
+ const C = i.getState().dashboardDefinition;
1586
+ if (!C || !e.onCompose) return;
1587
+ const A = bt(C);
1588
+ if (A) {
1589
+ c(A), setTimeout(() => c(void 0), 2e3);
1590
+ return;
1591
+ }
1592
+ e.onCompose(C);
1593
+ }, [e.onCompose, i]), D = W((C) => {
1594
+ var A;
1595
+ K.current = C.id ?? null, bt(C), i.getState().updateDashboard(C), (A = e.onChange) == null || A.call(e, C);
1596
+ }, [e.onChange, i]), z = W(async () => {
1597
+ var A;
1598
+ const C = i.getState().dashboardDefinition;
1599
+ if (!(!(C != null && C.id) || !n)) {
1600
+ p(!0);
1601
+ try {
1602
+ await at(n, C), (A = e.onChange) == null || A.call(e, C);
1603
+ } catch (Y) {
1604
+ console.error("[@aintela/bi composer] Error saving dashboard:", Y);
1605
+ } finally {
1606
+ p(!1);
1607
+ }
1608
+ }
1609
+ }, [n, e.onChange, i]);
1610
+ q(() => {
1611
+ if (!n || !e.dashboardId || V.current || K.current === e.dashboardId) return;
1612
+ v(null), i.getState().updateDashboard(void 0);
1613
+ const C = n.getDashboard(e.dashboardId);
1614
+ V.current = C, C.then((A) => D(Be(A))).catch((A) => v(String(A))).finally(() => {
1615
+ V.current = null;
1616
+ });
1617
+ }, [D, n, e.dashboardId, i]);
1618
+ const I = W(async () => {
1619
+ if (n)
1620
+ try {
1621
+ D(await Pt(n, e.sessionId));
1622
+ } catch (C) {
1623
+ console.error("[@aintela/bi composer] Error creating new dashboard:", C);
1624
+ }
1625
+ }, [D, n, e.sessionId]), U = W(() => {
1626
+ i.getState().refreshDashboard();
1627
+ }, [i]), J = W(async () => {
1628
+ const C = !f;
1629
+ if (y(C), C && n) {
1630
+ P(!0);
1631
+ try {
1632
+ H(await n.getDashboardHierarchy());
1633
+ } catch (A) {
1634
+ console.error("[@aintela/bi composer] Error fetching hierarchy:", A);
1635
+ } finally {
1636
+ P(!1);
1637
+ }
1638
+ }
1639
+ }, [n, f]), Q = W(async (C) => {
1640
+ if (!(!C.id || !n)) {
1641
+ y(!1);
1642
+ try {
1643
+ D(Be(await n.getDashboard(C.id)));
1644
+ } catch (A) {
1645
+ console.error("[@aintela/bi composer] Error loading dashboard:", A);
1646
+ }
1647
+ }
1648
+ }, [D, n]), ne = e.renderDashboardPicker, de = /* @__PURE__ */ a((C, A) => He.cloneElement(A, { className: "llm-env-target llm-env-dashboard-action", "data-env-id": C, sx: { fontSize: 18 } }), "envIcon"), me = /* @__PURE__ */ a((C) => ({ border: C ? "0px" : `1px solid ${M.palette.divider}`, px: 1, py: 0, gap: 0.5, textTransform: "none" }), "viewToggleSx"), ge = /* @__PURE__ */ a((C, A) => ({ fontSize: "0.7rem", lineHeight: 1, maxWidth: C ? A : 0, overflow: "hidden", opacity: C ? 1 : 0, whiteSpace: "nowrap", transition: "max-width 0.25s ease, opacity 0.2s ease" }), "viewLabelSx");
1649
+ return /* @__PURE__ */ b(se, { className: "bi-dashboard-pad", sx: { height: "100%", minHeight: 0 }, children: [
1650
+ /* @__PURE__ */ t(j, { sx: { display: "flex", py: 0.5, backgroundColor: M.palette.background.paper, borderBottom: `1px solid ${M.palette.divider}`, px: 1 }, children: /* @__PURE__ */ b(se, { direction: "row", gap: 0.5, sx: { alignItems: "center", width: "100%", px: 1 }, children: [
1651
+ !l && !d && /* @__PURE__ */ b(se, { direction: "row", gap: 1, alignItems: "center", children: [
1652
+ /* @__PURE__ */ t(ft, { size: 16 }),
1653
+ /* @__PURE__ */ t(ie, { color: "text.secondary", children: "Carregando dashboard" })
1654
+ ] }),
1655
+ d && /* @__PURE__ */ b(ie, { color: "error", children: [
1656
+ "Error creating dashboard: ",
1657
+ d
1658
+ ] }),
1659
+ l && /* @__PURE__ */ b(Te, { children: [
1660
+ e.onBack && /* @__PURE__ */ t(De, { onClick: e.onBack, icon: de("dashboard-pad-back", /* @__PURE__ */ t(Ni, {})), label: "Voltar" }),
1661
+ /* @__PURE__ */ b(
1662
+ sn,
1663
+ {
1664
+ value: r,
1665
+ exclusive: !0,
1666
+ onChange: /* @__PURE__ */ a((C, A) => A && i.getState().setViewType(A), "onChange"),
1667
+ size: "small",
1668
+ className: "llm-env-target llm-env-view-toggle",
1669
+ "data-env-id": "dashboard-pad-view-toggle",
1670
+ sx: { height: 24, border: "0px", "& .Mui-selected": { border: `1px solid ${M.palette.divider}` } },
1671
+ children: [
1672
+ /* @__PURE__ */ b(Je, { value: "Sketch", className: "llm-env-target llm-env-action-sketch", "data-env-id": "dashboard-pad-view-sketch", sx: me(r == "Sketch"), children: [
1673
+ /* @__PURE__ */ t(Tt, { sx: { fontSize: 18 } }),
1674
+ /* @__PURE__ */ t(ie, { component: "span", sx: ge(r === "Sketch", 50), children: "Sketch" })
1675
+ ] }),
1676
+ /* @__PURE__ */ b(Je, { value: "Generated", className: "llm-env-target llm-env-action-generated", "data-env-id": "dashboard-pad-view-generated", sx: me(r == "Generated"), children: [
1677
+ /* @__PURE__ */ t(_i, { sx: { fontSize: 18 } }),
1678
+ /* @__PURE__ */ t(ie, { component: "span", sx: ge(r === "Generated", 70), children: "Dashboard" })
1679
+ ] })
1680
+ ]
1681
+ }
1682
+ ),
1683
+ /* @__PURE__ */ t(Ke, { orientation: "vertical", flexItem: !0, sx: { mx: 1 } }),
1684
+ /* @__PURE__ */ t(j, { sx: { flex: 1, display: "flex", justifyContent: "center", alignItems: "center" }, children: /* @__PURE__ */ t(
1685
+ Mn,
1686
+ {
1687
+ onAddGeneric: /* @__PURE__ */ a(() => {
1688
+ var C;
1689
+ return (C = $.current) == null ? void 0 : C.addGenericCell();
1690
+ }, "onAddGeneric"),
1691
+ onAddTyped: /* @__PURE__ */ a((C, A, Y) => {
1692
+ var m;
1693
+ return (m = $.current) == null ? void 0 : m.addTypedCell(C, A, Y);
1694
+ }, "onAddTyped"),
1695
+ onAddFilter: /* @__PURE__ */ a((C) => {
1696
+ var A;
1697
+ return (A = $.current) == null ? void 0 : A.handleAddFilter(C);
1698
+ }, "onAddFilter")
1699
+ }
1700
+ ) }),
1701
+ /* @__PURE__ */ t(Ke, { orientation: "vertical", flexItem: !0, sx: { mx: 1 } }),
1702
+ /* @__PURE__ */ b(se, { direction: "row", gap: 0.25, alignItems: "center", children: [
1703
+ n && /* @__PURE__ */ t(De, { onClick: I, icon: de("dashboard-pad-new", /* @__PURE__ */ t(Bi, {})), label: "Novo" }),
1704
+ n && /* @__PURE__ */ t(
1705
+ De,
1706
+ {
1707
+ onClick: u ? void 0 : z,
1708
+ icon: /* @__PURE__ */ a(() => u ? /* @__PURE__ */ t(ft, { size: 14 }) : de("dashboard-pad-save", /* @__PURE__ */ t(Hi, {})), "icon"),
1709
+ label: "Salvar"
1710
+ }
1711
+ ),
1712
+ /* @__PURE__ */ t(De, { onClick: U, icon: de("dashboard-pad-refresh", /* @__PURE__ */ t(ln, {})), label: "Atualizar" }),
1713
+ n && ne && /* @__PURE__ */ t("div", { ref: _, children: /* @__PURE__ */ t(
1714
+ De,
1715
+ {
1716
+ onClick: J,
1717
+ icon: /* @__PURE__ */ b(se, { direction: "row", alignItems: "center", "data-env-id": "dashboard-pad-load", className: "llm-env-target llm-env-dashboard-action", children: [
1718
+ /* @__PURE__ */ t(Fi, { sx: { fontSize: 18 } }),
1719
+ /* @__PURE__ */ t(mt, { sx: { fontSize: 14, ml: -0.25 } })
1720
+ ] }),
1721
+ label: "Abrir"
1722
+ }
1723
+ ) }),
1724
+ /* @__PURE__ */ t(Ie, { open: !!s, title: s ?? "", placement: "bottom", slotProps: { tooltip: { sx: { backgroundColor: "error.dark" } } }, children: /* @__PURE__ */ b(
1725
+ j,
1726
+ {
1727
+ className: "action-btn-fixed",
1728
+ onClick: F,
1729
+ sx: {
1730
+ display: "inline-flex",
1731
+ alignItems: "center",
1732
+ height: 28,
1733
+ borderRadius: 1,
1734
+ px: 0.75,
1735
+ cursor: "pointer",
1736
+ color: M.palette.success.contrastText,
1737
+ backgroundColor: M.palette.success.main,
1738
+ "&:hover": { bgcolor: M.palette.success.light }
1739
+ },
1740
+ children: [
1741
+ /* @__PURE__ */ t(ie, { component: "span", sx: { whiteSpace: "nowrap", fontSize: "0.7rem", lineHeight: 1, mr: 1 }, children: "Compose" }),
1742
+ de("dashboard-pad-compose", /* @__PURE__ */ t(Li, {}))
1743
+ ]
1744
+ }
1745
+ ) })
1746
+ ] })
1747
+ ] })
1748
+ ] }) }),
1749
+ ne && /* @__PURE__ */ t(Ve, { open: f, anchorEl: _.current, placement: "bottom-end", transition: !0, sx: { zIndex: 1300 }, children: /* @__PURE__ */ a(({ TransitionProps: C }) => /* @__PURE__ */ t(je, { ...C, children: /* @__PURE__ */ t(Fe, { elevation: 8, sx: { overflow: "hidden", minWidth: 320, maxWidth: 380 }, children: /* @__PURE__ */ t(Ue, { onClickAway: /* @__PURE__ */ a(() => y(!1), "onClickAway"), children: /* @__PURE__ */ t(j, { sx: { width: 360, maxWidth: "100%", height: 420 }, children: ne({ hierarchy: R, loading: L, selectedDashboardId: x, onSelect: /* @__PURE__ */ a((A) => void Q(A), "onSelect") }) }) }) }) }), "children") }),
1750
+ r == "Sketch" && /* @__PURE__ */ b(se, { sx: { flex: 1, minHeight: 0 }, children: [
1751
+ e.showDebug && /* @__PURE__ */ t(Fe, { variant: "outlined", sx: { maxHeight: 200, p: 1, overflow: "auto", "& pre": { bgcolor: "background.default", p: 1, borderRadius: 1, overflow: "auto", fontSize: 11, m: 0 } }, children: /* @__PURE__ */ t("pre", { children: JSON.stringify(l, void 0, 2) }) }),
1752
+ /* @__PURE__ */ t("div", { style: { minHeight: "300px", flex: 1 }, children: /* @__PURE__ */ t(ot, { ref: $, renderId: w, headerExtra: e.headerExtra, renderDescription: e.renderDescription }) })
1753
+ ] }),
1754
+ r == "Generated" && (o == null ? void 0 : o.id) && /* @__PURE__ */ t(j, { sx: { flex: 1, minHeight: 0, overflow: "auto" }, children: /* @__PURE__ */ t(_e, { dashboard: o, codeGeneration: g, llmRenderCount: h, dragLocked: !1, editable: !0, onLayoutCommit: /* @__PURE__ */ a(() => i.getState().commitDashboardLayout(), "onLayoutCommit") }, o.id) })
1755
+ ] });
1756
+ }, "DashboardPad");
1757
+ Rn.displayName = "DashboardPad";
1758
+ const pt = 40, Ea = 100, $a = 150, _n = wt((e, n) => {
1759
+ const i = e.defaultContentType ?? "default", l = ee(0), o = W(() => (l.current += 1, `Untitled-${l.current}`), []), [r, g] = N(() => e.tabs ?? [{ name: o(), contentType: i, id: ze() }]), [h, x] = N(() => r[0].name), [d, v] = N(null), [s, c] = N(""), [u, p] = N(null), f = ee(null), y = r.find((w) => w.name === h) ?? r[0] ?? null, R = W((w, F) => {
1760
+ let D = w, z = 1;
1761
+ for (; r.some((I) => I.name === D && I.name !== F); )
1762
+ z += 1, D = `${w} (${z})`;
1763
+ return D;
1764
+ }, [r]), H = W((w) => {
1765
+ r.some((F) => F.name === w) && x(w);
1766
+ }, [r]), L = W((w, F) => {
1767
+ var I;
1768
+ const D = R(F ?? o()), z = { id: ze(), name: D, contentType: w ?? i };
1769
+ return g((U) => [...U, z]), x(D), (I = e.onTabCreate) == null || I.call(e, z), D;
1770
+ }, [i, R, e.onTabCreate, o]), P = W((w) => {
1771
+ g((F) => {
1772
+ var U, J;
1773
+ const D = F.findIndex((Q) => Q.name === w);
1774
+ if (D === -1) return F;
1775
+ const z = F[D], I = F.filter((Q) => Q.name !== w);
1776
+ if (I.length === 0) {
1777
+ const Q = { name: o(), contentType: i, id: ze() };
1778
+ return x(Q.name), (U = e.onTabClose) == null || U.call(e, z), [Q];
1779
+ }
1780
+ return h === w && x(I[Math.min(D, I.length - 1)].name), (J = e.onTabClose) == null || J.call(e, z), I;
1781
+ });
1782
+ }, [h, i, e.onTabClose, o]);
1783
+ Qt(n, () => ({ focusTab: H, createTab: L, closeTab: P, getActiveTab: /* @__PURE__ */ a(() => y, "getActiveTab"), getTabs: /* @__PURE__ */ a(() => r, "getTabs") }), [H, L, P, y, r]), q(() => {
1784
+ var w;
1785
+ y && ((w = e.onTabChange) == null || w.call(e, y));
1786
+ }, [h]);
1787
+ const _ = /* @__PURE__ */ a((w) => {
1788
+ v(w.name), c(w.name);
1789
+ }, "startRename"), $ = /* @__PURE__ */ a(() => {
1790
+ var F;
1791
+ if (!d) return;
1792
+ const w = s.trim();
1793
+ if (w && w !== d) {
1794
+ const D = R(w, d), z = d;
1795
+ g((U) => U.map((J) => J.name === d ? { ...J, name: D } : J)), h === d && x(D);
1796
+ const I = r.find((U) => U.name === d);
1797
+ I && ((F = e.onTabRename) == null || F.call(e, { ...I, name: D }, z));
1798
+ }
1799
+ v(null);
1800
+ }, "commitRename"), V = /* @__PURE__ */ a((w) => {
1801
+ w.key === "Enter" ? $() : w.key === "Escape" && v(null);
1802
+ }, "handleRenameKeyDown");
1803
+ q(() => {
1804
+ d && f.current && (f.current.focus(), f.current.select());
1805
+ }, [d]);
1806
+ const K = /* @__PURE__ */ a((w) => {
1807
+ var F;
1808
+ (F = e.addMenuItems) != null && F.length ? p(w.currentTarget) : L();
1809
+ }, "handleAddMenuOpen"), M = /* @__PURE__ */ t(Vi, { sx: { fontSize: 15, color: "text.secondary", flexShrink: 0 } });
1810
+ return /* @__PURE__ */ b(j, { sx: { display: "flex", flexDirection: "column", height: "100%", overflow: "hidden" }, children: [
1811
+ /* @__PURE__ */ b(j, { sx: { display: "flex", alignItems: "center", borderBottom: "1px solid", borderColor: "divider", backgroundColor: "background.paper", minHeight: pt, maxHeight: pt, overflow: "hidden" }, children: [
1812
+ /* @__PURE__ */ t(j, { sx: { display: "flex", alignItems: "center", flex: 1, overflow: "auto", backgroundColor: "background.default", "&::-webkit-scrollbar": { height: 0 } }, children: r.map((w) => {
1813
+ var z;
1814
+ const F = w.name === h, D = w.name === d;
1815
+ return /* @__PURE__ */ b(
1816
+ j,
1817
+ {
1818
+ onClick: /* @__PURE__ */ a(() => {
1819
+ D || x(w.name);
1820
+ }, "onClick"),
1821
+ onDoubleClick: /* @__PURE__ */ a(() => _(w), "onDoubleClick"),
1822
+ sx: /* @__PURE__ */ a((I) => ({
1823
+ display: "flex",
1824
+ alignItems: "center",
1825
+ gap: 0.5,
1826
+ minWidth: Ea,
1827
+ maxWidth: $a,
1828
+ height: pt,
1829
+ px: 1.5,
1830
+ cursor: "pointer",
1831
+ userSelect: "none",
1832
+ borderBottom: "2px solid",
1833
+ borderColor: F ? "primary.main" : "transparent",
1834
+ backgroundColor: F ? I.palette.action.selected : I.palette.background.paper,
1835
+ "&:hover": { backgroundColor: F ? I.palette.action.selected : I.palette.action.hover },
1836
+ transition: "background-color 0.15s, border-color 0.15s"
1837
+ }), "sx"),
1838
+ children: [
1839
+ ((z = e.renderTabIcon) == null ? void 0 : z.call(e, w)) ?? M,
1840
+ D ? /* @__PURE__ */ t(
1841
+ Ne,
1842
+ {
1843
+ inputRef: f,
1844
+ value: s,
1845
+ onChange: /* @__PURE__ */ a((I) => c(I.target.value), "onChange"),
1846
+ onBlur: $,
1847
+ onKeyDown: V,
1848
+ variant: "standard",
1849
+ size: "small",
1850
+ slotProps: {
1851
+ input: { disableUnderline: !0, style: { fontSize: "0.75rem", fontWeight: 500, padding: "0px", height: 20, border: "0px" } },
1852
+ root: { style: { padding: "2px 0px 0px 0px", border: "0px" } }
1853
+ },
1854
+ sx: { minWidth: "30px", maxWidth: "80%" },
1855
+ onClick: /* @__PURE__ */ a((I) => I.stopPropagation(), "onClick")
1856
+ }
1857
+ ) : /* @__PURE__ */ t(ie, { variant: "caption", noWrap: !0, sx: { minWidth: "60px", fontWeight: F ? 600 : 400, color: F ? "text.primary" : "text.secondary", fontSize: "0.75rem" }, children: w.name }),
1858
+ /* @__PURE__ */ t(
1859
+ Pe,
1860
+ {
1861
+ size: "small",
1862
+ onClick: /* @__PURE__ */ a((I) => {
1863
+ I.stopPropagation(), P(w.name);
1864
+ }, "onClick"),
1865
+ sx: { p: 0.2, opacity: F ? 0.7 : 0, "&:hover": { opacity: 1 }, transition: "opacity 0.15s" },
1866
+ "aria-label": "Fechar aba",
1867
+ children: /* @__PURE__ */ t(Gi, { sx: { fontSize: 14 } })
1868
+ }
1869
+ )
1870
+ ]
1871
+ },
1872
+ w.name
1873
+ );
1874
+ }) }),
1875
+ /* @__PURE__ */ t(Pe, { size: "small", onClick: K, sx: { mx: 0.5, flexShrink: 0 }, title: "Adicionar aba", children: /* @__PURE__ */ t(Wi, { sx: { fontSize: 18 } }) }),
1876
+ e.addMenuItems && /* @__PURE__ */ t(Ui, { anchorEl: u, open: !!u, onClose: /* @__PURE__ */ a(() => p(null), "onClose"), anchorOrigin: { vertical: "bottom", horizontal: "left" }, transformOrigin: { vertical: "top", horizontal: "left" }, children: e.addMenuItems.map((w, F) => [
1877
+ w.dividerBefore && /* @__PURE__ */ t(j, { component: "li", sx: { borderTop: "1px solid", borderColor: "divider" } }, `div-${F}`),
1878
+ /* @__PURE__ */ b(
1879
+ Ee,
1880
+ {
1881
+ onClick: /* @__PURE__ */ a(() => {
1882
+ L(w.contentType), p(null);
1883
+ }, "onClick"),
1884
+ disabled: w.disabled,
1885
+ children: [
1886
+ w.icon && /* @__PURE__ */ t(qe, { children: w.icon }),
1887
+ /* @__PURE__ */ t(Ye, { children: w.label })
1888
+ ]
1889
+ },
1890
+ w.label
1891
+ )
1892
+ ]) })
1893
+ ] }),
1894
+ r.map((w) => /* @__PURE__ */ t(j, { sx: { flex: 1, overflow: "auto", pr: 0, display: w.name === h ? "flex" : "none", flexDirection: "column" }, children: e.renderContent(w) }, w.id))
1895
+ ] });
1896
+ });
1897
+ _n.displayName = "DashboardPadEditor";
1898
+ const Aa = /* @__PURE__ */ a(({
1899
+ orientation: e = "row",
1900
+ datasets: n,
1901
+ defaultTemplateDataset: i = "BI_TemplateModel",
1902
+ agents: l,
1903
+ agentId: o,
1904
+ recommendedAgentId: r,
1905
+ onAgentChange: g
1906
+ }) => {
1907
+ const h = le(), x = he(), d = B((p) => {
1908
+ var f;
1909
+ return ((f = p.dashboardDefinition) == null ? void 0 : f.isDatasetParameterized) ?? !1;
1910
+ }), v = B((p) => {
1911
+ var f;
1912
+ return (f = p.dashboardDefinition) == null ? void 0 : f.defaultDatasetName;
1913
+ }), s = /* @__PURE__ */ a((p, f) => {
1914
+ x.getState().updateDashboard({
1915
+ isDatasetParameterized: f,
1916
+ defaultDatasetName: f ? v ?? i : void 0
1917
+ });
1918
+ }, "handleToggle"), c = o ?? (r == null ? void 0 : r(d)) ?? "", u = e === "column";
1919
+ return /* @__PURE__ */ b(
1920
+ se,
1921
+ {
1922
+ direction: u ? "column" : "row",
1923
+ alignItems: u ? "stretch" : "center",
1924
+ gap: u ? 0.75 : 1,
1925
+ sx: u ? {} : { px: 1, py: 0.25, borderLeft: `1px solid ${h.palette.divider}` },
1926
+ children: [
1927
+ /* @__PURE__ */ b(se, { direction: "row", alignItems: "center", gap: 0.5, children: [
1928
+ /* @__PURE__ */ t(xt, { size: "small", checked: d, onChange: s, "data-env-id": "dashboard-pad-dataset-parameterized" }),
1929
+ /* @__PURE__ */ t(ie, { variant: "body2", sx: { color: "text.secondary", whiteSpace: "nowrap", fontSize: u ? 11.5 : void 0 }, children: "DataSet Dinâmico" })
1930
+ ] }),
1931
+ d && /* @__PURE__ */ t(
1932
+ Nt,
1933
+ {
1934
+ size: "small",
1935
+ value: v ?? "",
1936
+ onChange: /* @__PURE__ */ a((p) => x.getState().updateDashboard({ defaultDatasetName: p.target.value }), "onChange"),
1937
+ displayEmpty: !0,
1938
+ fullWidth: u,
1939
+ sx: { minWidth: u ? void 0 : 160, fontSize: "0.8rem", "& .MuiSelect-select": { py: 0.5 } },
1940
+ renderValue: /* @__PURE__ */ a((p) => {
1941
+ var f;
1942
+ return p ? ((f = n.find((y) => y.dataSetId === p)) == null ? void 0 : f.name) ?? p : "Default…";
1943
+ }, "renderValue"),
1944
+ children: n.map((p) => /* @__PURE__ */ t(Ee, { value: p.dataSetId, sx: { fontSize: "0.8rem" }, children: /* @__PURE__ */ b(j, { sx: { display: "flex", alignItems: "center", gap: 1 }, children: [
1945
+ /* @__PURE__ */ t("span", { children: p.name }),
1946
+ p.isTemplate && /* @__PURE__ */ t(ie, { variant: "caption", sx: { color: "text.disabled" }, children: "(template)" })
1947
+ ] }) }, p.dataSetId))
1948
+ }
1949
+ ),
1950
+ l && /* @__PURE__ */ t(j, { sx: u ? {} : { borderLeft: `1px solid ${h.palette.divider}`, pl: 1 }, children: /* @__PURE__ */ t(
1951
+ Nt,
1952
+ {
1953
+ size: "small",
1954
+ value: c,
1955
+ onChange: /* @__PURE__ */ a((p) => {
1956
+ const f = l.find((y) => y.id === p.target.value);
1957
+ f && (g == null || g(f));
1958
+ }, "onChange"),
1959
+ displayEmpty: !0,
1960
+ fullWidth: u,
1961
+ sx: { minWidth: u ? void 0 : 180, fontSize: "0.8rem", "& .MuiSelect-select": { py: 0.5 } },
1962
+ renderValue: /* @__PURE__ */ a((p) => {
1963
+ var f;
1964
+ return ((f = l.find((y) => y.id === p)) == null ? void 0 : f.name) ?? "Agent…";
1965
+ }, "renderValue"),
1966
+ "data-env-id": "dashboard-pad-agent-picker",
1967
+ children: l.map((p) => /* @__PURE__ */ t(Ee, { value: p.id, sx: { fontSize: "0.8rem" }, children: p.name }, p.id))
1968
+ }
1969
+ ) })
1970
+ ]
1971
+ }
1972
+ );
1973
+ }, "DatasetParameterizationControls"), Ma = /* @__PURE__ */ a(({ backgroundColor: e, zoom: n = 0.7, width: i = "80%", title: l, config: o }) => /* @__PURE__ */ t(j, { sx: /* @__PURE__ */ a((r) => ({ display: "inline-flex", justifyContent: "left", width: "100%", border: `1px solid ${r.palette.divider}`, borderRadius: "10px", p: 2, maxHeight: "500px", overflow: "auto" }), "sx"), children: /* @__PURE__ */ b(se, { gap: 2, sx: /* @__PURE__ */ a((r) => ({ p: 1, borderRadius: 2, backgroundColor: e ?? r.palette.background.paper, width: i, zoom: n }), "sx"), children: [
1974
+ l && /* @__PURE__ */ t(ie, { variant: "body1", children: l }),
1975
+ /* @__PURE__ */ t(Xe, { container: !0, spacing: 1, children: o.map((r, g) => /* @__PURE__ */ t(Xe, { size: r.size, maxHeight: 300, children: /* @__PURE__ */ t(j, { sx: { width: "100%", height: r.specificType == "Gauge" || r.specificType == "MetricComparison" ? "100px" : `${Math.max(r.height ?? 0, nt)}px` }, children: r.card }) }, `example-pad-card-${g}`)) })
1976
+ ] }) }), "ExamplePad"), rt = /* @__PURE__ */ a((e) => {
1977
+ const n = Me(), i = e.specificType ?? "Generic", l = n.specificType[i] ?? n.specificType.Generic;
1978
+ return /* @__PURE__ */ b(j, { sx: { ...e.sx, width: "100%", height: "100%", p: 1, gap: 0.2, textAlign: "justify" }, className: "react-grid-placeholder-example", children: [
1979
+ /* @__PURE__ */ t(l, { fontSize: "small", sx: { float: "left", shapeOutside: "margin-box", mr: 0.5 } }),
1980
+ /* @__PURE__ */ t(ie, { sx: { fontSize: "14px" }, children: `[${e.name}] - ${e.description}` })
1981
+ ] });
1982
+ }, "ExampleCardSketch"), Ra = rt, _a = rt, Fa = /* @__PURE__ */ a(({ backgroundColor: e, zoom: n = 0.8, width: i = "100%", title: l, config: o }) => /* @__PURE__ */ b(se, { gap: 2, sx: /* @__PURE__ */ a((r) => ({ p: 1, borderRadius: 2, backgroundColor: e ?? r.palette.background.paper, width: i, maxHeight: "1400px" }), "sx"), children: [
1983
+ l && /* @__PURE__ */ t(ie, { variant: "body1", children: l }),
1984
+ /* @__PURE__ */ t(Xe, { container: !0, spacing: 1, sx: { zoom: n }, children: o.map((r, g) => /* @__PURE__ */ t(Xe, { size: r.size, children: /* @__PURE__ */ t(j, { sx: { width: "100%", height: r.height ?? nt, "& > *": { width: "100%", maxHeight: "500px" } }, children: r.card }) }, `prototype-pad-card-${g}`)) })
1985
+ ] }), "PrototypePad");
1986
+ function Na(e, n, i, l, o) {
1987
+ if (l === void 0) return { size: e, height: n, card: i };
1988
+ const r = i;
1989
+ return o !== void 0 && typeof o != "string" ? { size: e, height: n, name: r, specificType: l, card: o } : {
1990
+ size: e,
1991
+ height: n,
1992
+ name: r,
1993
+ specificType: l,
1994
+ description: o,
1995
+ card: /* @__PURE__ */ t(rt, { name: r, specificType: l, description: o })
1996
+ };
1997
+ }
1998
+ a(Na, "c");
1999
+ const Ba = /* @__PURE__ */ a((e, n) => ({
2000
+ i: e,
2001
+ name: n,
2002
+ filterType: "DateRangePicker",
2003
+ mandatory: !0,
2004
+ parametersNames: [`${n}_inicio`, `${n}_fim`]
2005
+ }), "dateRange"), Ha = /* @__PURE__ */ a((e, n, i = !1) => ({
2006
+ i: e,
2007
+ name: n,
2008
+ filterType: "DatePicker",
2009
+ mandatory: i,
2010
+ parametersNames: [n]
2011
+ }), "datePicker"), La = /* @__PURE__ */ a((e, n, i = !0, l = !1) => ({
2012
+ i: e,
2013
+ name: n,
2014
+ filterType: "AutoComplete",
2015
+ mandatory: l,
2016
+ multipleSelection: i,
2017
+ parametersNames: [n]
2018
+ }), "autoComplete");
2019
+ function Ga(e, n) {
2020
+ const i = dn();
2021
+ q(() => {
2022
+ var l, o;
2023
+ n == "update" ? (l = i.updateDashboardPad) == null || l.call(i, e) : (o = i.createDashboardPad) == null || o.call(i, e);
2024
+ }, []);
2025
+ }
2026
+ a(Ga, "useDashboardPad");
2027
+ const Fn = {
2028
+ visible: { opacity: 1, y: 0, transition: { duration: 0.18, ease: "easeOut" } },
2029
+ hidden: { opacity: 0, y: -12, transition: { duration: 0.18, ease: "easeOut" } }
2030
+ }, Nn = {
2031
+ hidden: { opacity: 0, x: 16, transition: { duration: 0.1, ease: "easeOut" } },
2032
+ visible: { opacity: 1, x: 0, transition: { duration: 0.32, ease: "easeOut", delay: 0.22 } }
2033
+ }, Bn = { duration: 0.28, ease: "easeOut" }, Hn = {
2034
+ visible: { opacity: 1, transition: { duration: 0.15 } },
2035
+ hidden: { opacity: 0, transition: { duration: 0.15 } }
2036
+ }, Ln = {
2037
+ hidden: { opacity: 0, transition: { duration: 0.15 } },
2038
+ visible: { opacity: 1, transition: { duration: 0.15 } }
2039
+ }, Gn = { duration: 0.15, ease: "linear" }, Wn = {
2040
+ kpi: { category: "Métrica", specificType: "MetricComparison" },
2041
+ line: { category: "Gráfico", specificType: "ChartLine" },
2042
+ bars: { category: "Gráfico", specificType: "ChartBarV" },
2043
+ table: { category: "Tabela", specificType: "TableAuto" },
2044
+ donut: { category: "Gráfico", specificType: "ChartDonut" },
2045
+ heatmap: { category: "Tabela", specificType: "TableHeatmap" }
2046
+ };
2047
+ function Vn(e) {
2048
+ return e.cells.map((n) => n.kind);
2049
+ }
2050
+ a(Vn, "templateKinds");
2051
+ function jn(e, n) {
2052
+ const i = n ?? `${e.id}-${Date.now()}`;
2053
+ return e.cells.map((l, o) => {
2054
+ const r = Wn[l.kind];
2055
+ return {
2056
+ i: `${i}-${o}`,
2057
+ x: l.x,
2058
+ y: l.y,
2059
+ w: l.w,
2060
+ h: l.h,
2061
+ isResizable: !0,
2062
+ category: r.category,
2063
+ specificType: r.specificType,
2064
+ name: l.name,
2065
+ actionDescription: l.description
2066
+ };
2067
+ });
2068
+ }
2069
+ a(jn, "seedFromTemplate");
2070
+ const Mt = [
2071
+ {
2072
+ id: "t1",
2073
+ name: "Visão executiva",
2074
+ desc: "KPIs principais + tendência mensal",
2075
+ recommended: !0,
2076
+ cells: [
2077
+ { name: "Receita Total", kind: "kpi", description: "Receita acumulada no período vs. período anterior", x: 0, y: 0, w: 4, h: 4 },
2078
+ { name: "Ticket Médio", kind: "kpi", description: "Valor médio por pedido", x: 4, y: 0, w: 4, h: 4 },
2079
+ { name: "Conversão", kind: "kpi", description: "% de leads que viraram clientes", x: 8, y: 0, w: 4, h: 4 },
2080
+ { name: "Tendência Mensal", kind: "line", description: "Evolução de receita mês a mês", x: 0, y: 4, w: 12, h: 7 },
2081
+ { name: "Top 10 Clientes", kind: "table", description: "Ranking dos clientes com maior receita", x: 0, y: 11, w: 7, h: 7 },
2082
+ { name: "Receita por Canal", kind: "donut", description: "Distribuição percentual da receita por canal de venda", x: 7, y: 11, w: 5, h: 7 }
2083
+ ]
2084
+ },
2085
+ {
2086
+ id: "t2",
2087
+ name: "Análise comercial",
2088
+ desc: "Funil de vendas + receita por canal",
2089
+ cells: [
2090
+ { name: "Pipeline", kind: "kpi", description: "Valor total do pipeline aberto", x: 0, y: 0, w: 6, h: 4 },
2091
+ { name: "Win Rate", kind: "kpi", description: "% de oportunidades fechadas vs. perdidas", x: 6, y: 0, w: 6, h: 4 },
2092
+ { name: "Receita Semanal", kind: "line", description: "Receita semanal nos últimos 90 dias", x: 0, y: 4, w: 7, h: 6 },
2093
+ { name: "Vendas por Vendedor", kind: "bars", description: "Volume de vendas por representante comercial", x: 7, y: 4, w: 5, h: 6 },
2094
+ { name: "Funil de Vendas", kind: "line", description: "Conversão por estágio do funil", x: 0, y: 10, w: 5, h: 6 },
2095
+ { name: "Top Oportunidades", kind: "table", description: "Maiores oportunidades em aberto, ordenadas por valor", x: 5, y: 10, w: 7, h: 6 },
2096
+ { name: "Receita por Canal", kind: "donut", description: "Distribuição da receita por canal de venda", x: 0, y: 16, w: 5, h: 6 },
2097
+ { name: "Atividade da Equipe", kind: "heatmap", description: "Heatmap de atividade por vendedor por dia", x: 5, y: 16, w: 7, h: 6 }
2098
+ ]
2099
+ },
2100
+ {
2101
+ id: "t3",
2102
+ name: "Operação",
2103
+ desc: "Volume, ocupação e cancelamentos",
2104
+ cells: [
2105
+ { name: "Volume Diário", kind: "kpi", description: "Total de operações no dia atual", x: 0, y: 0, w: 4, h: 4 },
2106
+ { name: "Ocupação", kind: "kpi", description: "% de capacidade utilizada", x: 4, y: 0, w: 4, h: 4 },
2107
+ { name: "Cancelamentos", kind: "kpi", description: "% de operações canceladas no período", x: 8, y: 0, w: 4, h: 4 },
2108
+ { name: "Volume por Origem", kind: "bars", description: "Top origens por volume de operações", x: 0, y: 4, w: 7, h: 6 },
2109
+ { name: "SLA", kind: "line", description: "Tempo médio de processamento ao longo do dia", x: 7, y: 4, w: 5, h: 6 },
2110
+ { name: "Pendências", kind: "table", description: "Operações pendentes ordenadas por SLA", x: 0, y: 10, w: 7, h: 6 },
2111
+ { name: "Status", kind: "donut", description: "Distribuição percentual dos status (Aberto, Em andamento, Concluído)", x: 7, y: 10, w: 5, h: 6 }
2112
+ ]
2113
+ },
2114
+ {
2115
+ id: "t4",
2116
+ name: "Em branco",
2117
+ desc: "Comece do zero — adicione cards conforme pensa",
2118
+ cells: []
2119
+ }
2120
+ ], Wa = Mt, Rt = Ct(null), Vo = /* @__PURE__ */ a(({ children: e }) => {
2121
+ const [n, i] = N([]), l = ee(null), [, o] = N(0), r = W((v) => {
2122
+ i((s) => {
2123
+ const c = v.at ?? Date.now(), u = { visible: !1, ...v, at: c }, p = s.findIndex((R) => R.id === v.id);
2124
+ if (p === -1) return [...s, u];
2125
+ const f = { ...s[p], ...u, at: s[p].at, visible: s[p].visible }, y = s.slice();
2126
+ return y[p] = f, y;
2127
+ });
2128
+ }, []), g = W((v) => i((s) => s.filter((c) => c.id !== v)), []), h = W((v, s) => {
2129
+ i((c) => {
2130
+ const u = c.findIndex((f) => f.id === v);
2131
+ if (u === -1 || c[u].visible === s) return c;
2132
+ const p = c.slice();
2133
+ return p[u] = { ...p[u], visible: s }, p;
2134
+ });
2135
+ }, []), x = W((v) => {
2136
+ l.current !== v && (l.current = v, o((s) => s + 1));
2137
+ }, []), d = ve(
2138
+ () => ({ items: n, register: r, unregister: g, setVisible: h, scrollerRef: l, setScroller: x }),
2139
+ [n, r, g, h, x]
2140
+ );
2141
+ return /* @__PURE__ */ t(Rt.Provider, { value: d, children: e });
2142
+ }, "SessionVisualizationsProvider");
2143
+ function Un() {
2144
+ const e = Ae(Rt), n = W(
2145
+ (r) => {
2146
+ const g = e == null ? void 0 : e.scrollerRef.current, h = g == null ? void 0 : g.querySelector(`[data-viz="${CSS.escape(r)}"]`);
2147
+ if (!g || !h) return;
2148
+ const x = h.offsetTop - g.offsetTop - 24;
2149
+ g.scrollTo({ top: Math.max(0, x), behavior: "smooth" }), h.setAttribute("data-viz-focus", "true"), window.setTimeout(() => h.removeAttribute("data-viz-focus"), 2e3);
2150
+ },
2151
+ [e]
2152
+ ), i = (e == null ? void 0 : e.items) ?? Va, l = ve(() => i.filter((r) => !r.visible), [i]), o = (e == null ? void 0 : e.setScroller) ?? ja;
2153
+ return { items: i, offscreen: l, scrollTo: n, setScroller: o };
2154
+ }
2155
+ a(Un, "useSessionVisualizations");
2156
+ const Va = [], ja = /* @__PURE__ */ a(() => {
2157
+ }, "noop"), jt = 0.6, jo = /* @__PURE__ */ a(({ id: e, kind: n, title: i, group: l, preview: o, ready: r = !0, children: g }) => {
2158
+ const h = Ae(Rt), x = ee(null), d = h == null ? void 0 : h.register, v = h == null ? void 0 : h.unregister, s = h == null ? void 0 : h.setVisible, c = (h == null ? void 0 : h.scrollerRef.current) ?? null;
2159
+ return q(() => {
2160
+ d == null || d({ id: e, kind: n, title: i, group: l, preview: o, ready: r });
2161
+ }, [e, n, i, l, r, d]), q(() => {
2162
+ if (v)
2163
+ return () => v(e);
2164
+ }, [e, v]), q(() => {
2165
+ const u = x.current;
2166
+ if (!u || !s || typeof IntersectionObserver > "u") return;
2167
+ const p = new IntersectionObserver(
2168
+ (f) => {
2169
+ for (const y of f) s(e, y.intersectionRatio >= jt);
2170
+ },
2171
+ // `root: null` would measure against the viewport, which is wrong inside a scrolling transcript —
2172
+ // it reports a card visible while it sits far below the pane's own fold.
2173
+ { root: c, threshold: [0, jt, 1] }
2174
+ );
2175
+ return p.observe(u), () => p.disconnect();
2176
+ }, [e, c, s]), /* @__PURE__ */ t("div", { ref: x, "data-viz": e, children: g });
2177
+ }, "VisualizationFrame");
2178
+ function ue(e) {
2179
+ var l, o, r;
2180
+ const n = e.palette, i = e.typography.fontFamilyMono;
2181
+ return {
2182
+ raised: ((l = n.surface) == null ? void 0 : l.raised) ?? n.background.paper,
2183
+ hover: ((o = n.surface) == null ? void 0 : o.hover) ?? n.action.hover,
2184
+ borderSoft: ((r = n.border) == null ? void 0 : r.soft) ?? n.divider,
2185
+ fontFamilyMono: i ?? "ui-monospace, SFMono-Regular, Menlo, monospace"
2186
+ };
2187
+ }
2188
+ a(ue, "resolveComposerSurfaces");
2189
+ function Ua() {
2190
+ const e = /* @__PURE__ */ a(() => typeof window > "u" ? { width: 0, height: 0 } : { width: window.innerWidth, height: window.innerHeight }, "read"), [n, i] = N(e);
2191
+ return q(() => {
2192
+ if (typeof window > "u") return;
2193
+ const l = /* @__PURE__ */ a(() => i(e()), "onResize");
2194
+ return window.addEventListener("resize", l), () => window.removeEventListener("resize", l);
2195
+ }, []), n;
2196
+ }
2197
+ a(Ua, "useWindowSize");
2198
+ const Ut = /* @__PURE__ */ a((e) => e.toString().padStart(2, "0"), "pad2"), ht = /* @__PURE__ */ a((e) => `${e.getFullYear()}-${Ut(e.getMonth() + 1)}-${Ut(e.getDate())}`, "isoDate"), Kn = /* @__PURE__ */ a((e) => {
2199
+ const n = le(), i = ue(n), l = he(), o = B((z) => {
2200
+ var I;
2201
+ return ((I = z.publishedDashboard) == null ? void 0 : I.jsFileName) ?? null;
2202
+ }), r = B((z) => z.publishedDashboard), g = B((z) => z.llmCounter), h = B((z) => z.renderGeneration), x = B((z) => {
2203
+ var I;
2204
+ return ((I = z.publishedDashboard) == null ? void 0 : I.id) ?? null;
2205
+ }), d = B((z) => {
2206
+ var I;
2207
+ return ((I = z.publishedDashboard) == null ? void 0 : I.name) || "Dashboard";
2208
+ }), v = B((z) => {
2209
+ var I, U;
2210
+ return ((U = (I = z.publishedDashboard) == null ? void 0 : I.cards) == null ? void 0 : U.length) ?? 0;
2211
+ }), [s, c] = N(0), [u, p] = N(!1), [f, y] = N(e.defaultCollapsed ?? !1), [R, H] = N({});
2212
+ q(() => {
2213
+ if (!r) return;
2214
+ const z = {}, I = /* @__PURE__ */ new Date(), U = new Date(I.getTime() - 1e3 * 3600 * 24 * 30);
2215
+ for (const J of r.filters ?? [])
2216
+ J.mandatory && (J.filterType == "DateRangePicker" ? (z[`${J.name}_inicio`] = ht(U), z[`${J.name}_fim`] = ht(I)) : J.filterType == "DatePicker" && (z[J.name] = ht(I)));
2217
+ H(z);
2218
+ }, [r == null ? void 0 : r.filters, r]);
2219
+ const L = /* @__PURE__ */ a((z) => {
2220
+ var I;
2221
+ (I = e.onCollapseChange) == null || I.call(e, z), y(z);
2222
+ }, "changeCollapse");
2223
+ q(() => {
2224
+ L(e.defaultCollapsed ?? !1);
2225
+ }, [e.defaultCollapsed]);
2226
+ const P = f ? "25%" : e.width, { width: _, height: $ } = Ua(), V = _ > $ ? 1.7 : 1, K = $ > _ ? 1.7 : 1, M = Math.min(_, $) * V, w = Math.min(_, $) * K, F = !!o, D = { color: n.palette.text.secondary, p: 0.5, "&:hover": { color: n.palette.text.primary, backgroundColor: i.hover } };
2227
+ return /* @__PURE__ */ t(tt, { initial: !1, children: F && r && /* @__PURE__ */ b(
2228
+ re.aside,
2229
+ {
2230
+ initial: { width: 0, opacity: 0 },
2231
+ animate: { width: P, opacity: 1 },
2232
+ exit: { width: 0, opacity: 0 },
2233
+ transition: { duration: 0.32, ease: [0.22, 0.8, 0.32, 1] },
2234
+ style: { overflow: "hidden", display: "inline-flex", flexDirection: "column", borderLeft: `1px solid ${n.palette.divider}`, backgroundColor: n.palette.background.default, minHeight: 0 },
2235
+ children: [
2236
+ /* @__PURE__ */ b(re.div, { initial: { opacity: 0, y: 6 }, animate: { opacity: 1, y: 0 }, transition: { duration: 0.28, delay: 0.08, ease: "easeOut" }, style: { display: "inline-flex", flexDirection: "column", minHeight: 0, position: "relative", height: "100%" }, children: [
2237
+ /* @__PURE__ */ b(S, { sx: { display: "inline-flex", alignItems: "center", width: "100%", gap: 1, px: 1.75, py: 1.25, borderBottom: `1px solid ${n.palette.divider}`, backgroundColor: n.palette.background.paper }, children: [
2238
+ /* @__PURE__ */ t(S, { sx: { color: n.palette.primary.main, display: "inline-flex" }, children: /* @__PURE__ */ t(ke, { size: 15 }) }),
2239
+ /* @__PURE__ */ t(X, { sx: { color: n.palette.text.primary, fontWeight: 500, fontSize: 12.5, overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" }, children: d }),
2240
+ !f && /* @__PURE__ */ b(Te, { children: [
2241
+ /* @__PURE__ */ t(X, { sx: { color: n.palette.text.disabled, fontSize: 11, flexShrink: 0 }, children: "·" }),
2242
+ /* @__PURE__ */ b(X, { sx: { fontFamily: i.fontFamilyMono, color: n.palette.text.secondary, fontSize: 11, flexShrink: 0 }, children: [
2243
+ v,
2244
+ " ",
2245
+ v === 1 ? "card" : "cards"
2246
+ ] })
2247
+ ] }),
2248
+ /* @__PURE__ */ t(S, { sx: { flex: 1 } }),
2249
+ /* @__PURE__ */ t(ce, { title: "Atualizar dados (ignora cache)", placement: "top", children: /* @__PURE__ */ t(be, { size: "small", onClick: /* @__PURE__ */ a(() => c((z) => z + 1), "onClick"), sx: D, "aria-label": "Atualizar dados", children: /* @__PURE__ */ t(ln, { sx: { fontSize: 18 } }) }) }),
2250
+ /* @__PURE__ */ t(ce, { title: f ? "Expandir" : "Diminuir", placement: "top", children: /* @__PURE__ */ t(be, { size: "small", onClick: /* @__PURE__ */ a(() => L(!f), "onClick"), sx: D, "aria-label": f ? "Expandir" : "Diminuir", children: /* @__PURE__ */ t(Le, { size: 14 }) }) }),
2251
+ /* @__PURE__ */ t(ce, { title: "Tela cheia", placement: "top", children: /* @__PURE__ */ t(be, { size: "small", onClick: /* @__PURE__ */ a(() => p(!0), "onClick"), sx: D, "aria-label": "Abrir em tela cheia", children: /* @__PURE__ */ t(ji, { sx: { fontSize: "18px" } }) }) })
2252
+ ] }),
2253
+ /* @__PURE__ */ b(S, { sx: { display: "inline-flex", height: "100%", width: "100%", minHeight: 0, overflow: "auto", backgroundColor: n.palette.background.default }, children: [
2254
+ x && !f && /* @__PURE__ */ t(
2255
+ _e,
2256
+ {
2257
+ dragLocked: !1,
2258
+ llmRenderCount: g + s,
2259
+ codeGeneration: h,
2260
+ dashboard: r,
2261
+ editable: !0,
2262
+ onLayoutCommit: /* @__PURE__ */ a(() => l.getState().commitDashboardLayout(), "onLayoutCommit"),
2263
+ onFiltersChanged: /* @__PURE__ */ a((z) => H(z), "onFiltersChanged")
2264
+ },
2265
+ x
2266
+ ),
2267
+ x && f && /* @__PURE__ */ t(ci, { llmRenderCount: g + s, codeGeneration: h, dashboard: r, parameters: R }, x)
2268
+ ] })
2269
+ ] }),
2270
+ /* @__PURE__ */ b(cn, { open: u, onClose: /* @__PURE__ */ a(() => p(!1), "onClose"), maxWidth: !1, fullScreen: !0, slotProps: { paper: { sx: { backgroundColor: n.palette.background.default, backgroundImage: "none", color: n.palette.text.primary } } }, children: [
2271
+ /* @__PURE__ */ b(S, { sx: { display: "flex", alignItems: "center", gap: 1, px: 2, py: 1.25, borderBottom: `1px solid ${n.palette.divider}`, backgroundColor: n.palette.background.paper, flexShrink: 0 }, children: [
2272
+ /* @__PURE__ */ t(S, { sx: { color: n.palette.primary.main, display: "inline-flex" }, children: /* @__PURE__ */ t(ke, { size: 16 }) }),
2273
+ /* @__PURE__ */ t(X, { sx: { color: n.palette.text.primary, fontWeight: 500, fontSize: 13.5 }, children: d }),
2274
+ /* @__PURE__ */ t(X, { sx: { color: n.palette.text.disabled, fontSize: 12 }, children: "·" }),
2275
+ /* @__PURE__ */ b(X, { sx: { fontFamily: i.fontFamilyMono, color: n.palette.text.secondary, fontSize: 12 }, children: [
2276
+ v,
2277
+ " ",
2278
+ v === 1 ? "card" : "cards"
2279
+ ] }),
2280
+ /* @__PURE__ */ t(S, { sx: { flex: 1 } }),
2281
+ /* @__PURE__ */ t(ce, { title: "Fechar", placement: "left", children: /* @__PURE__ */ t(be, { size: "small", onClick: /* @__PURE__ */ a(() => p(!1), "onClick"), sx: { ...D, p: 0.75 }, "aria-label": "Fechar", children: /* @__PURE__ */ t(Dt, { size: 14 }) }) })
2282
+ ] }),
2283
+ /* @__PURE__ */ t(S, { sx: { width: "100%", justifyContent: "center", display: "inline-flex" }, children: /* @__PURE__ */ t(S, { sx: { minHeight: 0, overflow: "hidden", width: M, height: w, backgroundColor: n.palette.background.default }, children: x && /* @__PURE__ */ t(_e, { dragLocked: !1, llmRenderCount: g, codeGeneration: h, dashboard: r }, x) }) })
2284
+ ] })
2285
+ ]
2286
+ },
2287
+ "dashboard-side-panel"
2288
+ ) });
2289
+ }, "DashboardSidePanelInner");
2290
+ Kn.displayName = "DashboardSidePanel";
2291
+ const qn = He.memo(Kn), Ka = it(we), qa = [], We = /* @__PURE__ */ a(({ children: e }) => /* @__PURE__ */ t(X, { sx: /* @__PURE__ */ a((n) => ({ fontSize: 9.5, color: n.palette.text.disabled, textTransform: "uppercase", letterSpacing: 0.6, fontWeight: 500, lineHeight: 1.6 }), "sx"), children: e }), "RailSectionLabel");
2292
+ function Kt(e, n) {
2293
+ const i = new Map(e.map((h) => [h.i, h])), l = new Map(n.map((h) => [h.i, h]));
2294
+ let o = 0, r = 0, g = 0;
2295
+ for (const [h, x] of i) {
2296
+ const d = l.get(h);
2297
+ d ? JSON.stringify(x) !== JSON.stringify(d) && g++ : o++;
2298
+ }
2299
+ for (const h of l.keys()) i.has(h) || r++;
2300
+ return { added: o, removed: r, modified: g };
2301
+ }
2302
+ a(Kt, "diffById");
2303
+ function qt(e, n, i) {
2304
+ return {
2305
+ background: n.raised,
2306
+ border: `1px solid ${e.palette.divider}`,
2307
+ color: e.palette.text.primary,
2308
+ fontFamily: e.typography.fontFamily,
2309
+ fontSize: 11,
2310
+ fontWeight: 500,
2311
+ px: 1,
2312
+ py: 0.625,
2313
+ borderRadius: 1,
2314
+ cursor: i ? "not-allowed" : "pointer",
2315
+ opacity: i ? 0.45 : 1,
2316
+ display: "inline-flex",
2317
+ alignItems: "center",
2318
+ justifyContent: "flex-start",
2319
+ gap: 0.625,
2320
+ transition: "filter .12s, background-color .12s, border-color .12s, color .12s",
2321
+ "&:hover": i ? void 0 : { backgroundColor: n.hover }
2322
+ };
2323
+ }
2324
+ a(qt, "railActionPill");
2325
+ const Ya = /* @__PURE__ */ a(({ locked: e, name: n, onNameChange: i, layoutType: l, onLayoutTypeChange: o, onAddGenericCard: r, onAddTypedCard: g, onAddFilter: h, cardsOpened: x, filters: d, onEditFilter: v, onDeleteFilter: s, datasetControls: c }) => {
2326
+ const u = le(), p = ue(u), f = Me(), [y, R] = N(null), [H, L] = N(null), P = ee(null), [_, $] = N(!1);
2327
+ q(() => {
2328
+ P.current && x && P.current.click();
2329
+ }, [x]);
2330
+ const V = { display: "flex", flexDirection: "column", gap: 0.5, px: 1, pt: 1, pb: 0.875, borderBottom: `1px solid ${p.borderSoft}` }, K = { fontSize: 12, color: u.palette.text.primary, "&:hover": { backgroundColor: p.hover } }, M = { backgroundColor: p.raised, border: `1px solid ${u.palette.divider}`, ml: 0.5, minWidth: 260, maxHeight: 420, overflow: "auto" };
2331
+ return /* @__PURE__ */ b(
2332
+ re.aside,
2333
+ {
2334
+ animate: { width: _ ? 44 : "12vw" },
2335
+ transition: { duration: 0.22, ease: [0.22, 0.8, 0.32, 1] },
2336
+ style: { flexShrink: 0, display: "flex", flexDirection: "column", borderRight: `1px solid ${p.borderSoft}`, backgroundColor: u.palette.background.paper, overflow: "hidden", minHeight: 0 },
2337
+ children: [
2338
+ /* @__PURE__ */ b(S, { sx: { flexShrink: 0, display: "flex", alignItems: "center", gap: 0.625, pl: 1, pr: 1, py: 1.5, borderBottom: `1px solid ${p.borderSoft}` }, children: [
2339
+ /* @__PURE__ */ t(ce, { title: _ ? "Expandir painel" : "Recolher painel", placement: "right", children: /* @__PURE__ */ t(be, { size: "small", onClick: /* @__PURE__ */ a(() => $((w) => !w), "onClick"), sx: { color: u.palette.text.primary, p: 0.5, flexShrink: 0, "&:hover": { color: u.palette.primary.main } }, "aria-label": _ ? "Expandir painel" : "Recolher painel", children: /* @__PURE__ */ t(Le, { size: 13 }) }) }),
2340
+ !_ && /* @__PURE__ */ t(X, { sx: { color: u.palette.text.primary, fontWeight: 500, fontSize: 11.5, lineHeight: 1.2, whiteSpace: "nowrap", overflow: "hidden", textOverflow: "ellipsis" }, children: "Desenhe seu prompt" })
2341
+ ] }),
2342
+ !_ && /* @__PURE__ */ b(S, { sx: { flex: 1, minHeight: 0, overflowY: "auto", display: "flex", flexDirection: "column" }, children: [
2343
+ /* @__PURE__ */ b(S, { sx: { ...V, gap: 0.25 }, children: [
2344
+ /* @__PURE__ */ t(We, { children: "Nome" }),
2345
+ /* @__PURE__ */ t(S, { sx: { color: u.palette.text.primary, fontFamily: u.typography.fontFamily, fontSize: 12 }, children: /* @__PURE__ */ t(Ge, { placeHolderText: "novo dashboard", onEdit: i, text: n, fontSize: 12 }) })
2346
+ ] }),
2347
+ /* @__PURE__ */ b(S, { sx: { ...V, p: 1 }, children: [
2348
+ /* @__PURE__ */ b(
2349
+ S,
2350
+ {
2351
+ ref: P,
2352
+ component: "button",
2353
+ onClick: /* @__PURE__ */ a((w) => R(w.currentTarget), "onClick"),
2354
+ disabled: e,
2355
+ "data-env-id": "dashboardpad-add-card",
2356
+ "data-env-key": "dashboardpad-add-card-dropdown",
2357
+ className: "llm-env-target llm-env-dashboard-action",
2358
+ sx: qt(u, p, e),
2359
+ children: [
2360
+ /* @__PURE__ */ t(yt, { size: 11 }),
2361
+ /* @__PURE__ */ t(S, { component: "span", children: "Card" })
2362
+ ]
2363
+ }
2364
+ ),
2365
+ /* @__PURE__ */ b(S, { component: "button", onClick: /* @__PURE__ */ a((w) => L(w.currentTarget), "onClick"), disabled: e, "data-env-id": "dashboardpad-add-filter", className: "llm-env-target llm-env-dashboard-action", sx: qt(u, p, e), children: [
2366
+ /* @__PURE__ */ t(Ji, { size: 11 }),
2367
+ /* @__PURE__ */ t(S, { component: "span", children: "Filtro" })
2368
+ ] })
2369
+ ] }),
2370
+ d.length > 0 ? /* @__PURE__ */ b(S, { sx: { p: 1, display: "flex", flexDirection: "column", gap: 0.625 }, children: [
2371
+ /* @__PURE__ */ b(We, { children: [
2372
+ "Filtros · ",
2373
+ d.length
2374
+ ] }),
2375
+ d.map((w) => /* @__PURE__ */ t(At, { filter: w, onEdit: v, onDelete: s }, w.i))
2376
+ ] }) : /* @__PURE__ */ t(S, { sx: { p: 1, display: "flex", alignItems: "flex-start" }, children: /* @__PURE__ */ b(X, { sx: { fontSize: 10, color: u.palette.text.disabled, fontStyle: "italic", lineHeight: 1.4 }, children: [
2377
+ "Nenhum filtro ainda. Use ",
2378
+ /* @__PURE__ */ t("b", { children: "+ Filtro" }),
2379
+ " para adicionar."
2380
+ ] }) }),
2381
+ /* @__PURE__ */ b(S, { sx: { ...V, borderBottom: "none", borderTop: `1px solid ${p.borderSoft}` }, children: [
2382
+ /* @__PURE__ */ t(We, { children: "Layout" }),
2383
+ /* @__PURE__ */ b(
2384
+ aa,
2385
+ {
2386
+ exclusive: !0,
2387
+ size: "small",
2388
+ value: l,
2389
+ onChange: /* @__PURE__ */ a((w, F) => F && o(F), "onChange"),
2390
+ disabled: e,
2391
+ "data-env-id": "dashboard-pad-layout-toggle",
2392
+ className: "llm-env-target llm-env-layout-toggle",
2393
+ sx: {
2394
+ height: 24,
2395
+ "& .MuiToggleButton-root": {
2396
+ flex: 1,
2397
+ px: 0.875,
2398
+ py: 0,
2399
+ fontSize: 10.5,
2400
+ textTransform: "none",
2401
+ color: u.palette.text.secondary,
2402
+ border: `1px solid ${u.palette.divider}`,
2403
+ "&.Mui-selected": { color: u.palette.text.primary, backgroundColor: p.hover },
2404
+ "&.Mui-selected:hover": { backgroundColor: p.hover }
2405
+ }
2406
+ },
2407
+ children: [
2408
+ /* @__PURE__ */ t(Wt, { value: "Boxed", "data-env-id": "dashboard-pad-layout-boxed", children: "Boxed" }),
2409
+ /* @__PURE__ */ t(Wt, { value: "Naked", "data-env-id": "dashboard-pad-layout-naked", children: "Naked" })
2410
+ ]
2411
+ }
2412
+ )
2413
+ ] }),
2414
+ c && /* @__PURE__ */ b(S, { sx: { ...V, borderBottom: "none", borderTop: `1px solid ${p.borderSoft}` }, children: [
2415
+ /* @__PURE__ */ t(We, { children: "Dataset / Agent" }),
2416
+ c
2417
+ ] })
2418
+ ] }),
2419
+ /* @__PURE__ */ t(Gt, { open: !!y, anchorEl: y, onClose: /* @__PURE__ */ a(() => R(null), "onClose"), anchorOrigin: { vertical: "top", horizontal: "right" }, transformOrigin: { vertical: "top", horizontal: "left" }, slotProps: { paper: { sx: M } }, children: /* @__PURE__ */ b(Lt, { dense: !0, children: [
2420
+ /* @__PURE__ */ b(
2421
+ dt,
2422
+ {
2423
+ onClick: /* @__PURE__ */ a(() => {
2424
+ r(), R(null);
2425
+ }, "onClick"),
2426
+ sx: K,
2427
+ children: [
2428
+ /* @__PURE__ */ t(lt, { sx: { color: u.palette.primary.main, minWidth: 28 }, children: /* @__PURE__ */ t(yt, { size: 14 }) }),
2429
+ /* @__PURE__ */ t(st, { primaryTypographyProps: { fontSize: 12, fontWeight: 500 }, secondaryTypographyProps: { fontSize: 10.5, color: u.palette.text.disabled }, primary: "Genérico", secondary: "Card sem tipo definido — você ou o agente preenche depois" })
2430
+ ]
2431
+ }
2432
+ ),
2433
+ /* @__PURE__ */ t(Ht, { sx: { borderColor: p.borderSoft } }),
2434
+ Object.entries(Ka).map(([w, F], D) => {
2435
+ const z = f.category[w];
2436
+ return /* @__PURE__ */ b(S, { children: [
2437
+ D > 0 && /* @__PURE__ */ t(Ht, { sx: { borderColor: p.borderSoft } }),
2438
+ /* @__PURE__ */ b(X, { sx: { px: 2, pt: 1, pb: 0.5, fontSize: 10, textTransform: "uppercase", letterSpacing: 0.6, color: u.palette.text.disabled, display: "flex", alignItems: "center", gap: 0.5 }, children: [
2439
+ /* @__PURE__ */ t(z, { fontSize: "inherit" }),
2440
+ " ",
2441
+ w
2442
+ ] }),
2443
+ F.map((I) => {
2444
+ const U = f.specificType[I.specificType];
2445
+ return /* @__PURE__ */ b(
2446
+ dt,
2447
+ {
2448
+ onClick: /* @__PURE__ */ a(() => {
2449
+ g(I.category, I.specificType), R(null);
2450
+ }, "onClick"),
2451
+ sx: K,
2452
+ children: [
2453
+ /* @__PURE__ */ t(lt, { sx: { color: u.palette.text.secondary, minWidth: 28 }, children: /* @__PURE__ */ t(U, { fontSize: "small" }) }),
2454
+ /* @__PURE__ */ t(st, { primaryTypographyProps: { fontSize: 12 }, children: I.label })
2455
+ ]
2456
+ },
2457
+ I.specificType
2458
+ );
2459
+ })
2460
+ ] }, w);
2461
+ })
2462
+ ] }) }),
2463
+ /* @__PURE__ */ t(Gt, { open: !!H, anchorEl: H, onClose: /* @__PURE__ */ a(() => L(null), "onClose"), anchorOrigin: { vertical: "top", horizontal: "right" }, transformOrigin: { vertical: "top", horizontal: "left" }, slotProps: { paper: { sx: { ...M, minWidth: 220, maxHeight: void 0 } } }, children: /* @__PURE__ */ t(Lt, { dense: !0, children: It.map((w) => {
2464
+ const F = f.filterType[w.filterType];
2465
+ return /* @__PURE__ */ b(
2466
+ dt,
2467
+ {
2468
+ onClick: /* @__PURE__ */ a(() => {
2469
+ h(w.filterType), L(null);
2470
+ }, "onClick"),
2471
+ sx: K,
2472
+ children: [
2473
+ /* @__PURE__ */ t(lt, { sx: { color: u.palette.text.secondary, minWidth: 28 }, children: /* @__PURE__ */ t(F, { fontSize: "small" }) }),
2474
+ /* @__PURE__ */ t(st, { primaryTypographyProps: { fontSize: 12 }, children: w.label })
2475
+ ]
2476
+ },
2477
+ w.filterType
2478
+ );
2479
+ }) }) })
2480
+ ]
2481
+ }
2482
+ );
2483
+ }, "LeftRail");
2484
+ function Yn(e) {
2485
+ const [n, i] = N(!1), l = ee(!0);
2486
+ return q(() => {
2487
+ if (l.current) {
2488
+ l.current = !1;
2489
+ return;
2490
+ }
2491
+ i(e > 0);
2492
+ const o = window.setTimeout(() => i(!1), 2500);
2493
+ return () => window.clearTimeout(o);
2494
+ }, [e]), n;
2495
+ }
2496
+ a(Yn, "usePulseTooltip");
2497
+ const Jn = /* @__PURE__ */ a((e, n, i) => ({
2498
+ initial: i > 0 ? { scale: 1.18, backgroundColor: e.palette.primary.main, borderColor: e.palette.primary.main } : !1,
2499
+ animate: { scale: 1, backgroundColor: n.raised, borderColor: e.palette.divider },
2500
+ transition: { duration: 2, ease: [0.22, 0.8, 0.32, 1] },
2501
+ style: {
2502
+ display: "inline-flex",
2503
+ alignItems: "center",
2504
+ gap: 6,
2505
+ backgroundColor: n.raised,
2506
+ borderStyle: "solid",
2507
+ borderWidth: 1,
2508
+ borderColor: e.palette.divider,
2509
+ borderRadius: 999,
2510
+ paddingLeft: 10,
2511
+ paddingRight: 4,
2512
+ paddingTop: 3,
2513
+ paddingBottom: 3,
2514
+ fontSize: 11,
2515
+ color: e.palette.text.primary,
2516
+ transformOrigin: "center center"
2517
+ }
2518
+ }), "chipMotionProps"), Xn = /* @__PURE__ */ a(({ cardCount: e, surfaces: n }) => /* @__PURE__ */ b(Te, { children: [
2519
+ /* @__PURE__ */ t(S, { sx: /* @__PURE__ */ a((i) => ({ color: i.palette.primary.main, display: "inline-flex" }), "sx"), children: /* @__PURE__ */ t(Le, { size: 12 }) }),
2520
+ /* @__PURE__ */ t(S, { component: "span", sx: { fontWeight: 500 }, children: "Sketch" }),
2521
+ /* @__PURE__ */ t(S, { component: "span", sx: /* @__PURE__ */ a((i) => ({ color: i.palette.text.disabled }), "sx"), children: "·" }),
2522
+ /* @__PURE__ */ b(S, { component: "span", sx: /* @__PURE__ */ a((i) => ({ fontFamily: n.fontFamilyMono, color: i.palette.text.secondary }), "sx"), children: [
2523
+ e,
2524
+ " ",
2525
+ e === 1 ? "card" : "cards"
2526
+ ] })
2527
+ ] }), "ChipHead"), Ja = /* @__PURE__ */ a(({ cardCount: e, expanded: n, locked: i, onToggle: l, pulseTick: o = 0 }) => {
2528
+ const r = le(), g = ue(r), h = Yn(o);
2529
+ return /* @__PURE__ */ t(
2530
+ ce,
2531
+ {
2532
+ title: "O agente atualizou o sketch — clique em editar para ver",
2533
+ placement: "top-end",
2534
+ arrow: !0,
2535
+ slotProps: { popper: { modifiers: [{ name: "offset", options: { offset: [0, 5] } }] }, tooltip: { sx: { backgroundColor: g.raised, border: `1px solid ${r.palette.primary.dark}`, color: r.palette.primary.dark } } },
2536
+ open: h,
2537
+ disableHoverListener: !0,
2538
+ disableFocusListener: !0,
2539
+ disableTouchListener: !0,
2540
+ children: /* @__PURE__ */ b(re.div, { ...Jn(r, g, o), children: [
2541
+ /* @__PURE__ */ t(Xn, { cardCount: e, surfaces: g }),
2542
+ /* @__PURE__ */ t(ce, { title: n ? "Recolher sketch" : "Editar sketch", placement: "top", children: /* @__PURE__ */ t(
2543
+ S,
2544
+ {
2545
+ component: "button",
2546
+ onClick: l,
2547
+ disabled: i,
2548
+ sx: {
2549
+ background: g.raised,
2550
+ border: `1px solid ${r.palette.divider}`,
2551
+ color: r.palette.text.primary,
2552
+ fontFamily: r.typography.fontFamily,
2553
+ fontSize: 11.5,
2554
+ display: "inline-flex",
2555
+ alignItems: "center",
2556
+ gap: 0.625,
2557
+ pl: 1,
2558
+ pr: 1.25,
2559
+ py: 0.625,
2560
+ borderRadius: 999,
2561
+ cursor: i ? "not-allowed" : "pointer",
2562
+ opacity: i ? 0.45 : 1,
2563
+ transition: "background-color 2s, border-color 2s",
2564
+ "&:hover": i ? void 0 : { backgroundColor: g.hover, borderColor: r.palette.primary.main }
2565
+ },
2566
+ children: n ? /* @__PURE__ */ t(Le, { size: 13 }) : /* @__PURE__ */ t(oa, { sx: { fontSize: 14 } })
2567
+ }
2568
+ ) })
2569
+ ] }, o + i.toString())
2570
+ }
2571
+ );
2572
+ }, "SketchChip"), Xa = /* @__PURE__ */ a(({ cardCount: e, locked: n, onCreate: i, pulseTick: l = 0 }) => {
2573
+ const o = le(), r = ue(o), g = Yn(l), h = n || !i;
2574
+ return /* @__PURE__ */ t(
2575
+ ce,
2576
+ {
2577
+ title: "O agente atualizou o sketch — clique em editar para ver",
2578
+ placement: "top",
2579
+ slotProps: { popper: { modifiers: [{ name: "offset", options: { offset: [0, 5] } }] }, tooltip: { sx: { backgroundColor: r.raised, color: o.palette.primary.main } } },
2580
+ open: g,
2581
+ disableHoverListener: !0,
2582
+ disableFocusListener: !0,
2583
+ disableTouchListener: !0,
2584
+ children: /* @__PURE__ */ b(re.div, { ...Jn(o, r, l), children: [
2585
+ /* @__PURE__ */ t(Xn, { cardCount: e, surfaces: r }),
2586
+ /* @__PURE__ */ b(
2587
+ S,
2588
+ {
2589
+ component: "button",
2590
+ onClick: i,
2591
+ disabled: h,
2592
+ "data-env-id": "dashboard-pad-new",
2593
+ className: "llm-env-target llm-env-dashboard-action",
2594
+ sx: {
2595
+ background: r.raised,
2596
+ border: "none",
2597
+ color: o.palette.text.primary,
2598
+ fontFamily: o.typography.fontFamily,
2599
+ fontSize: 11.5,
2600
+ display: "inline-flex",
2601
+ alignItems: "center",
2602
+ gap: 0.625,
2603
+ pl: 1,
2604
+ pr: 1.25,
2605
+ py: 0.625,
2606
+ borderRadius: 999,
2607
+ cursor: h ? "not-allowed" : "pointer",
2608
+ opacity: h ? 0.45 : 1,
2609
+ transition: "background-color .12s, border-color .12s",
2610
+ "&:hover": h ? void 0 : { backgroundColor: r.hover, borderColor: o.palette.primary.main }
2611
+ },
2612
+ children: [
2613
+ /* @__PURE__ */ t(S, { sx: { color: o.palette.primary.main, display: "inline-flex", backgroundColor: o.palette.background.default, borderRadius: 999, p: 0.25, border: `1px solid ${r.borderSoft}` }, children: /* @__PURE__ */ t(yt, { size: 11 }) }),
2614
+ /* @__PURE__ */ t(S, { component: "span", sx: { fontWeight: 500 }, children: "Adicionar sketch" }),
2615
+ /* @__PURE__ */ t(S, { component: "span", sx: { color: o.palette.text.disabled, fontFamily: r.fontFamilyMono, fontSize: 10.5 }, children: "desenhe o layout antes de pedir" })
2616
+ ]
2617
+ }
2618
+ )
2619
+ ] }, l)
2620
+ }
2621
+ );
2622
+ }, "AddSketchChip"), Zn = wt(({ onCreateSketch: e, onBeforeSend: n, sketchExpanded: i, bottomSlot: l, zoomLevel: o, onSketchExpandedChange: r, seedDraft: g, compact: h, datasetControls: x, renderDescription: d }, v) => {
2623
+ const s = he(), [c, u] = N(g);
2624
+ q(() => {
2625
+ u(g);
2626
+ }, [g]);
2627
+ const p = ee(null), f = B((T) => T.agentPulseTick), y = B((T) => {
2628
+ var O;
2629
+ return ((O = T.dashboardDefinition) == null ? void 0 : O.id) ?? null;
2630
+ }), R = B((T) => {
2631
+ var O;
2632
+ return ((O = T.dashboardDefinition) == null ? void 0 : O.name) ?? "";
2633
+ }), H = B((T) => {
2634
+ var O, ae;
2635
+ return ((ae = (O = T.dashboardDefinition) == null ? void 0 : O.cards) == null ? void 0 : ae.length) ?? 0;
2636
+ }), L = B((T) => {
2637
+ var O, ae;
2638
+ return ((ae = (O = T.dashboardDefinition) == null ? void 0 : O.filters) == null ? void 0 : ae.length) ?? 0;
2639
+ }), P = B((T) => T.currentSessionId), _ = B((T) => {
2640
+ var O;
2641
+ return (O = T.dashboardDefinition) == null ? void 0 : O.filters;
2642
+ }) ?? qa, $ = B((T) => {
2643
+ var O;
2644
+ return ((O = T.dashboardDefinition) == null ? void 0 : O.layoutType) ?? "Boxed";
2645
+ }), V = B((T) => T.turnOpen), K = B((T) => {
2646
+ var O;
2647
+ return ((O = T.dashboardDefinition) == null ? void 0 : O.clientSideChanges) ?? null;
2648
+ }), M = B((T) => T.dashboardDefinition), w = B((T) => T.lastSentDashboard), [F, D] = N(!1), z = ve(() => {
2649
+ if (!M && !w) return { hasAny: !1, text: null };
2650
+ if (!M || !w) return { hasAny: !0, text: "Sketch alterado" };
2651
+ const T = Kt(M.cards ?? [], w.cards ?? []), O = Kt(M.filters ?? [], w.filters ?? []), ae = (M.name ?? "") !== (w.name ?? ""), fe = (M.layoutType ?? "Boxed") !== (w.layoutType ?? "Boxed");
2652
+ if (T.added + T.removed + T.modified + O.added + O.removed + O.modified === 0 && !ae && !fe) return { hasAny: !1, text: null };
2653
+ const pe = [];
2654
+ return T.added && pe.push(`+${T.added} ${T.added === 1 ? "card" : "cards"}`), T.removed && pe.push(`-${T.removed} ${T.removed === 1 ? "card" : "cards"}`), T.modified && pe.push(`${T.modified} ${T.modified === 1 ? "card alterado" : "cards alterados"}`), O.added && pe.push(`+${O.added} ${O.added === 1 ? "filtro" : "filtros"}`), O.removed && pe.push(`-${O.removed} ${O.removed === 1 ? "filtro" : "filtros"}`), O.modified && pe.push(`${O.modified} ${O.modified === 1 ? "filtro alterado" : "filtros alterados"}`), pe.length === 0 && pe.push("Sketch alterado"), { hasAny: !0, text: pe.join(" · ") };
2655
+ }, [M, w]), I = z.hasAny, U = z.text, J = !!y || H > 0 || L > 0, Q = /* @__PURE__ */ a(async (T) => {
2656
+ u(""), s.getState().commitForSend(), n && await n(T);
2657
+ }, "handleOnBefore"), ne = i ?? !1, de = /* @__PURE__ */ a((T) => r == null ? void 0 : r(T), "setSketchExpanded"), me = /* @__PURE__ */ a(() => {
2658
+ D(!0), setTimeout(() => D(!1), 1e3);
2659
+ }, "handleForceOpenCard"), ge = /* @__PURE__ */ a((T) => {
2660
+ const O = T.length === 0 ? "Untitled Dashboard" : T;
2661
+ s.getState().recordSketchChange("dashboard:name", `Renamed dashboard to '${O}'`), s.getState().updateDashboard({ name: O });
2662
+ }, "handleNameChange"), C = /* @__PURE__ */ a((T) => {
2663
+ s.getState().recordSketchChange("dashboard:layoutType", `Set layout type to ${T}`), s.getState().updateDashboard({ layoutType: T });
2664
+ }, "handleLayoutTypeChange"), A = /* @__PURE__ */ a(() => {
2665
+ var T;
2666
+ return (T = p.current) == null ? void 0 : T.addGenericCell();
2667
+ }, "handleAddGenericCard"), Y = /* @__PURE__ */ a((T, O) => {
2668
+ var ae;
2669
+ return (ae = p.current) == null ? void 0 : ae.addTypedCell(T, O, "");
2670
+ }, "handleAddTypedCard"), m = /* @__PURE__ */ a((T) => {
2671
+ var O;
2672
+ return (O = p.current) == null ? void 0 : O.handleAddFilter(T);
2673
+ }, "handleAddFilter"), k = /* @__PURE__ */ a((T) => {
2674
+ var ae;
2675
+ const O = ((ae = s.getState().dashboardDefinition) == null ? void 0 : ae.filters) ?? [];
2676
+ s.getState().recordSketchChange(`filter:${T.i}:edit`, `Edited filter '${T.name}'`), s.getState().updateDashboard({ filters: O.map((fe) => fe.i === T.i ? { ...T } : fe) });
2677
+ }, "handleEditFilter"), E = /* @__PURE__ */ a((T) => {
2678
+ var fe;
2679
+ const O = ((fe = s.getState().dashboardDefinition) == null ? void 0 : fe.filters) ?? [], ae = O.find((Se) => Se.i === T);
2680
+ s.getState().recordSketchChange(`filter:${T}:delete`, `Deleted filter '${(ae == null ? void 0 : ae.name) ?? T}'`), s.getState().updateDashboard({ filters: O.filter((Se) => Se.i !== T) });
2681
+ }, "handleDeleteFilter"), G = /* @__PURE__ */ b(S, { sx: { display: "flex", flexDirection: "column" }, children: [
2682
+ /* @__PURE__ */ b(tt, { mode: "wait", initial: !1, children: [
2683
+ !J && !ne && /* @__PURE__ */ t(re.div, { initial: { opacity: 0, height: 0 }, animate: { opacity: 1, height: "auto" }, exit: { opacity: 0, height: 0 }, transition: { duration: 0.18, ease: "easeOut" }, children: /* @__PURE__ */ t(S, { sx: { px: 1.25, py: 1, display: "flex", alignItems: "center" }, children: /* @__PURE__ */ t(Xa, { onCreate: e, locked: V, cardCount: H, pulseTick: f }) }) }, "add-sketch"),
2684
+ ne && /* @__PURE__ */ t(re.div, { style: { overflow: "hidden" }, initial: { opacity: 0, height: 0 }, animate: { opacity: 1, height: "auto" }, exit: { opacity: 0, height: 0 }, transition: { duration: 0.25, ease: "easeOut" }, children: /* @__PURE__ */ b(S, { sx: /* @__PURE__ */ a((T) => ({ flexShrink: 0, height: "min(50vh, 300px)", minHeight: 280, display: "flex", flexDirection: "row", overflow: "auto", background: T.palette.background.default }), "sx"), children: [
2685
+ /* @__PURE__ */ t(
2686
+ Ya,
2687
+ {
2688
+ locked: V,
2689
+ name: R,
2690
+ onNameChange: ge,
2691
+ layoutType: $,
2692
+ onLayoutTypeChange: C,
2693
+ onAddGenericCard: A,
2694
+ onAddTypedCard: Y,
2695
+ onAddFilter: m,
2696
+ cardsOpened: F,
2697
+ filters: _,
2698
+ onEditFilter: k,
2699
+ onDeleteFilter: E,
2700
+ datasetControls: x
2701
+ }
2702
+ ),
2703
+ /* @__PURE__ */ t(S, { sx: { flex: 1, pt: 1, minWidth: 0, display: "flex", flexDirection: "column" }, children: /* @__PURE__ */ t(ot, { ref: p, zoomLevel: o, onAddCard: me, renderId: "composer-pad", hideInternalHeader: !0, hideFiltersInSketch: !0, renderDescription: d }) })
2704
+ ] }) }, "sketch-expanded")
2705
+ ] }),
2706
+ J && /* @__PURE__ */ t(
2707
+ re.div,
2708
+ {
2709
+ initial: { opacity: ne ? 0 : 1, height: 0, display: ne ? "flex" : "none" },
2710
+ animate: { opacity: ne ? 0 : 1, height: "auto", display: ne ? "none" : "flex" },
2711
+ exit: { opacity: J ? 1 : 0, height: 0, display: "flex" },
2712
+ transition: { duration: 0.5, ease: "easeInOut" },
2713
+ children: /* @__PURE__ */ b(S, { sx: { display: "flex", alignItems: "center", gap: 1, px: 1.25, py: 0.875 }, children: [
2714
+ /* @__PURE__ */ t(Ja, { cardCount: H, expanded: ne, locked: V, onToggle: /* @__PURE__ */ a(() => de(!ne), "onToggle"), pulseTick: f }),
2715
+ /* @__PURE__ */ t(X, { sx: /* @__PURE__ */ a((T) => ({ color: T.palette.text.primary, fontWeight: 500, fontSize: 11.5, lineHeight: 1.2, whiteSpace: "nowrap", overflow: "hidden", textOverflow: "ellipsis" }), "sx"), children: R })
2716
+ ] })
2717
+ },
2718
+ "filled-sketch"
2719
+ )
2720
+ ] }), Z = ve(() => {
2721
+ const T = "Será enviado junto com a mensagem", O = kt(K ?? void 0);
2722
+ return O ? `${T}:
2723
+
2724
+ ${O}` : T;
2725
+ }, [K]);
2726
+ return /* @__PURE__ */ t(
2727
+ Yi,
2728
+ {
2729
+ ref: v,
2730
+ seedDraft: c,
2731
+ showLastPrompts: !1,
2732
+ topSlot: G,
2733
+ topSlotCollapsible: J || ne,
2734
+ topSlotExpanded: ne,
2735
+ onTopSlotExpandedChange: de,
2736
+ onBeforeSend: Q,
2737
+ sendButtonProps: { "data-env-id": "dashboard-pad-compose", className: "llm-env-target llm-env-dashboard-action" },
2738
+ allowEmptyDraft: I,
2739
+ submitAdornment: U ? /* @__PURE__ */ t(ce, { placement: "top", title: Z, slotProps: { tooltip: { sx: { whiteSpace: "pre-line", maxWidth: 360, fontSize: 11.5, lineHeight: 1.4, fontFamily: /* @__PURE__ */ a((T) => T.typography.fontFamily, "fontFamily") } } }, children: /* @__PURE__ */ t(S, { sx: /* @__PURE__ */ a((T) => ({ display: "inline-flex", alignItems: "center", gap: 0.5, px: 0.875, py: 0.25, mr: 0.75, borderRadius: 999, border: `1px solid ${T.palette.primary.dark}`, color: T.palette.primary.main, fontFamily: T.typography.fontFamily, fontSize: 10.5, lineHeight: 1.2, whiteSpace: "nowrap", pointerEvents: "auto" }), "sx"), children: U }) }) : null,
2740
+ inputMinHeight: ne || h ? 40 : 120
2741
+ },
2742
+ P ?? "no-session"
2743
+ );
2744
+ });
2745
+ Zn.displayName = "DrawablePrompt";
2746
+ const Qn = He.memo(Zn), ei = [
2747
+ {
2748
+ label: "Compare vendas e reservas por semana, focando em rotas internacionais",
2749
+ prompt: "Crie uma sugestão de dashboard de vendas e reservas por semana, focando em rotas nacionais. Envie um rascunho pronto para carregar na minha interface."
2750
+ },
2751
+ {
2752
+ label: "Me ajude a entender como o Dashboard Composer funciona",
2753
+ prompt: "Me ajude a entender como o Dashboard Composer funciona. Apresente os tipos de gráficos e depois envie um guia ao vivo, do passo a passo da interface"
2754
+ }
2755
+ ];
2756
+ function Za({ kinds: e, accent: n }) {
2757
+ const i = le(), l = ue(i), o = n ? i.palette.primary.main : i.palette.text.disabled;
2758
+ return e.length === 0 ? /* @__PURE__ */ t(S, { sx: { width: "100%", height: 56, display: "grid", gridTemplateColumns: "repeat(3, 1fr)", gap: 0.375 }, children: Array.from({ length: 6 }).map((r, g) => /* @__PURE__ */ t(S, { sx: { background: i.palette.background.default, border: `1px dashed ${l.borderSoft}`, borderRadius: 0.5 } }, g)) }) : /* @__PURE__ */ t(S, { sx: { width: "100%", height: 56, display: "grid", gridTemplateColumns: "repeat(3, 1fr)", gap: 0.375 }, children: e.slice(0, 6).map((r, g) => /* @__PURE__ */ b(
2759
+ S,
2760
+ {
2761
+ sx: {
2762
+ background: i.palette.background.default,
2763
+ border: `1px solid ${n ? i.palette.primary.main : l.borderSoft}`,
2764
+ borderRadius: 0.5,
2765
+ p: 0.5,
2766
+ display: "flex",
2767
+ alignItems: "center",
2768
+ justifyContent: "center",
2769
+ color: o
2770
+ },
2771
+ children: [
2772
+ r === "kpi" && /* @__PURE__ */ t(S, { sx: { fontSize: 8, fontWeight: 600 }, children: "R$ ··" }),
2773
+ r === "line" && /* @__PURE__ */ t("svg", { width: "100%", height: "14", viewBox: "0 0 40 14", preserveAspectRatio: "none", children: /* @__PURE__ */ t("path", { d: "M0 11 L8 7 L16 9 L24 4 L32 6 L40 2", stroke: o, strokeWidth: "1", fill: "none" }) }),
2774
+ r === "bars" && /* @__PURE__ */ t("svg", { width: "100%", height: "14", viewBox: "0 0 40 14", preserveAspectRatio: "none", children: [3, 7, 5, 9, 6, 11, 8, 12].map((h, x) => /* @__PURE__ */ t("rect", { x: x * 5 + 0.5, y: 14 - h, width: 3.5, height: h, fill: o }, x)) }),
2775
+ r === "table" && /* @__PURE__ */ t(S, { sx: { width: "90%", display: "flex", flexDirection: "column", gap: "1px" }, children: [0, 1, 2].map((h) => /* @__PURE__ */ t(S, { sx: { height: 1.5, background: o, borderRadius: "0.5px" } }, h)) }),
2776
+ r === "donut" && /* @__PURE__ */ t("svg", { width: "14", height: "14", viewBox: "0 0 14 14", children: /* @__PURE__ */ t("circle", { cx: "7", cy: "7", r: "5", stroke: o, strokeWidth: "2", fill: "none", strokeDasharray: "20 30" }) }),
2777
+ r === "heatmap" && /* @__PURE__ */ t(S, { sx: { display: "grid", gridTemplateColumns: "repeat(4, 1fr)", gap: "0.5px", width: "70%" }, children: Array.from({ length: 8 }).map((h, x) => /* @__PURE__ */ t(S, { sx: { aspectRatio: "1", background: o, opacity: 0.2 + x / 8 * 0.7 } }, x)) })
2778
+ ]
2779
+ },
2780
+ `Template${g}`
2781
+ )) });
2782
+ }
2783
+ a(Za, "TemplatePreview");
2784
+ function Qa(e) {
2785
+ if (!e) return "";
2786
+ const n = Date.now() - e, i = 6e4, l = 60 * i, o = 24 * l;
2787
+ return n < i ? "agora" : n < l ? `${Math.floor(n / i)}m` : n < o ? `${Math.floor(n / l)}h` : n < 7 * o ? `${Math.floor(n / o)}d` : `${Math.floor(n / (7 * o))}sem`;
2788
+ }
2789
+ a(Qa, "formatRelativeTime");
2790
+ const _t = /* @__PURE__ */ a(({
2791
+ onDraftPromptChange: e,
2792
+ onApplyTemplate: n,
2793
+ composerSlot: i,
2794
+ ambientWrapper: l,
2795
+ recentSessions: o,
2796
+ onSelectSession: r,
2797
+ onSearchAllSessions: g,
2798
+ suggestions: h = ei,
2799
+ templates: x = Mt
2800
+ }) => {
2801
+ const d = le(), v = ue(d), s = l ?? ((p) => p), c = {
2802
+ background: "transparent",
2803
+ border: "none",
2804
+ textAlign: "left",
2805
+ padding: "6px 0",
2806
+ color: d.palette.text.secondary,
2807
+ fontFamily: d.typography.fontFamily,
2808
+ fontSize: 13,
2809
+ cursor: "pointer",
2810
+ display: "flex",
2811
+ alignItems: "center",
2812
+ gap: 1,
2813
+ "&:hover": { color: d.palette.text.primary }
2814
+ }, u = { fontSize: 11, color: d.palette.text.disabled, textTransform: "uppercase", letterSpacing: 0.5, mb: 1 };
2815
+ return /* @__PURE__ */ b(S, { sx: { flex: 1, minHeight: 0, overflow: "auto", display: "flex", flexDirection: "column", gap: 3.5, padding: { xs: 3, md: "40px 56px" }, background: d.palette.background.default }, children: [
2816
+ s(
2817
+ /* @__PURE__ */ b(S, { children: [
2818
+ /* @__PURE__ */ t(X, { sx: { fontSize: 11, color: d.palette.primary.main, textTransform: "uppercase", letterSpacing: 0.8, mb: 1, fontWeight: 500 }, children: "Novo dashboard" }),
2819
+ /* @__PURE__ */ b(X, { component: "h1", sx: { fontSize: 30, fontWeight: 600, color: d.palette.text.primary, margin: 0, lineHeight: 1.2, letterSpacing: -0.4 }, children: [
2820
+ "Descreva o que você quer, peça ajuda",
2821
+ " ",
2822
+ /* @__PURE__ */ t(S, { component: "span", sx: { color: d.palette.text.disabled }, children: "ou comece de um template." })
2823
+ ] })
2824
+ ] }),
2825
+ "hero"
2826
+ ),
2827
+ i,
2828
+ s(
2829
+ /* @__PURE__ */ b(S, { sx: { display: "grid", gridTemplateColumns: { xs: "1fr", md: "1fr 1fr" }, gap: { xs: 3, md: 5 } }, children: [
2830
+ /* @__PURE__ */ b(S, { children: [
2831
+ /* @__PURE__ */ t(X, { sx: u, children: "Sugestões" }),
2832
+ /* @__PURE__ */ t(S, { sx: { display: "flex", flexDirection: "column", gap: 0.25 }, children: h.map((p) => /* @__PURE__ */ b(S, { component: "button", onClick: /* @__PURE__ */ a(() => e(p.prompt), "onClick"), sx: c, children: [
2833
+ /* @__PURE__ */ t(S, { component: "span", sx: { color: d.palette.text.disabled }, children: "↗" }),
2834
+ /* @__PURE__ */ t("span", { children: p.label })
2835
+ ] }, p.label)) })
2836
+ ] }),
2837
+ /* @__PURE__ */ b(S, { children: [
2838
+ /* @__PURE__ */ t(X, { sx: u, children: "Sessões recentes" }),
2839
+ !o || o.length === 0 ? /* @__PURE__ */ t(X, { sx: { fontSize: 12, color: d.palette.text.disabled, fontStyle: "italic", py: 0.5 }, children: "Você ainda não tem sessões salvas. Crie um novo dashboard acima." }) : /* @__PURE__ */ b(S, { sx: { display: "flex", flexDirection: "column", gap: 0.25 }, children: [
2840
+ o.map((p, f) => /* @__PURE__ */ b(
2841
+ S,
2842
+ {
2843
+ component: "button",
2844
+ onClick: /* @__PURE__ */ a(() => r == null ? void 0 : r(p.sessionId), "onClick"),
2845
+ disabled: !r,
2846
+ sx: { ...c, minWidth: 0, cursor: r ? "pointer" : "default", "&:hover": r ? c["&:hover"] : void 0 },
2847
+ children: [
2848
+ /* @__PURE__ */ t(S, { component: "span", sx: { color: d.palette.text.disabled, flexShrink: 0 }, children: "↺" }),
2849
+ /* @__PURE__ */ t(S, { component: "span", sx: { flex: 1, minWidth: 0, overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" }, children: p.name }),
2850
+ /* @__PURE__ */ b(S, { component: "span", sx: { color: d.palette.text.disabled, fontFamily: v.fontFamilyMono, fontSize: 11, flexShrink: 0 }, children: [
2851
+ p.cardCount,
2852
+ " ",
2853
+ p.cardCount === 1 ? "card" : "cards",
2854
+ p.updatedAt ? ` · ${Qa(p.updatedAt)}` : ""
2855
+ ] })
2856
+ ]
2857
+ },
2858
+ p.sessionId + f
2859
+ )),
2860
+ g && /* @__PURE__ */ b(S, { component: "button", onClick: g, sx: { ...c, color: d.palette.primary.main, fontSize: 12.5, mt: 0.5, "&:hover": { filter: "brightness(1.1)" } }, children: [
2861
+ /* @__PURE__ */ t(S, { component: "span", sx: { color: d.palette.text.disabled }, children: "⌕" }),
2862
+ /* @__PURE__ */ t("span", { children: "Buscar todas as sessões" })
2863
+ ] })
2864
+ ] })
2865
+ ] })
2866
+ ] }),
2867
+ "suggestions"
2868
+ ),
2869
+ s(
2870
+ /* @__PURE__ */ b(S, { children: [
2871
+ /* @__PURE__ */ b(S, { sx: { display: "flex", alignItems: "center", gap: 1, mb: 1.25, fontSize: 11, color: d.palette.text.disabled, textTransform: "uppercase", letterSpacing: 0.5 }, children: [
2872
+ /* @__PURE__ */ t("span", { children: "ou comece de um template" }),
2873
+ /* @__PURE__ */ t(S, { sx: { flex: 1, height: "1px", background: v.borderSoft } })
2874
+ ] }),
2875
+ /* @__PURE__ */ t(S, { sx: { display: "grid", gridTemplateColumns: { xs: "1fr 1fr", md: "repeat(4, 1fr)" }, gap: 1.25 }, children: x.map((p) => /* @__PURE__ */ b(
2876
+ S,
2877
+ {
2878
+ component: "button",
2879
+ onClick: /* @__PURE__ */ a(() => n(p), "onClick"),
2880
+ sx: {
2881
+ background: d.palette.background.paper,
2882
+ border: `1px solid ${d.palette.divider}`,
2883
+ borderRadius: 1.25,
2884
+ padding: 1.5,
2885
+ cursor: "pointer",
2886
+ textAlign: "left",
2887
+ fontFamily: d.typography.fontFamily,
2888
+ display: "flex",
2889
+ flexDirection: "column",
2890
+ gap: 1,
2891
+ transition: "border-color .15s, transform .15s",
2892
+ "&:hover": { borderColor: d.palette.primary.main, transform: "translateY(-1px)" }
2893
+ },
2894
+ children: [
2895
+ /* @__PURE__ */ t(Za, { kinds: Vn(p), accent: p.recommended }),
2896
+ /* @__PURE__ */ b(S, { children: [
2897
+ /* @__PURE__ */ t(X, { sx: { fontSize: 12.5, color: d.palette.text.primary, fontWeight: 500 }, children: p.name }),
2898
+ /* @__PURE__ */ t(X, { sx: { fontSize: 10.5, color: d.palette.text.secondary, mt: 0.25, lineHeight: 1.4 }, children: p.desc }),
2899
+ /* @__PURE__ */ t(X, { sx: { fontSize: 10, color: d.palette.text.disabled, fontFamily: v.fontFamilyMono, mt: 0.5 }, children: p.cells.length === 0 ? "em branco" : `${p.cells.length} cards` })
2900
+ ] })
2901
+ ]
2902
+ },
2903
+ p.id
2904
+ )) })
2905
+ ] }),
2906
+ "templates"
2907
+ )
2908
+ ] });
2909
+ }, "EntryEmptyState");
2910
+ _t.displayName = "EntryEmptyState";
2911
+ const oe = 6, Re = 12, Yt = 320, eo = 220, Jt = 150, Xt = 3e3;
2912
+ function to(e, n, i, l) {
2913
+ const o = window.innerWidth, r = window.innerHeight, g = e && e !== "auto" ? [e] : ["bottom", "top", "right", "left"];
2914
+ for (const h of g) {
2915
+ let x = 0, d = 0;
2916
+ switch (h) {
2917
+ case "bottom":
2918
+ x = n.top + n.height + oe + Re, d = n.left + n.width / 2 - i / 2;
2919
+ break;
2920
+ case "top":
2921
+ x = n.top - oe - Re - l, d = n.left + n.width / 2 - i / 2;
2922
+ break;
2923
+ case "right":
2924
+ x = n.top + n.height / 2 - l / 2, d = n.left + n.width + oe + Re;
2925
+ break;
2926
+ case "left":
2927
+ x = n.top + n.height / 2 - l / 2, d = n.left - oe - Re - i;
2928
+ break;
2929
+ }
2930
+ if (d = Math.max(8, Math.min(d, o - i - 8)), x = Math.max(8, Math.min(x, r - l - 8)), x >= 0 && x + l <= r && d >= 0 && d + i <= o || h === g[g.length - 1]) return { top: x, left: d, resolvedPlacement: h };
2931
+ }
2932
+ return { top: n.top + n.height + Re, left: n.left, resolvedPlacement: "bottom" };
2933
+ }
2934
+ a(to, "computePlacement");
2935
+ const ti = /* @__PURE__ */ a(({ steps: e, overlayOpacity: n = 0.6, allowInteraction: i = !1, onComplete: l, onDismiss: o, resolveElement: r = Ot }) => {
2936
+ const g = le(), h = ue(g), [x, d] = N(0), [v, s] = N(null), [c, u] = N({ width: Yt, height: 120 }), p = ee(null), f = ee(0), y = e[x], R = x === 0, H = x === e.length - 1, L = W(() => {
2937
+ var w;
2938
+ if (!y) return;
2939
+ const M = r(y.target);
2940
+ if (M) {
2941
+ const F = M.getBoundingClientRect();
2942
+ s({ top: F.top, left: F.left, width: F.width, height: F.height }), (w = M.scrollIntoView) == null || w.call(M, { behavior: "smooth", block: "nearest", inline: "nearest" });
2943
+ } else
2944
+ s(null);
2945
+ }, [y, r]);
2946
+ q(() => {
2947
+ if (!y) return;
2948
+ let M = !1, w = 0, F;
2949
+ const D = /* @__PURE__ */ a(() => {
2950
+ console.warn(`[@aintela/bi SpotlightOverlay] Step ${x + 1}/${e.length} could not resolve its target within ${Xt} ms; skipping.`, { target: y.target, title: y.title }), x < e.length - 1 ? d((U) => U + 1) : (console.warn("[@aintela/bi SpotlightOverlay] All steps failed to resolve; dismissing tour."), o());
2951
+ }, "giveUpOnStep"), z = /* @__PURE__ */ a(() => {
2952
+ var J;
2953
+ if (M) return;
2954
+ const U = r(y.target);
2955
+ if (U) {
2956
+ const Q = U.getBoundingClientRect();
2957
+ if (Q.width > 0 && Q.height > 0) {
2958
+ s({ top: Q.top, left: Q.left, width: Q.width, height: Q.height }), (J = U.scrollIntoView) == null || J.call(U, { behavior: "smooth", block: "nearest", inline: "nearest" });
2959
+ return;
2960
+ }
2961
+ }
2962
+ if (w += Jt, w >= Xt) {
2963
+ D();
2964
+ return;
2965
+ }
2966
+ F = window.setTimeout(z, Jt);
2967
+ }, "attempt");
2968
+ z();
2969
+ const I = /* @__PURE__ */ a(() => {
2970
+ cancelAnimationFrame(f.current), f.current = requestAnimationFrame(L);
2971
+ }, "onScroll");
2972
+ return window.addEventListener("scroll", I, !0), window.addEventListener("resize", I), () => {
2973
+ M = !0, F !== void 0 && window.clearTimeout(F), window.removeEventListener("scroll", I, !0), window.removeEventListener("resize", I), cancelAnimationFrame(f.current);
2974
+ };
2975
+ }, [y, r, o, L, x, e.length]), q(() => {
2976
+ if (p.current) {
2977
+ const { offsetWidth: M, offsetHeight: w } = p.current;
2978
+ u({ width: M, height: w });
2979
+ }
2980
+ }, [x, v]);
2981
+ const P = W(() => {
2982
+ H ? (l == null || l(), o()) : d((M) => M + 1);
2983
+ }, [H, l, o]), _ = W(() => {
2984
+ R || d((M) => M - 1);
2985
+ }, [R]);
2986
+ if (q(() => {
2987
+ const M = /* @__PURE__ */ a((w) => {
2988
+ w.key === "Escape" ? o() : w.key === "ArrowRight" || w.key === "Enter" ? P() : w.key === "ArrowLeft" && _();
2989
+ }, "onKey");
2990
+ return window.addEventListener("keydown", M), () => window.removeEventListener("keydown", M);
2991
+ }, [o, P, _]), !y || typeof document > "u") return null;
2992
+ const $ = v ? `polygon(
2993
+ 0% 0%, 0% 100%, 100% 100%, 100% 0%, 0% 0%,
2994
+ ${v.left - oe}px ${v.top - oe}px,
2995
+ ${v.left + v.width + oe}px ${v.top - oe}px,
2996
+ ${v.left + v.width + oe}px ${v.top + v.height + oe}px,
2997
+ ${v.left - oe}px ${v.top + v.height + oe}px,
2998
+ ${v.left - oe}px ${v.top - oe}px
2999
+ )` : void 0, V = v ? to(y.placement, v, c.width, c.height) : null, K = {
3000
+ fontFamily: g.typography.fontFamily,
3001
+ fontSize: 11.5,
3002
+ fontWeight: 500,
3003
+ px: 1.25,
3004
+ py: 0.625,
3005
+ borderRadius: 1,
3006
+ cursor: "pointer",
3007
+ transition: "filter .12s, background-color .12s, border-color .12s",
3008
+ border: "1px solid transparent"
3009
+ };
3010
+ return ra(
3011
+ /* @__PURE__ */ b(S, { className: "llm-guide-overlay-root", sx: { position: "fixed", inset: 0, zIndex: 9999 }, children: [
3012
+ v && /* @__PURE__ */ t(
3013
+ S,
3014
+ {
3015
+ onClick: i ? o : void 0,
3016
+ sx: {
3017
+ position: "absolute",
3018
+ inset: 0,
3019
+ backgroundColor: Ce(g.palette.common.black, n),
3020
+ clipPath: $,
3021
+ transition: "clip-path 0.3s ease",
3022
+ pointerEvents: i ? "none" : "auto"
3023
+ }
3024
+ }
3025
+ ),
3026
+ v && /* @__PURE__ */ t(
3027
+ S,
3028
+ {
3029
+ className: "llm-guide-spotlight-ring",
3030
+ sx: {
3031
+ position: "absolute",
3032
+ top: v.top - oe,
3033
+ left: v.left - oe,
3034
+ width: v.width + oe * 2,
3035
+ height: v.height + oe * 2,
3036
+ borderRadius: "6px",
3037
+ border: `2px solid ${g.palette.primary.main}`,
3038
+ boxShadow: `0 0 0 4px ${Ce(g.palette.primary.main, 0.2)}, 0 8px 24px ${Ce(g.palette.primary.main, 0.13)}`,
3039
+ transition: "all 0.3s ease",
3040
+ pointerEvents: "none"
3041
+ }
3042
+ }
3043
+ ),
3044
+ V && /* @__PURE__ */ b(
3045
+ S,
3046
+ {
3047
+ ref: p,
3048
+ sx: {
3049
+ position: "absolute",
3050
+ top: V.top,
3051
+ left: V.left,
3052
+ maxWidth: Yt,
3053
+ minWidth: eo,
3054
+ p: 2,
3055
+ borderRadius: 1.5,
3056
+ backgroundColor: g.palette.background.paper,
3057
+ border: `1px solid ${g.palette.divider}`,
3058
+ boxShadow: g.shadows[8],
3059
+ transition: "top 0.3s ease, left 0.3s ease",
3060
+ pointerEvents: "auto",
3061
+ display: "flex",
3062
+ flexDirection: "column",
3063
+ gap: 1.25,
3064
+ fontFamily: g.typography.fontFamily
3065
+ },
3066
+ children: [
3067
+ /* @__PURE__ */ b(S, { sx: { display: "flex", justifyContent: "space-between", alignItems: "flex-start", gap: 1 }, children: [
3068
+ /* @__PURE__ */ b(S, { sx: { flex: 1, minWidth: 0 }, children: [
3069
+ /* @__PURE__ */ b(X, { sx: { fontSize: 10, color: g.palette.primary.main, textTransform: "uppercase", letterSpacing: 0.6, fontWeight: 500, mb: y.title ? 0.5 : 0 }, children: [
3070
+ "Guia · ",
3071
+ x + 1,
3072
+ " / ",
3073
+ e.length
3074
+ ] }),
3075
+ y.title && /* @__PURE__ */ t(X, { sx: { fontSize: 13.5, fontWeight: 600, color: g.palette.text.primary, lineHeight: 1.3, mb: 0.5 }, children: y.title }),
3076
+ /* @__PURE__ */ t(X, { sx: { fontSize: 12.5, color: g.palette.text.secondary, lineHeight: 1.5 }, children: y.description })
3077
+ ] }),
3078
+ /* @__PURE__ */ t(S, { component: "button", onClick: o, "aria-label": "Fechar guia", sx: { ...K, background: "transparent", border: "none", color: g.palette.text.disabled, p: 0.5, display: "inline-flex", "&:hover": { color: g.palette.text.primary } }, children: /* @__PURE__ */ t(Dt, { size: 12 }) })
3079
+ ] }),
3080
+ /* @__PURE__ */ b(S, { sx: { display: "flex", justifyContent: "flex-end", alignItems: "center", gap: 0.75 }, children: [
3081
+ !R && /* @__PURE__ */ t(S, { component: "button", onClick: _, sx: { ...K, background: "transparent", color: g.palette.text.secondary, "&:hover": { color: g.palette.text.primary, backgroundColor: h.raised } }, children: "Anterior" }),
3082
+ /* @__PURE__ */ t(S, { component: "button", onClick: P, sx: { ...K, background: g.palette.primary.main, color: g.palette.primary.contrastText, fontWeight: 600, "&:hover": { filter: "brightness(1.05)" } }, children: H ? "Concluir" : "Próximo" })
3083
+ ] })
3084
+ ]
3085
+ }
3086
+ )
3087
+ ] }),
3088
+ document.body
3089
+ );
3090
+ }, "SpotlightOverlay"), no = "aintela-bi-composer", io = 2, ao = /* @__PURE__ */ a((e) => {
3091
+ var ge;
3092
+ const { sessionId: n = null, routeSessionId: i, composerMode: l, onForceExecutionMode: o, recentSessionsResolved: r } = e, g = le(), h = ue(g), x = he(), d = et(), v = B((C) => {
3093
+ var A;
3094
+ return ((A = C.dashboardDefinition) == null ? void 0 : A.jsFileName) ?? null;
3095
+ }), s = B((C) => {
3096
+ var A;
3097
+ return ((A = C.dashboardDefinition) == null ? void 0 : A.name) ?? null;
3098
+ }), c = B((C) => C.turnOpen), u = B((C) => C.sketchExpanded), p = W((C) => x.getState().setSketchExpanded(C), [x]), [f, y] = N(""), [R, H] = N(void 0), [L, P] = N(!1), [_, $] = N(!1), V = v !== null, K = ee(null);
3099
+ q(() => {
3100
+ var A;
3101
+ const C = s == null ? void 0 : s.trim();
3102
+ return (A = e.onDashboardNameChange) == null || A.call(e, C || null), () => {
3103
+ var Y;
3104
+ return (Y = e.onDashboardNameChange) == null ? void 0 : Y.call(e, null);
3105
+ };
3106
+ }, [s]), q(() => {
3107
+ x.getState().currentSessionId !== n && x.getState().setCurrentSessionId(n);
3108
+ }, [n, x]), q(() => {
3109
+ c && $(!1);
3110
+ }, [c]), q(() => {
3111
+ (v || void 0) !== R && $(!0), H(v ?? void 0);
3112
+ }, [v]), q(() => {
3113
+ var m;
3114
+ const C = x.getState().dashboardDefinition, A = (C == null ? void 0 : C.originalSessionId) ?? null;
3115
+ if (A && A !== (i ?? null) && (x.getState().updateDashboard(void 0), K.current = null), !i && A && (x.getState().updateDashboard(void 0), K.current = null), !i || !d || K.current === i) return;
3116
+ if ((m = x.getState().dashboardDefinition) != null && m.id) {
3117
+ K.current = i;
3118
+ return;
3119
+ }
3120
+ let Y = !1;
3121
+ return (async () => {
3122
+ var k;
3123
+ try {
3124
+ const E = await d.getDashboardBySession(i);
3125
+ if (Y) return;
3126
+ if ((k = x.getState().dashboardDefinition) != null && k.id) {
3127
+ K.current = i;
3128
+ return;
3129
+ }
3130
+ if (!E) {
3131
+ console.warn("[@aintela/bi composer] no dashboard found for session", i), K.current = i;
3132
+ return;
3133
+ }
3134
+ x.getState().loadDashboard(Be(E)), K.current = i;
3135
+ } catch (E) {
3136
+ console.error("[@aintela/bi composer] failed to load dashboard for session", E);
3137
+ }
3138
+ })(), () => {
3139
+ Y = !0;
3140
+ };
3141
+ }, [i, d, x]);
3142
+ const M = W(
3143
+ async (C) => {
3144
+ var m, k, E, G;
3145
+ const A = n;
3146
+ let Y = x.getState().dashboardDefinition;
3147
+ if (Y != null && Y.id && Y.originalSessionId && Y.originalSessionId !== A && Y.originalSessionId !== i && (x.getState().updateDashboard(void 0), Y = x.getState().dashboardDefinition), Y != null && Y.id) {
3148
+ C && x.getState().updateDashboard({
3149
+ originalSessionId: i !== x.getState().currentSessionId ? x.getState().currentSessionId : Y.originalSessionId,
3150
+ ...C.name !== void 0 && { name: C.name },
3151
+ ...C.cards !== void 0 && { cards: C.cards },
3152
+ ...C.filters !== void 0 && { filters: C.filters }
3153
+ });
3154
+ return;
3155
+ }
3156
+ if (!A || !d) {
3157
+ C ? (x.getState().updateDashboard({ name: C.name ?? "Untitled Dashboard", cards: C.cards ?? [], filters: C.filters ?? [] }), p(!0)) : (x.getState().updateDashboard({ name: "Untitled Dashboard", cards: [], filters: [] }), p(!0));
3158
+ return;
3159
+ }
3160
+ try {
3161
+ const Z = !C && Y && ((((m = Y.cards) == null ? void 0 : m.length) ?? 0) > 0 || (((k = Y.filters) == null ? void 0 : k.length) ?? 0) > 0) ? { name: Y.name, cards: Y.cards, filters: Y.filters, layoutType: Y.layoutType } : void 0, te = C ?? Z;
3162
+ te && !te.layoutType && (te.layoutType = "Naked");
3163
+ const T = await Pt(d, A, te), O = x.getState().dashboardDefinition;
3164
+ x.getState().updateDashboard({
3165
+ ...T,
3166
+ name: (te == null ? void 0 : te.name) ?? (O == null ? void 0 : O.name) ?? T.name,
3167
+ cards: (te == null ? void 0 : te.cards) ?? ((E = O == null ? void 0 : O.cards) != null && E.length ? O.cards : T.cards),
3168
+ filters: (te == null ? void 0 : te.filters) ?? ((G = O == null ? void 0 : O.filters) != null && G.length ? O.filters : T.filters)
3169
+ }), p(!0);
3170
+ } catch (Z) {
3171
+ console.error("[@aintela/bi composer] createDraft failed", Z);
3172
+ }
3173
+ },
3174
+ [d, n, i, p, x]
3175
+ ), w = W(() => {
3176
+ p(!0), M();
3177
+ }, [M, p]), F = W(async (C) => {
3178
+ var A;
3179
+ await M(), await ((A = e.onBeforeSend) == null ? void 0 : A.call(e, C));
3180
+ }, [M, e.onBeforeSend]), D = W((C) => {
3181
+ if (C.cells.length === 0) {
3182
+ o();
3183
+ return;
3184
+ }
3185
+ M({ name: C.name, cards: jn(C), filters: [] });
3186
+ }, [M, o]), { setScroller: z } = Un(), I = ee(null);
3187
+ q(() => {
3188
+ const C = I.current;
3189
+ if (!C) {
3190
+ z(null);
3191
+ return;
3192
+ }
3193
+ const A = /* @__PURE__ */ a(() => [C, ...Array.from(C.querySelectorAll("*"))].reverse().find((E) => E.scrollHeight > E.clientHeight + 8 && /auto|scroll/.test(getComputedStyle(E).overflowY)) ?? null, "find"), Y = A();
3194
+ if (Y) {
3195
+ z(Y);
3196
+ return;
3197
+ }
3198
+ if (typeof ResizeObserver > "u") return;
3199
+ const m = new ResizeObserver(() => {
3200
+ const k = A();
3201
+ k && (z(k), m.disconnect());
3202
+ });
3203
+ return m.observe(C), () => m.disconnect();
3204
+ }, [l, z]);
3205
+ const U = ia(), J = U ? Hn : Fn, Q = U ? Ln : Nn, ne = U ? Gn : Bn, de = W(
3206
+ (C, A) => /* @__PURE__ */ t(re.div, { variants: J, initial: "hidden", animate: "visible", exit: "hidden", children: C }, A),
3207
+ [J]
3208
+ ), me = /* @__PURE__ */ a(() => /* @__PURE__ */ t(re.div, { layoutId: no, transition: ne, style: { display: "flex", flexDirection: "column" }, children: /* @__PURE__ */ t(
3209
+ Qn,
3210
+ {
3211
+ onCreateSketch: w,
3212
+ onBeforeSend: F,
3213
+ sketchExpanded: u,
3214
+ onSketchExpandedChange: p,
3215
+ seedDraft: f,
3216
+ zoomLevel: V ? 0.8 : 0.95,
3217
+ compact: l !== "empty",
3218
+ bottomSlot: l === "empty" ? e.progressStrip : void 0,
3219
+ datasetControls: e.datasetControls,
3220
+ renderDescription: e.renderDescription
3221
+ }
3222
+ ) }), "renderPromptForBranch");
3223
+ return /* @__PURE__ */ t(tt, { mode: "popLayout", initial: !1, children: l === "empty" ? /* @__PURE__ */ t(re.div, { initial: { opacity: 1 }, animate: { opacity: 1 }, exit: { opacity: 0 }, transition: { duration: 0.2, ease: "easeOut" }, style: { flex: 1, minHeight: 0, display: "flex", flexDirection: "column" }, children: /* @__PURE__ */ t(
3224
+ _t,
3225
+ {
3226
+ onDraftPromptChange: y,
3227
+ onApplyTemplate: D,
3228
+ composerSlot: me(),
3229
+ ambientWrapper: de,
3230
+ recentSessions: r,
3231
+ onSelectSession: e.onSelectSession,
3232
+ onSearchAllSessions: e.onSearchAllSessions,
3233
+ suggestions: e.suggestions,
3234
+ templates: e.templates
3235
+ }
3236
+ ) }, "empty-layout") : /* @__PURE__ */ t(re.div, { initial: { opacity: 0 }, animate: { opacity: 1 }, exit: { opacity: 0 }, transition: { duration: 0.2, ease: "easeOut" }, style: { minHeight: 0, width: "100%", height: "100%", display: "flex", background: g.palette.background.default }, children: /* @__PURE__ */ b(Bt, { direction: "row", sx: { display: "inline-flex", width: "100%", height: "100%", flexWrap: "nowrap" }, children: [
3237
+ /* @__PURE__ */ b(
3238
+ Bt,
3239
+ {
3240
+ sx: {
3241
+ minWidth: "20%",
3242
+ width: V ? e.chatColumnWidthWithDashboard ?? "80%" : "100%",
3243
+ minHeight: 0,
3244
+ height: "100%",
3245
+ display: "flex",
3246
+ flexDirection: "column",
3247
+ overflow: "hidden",
3248
+ '& [data-message-role="user"]': { backgroundColor: `${h.hover} !important`, border: `1px solid ${h.borderSoft} !important`, borderRadius: "12px !important" },
3249
+ '& [data-message-role="user"], & [data-message-role="user"] span, & [data-message-role="user"] p': { fontSize: "12.5px", lineHeight: 1.55 }
3250
+ },
3251
+ children: [
3252
+ /* @__PURE__ */ t(S, { ref: I, className: "bi-composer-chat-pane", sx: { minHeight: 0, width: "100%", flex: 5, overflow: "hidden", display: "flex", flexDirection: "column" }, children: e.chatPane }),
3253
+ /* @__PURE__ */ t(re.div, { variants: Q, initial: "hidden", animate: "visible", exit: "hidden", style: { width: "100%", flex: 1 }, children: /* @__PURE__ */ t(S, { sx: { backgroundColor: g.palette.background.default, flex: 1 }, children: me() }) })
3254
+ ]
3255
+ }
3256
+ ),
3257
+ e.sidePanel === void 0 ? /* @__PURE__ */ t(qn, { width: e.sidePanelWidth ?? "70%", defaultCollapsed: !_, onCollapseChange: P }) : typeof e.sidePanel == "function" ? e.sidePanel({ hasDashboard: V, turnOpen: c }) : e.sidePanel,
3258
+ (ge = e.renderProgressPanel) == null ? void 0 : ge.call(e, { hasDashboard: V, dashboardCollapsed: L, turnOpen: c })
3259
+ ] }) }, "execution-layout") });
3260
+ }, "ComposerInner"), ni = /* @__PURE__ */ a((e) => {
3261
+ const n = he(), i = et(), l = ee(null);
3262
+ q(() => {
3263
+ const P = l.current;
3264
+ if (!P || typeof ResizeObserver > "u") return;
3265
+ const _ = /* @__PURE__ */ a(() => {
3266
+ const V = P.getBoundingClientRect();
3267
+ n.getState().setViewport({ width: V.width, height: V.height });
3268
+ }, "publish");
3269
+ _();
3270
+ const $ = new ResizeObserver(_);
3271
+ return $.observe(P), () => $.disconnect();
3272
+ }, [n]);
3273
+ const [o, r] = N([]);
3274
+ q(() => {
3275
+ if (e.recentSessions || !i) return;
3276
+ let P = !1;
3277
+ return (async () => {
3278
+ try {
3279
+ const _ = await i.listDashboards();
3280
+ if (P) return;
3281
+ const $ = _.filter((V) => !!V.originalSessionId).map((V) => {
3282
+ var M;
3283
+ const K = V.updatedAt ? V.updatedAt instanceof Date ? V.updatedAt.getTime() : Date.parse(String(V.updatedAt)) : 0;
3284
+ return { sessionId: V.originalSessionId, name: V.name || "Dashboard", cardCount: ((M = V.cards) == null ? void 0 : M.length) ?? 0, updatedAt: Number.isFinite(K) ? K : 0 };
3285
+ });
3286
+ $.sort((V, K) => (K.updatedAt ?? 0) - (V.updatedAt ?? 0)), r($.slice(0, io));
3287
+ } catch (_) {
3288
+ console.error("[@aintela/bi composer] failed to list dashboards", _);
3289
+ }
3290
+ })(), () => {
3291
+ P = !0;
3292
+ };
3293
+ }, [i, e.recentSessions, e.routeSessionId]);
3294
+ const g = e.recentSessions ?? o, h = B((P) => P.turnOpen), x = B((P) => P.hasCompletedOnce), d = B((P) => P.producedDashboardId), v = B((P) => {
3295
+ var _;
3296
+ return !!((_ = P.dashboardDefinition) != null && _.jsFileName);
3297
+ }), s = B((P) => {
3298
+ var _;
3299
+ return ((_ = P.dashboardDefinition) == null ? void 0 : _.id) ?? null;
3300
+ }), c = B((P) => {
3301
+ var _, $;
3302
+ return (($ = (_ = P.dashboardDefinition) == null ? void 0 : _.cards) == null ? void 0 : $.length) ?? 0;
3303
+ }), u = B((P) => {
3304
+ var _, $;
3305
+ return (($ = (_ = P.dashboardDefinition) == null ? void 0 : _.filters) == null ? void 0 : $.length) ?? 0;
3306
+ }), p = ee({ id: s, cards: c, filters: u, firstTime: !0 });
3307
+ q(() => {
3308
+ if (h) return;
3309
+ const P = p.current, _ = !P.id && !!s, $ = P.cards === 0 && c > 0, V = P.filters === 0 && u > 0, K = P.firstTime;
3310
+ p.current = { id: s, cards: c, filters: u, firstTime: !1 }, !K && (_ || $ || V) && n.getState().setSketchExpanded(!0);
3311
+ }, [s, c, u, h, n]);
3312
+ const f = B((P) => P.guideSteps), y = B((P) => P.guideOptions), R = B((P) => P.dismissGuide);
3313
+ q(() => {
3314
+ f && f.length > 0 && vn(f) && n.getState().setSketchExpanded(!0);
3315
+ }, [f, n]);
3316
+ const H = ve(() => h ? "generating" : !x && !e.routeSessionId ? "empty" : d || v ? "done-dashboard" : "done-text", [h, x, d, v, e.routeSessionId]), L = W(() => {
3317
+ n.getState().setHasCompletedOnce(!0), n.getState().setSketchExpanded(!1);
3318
+ }, [n]);
3319
+ return /* @__PURE__ */ b(Te, { children: [
3320
+ /* @__PURE__ */ t("div", { className: "bi-composer-root", ref: l, style: { display: "inherit", height: "100%" }, children: /* @__PURE__ */ t(ao, { ...e, composerMode: H, onForceExecutionMode: L, recentSessionsResolved: g }) }),
3321
+ f && f.length > 0 && /* @__PURE__ */ t(ti, { steps: f, overlayOpacity: y == null ? void 0 : y.overlayOpacity, allowInteraction: y == null ? void 0 : y.allowInteraction, onComplete: y == null ? void 0 : y.onComplete, onDismiss: R, resolveElement: e.resolveGuideElement ?? Ot })
3322
+ ] });
3323
+ }, "ComposerView");
3324
+ ni.displayName = "ComposerView";
3325
+ const St = 20, oo = 60;
3326
+ function ro(e) {
3327
+ for (const n of e.artifactData ?? [])
3328
+ if ((n == null ? void 0 : n.type) === "Dashboard" && n.id) return n.id;
3329
+ return null;
3330
+ }
3331
+ a(ro, "detectProducedDashboardId");
3332
+ function ii() {
3333
+ const e = he(), n = In(), i = W((h) => {
3334
+ var H, L, P, _;
3335
+ const { viewport: x, dashboardDefinition: d } = e.getState(), v = Math.round(x.height), s = x.width === 0 ? 0 : Math.round(x.width / 2 - oo), c = s, u = Math.round(1080 * 0.9), p = Math.round(u / 12), f = ((d == null ? void 0 : d.cards) ?? []).map(($) => ({
3336
+ ...$,
3337
+ widthPx: typeof $.w == "number" && p > 0 ? Math.round(p * $.w * 0.95) : void 0,
3338
+ heightPx: typeof $.h == "number" ? Math.round($.h * St * 0.95) : void 0
3339
+ }));
3340
+ let y;
3341
+ try {
3342
+ const $ = JSON.parse(h), V = (((L = (H = $ == null ? void 0 : $.userPrompt) == null ? void 0 : H.trim()) == null ? void 0 : L.length) ?? 0) > 0 ? $.userPrompt : void 0, K = ((P = $ == null ? void 0 : $.cards) == null ? void 0 : P.length) ?? 0, M = ((_ = $ == null ? void 0 : $.filters) == null ? void 0 : _.length) ?? 0, w = K > 0 ? `${K} card(s) ` : "", F = M > 0 ? ` - ${M} filter(s) ` : "";
3343
+ y = V ?? `${w}${F}(${($ == null ? void 0 : $.layoutType) ?? ""})`;
3344
+ } catch {
3345
+ y = void 0;
3346
+ }
3347
+ const R = {
3348
+ id: (d == null ? void 0 : d.id) ?? "",
3349
+ name: (d == null ? void 0 : d.name) ?? "",
3350
+ cards: f,
3351
+ filters: (d == null ? void 0 : d.filters) ?? [],
3352
+ layoutType: (d == null ? void 0 : d.layoutType) ?? "Boxed",
3353
+ remarks: d == null ? void 0 : d.remarks,
3354
+ userPrompt: h,
3355
+ screenData: {
3356
+ chatBox: { heightPx: v, widthPx: c },
3357
+ dashboardPreviewBox: { heightPx: v, widthPx: s },
3358
+ dashboardVisualizationBox: { heightPx: v, widthPx: u },
3359
+ gridRowHeightPixelsPerUnit: St,
3360
+ gridColumnWidthPixelsPerUnit: p,
3361
+ gridColumnWidthPixelsPerUnitFullView: p
3362
+ },
3363
+ isDatasetParameterized: (d == null ? void 0 : d.isDatasetParameterized) ?? !1,
3364
+ defaultDatasetName: d == null ? void 0 : d.defaultDatasetName,
3365
+ clientSideChanges: kt(d == null ? void 0 : d.clientSideChanges)
3366
+ };
3367
+ return d != null && d.clientSideChanges && Object.keys(d.clientSideChanges).length > 0 && e.getState().clearClientSideChanges(), { promptAsString: y ?? "", json: JSON.stringify(R) };
3368
+ }, [e]), l = W(() => {
3369
+ const h = e.getState();
3370
+ h.setTurnOpen(!0), h.dismissGuide(), h.setHasCompletedOnce(!1), h.setProducedDashboardId(null), h.setSketchExpanded(!1);
3371
+ }, [e]), o = W((h) => {
3372
+ const x = e.getState();
3373
+ x.setProducedDashboardId(ro(h)), x.setHasCompletedOnce(!0), x.setTurnOpen(!1);
3374
+ }, [e]), r = W((h, x) => e.getState().ingestToolEvent(h, x), [e]), g = W((h) => {
3375
+ e.getState().currentSessionId !== h && e.getState().setCurrentSessionId(h);
3376
+ }, [e]);
3377
+ return ve(() => ({ onRenderPrompt: i, onTurnOpen: l, onTurnComplete: o, ingestToolEvent: r, setSessionId: g, environment: n }), [i, l, o, r, g, n]);
3378
+ }
3379
+ a(ii, "useComposerChatBridge");
3380
+ const lo = /* @__PURE__ */ a(() => {
3381
+ const e = ii(), n = Xi((l) => {
3382
+ var o;
3383
+ return ((o = l.session) == null ? void 0 : o.id) ?? null;
3384
+ }), { eventBusService: i } = Zi();
3385
+ return q(() => {
3386
+ e.setSessionId(n);
3387
+ }, [n, e]), q(() => {
3388
+ const l = i;
3389
+ if (!(l != null && l.gatewayOnToolEvent)) return;
3390
+ const o = /* @__PURE__ */ a((r, g) => e.ingestToolEvent(r, g), "handler");
3391
+ return l.gatewayOnToolEvent(o), () => {
3392
+ var r;
3393
+ return (r = l.gatewayOffToolEvent) == null ? void 0 : r.call(l, o);
3394
+ };
3395
+ }, [i, e]), null;
3396
+ }, "ComposerChatBinding"), Zt = {
3397
+ metric: "KPI",
3398
+ chart: "GRÁFICO",
3399
+ table: "TABELA",
3400
+ iframe: "PAINEL",
3401
+ dashboard: "DASHBOARD"
3402
+ }, so = new Intl.DateTimeFormat(void 0, { hour: "2-digit", minute: "2-digit" }), ai = /* @__PURE__ */ a(({
3403
+ width: e = 560,
3404
+ title: n = "Visualizações da sessão",
3405
+ footerAction: i,
3406
+ headerActions: l
3407
+ }) => {
3408
+ const o = le(), r = ue(o), { items: g, offscreen: h, scrollTo: x } = Un(), d = ve(() => {
3409
+ const s = /* @__PURE__ */ new Map();
3410
+ for (const c of h) {
3411
+ const u = c.group ?? "default", p = s.get(u);
3412
+ p ? p.push(c) : s.set(u, [c]);
3413
+ }
3414
+ return [...s.entries()].map(([c, u]) => {
3415
+ var p;
3416
+ return { key: c, items: u, at: ((p = u[0]) == null ? void 0 : p.at) ?? 0 };
3417
+ });
3418
+ }, [h]), v = { fontFamily: r.fontFamilyMono };
3419
+ return /* @__PURE__ */ b(
3420
+ S,
3421
+ {
3422
+ component: "aside",
3423
+ "aria-label": n,
3424
+ sx: {
3425
+ width: e,
3426
+ flex: "none",
3427
+ minHeight: 0,
3428
+ display: "flex",
3429
+ flexDirection: "column",
3430
+ borderLeft: `1px solid ${o.palette.divider}`,
3431
+ backgroundColor: o.palette.background.default
3432
+ },
3433
+ children: [
3434
+ /* @__PURE__ */ b(S, { sx: { display: "flex", alignItems: "center", gap: 1, px: 2.25, py: 1.75, flexShrink: 0 }, children: [
3435
+ /* @__PURE__ */ t(X, { sx: { fontSize: 13.5, fontWeight: 600, letterSpacing: "-0.01em" }, children: n }),
3436
+ /* @__PURE__ */ t(X, { sx: { ...v, fontSize: 10.5, color: o.palette.text.disabled }, children: h.length > 0 ? `${h.length} fora da vista` : "todas visíveis" }),
3437
+ /* @__PURE__ */ t(S, { sx: { flex: 1 } }),
3438
+ l
3439
+ ] }),
3440
+ /* @__PURE__ */ b(S, { sx: { flex: 1, minHeight: 0, overflowY: "auto", px: 2.25, pb: 2, display: "flex", flexDirection: "column", gap: 2 }, children: [
3441
+ h.length === 0 && /* @__PURE__ */ t(X, { sx: { fontSize: 12, color: o.palette.text.disabled, lineHeight: 1.6 }, children: g.length === 0 ? "Nada gerado ainda. Os gráficos, KPIs e tabelas que o agente produzir aparecem aqui quando saírem de vista." : "Tudo o que a sessão gerou está visível no chat. Role a conversa e as visualizações que saírem de vista aparecem aqui." }),
3442
+ d.map((s) => /* @__PURE__ */ b(S, { children: [
3443
+ /* @__PURE__ */ t(
3444
+ X,
3445
+ {
3446
+ sx: { ...v, fontSize: 10, letterSpacing: "0.12em", textTransform: "uppercase", color: o.palette.text.disabled, mb: 1 },
3447
+ children: so.format(s.at)
3448
+ }
3449
+ ),
3450
+ /* @__PURE__ */ t(S, { sx: { display: "flex", flexDirection: "column", gap: 1 }, children: s.items.map((c) => /* @__PURE__ */ b(
3451
+ S,
3452
+ {
3453
+ component: "button",
3454
+ type: "button",
3455
+ onClick: /* @__PURE__ */ a(() => x(c.id), "onClick"),
3456
+ disabled: !c.ready,
3457
+ sx: {
3458
+ all: "unset",
3459
+ boxSizing: "border-box",
3460
+ cursor: c.ready ? "pointer" : "default",
3461
+ opacity: c.ready ? 1 : 0.55,
3462
+ display: "grid",
3463
+ gridTemplateColumns: "auto 1fr 14px",
3464
+ alignItems: "start",
3465
+ gap: 1.5,
3466
+ px: 1.5,
3467
+ py: 1.25,
3468
+ borderRadius: "10px",
3469
+ border: c.ready ? `1px solid ${o.palette.divider}` : `1px dashed ${o.palette.divider}`,
3470
+ backgroundColor: o.palette.background.paper,
3471
+ "&:hover": c.ready ? { borderColor: o.palette.text.primary } : void 0,
3472
+ "&:focus-visible": { outline: `2px solid ${o.palette.primary.main}`, outlineOffset: 1 }
3473
+ },
3474
+ children: [
3475
+ /* @__PURE__ */ t(
3476
+ X,
3477
+ {
3478
+ component: "span",
3479
+ sx: {
3480
+ ...v,
3481
+ fontSize: 9,
3482
+ letterSpacing: "0.08em",
3483
+ px: 0.75,
3484
+ py: 0.25,
3485
+ borderRadius: "6px",
3486
+ backgroundColor: r.hover,
3487
+ color: o.palette.text.secondary
3488
+ },
3489
+ children: Zt[c.kind]
3490
+ }
3491
+ ),
3492
+ /* @__PURE__ */ b(S, { sx: { minWidth: 0 }, children: [
3493
+ /* @__PURE__ */ t(X, { sx: { fontSize: 12.5, fontWeight: 500, lineHeight: 1.35, overflow: "hidden", textOverflow: "ellipsis" }, children: c.title || Zt[c.kind] }),
3494
+ c.preview && /* @__PURE__ */ t(S, { sx: { mt: 0.75, maxHeight: 56, overflow: "hidden" }, children: c.preview }),
3495
+ !c.ready && /* @__PURE__ */ t(X, { sx: { ...v, fontSize: 10, color: o.palette.warning.main, mt: 0.5 }, children: "gerando…" })
3496
+ ] }),
3497
+ /* @__PURE__ */ t(X, { component: "span", "aria-hidden": !0, sx: { ...v, fontSize: 12, color: o.palette.text.disabled, justifySelf: "end" }, children: c.ready ? "↑" : "" })
3498
+ ]
3499
+ },
3500
+ c.id
3501
+ )) })
3502
+ ] }, s.key))
3503
+ ] }),
3504
+ /* @__PURE__ */ b(
3505
+ S,
3506
+ {
3507
+ sx: {
3508
+ flexShrink: 0,
3509
+ px: 2.25,
3510
+ py: 1.5,
3511
+ borderTop: `1px solid ${o.palette.divider}`,
3512
+ display: "flex",
3513
+ alignItems: "center",
3514
+ gap: 1,
3515
+ backgroundColor: Ce(o.palette.background.paper, 0.6)
3516
+ },
3517
+ children: [
3518
+ /* @__PURE__ */ t(X, { sx: { ...v, fontSize: 10, letterSpacing: "0.08em", textTransform: "uppercase", color: o.palette.text.disabled }, children: "clique para rolar o chat até a visualização" }),
3519
+ /* @__PURE__ */ t(S, { sx: { flex: 1 } }),
3520
+ i == null ? void 0 : i(h)
3521
+ ]
3522
+ }
3523
+ )
3524
+ ]
3525
+ }
3526
+ );
3527
+ }, "SessionVisualizationsPanel");
3528
+ ai.displayName = "SessionVisualizationsPanel";
3529
+ const co = /* @__PURE__ */ a(({ label: e, onClick: n, children: i }) => /* @__PURE__ */ t(ce, { title: e, placement: "top", children: /* @__PURE__ */ t(
3530
+ be,
3531
+ {
3532
+ size: "small",
3533
+ "aria-label": e,
3534
+ onClick: n,
3535
+ sx: /* @__PURE__ */ a((l) => ({ width: 26, height: 26, borderRadius: "6px", border: `1px solid ${l.palette.divider}`, color: l.palette.text.secondary }), "sx"),
3536
+ children: i
3537
+ }
3538
+ ) }), "SessionVisualizationsPanelButton"), po = "0 0 40%", oi = /* @__PURE__ */ a(() => {
3539
+ const e = le(), n = ue(e), i = B((f) => {
3540
+ var y;
3541
+ return ((y = f.dashboardDefinition) == null ? void 0 : y.jsFileName) ?? null;
3542
+ }), l = B((f) => {
3543
+ var y;
3544
+ return ((y = f.dashboardDefinition) == null ? void 0 : y.id) ?? null;
3545
+ }), o = B((f) => {
3546
+ var y;
3547
+ return ((y = f.dashboardDefinition) == null ? void 0 : y.name) || "Dashboard";
3548
+ }), r = B((f) => {
3549
+ var y, R;
3550
+ return ((R = (y = f.dashboardDefinition) == null ? void 0 : y.cards) == null ? void 0 : R.length) ?? 0;
3551
+ }), [g, h] = N("expanded"), [x, d] = N(!1), v = !!i && !!l, [s, c] = N(!1);
3552
+ if (q(() => {
3553
+ if (!v) {
3554
+ c(!1);
3555
+ return;
3556
+ }
3557
+ c(!0);
3558
+ const f = window.setTimeout(() => c(!1), 2500);
3559
+ return () => window.clearTimeout(f);
3560
+ }, [v]), !v || !l) return null;
3561
+ const u = { color: e.palette.text.secondary, p: 0.5, "&:hover": { color: e.palette.text.primary, backgroundColor: n.hover } }, p = /* @__PURE__ */ b(Te, { children: [
3562
+ /* @__PURE__ */ t(X, { sx: { color: e.palette.text.disabled, fontSize: 11 }, children: "·" }),
3563
+ /* @__PURE__ */ b(X, { sx: { fontFamily: n.fontFamilyMono, color: e.palette.text.secondary, fontSize: 11 }, children: [
3564
+ r,
3565
+ " ",
3566
+ r === 1 ? "card" : "cards"
3567
+ ] })
3568
+ ] });
3569
+ return g === "minimized" ? /* @__PURE__ */ t(S, { sx: { flexShrink: 0, px: 1.5, py: 1, borderBottom: `1px solid ${n.borderSoft}`, backgroundColor: e.palette.background.paper }, children: /* @__PURE__ */ b(
3570
+ S,
3571
+ {
3572
+ role: "button",
3573
+ tabIndex: 0,
3574
+ onClick: /* @__PURE__ */ a(() => h("expanded"), "onClick"),
3575
+ onKeyDown: /* @__PURE__ */ a((f) => {
3576
+ f.key === "Enter" && h("expanded");
3577
+ }, "onKeyDown"),
3578
+ sx: {
3579
+ display: "inline-flex",
3580
+ alignItems: "center",
3581
+ gap: 0.75,
3582
+ px: 1.25,
3583
+ py: 0.5,
3584
+ borderRadius: 999,
3585
+ cursor: "pointer",
3586
+ backgroundColor: n.raised,
3587
+ border: `1px solid ${e.palette.divider}`,
3588
+ color: e.palette.text.primary,
3589
+ fontFamily: e.typography.fontFamily,
3590
+ fontSize: 11.5,
3591
+ transition: "background-color .12s, border-color .12s",
3592
+ "&:hover": { backgroundColor: n.hover, borderColor: e.palette.primary.main }
3593
+ },
3594
+ children: [
3595
+ /* @__PURE__ */ t(S, { sx: { color: e.palette.primary.main, display: "inline-flex" }, children: /* @__PURE__ */ t(ke, { size: 13 }) }),
3596
+ /* @__PURE__ */ t(S, { component: "span", sx: { fontWeight: 500 }, children: o }),
3597
+ p,
3598
+ /* @__PURE__ */ t(S, { component: "span", sx: { color: e.palette.text.disabled, mx: 0.25 }, children: "|" }),
3599
+ /* @__PURE__ */ t(S, { component: "span", sx: { color: e.palette.primary.main, fontWeight: 500 }, children: "expandir" })
3600
+ ]
3601
+ }
3602
+ ) }) : /* @__PURE__ */ b(Te, { children: [
3603
+ /* @__PURE__ */ t(re.div, { initial: { opacity: 0, y: -8, scaleY: 0.96 }, animate: { opacity: 1, y: 0, scaleY: 1 }, transition: { duration: 0.32, ease: [0.22, 0.8, 0.32, 1] }, style: { transformOrigin: "top center", flex: po, minHeight: 200, display: "flex", flexDirection: "column" }, children: /* @__PURE__ */ b(S, { sx: { flex: 1, minHeight: 0, display: "flex", flexDirection: "column", borderBottom: `1px solid ${n.borderSoft}`, backgroundColor: e.palette.background.default, overflow: "hidden", position: "relative" }, children: [
3604
+ /* @__PURE__ */ b(S, { sx: { display: "flex", alignItems: "center", gap: 1, px: 1.5, py: 0.875, borderBottom: `1px solid ${n.borderSoft}`, backgroundColor: e.palette.background.paper, flexShrink: 0 }, children: [
3605
+ /* @__PURE__ */ t(S, { sx: { color: e.palette.primary.main, display: "inline-flex" }, children: /* @__PURE__ */ t(ke, { size: 14 }) }),
3606
+ /* @__PURE__ */ t(X, { sx: { color: e.palette.text.primary, fontWeight: 500, fontSize: 12 }, children: o }),
3607
+ p,
3608
+ /* @__PURE__ */ t(S, { sx: { flex: 1 } }),
3609
+ /* @__PURE__ */ t(ce, { title: "Tela cheia", placement: "top", children: /* @__PURE__ */ t(be, { size: "small", onClick: /* @__PURE__ */ a(() => d(!0), "onClick"), sx: u, "aria-label": "Abrir em tela cheia", children: /* @__PURE__ */ t(Le, { size: 13 }) }) }),
3610
+ /* @__PURE__ */ t(ce, { title: "Minimizar", placement: "top", children: /* @__PURE__ */ t(be, { size: "small", onClick: /* @__PURE__ */ a(() => h("minimized"), "onClick"), sx: { ...u, transform: "rotate(180deg)" }, "aria-label": "Minimizar", children: /* @__PURE__ */ t(Qi, { size: 13 }) }) })
3611
+ ] }),
3612
+ /* @__PURE__ */ t(tt, { children: s && /* @__PURE__ */ b(
3613
+ re.div,
3614
+ {
3615
+ initial: { opacity: 0, y: -6 },
3616
+ animate: { opacity: 1, y: 0 },
3617
+ exit: { opacity: 0, y: -4 },
3618
+ transition: { duration: 0.25, ease: "easeOut" },
3619
+ style: {
3620
+ position: "absolute",
3621
+ top: 8,
3622
+ right: 12,
3623
+ zIndex: 2,
3624
+ pointerEvents: "none",
3625
+ display: "inline-flex",
3626
+ alignItems: "center",
3627
+ gap: 6,
3628
+ background: e.palette.primary.main,
3629
+ color: e.palette.primary.contrastText,
3630
+ fontFamily: e.typography.fontFamily,
3631
+ fontSize: 11,
3632
+ fontWeight: 600,
3633
+ padding: "4px 10px 4px 8px",
3634
+ borderRadius: 999,
3635
+ boxShadow: `0 4px 14px ${Ce(e.palette.primary.main, 0.35)}`
3636
+ },
3637
+ children: [
3638
+ /* @__PURE__ */ t(ke, { size: 11 }),
3639
+ "Dashboard pronto"
3640
+ ]
3641
+ }
3642
+ ) }),
3643
+ /* @__PURE__ */ t(S, { sx: { flex: 1, minHeight: 0, overflow: "auto" }, children: /* @__PURE__ */ t(_e, { dashboardId: l }) })
3644
+ ] }) }),
3645
+ /* @__PURE__ */ b(cn, { open: x, onClose: /* @__PURE__ */ a(() => d(!1), "onClose"), maxWidth: !1, fullScreen: !0, slotProps: { paper: { sx: { backgroundColor: e.palette.background.default, backgroundImage: "none", color: e.palette.text.primary } } }, children: [
3646
+ /* @__PURE__ */ b(S, { sx: { display: "flex", alignItems: "center", gap: 1, px: 2, py: 1.25, borderBottom: `1px solid ${e.palette.divider}`, backgroundColor: e.palette.background.paper, flexShrink: 0 }, children: [
3647
+ /* @__PURE__ */ t(S, { sx: { color: e.palette.primary.main, display: "inline-flex" }, children: /* @__PURE__ */ t(ke, { size: 16 }) }),
3648
+ /* @__PURE__ */ t(X, { sx: { color: e.palette.text.primary, fontWeight: 500, fontSize: 13.5 }, children: o }),
3649
+ p,
3650
+ /* @__PURE__ */ t(S, { sx: { flex: 1 } }),
3651
+ /* @__PURE__ */ t(ce, { title: "Fechar", placement: "left", children: /* @__PURE__ */ t(be, { size: "small", onClick: /* @__PURE__ */ a(() => d(!1), "onClick"), sx: { ...u, p: 0.75 }, "aria-label": "Fechar", children: /* @__PURE__ */ t(Dt, { size: 14 }) }) })
3652
+ ] }),
3653
+ /* @__PURE__ */ t(S, { sx: { flex: 1, minHeight: 0, overflow: "auto" }, children: /* @__PURE__ */ t(_e, { dashboardId: l }) })
3654
+ ] })
3655
+ ] });
3656
+ }, "DashboardPinInner");
3657
+ oi.displayName = "DashboardPin";
3658
+ const ho = He.memo(oi), Uo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3659
+ __proto__: null,
3660
+ CARD_TYPE_CATALOG: we,
3661
+ CATEGORY_ICONS: zn,
3662
+ COLOR_MAP: On,
3663
+ CardScketch: va,
3664
+ CardSketch: $t,
3665
+ CardTypeIconsProvider: ga,
3666
+ ClonedComponent: Sn,
3667
+ ComposerChatBinding: lo,
3668
+ ComposerProvider: ua,
3669
+ ComposerView: ni,
3670
+ DEFAULT_PAD_HEIGHT_PX: nt,
3671
+ DRAFT_SAVE_DEBOUNCE_MS: Tn,
3672
+ DashboardPad: Rn,
3673
+ DashboardPadEditor: _n,
3674
+ DashboardPadSketch: ot,
3675
+ DashboardPin: ho,
3676
+ DashboardSidePanel: qn,
3677
+ DatasetParameterizationControls: Aa,
3678
+ DrawablePrompt: Qn,
3679
+ ENV_HIGHLIGHT_CLASS: Ze,
3680
+ EntryEmptyState: _t,
3681
+ EnvironmentProvider: ea,
3682
+ ExampleCardSkath: _a,
3683
+ ExampleCardSketch: rt,
3684
+ ExampleCardSketh: Ra,
3685
+ ExamplePad: Ma,
3686
+ FILTER_TYPE_CATALOG: It,
3687
+ FILTER_TYPE_ICONS: $n,
3688
+ FilterSketch: At,
3689
+ GRID_ROW_HEIGHT_PX: St,
3690
+ GUIDE_SHOW_DELAY_MS: Dn,
3691
+ HoverButton: De,
3692
+ InertEnvironmentProvider: ta,
3693
+ PAD_INTERNAL_CLASSES: yn,
3694
+ PAD_INTERNAL_IDS: xn,
3695
+ PrototypePad: Fa,
3696
+ SPECIFIC_TYPE_ICONS: Pn,
3697
+ SPECIFIC_TYPE_ICON_NAMES: En,
3698
+ STARTER_TEMPLATES: Wa,
3699
+ SessionVisualizationsPanel: ai,
3700
+ SessionVisualizationsPanelButton: co,
3701
+ SpotlightOverlay: ti,
3702
+ TEMPLATE_KIND_TO_SKETCH: Wn,
3703
+ TextSketh: Sa,
3704
+ TitleSkath: Ca,
3705
+ TitleSketch: Ge,
3706
+ ToolBox: Mn,
3707
+ VIEWER_COMMIT_DEBOUNCE_MS: wn,
3708
+ activityPanelVariants: Nn,
3709
+ activityPanelVariantsReduced: Ln,
3710
+ ambientVariants: Fn,
3711
+ ambientVariantsReduced: Hn,
3712
+ autoComplete: La,
3713
+ c: Na,
3714
+ categoryPrefix: ca,
3715
+ composerLayoutTransition: Bn,
3716
+ composerLayoutTransitionReduced: Gn,
3717
+ createComposerStore: kn,
3718
+ createDashboardDraft: Pt,
3719
+ datePicker: Ha,
3720
+ dateRange: Ba,
3721
+ defaultCardTypeIcons: An,
3722
+ defaultComposerSuggestions: ei,
3723
+ defaultComposerTemplates: Mt,
3724
+ environmentFromStore: fa,
3725
+ fromUpsertResponse: Be,
3726
+ groupCardCatalog: it,
3727
+ guideStepsRequireSketch: vn,
3728
+ isElementVisible: zt,
3729
+ isSimplePadDefinition: hn,
3730
+ joinClientSideChanges: kt,
3731
+ padConfigToDashboard: pn,
3732
+ pickBestElement: gn,
3733
+ randomId: ze,
3734
+ resolveComposerSurfaces: ue,
3735
+ resolveEnvironmentElements: Qe,
3736
+ resolveGuideElement: Ot,
3737
+ sanitizeToJsVariable: $e,
3738
+ seedFromTemplate: jn,
3739
+ sketchCardItemComparer: la,
3740
+ sketchFilterComparer: sa,
3741
+ targetSuggestsPadInternal: bn,
3742
+ templateKinds: Vn,
3743
+ toDraftPayload: Cn,
3744
+ toSelectorList: fn,
3745
+ upsertDashboardDraft: at,
3746
+ useCardTypeIcons: Me,
3747
+ useComposer: B,
3748
+ useComposerChatBridge: ii,
3749
+ useComposerEnvironment: In,
3750
+ useComposerStore: he,
3751
+ useComposerStoreOptional: ma,
3752
+ useDashboardPad: Ga,
3753
+ useEnvironment: dn,
3754
+ useEnvironmentOptional: na,
3755
+ validateSketch: bt
3756
+ }, Symbol.toStringTag, { value: "Module" }));
3757
+ export {
3758
+ La as $,
3759
+ Fa as A,
3760
+ En as B,
3761
+ we as C,
3762
+ nt as D,
3763
+ Ze as E,
3764
+ It as F,
3765
+ St as G,
3766
+ De as H,
3767
+ Wa as I,
3768
+ ai as J,
3769
+ co as K,
3770
+ Vo as L,
3771
+ ti as M,
3772
+ Sa as N,
3773
+ Ca as O,
3774
+ yn as P,
3775
+ Ge as Q,
3776
+ Mn as R,
3777
+ Pn as S,
3778
+ Wn as T,
3779
+ jt as U,
3780
+ wn as V,
3781
+ jo as W,
3782
+ Nn as X,
3783
+ Ln as Y,
3784
+ Fn as Z,
3785
+ Hn as _,
3786
+ zn as a,
3787
+ Na as a0,
3788
+ ca as a1,
3789
+ Bn as a2,
3790
+ Gn as a3,
3791
+ kn as a4,
3792
+ Pt as a5,
3793
+ Ha as a6,
3794
+ Ba as a7,
3795
+ An as a8,
3796
+ ei as a9,
3797
+ In as aA,
3798
+ he as aB,
3799
+ ma as aC,
3800
+ Ga as aD,
3801
+ Un as aE,
3802
+ bt as aF,
3803
+ Uo as aG,
3804
+ Mt as aa,
3805
+ fa as ab,
3806
+ Be as ac,
3807
+ it as ad,
3808
+ vn as ae,
3809
+ zt as af,
3810
+ hn as ag,
3811
+ kt as ah,
3812
+ pn as ai,
3813
+ gn as aj,
3814
+ ze as ak,
3815
+ ue as al,
3816
+ Qe as am,
3817
+ Ot as an,
3818
+ $e as ao,
3819
+ jn as ap,
3820
+ la as aq,
3821
+ sa as ar,
3822
+ bn as as,
3823
+ Vn as at,
3824
+ Cn as au,
3825
+ fn as av,
3826
+ at as aw,
3827
+ Me as ax,
3828
+ B as ay,
3829
+ ii as az,
3830
+ On as b,
3831
+ va as c,
3832
+ $t as d,
3833
+ ga as e,
3834
+ Sn as f,
3835
+ lo as g,
3836
+ ua as h,
3837
+ ni as i,
3838
+ Tn as j,
3839
+ Rn as k,
3840
+ _n as l,
3841
+ ot as m,
3842
+ ho as n,
3843
+ qn as o,
3844
+ Aa as p,
3845
+ Qn as q,
3846
+ _t as r,
3847
+ _a as s,
3848
+ rt as t,
3849
+ Ra as u,
3850
+ Ma as v,
3851
+ $n as w,
3852
+ At as x,
3853
+ Dn as y,
3854
+ xn as z
3855
+ };
3856
+ //# sourceMappingURL=index-C4_VSDeU.js.map