import e from"../../_util/props-util/initDefaultProps.mjs";import t from"../../_util/hooks/useRefs.mjs";import{defaultProps as n,useTransitionDuration as r}from"./common.mjs";import{propTypes as i}from"./types.mjs";import{computed as a,createVNode as o,defineComponent as s,ref as c}from"vue";var l=0;function u(e){return+e.replace(`%`,``)}function d(e){return Array.isArray(e)?e:[e]}function f(e,t,n,r,i=0,a){let o=50-r/2,s=0,c=-o,l=0,u=-2*o;switch(a){case`left`:s=-o,c=0,l=2*o,u=0;break;case`right`:s=o,c=0,l=-2*o,u=0;break;case`bottom`:c=o,u=2*o;break;default:}let d=`M 50,50 m ${s},${c}
   a ${o},${o} 0 1 1 ${l},${-u}
   a ${o},${o} 0 1 1 ${-l},${u}`,f=Math.PI*2*o;return{pathString:d,pathStyle:{stroke:n,strokeDasharray:`${t/100*(f-i)}px ${f}px`,strokeDashoffset:`-${i/2+e/100*(f-i)}px`,transition:`stroke-dashoffset .3s ease 0s, stroke-dasharray .3s ease 0s, stroke .3s, stroke-width .06s ease .3s, opacity .3s ease 0s`}}}var p=s({compatConfig:{MODE:3},name:`VCCircle`,props:e(i,n),setup(e){l+=1;let n=c(l),i=a(()=>d(e.percent)),s=a(()=>d(e.strokeColor)),[p,m]=t();r(m);let h=()=>{let{prefixCls:t,strokeWidth:r,strokeLinecap:a,gapDegree:c,gapPosition:l}=e,u=0;return i.value.map((e,i)=>{let d=s.value[i]||s.value[s.value.length-1],m=Object.prototype.toString.call(d)===`[object Object]`?`url(#${t}-gradient-${n.value})`:``,{pathString:h,pathStyle:g}=f(u,e,d,r,c,l);u+=e;let _={key:i,d:h,stroke:m,"stroke-linecap":a,"stroke-width":r,opacity:e===0?0:1,"fill-opacity":`0`,class:`${t}-circle-path`,style:g};return o(`path`,{ref:p(i),..._},null)})};return()=>{let{prefixCls:t,strokeWidth:r,trailWidth:i,gapDegree:a,gapPosition:c,trailColor:l,strokeLinecap:d,strokeColor:p,...m}=e,{pathString:g,pathStyle:_}=f(0,100,l,r,a,c);delete m.percent;let v=s.value.find(e=>Object.prototype.toString.call(e)===`[object Object]`),y={d:g,stroke:l,"stroke-linecap":d,"stroke-width":i||r,"fill-opacity":`0`,class:`${t}-circle-trail`,style:_};return o(`svg`,{class:`${t}-circle`,viewBox:`0 0 100 100`,...m},[v&&o(`defs`,null,[o(`linearGradient`,{id:`${t}-gradient-${n.value}`,x1:`100%`,y1:`0%`,x2:`0%`,y2:`0%`},[Object.keys(v).sort((e,t)=>u(e)-u(t)).map((e,t)=>o(`stop`,{key:t,offset:e,"stop-color":v[e]},null))])]),o(`path`,y,null),h().reverse()])}}});export{p as default};