// Feed Types

export interface FeedItem {
  id: string;
  title: string;
  link?: string;
  description?: string;
  content?: string;
  author?: string;
  published?: Date;
  updated?: Date;
  categories?: string[];
  enclosure?: {
    url: string;
    type: string;
    length?: number;
  };
  guid?: string;
  subscriptionTitle?: string;
}

export interface Feed {
  id: string;
  title: string;
  link?: string;
  description?: string;
  subtitle?: string;
  language?: string;
  lastBuildDate?: Date;
  updated?: Date;
  generator?: string;
  ttl?: number;
  items: FeedItem[];
  rawUrl: string;
  lastFetchedAt?: Date;
  nextFetchAt?: Date;
}

export interface FeedSubscription {
  id: string;
  url: string;
  title: string;
  category?: string;
  enabled: boolean;
  fetchInterval: number; // in minutes
  createdAt: Date;
  updatedAt: Date;
  lastFetchedAt?: Date;
  nextFetchAt?: Date;
  error?: string;
  httpAuth?: {
    username: string;
    password: string;
  };
}

// Sync Interval Options
export type SyncInterval = {
  label: string;
  value: number; // in minutes
};

export const SYNC_INTERVALS: SyncInterval[] = [
  { label: 'Every 5 minutes', value: 5 },
  { label: 'Every 15 minutes', value: 15 },
  { label: 'Every 30 minutes', value: 30 },
  { label: 'Every hour', value: 60 },
  { label: 'Every 4 hours', value: 240 },
  { label: 'Every 8 hours', value: 480 },
  { label: 'Daily', value: 1440 },
  { label: 'Weekly', value: 10080 },
  { label: 'Monthly', value: 72000 },
];

// Notification Preferences
export interface NotificationPreferences {
  newArticles: boolean;
  episodeReleases: boolean;
  customAlerts: boolean;
  badgeCount: boolean;
  sound: boolean;
  vibration: boolean;
}

// Reading Preferences
export interface ReadingPreferences {
  fontSize: 'small' | 'medium' | 'large' | 'xlarge';
  lineHeight: 'normal' | 'relaxed' | 'loose';
  showTableOfContents: boolean;
  showReadingTime: boolean;
  showAuthor: boolean;
  showDate: boolean;
}

// Account Settings
export interface AccountSettings {
  email: string;
  notificationsEnabled: boolean;
  privacy: 'public' | 'private' | 'anonymous';
  language: string;
  timezone: string;
  theme: 'system' | 'light' | 'dark';
}

// Parse Result Types

export interface ParseResult {
  success: boolean;
  feed?: Feed;
  error?: string;
  feedType?: 'rss' | 'atom' | 'unknown';
}

// Search Types

export interface SearchQuery {
  query: string;
  page?: number;
  pageSize?: number;
}

export interface SearchFilters {
  dateFrom?: Date;
  dateTo?: Date;
  feedIds?: string[];
  authors?: string[];
  contentType?: 'article' | 'audio' | 'video';
}

export type SearchSortOption = 'relevance' | 'date_desc' | 'date_asc' | 'title_asc' | 'title_desc' | 'feed_asc' | 'feed_desc';

export interface SearchResult {
  id: string;
  type: 'article' | 'feed';
  title: string;
  snippet?: string;
  link?: string;
  feedTitle?: string;
  published?: Date;
  score?: number;
}

export interface SearchHistoryItem {
  id: string;
  query: string;
  timestamp: Date;
}
