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AAG,IAAW,EAAU,MAAQ,KAAK,KAAO,IAAU,GAAW,EAAmB,GAAT,SAC1F,OAAO,EAAW,EAAW,IAAW,EAAU,C","file":"/npm/timerel@5.8.5/dist/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/timerel@5.8.5/dist/index.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","export type TimerelAnyDate = string | number | Date;\nexport type TimesArray = Array<[number, number, string]>;\n\nconst defaultTimes: TimesArray = [\n  [1e3, 6e4, \"sec\"],\n  [6e4, 36e5, \"min\"],\n  [36e5, 864e5, \"hour\"],\n  [864e5, 6048e5, \"day\"],\n  [6048e5, 2628e6, \"week\"],\n  [2628e6, 31536e6, \"month\"],\n  [31536e6, Infinity, \"year\"],\n];\n\nexport type AliasesMap = Record<string, string>;\n\nconst defaultAliasesMap: AliasesMap = {\n  \"1 day ago\": \"yesterday\",\n  \"1 week ago\": \"last week\",\n  \"1 month ago\": \"last month\",\n  \"1 year ago\": \"last year\",\n  \"in 1 day\": \"tomorrow\",\n  \"in 1 week\": \"next week\",\n  \"in 1 month\": \"next month\",\n  \"in 1 year\": \"next year\",\n};\n\nexport type UnitsMap = Record<string, string>;\n\nconst longUnitsMap: UnitsMap = {\n  sec: \"second\",\n  min: \"minute\",\n};\n\nexport type TimerelOpts = {\n  /** The date to compare to. Default: `Date.now()`. */\n  now?: Date | string | number,\n  /** Whether to omit `ago` and `in` affixes. Default: `false`. **/\n  noAffix?: boolean,\n  /** A custom time table that overrides the built-in one. **/\n  times?: TimesArray,\n  /** Number of milliseconds below which to output `\"now\"`. Default: 2000. */\n  nowThreshold?: number,\n  /** String to output for now. Default: `\"now\"`. */\n  nowString?: string,\n  /** String to output for invalid dates. Default: `String(date)`. */\n  unknownString?: string,\n  /** Use aliases like \"yesterday\" instead of \"1 day ago\". Default: `false`. */\n  aliases?: boolean,\n  /** A custom aliases object to use instead of the built-in one. */\n  aliasesMap?: AliasesMap,\n  /** Use minutes/secoonds instead of mins/secs. Default: `false`. */\n  longUnits?: boolean,\n};\n\nfunction toNum(date: TimerelAnyDate): number {\n  if (date instanceof Date) {\n    return date.getTime();\n  } else if (typeof date === \"string\") {\n    return Date.parse(date);\n  }\n  return date;\n}\n\n/** Format a date to a relative time format */\nexport function timerel(date: TimerelAnyDate, {now, noAffix = false, times = defaultTimes, nowThreshold = 2000, nowString = \"now\", unknownString = \"\", aliases = false, aliasesMap = defaultAliasesMap, longUnits = false}: TimerelOpts = {}): string {\n  const dateObj = toNum(date);\n  now = now !== undefined ? toNum(now) : Date.now();\n  if (Number.isNaN(dateObj)) return unknownString || String(date);\n\n  let future = false;\n  let diff = now - dateObj;\n\n  if (diff < 0) {\n    future = true;\n    diff = Math.abs(diff);\n  }\n  if (diff < nowThreshold) return nowString;\n\n  let num: number = 0;\n  let suffix: string = \"\";\n  for (let i = 0, len = times.length; i < len; i++) {\n    const time = times[i];\n    if (diff >= time[1]) continue;\n    num = Math.floor(diff / time[0]);\n    suffix = (longUnits ? longUnitsMap[time[2]] || time[2] : time[2]) + (num > 1 ? \"s\" : \"\");\n    break;\n  }\n\n  const result = `${future && !noAffix ? \"in \" : \"\"}${num} ${suffix}${!future && !noAffix ? \" ago\" : \"\"}`;\n  return aliases ? (aliasesMap[result] ?? result) : result;\n}\n"]}