"use client"; import { Handle, NodeProps, Position } from "@xyflow/react"; import { FileTextIcon, GitBranchIcon, GitCompareIcon, SparklesIcon, CircleStopIcon, TimerIcon, } from "lucide-react"; import type { DialogueNodeData, NpcDialogueNodeType } from "@/lib/npc-dialogue/dialogue"; import { conditionSummary, hasEmptyConditionKey } from "@/lib/npc-dialogue/dialogue"; import { DialogueText } from "@/lib/npc-dialogue/DialogueText"; import { DIALOGUE_NODES } from "./types"; const position: Position = Position.Right; const inputPosition: Position = Position.Left; /** Single reusable canvas node for every dialogue node type. */ export function NpcDialogueNode({ data, type, selected }: NodeProps) { const d = data as DialogueNodeData; const nodeType = type as NpcDialogueNodeType; const meta = DIALOGUE_NODES[nodeType]; // Only end nodes are truly terminal. A choice node keeps its generic source // handle while it has zero choices, otherwise there would be no way to drag // the first choice out of it; once choices exist each row gets its own // handle (litegraph-style per-output wiring). Condition nodes always use // dedicated true/false handles instead of the generic one. const choiceCount = nodeType === "choice" ? (d.choices?.length ?? 0) : 1; const terminal = nodeType === "end"; const genericSource = !terminal && nodeType !== "condition" && !(nodeType === "choice" && choiceCount > 0); return (
{d.speaker}
)}
{d.body ? (