// 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>
/// Type of PDF annotation.
/// </summary>
[JsonConverter(typeof(PdfAnnotationTypeJsonConverter))]
public enum PdfAnnotationType
{
    /// <summary>
    /// Sticky note / text annotation
    /// </summary>
    [JsonPropertyName("text")]
    Text,
    /// <summary>
    /// Highlighted text region
    /// </summary>
    [JsonPropertyName("highlight")]
    Highlight,
    /// <summary>
    /// Hyperlink annotation
    /// </summary>
    [JsonPropertyName("link")]
    Link,
    /// <summary>
    /// Rubber stamp annotation
    /// </summary>
    [JsonPropertyName("stamp")]
    Stamp,
    /// <summary>
    /// Underline text markup
    /// </summary>
    [JsonPropertyName("underline")]
    Underline,
    /// <summary>
    /// Strikeout text markup
    /// </summary>
    [JsonPropertyName("strike_out")]
    StrikeOut,
    /// <summary>
    /// Any other annotation type
    /// </summary>
    [JsonPropertyName("other")]
    Other,
}


/// <summary>
/// Custom JSON converter for <see cref="PdfAnnotationType"/> that respects explicit variant names.
/// </summary>
internal sealed class PdfAnnotationTypeJsonConverter : JsonConverter<PdfAnnotationType>
{
    public override PdfAnnotationType Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
    {
        var value = reader.GetString();
        return value switch
        {
            "text" => PdfAnnotationType.Text,
            "highlight" => PdfAnnotationType.Highlight,
            "link" => PdfAnnotationType.Link,
            "stamp" => PdfAnnotationType.Stamp,
            "underline" => PdfAnnotationType.Underline,
            "strike_out" => PdfAnnotationType.StrikeOut,
            "other" => PdfAnnotationType.Other,
            _ => throw new JsonException($"Unknown PdfAnnotationType value: {value}")
        };
    }

    public override void Write(Utf8JsonWriter writer, PdfAnnotationType value, JsonSerializerOptions options)
    {
        var str = value switch
        {
            PdfAnnotationType.Text => "text",
            PdfAnnotationType.Highlight => "highlight",
            PdfAnnotationType.Link => "link",
            PdfAnnotationType.Stamp => "stamp",
            PdfAnnotationType.Underline => "underline",
            PdfAnnotationType.StrikeOut => "strike_out",
            PdfAnnotationType.Other => "other",
            _ => throw new JsonException($"Unknown PdfAnnotationType value: {value}")
        };
        writer.WriteStringValue(str);
    }
}
