package collector

import "strings"

const (
	statusOK       = "OK"
	statusWarning  = "Warning"
	statusCritical = "Critical"
	statusUnknown  = "Unknown"
	statusEmpty    = "Empty"
)

func mapPCIeDeviceClass(raw string) string {
	normalized := strings.ToLower(strings.TrimSpace(raw))
	switch {
	case normalized == "":
		return ""
	case strings.Contains(normalized, "ethernet controller"):
		return "EthernetController"
	case strings.Contains(normalized, "fibre channel"):
		return "FibreChannelController"
	case strings.Contains(normalized, "network controller"), strings.Contains(normalized, "infiniband controller"):
		return "NetworkController"
	case strings.Contains(normalized, "serial attached scsi"), strings.Contains(normalized, "storage controller"):
		return "StorageController"
	case strings.Contains(normalized, "raid"), strings.Contains(normalized, "mass storage"):
		return "MassStorageController"
	case strings.Contains(normalized, "display controller"):
		return "DisplayController"
	case strings.Contains(normalized, "vga"), strings.Contains(normalized, "3d controller"), strings.Contains(normalized, "video controller"):
		return "VideoController"
	case strings.Contains(normalized, "processing accelerators"), strings.Contains(normalized, "processing accelerator"):
		return "ProcessingAccelerator"
	default:
		return raw
	}
}

func isNICClass(class string) bool {
	switch strings.TrimSpace(class) {
	case "EthernetController", "NetworkController":
		return true
	default:
		return false
	}
}

func isGPUClass(class string) bool {
	switch strings.TrimSpace(class) {
	case "VideoController", "DisplayController", "ProcessingAccelerator":
		return true
	default:
		return false
	}
}

func isRAIDClass(class string) bool {
	switch strings.TrimSpace(class) {
	case "MassStorageController", "StorageController":
		return true
	default:
		return false
	}
}
