import{a as e}from"./rolldown-runtime.BRE-HNa9.js";import{i as t}from"./nc-main-C6OeyNBF.js";import{t as n}from"./nc-echart.DAizfQkX.js";import{t as r}from"./element-resize-detector.CBKJ7I8g.js";import{createElementBlock as i,inject as a,onActivated as o,onBeforeUnmount as s,onMounted as c,openBlock as l,ref as u,watch as d}from"/vue.js";var f=e(r()),p=`legendselectchanged.legendselected.legendunselected.legendunscroll.datazoom.datarangeselected.timelinechanged.timelineplaychanged.restore.dataviewchanged.magictypechanged.geoselectchanged.geoselected.geounselected.pieselectchanged.pieselected.pieunselected.mapselectchanged.mapselected.mapunselected.axisareaselected.focusnodeadjacency.unfocusnodeadjacency.brush.brushselected.rendered.finished.click.dblclick.mouseover.mouseout.mousedown.mouseup.globalout`.split(`.`),m=Object.assign({name:`NcChart`},{__name:`nc-chart`,props:{options:{type:[Object],required:!1},initOptions:{type:[Object],required:!1,default:void 0},theme:{type:[String,Object],default:`light`},group:{type:String,default:void 0},autoResize:{type:Boolean,default:!0},update:{type:Number,default:void 0}},emits:p,setup(e,{emit:r}){console.debug(`* nc-chart lazy-loaded`);let m=u(null),h=a(`state`),g,_,v,y=r,b=e;function x(e){if(e){g||S();try{g.setOption(e||{},!0)}catch(e){t.setError(h,`echarts watch option, set option failed with error '${e}'`)}}}c(function(){b.options&&S(),d(()=>b.options,e=>{x(e)}),d(()=>b.update,()=>{x(b.options)})}),o(function(){b.autoResize&&g&&g.resize()}),s(()=>{_&&_.uninstall(m.value),_=null,g&&g.dispose(),g=null});function S(){if(!g){v=b.manualOptions;try{g=n.init(m.value,b.theme,b.initOptions||{})}catch(e){t.setError(h,`echarts init failed with error '${e}'`)}b.group&&(g.group=b.group);try{g.setOption(v||b.options||{},!0)}catch(e){t.setError(h,`echarts set option failed with error '${e}'`)}setTimeout(()=>{_=(0,f.default)({}),_.listenTo(m.value,()=>{g&&g.resize&&g.resize()})},100),p.forEach(e=>{g.on(e,t=>{y(e,t)})}),Object.defineProperties(b,{width:{configurable:!0,get:()=>C(`width`,`getWidth`)},height:{configurable:!0,get:()=>C(`height`,`getHeight`)},isDisposed:{configurable:!0,get:()=>!!C(`isDisposed`,`isDisposed`)},computedOptions:{configurable:!0,get:()=>C(`computedOptions`,`getOption`)}})}}function C(e,t){return g||S(),g[t]()}return(e,t)=>(l(),i(`div`,{class:`nc-chart`,ref_key:`chartElem`,ref:m},null,512))}});export{m as default};