dp-widgets-framework 1.3.6 → 1.3.8

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.esm.js +2260 -84
  2. package/dist/index.js +2260 -84
  3. package/package.json +1 -1
package/dist/index.esm.js CHANGED
@@ -16,8 +16,6 @@ import { WidthProvider, Responsive } from 'react-grid-layout';
16
16
  import { v4 } from 'uuid';
17
17
  import { CopilotKit, useCopilotContext, useCoAgent, useCopilotChat } from '@copilotkit/react-core';
18
18
  import { CopilotChat } from '@copilotkit/react-ui';
19
- import ChartDataLabels from 'chartjs-plugin-datalabels';
20
- import ChartPieChartOutlabels from '@energiency/chartjs-plugin-piechart-outlabels';
21
19
  import * as CheckboxPrimitive from '@radix-ui/react-checkbox';
22
20
  import * as DialogPrimitive from '@radix-ui/react-dialog';
23
21
 
@@ -1487,11 +1485,11 @@ const Input = React.forwardRef((_a, ref) => {
1487
1485
  Input.displayName = "Input";
1488
1486
 
1489
1487
  const labelVariants = cva("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70");
1490
- const Label = React.forwardRef((_a, ref) => {
1488
+ const Label$1 = React.forwardRef((_a, ref) => {
1491
1489
  var { className } = _a, props = __rest(_a, ["className"]);
1492
1490
  return (jsxRuntimeExports.jsx(LabelPrimitive.Root, Object.assign({ ref: ref, className: cn(labelVariants(), className) }, props)));
1493
1491
  });
1494
- Label.displayName = LabelPrimitive.Root.displayName;
1492
+ Label$1.displayName = LabelPrimitive.Root.displayName;
1495
1493
 
1496
1494
  const Switch = React.forwardRef((_a, ref) => {
1497
1495
  var { className } = _a, props = __rest(_a, ["className"]);
@@ -1800,17 +1798,17 @@ function WidgetSettingsPanel({ pageId, widget, onClose, onWidgetUpdate, widgetBa
1800
1798
  };
1801
1799
  const renderCommonSettings = () => {
1802
1800
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
1803
- return (jsxRuntimeExports.jsxs("div", { className: "space-y-4", children: [jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [jsxRuntimeExports.jsx(Label, { className: "text-xs", children: "Title" }), jsxRuntimeExports.jsx(Input, { value: localWidget.title, onChange: (e) => updateWidget({ title: e.target.value }), className: "h-8" })] }), jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between py-2", children: [jsxRuntimeExports.jsx(Label, { className: "text-xs", children: "Show Header" }), jsxRuntimeExports.jsx(Switch, { checked: ((_a = localWidget.config) === null || _a === void 0 ? void 0 : _a.showHeader) !== false, onCheckedChange: (checked) => updateConfig({ showHeader: checked }) })] }), jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between py-2", children: [jsxRuntimeExports.jsx(Label, { className: "text-xs", children: "Resizable" }), jsxRuntimeExports.jsx(Switch, { checked: localWidget.is_resizable, onCheckedChange: (checked) => updateWidget({ is_resizable: checked }) })] }), jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between py-2", children: [jsxRuntimeExports.jsx(Label, { className: "text-xs", children: "Draggable" }), jsxRuntimeExports.jsx(Switch, { checked: localWidget.is_draggable, onCheckedChange: (checked) => updateWidget({ is_draggable: checked }) })] }), jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [jsxRuntimeExports.jsx(Label, { className: "text-xs", children: "Background Color" }), jsxRuntimeExports.jsxs("div", { className: "flex gap-2", children: [jsxRuntimeExports.jsx(Input, { type: "color", value: ((_c = (_b = localWidget.config) === null || _b === void 0 ? void 0 : _b.styles) === null || _c === void 0 ? void 0 : _c.backgroundColor) || "#ffffff", onChange: (e) => updateStyle({ backgroundColor: e.target.value }), className: "w-12 h-8 p-1" }), jsxRuntimeExports.jsx(Input, { value: ((_e = (_d = localWidget.config) === null || _d === void 0 ? void 0 : _d.styles) === null || _e === void 0 ? void 0 : _e.backgroundColor) || "#ffffff", onChange: (e) => updateStyle({ backgroundColor: e.target.value }), className: "h-8" })] })] }), jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [jsxRuntimeExports.jsx(Label, { className: "text-xs", children: "Border Radius" }), jsxRuntimeExports.jsxs(Select, { value: ((_g = (_f = localWidget.config) === null || _f === void 0 ? void 0 : _f.styles) === null || _g === void 0 ? void 0 : _g.borderRadius) || "rounded", onValueChange: (value) => updateStyle({ borderRadius: value }), children: [jsxRuntimeExports.jsx(SelectTrigger, { className: "h-8", children: jsxRuntimeExports.jsx(SelectValue, { placeholder: "Select border radius" }) }), jsxRuntimeExports.jsxs(SelectContent, { children: [jsxRuntimeExports.jsx(SelectItem, { value: "none", children: "None" }), jsxRuntimeExports.jsx(SelectItem, { value: "rounded", children: "Rounded" }), jsxRuntimeExports.jsx(SelectItem, { value: "large", children: "Large" }), jsxRuntimeExports.jsx(SelectItem, { value: "extra-large", children: "Extra Large" })] })] })] }), jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [jsxRuntimeExports.jsx(Label, { className: "text-xs", children: "Padding" }), jsxRuntimeExports.jsxs(Select, { value: ((_j = (_h = localWidget.config) === null || _h === void 0 ? void 0 : _h.styles) === null || _j === void 0 ? void 0 : _j.padding) || "medium", onValueChange: (value) => updateStyle({ padding: value }), children: [jsxRuntimeExports.jsx(SelectTrigger, { className: "h-8", children: jsxRuntimeExports.jsx(SelectValue, { placeholder: "Select padding" }) }), jsxRuntimeExports.jsxs(SelectContent, { children: [jsxRuntimeExports.jsx(SelectItem, { value: "small", children: "Small" }), jsxRuntimeExports.jsx(SelectItem, { value: "medium", children: "Medium" }), jsxRuntimeExports.jsx(SelectItem, { value: "large", children: "Large" }), jsxRuntimeExports.jsx(SelectItem, { value: "extra-large", children: "Extra Large" })] })] })] }), jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [jsxRuntimeExports.jsx(Label, { className: "text-xs", children: "Text Color" }), jsxRuntimeExports.jsxs("div", { className: "flex gap-2", children: [jsxRuntimeExports.jsx(Input, { type: "color", value: ((_l = (_k = localWidget.config) === null || _k === void 0 ? void 0 : _k.styles) === null || _l === void 0 ? void 0 : _l.textColor) || "#000000", onChange: (e) => updateStyle({ textColor: e.target.value }), className: "w-12 h-8 p-1" }), jsxRuntimeExports.jsx(Input, { value: ((_o = (_m = localWidget.config) === null || _m === void 0 ? void 0 : _m.styles) === null || _o === void 0 ? void 0 : _o.textColor) || "#000000", onChange: (e) => updateStyle({ textColor: e.target.value }), className: "h-8" })] })] }), jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [jsxRuntimeExports.jsx(Label, { className: "text-xs", children: "Font Size" }), jsxRuntimeExports.jsx(Input, { value: ((_q = (_p = localWidget.config) === null || _p === void 0 ? void 0 : _p.styles) === null || _q === void 0 ? void 0 : _q.fontSize) || "14px", onChange: (e) => updateStyle({ fontSize: e.target.value }), className: "h-8", placeholder: "e.g., 14px, 1rem" })] }), jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [jsxRuntimeExports.jsx(Label, { className: "text-xs", children: "Alignment" }), jsxRuntimeExports.jsxs(Select, { value: ((_s = (_r = localWidget.config) === null || _r === void 0 ? void 0 : _r.styles) === null || _s === void 0 ? void 0 : _s.alignment) || "left", onValueChange: (value) => updateStyle({ alignment: value }), children: [jsxRuntimeExports.jsx(SelectTrigger, { className: "h-8", children: jsxRuntimeExports.jsx(SelectValue, { placeholder: "Select alignment" }) }), jsxRuntimeExports.jsxs(SelectContent, { children: [jsxRuntimeExports.jsx(SelectItem, { value: "left", children: "Left" }), jsxRuntimeExports.jsx(SelectItem, { value: "center", children: "Center" }), jsxRuntimeExports.jsx(SelectItem, { value: "right", children: "Right" })] })] })] })] }));
1801
+ return (jsxRuntimeExports.jsxs("div", { className: "space-y-4", children: [jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [jsxRuntimeExports.jsx(Label$1, { className: "text-xs", children: "Title" }), jsxRuntimeExports.jsx(Input, { value: localWidget.title, onChange: (e) => updateWidget({ title: e.target.value }), className: "h-8" })] }), jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between py-2", children: [jsxRuntimeExports.jsx(Label$1, { className: "text-xs", children: "Show Header" }), jsxRuntimeExports.jsx(Switch, { checked: ((_a = localWidget.config) === null || _a === void 0 ? void 0 : _a.showHeader) !== false, onCheckedChange: (checked) => updateConfig({ showHeader: checked }) })] }), jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between py-2", children: [jsxRuntimeExports.jsx(Label$1, { className: "text-xs", children: "Resizable" }), jsxRuntimeExports.jsx(Switch, { checked: localWidget.is_resizable, onCheckedChange: (checked) => updateWidget({ is_resizable: checked }) })] }), jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between py-2", children: [jsxRuntimeExports.jsx(Label$1, { className: "text-xs", children: "Draggable" }), jsxRuntimeExports.jsx(Switch, { checked: localWidget.is_draggable, onCheckedChange: (checked) => updateWidget({ is_draggable: checked }) })] }), jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [jsxRuntimeExports.jsx(Label$1, { className: "text-xs", children: "Background Color" }), jsxRuntimeExports.jsxs("div", { className: "flex gap-2", children: [jsxRuntimeExports.jsx(Input, { type: "color", value: ((_c = (_b = localWidget.config) === null || _b === void 0 ? void 0 : _b.styles) === null || _c === void 0 ? void 0 : _c.backgroundColor) || "#ffffff", onChange: (e) => updateStyle({ backgroundColor: e.target.value }), className: "w-12 h-8 p-1" }), jsxRuntimeExports.jsx(Input, { value: ((_e = (_d = localWidget.config) === null || _d === void 0 ? void 0 : _d.styles) === null || _e === void 0 ? void 0 : _e.backgroundColor) || "#ffffff", onChange: (e) => updateStyle({ backgroundColor: e.target.value }), className: "h-8" })] })] }), jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [jsxRuntimeExports.jsx(Label$1, { className: "text-xs", children: "Border Radius" }), jsxRuntimeExports.jsxs(Select, { value: ((_g = (_f = localWidget.config) === null || _f === void 0 ? void 0 : _f.styles) === null || _g === void 0 ? void 0 : _g.borderRadius) || "rounded", onValueChange: (value) => updateStyle({ borderRadius: value }), children: [jsxRuntimeExports.jsx(SelectTrigger, { className: "h-8", children: jsxRuntimeExports.jsx(SelectValue, { placeholder: "Select border radius" }) }), jsxRuntimeExports.jsxs(SelectContent, { children: [jsxRuntimeExports.jsx(SelectItem, { value: "none", children: "None" }), jsxRuntimeExports.jsx(SelectItem, { value: "rounded", children: "Rounded" }), jsxRuntimeExports.jsx(SelectItem, { value: "large", children: "Large" }), jsxRuntimeExports.jsx(SelectItem, { value: "extra-large", children: "Extra Large" })] })] })] }), jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [jsxRuntimeExports.jsx(Label$1, { className: "text-xs", children: "Padding" }), jsxRuntimeExports.jsxs(Select, { value: ((_j = (_h = localWidget.config) === null || _h === void 0 ? void 0 : _h.styles) === null || _j === void 0 ? void 0 : _j.padding) || "medium", onValueChange: (value) => updateStyle({ padding: value }), children: [jsxRuntimeExports.jsx(SelectTrigger, { className: "h-8", children: jsxRuntimeExports.jsx(SelectValue, { placeholder: "Select padding" }) }), jsxRuntimeExports.jsxs(SelectContent, { children: [jsxRuntimeExports.jsx(SelectItem, { value: "small", children: "Small" }), jsxRuntimeExports.jsx(SelectItem, { value: "medium", children: "Medium" }), jsxRuntimeExports.jsx(SelectItem, { value: "large", children: "Large" }), jsxRuntimeExports.jsx(SelectItem, { value: "extra-large", children: "Extra Large" })] })] })] }), jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [jsxRuntimeExports.jsx(Label$1, { className: "text-xs", children: "Text Color" }), jsxRuntimeExports.jsxs("div", { className: "flex gap-2", children: [jsxRuntimeExports.jsx(Input, { type: "color", value: ((_l = (_k = localWidget.config) === null || _k === void 0 ? void 0 : _k.styles) === null || _l === void 0 ? void 0 : _l.textColor) || "#000000", onChange: (e) => updateStyle({ textColor: e.target.value }), className: "w-12 h-8 p-1" }), jsxRuntimeExports.jsx(Input, { value: ((_o = (_m = localWidget.config) === null || _m === void 0 ? void 0 : _m.styles) === null || _o === void 0 ? void 0 : _o.textColor) || "#000000", onChange: (e) => updateStyle({ textColor: e.target.value }), className: "h-8" })] })] }), jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [jsxRuntimeExports.jsx(Label$1, { className: "text-xs", children: "Font Size" }), jsxRuntimeExports.jsx(Input, { value: ((_q = (_p = localWidget.config) === null || _p === void 0 ? void 0 : _p.styles) === null || _q === void 0 ? void 0 : _q.fontSize) || "14px", onChange: (e) => updateStyle({ fontSize: e.target.value }), className: "h-8", placeholder: "e.g., 14px, 1rem" })] }), jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [jsxRuntimeExports.jsx(Label$1, { className: "text-xs", children: "Alignment" }), jsxRuntimeExports.jsxs(Select, { value: ((_s = (_r = localWidget.config) === null || _r === void 0 ? void 0 : _r.styles) === null || _s === void 0 ? void 0 : _s.alignment) || "left", onValueChange: (value) => updateStyle({ alignment: value }), children: [jsxRuntimeExports.jsx(SelectTrigger, { className: "h-8", children: jsxRuntimeExports.jsx(SelectValue, { placeholder: "Select alignment" }) }), jsxRuntimeExports.jsxs(SelectContent, { children: [jsxRuntimeExports.jsx(SelectItem, { value: "left", children: "Left" }), jsxRuntimeExports.jsx(SelectItem, { value: "center", children: "Center" }), jsxRuntimeExports.jsx(SelectItem, { value: "right", children: "Right" })] })] })] })] }));
1804
1802
  };
1805
1803
  const renderSearchSettings = () => {
1806
1804
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
1807
- return (jsxRuntimeExports.jsxs("div", { className: "space-y-4", children: [jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [jsxRuntimeExports.jsx(Label, { className: "text-xs", children: "Placeholder Text" }), jsxRuntimeExports.jsx(Input, { value: ((_a = localWidget.config) === null || _a === void 0 ? void 0 : _a.placeholder) || "", onChange: (e) => updateConfig({ placeholder: e.target.value }), className: "h-8" })] }), jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [jsxRuntimeExports.jsx(Label, { className: "text-xs", children: "Minimum Characters" }), jsxRuntimeExports.jsx(Input, { type: "number", min: 1, max: 10, value: ((_b = localWidget.config) === null || _b === void 0 ? void 0 : _b.minCharacters) || 3, onChange: (e) => updateConfig({
1805
+ return (jsxRuntimeExports.jsxs("div", { className: "space-y-4", children: [jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [jsxRuntimeExports.jsx(Label$1, { className: "text-xs", children: "Placeholder Text" }), jsxRuntimeExports.jsx(Input, { value: ((_a = localWidget.config) === null || _a === void 0 ? void 0 : _a.placeholder) || "", onChange: (e) => updateConfig({ placeholder: e.target.value }), className: "h-8" })] }), jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [jsxRuntimeExports.jsx(Label$1, { className: "text-xs", children: "Minimum Characters" }), jsxRuntimeExports.jsx(Input, { type: "number", min: 1, max: 10, value: ((_b = localWidget.config) === null || _b === void 0 ? void 0 : _b.minCharacters) || 3, onChange: (e) => updateConfig({
1808
1806
  minCharacters: parseInt(e.target.value) || 3,
1809
- }), className: "h-8" })] }), jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [jsxRuntimeExports.jsx(Label, { className: "text-xs", children: "Search Delay (ms)" }), jsxRuntimeExports.jsx(Input, { type: "number", min: 0, max: 1000, step: 50, value: ((_c = localWidget.config) === null || _c === void 0 ? void 0 : _c.searchDelay) || 300, onChange: (e) => updateConfig({
1807
+ }), className: "h-8" })] }), jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [jsxRuntimeExports.jsx(Label$1, { className: "text-xs", children: "Search Delay (ms)" }), jsxRuntimeExports.jsx(Input, { type: "number", min: 0, max: 1000, step: 50, value: ((_c = localWidget.config) === null || _c === void 0 ? void 0 : _c.searchDelay) || 300, onChange: (e) => updateConfig({
1810
1808
  searchDelay: parseInt(e.target.value) || 300,
1811
- }), className: "h-8" })] }), jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between py-2", children: [jsxRuntimeExports.jsx(Label, { className: "text-xs", children: "Auto Focus" }), jsxRuntimeExports.jsx(Switch, { checked: ((_d = localWidget.config) === null || _d === void 0 ? void 0 : _d.autoFocus) || false, onCheckedChange: (checked) => updateConfig({ autoFocus: checked }) })] }), jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between py-2", children: [jsxRuntimeExports.jsx(Label, { className: "text-xs", children: "Voice Search" }), jsxRuntimeExports.jsx(Switch, { checked: ((_e = localWidget.config) === null || _e === void 0 ? void 0 : _e.voiceSearch) || false, onCheckedChange: (checked) => updateConfig({ voiceSearch: checked }) })] }), jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between py-2", children: [jsxRuntimeExports.jsx(Label, { className: "text-xs", children: "Recent Searches" }), jsxRuntimeExports.jsx(Switch, { checked: ((_f = localWidget.config) === null || _f === void 0 ? void 0 : _f.recentSearches) || false, onCheckedChange: (checked) => updateConfig({ recentSearches: checked }) })] }), ((_g = localWidget.config) === null || _g === void 0 ? void 0 : _g.recentSearches) && (jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [jsxRuntimeExports.jsx(Label, { className: "text-xs", children: "Maximum Recent Searches" }), jsxRuntimeExports.jsx(Input, { type: "number", min: 1, value: ((_h = localWidget.config) === null || _h === void 0 ? void 0 : _h.maxRecentSearches) || 5, onChange: (e) => updateConfig({
1809
+ }), className: "h-8" })] }), jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between py-2", children: [jsxRuntimeExports.jsx(Label$1, { className: "text-xs", children: "Auto Focus" }), jsxRuntimeExports.jsx(Switch, { checked: ((_d = localWidget.config) === null || _d === void 0 ? void 0 : _d.autoFocus) || false, onCheckedChange: (checked) => updateConfig({ autoFocus: checked }) })] }), jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between py-2", children: [jsxRuntimeExports.jsx(Label$1, { className: "text-xs", children: "Voice Search" }), jsxRuntimeExports.jsx(Switch, { checked: ((_e = localWidget.config) === null || _e === void 0 ? void 0 : _e.voiceSearch) || false, onCheckedChange: (checked) => updateConfig({ voiceSearch: checked }) })] }), jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between py-2", children: [jsxRuntimeExports.jsx(Label$1, { className: "text-xs", children: "Recent Searches" }), jsxRuntimeExports.jsx(Switch, { checked: ((_f = localWidget.config) === null || _f === void 0 ? void 0 : _f.recentSearches) || false, onCheckedChange: (checked) => updateConfig({ recentSearches: checked }) })] }), ((_g = localWidget.config) === null || _g === void 0 ? void 0 : _g.recentSearches) && (jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [jsxRuntimeExports.jsx(Label$1, { className: "text-xs", children: "Maximum Recent Searches" }), jsxRuntimeExports.jsx(Input, { type: "number", min: 1, value: ((_h = localWidget.config) === null || _h === void 0 ? void 0 : _h.maxRecentSearches) || 5, onChange: (e) => updateConfig({
1812
1810
  maxRecentSearches: parseInt(e.target.value) || 5,
1813
- }), className: "h-8" })] })), jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between", children: [jsxRuntimeExports.jsx(Label, { children: "Enable Facets" }), jsxRuntimeExports.jsx(Switch, { checked: (_l = (_k = (_j = widget.config) === null || _j === void 0 ? void 0 : _j.facets) === null || _k === void 0 ? void 0 : _k.enabled) !== null && _l !== void 0 ? _l : false, onCheckedChange: (checked) => {
1811
+ }), className: "h-8" })] })), jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between", children: [jsxRuntimeExports.jsx(Label$1, { children: "Enable Facets" }), jsxRuntimeExports.jsx(Switch, { checked: (_l = (_k = (_j = widget.config) === null || _j === void 0 ? void 0 : _j.facets) === null || _k === void 0 ? void 0 : _k.enabled) !== null && _l !== void 0 ? _l : false, onCheckedChange: (checked) => {
1814
1812
  var _a, _b, _c;
1815
1813
  const newConfig = Object.assign(Object.assign({}, widget.config), { facets: Object.assign(Object.assign({}, (((_a = widget.config) === null || _a === void 0 ? void 0 : _a.facets) || {})), { enabled: checked, fields: ((_c = (_b = widget.config) === null || _b === void 0 ? void 0 : _b.facets) === null || _c === void 0 ? void 0 : _c.fields) || [] }) });
1816
1814
  updateWidgetAPI(widget.id, { config: newConfig }).catch(console.error);
@@ -1821,29 +1819,29 @@ function WidgetSettingsPanel({ pageId, widget, onClose, onWidgetUpdate, widgetBa
1821
1819
  };
1822
1820
  const renderResultsSettings = () => {
1823
1821
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
1824
- return (jsxRuntimeExports.jsxs("div", { className: "space-y-4", children: [jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [jsxRuntimeExports.jsx(Label, { className: "text-xs", children: "Layout Type" }), jsxRuntimeExports.jsxs(Select, { value: ((_b = (_a = localWidget.config) === null || _a === void 0 ? void 0 : _a.layout) === null || _b === void 0 ? void 0 : _b.type) || "list", onValueChange: (value) => {
1822
+ return (jsxRuntimeExports.jsxs("div", { className: "space-y-4", children: [jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [jsxRuntimeExports.jsx(Label$1, { className: "text-xs", children: "Layout Type" }), jsxRuntimeExports.jsxs(Select, { value: ((_b = (_a = localWidget.config) === null || _a === void 0 ? void 0 : _a.layout) === null || _b === void 0 ? void 0 : _b.type) || "list", onValueChange: (value) => {
1825
1823
  var _a;
1826
1824
  return updateConfig({
1827
1825
  layout: Object.assign(Object.assign({}, (_a = localWidget.config) === null || _a === void 0 ? void 0 : _a.layout), { type: value }),
1828
1826
  });
1829
- }, children: [jsxRuntimeExports.jsx(SelectTrigger, { className: "h-8", children: jsxRuntimeExports.jsx(SelectValue, { placeholder: "Select layout type" }) }), jsxRuntimeExports.jsxs(SelectContent, { children: [jsxRuntimeExports.jsx(SelectItem, { value: "grid", children: "Grid" }), jsxRuntimeExports.jsx(SelectItem, { value: "list", children: "List" }), jsxRuntimeExports.jsx(SelectItem, { value: "table", children: "Table" })] })] })] }), jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [jsxRuntimeExports.jsx(Label, { className: "text-xs", children: "Items Per Page" }), jsxRuntimeExports.jsxs(Select, { value: String(((_d = (_c = localWidget.config) === null || _c === void 0 ? void 0 : _c.layout) === null || _d === void 0 ? void 0 : _d.itemsPerPage) || 10), onValueChange: (value) => {
1827
+ }, children: [jsxRuntimeExports.jsx(SelectTrigger, { className: "h-8", children: jsxRuntimeExports.jsx(SelectValue, { placeholder: "Select layout type" }) }), jsxRuntimeExports.jsxs(SelectContent, { children: [jsxRuntimeExports.jsx(SelectItem, { value: "grid", children: "Grid" }), jsxRuntimeExports.jsx(SelectItem, { value: "list", children: "List" }), jsxRuntimeExports.jsx(SelectItem, { value: "table", children: "Table" })] })] })] }), jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [jsxRuntimeExports.jsx(Label$1, { className: "text-xs", children: "Items Per Page" }), jsxRuntimeExports.jsxs(Select, { value: String(((_d = (_c = localWidget.config) === null || _c === void 0 ? void 0 : _c.layout) === null || _d === void 0 ? void 0 : _d.itemsPerPage) || 10), onValueChange: (value) => {
1830
1828
  var _a;
1831
1829
  return updateConfig({
1832
1830
  layout: Object.assign(Object.assign({}, (_a = localWidget.config) === null || _a === void 0 ? void 0 : _a.layout), { itemsPerPage: parseInt(value) }),
1833
1831
  });
1834
- }, children: [jsxRuntimeExports.jsx(SelectTrigger, { className: "h-8", children: jsxRuntimeExports.jsx(SelectValue, { placeholder: "Select items per page" }) }), jsxRuntimeExports.jsx(SelectContent, { children: [5, 10, 20, 50, 100].map((value) => (jsxRuntimeExports.jsxs(SelectItem, { value: String(value), children: [value, " items"] }, value))) })] })] }), jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between py-2", children: [jsxRuntimeExports.jsx(Label, { className: "text-xs", children: "Infinite Scroll" }), jsxRuntimeExports.jsx(Switch, { checked: ((_f = (_e = localWidget.config) === null || _e === void 0 ? void 0 : _e.layout) === null || _f === void 0 ? void 0 : _f.infiniteScroll) || false, onCheckedChange: (checked) => {
1832
+ }, children: [jsxRuntimeExports.jsx(SelectTrigger, { className: "h-8", children: jsxRuntimeExports.jsx(SelectValue, { placeholder: "Select items per page" }) }), jsxRuntimeExports.jsx(SelectContent, { children: [5, 10, 20, 50, 100].map((value) => (jsxRuntimeExports.jsxs(SelectItem, { value: String(value), children: [value, " items"] }, value))) })] })] }), jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between py-2", children: [jsxRuntimeExports.jsx(Label$1, { className: "text-xs", children: "Infinite Scroll" }), jsxRuntimeExports.jsx(Switch, { checked: ((_f = (_e = localWidget.config) === null || _e === void 0 ? void 0 : _e.layout) === null || _f === void 0 ? void 0 : _f.infiniteScroll) || false, onCheckedChange: (checked) => {
1835
1833
  var _a;
1836
1834
  return updateConfig({
1837
1835
  layout: Object.assign(Object.assign({}, (_a = localWidget.config) === null || _a === void 0 ? void 0 : _a.layout), { infiniteScroll: checked }),
1838
1836
  });
1839
- } })] }), jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between py-2", children: [jsxRuntimeExports.jsx(Label, { className: "text-xs", children: "Show Pagination" }), jsxRuntimeExports.jsx(Switch, { checked: ((_g = localWidget.config) === null || _g === void 0 ? void 0 : _g.showPagination) !== false, onCheckedChange: (checked) => updateConfig({ showPagination: checked }) })] }), jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between py-2", children: [jsxRuntimeExports.jsx(Label, { className: "text-xs", children: "Hide Relevance" }), jsxRuntimeExports.jsx(Switch, { checked: (_j = (_h = localWidget.config) === null || _h === void 0 ? void 0 : _h.hideRelevance) !== null && _j !== void 0 ? _j : false, onCheckedChange: (checked) => updateConfig({ hideRelevance: checked }) })] }), jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [jsxRuntimeExports.jsx(Label, { className: "text-xs", children: "Title" }), jsxRuntimeExports.jsxs(Select, { value: ((_k = localWidget.config) === null || _k === void 0 ? void 0 : _k.titleTemplate) || "filename", onValueChange: (value) => updateConfig({ titleTemplate: value }), children: [jsxRuntimeExports.jsx(SelectTrigger, { className: "h-8", children: jsxRuntimeExports.jsx(SelectValue, { placeholder: "Select title template" }) }), jsxRuntimeExports.jsx(SelectContent, { children: availableFacets.map((facet) => facet.type === "string" && (jsxRuntimeExports.jsx(SelectItem, { value: facet.value, children: facet.value }, facet.value))) })] })] }), jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [jsxRuntimeExports.jsx(Label, { className: "text-xs", children: "Metadata" }), jsxRuntimeExports.jsx(SearchWidgetFacetSettings, { placeHolder: "Select metadata field", value: ((_m = (_l = widget.config) === null || _l === void 0 ? void 0 : _l.metadata) === null || _m === void 0 ? void 0 : _m.fields) || [], onChange: (fields) => {
1837
+ } })] }), jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between py-2", children: [jsxRuntimeExports.jsx(Label$1, { className: "text-xs", children: "Show Pagination" }), jsxRuntimeExports.jsx(Switch, { checked: ((_g = localWidget.config) === null || _g === void 0 ? void 0 : _g.showPagination) !== false, onCheckedChange: (checked) => updateConfig({ showPagination: checked }) })] }), jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between py-2", children: [jsxRuntimeExports.jsx(Label$1, { className: "text-xs", children: "Hide Relevance" }), jsxRuntimeExports.jsx(Switch, { checked: (_j = (_h = localWidget.config) === null || _h === void 0 ? void 0 : _h.hideRelevance) !== null && _j !== void 0 ? _j : false, onCheckedChange: (checked) => updateConfig({ hideRelevance: checked }) })] }), jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [jsxRuntimeExports.jsx(Label$1, { className: "text-xs", children: "Title" }), jsxRuntimeExports.jsxs(Select, { value: ((_k = localWidget.config) === null || _k === void 0 ? void 0 : _k.titleTemplate) || "filename", onValueChange: (value) => updateConfig({ titleTemplate: value }), children: [jsxRuntimeExports.jsx(SelectTrigger, { className: "h-8", children: jsxRuntimeExports.jsx(SelectValue, { placeholder: "Select title template" }) }), jsxRuntimeExports.jsx(SelectContent, { children: availableFacets.map((facet) => facet.type === "string" && (jsxRuntimeExports.jsx(SelectItem, { value: facet.value, children: facet.value }, facet.value))) })] })] }), jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [jsxRuntimeExports.jsx(Label$1, { className: "text-xs", children: "Metadata" }), jsxRuntimeExports.jsx(SearchWidgetFacetSettings, { placeHolder: "Select metadata field", value: ((_m = (_l = widget.config) === null || _l === void 0 ? void 0 : _l.metadata) === null || _m === void 0 ? void 0 : _m.fields) || [], onChange: (fields) => {
1840
1838
  const newConfig = Object.assign(Object.assign({}, widget.config), { metadata: Object.assign(Object.assign({}, widget.config.metadata), { fields }) });
1841
1839
  updateWidgetAPI(widget.id, { config: newConfig }).catch(console.error);
1842
1840
  }, maxFields: ((_p = (_o = widget.config) === null || _o === void 0 ? void 0 : _o.facets) === null || _p === void 0 ? void 0 : _p.maxFields) || 10 })] })] }));
1843
1841
  };
1844
1842
  const renderCodeSettings = () => {
1845
1843
  var _a;
1846
- return (jsxRuntimeExports.jsx("div", { className: "space-y-4", children: jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [jsxRuntimeExports.jsx(Label, { className: "text-xs", children: "Custom Widget Code" }), jsxRuntimeExports.jsx(CodeEditor, { value: ((_a = localWidget.config) === null || _a === void 0 ? void 0 : _a.customCode) ||
1844
+ return (jsxRuntimeExports.jsx("div", { className: "space-y-4", children: jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [jsxRuntimeExports.jsx(Label$1, { className: "text-xs", children: "Custom Widget Code" }), jsxRuntimeExports.jsx(CodeEditor, { value: ((_a = localWidget.config) === null || _a === void 0 ? void 0 : _a.customCode) ||
1847
1845
  `// Custom search widget code
1848
1846
  // You can modify the widget behavior here
1849
1847
  function customSearch(query) {
@@ -1858,7 +1856,7 @@ function WidgetSettingsPanel({ pageId, widget, onClose, onWidgetUpdate, widgetBa
1858
1856
  };
1859
1857
  const renderFilterSettings = () => {
1860
1858
  var _a, _b, _c, _d, _e, _f, _g, _h;
1861
- return (jsxRuntimeExports.jsxs("div", { className: "space-y-4", children: [jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between py-2", children: [jsxRuntimeExports.jsx(Label, { className: "text-xs", children: "Show Clear Button" }), jsxRuntimeExports.jsx(Switch, { checked: ((_a = localWidget.config) === null || _a === void 0 ? void 0 : _a.showClearButton) !== false, onCheckedChange: (checked) => updateConfig({ showClearButton: checked }) })] }), jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between py-2", children: [jsxRuntimeExports.jsx(Label, { className: "text-xs", children: "Collapsible Sections" }), jsxRuntimeExports.jsx(Switch, { checked: ((_b = localWidget.config) === null || _b === void 0 ? void 0 : _b.collapsible) !== false, onCheckedChange: (checked) => updateConfig({ collapsible: checked }) })] }), jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between py-2", children: [jsxRuntimeExports.jsx(Label, { className: "text-xs", children: "Default Expanded" }), jsxRuntimeExports.jsx(Switch, { checked: ((_c = localWidget.config) === null || _c === void 0 ? void 0 : _c.defaultExpanded) !== false, onCheckedChange: (checked) => updateConfig({ defaultExpanded: checked }) })] }), jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between", children: [jsxRuntimeExports.jsx(Label, { children: "Enable Facets" }), jsxRuntimeExports.jsx(Switch, { checked: (_f = (_e = (_d = widget.config) === null || _d === void 0 ? void 0 : _d.facets) === null || _e === void 0 ? void 0 : _e.enabled) !== null && _f !== void 0 ? _f : false, onCheckedChange: (checked) => {
1859
+ return (jsxRuntimeExports.jsxs("div", { className: "space-y-4", children: [jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between py-2", children: [jsxRuntimeExports.jsx(Label$1, { className: "text-xs", children: "Show Clear Button" }), jsxRuntimeExports.jsx(Switch, { checked: ((_a = localWidget.config) === null || _a === void 0 ? void 0 : _a.showClearButton) !== false, onCheckedChange: (checked) => updateConfig({ showClearButton: checked }) })] }), jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between py-2", children: [jsxRuntimeExports.jsx(Label$1, { className: "text-xs", children: "Collapsible Sections" }), jsxRuntimeExports.jsx(Switch, { checked: ((_b = localWidget.config) === null || _b === void 0 ? void 0 : _b.collapsible) !== false, onCheckedChange: (checked) => updateConfig({ collapsible: checked }) })] }), jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between py-2", children: [jsxRuntimeExports.jsx(Label$1, { className: "text-xs", children: "Default Expanded" }), jsxRuntimeExports.jsx(Switch, { checked: ((_c = localWidget.config) === null || _c === void 0 ? void 0 : _c.defaultExpanded) !== false, onCheckedChange: (checked) => updateConfig({ defaultExpanded: checked }) })] }), jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between", children: [jsxRuntimeExports.jsx(Label$1, { children: "Enable Facets" }), jsxRuntimeExports.jsx(Switch, { checked: (_f = (_e = (_d = widget.config) === null || _d === void 0 ? void 0 : _d.facets) === null || _e === void 0 ? void 0 : _e.enabled) !== null && _f !== void 0 ? _f : false, onCheckedChange: (checked) => {
1862
1860
  var _a, _b, _c;
1863
1861
  const newConfig = Object.assign(Object.assign({}, widget.config), { facets: Object.assign(Object.assign({}, (((_a = widget.config) === null || _a === void 0 ? void 0 : _a.facets) || {})), { enabled: checked, fields: ((_c = (_b = widget.config) === null || _b === void 0 ? void 0 : _b.facets) === null || _c === void 0 ? void 0 : _c.fields) || [] }) });
1864
1862
  console.log("newConfig", newConfig);
@@ -1870,14 +1868,14 @@ function WidgetSettingsPanel({ pageId, widget, onClose, onWidgetUpdate, widgetBa
1870
1868
  };
1871
1869
  const renderAgentSettings = () => {
1872
1870
  var _a, _b, _c, _d, _e;
1873
- return (jsxRuntimeExports.jsxs("div", { className: "space-y-4", children: [jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [jsxRuntimeExports.jsx(Label, { className: "text-xs", children: "Agent Type" }), jsxRuntimeExports.jsxs(Select, { value: ((_a = localWidget.config) === null || _a === void 0 ? void 0 : _a.agentType) || "Chatbot Agent", onValueChange: (value) => {
1871
+ return (jsxRuntimeExports.jsxs("div", { className: "space-y-4", children: [jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [jsxRuntimeExports.jsx(Label$1, { className: "text-xs", children: "Agent Type" }), jsxRuntimeExports.jsxs(Select, { value: ((_a = localWidget.config) === null || _a === void 0 ? void 0 : _a.agentType) || "Chatbot Agent", onValueChange: (value) => {
1874
1872
  const updates = { agentType: value };
1875
1873
  // Remove query property when Chatbot Agent is selected
1876
1874
  if (value === "Chatbot Agent") {
1877
1875
  updates.query = undefined;
1878
1876
  }
1879
1877
  updateConfig(updates);
1880
- }, children: [jsxRuntimeExports.jsx(SelectTrigger, { className: "h-8", children: jsxRuntimeExports.jsx(SelectValue, { placeholder: "Select agent type" }) }), jsxRuntimeExports.jsxs(SelectContent, { children: [jsxRuntimeExports.jsx(SelectItem, { value: "Chatbot Agent", children: "Chatbot Agent" }), jsxRuntimeExports.jsx(SelectItem, { value: "Bar Chart Agent", children: "Bar Chart Agent" }), jsxRuntimeExports.jsx(SelectItem, { value: "Pie Chart Agent", children: "Pie Chart Agent" })] })] })] }), jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [jsxRuntimeExports.jsx(Label, { className: "text-xs", children: "Agent ID" }), agentIds && agentIds.length > 0 ? (jsxRuntimeExports.jsxs(Select, { value: ((_b = localWidget.config) === null || _b === void 0 ? void 0 : _b.agentName) || "", onValueChange: (value) => updateConfig({ agentName: value }), children: [jsxRuntimeExports.jsx(SelectTrigger, { className: "h-8", children: jsxRuntimeExports.jsx(SelectValue, { placeholder: "Select an agent ID" }) }), jsxRuntimeExports.jsx(SelectContent, { children: agentIds.map((agentId) => (jsxRuntimeExports.jsx(SelectItem, { value: agentId, children: agentId }, agentId))) })] })) : (jsxRuntimeExports.jsx(Input, { value: ((_c = localWidget.config) === null || _c === void 0 ? void 0 : _c.agentName) || "", onChange: (e) => updateConfig({ agentName: e.target.value }), className: "h-8", placeholder: "e.g., adk-construction-project-agent" }))] }), ((_d = localWidget.config) === null || _d === void 0 ? void 0 : _d.agentType) !== "Chatbot Agent" && (jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [jsxRuntimeExports.jsx(Label, { className: "text-xs", children: "Query" }), jsxRuntimeExports.jsx(Input, { value: ((_e = localWidget.config) === null || _e === void 0 ? void 0 : _e.query) || "", onChange: (e) => updateConfig({ query: e.target.value }), className: "h-8", placeholder: "Enter query for the agent..." })] }))] }));
1878
+ }, children: [jsxRuntimeExports.jsx(SelectTrigger, { className: "h-8", children: jsxRuntimeExports.jsx(SelectValue, { placeholder: "Select agent type" }) }), jsxRuntimeExports.jsxs(SelectContent, { children: [jsxRuntimeExports.jsx(SelectItem, { value: "Chatbot Agent", children: "Chatbot Agent" }), jsxRuntimeExports.jsx(SelectItem, { value: "Bar Chart Agent", children: "Bar Chart Agent" }), jsxRuntimeExports.jsx(SelectItem, { value: "Pie Chart Agent", children: "Pie Chart Agent" })] })] })] }), jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [jsxRuntimeExports.jsx(Label$1, { className: "text-xs", children: "Agent ID" }), agentIds && agentIds.length > 0 ? (jsxRuntimeExports.jsxs(Select, { value: ((_b = localWidget.config) === null || _b === void 0 ? void 0 : _b.agentName) || "", onValueChange: (value) => updateConfig({ agentName: value }), children: [jsxRuntimeExports.jsx(SelectTrigger, { className: "h-8", children: jsxRuntimeExports.jsx(SelectValue, { placeholder: "Select an agent ID" }) }), jsxRuntimeExports.jsx(SelectContent, { children: agentIds.map((agentId) => (jsxRuntimeExports.jsx(SelectItem, { value: agentId, children: agentId }, agentId))) })] })) : (jsxRuntimeExports.jsx(Input, { value: ((_c = localWidget.config) === null || _c === void 0 ? void 0 : _c.agentName) || "", onChange: (e) => updateConfig({ agentName: e.target.value }), className: "h-8", placeholder: "e.g., adk-construction-project-agent" }))] }), ((_d = localWidget.config) === null || _d === void 0 ? void 0 : _d.agentType) !== "Chatbot Agent" && (jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [jsxRuntimeExports.jsx(Label$1, { className: "text-xs", children: "Query" }), jsxRuntimeExports.jsx(Input, { value: ((_e = localWidget.config) === null || _e === void 0 ? void 0 : _e.query) || "", onChange: (e) => updateConfig({ query: e.target.value }), className: "h-8", placeholder: "Enter query for the agent..." })] }))] }));
1881
1879
  };
1882
1880
  return (jsxRuntimeExports.jsxs("div", { className: "h-full flex flex-col", children: [jsxRuntimeExports.jsx("div", { className: "p-3 border-b flex justify-between items-center", children: jsxRuntimeExports.jsx("h3", { className: "font-medium text-sm", children: "Widget Settings" }) }), error && (jsxRuntimeExports.jsxs(Alert, { variant: "destructive", className: "m-3", children: [jsxRuntimeExports.jsx(AlertCircle, { className: "h-4 w-4" }), jsxRuntimeExports.jsx(AlertDescription, { children: error })] })), jsxRuntimeExports.jsx(ScrollArea, { className: "flex-1", children: jsxRuntimeExports.jsx("div", { className: "p-3", children: jsxRuntimeExports.jsxs(Tabs, { defaultValue: "common", children: [jsxRuntimeExports.jsxs(TabsList, { className: "w-full", children: [jsxRuntimeExports.jsx(TabsTrigger, { value: "common", className: "flex-1", children: "Common" }), localWidget.type === "search" && (jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [jsxRuntimeExports.jsx(TabsTrigger, { value: "search", className: "flex-1", children: "Search" }), jsxRuntimeExports.jsx(TabsTrigger, { value: "code", className: "flex-1", children: "Code" })] })), localWidget.type === "results" && (jsxRuntimeExports.jsx(TabsTrigger, { value: "results", className: "flex-1", children: "Results" })), localWidget.type === "filter" && (jsxRuntimeExports.jsx(TabsTrigger, { value: "filter", className: "flex-1", children: "Filter" })), localWidget.type === "agent" && (jsxRuntimeExports.jsx(TabsTrigger, { value: "agent", className: "flex-1", children: "Agent" }))] }), jsxRuntimeExports.jsxs("div", { className: "mt-4", children: [jsxRuntimeExports.jsx(TabsContent, { value: "common", children: renderCommonSettings() }), jsxRuntimeExports.jsx(TabsContent, { value: "search", children: renderSearchSettings() }), jsxRuntimeExports.jsx(TabsContent, { value: "results", children: renderResultsSettings() }), jsxRuntimeExports.jsx(TabsContent, { value: "filter", children: renderFilterSettings() }), jsxRuntimeExports.jsx(TabsContent, { value: "agent", children: renderAgentSettings() }), jsxRuntimeExports.jsx(TabsContent, { value: "code", children: renderCodeSettings() })] })] }) }) }), jsxRuntimeExports.jsxs("div", { className: "p-3 border-t flex justify-between gap-2", children: [jsxRuntimeExports.jsx("div", { className: "text-sm text-muted-foreground", children: isAutosaving && "Autosaving..." }), jsxRuntimeExports.jsxs("div", { className: "flex gap-2", children: [jsxRuntimeExports.jsx(Button, { variant: "outline", onClick: handleCancel, disabled: isSaving || isAutosaving, children: "Cancel" }), jsxRuntimeExports.jsx(Button, { onClick: handleSave, disabled: isSaving || isAutosaving, children: isSaving ? "Saving..." : "Save Changes" })] })] })] }));
1883
1881
  }
@@ -2189,7 +2187,7 @@ function FacetWidget({ widget, showHeader = true, onConfigUpdate, }) {
2189
2187
  onConfigUpdate(Object.assign(Object.assign({}, widget.config), { fields: newFields }));
2190
2188
  }
2191
2189
  };
2192
- return (jsxRuntimeExports.jsxs(Card, { className: "p-4 h-full", children: [showHeader && jsxRuntimeExports.jsx("h3", { className: "font-medium mb-4", children: "Facet Configuration" }), jsxRuntimeExports.jsx(ScrollArea, { className: "h-[calc(100%-2rem)]", children: jsxRuntimeExports.jsxs("div", { className: "space-y-4", children: [fields.map((field, index) => (jsxRuntimeExports.jsxs("div", { className: "flex items-start gap-2 bg-accent/10 p-2 rounded-md", children: [jsxRuntimeExports.jsxs("div", { className: "flex-1 space-y-2", children: [jsxRuntimeExports.jsxs("div", { className: "space-y-1", children: [jsxRuntimeExports.jsxs(Label, { children: ["Field ", index + 1] }), jsxRuntimeExports.jsxs(Select, { value: field.field, onValueChange: (value) => updateField(index, value, field.displayName), children: [jsxRuntimeExports.jsx(SelectTrigger, { children: jsxRuntimeExports.jsx(SelectValue, { placeholder: "Select field" }) }), jsxRuntimeExports.jsx(SelectContent, { children: availableFacets.map((facet) => (jsxRuntimeExports.jsx(SelectItem, { value: facet.value, children: facet.value }, facet.value))) })] })] }), jsxRuntimeExports.jsxs("div", { className: "space-y-1", children: [jsxRuntimeExports.jsx(Label, { children: "Display Name" }), jsxRuntimeExports.jsx(Input, { value: field.displayName, onChange: (e) => updateField(index, field.field, e.target.value), placeholder: "Enter display name" })] })] }), jsxRuntimeExports.jsxs("div", { className: "flex flex-col gap-1", children: [jsxRuntimeExports.jsx(Button, { variant: "ghost", size: "icon", onClick: () => moveField(index, "up"), disabled: index === 0, children: jsxRuntimeExports.jsx(ArrowUp, { className: "h-4 w-4" }) }), jsxRuntimeExports.jsx(Button, { variant: "ghost", size: "icon", onClick: () => moveField(index, "down"), disabled: index === fields.length - 1, children: jsxRuntimeExports.jsx(ArrowDown, { className: "h-4 w-4" }) }), jsxRuntimeExports.jsx(Button, { variant: "ghost", size: "icon", onClick: () => removeField(index), children: jsxRuntimeExports.jsx(Trash2, { className: "h-4 w-4" }) })] })] }, index))), fields.length < (((_b = widget.config) === null || _b === void 0 ? void 0 : _b.maxFields) || 10) && (jsxRuntimeExports.jsxs(Button, { variant: "outline", className: "w-full", onClick: addField, children: [jsxRuntimeExports.jsx(Plus, { className: "h-4 w-4 mr-2" }), "Add Facet"] })), error && jsxRuntimeExports.jsx("p", { className: "text-sm text-destructive mt-2", children: error })] }) })] }));
2190
+ return (jsxRuntimeExports.jsxs(Card, { className: "p-4 h-full", children: [showHeader && jsxRuntimeExports.jsx("h3", { className: "font-medium mb-4", children: "Facet Configuration" }), jsxRuntimeExports.jsx(ScrollArea, { className: "h-[calc(100%-2rem)]", children: jsxRuntimeExports.jsxs("div", { className: "space-y-4", children: [fields.map((field, index) => (jsxRuntimeExports.jsxs("div", { className: "flex items-start gap-2 bg-accent/10 p-2 rounded-md", children: [jsxRuntimeExports.jsxs("div", { className: "flex-1 space-y-2", children: [jsxRuntimeExports.jsxs("div", { className: "space-y-1", children: [jsxRuntimeExports.jsxs(Label$1, { children: ["Field ", index + 1] }), jsxRuntimeExports.jsxs(Select, { value: field.field, onValueChange: (value) => updateField(index, value, field.displayName), children: [jsxRuntimeExports.jsx(SelectTrigger, { children: jsxRuntimeExports.jsx(SelectValue, { placeholder: "Select field" }) }), jsxRuntimeExports.jsx(SelectContent, { children: availableFacets.map((facet) => (jsxRuntimeExports.jsx(SelectItem, { value: facet.value, children: facet.value }, facet.value))) })] })] }), jsxRuntimeExports.jsxs("div", { className: "space-y-1", children: [jsxRuntimeExports.jsx(Label$1, { children: "Display Name" }), jsxRuntimeExports.jsx(Input, { value: field.displayName, onChange: (e) => updateField(index, field.field, e.target.value), placeholder: "Enter display name" })] })] }), jsxRuntimeExports.jsxs("div", { className: "flex flex-col gap-1", children: [jsxRuntimeExports.jsx(Button, { variant: "ghost", size: "icon", onClick: () => moveField(index, "up"), disabled: index === 0, children: jsxRuntimeExports.jsx(ArrowUp, { className: "h-4 w-4" }) }), jsxRuntimeExports.jsx(Button, { variant: "ghost", size: "icon", onClick: () => moveField(index, "down"), disabled: index === fields.length - 1, children: jsxRuntimeExports.jsx(ArrowDown, { className: "h-4 w-4" }) }), jsxRuntimeExports.jsx(Button, { variant: "ghost", size: "icon", onClick: () => removeField(index), children: jsxRuntimeExports.jsx(Trash2, { className: "h-4 w-4" }) })] })] }, index))), fields.length < (((_b = widget.config) === null || _b === void 0 ? void 0 : _b.maxFields) || 10) && (jsxRuntimeExports.jsxs(Button, { variant: "outline", className: "w-full", onClick: addField, children: [jsxRuntimeExports.jsx(Plus, { className: "h-4 w-4 mr-2" }), "Add Facet"] })), error && jsxRuntimeExports.jsx("p", { className: "text-sm text-destructive mt-2", children: error })] }) })] }));
2193
2191
  }
2194
2192
 
2195
2193
  // src/graphql/@generated/graphql.ts
@@ -3892,7 +3890,7 @@ function set(root, scope, values) {
3892
3890
  appliers.forEach((apply)=>apply(this));
3893
3891
  }
3894
3892
  }
3895
- var defaults = /* #__PURE__ */ new Defaults({
3893
+ var defaults$1 = /* #__PURE__ */ new Defaults({
3896
3894
  _scriptable: (name)=>!name.startsWith('on'),
3897
3895
  _indexable: (name)=>name !== 'events',
3898
3896
  hover: {
@@ -3913,7 +3911,7 @@ var defaults = /* #__PURE__ */ new Defaults({
3913
3911
  * @param font - A font object.
3914
3912
  * @return The CSS font string. See https://developer.mozilla.org/en-US/docs/Web/CSS/font
3915
3913
  * @private
3916
- */ function toFontString(font) {
3914
+ */ function toFontString$1(font) {
3917
3915
  if (!font || isNullOrUndef(font.size) || isNullOrUndef(font.family)) {
3918
3916
  return null;
3919
3917
  }
@@ -4324,7 +4322,7 @@ function _readValueToProps(value, props) {
4324
4322
  * @private
4325
4323
  */ function toFont(options, fallback) {
4326
4324
  options = options || {};
4327
- fallback = fallback || defaults.font;
4325
+ fallback = fallback || defaults$1.font;
4328
4326
  let size = valueOrDefault(options.size, fallback.size);
4329
4327
  if (typeof size === 'string') {
4330
4328
  size = parseInt(size, 10);
@@ -4342,7 +4340,7 @@ function _readValueToProps(value, props) {
4342
4340
  weight: valueOrDefault(options.weight, fallback.weight),
4343
4341
  string: ''
4344
4342
  };
4345
- font.string = toFontString(font);
4343
+ font.string = toFontString$1(font);
4346
4344
  return font;
4347
4345
  }
4348
4346
  /**
@@ -4362,6 +4360,12 @@ function _readValueToProps(value, props) {
4362
4360
  if (value === undefined) {
4363
4361
  continue;
4364
4362
  }
4363
+ if (context !== undefined && typeof value === 'function') {
4364
+ value = value(context);
4365
+ }
4366
+ if (index !== undefined && isArray(value)) {
4367
+ value = value[index % value.length];
4368
+ }
4365
4369
  if (value !== undefined) {
4366
4370
  return value;
4367
4371
  }
@@ -5769,7 +5773,7 @@ class Animations {
5769
5773
  if (!isObject(config)) {
5770
5774
  return;
5771
5775
  }
5772
- const animationOptions = Object.keys(defaults.animation);
5776
+ const animationOptions = Object.keys(defaults$1.animation);
5773
5777
  const animatedProps = this._properties;
5774
5778
  Object.getOwnPropertyNames(config).forEach((key)=>{
5775
5779
  const cfg = config[key];
@@ -6467,7 +6471,7 @@ class DatasetController {
6467
6471
  ''
6468
6472
  ];
6469
6473
  const scopes = config.getOptionScopes(this.getDataset(), scopeKeys);
6470
- const names = Object.keys(defaults.elements[elementType]);
6474
+ const names = Object.keys(defaults$1.elements[elementType]);
6471
6475
  const context = ()=>this.getContext(index, active, mode);
6472
6476
  const values = config.resolveNamedOptions(scopes, names, context, prefixes);
6473
6477
  if (values.$shared) {
@@ -8225,7 +8229,7 @@ class BasicPlatform extends BasePlatform {
8225
8229
  }
8226
8230
  }
8227
8231
 
8228
- const EXPANDO_KEY = '$chartjs';
8232
+ const EXPANDO_KEY$1 = '$chartjs';
8229
8233
  const EVENT_TYPES = {
8230
8234
  touchstart: 'mousedown',
8231
8235
  touchmove: 'mousemove',
@@ -8242,7 +8246,7 @@ const isNullOrEmpty = (value)=>value === null || value === '';
8242
8246
  const style = canvas.style;
8243
8247
  const renderHeight = canvas.getAttribute('height');
8244
8248
  const renderWidth = canvas.getAttribute('width');
8245
- canvas[EXPANDO_KEY] = {
8249
+ canvas[EXPANDO_KEY$1] = {
8246
8250
  initial: {
8247
8251
  height: renderHeight,
8248
8252
  width: renderWidth,
@@ -8421,10 +8425,10 @@ function createProxyAndListen(chart, type, listener) {
8421
8425
  }
8422
8426
  releaseContext(context) {
8423
8427
  const canvas = context.canvas;
8424
- if (!canvas[EXPANDO_KEY]) {
8428
+ if (!canvas[EXPANDO_KEY$1]) {
8425
8429
  return false;
8426
8430
  }
8427
- const initial = canvas[EXPANDO_KEY].initial;
8431
+ const initial = canvas[EXPANDO_KEY$1].initial;
8428
8432
  [
8429
8433
  'height',
8430
8434
  'width'
@@ -8441,7 +8445,7 @@ function createProxyAndListen(chart, type, listener) {
8441
8445
  canvas.style[key] = style[key];
8442
8446
  });
8443
8447
  canvas.width = canvas.width;
8444
- delete canvas[EXPANDO_KEY];
8448
+ delete canvas[EXPANDO_KEY$1];
8445
8449
  return true;
8446
8450
  }
8447
8451
  addEventListener(chart, type, listener) {
@@ -9933,7 +9937,7 @@ class TypedRegistry {
9933
9937
  items[id] = item;
9934
9938
  registerDefaults(item, scope, parentScope);
9935
9939
  if (this.override) {
9936
- defaults.override(item.id, item.overrides);
9940
+ defaults$1.override(item.id, item.overrides);
9937
9941
  }
9938
9942
  return scope;
9939
9943
  }
@@ -9947,8 +9951,8 @@ class TypedRegistry {
9947
9951
  if (id in items) {
9948
9952
  delete items[id];
9949
9953
  }
9950
- if (scope && id in defaults[scope]) {
9951
- delete defaults[scope][id];
9954
+ if (scope && id in defaults$1[scope]) {
9955
+ delete defaults$1[scope][id];
9952
9956
  if (this.override) {
9953
9957
  delete overrides[id];
9954
9958
  }
@@ -9957,16 +9961,16 @@ class TypedRegistry {
9957
9961
  }
9958
9962
  function registerDefaults(item, scope, parentScope) {
9959
9963
  const itemDefaults = merge$1(Object.create(null), [
9960
- parentScope ? defaults.get(parentScope) : {},
9961
- defaults.get(scope),
9964
+ parentScope ? defaults$1.get(parentScope) : {},
9965
+ defaults$1.get(scope),
9962
9966
  item.defaults
9963
9967
  ]);
9964
- defaults.set(scope, itemDefaults);
9968
+ defaults$1.set(scope, itemDefaults);
9965
9969
  if (item.defaultRoutes) {
9966
9970
  routeDefaults(scope, item.defaultRoutes);
9967
9971
  }
9968
9972
  if (item.descriptors) {
9969
- defaults.describe(scope, item.descriptors);
9973
+ defaults$1.describe(scope, item.descriptors);
9970
9974
  }
9971
9975
  }
9972
9976
  function routeDefaults(scope, routes) {
@@ -9979,7 +9983,7 @@ function routeDefaults(scope, routes) {
9979
9983
  const parts = routes[property].split('.');
9980
9984
  const targetName = parts.pop();
9981
9985
  const targetScope = parts.join('.');
9982
- defaults.route(sourceScope, sourceName, targetScope, targetName);
9986
+ defaults$1.route(sourceScope, sourceName, targetScope, targetName);
9983
9987
  });
9984
9988
  }
9985
9989
  function isIChartComponent(proto) {
@@ -10205,7 +10209,7 @@ function pluginOpts(config, { plugin , local }, opts, context) {
10205
10209
  }
10206
10210
 
10207
10211
  function getIndexAxis(type, options) {
10208
- const datasetDefaults = defaults.datasets[type] || {};
10212
+ const datasetDefaults = defaults$1.datasets[type] || {};
10209
10213
  const datasetOptions = (options.datasets || {})[type] || {};
10210
10214
  return datasetOptions.indexAxis || options.indexAxis || datasetDefaults.indexAxis || 'x';
10211
10215
  }
@@ -10277,7 +10281,7 @@ function mergeScaleConfig(config, options) {
10277
10281
  if (scaleConf._proxy) {
10278
10282
  return console.warn(`Ignoring resolver passed as options for scale: ${id}`);
10279
10283
  }
10280
- const axis = determineAxis(id, scaleConf, retrieveAxisFromDatasets(id, config), defaults.scales[scaleConf.type]);
10284
+ const axis = determineAxis(id, scaleConf, retrieveAxisFromDatasets(id, config), defaults$1.scales[scaleConf.type]);
10281
10285
  const defaultId = getDefaultScaleIDFromAxis(axis, chartIndexAxis);
10282
10286
  const defaultScaleOptions = chartDefaults.scales || {};
10283
10287
  scales[id] = mergeIf(Object.create(null), [
@@ -10310,8 +10314,8 @@ function mergeScaleConfig(config, options) {
10310
10314
  Object.keys(scales).forEach((key)=>{
10311
10315
  const scale = scales[key];
10312
10316
  mergeIf(scale, [
10313
- defaults.scales[scale.type],
10314
- defaults.scale
10317
+ defaults$1.scales[scale.type],
10318
+ defaults$1.scale
10315
10319
  ]);
10316
10320
  });
10317
10321
  return scales;
@@ -10453,7 +10457,7 @@ class Config {
10453
10457
  }
10454
10458
  keys.forEach((key)=>addIfFound(scopes, options, key));
10455
10459
  keys.forEach((key)=>addIfFound(scopes, overrides[type] || {}, key));
10456
- keys.forEach((key)=>addIfFound(scopes, defaults, key));
10460
+ keys.forEach((key)=>addIfFound(scopes, defaults$1, key));
10457
10461
  keys.forEach((key)=>addIfFound(scopes, descriptors, key));
10458
10462
  });
10459
10463
  const array = Array.from(scopes);
@@ -10470,11 +10474,11 @@ class Config {
10470
10474
  return [
10471
10475
  options,
10472
10476
  overrides[type] || {},
10473
- defaults.datasets[type] || {},
10477
+ defaults$1.datasets[type] || {},
10474
10478
  {
10475
10479
  type
10476
10480
  },
10477
- defaults,
10481
+ defaults$1,
10478
10482
  descriptors
10479
10483
  ];
10480
10484
  }
@@ -10607,7 +10611,7 @@ function moveNumericKeys(obj, start, move) {
10607
10611
  return e;
10608
10612
  }
10609
10613
  let Chart$1 = class Chart {
10610
- static defaults = defaults;
10614
+ static defaults = defaults$1;
10611
10615
  static instances = instances;
10612
10616
  static overrides = overrides;
10613
10617
  static registry = registry;
@@ -10865,7 +10869,7 @@ let Chart$1 = class Chart {
10865
10869
  meta.controller.linkScales();
10866
10870
  } else {
10867
10871
  const ControllerClass = registry.getController(type);
10868
- const { datasetElementType , dataElementType } = defaults.datasets[type];
10872
+ const { datasetElementType , dataElementType } = defaults$1.datasets[type];
10869
10873
  Object.assign(ControllerClass, {
10870
10874
  dataElementType: registry.getElement(dataElementType),
10871
10875
  datasetElementType: datasetElementType && registry.getElement(datasetElementType)
@@ -12198,7 +12202,7 @@ function parseBorderRadius(bar, maxW, maxH) {
12198
12202
  bottomRight: skipOrLimit(!enableBorder || skip.bottom || skip.right, o.bottomRight, 0, maxR)
12199
12203
  };
12200
12204
  }
12201
- function boundingRects(bar) {
12205
+ function boundingRects$1(bar) {
12202
12206
  const bounds = getBarBounds(bar);
12203
12207
  const width = bounds.right - bounds.left;
12204
12208
  const height = bounds.bottom - bounds.top;
@@ -12279,7 +12283,7 @@ class BarElement extends Element {
12279
12283
  }
12280
12284
  draw(ctx) {
12281
12285
  const { inflateAmount , options: { borderColor , backgroundColor } } = this;
12282
- const { inner , outer } = boundingRects(this);
12286
+ const { inner , outer } = boundingRects$1(this);
12283
12287
  const addRectPath = hasRadius(outer.radius) ? addRoundedRectPath : addNormalRectPath;
12284
12288
  ctx.save();
12285
12289
  if (outer.w !== inner.w || outer.h !== inner.h) {
@@ -12537,7 +12541,7 @@ class Legend extends Element {
12537
12541
  _draw() {
12538
12542
  const { options: opts , columnSizes , lineWidths , ctx } = this;
12539
12543
  const { align , labels: labelOpts } = opts;
12540
- const defaultColor = defaults.color;
12544
+ const defaultColor = defaults$1.color;
12541
12545
  const rtlHelper = getRtlAdapter(opts.rtl, this.left, this.width);
12542
12546
  const labelFont = toFont(labelOpts.font);
12543
12547
  const { padding } = labelOpts;
@@ -13011,7 +13015,7 @@ var plugin_title = {
13011
13015
  }
13012
13016
  };
13013
13017
 
13014
- const positioners = {
13018
+ const positioners$2 = {
13015
13019
  average (items) {
13016
13020
  if (!items.length) {
13017
13021
  return false;
@@ -13326,7 +13330,7 @@ const defaultCallbacks = {
13326
13330
  return result;
13327
13331
  }
13328
13332
  class Tooltip extends Element {
13329
- static positioners = positioners;
13333
+ static positioners = positioners$2;
13330
13334
  constructor(config){
13331
13335
  super();
13332
13336
  this.opacity = 0;
@@ -13465,7 +13469,7 @@ class Tooltip extends Element {
13465
13469
  };
13466
13470
  }
13467
13471
  } else {
13468
- const position = positioners[options.position].call(this, active, this._eventPosition);
13472
+ const position = positioners$2[options.position].call(this, active, this._eventPosition);
13469
13473
  tooltipItems = this._createItems(options);
13470
13474
  this.title = this.getTitle(tooltipItems, options);
13471
13475
  this.beforeBody = this.getBeforeBody(tooltipItems, options);
@@ -13746,7 +13750,7 @@ class Tooltip extends Element {
13746
13750
  const animX = anims && anims.x;
13747
13751
  const animY = anims && anims.y;
13748
13752
  if (animX || animY) {
13749
- const position = positioners[options.position].call(this, this._active, this._eventPosition);
13753
+ const position = positioners$2[options.position].call(this, this._active, this._eventPosition);
13750
13754
  if (!position) {
13751
13755
  return;
13752
13756
  }
@@ -13862,14 +13866,14 @@ class Tooltip extends Element {
13862
13866
  }
13863
13867
  _positionChanged(active, e) {
13864
13868
  const { caretX , caretY , options } = this;
13865
- const position = positioners[options.position].call(this, active, e);
13869
+ const position = positioners$2[options.position].call(this, active, e);
13866
13870
  return position !== false && (caretX !== position.x || caretY !== position.y);
13867
13871
  }
13868
13872
  }
13869
13873
  var plugin_tooltip = {
13870
13874
  id: 'tooltip',
13871
13875
  _element: Tooltip,
13872
- positioners,
13876
+ positioners: positioners$2,
13873
13877
  afterInit (chart, _args, options) {
13874
13878
  if (options) {
13875
13879
  chart.tooltip = new Tooltip({
@@ -15135,7 +15139,7 @@ function BarChart({ orientation, title, data, options, className, units, content
15135
15139
  }
15136
15140
 
15137
15141
  Chart$1.register(CategoryScale, LinearScale, BarElement, plugin_title, plugin_tooltip, plugin_legend);
15138
- function SeriesChart({ orientation, title, data, options, className, units, content }) {
15142
+ function SeriesChart({ orientation, title, data, options, className, units, content, x_axis_title, y_axis_title }) {
15139
15143
  var _a, _b;
15140
15144
  const formatValue = (value) => {
15141
15145
  const numValue = typeof value === 'string' ? parseFloat(value) : value;
@@ -15222,12 +15226,16 @@ function SeriesChart({ orientation, title, data, options, className, units, cont
15222
15226
  },
15223
15227
  scales: {
15224
15228
  x: {
15229
+ title: {
15230
+ display: !!x_axis_title,
15231
+ text: x_axis_title,
15232
+ },
15225
15233
  ticks: { autoSkip: false, maxRotation: 45, minRotation: 0 },
15226
15234
  },
15227
15235
  y: {
15228
15236
  title: {
15229
15237
  display: true,
15230
- text: (data === null || data === void 0 ? void 0 : data.datasets) && ((_a = data === null || data === void 0 ? void 0 : data.datasets) === null || _a === void 0 ? void 0 : _a.length) === 1 ? (_b = data === null || data === void 0 ? void 0 : data.datasets) === null || _b === void 0 ? void 0 : _b[0].label : getAxisLabel(units !== null && units !== void 0 ? units : ""),
15238
+ text: y_axis_title || ((data === null || data === void 0 ? void 0 : data.datasets) && ((_a = data === null || data === void 0 ? void 0 : data.datasets) === null || _a === void 0 ? void 0 : _a.length) === 1 ? (_b = data === null || data === void 0 ? void 0 : data.datasets) === null || _b === void 0 ? void 0 : _b[0].label : getAxisLabel(units !== null && units !== void 0 ? units : "")),
15231
15239
  },
15232
15240
  beginAtZero: true,
15233
15241
  ticks: {
@@ -15244,9 +15252,1358 @@ function SeriesChart({ orientation, title, data, options, className, units, cont
15244
15252
  return (jsxRuntimeExports.jsx(Bar, { data: data, options: options !== null && options !== void 0 ? options : defaultOptions, plugins: [barValuePlugin] }));
15245
15253
  }
15246
15254
 
15255
+ /*!
15256
+ * chartjs-plugin-datalabels v2.2.0
15257
+ * https://chartjs-plugin-datalabels.netlify.app
15258
+ * (c) 2017-2022 chartjs-plugin-datalabels contributors
15259
+ * Released under the MIT license
15260
+ */
15261
+
15262
+ var devicePixelRatio = (function() {
15263
+ if (typeof window !== 'undefined') {
15264
+ if (window.devicePixelRatio) {
15265
+ return window.devicePixelRatio;
15266
+ }
15267
+
15268
+ // devicePixelRatio is undefined on IE10
15269
+ // https://stackoverflow.com/a/20204180/8837887
15270
+ // https://github.com/chartjs/chartjs-plugin-datalabels/issues/85
15271
+ var screen = window.screen;
15272
+ if (screen) {
15273
+ return (screen.deviceXDPI || 1) / (screen.logicalXDPI || 1);
15274
+ }
15275
+ }
15276
+
15277
+ return 1;
15278
+ }());
15279
+
15280
+ var utils = {
15281
+ // @todo move this in Chart.helpers.toTextLines
15282
+ toTextLines: function(inputs) {
15283
+ var lines = [];
15284
+ var input;
15285
+
15286
+ inputs = [].concat(inputs);
15287
+ while (inputs.length) {
15288
+ input = inputs.pop();
15289
+ if (typeof input === 'string') {
15290
+ lines.unshift.apply(lines, input.split('\n'));
15291
+ } else if (Array.isArray(input)) {
15292
+ inputs.push.apply(inputs, input);
15293
+ } else if (!isNullOrUndef(inputs)) {
15294
+ lines.unshift('' + input);
15295
+ }
15296
+ }
15297
+
15298
+ return lines;
15299
+ },
15300
+
15301
+ // @todo move this in Chart.helpers.canvas.textSize
15302
+ // @todo cache calls of measureText if font doesn't change?!
15303
+ textSize: function(ctx, lines, font) {
15304
+ var items = [].concat(lines);
15305
+ var ilen = items.length;
15306
+ var prev = ctx.font;
15307
+ var width = 0;
15308
+ var i;
15309
+
15310
+ ctx.font = font.string;
15311
+
15312
+ for (i = 0; i < ilen; ++i) {
15313
+ width = Math.max(ctx.measureText(items[i]).width, width);
15314
+ }
15315
+
15316
+ ctx.font = prev;
15317
+
15318
+ return {
15319
+ height: ilen * font.lineHeight,
15320
+ width: width
15321
+ };
15322
+ },
15323
+
15324
+ /**
15325
+ * Returns value bounded by min and max. This is equivalent to max(min, min(value, max)).
15326
+ * @todo move this method in Chart.helpers.bound
15327
+ * https://doc.qt.io/qt-5/qtglobal.html#qBound
15328
+ */
15329
+ bound: function(min, value, max) {
15330
+ return Math.max(min, Math.min(value, max));
15331
+ },
15332
+
15333
+ /**
15334
+ * Returns an array of pair [value, state] where state is:
15335
+ * * -1: value is only in a0 (removed)
15336
+ * * 1: value is only in a1 (added)
15337
+ */
15338
+ arrayDiff: function(a0, a1) {
15339
+ var prev = a0.slice();
15340
+ var updates = [];
15341
+ var i, j, ilen, v;
15342
+
15343
+ for (i = 0, ilen = a1.length; i < ilen; ++i) {
15344
+ v = a1[i];
15345
+ j = prev.indexOf(v);
15346
+
15347
+ if (j === -1) {
15348
+ updates.push([v, 1]);
15349
+ } else {
15350
+ prev.splice(j, 1);
15351
+ }
15352
+ }
15353
+
15354
+ for (i = 0, ilen = prev.length; i < ilen; ++i) {
15355
+ updates.push([prev[i], -1]);
15356
+ }
15357
+
15358
+ return updates;
15359
+ },
15360
+
15361
+ /**
15362
+ * https://github.com/chartjs/chartjs-plugin-datalabels/issues/70
15363
+ */
15364
+ rasterize: function(v) {
15365
+ return Math.round(v * devicePixelRatio) / devicePixelRatio;
15366
+ }
15367
+ };
15368
+
15369
+ function orient(point, origin) {
15370
+ var x0 = origin.x;
15371
+ var y0 = origin.y;
15372
+
15373
+ if (x0 === null) {
15374
+ return {x: 0, y: -1};
15375
+ }
15376
+ if (y0 === null) {
15377
+ return {x: 1, y: 0};
15378
+ }
15379
+
15380
+ var dx = point.x - x0;
15381
+ var dy = point.y - y0;
15382
+ var ln = Math.sqrt(dx * dx + dy * dy);
15383
+
15384
+ return {
15385
+ x: ln ? dx / ln : 0,
15386
+ y: ln ? dy / ln : -1
15387
+ };
15388
+ }
15389
+
15390
+ function aligned(x, y, vx, vy, align) {
15391
+ switch (align) {
15392
+ case 'center':
15393
+ vx = vy = 0;
15394
+ break;
15395
+ case 'bottom':
15396
+ vx = 0;
15397
+ vy = 1;
15398
+ break;
15399
+ case 'right':
15400
+ vx = 1;
15401
+ vy = 0;
15402
+ break;
15403
+ case 'left':
15404
+ vx = -1;
15405
+ vy = 0;
15406
+ break;
15407
+ case 'top':
15408
+ vx = 0;
15409
+ vy = -1;
15410
+ break;
15411
+ case 'start':
15412
+ vx = -vx;
15413
+ vy = -vy;
15414
+ break;
15415
+ case 'end':
15416
+ // keep natural orientation
15417
+ break;
15418
+ default:
15419
+ // clockwise rotation (in degree)
15420
+ align *= (Math.PI / 180);
15421
+ vx = Math.cos(align);
15422
+ vy = Math.sin(align);
15423
+ break;
15424
+ }
15425
+
15426
+ return {
15427
+ x: x,
15428
+ y: y,
15429
+ vx: vx,
15430
+ vy: vy
15431
+ };
15432
+ }
15433
+
15434
+ // Line clipping (Cohen–Sutherland algorithm)
15435
+ // https://en.wikipedia.org/wiki/Cohen–Sutherland_algorithm
15436
+
15437
+ var R_INSIDE = 0;
15438
+ var R_LEFT = 1;
15439
+ var R_RIGHT = 2;
15440
+ var R_BOTTOM = 4;
15441
+ var R_TOP = 8;
15442
+
15443
+ function region(x, y, rect) {
15444
+ var res = R_INSIDE;
15445
+
15446
+ if (x < rect.left) {
15447
+ res |= R_LEFT;
15448
+ } else if (x > rect.right) {
15449
+ res |= R_RIGHT;
15450
+ }
15451
+ if (y < rect.top) {
15452
+ res |= R_TOP;
15453
+ } else if (y > rect.bottom) {
15454
+ res |= R_BOTTOM;
15455
+ }
15456
+
15457
+ return res;
15458
+ }
15459
+
15460
+ function clipped(segment, area) {
15461
+ var x0 = segment.x0;
15462
+ var y0 = segment.y0;
15463
+ var x1 = segment.x1;
15464
+ var y1 = segment.y1;
15465
+ var r0 = region(x0, y0, area);
15466
+ var r1 = region(x1, y1, area);
15467
+ var r, x, y;
15468
+
15469
+ // eslint-disable-next-line no-constant-condition
15470
+ while (true) {
15471
+ if (!(r0 | r1) || (r0 & r1)) {
15472
+ // both points inside or on the same side: no clipping
15473
+ break;
15474
+ }
15475
+
15476
+ // at least one point is outside
15477
+ r = r0 || r1;
15478
+
15479
+ if (r & R_TOP) {
15480
+ x = x0 + (x1 - x0) * (area.top - y0) / (y1 - y0);
15481
+ y = area.top;
15482
+ } else if (r & R_BOTTOM) {
15483
+ x = x0 + (x1 - x0) * (area.bottom - y0) / (y1 - y0);
15484
+ y = area.bottom;
15485
+ } else if (r & R_RIGHT) {
15486
+ y = y0 + (y1 - y0) * (area.right - x0) / (x1 - x0);
15487
+ x = area.right;
15488
+ } else if (r & R_LEFT) {
15489
+ y = y0 + (y1 - y0) * (area.left - x0) / (x1 - x0);
15490
+ x = area.left;
15491
+ }
15492
+
15493
+ if (r === r0) {
15494
+ x0 = x;
15495
+ y0 = y;
15496
+ r0 = region(x0, y0, area);
15497
+ } else {
15498
+ x1 = x;
15499
+ y1 = y;
15500
+ r1 = region(x1, y1, area);
15501
+ }
15502
+ }
15503
+
15504
+ return {
15505
+ x0: x0,
15506
+ x1: x1,
15507
+ y0: y0,
15508
+ y1: y1
15509
+ };
15510
+ }
15511
+
15512
+ function compute$1(range, config) {
15513
+ var anchor = config.anchor;
15514
+ var segment = range;
15515
+ var x, y;
15516
+
15517
+ if (config.clamp) {
15518
+ segment = clipped(segment, config.area);
15519
+ }
15520
+
15521
+ if (anchor === 'start') {
15522
+ x = segment.x0;
15523
+ y = segment.y0;
15524
+ } else if (anchor === 'end') {
15525
+ x = segment.x1;
15526
+ y = segment.y1;
15527
+ } else {
15528
+ x = (segment.x0 + segment.x1) / 2;
15529
+ y = (segment.y0 + segment.y1) / 2;
15530
+ }
15531
+
15532
+ return aligned(x, y, range.vx, range.vy, config.align);
15533
+ }
15534
+
15535
+ var positioners$1 = {
15536
+ arc: function(el, config) {
15537
+ var angle = (el.startAngle + el.endAngle) / 2;
15538
+ var vx = Math.cos(angle);
15539
+ var vy = Math.sin(angle);
15540
+ var r0 = el.innerRadius;
15541
+ var r1 = el.outerRadius;
15542
+
15543
+ return compute$1({
15544
+ x0: el.x + vx * r0,
15545
+ y0: el.y + vy * r0,
15546
+ x1: el.x + vx * r1,
15547
+ y1: el.y + vy * r1,
15548
+ vx: vx,
15549
+ vy: vy
15550
+ }, config);
15551
+ },
15552
+
15553
+ point: function(el, config) {
15554
+ var v = orient(el, config.origin);
15555
+ var rx = v.x * el.options.radius;
15556
+ var ry = v.y * el.options.radius;
15557
+
15558
+ return compute$1({
15559
+ x0: el.x - rx,
15560
+ y0: el.y - ry,
15561
+ x1: el.x + rx,
15562
+ y1: el.y + ry,
15563
+ vx: v.x,
15564
+ vy: v.y
15565
+ }, config);
15566
+ },
15567
+
15568
+ bar: function(el, config) {
15569
+ var v = orient(el, config.origin);
15570
+ var x = el.x;
15571
+ var y = el.y;
15572
+ var sx = 0;
15573
+ var sy = 0;
15574
+
15575
+ if (el.horizontal) {
15576
+ x = Math.min(el.x, el.base);
15577
+ sx = Math.abs(el.base - el.x);
15578
+ } else {
15579
+ y = Math.min(el.y, el.base);
15580
+ sy = Math.abs(el.base - el.y);
15581
+ }
15582
+
15583
+ return compute$1({
15584
+ x0: x,
15585
+ y0: y + sy,
15586
+ x1: x + sx,
15587
+ y1: y,
15588
+ vx: v.x,
15589
+ vy: v.y
15590
+ }, config);
15591
+ },
15592
+
15593
+ fallback: function(el, config) {
15594
+ var v = orient(el, config.origin);
15595
+
15596
+ return compute$1({
15597
+ x0: el.x,
15598
+ y0: el.y,
15599
+ x1: el.x + (el.width || 0),
15600
+ y1: el.y + (el.height || 0),
15601
+ vx: v.x,
15602
+ vy: v.y
15603
+ }, config);
15604
+ }
15605
+ };
15606
+
15607
+ var rasterize = utils.rasterize;
15608
+
15609
+ function boundingRects(model) {
15610
+ var borderWidth = model.borderWidth || 0;
15611
+ var padding = model.padding;
15612
+ var th = model.size.height;
15613
+ var tw = model.size.width;
15614
+ var tx = -tw / 2;
15615
+ var ty = -th / 2;
15616
+
15617
+ return {
15618
+ frame: {
15619
+ x: tx - padding.left - borderWidth,
15620
+ y: ty - padding.top - borderWidth,
15621
+ w: tw + padding.width + borderWidth * 2,
15622
+ h: th + padding.height + borderWidth * 2
15623
+ },
15624
+ text: {
15625
+ x: tx,
15626
+ y: ty,
15627
+ w: tw,
15628
+ h: th
15629
+ }
15630
+ };
15631
+ }
15632
+
15633
+ function getScaleOrigin(el, context) {
15634
+ var scale = context.chart.getDatasetMeta(context.datasetIndex).vScale;
15635
+
15636
+ if (!scale) {
15637
+ return null;
15638
+ }
15639
+
15640
+ if (scale.xCenter !== undefined && scale.yCenter !== undefined) {
15641
+ return {x: scale.xCenter, y: scale.yCenter};
15642
+ }
15643
+
15644
+ var pixel = scale.getBasePixel();
15645
+ return el.horizontal ?
15646
+ {x: pixel, y: null} :
15647
+ {x: null, y: pixel};
15648
+ }
15649
+
15650
+ function getPositioner(el) {
15651
+ if (el instanceof ArcElement) {
15652
+ return positioners$1.arc;
15653
+ }
15654
+ if (el instanceof PointElement) {
15655
+ return positioners$1.point;
15656
+ }
15657
+ if (el instanceof BarElement) {
15658
+ return positioners$1.bar;
15659
+ }
15660
+ return positioners$1.fallback;
15661
+ }
15662
+
15663
+ function drawRoundedRect(ctx, x, y, w, h, radius) {
15664
+ var HALF_PI = Math.PI / 2;
15665
+
15666
+ if (radius) {
15667
+ var r = Math.min(radius, h / 2, w / 2);
15668
+ var left = x + r;
15669
+ var top = y + r;
15670
+ var right = x + w - r;
15671
+ var bottom = y + h - r;
15672
+
15673
+ ctx.moveTo(x, top);
15674
+ if (left < right && top < bottom) {
15675
+ ctx.arc(left, top, r, -Math.PI, -HALF_PI);
15676
+ ctx.arc(right, top, r, -HALF_PI, 0);
15677
+ ctx.arc(right, bottom, r, 0, HALF_PI);
15678
+ ctx.arc(left, bottom, r, HALF_PI, Math.PI);
15679
+ } else if (left < right) {
15680
+ ctx.moveTo(left, y);
15681
+ ctx.arc(right, top, r, -HALF_PI, HALF_PI);
15682
+ ctx.arc(left, top, r, HALF_PI, Math.PI + HALF_PI);
15683
+ } else if (top < bottom) {
15684
+ ctx.arc(left, top, r, -Math.PI, 0);
15685
+ ctx.arc(left, bottom, r, 0, Math.PI);
15686
+ } else {
15687
+ ctx.arc(left, top, r, -Math.PI, Math.PI);
15688
+ }
15689
+ ctx.closePath();
15690
+ ctx.moveTo(x, y);
15691
+ } else {
15692
+ ctx.rect(x, y, w, h);
15693
+ }
15694
+ }
15695
+
15696
+ function drawFrame(ctx, rect, model) {
15697
+ var bgColor = model.backgroundColor;
15698
+ var borderColor = model.borderColor;
15699
+ var borderWidth = model.borderWidth;
15700
+
15701
+ if (!bgColor && (!borderColor || !borderWidth)) {
15702
+ return;
15703
+ }
15704
+
15705
+ ctx.beginPath();
15706
+
15707
+ drawRoundedRect(
15708
+ ctx,
15709
+ rasterize(rect.x) + borderWidth / 2,
15710
+ rasterize(rect.y) + borderWidth / 2,
15711
+ rasterize(rect.w) - borderWidth,
15712
+ rasterize(rect.h) - borderWidth,
15713
+ model.borderRadius);
15714
+
15715
+ ctx.closePath();
15716
+
15717
+ if (bgColor) {
15718
+ ctx.fillStyle = bgColor;
15719
+ ctx.fill();
15720
+ }
15721
+
15722
+ if (borderColor && borderWidth) {
15723
+ ctx.strokeStyle = borderColor;
15724
+ ctx.lineWidth = borderWidth;
15725
+ ctx.lineJoin = 'miter';
15726
+ ctx.stroke();
15727
+ }
15728
+ }
15729
+
15730
+ function textGeometry(rect, align, font) {
15731
+ var h = font.lineHeight;
15732
+ var w = rect.w;
15733
+ var x = rect.x;
15734
+ var y = rect.y + h / 2;
15735
+
15736
+ if (align === 'center') {
15737
+ x += w / 2;
15738
+ } else if (align === 'end' || align === 'right') {
15739
+ x += w;
15740
+ }
15741
+
15742
+ return {
15743
+ h: h,
15744
+ w: w,
15745
+ x: x,
15746
+ y: y
15747
+ };
15748
+ }
15749
+
15750
+ function drawTextLine(ctx, text, cfg) {
15751
+ var shadow = ctx.shadowBlur;
15752
+ var stroked = cfg.stroked;
15753
+ var x = rasterize(cfg.x);
15754
+ var y = rasterize(cfg.y);
15755
+ var w = rasterize(cfg.w);
15756
+
15757
+ if (stroked) {
15758
+ ctx.strokeText(text, x, y, w);
15759
+ }
15760
+
15761
+ if (cfg.filled) {
15762
+ if (shadow && stroked) {
15763
+ // Prevent drawing shadow on both the text stroke and fill, so
15764
+ // if the text is stroked, remove the shadow for the text fill.
15765
+ ctx.shadowBlur = 0;
15766
+ }
15767
+
15768
+ ctx.fillText(text, x, y, w);
15769
+
15770
+ if (shadow && stroked) {
15771
+ ctx.shadowBlur = shadow;
15772
+ }
15773
+ }
15774
+ }
15775
+
15776
+ function drawText(ctx, lines, rect, model) {
15777
+ var align = model.textAlign;
15778
+ var color = model.color;
15779
+ var filled = !!color;
15780
+ var font = model.font;
15781
+ var ilen = lines.length;
15782
+ var strokeColor = model.textStrokeColor;
15783
+ var strokeWidth = model.textStrokeWidth;
15784
+ var stroked = strokeColor && strokeWidth;
15785
+ var i;
15786
+
15787
+ if (!ilen || (!filled && !stroked)) {
15788
+ return;
15789
+ }
15790
+
15791
+ // Adjust coordinates based on text alignment and line height
15792
+ rect = textGeometry(rect, align, font);
15793
+
15794
+ ctx.font = font.string;
15795
+ ctx.textAlign = align;
15796
+ ctx.textBaseline = 'middle';
15797
+ ctx.shadowBlur = model.textShadowBlur;
15798
+ ctx.shadowColor = model.textShadowColor;
15799
+
15800
+ if (filled) {
15801
+ ctx.fillStyle = color;
15802
+ }
15803
+ if (stroked) {
15804
+ ctx.lineJoin = 'round';
15805
+ ctx.lineWidth = strokeWidth;
15806
+ ctx.strokeStyle = strokeColor;
15807
+ }
15808
+
15809
+ for (i = 0, ilen = lines.length; i < ilen; ++i) {
15810
+ drawTextLine(ctx, lines[i], {
15811
+ stroked: stroked,
15812
+ filled: filled,
15813
+ w: rect.w,
15814
+ x: rect.x,
15815
+ y: rect.y + rect.h * i
15816
+ });
15817
+ }
15818
+ }
15819
+
15820
+ var Label = function(config, ctx, el, index) {
15821
+ var me = this;
15822
+
15823
+ me._config = config;
15824
+ me._index = index;
15825
+ me._model = null;
15826
+ me._rects = null;
15827
+ me._ctx = ctx;
15828
+ me._el = el;
15829
+ };
15830
+
15831
+ merge$1(Label.prototype, {
15832
+ /**
15833
+ * @private
15834
+ */
15835
+ _modelize: function(display, lines, config, context) {
15836
+ var me = this;
15837
+ var index = me._index;
15838
+ var font = toFont(resolve([config.font, {}], context, index));
15839
+ var color = resolve([config.color, defaults$1.color], context, index);
15840
+
15841
+ return {
15842
+ align: resolve([config.align, 'center'], context, index),
15843
+ anchor: resolve([config.anchor, 'center'], context, index),
15844
+ area: context.chart.chartArea,
15845
+ backgroundColor: resolve([config.backgroundColor, null], context, index),
15846
+ borderColor: resolve([config.borderColor, null], context, index),
15847
+ borderRadius: resolve([config.borderRadius, 0], context, index),
15848
+ borderWidth: resolve([config.borderWidth, 0], context, index),
15849
+ clamp: resolve([config.clamp, false], context, index),
15850
+ clip: resolve([config.clip, false], context, index),
15851
+ color: color,
15852
+ display: display,
15853
+ font: font,
15854
+ lines: lines,
15855
+ offset: resolve([config.offset, 4], context, index),
15856
+ opacity: resolve([config.opacity, 1], context, index),
15857
+ origin: getScaleOrigin(me._el, context),
15858
+ padding: toPadding(resolve([config.padding, 4], context, index)),
15859
+ positioner: getPositioner(me._el),
15860
+ rotation: resolve([config.rotation, 0], context, index) * (Math.PI / 180),
15861
+ size: utils.textSize(me._ctx, lines, font),
15862
+ textAlign: resolve([config.textAlign, 'start'], context, index),
15863
+ textShadowBlur: resolve([config.textShadowBlur, 0], context, index),
15864
+ textShadowColor: resolve([config.textShadowColor, color], context, index),
15865
+ textStrokeColor: resolve([config.textStrokeColor, color], context, index),
15866
+ textStrokeWidth: resolve([config.textStrokeWidth, 0], context, index)
15867
+ };
15868
+ },
15869
+
15870
+ update: function(context) {
15871
+ var me = this;
15872
+ var model = null;
15873
+ var rects = null;
15874
+ var index = me._index;
15875
+ var config = me._config;
15876
+ var value, label, lines;
15877
+
15878
+ // We first resolve the display option (separately) to avoid computing
15879
+ // other options in case the label is hidden (i.e. display: false).
15880
+ var display = resolve([config.display, true], context, index);
15881
+
15882
+ if (display) {
15883
+ value = context.dataset.data[index];
15884
+ label = valueOrDefault(callback(config.formatter, [value, context]), value);
15885
+ lines = isNullOrUndef(label) ? [] : utils.toTextLines(label);
15886
+
15887
+ if (lines.length) {
15888
+ model = me._modelize(display, lines, config, context);
15889
+ rects = boundingRects(model);
15890
+ }
15891
+ }
15892
+
15893
+ me._model = model;
15894
+ me._rects = rects;
15895
+ },
15896
+
15897
+ geometry: function() {
15898
+ return this._rects ? this._rects.frame : {};
15899
+ },
15900
+
15901
+ rotation: function() {
15902
+ return this._model ? this._model.rotation : 0;
15903
+ },
15904
+
15905
+ visible: function() {
15906
+ return this._model && this._model.opacity;
15907
+ },
15908
+
15909
+ model: function() {
15910
+ return this._model;
15911
+ },
15912
+
15913
+ draw: function(chart, center) {
15914
+ var me = this;
15915
+ var ctx = chart.ctx;
15916
+ var model = me._model;
15917
+ var rects = me._rects;
15918
+ var area;
15919
+
15920
+ if (!this.visible()) {
15921
+ return;
15922
+ }
15923
+
15924
+ ctx.save();
15925
+
15926
+ if (model.clip) {
15927
+ area = model.area;
15928
+ ctx.beginPath();
15929
+ ctx.rect(
15930
+ area.left,
15931
+ area.top,
15932
+ area.right - area.left,
15933
+ area.bottom - area.top);
15934
+ ctx.clip();
15935
+ }
15936
+
15937
+ ctx.globalAlpha = utils.bound(0, model.opacity, 1);
15938
+ ctx.translate(rasterize(center.x), rasterize(center.y));
15939
+ ctx.rotate(model.rotation);
15940
+
15941
+ drawFrame(ctx, rects.frame, model);
15942
+ drawText(ctx, model.lines, rects.text, model);
15943
+
15944
+ ctx.restore();
15945
+ }
15946
+ });
15947
+
15948
+ var MIN_INTEGER = Number.MIN_SAFE_INTEGER || -9007199254740991; // eslint-disable-line es/no-number-minsafeinteger
15949
+ var MAX_INTEGER = Number.MAX_SAFE_INTEGER || 9007199254740991; // eslint-disable-line es/no-number-maxsafeinteger
15950
+
15951
+ function rotated(point, center, angle) {
15952
+ var cos = Math.cos(angle);
15953
+ var sin = Math.sin(angle);
15954
+ var cx = center.x;
15955
+ var cy = center.y;
15956
+
15957
+ return {
15958
+ x: cx + cos * (point.x - cx) - sin * (point.y - cy),
15959
+ y: cy + sin * (point.x - cx) + cos * (point.y - cy)
15960
+ };
15961
+ }
15962
+
15963
+ function projected(points, axis) {
15964
+ var min = MAX_INTEGER;
15965
+ var max = MIN_INTEGER;
15966
+ var origin = axis.origin;
15967
+ var i, pt, vx, vy, dp;
15968
+
15969
+ for (i = 0; i < points.length; ++i) {
15970
+ pt = points[i];
15971
+ vx = pt.x - origin.x;
15972
+ vy = pt.y - origin.y;
15973
+ dp = axis.vx * vx + axis.vy * vy;
15974
+ min = Math.min(min, dp);
15975
+ max = Math.max(max, dp);
15976
+ }
15977
+
15978
+ return {
15979
+ min: min,
15980
+ max: max
15981
+ };
15982
+ }
15983
+
15984
+ function toAxis(p0, p1) {
15985
+ var vx = p1.x - p0.x;
15986
+ var vy = p1.y - p0.y;
15987
+ var ln = Math.sqrt(vx * vx + vy * vy);
15988
+
15989
+ return {
15990
+ vx: (p1.x - p0.x) / ln,
15991
+ vy: (p1.y - p0.y) / ln,
15992
+ origin: p0,
15993
+ ln: ln
15994
+ };
15995
+ }
15996
+
15997
+ var HitBox = function() {
15998
+ this._rotation = 0;
15999
+ this._rect = {
16000
+ x: 0,
16001
+ y: 0,
16002
+ w: 0,
16003
+ h: 0
16004
+ };
16005
+ };
16006
+
16007
+ merge$1(HitBox.prototype, {
16008
+ center: function() {
16009
+ var r = this._rect;
16010
+ return {
16011
+ x: r.x + r.w / 2,
16012
+ y: r.y + r.h / 2
16013
+ };
16014
+ },
16015
+
16016
+ update: function(center, rect, rotation) {
16017
+ this._rotation = rotation;
16018
+ this._rect = {
16019
+ x: rect.x + center.x,
16020
+ y: rect.y + center.y,
16021
+ w: rect.w,
16022
+ h: rect.h
16023
+ };
16024
+ },
16025
+
16026
+ contains: function(point) {
16027
+ var me = this;
16028
+ var margin = 1;
16029
+ var rect = me._rect;
16030
+
16031
+ point = rotated(point, me.center(), -me._rotation);
16032
+
16033
+ return !(point.x < rect.x - margin
16034
+ || point.y < rect.y - margin
16035
+ || point.x > rect.x + rect.w + margin * 2
16036
+ || point.y > rect.y + rect.h + margin * 2);
16037
+ },
16038
+
16039
+ // Separating Axis Theorem
16040
+ // https://gamedevelopment.tutsplus.com/tutorials/collision-detection-using-the-separating-axis-theorem--gamedev-169
16041
+ intersects: function(other) {
16042
+ var r0 = this._points();
16043
+ var r1 = other._points();
16044
+ var axes = [
16045
+ toAxis(r0[0], r0[1]),
16046
+ toAxis(r0[0], r0[3])
16047
+ ];
16048
+ var i, pr0, pr1;
16049
+
16050
+ if (this._rotation !== other._rotation) {
16051
+ // Only separate with r1 axis if the rotation is different,
16052
+ // else it's enough to separate r0 and r1 with r0 axis only!
16053
+ axes.push(
16054
+ toAxis(r1[0], r1[1]),
16055
+ toAxis(r1[0], r1[3])
16056
+ );
16057
+ }
16058
+
16059
+ for (i = 0; i < axes.length; ++i) {
16060
+ pr0 = projected(r0, axes[i]);
16061
+ pr1 = projected(r1, axes[i]);
16062
+
16063
+ if (pr0.max < pr1.min || pr1.max < pr0.min) {
16064
+ return false;
16065
+ }
16066
+ }
16067
+
16068
+ return true;
16069
+ },
16070
+
16071
+ /**
16072
+ * @private
16073
+ */
16074
+ _points: function() {
16075
+ var me = this;
16076
+ var rect = me._rect;
16077
+ var angle = me._rotation;
16078
+ var center = me.center();
16079
+
16080
+ return [
16081
+ rotated({x: rect.x, y: rect.y}, center, angle),
16082
+ rotated({x: rect.x + rect.w, y: rect.y}, center, angle),
16083
+ rotated({x: rect.x + rect.w, y: rect.y + rect.h}, center, angle),
16084
+ rotated({x: rect.x, y: rect.y + rect.h}, center, angle)
16085
+ ];
16086
+ }
16087
+ });
16088
+
16089
+ function coordinates(el, model, geometry) {
16090
+ var point = model.positioner(el, model);
16091
+ var vx = point.vx;
16092
+ var vy = point.vy;
16093
+
16094
+ if (!vx && !vy) {
16095
+ // if aligned center, we don't want to offset the center point
16096
+ return {x: point.x, y: point.y};
16097
+ }
16098
+
16099
+ var w = geometry.w;
16100
+ var h = geometry.h;
16101
+
16102
+ // take in account the label rotation
16103
+ var rotation = model.rotation;
16104
+ var dx = Math.abs(w / 2 * Math.cos(rotation)) + Math.abs(h / 2 * Math.sin(rotation));
16105
+ var dy = Math.abs(w / 2 * Math.sin(rotation)) + Math.abs(h / 2 * Math.cos(rotation));
16106
+
16107
+ // scale the unit vector (vx, vy) to get at least dx or dy equal to
16108
+ // w or h respectively (else we would calculate the distance to the
16109
+ // ellipse inscribed in the bounding rect)
16110
+ var vs = 1 / Math.max(Math.abs(vx), Math.abs(vy));
16111
+ dx *= vx * vs;
16112
+ dy *= vy * vs;
16113
+
16114
+ // finally, include the explicit offset
16115
+ dx += model.offset * vx;
16116
+ dy += model.offset * vy;
16117
+
16118
+ return {
16119
+ x: point.x + dx,
16120
+ y: point.y + dy
16121
+ };
16122
+ }
16123
+
16124
+ function collide(labels, collider) {
16125
+ var i, j, s0, s1;
16126
+
16127
+ // IMPORTANT Iterate in the reverse order since items at the end of the
16128
+ // list have an higher weight/priority and thus should be less impacted
16129
+ // by the overlapping strategy.
16130
+
16131
+ for (i = labels.length - 1; i >= 0; --i) {
16132
+ s0 = labels[i].$layout;
16133
+
16134
+ for (j = i - 1; j >= 0 && s0._visible; --j) {
16135
+ s1 = labels[j].$layout;
16136
+
16137
+ if (s1._visible && s0._box.intersects(s1._box)) {
16138
+ collider(s0, s1);
16139
+ }
16140
+ }
16141
+ }
16142
+
16143
+ return labels;
16144
+ }
16145
+
16146
+ function compute(labels) {
16147
+ var i, ilen, label, state, geometry, center, proxy;
16148
+
16149
+ // Initialize labels for overlap detection
16150
+ for (i = 0, ilen = labels.length; i < ilen; ++i) {
16151
+ label = labels[i];
16152
+ state = label.$layout;
16153
+
16154
+ if (state._visible) {
16155
+ // Chart.js 3 removed el._model in favor of getProps(), making harder to
16156
+ // abstract reading values in positioners. Also, using string arrays to
16157
+ // read values (i.e. var {a,b,c} = el.getProps(["a","b","c"])) would make
16158
+ // positioners inefficient in the normal case (i.e. not the final values)
16159
+ // and the code a bit ugly, so let's use a Proxy instead.
16160
+ proxy = new Proxy(label._el, {get: (el, p) => el.getProps([p], true)[p]});
16161
+
16162
+ geometry = label.geometry();
16163
+ center = coordinates(proxy, label.model(), geometry);
16164
+ state._box.update(center, geometry, label.rotation());
16165
+ }
16166
+ }
16167
+
16168
+ // Auto hide overlapping labels
16169
+ return collide(labels, function(s0, s1) {
16170
+ var h0 = s0._hidable;
16171
+ var h1 = s1._hidable;
16172
+
16173
+ if ((h0 && h1) || h1) {
16174
+ s1._visible = false;
16175
+ } else if (h0) {
16176
+ s0._visible = false;
16177
+ }
16178
+ });
16179
+ }
16180
+
16181
+ var layout = {
16182
+ prepare: function(datasets) {
16183
+ var labels = [];
16184
+ var i, j, ilen, jlen, label;
16185
+
16186
+ for (i = 0, ilen = datasets.length; i < ilen; ++i) {
16187
+ for (j = 0, jlen = datasets[i].length; j < jlen; ++j) {
16188
+ label = datasets[i][j];
16189
+ labels.push(label);
16190
+ label.$layout = {
16191
+ _box: new HitBox(),
16192
+ _hidable: false,
16193
+ _visible: true,
16194
+ _set: i,
16195
+ _idx: label._index
16196
+ };
16197
+ }
16198
+ }
16199
+
16200
+ // TODO New `z` option: labels with a higher z-index are drawn
16201
+ // of top of the ones with a lower index. Lowest z-index labels
16202
+ // are also discarded first when hiding overlapping labels.
16203
+ labels.sort(function(a, b) {
16204
+ var sa = a.$layout;
16205
+ var sb = b.$layout;
16206
+
16207
+ return sa._idx === sb._idx
16208
+ ? sb._set - sa._set
16209
+ : sb._idx - sa._idx;
16210
+ });
16211
+
16212
+ this.update(labels);
16213
+
16214
+ return labels;
16215
+ },
16216
+
16217
+ update: function(labels) {
16218
+ var dirty = false;
16219
+ var i, ilen, label, model, state;
16220
+
16221
+ for (i = 0, ilen = labels.length; i < ilen; ++i) {
16222
+ label = labels[i];
16223
+ model = label.model();
16224
+ state = label.$layout;
16225
+ state._hidable = model && model.display === 'auto';
16226
+ state._visible = label.visible();
16227
+ dirty |= state._hidable;
16228
+ }
16229
+
16230
+ if (dirty) {
16231
+ compute(labels);
16232
+ }
16233
+ },
16234
+
16235
+ lookup: function(labels, point) {
16236
+ var i, state;
16237
+
16238
+ // IMPORTANT Iterate in the reverse order since items at the end of
16239
+ // the list have an higher z-index, thus should be picked first.
16240
+
16241
+ for (i = labels.length - 1; i >= 0; --i) {
16242
+ state = labels[i].$layout;
16243
+
16244
+ if (state && state._visible && state._box.contains(point)) {
16245
+ return labels[i];
16246
+ }
16247
+ }
16248
+
16249
+ return null;
16250
+ },
16251
+
16252
+ draw: function(chart, labels) {
16253
+ var i, ilen, label, state, geometry, center;
16254
+
16255
+ for (i = 0, ilen = labels.length; i < ilen; ++i) {
16256
+ label = labels[i];
16257
+ state = label.$layout;
16258
+
16259
+ if (state._visible) {
16260
+ geometry = label.geometry();
16261
+ center = coordinates(label._el, label.model(), geometry);
16262
+ state._box.update(center, geometry, label.rotation());
16263
+ label.draw(chart, center);
16264
+ }
16265
+ }
16266
+ }
16267
+ };
16268
+
16269
+ var formatter = function(value) {
16270
+ if (isNullOrUndef(value)) {
16271
+ return null;
16272
+ }
16273
+
16274
+ var label = value;
16275
+ var keys, klen, k;
16276
+ if (isObject(value)) {
16277
+ if (!isNullOrUndef(value.label)) {
16278
+ label = value.label;
16279
+ } else if (!isNullOrUndef(value.r)) {
16280
+ label = value.r;
16281
+ } else {
16282
+ label = '';
16283
+ keys = Object.keys(value);
16284
+ for (k = 0, klen = keys.length; k < klen; ++k) {
16285
+ label += (k !== 0 ? ', ' : '') + keys[k] + ': ' + value[keys[k]];
16286
+ }
16287
+ }
16288
+ }
16289
+
16290
+ return '' + label;
16291
+ };
16292
+
16293
+ /**
16294
+ * IMPORTANT: make sure to also update tests and TypeScript definition
16295
+ * files (`/test/specs/defaults.spec.js` and `/types/options.d.ts`)
16296
+ */
16297
+
16298
+ var defaults = {
16299
+ align: 'center',
16300
+ anchor: 'center',
16301
+ backgroundColor: null,
16302
+ borderColor: null,
16303
+ borderRadius: 0,
16304
+ borderWidth: 0,
16305
+ clamp: false,
16306
+ clip: false,
16307
+ color: undefined,
16308
+ display: true,
16309
+ font: {
16310
+ family: undefined,
16311
+ lineHeight: 1.2,
16312
+ size: undefined,
16313
+ style: undefined,
16314
+ weight: null
16315
+ },
16316
+ formatter: formatter,
16317
+ labels: undefined,
16318
+ listeners: {},
16319
+ offset: 4,
16320
+ opacity: 1,
16321
+ padding: {
16322
+ top: 4,
16323
+ right: 4,
16324
+ bottom: 4,
16325
+ left: 4
16326
+ },
16327
+ rotation: 0,
16328
+ textAlign: 'start',
16329
+ textStrokeColor: undefined,
16330
+ textStrokeWidth: 0,
16331
+ textShadowBlur: 0,
16332
+ textShadowColor: undefined
16333
+ };
16334
+
16335
+ /**
16336
+ * @see https://github.com/chartjs/Chart.js/issues/4176
16337
+ */
16338
+
16339
+ var EXPANDO_KEY = '$datalabels';
16340
+ var DEFAULT_KEY = '$default';
16341
+
16342
+ function configure$2(dataset, options) {
16343
+ var override = dataset.datalabels;
16344
+ var listeners = {};
16345
+ var configs = [];
16346
+ var labels, keys;
16347
+
16348
+ if (override === false) {
16349
+ return null;
16350
+ }
16351
+ if (override === true) {
16352
+ override = {};
16353
+ }
16354
+
16355
+ options = merge$1({}, [options, override]);
16356
+ labels = options.labels || {};
16357
+ keys = Object.keys(labels);
16358
+ delete options.labels;
16359
+
16360
+ if (keys.length) {
16361
+ keys.forEach(function(key) {
16362
+ if (labels[key]) {
16363
+ configs.push(merge$1({}, [
16364
+ options,
16365
+ labels[key],
16366
+ {_key: key}
16367
+ ]));
16368
+ }
16369
+ });
16370
+ } else {
16371
+ // Default label if no "named" label defined.
16372
+ configs.push(options);
16373
+ }
16374
+
16375
+ // listeners: {<event-type>: {<label-key>: <fn>}}
16376
+ listeners = configs.reduce(function(target, config) {
16377
+ each(config.listeners || {}, function(fn, event) {
16378
+ target[event] = target[event] || {};
16379
+ target[event][config._key || DEFAULT_KEY] = fn;
16380
+ });
16381
+
16382
+ delete config.listeners;
16383
+ return target;
16384
+ }, {});
16385
+
16386
+ return {
16387
+ labels: configs,
16388
+ listeners: listeners
16389
+ };
16390
+ }
16391
+
16392
+ function dispatchEvent(chart, listeners, label, event) {
16393
+ if (!listeners) {
16394
+ return;
16395
+ }
16396
+
16397
+ var context = label.$context;
16398
+ var groups = label.$groups;
16399
+ var callback$1;
16400
+
16401
+ if (!listeners[groups._set]) {
16402
+ return;
16403
+ }
16404
+
16405
+ callback$1 = listeners[groups._set][groups._key];
16406
+ if (!callback$1) {
16407
+ return;
16408
+ }
16409
+
16410
+ if (callback(callback$1, [context, event]) === true) {
16411
+ // Users are allowed to tweak the given context by injecting values that can be
16412
+ // used in scriptable options to display labels differently based on the current
16413
+ // event (e.g. highlight an hovered label). That's why we update the label with
16414
+ // the output context and schedule a new chart render by setting it dirty.
16415
+ chart[EXPANDO_KEY]._dirty = true;
16416
+ label.update(context);
16417
+ }
16418
+ }
16419
+
16420
+ function dispatchMoveEvents(chart, listeners, previous, label, event) {
16421
+ var enter, leave;
16422
+
16423
+ if (!previous && !label) {
16424
+ return;
16425
+ }
16426
+
16427
+ if (!previous) {
16428
+ enter = true;
16429
+ } else if (!label) {
16430
+ leave = true;
16431
+ } else if (previous !== label) {
16432
+ leave = enter = true;
16433
+ }
16434
+
16435
+ if (leave) {
16436
+ dispatchEvent(chart, listeners.leave, previous, event);
16437
+ }
16438
+ if (enter) {
16439
+ dispatchEvent(chart, listeners.enter, label, event);
16440
+ }
16441
+ }
16442
+
16443
+ function handleMoveEvents(chart, event) {
16444
+ var expando = chart[EXPANDO_KEY];
16445
+ var listeners = expando._listeners;
16446
+ var previous, label;
16447
+
16448
+ if (!listeners.enter && !listeners.leave) {
16449
+ return;
16450
+ }
16451
+
16452
+ if (event.type === 'mousemove') {
16453
+ label = layout.lookup(expando._labels, event);
16454
+ } else if (event.type !== 'mouseout') {
16455
+ return;
16456
+ }
16457
+
16458
+ previous = expando._hovered;
16459
+ expando._hovered = label;
16460
+ dispatchMoveEvents(chart, listeners, previous, label, event);
16461
+ }
16462
+
16463
+ function handleClickEvents(chart, event) {
16464
+ var expando = chart[EXPANDO_KEY];
16465
+ var handlers = expando._listeners.click;
16466
+ var label = handlers && layout.lookup(expando._labels, event);
16467
+ if (label) {
16468
+ dispatchEvent(chart, handlers, label, event);
16469
+ }
16470
+ }
16471
+
16472
+ var plugin$1 = {
16473
+ id: 'datalabels',
16474
+
16475
+ defaults: defaults,
16476
+
16477
+ beforeInit: function(chart) {
16478
+ chart[EXPANDO_KEY] = {
16479
+ _actives: []
16480
+ };
16481
+ },
16482
+
16483
+ beforeUpdate: function(chart) {
16484
+ var expando = chart[EXPANDO_KEY];
16485
+ expando._listened = false;
16486
+ expando._listeners = {}; // {<event-type>: {<dataset-index>: {<label-key>: <fn>}}}
16487
+ expando._datasets = []; // per dataset labels: [Label[]]
16488
+ expando._labels = []; // layouted labels: Label[]
16489
+ },
16490
+
16491
+ afterDatasetUpdate: function(chart, args, options) {
16492
+ var datasetIndex = args.index;
16493
+ var expando = chart[EXPANDO_KEY];
16494
+ var labels = expando._datasets[datasetIndex] = [];
16495
+ var visible = chart.isDatasetVisible(datasetIndex);
16496
+ var dataset = chart.data.datasets[datasetIndex];
16497
+ var config = configure$2(dataset, options);
16498
+ var elements = args.meta.data || [];
16499
+ var ctx = chart.ctx;
16500
+ var i, j, ilen, jlen, cfg, key, el, label;
16501
+
16502
+ ctx.save();
16503
+
16504
+ for (i = 0, ilen = elements.length; i < ilen; ++i) {
16505
+ el = elements[i];
16506
+ el[EXPANDO_KEY] = [];
16507
+
16508
+ if (visible && el && chart.getDataVisibility(i) && !el.skip) {
16509
+ for (j = 0, jlen = config.labels.length; j < jlen; ++j) {
16510
+ cfg = config.labels[j];
16511
+ key = cfg._key;
16512
+
16513
+ label = new Label(cfg, ctx, el, i);
16514
+ label.$groups = {
16515
+ _set: datasetIndex,
16516
+ _key: key || DEFAULT_KEY
16517
+ };
16518
+ label.$context = {
16519
+ active: false,
16520
+ chart: chart,
16521
+ dataIndex: i,
16522
+ dataset: dataset,
16523
+ datasetIndex: datasetIndex
16524
+ };
16525
+
16526
+ label.update(label.$context);
16527
+ el[EXPANDO_KEY].push(label);
16528
+ labels.push(label);
16529
+ }
16530
+ }
16531
+ }
16532
+
16533
+ ctx.restore();
16534
+
16535
+ // Store listeners at the chart level and per event type to optimize
16536
+ // cases where no listeners are registered for a specific event.
16537
+ merge$1(expando._listeners, config.listeners, {
16538
+ merger: function(event, target, source) {
16539
+ target[event] = target[event] || {};
16540
+ target[event][args.index] = source[event];
16541
+ expando._listened = true;
16542
+ }
16543
+ });
16544
+ },
16545
+
16546
+ afterUpdate: function(chart) {
16547
+ chart[EXPANDO_KEY]._labels = layout.prepare(chart[EXPANDO_KEY]._datasets);
16548
+ },
16549
+
16550
+ // Draw labels on top of all dataset elements
16551
+ // https://github.com/chartjs/chartjs-plugin-datalabels/issues/29
16552
+ // https://github.com/chartjs/chartjs-plugin-datalabels/issues/32
16553
+ afterDatasetsDraw: function(chart) {
16554
+ layout.draw(chart, chart[EXPANDO_KEY]._labels);
16555
+ },
16556
+
16557
+ beforeEvent: function(chart, args) {
16558
+ // If there is no listener registered for this chart, `listened` will be false,
16559
+ // meaning we can immediately ignore the incoming event and avoid useless extra
16560
+ // computation for users who don't implement label interactions.
16561
+ if (chart[EXPANDO_KEY]._listened) {
16562
+ var event = args.event;
16563
+ switch (event.type) {
16564
+ case 'mousemove':
16565
+ case 'mouseout':
16566
+ handleMoveEvents(chart, event);
16567
+ break;
16568
+ case 'click':
16569
+ handleClickEvents(chart, event);
16570
+ break;
16571
+ }
16572
+ }
16573
+ },
16574
+
16575
+ afterEvent: function(chart) {
16576
+ var expando = chart[EXPANDO_KEY];
16577
+ var previous = expando._actives;
16578
+ var actives = expando._actives = chart.getActiveElements();
16579
+ var updates = utils.arrayDiff(previous, actives);
16580
+ var i, ilen, j, jlen, update, label, labels;
16581
+
16582
+ for (i = 0, ilen = updates.length; i < ilen; ++i) {
16583
+ update = updates[i];
16584
+ if (update[1]) {
16585
+ labels = update[0].element[EXPANDO_KEY] || [];
16586
+ for (j = 0, jlen = labels.length; j < jlen; ++j) {
16587
+ label = labels[j];
16588
+ label.$context.active = (update[1] === 1);
16589
+ label.update(label.$context);
16590
+ }
16591
+ }
16592
+ }
16593
+
16594
+ if (expando._dirty || updates.length) {
16595
+ layout.update(expando._labels);
16596
+ chart.render();
16597
+ }
16598
+
16599
+ delete expando._dirty;
16600
+ }
16601
+ };
16602
+
15247
16603
  Chart$1.register(CategoryScale, LinearScale, PointElement, LineElement, plugin_title, plugin_tooltip, plugin_legend);
15248
- function SeriesLineChart({ orientation, title, data, options, className, units, content }) {
16604
+ function SeriesLineChart({ orientation, title, data, options, className, units, content, x_axis_title, y_axis_title }) {
15249
16605
  var _a, _b;
16606
+ console.log('x_axis_title==>', x_axis_title);
15250
16607
  const formatValue = (value) => {
15251
16608
  const numValue = typeof value === 'string' ? parseFloat(value) : value;
15252
16609
  if (!isNaN(numValue)) {
@@ -15321,12 +16678,16 @@ function SeriesLineChart({ orientation, title, data, options, className, units,
15321
16678
  },
15322
16679
  scales: {
15323
16680
  x: {
16681
+ title: {
16682
+ display: !!x_axis_title,
16683
+ text: x_axis_title,
16684
+ },
15324
16685
  ticks: { autoSkip: true, maxTicksLimit: 8, maxRotation: 45, minRotation: 0 },
15325
16686
  },
15326
16687
  y: {
15327
16688
  title: {
15328
16689
  display: true,
15329
- text: (data === null || data === void 0 ? void 0 : data.datasets) && ((_a = data === null || data === void 0 ? void 0 : data.datasets) === null || _a === void 0 ? void 0 : _a.length) === 1 ? (_b = data === null || data === void 0 ? void 0 : data.datasets) === null || _b === void 0 ? void 0 : _b[0].label : getAxisLabel(units !== null && units !== void 0 ? units : ""),
16690
+ text: y_axis_title || ((data === null || data === void 0 ? void 0 : data.datasets) && ((_a = data === null || data === void 0 ? void 0 : data.datasets) === null || _a === void 0 ? void 0 : _a.length) === 1 ? (_b = data === null || data === void 0 ? void 0 : data.datasets) === null || _b === void 0 ? void 0 : _b[0].label : getAxisLabel(units !== null && units !== void 0 ? units : "")),
15330
16691
  },
15331
16692
  beginAtZero: true,
15332
16693
  ticks: {
@@ -15345,9 +16706,791 @@ function SeriesLineChart({ orientation, title, data, options, className, units,
15345
16706
  },
15346
16707
  },
15347
16708
  };
15348
- return (jsxRuntimeExports.jsx(Line, { data: data, options: options !== null && options !== void 0 ? options : defaultOptions, plugins: [ChartDataLabels] }));
16709
+ return (jsxRuntimeExports.jsx(Line, { data: data, options: options !== null && options !== void 0 ? options : defaultOptions, plugins: [plugin$1] }));
15349
16710
  }
15350
16711
 
16712
+ /*!
16713
+ * @energiency/chartjs-plugin-piechart-outlabels v1.3.4
16714
+ * http://www.chartjs.org
16715
+ * (c) 2017-2025 @energiency/chartjs-plugin-piechart-outlabels contributors
16716
+ * Released under the MIT license
16717
+ */
16718
+
16719
+ /**
16720
+ * @module Options
16721
+ */
16722
+
16723
+ var customDefaults = {
16724
+ PLUGIN_KEY: '$outlabels',
16725
+
16726
+ /**
16727
+ * The color used to draw the background of the label rect.
16728
+ * @member {String|Array|Function|null}
16729
+ * @default null (adaptive background)
16730
+ */
16731
+ backgroundColor: function (context) {
16732
+ return context.dataset.backgroundColor;
16733
+ },
16734
+
16735
+ /**
16736
+ * The color used to draw the border of the label rect.
16737
+ * @member {String|Array|Function|null}
16738
+ * @default null (adaptive border color)
16739
+ */
16740
+ borderColor: function (context) {
16741
+ return context.dataset.backgroundColor;
16742
+ },
16743
+
16744
+ /**
16745
+ * The color used to draw the line between label and arc of the chart.
16746
+ * @member {String|Array|Function|null}
16747
+ * @default null (adaptive line color)
16748
+ */
16749
+ lineColor: function (context) {
16750
+ return context.dataset.backgroundColor;
16751
+ },
16752
+
16753
+ /**
16754
+ * The border radius used to add rounded corners to the label rect.
16755
+ * @member {Number|Array|Function}
16756
+ * @default 0 (not rounded)
16757
+ */
16758
+ borderRadius: 0,
16759
+
16760
+ /**
16761
+ * The border width of the surrounding frame.
16762
+ * @member {Number|Array|Function}
16763
+ * @default 0 (no border)
16764
+ */
16765
+ borderWidth: 0,
16766
+
16767
+ /**
16768
+ * The width (thickness) of the line between label and chart arc.
16769
+ * @member {Number|Array|Function}
16770
+ * @default 2
16771
+ */
16772
+ lineWidth: 2,
16773
+
16774
+ /**
16775
+ * The color used to draw the label text.
16776
+ * @member {String|Array|Function}
16777
+ * @default white
16778
+ */
16779
+ color: 'white',
16780
+
16781
+ /**
16782
+ * Whether to display labels global (boolean) or per data (function)
16783
+ * @member {Boolean|Array|Function}
16784
+ * @default true
16785
+ */
16786
+ display: true,
16787
+
16788
+ /**
16789
+ * The font options used to draw the label text.
16790
+ * @member {Object|Array|Function}
16791
+ * @prop {Boolean} font.family - defaults to Chart.defaults.global.defaultFontFamily
16792
+ * @prop {Boolean} font.size - defaults to Chart.defaults.global.defaultFontSize
16793
+ * @prop {Boolean} font.style - defaults to Chart.defaults.global.defaultFontStyle
16794
+ * @prop {Boolean} font.weight - defaults to 'normal'
16795
+ * @prop {Boolean} font.maxSize - defaults to undefined (unlimited)
16796
+ * @prop {Boolean} font.minSize - defaults to undefined (unlimited)
16797
+ * @prop {Boolean} font.resizable - defaults to true
16798
+ * @default Chart.defaults.global.defaultFont.*
16799
+ */
16800
+ font: {
16801
+ family: undefined,
16802
+ size: undefined,
16803
+ style: undefined,
16804
+ weight: null,
16805
+ maxSize: null,
16806
+ minSize: null,
16807
+ resizable: true,
16808
+ },
16809
+
16810
+ /**
16811
+ * The line height (in pixel) to use for multi-lines labels.
16812
+ * @member {Number|Array|Function|undefined}
16813
+ * @default 1.2
16814
+ */
16815
+ lineHeight: 1.2,
16816
+
16817
+ /**
16818
+ * The padding (in pixels) to apply between the text and the surrounding frame.
16819
+ * @member {Number|Object|Array|Function}
16820
+ * @prop {Number} padding.top - Space above the text.
16821
+ * @prop {Number} padding.right - Space on the right of the text.
16822
+ * @prop {Number} padding.bottom - Space below the text.
16823
+ * @prop {Number} padding.left - Space on the left of the text.
16824
+ * @default 4 (all values)
16825
+ */
16826
+ padding: {
16827
+ top: 2,
16828
+ right: 2,
16829
+ bottom: 2,
16830
+ left: 2,
16831
+ },
16832
+
16833
+ /**
16834
+ * Text alignment for multi-lines labels ('left'|'right'|'start'|'center'|'end').
16835
+ * @member {String|Array|Function}
16836
+ * @default 'center'
16837
+ */
16838
+ textAlign: 'center',
16839
+
16840
+ /**
16841
+ * The radius of distance where the label will be drawn
16842
+ * @member {Number|Array|Function|undefined}
16843
+ * @default 30
16844
+ */
16845
+ stretch: 12,
16846
+
16847
+ /**
16848
+ * The length of the horizontal part of line between label and chart arc.
16849
+ * @member {Number}
16850
+ * @default 30
16851
+ */
16852
+ horizontalStrechPad: 12,
16853
+
16854
+ /**
16855
+ * The text of the label.
16856
+ * @member {String}
16857
+ * @default '%l %p' (label name and value percentage)
16858
+ */
16859
+ text: '%l %p',
16860
+
16861
+ /**
16862
+ * The max level of zoom (out) for pie/doughnut chart in percent.
16863
+ * @member {Number}
16864
+ * @default 50 (%)
16865
+ */
16866
+ maxZoomOutPercentage: 50,
16867
+
16868
+ /**
16869
+ * The count of numbers after the point separator for float values of percent property
16870
+ * @member {Number}
16871
+ * @default 1
16872
+ */
16873
+ percentPrecision: 1,
16874
+
16875
+ /**
16876
+ * The count of numbers after the point separator for float values of value property
16877
+ * @member {Number}
16878
+ * @default 3
16879
+ */
16880
+ valuePrecision: 3,
16881
+ };
16882
+
16883
+ const chartStates = new WeakMap();
16884
+
16885
+ function getState(chart) {
16886
+ let state = chartStates.get(chart);
16887
+ if (!state) {
16888
+ state = { sizeChanged: false, fitting: false };
16889
+ chartStates.set(chart, state);
16890
+ }
16891
+ return state;
16892
+ }
16893
+
16894
+ function removeState(chart) {
16895
+ chartStates.delete(chart);
16896
+ }
16897
+
16898
+ var positioners = {
16899
+ center: function (arc, stretch) {
16900
+ var angle = (arc.startAngle + arc.endAngle) / 2;
16901
+ var cosA = Math.cos(angle);
16902
+ var sinA = Math.sin(angle);
16903
+ var d = arc.outerRadius;
16904
+
16905
+ var stretchedD = d + stretch;
16906
+ return {
16907
+ x: arc.x + cosA * stretchedD,
16908
+ y: arc.y + sinA * stretchedD,
16909
+ d: stretchedD,
16910
+ arc: arc,
16911
+ anchor: { x: arc.x + cosA * d, y: arc.y + sinA * d },
16912
+ copy: { x: arc.x + cosA * stretchedD, y: arc.y + sinA * stretchedD },
16913
+ };
16914
+ },
16915
+
16916
+ moveFromAnchor: function (center, dist) {
16917
+ var arc = center.arc;
16918
+ var d = center.d;
16919
+ var angle = (arc.startAngle + arc.endAngle) / 2;
16920
+ var cosA = Math.cos(angle);
16921
+ var sinA = Math.sin(angle);
16922
+
16923
+ d += dist;
16924
+
16925
+ return {
16926
+ x: arc.x + cosA * d,
16927
+ y: arc.y + sinA * d,
16928
+ d: d,
16929
+ arc: arc,
16930
+ anchor: center.anchor,
16931
+ copy: {
16932
+ x: arc.x + cosA * d,
16933
+ y: arc.y + sinA * d,
16934
+ },
16935
+ };
16936
+ },
16937
+ };
16938
+
16939
+ function toFontString(font) {
16940
+ if (!font || isNullOrUndef(font.size) || isNullOrUndef(font.family)) {
16941
+ return null;
16942
+ }
16943
+
16944
+ return (
16945
+ (font.style ? font.style + ' ' : '') + (font.weight ? font.weight + ' ' : '') + font.size + 'px ' + font.family
16946
+ );
16947
+ }
16948
+
16949
+ function textSize(ctx, lines, font) {
16950
+ var items = [].concat(lines);
16951
+ var ilen = items.length;
16952
+ var prev = ctx.font;
16953
+ var width = 0;
16954
+ var i;
16955
+
16956
+ ctx.font = font.string;
16957
+
16958
+ for (i = 0; i < ilen; ++i) {
16959
+ width = Math.max(ctx.measureText(items[i]).width, width);
16960
+ }
16961
+
16962
+ ctx.font = prev;
16963
+
16964
+ return {
16965
+ height: ilen * font.lineHeight,
16966
+ width,
16967
+ };
16968
+ }
16969
+
16970
+ function adaptTextSizeToDimensions(width, height, minimum, maximum) {
16971
+ const diag = Math.sqrt(Math.pow(width || 100, 2) + Math.pow(height || 100, 2));
16972
+ const size = Math.round(diag * 0.02);
16973
+
16974
+ if (minimum && size < minimum) {
16975
+ return minimum;
16976
+ }
16977
+ if (maximum && size > maximum) {
16978
+ return maximum;
16979
+ }
16980
+ return size;
16981
+ }
16982
+
16983
+ function parseFont(value, width, height) {
16984
+ var size = valueOrDefault(value.size, Chart$1.defaults.defaultFontSize);
16985
+
16986
+ if (value.resizable) {
16987
+ size = adaptTextSizeToDimensions(width, height, value.minSize, value.maxSize);
16988
+ }
16989
+
16990
+ var font = {
16991
+ family: valueOrDefault(value.family, Chart$1.defaults.defaultFontFamily),
16992
+ lineHeight: toLineHeight(value.lineHeight, size),
16993
+ lineWidth: toLineHeight(value.lineWidth, size),
16994
+ size,
16995
+ style: valueOrDefault(value.style, Chart$1.defaults.defaultFontStyle),
16996
+ weight: valueOrDefault(value.weight, null),
16997
+ string: '',
16998
+ };
16999
+
17000
+ font.string = toFontString(font);
17001
+ return font;
17002
+ }
17003
+
17004
+ var PLUGIN_KEY$1 = customDefaults.PLUGIN_KEY;
17005
+
17006
+ function collides(rect, otherRect) {
17007
+ return (
17008
+ rect.x < otherRect.x + otherRect.width &&
17009
+ rect.x + rect.width > otherRect.x &&
17010
+ rect.y < otherRect.y + otherRect.height &&
17011
+ rect.y + rect.height > otherRect.y
17012
+ );
17013
+ }
17014
+
17015
+ var classes = {
17016
+ OutLabel: function (chart, index, ctx, config, context) {
17017
+ // Check whether the label should be displayed
17018
+ if (!resolve([config.display, true], context, index)) {
17019
+ throw new Error('Label display property is set to false.');
17020
+ }
17021
+
17022
+ // Init text
17023
+ var value = context.dataset.data[index];
17024
+ var label = context.labels[index];
17025
+ var text = resolve([config.text, customDefaults.text], context, index);
17026
+ /* Replace label marker */
17027
+ text = text.replace(/%l/gi, label);
17028
+
17029
+ /* Replace value marker with possible precision value */
17030
+ (text.match(/%v\.?(\d*)/gi) || [])
17031
+ .map(function (val) {
17032
+ var prec = val.replace(/%v\./gi, '');
17033
+ if (prec.length) {
17034
+ return +prec;
17035
+ }
17036
+ return config.valuePrecision || customDefaults.valuePrecision;
17037
+ })
17038
+ .forEach(function (val) {
17039
+ text = text.replace(/%v\.?(\d*)/i, value.toFixed(val));
17040
+ });
17041
+
17042
+ /* Replace percent marker with possible precision value */
17043
+ (text.match(/%p\.?(\d*)/gi) || [])
17044
+ .map(function (val) {
17045
+ var prec = val.replace(/%p\./gi, '');
17046
+ if (prec.length) {
17047
+ return +prec;
17048
+ }
17049
+ return config.percentPrecision || customDefaults.percentPrecision;
17050
+ })
17051
+ .forEach(function (val) {
17052
+ text = text.replace(/%p\.?(\d*)/i, (context.percent * 100).toFixed(val) + '%');
17053
+ });
17054
+
17055
+ // Count lines
17056
+ var lines = text.match(/[^\r\n]+/g) || [];
17057
+
17058
+ // Remove unnecessary spaces
17059
+ for (var i = 0; i < lines.length; ++i) {
17060
+ lines[i] = lines[i].trim();
17061
+ }
17062
+
17063
+ /* ===================== CONSTRUCTOR ==================== */
17064
+ this.init = function (text, lines) {
17065
+ // If everything ok -> begin initializing
17066
+ this.encodedText = config.text;
17067
+ this.text = text;
17068
+ this.lines = lines;
17069
+ this.label = label;
17070
+ this.value = value;
17071
+
17072
+ // Init style
17073
+ this.style = {
17074
+ backgroundColor: resolve(
17075
+ [config.backgroundColor, customDefaults.backgroundColor, 'black'],
17076
+ context,
17077
+ index,
17078
+ ),
17079
+ borderColor: resolve([config.borderColor, customDefaults.borderColor, 'black'], context, index),
17080
+ borderRadius: resolve([config.borderRadius, 0], context, index),
17081
+ borderWidth: resolve([config.borderWidth, 0], context, index),
17082
+ lineWidth: resolve([config.lineWidth, 2], context, index),
17083
+ lineColor: resolve([config.lineColor, customDefaults.lineColor, 'black'], context, index),
17084
+ color: resolve([config.color, 'white'], context, index),
17085
+ font: parseFont(
17086
+ resolve([config.font, { resizable: true }]),
17087
+ ctx.canvas.style.width.slice(0, -2),
17088
+ ctx.canvas.style.height.slice(0, -2),
17089
+ ),
17090
+ padding: toPadding(resolve([config.padding, 0], context, index)),
17091
+ textAlign: resolve([config.textAlign, 'left'], context, index),
17092
+ };
17093
+
17094
+ this.stretch = resolve([config.stretch, customDefaults.stretch], context, index);
17095
+ this.horizontalStrechPad = resolve(
17096
+ [config.horizontalStrechPad, customDefaults.horizontalStrechPad],
17097
+ context,
17098
+ index,
17099
+ );
17100
+ this.size = textSize(ctx, this.lines, this.style.font);
17101
+
17102
+ this.offsetStep = this.size.width / 20;
17103
+ this.offset = {
17104
+ x: 0,
17105
+ y: 0,
17106
+ };
17107
+ };
17108
+
17109
+ this.init(text, lines);
17110
+
17111
+ /* COMPUTING RECTS PART */
17112
+ this.computeLabelRect = function () {
17113
+ var width =
17114
+ this.textRect.width + 2 * this.style.borderWidth + this.style.padding.left + this.style.padding.right;
17115
+ var height =
17116
+ this.textRect.height + 2 * this.style.borderWidth + this.style.padding.top + this.style.padding.bottom;
17117
+
17118
+ var x = this.textRect.x - this.style.borderWidth;
17119
+ var y = this.textRect.y - this.style.borderWidth;
17120
+
17121
+ return {
17122
+ x: x,
17123
+ y: y,
17124
+ width: width,
17125
+ height: height,
17126
+ isLeft: this.textRect.isLeft,
17127
+ isTop: this.textRect.isTop,
17128
+ };
17129
+ };
17130
+
17131
+ this.computeTextRect = function () {
17132
+ const isLeft = this.center.x - this.center.anchor.x < 0;
17133
+ const isTop = this.center.y - this.center.anchor.y < 0;
17134
+ const shift = isLeft ? -(this.horizontalStrechPad + this.size.width) : this.horizontalStrechPad;
17135
+ return {
17136
+ x: this.center.x - this.style.padding.left + shift,
17137
+ y: this.center.y - this.size.height / 2,
17138
+ width: this.size.width,
17139
+ height: this.size.height,
17140
+ isLeft,
17141
+ isTop,
17142
+ };
17143
+ };
17144
+
17145
+ /* ======================= DRAWING ======================= */
17146
+ // Draw label text
17147
+ this.drawText = function (ctx) {
17148
+ var align = this.style.textAlign;
17149
+ var font = this.style.font;
17150
+ var lh = font.lineHeight;
17151
+ var color = this.style.color;
17152
+ var ilen = this.lines.length;
17153
+ var x, y, idx;
17154
+
17155
+ if (!ilen || !color) {
17156
+ return;
17157
+ }
17158
+
17159
+ x = this.textRect.x;
17160
+ y = this.textRect.y + lh / 2;
17161
+
17162
+ if (align === 'center') {
17163
+ x += this.textRect.width / 2;
17164
+ } else if (align === 'end' || align === 'right') {
17165
+ x += this.textRect.width;
17166
+ }
17167
+
17168
+ ctx.font = this.style.font.string;
17169
+ ctx.fillStyle = color;
17170
+ ctx.textAlign = align;
17171
+ ctx.textBaseline = 'middle';
17172
+
17173
+ for (idx = 0; idx < ilen; ++idx) {
17174
+ ctx.fillText(
17175
+ this.lines[idx],
17176
+ Math.round(x) + this.style.padding.left,
17177
+ Math.round(y),
17178
+ Math.round(this.textRect.width),
17179
+ );
17180
+ y += lh;
17181
+ }
17182
+ };
17183
+
17184
+ // Draw label box
17185
+ this.drawLabel = function (ctx) {
17186
+ ctx.beginPath();
17187
+
17188
+ ctx.roundRect(
17189
+ Math.round(this.labelRect.x),
17190
+ Math.round(this.labelRect.y),
17191
+ Math.round(this.labelRect.width),
17192
+ Math.round(this.labelRect.height),
17193
+ this.style.borderRadius,
17194
+ );
17195
+ ctx.closePath();
17196
+
17197
+ if (this.style.backgroundColor) {
17198
+ ctx.fillStyle = this.style.backgroundColor || 'transparent';
17199
+ ctx.fill();
17200
+ }
17201
+
17202
+ if (this.style.borderColor && this.style.borderWidth) {
17203
+ ctx.strokeStyle = this.style.borderColor;
17204
+ ctx.lineWidth = this.style.borderWidth;
17205
+ ctx.lineJoin = 'miter';
17206
+ ctx.stroke();
17207
+ }
17208
+ };
17209
+
17210
+ this.ccw = function (A, B, C) {
17211
+ return (C.y - A.y) * (B.x - A.x) > (B.y - A.y) * (C.x - A.x);
17212
+ };
17213
+
17214
+ this.intersects = function (A, B, C, D) {
17215
+ return this.ccw(A, C, D) !== this.ccw(B, C, D) && this.ccw(A, B, C) !== this.ccw(A, B, D);
17216
+ };
17217
+
17218
+ this.drawLine = function (ctx) {
17219
+ if (!this.lines.length) {
17220
+ return;
17221
+ }
17222
+ ctx.save();
17223
+
17224
+ ctx.strokeStyle = this.style.lineColor;
17225
+ ctx.lineWidth = this.style.lineWidth;
17226
+ ctx.lineJoin = 'miter';
17227
+ ctx.beginPath();
17228
+ ctx.moveTo(this.center.anchor.x, this.center.anchor.y);
17229
+ ctx.lineTo(this.center.copy.x, this.center.copy.y);
17230
+ ctx.stroke();
17231
+
17232
+ ctx.beginPath();
17233
+ ctx.moveTo(this.center.copy.x, this.center.copy.y);
17234
+ const xOffset = this.textRect.width + this.style.padding.width;
17235
+ const intersect = this.intersects(
17236
+ this.textRect,
17237
+ {
17238
+ x: this.textRect.x + this.textRect.width,
17239
+ y: this.textRect.y + this.textRect.height,
17240
+ },
17241
+ this.center.copy,
17242
+ {
17243
+ x: this.textRect.x,
17244
+ y: this.textRect.y + this.textRect.height / 2,
17245
+ },
17246
+ );
17247
+ ctx.lineTo(this.textRect.x + (intersect ? xOffset : 0), this.textRect.y + this.textRect.height / 2);
17248
+ ctx.stroke();
17249
+ ctx.restore();
17250
+ };
17251
+
17252
+ this.draw = function (ctx) {
17253
+ if (chart.getDataVisibility(index)) {
17254
+ this.drawLabel(ctx);
17255
+ this.drawText(ctx);
17256
+ this.drawLine(ctx);
17257
+ }
17258
+ };
17259
+
17260
+ // eslint-disable-next-line max-statements
17261
+ this.update = function (view, elements, max) {
17262
+ this.center = positioners.center(view, this.stretch);
17263
+
17264
+ let valid = false;
17265
+ let steps = 30;
17266
+
17267
+ while (!valid && steps > 0) {
17268
+ this.textRect = this.computeTextRect();
17269
+ this.labelRect = this.computeLabelRect();
17270
+
17271
+ valid = true;
17272
+
17273
+ for (var e = 0; e < max; ++e) {
17274
+ var element = elements[e][PLUGIN_KEY$1];
17275
+ if (!element || !chart.getDataVisibility(index)) {
17276
+ continue;
17277
+ }
17278
+
17279
+ if (collides(this.labelRect, element.labelRect)) {
17280
+ valid = false;
17281
+ break;
17282
+ }
17283
+ }
17284
+
17285
+ if (!valid) {
17286
+ this.center = positioners.moveFromAnchor(this.center, 5);
17287
+ }
17288
+
17289
+ steps--;
17290
+ }
17291
+ };
17292
+ },
17293
+ };
17294
+
17295
+ defaults$1.plugins.outlabels = customDefaults;
17296
+
17297
+ var PLUGIN_KEY = customDefaults.PLUGIN_KEY;
17298
+
17299
+ function configure$1(dataset, options) {
17300
+ var override = dataset.outlabels;
17301
+ var config = {};
17302
+
17303
+ if (override === false) {
17304
+ return null;
17305
+ }
17306
+ if (override === true) {
17307
+ override = {};
17308
+ }
17309
+
17310
+ return Object.assign({}, config, options, override);
17311
+ }
17312
+
17313
+ /**
17314
+ * Returns the bounding box of the given label elements.
17315
+ *
17316
+ * @param {*} elements List of chart elements
17317
+ * @returns Bounding box
17318
+ */
17319
+ function getBoundingBox(elements) {
17320
+ const rect = { left: Infinity, right: -Infinity, top: Infinity, bottom: -Infinity };
17321
+
17322
+ for (let i = 0, l = elements.length; i < l; i++) {
17323
+ const outlabel = elements[i][PLUGIN_KEY];
17324
+ if (!outlabel || !outlabel.labelRect) {
17325
+ continue;
17326
+ }
17327
+
17328
+ const { labelRect } = outlabel;
17329
+ const { x, y, width, height } = labelRect;
17330
+
17331
+ rect.left = Math.min(rect.left, x);
17332
+ rect.right = Math.max(rect.right, x + width);
17333
+ rect.top = Math.min(rect.top, y);
17334
+ rect.bottom = Math.max(rect.bottom, y + height);
17335
+ }
17336
+
17337
+ return {
17338
+ ...rect,
17339
+ width: rect.right - rect.left,
17340
+ height: rect.bottom - rect.top,
17341
+ };
17342
+ }
17343
+
17344
+ /**
17345
+ * Returns the zoom percentage required to fit the given bounding box within the given bounding box.
17346
+ *
17347
+ * @param {*} boundingBoxToResize
17348
+ * @param {*} boundingBoxToFitWithin
17349
+ * @returns Zoom percentage
17350
+ */
17351
+ function getResizeZoomPercentage(boundingBoxToResize, boundingBoxToFitWithin) {
17352
+ const { width, height } = boundingBoxToFitWithin;
17353
+ const deltas = [
17354
+ ((boundingBoxToFitWithin.left - boundingBoxToResize.left) / width) * 2,
17355
+ ((boundingBoxToFitWithin.top - boundingBoxToResize.top) / height) * 2,
17356
+ ((boundingBoxToResize.right - boundingBoxToFitWithin.right) / width) * 2,
17357
+ ((boundingBoxToResize.bottom - boundingBoxToFitWithin.bottom) / height) * 2,
17358
+ ];
17359
+
17360
+ const maxDelta = Math.max(0, ...deltas);
17361
+ return 1 - maxDelta;
17362
+ }
17363
+
17364
+ /**
17365
+ * Updates the labels of the given elements.
17366
+ * @param {*} elements
17367
+ */
17368
+ function updateLabels(elements) {
17369
+ for (let i = 0, l = elements.length; i < l; i++) {
17370
+ const element = elements[i];
17371
+ const outlabel = element[PLUGIN_KEY];
17372
+ if (!outlabel) {
17373
+ continue;
17374
+ }
17375
+
17376
+ outlabel.update(element, elements, i);
17377
+ }
17378
+ }
17379
+
17380
+ function fitChartArea(chart) {
17381
+ const ctrl = chart._metasets[0].controller;
17382
+ const meta = ctrl.getMeta();
17383
+ const elements = meta.data || [];
17384
+
17385
+ const boundingBox = getBoundingBox(elements);
17386
+ const zoom = getResizeZoomPercentage(boundingBox, chart.chartArea);
17387
+
17388
+ if (zoom && zoom !== 1) {
17389
+ ctrl.outerRadius = ctrl.outerRadius * zoom;
17390
+ ctrl.innerRadius *= zoom;
17391
+
17392
+ ctrl.updateElements(meta.data, 0, meta.data.length, 'none');
17393
+ return true;
17394
+ }
17395
+
17396
+ return false;
17397
+ }
17398
+
17399
+ var plugin = {
17400
+ id: 'outlabels',
17401
+ resize: function (chart) {
17402
+ getState(chart).sizeChanged = true;
17403
+ },
17404
+ afterUpdate: (chart) => {
17405
+ const ctrl = chart._metasets[0].controller;
17406
+ const meta = ctrl.getMeta();
17407
+ const elements = meta.data || [];
17408
+
17409
+ let fit = false;
17410
+ // Limit the number of steps to prevent infinite loops
17411
+ // It seems that using the number of elements will ensure that the chart
17412
+ // fits by positioning all labels in successive resizes
17413
+ let maxSteps = elements.length;
17414
+
17415
+ // Avoid to draw labels while fitting the chart area
17416
+ getState(chart).fitting = true;
17417
+
17418
+ while (!fit && maxSteps-- > 0) {
17419
+ updateLabels(elements);
17420
+ fit = !fitChartArea(chart);
17421
+ }
17422
+
17423
+ getState(chart).fitting = false;
17424
+ },
17425
+ afterDatasetUpdate: function (chart, args, options) {
17426
+ var labels = chart.config.data.labels;
17427
+ var dataset = chart.data.datasets[args.index];
17428
+ var config = configure$1(dataset, options);
17429
+ var display = config && config.display;
17430
+ var elements = args.meta.data || [];
17431
+ var ctx = chart.ctx;
17432
+ var el, label, percent, newLabel, context, i;
17433
+ ctx.save();
17434
+
17435
+ for (i = 0; i < elements.length; ++i) {
17436
+ el = elements[i];
17437
+ label = el[PLUGIN_KEY];
17438
+ percent = dataset.data[i] / args.meta.total;
17439
+ newLabel = null;
17440
+
17441
+ if (display && el && !el.hidden) {
17442
+ try {
17443
+ context = {
17444
+ chart: chart,
17445
+ dataIndex: i,
17446
+ dataset: dataset,
17447
+ labels: labels,
17448
+ datasetIndex: args.index,
17449
+ percent: percent,
17450
+ };
17451
+ newLabel = new classes.OutLabel(chart, i, ctx, config, context);
17452
+ } catch (e) {
17453
+ newLabel = null;
17454
+ }
17455
+ }
17456
+
17457
+ if (
17458
+ label &&
17459
+ newLabel &&
17460
+ !getState(chart).sizeChanged &&
17461
+ label.label === newLabel.label &&
17462
+ label.encodedText === newLabel.encodedText
17463
+ ) {
17464
+ newLabel.offset = label.offset;
17465
+ }
17466
+ el[PLUGIN_KEY] = newLabel;
17467
+ }
17468
+
17469
+ ctx.restore();
17470
+ getState(chart).sizeChanged = false;
17471
+ },
17472
+ afterDatasetDraw: function (chart, args) {
17473
+ var elements = args.meta.data || [];
17474
+ var ctx = chart.ctx;
17475
+
17476
+ if (getState(chart).fitting) {
17477
+ return;
17478
+ }
17479
+
17480
+ elements.forEach((el, index) => {
17481
+ const outlabelPlugin = el[PLUGIN_KEY];
17482
+ if (!outlabelPlugin) {
17483
+ return;
17484
+ }
17485
+ outlabelPlugin.update(el, elements, index);
17486
+ outlabelPlugin.draw(ctx);
17487
+ });
17488
+ },
17489
+ afterDestroy: function (chart) {
17490
+ removeState(chart);
17491
+ },
17492
+ };
17493
+
15351
17494
  Chart$1.register(ArcElement, plugin_tooltip, plugin_legend);
15352
17495
  const PieChart = (props) => {
15353
17496
  const { data, title, options, units, content } = props;
@@ -15425,7 +17568,7 @@ const PieChart = (props) => {
15425
17568
  },
15426
17569
  },
15427
17570
  };
15428
- return jsxRuntimeExports.jsx(Pie, { data: data, options: options !== null && options !== void 0 ? options : defaultOptions, plugins: [ChartPieChartOutlabels] });
17571
+ return jsxRuntimeExports.jsx(Pie, { data: data, options: options !== null && options !== void 0 ? options : defaultOptions, plugins: [plugin] });
15429
17572
  };
15430
17573
 
15431
17574
  Chart$1.register(CategoryScale, LinearScale, PointElement, LineElement, plugin_title, plugin_tooltip, plugin_legend);
@@ -15502,13 +17645,14 @@ function LineChart({ title, data, options, className, units, content }) {
15502
17645
  },
15503
17646
  },
15504
17647
  };
15505
- return (jsxRuntimeExports.jsx(Line, { data: data, options: options !== null && options !== void 0 ? options : defaultOptions, plugins: [ChartDataLabels] }));
17648
+ return (jsxRuntimeExports.jsx(Line, { data: data, options: options !== null && options !== void 0 ? options : defaultOptions, plugins: [plugin$1] }));
15506
17649
  }
15507
17650
 
15508
17651
  function DataGrid({ title, data, className }) {
15509
17652
  var _a;
15510
- const { columns, rows, grouped = false, grouping } = data;
17653
+ const { columns, rows, units, grouped = false, grouping } = data;
15511
17654
  const [expandedGroups, setExpandedGroups] = useState(new Set(((_a = grouping === null || grouping === void 0 ? void 0 : grouping.sections) === null || _a === void 0 ? void 0 : _a.filter(s => s.expanded).map(s => s.group_value)) || []));
17655
+ console.log('units==>', units);
15512
17656
  const toggleGroup = (groupValue) => {
15513
17657
  const newExpanded = new Set(expandedGroups);
15514
17658
  if (newExpanded.has(groupValue)) {
@@ -15519,6 +17663,30 @@ function DataGrid({ title, data, className }) {
15519
17663
  }
15520
17664
  setExpandedGroups(newExpanded);
15521
17665
  };
17666
+ const formatValueWithUnit = (value, columnIndex) => {
17667
+ if (value === null || value === undefined)
17668
+ return "—";
17669
+ const unit = units === null || units === void 0 ? void 0 : units[columnIndex];
17670
+ // Format the value with commas if it's a number or numeric string
17671
+ let valueStr;
17672
+ if (typeof value === 'number') {
17673
+ valueStr = value.toLocaleString();
17674
+ }
17675
+ else {
17676
+ const numValue = parseFloat(String(value));
17677
+ valueStr = !isNaN(numValue) ? numValue.toLocaleString() : String(value);
17678
+ }
17679
+ // If no unit or unit length > 3, return value only
17680
+ if (!unit || unit.length > 3) {
17681
+ return valueStr;
17682
+ }
17683
+ // If unit is $, display unit before value
17684
+ if (unit === '$') {
17685
+ return `${unit}${valueStr}`;
17686
+ }
17687
+ // Otherwise display value then unit
17688
+ return `${valueStr}${unit}`;
17689
+ };
15522
17690
  // Backward compatibility: if no data or not grouped, show original table
15523
17691
  if (!columns || columns.length === 0 || (!grouped && (!rows || rows.length === 0))) {
15524
17692
  return (jsxRuntimeExports.jsx("div", { className: "flex items-center justify-center h-full", children: jsxRuntimeExports.jsx("p", { className: "text-sm text-gray-500", children: "No data available" }) }));
@@ -15530,7 +17698,7 @@ function DataGrid({ title, data, className }) {
15530
17698
  const renderGroupedTable = () => {
15531
17699
  if (!(grouping === null || grouping === void 0 ? void 0 : grouping.sections))
15532
17700
  return null;
15533
- return (jsxRuntimeExports.jsxs("table", { className: "w-full border-collapse", children: [jsxRuntimeExports.jsx("thead", { children: jsxRuntimeExports.jsxs("tr", { className: "border-b border-gray-200", children: [jsxRuntimeExports.jsx("th", { className: "px-4 py-3 text-left text-sm font-medium text-gray-900 bg-gray-50 w-8" }), columns.map((column, index) => (jsxRuntimeExports.jsx("th", { className: "px-4 py-3 text-left text-sm font-medium text-gray-900 bg-gray-50", children: column }, index)))] }) }), jsxRuntimeExports.jsx("tbody", { children: grouping.sections.map((section, sectionIndex) => {
17701
+ return (jsxRuntimeExports.jsxs("table", { className: "w-full border-collapse", children: [jsxRuntimeExports.jsx("thead", { children: jsxRuntimeExports.jsxs("tr", { className: "border-b border-gray-200", children: [jsxRuntimeExports.jsx("th", { className: "px-4 py-3 text-left text-sm font-medium text-gray-900 bg-gray-50 w-8" }), columns.map((column, index) => (jsxRuntimeExports.jsxs("th", { className: "px-4 py-3 text-left text-sm font-medium text-gray-900 bg-gray-50", children: [column, (units === null || units === void 0 ? void 0 : units[index]) ? ` (${units[index]})` : ''] }, index)))] }) }), jsxRuntimeExports.jsx("tbody", { children: grouping.sections.map((section, sectionIndex) => {
15534
17702
  const isExpanded = expandedGroups.has(section.group_value);
15535
17703
  return (jsxRuntimeExports.jsxs(React__default.Fragment, { children: [jsxRuntimeExports.jsxs("tr", { className: "bg-blue-50 border-b border-gray-200", children: [jsxRuntimeExports.jsx("td", { className: "px-4 py-3", children: section.collapsible && (jsxRuntimeExports.jsx("button", { onClick: () => toggleGroup(section.group_value), className: "flex items-center justify-center w-6 h-6 hover:bg-blue-100 rounded transition-colors", "aria-label": isExpanded ? "Collapse group" : "Expand group", children: isExpanded ? (jsxRuntimeExports.jsx(ChevronDown, { className: "w-4 h-4 text-blue-600" })) : (jsxRuntimeExports.jsx(ChevronRight, { className: "w-4 h-4 text-blue-600" })) })) }), columns.map((column, columnIndex) => (jsxRuntimeExports.jsx("td", { className: "px-4 py-3 text-sm font-medium text-blue-700", children: columnIndex === 0 ? (jsxRuntimeExports.jsxs("span", { className: "font-semibold text-blue-900", children: [section.title, ": ", section.group_value] })) : (jsxRuntimeExports.jsx("div", { className: "text-left", children: (() => {
15536
17704
  var _a;
@@ -15542,7 +17710,7 @@ function DataGrid({ title, data, className }) {
15542
17710
  if (sectionStats[column] &&
15543
17711
  typeof sectionStats[column].total === 'number' &&
15544
17712
  !isNaN(sectionStats[column].total)) {
15545
- return (jsxRuntimeExports.jsx("span", { className: "whitespace-nowrap text-xs font-medium text-blue-800", children: sectionStats[column].total.toLocaleString() }));
17713
+ return (jsxRuntimeExports.jsx("span", { className: "whitespace-nowrap text-xs font-medium text-blue-800", children: formatValueWithUnit(sectionStats[column].total, columnIndex) }));
15546
17714
  }
15547
17715
  // If exact match fails, try to find by partial match
15548
17716
  const matchingKey = Object.keys(sectionStats).find(key => key.toLowerCase().includes(column.toLowerCase()) ||
@@ -15550,17 +17718,17 @@ function DataGrid({ title, data, className }) {
15550
17718
  if (matchingKey && sectionStats[matchingKey] &&
15551
17719
  typeof sectionStats[matchingKey].total === 'number' &&
15552
17720
  !isNaN(sectionStats[matchingKey].total)) {
15553
- return (jsxRuntimeExports.jsx("span", { className: "whitespace-nowrap text-xs font-medium text-blue-800", children: sectionStats[matchingKey].total.toLocaleString() }));
17721
+ return (jsxRuntimeExports.jsx("span", { className: "whitespace-nowrap text-xs font-medium text-blue-800", children: formatValueWithUnit(sectionStats[matchingKey].total, columnIndex) }));
15554
17722
  }
15555
17723
  return jsxRuntimeExports.jsx("span", { className: "text-gray-400", children: "\u2014" });
15556
17724
  })() })) }, columnIndex)))] }), (!section.collapsible || isExpanded) && section.rows.map((row, rowIndex) => (jsxRuntimeExports.jsxs("tr", { className: `border-b border-gray-200 ${rowIndex % 2 === 0
15557
17725
  ? "bg-white"
15558
- : "bg-gray-50"} hover:bg-gray-100 transition-colors`, children: [jsxRuntimeExports.jsx("td", { className: "px-4 py-3" }), row.map((cell, cellIndex) => (jsxRuntimeExports.jsx("td", { className: "px-4 py-3 text-sm text-gray-900", children: cell !== null && cell !== undefined ? String(cell) : "—" }, cellIndex)))] }, `${sectionIndex}-${rowIndex}`)))] }, `section-${sectionIndex}`));
17726
+ : "bg-gray-50"} hover:bg-gray-100 transition-colors`, children: [jsxRuntimeExports.jsx("td", { className: "px-4 py-3" }), row.map((cell, cellIndex) => (jsxRuntimeExports.jsx("td", { className: "px-4 py-3 text-sm text-gray-900", children: formatValueWithUnit(cell, cellIndex) }, cellIndex)))] }, `${sectionIndex}-${rowIndex}`)))] }, `section-${sectionIndex}`));
15559
17727
  }) })] }));
15560
17728
  };
15561
- const renderRegularTable = () => (jsxRuntimeExports.jsxs("table", { className: "w-full border-collapse", children: [jsxRuntimeExports.jsx("thead", { children: jsxRuntimeExports.jsx("tr", { className: "border-b border-gray-200", children: columns.map((column, index) => (jsxRuntimeExports.jsx("th", { className: "px-4 py-3 text-left text-sm font-medium text-gray-900 bg-gray-50", children: column }, index))) }) }), jsxRuntimeExports.jsx("tbody", { children: rows.map((row, rowIndex) => (jsxRuntimeExports.jsx("tr", { className: `border-b border-gray-200 ${rowIndex % 2 === 0
17729
+ const renderRegularTable = () => (jsxRuntimeExports.jsxs("table", { className: "w-full border-collapse", children: [jsxRuntimeExports.jsx("thead", { children: jsxRuntimeExports.jsx("tr", { className: "border-b border-gray-200", children: columns.map((column, index) => (jsxRuntimeExports.jsxs("th", { className: "px-4 py-3 text-left text-sm font-medium text-gray-900 bg-gray-50", children: [column, (units === null || units === void 0 ? void 0 : units[index]) ? ` (${units[index]})` : ''] }, index))) }) }), jsxRuntimeExports.jsx("tbody", { children: rows.map((row, rowIndex) => (jsxRuntimeExports.jsx("tr", { className: `border-b border-gray-200 ${rowIndex % 2 === 0
15562
17730
  ? "bg-white"
15563
- : "bg-gray-50"} hover:bg-gray-100 transition-colors`, children: row.map((cell, cellIndex) => (jsxRuntimeExports.jsx("td", { className: "px-4 py-3 text-sm text-gray-900", children: cell !== null && cell !== undefined ? String(cell) : "—" }, cellIndex))) }, rowIndex))) })] }));
17731
+ : "bg-gray-50"} hover:bg-gray-100 transition-colors`, children: row.map((cell, cellIndex) => (jsxRuntimeExports.jsx("td", { className: "px-4 py-3 text-sm text-gray-900", children: formatValueWithUnit(cell, cellIndex) }, cellIndex))) }, rowIndex))) })] }));
15564
17732
  return (jsxRuntimeExports.jsxs("div", { className: `h-full flex flex-col ${className || ""}`, children: [title && (jsxRuntimeExports.jsx("div", { className: "pb-4", children: jsxRuntimeExports.jsx("h3", { className: "text-lg font-bold", style: {
15565
17733
  color: "#0F172A"
15566
17734
  }, children: title }) })), jsxRuntimeExports.jsx("div", { className: "flex-1 overflow-auto", children: jsxRuntimeExports.jsx("div", { className: "min-w-full", children: grouped && grouping ? renderGroupedTable() : renderRegularTable() }) }), jsxRuntimeExports.jsx("div", { className: "pt-2 text-xs text-gray-500", children: grouped && grouping && grouping.section_statistics ? (jsxRuntimeExports.jsxs("div", { className: "flex gap-6", children: [jsxRuntimeExports.jsxs("span", { children: [grouping.total_groups, " group", grouping.total_groups !== 1 ? "s" : "", " \u00D7 ", columns.length, " column", columns.length !== 1 ? "s" : ""] }), jsxRuntimeExports.jsx("div", { className: "flex gap-4", children: (() => {
@@ -15572,7 +17740,10 @@ function DataGrid({ title, data, className }) {
15572
17740
  }
15573
17741
  });
15574
17742
  });
15575
- return Object.entries(totals).map(([column, total], index) => (jsxRuntimeExports.jsxs("span", { className: "font-medium", children: ["Total ", column, ": ", total.toLocaleString()] }, index)));
17743
+ return Object.entries(totals).map(([column, total], index) => {
17744
+ const columnIndex = columns.findIndex(col => col === column);
17745
+ return (jsxRuntimeExports.jsxs("span", { className: "font-medium", children: ["Total ", column, ": ", formatValueWithUnit(total, columnIndex)] }, index));
17746
+ });
15576
17747
  })() })] })) : (jsxRuntimeExports.jsxs("span", { children: ["Showing ", rows.length, " row", rows.length !== 1 ? "s" : "", " \u00D7 ", columns.length, " column", columns.length !== 1 ? "s" : ""] })) })] }));
15577
17748
  }
15578
17749
 
@@ -36463,12 +38634,14 @@ function BarChartComponent({ orientation, barChartState, styles, appendMessage,
36463
38634
  return (jsxRuntimeExports.jsx(BarChart, { orientation: orientation, title: chartTitle, data: transformedData, units: units, content: content }));
36464
38635
  }
36465
38636
  function SeriesBarChartComponent({ orientation, seriesBarChartState, styles, appendMessage, query, isFirstLoad, widgetBackendUrl, widgetId, startLoadingTimeout, clearLoadingTimeout, content }) {
36466
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
38637
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x;
36467
38638
  const hasCalledRef = useRef(false);
36468
38639
  const labels = ((_b = (_a = seriesBarChartState === null || seriesBarChartState === void 0 ? void 0 : seriesBarChartState.series_bar_chart_data) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.labels) || ((_e = (_d = (_c = seriesBarChartState === null || seriesBarChartState === void 0 ? void 0 : seriesBarChartState.state) === null || _c === void 0 ? void 0 : _c.series_bar_chart_data) === null || _d === void 0 ? void 0 : _d.data) === null || _e === void 0 ? void 0 : _e.labels) || [];
36469
- const series = ((_g = (_f = seriesBarChartState === null || seriesBarChartState === void 0 ? void 0 : seriesBarChartState.series_bar_chart_data) === null || _f === void 0 ? void 0 : _f.data) === null || _g === void 0 ? void 0 : _g.series) || ((_k = (_j = (_h = seriesBarChartState === null || seriesBarChartState === void 0 ? void 0 : seriesBarChartState.state) === null || _h === void 0 ? void 0 : _h.series_bar_chart_data) === null || _j === void 0 ? void 0 : _j.data) === null || _k === void 0 ? void 0 : _k.series) || [];
36470
- const chartTitle = ((_l = seriesBarChartState === null || seriesBarChartState === void 0 ? void 0 : seriesBarChartState.series_bar_chart_data) === null || _l === void 0 ? void 0 : _l.title) || ((_o = (_m = seriesBarChartState === null || seriesBarChartState === void 0 ? void 0 : seriesBarChartState.state) === null || _m === void 0 ? void 0 : _m.series_bar_chart_data) === null || _o === void 0 ? void 0 : _o.title) || "";
36471
- const units = ((_p = seriesBarChartState === null || seriesBarChartState === void 0 ? void 0 : seriesBarChartState.series_bar_chart_data) === null || _p === void 0 ? void 0 : _p.units) || ((_r = (_q = seriesBarChartState === null || seriesBarChartState === void 0 ? void 0 : seriesBarChartState.state) === null || _q === void 0 ? void 0 : _q.series_bar_chart_data) === null || _r === void 0 ? void 0 : _r.units) || "";
38640
+ const x_axis_title = ((_f = seriesBarChartState === null || seriesBarChartState === void 0 ? void 0 : seriesBarChartState.series_bar_chart_data) === null || _f === void 0 ? void 0 : _f.x_axis_title) || ((_h = (_g = seriesBarChartState === null || seriesBarChartState === void 0 ? void 0 : seriesBarChartState.state) === null || _g === void 0 ? void 0 : _g.series_bar_chart_data) === null || _h === void 0 ? void 0 : _h.x_axis_title) || "";
38641
+ const y_axis_title = ((_j = seriesBarChartState === null || seriesBarChartState === void 0 ? void 0 : seriesBarChartState.series_bar_chart_data) === null || _j === void 0 ? void 0 : _j.y_axis_title) || ((_l = (_k = seriesBarChartState === null || seriesBarChartState === void 0 ? void 0 : seriesBarChartState.state) === null || _k === void 0 ? void 0 : _k.series_bar_chart_data) === null || _l === void 0 ? void 0 : _l.y_axis_title) || "";
38642
+ const series = ((_o = (_m = seriesBarChartState === null || seriesBarChartState === void 0 ? void 0 : seriesBarChartState.series_bar_chart_data) === null || _m === void 0 ? void 0 : _m.data) === null || _o === void 0 ? void 0 : _o.series) || ((_r = (_q = (_p = seriesBarChartState === null || seriesBarChartState === void 0 ? void 0 : seriesBarChartState.state) === null || _p === void 0 ? void 0 : _p.series_bar_chart_data) === null || _q === void 0 ? void 0 : _q.data) === null || _r === void 0 ? void 0 : _r.series) || [];
38643
+ const chartTitle = ((_s = seriesBarChartState === null || seriesBarChartState === void 0 ? void 0 : seriesBarChartState.series_bar_chart_data) === null || _s === void 0 ? void 0 : _s.title) || ((_u = (_t = seriesBarChartState === null || seriesBarChartState === void 0 ? void 0 : seriesBarChartState.state) === null || _t === void 0 ? void 0 : _t.series_bar_chart_data) === null || _u === void 0 ? void 0 : _u.title) || "";
38644
+ const units = ((_v = seriesBarChartState === null || seriesBarChartState === void 0 ? void 0 : seriesBarChartState.series_bar_chart_data) === null || _v === void 0 ? void 0 : _v.units) || ((_x = (_w = seriesBarChartState === null || seriesBarChartState === void 0 ? void 0 : seriesBarChartState.state) === null || _w === void 0 ? void 0 : _w.series_bar_chart_data) === null || _x === void 0 ? void 0 : _x.units) || "";
36472
38645
  const isEmpty = labels.length === 0 || series.length === 0;
36473
38646
  const handleRefresh = async () => {
36474
38647
  if (query) {
@@ -36511,15 +38684,17 @@ function SeriesBarChartComponent({ orientation, seriesBarChartState, styles, app
36511
38684
  backgroundColor: (seriesItem === null || seriesItem === void 0 ? void 0 : seriesItem.colors) || (seriesItem === null || seriesItem === void 0 ? void 0 : seriesItem.color) || finalColors[index % finalColors.length],
36512
38685
  })),
36513
38686
  };
36514
- return (jsxRuntimeExports.jsx(SeriesChart, { orientation: orientation, title: chartTitle, data: transformedData, units: units, content: content }));
38687
+ return (jsxRuntimeExports.jsx(SeriesChart, { orientation: orientation, title: chartTitle, data: transformedData, units: units, content: content, x_axis_title: x_axis_title, y_axis_title: y_axis_title }));
36515
38688
  }
36516
38689
  function SeriesLineChartComponent({ orientation, seriesLineChartState, styles, appendMessage, content, query, isFirstLoad, widgetBackendUrl, widgetId, startLoadingTimeout, clearLoadingTimeout }) {
36517
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
38690
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x;
36518
38691
  const hasCalledRef = useRef(false);
36519
38692
  const labels = ((_b = (_a = seriesLineChartState === null || seriesLineChartState === void 0 ? void 0 : seriesLineChartState.series_bar_chart_data) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.labels) || ((_e = (_d = (_c = seriesLineChartState === null || seriesLineChartState === void 0 ? void 0 : seriesLineChartState.state) === null || _c === void 0 ? void 0 : _c.series_bar_chart_data) === null || _d === void 0 ? void 0 : _d.data) === null || _e === void 0 ? void 0 : _e.labels) || [];
36520
38693
  const series = ((_g = (_f = seriesLineChartState === null || seriesLineChartState === void 0 ? void 0 : seriesLineChartState.series_bar_chart_data) === null || _f === void 0 ? void 0 : _f.data) === null || _g === void 0 ? void 0 : _g.series) || ((_k = (_j = (_h = seriesLineChartState === null || seriesLineChartState === void 0 ? void 0 : seriesLineChartState.state) === null || _h === void 0 ? void 0 : _h.series_bar_chart_data) === null || _j === void 0 ? void 0 : _j.data) === null || _k === void 0 ? void 0 : _k.series) || [];
36521
- const chartTitle = ((_l = seriesLineChartState === null || seriesLineChartState === void 0 ? void 0 : seriesLineChartState.series_bar_chart_data) === null || _l === void 0 ? void 0 : _l.title) || ((_o = (_m = seriesLineChartState === null || seriesLineChartState === void 0 ? void 0 : seriesLineChartState.state) === null || _m === void 0 ? void 0 : _m.series_bar_chart_data) === null || _o === void 0 ? void 0 : _o.title) || "";
36522
- const units = ((_p = seriesLineChartState === null || seriesLineChartState === void 0 ? void 0 : seriesLineChartState.series_bar_chart_data) === null || _p === void 0 ? void 0 : _p.units) || ((_r = (_q = seriesLineChartState === null || seriesLineChartState === void 0 ? void 0 : seriesLineChartState.state) === null || _q === void 0 ? void 0 : _q.series_bar_chart_data) === null || _r === void 0 ? void 0 : _r.units) || "";
38694
+ const x_axis_title = ((_l = seriesLineChartState === null || seriesLineChartState === void 0 ? void 0 : seriesLineChartState.series_bar_chart_data) === null || _l === void 0 ? void 0 : _l.x_axis_title) || ((_o = (_m = seriesLineChartState === null || seriesLineChartState === void 0 ? void 0 : seriesLineChartState.state) === null || _m === void 0 ? void 0 : _m.series_bar_chart_data) === null || _o === void 0 ? void 0 : _o.x_axis_title) || "";
38695
+ const y_axis_title = ((_p = seriesLineChartState === null || seriesLineChartState === void 0 ? void 0 : seriesLineChartState.series_bar_chart_data) === null || _p === void 0 ? void 0 : _p.y_axis_title) || ((_r = (_q = seriesLineChartState === null || seriesLineChartState === void 0 ? void 0 : seriesLineChartState.state) === null || _q === void 0 ? void 0 : _q.series_bar_chart_data) === null || _r === void 0 ? void 0 : _r.y_axis_title) || "";
38696
+ const chartTitle = ((_s = seriesLineChartState === null || seriesLineChartState === void 0 ? void 0 : seriesLineChartState.series_bar_chart_data) === null || _s === void 0 ? void 0 : _s.title) || ((_u = (_t = seriesLineChartState === null || seriesLineChartState === void 0 ? void 0 : seriesLineChartState.state) === null || _t === void 0 ? void 0 : _t.series_bar_chart_data) === null || _u === void 0 ? void 0 : _u.title) || "";
38697
+ const units = ((_v = seriesLineChartState === null || seriesLineChartState === void 0 ? void 0 : seriesLineChartState.series_bar_chart_data) === null || _v === void 0 ? void 0 : _v.units) || ((_x = (_w = seriesLineChartState === null || seriesLineChartState === void 0 ? void 0 : seriesLineChartState.state) === null || _w === void 0 ? void 0 : _w.series_bar_chart_data) === null || _x === void 0 ? void 0 : _x.units) || "";
36523
38698
  const isEmpty = labels.length === 0 || series.length === 0;
36524
38699
  const handleRefresh = async () => {
36525
38700
  if (query) {
@@ -36569,7 +38744,7 @@ function SeriesLineChartComponent({ orientation, seriesLineChartState, styles, a
36569
38744
  tension: 0.1,
36570
38745
  })),
36571
38746
  };
36572
- return (jsxRuntimeExports.jsx(SeriesLineChart, { orientation: orientation, title: chartTitle, data: transformedData, units: units, content: content }));
38747
+ return (jsxRuntimeExports.jsx(SeriesLineChart, { orientation: orientation, title: chartTitle, data: transformedData, units: units, content: content, x_axis_title: x_axis_title, y_axis_title: y_axis_title }));
36573
38748
  }
36574
38749
  function PieChartComponent({ pieChartState, styles, appendMessage, query, isFirstLoad, widgetBackendUrl, widgetId, startLoadingTimeout, clearLoadingTimeout, content }) {
36575
38750
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1;
@@ -36685,11 +38860,12 @@ function LineChartComponent({ lineChartState, styles, appendMessage, query, isFi
36685
38860
  return (jsxRuntimeExports.jsx(LineChart, { title: chartTitle, data: transformedData, units: units, content: content }));
36686
38861
  }
36687
38862
  function DataGridComponent({ dataGridState, styles, appendMessage, query, isFirstLoad, widgetBackendUrl, widgetId, startLoadingTimeout, clearLoadingTimeout }) {
36688
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u;
38863
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z;
36689
38864
  const hasCalledRef = useRef(false);
36690
38865
  const columns = ((_b = (_a = dataGridState === null || dataGridState === void 0 ? void 0 : dataGridState.matrix_grid_data) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.headers) || ((_e = (_d = (_c = dataGridState === null || dataGridState === void 0 ? void 0 : dataGridState.state) === null || _c === void 0 ? void 0 : _c.matrix_grid_data) === null || _d === void 0 ? void 0 : _d.data) === null || _e === void 0 ? void 0 : _e.headers) || [];
36691
38866
  const rows = ((_g = (_f = dataGridState === null || dataGridState === void 0 ? void 0 : dataGridState.matrix_grid_data) === null || _f === void 0 ? void 0 : _f.data) === null || _g === void 0 ? void 0 : _g.rows) || ((_k = (_j = (_h = dataGridState === null || dataGridState === void 0 ? void 0 : dataGridState.state) === null || _h === void 0 ? void 0 : _h.matrix_grid_data) === null || _j === void 0 ? void 0 : _j.data) === null || _k === void 0 ? void 0 : _k.rows) || [];
36692
38867
  const gridTitle = ((_l = dataGridState === null || dataGridState === void 0 ? void 0 : dataGridState.matrix_grid_data) === null || _l === void 0 ? void 0 : _l.title) || ((_o = (_m = dataGridState === null || dataGridState === void 0 ? void 0 : dataGridState.state) === null || _m === void 0 ? void 0 : _m.matrix_grid_data) === null || _o === void 0 ? void 0 : _o.title) || "";
38868
+ const units = ((_q = (_p = dataGridState === null || dataGridState === void 0 ? void 0 : dataGridState.matrix_grid_data) === null || _p === void 0 ? void 0 : _p.data) === null || _q === void 0 ? void 0 : _q.units) || ((_t = (_s = (_r = dataGridState === null || dataGridState === void 0 ? void 0 : dataGridState.state) === null || _r === void 0 ? void 0 : _r.matrix_grid_data) === null || _s === void 0 ? void 0 : _s.data) === null || _t === void 0 ? void 0 : _t.units) || [];
36693
38869
  const isEmpty = columns.length === 0 || rows.length === 0;
36694
38870
  const handleRefresh = async () => {
36695
38871
  if (query) {
@@ -36723,9 +38899,10 @@ function DataGridComponent({ dataGridState, styles, appendMessage, query, isFirs
36723
38899
  }
36724
38900
  const transformedData = {
36725
38901
  columns: columns,
38902
+ units: units,
36726
38903
  rows: rows,
36727
- grouped: ((_p = dataGridState === null || dataGridState === void 0 ? void 0 : dataGridState.matrix_grid_data) === null || _p === void 0 ? void 0 : _p.grouped) || ((_r = (_q = dataGridState === null || dataGridState === void 0 ? void 0 : dataGridState.state) === null || _q === void 0 ? void 0 : _q.matrix_grid_data) === null || _r === void 0 ? void 0 : _r.grouped) || false,
36728
- grouping: ((_s = dataGridState === null || dataGridState === void 0 ? void 0 : dataGridState.matrix_grid_data) === null || _s === void 0 ? void 0 : _s.grouping) || ((_u = (_t = dataGridState === null || dataGridState === void 0 ? void 0 : dataGridState.state) === null || _t === void 0 ? void 0 : _t.matrix_grid_data) === null || _u === void 0 ? void 0 : _u.grouping)
38904
+ grouped: ((_u = dataGridState === null || dataGridState === void 0 ? void 0 : dataGridState.matrix_grid_data) === null || _u === void 0 ? void 0 : _u.grouped) || ((_w = (_v = dataGridState === null || dataGridState === void 0 ? void 0 : dataGridState.state) === null || _v === void 0 ? void 0 : _v.matrix_grid_data) === null || _w === void 0 ? void 0 : _w.grouped) || false,
38905
+ grouping: ((_x = dataGridState === null || dataGridState === void 0 ? void 0 : dataGridState.matrix_grid_data) === null || _x === void 0 ? void 0 : _x.grouping) || ((_z = (_y = dataGridState === null || dataGridState === void 0 ? void 0 : dataGridState.state) === null || _y === void 0 ? void 0 : _y.matrix_grid_data) === null || _z === void 0 ? void 0 : _z.grouping)
36729
38906
  };
36730
38907
  return (jsxRuntimeExports.jsx(DataGrid, { title: gridTitle, data: transformedData, className: "" }));
36731
38908
  }
@@ -36875,7 +39052,6 @@ function CopilotKitAgent({ widget, showHeader, styles, onResetReady, widgetIds,
36875
39052
  useEffect(() => {
36876
39053
  const handleTriggerAgent = (event) => {
36877
39054
  const { widgetId, query, agentType: eventAgentType, datasetId } = event.detail;
36878
- console.log('event.detail==>', event.detail);
36879
39055
  if (widgetId === widget.id) {
36880
39056
  let messageContent = query;
36881
39057
  // Customize message based on agent type
@@ -40755,7 +42931,7 @@ function SavedPages({ onEditPage, widgetBackendUrl }) {
40755
42931
  if (isLoading) {
40756
42932
  return (jsxRuntimeExports.jsx("div", { className: "flex items-center justify-center h-screen", children: jsxRuntimeExports.jsx("div", { className: "animate-spin rounded-full h-8 w-8 border-b-2 border-gray-900" }) }));
40757
42933
  }
40758
- return (jsxRuntimeExports.jsxs("div", { className: "container mx-auto p-6 space-y-6", children: [jsxRuntimeExports.jsxs("div", { className: "flex justify-between items-center", children: [jsxRuntimeExports.jsx("h1", { className: "text-2xl font-bold", children: "Saved Pages" }), jsxRuntimeExports.jsxs(Button, { onClick: handleCreatePage, children: [jsxRuntimeExports.jsx(Plus, { className: "h-4 w-4 mr-2" }), "Create New Page"] })] }), error && (jsxRuntimeExports.jsx(Alert, { variant: "destructive", children: jsxRuntimeExports.jsx(AlertDescription, { children: error }) })), jsxRuntimeExports.jsxs("div", { className: "flex items-center space-x-2", children: [jsxRuntimeExports.jsx(Search, { className: "h-4 w-4 text-muted-foreground" }), jsxRuntimeExports.jsx(Input, { placeholder: "Search pages...", value: searchTerm, onChange: (e) => setSearchTerm(e.target.value), className: "max-w-sm" })] }), jsxRuntimeExports.jsx("div", { className: "grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6", children: filteredPages.map((page) => (jsxRuntimeExports.jsxs(Card, { className: "hover:shadow-lg transition-shadow", children: [jsxRuntimeExports.jsxs(CardHeader, { children: [jsxRuntimeExports.jsx(CardTitle, { children: page.title }), jsxRuntimeExports.jsxs(CardDescription, { children: ["Created: ", format(new Date(page.created_at), "PPP")] })] }), jsxRuntimeExports.jsx(CardContent, { children: jsxRuntimeExports.jsxs("div", { className: "flex justify-between items-center", children: [jsxRuntimeExports.jsxs("div", { className: "flex items-center space-x-2 text-sm text-muted-foreground", children: [jsxRuntimeExports.jsx(LayoutGrid, { className: "h-4 w-4" }), jsxRuntimeExports.jsxs("span", { children: ["Page #", page.id] })] }), jsxRuntimeExports.jsxs("div", { className: "flex space-x-2", children: [jsxRuntimeExports.jsx(Button, { variant: "outline", size: "sm", onClick: () => onEditPage(page.id), children: jsxRuntimeExports.jsx(Edit2, { className: "h-4 w-4" }) }), jsxRuntimeExports.jsx(Button, { variant: "outline", size: "sm", onClick: () => handleDeletePage(page.id), children: jsxRuntimeExports.jsx(Trash2, { className: "h-4 w-4" }) })] })] }) })] }, page.id))) }), filteredPages.length === 0 && (jsxRuntimeExports.jsx("div", { className: "text-center text-muted-foreground py-12", children: "No pages found. Create a new one to get started." })), jsxRuntimeExports.jsx(Dialog, { open: isCreateModalOpen, onOpenChange: setIsCreateModalOpen, children: jsxRuntimeExports.jsxs(DialogContent, { className: "sm:max-w-[425px]", children: [jsxRuntimeExports.jsxs(DialogHeader, { children: [jsxRuntimeExports.jsx(DialogTitle, { children: "Create New Page" }), jsxRuntimeExports.jsx(DialogDescription, { children: "Create a new page with widgets. You can customize it after creation." })] }), jsxRuntimeExports.jsxs("div", { className: "grid gap-4 py-4", children: [jsxRuntimeExports.jsxs("div", { className: "grid grid-cols-4 items-center gap-4", children: [jsxRuntimeExports.jsx(Label, { htmlFor: "title", className: "text-right", children: "Title" }), jsxRuntimeExports.jsx(Input, { id: "title", value: newPageTitle, onChange: (e) => setNewPageTitle(e.target.value), placeholder: "Enter page title...", className: "col-span-3" })] }), jsxRuntimeExports.jsxs("div", { className: "flex items-center space-x-2", children: [jsxRuntimeExports.jsx(Checkbox, { id: "public", checked: newPageIsPublic, onCheckedChange: (checked) => setNewPageIsPublic(checked === true) }), jsxRuntimeExports.jsx(Label, { htmlFor: "public", className: "text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70", children: "Make this page public" })] })] }), jsxRuntimeExports.jsxs(DialogFooter, { children: [jsxRuntimeExports.jsx(Button, { type: "button", variant: "outline", onClick: () => {
42934
+ return (jsxRuntimeExports.jsxs("div", { className: "container mx-auto p-6 space-y-6", children: [jsxRuntimeExports.jsxs("div", { className: "flex justify-between items-center", children: [jsxRuntimeExports.jsx("h1", { className: "text-2xl font-bold", children: "Saved Pages" }), jsxRuntimeExports.jsxs(Button, { onClick: handleCreatePage, children: [jsxRuntimeExports.jsx(Plus, { className: "h-4 w-4 mr-2" }), "Create New Page"] })] }), error && (jsxRuntimeExports.jsx(Alert, { variant: "destructive", children: jsxRuntimeExports.jsx(AlertDescription, { children: error }) })), jsxRuntimeExports.jsxs("div", { className: "flex items-center space-x-2", children: [jsxRuntimeExports.jsx(Search, { className: "h-4 w-4 text-muted-foreground" }), jsxRuntimeExports.jsx(Input, { placeholder: "Search pages...", value: searchTerm, onChange: (e) => setSearchTerm(e.target.value), className: "max-w-sm" })] }), jsxRuntimeExports.jsx("div", { className: "grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6", children: filteredPages.map((page) => (jsxRuntimeExports.jsxs(Card, { className: "hover:shadow-lg transition-shadow", children: [jsxRuntimeExports.jsxs(CardHeader, { children: [jsxRuntimeExports.jsx(CardTitle, { children: page.title }), jsxRuntimeExports.jsxs(CardDescription, { children: ["Created: ", format(new Date(page.created_at), "PPP")] })] }), jsxRuntimeExports.jsx(CardContent, { children: jsxRuntimeExports.jsxs("div", { className: "flex justify-between items-center", children: [jsxRuntimeExports.jsxs("div", { className: "flex items-center space-x-2 text-sm text-muted-foreground", children: [jsxRuntimeExports.jsx(LayoutGrid, { className: "h-4 w-4" }), jsxRuntimeExports.jsxs("span", { children: ["Page #", page.id] })] }), jsxRuntimeExports.jsxs("div", { className: "flex space-x-2", children: [jsxRuntimeExports.jsx(Button, { variant: "outline", size: "sm", onClick: () => onEditPage(page.id), children: jsxRuntimeExports.jsx(Edit2, { className: "h-4 w-4" }) }), jsxRuntimeExports.jsx(Button, { variant: "outline", size: "sm", onClick: () => handleDeletePage(page.id), children: jsxRuntimeExports.jsx(Trash2, { className: "h-4 w-4" }) })] })] }) })] }, page.id))) }), filteredPages.length === 0 && (jsxRuntimeExports.jsx("div", { className: "text-center text-muted-foreground py-12", children: "No pages found. Create a new one to get started." })), jsxRuntimeExports.jsx(Dialog, { open: isCreateModalOpen, onOpenChange: setIsCreateModalOpen, children: jsxRuntimeExports.jsxs(DialogContent, { className: "sm:max-w-[425px]", children: [jsxRuntimeExports.jsxs(DialogHeader, { children: [jsxRuntimeExports.jsx(DialogTitle, { children: "Create New Page" }), jsxRuntimeExports.jsx(DialogDescription, { children: "Create a new page with widgets. You can customize it after creation." })] }), jsxRuntimeExports.jsxs("div", { className: "grid gap-4 py-4", children: [jsxRuntimeExports.jsxs("div", { className: "grid grid-cols-4 items-center gap-4", children: [jsxRuntimeExports.jsx(Label$1, { htmlFor: "title", className: "text-right", children: "Title" }), jsxRuntimeExports.jsx(Input, { id: "title", value: newPageTitle, onChange: (e) => setNewPageTitle(e.target.value), placeholder: "Enter page title...", className: "col-span-3" })] }), jsxRuntimeExports.jsxs("div", { className: "flex items-center space-x-2", children: [jsxRuntimeExports.jsx(Checkbox, { id: "public", checked: newPageIsPublic, onCheckedChange: (checked) => setNewPageIsPublic(checked === true) }), jsxRuntimeExports.jsx(Label$1, { htmlFor: "public", className: "text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70", children: "Make this page public" })] })] }), jsxRuntimeExports.jsxs(DialogFooter, { children: [jsxRuntimeExports.jsx(Button, { type: "button", variant: "outline", onClick: () => {
40759
42935
  setIsCreateModalOpen(false);
40760
42936
  setNewPageTitle("");
40761
42937
  setNewPageIsPublic(false);