'use client' import { memo } from 'react' import { Handle, Position, type NodeProps } from '@xyflow/react' export interface ThresholdGateData { threshold: number currentValue: number label?: string } function ThresholdGate({ data }: NodeProps) { const { threshold, currentValue, label } = data as ThresholdGateData const isOpen = currentValue >= threshold const progress = Math.min((currentValue / threshold) * 100, 100) return (
75 ? 'border-amber-500' : 'border-rose-500'} transition-all duration-300 `}> {/* Gate Icon */}
{isOpen ? '🔓' : progress > 75 ? '⚠️' : '🔒'}
{label && (
{label}
)} {/* Mini threshold meter */}
75 ? 'bg-amber-500' : 'bg-rose-500' }`} style={{ width: `${progress}%` }} />
${currentValue.toLocaleString()}
/ ${threshold.toLocaleString()}
75 ? 'bg-amber-500/20 text-amber-400' : 'bg-rose-500/20 text-rose-400'} `}> {isOpen ? 'OPEN' : progress > 75 ? 'NEAR' : 'LOCKED'}
) } export default memo(ThresholdGate)