import{G as M,H as C,I as F,r as k}from"./vendor-DdPBfMMb.js";var z={},l={},q;function L(){if(q)return l;q=1,Object.defineProperty(l,"__esModule",{value:!0}),l.pick=void 0;function c(i,t){var e={};return t.forEach(function(n){e[n]=i[n]}),e}return l.pick=c,l}var d={},I;function U(){if(I)return d;I=1,Object.defineProperty(d,"__esModule",{value:!0}),d.isFunction=void 0;function c(i){return typeof i=="function"}return d.isFunction=c,d}var f={},b;function j(){if(b)return f;b=1,Object.defineProperty(f,"__esModule",{value:!0}),f.isString=void 0;function c(i){return typeof i=="string"}return f.isString=c,f}var v={},O;function H(){if(O)return v;O=1,Object.defineProperty(v,"__esModule",{value:!0}),v.isEqual=void 0;var c=M,i=c.__importDefault(C());return v.isEqual=i.default,v}Object.defineProperty(z,"__esModule",{value:!0});var u=M,R=u.__importStar(k),m=F(),w=L(),E=U(),D=j(),p=H(),N=function(c){u.__extends(i,c);function i(t){var e=c.call(this,t)||this;return e.echarts=t.echarts,e.ele=null,e.isInitialResize=!0,e.eventHandlerRefs={},e}return i.prototype.componentDidMount=function(){this.renderNewEcharts()},i.prototype.componentDidUpdate=function(t){var e=this.props.shouldSetOption;if(!((0,E.isFunction)(e)&&!e(t,this.props))){if(!(0,p.isEqual)(t.theme,this.props.theme)||!(0,p.isEqual)(t.opts,this.props.opts)){this.dispose(),this.renderNewEcharts();return}var n=this.getEchartsInstance();(0,p.isEqual)(t.onEvents,this.props.onEvents)||(this.unbindEvents(n),this.bindEvents(n,this.props.onEvents));var r=["option","notMerge","replaceMerge","lazyUpdate","showLoading","loadingOption"];(0,p.isEqual)((0,w.pick)(this.props,r),(0,w.pick)(t,r))||this.updateEChartsOption(),(!(0,p.isEqual)(t.style,this.props.style)||!(0,p.isEqual)(t.className,this.props.className))&&this.resize()}},i.prototype.componentWillUnmount=function(){this.dispose()},i.prototype.initEchartsInstance=function(){return u.__awaiter(this,void 0,void 0,function(){var t=this;return u.__generator(this,function(e){return[2,new Promise(function(n){t.echarts.init(t.ele,t.props.theme,t.props.opts);var r=t.getEchartsInstance();r.on("finished",function(){var s=t.ele.clientWidth,o=t.ele.clientHeight;t.echarts.dispose(t.ele);var a=u.__assign({width:s,height:o},t.props.opts);n(t.echarts.init(t.ele,t.props.theme,a))})})]})})},i.prototype.getEchartsInstance=function(){return this.echarts.getInstanceByDom(this.ele)},i.prototype.dispose=function(){if(this.ele){try{(0,m.clear)(this.ele)}catch(t){console.warn(t)}this.echarts.dispose(this.ele)}},i.prototype.renderNewEcharts=function(){return u.__awaiter(this,void 0,void 0,function(){var t,e,n,r,s,o,a=this;return u.__generator(this,function(h){switch(h.label){case 0:return t=this.props,e=t.onEvents,n=t.onChartReady,r=t.autoResize,s=r===void 0?!0:r,[4,this.initEchartsInstance()];case 1:return h.sent(),o=this.updateEChartsOption(),this.bindEvents(o,e||{}),(0,E.isFunction)(n)&&n(o),this.ele&&s&&(0,m.bind)(this.ele,function(){a.resize()}),[2]}})})},i.prototype.bindEvents=function(t,e){var n=this,r=function(o,a){if((0,D.isString)(o)&&(0,E.isFunction)(a)){var h=function(g){a(g,t)};t.on(o,h),n.eventHandlerRefs[o]=h}};for(var s in e)Object.prototype.hasOwnProperty.call(e,s)&&r(s,e[s])},i.prototype.unbindEvents=function(t){for(var e=0,n=Object.entries(this.eventHandlerRefs);e<n.length;e++){var r=n[e],s=r[0],o=r[1];t.off(s,o)}this.eventHandlerRefs={}},i.prototype.updateEChartsOption=function(){var t=this.props,e=t.option,n=t.notMerge,r=n===void 0?!1:n,s=t.replaceMerge,o=s===void 0?null:s,a=t.lazyUpdate,h=a===void 0?!1:a,g=t.showLoading,y=t.loadingOption,S=y===void 0?null:y,_=this.getEchartsInstance();return _.setOption(e,{notMerge:r,replaceMerge:o,lazyUpdate:h}),g?_.showLoading(S):_.hideLoading(),_},i.prototype.resize=function(){var t=this.getEchartsInstance();if(!this.isInitialResize)try{t.resize({width:"auto",height:"auto"})}catch(e){console.warn(e)}this.isInitialResize=!1},i.prototype.render=function(){var t=this,e=this.props,n=e.style,r=e.className,s=r===void 0?"":r;e.echarts,e.option,e.theme,e.notMerge,e.replaceMerge,e.lazyUpdate,e.showLoading,e.loadingOption,e.opts,e.onChartReady,e.onEvents,e.shouldSetOption,e.autoResize;var o=u.__rest(e,["style","className","echarts","option","theme","notMerge","replaceMerge","lazyUpdate","showLoading","loadingOption","opts","onChartReady","onEvents","shouldSetOption","autoResize"]),a=u.__assign({height:300},n);return R.default.createElement("div",u.__assign({ref:function(h){t.ele=h},style:a,className:"echarts-for-react ".concat(s)},o))},i}(R.PureComponent),P=z.default=N;export{P as _};
