import type { ClassValue } from 'clsx'
import { clsx } from 'clsx'
import { twMerge } from 'tailwind-merge'

export interface SelectOptionType<T> {
  value: string
  label: string
  code?: string
}

export function cn(...inputs: ClassValue[]) {
  return twMerge(clsx(inputs))
}

export function mapToComboboxOptList(items: Record<string, string>): SelectOptionType<string>[] {
  if (!items) {
    return []
  }
  const result: SelectOptionType<string>[] = []
  Object.keys(items).forEach((item) => {
    result.push({
      label: items[item] as string,
      value: item,
      code: item,
    })
  })
  return result
}
