using System.Text.Json;
using Tiku.Domain.Catalog;
using Tiku.Domain.Commerce;

namespace Tiku.Application.Catalog;

public sealed record CatalogList<TItem>(IReadOnlyCollection<TItem> Items);

public sealed record CatalogFilter(
    Guid TenantId,
    Guid? RegionId = null,
    Guid? ModuleId = null,
    Guid? ParentId = null,
    bool ParentIsRoot = false,
    Guid? SchoolId = null,
    Guid? MajorId = null,
    Guid? SubjectId = null,
    Guid? NodeId = null,
    string? Keyword = null,
    string? Type = null,
    int? Limit = null);

public sealed record RegionCatalogItem(
    Guid Id,
    string? LegacyId,
    string Name,
    string? Code,
    string? ShortName,
    string? FullName,
    string? Icon,
    string? Pinyin,
    int Order,
    bool IsHot);

public sealed record RegionModuleCatalogItem(
    Guid Id,
    string? LegacyId,
    Guid? RegionId,
    string Name,
    string? Type,
    string? Icon,
    string? Color,
    string? TextColor,
    string? Description,
    string? Route,
    int Order,
    bool IsPrimarySchoolModule);

public sealed record ModuleNodeCatalogItem(
    Guid Id,
    string? LegacyId,
    Guid? RegionId,
    Guid? ModuleId,
    Guid? ParentId,
    string? LegacyParentId,
    ModuleNodeType Type,
    string Name,
    string? Path,
    int Order,
    JsonElement Metadata);

public sealed record SchoolCatalogItem(
    Guid Id,
    string? LegacyId,
    Guid? RegionId,
    Guid? ModuleId,
    string Name,
    string? ProfessionalExamDate,
    JsonElement Metadata);

public sealed record MajorCatalogItem(
    Guid Id,
    string? LegacyId,
    Guid? RegionId,
    Guid? SchoolId,
    string Name,
    string? Description,
    string? StudyTips,
    int Order);

public sealed record SubjectCatalogItem(
    Guid Id,
    string? LegacyId,
    Guid? RegionId,
    Guid? ModuleId,
    Guid? SchoolId,
    Guid? MajorId,
    Guid? NodeId,
    string Name,
    SubjectType? Type,
    string? Icon,
    string? Description,
    JsonElement Stats,
    int Order);

public sealed record CategoryCatalogItem(
    Guid Id,
    string? LegacyId,
    Guid? SubjectId,
    Guid? NodeId,
    string Name,
    CategoryType? CategoryType,
    int Order,
    int? SvipQuestionLimit);

public sealed record BannerCatalogItem(
    Guid Id,
    string? LegacyId,
    Guid? RegionId,
    string? Title,
    string? Subtitle,
    string? Content,
    string? ButtonText,
    string? ButtonLink,
    string? BackgroundColor,
    string? BorderColor,
    int Order,
    bool IsActive);

public sealed record FaqCatalogItem(
    Guid Id,
    string? LegacyId,
    Guid? RegionId,
    string? Question,
    string? Answer,
    int Order,
    bool IsActive);

public sealed record AnnouncementCatalogItem(
    Guid Id,
    string? LegacyId,
    string? Content,
    string? Link,
    string? BackgroundColor,
    int Order,
    bool IsActive);

public sealed record ExamDateCatalogItem(
    Guid Id,
    string? LegacyId,
    Guid? RegionId,
    Guid? SchoolId,
    string ExamName,
    DateTimeOffset? ExamAt,
    string? ExamType,
    string? Description,
    JsonElement Metadata,
    int Order,
    bool IsActive,
    int? DaysLeft);

public sealed record ProductCatalogItem(
    Guid Id,
    string? LegacyId,
    Guid? RegionId,
    string Title,
    decimal? Price,
    string? PriceLabel,
    string? Link,
    ProductType Type,
    JsonElement Tags,
    string? Cover,
    string? PreviewIframe,
    JsonElement DetailImages,
    int Order,
    bool IsActive);

public sealed record SvipPlanCatalogItem(
    Guid Id,
    string? LegacyId,
    Guid? RegionId,
    string Name,
    int PriceCents,
    decimal Price,
    int? OriginalPriceCents,
    decimal? OriginalPrice,
    int Days,
    string? Description,
    string? PerDayLabel,
    string? Badge,
    bool Recommended,
    bool CouponOnly,
    string? VpProductId,
    bool VpEnabled,
    int Order,
    bool IsActive);