import { IsEmail, IsNotEmpty, IsString, IsOptional, IsNumber, IsArray, ArrayNotEmpty, IsBoolean, IsEnum } from "class-validator";
import { ApiProperty } from '@nestjs/swagger';
import { Types } from 'mongoose';
import { Transform } from "class-transformer";
import { AgentStatus } from "../../model/schema/agent.schema";

export class agentCreate {

    @ApiProperty({})
    @IsString()
    @IsOptional()
    name: string;

    @ApiProperty({})
    @IsString()
    @IsOptional()
    type: string;

    @ApiProperty({})
    @IsString()
    @IsOptional()
    voice: string;

    @ApiProperty({})
    @IsString()
    @IsOptional()
    image: string;

    @ApiProperty({})
    @IsString()
    @IsOptional()
    chat_first_message: string;

    @ApiProperty({})
    @IsString()
    @IsOptional()
    chat_prompt: string;

    @ApiProperty({})
    @IsString()
    @IsOptional()
    call_first_message: string;

    @ApiProperty({})
    @IsString()
    @IsOptional()
    call_prompt: string;

    @ApiProperty({ required: false })
    @IsString()
    @IsOptional()
    phone_no: string;

    @ApiProperty()
    @IsString()
    @IsOptional()
    twilio_config: string;

    @ApiProperty({ required: false })
    @IsString()
    @IsOptional()
    country_code: string;

    @ApiProperty({})
    @IsArray()
    @IsOptional()
    knowledge_base_id: string[];

    @ApiProperty({ required: false })
    @IsString()
    @IsOptional()
    ai_model: string

    @ApiProperty({ required: false })
    @IsBoolean()
    @IsOptional()
    idle_reminder: boolean

    @ApiProperty({ required: false })
    @IsBoolean()
    @IsOptional()
    call_cut_ability: boolean

    // @Prop({ type: String, default: null })
    // call_limit: string = null

    @ApiProperty({ required: false })
    @IsString()
    @IsOptional()
    call_limit_duration: string = null

    @ApiProperty({ required: false })
    @IsBoolean()
    @IsOptional()
    call_transfer: boolean

    @ApiProperty({ required: false })
    @IsBoolean()
    @IsOptional()
    send_message: boolean

    @ApiProperty({ required: false })
    @IsBoolean()
    @IsOptional()
    real_time_booking: boolean

    @ApiProperty({ required: false })
    @IsString()
    @IsOptional()
    ai_model_version: string

}

export class agentEdit {

    @ApiProperty({})
    @IsString()
    @IsOptional()
    name: string;

    @ApiProperty({})
    @IsString()
    @IsOptional()
    image: string;

    @ApiProperty({})
    @IsString()
    @IsOptional()
    chat_first_message: string;

    @ApiProperty({})
    @IsString()
    @IsOptional()
    chat_prompt: string;

    @ApiProperty({})
    @IsString()
    @IsOptional()
    call_first_message: string;

    @ApiProperty({})
    @IsString()
    @IsOptional()
    call_prompt: string;
    
    @ApiProperty({})
    @IsArray()
    @IsOptional()
    knowledge_base_id: string[];

    @ApiProperty({ required: false })
    @IsString()
    @IsOptional()
    ai_model: string

    @ApiProperty({})
    @IsString()
    @IsOptional()
    voice: string;

    @ApiProperty()
    @IsString()
    @IsOptional()
    twilio_config: string;

}

export class get_agent {

    @Transform(({ value }) => parseInt(value))
    @ApiProperty({ required: false })
    @IsNumber()
    @IsOptional()
    pagination: number;

    @Transform(({ value }) => parseInt(value))
    @ApiProperty({ required: false })
    @IsNumber()
    @IsOptional()
    limit: number;
}

export class defaultAgentCreate {

    @ApiProperty({})
    @IsString()
    @IsOptional()
    name: string;

    @ApiProperty({})
    @IsString()
    @IsOptional()
    image: string;

    @ApiProperty({})
    @IsString()
    @IsOptional()
    first_message: string;

    @ApiProperty({ required: false })
    @IsString()
    @IsOptional()
    type: string;

    @ApiProperty({ required: false })
    @IsString()
    @IsOptional()
    voice: string;

    @ApiProperty({})
    @IsString()
    @IsOptional()
    prompt: string;


    @ApiProperty({ required: false })
    @IsString()
    @IsOptional()
    ai_model: string

    @ApiProperty({ required: false })
    @IsString()
    @IsOptional()
    ai_model_version: string

    @ApiProperty({ required: false })
    @IsBoolean()
    @IsOptional()
    idle_reminder: boolean

    @ApiProperty({ required: false })
    @IsBoolean()
    @IsOptional()
    call_cut_ability: boolean

    // @Prop({ type: String, default: null })
    // call_limit: string = null

    @ApiProperty({ required: false })
    @IsString()
    @IsOptional()
    call_limit_duration: string = null

    @ApiProperty({ required: false })
    @IsBoolean()
    @IsOptional()
    call_transfer: boolean

    @ApiProperty({ required: false })
    @IsBoolean()
    @IsOptional()
    send_message: boolean

    @ApiProperty({ required: false })
    @IsBoolean()
    @IsOptional()
    real_time_booking: boolean

    @ApiProperty({ required: false })
    @IsString()
    @IsOptional()
    phone_no: string;
}

export enum callType {
    CALL = "CALL",
    CHAT = "CHAT",
    VOICE_CHAT = "VOICE_CHAT"
}
export class get_agent_chat {
    
    @ApiProperty({ required: false, enum: callType, default: callType.CHAT })
    @IsOptional()
    @IsString()
    type: string;

    @ApiProperty({ required: false, default:null })
    @IsOptional()
    @IsString()
    search: string;

    @Transform(({ value }) => parseInt(value))
    @ApiProperty({ required: false })
    @IsNumber()
    @IsOptional()
    pagination: number;

    @Transform(({ value }) => parseInt(value))
    @ApiProperty({ required: false })
    @IsNumber()
    @IsOptional()
    limit: number;

}


export class websiteDefaultAgent {

    // @ApiProperty({ required: false })
    // @IsString()
    // @IsOptional()
    // name: string;

    @ApiProperty({ required: false })
    @IsString()
    @IsOptional()
    voice: string;

    @ApiProperty({ required: true })
    @IsArray()
    @IsOptional()
    knowledge_base_id_for_website: string[]

    @ApiProperty({})
    @IsString()
    @IsOptional()
    chat_first_message: string;

    @ApiProperty({})
    @IsString()
    @IsOptional()
    chat_prompt: string;

    @ApiProperty({})
    @IsString()
    @IsOptional()
    call_first_message: string;

    @ApiProperty({})
    @IsString()
    @IsOptional()
    call_prompt: string;

    @ApiProperty({})
    @IsString()
    @IsOptional()
    ai_model: string;
}

export class agentStatusEdit {

    @ApiProperty({ required: true })
    @IsString()
    agent_id: string;

    @ApiProperty({
        description: 'The status of the agent',
        enum: AgentStatus,
        example: AgentStatus.ACTIVE,
    })
    @IsEnum(AgentStatus)
    status: string;
}
