// 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>
/// Heuristic classification of what an image likely depicts.
/// </summary>
[JsonConverter(typeof(ImageKindJsonConverter))]
public enum ImageKind
{
    /// <summary>
    /// Photographic image (natural scene, photograph)
    /// </summary>
    [JsonPropertyName("photograph")]
    Photograph,
    /// <summary>
    /// Technical or schematic diagram
    /// </summary>
    [JsonPropertyName("diagram")]
    Diagram,
    /// <summary>
    /// Chart, graph, or plot
    /// </summary>
    [JsonPropertyName("chart")]
    Chart,
    /// <summary>
    /// Freehand or technical drawing
    /// </summary>
    [JsonPropertyName("drawing")]
    Drawing,
    /// <summary>
    /// Text-heavy image (scanned text, document)
    /// </summary>
    [JsonPropertyName("text_block")]
    TextBlock,
    /// <summary>
    /// Decorative element or border
    /// </summary>
    [JsonPropertyName("decoration")]
    Decoration,
    /// <summary>
    /// Logo or brand mark
    /// </summary>
    [JsonPropertyName("logo")]
    Logo,
    /// <summary>
    /// Small icon
    /// </summary>
    [JsonPropertyName("icon")]
    Icon,
    /// <summary>
    /// Fragment of a larger tiled image (tile of a technical drawing)
    /// </summary>
    [JsonPropertyName("tile_fragment")]
    TileFragment,
    /// <summary>
    /// Mask or transparency map
    /// </summary>
    [JsonPropertyName("mask")]
    Mask,
    /// <summary>
    /// Full-page render produced during OCR preprocessing; used as a citation thumbnail.
    /// </summary>
    [JsonPropertyName("page_raster")]
    PageRaster,
    /// <summary>
    /// Could not classify with reasonable confidence
    /// </summary>
    [JsonPropertyName("unknown")]
    Unknown,
}


/// <summary>
/// Custom JSON converter for <see cref="ImageKind"/> that respects explicit variant names.
/// </summary>
internal sealed class ImageKindJsonConverter : JsonConverter<ImageKind>
{
    public override ImageKind Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
    {
        var value = reader.GetString();
        return value switch
        {
            "photograph" => ImageKind.Photograph,
            "diagram" => ImageKind.Diagram,
            "chart" => ImageKind.Chart,
            "drawing" => ImageKind.Drawing,
            "text_block" => ImageKind.TextBlock,
            "decoration" => ImageKind.Decoration,
            "logo" => ImageKind.Logo,
            "icon" => ImageKind.Icon,
            "tile_fragment" => ImageKind.TileFragment,
            "mask" => ImageKind.Mask,
            "page_raster" => ImageKind.PageRaster,
            "unknown" => ImageKind.Unknown,
            _ => throw new JsonException($"Unknown ImageKind value: {value}")
        };
    }

    public override void Write(Utf8JsonWriter writer, ImageKind value, JsonSerializerOptions options)
    {
        var str = value switch
        {
            ImageKind.Photograph => "photograph",
            ImageKind.Diagram => "diagram",
            ImageKind.Chart => "chart",
            ImageKind.Drawing => "drawing",
            ImageKind.TextBlock => "text_block",
            ImageKind.Decoration => "decoration",
            ImageKind.Logo => "logo",
            ImageKind.Icon => "icon",
            ImageKind.TileFragment => "tile_fragment",
            ImageKind.Mask => "mask",
            ImageKind.PageRaster => "page_raster",
            ImageKind.Unknown => "unknown",
            _ => throw new JsonException($"Unknown ImageKind value: {value}")
        };
        writer.WriteStringValue(str);
    }
}
