import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
import { Transform, Type } from 'class-transformer';
import { IsNumber, IsOptional, IsString, IsUrl, Length, Max, Min } from 'class-validator';

export class ProfileSetupDto {
  @ApiPropertyOptional({ example: 'Artist One' })
  @IsOptional()
  @IsString()
  @Length(1, 80)
  stageName?: string;

  @ApiPropertyOptional({ example: 'https://cdn.example.com/avatar.jpg' })
  @IsOptional()
  @IsUrl({ require_tld: false })
  avatar?: string;

  @ApiPropertyOptional({ example: 'https://cdn.example.com/profile-cover.jpg' })
  @IsOptional()
  @IsUrl({ require_tld: false })
  coverImage?: string;

  @ApiPropertyOptional({ example: 'Short bio about me', maxLength: 150 })
  @IsOptional()
  @IsString()
  @Length(0, 150)
  bio?: string;

  @ApiPropertyOptional({ example: 'Riyadh, Saudi Arabia' })
  @IsOptional()
  @IsString()
  @Length(0, 120)
  location?: string;

  @ApiPropertyOptional({ example: 'طربي', maxLength: 80 })
  @IsOptional()
  @IsString()
  @Length(0, 80)
  preferredMood?: string;

  @ApiProperty({ example: 24.7136, minimum: -90, maximum: 90 })
  @Transform(({ value }) => (typeof value === 'string' ? Number.parseFloat(value) : value))
  @Type(() => Number)
  @IsNumber()
  @Min(-90)
  @Max(90)
  latitude!: number;

  @ApiProperty({ example: 46.6753, minimum: -180, maximum: 180 })
  @Transform(({ value }) => (typeof value === 'string' ? Number.parseFloat(value) : value))
  @Type(() => Number)
  @IsNumber()
  @Min(-180)
  @Max(180)
  longitude!: number;
}
