// This file is auto-generated by alef. DO NOT EDIT.
// alef:hash:4e15143f4af1ae8bafbdb1506ef057da924484c66a19483966333558ad437e75
#nullable enable

using System;
using System.Text.Json;
using System.Text.Json.Serialization;

namespace Kreuzberg;
[JsonConverter(typeof(ReductionLevelJsonConverter))]
public enum ReductionLevel
{
    [JsonPropertyName("off")]
    Off,
    [JsonPropertyName("light")]
    Light,
    [JsonPropertyName("moderate")]
    Moderate,
    [JsonPropertyName("aggressive")]
    Aggressive,
    [JsonPropertyName("maximum")]
    Maximum,
}


/// <summary>
/// Custom JSON converter for <see cref="ReductionLevel"/> that respects explicit variant names.
/// </summary>
internal sealed class ReductionLevelJsonConverter : JsonConverter<ReductionLevel>
{
    public override ReductionLevel Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
    {
        var value = reader.GetString();
        return value switch
        {
            "off" => ReductionLevel.Off,
            "light" => ReductionLevel.Light,
            "moderate" => ReductionLevel.Moderate,
            "aggressive" => ReductionLevel.Aggressive,
            "maximum" => ReductionLevel.Maximum,
            _ => throw new JsonException($"Unknown ReductionLevel value: {value}")
        };
    }

    public override void Write(Utf8JsonWriter writer, ReductionLevel value, JsonSerializerOptions options)
    {
        var str = value switch
        {
            ReductionLevel.Off => "off",
            ReductionLevel.Light => "light",
            ReductionLevel.Moderate => "moderate",
            ReductionLevel.Aggressive => "aggressive",
            ReductionLevel.Maximum => "maximum",
            _ => throw new JsonException($"Unknown ReductionLevel value: {value}")
        };
        writer.WriteStringValue(str);
    }
}
