import { IsString, IsOptional, IsEnum, IsUUID, IsArray, IsObject, IsInt, Min, IsUrl } from 'class-validator';
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
import { AssetType, AssetStatus } from '../entities/asset.entity';

export class CreateAssetDto {
  @ApiProperty({ description: 'Asset name' })
  @IsString()
  name: string;

  @ApiProperty({ description: 'Original file name' })
  @IsString()
  original_name: string;

  @ApiPropertyOptional({ description: 'Brand ID', format: 'uuid' })
  @IsOptional()
  @IsUUID()
  brand_id?: string;

  @ApiPropertyOptional({ enum: AssetType, default: AssetType.IMAGE })
  @IsOptional()
  @IsEnum(AssetType)
  type?: AssetType;

  @ApiProperty({ description: 'MIME type' })
  @IsString()
  mime_type: string;

  @ApiProperty({ description: 'File size in bytes' })
  @IsInt()
  @Min(0)
  size: number;

  @ApiProperty({ description: 'Asset URL' })
  @IsUrl()
  url: string;

  @ApiPropertyOptional({ description: 'Thumbnail URL' })
  @IsOptional()
  @IsUrl()
  thumbnail_url?: string;

  @ApiPropertyOptional({ description: 'Image/Video width' })
  @IsOptional()
  @IsInt()
  @Min(0)
  width?: number;

  @ApiPropertyOptional({ description: 'Image/Video height' })
  @IsOptional()
  @IsInt()
  @Min(0)
  height?: number;

  @ApiPropertyOptional({ description: 'Duration in seconds for video/audio' })
  @IsOptional()
  @IsInt()
  @Min(0)
  duration?: number;

  @ApiPropertyOptional({ description: 'Alternative text' })
  @IsOptional()
  @IsString()
  alt_text?: string;

  @ApiPropertyOptional({ description: 'Asset description' })
  @IsOptional()
  @IsString()
  description?: string;

  @ApiPropertyOptional({ description: 'Tags', type: [String] })
  @IsOptional()
  @IsArray()
  @IsString({ each: true })
  tags?: string[];

  @ApiPropertyOptional({ description: 'Additional metadata' })
  @IsOptional()
  @IsObject()
  metadata?: Record<string, any>;

  @ApiPropertyOptional({ enum: AssetStatus, default: AssetStatus.READY })
  @IsOptional()
  @IsEnum(AssetStatus)
  status?: AssetStatus;

  @ApiPropertyOptional({ description: 'Storage path' })
  @IsOptional()
  @IsString()
  storage_path?: string;

  @ApiPropertyOptional({ description: 'Storage provider (s3, gcs, local)' })
  @IsOptional()
  @IsString()
  storage_provider?: string;
}
