export function parseCssClassList(rawValue?: string): string[] {
  if (!rawValue) {
    return []
  }

  const classNamePattern = /^[A-Za-z_-][A-Za-z0-9_-]*$/
  const uniqueClassNames = new Set<string>()

  rawValue
    .split(',')
    .map((entry) => entry.trim())
    .filter((entry) => entry.length > 0)
    .forEach((entry) => {
      const classTokens = entry.split(/\s+/)
      classTokens.forEach((token) => {
        if (classNamePattern.test(token)) {
          uniqueClassNames.add(token)
        }
      })
    })

  return Array.from(uniqueClassNames)
}
