import{d as O}from"./debounce-Xd493GvO.js";import{r as b}from"./request-CEvu378m.js";import{ar as V,_ as w,Q as S,m as q}from"./echarts-DB130vfq.js";import{ax as T,s as $,r as x,l as j,c as h,w as g,j as K,n as P,X as B,B as W,z as E,u as F}from"./vue-BJk78QHK.js";import"./index-M_JNBppB.js";import"./element-3_pOinej.js";import"./utils-YI6ye1sf.js";import"./threejs-BafxXW5-.js";import"./vxe-Dx3zSILm.js";const J=Object.assign({name:"CalendarPie"},{__name:"CalendarPie",props:{propValue:{type:Object,default:()=>({})},request:{type:Object,default:()=>({})},element:{type:Object,default:()=>({})}},setup(z){const e=z,c=T(),l=$(null),d=x(null),v=x(0),s=j({cancelRequest:null,pieRadius:30,nextMonth:""}),f=h(()=>e.propValue.config.month),M=h(()=>{const t=e.element.style.width,a=e.element.style.height;return{width:t,height:a}}),i=h(()=>[e.element.style.width/7-10,e.element.style.height/5.5-30]);g(M,O(t=>{s.cancelRequest&&s.cancelRequest(),l.value&&l.value.clear(),v.value++,setTimeout(()=>{l.value=null,l.value=V(d.value,"vintage"),m()},500)},500),{deep:!0}),g(()=>e.propValue,t=>{m()},{deep:!0}),K(()=>{var t,a;e.request&&(s.cancelRequest=b(e.request,e.propValue,"config")),((a=(t=e.request)==null?void 0:t.global)==null?void 0:a.length)>0&&g(()=>c.state.globalKey,()=>{e.request.global.forEach(o=>{const r=c.state.globalKey.findIndex(n=>n.globalKey===o);if(r>-1){const n=[c.state.globalKey[r].globalKey,c.state.globalKey[r].globalValue],p=e.request.data.findIndex(u=>u[0]===n[0]);p>-1?e.request.data[p][1]=n[1]:e.request.data.push(n)}}),s.cancelRequest(),s.cancelRequest=b(e.request,e.propValue,"config")},{deep:!0}),l.value=V(d.value,"vintage"),P(()=>{m()}),window.addEventListener("resize",L)}),B(()=>{e.request&&s.cancelRequest(),l.value&&(l.value.clear(),l.value.dispose())});function R(){let t=new Date(f.value),a=t.setMonth(t.getMonth()+1);a=new Date(a);let o=a.getFullYear(),r=k(a.getMonth()+1);return a=`${o}-${r}`,a}function k(t){return t<10&&(t=`0${t}`),t}function _(){let t=+S(`${f.value}-01`),a=+S(`${R()}-01`),o=3600*24*1e3,r=[];for(let n=t;n<a;n+=o)r.push([w("yyyy-MM-dd",n),Math.floor(Math.random()*1e4)]);return r}function D(t,a){let o=[];return o=q(t,(r,n)=>{let p=a.convertToPixel("calendar",r);for(let u=0;u<e.propValue.config.data.length;u++){let y=e.propValue.config.data[u];if(y.time==r[0])return{id:`${n}pie`,type:"pie",center:p,label:{normal:{formatter:"{c}",position:"inside"}},radius:i.value[0]<=i.value[1]+20?i.value[0]/2-10:i.value[1]/2-10,data:y.data,color:e.propValue.config.color}}return!1}),o}function C(t,a){return q(t,(o,r)=>{const n=a.convertToPixel("calendar",o);return{id:`${r}pie`,center:n}})}function m(){if(!l.value)return;const t=_(),a={tooltip:{},legend:{data:e.propValue.config.legend,top:5,textStyle:{color:"#fff",fontSize:12,fontWeight:500}},calendar:{top:80,left:35,orient:"vertical",cellSize:i.value,yearLabel:{show:!1,textStyle:{fontSize:30}},dayLabel:{margin:20,firstDay:1,nameMap:["星期日","星期一","星期二","星期三","星期四","星期五","星期六"],show:!0,color:e.propValue.weekColor,fontSize:e.propValue.weekFontSize},monthLabel:{show:!1,textStyle:{fontSize:30}},range:[f.value],itemStyle:{borderColor:e.propValue.borderColor,color:e.propValue.background},splitLine:{lineStyle:{width:e.propValue.splitLineWidth,color:e.propValue.splitLinecolor}}},series:[{id:"label",type:"scatter",coordinateSystem:"calendar",symbolSize:1,label:{normal:{show:!0,formatter(o){return w("dd",o.value[0])},offset:[-i.value[0]/2+10,-i.value[1]/2+10],textStyle:{color:e.propValue.dayColor,fontSize:e.propValue.dayFontSize}}},data:t}]};if(l.value.setOption(a),!l.value.inNode){let o=!1;setTimeout(()=>{o=!0,l.value.setOption({series:D(t,l.value)})},10),l.value.on("resize",()=>{o&&l.value.setOption({series:C(t,l.value)})})}}function L(){l.value.resize()}return(t,a)=>(E(),W("div",{key:F(v),ref_key:"chartRef",ref:d,style:{width:"100%",height:"100%"}}))}});export{J as default};
