javascript-time-ago 2.5.1 → 2.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md
CHANGED
|
@@ -906,6 +906,32 @@ npm install [module name with version].tar.gz
|
|
|
906
906
|
```
|
|
907
907
|
-->
|
|
908
908
|
|
|
909
|
+
## Tests
|
|
910
|
+
|
|
911
|
+
This component comes with a 100% code coverage.
|
|
912
|
+
|
|
913
|
+
To run tests:
|
|
914
|
+
|
|
915
|
+
```
|
|
916
|
+
npm test
|
|
917
|
+
```
|
|
918
|
+
|
|
919
|
+
To generate a code coverage report:
|
|
920
|
+
|
|
921
|
+
```
|
|
922
|
+
npm run test-coverage
|
|
923
|
+
```
|
|
924
|
+
|
|
925
|
+
The code coverage report can be viewed by opening `./coverage/lcov-report/index.html`.
|
|
926
|
+
|
|
927
|
+
The `handlebars@4.5.3` [work](https://github.com/handlebars-lang/handlebars.js/issues/1646#issuecomment-578306544)[around](https://github.com/facebook/jest/issues/9396#issuecomment-573328488) in `devDependencies` is for the test coverage to not produce empty reports:
|
|
928
|
+
|
|
929
|
+
```
|
|
930
|
+
Handlebars: Access has been denied to resolve the property "statements" because it is not an "own property" of its parent.
|
|
931
|
+
You can add a runtime option to disable the check or this warning:
|
|
932
|
+
See https://handlebarsjs.com/api-reference/runtime-options.html#options-to-control-prototype-access for details
|
|
933
|
+
```
|
|
934
|
+
|
|
909
935
|
## GitHub
|
|
910
936
|
|
|
911
937
|
On March 9th, 2020, GitHub, Inc. silently [banned](https://medium.com/@catamphetamine/how-github-blocked-me-and-all-my-libraries-c32c61f061d3) my account (erasing all my repos, issues and comments, even in my employer's private repos) without any notice or explanation. Because of that, all source codes had to be promptly moved to GitLab. The [GitHub repo](https://github.com/catamphetamine/javascript-time-ago) is now only used as a backup (you can star the repo there too), and the primary repo is now the [GitLab one](https://gitlab.com/catamphetamine/javascript-time-ago). Issues can be reported in any repo.
|
|
@@ -19,7 +19,7 @@ for (const locale of ALL_LOCALES) {
|
|
|
19
19
|
createLegacyCompatibilityLocaleFolder(locale)
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
addLocaleExports()
|
|
22
|
+
addLocaleExports(ALL_LOCALES)
|
|
23
23
|
|
|
24
24
|
/**
|
|
25
25
|
* Returns a list of all locales supported by `relative-time-format`.
|
|
@@ -141,7 +141,7 @@ exports['default'] = localeData
|
|
|
141
141
|
}
|
|
142
142
|
|
|
143
143
|
// Add `export` entries in `package.json`.
|
|
144
|
-
function addLocaleExports() {
|
|
144
|
+
function addLocaleExports(ALL_LOCALES) {
|
|
145
145
|
// Read `package.json` file.
|
|
146
146
|
const packageJson = readJsonFromFile('./package.json')
|
|
147
147
|
|
|
@@ -163,5 +163,5 @@ function addLocaleExports() {
|
|
|
163
163
|
}
|
|
164
164
|
|
|
165
165
|
// Save `package.json` file.
|
|
166
|
-
fs.writeFileSync('./package.json', JSON.stringify(packageJson, null, 2), 'utf8')
|
|
166
|
+
fs.writeFileSync('./package.json', JSON.stringify(packageJson, null, 2) + '\n', 'utf8')
|
|
167
167
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).TimeAgo=e()}(this,(function(){"use strict";var t="en",e={},r={};function n(){return t}function o(t){return e[t]}function a(t){return e[t]?t:r[t.toLowerCase()]?r[t.toLowerCase()]:void 0}function i(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=e.localeMatcher||"lookup";switch(r){case"lookup":case"best fit":return u(t);default:throw new RangeError('Invalid "localeMatcher" option: '.concat(r))}}function u(t){var e=a(t);if(e)return e;for(var r=t.split("-");t.length>1;){r.pop();var n=a(t=r.join("-"));if(n)return n}}var c={af:function(t){return 1==t?"one":"other"},am:function(t){return t>=0&&t<=1?"one":"other"},ar:function(t){var e=String(t).split("."),r=Number(e[0])==t&&e[0].slice(-2);return 0==t?"zero":1==t?"one":2==t?"two":r>=3&&r<=10?"few":r>=11&&r<=99?"many":"other"},ast:function(t){var e=!String(t).split(".")[1];return 1==t&&e?"one":"other"},be:function(t){var e=String(t).split("."),r=Number(e[0])==t,n=r&&e[0].slice(-1),o=r&&e[0].slice(-2);return 1==n&&11!=o?"one":n>=2&&n<=4&&(o<12||o>14)?"few":r&&0==n||n>=5&&n<=9||o>=11&&o<=14?"many":"other"},br:function(t){var e=String(t).split("."),r=Number(e[0])==t,n=r&&e[0].slice(-1),o=r&&e[0].slice(-2),a=r&&e[0].slice(-6);return 1==n&&11!=o&&71!=o&&91!=o?"one":2==n&&12!=o&&72!=o&&92!=o?"two":(3==n||4==n||9==n)&&(o<10||o>19)&&(o<70||o>79)&&(o<90||o>99)?"few":0!=t&&r&&0==a?"many":"other"},bs:function(t){var e=String(t).split("."),r=e[0],n=e[1]||"",o=!e[1],a=r.slice(-1),i=r.slice(-2),u=n.slice(-1),c=n.slice(-2);return o&&1==a&&11!=i||1==u&&11!=c?"one":o&&a>=2&&a<=4&&(i<12||i>14)||u>=2&&u<=4&&(c<12||c>14)?"few":"other"},ceb:function(t){var e=String(t).split("."),r=e[0],n=e[1]||"",o=!e[1],a=r.slice(-1),i=n.slice(-1);return o&&(1==r||2==r||3==r)||o&&4!=a&&6!=a&&9!=a||!o&&4!=i&&6!=i&&9!=i?"one":"other"},cs:function(t){var e=String(t).split("."),r=e[0],n=!e[1];return 1==t&&n?"one":r>=2&&r<=4&&n?"few":n?"other":"many"},cy:function(t){return 0==t?"zero":1==t?"one":2==t?"two":3==t?"few":6==t?"many":"other"},da:function(t){var e=String(t).split("."),r=e[0],n=Number(e[0])==t;return 1!=t&&(n||0!=r&&1!=r)?"other":"one"},dsb:function(t){var e=String(t).split("."),r=e[0],n=e[1]||"",o=!e[1],a=r.slice(-2),i=n.slice(-2);return o&&1==a||1==i?"one":o&&2==a||2==i?"two":o&&(3==a||4==a)||3==i||4==i?"few":"other"},dz:function(t){return"other"},es:function(t){var e=String(t).split("."),r=e[0],n=!e[1],o=r.slice(-6);return 1==t?"one":0!=r&&0==o&&n?"many":"other"},ff:function(t){return t>=0&&t<2?"one":"other"},fr:function(t){var e=String(t).split("."),r=e[0],n=!e[1],o=r.slice(-6);return t>=0&&t<2?"one":0!=r&&0==o&&n?"many":"other"},ga:function(t){var e=String(t).split("."),r=Number(e[0])==t;return 1==t?"one":2==t?"two":r&&t>=3&&t<=6?"few":r&&t>=7&&t<=10?"many":"other"},gd:function(t){var e=String(t).split("."),r=Number(e[0])==t;return 1==t||11==t?"one":2==t||12==t?"two":r&&t>=3&&t<=10||r&&t>=13&&t<=19?"few":"other"},he:function(t){var e=String(t).split("."),r=e[0],n=!e[1],o=Number(e[0])==t,a=o&&e[0].slice(-1);return 1==t&&n?"one":2==r&&n?"two":n&&(t<0||t>10)&&o&&0==a?"many":"other"},is:function(t){var e=String(t).split("."),r=e[0],n=Number(e[0])==t,o=r.slice(-1),a=r.slice(-2);return n&&1==o&&11!=a||!n?"one":"other"},it:function(t){var e=String(t).split("."),r=e[0],n=!e[1],o=r.slice(-6);return 1==t&&n?"one":0!=r&&0==o&&n?"many":"other"},ksh:function(t){return 0==t?"zero":1==t?"one":"other"},lt:function(t){var e=String(t).split("."),r=e[1]||"",n=Number(e[0])==t,o=n&&e[0].slice(-1),a=n&&e[0].slice(-2);return 1==o&&(a<11||a>19)?"one":o>=2&&o<=9&&(a<11||a>19)?"few":0!=r?"many":"other"},lv:function(t){var e=String(t).split("."),r=e[1]||"",n=r.length,o=Number(e[0])==t,a=o&&e[0].slice(-1),i=o&&e[0].slice(-2),u=r.slice(-2),c=r.slice(-1);return o&&0==a||i>=11&&i<=19||2==n&&u>=11&&u<=19?"zero":1==a&&11!=i||2==n&&1==c&&11!=u||2!=n&&1==c?"one":"other"},mk:function(t){var e=String(t).split("."),r=e[0],n=e[1]||"",o=!e[1],a=r.slice(-1),i=r.slice(-2),u=n.slice(-1),c=n.slice(-2);return o&&1==a&&11!=i||1==u&&11!=c?"one":"other"},mt:function(t){var e=String(t).split("."),r=Number(e[0])==t&&e[0].slice(-2);return 1==t?"one":0==t||r>=2&&r<=10?"few":r>=11&&r<=19?"many":"other"},pa:function(t){return 0==t||1==t?"one":"other"},pl:function(t){var e=String(t).split("."),r=e[0],n=!e[1],o=r.slice(-1),a=r.slice(-2);return 1==t&&n?"one":n&&o>=2&&o<=4&&(a<12||a>14)?"few":n&&1!=r&&(0==o||1==o)||n&&o>=5&&o<=9||n&&a>=12&&a<=14?"many":"other"},pt:function(t){var e=String(t).split("."),r=e[0],n=!e[1],o=r.slice(-6);return 0==r||1==r?"one":0!=r&&0==o&&n?"many":"other"},ro:function(t){var e=String(t).split("."),r=!e[1],n=Number(e[0])==t&&e[0].slice(-2);return 1==t&&r?"one":!r||0==t||n>=2&&n<=19?"few":"other"},ru:function(t){var e=String(t).split("."),r=e[0],n=!e[1],o=r.slice(-1),a=r.slice(-2);return n&&1==o&&11!=a?"one":n&&o>=2&&o<=4&&(a<12||a>14)?"few":n&&0==o||n&&o>=5&&o<=9||n&&a>=11&&a<=14?"many":"other"},se:function(t){return 1==t?"one":2==t?"two":"other"},si:function(t){var e=String(t).split("."),r=e[0],n=e[1]||"";return 0==t||1==t||0==r&&1==n?"one":"other"},sl:function(t){var e=String(t).split("."),r=e[0],n=!e[1],o=r.slice(-2);return n&&1==o?"one":n&&2==o?"two":n&&(3==o||4==o)||!n?"few":"other"}};c.as=c.am,c.az=c.af,c.bg=c.af,c.bn=c.am,c.brx=c.af,c.ca=c.ast,c.ce=c.af,c.chr=c.af,c.de=c.ast,c.ee=c.af,c.el=c.af,c.en=c.ast,c.et=c.ast,c.eu=c.af,c.fa=c.am,c.fi=c.ast,c.fil=c.ceb,c.fo=c.af,c.fur=c.af,c.fy=c.ast,c.gl=c.ast,c.gu=c.am,c.ha=c.af,c.hi=c.am,c.hr=c.bs,c.hsb=c.dsb,c.hu=c.af,c.hy=c.ff,c.ia=c.ast,c.id=c.dz,c.ig=c.dz,c.ja=c.dz,c.jgo=c.af,c.jv=c.dz,c.ka=c.af,c.kea=c.dz,c.kk=c.af,c.kl=c.af,c.km=c.dz,c.kn=c.am,c.ko=c.dz,c.ku=c.af,c.ky=c.af,c.lb=c.af,c.lkt=c.dz,c.lo=c.dz,c.ml=c.af,c.mn=c.af,c.mr=c.af,c.ms=c.dz,c.my=c.dz,c.nb=c.af,c.ne=c.af,c.nl=c.ast,c.nn=c.af,c.no=c.af,c.or=c.af,c.pcm=c.am,c.ps=c.af,c.rm=c.af,c.sah=c.dz,c.sc=c.ast,c.sd=c.af,c.sk=c.cs,c.so=c.af,c.sq=c.af,c.sr=c.bs,c.su=c.dz,c.sv=c.ast,c.sw=c.ast,c.ta=c.af,c.te=c.af,c.th=c.dz,c.ti=c.pa,c.tk=c.af,c.to=c.dz,c.tr=c.af,c.ug=c.af,c.uk=c.ru,c.ur=c.ast,c.uz=c.af,c.vi=c.dz,c.wae=c.af,c.wo=c.dz,c.yi=c.ast,c.yo=c.dz,c.yue=c.dz,c.zh=c.dz,c.zu=c.am;var l=c;function f(t){return"pt-PT"===t?t:function(t){var e=t.match(s);if(!e)throw new TypeError("Invalid locale: ".concat(t));return e[1]}(t)}var s=/^([a-z0-9]+)/i;function p(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}var y=function(){function t(e,r){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t);var n=t.supportedLocalesOf(e);if(0===n.length)throw new RangeError("Unsupported locale: "+e);if(r&&"cardinal"!==r.type)throw new RangeError('Only "cardinal" "type" is supported');this.$=l[f(n[0])]}var e,r,n;return e=t,n=[{key:"supportedLocalesOf",value:function(t){return"string"==typeof t&&(t=[t]),t.filter((function(t){return l[f(t)]}))}}],(r=[{key:"select",value:function(t){return this.$(t)}}])&&p(e.prototype,r),n&&p(e,n),t}();function m(t){return(m="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function b(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter((function(t){return Object.getOwnPropertyDescriptor(r,t).enumerable})))),n.forEach((function(e){g(t,e,r[e])}))}return t}function h(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=[],n=!0,o=!1,a=void 0;try{for(var i,u=t[Symbol.iterator]();!(n=(i=u.next()).done)&&(r.push(i.value),!e||r.length!==e);n=!0);}catch(t){o=!0,a=t}finally{try{n||null==u.return||u.return()}finally{if(o)throw a}}return r}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}function d(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function v(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function g(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var w=["second","minute","hour","day","week","month","quarter","year"],O=["auto","always"],j=["long","short","narrow"],S=["lookup","best fit"],P=function(){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};d(this,t),g(this,"numeric","always"),g(this,"style","long"),g(this,"localeMatcher","lookup");var a=r.numeric,u=r.style,c=r.styleFallback,l=r.localeMatcher;if(void 0!==a){if(O.indexOf(a)<0)throw new RangeError('Invalid "numeric" option: '.concat(a));this.numeric=a}if(void 0!==u){if(j.indexOf(u)<0&&!c)throw new RangeError('Invalid "style" option: '.concat(u));this.style=u}if(void 0!==l){if(S.indexOf(l)<0)throw new RangeError('Invalid "localeMatcher" option: '.concat(l));this.localeMatcher=l}if("string"==typeof e&&(e=[e]),e.push(n()),this.locale=t.supportedLocalesOf(e,{localeMatcher:this.localeMatcher})[0],!this.locale)throw new Error("No supported locale was found");if(y.supportedLocalesOf(this.locale).length>0?this.pluralRules=new y(this.locale):console.warn('"'.concat(this.locale,'" locale is not supported')),"undefined"!=typeof Intl&&Intl.NumberFormat?(this.numberFormat=new Intl.NumberFormat(this.locale),this.numberingSystem=this.numberFormat.resolvedOptions().numberingSystem):this.numberingSystem="latn",this.locale=i(this.locale,{localeMatcher:this.localeMatcher}),c)for(var f=Object.keys(o(this.locale)),s=[this.style].concat(j,[f[0]]),p=0;p<s.length;p++){var m=s[p];if(f.indexOf(m)>=0){this.style=m;break}}}var e,r,a;return e=t,(r=[{key:"format",value:function(){var t=T(arguments),e=h(t,2),r=e[0],n=e[1];return this.getRule(r,n).replace("{0}",this.formatNumber(Math.abs(r)))}},{key:"formatToParts",value:function(){var t=T(arguments),e=h(t,2),r=e[0],n=e[1],o=this.getRule(r,n),a=o.indexOf("{0}");if(a<0)return[{type:"literal",value:o}];var i=[];return a>0&&i.push({type:"literal",value:o.slice(0,a)}),i=i.concat(this.formatNumberToParts(Math.abs(r)).map((function(t){return b({},t,{unit:n})}))),a+"{0}".length<o.length-1&&i.push({type:"literal",value:o.slice(a+"{0}".length)}),i}},{key:"getRule",value:function(t,e){var r=o(this.locale)[this.style][e];if("string"==typeof r)return r;if("auto"===this.numeric)if(-2===t||-1===t){var n=r["previous".concat(-1===t?"":"-"+Math.abs(t))];if(n)return n}else if(1===t||2===t){var a=r["next".concat(1===t?"":"-"+Math.abs(t))];if(a)return a}else if(0===t&&r.current)return r.current;var i,u=r[(i=t,i<0||0===i&&function(t){return 1/t==-1/0}(i)?"past":"future")];return"string"==typeof u?u:u[this.pluralRules&&this.pluralRules.select(Math.abs(t))||"other"]||u.other}},{key:"formatNumber",value:function(t){return this.numberFormat?this.numberFormat.format(t):String(t)}},{key:"formatNumberToParts",value:function(t){return this.numberFormat&&this.numberFormat.formatToParts?this.numberFormat.formatToParts(t):[{type:"integer",value:this.formatNumber(t)}]}},{key:"resolvedOptions",value:function(){return{locale:this.locale,style:this.style,numeric:this.numeric,numberingSystem:this.numberingSystem}}}])&&v(e.prototype,r),a&&v(e,a),t}();P.supportedLocalesOf=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if("string"==typeof t)t=[t];else if(!Array.isArray(t))throw new TypeError('Invalid "locales" argument');return t.filter((function(t){return i(t,e)}))},P.addLocale=function(t){if(!t)throw new Error("No locale data passed");e[t.locale]=t,r[t.locale.toLowerCase()]=t.locale},P.setDefaultLocale=function(e){t=e},P.getDefaultLocale=n,P.PluralRules=y;var A='Invalid "unit" argument';function k(t){if("symbol"===m(t))throw new TypeError(A);if("string"!=typeof t)throw new RangeError("".concat(A,": ").concat(t));if("s"===t[t.length-1]&&(t=t.slice(0,t.length-1)),w.indexOf(t)<0)throw new RangeError("".concat(A,": ").concat(t));return t}function D(t){if(t=Number(t),Number.isFinite&&!Number.isFinite(t))throw new RangeError("".concat('Invalid "number" argument',": ").concat(t));return t}function T(t){if(t.length<2)throw new TypeError('"unit" argument is required');return[D(t[0]),k(t[1])]}function E(t){return(E="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function F(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}var N=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.cache={}}var e,r,n;return e=t,(r=[{key:"get",value:function(){for(var t=this.cache,e=arguments.length,r=new Array(e),n=0;n<e;n++)r[n]=arguments[n];for(var o=0,a=r;o<a.length;o++){var i=a[o];if("object"!==E(t))return;t=t[i]}return t}},{key:"put",value:function(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];for(var n=e.pop(),o=e.pop(),a=this.cache,i=0,u=e;i<u.length;i++){var c=u[i];"object"!==E(a[c])&&(a[c]={}),a=a[c]}return a[o]=n}}])&&F(e.prototype,r),n&&F(e,n),Object.defineProperty(e,"prototype",{writable:!1}),t}();function I(t){return(I="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function M(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(r)return(r=r.call(t)).next.bind(r);if(Array.isArray(t)||(r=function(t,e){if(!t)return;if("string"==typeof t)return R(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);"Object"===r&&t.constructor&&(r=t.constructor.name);if("Map"===r||"Set"===r)return Array.from(t);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return R(t,e)}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0;return function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function R(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function z(t,e){for(var r,n=M(t);!(r=n()).done;){var o=r.value;if(e(o))return o;for(var a=o.split("-");a.length>1;)if(a.pop(),e(o=a.join("-")))return o}throw new Error("No locale data has been registered for any of the locales: ".concat(t.join(", ")))}function x(t){return(x="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function L(t){return function(t){return void 0!==x(t)&&null!==t&&t.constructor===C}(t)&&(Array.isArray(t.steps)||Array.isArray(t.gradation)||Array.isArray(t.flavour)||"string"==typeof t.flavour||Array.isArray(t.labels)||"string"==typeof t.labels||Array.isArray(t.units)||"function"==typeof t.custom)}var C={}.constructor;var U=60,_=3600,Y=86400,$=7*Y,q=2630016,V=31556952;function J(t){switch(t){case"second":return 1;case"minute":return U;case"hour":return _;case"day":return Y;case"week":return $;case"month":return q;case"year":return V}}function B(t){return void 0!==t.factor?t.factor:J(t.unit||t.formatAs)||1}function G(t){switch(t){case"floor":return Math.floor;default:return Math.round}}function H(t){switch(t){case"floor":return 1;default:return.5}}function K(t){return(K="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function Q(t,e){var r,n=e.prevStep,o=e.timestamp,a=e.now,i=e.future,u=e.round;return n&&(n.id||n.unit)&&(r=t["threshold_for_".concat(n.id||n.unit)]),void 0===r&&void 0!==t.threshold&&"function"==typeof(r=t.threshold)&&(r=r(a,i)),void 0===r&&(r=t.minTime),"object"===K(r)&&(r=n&&n.id&&void 0!==r[n.id]?r[n.id]:r.default),"function"==typeof r&&(r=r(o,{future:i,getMinTimeForUnit:function(t,e){return W(t,e||n&&n.formatAs,{round:u})}})),void 0===r&&t.test&&(r=t.test(o,{now:a,future:i})?0:9007199254740991),void 0===r&&(n?t.formatAs&&n.formatAs&&(r=W(t.formatAs,n.formatAs,{round:u})):r=0),void 0===r&&console.warn("[javascript-time-ago] A step should specify `minTime`:\n"+JSON.stringify(t,null,2)),r}function W(t,e,r){var n,o=r.round,a=J(t);if(n=J("now"===e?t:e),void 0!==a&&void 0!==n)return a-n*(1-H(o))}function X(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function Z(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?X(Object(r),!0).forEach((function(e){tt(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):X(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function tt(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function et(t,e,r){var n=r.now,o=r.future,a=r.round,i=r.units,u=r.getNextStep,c=function(t,e,r){var n=r.now,o=r.future,a=r.round;if(0===t.length)return;var i=rt(t,e,{now:n,future:o||e<0,round:a});if(-1===i)return;var u=t[i];if(u.granularity){if(0===G(a)(Math.abs(e)/B(u)/u.granularity)*u.granularity&&i>0)return t[i-1]}return u}(t=function(t,e){return t.filter((function(t){var r=t.unit,n=t.formatAs;return!(r=r||n)||e.indexOf(r)>=0}))}(t,i),e,{now:n,future:o,round:a});return u?c?[t[t.indexOf(c)-1],c,t[t.indexOf(c)+1]]:[void 0,void 0,t[0]]:c}function rt(t,e,r){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,o=Q(t[n],Z({prevStep:t[n-1],timestamp:r.now-1e3*e},r));return void 0===o||Math.abs(e)<o?n-1:n===t.length-1?n:rt(t,e,r,n+1)}function nt(t,e,r){var n=r.now,o=r.round;if(J(t)){var a=1e3*J(t),i=e>n,u=Math.abs(e-n),c=G(o)(u/a)*a;return i?c>0?u-c+function(t,e){return(1-H(t))*e+1}(o,a):u-c+1:-(u-c)+function(t,e){return H(t)*e}(o,a)}}var ot=31536e9;function at(t,e,r){var n=r.prevStep,o=r.nextStep,a=r.now,i=r.future,u=r.round,c=t.getTime?t.getTime():t,l=function(t){return nt(t,c,{now:a,round:u})},f=function(t,e,r){var n=r.now,o=r.future,a=r.round,i=r.prevStep;if(t){var u=function(t,e,r){var n=r.now,o=r.future,a=r.round,i=r.prevStep,u=Q(t,{timestamp:e,now:n,future:o,round:a,prevStep:i});if(void 0===u)return;return o?e-1e3*u+1:0===u&&e===n?ot:e+1e3*u}(t,e,{now:n,future:o,round:a,prevStep:i});if(void 0===u)return;return u-n}return o?e-n+1:ot}(i?e:o,c,{future:i,now:a,round:u,prevStep:i?n:e});if(void 0!==f){var s;if(e&&(e.getTimeToNextUpdate&&(s=e.getTimeToNextUpdate(c,{getTimeToNextUpdateForUnit:l,getRoundFunction:G,now:a,future:i,round:u})),void 0===s)){var p=e.unit||e.formatAs;p&&(s=l(p))}return void 0===s?f:Math.min(s,f)}}var it={};function ut(t){return it[t]}function ct(t){if(!t)throw new Error("[javascript-time-ago] No locale data passed.");it[t.locale]=t}var lt={steps:[{formatAs:"now"},{formatAs:"second"},{formatAs:"minute"},{formatAs:"hour"},{formatAs:"day"},{formatAs:"week"},{formatAs:"month"},{formatAs:"year"}],labels:"long"};function ft(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function st(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?ft(Object(r),!0).forEach((function(e){pt(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):ft(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function pt(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var yt=st(st({},lt),{},{steps:lt.steps.filter((function(t){return"second"!==t.formatAs}))}),mt=[{factor:1,unit:"now"},{threshold:1,threshold_for_now:45.5,factor:1,unit:"second"},{threshold:45.5,factor:U,unit:"minute"},{threshold:150,granularity:5,factor:U,unit:"minute"},{threshold:1350,factor:1800,unit:"half-hour"},{threshold:2550,threshold_for_minute:3150,factor:_,unit:"hour"},{threshold:73800,factor:Y,unit:"day"},{threshold:475200,factor:$,unit:"week"},{threshold:2116800,factor:q,unit:"month"},{threshold:27615168,factor:V,unit:"year"}],bt={gradation:mt,flavour:"long",units:["now","minute","hour","day","week","month","year"]},ht={gradation:mt,flavour:"long-time",units:["now","minute","hour","day","week","month","year"]};function dt(t){return t instanceof Date?t:new Date(t)}var vt=[{formatAs:"second"},{formatAs:"minute"},{formatAs:"hour"}],gt={},wt={minTime:function(t,e){return e.future,(0,e.getMinTimeForUnit)("day")},format:function(t,e){return gt[e]||(gt[e]={}),gt[e].dayMonth||(gt[e].dayMonth=new Intl.DateTimeFormat(e,{month:"short",day:"numeric"})),gt[e].dayMonth.format(dt(t))}},Ot={minTime:function(t,e){return e.future?(t-(new Date(new Date(t).getFullYear(),0).getTime()-1))/1e3:(new Date(new Date(t).getFullYear()+1,0).getTime()-t)/1e3},format:function(t,e){return gt[e]||(gt[e]={}),gt[e].dayMonthYear||(gt[e].dayMonthYear=new Intl.DateTimeFormat(e,{year:"numeric",month:"short",day:"numeric"})),gt[e].dayMonthYear.format(dt(t))}};"object"===("undefined"==typeof Intl?"undefined":I(Intl))&&"function"==typeof Intl.DateTimeFormat?vt.push(wt,Ot):vt.push({formatAs:"day"},{formatAs:"week"},{formatAs:"month"},{formatAs:"year"});var jt={steps:vt,labels:["mini","short-time","narrow","short"]};function St(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function Pt(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?St(Object(r),!0).forEach((function(e){At(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):St(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function At(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var kt=Pt(Pt({},jt),{},{steps:[{formatAs:"now"}].concat(jt.steps)});function Dt(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function Tt(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?Dt(Object(r),!0).forEach((function(e){Et(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):Dt(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function Et(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var Ft=Tt(Tt({},jt),{},{steps:jt.steps.filter((function(t){return"second"!==t.formatAs}))});function Nt(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function It(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?Nt(Object(r),!0).forEach((function(e){Mt(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):Nt(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function Mt(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var Rt=It(It({},Ft),{},{steps:[{formatAs:"now"}].concat(Ft.steps)});function zt(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function xt(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?zt(Object(r),!0).forEach((function(e){Lt(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):zt(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function Lt(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var Ct=xt(xt({},jt),{},{steps:jt.steps.filter((function(t){return"second"!==t.formatAs})).map((function(t){return"minute"===t.formatAs?xt(xt({},t),{},{minTime:U}):t}))}),Ut={steps:[{formatAs:"second"},{formatAs:"minute"},{formatAs:"hour"},{formatAs:"day"},{formatAs:"month"},{formatAs:"year"}],labels:["mini","short-time","narrow","short"]};function _t(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function Yt(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?_t(Object(r),!0).forEach((function(e){$t(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):_t(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function $t(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var qt=Yt(Yt({},Ut),{},{steps:[{formatAs:"now"}].concat(Ut.steps)});function Vt(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function Jt(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?Vt(Object(r),!0).forEach((function(e){Bt(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):Vt(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function Bt(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var Gt=Jt(Jt({},Ut),{},{steps:Ut.steps.filter((function(t){return"second"!==t.formatAs}))});function Ht(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function Kt(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?Ht(Object(r),!0).forEach((function(e){Qt(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):Ht(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function Qt(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var Wt=Kt(Kt({},Gt),{},{steps:[{formatAs:"now"}].concat(Gt.steps)});function Xt(t){switch(t){case"default":case"round":return lt;case"round-minute":return yt;case"approximate":return bt;case"time":case"approximate-time":return ht;case"mini":return Ut;case"mini-now":return qt;case"mini-minute":return Gt;case"mini-minute-now":return Wt;case"twitter":return jt;case"twitter-now":return kt;case"twitter-minute":return Ft;case"twitter-minute-now":return Rt;case"twitter-first-minute":return Ct;default:return bt}}function Zt(t){return(Zt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function te(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(r)return(r=r.call(t)).next.bind(r);if(Array.isArray(t)||(r=re(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0;return function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function ee(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null==r)return;var n,o,a=[],i=!0,u=!1;try{for(r=r.call(t);!(i=(n=r.next()).done)&&(a.push(n.value),!e||a.length!==e);i=!0);}catch(t){u=!0,o=t}finally{try{i||null==r.return||r.return()}finally{if(u)throw o}}return a}(t,e)||re(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function re(t,e){if(t){if("string"==typeof t)return ne(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?ne(t,e):void 0}}function ne(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function oe(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function ae(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}var ie,ue=function(){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=r.polyfill;oe(this,t),"string"==typeof e&&(e=[e]),this.locale=z(e.concat(t.getDefaultLocale()),ut),"undefined"!=typeof Intl&&Intl.NumberFormat&&(this.numberFormat=new Intl.NumberFormat(this.locale)),!1===n?(this.IntlRelativeTimeFormat=Intl.RelativeTimeFormat,this.IntlPluralRules=Intl.PluralRules):(this.IntlRelativeTimeFormat=P,this.IntlPluralRules=P.PluralRules),this.relativeTimeFormatCache=new N,this.pluralRulesCache=new N}var e,r,n;return e=t,(r=[{key:"format",value:function(t,e,r){var n;r||(e&&"string"!=typeof(n=e)&&!L(n)?(r=e,e=void 0):r={}),e||(e=yt),"string"==typeof e&&(e=Xt(e));var o,a=function(t){if(t.constructor===Date||"object"===Zt(e=t)&&"function"==typeof e.getTime)return t.getTime();var e;if("number"==typeof t)return t;throw new Error("Unsupported relative time formatter input: ".concat(Zt(t),", ").concat(t))}(t),i=this.getLabels(e.flavour||e.labels),u=i.labels,c=i.labelsType;void 0!==e.now&&(o=e.now),void 0===o&&void 0!==r.now&&(o=r.now),void 0===o&&(o=Date.now());var l=(o-a)/1e3,f=r.future||l<0,s=function(t,e,r,n){var o=t.now||e&&e.now;return o?"string"==typeof o?o:n?o.future:o.past:r&&r.second&&r.second.current?r.second.current:void 0}(u,ut(this.locale).now,ut(this.locale).long,f);if(e.custom){var p=e.custom({now:o,date:new Date(a),time:a,elapsed:l,locale:this.locale});if(void 0!==p)return p}var y=function(t,e,r){var n=Object.keys(e);return r&&n.push("now"),t&&(n=t.filter((function(t){return"now"===t||n.indexOf(t)>=0}))),n}(e.units,u,s),m=r.round||e.round,b=ee(et(e.gradation||e.steps||yt.steps,l,{now:o,units:y,round:m,future:f,getNextStep:!0}),3),h=b[0],d=b[1],v=b[2],g=this.formatDateForStep(a,d,l,{labels:u,labelsType:c,nowLabel:s,now:o,future:f,round:m})||"";return r.getTimeToNextUpdate?[g,at(a,d,{nextStep:v,prevStep:h,now:o,future:f,round:m})]:g}},{key:"formatDateForStep",value:function(t,e,r,n){var o=this,a=n.labels,i=n.labelsType,u=n.nowLabel,c=n.now,l=n.future,f=n.round;if(e){if(e.format)return e.format(t,this.locale,{formatAs:function(t,e){return o.formatValue(e,t,{labels:a,future:l})},now:c,future:l});var s=e.unit||e.formatAs;if(!s)throw new Error("[javascript-time-ago] Each step must define either `formatAs` or `format()`. Step: ".concat(JSON.stringify(e)));if("now"===s)return u;var p=Math.abs(r)/B(e);e.granularity&&(p=G(f)(p/e.granularity)*e.granularity);var y=-1*Math.sign(r)*G(f)(p);switch(0===y&&(y=l?0:-0),i){case"long":case"short":case"narrow":return this.getFormatter(i).format(y,s);default:return this.formatValue(y,s,{labels:a,future:l})}}}},{key:"formatValue",value:function(t,e,r){var n=r.labels,o=r.future;return this.getFormattingRule(n,e,t,{future:o}).replace("{0}",this.formatNumber(Math.abs(t)))}},{key:"getFormattingRule",value:function(t,e,r,n){var o=n.future;if(this.locale,"string"==typeof(t=t[e]))return t;var a=t[0===r?o?"future":"past":r<0?"past":"future"]||t;return"string"==typeof a?a:a[this.getPluralRules().select(Math.abs(r))]||a.other}},{key:"formatNumber",value:function(t){return this.numberFormat?this.numberFormat.format(t):String(t)}},{key:"getFormatter",value:function(t){return this.relativeTimeFormatCache.get(this.locale,t)||this.relativeTimeFormatCache.put(this.locale,t,new this.IntlRelativeTimeFormat(this.locale,{style:t}))}},{key:"getPluralRules",value:function(){return this.pluralRulesCache.get(this.locale)||this.pluralRulesCache.put(this.locale,new this.IntlPluralRules(this.locale))}},{key:"getLabels",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];"string"==typeof t&&(t=[t]),t=(t=t.map((function(t){switch(t){case"tiny":case"mini-time":return"mini";default:return t}}))).concat("long");for(var e,r=ut(this.locale),n=te(t);!(e=n()).done;){var o=e.value;if(r[o])return{labelsType:o,labels:r[o]}}}}])&&ae(e.prototype,r),n&&ae(e,n),Object.defineProperty(e,"prototype",{writable:!1}),t}(),ce="en";return ue.getDefaultLocale=function(){return ce},ue.setDefaultLocale=function(t){return ce=t},ue.addDefaultLocale=function(t){if(ie)return console.error("[javascript-time-ago] `TimeAgo.addDefaultLocale()` can only be called once. To add other locales, use `TimeAgo.addLocale()`.");ie=!0,ue.setDefaultLocale(t.locale),ue.addLocale(t)},ue.addLocale=function(t){ct(t),P.addLocale(t)},ue.locale=ue.addLocale,ue.addLabels=function(t,e,r){var n=ut(t);n||(ct({locale:t}),n=ut(t)),n[e]=r},ue}));
|
|
1
|
+
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).TimeAgo=e()}(this,(function(){"use strict";var t="en",e={},r={};function n(){return t}function o(t){return e[t]}function a(t){return e[t]?t:r[t.toLowerCase()]?r[t.toLowerCase()]:void 0}function i(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=e.localeMatcher||"lookup";switch(r){case"lookup":case"best fit":return u(t);default:throw new RangeError('Invalid "localeMatcher" option: '.concat(r))}}function u(t){var e=a(t);if(e)return e;for(var r=t.split("-");t.length>1;){r.pop();var n=a(t=r.join("-"));if(n)return n}}var c={af:function(t){return 1==t?"one":"other"},am:function(t){return t>=0&&t<=1?"one":"other"},ar:function(t){var e=String(t).split("."),r=Number(e[0])==t&&e[0].slice(-2);return 0==t?"zero":1==t?"one":2==t?"two":r>=3&&r<=10?"few":r>=11&&r<=99?"many":"other"},ast:function(t){var e=!String(t).split(".")[1];return 1==t&&e?"one":"other"},be:function(t){var e=String(t).split("."),r=Number(e[0])==t,n=r&&e[0].slice(-1),o=r&&e[0].slice(-2);return 1==n&&11!=o?"one":n>=2&&n<=4&&(o<12||o>14)?"few":r&&0==n||n>=5&&n<=9||o>=11&&o<=14?"many":"other"},br:function(t){var e=String(t).split("."),r=Number(e[0])==t,n=r&&e[0].slice(-1),o=r&&e[0].slice(-2),a=r&&e[0].slice(-6);return 1==n&&11!=o&&71!=o&&91!=o?"one":2==n&&12!=o&&72!=o&&92!=o?"two":(3==n||4==n||9==n)&&(o<10||o>19)&&(o<70||o>79)&&(o<90||o>99)?"few":0!=t&&r&&0==a?"many":"other"},bs:function(t){var e=String(t).split("."),r=e[0],n=e[1]||"",o=!e[1],a=r.slice(-1),i=r.slice(-2),u=n.slice(-1),c=n.slice(-2);return o&&1==a&&11!=i||1==u&&11!=c?"one":o&&a>=2&&a<=4&&(i<12||i>14)||u>=2&&u<=4&&(c<12||c>14)?"few":"other"},ceb:function(t){var e=String(t).split("."),r=e[0],n=e[1]||"",o=!e[1],a=r.slice(-1),i=n.slice(-1);return o&&(1==r||2==r||3==r)||o&&4!=a&&6!=a&&9!=a||!o&&4!=i&&6!=i&&9!=i?"one":"other"},cs:function(t){var e=String(t).split("."),r=e[0],n=!e[1];return 1==t&&n?"one":r>=2&&r<=4&&n?"few":n?"other":"many"},cy:function(t){return 0==t?"zero":1==t?"one":2==t?"two":3==t?"few":6==t?"many":"other"},da:function(t){var e=String(t).split("."),r=e[0],n=Number(e[0])==t;return 1!=t&&(n||0!=r&&1!=r)?"other":"one"},dsb:function(t){var e=String(t).split("."),r=e[0],n=e[1]||"",o=!e[1],a=r.slice(-2),i=n.slice(-2);return o&&1==a||1==i?"one":o&&2==a||2==i?"two":o&&(3==a||4==a)||3==i||4==i?"few":"other"},dz:function(t){return"other"},es:function(t){var e=String(t).split("."),r=e[0],n=!e[1],o=r.slice(-6);return 1==t?"one":0!=r&&0==o&&n?"many":"other"},ff:function(t){return t>=0&&t<2?"one":"other"},fr:function(t){var e=String(t).split("."),r=e[0],n=!e[1],o=r.slice(-6);return t>=0&&t<2?"one":0!=r&&0==o&&n?"many":"other"},ga:function(t){var e=String(t).split("."),r=Number(e[0])==t;return 1==t?"one":2==t?"two":r&&t>=3&&t<=6?"few":r&&t>=7&&t<=10?"many":"other"},gd:function(t){var e=String(t).split("."),r=Number(e[0])==t;return 1==t||11==t?"one":2==t||12==t?"two":r&&t>=3&&t<=10||r&&t>=13&&t<=19?"few":"other"},he:function(t){var e=String(t).split("."),r=e[0],n=!e[1],o=Number(e[0])==t,a=o&&e[0].slice(-1);return 1==t&&n?"one":2==r&&n?"two":n&&(t<0||t>10)&&o&&0==a?"many":"other"},is:function(t){var e=String(t).split("."),r=e[0],n=Number(e[0])==t,o=r.slice(-1),a=r.slice(-2);return n&&1==o&&11!=a||!n?"one":"other"},it:function(t){var e=String(t).split("."),r=e[0],n=!e[1],o=r.slice(-6);return 1==t&&n?"one":0!=r&&0==o&&n?"many":"other"},ksh:function(t){return 0==t?"zero":1==t?"one":"other"},lt:function(t){var e=String(t).split("."),r=e[1]||"",n=Number(e[0])==t,o=n&&e[0].slice(-1),a=n&&e[0].slice(-2);return 1==o&&(a<11||a>19)?"one":o>=2&&o<=9&&(a<11||a>19)?"few":0!=r?"many":"other"},lv:function(t){var e=String(t).split("."),r=e[1]||"",n=r.length,o=Number(e[0])==t,a=o&&e[0].slice(-1),i=o&&e[0].slice(-2),u=r.slice(-2),c=r.slice(-1);return o&&0==a||i>=11&&i<=19||2==n&&u>=11&&u<=19?"zero":1==a&&11!=i||2==n&&1==c&&11!=u||2!=n&&1==c?"one":"other"},mk:function(t){var e=String(t).split("."),r=e[0],n=e[1]||"",o=!e[1],a=r.slice(-1),i=r.slice(-2),u=n.slice(-1),c=n.slice(-2);return o&&1==a&&11!=i||1==u&&11!=c?"one":"other"},mt:function(t){var e=String(t).split("."),r=Number(e[0])==t&&e[0].slice(-2);return 1==t?"one":0==t||r>=2&&r<=10?"few":r>=11&&r<=19?"many":"other"},pa:function(t){return 0==t||1==t?"one":"other"},pl:function(t){var e=String(t).split("."),r=e[0],n=!e[1],o=r.slice(-1),a=r.slice(-2);return 1==t&&n?"one":n&&o>=2&&o<=4&&(a<12||a>14)?"few":n&&1!=r&&(0==o||1==o)||n&&o>=5&&o<=9||n&&a>=12&&a<=14?"many":"other"},pt:function(t){var e=String(t).split("."),r=e[0],n=!e[1],o=r.slice(-6);return 0==r||1==r?"one":0!=r&&0==o&&n?"many":"other"},ro:function(t){var e=String(t).split("."),r=!e[1],n=Number(e[0])==t&&e[0].slice(-2);return 1==t&&r?"one":!r||0==t||n>=2&&n<=19?"few":"other"},ru:function(t){var e=String(t).split("."),r=e[0],n=!e[1],o=r.slice(-1),a=r.slice(-2);return n&&1==o&&11!=a?"one":n&&o>=2&&o<=4&&(a<12||a>14)?"few":n&&0==o||n&&o>=5&&o<=9||n&&a>=11&&a<=14?"many":"other"},se:function(t){return 1==t?"one":2==t?"two":"other"},si:function(t){var e=String(t).split("."),r=e[0],n=e[1]||"";return 0==t||1==t||0==r&&1==n?"one":"other"},sl:function(t){var e=String(t).split("."),r=e[0],n=!e[1],o=r.slice(-2);return n&&1==o?"one":n&&2==o?"two":n&&(3==o||4==o)||!n?"few":"other"}};c.as=c.am,c.az=c.af,c.bg=c.af,c.bn=c.am,c.brx=c.af,c.ca=c.ast,c.ce=c.af,c.chr=c.af,c.de=c.ast,c.ee=c.af,c.el=c.af,c.en=c.ast,c.et=c.ast,c.eu=c.af,c.fa=c.am,c.fi=c.ast,c.fil=c.ceb,c.fo=c.af,c.fur=c.af,c.fy=c.ast,c.gl=c.ast,c.gu=c.am,c.ha=c.af,c.hi=c.am,c.hr=c.bs,c.hsb=c.dsb,c.hu=c.af,c.hy=c.ff,c.ia=c.ast,c.id=c.dz,c.ig=c.dz,c.ja=c.dz,c.jgo=c.af,c.jv=c.dz,c.ka=c.af,c.kea=c.dz,c.kk=c.af,c.kl=c.af,c.km=c.dz,c.kn=c.am,c.ko=c.dz,c.ku=c.af,c.ky=c.af,c.lb=c.af,c.lkt=c.dz,c.lo=c.dz,c.ml=c.af,c.mn=c.af,c.mr=c.af,c.ms=c.dz,c.my=c.dz,c.nb=c.af,c.ne=c.af,c.nl=c.ast,c.nn=c.af,c.no=c.af,c.or=c.af,c.pcm=c.am,c.ps=c.af,c.rm=c.af,c.sah=c.dz,c.sc=c.ast,c.sd=c.af,c.sk=c.cs,c.so=c.af,c.sq=c.af,c.sr=c.bs,c.su=c.dz,c.sv=c.ast,c.sw=c.ast,c.ta=c.af,c.te=c.af,c.th=c.dz,c.ti=c.pa,c.tk=c.af,c.to=c.dz,c.tr=c.af,c.ug=c.af,c.uk=c.ru,c.ur=c.ast,c.uz=c.af,c.vi=c.dz,c.wae=c.af,c.wo=c.dz,c.yi=c.ast,c.yo=c.dz,c.yue=c.dz,c.zh=c.dz,c.zu=c.am;var l=c;function f(t){return"pt-PT"===t?t:function(t){var e=t.match(s);if(!e)throw new TypeError("Invalid locale: ".concat(t));return e[1]}(t)}var s=/^([a-z0-9]+)/i;function p(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}var y=function(){function t(e,r){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t);var n=t.supportedLocalesOf(e);if(0===n.length)throw new RangeError("Unsupported locale: "+e);if(r&&"cardinal"!==r.type)throw new RangeError('Only "cardinal" "type" is supported');this.$=l[f(n[0])]}var e,r,n;return e=t,n=[{key:"supportedLocalesOf",value:function(t){return"string"==typeof t&&(t=[t]),t.filter((function(t){return l[f(t)]}))}}],(r=[{key:"select",value:function(t){return this.$(t)}}])&&p(e.prototype,r),n&&p(e,n),Object.defineProperty(e,"prototype",{writable:!1}),t}();function m(t){return(m="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function b(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function h(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?b(Object(r),!0).forEach((function(e){d(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):b(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function d(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function v(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null==r)return;var n,o,a=[],i=!0,u=!1;try{for(r=r.call(t);!(i=(n=r.next()).done)&&(a.push(n.value),!e||a.length!==e);i=!0);}catch(t){u=!0,o=t}finally{try{i||null==r.return||r.return()}finally{if(u)throw o}}return a}(t,e)||function(t,e){if(!t)return;if("string"==typeof t)return g(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);"Object"===r&&t.constructor&&(r=t.constructor.name);if("Map"===r||"Set"===r)return Array.from(t);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return g(t,e)}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function g(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function w(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function O(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}var j=["second","minute","hour","day","week","month","quarter","year"],S=["auto","always"],P=["long","short","narrow"],A=["lookup","best fit"],k=function(){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};w(this,t);var a=r.numeric,u=r.style,c=r.styleFallback,l=r.localeMatcher;if(this.numeric="always",this.style="long",this.localeMatcher="lookup",void 0!==a){if(S.indexOf(a)<0)throw new RangeError('Invalid "numeric" option: '.concat(a));this.numeric=a}if(void 0!==u){if(P.indexOf(u)<0&&!c)throw new RangeError('Invalid "style" option: '.concat(u));this.style=u}if(void 0!==l){if(A.indexOf(l)<0)throw new RangeError('Invalid "localeMatcher" option: '.concat(l));this.localeMatcher=l}if("string"==typeof e&&(e=[e]),e.push(n()),this.locale=t.supportedLocalesOf(e,{localeMatcher:this.localeMatcher})[0],!this.locale)throw new Error("No supported locale was found");if(y.supportedLocalesOf(this.locale).length>0?this.pluralRules=new y(this.locale):console.warn('"'.concat(this.locale,'" locale is not supported')),"undefined"!=typeof Intl&&Intl.NumberFormat?(this.numberFormat=new Intl.NumberFormat(this.locale),this.numberingSystem=this.numberFormat.resolvedOptions().numberingSystem):this.numberingSystem="latn",this.locale=i(this.locale,{localeMatcher:this.localeMatcher}),c)for(var f=Object.keys(o(this.locale)),s=0,p=[this.style].concat(P,[f[0]]);s<p.length;s++){var m=p[s];if(f.indexOf(m)>=0){this.style=m;break}}}var e,r,a;return e=t,(r=[{key:"format",value:function(){var t=F(arguments),e=v(t,2),r=e[0],n=e[1];return this.getRule(r,n).replace("{0}",this.formatNumber(Math.abs(r)))}},{key:"formatToParts",value:function(){var t=F(arguments),e=v(t,2),r=e[0],n=e[1],o=this.getRule(r,n),a=o.indexOf("{0}");if(a<0)return[{type:"literal",value:o}];var i=[];return a>0&&i.push({type:"literal",value:o.slice(0,a)}),i=i.concat(this.formatNumberToParts(Math.abs(r)).map((function(t){return h(h({},t),{},{unit:n})}))),a+"{0}".length<o.length-1&&i.push({type:"literal",value:o.slice(a+"{0}".length)}),i}},{key:"getRule",value:function(t,e){var r=o(this.locale)[this.style][e];if("string"==typeof r)return r;if("auto"===this.numeric)if(-2===t||-1===t){var n=r["previous".concat(-1===t?"":"-"+Math.abs(t))];if(n)return n}else if(1===t||2===t){var a=r["next".concat(1===t?"":"-"+Math.abs(t))];if(a)return a}else if(0===t&&r.current)return r.current;var i,u=r[(i=t,i<0||0===i&&function(t){return 1/t==-1/0}(i)?"past":"future")];return"string"==typeof u?u:u[this.pluralRules&&this.pluralRules.select(Math.abs(t))||"other"]||u.other}},{key:"formatNumber",value:function(t){return this.numberFormat?this.numberFormat.format(t):String(t)}},{key:"formatNumberToParts",value:function(t){return this.numberFormat&&this.numberFormat.formatToParts?this.numberFormat.formatToParts(t):[{type:"integer",value:this.formatNumber(t)}]}},{key:"resolvedOptions",value:function(){return{locale:this.locale,style:this.style,numeric:this.numeric,numberingSystem:this.numberingSystem}}}])&&O(e.prototype,r),a&&O(e,a),Object.defineProperty(e,"prototype",{writable:!1}),t}();k.supportedLocalesOf=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if("string"==typeof t)t=[t];else if(!Array.isArray(t))throw new TypeError('Invalid "locales" argument');return t.filter((function(t){return i(t,e)}))},k.addLocale=function(t){if(!t)throw new Error("No locale data passed");e[t.locale]=t,r[t.locale.toLowerCase()]=t.locale},k.setDefaultLocale=function(e){t=e},k.getDefaultLocale=n,k.PluralRules=y;var D='Invalid "unit" argument';function T(t){if("symbol"===m(t))throw new TypeError(D);if("string"!=typeof t)throw new RangeError("".concat(D,": ").concat(t));if("s"===t[t.length-1]&&(t=t.slice(0,t.length-1)),j.indexOf(t)<0)throw new RangeError("".concat(D,": ").concat(t));return t}function E(t){if(t=Number(t),Number.isFinite&&!Number.isFinite(t))throw new RangeError("".concat('Invalid "number" argument',": ").concat(t));return t}function F(t){if(t.length<2)throw new TypeError('"unit" argument is required');return[E(t[0]),T(t[1])]}function I(t){return(I="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function N(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}var M=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.cache={}}var e,r,n;return e=t,(r=[{key:"get",value:function(){for(var t=this.cache,e=arguments.length,r=new Array(e),n=0;n<e;n++)r[n]=arguments[n];for(var o=0,a=r;o<a.length;o++){var i=a[o];if("object"!==I(t))return;t=t[i]}return t}},{key:"put",value:function(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];for(var n=e.pop(),o=e.pop(),a=this.cache,i=0,u=e;i<u.length;i++){var c=u[i];"object"!==I(a[c])&&(a[c]={}),a=a[c]}return a[o]=n}}])&&N(e.prototype,r),n&&N(e,n),Object.defineProperty(e,"prototype",{writable:!1}),t}();function R(t){return(R="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function z(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(r)return(r=r.call(t)).next.bind(r);if(Array.isArray(t)||(r=function(t,e){if(!t)return;if("string"==typeof t)return x(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);"Object"===r&&t.constructor&&(r=t.constructor.name);if("Map"===r||"Set"===r)return Array.from(t);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return x(t,e)}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0;return function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function x(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function L(t,e){for(var r,n=z(t);!(r=n()).done;){var o=r.value;if(e(o))return o;for(var a=o.split("-");a.length>1;)if(a.pop(),e(o=a.join("-")))return o}throw new Error("No locale data has been registered for any of the locales: ".concat(t.join(", ")))}function C(t){return(C="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function U(t){return function(t){return void 0!==C(t)&&null!==t&&t.constructor===_}(t)&&(Array.isArray(t.steps)||Array.isArray(t.gradation)||Array.isArray(t.flavour)||"string"==typeof t.flavour||Array.isArray(t.labels)||"string"==typeof t.labels||Array.isArray(t.units)||"function"==typeof t.custom)}var _={}.constructor;var Y=60,$=3600,q=86400,V=7*q,J=2630016,B=31556952;function G(t){switch(t){case"second":return 1;case"minute":return Y;case"hour":return $;case"day":return q;case"week":return V;case"month":return J;case"year":return B}}function H(t){return void 0!==t.factor?t.factor:G(t.unit||t.formatAs)||1}function K(t){switch(t){case"floor":return Math.floor;default:return Math.round}}function Q(t){switch(t){case"floor":return 1;default:return.5}}function W(t){return(W="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function X(t,e){var r,n=e.prevStep,o=e.timestamp,a=e.now,i=e.future,u=e.round;return n&&(n.id||n.unit)&&(r=t["threshold_for_".concat(n.id||n.unit)]),void 0===r&&void 0!==t.threshold&&"function"==typeof(r=t.threshold)&&(r=r(a,i)),void 0===r&&(r=t.minTime),"object"===W(r)&&(r=n&&n.id&&void 0!==r[n.id]?r[n.id]:r.default),"function"==typeof r&&(r=r(o,{future:i,getMinTimeForUnit:function(t,e){return Z(t,e||n&&n.formatAs,{round:u})}})),void 0===r&&t.test&&(r=t.test(o,{now:a,future:i})?0:9007199254740991),void 0===r&&(n?t.formatAs&&n.formatAs&&(r=Z(t.formatAs,n.formatAs,{round:u})):r=0),void 0===r&&console.warn("[javascript-time-ago] A step should specify `minTime`:\n"+JSON.stringify(t,null,2)),r}function Z(t,e,r){var n,o=r.round,a=G(t);if(n=G("now"===e?t:e),void 0!==a&&void 0!==n)return a-n*(1-Q(o))}function tt(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function et(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?tt(Object(r),!0).forEach((function(e){rt(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):tt(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function rt(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function nt(t,e,r){var n=r.now,o=r.future,a=r.round,i=r.units,u=r.getNextStep,c=function(t,e,r){var n=r.now,o=r.future,a=r.round;if(0===t.length)return;var i=ot(t,e,{now:n,future:o||e<0,round:a});if(-1===i)return;var u=t[i];if(u.granularity){if(0===K(a)(Math.abs(e)/H(u)/u.granularity)*u.granularity&&i>0)return t[i-1]}return u}(t=function(t,e){return t.filter((function(t){var r=t.unit,n=t.formatAs;return!(r=r||n)||e.indexOf(r)>=0}))}(t,i),e,{now:n,future:o,round:a});return u?c?[t[t.indexOf(c)-1],c,t[t.indexOf(c)+1]]:[void 0,void 0,t[0]]:c}function ot(t,e,r){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,o=X(t[n],et({prevStep:t[n-1],timestamp:r.now-1e3*e},r));return void 0===o||Math.abs(e)<o?n-1:n===t.length-1?n:ot(t,e,r,n+1)}function at(t,e,r){var n=r.now,o=r.round;if(G(t)){var a=1e3*G(t),i=e>n,u=Math.abs(e-n),c=K(o)(u/a)*a;return i?c>0?u-c+function(t,e){return(1-Q(t))*e+1}(o,a):u-c+1:-(u-c)+function(t,e){return Q(t)*e}(o,a)}}var it=31536e9;function ut(t,e,r){var n=r.prevStep,o=r.nextStep,a=r.now,i=r.future,u=r.round,c=t.getTime?t.getTime():t,l=function(t){return at(t,c,{now:a,round:u})},f=function(t,e,r){var n=r.now,o=r.future,a=r.round,i=r.prevStep;if(t){var u=function(t,e,r){var n=r.now,o=r.future,a=r.round,i=r.prevStep,u=X(t,{timestamp:e,now:n,future:o,round:a,prevStep:i});if(void 0===u)return;return o?e-1e3*u+1:0===u&&e===n?it:e+1e3*u}(t,e,{now:n,future:o,round:a,prevStep:i});if(void 0===u)return;return u-n}return o?e-n+1:it}(i?e:o,c,{future:i,now:a,round:u,prevStep:i?n:e});if(void 0!==f){var s;if(e&&(e.getTimeToNextUpdate&&(s=e.getTimeToNextUpdate(c,{getTimeToNextUpdateForUnit:l,getRoundFunction:K,now:a,future:i,round:u})),void 0===s)){var p=e.unit||e.formatAs;p&&(s=l(p))}return void 0===s?f:Math.min(s,f)}}var ct={};function lt(t){return ct[t]}function ft(t){if(!t)throw new Error("[javascript-time-ago] No locale data passed.");ct[t.locale]=t}var st={steps:[{formatAs:"now"},{formatAs:"second"},{formatAs:"minute"},{formatAs:"hour"},{formatAs:"day"},{formatAs:"week"},{formatAs:"month"},{formatAs:"year"}],labels:"long"};function pt(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function yt(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?pt(Object(r),!0).forEach((function(e){mt(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):pt(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function mt(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var bt=yt(yt({},st),{},{steps:st.steps.filter((function(t){return"second"!==t.formatAs}))}),ht=[{factor:1,unit:"now"},{threshold:1,threshold_for_now:45.5,factor:1,unit:"second"},{threshold:45.5,factor:Y,unit:"minute"},{threshold:150,granularity:5,factor:Y,unit:"minute"},{threshold:1350,factor:1800,unit:"half-hour"},{threshold:2550,threshold_for_minute:3150,factor:$,unit:"hour"},{threshold:73800,factor:q,unit:"day"},{threshold:475200,factor:V,unit:"week"},{threshold:2116800,factor:J,unit:"month"},{threshold:27615168,factor:B,unit:"year"}],dt={gradation:ht,flavour:"long",units:["now","minute","hour","day","week","month","year"]},vt={gradation:ht,flavour:"long-time",units:["now","minute","hour","day","week","month","year"]};function gt(t){return t instanceof Date?t:new Date(t)}var wt=[{formatAs:"second"},{formatAs:"minute"},{formatAs:"hour"}],Ot={},jt={minTime:function(t,e){return e.future,(0,e.getMinTimeForUnit)("day")},format:function(t,e){return Ot[e]||(Ot[e]={}),Ot[e].dayMonth||(Ot[e].dayMonth=new Intl.DateTimeFormat(e,{month:"short",day:"numeric"})),Ot[e].dayMonth.format(gt(t))}},St={minTime:function(t,e){return e.future?(t-(new Date(new Date(t).getFullYear(),0).getTime()-1))/1e3:(new Date(new Date(t).getFullYear()+1,0).getTime()-t)/1e3},format:function(t,e){return Ot[e]||(Ot[e]={}),Ot[e].dayMonthYear||(Ot[e].dayMonthYear=new Intl.DateTimeFormat(e,{year:"numeric",month:"short",day:"numeric"})),Ot[e].dayMonthYear.format(gt(t))}};"object"===("undefined"==typeof Intl?"undefined":R(Intl))&&"function"==typeof Intl.DateTimeFormat?wt.push(jt,St):wt.push({formatAs:"day"},{formatAs:"week"},{formatAs:"month"},{formatAs:"year"});var Pt={steps:wt,labels:["mini","short-time","narrow","short"]};function At(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function kt(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?At(Object(r),!0).forEach((function(e){Dt(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):At(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function Dt(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var Tt=kt(kt({},Pt),{},{steps:[{formatAs:"now"}].concat(Pt.steps)});function Et(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function Ft(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?Et(Object(r),!0).forEach((function(e){It(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):Et(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function It(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var Nt=Ft(Ft({},Pt),{},{steps:Pt.steps.filter((function(t){return"second"!==t.formatAs}))});function Mt(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function Rt(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?Mt(Object(r),!0).forEach((function(e){zt(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):Mt(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function zt(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var xt=Rt(Rt({},Nt),{},{steps:[{formatAs:"now"}].concat(Nt.steps)});function Lt(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function Ct(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?Lt(Object(r),!0).forEach((function(e){Ut(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):Lt(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function Ut(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var _t=Ct(Ct({},Pt),{},{steps:Pt.steps.filter((function(t){return"second"!==t.formatAs})).map((function(t){return"minute"===t.formatAs?Ct(Ct({},t),{},{minTime:Y}):t}))}),Yt={steps:[{formatAs:"second"},{formatAs:"minute"},{formatAs:"hour"},{formatAs:"day"},{formatAs:"month"},{formatAs:"year"}],labels:["mini","short-time","narrow","short"]};function $t(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function qt(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?$t(Object(r),!0).forEach((function(e){Vt(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):$t(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function Vt(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var Jt=qt(qt({},Yt),{},{steps:[{formatAs:"now"}].concat(Yt.steps)});function Bt(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function Gt(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?Bt(Object(r),!0).forEach((function(e){Ht(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):Bt(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function Ht(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var Kt=Gt(Gt({},Yt),{},{steps:Yt.steps.filter((function(t){return"second"!==t.formatAs}))});function Qt(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function Wt(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?Qt(Object(r),!0).forEach((function(e){Xt(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):Qt(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function Xt(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var Zt=Wt(Wt({},Kt),{},{steps:[{formatAs:"now"}].concat(Kt.steps)});function te(t){switch(t){case"default":case"round":return st;case"round-minute":return bt;case"approximate":return dt;case"time":case"approximate-time":return vt;case"mini":return Yt;case"mini-now":return Jt;case"mini-minute":return Kt;case"mini-minute-now":return Zt;case"twitter":return Pt;case"twitter-now":return Tt;case"twitter-minute":return Nt;case"twitter-minute-now":return xt;case"twitter-first-minute":return _t;default:return dt}}function ee(t){return(ee="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function re(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(r)return(r=r.call(t)).next.bind(r);if(Array.isArray(t)||(r=oe(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0;return function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function ne(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null==r)return;var n,o,a=[],i=!0,u=!1;try{for(r=r.call(t);!(i=(n=r.next()).done)&&(a.push(n.value),!e||a.length!==e);i=!0);}catch(t){u=!0,o=t}finally{try{i||null==r.return||r.return()}finally{if(u)throw o}}return a}(t,e)||oe(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function oe(t,e){if(t){if("string"==typeof t)return ae(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?ae(t,e):void 0}}function ae(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function ie(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function ue(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}var ce,le=function(){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=r.polyfill;ie(this,t),"string"==typeof e&&(e=[e]),this.locale=L(e.concat(t.getDefaultLocale()),lt),"undefined"!=typeof Intl&&Intl.NumberFormat&&(this.numberFormat=new Intl.NumberFormat(this.locale)),!1===n?(this.IntlRelativeTimeFormat=Intl.RelativeTimeFormat,this.IntlPluralRules=Intl.PluralRules):(this.IntlRelativeTimeFormat=k,this.IntlPluralRules=k.PluralRules),this.relativeTimeFormatCache=new M,this.pluralRulesCache=new M}var e,r,n;return e=t,(r=[{key:"format",value:function(t,e,r){var n;r||(e&&"string"!=typeof(n=e)&&!U(n)?(r=e,e=void 0):r={}),e||(e=bt),"string"==typeof e&&(e=te(e));var o,a=function(t){if(t.constructor===Date||"object"===ee(e=t)&&"function"==typeof e.getTime)return t.getTime();var e;if("number"==typeof t)return t;throw new Error("Unsupported relative time formatter input: ".concat(ee(t),", ").concat(t))}(t),i=this.getLabels(e.flavour||e.labels),u=i.labels,c=i.labelsType;void 0!==e.now&&(o=e.now),void 0===o&&void 0!==r.now&&(o=r.now),void 0===o&&(o=Date.now());var l=(o-a)/1e3,f=r.future||l<0,s=function(t,e,r,n){var o=t.now||e&&e.now;return o?"string"==typeof o?o:n?o.future:o.past:r&&r.second&&r.second.current?r.second.current:void 0}(u,lt(this.locale).now,lt(this.locale).long,f);if(e.custom){var p=e.custom({now:o,date:new Date(a),time:a,elapsed:l,locale:this.locale});if(void 0!==p)return p}var y=function(t,e,r){var n=Object.keys(e);return r&&n.push("now"),t&&(n=t.filter((function(t){return"now"===t||n.indexOf(t)>=0}))),n}(e.units,u,s),m=r.round||e.round,b=ne(nt(e.gradation||e.steps||bt.steps,l,{now:o,units:y,round:m,future:f,getNextStep:!0}),3),h=b[0],d=b[1],v=b[2],g=this.formatDateForStep(a,d,l,{labels:u,labelsType:c,nowLabel:s,now:o,future:f,round:m})||"";return r.getTimeToNextUpdate?[g,ut(a,d,{nextStep:v,prevStep:h,now:o,future:f,round:m})]:g}},{key:"formatDateForStep",value:function(t,e,r,n){var o=this,a=n.labels,i=n.labelsType,u=n.nowLabel,c=n.now,l=n.future,f=n.round;if(e){if(e.format)return e.format(t,this.locale,{formatAs:function(t,e){return o.formatValue(e,t,{labels:a,future:l})},now:c,future:l});var s=e.unit||e.formatAs;if(!s)throw new Error("[javascript-time-ago] Each step must define either `formatAs` or `format()`. Step: ".concat(JSON.stringify(e)));if("now"===s)return u;var p=Math.abs(r)/H(e);e.granularity&&(p=K(f)(p/e.granularity)*e.granularity);var y=-1*Math.sign(r)*K(f)(p);switch(0===y&&(y=l?0:-0),i){case"long":case"short":case"narrow":return this.getFormatter(i).format(y,s);default:return this.formatValue(y,s,{labels:a,future:l})}}}},{key:"formatValue",value:function(t,e,r){var n=r.labels,o=r.future;return this.getFormattingRule(n,e,t,{future:o}).replace("{0}",this.formatNumber(Math.abs(t)))}},{key:"getFormattingRule",value:function(t,e,r,n){var o=n.future;if(this.locale,"string"==typeof(t=t[e]))return t;var a=t[0===r?o?"future":"past":r<0?"past":"future"]||t;return"string"==typeof a?a:a[this.getPluralRules().select(Math.abs(r))]||a.other}},{key:"formatNumber",value:function(t){return this.numberFormat?this.numberFormat.format(t):String(t)}},{key:"getFormatter",value:function(t){return this.relativeTimeFormatCache.get(this.locale,t)||this.relativeTimeFormatCache.put(this.locale,t,new this.IntlRelativeTimeFormat(this.locale,{style:t}))}},{key:"getPluralRules",value:function(){return this.pluralRulesCache.get(this.locale)||this.pluralRulesCache.put(this.locale,new this.IntlPluralRules(this.locale))}},{key:"getLabels",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];"string"==typeof t&&(t=[t]),t=(t=t.map((function(t){switch(t){case"tiny":case"mini-time":return"mini";default:return t}}))).concat("long");for(var e,r=lt(this.locale),n=re(t);!(e=n()).done;){var o=e.value;if(r[o])return{labelsType:o,labels:r[o]}}}}])&&ue(e.prototype,r),n&&ue(e,n),Object.defineProperty(e,"prototype",{writable:!1}),t}(),fe="en";return le.getDefaultLocale=function(){return fe},le.setDefaultLocale=function(t){return fe=t},le.addDefaultLocale=function(t){if(ce)return console.error("[javascript-time-ago] `TimeAgo.addDefaultLocale()` can only be called once. To add other locales, use `TimeAgo.addLocale()`.");ce=!0,le.setDefaultLocale(t.locale),le.addLocale(t)},le.addLocale=function(t){ft(t),k.addLocale(t)},le.locale=le.addLocale,le.addLabels=function(t,e,r){var n=lt(t);n||(ft({locale:t}),n=lt(t)),n[e]=r},le}));
|
|
2
2
|
//# sourceMappingURL=javascript-time-ago.js.map
|