// 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;
/// <summary>
/// Supported languages in PaddleOCR.
///
/// Maps user-friendly language codes to paddle-ocr-rs language identifiers.
/// </summary>
[JsonConverter(typeof(PaddleLanguageJsonConverter))]
public enum PaddleLanguage
{
    /// <summary>
    /// English
    /// </summary>
    [JsonPropertyName("english")]
    English,
    /// <summary>
    /// Simplified Chinese
    /// </summary>
    [JsonPropertyName("chinese")]
    Chinese,
    /// <summary>
    /// Japanese
    /// </summary>
    [JsonPropertyName("japanese")]
    Japanese,
    /// <summary>
    /// Korean
    /// </summary>
    [JsonPropertyName("korean")]
    Korean,
    /// <summary>
    /// German
    /// </summary>
    [JsonPropertyName("german")]
    German,
    /// <summary>
    /// French
    /// </summary>
    [JsonPropertyName("french")]
    French,
    /// <summary>
    /// Latin script (covers most European languages)
    /// </summary>
    [JsonPropertyName("latin")]
    Latin,
    /// <summary>
    /// Cyrillic (Russian and related)
    /// </summary>
    [JsonPropertyName("cyrillic")]
    Cyrillic,
    /// <summary>
    /// Traditional Chinese
    /// </summary>
    [JsonPropertyName("traditionalchinese")]
    TraditionalChinese,
    /// <summary>
    /// Thai
    /// </summary>
    [JsonPropertyName("thai")]
    Thai,
    /// <summary>
    /// Greek
    /// </summary>
    [JsonPropertyName("greek")]
    Greek,
    /// <summary>
    /// East Slavic (Russian, Ukrainian, Belarusian)
    /// </summary>
    [JsonPropertyName("eastslavic")]
    EastSlavic,
    /// <summary>
    /// Arabic (Arabic, Persian, Urdu)
    /// </summary>
    [JsonPropertyName("arabic")]
    Arabic,
    /// <summary>
    /// Devanagari (Hindi, Marathi, Sanskrit, Nepali)
    /// </summary>
    [JsonPropertyName("devanagari")]
    Devanagari,
    /// <summary>
    /// Tamil
    /// </summary>
    [JsonPropertyName("tamil")]
    Tamil,
    /// <summary>
    /// Telugu
    /// </summary>
    [JsonPropertyName("telugu")]
    Telugu,
}


/// <summary>
/// Custom JSON converter for <see cref="PaddleLanguage"/> that respects explicit variant names.
/// </summary>
internal sealed class PaddleLanguageJsonConverter : JsonConverter<PaddleLanguage>
{
    public override PaddleLanguage Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
    {
        var value = reader.GetString();
        return value switch
        {
            "english" => PaddleLanguage.English,
            "chinese" => PaddleLanguage.Chinese,
            "japanese" => PaddleLanguage.Japanese,
            "korean" => PaddleLanguage.Korean,
            "german" => PaddleLanguage.German,
            "french" => PaddleLanguage.French,
            "latin" => PaddleLanguage.Latin,
            "cyrillic" => PaddleLanguage.Cyrillic,
            "traditionalchinese" => PaddleLanguage.TraditionalChinese,
            "thai" => PaddleLanguage.Thai,
            "greek" => PaddleLanguage.Greek,
            "eastslavic" => PaddleLanguage.EastSlavic,
            "arabic" => PaddleLanguage.Arabic,
            "devanagari" => PaddleLanguage.Devanagari,
            "tamil" => PaddleLanguage.Tamil,
            "telugu" => PaddleLanguage.Telugu,
            _ => throw new JsonException($"Unknown PaddleLanguage value: {value}")
        };
    }

    public override void Write(Utf8JsonWriter writer, PaddleLanguage value, JsonSerializerOptions options)
    {
        var str = value switch
        {
            PaddleLanguage.English => "english",
            PaddleLanguage.Chinese => "chinese",
            PaddleLanguage.Japanese => "japanese",
            PaddleLanguage.Korean => "korean",
            PaddleLanguage.German => "german",
            PaddleLanguage.French => "french",
            PaddleLanguage.Latin => "latin",
            PaddleLanguage.Cyrillic => "cyrillic",
            PaddleLanguage.TraditionalChinese => "traditionalchinese",
            PaddleLanguage.Thai => "thai",
            PaddleLanguage.Greek => "greek",
            PaddleLanguage.EastSlavic => "eastslavic",
            PaddleLanguage.Arabic => "arabic",
            PaddleLanguage.Devanagari => "devanagari",
            PaddleLanguage.Tamil => "tamil",
            PaddleLanguage.Telugu => "telugu",
            _ => throw new JsonException($"Unknown PaddleLanguage value: {value}")
        };
        writer.WriteStringValue(str);
    }
}
