const g=[["Y",31536e6],["M",2592e6],["D",864e5],["H",36e5],["m",6e4],["s",1e3],["S",1]];function d(r,n){let o=r;const t=/\[[^\]]*\]/g,c=(n.match(t)||[]).map(e=>e.slice(1,-1)),a=n.replace(t,"[]"),u=g.reduce((e,[l,i])=>{if(e.includes(l)){const p=Math.floor(o/i);return o-=p*i,e.replace(new RegExp(`${l}+`,"g"),m=>{const f=m.length;return p.toString().padStart(f,"0")})}return e},a);let s=0;return u.replace(t,()=>{const e=c[s];return s+=1,e})}function x(r,n){const{format:o=""}=n,t=new Date(r).getTime(),c=Date.now(),a=Math.max(t-c,0);return d(a,o)}export{x as formatCountdown,d as formatTimeStr};
