using System.Collections.Generic;
using System.ComponentModel;
using System.Runtime.CompilerServices;
using System.Xml.Linq;
using Avalonia.Media;
using CommunityToolkit.Mvvm.DependencyInjection;
using Material.Icons;
using PSCHelpdesk.Shared.Service;
using ReactiveUI;

namespace PSCHelpdesk.Plugins.HetznerServer.Models;

public class Server : ReactiveObject
{
    private bool _isChecked;

    public bool IsChecked
    {
        get => _isChecked;
        set => this.RaiseAndSetIfChanged(ref _isChecked, value);
    }
    
    private bool _hasNeedRestart;

    public bool HasNeedRestart
    {
        get => _hasNeedRestart;
        set => this.RaiseAndSetIfChanged(ref _hasNeedRestart, value);
    }
    
    private bool _isRestartAlways;

    public bool IsRestartAlways
    {
        get => _isRestartAlways;
        set => this.RaiseAndSetIfChanged(ref _isRestartAlways, value);
    }

    private long _serverId;
    
    public long ServerId
    {
        get => _serverId;
        set => this.RaiseAndSetIfChanged(ref _serverId, value);
    }
    public string Name { get; set; }
    
    private Instance _instance;

    public Instance Instance
    {
        get => _instance;
        set => this.RaiseAndSetIfChanged(ref _instance, value);
    }

    private List<Plugin> _plugins;
    public List<Plugin> Plugins
    {
        get => _plugins;
        set => this.RaiseAndSetIfChanged(ref _plugins, value);
    }
    
    private string _pscApiKey;

    public string PscApiKey
    {
        get => _pscApiKey;
        set => this.RaiseAndSetIfChanged(ref _pscApiKey, value);
    }
    
    private string _fastBillId;
    
    public string FastBillId
    {
        get => _fastBillId;
        set => this.RaiseAndSetIfChanged(ref _fastBillId, value);
    }
    
    private string _fastBillNr;
    
    public string FastBillNr
    {
        get => _fastBillNr;
        set => this.RaiseAndSetIfChanged(ref _fastBillNr, value);
    }
    
    public string Status { get; set; }
    
    private MaterialIconKind _isGoodIcon = MaterialIconKind.AlertCircleOutline;
    
    public MaterialIconKind IsGoodIcon
    {
        get => _isGoodIcon;
        set => this.RaiseAndSetIfChanged(ref _isGoodIcon, value);
    }
    
    private IImmutableSolidColorBrush? _isGoodColor = Brushes.Red;
    
    public IImmutableSolidColorBrush? IsGoodColor
    {
        get => _isGoodColor;
        set => this.RaiseAndSetIfChanged(ref _isGoodColor, value);
    }
    
    private String _rootDirUsed = "100%";
    
    public string RootDirUsed
    {
        get => _rootDirUsed;
        set => this.RaiseAndSetIfChanged(ref _rootDirUsed, value);
    }
    
    private String _dataDirUsed = "100%";
    
    public string DataDirUsed
    {
        get => _dataDirUsed;
        set => this.RaiseAndSetIfChanged(ref _dataDirUsed, value);
    }

    private String _mongoVersion = "";
    
    public string MongoVersion
    {
        get => _mongoVersion;
        set => this.RaiseAndSetIfChanged(ref _mongoVersion, value);
    }

    private int _runningContainerCount = 0;
    
    public int RunningContainerCount
    {
        get => _runningContainerCount;
        set => this.RaiseAndSetIfChanged(ref _runningContainerCount, value);
    }

    private String _mysqlVersion = "";
    
    public string MysqlVersion
    {
        get => _mysqlVersion;
        set => this.RaiseAndSetIfChanged(ref _mysqlVersion, value);
    }
    
    public string Type { get; set; }
    public string Ipv4 { get; set; }
    public string Ipv6 { get; set; }

    public Server(long serverId, string name, string type, string status, string ipv4, string ipv6)
    {
        ServerId = serverId;
        Name = name;
        Type = type;
        Status = status;
        Ipv4 = ipv4;
        Ipv6 = ipv6;
        Domains = new List<Domain>();
        Plugins = new List<Plugin>();
        Instance = new Instance();
    }
    
    private List<Domain> _domains;
    
    public List<Domain> Domains
    {
        get => _domains;
        set => this.RaiseAndSetIfChanged(ref _domains, value);
    }
    
    private string _datum;
    
    public string Datum
    {
        get => _datum;
        set => this.RaiseAndSetIfChanged(ref _datum, value);
    }
    
    private float _release;
    
    public float Release
    {
        get => _release;
        set => this.RaiseAndSetIfChanged(ref _release, value);
    }

    private DateTime _backupLastModified;
    public DateTime BackupLastModified {
        get => _backupLastModified;
        set => this.RaiseAndSetIfChanged(ref _backupLastModified, value);
    }
    
    private bool _hasBackup = false;
    
    public bool HasBackup {
        get => _hasBackup;
        set => this.RaiseAndSetIfChanged(ref _hasBackup, value);
    }
}