package autobrr

import "encoding/json"

// Filter is autobrr's filter shape (subset of the REST API response).
// Phase 5 reads filter list + each filter's recent activity; future phases
// (Phase 13 bandit) extend this.
type Filter struct {
	ID             int    `json:"id"`
	Name           string `json:"name"`
	Enabled        bool   `json:"enabled"`
	Priority       int    `json:"priority"`
	MatchReleases  string `json:"match_releases,omitempty"`
	ExceptReleases string `json:"except_releases,omitempty"`
	UseRegex       bool   `json:"use_regex,omitempty"`
	Indexers       []any  `json:"indexers,omitempty"`
	Tags           []any  `json:"tags,omitempty"`
	CreatedAt      string `json:"created_at,omitempty"`
	UpdatedAt      string `json:"updated_at,omitempty"`

	// Extra captures fields we don't type. Useful for the detail view.
	Extra map[string]json.RawMessage `json:"-"`
}

// Release is one release-history row from autobrr's REST API.
type Release struct {
	ID         int    `json:"id"`
	FilterID   int    `json:"filter_id"`
	FilterName string `json:"filter,omitempty"`
	Name       string `json:"name"`
	Indexer    string `json:"indexer"`
	InfoHash   string `json:"info_hash,omitempty"`
	Size       int64  `json:"size,omitempty"`
	Status     string `json:"status,omitempty"`
	Timestamp  string `json:"timestamp"`
}

// IndexerStatus is the per-announce-source connection state. Phase 6's
// `automation_disconnected` trigger reads from this; Phase 5 only surfaces
// it in the automation overview.
type IndexerStatus struct {
	Identifier string `json:"identifier"`
	Name       string `json:"name"`
	Status     string `json:"status"`     // "connected" | "disconnected" | "unknown"
	LastEvent  string `json:"last_event"` // ISO8601
}
