import{someType as e}from"../_util/type.mjs";import t from"../_util/omit.mjs";import n from"../_util/props-util/initDefaultProps.mjs";import r,{statisticProps as i}from"./Statistic.mjs";import{formatCountdown as a}from"./utils.mjs";import{createVNode as o,defineComponent as s,onBeforeUnmount as c,onMounted as l,onUpdated as u,ref as d}from"vue";var f=1e3/30;function p(e){return new Date(e).getTime()}var m=()=>({...i(),value:e([Number,String,Object]),format:String,onFinish:Function,onChange:Function}),h=s({compatConfig:{MODE:3},name:`AStatisticCountdown`,props:n(m(),{format:`HH:mm:ss`}),setup(e,{emit:n,slots:i}){let s=d(),m=d(),h=()=>{let{value:t}=e;p(t)>=Date.now()?g():_()},g=()=>{if(s.value)return;let t=p(e.value);s.value=setInterval(()=>{m.value.$forceUpdate(),t>Date.now()&&n(`change`,t-Date.now()),h()},f)},_=()=>{let{value:t}=e;s.value&&(clearInterval(s.value),s.value=void 0,p(t)<Date.now()&&n(`finish`))},v=({value:t,config:n})=>{let{format:r}=e;return a(t,{...n,format:r})},y=e=>e;return l(()=>{h()}),u(()=>{h()}),c(()=>{_()}),()=>{let n=e.value;return o(r,{ref:m,...t(e,[`onFinish`,`onChange`]),value:n,valueRender:y,formatter:v},i)}}});export{m as countdownProps,h as default};