index.9227cf35.js 1.1 KB

1
  1. import{a7 as u,t as r,w as S,u as m,v as p,d as h,a8 as D,y as w,Z as v,W as H,c as C,D as g}from"./index.332c7f08.js";function P(e,n){const{days:i}=n;let{hours:s,minutes:c,seconds:l,milliseconds:t}=n;if(e.includes("DD")?e=e.replace("DD",u(i)):s+=i*24,e.includes("HH")?e=e.replace("HH",u(s)):c+=s*60,e.includes("mm")?e=e.replace("mm",u(c)):l+=c*60,e.includes("ss")?e=e.replace("ss",u(l)):t+=l*1e3,e.includes("S")){const a=u(t,3);e.includes("SSS")?e=e.replace("SSS",a):e.includes("SS")?e=e.replace("SS",a.slice(0,2)):e=e.replace("S",a.charAt(0))}return e}const[x,N]=r("count-down"),k={time:S(0),format:m("HH:mm:ss"),autoStart:p,millisecond:Boolean};var y=h({name:x,props:k,emits:["change","finish"],setup(e,{emit:n,slots:i}){const{start:s,pause:c,reset:l,current:t}=D({time:+e.time,millisecond:e.millisecond,onChange:o=>n("change",o),onFinish:()=>n("finish")}),a=w(()=>P(e.format,t.value)),d=()=>{l(+e.time),e.autoStart&&s()};return v(()=>e.time,d,{immediate:!0}),H({start:s,pause:c,reset:d}),()=>C("div",{role:"timer",class:N()},[i.default?i.default(t.value):a.value])}});const Z=g(y);export{Z as C};