import { Group, Rect, Line } from 'react-konva';

interface JunctionBoxSymbolProps {
  readonly x: number;
  readonly y: number;
  readonly rotation: number;
  readonly color: string;
  readonly scale: number;
}

/** IEC junction box: square with an X inside. */
export function JunctionBoxSymbol({ x, y, rotation, color, scale }: JunctionBoxSymbolProps) {
  const size = 14 * scale;
  const half = size / 2;

  return (
    <Group x={x} y={y} rotation={rotation}>
      <Rect
        x={-half}
        y={-half}
        width={size}
        height={size}
        stroke={color}
        strokeWidth={1.5}
        fill="transparent"
        listening={false}
      />
      {/* X cross */}
      <Line points={[-half, -half, half, half]} stroke={color} strokeWidth={1.2} listening={false} />
      <Line points={[half, -half, -half, half]} stroke={color} strokeWidth={1.2} listening={false} />
    </Group>
  );
}
