using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

namespace Intentor.Models;

public class IntentActivation
{
    [Key]
    public long Id { get; set; }

    [Required]
    public int SpaceId { get; set; }

    [ForeignKey(nameof(SpaceId))]
    public Space Space { get; set; } = null!;

    [Required]
    public int IntentId { get; set; }

    [ForeignKey(nameof(IntentId))]
    public Intent Intent { get; set; } = null!;

    /// <summary>
    /// When this activation was created. Useful for tie-breaking.
    /// </summary>
    public DateTimeOffset CreatedAt { get; set; } = DateTimeOffset.UtcNow;

    /// <summary>
    /// If set: activation automatically expires at this time.
    /// If null: activation stays until explicitly removed.
    /// </summary>
    public DateTimeOffset? Until { get; set; }

    /// <summary>
    /// Optional: who/what created this activation (e.g. "ha:binary_sensor.hallway_motion").
    /// Helps you update/remove a specific activation later.
    /// </summary>
    [MaxLength(200)]
    public string? Source { get; set; }
}
