import { IsString, IsNumber, IsArray, IsOptional, ValidateNested, IsEnum } from 'class-validator';
import { Type } from 'class-transformer';

export enum DrawingTool {
  PEN = 'pen',
  ERASER = 'eraser',
  LINE = 'line',
  RECTANGLE = 'rectangle',
  CIRCLE = 'circle',
  TEXT = 'text',
}

export class Point {
  @IsNumber()
  x: number;

  @IsNumber()
  y: number;
}

export class WhiteboardDrawDto {
  @IsString()
  whiteboardId: string;

  @IsEnum(DrawingTool)
  tool: DrawingTool;

  @IsArray()
  @ValidateNested({ each: true })
  @Type(() => Point)
  points: Point[];

  @IsString()
  @IsOptional()
  color?: string;

  @IsNumber()
  @IsOptional()
  lineWidth?: number;

  @IsString()
  @IsOptional()
  text?: string;

  @IsString()
  userId: string;
}

export class WhiteboardClearDto {
  @IsString()
  whiteboardId: string;

  @IsString()
  userId: string;
}

export class WhiteboardJoinDto {
  @IsString()
  whiteboardId: string;

  @IsString()
  userId: string;
}

export class WhiteboardCursorDto {
  @IsString()
  whiteboardId: string;

  @IsString()
  userId: string;

  @IsNumber()
  x: number;

  @IsNumber()
  y: number;
}
