import { ApiProperty } from "@nestjs/swagger";
import { IsBoolean, IsDefined, IsEnum, IsNotEmpty, IsNumber, IsOptional, IsString, ValidateIf } from "class-validator";


export class ImageDto {
	@ApiProperty({ example: 'Generate an image of a city at night', required: true, description: 'prompt' })
	@IsString({ message: 'Prompt must be a string' })
	prompt: string;

	@ApiProperty({ example: 2, required: false, description: 'Samples to generate' })
	@IsOptional()
	@IsNumber({}, { message: 'Samples must be a number' })
	samples?: number;

	@ApiProperty({ example: 'cinematic', required: false, description: 'style_preset' })
	@IsOptional()
	@IsString({ message: 'Style preset must be a string' })
	style_preset?: string;

	@ApiProperty({ example: false, required: false, description: 'isExample' })
	@IsOptional()
	@IsBoolean({ message: 'isExample must be a boolean' })
	isExample?: boolean;

	@ApiProperty({ example: 1, description: 'sampleNumber' })
	@ValidateIf((obj) => obj.isExample === true || obj.isExample === "true")
	@IsDefined()
	sampleNumber: number;

	@ApiProperty({ example: 'flux', description: 'Model ID from admin configuration' })
	@IsOptional()
	@IsString({ message: 'Model must be a string' })
	model?: string;

	@ApiProperty({ example: '16:9', required: false, description: 'aspect ratio (1:1 / 16:9 / 9:16 / 4:3 / 3:2)' })
	@IsOptional()
	@IsString({ message: 'aspect_ratio must be a string' })
	aspect_ratio?: string;

}

export class ImageToImageDto {
	@ApiProperty({ type: 'string', required: true, format: 'binary' })
	file: any;

	@ApiProperty({ example: 'Generate an image of a city at night', required: true, description: 'prompt' })
	@IsString({ message: 'Prompt must be a string' })
	prompt: string;

	@ApiProperty({ example: 2, required: false, description: 'Samples to generate' })
	@IsOptional()
	@IsNumber({}, { message: 'Samples must be a number' })
	samples?: number;

	@ApiProperty({ example: 'cinematic', required: false, description: 'style_preset' })
	@IsOptional()
	@IsString({ message: 'Style preset must be a string' })
	style_preset?: string;

	@ApiProperty({ example: 'pro-ultra', description: 'Model ID from admin configuration' })
	@IsOptional()
	@IsString({ message: 'Model must be a string' })
	model?: string;

	@ApiProperty({ example: '16:9', required: false, description: 'aspect ratio' })
	@IsOptional()
	@IsString({ message: 'aspect_ratio must be a string' })
	aspect_ratio?: string;
}


enum DimensionType {
	Height = 'height',
	Width = 'width',
}

export class ImageUpscaleDto {
	@ApiProperty({ example: 'height', required: false, description: 'type' })
	@IsOptional()
	@IsEnum(DimensionType, { message: 'Type must be either "height" or "width"' })
	type?: DimensionType;

	@ApiProperty({ example: 1024, required: false })
	@IsOptional()
	// @IsNumber({}, { message: 'Scale must be a number' })
	scale?: number;

	@ApiProperty({ example: 'high quality image', required: false, description: 'prompt' })
	@IsString({ message: 'Prompt must be a string' })
	@IsOptional()
	prompt: string;

	@ApiProperty({ type: 'string', required: true, format: 'binary' })
	file: any;
}
