import type { ConversationTraceItem, TraceTone } from "./useMessageTraces"

export function formatTraceTime(value: string): string {
  const date = new Date(value)
  if (Number.isNaN(date.getTime())) {
    return value
  }

  return date.toLocaleTimeString("zh-CN", { hour12: false })
}

export function getTraceLineClassName(tone: TraceTone): string {
  return "message-trace-line " + tone
}

export function getTraceLineLabels(item: ConversationTraceItem): {
  time: string
  label: string
  detail?: string
} {
  return {
    time: formatTraceTime(item.createdAt),
    label: item.label,
    detail: item.detail
  }
}
