import { GitCompareArrows } from "lucide-react";
import type { CanvasItem, OpenTarget } from "@/lib/types";

interface Props {
  item: CanvasItem;
  onOpen: (item: CanvasItem, target: OpenTarget) => void;
  className?: string;
}

export function SourceComparisonButton({ item, onOpen, className = "nodeAction nodrag nopan" }: Props) {
  if (!("detailRef" in item) || !item.detailRef) return null;
  return <button
    type="button"
    className={`${className} lineageAction`}
    data-focus-return={`${item.id}:lineage`}
    onClick={(event) => {
      event.stopPropagation();
      onOpen(item, "lineage");
    }}
  >
    <GitCompareArrows aria-hidden="true" size={14} />数据来源
  </button>;
}
