'use strict';

var spriteGeneratorCore = require('./spriteGeneratorCore.js');

/**
 * buildingGeneratorPresets.ts — Modular building generator.
 *
 * Buildings are assembled from stackable floors: foundation, wall floors,
 * roof. Each floor has layout, style and colour options.
 * Doors, windows, chimneys are placed as decoration parts.
 */
/* ════════════════════════════════════════════════════════════════
   COLOUR PALETTES
   ════════════════════════════════════════════════════════════════ */
const WALL_PALETTES = {
    stone: ['#a0a0a0', '#808080', '#606060', '#404040'],
    brick: ['#c06040', '#a04830', '#803020', '#602018'],
    wood: ['#c09060', '#a07848', '#806038', '#604828'],
    sandstone: ['#e0c890', '#c8b070', '#b09850', '#988038'],
    marble: ['#f0f0f0', '#d8d8e0', '#c0c0c8', '#a8a8b0'],
    darkStone: ['#585860', '#404048', '#303038', '#202028'],
};
const ROOF_PALETTES = {
    redTile: ['#c04030', '#a03020', '#802018', '#601010'],
    darkTile: ['#505058', '#404048', '#303038', '#202028'],
    thatch: ['#c0a040', '#a08830', '#807020', '#605818'],
    blue: ['#4060b0', '#304890', '#203870', '#182850'],
    green: ['#408040', '#306830', '#205020', '#103810'],
};
/* ════════════════════════════════════════════════════════════════
   BUILDING PARTS — transparent shorthand
   ════════════════════════════════════════════════════════════════ */
const _ = -1;
/* ── Foundations ── */
const FOUNDATION_STONE = spriteGeneratorCore.createPartData(16, 4, [
    [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],
    [0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0],
    [0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0],
    [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
], ['#a0a0a0', '#606060']);
const FOUNDATION_BRICK = spriteGeneratorCore.createPartData(16, 4, [
    [1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0],
    [0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0],
    [1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0],
    [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
], ['#c06040', '#803020']);
const FOUNDATION_WOOD = spriteGeneratorCore.createPartData(16, 3, [
    [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],
    [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
    [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
], ['#c09060', '#604828']);
/* ── Wall sections (one floor height) ── */
const WALL_STONE_SECTION = spriteGeneratorCore.createPartData(16, 8, [
    [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],
    [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],
    [0, 0, 0, 2, 0, 0, 0, 2, 0, 0, 2, 0, 0, 0, 0, 0],
    [0, 0, 2, 0, 0, 0, 2, 0, 0, 0, 0, 0, 2, 0, 0, 0],
    [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],
    [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],
    [0, 0, 0, 0, 2, 0, 0, 0, 0, 2, 0, 0, 0, 2, 0, 0],
    [0, 0, 2, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 2, 0],
], ['#a0a0a0', '#808080', '#606060']);
const WALL_BRICK_SECTION = spriteGeneratorCore.createPartData(16, 8, [
    [2, 0, 0, 0, 2, 0, 0, 0, 2, 0, 0, 0, 2, 0, 0, 0],
    [0, 0, 2, 0, 0, 0, 2, 0, 0, 0, 2, 0, 0, 0, 2, 0],
    [2, 0, 0, 0, 2, 0, 0, 0, 2, 0, 0, 0, 2, 0, 0, 0],
    [0, 0, 2, 0, 0, 0, 2, 0, 0, 0, 2, 0, 0, 0, 2, 0],
    [2, 0, 0, 0, 2, 0, 0, 0, 2, 0, 0, 0, 2, 0, 0, 0],
    [0, 0, 2, 0, 0, 0, 2, 0, 0, 0, 2, 0, 0, 0, 2, 0],
    [2, 0, 0, 0, 2, 0, 0, 0, 2, 0, 0, 0, 2, 0, 0, 0],
    [0, 0, 2, 0, 0, 0, 2, 0, 0, 0, 2, 0, 0, 0, 2, 0],
], ['#c06040', '#a04830', '#803020']);
const WALL_WOOD_SECTION = spriteGeneratorCore.createPartData(16, 8, [
    [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],
    [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],
    [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],
    [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
    [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],
    [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],
    [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],
    [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
], ['#c09060', '#806038']);
const WALL_HALFTIMBER_SECTION = spriteGeneratorCore.createPartData(16, 8, [
    [2, 0, 0, 0, 0, 0, 0, 2, 2, 0, 0, 0, 0, 0, 0, 2],
    [2, 0, 0, 0, 0, 0, 2, 0, 0, 2, 0, 0, 0, 0, 0, 2],
    [2, 0, 0, 0, 0, 2, 0, 0, 0, 0, 2, 0, 0, 0, 0, 2],
    [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],
    [2, 0, 0, 0, 0, 2, 0, 0, 0, 0, 2, 0, 0, 0, 0, 2],
    [2, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 2],
    [2, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 2],
    [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],
], ['#f0e8d0', '#e0d8c0', '#806038']);
/* ── Roofs ── */
const ROOF_TRIANGLE = spriteGeneratorCore.createPartData(20, 8, [
    [_, _, _, _, _, _, _, _, _, 0, 0, _, _, _, _, _, _, _, _, _],
    [_, _, _, _, _, _, _, _, 0, 1, 1, 0, _, _, _, _, _, _, _, _],
    [_, _, _, _, _, _, _, 0, 1, 1, 1, 1, 0, _, _, _, _, _, _, _],
    [_, _, _, _, _, _, 0, 1, 1, 1, 1, 1, 1, 0, _, _, _, _, _, _],
    [_, _, _, _, _, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, _, _, _, _, _],
    [_, _, _, _, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, _, _, _, _],
    [_, _, _, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, _, _, _],
    [_, _, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, _, _],
], ['#c04030', '#a03020', '#602018']);
const ROOF_FLAT = spriteGeneratorCore.createPartData(18, 4, [
    [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
    [0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0],
    [0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0],
    [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],
], ['#505058', '#404048', '#303038']);
const ROOF_PAGODA = spriteGeneratorCore.createPartData(22, 6, [
    [_, _, _, _, _, _, _, _, _, _, 0, 0, _, _, _, _, _, _, _, _, _, _],
    [_, _, _, _, _, _, _, _, 0, 0, 1, 1, 0, 0, _, _, _, _, _, _, _, _],
    [_, _, _, _, _, _, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, _, _, _, _, _, _],
    [_, _, _, _, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, _, _, _, _],
    [_, _, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, _, _],
    [0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0],
], ['#c04030', '#a03020', '#602018']);
const ROOF_DOME = spriteGeneratorCore.createPartData(18, 8, [
    [_, _, _, _, _, _, _, 0, 0, 0, 0, _, _, _, _, _, _, _],
    [_, _, _, _, _, 0, 0, 1, 1, 1, 1, 0, 0, _, _, _, _, _],
    [_, _, _, _, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, _, _, _, _],
    [_, _, _, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, _, _, _],
    [_, _, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, _, _],
    [_, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, _],
    [0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0],
    [0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0],
], ['#4060b0', '#304890', '#203870']);
/* ── Doors ── */
const DOOR_WOOD = spriteGeneratorCore.createPartData(4, 6, [
    [_, 0, 0, _],
    [0, 1, 1, 0],
    [0, 1, 1, 0],
    [0, 1, 2, 0],
    [0, 1, 1, 0],
    [0, 1, 1, 0],
], ['#604828', '#c09060', '#f0d060']);
const DOOR_ARCH = spriteGeneratorCore.createPartData(6, 8, [
    [_, _, 0, 0, _, _],
    [_, 0, 1, 1, 0, _],
    [0, 1, 1, 1, 1, 0],
    [0, 1, 1, 1, 1, 0],
    [0, 1, 1, 1, 1, 0],
    [0, 1, 1, 2, 1, 0],
    [0, 1, 1, 1, 1, 0],
    [0, 1, 1, 1, 1, 0],
], ['#604828', '#a07848', '#f0d060']);
const DOOR_DOUBLE = spriteGeneratorCore.createPartData(8, 7, [
    [_, 0, 0, 0, 0, 0, 0, _],
    [0, 1, 1, 0, 0, 1, 1, 0],
    [0, 1, 1, 0, 0, 1, 1, 0],
    [0, 1, 2, 0, 0, 2, 1, 0],
    [0, 1, 1, 0, 0, 1, 1, 0],
    [0, 1, 1, 0, 0, 1, 1, 0],
    [0, 0, 0, 0, 0, 0, 0, 0],
], ['#604828', '#c09060', '#f0d060']);
/* ── Windows ── */
const WINDOW_SIMPLE = spriteGeneratorCore.createPartData(4, 4, [
    [0, 0, 0, 0],
    [0, 1, 1, 0],
    [0, 1, 1, 0],
    [0, 0, 0, 0],
], ['#404040', '#88c8ff']);
const WINDOW_CROSS = spriteGeneratorCore.createPartData(4, 4, [
    [0, 0, 0, 0],
    [0, 1, 0, 1],
    [0, 0, 0, 0],
    [0, 1, 0, 1],
], ['#404040', '#88c8ff']);
const WINDOW_ARCH = spriteGeneratorCore.createPartData(4, 5, [
    [_, 0, 0, _],
    [0, 1, 1, 0],
    [0, 1, 1, 0],
    [0, 0, 0, 0],
    [0, 1, 1, 0],
], ['#404040', '#88c8ff']);
const WINDOW_ROUND = spriteGeneratorCore.createPartData(4, 4, [
    [_, 0, 0, _],
    [0, 1, 1, 0],
    [0, 1, 1, 0],
    [_, 0, 0, _],
], ['#404040', '#88c8ff']);
/* ── Chimneys ── */
const CHIMNEY_BRICK = spriteGeneratorCore.createPartData(4, 6, [
    [_, 2, 2, _],
    [0, 0, 0, 0],
    [0, 1, 1, 0],
    [0, 1, 1, 0],
    [0, 1, 1, 0],
    [0, 0, 0, 0],
], ['#c06040', '#a04830', '#606060']);
const CHIMNEY_STONE = spriteGeneratorCore.createPartData(3, 5, [
    [_, 2, _],
    [0, 0, 0],
    [0, 1, 0],
    [0, 1, 0],
    [0, 0, 0],
], ['#808080', '#a0a0a0', '#505050']);
/* ── Decorations ── */
const BALCONY = spriteGeneratorCore.createPartData(8, 3, [
    [0, 0, 0, 0, 0, 0, 0, 0],
    [0, _, 0, _, _, 0, _, 0],
    [0, 0, 0, 0, 0, 0, 0, 0],
], ['#808080']);
const BANNER = spriteGeneratorCore.createPartData(4, 6, [
    [_, 0, 0, _],
    [_, 1, 1, _],
    [_, 1, 1, _],
    [_, 1, 1, _],
    [_, 1, 1, _],
    [_, _, 1, _],
], ['#806038', '#d04040']);
const TOWER_TOP = spriteGeneratorCore.createPartData(8, 4, [
    [0, _, 0, _, 0, _, 0, _],
    [0, 0, 0, 0, 0, 0, 0, 0],
    [0, 1, 1, 1, 1, 1, 1, 0],
    [0, 1, 1, 1, 1, 1, 1, 0],
], ['#808080', '#a0a0a0']);
const SHOP_AWNING = spriteGeneratorCore.createPartData(14, 4, [
    [_, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, _],
    [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1],
    [_, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, _],
    [_, _, 0, _, 0, _, 0, _, 0, _, 0, _, _, _],
], ['#d04040', '#f0f0f0']);
/* ════════════════════════════════════════════════════════════════
   REGISTER BUILDING PARTS
   ════════════════════════════════════════════════════════════════ */
const BUILDING_PARTS = [
    // ── Foundations ──
    {
        id: 'foundation-stone', name: 'Stone Foundation', category: 'foundation', slot: 'foundation',
        anchorX: 8, anchorY: 0, zOrder: 0, tags: ['stone', 'foundation'],
        pixels: { S: FOUNDATION_STONE }, recolorableIndices: [0, 1],
    },
    {
        id: 'foundation-brick', name: 'Brick Foundation', category: 'foundation', slot: 'foundation',
        anchorX: 8, anchorY: 0, zOrder: 0, tags: ['brick', 'foundation'],
        pixels: { S: FOUNDATION_BRICK }, recolorableIndices: [0, 1],
    },
    {
        id: 'foundation-wood', name: 'Wood Foundation', category: 'foundation', slot: 'foundation',
        anchorX: 8, anchorY: 0, zOrder: 0, tags: ['wood', 'foundation'],
        pixels: { S: FOUNDATION_WOOD }, recolorableIndices: [0, 1],
    },
    // ── Walls ──
    {
        id: 'wall-stone', name: 'Stone Wall', category: 'wall', slot: 'wall',
        anchorX: 8, anchorY: 0, zOrder: 1, tags: ['stone', 'wall'],
        pixels: { S: WALL_STONE_SECTION }, recolorableIndices: [0, 1, 2],
    },
    {
        id: 'wall-brick', name: 'Brick Wall', category: 'wall', slot: 'wall',
        anchorX: 8, anchorY: 0, zOrder: 1, tags: ['brick', 'wall'],
        pixels: { S: WALL_BRICK_SECTION }, recolorableIndices: [0, 1, 2],
    },
    {
        id: 'wall-wood', name: 'Wood Wall', category: 'wall', slot: 'wall',
        anchorX: 8, anchorY: 0, zOrder: 1, tags: ['wood', 'wall'],
        pixels: { S: WALL_WOOD_SECTION }, recolorableIndices: [0, 1],
    },
    {
        id: 'wall-halftimber', name: 'Half-timber Wall', category: 'wall', slot: 'wall',
        anchorX: 8, anchorY: 0, zOrder: 1, tags: ['halftimber', 'medieval', 'wall'],
        pixels: { S: WALL_HALFTIMBER_SECTION }, recolorableIndices: [0, 1, 2],
    },
    // ── Roofs ──
    {
        id: 'roof-triangle', name: 'Triangle Roof', category: 'roof', slot: 'roof',
        anchorX: 10, anchorY: 7, zOrder: 10, tags: ['triangle', 'classic'],
        pixels: { S: ROOF_TRIANGLE }, recolorableIndices: [0, 1, 2],
    },
    {
        id: 'roof-flat', name: 'Flat Roof', category: 'roof', slot: 'roof',
        anchorX: 9, anchorY: 3, zOrder: 10, tags: ['flat', 'modern'],
        pixels: { S: ROOF_FLAT }, recolorableIndices: [0, 1, 2],
    },
    {
        id: 'roof-pagoda', name: 'Pagoda Roof', category: 'roof', slot: 'roof',
        anchorX: 11, anchorY: 5, zOrder: 10, tags: ['pagoda', 'asian', 'curved'],
        pixels: { S: ROOF_PAGODA }, recolorableIndices: [0, 1, 2],
    },
    {
        id: 'roof-dome', name: 'Dome Roof', category: 'roof', slot: 'roof',
        anchorX: 9, anchorY: 7, zOrder: 10, tags: ['dome', 'round', 'church'],
        pixels: { S: ROOF_DOME }, recolorableIndices: [0, 1, 2],
    },
    // ── Doors ──
    {
        id: 'door-wood', name: 'Wooden Door', category: 'door', slot: 'door',
        anchorX: 2, anchorY: 0, zOrder: 5, tags: ['wood', 'simple'],
        pixels: { S: DOOR_WOOD }, recolorableIndices: [0, 1, 2],
    },
    {
        id: 'door-arch', name: 'Arch Door', category: 'door', slot: 'door',
        anchorX: 3, anchorY: 0, zOrder: 5, tags: ['arch', 'medieval'],
        pixels: { S: DOOR_ARCH }, recolorableIndices: [0, 1, 2],
    },
    {
        id: 'door-double', name: 'Double Door', category: 'door', slot: 'door',
        anchorX: 4, anchorY: 0, zOrder: 5, tags: ['double', 'grand'],
        pixels: { S: DOOR_DOUBLE }, recolorableIndices: [0, 1, 2],
    },
    // ── Windows ──
    {
        id: 'window-simple', name: 'Simple Window', category: 'window', slot: 'window',
        anchorX: 2, anchorY: 2, zOrder: 5, tags: ['simple', 'basic'],
        pixels: { S: WINDOW_SIMPLE }, recolorableIndices: [0, 1],
    },
    {
        id: 'window-cross', name: 'Cross Window', category: 'window', slot: 'window',
        anchorX: 2, anchorY: 2, zOrder: 5, tags: ['cross', 'medieval'],
        pixels: { S: WINDOW_CROSS }, recolorableIndices: [0, 1],
    },
    {
        id: 'window-arch', name: 'Arch Window', category: 'window', slot: 'window',
        anchorX: 2, anchorY: 2, zOrder: 5, tags: ['arch', 'gothic'],
        pixels: { S: WINDOW_ARCH }, recolorableIndices: [0, 1],
    },
    {
        id: 'window-round', name: 'Round Window', category: 'window', slot: 'window',
        anchorX: 2, anchorY: 2, zOrder: 5, tags: ['round', 'porthole'],
        pixels: { S: WINDOW_ROUND }, recolorableIndices: [0, 1],
    },
    // ── Chimneys ──
    {
        id: 'chimney-brick', name: 'Brick Chimney', category: 'chimney', slot: 'chimney',
        anchorX: 2, anchorY: 5, zOrder: 12, tags: ['brick', 'chimney'],
        pixels: { S: CHIMNEY_BRICK }, recolorableIndices: [0, 1, 2],
    },
    {
        id: 'chimney-stone', name: 'Stone Chimney', category: 'chimney', slot: 'chimney',
        anchorX: 1, anchorY: 4, zOrder: 12, tags: ['stone', 'chimney'],
        pixels: { S: CHIMNEY_STONE }, recolorableIndices: [0, 1, 2],
    },
    // ── Decorations ──
    {
        id: 'deco-balcony', name: 'Balcony', category: 'decoration', slot: 'wall',
        anchorX: 4, anchorY: 0, zOrder: 6, tags: ['balcony', 'decoration'],
        pixels: { S: BALCONY }, recolorableIndices: [0],
    },
    {
        id: 'deco-banner', name: 'Banner', category: 'decoration', slot: 'wall',
        anchorX: 2, anchorY: 0, zOrder: 7, tags: ['banner', 'decoration', 'flag'],
        pixels: { S: BANNER }, recolorableIndices: [0, 1],
    },
    {
        id: 'deco-tower-top', name: 'Tower Battlements', category: 'decoration', slot: 'roof',
        anchorX: 4, anchorY: 3, zOrder: 11, tags: ['tower', 'castle', 'battlements'],
        pixels: { S: TOWER_TOP }, recolorableIndices: [0, 1],
    },
    {
        id: 'deco-shop-awning', name: 'Shop Awning', category: 'decoration', slot: 'wall',
        anchorX: 7, anchorY: 0, zOrder: 6, tags: ['shop', 'awning', 'market'],
        pixels: { S: SHOP_AWNING }, recolorableIndices: [0, 1],
    },
];
/** Assemble a building from config into a SpriteAssembly */
function assembleBuildingFromConfig(config) {
    var _a;
    const floorHeight = 8;
    const foundationHeight = 4;
    const roofHeight = 8;
    const totalHeight = foundationHeight + config.floors.length * floorHeight + roofHeight + 4;
    const parts = [];
    // Foundation at bottom
    const baseY = totalHeight - foundationHeight;
    parts.push({ partId: config.foundationId, offsetX: 0, offsetY: baseY });
    // Floors bottom-up
    for (let i = 0; i < config.floors.length; i++) {
        const floor = config.floors[i];
        const floorY = baseY - (i + 1) * floorHeight;
        // Wall
        parts.push({
            partId: floor.wallId,
            offsetX: 0,
            offsetY: floorY,
            colorOverrides: floor.colorOverrides,
        });
        // Windows
        for (const wx of floor.windowPositions) {
            const winId = floor.windowIds[0] || 'window-simple';
            parts.push({ partId: winId, offsetX: wx, offsetY: floorY + 2 });
        }
        // Door (only ground floor typically)
        if (floor.doorId && floor.doorPosition !== undefined) {
            parts.push({ partId: floor.doorId, offsetX: floor.doorPosition, offsetY: floorY + 2 });
        }
        // Decorations
        if (floor.decorationIds) {
            for (const dId of floor.decorationIds) {
                parts.push({ partId: dId, offsetX: 0, offsetY: floorY });
            }
        }
    }
    // Roof
    const roofY = baseY - config.floors.length * floorHeight - roofHeight;
    parts.push({ partId: config.roofId, offsetX: -2, offsetY: roofY });
    // Chimney
    if (config.chimneyId) {
        parts.push({
            partId: config.chimneyId,
            offsetX: (_a = config.chimneyPosition) !== null && _a !== void 0 ? _a : (config.width - 6),
            offsetY: roofY - 3,
        });
    }
    return {
        id: `building-${config.name.toLowerCase().replace(/\s+/g, '-')}`,
        name: config.name,
        parts,
        canvasWidth: Math.max(config.width, 24),
        canvasHeight: totalHeight,
        projection: 'sideView',
    };
}
const BUILDING_PRESETS = [
    {
        id: 'preset-cottage', name: 'Cottage', description: 'Simple wooden cottage',
        tags: ['wood', 'simple', 'village'],
        config: {
            name: 'Cottage', foundationId: 'foundation-wood', roofId: 'roof-triangle',
            chimneyId: 'chimney-brick', chimneyPosition: 12, width: 16,
            floors: [{
                    wallId: 'wall-wood',
                    windowIds: ['window-simple'],
                    windowPositions: [2, 10],
                    doorId: 'door-wood', doorPosition: 6,
                }],
        },
    },
    {
        id: 'preset-house', name: 'Town House', description: 'Two-story brick house',
        tags: ['brick', 'town', 'residential'],
        config: {
            name: 'Town House', foundationId: 'foundation-brick', roofId: 'roof-triangle',
            chimneyId: 'chimney-brick', chimneyPosition: 11, width: 16,
            floors: [
                {
                    wallId: 'wall-brick',
                    windowIds: ['window-cross'],
                    windowPositions: [2, 10],
                    doorId: 'door-wood', doorPosition: 6,
                },
                {
                    wallId: 'wall-brick',
                    windowIds: ['window-cross'],
                    windowPositions: [2, 6, 10],
                },
            ],
        },
    },
    {
        id: 'preset-castle-tower', name: 'Castle Tower', description: 'Medieval stone tower',
        tags: ['stone', 'castle', 'medieval', 'tower'],
        config: {
            name: 'Castle Tower', foundationId: 'foundation-stone', roofId: 'roof-flat',
            width: 16,
            floors: [
                {
                    wallId: 'wall-stone',
                    windowIds: ['window-arch'],
                    windowPositions: [6],
                    doorId: 'door-arch', doorPosition: 5,
                },
                {
                    wallId: 'wall-stone',
                    windowIds: ['window-arch'],
                    windowPositions: [3, 9],
                },
                {
                    wallId: 'wall-stone',
                    windowIds: ['window-arch'],
                    windowPositions: [3, 9],
                    decorationIds: ['deco-banner'],
                },
            ],
        },
    },
    {
        id: 'preset-shop', name: 'Shop', description: 'Market shop with awning',
        tags: ['wood', 'shop', 'market', 'town'],
        config: {
            name: 'Shop', foundationId: 'foundation-wood', roofId: 'roof-triangle',
            width: 16,
            floors: [{
                    wallId: 'wall-halftimber',
                    windowIds: ['window-simple'],
                    windowPositions: [2, 10],
                    doorId: 'door-double', doorPosition: 4,
                    decorationIds: ['deco-shop-awning'],
                }],
        },
    },
    {
        id: 'preset-inn', name: 'Inn', description: 'Half-timber two-story inn',
        tags: ['halftimber', 'inn', 'medieval', 'town'],
        config: {
            name: 'Inn', foundationId: 'foundation-stone', roofId: 'roof-triangle',
            chimneyId: 'chimney-stone', chimneyPosition: 12, width: 16,
            floors: [
                {
                    wallId: 'wall-halftimber',
                    windowIds: ['window-simple'],
                    windowPositions: [2, 10],
                    doorId: 'door-double', doorPosition: 4,
                },
                {
                    wallId: 'wall-halftimber',
                    windowIds: ['window-cross'],
                    windowPositions: [2, 6, 10],
                    decorationIds: ['deco-balcony'],
                },
            ],
        },
    },
    {
        id: 'preset-temple', name: 'Temple', description: 'Domed temple building',
        tags: ['stone', 'temple', 'church', 'dome'],
        config: {
            name: 'Temple', foundationId: 'foundation-stone', roofId: 'roof-dome',
            width: 18,
            floors: [
                {
                    wallId: 'wall-stone',
                    windowIds: ['window-round'],
                    windowPositions: [3, 11],
                    doorId: 'door-arch', doorPosition: 6,
                },
                {
                    wallId: 'wall-stone',
                    windowIds: ['window-arch'],
                    windowPositions: [3, 7, 11],
                },
            ],
        },
    },
    {
        id: 'preset-pagoda', name: 'Pagoda', description: 'Multi-story pagoda tower',
        tags: ['wood', 'pagoda', 'asian', 'tower'],
        config: {
            name: 'Pagoda', foundationId: 'foundation-stone', roofId: 'roof-pagoda',
            width: 16,
            floors: [
                {
                    wallId: 'wall-wood',
                    windowIds: ['window-arch'],
                    windowPositions: [3, 9],
                    doorId: 'door-arch', doorPosition: 6,
                },
                {
                    wallId: 'wall-wood',
                    windowIds: ['window-arch'],
                    windowPositions: [3, 9],
                },
                {
                    wallId: 'wall-wood',
                    windowIds: ['window-round'],
                    windowPositions: [6],
                },
            ],
        },
    },
];
/** Initialize: register all building parts */
function initBuildingParts() {
    spriteGeneratorCore.registerParts(BUILDING_PARTS);
}

exports.BUILDING_PARTS = BUILDING_PARTS;
exports.BUILDING_PRESETS = BUILDING_PRESETS;
exports.ROOF_PALETTES = ROOF_PALETTES;
exports.WALL_PALETTES = WALL_PALETTES;
exports.assembleBuildingFromConfig = assembleBuildingFromConfig;
exports.initBuildingParts = initBuildingParts;
//# sourceMappingURL=buildingGeneratorPresets.js.map
