namespace Metin2Launcher.Formats;

/// <summary>
/// Resolves an <see cref="IReleaseFormat"/> for a given manifest. Lives
/// behind a factory so the <see cref="Orchestration.UpdateOrchestrator"/>
/// doesn't grow a switch statement and so tests can inject fakes.
/// </summary>
public static class ReleaseFormatFactory
{
    /// <summary>
    /// Returns the strategy for the given manifest format identifier.
    /// Unknown identifiers throw — we deliberately do NOT silently fall back
    /// to the legacy format, because that would turn a signed, malicious
    /// <c>format: "evil"</c> value into a downgrade attack vector.
    /// </summary>
    public static IReleaseFormat Resolve(string effectiveFormat)
    {
        return effectiveFormat switch
        {
            LegacyJsonBlobFormat.FormatName => new LegacyJsonBlobFormat(),
            M2PackFormat.FormatName         => new M2PackFormat(),
            _ => throw new NotSupportedException(
                $"manifest release format '{effectiveFormat}' is not supported by this launcher"),
        };
    }
}
