// Bounding box que cubre el norte/centro de Chile y el norte de Argentina
// (donde están los activos). Proyección lineal simple lat/lng → XY normalizado.
export const MAP_BOUNDS = {
  north: -17,
  south: -52,
  west: -76,
  east: -64,
}

function clamp01(v: number): number {
  return Math.max(0, Math.min(1, v))
}

export function projectCoord(lat: number, lng: number): { x: number; y: number } {
  const x = (lng - MAP_BOUNDS.west) / (MAP_BOUNDS.east - MAP_BOUNDS.west)
  const y = (lat - MAP_BOUNDS.north) / (MAP_BOUNDS.south - MAP_BOUNDS.north)
  return { x: clamp01(x), y: clamp01(y) }
}
