"use strict";function e(e,t=2){for(e+="";e.length<t;)e="0"+e;return e.slice(-t)}const t={yyyy:t=>e(t.year,4),yy:t=>e(t.year),MM:t=>e(t.month),M:e=>e.month,dd:t=>e(t.day),d:e=>e.day,hh:t=>e(t.hour),h:e=>e.hour,mm:t=>e(t.minute),m:e=>e.minute,ss:t=>e(t.second),s:e=>e.second,SSS:t=>e(t.millisecond,3),S:e=>e.millisecond};function n(e){return e instanceof Date?e:"string"==typeof e?e.indexOf("T")>-1?new Date(e):new Date(e.replace(/-/g,"/")):new Date(e)}exports.friendlyDate=function(e,{locale:o="zh",threshold:r=[6e4,36e5],format:a="yyyy/MM/dd hh:mm:ss"}){if("-"===e)return e;if(!e&&0!==e)return"";const s={zh:{year:"年",month:"月",day:"天",hour:"小时",minute:"分钟",second:"秒",ago:"前",later:"后",justNow:"刚刚",soon:"马上",template:"{num}{unit}{suffix}"},en:{year:"year",month:"month",day:"day",hour:"hour",minute:"minute",second:"second",ago:"ago",later:"later",justNow:"just now",soon:"soon",template:"{num} {unit} {suffix}"}},u=s[o]||s.zh;let i,h,l=n(e),c=l.getTime()-Date.now(),y=Math.abs(c);if(y<r[0])return c<0?u.justNow:u.soon;if(y>=r[1])return function(e,o="yyyy/MM/dd hh:mm:ss"){if(!e&&0!==e)return"";const r={year:(e=n(e)).getFullYear(),month:e.getMonth()+1,day:e.getDate(),hour:e.getHours(),minute:e.getMinutes(),second:e.getSeconds(),millisecond:e.getMilliseconds()},a=/yyyy|yy|MM|M|dd|d|hh|h|mm|m|ss|s|SSS|SS|S/;let s=!0,u=o;for(;s;)s=!1,u=u.replace(a,(function(e){return s=!0,t[e](r)}));return u}(l,a);let m=u.later;c<0&&(m=u.ago,c=-c);const d=Math.floor(c/1e3),f=Math.floor(d/60),M=Math.floor(f/60),g=Math.floor(M/24),S=Math.floor(g/30),p=Math.floor(S/12);switch(!0){case p>0:i=p,h=u.year;break;case S>0:i=S,h=u.month;break;case g>0:i=g,h=u.day;break;case M>0:i=M,h=u.hour;break;case f>0:i=f,h=u.minute;break;default:i=d,h=u.second}return"en"===o&&(1===i?i="a":h+="s"),u.template.replace(/{\s*num\s*}/g,i+"").replace(/{\s*unit\s*}/g,h).replace(/{\s*suffix\s*}/g,m)};
