/// Frequency interval types for recurring tasks.
///
/// IMPORTANT: Never reorder or remove values - intEnum stores the .index.
/// Always add new values at the END.
enum IntervalType {
  daily, // 0
  everyNDays, // 1
  weekly, // 2
  biweekly, // 3
  monthly, // 4
  everyNMonths, // 5
  quarterly, // 6
  yearly, // 7
}

/// A frequency interval combining a type with an optional multiplier.
class FrequencyInterval {
  final IntervalType intervalType;
  final int days;

  const FrequencyInterval({required this.intervalType, this.days = 1});

  /// German display label for this interval.
  String label() {
    switch (intervalType) {
      case IntervalType.daily:
        return 'Taeglich';
      case IntervalType.everyNDays:
        if (days == 7) return 'Woechentlich';
        if (days == 14) return 'Alle 2 Wochen';
        return 'Alle $days Tage';
      case IntervalType.weekly:
        return 'Woechentlich';
      case IntervalType.biweekly:
        return 'Alle 2 Wochen';
      case IntervalType.monthly:
        return 'Monatlich';
      case IntervalType.everyNMonths:
        if (days == 3) return 'Vierteljaehrlich';
        if (days == 6) return 'Halbjaehrlich';
        return 'Alle $days Monate';
      case IntervalType.quarterly:
        return 'Vierteljaehrlich';
      case IntervalType.yearly:
        return 'Jaehrlich';
    }
  }

  /// All preset frequency intervals per TASK-04.
  static const List<FrequencyInterval> presets = [
    FrequencyInterval(intervalType: IntervalType.daily),
    FrequencyInterval(intervalType: IntervalType.everyNDays, days: 2),
    FrequencyInterval(intervalType: IntervalType.everyNDays, days: 3),
    FrequencyInterval(intervalType: IntervalType.weekly),
    FrequencyInterval(intervalType: IntervalType.biweekly),
    FrequencyInterval(intervalType: IntervalType.monthly),
    FrequencyInterval(intervalType: IntervalType.everyNMonths, days: 2),
    FrequencyInterval(intervalType: IntervalType.quarterly),
    FrequencyInterval(intervalType: IntervalType.everyNMonths, days: 6),
    FrequencyInterval(intervalType: IntervalType.yearly),
  ];
}
