import{useState as e,useEffect as t,useMemo as r}from"react";let l=e=>new Date(e).getTime()-new Date().getTime(),n=r=>{let[n,o]=e(l(r));return t(()=>{let e=null;return n>0&&(e=setInterval(()=>{n>0?o(l(r)):e&&(clearInterval(e),e=null)},1e3)),()=>{e&&clearInterval(e)}},[n,r]),t(()=>{o(l(r))},[r]),a(n)},a=e=>{let t=Math.floor(e/6e4),r=Math.floor(e%6e4/1e3),l=`${t<10?"0":""}${t}:${r<10?"0":""}${r}`;return{isExpired:t+r<=0,format:l}},o=e=>{let{isExpired:t,expiredText:l,conditionText:n,format:a}=e,o=r(()=>t?l:`${n} <span dir="ltr">${a}</span>`,[t,a,n,l]);return{text:o}};export{n as useCountdown,o as useGetTextExpired};
