export { BedSilhouette } from './BedSilhouette';
export { DeskSilhouette } from './DeskSilhouette';
export { WardrobeSilhouette } from './WardrobeSilhouette';
export { SofaSilhouette } from './SofaSilhouette';
export { TableSilhouette } from './TableSilhouette';
export { ChairSilhouette } from './ChairSilhouette';
export { ShelfSilhouette } from './ShelfSilhouette';
export { TvSilhouette } from './TvSilhouette';

import type { FurnitureType } from '@house-plan-maker/shared';

/**
 * Logical grouping for the furniture picker. The category controls which
 * tab/section an item appears under and is purely a UI concern — the data
 * model only cares about `type`.
 */
export const FURNITURE_CATEGORIES = [
  'sleeping',
  'seating',
  'tables',
  'storage',
  'electronics',
  'climate',
  'decor',
  'pets',
] as const;
export type FurnitureCategory = (typeof FURNITURE_CATEGORIES)[number];

/** Default dimensions for each furniture type (width x depth x height in meters). */
export interface FurnitureDef {
  readonly type: FurnitureType;
  readonly category: FurnitureCategory;
  readonly label: string;
  readonly width: number;
  readonly depth: number;
  readonly height: number;
  readonly icon: string;
  /**
   * Type-specific default metadata applied when a new item is placed from
   * this preset. Used for plants to seed `{ variant, flowerColor }`, for
   * curtains to seed `{ openAmount, fabricColor }` when new presets need
   * non-default state, etc. The shape is opaque to the picker — readers
   * on the mesh side look for the keys they care about.
   */
  readonly defaultMetadata?: Record<string, unknown>;
}

export const FURNITURE_DEFS: readonly FurnitureDef[] = [
  { type: 'BED', category: 'sleeping', label: 'Single Bed', width: 1.0, depth: 2.0, height: 0.5, icon: '\u{1F6CF}' },
  { type: 'BED', category: 'sleeping', label: 'Double Bed', width: 1.4, depth: 2.0, height: 0.5, icon: '\u{1F6CF}' },
  { type: 'BED', category: 'sleeping', label: 'Queen Bed', width: 1.6, depth: 2.0, height: 0.5, icon: '\u{1F6CF}' },
  { type: 'BED', category: 'sleeping', label: 'King Bed', width: 1.8, depth: 2.0, height: 0.5, icon: '\u{1F6CF}' },
  // Cribs — a baby bed with slatted rails. Standard EU/US sizes: full-size
  // ~70×130cm and compact ~60×120cm. Total height includes the top rail
  // (~95cm from floor) which is what the 3D mesh draws the slats up to.
  { type: 'CRIB', category: 'sleeping', label: 'Crib (Standard)', width: 0.72, depth: 1.32, height: 0.95, icon: '\u{1F476}' },
  { type: 'CRIB', category: 'sleeping', label: 'Crib (Compact)', width: 0.6, depth: 1.2, height: 0.95, icon: '\u{1F476}' },
  { type: 'NIGHTSTAND', category: 'sleeping', label: 'Nightstand', width: 0.5, depth: 0.4, height: 0.5, icon: '\u{1F4E6}' },
  { type: 'SOFA', category: 'seating', label: 'Sofa', width: 2.0, depth: 0.9, height: 0.8, icon: '\u{1FA91}' },
  { type: 'CHAIR', category: 'seating', label: 'Chair', width: 0.45, depth: 0.45, height: 0.85, icon: '\u{1FA91}' },
  // Office chairs — ergonomic task chair with wheeled 5-star base, gas
  // lift, padded seat and tall backrest. Total height is top of the
  // backrest; seat pan sits at ~45% of total height. Three presets:
  // compact task chair, standard, and tall executive.
  { type: 'OFFICE_CHAIR', category: 'seating', label: 'Office Chair', width: 0.6, depth: 0.6, height: 1.05, icon: '\u{1FA91}' },
  { type: 'OFFICE_CHAIR', category: 'seating', label: 'Office Chair (Task)', width: 0.55, depth: 0.55, height: 0.95, icon: '\u{1FA91}' },
  { type: 'OFFICE_CHAIR', category: 'seating', label: 'Office Chair (Executive)', width: 0.68, depth: 0.68, height: 1.2, icon: '\u{1FA91}' },
  { type: 'DESK', category: 'tables', label: 'Desk', width: 1.2, depth: 0.6, height: 0.75, icon: '\u{1F4BC}' },
  { type: 'TABLE', category: 'tables', label: 'Dining Table', width: 1.2, depth: 0.8, height: 0.75, icon: '\u{1F37D}' },
  { type: 'WARDROBE', category: 'storage', label: 'Wardrobe (S)', width: 1.0, depth: 0.6, height: 2.0, icon: '\u{1F3EA}' },
  { type: 'WARDROBE', category: 'storage', label: 'Wardrobe (M)', width: 1.5, depth: 0.6, height: 2.0, icon: '\u{1F3EA}' },
  { type: 'WARDROBE', category: 'storage', label: 'Wardrobe (L)', width: 2.0, depth: 0.6, height: 2.0, icon: '\u{1F3EA}' },
  { type: 'DRESSER', category: 'storage', label: 'Dresser', width: 1.0, depth: 0.5, height: 0.8, icon: '\u{1F3EA}' },
  // Dressing table / vanity — desk-like base with an upright mirror. The
  // height includes the mirror (total ~1.5m) and the mesh derives the desk
  // slab thickness from `height * 0.45`.
  { type: 'DRESSING_TABLE', category: 'storage', label: 'Dressing Table', width: 1.0, depth: 0.4, height: 1.5, icon: '\u{1F484}' },
  { type: 'DRESSING_TABLE', category: 'storage', label: 'Dressing Table (L)', width: 1.3, depth: 0.45, height: 1.6, icon: '\u{1F484}' },
  { type: 'SHELF', category: 'storage', label: 'Tall Shelf', width: 0.8, depth: 0.3, height: 1.8, icon: '\u{1F4DA}' },
  { type: 'SHELF', category: 'storage', label: 'Wall Shelf 60', width: 0.6, depth: 0.25, height: 0.04, icon: '\u{1F4DA}' },
  { type: 'SHELF', category: 'storage', label: 'Wall Shelf 80', width: 0.8, depth: 0.25, height: 0.04, icon: '\u{1F4DA}' },
  { type: 'SHELF', category: 'storage', label: 'Wall Shelf 120', width: 1.2, depth: 0.25, height: 0.04, icon: '\u{1F4DA}' },
  { type: 'BOOKCASE', category: 'storage', label: 'Bookcase', width: 0.8, depth: 0.3, height: 2.0, icon: '\u{1F4DA}' },
  // Open bookshelves — no back panel, so the shelf contents are
  // visible from both sides and the unit reads as a room divider.
  // Row count is user-configurable via the properties panel and
  // stored in `metadata.shelfRows`. Presets cover common
  // 3/4/5-cube sizes.
  { type: 'BOOKCASE', category: 'storage', label: 'Open Bookshelf 3', width: 0.8, depth: 0.3, height: 1.2, icon: '\u{1F4D6}', defaultMetadata: { shelfRows: 3, hasBackPanel: false } },
  { type: 'BOOKCASE', category: 'storage', label: 'Open Bookshelf 4', width: 0.8, depth: 0.3, height: 1.6, icon: '\u{1F4D6}', defaultMetadata: { shelfRows: 4, hasBackPanel: false } },
  { type: 'BOOKCASE', category: 'storage', label: 'Open Bookshelf 5', width: 0.8, depth: 0.3, height: 2.0, icon: '\u{1F4D6}', defaultMetadata: { shelfRows: 5, hasBackPanel: false } },
  { type: 'BOOKCASE', category: 'storage', label: 'Open Bookshelf (Wide)', width: 1.6, depth: 0.3, height: 2.0, icon: '\u{1F4D6}', defaultMetadata: { shelfRows: 5, hasBackPanel: false } },
  { type: 'TV', category: 'electronics', label: 'TV 32"', width: 0.73, depth: 0.08, height: 0.43, icon: '\u{1F4FA}' },
  { type: 'TV', category: 'electronics', label: 'TV 43"', width: 0.97, depth: 0.08, height: 0.57, icon: '\u{1F4FA}' },
  { type: 'TV', category: 'electronics', label: 'TV 55"', width: 1.24, depth: 0.08, height: 0.72, icon: '\u{1F4FA}' },
  { type: 'TV', category: 'electronics', label: 'TV 65"', width: 1.46, depth: 0.08, height: 0.84, icon: '\u{1F4FA}' },
  // Digital pianos. Width ≈ number of keys × ~2.4cm + 5cm for chassis
  // sides; total height includes an X-frame stand when `hasStand` is on.
  // Default stand height brings the chassis to ~72cm (standard playing
  // height); turn the stand off in the properties panel to place the
  // piano on a table. 88-key is the full-range preset; 76 and 61 are
  // common portable sizes.
  { type: 'DIGITAL_PIANO', category: 'electronics', label: 'Digital Piano 88', width: 1.3, depth: 0.32, height: 0.85, icon: '\u{1F3B9}', defaultMetadata: { hasStand: true } },
  { type: 'DIGITAL_PIANO', category: 'electronics', label: 'Digital Piano 76', width: 1.15, depth: 0.3, height: 0.85, icon: '\u{1F3B9}', defaultMetadata: { hasStand: true } },
  { type: 'DIGITAL_PIANO', category: 'electronics', label: 'Digital Piano 61', width: 0.95, depth: 0.28, height: 0.85, icon: '\u{1F3B9}', defaultMetadata: { hasStand: true } },
  // Speakers — compact shelf monitors and tall floor-standing towers.
  // Shelf dimensions are typical 2-way bookshelf (~20×25×35cm); floor
  // towers are 3-way with a deeper cabinet and ~1m height.
  { type: 'SPEAKER', category: 'electronics', label: 'Shelf Speaker (S)', width: 0.18, depth: 0.22, height: 0.3, icon: '\u{1F50A}', defaultMetadata: { variant: 'shelf' } },
  { type: 'SPEAKER', category: 'electronics', label: 'Shelf Speaker (M)', width: 0.22, depth: 0.28, height: 0.38, icon: '\u{1F50A}', defaultMetadata: { variant: 'shelf' } },
  { type: 'SPEAKER', category: 'electronics', label: 'Shelf Speaker (L)', width: 0.26, depth: 0.32, height: 0.44, icon: '\u{1F50A}', defaultMetadata: { variant: 'shelf' } },
  { type: 'SPEAKER', category: 'electronics', label: 'Floor Speaker', width: 0.25, depth: 0.35, height: 1.0, icon: '\u{1F50A}', defaultMetadata: { variant: 'floor' } },
  { type: 'SPEAKER', category: 'electronics', label: 'Floor Speaker (L)', width: 0.3, depth: 0.4, height: 1.2, icon: '\u{1F50A}', defaultMetadata: { variant: 'floor' } },
  // TV soundbars — long horizontal speakers that pair with a TV. Width
  // roughly tracks the associated TV size (~90cm for 43", ~110cm for 55",
  // ~140cm for 65"+). Height is ~6–8cm, depth ~9–10cm. Elevation is
  // typically set so the bar sits just below the TV (set when placed).
  { type: 'SPEAKER', category: 'electronics', label: 'Soundbar 90', width: 0.9, depth: 0.09, height: 0.06, icon: '\u{1F50A}', defaultMetadata: { variant: 'soundbar' } },
  { type: 'SPEAKER', category: 'electronics', label: 'Soundbar 110', width: 1.1, depth: 0.1, height: 0.07, icon: '\u{1F50A}', defaultMetadata: { variant: 'soundbar' } },
  { type: 'SPEAKER', category: 'electronics', label: 'Soundbar 140', width: 1.4, depth: 0.1, height: 0.08, icon: '\u{1F50A}', defaultMetadata: { variant: 'soundbar' } },
  // PC tower / desktop case. Dimensions match typical ATX mid-tower (~20cm
  // wide, ~45cm deep, ~45cm tall) and mini-tower variants. Sits on the
  // floor or under a desk — default elevation 0.
  { type: 'PC_TOWER', category: 'electronics', label: 'PC Tower (Mid)', width: 0.2, depth: 0.45, height: 0.45, icon: '\u{1F5A5}' },
  { type: 'PC_TOWER', category: 'electronics', label: 'PC Tower (Full)', width: 0.22, depth: 0.5, height: 0.55, icon: '\u{1F5A5}' },
  { type: 'PC_TOWER', category: 'electronics', label: 'PC Tower (Mini)', width: 0.18, depth: 0.38, height: 0.38, icon: '\u{1F5A5}' },
  { type: 'AC_UNIT', category: 'climate', label: 'AC Unit', width: 0.85, depth: 0.2, height: 0.3, icon: '\u{2744}' },
  // Standard panel-type room radiators. Width varies by section count;
  // the 3D mesh derives the fin count from the width so the visual
  // automatically tracks the chosen size. Depth is fairly thin (~10cm)
  // and height matches typical 50cm under-window or 60cm wall units.
  { type: 'RADIATOR', category: 'climate', label: 'Radiator 60', width: 0.6, depth: 0.1, height: 0.5, icon: '\u{1F525}' },
  { type: 'RADIATOR', category: 'climate', label: 'Radiator 100', width: 1.0, depth: 0.1, height: 0.5, icon: '\u{1F525}' },
  { type: 'RADIATOR', category: 'climate', label: 'Radiator 140', width: 1.4, depth: 0.1, height: 0.5, icon: '\u{1F525}' },
  // Wall photo collage — flat decorative panel mounted on a wall. Default
  // elevation 1.4m (eye level) is set in FurnitureTool when placed.
  { type: 'WALL_COLLAGE', category: 'decor', label: 'Wall Collage 3x2', width: 1.0, depth: 0.02, height: 0.7, icon: '\u{1F5BC}' },
  { type: 'WALL_COLLAGE', category: 'decor', label: 'Wall Collage 4x3', width: 1.4, depth: 0.02, height: 1.0, icon: '\u{1F5BC}' },
  { type: 'WALL_COLLAGE', category: 'decor', label: 'Wall Collage 5x2', width: 1.5, depth: 0.02, height: 0.6, icon: '\u{1F5BC}' },
  // Curtains — pleated fabric hanging from a rod. Height defaults to a
  // typical 2.2m window drop; width varies by window size. Depth includes
  // the pleat bulge (~10cm) so the item doesn't clip into the wall.
  { type: 'CURTAIN', category: 'decor', label: 'Curtain 120', width: 1.2, depth: 0.1, height: 2.2, icon: '\u{1FA9F}' },
  { type: 'CURTAIN', category: 'decor', label: 'Curtain 160', width: 1.6, depth: 0.1, height: 2.2, icon: '\u{1FA9F}' },
  { type: 'CURTAIN', category: 'decor', label: 'Curtain 200', width: 2.0, depth: 0.1, height: 2.2, icon: '\u{1FA9F}' },
  // Plants — terracotta pot + foliage. Variant controls the mesh style:
  //   - `bush`   → spherical leafy top (default if variant omitted)
  //   - `tall`   → trunk + canopy (ficus / indoor tree)
  //   - `flower` → coloured blossom on a short stem
  // flowerColor is used only by the flower variant.
  { type: 'PLANT', category: 'decor', label: 'Potted Plant (S)', width: 0.22, depth: 0.22, height: 0.45, icon: '\u{1FAB4}', defaultMetadata: { variant: 'bush' } },
  { type: 'PLANT', category: 'decor', label: 'Potted Plant (M)', width: 0.3, depth: 0.3, height: 0.7, icon: '\u{1FAB4}', defaultMetadata: { variant: 'bush' } },
  { type: 'PLANT', category: 'decor', label: 'Floor Plant (Ficus)', width: 0.4, depth: 0.4, height: 1.5, icon: '\u{1F333}', defaultMetadata: { variant: 'tall' } },
  { type: 'PLANT', category: 'decor', label: 'Floor Plant (Tall)', width: 0.45, depth: 0.45, height: 1.8, icon: '\u{1F333}', defaultMetadata: { variant: 'tall' } },
  { type: 'PLANT', category: 'decor', label: 'Pink Flower', width: 0.2, depth: 0.2, height: 0.4, icon: '\u{1F337}', defaultMetadata: { variant: 'flower', flowerColor: '#e05570' } },
  { type: 'PLANT', category: 'decor', label: 'Yellow Flower', width: 0.2, depth: 0.2, height: 0.4, icon: '\u{1F33B}', defaultMetadata: { variant: 'flower', flowerColor: '#f0c040' } },
  { type: 'PLANT', category: 'decor', label: 'Red Flower', width: 0.2, depth: 0.2, height: 0.4, icon: '\u{1F339}', defaultMetadata: { variant: 'flower', flowerColor: '#c8394a' } },
  { type: 'PLANT', category: 'decor', label: 'White Flower', width: 0.2, depth: 0.2, height: 0.4, icon: '\u{1F33C}', defaultMetadata: { variant: 'flower', flowerColor: '#f4f4ee' } },
  // Mirrors — framed reflective panels. Two variants:
  //   - wall: thin panel, wall-mounted, default elevation ~1.2m (eye level)
  //   - floor: full-length with an A-frame stand, sits on the floor
  // Depth reflects the physical thickness including any stand legs.
  { type: 'MIRROR', category: 'decor', label: 'Wall Mirror (S)', width: 0.6, depth: 0.04, height: 0.9, icon: '\u{1FA9E}', defaultMetadata: { variant: 'wall' } },
  { type: 'MIRROR', category: 'decor', label: 'Wall Mirror (M)', width: 0.8, depth: 0.04, height: 1.2, icon: '\u{1FA9E}', defaultMetadata: { variant: 'wall' } },
  { type: 'MIRROR', category: 'decor', label: 'Wall Mirror (L)', width: 1.0, depth: 0.04, height: 1.5, icon: '\u{1FA9E}', defaultMetadata: { variant: 'wall' } },
  { type: 'MIRROR', category: 'decor', label: 'Floor Mirror', width: 0.5, depth: 0.4, height: 1.6, icon: '\u{1FA9E}', defaultMetadata: { variant: 'floor' } },
  { type: 'MIRROR', category: 'decor', label: 'Floor Mirror (L)', width: 0.6, depth: 0.5, height: 1.8, icon: '\u{1FA9E}', defaultMetadata: { variant: 'floor' } },
  // Scratching posts — cat furniture. Variants control the mesh style:
  //   - `simple`  → single sisal-wrapped post on a base with a small platform on top
  //   - `tree`    → multi-tier cat tree with 2–3 platforms at different heights
  //   - `condo`   → tower with an enclosed cubby and a platform on the roof
  //   - `wall`    → flat wall-mounted scratcher pad (thin, meant to be elevated)
  { type: 'SCRATCHING_POST', category: 'pets', label: 'Scratching Post (S)', width: 0.3, depth: 0.3, height: 0.5, icon: '\u{1F431}', defaultMetadata: { variant: 'simple' } },
  { type: 'SCRATCHING_POST', category: 'pets', label: 'Scratching Post', width: 0.35, depth: 0.35, height: 0.7, icon: '\u{1F431}', defaultMetadata: { variant: 'simple' } },
  { type: 'SCRATCHING_POST', category: 'pets', label: 'Cat Tree (S)', width: 0.45, depth: 0.45, height: 0.9, icon: '\u{1F408}', defaultMetadata: { variant: 'tree' } },
  { type: 'SCRATCHING_POST', category: 'pets', label: 'Cat Tree (M)', width: 0.55, depth: 0.55, height: 1.3, icon: '\u{1F408}', defaultMetadata: { variant: 'tree' } },
  { type: 'SCRATCHING_POST', category: 'pets', label: 'Cat Tree (L)', width: 0.65, depth: 0.65, height: 1.7, icon: '\u{1F408}', defaultMetadata: { variant: 'tree' } },
  { type: 'SCRATCHING_POST', category: 'pets', label: 'Cat Condo', width: 0.45, depth: 0.45, height: 1.0, icon: '\u{1F3E0}', defaultMetadata: { variant: 'condo' } },
  { type: 'SCRATCHING_POST', category: 'pets', label: 'Cat Condo (L)', width: 0.55, depth: 0.55, height: 1.4, icon: '\u{1F3E0}', defaultMetadata: { variant: 'condo' } },
  { type: 'SCRATCHING_POST', category: 'pets', label: 'Wall Scratcher', width: 0.2, depth: 0.04, height: 0.6, icon: '\u{1F431}', defaultMetadata: { variant: 'wall' } },
];
