import type { ScreenplayElement, TemplateType } from '../screenplay/types';

export type ExportFormat = 'fountain' | 'fdx' | 'pdf' | 'screenplay-pro';

export interface ExportOptions {
  format: ExportFormat;
  template?: TemplateType;
  title?: string;
  author?: string;
  contact?: string;
  datetime?: string;
  pageNumber?: number;
  includeCoverPage?: boolean;
  gutterMargin?: number;
}

export interface ExportResult {
  format: ExportFormat;
  contentType: string;
  extension: string;
  data: string | Uint8Array;
  filename: string;
  pageCount?: number;
}

export interface ScreenplayExporter {
  readonly supportedFormats: readonly ExportFormat[];
  export(elements: ScreenplayElement[], options: ExportOptions): ExportResult;
}

export interface BatchExportOptions {
  title?: string;
  author?: string;
  contact?: string;
  template?: TemplateType;
  includeCoverPage?: boolean;
  gutterMargin?: number;
}

export interface BatchExportResult {
  formats: ExportFormat[];
  results: ExportResult[];
  errors: BatchExportError[];
}

export interface BatchExportError {
  format: ExportFormat;
  error: string;
}

export const CONTENT_TYPES: Record<ExportFormat, string> = {
  fountain: 'text/plain',
  fdx: 'application/xml',
  pdf: 'application/pdf',
  'screenplay-pro': 'text/plain',
};

export const EXTENSIONS: Record<ExportFormat, string> = {
  fountain: '.fountain',
  fdx: '.fdx',
  pdf: '.pdf',
  'screenplay-pro': '.sp',
};
