import{_ as h,$ as x,a3 as X,b4 as b,b5 as O,b6 as S,b7 as D,b8 as y}from"./index-C9vqJYWU.js";import{e as T,d as w}from"./endOfMonth-RDioccRl.js";function M(n,s){const r=+h(n)-+h(s);return r<0?-1:r>0?1:r}function _(n){return x(n,Date.now())}function N(n){return s=>{const a=(n?Math[n]:Math.trunc)(s);return a===0?0:a}}function Y(n,s){return+h(n)-+h(s)}function p(n,s){const r=h(n,s?.in);return r.setHours(23,59,59,999),r}function v(n,s){const r=h(n,s?.in);return+p(r,s)==+T(r,s)}function z(n,s,r){const[a,t,c]=X(r?.in,n,n,s),f=M(t,c),e=Math.abs(w(t,c));if(e<1)return 0;t.getMonth()===1&&t.getDate()>27&&t.setDate(30),t.setMonth(t.getMonth()-f*e);let u=M(t,c)===-f;v(a)&&e===1&&M(a,c)===1&&(u=!1);const l=f*(e-+u);return l===0?0:l}function A(n,s,r){const a=Y(n,s)/1e3;return N(r?.roundingMethod)(a)}function H(n,s,r){const a=y(),t=r?.locale??a.locale??O,c=2520,f=M(n,s);if(isNaN(f))throw new RangeError("Invalid time value");const e=Object.assign({},r,{addSuffix:r?.addSuffix,comparison:f}),[u,l]=X(r?.in,...f>0?[s,n]:[n,s]),d=A(l,u),I=(b(l)-b(u))/1e3,o=Math.round((d-I)/60);let m;if(o<2)return r?.includeSeconds?d<5?t.formatDistance("lessThanXSeconds",5,e):d<10?t.formatDistance("lessThanXSeconds",10,e):d<20?t.formatDistance("lessThanXSeconds",20,e):d<40?t.formatDistance("halfAMinute",0,e):d<60?t.formatDistance("lessThanXMinutes",1,e):t.formatDistance("xMinutes",1,e):o===0?t.formatDistance("lessThanXMinutes",1,e):t.formatDistance("xMinutes",o,e);if(o<45)return t.formatDistance("xMinutes",o,e);if(o<90)return t.formatDistance("aboutXHours",1,e);if(o<S){const i=Math.round(o/60);return t.formatDistance("aboutXHours",i,e)}else{if(o<c)return t.formatDistance("xDays",1,e);if(o<D){const i=Math.round(o/S);return t.formatDistance("xDays",i,e)}else if(o<D*2)return m=Math.round(o/D),t.formatDistance("aboutXMonths",m,e)}if(m=z(l,u),m<12){const i=Math.round(o/D);return t.formatDistance("xMonths",i,e)}else{const i=m%12,g=Math.trunc(m/12);return i<3?t.formatDistance("aboutXYears",g,e):i<9?t.formatDistance("overXYears",g,e):t.formatDistance("almostXYears",g+1,e)}}function R(n,s){return H(n,_(n),s)}export{R as f};
