import type { CellInfo } from '@/utils/practice'
import { knowledgeAreaMap, processMap } from '@/data'

interface HintInfoProps {
  currentCell: CellInfo | undefined
}

export function HintInfo({ currentCell }: HintInfoProps) {
  if (!currentCell) return null

  if (currentCell.type === 'knowledge-area') {
    const ka = knowledgeAreaMap.get(currentCell.knowledgeAreaId)
    if (!ka?.tailoringFactors || ka.tailoringFactors.length === 0) {
      return (
        <div className="text-base text-gray-500 dark:text-gray-400">
          暂无裁剪因素信息
        </div>
      )
    }

    return (
      <div className="space-y-2">
        <h3 className="text-base font-semibold text-gray-900 dark:text-gray-100">
          敏捷裁剪因素
        </h3>
        <p className="text-base text-gray-700 dark:text-gray-300 leading-relaxed">
          {ka.tailoringFactors.map((factor) => factor.title).join('；')}
        </p>
      </div>
    )
  } else {
    const process = processMap.get(currentCell.processId!)
    const purpose = process?.purpose

    return (
      <div>
        <h3 className="text-base font-semibold text-gray-900 dark:text-gray-100 mb-2">
          主要作用
        </h3>
        {purpose ? (
          <p className="text-base text-gray-700 dark:text-gray-300 leading-relaxed">
            {purpose}
          </p>
        ) : (
          <p className="text-base text-gray-500 dark:text-gray-400">暂无主要作用说明</p>
        )}
      </div>
    )
  }
}
