@optifye/dashboard-core 4.3.3 → 4.3.5

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 (3) hide show
  1. package/dist/index.js +365 -37
  2. package/dist/index.mjs +366 -38
  3. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -25046,12 +25046,22 @@ var AIAgentView = () => {
25046
25046
  const parseChartPatterns = (text) => {
25047
25047
  const chartElements = [];
25048
25048
  let lastIndex = 0;
25049
+ console.log("[DEBUG] Parsing chart patterns from text:", text);
25049
25050
  const chartRegex = /\[\s*(?:Calling\s+|CALL\s+)?(create_[a-z_]+)\s*\(([\s\S]*?)\)\s*\]/g;
25050
25051
  let match;
25051
25052
  const processedIndices = /* @__PURE__ */ new Set();
25053
+ let matchCount = 0;
25052
25054
  while ((match = chartRegex.exec(text)) !== null) {
25055
+ matchCount++;
25053
25056
  const startIndex = match.index;
25054
25057
  const endIndex = startIndex + match[0].length;
25058
+ console.log(`[DEBUG] Found chart pattern #${matchCount}:`, {
25059
+ fullMatch: match[0],
25060
+ chartType: match[1],
25061
+ argsString: match[2],
25062
+ startIndex,
25063
+ endIndex
25064
+ });
25055
25065
  if (!processedIndices.has(startIndex)) {
25056
25066
  processedIndices.add(startIndex);
25057
25067
  if (startIndex > lastIndex) {
@@ -25072,18 +25082,53 @@ var AIAgentView = () => {
25072
25082
  const args = parseChartArguments(argsString);
25073
25083
  const chartElement = renderChart(chartType, args, startIndex);
25074
25084
  if (chartElement) {
25085
+ console.log(`[DEBUG] Successfully rendered chart: ${chartType}`);
25075
25086
  chartElements.push(chartElement);
25087
+ } else {
25088
+ console.warn(`[DEBUG] Chart element was null for type: ${chartType}`);
25089
+ console.warn(`[DEBUG] Args were:`, args);
25090
+ chartElements.push(
25091
+ /* @__PURE__ */ jsxRuntime.jsxs(
25092
+ "div",
25093
+ {
25094
+ className: "text-red-500 text-sm border border-red-300 bg-red-50 p-3 rounded",
25095
+ children: [
25096
+ /* @__PURE__ */ jsxRuntime.jsx("strong", { children: "Chart Rendering Error:" }),
25097
+ " Failed to render ",
25098
+ chartType,
25099
+ /* @__PURE__ */ jsxRuntime.jsx("br", {}),
25100
+ /* @__PURE__ */ jsxRuntime.jsxs("small", { children: [
25101
+ "Check console for details. Args: ",
25102
+ JSON.stringify(args, null, 2)
25103
+ ] })
25104
+ ]
25105
+ },
25106
+ `error-${startIndex}`
25107
+ )
25108
+ );
25076
25109
  }
25077
25110
  } catch (error) {
25078
25111
  console.error(`Failed to parse chart ${chartType}:`, error);
25112
+ console.error(`Args string was:`, argsString);
25079
25113
  chartElements.push(
25080
25114
  /* @__PURE__ */ jsxRuntime.jsxs(
25081
25115
  "div",
25082
25116
  {
25083
- className: "text-red-500 text-sm",
25117
+ className: "text-red-500 text-sm border border-red-300 bg-red-50 p-3 rounded",
25084
25118
  children: [
25085
- "Error rendering chart: ",
25086
- match[0]
25119
+ /* @__PURE__ */ jsxRuntime.jsx("strong", { children: "Chart Parsing Error:" }),
25120
+ " Failed to parse ",
25121
+ chartType,
25122
+ /* @__PURE__ */ jsxRuntime.jsx("br", {}),
25123
+ /* @__PURE__ */ jsxRuntime.jsxs("small", { children: [
25124
+ "Error: ",
25125
+ error instanceof Error ? error.message : String(error)
25126
+ ] }),
25127
+ /* @__PURE__ */ jsxRuntime.jsx("br", {}),
25128
+ /* @__PURE__ */ jsxRuntime.jsxs("small", { children: [
25129
+ "Original: ",
25130
+ match[0]
25131
+ ] })
25087
25132
  ]
25088
25133
  },
25089
25134
  `error-${startIndex}`
@@ -25093,6 +25138,7 @@ var AIAgentView = () => {
25093
25138
  lastIndex = endIndex;
25094
25139
  }
25095
25140
  }
25141
+ console.log(`[DEBUG] Total chart patterns found: ${matchCount}`);
25096
25142
  if (lastIndex < text.length) {
25097
25143
  const remainingText = text.substring(lastIndex);
25098
25144
  chartElements.push(
@@ -25106,47 +25152,139 @@ var AIAgentView = () => {
25106
25152
  );
25107
25153
  }
25108
25154
  if (chartElements.length === 1 && lastIndex === 0) {
25155
+ console.log("[DEBUG] No charts found in text, returning null");
25109
25156
  return null;
25110
25157
  }
25158
+ console.log(`[DEBUG] Returning ${chartElements.length} chart elements`);
25111
25159
  return chartElements;
25112
25160
  };
25113
25161
  const parseChartArguments = (argsString) => {
25114
- const args = {};
25115
- const jsonParamRegex = /(\w+)\s*=\s*(\[[\s\S]*?\](?=\s*(?:,|\s*\)|\s*$))|\{[\s\S]*?\}(?=\s*(?:,|\s*\)|\s*$)))/g;
25116
- let jsonMatch;
25117
- while ((jsonMatch = jsonParamRegex.exec(argsString)) !== null) {
25118
- const paramName = jsonMatch[1];
25119
- const jsonValue = jsonMatch[2];
25120
- try {
25121
- args[paramName] = JSON.parse(jsonValue);
25122
- argsString = argsString.replace(jsonMatch[0], "");
25123
- } catch (e) {
25124
- console.error(`Failed to parse ${paramName} JSON:`, e);
25125
- }
25126
- }
25127
- const argRegex = /(\w+)\s*=\s*("([^"]*)"|'([^']*)'|([^,\s\)]+))/g;
25128
- let argMatch;
25129
- while ((argMatch = argRegex.exec(argsString)) !== null) {
25130
- const key = argMatch[1];
25131
- const value = argMatch[3] || argMatch[4] || argMatch[5];
25132
- if (key === "data") continue;
25133
- if (value === "true" || value === "True") {
25134
- args[key] = true;
25135
- } else if (value === "false" || value === "False") {
25136
- args[key] = false;
25137
- } else if (value === "null" || value === "None") {
25138
- args[key] = null;
25139
- } else if (!isNaN(Number(value)) && value !== "") {
25140
- args[key] = Number(value);
25141
- } else {
25142
- args[key] = value;
25162
+ console.log("[DEBUG] Parsing chart arguments:", argsString);
25163
+ const extractParameters = (str) => {
25164
+ const params = {};
25165
+ let currentPos = 0;
25166
+ while (currentPos < str.length) {
25167
+ while (currentPos < str.length && /\s|,/.test(str[currentPos])) {
25168
+ currentPos++;
25169
+ }
25170
+ if (currentPos >= str.length) break;
25171
+ const paramMatch = str.substring(currentPos).match(/^(\w+)\s*=/);
25172
+ if (!paramMatch) {
25173
+ console.warn("[DEBUG] No parameter name found at position", currentPos);
25174
+ break;
25175
+ }
25176
+ const paramName = paramMatch[1];
25177
+ currentPos += paramMatch[0].length;
25178
+ while (currentPos < str.length && /\s/.test(str[currentPos])) {
25179
+ currentPos++;
25180
+ }
25181
+ if (currentPos >= str.length) break;
25182
+ let value;
25183
+ let valueEnd;
25184
+ if (str[currentPos] === "[") {
25185
+ let bracketCount = 0;
25186
+ let arrayStart = currentPos;
25187
+ valueEnd = str.length;
25188
+ for (let i = currentPos; i < str.length; i++) {
25189
+ if (str[i] === "[") bracketCount++;
25190
+ else if (str[i] === "]") bracketCount--;
25191
+ if (bracketCount === 0) {
25192
+ valueEnd = i + 1;
25193
+ break;
25194
+ }
25195
+ }
25196
+ if (bracketCount !== 0) {
25197
+ console.error("[DEBUG] Unmatched brackets in array value");
25198
+ break;
25199
+ }
25200
+ const arrayStr = str.substring(arrayStart, valueEnd);
25201
+ console.log(`[DEBUG] Found array parameter: ${paramName} = ${arrayStr}`);
25202
+ try {
25203
+ value = JSON.parse(arrayStr);
25204
+ console.log(`[DEBUG] Successfully parsed array ${paramName}:`, value);
25205
+ } catch (e) {
25206
+ console.error(`[DEBUG] Failed to parse array ${paramName}:`, e);
25207
+ console.error(`Array value that failed:`, arrayStr);
25208
+ value = arrayStr;
25209
+ }
25210
+ } else if (str[currentPos] === "{") {
25211
+ let braceCount = 0;
25212
+ let objectStart = currentPos;
25213
+ valueEnd = str.length;
25214
+ for (let i = currentPos; i < str.length; i++) {
25215
+ if (str[i] === "{") braceCount++;
25216
+ else if (str[i] === "}") braceCount--;
25217
+ if (braceCount === 0) {
25218
+ valueEnd = i + 1;
25219
+ break;
25220
+ }
25221
+ }
25222
+ if (braceCount !== 0) {
25223
+ console.error("[DEBUG] Unmatched braces in object value");
25224
+ break;
25225
+ }
25226
+ const objectStr = str.substring(objectStart, valueEnd);
25227
+ console.log(`[DEBUG] Found object parameter: ${paramName} = ${objectStr}`);
25228
+ try {
25229
+ value = JSON.parse(objectStr);
25230
+ console.log(`[DEBUG] Successfully parsed object ${paramName}:`, value);
25231
+ } catch (e) {
25232
+ console.error(`[DEBUG] Failed to parse object ${paramName}:`, e);
25233
+ console.error(`Object value that failed:`, objectStr);
25234
+ value = objectStr;
25235
+ }
25236
+ } else if (str[currentPos] === '"') {
25237
+ let stringStart = currentPos + 1;
25238
+ let stringEnd = stringStart;
25239
+ while (stringEnd < str.length) {
25240
+ if (str[stringEnd] === '"' && str[stringEnd - 1] !== "\\") {
25241
+ break;
25242
+ }
25243
+ stringEnd++;
25244
+ }
25245
+ if (stringEnd >= str.length) {
25246
+ console.error("[DEBUG] Unterminated string value");
25247
+ valueEnd = str.length;
25248
+ break;
25249
+ }
25250
+ value = str.substring(stringStart, stringEnd);
25251
+ valueEnd = stringEnd + 1;
25252
+ console.log(`[DEBUG] Found string parameter: ${paramName} = "${value}"`);
25253
+ } else {
25254
+ let valueStart = currentPos;
25255
+ let valueEndPos = valueStart;
25256
+ while (valueEndPos < str.length && str[valueEndPos] !== ",") {
25257
+ valueEndPos++;
25258
+ }
25259
+ const rawValue = str.substring(valueStart, valueEndPos).trim();
25260
+ valueEnd = valueEndPos;
25261
+ if (rawValue === "true" || rawValue === "True") {
25262
+ value = true;
25263
+ } else if (rawValue === "false" || rawValue === "False") {
25264
+ value = false;
25265
+ } else if (rawValue === "null" || rawValue === "None") {
25266
+ value = null;
25267
+ } else if (!isNaN(Number(rawValue)) && rawValue !== "") {
25268
+ value = Number(rawValue);
25269
+ } else {
25270
+ value = rawValue;
25271
+ }
25272
+ console.log(`[DEBUG] Found unquoted parameter: ${paramName} = ${rawValue} (parsed as ${typeof value})`);
25273
+ }
25274
+ params[paramName] = value;
25275
+ currentPos = valueEnd;
25143
25276
  }
25144
- }
25145
- return args;
25277
+ return params;
25278
+ };
25279
+ const result = extractParameters(argsString);
25280
+ console.log("[DEBUG] Final parsed arguments:", result);
25281
+ return result;
25146
25282
  };
25147
25283
  const renderChart = (chartType, args, key) => {
25284
+ console.log(`[DEBUG] Attempting to render chart type: ${chartType}`, args);
25148
25285
  switch (chartType) {
25149
25286
  case "create_gauge_chart":
25287
+ console.log("[DEBUG] Rendering gauge chart");
25150
25288
  return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "my-6 h-64 w-full flex justify-center", children: /* @__PURE__ */ jsxRuntime.jsx(
25151
25289
  GaugeChart,
25152
25290
  {
@@ -25161,8 +25299,9 @@ var AIAgentView = () => {
25161
25299
  }
25162
25300
  ) }, `gauge-${key}`);
25163
25301
  case "create_bar_chart":
25302
+ console.log("[DEBUG] Rendering bar chart");
25164
25303
  if (!args.data || !args.x_field || !args.y_field) {
25165
- console.error("Bar chart missing required parameters");
25304
+ console.error("Bar chart missing required parameters:", { data: !!args.data, x_field: !!args.x_field, y_field: !!args.y_field });
25166
25305
  return null;
25167
25306
  }
25168
25307
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "my-6 w-full", style: { maxWidth: args.max_width || "100%" }, children: [
@@ -25183,8 +25322,9 @@ var AIAgentView = () => {
25183
25322
  args.title && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-center text-sm text-gray-600 mt-2", children: args.title })
25184
25323
  ] }, `bar-${key}`);
25185
25324
  case "create_line_chart":
25325
+ console.log("[DEBUG] Rendering line chart");
25186
25326
  if (!args.data || !args.x_field || !args.y_field) {
25187
- console.error("Line chart missing required parameters");
25327
+ console.error("Line chart missing required parameters:", { data: !!args.data, x_field: !!args.x_field, y_field: !!args.y_field });
25188
25328
  return null;
25189
25329
  }
25190
25330
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "my-6 w-full", style: {
@@ -25208,14 +25348,17 @@ var AIAgentView = () => {
25208
25348
  args.title && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-center text-sm text-gray-600 mt-2", children: args.title })
25209
25349
  ] }, `line-${key}`);
25210
25350
  case "create_pie_chart":
25351
+ console.log("[DEBUG] Rendering pie chart");
25211
25352
  if (!args.data || !args.label_field || !args.value_field) {
25212
- console.error("Pie chart missing required parameters");
25353
+ console.error("Pie chart missing required parameters:", { data: !!args.data, label_field: !!args.label_field, value_field: !!args.value_field });
25354
+ console.error("Available args:", Object.keys(args));
25213
25355
  return null;
25214
25356
  }
25215
25357
  const pieData = args.data.map((item) => ({
25216
25358
  name: item[args.label_field],
25217
25359
  value: item[args.value_field]
25218
25360
  }));
25361
+ console.log("[DEBUG] Pie chart data transformed:", pieData);
25219
25362
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "my-6 w-full flex flex-col items-center", children: [
25220
25363
  args.title && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm font-medium text-gray-700 mb-2", children: args.title }),
25221
25364
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: "h-64 w-full max-w-md", children: /* @__PURE__ */ jsxRuntime.jsx(
@@ -25227,6 +25370,7 @@ var AIAgentView = () => {
25227
25370
  ) })
25228
25371
  ] }, `pie-${key}`);
25229
25372
  case "create_comparison_table":
25373
+ console.log("[DEBUG] Rendering comparison table");
25230
25374
  if (!args.data) {
25231
25375
  console.error("Comparison table missing required data");
25232
25376
  return null;
@@ -25262,6 +25406,190 @@ var AIAgentView = () => {
25262
25406
  )) }, rowIdx)) })
25263
25407
  ] })
25264
25408
  ] }, `table-${key}`);
25409
+ case "create_multi_line_chart":
25410
+ console.log("[DEBUG] Rendering multi-line chart");
25411
+ if (!args.data || !args.x_field || !args.y_fields || !args.legend) {
25412
+ console.error("Multi-line chart missing required parameters:", {
25413
+ data: !!args.data,
25414
+ x_field: !!args.x_field,
25415
+ y_fields: !!args.y_fields,
25416
+ legend: !!args.legend
25417
+ });
25418
+ return null;
25419
+ }
25420
+ const colors = ["#3b82f6", "#ef4444", "#10b981", "#f59e0b", "#8b5cf6", "#06b6d4", "#84cc16", "#f97316"];
25421
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "my-6 w-full", children: [
25422
+ /* @__PURE__ */ jsxRuntime.jsx(recharts.ResponsiveContainer, { width: "100%", height: 400, children: /* @__PURE__ */ jsxRuntime.jsxs(recharts.LineChart, { data: args.data, children: [
25423
+ /* @__PURE__ */ jsxRuntime.jsx(recharts.CartesianGrid, { strokeDasharray: "3 3" }),
25424
+ /* @__PURE__ */ jsxRuntime.jsx(recharts.XAxis, { dataKey: args.x_field }),
25425
+ /* @__PURE__ */ jsxRuntime.jsx(recharts.YAxis, {}),
25426
+ /* @__PURE__ */ jsxRuntime.jsx(recharts.Tooltip, {}),
25427
+ /* @__PURE__ */ jsxRuntime.jsx(recharts.Legend, {}),
25428
+ args.y_fields.map((field, index) => /* @__PURE__ */ jsxRuntime.jsx(
25429
+ recharts.Line,
25430
+ {
25431
+ type: "monotone",
25432
+ dataKey: field,
25433
+ stroke: colors[index % colors.length],
25434
+ strokeWidth: 2,
25435
+ name: args.legend[index] || field,
25436
+ dot: { r: 4 },
25437
+ activeDot: { r: 6 }
25438
+ },
25439
+ field
25440
+ ))
25441
+ ] }) }),
25442
+ args.title && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-center text-sm text-gray-600 mt-2", children: args.title })
25443
+ ] }, `multi-line-${key}`);
25444
+ case "create_stacked_bar_chart":
25445
+ console.log("[DEBUG] Rendering stacked bar chart");
25446
+ if (!args.data || !args.x_field || !args.stack_fields) {
25447
+ console.error("Stacked bar chart missing required parameters:", {
25448
+ data: !!args.data,
25449
+ x_field: !!args.x_field,
25450
+ stack_fields: !!args.stack_fields
25451
+ });
25452
+ return null;
25453
+ }
25454
+ const stackColors = ["#3b82f6", "#ef4444", "#10b981", "#f59e0b", "#8b5cf6", "#06b6d4", "#84cc16", "#f97316"];
25455
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "my-6 w-full", children: [
25456
+ /* @__PURE__ */ jsxRuntime.jsx(recharts.ResponsiveContainer, { width: "100%", height: 400, children: /* @__PURE__ */ jsxRuntime.jsxs(recharts.BarChart, { data: args.data, children: [
25457
+ /* @__PURE__ */ jsxRuntime.jsx(recharts.CartesianGrid, { strokeDasharray: "3 3" }),
25458
+ /* @__PURE__ */ jsxRuntime.jsx(recharts.XAxis, { dataKey: args.x_field }),
25459
+ /* @__PURE__ */ jsxRuntime.jsx(recharts.YAxis, {}),
25460
+ /* @__PURE__ */ jsxRuntime.jsx(recharts.Tooltip, {}),
25461
+ /* @__PURE__ */ jsxRuntime.jsx(recharts.Legend, {}),
25462
+ args.stack_fields.map((field, index) => /* @__PURE__ */ jsxRuntime.jsx(
25463
+ recharts.Bar,
25464
+ {
25465
+ dataKey: field,
25466
+ stackId: "stack",
25467
+ fill: stackColors[index % stackColors.length],
25468
+ name: field
25469
+ },
25470
+ field
25471
+ ))
25472
+ ] }) }),
25473
+ args.title && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-center text-sm text-gray-600 mt-2", children: args.title })
25474
+ ] }, `stacked-bar-${key}`);
25475
+ case "create_dual_axis_chart":
25476
+ console.log("[DEBUG] Rendering dual-axis chart");
25477
+ if (!args.data || !args.x_field || !args.left_y_field || !args.right_y_field) {
25478
+ console.error("Dual-axis chart missing required parameters:", {
25479
+ data: !!args.data,
25480
+ x_field: !!args.x_field,
25481
+ left_y_field: !!args.left_y_field,
25482
+ right_y_field: !!args.right_y_field
25483
+ });
25484
+ return null;
25485
+ }
25486
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "my-6 w-full", children: [
25487
+ /* @__PURE__ */ jsxRuntime.jsx(recharts.ResponsiveContainer, { width: "100%", height: 400, children: /* @__PURE__ */ jsxRuntime.jsxs(recharts.ComposedChart, { data: args.data, children: [
25488
+ /* @__PURE__ */ jsxRuntime.jsx(recharts.CartesianGrid, { strokeDasharray: "3 3" }),
25489
+ /* @__PURE__ */ jsxRuntime.jsx(recharts.XAxis, { dataKey: args.x_field }),
25490
+ /* @__PURE__ */ jsxRuntime.jsx(recharts.YAxis, { yAxisId: "left", orientation: "left", label: { value: args.left_label || "", angle: -90, position: "insideLeft" } }),
25491
+ /* @__PURE__ */ jsxRuntime.jsx(recharts.YAxis, { yAxisId: "right", orientation: "right", label: { value: args.right_label || "", angle: 90, position: "insideRight" } }),
25492
+ /* @__PURE__ */ jsxRuntime.jsx(recharts.Tooltip, {}),
25493
+ /* @__PURE__ */ jsxRuntime.jsx(recharts.Legend, {}),
25494
+ /* @__PURE__ */ jsxRuntime.jsx(recharts.Bar, { yAxisId: "left", dataKey: args.left_y_field, fill: "#3b82f6", name: args.left_label || args.left_y_field }),
25495
+ /* @__PURE__ */ jsxRuntime.jsx(recharts.Line, { yAxisId: "right", type: "monotone", dataKey: args.right_y_field, stroke: "#ef4444", strokeWidth: 2, name: args.right_label || args.right_y_field })
25496
+ ] }) }),
25497
+ args.title && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-center text-sm text-gray-600 mt-2", children: args.title })
25498
+ ] }, `dual-axis-${key}`);
25499
+ case "create_scatter_plot":
25500
+ console.log("[DEBUG] Rendering scatter plot");
25501
+ if (!args.data || !args.x_field || !args.y_field || !args.group_field) {
25502
+ console.error("Scatter plot missing required parameters:", {
25503
+ data: !!args.data,
25504
+ x_field: !!args.x_field,
25505
+ y_field: !!args.y_field,
25506
+ group_field: !!args.group_field
25507
+ });
25508
+ return null;
25509
+ }
25510
+ const groupedData = args.data.reduce((acc, item) => {
25511
+ const group = item[args.group_field];
25512
+ if (!acc[group]) {
25513
+ acc[group] = [];
25514
+ }
25515
+ acc[group].push(item);
25516
+ return acc;
25517
+ }, {});
25518
+ const scatterColors = ["#3b82f6", "#ef4444", "#10b981", "#f59e0b", "#8b5cf6", "#06b6d4", "#84cc16", "#f97316"];
25519
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "my-6 w-full", children: [
25520
+ /* @__PURE__ */ jsxRuntime.jsx(recharts.ResponsiveContainer, { width: "100%", height: 400, children: /* @__PURE__ */ jsxRuntime.jsxs(recharts.ScatterChart, { children: [
25521
+ /* @__PURE__ */ jsxRuntime.jsx(recharts.CartesianGrid, { strokeDasharray: "3 3" }),
25522
+ /* @__PURE__ */ jsxRuntime.jsx(recharts.XAxis, { dataKey: args.x_field, type: "number", name: args.x_field }),
25523
+ /* @__PURE__ */ jsxRuntime.jsx(recharts.YAxis, { dataKey: args.y_field, type: "number", name: args.y_field }),
25524
+ /* @__PURE__ */ jsxRuntime.jsx(recharts.Tooltip, { cursor: { strokeDasharray: "3 3" } }),
25525
+ /* @__PURE__ */ jsxRuntime.jsx(recharts.Legend, {}),
25526
+ Object.entries(groupedData).map(([group, data], index) => /* @__PURE__ */ jsxRuntime.jsx(
25527
+ recharts.Scatter,
25528
+ {
25529
+ name: group,
25530
+ data,
25531
+ fill: scatterColors[index % scatterColors.length]
25532
+ },
25533
+ group
25534
+ ))
25535
+ ] }) }),
25536
+ args.title && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-center text-sm text-gray-600 mt-2", children: args.title })
25537
+ ] }, `scatter-${key}`);
25538
+ case "create_combo_chart":
25539
+ console.log("[DEBUG] Rendering combo chart");
25540
+ if (!args.data || !args.x_field || !args.bar_field || !args.line_field) {
25541
+ console.error("Combo chart missing required parameters:", {
25542
+ data: !!args.data,
25543
+ x_field: !!args.x_field,
25544
+ bar_field: !!args.bar_field,
25545
+ line_field: !!args.line_field
25546
+ });
25547
+ return null;
25548
+ }
25549
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "my-6 w-full", children: [
25550
+ /* @__PURE__ */ jsxRuntime.jsx(recharts.ResponsiveContainer, { width: "100%", height: 400, children: /* @__PURE__ */ jsxRuntime.jsxs(recharts.ComposedChart, { data: args.data, children: [
25551
+ /* @__PURE__ */ jsxRuntime.jsx(recharts.CartesianGrid, { strokeDasharray: "3 3" }),
25552
+ /* @__PURE__ */ jsxRuntime.jsx(recharts.XAxis, { dataKey: args.x_field }),
25553
+ /* @__PURE__ */ jsxRuntime.jsx(recharts.YAxis, { yAxisId: "left", orientation: "left" }),
25554
+ /* @__PURE__ */ jsxRuntime.jsx(recharts.YAxis, { yAxisId: "right", orientation: "right" }),
25555
+ /* @__PURE__ */ jsxRuntime.jsx(recharts.Tooltip, {}),
25556
+ /* @__PURE__ */ jsxRuntime.jsx(recharts.Legend, {}),
25557
+ /* @__PURE__ */ jsxRuntime.jsx(recharts.Bar, { yAxisId: "left", dataKey: args.bar_field, fill: "#3b82f6", name: args.bar_field }),
25558
+ /* @__PURE__ */ jsxRuntime.jsx(recharts.Line, { yAxisId: "right", type: "monotone", dataKey: args.line_field, stroke: "#ef4444", strokeWidth: 2, name: args.line_field })
25559
+ ] }) }),
25560
+ args.title && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-center text-sm text-gray-600 mt-2", children: args.title })
25561
+ ] }, `combo-${key}`);
25562
+ case "create_area_chart":
25563
+ console.log("[DEBUG] Rendering area chart");
25564
+ if (!args.data || !args.x_field || !args.y_field) {
25565
+ console.error("Area chart missing required parameters:", {
25566
+ data: !!args.data,
25567
+ x_field: !!args.x_field,
25568
+ y_field: !!args.y_field
25569
+ });
25570
+ return null;
25571
+ }
25572
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "my-6 w-full", children: [
25573
+ /* @__PURE__ */ jsxRuntime.jsx(recharts.ResponsiveContainer, { width: "100%", height: 400, children: /* @__PURE__ */ jsxRuntime.jsxs(recharts.ComposedChart, { data: args.data, children: [
25574
+ /* @__PURE__ */ jsxRuntime.jsx(recharts.CartesianGrid, { strokeDasharray: "3 3" }),
25575
+ /* @__PURE__ */ jsxRuntime.jsx(recharts.XAxis, { dataKey: args.x_field }),
25576
+ /* @__PURE__ */ jsxRuntime.jsx(recharts.YAxis, {}),
25577
+ /* @__PURE__ */ jsxRuntime.jsx(recharts.Tooltip, {}),
25578
+ /* @__PURE__ */ jsxRuntime.jsx(recharts.Legend, {}),
25579
+ /* @__PURE__ */ jsxRuntime.jsx(
25580
+ recharts.Area,
25581
+ {
25582
+ type: "monotone",
25583
+ dataKey: args.y_field,
25584
+ stroke: "#3b82f6",
25585
+ fill: args.fill ? "#3b82f6" : "none",
25586
+ fillOpacity: args.fill ? 0.6 : 0,
25587
+ name: args.y_field
25588
+ }
25589
+ )
25590
+ ] }) }),
25591
+ args.title && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-center text-sm text-gray-600 mt-2", children: args.title })
25592
+ ] }, `area-${key}`);
25265
25593
  default:
25266
25594
  console.warn(`Unknown chart type: ${chartType}`);
25267
25595
  return null;
package/dist/index.mjs CHANGED
@@ -10,7 +10,7 @@ import Hls2 from 'hls.js';
10
10
  import useSWR from 'swr';
11
11
  import { noop, warning, invariant, progress, secondsToMilliseconds, millisecondsToSeconds, memo as memo$1 } from 'motion-utils';
12
12
  import { getValueTransition, hover, press, isPrimaryPointer, GroupPlaybackControls, setDragLock, supportsLinearEasing, attachTimeline, isGenerator, calcGeneratorDuration, isWaapiSupportedEasing, mapEasingToNativeEasing, maxGeneratorDuration, generateLinearEasing, isBezierDefinition } from 'motion-dom';
13
- import { Bar, LabelList, ResponsiveContainer, BarChart as BarChart$1, CartesianGrid, XAxis, YAxis, Tooltip, ReferenceLine, Cell, PieChart, Pie, Legend, LineChart as LineChart$1, Line } from 'recharts';
13
+ import { Bar, LabelList, ResponsiveContainer, BarChart as BarChart$1, CartesianGrid, XAxis, YAxis, Tooltip, ReferenceLine, Cell, PieChart, Pie, Legend, LineChart as LineChart$1, Line, ComposedChart, Area, ScatterChart, Scatter } from 'recharts';
14
14
  import { Slot } from '@radix-ui/react-slot';
15
15
  import { Camera, ChevronDown, ChevronUp, Check, ShieldCheck, Star, Award, X, Coffee, Plus, Clock, Minus, ArrowDown, ArrowUp, Search, CheckCircle, AlertTriangle, Info, Share2, Download, User, XCircle, ChevronLeft, ChevronRight, AlertCircle, Sun, Moon, MessageSquare, Trash2, ArrowLeft, RefreshCw, Menu, Send, Copy, Edit2, UserCheck, Save, LogOut, Calendar, Settings, LifeBuoy, Loader2, ArrowLeftIcon as ArrowLeftIcon$1, Settings2, CheckCircle2, EyeOff, Eye, Zap, UserCircle } from 'lucide-react';
16
16
  import { DayPicker, useNavigation as useNavigation$1 } from 'react-day-picker';
@@ -25017,12 +25017,22 @@ var AIAgentView = () => {
25017
25017
  const parseChartPatterns = (text) => {
25018
25018
  const chartElements = [];
25019
25019
  let lastIndex = 0;
25020
+ console.log("[DEBUG] Parsing chart patterns from text:", text);
25020
25021
  const chartRegex = /\[\s*(?:Calling\s+|CALL\s+)?(create_[a-z_]+)\s*\(([\s\S]*?)\)\s*\]/g;
25021
25022
  let match;
25022
25023
  const processedIndices = /* @__PURE__ */ new Set();
25024
+ let matchCount = 0;
25023
25025
  while ((match = chartRegex.exec(text)) !== null) {
25026
+ matchCount++;
25024
25027
  const startIndex = match.index;
25025
25028
  const endIndex = startIndex + match[0].length;
25029
+ console.log(`[DEBUG] Found chart pattern #${matchCount}:`, {
25030
+ fullMatch: match[0],
25031
+ chartType: match[1],
25032
+ argsString: match[2],
25033
+ startIndex,
25034
+ endIndex
25035
+ });
25026
25036
  if (!processedIndices.has(startIndex)) {
25027
25037
  processedIndices.add(startIndex);
25028
25038
  if (startIndex > lastIndex) {
@@ -25043,18 +25053,53 @@ var AIAgentView = () => {
25043
25053
  const args = parseChartArguments(argsString);
25044
25054
  const chartElement = renderChart(chartType, args, startIndex);
25045
25055
  if (chartElement) {
25056
+ console.log(`[DEBUG] Successfully rendered chart: ${chartType}`);
25046
25057
  chartElements.push(chartElement);
25058
+ } else {
25059
+ console.warn(`[DEBUG] Chart element was null for type: ${chartType}`);
25060
+ console.warn(`[DEBUG] Args were:`, args);
25061
+ chartElements.push(
25062
+ /* @__PURE__ */ jsxs(
25063
+ "div",
25064
+ {
25065
+ className: "text-red-500 text-sm border border-red-300 bg-red-50 p-3 rounded",
25066
+ children: [
25067
+ /* @__PURE__ */ jsx("strong", { children: "Chart Rendering Error:" }),
25068
+ " Failed to render ",
25069
+ chartType,
25070
+ /* @__PURE__ */ jsx("br", {}),
25071
+ /* @__PURE__ */ jsxs("small", { children: [
25072
+ "Check console for details. Args: ",
25073
+ JSON.stringify(args, null, 2)
25074
+ ] })
25075
+ ]
25076
+ },
25077
+ `error-${startIndex}`
25078
+ )
25079
+ );
25047
25080
  }
25048
25081
  } catch (error) {
25049
25082
  console.error(`Failed to parse chart ${chartType}:`, error);
25083
+ console.error(`Args string was:`, argsString);
25050
25084
  chartElements.push(
25051
25085
  /* @__PURE__ */ jsxs(
25052
25086
  "div",
25053
25087
  {
25054
- className: "text-red-500 text-sm",
25088
+ className: "text-red-500 text-sm border border-red-300 bg-red-50 p-3 rounded",
25055
25089
  children: [
25056
- "Error rendering chart: ",
25057
- match[0]
25090
+ /* @__PURE__ */ jsx("strong", { children: "Chart Parsing Error:" }),
25091
+ " Failed to parse ",
25092
+ chartType,
25093
+ /* @__PURE__ */ jsx("br", {}),
25094
+ /* @__PURE__ */ jsxs("small", { children: [
25095
+ "Error: ",
25096
+ error instanceof Error ? error.message : String(error)
25097
+ ] }),
25098
+ /* @__PURE__ */ jsx("br", {}),
25099
+ /* @__PURE__ */ jsxs("small", { children: [
25100
+ "Original: ",
25101
+ match[0]
25102
+ ] })
25058
25103
  ]
25059
25104
  },
25060
25105
  `error-${startIndex}`
@@ -25064,6 +25109,7 @@ var AIAgentView = () => {
25064
25109
  lastIndex = endIndex;
25065
25110
  }
25066
25111
  }
25112
+ console.log(`[DEBUG] Total chart patterns found: ${matchCount}`);
25067
25113
  if (lastIndex < text.length) {
25068
25114
  const remainingText = text.substring(lastIndex);
25069
25115
  chartElements.push(
@@ -25077,47 +25123,139 @@ var AIAgentView = () => {
25077
25123
  );
25078
25124
  }
25079
25125
  if (chartElements.length === 1 && lastIndex === 0) {
25126
+ console.log("[DEBUG] No charts found in text, returning null");
25080
25127
  return null;
25081
25128
  }
25129
+ console.log(`[DEBUG] Returning ${chartElements.length} chart elements`);
25082
25130
  return chartElements;
25083
25131
  };
25084
25132
  const parseChartArguments = (argsString) => {
25085
- const args = {};
25086
- const jsonParamRegex = /(\w+)\s*=\s*(\[[\s\S]*?\](?=\s*(?:,|\s*\)|\s*$))|\{[\s\S]*?\}(?=\s*(?:,|\s*\)|\s*$)))/g;
25087
- let jsonMatch;
25088
- while ((jsonMatch = jsonParamRegex.exec(argsString)) !== null) {
25089
- const paramName = jsonMatch[1];
25090
- const jsonValue = jsonMatch[2];
25091
- try {
25092
- args[paramName] = JSON.parse(jsonValue);
25093
- argsString = argsString.replace(jsonMatch[0], "");
25094
- } catch (e) {
25095
- console.error(`Failed to parse ${paramName} JSON:`, e);
25096
- }
25097
- }
25098
- const argRegex = /(\w+)\s*=\s*("([^"]*)"|'([^']*)'|([^,\s\)]+))/g;
25099
- let argMatch;
25100
- while ((argMatch = argRegex.exec(argsString)) !== null) {
25101
- const key = argMatch[1];
25102
- const value = argMatch[3] || argMatch[4] || argMatch[5];
25103
- if (key === "data") continue;
25104
- if (value === "true" || value === "True") {
25105
- args[key] = true;
25106
- } else if (value === "false" || value === "False") {
25107
- args[key] = false;
25108
- } else if (value === "null" || value === "None") {
25109
- args[key] = null;
25110
- } else if (!isNaN(Number(value)) && value !== "") {
25111
- args[key] = Number(value);
25112
- } else {
25113
- args[key] = value;
25133
+ console.log("[DEBUG] Parsing chart arguments:", argsString);
25134
+ const extractParameters = (str) => {
25135
+ const params = {};
25136
+ let currentPos = 0;
25137
+ while (currentPos < str.length) {
25138
+ while (currentPos < str.length && /\s|,/.test(str[currentPos])) {
25139
+ currentPos++;
25140
+ }
25141
+ if (currentPos >= str.length) break;
25142
+ const paramMatch = str.substring(currentPos).match(/^(\w+)\s*=/);
25143
+ if (!paramMatch) {
25144
+ console.warn("[DEBUG] No parameter name found at position", currentPos);
25145
+ break;
25146
+ }
25147
+ const paramName = paramMatch[1];
25148
+ currentPos += paramMatch[0].length;
25149
+ while (currentPos < str.length && /\s/.test(str[currentPos])) {
25150
+ currentPos++;
25151
+ }
25152
+ if (currentPos >= str.length) break;
25153
+ let value;
25154
+ let valueEnd;
25155
+ if (str[currentPos] === "[") {
25156
+ let bracketCount = 0;
25157
+ let arrayStart = currentPos;
25158
+ valueEnd = str.length;
25159
+ for (let i = currentPos; i < str.length; i++) {
25160
+ if (str[i] === "[") bracketCount++;
25161
+ else if (str[i] === "]") bracketCount--;
25162
+ if (bracketCount === 0) {
25163
+ valueEnd = i + 1;
25164
+ break;
25165
+ }
25166
+ }
25167
+ if (bracketCount !== 0) {
25168
+ console.error("[DEBUG] Unmatched brackets in array value");
25169
+ break;
25170
+ }
25171
+ const arrayStr = str.substring(arrayStart, valueEnd);
25172
+ console.log(`[DEBUG] Found array parameter: ${paramName} = ${arrayStr}`);
25173
+ try {
25174
+ value = JSON.parse(arrayStr);
25175
+ console.log(`[DEBUG] Successfully parsed array ${paramName}:`, value);
25176
+ } catch (e) {
25177
+ console.error(`[DEBUG] Failed to parse array ${paramName}:`, e);
25178
+ console.error(`Array value that failed:`, arrayStr);
25179
+ value = arrayStr;
25180
+ }
25181
+ } else if (str[currentPos] === "{") {
25182
+ let braceCount = 0;
25183
+ let objectStart = currentPos;
25184
+ valueEnd = str.length;
25185
+ for (let i = currentPos; i < str.length; i++) {
25186
+ if (str[i] === "{") braceCount++;
25187
+ else if (str[i] === "}") braceCount--;
25188
+ if (braceCount === 0) {
25189
+ valueEnd = i + 1;
25190
+ break;
25191
+ }
25192
+ }
25193
+ if (braceCount !== 0) {
25194
+ console.error("[DEBUG] Unmatched braces in object value");
25195
+ break;
25196
+ }
25197
+ const objectStr = str.substring(objectStart, valueEnd);
25198
+ console.log(`[DEBUG] Found object parameter: ${paramName} = ${objectStr}`);
25199
+ try {
25200
+ value = JSON.parse(objectStr);
25201
+ console.log(`[DEBUG] Successfully parsed object ${paramName}:`, value);
25202
+ } catch (e) {
25203
+ console.error(`[DEBUG] Failed to parse object ${paramName}:`, e);
25204
+ console.error(`Object value that failed:`, objectStr);
25205
+ value = objectStr;
25206
+ }
25207
+ } else if (str[currentPos] === '"') {
25208
+ let stringStart = currentPos + 1;
25209
+ let stringEnd = stringStart;
25210
+ while (stringEnd < str.length) {
25211
+ if (str[stringEnd] === '"' && str[stringEnd - 1] !== "\\") {
25212
+ break;
25213
+ }
25214
+ stringEnd++;
25215
+ }
25216
+ if (stringEnd >= str.length) {
25217
+ console.error("[DEBUG] Unterminated string value");
25218
+ valueEnd = str.length;
25219
+ break;
25220
+ }
25221
+ value = str.substring(stringStart, stringEnd);
25222
+ valueEnd = stringEnd + 1;
25223
+ console.log(`[DEBUG] Found string parameter: ${paramName} = "${value}"`);
25224
+ } else {
25225
+ let valueStart = currentPos;
25226
+ let valueEndPos = valueStart;
25227
+ while (valueEndPos < str.length && str[valueEndPos] !== ",") {
25228
+ valueEndPos++;
25229
+ }
25230
+ const rawValue = str.substring(valueStart, valueEndPos).trim();
25231
+ valueEnd = valueEndPos;
25232
+ if (rawValue === "true" || rawValue === "True") {
25233
+ value = true;
25234
+ } else if (rawValue === "false" || rawValue === "False") {
25235
+ value = false;
25236
+ } else if (rawValue === "null" || rawValue === "None") {
25237
+ value = null;
25238
+ } else if (!isNaN(Number(rawValue)) && rawValue !== "") {
25239
+ value = Number(rawValue);
25240
+ } else {
25241
+ value = rawValue;
25242
+ }
25243
+ console.log(`[DEBUG] Found unquoted parameter: ${paramName} = ${rawValue} (parsed as ${typeof value})`);
25244
+ }
25245
+ params[paramName] = value;
25246
+ currentPos = valueEnd;
25114
25247
  }
25115
- }
25116
- return args;
25248
+ return params;
25249
+ };
25250
+ const result = extractParameters(argsString);
25251
+ console.log("[DEBUG] Final parsed arguments:", result);
25252
+ return result;
25117
25253
  };
25118
25254
  const renderChart = (chartType, args, key) => {
25255
+ console.log(`[DEBUG] Attempting to render chart type: ${chartType}`, args);
25119
25256
  switch (chartType) {
25120
25257
  case "create_gauge_chart":
25258
+ console.log("[DEBUG] Rendering gauge chart");
25121
25259
  return /* @__PURE__ */ jsx("div", { className: "my-6 h-64 w-full flex justify-center", children: /* @__PURE__ */ jsx(
25122
25260
  GaugeChart,
25123
25261
  {
@@ -25132,8 +25270,9 @@ var AIAgentView = () => {
25132
25270
  }
25133
25271
  ) }, `gauge-${key}`);
25134
25272
  case "create_bar_chart":
25273
+ console.log("[DEBUG] Rendering bar chart");
25135
25274
  if (!args.data || !args.x_field || !args.y_field) {
25136
- console.error("Bar chart missing required parameters");
25275
+ console.error("Bar chart missing required parameters:", { data: !!args.data, x_field: !!args.x_field, y_field: !!args.y_field });
25137
25276
  return null;
25138
25277
  }
25139
25278
  return /* @__PURE__ */ jsxs("div", { className: "my-6 w-full", style: { maxWidth: args.max_width || "100%" }, children: [
@@ -25154,8 +25293,9 @@ var AIAgentView = () => {
25154
25293
  args.title && /* @__PURE__ */ jsx("p", { className: "text-center text-sm text-gray-600 mt-2", children: args.title })
25155
25294
  ] }, `bar-${key}`);
25156
25295
  case "create_line_chart":
25296
+ console.log("[DEBUG] Rendering line chart");
25157
25297
  if (!args.data || !args.x_field || !args.y_field) {
25158
- console.error("Line chart missing required parameters");
25298
+ console.error("Line chart missing required parameters:", { data: !!args.data, x_field: !!args.x_field, y_field: !!args.y_field });
25159
25299
  return null;
25160
25300
  }
25161
25301
  return /* @__PURE__ */ jsxs("div", { className: "my-6 w-full", style: {
@@ -25179,14 +25319,17 @@ var AIAgentView = () => {
25179
25319
  args.title && /* @__PURE__ */ jsx("p", { className: "text-center text-sm text-gray-600 mt-2", children: args.title })
25180
25320
  ] }, `line-${key}`);
25181
25321
  case "create_pie_chart":
25322
+ console.log("[DEBUG] Rendering pie chart");
25182
25323
  if (!args.data || !args.label_field || !args.value_field) {
25183
- console.error("Pie chart missing required parameters");
25324
+ console.error("Pie chart missing required parameters:", { data: !!args.data, label_field: !!args.label_field, value_field: !!args.value_field });
25325
+ console.error("Available args:", Object.keys(args));
25184
25326
  return null;
25185
25327
  }
25186
25328
  const pieData = args.data.map((item) => ({
25187
25329
  name: item[args.label_field],
25188
25330
  value: item[args.value_field]
25189
25331
  }));
25332
+ console.log("[DEBUG] Pie chart data transformed:", pieData);
25190
25333
  return /* @__PURE__ */ jsxs("div", { className: "my-6 w-full flex flex-col items-center", children: [
25191
25334
  args.title && /* @__PURE__ */ jsx("p", { className: "text-sm font-medium text-gray-700 mb-2", children: args.title }),
25192
25335
  /* @__PURE__ */ jsx("div", { className: "h-64 w-full max-w-md", children: /* @__PURE__ */ jsx(
@@ -25198,6 +25341,7 @@ var AIAgentView = () => {
25198
25341
  ) })
25199
25342
  ] }, `pie-${key}`);
25200
25343
  case "create_comparison_table":
25344
+ console.log("[DEBUG] Rendering comparison table");
25201
25345
  if (!args.data) {
25202
25346
  console.error("Comparison table missing required data");
25203
25347
  return null;
@@ -25233,6 +25377,190 @@ var AIAgentView = () => {
25233
25377
  )) }, rowIdx)) })
25234
25378
  ] })
25235
25379
  ] }, `table-${key}`);
25380
+ case "create_multi_line_chart":
25381
+ console.log("[DEBUG] Rendering multi-line chart");
25382
+ if (!args.data || !args.x_field || !args.y_fields || !args.legend) {
25383
+ console.error("Multi-line chart missing required parameters:", {
25384
+ data: !!args.data,
25385
+ x_field: !!args.x_field,
25386
+ y_fields: !!args.y_fields,
25387
+ legend: !!args.legend
25388
+ });
25389
+ return null;
25390
+ }
25391
+ const colors = ["#3b82f6", "#ef4444", "#10b981", "#f59e0b", "#8b5cf6", "#06b6d4", "#84cc16", "#f97316"];
25392
+ return /* @__PURE__ */ jsxs("div", { className: "my-6 w-full", children: [
25393
+ /* @__PURE__ */ jsx(ResponsiveContainer, { width: "100%", height: 400, children: /* @__PURE__ */ jsxs(LineChart$1, { data: args.data, children: [
25394
+ /* @__PURE__ */ jsx(CartesianGrid, { strokeDasharray: "3 3" }),
25395
+ /* @__PURE__ */ jsx(XAxis, { dataKey: args.x_field }),
25396
+ /* @__PURE__ */ jsx(YAxis, {}),
25397
+ /* @__PURE__ */ jsx(Tooltip, {}),
25398
+ /* @__PURE__ */ jsx(Legend, {}),
25399
+ args.y_fields.map((field, index) => /* @__PURE__ */ jsx(
25400
+ Line,
25401
+ {
25402
+ type: "monotone",
25403
+ dataKey: field,
25404
+ stroke: colors[index % colors.length],
25405
+ strokeWidth: 2,
25406
+ name: args.legend[index] || field,
25407
+ dot: { r: 4 },
25408
+ activeDot: { r: 6 }
25409
+ },
25410
+ field
25411
+ ))
25412
+ ] }) }),
25413
+ args.title && /* @__PURE__ */ jsx("p", { className: "text-center text-sm text-gray-600 mt-2", children: args.title })
25414
+ ] }, `multi-line-${key}`);
25415
+ case "create_stacked_bar_chart":
25416
+ console.log("[DEBUG] Rendering stacked bar chart");
25417
+ if (!args.data || !args.x_field || !args.stack_fields) {
25418
+ console.error("Stacked bar chart missing required parameters:", {
25419
+ data: !!args.data,
25420
+ x_field: !!args.x_field,
25421
+ stack_fields: !!args.stack_fields
25422
+ });
25423
+ return null;
25424
+ }
25425
+ const stackColors = ["#3b82f6", "#ef4444", "#10b981", "#f59e0b", "#8b5cf6", "#06b6d4", "#84cc16", "#f97316"];
25426
+ return /* @__PURE__ */ jsxs("div", { className: "my-6 w-full", children: [
25427
+ /* @__PURE__ */ jsx(ResponsiveContainer, { width: "100%", height: 400, children: /* @__PURE__ */ jsxs(BarChart$1, { data: args.data, children: [
25428
+ /* @__PURE__ */ jsx(CartesianGrid, { strokeDasharray: "3 3" }),
25429
+ /* @__PURE__ */ jsx(XAxis, { dataKey: args.x_field }),
25430
+ /* @__PURE__ */ jsx(YAxis, {}),
25431
+ /* @__PURE__ */ jsx(Tooltip, {}),
25432
+ /* @__PURE__ */ jsx(Legend, {}),
25433
+ args.stack_fields.map((field, index) => /* @__PURE__ */ jsx(
25434
+ Bar,
25435
+ {
25436
+ dataKey: field,
25437
+ stackId: "stack",
25438
+ fill: stackColors[index % stackColors.length],
25439
+ name: field
25440
+ },
25441
+ field
25442
+ ))
25443
+ ] }) }),
25444
+ args.title && /* @__PURE__ */ jsx("p", { className: "text-center text-sm text-gray-600 mt-2", children: args.title })
25445
+ ] }, `stacked-bar-${key}`);
25446
+ case "create_dual_axis_chart":
25447
+ console.log("[DEBUG] Rendering dual-axis chart");
25448
+ if (!args.data || !args.x_field || !args.left_y_field || !args.right_y_field) {
25449
+ console.error("Dual-axis chart missing required parameters:", {
25450
+ data: !!args.data,
25451
+ x_field: !!args.x_field,
25452
+ left_y_field: !!args.left_y_field,
25453
+ right_y_field: !!args.right_y_field
25454
+ });
25455
+ return null;
25456
+ }
25457
+ return /* @__PURE__ */ jsxs("div", { className: "my-6 w-full", children: [
25458
+ /* @__PURE__ */ jsx(ResponsiveContainer, { width: "100%", height: 400, children: /* @__PURE__ */ jsxs(ComposedChart, { data: args.data, children: [
25459
+ /* @__PURE__ */ jsx(CartesianGrid, { strokeDasharray: "3 3" }),
25460
+ /* @__PURE__ */ jsx(XAxis, { dataKey: args.x_field }),
25461
+ /* @__PURE__ */ jsx(YAxis, { yAxisId: "left", orientation: "left", label: { value: args.left_label || "", angle: -90, position: "insideLeft" } }),
25462
+ /* @__PURE__ */ jsx(YAxis, { yAxisId: "right", orientation: "right", label: { value: args.right_label || "", angle: 90, position: "insideRight" } }),
25463
+ /* @__PURE__ */ jsx(Tooltip, {}),
25464
+ /* @__PURE__ */ jsx(Legend, {}),
25465
+ /* @__PURE__ */ jsx(Bar, { yAxisId: "left", dataKey: args.left_y_field, fill: "#3b82f6", name: args.left_label || args.left_y_field }),
25466
+ /* @__PURE__ */ jsx(Line, { yAxisId: "right", type: "monotone", dataKey: args.right_y_field, stroke: "#ef4444", strokeWidth: 2, name: args.right_label || args.right_y_field })
25467
+ ] }) }),
25468
+ args.title && /* @__PURE__ */ jsx("p", { className: "text-center text-sm text-gray-600 mt-2", children: args.title })
25469
+ ] }, `dual-axis-${key}`);
25470
+ case "create_scatter_plot":
25471
+ console.log("[DEBUG] Rendering scatter plot");
25472
+ if (!args.data || !args.x_field || !args.y_field || !args.group_field) {
25473
+ console.error("Scatter plot missing required parameters:", {
25474
+ data: !!args.data,
25475
+ x_field: !!args.x_field,
25476
+ y_field: !!args.y_field,
25477
+ group_field: !!args.group_field
25478
+ });
25479
+ return null;
25480
+ }
25481
+ const groupedData = args.data.reduce((acc, item) => {
25482
+ const group = item[args.group_field];
25483
+ if (!acc[group]) {
25484
+ acc[group] = [];
25485
+ }
25486
+ acc[group].push(item);
25487
+ return acc;
25488
+ }, {});
25489
+ const scatterColors = ["#3b82f6", "#ef4444", "#10b981", "#f59e0b", "#8b5cf6", "#06b6d4", "#84cc16", "#f97316"];
25490
+ return /* @__PURE__ */ jsxs("div", { className: "my-6 w-full", children: [
25491
+ /* @__PURE__ */ jsx(ResponsiveContainer, { width: "100%", height: 400, children: /* @__PURE__ */ jsxs(ScatterChart, { children: [
25492
+ /* @__PURE__ */ jsx(CartesianGrid, { strokeDasharray: "3 3" }),
25493
+ /* @__PURE__ */ jsx(XAxis, { dataKey: args.x_field, type: "number", name: args.x_field }),
25494
+ /* @__PURE__ */ jsx(YAxis, { dataKey: args.y_field, type: "number", name: args.y_field }),
25495
+ /* @__PURE__ */ jsx(Tooltip, { cursor: { strokeDasharray: "3 3" } }),
25496
+ /* @__PURE__ */ jsx(Legend, {}),
25497
+ Object.entries(groupedData).map(([group, data], index) => /* @__PURE__ */ jsx(
25498
+ Scatter,
25499
+ {
25500
+ name: group,
25501
+ data,
25502
+ fill: scatterColors[index % scatterColors.length]
25503
+ },
25504
+ group
25505
+ ))
25506
+ ] }) }),
25507
+ args.title && /* @__PURE__ */ jsx("p", { className: "text-center text-sm text-gray-600 mt-2", children: args.title })
25508
+ ] }, `scatter-${key}`);
25509
+ case "create_combo_chart":
25510
+ console.log("[DEBUG] Rendering combo chart");
25511
+ if (!args.data || !args.x_field || !args.bar_field || !args.line_field) {
25512
+ console.error("Combo chart missing required parameters:", {
25513
+ data: !!args.data,
25514
+ x_field: !!args.x_field,
25515
+ bar_field: !!args.bar_field,
25516
+ line_field: !!args.line_field
25517
+ });
25518
+ return null;
25519
+ }
25520
+ return /* @__PURE__ */ jsxs("div", { className: "my-6 w-full", children: [
25521
+ /* @__PURE__ */ jsx(ResponsiveContainer, { width: "100%", height: 400, children: /* @__PURE__ */ jsxs(ComposedChart, { data: args.data, children: [
25522
+ /* @__PURE__ */ jsx(CartesianGrid, { strokeDasharray: "3 3" }),
25523
+ /* @__PURE__ */ jsx(XAxis, { dataKey: args.x_field }),
25524
+ /* @__PURE__ */ jsx(YAxis, { yAxisId: "left", orientation: "left" }),
25525
+ /* @__PURE__ */ jsx(YAxis, { yAxisId: "right", orientation: "right" }),
25526
+ /* @__PURE__ */ jsx(Tooltip, {}),
25527
+ /* @__PURE__ */ jsx(Legend, {}),
25528
+ /* @__PURE__ */ jsx(Bar, { yAxisId: "left", dataKey: args.bar_field, fill: "#3b82f6", name: args.bar_field }),
25529
+ /* @__PURE__ */ jsx(Line, { yAxisId: "right", type: "monotone", dataKey: args.line_field, stroke: "#ef4444", strokeWidth: 2, name: args.line_field })
25530
+ ] }) }),
25531
+ args.title && /* @__PURE__ */ jsx("p", { className: "text-center text-sm text-gray-600 mt-2", children: args.title })
25532
+ ] }, `combo-${key}`);
25533
+ case "create_area_chart":
25534
+ console.log("[DEBUG] Rendering area chart");
25535
+ if (!args.data || !args.x_field || !args.y_field) {
25536
+ console.error("Area chart missing required parameters:", {
25537
+ data: !!args.data,
25538
+ x_field: !!args.x_field,
25539
+ y_field: !!args.y_field
25540
+ });
25541
+ return null;
25542
+ }
25543
+ return /* @__PURE__ */ jsxs("div", { className: "my-6 w-full", children: [
25544
+ /* @__PURE__ */ jsx(ResponsiveContainer, { width: "100%", height: 400, children: /* @__PURE__ */ jsxs(ComposedChart, { data: args.data, children: [
25545
+ /* @__PURE__ */ jsx(CartesianGrid, { strokeDasharray: "3 3" }),
25546
+ /* @__PURE__ */ jsx(XAxis, { dataKey: args.x_field }),
25547
+ /* @__PURE__ */ jsx(YAxis, {}),
25548
+ /* @__PURE__ */ jsx(Tooltip, {}),
25549
+ /* @__PURE__ */ jsx(Legend, {}),
25550
+ /* @__PURE__ */ jsx(
25551
+ Area,
25552
+ {
25553
+ type: "monotone",
25554
+ dataKey: args.y_field,
25555
+ stroke: "#3b82f6",
25556
+ fill: args.fill ? "#3b82f6" : "none",
25557
+ fillOpacity: args.fill ? 0.6 : 0,
25558
+ name: args.y_field
25559
+ }
25560
+ )
25561
+ ] }) }),
25562
+ args.title && /* @__PURE__ */ jsx("p", { className: "text-center text-sm text-gray-600 mt-2", children: args.title })
25563
+ ] }, `area-${key}`);
25236
25564
  default:
25237
25565
  console.warn(`Unknown chart type: ${chartType}`);
25238
25566
  return null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@optifye/dashboard-core",
3
- "version": "4.3.3",
3
+ "version": "4.3.5",
4
4
  "description": "Reusable UI & logic for Optifye dashboard",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",