--[==[
To inspect the content of this data module, PRe [[Special:ExpandTemplates]]
and enter the following input text:
  {{#invoke:Road data/dump|dump|module=Module:<name-of-this-module>}}

To inspect the content of this data module when editing, enter the following
into the Debug console:
  local util = require("Module:Road data/util")
  print(util.arrayToString(p))
To inspect a particular route type, change `p` above to include the route type,
e.g., `p.I` and `p["PR-Hist"]`.
]==]

-- Puerto Rico
local PR = {}

local util = require("Module:Road data/util")
local format = mw.ustring.format
util.addAll(PR, require("Module:Road data/strings/USA"))

local suffix = " ([dab||%dab%, |]Puerto Rico)"

PR.I.shield = "I-PR%route%.svg"
PR.I.link = "Interstate PR%route%"
PR.I.abbr = "PRI-%route%"

local primary = "PR primary %route%.svg"
local urban = "PR urban primary %route%.svg"
local secondary = "PR secondary %route%.svg"
local tertiary = "Ellipse sign %route%.svg"

local shieldmain = {
	default = {
		hook = "splitlen",
		split = 3,
		above = {
			hook = "split",
			split = 300,
			above = tertiary,
			below = secondary
		},
		below = primary
	},
	["1"] = {primary, urban, secondary, tertiary},
	["1P"] = {urban, tertiary},
	["1R"] = {urban, tertiary},
	["2"] = {primary, urban, secondary},
	["2R"] = urban,
	["3"] = {primary, urban, secondary, tertiary},
	["3R"] = urban,
	["5"] = {primary, urban, secondary, tertiary},
	["6"] = urban,
	["8"] = urban,
	["9"] = urban,
	["14"] = {urban, secondary, tertiary},
	["14P"] = {urban, tertiary},
	["14R"] = tertiary,
	["15"] = {urban, tertiary},
	["15P"] = urban,
	["16"] = urban,
	["17"] = {primary, urban},
	["19"] = tertiary,
	["21"] = {urban, tertiary},
	["22"] = {"PR toll roads.svg", primary},
	["23"] = urban,
	["24"] = tertiary,
	["25"] = urban,
	["25P"] = urban,
	["25R"] = urban,
	["27"] = {urban, tertiary},
	["28"] = tertiary,
	["29"] = tertiary,
	["31"] = {secondary, tertiary},
	["32"] = urban,
	["33"] = urban,
	["34"] = urban,
	["35"] = urban,
	["36"] = tertiary,
	["37"] = tertiary,
	["38"] = tertiary,
	["39"] = tertiary,
	["40"] = tertiary,
	["41"] = tertiary,
	["42"] = tertiary,
	["47"] = tertiary,
	["52"] = {"PR toll roads.svg", primary},
	["53"] = {"PR toll roads.svg", primary},
	["54R"] = urban,
	["63"] = urban,
	["64"] = tertiary,
	["65"] = urban,
	["66"] = {"PR toll roads.svg", primary},
	["101"] = {secondary, tertiary},
	["102"] = {urban, secondary, tertiary},
	["103"] = tertiary,
	["103R"] = tertiary,
	["104"] = tertiary,
	["105"] = {urban, secondary, tertiary},
	["106"] = {urban, secondary},
	["107"] = {urban, secondary},
	["108"] = {urban, secondary},
	["109"] = {secondary, tertiary},
	["110"] = {secondary, tertiary},
	["110R"] = tertiary,
	["111R"] = tertiary,
	["112"] = {secondary, tertiary},
	["113"] = tertiary,
	["114"] = {urban, secondary, tertiary},
	["115"] = {secondary, tertiary},
	["115R"] = tertiary,
	["116R"] = tertiary,
	["117"] = tertiary,
	["118"] = tertiary,
	["119"] = {secondary, tertiary},
	["121"] = {secondary, tertiary},
	["123"] = {primary, urban, secondary, tertiary},
	["123P"] = {urban, tertiary},
	["124"] = {secondary, tertiary},
	["125"] = {secondary, tertiary},
	["125R"] = tertiary,
	["127"] = tertiary,
	["128"] = tertiary,
	["129"] = {urban, secondary},
	["130"] = tertiary,
	["131"] = tertiary,
	["132"] = {urban, secondary},
	["133"] = urban,
	["134"] = tertiary,
	["135"] = {secondary, tertiary},
	["136"] = tertiary,
	["139"] = {urban, tertiary},
	["139R"] = tertiary,
	["140"] = {secondary, tertiary},
	["143"] = {secondary, tertiary},
	["144"] = {secondary, tertiary},
	["149"] = {secondary, tertiary},
	["149P"] = secondary,
	["149R"] = {secondary, tertiary},
	["152P"] = secondary,
	["154"] = tertiary,
	["155"] = {secondary, tertiary},
	["155P"] = tertiary,
	["156"] = {urban, secondary, tertiary},
	["156R"] = tertiary,
	["158"] = tertiary,
	["159"] = {secondary, tertiary},
	["160"] = tertiary,
	["162"] = {secondary, tertiary},
	["163"] = urban,
	["164"] = {secondary, tertiary},
	["165"] = {urban, secondary, tertiary},
	["165R"] = tertiary,
	["167"] = {urban, secondary},
	["167R"] = tertiary,
	["168"] = tertiary,
	["169"] = tertiary,
	["170"] = tertiary,
	["171"] = tertiary,
	["172"] = {urban, secondary, tertiary},
	["173"] = {secondary, tertiary},
	["174"] = {urban, tertiary},
	["175"] = tertiary,
	["176"] = {urban, tertiary},
	["177"] = urban,
	["178"] = tertiary,
	["179"] = tertiary,
	["180"] = tertiary,
	["181"] = {urban, secondary, tertiary},
	["182"] = tertiary,
	["183"] = {urban, secondary},
	["185"] = {secondary, tertiary},
	["186"] = {tertiary, "Forest Route %route% (Puerto Rico).svg"},
	["187"] = {urban, secondary},
	["187R"] = tertiary,
	["189"] = {urban, tertiary},
	["190"] = tertiary,
	["191"] = {tertiary, "Forest Route %route% (Puerto Rico).svg"},
	["191N"] = tertiary,
	["191S"] = tertiary,
	["192"] = tertiary,
	["193"] = tertiary,
	["194"] = {secondary, tertiary},
	["195"] = {secondary, tertiary},
	["196"] = urban,
	["198"] = {urban, secondary, tertiary},
	["198P"] = urban,
	["198R"] = urban,
	["199"] = {urban, tertiary},
	["200"] = tertiary,
	["200R"] = tertiary,
	["201"] = tertiary,
	["206"] = urban,
	["239"] = urban,
	["249"] = urban,
	["250"] = tertiary,
	["251"] = tertiary,
	["252"] = tertiary,
	["253"] = tertiary,
	["259"] = urban,
	["315"] = {secondary, tertiary},
	["318"] = secondary,
	["319"] = secondary,
	["339"] = secondary,
	["343"] = {urban, tertiary},
	["357"] = secondary,
	["385"] = {secondary, tertiary},
	["402"] = {secondary, tertiary},
	["409"] = {secondary, tertiary},
	["417"] = {secondary, tertiary},
	["440"] = urban,
	["500"] = {urban, tertiary},
	["503"] = {secondary, tertiary},
	["505"] = {urban, secondary},
	["533"] = secondary,
	["585"] = urban,
	["621"] = {secondary, tertiary},
	["642"] = {secondary, tertiary},
	["649"] = secondary,
	["693"] = {secondary, tertiary},
	["694"] = {secondary, tertiary},
	["719"] = secondary,
	["722"] = secondary,
	["734"] = secondary,
	["735"] = {urban, secondary},
	["740"] = secondary,
	["741"] = {secondary, tertiary},
	["760"] = {primary, tertiary},
	["775"] = {secondary, tertiary},
	["778"] = {secondary, tertiary},
	["779"] = {secondary, tertiary},
	["784"] = {urban, tertiary},
	["797"] = secondary,
	["860"] = {urban, tertiary},
	["887"] = {urban, tertiary},
	["901"] = {primary, secondary, tertiary},
	["906"] = {urban, tertiary},
	["908"] = {urban, tertiary},
	["909"] = {urban, tertiary},
	["943P"] = tertiary,
	["951"] = {secondary, tertiary},
	["1107"] = urban,
	["1107P"] = urban,
	["3108"] = urban,
	["3132"] = {secondary, tertiary},
	["4406"] = secondary,
	["4409"] = secondary,
	["4472"] = secondary,
	["5155"] = secondary,
	["5506"] = urban,
	["5516"] = {primary, secondary},
	["5518"] = primary,
	["5555"] = {secondary, tertiary},
	["6165"] = secondary,
	["6632"] = secondary,
	["6633"] = secondary,
	["6642"] = secondary,
	["6685"] = {secondary, tertiary},
	["7152"] = secondary,
	["7715"] = {urban, tertiary},
	["7718"] = secondary,
	["7722"] = secondary,
	["7733"] = {secondary, tertiary},
	["7774"] = secondary,
	["7778"] = secondary,
	["8860"] = urban,
	["9185"] = secondary,
	["9188"] = secondary,
	["9914"] = {primary, tertiary},
}

PR.PR = {
	shield = primary,
	shieldmain = shieldmain,
	name = "Highway %route%",
	link = "Puerto Rico Highway %route% [dab||(%dab%)|]",
	abbr = "PR-%route%",
	width = "expand",
	translation = "Ruta %route%",
	lang = "es"
}

PR.Urban = {
	shield = urban
}

PR.Sec = {
	shield = {
		ifexists = true,
		default = secondary,
		otherwise = {
			hook = "splitlen",
			split = 3,
			above = "CR %route% jct wide.svg",
			below = "CR %route% jct.svg"
		}
	}
}
	

PR.Ter = {
	shield = tertiary
}

for k, v in pairs(PR) do if k:find ("^%a") then 
	v.name = PR.PR.name
	v.link = PR.PR.link
	v.abbr = PR.PR.abbr
	v.width = PR.PR.width
	v.translation = PR.PR.translation
	v.lang = PR.PR.lang
	v.color = {
		arg = "route",
		["186"] = "hist",
		["191"] = "hist"
	}
	end
end

for _,type in ipairs({'PR', 'Urban', 'Sec', 'Ter'}) do
	for _,auxType in ipairs({"Spur"}) do
		local spec = PR[" aux "][auxType]
		PR[type .. "-" .. auxType] = {
			shield = PR[type].shield,
			shieldmain = PR[type].shield,
			name = PR[type].name .. " Spur",
			link = PR[type].link .. " Spur" .. suffix,
			abbr = PR[type].abbr .. " Spur",
			banner = "Spur plate (es).svg",
			aux = spec.aux,
			width = PR[type].width,
			translation = "Ruta %route% Ramal",
			lang = "es"
		}
	end
end

PR["PR-Spur"].banner = "Spur plate blue (es).svg"
PR["Sec-Spur"].banner = "Spur plate county (es).svg"
PR["PR-Ramal"] = PR["PR-Spur"]	
PR["Urban-Ramal"] = PR["Urban-Spur"]
PR["Sec-Ramal"] = PR["Sec-Spur"]
PR["Ter-Ramal"] = PR["Ter-Spur"]

-- add new types above this line if you want it to have the state highway browse and maint
for k, v in pairs(PR) do if k:find ("^%a") then
	v.maint = "[[Puerto Rico Department of Transportation and Public Works|Puerto Rico DTPW]]"
	end
end

return PR