import { b as getDefaultExportFromCjs, r as requireDayjs_min, i as i18n, g as getLocale, d as dayjs } from './store.js';

var relativeTime$2 = {exports: {}};

var relativeTime$1 = relativeTime$2.exports;

var hasRequiredRelativeTime;

function requireRelativeTime () {
	if (hasRequiredRelativeTime) return relativeTime$2.exports;
	hasRequiredRelativeTime = 1;
	(function (module, exports) {
		!function(r,e){module.exports=e();}(relativeTime$1,(function(){return function(r,e,t){r=r||{};var n=e.prototype,o={future:"in %s",past:"%s ago",s:"a few seconds",m:"a minute",mm:"%d minutes",h:"an hour",hh:"%d hours",d:"a day",dd:"%d days",M:"a month",MM:"%d months",y:"a year",yy:"%d years"};function i(r,e,t,o){return n.fromToBase(r,e,t,o)}t.en.relativeTime=o,n.fromToBase=function(e,n,i,d,u){for(var f,a,s,l=i.$locale().relativeTime||o,h=r.thresholds||[{l:"s",r:44,d:"second"},{l:"m",r:89},{l:"mm",r:44,d:"minute"},{l:"h",r:89},{l:"hh",r:21,d:"hour"},{l:"d",r:35},{l:"dd",r:25,d:"day"},{l:"M",r:45},{l:"MM",r:10,d:"month"},{l:"y",r:17},{l:"yy",d:"year"}],m=h.length,c=0;c<m;c+=1){var y=h[c];y.d&&(f=d?t(e).diff(i,y.d,true):i.diff(e,y.d,true));var p=(r.rounding||Math.round)(Math.abs(f));if(s=f>0,p<=y.r||!y.r){p<=1&&c>0&&(y=h[c-1]);var v=l[y.l];u&&(p=u(""+p)),a="string"==typeof v?v.replace("%d",p):v(p,n,y.l,s);break}}if(n)return a;var M=s?l.future:l.past;return "function"==typeof M?M(a):M.replace("%s",a)},n.to=function(r,e){return i(r,e,this,true)},n.from=function(r,e){return i(r,e,this)};var d=function(r){return r.$u?t.utc():t()};n.toNow=function(r){return this.to(d(this),r)},n.fromNow=function(r){return this.from(d(this),r)};}})); 
	} (relativeTime$2));
	return relativeTime$2.exports;
}

var relativeTimeExports = requireRelativeTime();
var relativeTime = /*@__PURE__*/getDefaultExportFromCjs(relativeTimeExports);

var nl$1 = {exports: {}};

var nl = nl$1.exports;

var hasRequiredNl;

function requireNl () {
	if (hasRequiredNl) return nl$1.exports;
	hasRequiredNl = 1;
	(function (module, exports) {
		!function(e,a){module.exports=a(requireDayjs_min());}(nl,(function(e){function a(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var d=a(e),n={name:"nl",weekdays:"zondag_maandag_dinsdag_woensdag_donderdag_vrijdag_zaterdag".split("_"),weekdaysShort:"zo._ma._di._wo._do._vr._za.".split("_"),weekdaysMin:"zo_ma_di_wo_do_vr_za".split("_"),months:"januari_februari_maart_april_mei_juni_juli_augustus_september_oktober_november_december".split("_"),monthsShort:"jan_feb_mrt_apr_mei_jun_jul_aug_sep_okt_nov_dec".split("_"),ordinal:function(e){return "["+e+(1===e||8===e||e>=20?"ste":"de")+"]"},weekStart:1,yearStart:4,formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD-MM-YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd D MMMM YYYY HH:mm"},relativeTime:{future:"over %s",past:"%s geleden",s:"een paar seconden",m:"een minuut",mm:"%d minuten",h:"een uur",hh:"%d uur",d:"een dag",dd:"%d dagen",M:"een maand",MM:"%d maanden",y:"een jaar",yy:"%d jaar"}};return d.default.locale(n,null,true),n})); 
	} (nl$1));
	return nl$1.exports;
}

requireNl();

/**
 * Get relative time but prevent future timestamps from showing "in a few seconds"
 * This handles cases where server timestamps are slightly ahead of client time
 * due to clock synchronization differences or network latency
 */
const getSafeRelativeTime = (timestamp, locale) => {
    const currentLocale = getLocale(locale);
    if (timestamp === null ||
        timestamp === undefined ||
        (typeof timestamp === "number" && timestamp === 0) ||
        (typeof timestamp === "string" && timestamp === "")) {
        return i18n.t("ui:time.unknown", { lng: currentLocale });
    }
    const now = dayjs();
    const time = dayjs(timestamp);
    const secondsAgo = now.diff(time, "second");
    // If timestamp is in the future (within reasonable bounds),
    // or less than 60 seconds ago, show it as "Just now"
    // This prevents "in a few seconds" from appearing due to clock drift
    if (time.isAfter(now) || secondsAgo < 60) {
        return i18n.t("ui:time.just_now", { lng: currentLocale });
    }
    return time.locale(currentLocale).fromNow();
};

export { getSafeRelativeTime as g, relativeTime as r };
//# sourceMappingURL=safe-relative-time.js.map

//# sourceMappingURL=safe-relative-time.js.map