| 22 | |
| 23 | // Auto-cycle: first 6 follow DEFAULT_COLOR_ORDER, then pick unused, then random |
| 24 | function getNextAutoColor(existingColors: string[]): string { |
| 25 | const used = new Set(existingColors.map(c => c.toUpperCase())); |
| 26 | const count = existingColors.length; |
| 27 | |
| 28 | // First 6 fields: use the ordered defaults |
| 29 | if (count < DEFAULT_COLOR_ORDER.length) { |
| 30 | const color = DEFAULT_COLOR_ORDER[count]; |
| 31 | if (!used.has(color.toUpperCase())) return color; |
| 32 | } |
| 33 | |
| 34 | // After that, pick first unused from full palette |
| 35 | for (const color of PRESET_COLORS) { |
| 36 | if (!used.has(color.toUpperCase())) return color; |
| 37 | } |
| 38 | |
| 39 | // All used: random from palette |
| 40 | return PRESET_COLORS[Math.floor(Math.random() * PRESET_COLORS.length)]; |
| 41 | } |
| 42 | |
| 43 | const URBAN_LAND_USES = [ |
| 44 | "Residential", "Commercial", "Park / Garden", "Industrial", |