// src/types/youtube.ts

/**
 * YouTube API Type Definitions
 * Für Community Management Phase 2.2
 */

export interface YouTubeComment {
  id: string
  snippet: {
    videoId: string
    topLevelComment: {
      id: string
      snippet: {
        textDisplay: string
        textOriginal: string
        authorDisplayName: string
        authorProfileImageUrl: string
        authorChannelUrl: string
        authorChannelId: { value: string }
        likeCount: number
        publishedAt: string
        updatedAt: string
      }
    }
    totalReplyCount: number
    canReply: boolean
  }
}

export interface YouTubeCommentThread {
  kind: string
  etag: string
  id: string
  snippet: YouTubeComment['snippet']
  replies?: {
    comments: Array<{
      id: string
      snippet: {
        textDisplay: string
        textOriginal: string
        authorDisplayName: string
        authorProfileImageUrl: string
        authorChannelUrl: string
        authorChannelId: { value: string }
        parentId: string
        likeCount: number
        publishedAt: string
        updatedAt: string
      }
    }>
  }
}

export interface SyncResult {
  accountId: number
  accountName: string
  videosProcessed: number
  newComments: number
  updatedComments: number
  errors: string[]
  duration: number
}

export interface SyncJobStatus {
  isRunning: boolean
  lastRunAt: string | null
  lastResult: SyncResult[] | null
  nextRunAt: string | null
}

export interface YouTubeCredentials {
  clientId: string
  clientSecret: string
  accessToken: string
  refreshToken: string
}

export interface YouTubeTokens {
  access_token: string
  refresh_token?: string
  expires_in?: number
  token_type?: string
}

export interface ReplyContext {
  channelName: string
  channelType: 'corporate' | 'lifestyle' | 'business'
  videoTitle: string
  videoTopics: string[]
  commentText: string
  commentSentiment: string
  authorName: string
  isMedicalQuestion: boolean
  previousReplies?: string[]
}

export interface GeneratedReply {
  text: string
  tone: string
  confidence: number
  alternatives: string[]
  warnings: string[]
}
