package consts

import (
	"time"

	"quyun/v2/app/requests"
)

// Format
//
// // swagger:enum CacheKey
// // ENUM(
// // VerifyCode = "code:__CHANNEL__:%s",
// // )

// swagger:enum Role
// ENUM( user, super_admin, creator)
type Role string

// Description returns the Chinese label for the specific enum value.
func (t Role) Description() string {
	switch t {
	case RoleUser:
		return "用户"
	case RoleSuperAdmin:
		return "超级管理员"
	case RoleCreator:
		return "创作者"
	default:
		return "未知角色"
	}
}

// RoleItems returns the KV list for FE dropdowns.
func RoleItems() []requests.KV {
	values := RoleValues()
	items := make([]requests.KV, 0, len(values))
	for _, v := range values {
		items = append(items, requests.NewKV(string(v), v.Description()))
	}
	return items
}

// swagger:enum UserStatus
// ENUM(active, inactive, pending_verify, verified, banned, )
type UserStatus string

// Description returns the Chinese label for the specific enum value.
func (t UserStatus) Description() string {
	switch t {
	case UserStatusActive:
		return "正常"
	case UserStatusInactive:
		return "未激活"
	case UserStatusPendingVerify:
		return "待审核"
	case UserStatusVerified:
		return "已审核"
	case UserStatusBanned:
		return "已封禁"
	default:
		return "未知状态"
	}
}

// UserStatusItems returns the KV list for FE dropdowns.
func UserStatusItems() []requests.KV {
	values := UserStatusValues()
	items := make([]requests.KV, 0, len(values))
	for _, v := range values {
		items = append(items, requests.NewKV(string(v), v.Description()))
	}
	return items
}

// tenants

// swagger:enum TenantStatus
// ENUM( pending_verify, verified, banned )
type TenantStatus string

// Description returns the Chinese label for the specific enum value.
func (t TenantStatus) Description() string {
	switch t {
	case TenantStatusPendingVerify:
		return "待审核"
	case TenantStatusVerified:
		return "已审核"
	case TenantStatusBanned:
		return "已封禁"
	default:
		return "未知状态"
	}
}

// TenantStatusItems returns the KV list for FE dropdowns.
func TenantStatusItems() []requests.KV {
	values := TenantStatusValues()
	items := make([]requests.KV, 0, len(values))
	for _, v := range values {
		items = append(items, requests.NewKV(string(v), v.Description()))
	}
	return items
}

// swagger:enum TenantUserRole
// ENUM( member, tenant_admin)
type TenantUserRole string

// Description returns the Chinese label for the specific enum value.
func (t TenantUserRole) Description() string {
	switch t {
	case TenantUserRoleMember:
		return "成员"
	case TenantUserRoleTenantAdmin:
		return "租户管理员"
	default:
		return "未知角色"
	}
}

// TenantUserRoleItems returns the KV list for FE dropdowns.
func TenantUserRoleItems() []requests.KV {
	values := TenantUserRoleValues()
	items := make([]requests.KV, 0, len(values))
	for _, v := range values {
		items = append(items, requests.NewKV(string(v), v.Description()))
	}
	return items
}

// media_assets

// swagger:enum MediaAssetType
// ENUM( video, audio, image )
type MediaAssetType string

// Description returns the Chinese label for the specific enum value.
func (t MediaAssetType) Description() string {
	switch t {
	case MediaAssetTypeVideo:
		return "视频"
	case MediaAssetTypeAudio:
		return "音频"
	case MediaAssetTypeImage:
		return "图片"
	default:
		return "未知类型"
	}
}

// MediaAssetTypeItems returns the KV list for FE dropdowns.
func MediaAssetTypeItems() []requests.KV {
	values := MediaAssetTypeValues()
	items := make([]requests.KV, 0, len(values))
	for _, v := range values {
		items = append(items, requests.NewKV(string(v), v.Description()))
	}
	return items
}

// swagger:enum MediaAssetStatus
// ENUM( uploaded, processing, ready, failed, deleted )
type MediaAssetStatus string

// Description returns the Chinese label for the specific enum value.
func (t MediaAssetStatus) Description() string {
	switch t {
	case MediaAssetStatusUploaded:
		return "已上传"
	case MediaAssetStatusProcessing:
		return "处理中"
	case MediaAssetStatusReady:
		return "就绪"
	case MediaAssetStatusFailed:
		return "失败"
	case MediaAssetStatusDeleted:
		return "已删除"
	default:
		return "未知状态"
	}
}

// MediaAssetStatusItems returns the KV list for FE dropdowns.
func MediaAssetStatusItems() []requests.KV {
	values := MediaAssetStatusValues()
	items := make([]requests.KV, 0, len(values))
	for _, v := range values {
		items = append(items, requests.NewKV(string(v), v.Description()))
	}
	return items
}

// swagger:enum MediaAssetVariant
// ENUM( main, preview )
type MediaAssetVariant string

// Description returns the Chinese label for the specific enum value.
func (t MediaAssetVariant) Description() string {
	switch t {
	case MediaAssetVariantMain:
		return "正片产物"
	case MediaAssetVariantPreview:
		return "试看产物"
	default:
		return "未知产物"
	}
}

// MediaAssetVariantItems returns the KV list for FE dropdowns.
func MediaAssetVariantItems() []requests.KV {
	values := MediaAssetVariantValues()
	items := make([]requests.KV, 0, len(values))
	for _, v := range values {
		items = append(items, requests.NewKV(string(v), v.Description()))
	}
	return items
}

// contents

// swagger:enum ContentStatus
// ENUM( draft, reviewing, published, unpublished, blocked )
type ContentStatus string

// Description returns the Chinese label for the specific enum value.
func (t ContentStatus) Description() string {
	switch t {
	case ContentStatusDraft:
		return "草稿"
	case ContentStatusReviewing:
		return "审核中"
	case ContentStatusPublished:
		return "已发布"
	case ContentStatusUnpublished:
		return "已下架"
	case ContentStatusBlocked:
		return "已封禁"
	default:
		return "未知状态"
	}
}

// ContentStatusItems returns the KV list for FE dropdowns.
func ContentStatusItems() []requests.KV {
	values := ContentStatusValues()
	items := make([]requests.KV, 0, len(values))
	for _, v := range values {
		items = append(items, requests.NewKV(string(v), v.Description()))
	}
	return items
}

// swagger:enum ContentVisibility
// ENUM( public, tenant_only, private )
type ContentVisibility string

// Description returns the Chinese label for the specific enum value.
func (t ContentVisibility) Description() string {
	switch t {
	case ContentVisibilityPublic:
		return "公开"
	case ContentVisibilityTenantOnly:
		return "租户可见"
	case ContentVisibilityPrivate:
		return "仅自己"
	default:
		return "未知"
	}
}

// ContentVisibilityItems returns the KV list for FE dropdowns.
func ContentVisibilityItems() []requests.KV {
	values := ContentVisibilityValues()
	items := make([]requests.KV, 0, len(values))
	for _, v := range values {
		items = append(items, requests.NewKV(string(v), v.Description()))
	}
	return items
}

// swagger:enum ContentAssetRole
// ENUM( main, cover, preview )
type ContentAssetRole string

// Description returns the Chinese label for the specific enum value.
func (t ContentAssetRole) Description() string {
	switch t {
	case ContentAssetRoleMain:
		return "正片"
	case ContentAssetRoleCover:
		return "封面"
	case ContentAssetRolePreview:
		return "试看"
	default:
		return "未知"
	}
}

// ContentAssetRoleItems returns the KV list for FE dropdowns.
func ContentAssetRoleItems() []requests.KV {
	values := ContentAssetRoleValues()
	items := make([]requests.KV, 0, len(values))
	for _, v := range values {
		items = append(items, requests.NewKV(string(v), v.Description()))
	}
	return items
}

const (
	// DefaultContentPreviewSeconds is the default preview duration in seconds when content.preview_seconds is unset/invalid.
	// 默认试看时长（秒）：当未配置或传入非法值时使用。
	DefaultContentPreviewSeconds int32 = 60

	// DefaultOrderRefundWindow is the default refundable time window starting from paid_at.
	// 默认退款时间窗：paid_at + 24h；租户管理侧可以通过强制退款绕过该限制（需审计）。
	DefaultOrderRefundWindow = 24 * time.Hour
)

// content_prices

// swagger:enum DiscountType
// ENUM( none, percent, amount )
type DiscountType string

// Description returns the Chinese label for the specific enum value.
func (t DiscountType) Description() string {
	switch t {
	case DiscountTypeNone:
		return "无折扣"
	case DiscountTypePercent:
		return "百分比折扣"
	case DiscountTypeAmount:
		return "立减"
	default:
		return "未知"
	}
}

// DiscountTypeItems returns the KV list for FE dropdowns.
func DiscountTypeItems() []requests.KV {
	values := DiscountTypeValues()
	items := make([]requests.KV, 0, len(values))
	for _, v := range values {
		items = append(items, requests.NewKV(string(v), v.Description()))
	}
	return items
}

// swagger:enum Currency
// ENUM( CNY )
type Currency string

// Description returns the Chinese label for the specific enum value.
func (t Currency) Description() string {
	switch t {
	case CurrencyCNY:
		return "人民币(CNY)"
	default:
		return "未知币种"
	}
}

// CurrencyItems returns the KV list for FE dropdowns.
func CurrencyItems() []requests.KV {
	values := CurrencyValues()
	items := make([]requests.KV, 0, len(values))
	for _, v := range values {
		items = append(items, requests.NewKV(string(v), v.Description()))
	}
	return items
}

// content_access

// swagger:enum ContentAccessStatus
// ENUM( active, revoked, expired )
type ContentAccessStatus string

// Description returns the Chinese label for the specific enum value.
func (t ContentAccessStatus) Description() string {
	switch t {
	case ContentAccessStatusActive:
		return "生效"
	case ContentAccessStatusRevoked:
		return "已撤销"
	case ContentAccessStatusExpired:
		return "已过期"
	default:
		return "未知状态"
	}
}

// ContentAccessStatusItems returns the KV list for FE dropdowns.
func ContentAccessStatusItems() []requests.KV {
	values := ContentAccessStatusValues()
	items := make([]requests.KV, 0, len(values))
	for _, v := range values {
		items = append(items, requests.NewKV(string(v), v.Description()))
	}
	return items
}

// orders

// swagger:enum OrderType
// ENUM( content_purchase, recharge, withdrawal )
type OrderType string

// Description returns the Chinese label for the specific enum value.
func (t OrderType) Description() string {
	switch t {
	case OrderTypeContentPurchase:
		return "购买内容"
	case OrderTypeRecharge:
		return "充值"
	case OrderTypeWithdrawal:
		return "提现"
	default:
		return "未知类型"
	}
}

// OrderTypeItems returns the KV list for FE dropdowns.
func OrderTypeItems() []requests.KV {
	values := OrderTypeValues()
	items := make([]requests.KV, 0, len(values))
	for _, v := range values {
		items = append(items, requests.NewKV(string(v), v.Description()))
	}
	return items
}

// swagger:enum OrderStatus
// ENUM( created, paid, refunding, refunded, canceled, failed )
type OrderStatus string

// Description returns the Chinese label for the specific enum value.
func (t OrderStatus) Description() string {
	switch t {
	case OrderStatusCreated:
		return "已创建"
	case OrderStatusPaid:
		return "已支付"
	case OrderStatusRefunding:
		return "退款中"
	case OrderStatusRefunded:
		return "已退款"
	case OrderStatusCanceled:
		return "已取消"
	case OrderStatusFailed:
		return "失败"
	default:
		return "未知状态"
	}
}

// OrderStatusItems returns the KV list for FE dropdowns.
func OrderStatusItems() []requests.KV {
	values := OrderStatusValues()
	items := make([]requests.KV, 0, len(values))
	for _, v := range values {
		items = append(items, requests.NewKV(string(v), v.Description()))
	}
	return items
}

// tenant_ledgers

// swagger:enum TenantLedgerType
// ENUM( debit_purchase, credit_refund, credit_withdrawal, freeze, unfreeze, adjustment )
type TenantLedgerType string

// Description returns the Chinese label for the specific enum value.
func (t TenantLedgerType) Description() string {
	switch t {
	case TenantLedgerTypeDebitPurchase:
		return "购买扣款"
	case TenantLedgerTypeCreditRefund:
		return "退款回滚"
	case TenantLedgerTypeCreditWithdrawal:
		return "提现扣款"
	case TenantLedgerTypeFreeze:
		return "冻结"
	case TenantLedgerTypeUnfreeze:
		return "解冻"
	case TenantLedgerTypeAdjustment:
		return "人工调账"
	default:
		return "未知类型"
	}
}

// TenantLedgerTypeItems returns the KV list for FE dropdowns.
func TenantLedgerTypeItems() []requests.KV {
	values := TenantLedgerTypeValues()
	items := make([]requests.KV, 0, len(values))
	for _, v := range values {
		items = append(items, requests.NewKV(string(v), v.Description()))
	}
	return items
}
