import { User, Author, Work, Translation, Tag, Comment, ReadingProgress } from "@shared/schema";

// Extended types with additional properties for the frontend

export interface WorkWithAuthor extends Work {
  author?: Author;
  tags?: Tag[];
  likes?: number;
}

export interface WorkWithDetails extends WorkWithAuthor {
  translations?: Translation[];
  comments?: CommentWithUser[];
}

export interface TranslationWithDetails extends Translation {
  translator?: User;
}

export interface CommentWithUser extends Comment {
  user?: Omit<User, 'password'>;
  replies?: CommentWithUser[];
}

export interface BookmarkWithWork {
  id: number;
  userId: number;
  workId: number;
  createdAt: Date;
  work: Work;
}

export interface CollectionWithItems {
  id: number;
  name: string;
  slug: string;
  description?: string;
  userId: number;
  isPublic: boolean;
  createdAt: Date;
  items: {
    id: number;
    collectionId: number;
    workId: number;
    order: number;
    addedAt: Date;
    work: Work;
  }[];
}

export interface AuthorWithWorks extends Author {
  works: WorkWithAuthor[];
}

export interface TimelineEventWithAuthor {
  id: number;
  authorId: number;
  year: number;
  title: string;
  description?: string;
  createdAt: Date;
  author: Author;
}

export interface SearchResults {
  works: Work[];
  authors: Author[];
}

export interface FilterParams {
  language?: string;
  type?: string;
  yearStart?: number;
  yearEnd?: number;
  tags?: number[];
}

export interface ReadingContext {
  workId: number;
  translationId?: number;
  progress: number;
  fontSizeClass: string;
  zenMode: boolean;
}

export interface Annotation {
  id: number;
  workId: number;
  translationId?: number;
  lineNumber: number;
  userId: number;
  userName: string;
  userAvatar: string | null;
  content: string;
  createdAt: Date;
  likes: number;
  liked: boolean;
}

export interface BlogPostWithDetails {
  id: number;
  title: string;
  slug: string;
  content: string;
  authorId: number;
  excerpt?: string;
  publishedAt: Date | null;
  createdAt: Date;
  author?: Omit<User, 'password'>;
  tags?: Tag[];
  commentCount?: number;
  likeCount?: number;
  comments?: CommentWithUser[];
}

export interface BlogPostListItem {
  id: number;
  title: string;
  slug: string;
  excerpt?: string;
  publishedAt: Date | null;
  createdAt: Date;
  author?: {
    id: number;
    displayName: string | null;
    avatar: string | null;
  };
  tags?: Tag[];
  commentCount: number;
  likeCount: number;
}
