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

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

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

export function mapToFlowbiteOptList(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,
    })
  })
  return result
}
