// src/utils/date-parsing.ts
var RELATIVE_UNITS = {
  h: 36e5,
  d: 864e5,
  w: 6048e5,
  m: 2592e6
};
function parseRelativeDate(input) {
  if (input === "now") return Date.now();
  const match = input.match(/^(\d+)(h|d|w|m)$/);
  if (match) {
    const [, amount, unit] = match;
    return Date.now() - parseInt(amount) * (RELATIVE_UNITS[unit] ?? 864e5);
  }
  const parsed = Date.parse(input);
  if (Number.isNaN(parsed)) {
    throw new Error(
      `Invalid date: "${input}". Use a relative duration (e.g. "24h", "7d", "4w") or an ISO date string.`
    );
  }
  return parsed;
}

export {
  parseRelativeDate
};
//# sourceMappingURL=chunk-ZXKLPC2E.js.map