{"version":3,"file":"react-timeago-C0hDYlD6.js","sources":["../../node_modules/react-timeago/es6/dateParser.js","../../node_modules/react-timeago/es6/defaultFormatter.js","../../node_modules/react-timeago/es6/index.js"],"sourcesContent":["export default function dateParser(date) {\n const parsed = new Date(date);\n if (!Number.isNaN(parsed.valueOf())) {\n return parsed;\n }\n const parts = String(date).match(/\\d+/g);\n if (parts == null || parts.length <= 2) {\n return parsed;\n } else {\n const [firstP, secondP, ...restPs] = parts.map(x => parseInt(x));\n const correctedParts = [firstP, secondP - 1, ...restPs];\n const isoDate = new Date(Date.UTC(...correctedParts));\n return isoDate;\n }\n}","export default function defaultFormatter(value, _unit, suffix) {\n const unit = value !== 1 ? _unit + 's' : _unit;\n return value + ' ' + unit + ' ' + suffix;\n}","function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }\nimport * as React from 'react';\nimport { useEffect, useState } from 'react';\nimport dateParser from './dateParser';\nimport defaultFormatter from './defaultFormatter';\n// Just some simple constants for readability\nconst MINUTE = 60;\nconst HOUR = MINUTE * 60;\nconst DAY = HOUR * 24;\nconst WEEK = DAY * 7;\nconst MONTH = DAY * 30;\nconst YEAR = DAY * 365;\nconst defaultNow = () => Date.now();\nexport default function TimeAgo({\n date,\n formatter = defaultFormatter,\n component = 'time',\n live = true,\n minPeriod = 0,\n maxPeriod = WEEK,\n title,\n now = defaultNow,\n ...passDownProps\n}) {\n const [timeNow, setTimeNow] = useState(now());\n useEffect(() => {\n if (!live) {\n return;\n }\n const tick = () => {\n const then = dateParser(date).valueOf();\n if (!then) {\n console.warn('[react-timeago] Invalid Date provided');\n return 0;\n }\n const seconds = Math.round(Math.abs(timeNow - then) / 1000);\n const unboundPeriod = seconds < MINUTE ? 1000 : seconds < HOUR ? 1000 * MINUTE : seconds < DAY ? 1000 * HOUR : 1000 * WEEK;\n const period = Math.min(Math.max(unboundPeriod, minPeriod * 1000), maxPeriod * 1000);\n if (period) {\n return setTimeout(() => {\n setTimeNow(now());\n }, period);\n }\n return 0;\n };\n const timeoutId = tick();\n return () => {\n if (timeoutId) {\n clearTimeout(timeoutId);\n }\n };\n }, [date, live, maxPeriod, minPeriod, now, timeNow]);\n const Komponent = component;\n const then = dateParser(date).valueOf();\n if (!then) {\n return null;\n }\n const seconds = Math.round(Math.abs(timeNow - then) / 1000);\n const suffix = then < timeNow ? 'ago' : 'from now';\n const [value, unit] = seconds < MINUTE ? [Math.round(seconds), 'second'] : seconds < HOUR ? [Math.round(seconds / MINUTE), 'minute'] : seconds < DAY ? [Math.round(seconds / HOUR), 'hour'] : seconds < WEEK ? [Math.round(seconds / DAY), 'day'] : seconds < MONTH ? [Math.round(seconds / WEEK), 'week'] : seconds < YEAR ? [Math.round(seconds / MONTH), 'month'] : [Math.round(seconds / YEAR), 'year'];\n const passDownTitle = typeof title === 'undefined' ? typeof date === 'string' ? date : dateParser(date).toISOString().substr(0, 16).replace('T', ' ') : title;\n const spreadProps = Komponent === 'time' ? {\n ...passDownProps,\n dateTime: dateParser(date).toISOString()\n } : passDownProps;\n const nextFormatter = defaultFormatter.bind(null, value, unit, suffix);\n return /*#__PURE__*/React.createElement(Komponent, _extends({}, spreadProps, {\n title: passDownTitle\n }), formatter(value, unit, suffix, then, nextFormatter, now));\n}"],"names":["dateParser","date","parsed","Date","Number","isNaN","valueOf","parts","String","match","length","firstP","secondP","restPs","map","x","parseInt","correctedParts","UTC","defaultFormatter","value","_unit","suffix","_extends","Object","assign","bind","target","i","arguments","source","key","prototype","hasOwnProperty","call","apply","this","HOUR","MINUTE","DAY","WEEK","MONTH","YEAR","defaultNow","now","TimeAgo","formatter","component","live","minPeriod","maxPeriod","title","passDownProps","timeNow","setTimeNow","useState","useEffect","timeoutId","then","console","warn","seconds","Math","round","abs","unboundPeriod","period","min","max","setTimeout","tick","clearTimeout","Komponent","unit","passDownTitle","toISOString","substr","replace","spreadProps","dateTime","nextFormatter","createElement"],"mappings":"wCAAe,SAASA,EAAWC,GAC3B,MAAAC,EAAS,IAAIC,KAAKF,GACxB,IAAKG,OAAOC,MAAMH,EAAOI,WAChB,OAAAJ,EAET,MAAMK,EAAQC,OAAOP,GAAMQ,MAAM,QACjC,GAAa,MAATF,GAAiBA,EAAMG,QAAU,EAC5B,OAAAR,EACF,CACC,MAACS,EAAQC,KAAYC,GAAUN,EAAMO,KAAIC,GAAKC,SAASD,KACvDE,EAAiB,CAACN,EAAQC,EAAU,KAAMC,GAEzC,OADS,IAAIV,KAAKA,KAAKe,OAAOD,GAEtC,CACH,CCde,SAASE,EAAiBC,EAAOC,EAAOC,GAE9C,OAAAF,EAAQ,KADQ,IAAVA,EAAcC,EAAQ,IAAMA,GACb,IAAMC,CACpC,CCHA,SAASC,IAAwS,OAA3RA,EAAWC,OAAOC,OAASD,OAAOC,OAAOC,OAAS,SAAUC,GAAU,IAAA,IAASC,EAAI,EAAGA,EAAIC,UAAUnB,OAAQkB,IAAK,CAAM,IAAAE,EAASD,UAAUD,GAAI,IAAA,IAASG,KAAOD,EAAcN,OAAOQ,UAAUC,eAAeC,KAAKJ,EAAQC,KAAeJ,EAAAI,GAAOD,EAAOC,IAAmB,OAAAJ,CAAS,EAASJ,EAASY,MAAMC,KAAMP,UAAa,CAMnV,MACMQ,EAAOC,KACPC,EAAMF,MACNG,EAAa,EAAND,EACPE,EAAc,GAANF,EACRG,EAAa,IAANH,EACPI,EAAa,IAAMxC,KAAKyC,MACf,SAASC,GAAQ5C,KAC9BA,EAAA6C,UACAA,EAAY3B,EAAA4B,UACZA,EAAY,OAAAC,KACZA,GAAO,EAAAC,UACPA,EAAY,EAAAC,UACZA,EAAYV,EAAAW,MACZA,EAAAP,IACAA,EAAMD,KACHS,IAEH,MAAOC,EAASC,GAAcC,EAAAA,SAASX,KACvCY,EAAAA,WAAU,KACR,IAAKR,EACH,OAEF,MAgBMS,EAhBO,MAC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