using System.Text.Json.Serialization;

namespace NexusShell.Models;

/// <summary>
/// Nexus Package (.nxp) manifest — maps 1:1 to manifest.json inside the archive.
/// </summary>
public sealed class NexusPackageManifest
{
    [JsonPropertyName("id")]
    public string Id { get; set; } = string.Empty;

    [JsonPropertyName("name")]
    public string Name { get; set; } = string.Empty;

    [JsonPropertyName("version")]
    public string Version { get; set; } = "1.0.0";

    [JsonPropertyName("publisher")]
    public string Publisher { get; set; } = "Ninja Nexus";

    [JsonPropertyName("description")]
    public string Description { get; set; } = string.Empty;

    [JsonPropertyName("entryPoint")]
    public string EntryPoint { get; set; } = string.Empty;

    [JsonPropertyName("dependencies")]
    public List<string> Dependencies { get; set; } = [];

    [JsonPropertyName("icon")]
    public string Icon { get; set; } = string.Empty;

    [JsonPropertyName("category")]
    public string Category { get; set; } = "System";

    [JsonPropertyName("minNexusVersion")]
    public string MinNexusVersion { get; set; } = string.Empty;

    [JsonPropertyName("releaseDate")]
    public string ReleaseDate { get; set; } = string.Empty;

    [JsonPropertyName("changelog")]
    public string Changelog { get; set; } = string.Empty;

    [JsonPropertyName("sizeLabel")]
    public string SizeLabel { get; set; } = "—";

    [JsonPropertyName("iconKey")]
    public string IconKey { get; set; } = "package";

    [JsonPropertyName("isNexusApp")]
    public bool IsNexusApp { get; set; }

    [JsonPropertyName("isNew")]
    public bool IsNew { get; set; }

    [JsonPropertyName("popularity")]
    public int Popularity { get; set; }

    [JsonPropertyName("updatedAt")]
    public string UpdatedAt { get; set; } = string.Empty;

    public string ResolvedIconKey =>
        !string.IsNullOrWhiteSpace(IconKey) ? IconKey :
        !string.IsNullOrWhiteSpace(Icon) ? Icon : "package";
}
