package model

import (
	"time"

	"gorm.io/gorm"
)

// Team represents an agent team within an account.
// Reference: Chatwoot Team model + P2B M5 spec
type Team struct {
	ID          uint           `gorm:"primaryKey" json:"id"`
	AccountID   uint           `gorm:"not null;index" json:"account_id"`
	Name        string         `gorm:"size:255;not null" json:"name"`
	Description string         `gorm:"type:text" json:"description"`
	AllowAutoAssignment bool   `gorm:"default:true" json:"allow_auto_assignment"`
	CreatedAt   time.Time      `gorm:"autoCreateTime" json:"created_at"`
	UpdatedAt   time.Time      `gorm:"autoUpdateTime" json:"updated_at"`
	DeletedAt   gorm.DeletedAt `gorm:"index" json:"deleted_at,omitempty"`

	Account  Account      `gorm:"foreignKey:AccountID" json:"account,omitempty"`
	Members  []TeamMember `gorm:"foreignKey:TeamID" json:"members,omitempty"`
}

func (Team) TableName() string { return "teams" }