import type { ScreenplayElementType } from '../screenplay/types';

export type RevisionStatus = 'draft' | 'pending_review' | 'accepted' | 'rejected';
export type ChangeType = 'addition' | 'deletion' | 'modification';

export interface RevisionData {
  id: number;
  scriptId: number;
  versionNumber: number;
  branchName: string;
  parentRevisionId: number | null;
  title: string;
  summary: string | null;
  content: string;
  authorId: number;
  status: RevisionStatus;
  reviewedById: number | null;
  reviewedAt: Date | null;
  createdAt: Date;
  updatedAt: Date;
}

export interface RevisionChangeData {
  id: number;
  revisionId: number;
  changeType: ChangeType;
  elementType: ScreenplayElementType | null;
  oldContent: string | null;
  newContent: string | null;
  sceneNumber: number | null;
  lineNumber: number | null;
  pageNumber: number | null;
  createdAt: Date;
}

export interface DiffResult {
  additions: number;
  deletions: number;
  modifications: number;
  changes: RevisionChangeData[];
}

export interface RevisionComparison {
  baseRevision: RevisionData;
  targetRevision: RevisionData;
  diff: DiffResult;
  baseContent: string;
  targetContent: string;
}

export interface CreateRevisionInput {
  scriptId: number;
  title: string;
  summary?: string;
  content: string;
  branchName?: string;
  parentRevisionId?: number;
  authorId: number;
}

export interface AcceptRevisionInput {
  revisionId: number;
  reviewedById: number;
}

export interface RejectRevisionInput {
  revisionId: number;
  reviewedById: number;
  reason?: string;
}

export interface RollbackRevisionInput {
  scriptId: number;
  revisionId: number;
  authorId: number;
}

export interface RevisionTimelineEntry {
  revision: RevisionData;
  changeCount: number;
  additions: number;
  deletions: number;
  modifications: number;
}

export interface BranchInfo {
  branchName: string;
  revisionCount: number;
  latestVersion: number;
  latestRevision: RevisionData | null;
}
