// SPDX-FileCopyrightText: Adam Evyčędo
//
// SPDX-License-Identifier: GPL-3.0-or-later

package xyz.apiote.bimba.czwek.repo

import xyz.apiote.bimba.czwek.api.LineTypeV1
import xyz.apiote.bimba.czwek.api.LineTypeV2
import xyz.apiote.bimba.czwek.api.LineTypeV3

enum class LineType {
	UNKNOWN, TRAM, BUS, TROLLEYBUS, METRO, RAIL, FERRY, CABLE_TRAM, CABLE_CAR, FUNICULAR, MONORAIL, PLANE;

	companion object {
		fun of(t: LineTypeV1): LineType {
			return when (t) {
				LineTypeV1.UNKNOWN -> valueOf("UNKNOWN")
				LineTypeV1.TRAM -> valueOf("TRAM")
				LineTypeV1.BUS -> valueOf("BUS")
			}
		}
		fun of(t: LineTypeV2): LineType {
			return when (t) {
				LineTypeV2.UNKNOWN -> valueOf("UNKNOWN")
				LineTypeV2.TRAM -> valueOf("TRAM")
				LineTypeV2.BUS -> valueOf("BUS")
				LineTypeV2.TROLLEYBUS -> valueOf("TROLLEYBUS")
			}
		}
		fun of(t: LineTypeV3): LineType {
			return when (t) {
				LineTypeV3.UNKNOWN -> valueOf("UNKNOWN")
				LineTypeV3.TRAM -> valueOf("TRAM")
				LineTypeV3.BUS -> valueOf("BUS")
				LineTypeV3.TROLLEYBUS -> valueOf("TROLLEYBUS")
				LineTypeV3.METRO -> valueOf("METRO")
				LineTypeV3.RAIL -> valueOf("RAIL")
				LineTypeV3.FERRY -> valueOf("FERRY")
				LineTypeV3.CABLE_TRAM -> valueOf("CABLE_TRAM")
				LineTypeV3.CABLE_CAR -> valueOf("CABLE_CAR")
				LineTypeV3.FUNICULAR -> valueOf("FUNICULAR")
				LineTypeV3.MONORAIL -> valueOf("MONORAIL")
			}
		}

		fun fromTransitous(clasz: Int): LineType {
			return when (clasz) {
				0 -> PLANE
				1 -> RAIL
				2 -> RAIL
				3 -> BUS
				4 -> RAIL
				5 -> RAIL
				6 -> RAIL
				7 -> METRO
				8 -> METRO
				9 -> TRAM
				10 -> BUS
				11 -> FERRY
				12 -> UNKNOWN // other
				else -> UNKNOWN
			}
		}
	}
}