package heroagent

import (
	"time"

	"git.threefold.info/herocode/heroagent/pkg/servers/ui"
	"git.threefold.info/herocode/heroagent/pkg/servers/webdavserver"
)

// Config holds the configuration for the HeroAgent server factory
type Config struct {
	// Redis server configuration
	Redis RedisConfig

	// WebDAV server configuration
	WebDAV WebDAVConfig

	// UI server configuration
	UI UIConfig

	// Job management configuration
	Jobs JobsConfig

	// Enable/disable specific servers
	EnableRedis  bool
	EnableWebDAV bool
	EnableUI     bool
	EnableJobs   bool
}

// RedisConfig holds the configuration for the Redis server
type RedisConfig struct {
	TCPPort        int
	UnixSocketPath string
}

// WebDAVConfig holds the configuration for the WebDAV server
type WebDAVConfig struct {
	// Use webdavserver.Config directly
	Config webdavserver.Config
}

// UIConfig holds the configuration for the UI server
type UIConfig struct {
	// UI server configuration
	Port string
	// Any additional UI-specific configuration
	AppConfig ui.AppConfig
}

// JobsConfig holds the configuration for the job management system
type JobsConfig struct {
	// OurDB configuration
	OurDBPath string

	// Job processing configuration
	WorkerCount       int
	QueuePollInterval time.Duration
}

// DefaultConfig returns the default configuration for the HeroAgent
func DefaultConfig() Config {
	return Config{
		Redis: RedisConfig{
			TCPPort:        6379,
			UnixSocketPath: "", // Empty string means use TCP only
		},
		WebDAV: WebDAVConfig{
			Config: webdavserver.DefaultConfig(),
		},
		UI: UIConfig{
			Port:      "9001", // Port is a string in UIConfig
			AppConfig: ui.AppConfig{},
		},
		Jobs: JobsConfig{
			OurDBPath:         "./data/ourdb",
			WorkerCount:       5,
			QueuePollInterval: 100 * time.Millisecond,
		},
		EnableRedis:  true,
		EnableWebDAV: true,
		EnableUI:     true,
		EnableJobs:   true,
	}
}
