@aintela/bi 0.2.0

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