import{M as p,O as g,U as h,aF as T,N,S as A,Q as F,l as k,$ as O,f as n,bl as W,aH as v,bw as C,aB as x,X as I}from"./index-BV0H45HW.js";const[L,d]=F("circle");let _=0;const P=t=>Math.min(Math.max(+t,0),100);function G(t,c){const l=t?1:0;return`M ${c/2} ${c/2} m 0, -500 a 500, 500 0 1, ${l} 0, 1000 a 500, 500 0 1, ${l} 0, -1000`}const j={text:String,size:A,fill:g("none"),rate:h(100),speed:h(0),color:[String,Object],clockwise:N,layerColor:String,currentRate:T(0),strokeWidth:h(40),strokeLinecap:String,startPosition:g("top")};var z=p({name:L,props:j,emits:["update:currentRate"],setup(t,{emit:c,slots:l}){const R=`van-circle-${_++}`,f=k(()=>+t.strokeWidth+1e3),y=k(()=>G(t.clockwise,f.value)),$=k(()=>{const e={top:0,right:90,bottom:180,left:270}[t.startPosition];if(e)return{transform:`rotate(${e}deg)`}});O(()=>t.rate,r=>{let e;const s=Date.now(),a=t.currentRate,o=P(r),i=Math.abs((a-o)*1e3/+t.speed),u=()=>{const b=Date.now(),m=Math.min((b-s)/i,1)*(o-a)+a;c("update:currentRate",P(parseFloat(m.toFixed(1)))),(o>a?m<o:m>o)&&(e=x(u))};t.speed?(e&&C(e),e=x(u)):c("update:currentRate",o)},{immediate:!0});const E=()=>{const{strokeWidth:e,currentRate:s,strokeLinecap:a}=t,o=3140*s/100,i=v(t.color)?`url(#${R})`:t.color,u={stroke:i,strokeWidth:`${+e+1}px`,strokeLinecap:a,strokeDasharray:`${o}px 3140px`};return n("path",{d:y.value,style:u,class:d("hover"),stroke:i},null)},M=()=>{const r={fill:t.fill,stroke:t.layerColor,strokeWidth:`${t.strokeWidth}px`};return n("path",{class:d("layer"),style:r,d:y.value},null)},w=()=>{const{color:r}=t;if(!v(r))return;const e=Object.keys(r).sort((s,a)=>parseFloat(s)-parseFloat(a)).map((s,a)=>n("stop",{key:a,offset:s,"stop-color":r[s]},null));return n("defs",null,[n("linearGradient",{id:R,x1:"100%",y1:"0%",x2:"0%",y2:"0%"},[e])])},S=()=>{if(l.default)return l.default();if(t.text)return n("div",{class:d("text")},[t.text])};return()=>n("div",{class:d(),style:W(t.size)},[n("svg",{viewBox:`0 0 ${f.value} ${f.value}`,style:$.value},[w(),M(),E()]),S()])}});const H=I(z);export{H as C};
