namespace ZB.MOM.WW.OtOpcUa.Configuration.Entities;

/// <summary>
///     v3 Raw-tree tag-organizing group. Nestable (Kepware-style) directly under a
///     <see cref="Device"/> or under another <see cref="TagGroup"/>. Groups contribute the middle
///     segments of a tag's <c>RawPath</c> (between the device and the tag name).
/// </summary>
public sealed class TagGroup
{
    /// <summary>Gets or sets the database row identifier (PK).</summary>
    public Guid TagGroupRowId { get; set; }

    /// <summary>Stable logical ID, unique fleet-wide.</summary>
    public required string TagGroupId { get; set; }

    /// <summary>Logical FK to <see cref="Device.DeviceId"/> — the group lives under a device.</summary>
    public required string DeviceId { get; set; }

    /// <summary>Logical FK to a parent <see cref="TagGroup.TagGroupId"/>; <see langword="null"/> = root under the device.</summary>
    public string? ParentTagGroupId { get; set; }

    /// <summary>Sibling-unique group name. A RawPath segment: no <c>/</c>, no lead/trail whitespace.</summary>
    public required string Name { get; set; }

    /// <summary>Sibling display ordering.</summary>
    public int SortOrder { get; set; }

    /// <summary>Optimistic concurrency token for last-write-wins detection in the v2 live-edit model.</summary>
    public byte[] RowVersion { get; set; } = Array.Empty<byte>();
}
