/** Formats an ISO date as a short Arabic relative time string, e.g. "منذ ١٥ دقيقة". */
export function timeAgoAr(iso: string): string {
  const diffMs = Date.now() - new Date(iso).getTime();
  const minutes = Math.floor(diffMs / 60000);

  const ARABIC_DIGITS = ["٠", "١", "٢", "٣", "٤", "٥", "٦", "٧", "٨", "٩"];
  const toArabicDigits = (n: number) => n.toString().replace(/\d/g, (d) => ARABIC_DIGITS[Number(d)] ?? d);

  if (minutes < 1) return "الآن";
  if (minutes < 60) return `منذ ${toArabicDigits(minutes)} دقيقة`;

  const hours = Math.floor(minutes / 60);
  if (hours < 24) return `منذ ${toArabicDigits(hours)} ساعة`;

  const days = Math.floor(hours / 24);
  return `منذ ${toArabicDigits(days)} يوم`;
}
