dp-widgets-framework 1.6.8 → 1.7.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.
package/dist/index.esm.js CHANGED
@@ -7,7 +7,7 @@ import * as LabelPrimitive from '@radix-ui/react-label';
7
7
  import { cva } from 'class-variance-authority';
8
8
  import * as SwitchPrimitives from '@radix-ui/react-switch';
9
9
  import * as SelectPrimitive from '@radix-ui/react-select';
10
- import { ChevronDown, ChevronUp, Check, AlertCircle, MoveUp, MoveDown, Trash2, Plus, Bot, Type, Layout, LayoutGrid, BarChart as BarChart$1, Filter, Search, ArrowUp, ArrowDown, ChevronRight, RefreshCw, Send, Loader2, X, AlignVerticalSpaceAround, LineChart as LineChart$1, PieChart as PieChart$1, Table, FileText, SlidersHorizontal, GripHorizontal, Edit, MessageCircleX, Edit2 } from 'lucide-react';
10
+ import { ChevronDown, ChevronUp, Check, AlertCircle, MoveUp, MoveDown, Trash2, Plus, Bot, Type, Layout, LayoutGrid, BarChart as BarChart$1, Filter, Search, ArrowUp, ArrowDown, ChevronRight, RefreshCw, Send, Loader2, X, AlignVerticalSpaceAround, LineChart as LineChart$1, PieChart as PieChart$1, Table, FileText, SlidersHorizontal, GripHorizontal, Edit, MessageCircleX, ChevronLeft, Maximize2, Grid3X3, Edit2 } from 'lucide-react';
11
11
  import * as ScrollAreaPrimitive from '@radix-ui/react-scroll-area';
12
12
  import { Slot, createSlot, createSlottable } from '@radix-ui/react-slot';
13
13
  import { debounce as debounce$1 } from 'lodash';
@@ -43606,24 +43606,6 @@ const loadAgentState$5 = async (widgetBackendUrl, threadId, agentName) => {
43606
43606
  return null;
43607
43607
  }
43608
43608
  };
43609
- const loadSessionStateDirect$5 = async (widgetBackendUrl, sessionId) => {
43610
- try {
43611
- const response = await fetch(`${widgetBackendUrl}/api/session/${sessionId}/state`, {
43612
- method: "GET",
43613
- headers: {
43614
- "Content-Type": "application/json"
43615
- }
43616
- });
43617
- if (!response.ok) {
43618
- throw new Error(`HTTP error! status: ${response.status}`);
43619
- }
43620
- const result = await response.json();
43621
- return result;
43622
- } catch (error) {
43623
- console.error("Failed to load session state directly:", error);
43624
- return null;
43625
- }
43626
- };
43627
43609
  const parseAndUpdateChartState$4 = (apiResponse, setChartState) => {
43628
43610
  var _a, _b;
43629
43611
  try {
@@ -44148,7 +44130,7 @@ function CopilotKitAgent({
44148
44130
  datasetId,
44149
44131
  widgetData
44150
44132
  }) {
44151
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H, _I, _J, _K, _L, _M, _N, _O, _P, _Q, _R, _S, _T, _U, _V, _W, _X, _Y, _Z, __, _$;
44133
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H, _I, _J, _K, _L, _M, _N, _O, _P, _Q, _R, _S, _T, _U, _V, _W, _X, _Y, _Z, __, _$, _aa;
44152
44134
  const agentType = (_a = widget.config) == null ? void 0 : _a.agentType;
44153
44135
  const orientation = (_b = widget.config) == null ? void 0 : _b.orientation;
44154
44136
  const isFirstLoad = (_c = widget.config) == null ? void 0 : _c.isFirstLoad;
@@ -44159,7 +44141,6 @@ function CopilotKitAgent({
44159
44141
  const [apiCallCount, setApiCallCount] = useState(0);
44160
44142
  const [hasTimeoutError, setHasTimeoutError] = useState(false);
44161
44143
  const hasInitialFetchRef = useRef(false);
44162
- const [isInitialFetchComplete, setIsInitialFetchComplete] = useState(false);
44163
44144
  useEffect(() => {
44164
44145
  setThreadId(widget.id);
44165
44146
  }, [widget.id, setThreadId]);
@@ -44169,16 +44150,17 @@ function CopilotKitAgent({
44169
44150
  });
44170
44151
  useEffect(() => {
44171
44152
  const fetchInitialState = async () => {
44153
+ var _a2;
44172
44154
  if (!widgetBackendUrl || !widget.id || hasInitialFetchRef.current) return;
44173
44155
  hasInitialFetchRef.current = true;
44174
- const apiResponse = await loadSessionStateDirect$5(widgetBackendUrl, widget.id);
44156
+ const agentName = ((_a2 = widget.config) == null ? void 0 : _a2.agentName) || "adk-construction-project-agent";
44157
+ const apiResponse = await loadAgentState$5(widgetBackendUrl, widget.id, agentName);
44175
44158
  if (apiResponse) {
44176
44159
  parseAndUpdateChartState$4(apiResponse, setChartState);
44177
44160
  }
44178
- setIsInitialFetchComplete(true);
44179
44161
  };
44180
44162
  fetchInitialState();
44181
- }, [widgetBackendUrl, widget.id, setChartState]);
44163
+ }, [widgetBackendUrl, widget.id, (_f = widget.config) == null ? void 0 : _f.agentName, setChartState]);
44182
44164
  const handleLoadingTimeout = useCallback(async () => {
44183
44165
  var _a2;
44184
44166
  if (!widgetBackendUrl || !widget.id || isTimeoutTriggered || (chartState == null ? void 0 : chartState.agent_message) || hasTimeoutError) return;
@@ -44198,7 +44180,7 @@ function CopilotKitAgent({
44198
44180
  if (apiResponse && !(chartState == null ? void 0 : chartState.agent_message)) {
44199
44181
  parseAndUpdateChartState$4(apiResponse, setChartState);
44200
44182
  }
44201
- }, [widgetBackendUrl, widget.id, isTimeoutTriggered, setChartState, (_f = widget.config) == null ? void 0 : _f.agentName, chartState, apiCallCount, hasTimeoutError]);
44183
+ }, [widgetBackendUrl, widget.id, isTimeoutTriggered, setChartState, (_g = widget.config) == null ? void 0 : _g.agentName, chartState, apiCallCount, hasTimeoutError]);
44202
44184
  const startLoadingTimeout = useCallback(() => {
44203
44185
  if (timeoutRef.current) {
44204
44186
  clearTimeout(timeoutRef.current);
@@ -44281,8 +44263,8 @@ function CopilotKitAgent({
44281
44263
  /* @__PURE__ */ jsxRuntimeExports.jsx(Bot, { className: "h-4 w-4" }),
44282
44264
  /* @__PURE__ */ jsxRuntimeExports.jsx("h3", { className: "text-sm font-medium", children: widget.title })
44283
44265
  ] }) }),
44284
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex-1 h-full", children: !isInitialFetchComplete && !isFirstLoad ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex items-center justify-center h-full", children: /* @__PURE__ */ jsxRuntimeExports.jsx(RefreshCw, { className: "h-6 w-6 animate-spin text-gray-400" }) }) : (chartState == null ? void 0 : chartState.agent_message) && agentType !== "chatbot" && // Check if data is empty based on agent type
44285
- (agentType === "Bar Chart Agent" && (!((_i = (_h = (_g = chartState.bar_chart_data) == null ? void 0 : _g.data) == null ? void 0 : _h.labels) == null ? void 0 : _i.length) || !((_l = (_k = (_j = chartState.bar_chart_data) == null ? void 0 : _j.data) == null ? void 0 : _k.values) == null ? void 0 : _l.length)) || agentType === "Series Bar Chart Agent" && (!((_o = (_n = (_m = chartState.series_bar_chart_data) == null ? void 0 : _m.data) == null ? void 0 : _n.labels) == null ? void 0 : _o.length) || !((_r = (_q = (_p = chartState.series_bar_chart_data) == null ? void 0 : _p.data) == null ? void 0 : _q.series) == null ? void 0 : _r.length)) || agentType === "Series Line Chart Agent" && (!((_u = (_t = (_s = chartState.series_bar_chart_data) == null ? void 0 : _s.data) == null ? void 0 : _t.labels) == null ? void 0 : _u.length) || !((_x = (_w = (_v = chartState.series_bar_chart_data) == null ? void 0 : _v.data) == null ? void 0 : _w.series) == null ? void 0 : _x.length)) || agentType === "Pie Chart Agent" && (!((_A = (_z = (_y = chartState.pie_chart_data) == null ? void 0 : _y.data) == null ? void 0 : _z.labels) == null ? void 0 : _A.length) || !((_D = (_C = (_B = chartState.pie_chart_data) == null ? void 0 : _B.data) == null ? void 0 : _C.values) == null ? void 0 : _D.length)) || agentType === "Line Chart Agent" && (!((_G = (_F = (_E = chartState.bar_chart_data) == null ? void 0 : _E.data) == null ? void 0 : _F.labels) == null ? void 0 : _G.length) || !((_J = (_I = (_H = chartState.bar_chart_data) == null ? void 0 : _H.data) == null ? void 0 : _I.values) == null ? void 0 : _J.length)) || agentType === "Data Grid Agent" && (!((_M = (_L = (_K = chartState.matrix_grid_data) == null ? void 0 : _K.data) == null ? void 0 : _L.headers) == null ? void 0 : _M.length) || !((_P = (_O = (_N = chartState.matrix_grid_data) == null ? void 0 : _N.data) == null ? void 0 : _O.rows) == null ? void 0 : _P.length)) || agentType === "Summary Agent" && (!((_R = (_Q = chartState.summary_data) == null ? void 0 : _Q.data) == null ? void 0 : _R.content) || ((_U = (_T = (_S = chartState.summary_data) == null ? void 0 : _S.data) == null ? void 0 : _T.content) == null ? void 0 : _U.trim()) === "")) ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex items-center justify-center h-full p-4", children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-center max-w-md", children: /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm text-gray-700", children: chartState.agent_message }) }) }) : agentType === "Bar Chart Agent" ? /* @__PURE__ */ jsxRuntimeExports.jsx(
44266
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex-1 h-full", children: (chartState == null ? void 0 : chartState.agent_message) && agentType !== "chatbot" && // Check if data is empty based on agent type
44267
+ (agentType === "Bar Chart Agent" && (!((_j = (_i = (_h = chartState.bar_chart_data) == null ? void 0 : _h.data) == null ? void 0 : _i.labels) == null ? void 0 : _j.length) || !((_m = (_l = (_k = chartState.bar_chart_data) == null ? void 0 : _k.data) == null ? void 0 : _l.values) == null ? void 0 : _m.length)) || agentType === "Series Bar Chart Agent" && (!((_p = (_o = (_n = chartState.series_bar_chart_data) == null ? void 0 : _n.data) == null ? void 0 : _o.labels) == null ? void 0 : _p.length) || !((_s = (_r = (_q = chartState.series_bar_chart_data) == null ? void 0 : _q.data) == null ? void 0 : _r.series) == null ? void 0 : _s.length)) || agentType === "Series Line Chart Agent" && (!((_v = (_u = (_t = chartState.series_bar_chart_data) == null ? void 0 : _t.data) == null ? void 0 : _u.labels) == null ? void 0 : _v.length) || !((_y = (_x = (_w = chartState.series_bar_chart_data) == null ? void 0 : _w.data) == null ? void 0 : _x.series) == null ? void 0 : _y.length)) || agentType === "Pie Chart Agent" && (!((_B = (_A = (_z = chartState.pie_chart_data) == null ? void 0 : _z.data) == null ? void 0 : _A.labels) == null ? void 0 : _B.length) || !((_E = (_D = (_C = chartState.pie_chart_data) == null ? void 0 : _C.data) == null ? void 0 : _D.values) == null ? void 0 : _E.length)) || agentType === "Line Chart Agent" && (!((_H = (_G = (_F = chartState.bar_chart_data) == null ? void 0 : _F.data) == null ? void 0 : _G.labels) == null ? void 0 : _H.length) || !((_K = (_J = (_I = chartState.bar_chart_data) == null ? void 0 : _I.data) == null ? void 0 : _J.values) == null ? void 0 : _K.length)) || agentType === "Data Grid Agent" && (!((_N = (_M = (_L = chartState.matrix_grid_data) == null ? void 0 : _L.data) == null ? void 0 : _M.headers) == null ? void 0 : _N.length) || !((_Q = (_P = (_O = chartState.matrix_grid_data) == null ? void 0 : _O.data) == null ? void 0 : _P.rows) == null ? void 0 : _Q.length)) || agentType === "Summary Agent" && (!((_S = (_R = chartState.summary_data) == null ? void 0 : _R.data) == null ? void 0 : _S.content) || ((_V = (_U = (_T = chartState.summary_data) == null ? void 0 : _T.data) == null ? void 0 : _U.content) == null ? void 0 : _V.trim()) === "")) ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex items-center justify-center h-full p-4", children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-center max-w-md", children: /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm text-gray-700", children: chartState.agent_message }) }) }) : agentType === "Bar Chart Agent" ? /* @__PURE__ */ jsxRuntimeExports.jsx(
44286
44268
  BarChartComponent,
44287
44269
  {
44288
44270
  barChartState: chartState,
@@ -44290,7 +44272,7 @@ function CopilotKitAgent({
44290
44272
  orientation,
44291
44273
  content,
44292
44274
  appendMessage,
44293
- query: (_V = widget.config) == null ? void 0 : _V.query,
44275
+ query: (_W = widget.config) == null ? void 0 : _W.query,
44294
44276
  isFirstLoad,
44295
44277
  widgetBackendUrl,
44296
44278
  widgetId: widget.id,
@@ -44305,7 +44287,7 @@ function CopilotKitAgent({
44305
44287
  orientation,
44306
44288
  content,
44307
44289
  appendMessage,
44308
- query: (_W = widget.config) == null ? void 0 : _W.query,
44290
+ query: (_X = widget.config) == null ? void 0 : _X.query,
44309
44291
  isFirstLoad,
44310
44292
  widgetBackendUrl,
44311
44293
  widgetId: widget.id,
@@ -44320,7 +44302,7 @@ function CopilotKitAgent({
44320
44302
  orientation,
44321
44303
  content,
44322
44304
  appendMessage,
44323
- query: (_X = widget.config) == null ? void 0 : _X.query,
44305
+ query: (_Y = widget.config) == null ? void 0 : _Y.query,
44324
44306
  isFirstLoad,
44325
44307
  widgetBackendUrl,
44326
44308
  widgetId: widget.id,
@@ -44334,7 +44316,7 @@ function CopilotKitAgent({
44334
44316
  styles,
44335
44317
  appendMessage,
44336
44318
  content,
44337
- query: (_Y = widget.config) == null ? void 0 : _Y.query,
44319
+ query: (_Z = widget.config) == null ? void 0 : _Z.query,
44338
44320
  isFirstLoad,
44339
44321
  widgetBackendUrl,
44340
44322
  widgetId: widget.id,
@@ -44348,7 +44330,7 @@ function CopilotKitAgent({
44348
44330
  styles,
44349
44331
  appendMessage,
44350
44332
  content,
44351
- query: (_Z = widget.config) == null ? void 0 : _Z.query,
44333
+ query: (__ = widget.config) == null ? void 0 : __.query,
44352
44334
  isFirstLoad,
44353
44335
  widgetBackendUrl,
44354
44336
  widgetId: widget.id,
@@ -44361,7 +44343,7 @@ function CopilotKitAgent({
44361
44343
  dataGridState: chartState,
44362
44344
  styles,
44363
44345
  appendMessage,
44364
- query: (__ = widget.config) == null ? void 0 : __.query,
44346
+ query: (_$ = widget.config) == null ? void 0 : _$.query,
44365
44347
  isFirstLoad,
44366
44348
  widgetBackendUrl,
44367
44349
  widgetId: widget.id,
@@ -44374,7 +44356,7 @@ function CopilotKitAgent({
44374
44356
  summaryState: chartState,
44375
44357
  styles,
44376
44358
  appendMessage,
44377
- query: (_$ = widget.config) == null ? void 0 : _$.query,
44359
+ query: (_aa = widget.config) == null ? void 0 : _aa.query,
44378
44360
  isFirstLoad,
44379
44361
  widgetBackendUrl,
44380
44362
  widgetId: widget.id,
@@ -44805,24 +44787,6 @@ const loadAgentState$4 = async (widgetBackendUrl, threadId, agentName) => {
44805
44787
  return null;
44806
44788
  }
44807
44789
  };
44808
- const loadSessionStateDirect$4 = async (widgetBackendUrl, sessionId) => {
44809
- try {
44810
- const response = await fetch(`${widgetBackendUrl}/api/session/${sessionId}/state`, {
44811
- method: "GET",
44812
- headers: {
44813
- "Content-Type": "application/json"
44814
- }
44815
- });
44816
- if (!response.ok) {
44817
- throw new Error(`HTTP error! status: ${response.status}`);
44818
- }
44819
- const result = await response.json();
44820
- return result;
44821
- } catch (error) {
44822
- console.error("Failed to load session state directly:", error);
44823
- return null;
44824
- }
44825
- };
44826
44790
  const parseAndUpdateFilterState = (apiResponse, setFilterState) => {
44827
44791
  var _a, _b;
44828
44792
  try {
@@ -45279,7 +45243,7 @@ function CopilotKitFilters({
45279
45243
  onApplyFilters,
45280
45244
  isEditing = false
45281
45245
  }) {
45282
- var _a, _b, _c, _d, _e, _f, _g, _h;
45246
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i;
45283
45247
  const isFirstLoad = (_a = widget.config) == null ? void 0 : _a.isFirstLoad;
45284
45248
  const widget_data = (_b = widget.widget_data) == null ? void 0 : _b.column_values;
45285
45249
  const { setThreadId } = useCopilotContext();
@@ -45297,15 +45261,17 @@ function CopilotKitFilters({
45297
45261
  const [filterState, setFilterState] = useState(createInitialFilterState(datasetId, widget_data));
45298
45262
  useEffect(() => {
45299
45263
  const fetchInitialState = async () => {
45264
+ var _a2;
45300
45265
  if (!widgetBackendUrl || !widget.id || hasInitialFetchRef.current) return;
45301
45266
  hasInitialFetchRef.current = true;
45302
- const apiResponse = await loadSessionStateDirect$4(widgetBackendUrl, widget.id);
45267
+ const agentName = ((_a2 = widget.config) == null ? void 0 : _a2.agentName) || "adk-construction-project-agent";
45268
+ const apiResponse = await loadAgentState$4(widgetBackendUrl, widget.id, agentName);
45303
45269
  if (apiResponse) {
45304
45270
  parseAndUpdateFilterState(apiResponse, setFilterState);
45305
45271
  }
45306
45272
  };
45307
45273
  fetchInitialState();
45308
- }, [widgetBackendUrl, widget.id, setFilterState]);
45274
+ }, [widgetBackendUrl, widget.id, (_d = widget.config) == null ? void 0 : _d.agentName, setFilterState]);
45309
45275
  const handleLoadingTimeout = useCallback(async () => {
45310
45276
  var _a2;
45311
45277
  if (!widgetBackendUrl || !widget.id || (filterState == null ? void 0 : filterState.agent_message) || hasTimeoutError) {
@@ -45329,7 +45295,7 @@ function CopilotKitFilters({
45329
45295
  if (apiResponse && !(filterState == null ? void 0 : filterState.agent_message)) {
45330
45296
  parseAndUpdateFilterState(apiResponse, setFilterState);
45331
45297
  }
45332
- }, [widgetBackendUrl, widget.id, setFilterState, (_d = widget.config) == null ? void 0 : _d.agentName, filterState, apiCallCount, hasTimeoutError]);
45298
+ }, [widgetBackendUrl, widget.id, setFilterState, (_e = widget.config) == null ? void 0 : _e.agentName, filterState, apiCallCount, hasTimeoutError]);
45333
45299
  const startLoadingTimeout = useCallback(() => {
45334
45300
  if (timeoutRef.current) {
45335
45301
  clearTimeout(timeoutRef.current);
@@ -45455,7 +45421,7 @@ function CopilotKitFilters({
45455
45421
  setHasTimeoutError(false);
45456
45422
  console.log("[FiltersWidget] Starting polling after confirmation");
45457
45423
  startLoadingTimeout();
45458
- }, [filterState.filter_columns, filterState.ambiguous_columns, (_e = widget.config) == null ? void 0 : _e.query, datasetId, appendMessage, setFilterState, setAgentState, startLoadingTimeout, setApiCallCount, setHasTimeoutError]);
45424
+ }, [filterState.filter_columns, filterState.ambiguous_columns, (_f = widget.config) == null ? void 0 : _f.query, datasetId, appendMessage, setFilterState, setAgentState, startLoadingTimeout, setApiCallCount, setHasTimeoutError]);
45459
45425
  const handleCancelConfirmation = useCallback(() => {
45460
45426
  setFilterState((prev) => __spreadProps$7(__spreadValues$9({}, prev), {
45461
45427
  status: void 0,
@@ -45468,7 +45434,7 @@ function CopilotKitFilters({
45468
45434
  console.log("[CopilotKitFilters] Filter state check:", {
45469
45435
  status: filterState.status,
45470
45436
  hasAmbiguousColumns: !!filterState.ambiguous_columns,
45471
- ambiguousColumnsLength: ((_f = filterState.ambiguous_columns) == null ? void 0 : _f.length) || 0,
45437
+ ambiguousColumnsLength: ((_g = filterState.ambiguous_columns) == null ? void 0 : _g.length) || 0,
45472
45438
  isWaitingForConfirmation,
45473
45439
  fullFilterState: filterState
45474
45440
  });
@@ -45484,7 +45450,7 @@ function CopilotKitFilters({
45484
45450
  onCancel: handleCancelConfirmation
45485
45451
  }
45486
45452
  )
45487
- ) : (filterState == null ? void 0 : filterState.agent_message) && !((_g = filterState.column_values) == null ? void 0 : _g.length) && filterState.status !== "waiting_for_confirmation" ? (
45453
+ ) : (filterState == null ? void 0 : filterState.agent_message) && !((_h = filterState.column_values) == null ? void 0 : _h.length) && filterState.status !== "waiting_for_confirmation" ? (
45488
45454
  // Show agent message (errors, warnings, etc.)
45489
45455
  /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex items-center justify-center h-full p-4", children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-center max-w-md", children: /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm text-gray-700 whitespace-pre-line", children: filterState.agent_message }) }) })
45490
45456
  ) : (
@@ -45497,7 +45463,7 @@ function CopilotKitFilters({
45497
45463
  onFilterChange,
45498
45464
  widget,
45499
45465
  appendMessage,
45500
- query: (_h = widget.config) == null ? void 0 : _h.query,
45466
+ query: (_i = widget.config) == null ? void 0 : _i.query,
45501
45467
  isFirstLoad,
45502
45468
  widgetBackendUrl,
45503
45469
  widgetId: widget.id,
@@ -45636,24 +45602,6 @@ const loadAgentState$3 = async (widgetBackendUrl, threadId, agentName) => {
45636
45602
  return null;
45637
45603
  }
45638
45604
  };
45639
- const loadSessionStateDirect$3 = async (widgetBackendUrl, sessionId) => {
45640
- try {
45641
- const response = await fetch(`${widgetBackendUrl}/api/session/${sessionId}/state`, {
45642
- method: "GET",
45643
- headers: {
45644
- "Content-Type": "application/json"
45645
- }
45646
- });
45647
- if (!response.ok) {
45648
- throw new Error(`HTTP error! status: ${response.status}`);
45649
- }
45650
- const result = await response.json();
45651
- return result;
45652
- } catch (error) {
45653
- console.error("Failed to load session state directly:", error);
45654
- return null;
45655
- }
45656
- };
45657
45605
  const parseAndUpdateChartState$3 = (apiResponse, setChartState) => {
45658
45606
  var _a, _b;
45659
45607
  try {
@@ -45779,7 +45727,7 @@ function CopilotKitPieChart({
45779
45727
  datasetId,
45780
45728
  widgetData
45781
45729
  }) {
45782
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p;
45730
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q;
45783
45731
  const isFirstLoad = (_a = widget.config) == null ? void 0 : _a.isFirstLoad;
45784
45732
  const content = (_b = widget.config) == null ? void 0 : _b.content;
45785
45733
  const widget_data = (_c = widget.widget_data) == null ? void 0 : _c.pie_chart_data;
@@ -45796,19 +45744,19 @@ function CopilotKitPieChart({
45796
45744
  initialState: createInitialChartState$3(datasetId, widget_data)
45797
45745
  });
45798
45746
  const [chartState, setChartState] = useState(createInitialChartState$3(datasetId, widget_data));
45799
- const [isInitialFetchComplete, setIsInitialFetchComplete] = useState(false);
45800
45747
  useEffect(() => {
45801
45748
  const fetchInitialState = async () => {
45749
+ var _a2;
45802
45750
  if (!widgetBackendUrl || !widget.id || hasInitialFetchRef.current) return;
45803
45751
  hasInitialFetchRef.current = true;
45804
- const apiResponse = await loadSessionStateDirect$3(widgetBackendUrl, widget.id);
45752
+ const agentName = ((_a2 = widget.config) == null ? void 0 : _a2.agentName) || "adk-construction-project-agent";
45753
+ const apiResponse = await loadAgentState$3(widgetBackendUrl, widget.id, agentName);
45805
45754
  if (apiResponse) {
45806
45755
  parseAndUpdateChartState$3(apiResponse, setChartState);
45807
45756
  }
45808
- setIsInitialFetchComplete(true);
45809
45757
  };
45810
45758
  fetchInitialState();
45811
- }, [widgetBackendUrl, widget.id, setChartState]);
45759
+ }, [widgetBackendUrl, widget.id, (_e = widget.config) == null ? void 0 : _e.agentName, setChartState]);
45812
45760
  const handleLoadingTimeout = useCallback(async () => {
45813
45761
  var _a2;
45814
45762
  if (!widgetBackendUrl || !widget.id || (chartState == null ? void 0 : chartState.agent_message) || hasTimeoutError) {
@@ -45832,7 +45780,7 @@ function CopilotKitPieChart({
45832
45780
  if (apiResponse && !(chartState == null ? void 0 : chartState.agent_message)) {
45833
45781
  parseAndUpdateChartState$3(apiResponse, setChartState);
45834
45782
  }
45835
- }, [widgetBackendUrl, widget.id, setChartState, (_e = widget.config) == null ? void 0 : _e.agentName, chartState, apiCallCount, hasTimeoutError]);
45783
+ }, [widgetBackendUrl, widget.id, setChartState, (_f = widget.config) == null ? void 0 : _f.agentName, chartState, apiCallCount, hasTimeoutError]);
45836
45784
  const startLoadingTimeout = useCallback(() => {
45837
45785
  if (timeoutRef.current) {
45838
45786
  clearTimeout(timeoutRef.current);
@@ -45906,20 +45854,20 @@ function CopilotKitPieChart({
45906
45854
  /* @__PURE__ */ jsxRuntimeExports.jsx(Bot, { className: "h-4 w-4" }),
45907
45855
  /* @__PURE__ */ jsxRuntimeExports.jsx("h3", { className: "text-sm font-medium", children: widget.title })
45908
45856
  ] }) }),
45909
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex-1 h-full", children: !isInitialFetchComplete && !isFirstLoad ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex items-center justify-center h-full", children: /* @__PURE__ */ jsxRuntimeExports.jsx(RefreshCw, { className: "h-6 w-6 animate-spin text-gray-400" }) }) : (chartState == null ? void 0 : chartState.agent_message) && (!((_h = (_g = (_f = chartState.pie_chart_data) == null ? void 0 : _f.data) == null ? void 0 : _g.labels) == null ? void 0 : _h.length) || !((_k = (_j = (_i = chartState.pie_chart_data) == null ? void 0 : _i.data) == null ? void 0 : _j.values) == null ? void 0 : _k.length)) ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex items-center justify-center h-full p-4", children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-center max-w-md", children: /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm text-gray-700", children: chartState.agent_message }) }) }) : /* @__PURE__ */ jsxRuntimeExports.jsx(
45857
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex-1 h-full", children: (chartState == null ? void 0 : chartState.agent_message) && (!((_i = (_h = (_g = chartState.pie_chart_data) == null ? void 0 : _g.data) == null ? void 0 : _h.labels) == null ? void 0 : _i.length) || !((_l = (_k = (_j = chartState.pie_chart_data) == null ? void 0 : _j.data) == null ? void 0 : _k.values) == null ? void 0 : _l.length)) ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex items-center justify-center h-full p-4", children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-center max-w-md", children: /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm text-gray-700", children: chartState.agent_message }) }) }) : /* @__PURE__ */ jsxRuntimeExports.jsx(
45910
45858
  PieChartComponent,
45911
45859
  {
45912
45860
  pieChartState: chartState,
45913
45861
  styles,
45914
45862
  appendMessage,
45915
45863
  content,
45916
- query: (_l = widget.config) == null ? void 0 : _l.query,
45864
+ query: (_m = widget.config) == null ? void 0 : _m.query,
45917
45865
  isFirstLoad,
45918
45866
  widgetBackendUrl,
45919
45867
  widgetId: widget.id,
45920
45868
  startLoadingTimeout,
45921
45869
  clearLoadingTimeout,
45922
- hasWidgetData: !!(((_n = (_m = widget_data == null ? void 0 : widget_data.data) == null ? void 0 : _m.labels) == null ? void 0 : _n.length) && ((_p = (_o = widget_data == null ? void 0 : widget_data.data) == null ? void 0 : _o.values) == null ? void 0 : _p.length))
45870
+ hasWidgetData: !!(((_o = (_n = widget_data == null ? void 0 : widget_data.data) == null ? void 0 : _n.labels) == null ? void 0 : _o.length) && ((_q = (_p = widget_data == null ? void 0 : widget_data.data) == null ? void 0 : _p.values) == null ? void 0 : _q.length))
45923
45871
  }
45924
45872
  ) })
45925
45873
  ] });
@@ -46068,24 +46016,6 @@ const loadAgentState$2 = async (widgetBackendUrl, threadId, agentName) => {
46068
46016
  return null;
46069
46017
  }
46070
46018
  };
46071
- const loadSessionStateDirect$2 = async (widgetBackendUrl, sessionId) => {
46072
- try {
46073
- const response = await fetch(`${widgetBackendUrl}/api/session/${sessionId}/state`, {
46074
- method: "GET",
46075
- headers: {
46076
- "Content-Type": "application/json"
46077
- }
46078
- });
46079
- if (!response.ok) {
46080
- throw new Error(`HTTP error! status: ${response.status}`);
46081
- }
46082
- const result = await response.json();
46083
- return result;
46084
- } catch (error) {
46085
- console.error("Failed to load session state directly:", error);
46086
- return null;
46087
- }
46088
- };
46089
46019
  const parseAndUpdateChartState$2 = (apiResponse, setChartState) => {
46090
46020
  var _a, _b;
46091
46021
  try {
@@ -46220,7 +46150,7 @@ function CopilotKitSeriesBarChart$1({
46220
46150
  datasetId,
46221
46151
  widgetData
46222
46152
  }) {
46223
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q;
46153
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r;
46224
46154
  const orientation = ((_a = widget.config) == null ? void 0 : _a.orientation) || "vertical";
46225
46155
  const isFirstLoad = (_b = widget.config) == null ? void 0 : _b.isFirstLoad;
46226
46156
  const content = (_c = widget.config) == null ? void 0 : _c.content;
@@ -46238,19 +46168,19 @@ function CopilotKitSeriesBarChart$1({
46238
46168
  initialState: createInitialChartState$2(datasetId, widget_data)
46239
46169
  });
46240
46170
  const [chartState, setChartState] = useState(createInitialChartState$2(datasetId, widget_data));
46241
- const [isInitialFetchComplete, setIsInitialFetchComplete] = useState(false);
46242
46171
  useEffect(() => {
46243
46172
  const fetchInitialState = async () => {
46173
+ var _a2;
46244
46174
  if (!widgetBackendUrl || !widget.id || hasInitialFetchRef.current) return;
46245
46175
  hasInitialFetchRef.current = true;
46246
- const apiResponse = await loadSessionStateDirect$2(widgetBackendUrl, widget.id);
46176
+ const agentName = ((_a2 = widget.config) == null ? void 0 : _a2.agentName) || "adk-construction-project-agent";
46177
+ const apiResponse = await loadAgentState$2(widgetBackendUrl, widget.id, agentName);
46247
46178
  if (apiResponse) {
46248
46179
  parseAndUpdateChartState$2(apiResponse, setChartState);
46249
46180
  }
46250
- setIsInitialFetchComplete(true);
46251
46181
  };
46252
46182
  fetchInitialState();
46253
- }, [widgetBackendUrl, widget.id, setChartState]);
46183
+ }, [widgetBackendUrl, widget.id, (_f = widget.config) == null ? void 0 : _f.agentName, setChartState]);
46254
46184
  const handleLoadingTimeout = useCallback(async () => {
46255
46185
  var _a2;
46256
46186
  if (!widgetBackendUrl || !widget.id || (chartState == null ? void 0 : chartState.agent_message) || hasTimeoutError) {
@@ -46274,7 +46204,7 @@ function CopilotKitSeriesBarChart$1({
46274
46204
  if (apiResponse && !(chartState == null ? void 0 : chartState.agent_message)) {
46275
46205
  parseAndUpdateChartState$2(apiResponse, setChartState);
46276
46206
  }
46277
- }, [widgetBackendUrl, widget.id, setChartState, (_f = widget.config) == null ? void 0 : _f.agentName, chartState, apiCallCount, hasTimeoutError]);
46207
+ }, [widgetBackendUrl, widget.id, setChartState, (_g = widget.config) == null ? void 0 : _g.agentName, chartState, apiCallCount, hasTimeoutError]);
46278
46208
  const startLoadingTimeout = useCallback(() => {
46279
46209
  if (timeoutRef.current) {
46280
46210
  clearTimeout(timeoutRef.current);
@@ -46348,7 +46278,7 @@ function CopilotKitSeriesBarChart$1({
46348
46278
  /* @__PURE__ */ jsxRuntimeExports.jsx(Bot, { className: "h-4 w-4" }),
46349
46279
  /* @__PURE__ */ jsxRuntimeExports.jsx("h3", { className: "text-sm font-medium", children: widget.title })
46350
46280
  ] }) }),
46351
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex-1 h-full", children: !isInitialFetchComplete && !isFirstLoad ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex items-center justify-center h-full", children: /* @__PURE__ */ jsxRuntimeExports.jsx(RefreshCw, { className: "h-6 w-6 animate-spin text-gray-400" }) }) : (chartState == null ? void 0 : chartState.agent_message) && (!((_i = (_h = (_g = chartState.series_bar_chart_data) == null ? void 0 : _g.data) == null ? void 0 : _h.labels) == null ? void 0 : _i.length) || !((_l = (_k = (_j = chartState.series_bar_chart_data) == null ? void 0 : _j.data) == null ? void 0 : _k.series) == null ? void 0 : _l.length)) ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex items-center justify-center h-full p-4", children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-center max-w-md", children: /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm text-gray-700", children: chartState.agent_message }) }) }) : /* @__PURE__ */ jsxRuntimeExports.jsx(
46281
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex-1 h-full", children: (chartState == null ? void 0 : chartState.agent_message) && (!((_j = (_i = (_h = chartState.series_bar_chart_data) == null ? void 0 : _h.data) == null ? void 0 : _i.labels) == null ? void 0 : _j.length) || !((_m = (_l = (_k = chartState.series_bar_chart_data) == null ? void 0 : _k.data) == null ? void 0 : _l.series) == null ? void 0 : _m.length)) ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex items-center justify-center h-full p-4", children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-center max-w-md", children: /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm text-gray-700", children: chartState.agent_message }) }) }) : /* @__PURE__ */ jsxRuntimeExports.jsx(
46352
46282
  SeriesBarChartComponent$1,
46353
46283
  {
46354
46284
  orientation,
@@ -46356,13 +46286,13 @@ function CopilotKitSeriesBarChart$1({
46356
46286
  styles,
46357
46287
  appendMessage,
46358
46288
  content,
46359
- query: (_m = widget.config) == null ? void 0 : _m.query,
46289
+ query: (_n = widget.config) == null ? void 0 : _n.query,
46360
46290
  isFirstLoad,
46361
46291
  widgetBackendUrl,
46362
46292
  widgetId: widget.id,
46363
46293
  startLoadingTimeout,
46364
46294
  clearLoadingTimeout,
46365
- hasWidgetData: !!(((_o = (_n = widget_data == null ? void 0 : widget_data.data) == null ? void 0 : _n.labels) == null ? void 0 : _o.length) && ((_q = (_p = widget_data == null ? void 0 : widget_data.data) == null ? void 0 : _p.series) == null ? void 0 : _q.length))
46295
+ hasWidgetData: !!(((_p = (_o = widget_data == null ? void 0 : widget_data.data) == null ? void 0 : _o.labels) == null ? void 0 : _p.length) && ((_r = (_q = widget_data == null ? void 0 : widget_data.data) == null ? void 0 : _q.series) == null ? void 0 : _r.length))
46366
46296
  }
46367
46297
  ) })
46368
46298
  ] });
@@ -46511,24 +46441,6 @@ const loadAgentState$1 = async (widgetBackendUrl, threadId, agentName) => {
46511
46441
  return null;
46512
46442
  }
46513
46443
  };
46514
- const loadSessionStateDirect$1 = async (widgetBackendUrl, sessionId) => {
46515
- try {
46516
- const response = await fetch(`${widgetBackendUrl}/api/session/${sessionId}/state`, {
46517
- method: "GET",
46518
- headers: {
46519
- "Content-Type": "application/json"
46520
- }
46521
- });
46522
- if (!response.ok) {
46523
- throw new Error(`HTTP error! status: ${response.status}`);
46524
- }
46525
- const result = await response.json();
46526
- return result;
46527
- } catch (error) {
46528
- console.error("Failed to load session state directly:", error);
46529
- return null;
46530
- }
46531
- };
46532
46444
  const parseAndUpdateChartState$1 = (apiResponse, setChartState) => {
46533
46445
  var _a, _b;
46534
46446
  try {
@@ -46663,7 +46575,7 @@ function CopilotKitSeriesBarChart({
46663
46575
  datasetId,
46664
46576
  widgetData
46665
46577
  }) {
46666
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q;
46578
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r;
46667
46579
  const orientation = ((_a = widget.config) == null ? void 0 : _a.orientation) || "vertical";
46668
46580
  const isFirstLoad = (_b = widget.config) == null ? void 0 : _b.isFirstLoad;
46669
46581
  const content = (_c = widget.config) == null ? void 0 : _c.content;
@@ -46681,19 +46593,19 @@ function CopilotKitSeriesBarChart({
46681
46593
  initialState: createInitialChartState$1(datasetId, widget_data)
46682
46594
  });
46683
46595
  const [chartState, setChartState] = useState(createInitialChartState$1(datasetId, widget_data));
46684
- const [isInitialFetchComplete, setIsInitialFetchComplete] = useState(false);
46685
46596
  useEffect(() => {
46686
46597
  const fetchInitialState = async () => {
46598
+ var _a2;
46687
46599
  if (!widgetBackendUrl || !widget.id || hasInitialFetchRef.current) return;
46688
46600
  hasInitialFetchRef.current = true;
46689
- const apiResponse = await loadSessionStateDirect$1(widgetBackendUrl, widget.id);
46601
+ const agentName = ((_a2 = widget.config) == null ? void 0 : _a2.agentName) || "adk-construction-project-agent";
46602
+ const apiResponse = await loadAgentState$1(widgetBackendUrl, widget.id, agentName);
46690
46603
  if (apiResponse) {
46691
46604
  parseAndUpdateChartState$1(apiResponse, setChartState);
46692
46605
  }
46693
- setIsInitialFetchComplete(true);
46694
46606
  };
46695
46607
  fetchInitialState();
46696
- }, [widgetBackendUrl, widget.id, setChartState]);
46608
+ }, [widgetBackendUrl, widget.id, (_f = widget.config) == null ? void 0 : _f.agentName, setChartState]);
46697
46609
  const handleLoadingTimeout = useCallback(async () => {
46698
46610
  var _a2;
46699
46611
  if (!widgetBackendUrl || !widget.id || (chartState == null ? void 0 : chartState.agent_message) || hasTimeoutError) {
@@ -46717,7 +46629,7 @@ function CopilotKitSeriesBarChart({
46717
46629
  if (apiResponse && !(chartState == null ? void 0 : chartState.agent_message)) {
46718
46630
  parseAndUpdateChartState$1(apiResponse, setChartState);
46719
46631
  }
46720
- }, [widgetBackendUrl, widget.id, setChartState, (_f = widget.config) == null ? void 0 : _f.agentName, chartState, apiCallCount, hasTimeoutError]);
46632
+ }, [widgetBackendUrl, widget.id, setChartState, (_g = widget.config) == null ? void 0 : _g.agentName, chartState, apiCallCount, hasTimeoutError]);
46721
46633
  const startLoadingTimeout = useCallback(() => {
46722
46634
  if (timeoutRef.current) {
46723
46635
  clearTimeout(timeoutRef.current);
@@ -46791,7 +46703,7 @@ function CopilotKitSeriesBarChart({
46791
46703
  /* @__PURE__ */ jsxRuntimeExports.jsx(Bot, { className: "h-4 w-4" }),
46792
46704
  /* @__PURE__ */ jsxRuntimeExports.jsx("h3", { className: "text-sm font-medium", children: widget.title })
46793
46705
  ] }) }),
46794
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex-1 h-full", children: !isInitialFetchComplete && !isFirstLoad ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex items-center justify-center h-full", children: /* @__PURE__ */ jsxRuntimeExports.jsx(RefreshCw, { className: "h-6 w-6 animate-spin text-gray-400" }) }) : (chartState == null ? void 0 : chartState.agent_message) && (!((_i = (_h = (_g = chartState.series_bar_chart_data) == null ? void 0 : _g.data) == null ? void 0 : _h.labels) == null ? void 0 : _i.length) || !((_l = (_k = (_j = chartState.series_bar_chart_data) == null ? void 0 : _j.data) == null ? void 0 : _k.series) == null ? void 0 : _l.length)) ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex items-center justify-center h-full p-4", children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-center max-w-md", children: /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm text-gray-700", children: chartState.agent_message }) }) }) : /* @__PURE__ */ jsxRuntimeExports.jsx(
46706
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex-1 h-full", children: (chartState == null ? void 0 : chartState.agent_message) && (!((_j = (_i = (_h = chartState.series_bar_chart_data) == null ? void 0 : _h.data) == null ? void 0 : _i.labels) == null ? void 0 : _j.length) || !((_m = (_l = (_k = chartState.series_bar_chart_data) == null ? void 0 : _k.data) == null ? void 0 : _l.series) == null ? void 0 : _m.length)) ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex items-center justify-center h-full p-4", children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-center max-w-md", children: /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm text-gray-700", children: chartState.agent_message }) }) }) : /* @__PURE__ */ jsxRuntimeExports.jsx(
46795
46707
  SeriesBarChartComponent,
46796
46708
  {
46797
46709
  orientation,
@@ -46799,13 +46711,13 @@ function CopilotKitSeriesBarChart({
46799
46711
  styles,
46800
46712
  appendMessage,
46801
46713
  content,
46802
- query: (_m = widget.config) == null ? void 0 : _m.query,
46714
+ query: (_n = widget.config) == null ? void 0 : _n.query,
46803
46715
  isFirstLoad,
46804
46716
  widgetBackendUrl,
46805
46717
  widgetId: widget.id,
46806
46718
  startLoadingTimeout,
46807
46719
  clearLoadingTimeout,
46808
- hasWidgetData: !!(((_o = (_n = widget_data == null ? void 0 : widget_data.data) == null ? void 0 : _n.labels) == null ? void 0 : _o.length) && ((_q = (_p = widget_data == null ? void 0 : widget_data.data) == null ? void 0 : _p.series) == null ? void 0 : _q.length))
46720
+ hasWidgetData: !!(((_p = (_o = widget_data == null ? void 0 : widget_data.data) == null ? void 0 : _o.labels) == null ? void 0 : _p.length) && ((_r = (_q = widget_data == null ? void 0 : widget_data.data) == null ? void 0 : _q.series) == null ? void 0 : _r.length))
46809
46721
  }
46810
46722
  ) })
46811
46723
  ] });
@@ -46944,24 +46856,6 @@ const loadAgentState = async (widgetBackendUrl, threadId, agentName) => {
46944
46856
  return null;
46945
46857
  }
46946
46858
  };
46947
- const loadSessionStateDirect = async (widgetBackendUrl, sessionId) => {
46948
- try {
46949
- const response = await fetch(`${widgetBackendUrl}/api/session/${sessionId}/state`, {
46950
- method: "GET",
46951
- headers: {
46952
- "Content-Type": "application/json"
46953
- }
46954
- });
46955
- if (!response.ok) {
46956
- throw new Error(`HTTP error! status: ${response.status}`);
46957
- }
46958
- const result = await response.json();
46959
- return result;
46960
- } catch (error) {
46961
- console.error("Failed to load session state directly:", error);
46962
- return null;
46963
- }
46964
- };
46965
46859
  const parseAndUpdateChartState = (apiResponse, setChartState) => {
46966
46860
  var _a, _b;
46967
46861
  try {
@@ -47078,7 +46972,7 @@ function CopilotKitDataGrid({
47078
46972
  datasetId,
47079
46973
  widgetData
47080
46974
  }) {
47081
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p;
46975
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q;
47082
46976
  const isFirstLoad = (_a = widget.config) == null ? void 0 : _a.isFirstLoad;
47083
46977
  const content = (_b = widget.config) == null ? void 0 : _b.content;
47084
46978
  const widget_data = (_c = widget.widget_data) == null ? void 0 : _c.matrix_grid_data;
@@ -47095,19 +46989,19 @@ function CopilotKitDataGrid({
47095
46989
  initialState: createInitialChartState(datasetId, widget_data)
47096
46990
  });
47097
46991
  const [chartState, setChartState] = useState(createInitialChartState(datasetId, widget_data));
47098
- const [isInitialFetchComplete, setIsInitialFetchComplete] = useState(false);
47099
46992
  useEffect(() => {
47100
46993
  const fetchInitialState = async () => {
46994
+ var _a2;
47101
46995
  if (!widgetBackendUrl || !widget.id || hasInitialFetchRef.current) return;
47102
46996
  hasInitialFetchRef.current = true;
47103
- const apiResponse = await loadSessionStateDirect(widgetBackendUrl, widget.id);
46997
+ const agentName = ((_a2 = widget.config) == null ? void 0 : _a2.agentName) || "adk-construction-project-agent";
46998
+ const apiResponse = await loadAgentState(widgetBackendUrl, widget.id, agentName);
47104
46999
  if (apiResponse) {
47105
47000
  parseAndUpdateChartState(apiResponse, setChartState);
47106
47001
  }
47107
- setIsInitialFetchComplete(true);
47108
47002
  };
47109
47003
  fetchInitialState();
47110
- }, [widgetBackendUrl, widget.id, setChartState]);
47004
+ }, [widgetBackendUrl, widget.id, (_e = widget.config) == null ? void 0 : _e.agentName, setChartState]);
47111
47005
  const handleLoadingTimeout = useCallback(async () => {
47112
47006
  var _a2;
47113
47007
  if (!widgetBackendUrl || !widget.id || (chartState == null ? void 0 : chartState.agent_message) || hasTimeoutError) {
@@ -47131,7 +47025,7 @@ function CopilotKitDataGrid({
47131
47025
  if (apiResponse && !(chartState == null ? void 0 : chartState.agent_message)) {
47132
47026
  parseAndUpdateChartState(apiResponse, setChartState);
47133
47027
  }
47134
- }, [widgetBackendUrl, widget.id, setChartState, (_e = widget.config) == null ? void 0 : _e.agentName, chartState, apiCallCount, hasTimeoutError]);
47028
+ }, [widgetBackendUrl, widget.id, setChartState, (_f = widget.config) == null ? void 0 : _f.agentName, chartState, apiCallCount, hasTimeoutError]);
47135
47029
  const startLoadingTimeout = useCallback(() => {
47136
47030
  if (timeoutRef.current) {
47137
47031
  clearTimeout(timeoutRef.current);
@@ -47205,20 +47099,20 @@ function CopilotKitDataGrid({
47205
47099
  /* @__PURE__ */ jsxRuntimeExports.jsx(Bot, { className: "h-4 w-4" }),
47206
47100
  /* @__PURE__ */ jsxRuntimeExports.jsx("h3", { className: "text-sm font-medium", children: widget.title })
47207
47101
  ] }) }),
47208
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex-1 h-full", children: !isInitialFetchComplete && !isFirstLoad ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex items-center justify-center h-full", children: /* @__PURE__ */ jsxRuntimeExports.jsx(RefreshCw, { className: "h-6 w-6 animate-spin text-gray-400" }) }) : (chartState == null ? void 0 : chartState.agent_message) && (!((_h = (_g = (_f = chartState.matrix_grid_data) == null ? void 0 : _f.data) == null ? void 0 : _g.headers) == null ? void 0 : _h.length) || !((_k = (_j = (_i = chartState.matrix_grid_data) == null ? void 0 : _i.data) == null ? void 0 : _j.rows) == null ? void 0 : _k.length)) ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex items-center justify-center h-full p-4", children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-center max-w-md", children: /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm text-gray-700", children: chartState.agent_message }) }) }) : /* @__PURE__ */ jsxRuntimeExports.jsx(
47102
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex-1 h-full", children: (chartState == null ? void 0 : chartState.agent_message) && (!((_i = (_h = (_g = chartState.matrix_grid_data) == null ? void 0 : _g.data) == null ? void 0 : _h.headers) == null ? void 0 : _i.length) || !((_l = (_k = (_j = chartState.matrix_grid_data) == null ? void 0 : _j.data) == null ? void 0 : _k.rows) == null ? void 0 : _l.length)) ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex items-center justify-center h-full p-4", children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-center max-w-md", children: /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm text-gray-700", children: chartState.agent_message }) }) }) : /* @__PURE__ */ jsxRuntimeExports.jsx(
47209
47103
  DataGridComponent,
47210
47104
  {
47211
47105
  dataGridState: chartState,
47212
47106
  styles,
47213
47107
  appendMessage,
47214
47108
  content,
47215
- query: (_l = widget.config) == null ? void 0 : _l.query,
47109
+ query: (_m = widget.config) == null ? void 0 : _m.query,
47216
47110
  isFirstLoad,
47217
47111
  widgetBackendUrl,
47218
47112
  widgetId: widget.id,
47219
47113
  startLoadingTimeout,
47220
47114
  clearLoadingTimeout,
47221
- hasWidgetData: !!(((_n = (_m = widget_data == null ? void 0 : widget_data.data) == null ? void 0 : _m.headers) == null ? void 0 : _n.length) && ((_p = (_o = widget_data == null ? void 0 : widget_data.data) == null ? void 0 : _o.rows) == null ? void 0 : _p.length))
47115
+ hasWidgetData: !!(((_o = (_n = widget_data == null ? void 0 : widget_data.data) == null ? void 0 : _n.headers) == null ? void 0 : _o.length) && ((_q = (_p = widget_data == null ? void 0 : widget_data.data) == null ? void 0 : _p.rows) == null ? void 0 : _q.length))
47222
47116
  }
47223
47117
  ) })
47224
47118
  ] });
@@ -48183,7 +48077,8 @@ function WidgetDashboard({
48183
48077
  userId,
48184
48078
  onApplyFilters,
48185
48079
  filterResults,
48186
- isApplyingFilters = false
48080
+ isApplyingFilters = false,
48081
+ focusWidgetId
48187
48082
  }) {
48188
48083
  const [widgets, setWidgets] = useState([]);
48189
48084
  const [datasetId, setDatasetId] = useState("");
@@ -48200,6 +48095,12 @@ function WidgetDashboard({
48200
48095
  const [editInitialQuery, setEditInitialQuery] = useState("");
48201
48096
  const [editingWidget, setEditingWidget] = useState(null);
48202
48097
  const [widgetResetFunctions, setWidgetResetFunctions] = useState(/* @__PURE__ */ new Map());
48098
+ const displayWidgets = React__default.useMemo(() => {
48099
+ if (focusWidgetId) {
48100
+ return widgets.filter((w) => w.id === focusWidgetId);
48101
+ }
48102
+ return widgets;
48103
+ }, [widgets, focusWidgetId]);
48203
48104
  const getWidgetFilterStatus = useCallback((widgetId) => {
48204
48105
  if (!filterResults) return null;
48205
48106
  const result = filterResults.results.find((r) => r.widgetId === widgetId);
@@ -48798,7 +48699,7 @@ function WidgetDashboard({
48798
48699
  };
48799
48700
  const getLayoutFromWidgets = () => {
48800
48701
  const processedIds = /* @__PURE__ */ new Set();
48801
- return widgets.filter((widget) => {
48702
+ return displayWidgets.filter((widget) => {
48802
48703
  if (processedIds.has(widget.id)) {
48803
48704
  return false;
48804
48705
  }
@@ -48806,6 +48707,22 @@ function WidgetDashboard({
48806
48707
  return true;
48807
48708
  }).map((widget) => {
48808
48709
  widget.type === "text";
48710
+ if (focusWidgetId && widget.id === focusWidgetId) {
48711
+ return {
48712
+ i: widget.id,
48713
+ x: 0,
48714
+ y: 0,
48715
+ w: 12,
48716
+ // Full width
48717
+ h: 10,
48718
+ // Increased height for presentation
48719
+ minW: 0,
48720
+ minH: 1,
48721
+ isResizable: false,
48722
+ static: true
48723
+ // Prevent any movement in focus mode
48724
+ };
48725
+ }
48809
48726
  return {
48810
48727
  i: widget.id,
48811
48728
  x: widget.position_x,
@@ -48888,11 +48805,15 @@ function WidgetDashboard({
48888
48805
  compactType: "vertical",
48889
48806
  containerPadding: [0, 0],
48890
48807
  margin: [16, 16],
48891
- children: widgets.map((w) => {
48808
+ children: displayWidgets.map((w) => {
48892
48809
  var _a, _b;
48893
48810
  const filterStatus = w.type === "agent" ? getWidgetFilterStatus(w.id) : null;
48894
48811
  const badgeInfo = filterStatus ? getFilterStatusBadge(filterStatus.status) : null;
48895
- return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: `${w.type === "text" || w.type === "spacer" ? `${((_b = (_a = w == null ? void 0 : w.config) == null ? void 0 : _a.content) == null ? void 0 : _b.divider) === "yes" && "border-b border-gray-300"} ${isEditing ? "shadow-lg rounded-xl border border-primary-300" : "flex items-center"}` : `shadow-lg rounded-xl border border-primary-300 p-4 ${isEditing ? "pb-14" : "pb-5"}`} relative`, children: [
48812
+ const isFocusMode = focusWidgetId && w.id === focusWidgetId;
48813
+ const widgetBaseStyles = "rounded-xl border border-gray-200 !bg-white";
48814
+ const widgetHoverStyles = isEditing ? "hover:border-primary-500 hover:shadow-lg transition-all duration-200" : "";
48815
+ const widgetShadow = "shadow-[0_2px_8px_-2px_rgba(0,0,0,0.15)]";
48816
+ return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { "data-widget-id": w.id, className: `${w.type === "text" || w.type === "spacer" ? `${((_b = (_a = w == null ? void 0 : w.config) == null ? void 0 : _a.content) == null ? void 0 : _b.divider) === "yes" && "border-b border-gray-300"} ${isEditing ? `${widgetBaseStyles} ${widgetShadow} ${widgetHoverStyles}` : "flex items-center"}` : `${widgetBaseStyles} ${widgetShadow} ${widgetHoverStyles} p-4 ${isEditing ? "pb-14" : "pb-5"}`} ${isFocusMode ? "h-full" : ""} relative`, children: [
48896
48817
  w.type === "agent" && badgeInfo && !isApplyingFilters && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "absolute top-2 right-2 z-10", title: (filterStatus == null ? void 0 : filterStatus.reason) || (filterStatus == null ? void 0 : filterStatus.error) || "", children: /* @__PURE__ */ jsxRuntimeExports.jsxs(Badge, { variant: badgeInfo.variant, className: "text-[10px] px-2 py-0.5 gap-1", children: [
48897
48818
  /* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: badgeInfo.icon }),
48898
48819
  /* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: badgeInfo.label })
@@ -48935,6 +48856,366 @@ function WidgetDashboard({
48935
48856
  ] });
48936
48857
  }
48937
48858
 
48859
+ const EXCLUDED_WIDGET_TYPES = ["text", "spacer", "filter", "filters", "Text", "Spacer", "Filter", "Filters"];
48860
+ const LaserPointerIcon = ({ className }) => /* @__PURE__ */ jsxRuntimeExports.jsxs(
48861
+ "svg",
48862
+ {
48863
+ viewBox: "0 0 24 24",
48864
+ fill: "none",
48865
+ stroke: "currentColor",
48866
+ strokeWidth: "2",
48867
+ strokeLinecap: "round",
48868
+ strokeLinejoin: "round",
48869
+ className,
48870
+ children: [
48871
+ /* @__PURE__ */ jsxRuntimeExports.jsx("circle", { cx: "12", cy: "12", r: "3", fill: "currentColor" }),
48872
+ /* @__PURE__ */ jsxRuntimeExports.jsx("line", { x1: "12", y1: "2", x2: "12", y2: "6" }),
48873
+ /* @__PURE__ */ jsxRuntimeExports.jsx("line", { x1: "12", y1: "18", x2: "12", y2: "22" }),
48874
+ /* @__PURE__ */ jsxRuntimeExports.jsx("line", { x1: "2", y1: "12", x2: "6", y2: "12" }),
48875
+ /* @__PURE__ */ jsxRuntimeExports.jsx("line", { x1: "18", y1: "12", x2: "22", y2: "12" })
48876
+ ]
48877
+ }
48878
+ );
48879
+ function PresentationMode({
48880
+ isOpen,
48881
+ onClose,
48882
+ pageId,
48883
+ dashboardTitle,
48884
+ widgetBackendUrl = "http://localhost:3001",
48885
+ branding = { title: "DASHBOARD", subtitle: "COMPOSER" }
48886
+ }) {
48887
+ const [viewMode, setViewMode] = useState("grid");
48888
+ const [widgets, setWidgets] = useState([]);
48889
+ const [focusableWidgets, setFocusableWidgets] = useState([]);
48890
+ const [currentFocusIndex, setCurrentFocusIndex] = useState(0);
48891
+ const [loading, setLoading] = useState(true);
48892
+ const [laserPointerActive, setLaserPointerActive] = useState(false);
48893
+ const [mousePosition, setMousePosition] = useState({ x: 0, y: 0 });
48894
+ const focusContainerRef = useRef(null);
48895
+ const gridContainerRef = useRef(null);
48896
+ useEffect(() => {
48897
+ if (isOpen && pageId) {
48898
+ setLoading(true);
48899
+ setCurrentFocusIndex(0);
48900
+ fetch(`${widgetBackendUrl}/api/widgets?page_id=${pageId}`).then((res) => {
48901
+ if (!res.ok) throw new Error("Failed to fetch widgets");
48902
+ return res.json();
48903
+ }).then((data) => {
48904
+ const widgetsArray = Array.isArray(data) ? data : [];
48905
+ setWidgets(widgetsArray);
48906
+ const focusable = widgetsArray.filter((widget) => !EXCLUDED_WIDGET_TYPES.includes(widget.type)).sort((a, b) => {
48907
+ if (a.position_y !== b.position_y) return a.position_y - b.position_y;
48908
+ return a.position_x - b.position_x;
48909
+ });
48910
+ setFocusableWidgets(focusable);
48911
+ console.log(`[PresentationMode] Loaded ${widgetsArray.length} widgets, ${focusable.length} focusable`);
48912
+ }).catch((error) => {
48913
+ console.error("Failed to fetch widgets:", error);
48914
+ setWidgets([]);
48915
+ setFocusableWidgets([]);
48916
+ }).finally(() => {
48917
+ setLoading(false);
48918
+ });
48919
+ }
48920
+ }, [isOpen, pageId, widgetBackendUrl]);
48921
+ useEffect(() => {
48922
+ if (focusableWidgets.length > 0 && currentFocusIndex >= focusableWidgets.length) {
48923
+ setCurrentFocusIndex(focusableWidgets.length - 1);
48924
+ }
48925
+ }, [focusableWidgets.length, currentFocusIndex]);
48926
+ useEffect(() => {
48927
+ if (!laserPointerActive) return;
48928
+ const handleMouseMove = (e) => {
48929
+ setMousePosition({ x: e.clientX, y: e.clientY });
48930
+ };
48931
+ window.addEventListener("mousemove", handleMouseMove);
48932
+ return () => window.removeEventListener("mousemove", handleMouseMove);
48933
+ }, [laserPointerActive]);
48934
+ useEffect(() => {
48935
+ if (!isOpen || viewMode !== "grid" || !gridContainerRef.current) return;
48936
+ const setupWidgetInteractions = () => {
48937
+ var _a;
48938
+ const gridItems = (_a = gridContainerRef.current) == null ? void 0 : _a.querySelectorAll(".react-grid-item");
48939
+ if (!gridItems) return;
48940
+ const handleMouseEnter = (e) => {
48941
+ var _a2;
48942
+ const item = e.currentTarget;
48943
+ const widgetId = item.getAttribute("data-widget-id") || ((_a2 = item.querySelector("[data-widget-id]")) == null ? void 0 : _a2.getAttribute("data-widget-id"));
48944
+ const widget = widgets.find((w) => w.id === widgetId);
48945
+ if (widget && EXCLUDED_WIDGET_TYPES.includes(widget.type)) {
48946
+ return;
48947
+ }
48948
+ item.style.cursor = "pointer";
48949
+ item.style.boxShadow = "0 0 0 3px var(--primary-500, #3b82f6), 0 10px 30px -5px rgba(0, 0, 0, 0.2)";
48950
+ item.style.transition = "box-shadow 0.2s ease-out";
48951
+ item.style.zIndex = "10";
48952
+ };
48953
+ const handleMouseLeave = (e) => {
48954
+ const item = e.currentTarget;
48955
+ item.style.cursor = "";
48956
+ item.style.boxShadow = "";
48957
+ item.style.zIndex = "";
48958
+ };
48959
+ const handleClick = (e) => {
48960
+ var _a2;
48961
+ const item = e.currentTarget;
48962
+ const widgetId = item.getAttribute("data-widget-id") || ((_a2 = item.querySelector("[data-widget-id]")) == null ? void 0 : _a2.getAttribute("data-widget-id"));
48963
+ const widget = widgets.find((w) => w.id === widgetId);
48964
+ if (widget && EXCLUDED_WIDGET_TYPES.includes(widget.type)) {
48965
+ return;
48966
+ }
48967
+ if (widgetId) {
48968
+ const index = focusableWidgets.findIndex((w) => w.id === widgetId);
48969
+ if (index !== -1) {
48970
+ setCurrentFocusIndex(index);
48971
+ setViewMode("focus");
48972
+ }
48973
+ }
48974
+ };
48975
+ gridItems.forEach((item) => {
48976
+ item.addEventListener("mouseenter", handleMouseEnter);
48977
+ item.addEventListener("mouseleave", handleMouseLeave);
48978
+ item.addEventListener("click", handleClick);
48979
+ });
48980
+ return () => {
48981
+ gridItems.forEach((item) => {
48982
+ item.removeEventListener("mouseenter", handleMouseEnter);
48983
+ item.removeEventListener("mouseleave", handleMouseLeave);
48984
+ item.removeEventListener("click", handleClick);
48985
+ item.style.cursor = "";
48986
+ item.style.transform = "";
48987
+ item.style.boxShadow = "";
48988
+ });
48989
+ };
48990
+ };
48991
+ const timeoutId = setTimeout(setupWidgetInteractions, 500);
48992
+ const observer = new MutationObserver(() => {
48993
+ setupWidgetInteractions();
48994
+ });
48995
+ if (gridContainerRef.current) {
48996
+ observer.observe(gridContainerRef.current, {
48997
+ childList: true,
48998
+ subtree: true
48999
+ });
49000
+ }
49001
+ return () => {
49002
+ clearTimeout(timeoutId);
49003
+ observer.disconnect();
49004
+ };
49005
+ }, [isOpen, viewMode, widgets, focusableWidgets, loading]);
49006
+ const handleKeyDown = useCallback(
49007
+ (e) => {
49008
+ if (!isOpen) return;
49009
+ if (e.target instanceof HTMLInputElement || e.target instanceof HTMLTextAreaElement) {
49010
+ return;
49011
+ }
49012
+ switch (e.key) {
49013
+ case "Escape":
49014
+ onClose();
49015
+ break;
49016
+ case "f":
49017
+ case "F":
49018
+ setViewMode((prev) => prev === "grid" ? "focus" : "grid");
49019
+ break;
49020
+ case "l":
49021
+ case "L":
49022
+ setLaserPointerActive((prev) => !prev);
49023
+ break;
49024
+ case "ArrowLeft":
49025
+ if (viewMode === "focus") {
49026
+ e.preventDefault();
49027
+ setCurrentFocusIndex(
49028
+ (prev) => prev > 0 ? prev - 1 : focusableWidgets.length - 1
49029
+ );
49030
+ }
49031
+ break;
49032
+ case "ArrowRight":
49033
+ if (viewMode === "focus") {
49034
+ e.preventDefault();
49035
+ setCurrentFocusIndex(
49036
+ (prev) => prev < focusableWidgets.length - 1 ? prev + 1 : 0
49037
+ );
49038
+ }
49039
+ break;
49040
+ }
49041
+ },
49042
+ [isOpen, onClose, viewMode, focusableWidgets.length]
49043
+ );
49044
+ useEffect(() => {
49045
+ window.addEventListener("keydown", handleKeyDown);
49046
+ return () => window.removeEventListener("keydown", handleKeyDown);
49047
+ }, [handleKeyDown]);
49048
+ useEffect(() => {
49049
+ if (isOpen) {
49050
+ document.body.style.overflow = "hidden";
49051
+ } else {
49052
+ document.body.style.overflow = "";
49053
+ }
49054
+ return () => {
49055
+ document.body.style.overflow = "";
49056
+ };
49057
+ }, [isOpen]);
49058
+ useEffect(() => {
49059
+ if (!isOpen) {
49060
+ setViewMode("grid");
49061
+ setCurrentFocusIndex(0);
49062
+ setLaserPointerActive(false);
49063
+ }
49064
+ }, [isOpen]);
49065
+ if (!isOpen) return null;
49066
+ const currentFocusWidget = focusableWidgets[currentFocusIndex];
49067
+ return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "fixed inset-0 z-50 bg-white flex flex-col", children: [
49068
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("header", { className: "flex items-center justify-between px-6 py-4 border-b border-gray-200 bg-white shrink-0", children: [
49069
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex items-center", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-col", children: [
49070
+ /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-xl font-bold text-primary-700 tracking-wide", children: branding.title }),
49071
+ /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-xs text-primary-500 tracking-[0.2em] -mt-1", children: branding.subtitle })
49072
+ ] }) }),
49073
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "absolute left-1/2 transform -translate-x-1/2 text-center", children: [
49074
+ /* @__PURE__ */ jsxRuntimeExports.jsx("h1", { className: "text-lg font-bold text-gray-900 uppercase tracking-wide", children: dashboardTitle }),
49075
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "w-12 h-1 bg-primary-600 mx-auto mt-1 rounded" })
49076
+ ] }),
49077
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
49078
+ "button",
49079
+ {
49080
+ onClick: onClose,
49081
+ className: "p-2 hover:bg-gray-100 rounded-lg transition-colors",
49082
+ "aria-label": "Close presentation",
49083
+ children: /* @__PURE__ */ jsxRuntimeExports.jsx(X, { className: "w-6 h-6 text-gray-600" })
49084
+ }
49085
+ )
49086
+ ] }),
49087
+ /* @__PURE__ */ jsxRuntimeExports.jsx("main", { className: `flex-1 min-h-0 ${viewMode === "grid" ? "overflow-auto bg-gray-50 p-6" : "overflow-hidden bg-gray-100"}`, children: loading ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex items-center justify-center h-full", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-col items-center gap-3", children: [
49088
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "w-8 h-8 border-4 border-primary-600 border-t-transparent rounded-full animate-spin" }),
49089
+ /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-gray-600", children: "Loading widgets..." })
49090
+ ] }) }) : viewMode === "grid" ? (
49091
+ /* Grid View - Show all widgets using WidgetDashboard */
49092
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "h-full relative", ref: gridContainerRef, children: /* @__PURE__ */ jsxRuntimeExports.jsx(
49093
+ WidgetDashboard,
49094
+ {
49095
+ pageId,
49096
+ isEditing: false,
49097
+ selectedWidget: null,
49098
+ onWidgetSelect: () => {
49099
+ },
49100
+ openWidgetPallete: false,
49101
+ onCloseWidgetPallete: () => {
49102
+ },
49103
+ onApplyFilters: () => {
49104
+ },
49105
+ isApplyingFilters: false,
49106
+ onSaveLayoutReady: () => {
49107
+ },
49108
+ widgetBackendUrl
49109
+ },
49110
+ `presentation-grid-${pageId}`
49111
+ ) })
49112
+ ) : (
49113
+ /* Focus View - Show one widget at a time */
49114
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "h-full flex flex-col", ref: focusContainerRef, children: focusableWidgets.length > 0 && currentFocusWidget ? /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex-1 flex flex-col min-h-0", children: [
49115
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "shrink-0 bg-white border-b border-gray-200 px-6 py-3 flex items-center justify-between", children: [
49116
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
49117
+ "button",
49118
+ {
49119
+ onClick: () => setCurrentFocusIndex((prev) => prev > 0 ? prev - 1 : focusableWidgets.length - 1),
49120
+ className: "p-2 rounded-full hover:bg-gray-100 transition-colors disabled:opacity-30",
49121
+ disabled: focusableWidgets.length <= 1,
49122
+ children: /* @__PURE__ */ jsxRuntimeExports.jsx(ChevronLeft, { className: "w-5 h-5 text-gray-600" })
49123
+ }
49124
+ ),
49125
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-center", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "text-sm text-gray-500", children: [
49126
+ currentFocusIndex + 1,
49127
+ " of ",
49128
+ focusableWidgets.length
49129
+ ] }) }),
49130
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
49131
+ "button",
49132
+ {
49133
+ onClick: () => setCurrentFocusIndex((prev) => prev < focusableWidgets.length - 1 ? prev + 1 : 0),
49134
+ className: "p-2 rounded-full hover:bg-gray-100 transition-colors disabled:opacity-30",
49135
+ disabled: focusableWidgets.length <= 1,
49136
+ children: /* @__PURE__ */ jsxRuntimeExports.jsx(ChevronRight, { className: "w-5 h-5 text-gray-600" })
49137
+ }
49138
+ )
49139
+ ] }),
49140
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex-1 bg-white p-6 min-h-0 overflow-hidden", children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "h-full w-full rounded-xl border border-gray-200 bg-white shadow-sm overflow-hidden", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
49141
+ WidgetRenderer,
49142
+ {
49143
+ widget: currentFocusWidget,
49144
+ widgetBackendUrl,
49145
+ pageId,
49146
+ isEditing: false
49147
+ },
49148
+ `focus-widget-${currentFocusWidget.id}`
49149
+ ) }) })
49150
+ ] }) : /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex-1 flex items-center justify-center", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "text-center text-gray-500", children: [
49151
+ /* @__PURE__ */ jsxRuntimeExports.jsx(Maximize2, { className: "w-12 h-12 mx-auto mb-4 text-gray-300" }),
49152
+ /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-lg font-medium", children: "No widgets available for focus view" }),
49153
+ /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm mt-2", children: "Text, Spacer, and Filter widgets are excluded." })
49154
+ ] }) }) })
49155
+ ) }),
49156
+ /* @__PURE__ */ jsxRuntimeExports.jsx("footer", { className: "bg-white border-t border-gray-200 py-4 shrink-0", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-col items-center gap-3", children: [
49157
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-1 bg-gray-100 rounded-full p-1", children: [
49158
+ /* @__PURE__ */ jsxRuntimeExports.jsxs(
49159
+ "button",
49160
+ {
49161
+ onClick: () => setViewMode("grid"),
49162
+ className: `flex items-center gap-2 px-4 py-2 rounded-full text-sm font-medium transition-all ${viewMode === "grid" ? "bg-primary-700 text-white shadow-md" : "text-gray-600 hover:text-gray-900"}`,
49163
+ children: [
49164
+ /* @__PURE__ */ jsxRuntimeExports.jsx(Grid3X3, { className: "w-4 h-4" }),
49165
+ "Grid"
49166
+ ]
49167
+ }
49168
+ ),
49169
+ /* @__PURE__ */ jsxRuntimeExports.jsxs(
49170
+ "button",
49171
+ {
49172
+ onClick: () => setViewMode("focus"),
49173
+ className: `flex items-center gap-2 px-4 py-2 rounded-full text-sm font-medium transition-all ${viewMode === "focus" ? "bg-primary-700 text-white shadow-md" : "text-gray-600 hover:text-gray-900"}`,
49174
+ children: [
49175
+ /* @__PURE__ */ jsxRuntimeExports.jsx(Maximize2, { className: "w-4 h-4" }),
49176
+ "Focus"
49177
+ ]
49178
+ }
49179
+ ),
49180
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "w-px h-6 bg-gray-300 mx-2" }),
49181
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
49182
+ "button",
49183
+ {
49184
+ onClick: () => setLaserPointerActive((prev) => !prev),
49185
+ className: `p-2 transition-colors rounded-full ${laserPointerActive ? "bg-primary-600 text-white" : "text-gray-600 hover:text-gray-900 hover:bg-gray-200"}`,
49186
+ "aria-label": "Toggle laser pointer (L)",
49187
+ title: "Toggle laser pointer (L)",
49188
+ children: /* @__PURE__ */ jsxRuntimeExports.jsx(LaserPointerIcon, { className: "w-4 h-4" })
49189
+ }
49190
+ ),
49191
+ viewMode === "focus" && focusableWidgets.length > 0 && /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
49192
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "w-px h-6 bg-gray-300 mx-2" }),
49193
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "text-sm text-gray-600 px-2", children: [
49194
+ currentFocusIndex + 1,
49195
+ " / ",
49196
+ focusableWidgets.length
49197
+ ] })
49198
+ ] })
49199
+ ] }),
49200
+ /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-gray-400 uppercase tracking-wider", children: "ESC TO EXIT \u2022 F TO TOGGLE \u2022 L FOR LASER \u2022 ARROWS TO NAVIGATE" })
49201
+ ] }) }),
49202
+ laserPointerActive && /* @__PURE__ */ jsxRuntimeExports.jsxs(
49203
+ "div",
49204
+ {
49205
+ className: "fixed pointer-events-none z-[100] transform -translate-x-1/2 -translate-y-1/2",
49206
+ style: {
49207
+ left: mousePosition.x,
49208
+ top: mousePosition.y
49209
+ },
49210
+ children: [
49211
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "absolute inset-0 w-8 h-8 -translate-x-1/2 -translate-y-1/2 bg-red-500/20 rounded-full blur-md" }),
49212
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "absolute w-4 h-4 -translate-x-1/2 -translate-y-1/2 bg-red-500 rounded-full shadow-lg shadow-red-500/50" })
49213
+ ]
49214
+ }
49215
+ )
49216
+ ] });
49217
+ }
49218
+
48938
49219
  var __defProp = Object.defineProperty;
48939
49220
  var __defProps = Object.defineProperties;
48940
49221
  var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
@@ -49396,5 +49677,5 @@ function DashboardPages({ widgetBackendUrl }) {
49396
49677
  ] });
49397
49678
  }
49398
49679
 
49399
- export { Button, DashboardPages, Input, SavedPages, WidgetDashboard, WidgetPalette, WidgetSettingsPanel, cn };
49680
+ export { Button, DashboardPages, Input, PresentationMode, SavedPages, WidgetDashboard, WidgetPalette, WidgetSettingsPanel, cn };
49400
49681
  //# sourceMappingURL=index.esm.js.map