package model

import (
	"encoding/json"
	"time"
)

// CaptainScenario represents a pre-configured AI response scenario.
// Reference: P2B M10 spec
type CaptainScenario struct {
	ID          uint           `gorm:"primaryKey" json:"id"`
	AssistantID uint           `gorm:"not null;index" json:"assistant_id"`
	Name        string         `gorm:"size:255;not null" json:"name"`
	Trigger     string         `gorm:"size:255" json:"trigger"`
	Response    string         `gorm:"type:text" json:"response"`
	Conditions  json.RawMessage `gorm:"type:jsonb" json:"conditions"`
	Priority    int            `gorm:"default:0" json:"priority"`
	Active      bool           `gorm:"default:true" json:"active"`
	CreatedAt   time.Time      `gorm:"autoCreateTime" json:"created_at"`
	UpdatedAt   time.Time      `gorm:"autoUpdateTime" json:"updated_at"`

	Assistant CaptainAssistant `gorm:"foreignKey:AssistantID" json:"assistant,omitempty"`
}

func (CaptainScenario) TableName() string { return "captain_scenarios" }