"use strict";var e=require("@babel/runtime/helpers/defineProperty"),t=require("react"),r=require("prop-types"),s=require("classnames"),n=require("lodash"),i=require("uuid"),a=require("./components/Track.js"),o=require("./components/Tooltip/CursorPositioner.js"),u=require("./constants.js"),c=require("./utils/dataParser.js"),l=require("./SettingsContext.js"),d=require("./DataContext.js"),p=require("./ChartsContext.js"),g=require("./ParameterCharts.css.js"),f=require("react/jsx-runtime");function y(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var h=y(e),m=y(s),j=y(i);function q(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,s)}return r}function b(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?q(Object(r),!0).forEach((function(t){h.default(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):q(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}var x=function(e){var r=e.settings,s=e.onSettingsChange,i=e.settingsKey,y=e.horizontal,q=e.mapping,x=e.data,O=e.indexes,v=e.isLoading,C=e.multipleAssets,P=e.assestColors,R=r[i],T=t.useRef(new Map);t.useEffect((function(){R&&R.length||s(b(b({},r),{},h.default({},i,[b(b({},u.DEFAULT_TRACK_SETTINGS),{},{id:j.default()})])))}),[]);var S=t.useMemo((function(){return n.get(n.maxBy(R,"traces.length"),"traces.length")||1}),[R]),D=t.useMemo((function(){return C?Object.keys(x).reduce((function(e,t){return b(b({},e),{},h.default({},t,c.convertData({data:x[t],mapping:q,indexesKeys:O.keys})))}),{}):c.convertData({data:x,mapping:q,indexesKeys:O.keys})}),[x,q,O.keys,C]);return f.jsx(l.Provider,{value:{horizontal:y,settingsKey:i,settings:r,onSettingsChange:s,maxTracesCount:S,multipleAssets:C,assestColors:P},children:f.jsx(d.Provider,{value:{mapping:q,parsedData:D,indexes:O,isLoading:v},children:f.jsx(p.Provider,{value:{chartsRef:T,onChartChange:function(e,t){T.current.set(e,t)}},children:f.jsxs("div",{className:m.default(g.container,h.default({},g.horizontal,y)),children:[f.jsx(o,{}),R&&R.map((function(e,t){return f.jsx(a,{settings:r,onSettingsChange:s,id:e.id,index:t},e.id)}))]})})})})};x.propTypes={data:r.shape({}).isRequired,mapping:r.arrayOf(r.shape({name:r.string.isRequired,key:r.string.isRequired,unit:r.string.isRequired,unitType:r.string.isRequired}).isRequired).isRequired,indexes:r.shape({key:r.string,name:r.string,min:r.number,max:r.number,unit:r.string,unitType:r.string}).isRequired,settingsKey:r.string,settings:r.shape({}),onSettingsChange:r.func.isRequired,horizontal:r.bool,multipleAssets:r.bool,isLoading:r.bool.isRequired,assestColors:r.arrayOf(r.string)},x.defaultProps={settingsKey:u.SETTINGS_KEY,horizontal:!1,multipleAssets:!1,settings:{},assestColors:[]},module.exports=x;
