"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const n=require("vue"),p=require("../_util/omit.js"),C=require("../_util/props-util/initDefaultProps.js"),T=require("../_util/type.js"),m=require("./Statistic.js"),D=require("./utils.js"),S=1e3/30;function u(e){return new Date(e).getTime()}const l=()=>({...m.statisticProps(),value:T.someType([Number,String,Object]),format:String,onFinish:Function,onChange:Function}),h=n.defineComponent({compatConfig:{MODE:3},name:"AStatisticCountdown",props:C.default(l(),{format:"HH:mm:ss"}),setup(e,{emit:s,slots:f}){const o=n.ref(),i=n.ref(),a=()=>{const{value:t}=e;u(t)>=Date.now()?d():c()},d=()=>{if(o.value)return;const t=u(e.value);o.value=setInterval(()=>{i.value.$forceUpdate(),t>Date.now()&&s("change",t-Date.now()),a()},S)},c=()=>{const{value:t}=e;o.value&&(clearInterval(o.value),o.value=void 0,u(t)<Date.now()&&s("finish"))},v=({value:t,config:r})=>{const{format:g}=e;return D.formatCountdown(t,{...r,format:g})},w=t=>t;return n.onMounted(()=>{a()}),n.onUpdated(()=>{a()}),n.onBeforeUnmount(()=>{c()}),()=>{const t=e.value;return n.createVNode(m.default,{ref:i,...p.default(e,["onFinish","onChange"]),value:t,valueRender:w,formatter:v},f)}}});exports.countdownProps=l;exports.default=h;
