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

interface SofaSilhouetteProps {
  readonly x: number;
  readonly y: number;
  readonly width: number;
  readonly depth: number;
  readonly rotation: number;
  readonly color: string;
  readonly fillColor: string;
}

/** Top-down sofa silhouette: rectangle with backrest and armrests. */
export function SofaSilhouette({ x, y, width, depth, rotation, color, fillColor }: SofaSilhouetteProps) {
  const halfW = width / 2;
  const halfD = depth / 2;
  const armW = depth * 0.2;
  const backD = depth * 0.22;

  return (
    <Group x={x} y={y} rotation={rotation}>
      {/* Main sofa body */}
      <Rect
        x={-halfW}
        y={-halfD}
        width={width}
        height={depth}
        stroke={color}
        strokeWidth={1.5}
        fill={fillColor}
        listening={false}
      />
      {/* Backrest */}
      <Rect
        x={-halfW}
        y={-halfD}
        width={width}
        height={backD}
        stroke={color}
        strokeWidth={0.8}
        listening={false}
      />
      {/* Left armrest */}
      <Rect
        x={-halfW}
        y={-halfD + backD}
        width={armW}
        height={depth - backD}
        stroke={color}
        strokeWidth={0.8}
        listening={false}
      />
      {/* Right armrest */}
      <Rect
        x={halfW - armW}
        y={-halfD + backD}
        width={armW}
        height={depth - backD}
        stroke={color}
        strokeWidth={0.8}
        listening={false}
      />
    </Group>
  );
}
