import type { ToastType } from '../types/toast';

const SIMPLE_TOAST_DURATION_MS = 2500;
const DETAILED_TOAST_DURATION_MS = 4000;

export function getAutoDismissDuration(
  hasDetails: boolean,
  type: ToastType,
  duration?: number,
): number | null {
  if (duration !== undefined) {
    return duration;
  }

  if (type === 'loading') {
    return null;
  }

  return hasDetails ? DETAILED_TOAST_DURATION_MS : SIMPLE_TOAST_DURATION_MS;
}
