import type { Wall, WallOpening, ElectricalItem, FurnitureItem, Annotation } from './elements.js';

export interface Point {
  readonly x: number;
  readonly y: number;
}

export const FLOOR_TYPES = [
  'CONCRETE',
  'WOOD_LIGHT',
  'WOOD_MEDIUM',
  'WOOD_DARK',
  'WOOD_HERRINGBONE',
  'OAK_NATURAL',
  'TILE_WHITE',
  'TILE_GRAY',
  'LAMINATE',
] as const;
export type FloorType = (typeof FLOOR_TYPES)[number];

/**
 * How walls are visually finished in the 3D view. PAINT uses the room's
 * `wallColor` flat-tinted; the textured finishes ignore wallColor and apply
 * a real PBR material instead.
 */
export const WALL_FINISHES = [
  'PAINT',
  'PLASTER',
  'BRICK',
  'CONCRETE',
  'WOOD_PANEL',
  'WALLPAPER',
] as const;
export type WallFinish = (typeof WALL_FINISHES)[number];

/**
 * Default physical dimensions of a single outlet face plate (meters).
 * Used when a room does not override these values. ~7 cm matches a typical
 * European single outlet faceplate.
 */
export const DEFAULT_OUTLET_WIDTH = 0.07;
export const DEFAULT_OUTLET_HEIGHT = 0.07;

export interface Room {
  readonly id: string;
  readonly apartmentId: string;
  readonly name: string;
  readonly shape: readonly Point[];
  readonly width: number | null;
  readonly height: number | null;
  readonly wallHeight: number;
  readonly plinthHeight: number;
  readonly plinthThickness: number;
  /**
   * Distance (meters) the stretch ceiling hangs below the structural ceiling.
   * 0 means no stretch ceiling. The effective ceiling plane is at
   * `wallHeight - stretchCeilingOffset`. Visualization only — does not
   * affect wall geometry, opening positions, or electrical elevations.
   */
  readonly stretchCeilingOffset: number;
  readonly order: number;
  readonly posX: number;
  readonly posY: number;
  readonly floorType: FloorType;
  readonly wallColor: string;
  readonly wallFinish: WallFinish;
  /** Physical width of a single outlet face plate (meters), used to draw outlet boundaries. */
  readonly outletWidth: number;
  /** Physical height of a single outlet face plate (meters), used to draw outlet boundaries. */
  readonly outletHeight: number;
  readonly createdAt: string;
  readonly updatedAt: string;
}

export interface RoomFull extends Room {
  readonly walls: readonly Wall[];
  readonly openings: readonly WallOpening[];
  readonly electricalItems: readonly ElectricalItem[];
  readonly furnitureItems: readonly FurnitureItem[];
  readonly annotations: readonly Annotation[];
}

export interface CreateRoomDto {
  readonly name: string;
  readonly shape?: readonly Point[];
  readonly width?: number | null;
  readonly height?: number | null;
  readonly wallHeight?: number;
  readonly plinthHeight?: number;
  readonly plinthThickness?: number;
  readonly stretchCeilingOffset?: number;
  readonly order?: number;
  readonly posX?: number;
  readonly posY?: number;
  readonly floorType?: FloorType;
  readonly wallColor?: string;
  readonly wallFinish?: WallFinish;
  readonly outletWidth?: number;
  readonly outletHeight?: number;
}

export interface UpdateRoomDto {
  readonly name?: string;
  readonly shape?: readonly Point[];
  readonly width?: number | null;
  readonly height?: number | null;
  readonly wallHeight?: number;
  readonly plinthHeight?: number;
  readonly plinthThickness?: number;
  readonly stretchCeilingOffset?: number;
  readonly order?: number;
  readonly posX?: number;
  readonly posY?: number;
  readonly floorType?: FloorType;
  readonly wallColor?: string;
  readonly wallFinish?: WallFinish;
  readonly outletWidth?: number;
  readonly outletHeight?: number;
}
