import{U as g}from"./AnimatedNumber.699a3d23.js";import{_ as m}from"./_plugin-vue_export-helper.eefbdd86.js";import{f as n,i as s,B as b,aq as c,j as a,M as i,O as d,ad as k,a0 as x,R as w,Q as v,U as C,P as h}from"./vendor-vue-ui.7850d25d.js";const L={emits:["resize"],props:{targetLineCount:{default:1,type:Number},unit:{default:"px",type:String},min:{default:12,type:Number},max:{default:36,type:Number},constrainToElement:{type:[Boolean,Element],default(){return!1}},elementPadding:{type:Number,default(){return 0}}},data(){return{observer:null}},methods:{calculate(){const e=this.$el,o=this.unit==="px"?1:.05;let t=this.max;if(e.style.display="inline-block",e.style.lineHeight="1px",e.style.fontSize=t+this.unit,this.constrainToElement)for(;e.offsetWidth>this.constrainToElement.offsetWidth-this.elementPadding&&t>this.min;)t-=o,e.style.fontSize=t+this.unit;else for(;e.offsetHeight>this.targetLineCount&&t>this.min;)t-=o,e.style.fontSize=t+this.unit;this.$emit("resize",{size:t,unit:this.unit}),e.style.display=null,e.style.lineHeight=null}},mounted(){this.calculate(),"MutationObserver"in window&&this.observer===null&&(this.observer=new MutationObserver(this.calculate),this.observer.observe(this.$el,{subtree:!0,characterData:!0})),window.addEventListener("resize",this.calculate)},beforeUnmount:function(){this.observer.disconnect(),window.removeEventListener("resize",this.calculate)}};function M(e,o,t,_,f,l){return n(),s("span",null,[b(e.$slots,"default")])}const T=m(L,[["render",M]]),z={components:{UtilAnimatedNumber:g,UtilFitText:T},props:{parts:{type:Array,required:!0},label:{type:String,required:!0},total:{type:Number,required:!0},animatedNumber:{type:Boolean,default(){return!0}},maxTotal:{type:String,required:!1},isLabelColored:{type:Boolean,default(){return!1}}},computed:{getColorClass(){if(!this.maxTotal)return"";switch(!0){case 33>=this.total:return"red";case 66>=this.total:return"orange";default:return"green"}},getClass(){return`total-container-large ${this.getColorClass}`}}},N={class:"aioseo-donut-chart"},B={key:0,viewBox:"0 0 33.83098862 33.83098862",xmlns:"http://www.w3.org/2000/svg"},S={key:1,viewBox:"0 0 33.83098862 33.83098862",xmlns:"http://www.w3.org/2000/svg"},F=["stroke-dasharray"],E=["stroke","stroke-dasharray"],H={class:"total-amount-wrapper"},$={class:"total-amount"},U={class:"total"},q=["innerHTML"],A={key:2,class:"total-max"},P=["innerHTML"];function D(e,o,t,_,f,l){const y=c("util-animated-number"),p=c("util-fit-text");return n(),s("div",N,[t.total===0?(n(),s("svg",B,[...o[0]||(o[0]=[a("circle",{class:"aioseo-donut-chart-score__circle",stroke:"#e8e8eb","stroke-dasharray":"100","stroke-linecap":"round","stroke-width":2,fill:"none",cx:"16.91549431",cy:"16.91549431",r:"15.91549431"},null,-1)])])):i("",!0),0<t.total?(n(),s("svg",S,[(n(!0),s(d,null,k(t.parts,(r,u)=>(n(),s(d,{key:u},[Math.round(r.ratio)&&u!==0?(n(),s("circle",{key:0,class:"aioseo-donut-chart-score__circle",stroke:"#FFFFFF","stroke-dasharray":`${Math.round(r.ratio)} ${parseFloat(99-Math.round(r.ratio))}`,"stroke-linecap":"round","stroke-width":2.5,fill:"none",cx:"16.91549431",cy:"16.91549431",r:"15.91549431"},null,8,F)):i("",!0),Math.round(r.ratio)?(n(),s("circle",{key:1,class:"aioseo-donut-chart-score__circle",stroke:r.color,"stroke-dasharray":`${Math.round(r.ratio)===100?100:Math.round(r.ratio)-1} 100`,"stroke-linecap":"round","stroke-width":2,fill:"none",cx:"16.91549431",cy:"16.91549431",r:"15.91549431"},null,8,E)):i("",!0)],64))),128))])):i("",!0),a("div",H,[a("div",$,[a("div",U,[x(p,{max:32,"constrain-to-element":e.$el,class:h(["total-container",l.getClass])},{default:w(()=>[t.animatedNumber?(n(),v(y,{key:0,number:parseInt(t.total)},null,8,["number"])):(n(),s("div",{key:1,innerHTML:parseInt(t.total)},null,8,q)),t.maxTotal?(n(),s("span",A," / "+C(parseInt(t.maxTotal)),1)):i("",!0)]),_:1},8,["constrain-to-element","class"])]),a("div",{class:h(["label",{[l.getColorClass]:t.isLabelColored}]),innerHTML:t.label},null,10,P)])])])}const R=m(z,[["render",D]]);export{R as C};
