import e from"@babel/runtime/helpers/defineProperty";import{useContext as r,useRef as t,useMemo as i,useEffect as n}from"react";import o from"prop-types";import s from"highcharts";import a from"highcharts-react-official";import{toNumber as c}from"lodash";import u from"../../DataContext.js";import p from"../../SettingsContext.js";import m from"../../ChartsContext.js";import f from"./EmptyChart.js";import{getLineOptionsByTrack as l}from"./options.js";import h from"./LineChart.css.js";import{jsx as y}from"react/jsx-runtime";function d(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);r&&(i=i.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),t.push.apply(t,i)}return t}function x(r){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?d(Object(i),!0).forEach((function(t){e(r,t,i[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(i)):d(Object(i)).forEach((function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(i,e))}))}return r}var g=function(e){var o=e.traceSettings,d=e.trackIndex,g=r(u),b=g.parsedData,j=g.indexes,O=r(m).onChartChange,v=r(p),C=v.maxTracesCount,S=v.multipleAssets,P=v.assestColors,M=t(),k=i((function(){var e=l(d),r=e.yAxis;if(e.yAxis=[],S){var t=o[0];if(!t)return e;Object.keys(b).forEach((function(i){e.series.push(x(x(x({},t),{},{lineColor:P[i]},b[i]["".concat(t.collection,".").concat(t.key)]),{},{name:i})),e.yAxis.push(x(x({},r),{},{min:!t.autoScale&&t.scaleMin?c(t.scaleMin):void 0,max:!t.autoScale&&t.scaleMax?c(t.scaleMax):void 0}))}))}else o.forEach((function(t){e.series.push(x(x({},t),b["".concat(t.collection,".").concat(t.key)])),e.yAxis.push(x(x({},r),{},{min:!t.autoScale&&t.scaleMin?c(t.scaleMin):void 0,max:!t.autoScale&&t.scaleMax?c(t.scaleMax):void 0}))}));return e}),[o,b]);n((function(){M.current&&M.current.chart.xAxis[0].setExtremes(j.min,j.max)}),[j.min,j.max]),n((function(){M.current&&M.current.chart.setSize()}),[C]),n((function(){O(d,M)}),[M]);var q=!k.series||!k.series.length||1===k.series.length&&!k.series[0].data;return i((function(){return q?y(f,{}):k&&y(a,{highcharts:s,options:k,ref:M,containerProps:{className:h.container}})}),[k])};g.propTypes={traceSettings:o.arrayOf(o.shape({dashStyle:o.string.isRequired,id:o.string.isRequired,key:o.string,color:o.string,name:o.string,traceType:o.string.isRequired,unit:o.string,lineWidth:o.number.isRequired}).isRequired).isRequired,trackIndex:o.number.isRequired};export{g as default};
//# sourceMappingURL=LineChart.js.map
