package chat

import "time"

type Principal struct {
	Type string
	ID   uint64
}

type ConversationDTO struct {
	ID                 uint64           `json:"id"`
	OrderID            *uint64          `json:"order_id"`
	Type               string           `json:"type"`
	Title              string           `json:"title"`
	Status             string           `json:"status"`
	Role               string           `json:"role"`
	Participants       []ParticipantDTO `json:"participants,omitempty"`
	LastMessageID      *uint64          `json:"last_message_id"`
	LastMessagePreview string           `json:"last_message_preview"`
	LastMessageAt      *time.Time       `json:"last_message_at"`
	UnreadCount        int64            `json:"unread_count"`
	CreatedAt          time.Time        `json:"created_at"`
	UpdatedAt          time.Time        `json:"updated_at"`
}

type ParticipantDTO struct {
	ID              uint64     `json:"id"`
	ConversationID  uint64     `json:"conversation_id"`
	ParticipantType string     `json:"participant_type"`
	ParticipantID   uint64     `json:"participant_id"`
	Role            string     `json:"role"`
	Remark          string     `json:"remark"`
	DisplayName     string     `json:"display_name"`
	AvatarURL       string     `json:"avatar_url"`
	LastReadAt      *time.Time `json:"last_read_at"`
	JoinedAt        time.Time  `json:"joined_at"`
}

type MessageDTO struct {
	ID             uint64    `json:"id"`
	ConversationID uint64    `json:"conversation_id"`
	SenderType     string    `json:"sender_type"`
	SenderID       uint64    `json:"sender_id"`
	SenderRole     string    `json:"sender_role"`
	SenderName     string    `json:"sender_name"`
	SenderAvatar   string    `json:"sender_avatar"`
	IsSelf         bool      `json:"is_self"`
	ContentType    string    `json:"content_type"`
	Content        string    `json:"content"`
	AttachmentURLS []string  `json:"attachment_urls"`
	CreatedAt      time.Time `json:"created_at"`
}

type SendMessageRequest struct {
	Content        string   `json:"content"`
	AttachmentURLS []string `json:"attachment_urls"`
}

type TransferRequest struct {
	ToAdminID uint64 `json:"to_admin_id" binding:"required"`
}

type UpdateRemarkRequest struct {
	Remark string `json:"remark"`
}

type SupportAdminDTO struct {
	ID            uint64 `json:"id"`
	Nickname      string `json:"nickname"`
	SupportStatus string `json:"support_status"`
	ChatCount     int64  `json:"chat_count"`
}

type QuickReplyDTO struct {
	ID          uint64 `json:"id"`
	AdminUserID uint64 `json:"admin_user_id"`
	Title       string `json:"title"`
	Content     string `json:"content"`
	SortOrder   int    `json:"sort_order"`
	IsGlobal    bool   `json:"is_global"`
}

type CreateQuickReplyRequest struct {
	Title     string `json:"title" binding:"required"`
	Content   string `json:"content" binding:"required"`
	SortOrder int    `json:"sort_order"`
	IsGlobal  bool   `json:"is_global"`
}

type UpdateQuickReplyRequest struct {
	Title     string `json:"title"`
	Content   string `json:"content"`
	SortOrder *int   `json:"sort_order"`
}

type PaginatedResult struct {
	Items    interface{} `json:"items"`
	Total    int64       `json:"total"`
	Page     int         `json:"page"`
	PageSize int         `json:"page_size"`
}
