import { ARCH_SERVICES, LAYERS, type ArchService, type ServiceLayer } from './architecture-data'

// =============================================================================
// TYPES
// =============================================================================

export type LayerFilter = 'alle' | ServiceLayer

// =============================================================================
// LAYOUT
// =============================================================================

export const NODE_WIDTH = 180
export const NODE_HEIGHT = 70
export const NODE_X_SPACING = 220
export const LANE_Y_START = 80
export const LANE_LABEL_HEIGHT = 40

export const LAYER_ORDER: ServiceLayer[] = ['frontend', 'backend', 'infrastructure', 'data-sovereignty']

export function getServicePosition(service: ArchService): { x: number; y: number } {
  const layer = LAYERS[service.layer]
  const layerServices = ARCH_SERVICES.filter(s => s.layer === service.layer)
  const idx = layerServices.findIndex(s => s.id === service.id)

  return {
    x: 80 + idx * NODE_X_SPACING,
    y: LANE_Y_START + LANE_LABEL_HEIGHT + layer.y,
  }
}
