/**
 * Private Gallery Types
 * TypeScript interfaces for the Private Gallery feature
 */

export interface PrivateMediaRelationship {
  id: number
  name: string
  color: string
  created_at?: string
}

export interface PrivateMediaPerson {
  id: number
  name: string
  sort_name?: string | null
  relationship_id: number
  relationship: PrivateMediaRelationship
  created_at?: string
  updated_at?: string
}

export interface PrivateMediaTag {
  id: number
  name: string
  slug: string
  color: string
  description?: string | null
}

export interface PrivateMediaItem {
  id: number
  storage_id: string
  filename: string
  description?: string | null
  file_hash: string
  file_size: number
  file_type: 'image' | 'video' | 'other'
  mime_type: string
  width?: number | null
  height?: number | null
  duration?: number | null
  person_id?: number | null
  person?: {
    id: number
    name: string
    relationship: PrivateMediaRelationship
  } | null
  media_date: string
  source_type?: string | null
  source_path?: string | null
  thumbnail_url: string
  stream_url: string
  file_url: string
  tags: PrivateMediaTag[]
  created_at: string
  updated_at: string
}

export interface PrivateMediaAlbum {
  person_id: number
  person_name: string
  relationship: PrivateMediaRelationship
  item_count: number
  cover_thumbnail_url?: string | null
}

export interface PrivateGalleryFilters {
  date_from?: string
  date_to?: string
  person_id?: number
  relationship_id?: number
  tag_ids?: number[]
  file_type?: 'image' | 'video' | 'all'
  search?: string
  sort_by: 'media_date' | 'created_at' | 'filename'
  sort_order: 'asc' | 'desc'
}

export interface PrivateGalleryConfig {
  storage_path: string
  thumbnail_path: string
  organize_by_person: boolean
  organize_by_date: boolean
  auto_lock_minutes: number
  is_setup_complete: boolean
}

export interface PrivateGalleryStatus {
  is_setup_complete: boolean
  is_unlocked: boolean
  active_sessions: number
}

export interface CopyToGalleryData {
  source_paths: string[]
  person_id: number
  tag_ids: number[]
  media_date?: string
  description?: string
}

export interface UploadFormData {
  files?: File[]
  person_id: number
  tag_ids: number[]
  media_date?: string
  description?: string
}

export interface PrivateGalleryStats {
  total_items: number
  total_size: number
  total_persons: number
  by_type: Record<string, number>
  by_person_count: Record<number, number>
  recent_7d: number
  storage_used: number
}

export interface PrivateMediaResponse {
  items: PrivateMediaItem[]
  total: number
  offset: number
  limit: number
  has_more: boolean
}

export interface UploadResult {
  id?: number
  filename: string
  status: 'created' | 'duplicate' | 'failed'
  existing_id?: number
  media_date?: string
  error?: string
}

export interface CopyResult {
  id?: number
  path: string
  status: 'created' | 'duplicate' | 'failed'
  existing_id?: number
  media_date?: string
  error?: string
}

export interface ImportAuthEntry {
  id: number
  domain: string
  auth_type: 'basic' | 'cookies' | 'both'
  has_username: boolean
  has_password: boolean
  cookies_count: number
  user_agent?: string | null
  notes?: string | null
  created_at: string
  updated_at: string
}
