import{f as S,r as x,e as O,g as A,t as l,h as E,i as h,j as b,k as U}from"./index-33b41d47.js";function w(o){return S({},o)}var T=1440,H=2520,D=43200,Y=86400;function j(o,u,n){var c,m;x(2,arguments);var I=U(),e=(c=(m=n==null?void 0:n.locale)!==null&&m!==void 0?m:I.locale)!==null&&c!==void 0?c:O;if(!e.formatDistance)throw new RangeError("locale must contain formatDistance property");var v=A(o,u);if(isNaN(v))throw new RangeError("Invalid time value");var a=S(w(n),{addSuffix:Boolean(n==null?void 0:n.addSuffix),comparison:v}),i,f;v>0?(i=l(u),f=l(o)):(i=l(o),f=l(u));var t=E(f,i),_=(h(f)-h(i))/1e3,r=Math.round((t-_)/60),s;if(r<2)return n!=null&&n.includeSeconds?t<5?e.formatDistance("lessThanXSeconds",5,a):t<10?e.formatDistance("lessThanXSeconds",10,a):t<20?e.formatDistance("lessThanXSeconds",20,a):t<40?e.formatDistance("halfAMinute",0,a):t<60?e.formatDistance("lessThanXMinutes",1,a):e.formatDistance("xMinutes",1,a):r===0?e.formatDistance("lessThanXMinutes",1,a):e.formatDistance("xMinutes",r,a);if(r<45)return e.formatDistance("xMinutes",r,a);if(r<90)return e.formatDistance("aboutXHours",1,a);if(r<T){var N=Math.round(r/60);return e.formatDistance("aboutXHours",N,a)}else{if(r<H)return e.formatDistance("xDays",1,a);if(r<D){var X=Math.round(r/T);return e.formatDistance("xDays",X,a)}else if(r<Y)return s=Math.round(r/D),e.formatDistance("aboutXMonths",s,a)}if(s=b(f,i),s<12){var g=Math.round(r/D);return e.formatDistance("xMonths",g,a)}else{var M=s%12,d=Math.floor(s/12);return M<3?e.formatDistance("aboutXYears",d,a):M<9?e.formatDistance("overXYears",d,a):e.formatDistance("almostXYears",d+1,a)}}export{j as f};
