import{C as e,S as t,_ as n,f as r,g as i,l as a,p as o,v as s}from"./format-Bks1Ebcz.js";function c(e,t){let r=+n(e)-n(t);return r<0?-1:r>0?1:r}function l(e){return s(e,Date.now())}function u(e,t,n){let[i,a]=r(n?.in,e,t),o=i.getFullYear()-a.getFullYear(),s=i.getMonth()-a.getMonth();return o*12+s}function d(e){return t=>{let n=(e?Math[e]:Math.trunc)(t);return n===0?0:n}}function f(e,t){return+n(e)-n(t)}function p(e,t){let r=n(e,t?.in);return r.setHours(23,59,59,999),r}function m(e,t){let r=n(e,t?.in),i=r.getMonth();return r.setFullYear(r.getFullYear(),i+1,0),r.setHours(23,59,59,999),r}function h(e,t){let r=n(e,t?.in);return+p(r,t)==+m(r,t)}function g(e,t,n){let[i,a,o]=r(n?.in,e,e,t),s=c(a,o),l=Math.abs(u(a,o));if(l<1)return 0;a.getMonth()===1&&a.getDate()>27&&a.setDate(30),a.setMonth(a.getMonth()-s*l);let d=c(a,o)===-s;h(i)&&l===1&&c(i,o)===1&&(d=!1);let f=s*(l-+d);return f===0?0:f}function _(e,t,n){let r=f(e,t)/1e3;return d(n?.roundingMethod)(r)}function v(n,s,l){let u=i(),d=l?.locale??u.locale??a,f=c(n,s);if(isNaN(f))throw RangeError(`Invalid time value`);let p=Object.assign({},l,{addSuffix:l?.addSuffix,comparison:f}),[m,h]=r(l?.in,...f>0?[s,n]:[n,s]),v=_(h,m),y=(o(h)-o(m))/1e3,b=Math.round((v-y)/60),x;if(b<2)return l?.includeSeconds?v<5?d.formatDistance(`lessThanXSeconds`,5,p):v<10?d.formatDistance(`lessThanXSeconds`,10,p):v<20?d.formatDistance(`lessThanXSeconds`,20,p):v<40?d.formatDistance(`halfAMinute`,0,p):v<60?d.formatDistance(`lessThanXMinutes`,1,p):d.formatDistance(`xMinutes`,1,p):b===0?d.formatDistance(`lessThanXMinutes`,1,p):d.formatDistance(`xMinutes`,b,p);if(b<45)return d.formatDistance(`xMinutes`,b,p);if(b<90)return d.formatDistance(`aboutXHours`,1,p);if(b<1440){let e=Math.round(b/60);return d.formatDistance(`aboutXHours`,e,p)}if(b<2520)return d.formatDistance(`xDays`,1,p);if(b<43200){let e=Math.round(b/t);return d.formatDistance(`xDays`,e,p)}if(b<86400)return x=Math.round(b/e),d.formatDistance(`aboutXMonths`,x,p);if(x=g(h,m),x<12){let t=Math.round(b/e);return d.formatDistance(`xMonths`,t,p)}{let e=x%12,t=Math.trunc(x/12);return e<3?d.formatDistance(`aboutXYears`,t,p):e<9?d.formatDistance(`overXYears`,t,p):d.formatDistance(`almostXYears`,t+1,p)}}function y(e,t){return v(e,l(e),t)}export{l as n,y as t};