import{U as b}from"./AnimatedNumber.cc7d07cd.js";import{_ as m}from"./_plugin-vue_export-helper.eefbdd86.js";import{o as n,c as s,q as g,x as u,b as r,G as d,N as k,a,H as x,m as w,l as v,t as C,K as h}from"./runtime-dom.esm-bundler.5d5e6b71.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,i=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-=i,e.style.fontSize=t+this.unit;else for(;e.offsetHeight>this.targetLineCount&&t>this.min;)t-=i,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,i,t,_,f,l){return n(),s("span",null,[g(e.$slots,"default")])}const N=m(L,[["render",M]]),T={components:{UtilAnimatedNumber:b,UtilFitText:N},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}`}}},z={class:"aioseo-donut-chart"},S={key:0,viewBox:"0 0 33.83098862 33.83098862",xmlns:"http://www.w3.org/2000/svg"},B=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),F=[B],H={key:1,viewBox:"0 0 33.83098862 33.83098862",xmlns:"http://www.w3.org/2000/svg"},E=["stroke-dasharray"],$=["stroke","stroke-dasharray"],q={class:"total-amount-wrapper"},A={class:"total-amount"},U={class:"total"},D=["innerHTML"],I={key:2,class:"total-max"},P=["innerHTML"];function V(e,i,t,_,f,l){const y=u("util-animated-number"),p=u("util-fit-text");return n(),s("div",z,[t.total===0?(n(),s("svg",S,F)):r("",!0),0<t.total?(n(),s("svg",H,[(n(!0),s(d,null,k(t.parts,(o,c)=>(n(),s(d,{key:c},[Math.round(o.ratio)&&c!==0?(n(),s("circle",{key:0,class:"aioseo-donut-chart-score__circle",stroke:"#FFFFFF","stroke-dasharray":`${Math.round(o.ratio)} ${parseFloat(99-Math.round(o.ratio))}`,"stroke-linecap":"round","stroke-width":2.5,fill:"none",cx:"16.91549431",cy:"16.91549431",r:"15.91549431"},null,8,E)):r("",!0),Math.round(o.ratio)?(n(),s("circle",{key:1,class:"aioseo-donut-chart-score__circle",stroke:o.color,"stroke-dasharray":`${Math.round(o.ratio)===100?100:Math.round(o.ratio)-1} 100`,"stroke-linecap":"round","stroke-width":2,fill:"none",cx:"16.91549431",cy:"16.91549431",r:"15.91549431"},null,8,$)):r("",!0)],64))),128))])):r("",!0),a("div",q,[a("div",A,[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,D)),t.maxTotal?(n(),s("span",I," / "+C(parseInt(t.maxTotal)),1)):r("",!0)]),_:1},8,["constrain-to-element","class"])]),a("div",{class:h(["label",{[l.getColorClass]:t.isLabelColored}]),innerHTML:t.label},null,10,P)])])])}const K=m(T,[["render",V]]);export{K as C};
