import e from"@babel/runtime/helpers/defineProperty";import o from"@babel/runtime/helpers/slicedToArray";import{makeStyles as t}from"@material-ui/core";import{isEmpty as r,merge as n}from"lodash";import{useState as i,useEffect as a}from"react";import l from"../ChartWrapperContext.js";import{MIN_CHART_HEIGHT as c}from"../constants.js";import{useZoom as h}from"../effects/useZoom.js";import{useChartModifier as s}from"../effects/useChartModifier.js";import{useChartTypeSwitch as d}from"../effects/useChartTypeSwitch.js";import m from"./AxisOverlay.js";import{jsx as u,jsxs as p}from"react/jsx-runtime";function f(e,o){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);o&&(r=r.filter((function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable}))),t.push.apply(t,r)}return t}function v(o){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?f(Object(r),!0).forEach((function(t){e(o,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(o,Object.getOwnPropertyDescriptors(r)):f(Object(r)).forEach((function(e){Object.defineProperty(o,e,Object.getOwnPropertyDescriptor(r,e))}))}return o}var C=t({container:{width:"100%",height:"100%",position:"relative"}}),b={zoomType:"xy",panning:{enabled:!0,type:"xy"}},y=function(e){var t,f,y,g,O,j,S,Z,P=e.children,w=e.chartRef,x=e.isAxesCoordinatesShown,E=void 0!==x&&x,z=e.onCustomizeScaleClick,T=void 0===z?null:z,k=e.onZoomChangeCallback,A=void 0===k?function(){}:k,D=e.chartOptions,B=void 0===D?{}:D,M=C(),R=i({}),H=o(R,2),I=H[0],N=H[1],W=h({chart:null===(t=w.current)||void 0===t?void 0:t.chart}),q=W.zoomStatus,F=W.zoomConfig,G=W.handleZoomEvent,J=W.handleResetZoom,K=W.isZoomEnabled,L=W.handleIsZoomEnabledChange,Q=W.debouncedChartSelection;a((function(){var e,o,t;r(null===(e=w.current)||void 0===e?void 0:e.chart)||N({marginBottom:null===(o=w.current)||void 0===o||null===(t=o.chart)||void 0===t?void 0:t.marginBottom})}),[]);var U=(null===(f=w.current)||void 0===f||null===(y=f.chart)||void 0===y||null===(g=y.plotBox)||void 0===g?void 0:g.height)<=c;s({chart:null===(O=w.current)||void 0===O?void 0:O.chart,chartOptions:n({},b,B),isZoomEnabled:K,isMinHeightChart:U,onZoomChangeCallback:A,handleChartSelection:Q,isAxesCoordinatesShown:E});var V=d({chart:null===(j=w.current)||void 0===j?void 0:j.chart}),X=V.chartType,Y=V.handleChartTypeChange,$={chart:null===(S=w.current)||void 0===S?void 0:S.chart,chartType:X,zoomConfig:F,chartStyles:I,zoomStatus:q,isZoomEnabled:K,setChartStyles:N,handleChartTypeChange:Y,handleResetZoom:J,handleZoomEvent:G,isMinHeightChart:U,handleChartSelection:Q,handleChangeChartStyles:function(e){N((function(o){return v(v({},o),e)}))},handleIsZoomEnabledChange:L};return u("div",{className:M.container,children:p(l.Provider,{value:$,children:[P,T&&(null===(Z=w.current)||void 0===Z?void 0:Z.chart.axes.map((function(e){return u(m,v({onCustomizeScaleClick:T},e),e.coll)})))]})})};y.defaultProps={onZoomChangeCallback:function(){}};export{y as default};
