import { createElement } from 'react' import { Handle, Position, NodeResizer, type NodeProps, type Node } from '@xyflow/react' import { Layers } from 'lucide-react' import type { NodeData } from '@/types' import { resolveNodeColors } from '@/utils/nodeColors' import { resolveNodeIcon } from '@/utils/nodeIcons' import { resolvePropertyIcon } from '@/utils/propertyIcons' import { useCanvasStore } from '@/stores/canvasStore' import { maskIp, splitIps } from '@/utils/maskIp' import { useThemeStore } from '@/stores/themeStore' import { THEMES } from '@/utils/themes' import { BaseNode } from './BaseNode' export function ProxmoxGroupNode(props: NodeProps>) { const { data, selected } = props const activeTheme = useThemeStore((s) => s.activeTheme) const hideIp = useCanvasStore((s) => s.hideIp) const theme = THEMES[activeTheme] const colors = resolveNodeColors(data, activeTheme) // Render as a regular node when container mode is disabled if (data.container_mode === false) { const proxmoxAccent = theme.colors.nodeAccents.proxmox.border return ( <> ) } const statusColor = theme.colors.statusColors[data.status] const isOnline = data.status === 'online' const glow = colors.border const proxmoxAccent = theme.colors.nodeAccents.proxmox.border const resolvedIcon = resolveNodeIcon(Layers, data.custom_icon) return ( <> {/* Group border */}
{/* Header bar */}
{createElement(resolvedIcon, { size: 12 })}
{data.label} {data.ip && splitIps(data.ip).map((ip) => ( {hideIp ? maskIp(ip) : ip} ))}
{/* Status dot */}
{/* Properties */} {data.properties?.filter((p) => p.visible).map((prop, i, arr) => { const Icon = resolvePropertyIcon(prop.icon) return (
{Icon && } {prop.key} · {prop.value}
) })} {/* Inner area — React Flow places children here */}
{/* Cluster handles */} ) }