import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
import { IsISO8601, IsNumber, IsOptional, IsString } from 'class-validator';

export class TrackingLocationUpdateDto {
  @ApiPropertyOptional({ description: 'Display id (same as tripId uuid)' })
  @IsOptional()
  @IsString()
  requestId?: string;

  @ApiProperty()
  @IsString()
  tripId: string;

  @ApiProperty()
  @IsNumber()
  latitude: number;

  @ApiProperty()
  @IsNumber()
  longitude: number;

  @ApiProperty({ example: '2026-06-16T09:00:00.000Z' })
  @IsISO8601()
  timestamp: string;

  @ApiPropertyOptional()
  @IsOptional()
  @IsNumber()
  speed?: number;

  @ApiPropertyOptional({ description: 'Alias for bearing' })
  @IsOptional()
  @IsNumber()
  heading?: number;

  @ApiPropertyOptional()
  @IsOptional()
  @IsNumber()
  bearing?: number;

  @ApiPropertyOptional()
  @IsOptional()
  @IsNumber()
  accuracy?: number;

  @ApiPropertyOptional()
  @IsOptional()
  @IsString()
  address?: string;

  @ApiPropertyOptional({ description: 'Client idempotency key' })
  @IsOptional()
  @IsString()
  pointId?: string;
}

export class TrackingJoinDto {
  @ApiProperty()
  @IsString()
  tripId: string;
}

export type LiveLocationPayload = {
  requestId: string;
  tripId: string;
  userId: string;
  latitude: number;
  longitude: number;
  timestamp: string;
  speed?: number;
  heading?: number;
  accuracy?: number;
  address?: string;
  pointId?: string;
};
