// <auto-generated />
// This file is auto-generated from core/models/src/vault/Item.ts
// Do not edit this file directly. Run 'npm run generate:models' to regenerate.

#nullable enable

namespace AliasClientDb.Models;

/// <summary>
/// Strongly-typed field types. Mirrors the string constants in <see cref="FieldType"/> so that
/// callers (e.g. importers) are forced to pick a known field type at compile time. Convert to and
/// from the canonical <see cref="FieldType"/> strings with <see cref="FieldTypeKindExtensions"/>.
/// </summary>
public enum FieldTypeKind
{
    /// <summary>
    /// Text field type.
    /// </summary>
    Text,

    /// <summary>
    /// Password field type.
    /// </summary>
    Password,

    /// <summary>
    /// Hidden field type.
    /// </summary>
    Hidden,

    /// <summary>
    /// Email field type.
    /// </summary>
    Email,

    /// <summary>
    /// URL field type.
    /// </summary>
    URL,

    /// <summary>
    /// Date field type.
    /// </summary>
    Date,

    /// <summary>
    /// Number field type.
    /// </summary>
    Number,

    /// <summary>
    /// Phone field type.
    /// </summary>
    Phone,

    /// <summary>
    /// TextArea field type.
    /// </summary>
    TextArea,
}

/// <summary>
/// Conversion helpers between <see cref="FieldTypeKind"/> and the canonical <see cref="FieldType"/> strings.
/// </summary>
public static class FieldTypeKindExtensions
{
    /// <summary>
    /// Converts a <see cref="FieldTypeKind"/> to its canonical <see cref="FieldType"/> string.
    /// </summary>
    /// <param name="kind">The field type kind.</param>
    /// <returns>The canonical field type string.</returns>
    public static string ToFieldTypeString(this FieldTypeKind kind) => kind switch
    {
        FieldTypeKind.Text => FieldType.Text,
        FieldTypeKind.Password => FieldType.Password,
        FieldTypeKind.Hidden => FieldType.Hidden,
        FieldTypeKind.Email => FieldType.Email,
        FieldTypeKind.URL => FieldType.URL,
        FieldTypeKind.Date => FieldType.Date,
        FieldTypeKind.Number => FieldType.Number,
        FieldTypeKind.Phone => FieldType.Phone,
        FieldTypeKind.TextArea => FieldType.TextArea,
        _ => FieldType.Text,
    };

    /// <summary>
    /// Converts a canonical <see cref="FieldType"/> string to a <see cref="FieldTypeKind"/>.
    /// Unknown or null values fall back to <see cref="FieldTypeKind.Text"/>.
    /// </summary>
    /// <param name="value">The canonical field type string.</param>
    /// <returns>The matching field type kind.</returns>
    public static FieldTypeKind ToFieldTypeKind(string? value) => value switch
    {
        FieldType.Text => FieldTypeKind.Text,
        FieldType.Password => FieldTypeKind.Password,
        FieldType.Hidden => FieldTypeKind.Hidden,
        FieldType.Email => FieldTypeKind.Email,
        FieldType.URL => FieldTypeKind.URL,
        FieldType.Date => FieldTypeKind.Date,
        FieldType.Number => FieldTypeKind.Number,
        FieldType.Phone => FieldTypeKind.Phone,
        FieldType.TextArea => FieldTypeKind.TextArea,
        _ => FieldTypeKind.Text,
    };
}
