// 📁 csv-importer.interface.ts
// Interfaces para o componente de importação de CSV

export interface CsvFile {
  id: string;
  file: File;
  fileName: string;
  size: number;
  status: CsvFileStatus;
  validationResult?: CsvValidationResult;
  uploadedFileId?: string;
  uploadProgress?: number;
  createdAt: Date;
}

export type CsvFileStatus = 
  | 'pending'     // Arquivo selecionado, aguardando validação
  | 'validating'  // Validando no servidor
  | 'validated'   // Validado com sucesso
  | 'error'       // Erro de validação
  | 'uploading'   // Fazendo upload
  | 'uploaded'    // Upload concluído
  | 'importing'   // Fazendo importação
  | 'imported'    // Importação concluída
  | 'failed';     // Falha geral

export interface CsvValidationResult {
  valid: boolean;
  errors?: string[];
  warnings?: string[];
  totalRows?: number;
  validRows?: number;
  invalidRows?: number;
  preview?: {
    headers: string[];
    rows: string[][];
    totalRows: number;
    previewRows: number;
  };
  summary?: {
    totalRecords: number;
    validRecords: number;
    invalidRecords: number;
  };
}

export interface CsvValidationResponse {
  success: boolean;
  data?: CsvValidationResult;
  message?: string;
  errors?: string[];
}

export interface ImportResult {
  success: boolean;
  data?: {
    imported: number;
    failed: number;
    total: number;
    failedRecords?: any[];
  };
  message: string;
  errors?: string[];
}

export interface CsvImporterConfig {
  maxSizeMb: number;
  allowedExtensions: string[];
  allowMultiple: boolean;
  showPreview: boolean;
  autoUpload: boolean;
  validateEndpoint: string;
  importEndpoint: string;
  modalTitle?: string;
  modalWidth?: string;
  acceptMessage?: string;
}

export interface CsvImporterModalData {
  config: CsvImporterConfig;
  title?: string;
  subtitle?: string;
}

// 📊 Eventos emitidos pelo componente
export interface CsvImporterEvents {
  fileSelected: CsvFile;
  validationCompleted: CsvValidationResult;
  uploadCompleted: string; // fileId
  importCompleted: ImportResult;
  error: string;
  statusChanged: { file: CsvFile; status: CsvFileStatus };
} 