import{e as d}from"./index-B9e-dLML.js";import{u as h,d as w,b as g,h as f,w as m,j as x,$ as _,Q as k,o as y,c as z,q as T,aS as C}from"./index-DO6SfH87.js";var p;const B=typeof window<"u";B&&((p=window==null?void 0:window.navigator)!=null&&p.userAgent)&&/iP(ad|hone|od)/.test(window.navigator.userAgent);function b(r,i){function e(...t){r(()=>i.apply(this,t),{fn:i,thisArg:this,args:t})}return e}function R(r,i={}){let e,t;return n=>{const o=h(r),a=h(i.maxWait);if(e&&clearTimeout(e),o<=0||a!==void 0&&a<=0)return t&&(clearTimeout(t),t=null),n();a&&!t&&(t=setTimeout(()=>{e&&clearTimeout(e),t=null,n()},a)),e=setTimeout(()=>{t&&clearTimeout(t),t=null,n()},o)}}function A(r,i=200,e={}){return b(R(i,e),r)}const I=w({__name:"index",props:{option:{},renderer:{default:"canvas"},resize:{type:Boolean,default:!0},theme:{},width:{},height:{},onClick:{}},setup(r,{expose:i}){const e=r,t=g(()=>e.width||e.height?{height:e.height+"px",width:e.width+"px"}:{height:"100%",width:"100%"}),u=f(),n=f(),o=()=>{n.value&&n.value.setOption(e.option,{notMerge:!0})};m(e,()=>{o()}),m(()=>e.option,s=>{o()},{deep:!0});const a=s=>e.onClick&&e.onClick(s),v=()=>{u.value&&(n.value=d.getInstanceByDom(u.value),n.value||(n.value=C(d.init(u.value,e.theme,{renderer:e.renderer})),n.value.on("click",a),o()))},l=()=>{n.value&&e.resize&&n.value.resize({animation:{duration:300}})},c=A(l,300,{maxWait:800});return x(()=>{_(()=>v()),window.addEventListener("resize",c)}),k(()=>{var s;(s=n.value)==null||s.dispose(),window.removeEventListener("resize",c)}),i({getInstance:()=>n.value,resize:l,draw:o}),(s,D)=>(y(),z("div",{id:"echarts",ref_key:"chartRef",ref:u,style:T(t.value)},null,4))}});export{I as _};
