var e=1e3,t=6e4,n=36e5,r=864e5,i=new Intl.DateTimeFormat(void 0,{hour:`numeric`,minute:`2-digit`}),a=new Intl.DateTimeFormat(void 0,{day:`numeric`,hour:`numeric`,minute:`2-digit`,month:`short`}),o=new Intl.DateTimeFormat(void 0,{dateStyle:`medium`,timeStyle:`short`}),s=new Intl.DateTimeFormat(void 0,{day:`numeric`,month:`short`,year:`numeric`}),c=new Intl.DateTimeFormat(void 0,{month:`long`}),l=new Intl.DateTimeFormat(void 0,{month:`long`,year:`numeric`}),u=new Intl.RelativeTimeFormat(void 0,{numeric:`auto`,style:`short`});function d(i,a=Date.now()){let o=i-a,s=Math.abs(o),c=o<0?-1:1;return s<6e4?u.format(c*Math.round(s/e),`second`):s<36e5?u.format(c*Math.round(s/t),`minute`):s<864e5?u.format(c*Math.round(s/n),`hour`):u.format(c*Math.round(s/r),`day`)}var f=e=>{let t=new Date(e);return new Date(t.getFullYear(),t.getMonth(),t.getDate()).getTime()},p=e=>f(e-4*n);function m(){try{let e=new Intl.Locale(new Intl.DateTimeFormat().resolvedOptions().locale),t=(e.getWeekInfo?.()??e.weekInfo)?.firstDay;return typeof t==`number`?t%7:1}catch{return 1}}function h(e,t){let n=new Date(f(e)),r=(n.getDay()-t+7)%7;return new Date(n.getFullYear(),n.getMonth(),n.getDate()-r).getTime()}function g(t,n=Date.now(),i=m()){let a=p(t*e),o=p(n),s=Math.round((o-a)/r);if(s<=0)return{at:a,key:`today`,kind:`today`};if(s===1)return{at:a,key:`yesterday`,kind:`yesterday`};let c=h(o,i);if(a>=c)return{at:a,key:`this-week`,kind:`thisWeek`};let l=new Date(c);if(a>=new Date(l.getFullYear(),l.getMonth(),l.getDate()-7).getTime())return{at:a,key:`last-week`,kind:`lastWeek`};let u=new Date(a),d=new Date(o),f=u.getFullYear()===d.getFullYear();if(f&&u.getMonth()===d.getMonth())return{at:a,key:`this-month`,kind:`thisMonth`};let g=`${u.getFullYear()}-${u.getMonth()}`;return f?{at:a,key:`m-${g}`,kind:`month`}:{at:a,key:`my-${g}`,kind:`monthYear`}}function _(e,t){switch(e.kind){case`today`:return t.today;case`yesterday`:return t.yesterday;case`thisWeek`:return t.thisWeek;case`lastWeek`:return t.lastWeek;case`thisMonth`:return t.thisMonth;case`month`:return c.format(e.at);case`monthYear`:return l.format(e.at)}}function v(i){let a=Math.max(0,i);return a>=864e5?{unit:`day`,value:Math.floor(a/r)}:a>=36e5?{unit:`hour`,value:Math.floor(a/n)}:a>=6e4?{unit:`minute`,value:Math.floor(a/t)}:{unit:`second`,value:Math.floor(a/e)}}export{v as a,o as c,d,_ as f,g as i,a as l,t as n,i as o,e as r,s,n as t,m as u};