import {Handle,Position,type NodeProps} from "@xyflow/react";import {Box,Typography} from "@mui/material";import type {Node} from "@xyflow/react";import type {Dag_Node_Data} from "./dag_types";import {format_nanoseconds} from "../protocol/format";
export function Dag_Node({data}:NodeProps<Node<Dag_Node_Data>>) {const node=data.render_node;return <Box sx={{width:250,p:1.5,borderRadius:2,border:"1px solid",borderColor:data.selected?"primary.main":data.critical?"secondary.main":"rgba(132,179,206,.35)",bgcolor:"#102239",boxShadow:data.selected?"0 0 0 2px rgba(89,214,197,.25)":"none"}}><Handle type="target" position={Position.Left}/><Typography variant="overline" color="primary.main">{node.kind}</Typography><Typography fontWeight={800} noWrap>{node.name||node.label}</Typography><Typography variant="caption" color="text.secondary">{node.owner}</Typography><Typography variant="body2">{data.duration_ns===undefined?"未执行":`${format_nanoseconds(data.duration_ns)} · worker ${data.worker_id}`}</Typography><Handle type="source" position={Position.Right}/></Box>;}
