--[==[
To inspect the content of this data module, use [[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))
]==]

--Washington
local WA = require("Module:Road data/strings/USA")

local util = require("Module:Road data/util")
local format = mw.ustring.format

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

WA.I.link =  {
	["82"]  = "Interstate 82",
	["182"] = "Interstate 182",
	["205"] = "Interstate 205 (Oregon–Washington)",
	["705"] = "Interstate 705",
	default = {
		hook = "splitlen",
		split = 3,
		above = "Interstate %route% (Washington)",
		below = "Interstate %route% in Washington"
	}
}
WA.I.law = "[[Revised Code of Washington|RCW]] <span class='plainlinks'>[http://apps.leg.wa.gov/RCW/default.aspx?cite=47.17.%section% 47.17.%section%]</span>"

for k, v in pairs(WA) do if k:find ("^I") then 
	v.link = WA.I.link
	end
end

WA.BL.link = "Interstate %route% Business" .. suffix

for k, v in pairs(WA) do if k:find ("^BL") then 
	v.link = WA.BL.link
	end
end

WA.US.link = "U.S. Route %route% in Washington"
WA.US.law = WA.I.law

for k, v in pairs(WA) do if k:find ("^US %d") then 
	v.link = WA.US.link
	end
end

for _,auxType in ipairs({"Alt", "Bus", "Byp", "City", "Conn", "Emerg", "Future", "Opt", "Scenic", "Spur", "Temp", "Toll", "Truck"}) do
	local spec = WA[" aux "][auxType]
		for k, v in pairs(WA) do if k:find (auxType) then if k:find ("^US") then
			v.base = WA.US.base .. " " .. spec.name
			v.link = WA.US.base .. " " .. spec.name .. suffix
			v.banner = spec.banneralt .. " plate.svg"
			end
		end
	end
end

WA["US-Alt2"] = {
	shield = "US %route% Alternate (Washington).svg",
	base = WA["US-Alt"].base,
	name = WA["US-Alt"].name,
	link = WA["US-Alt"].link,
	abbr = WA["US-Alt"].abbr,
	aux = WA["US-Alt"].aux,
	width = WA["US-Alt"].width,
	nbrowse = WA.US.nbrowse,
	nbrowselinks = WA.US.nbrowselinks
}

for _,year in ipairs({'1926', '1948', '1961'}) do
	for _,auxType in ipairs({"Alt", "Bus", "Byp", "Conn", "Opt", "Scenic", "Spur", "Temp", "Truck"}) do
		local type = "US " .. year
		local spec = WA[" aux "][auxType]
		WA[type .. "-" .. auxType] = {
			shield = WA[type].shield,
			shieldmain = WA[type].shieldmain,
			name = WA[type].name .. " " .. spec.name,
			link = WA[type].link .. " " .. spec.name .. suffix,
			abbr = WA[type].abbr .. " " .. spec.abbrsuffix,
			banner = spec.banneralt .. " plate " .. year .. ".svg",
			aux = spec.aux,
			width = WA[type].width
		}
	end
end

WA["US-Alt-plain"] = {
	shield = WA["US-Alt"].shield,
	base = WA["US-Alt"].base,
	name = WA["US-Alt"].name,
	link = WA["US-Alt"].base .. " ([dab|Washington–Montana|%dab%|%dab%, Washington])",
	abbr = WA["US-Alt"].abbr,
	aux = WA["US-Alt"].aux,
	width = WA["US-Alt"].width,
	nbrowse = WA.US.nbrowse,
	nbrowselinks = WA.US.nbrowselinks
}

WA.WA = {
	shield = "WA-%route%.svg",
	base = "Washington State Route %route%",
	name = "State Route %route%",
	link = "Washington State Route %route% [dab||(%dab%)|]",
	abbr = "SR&nbsp;%route%",
	law = WA.I.law
}
WA.SR = WA.WA

for _,type in ipairs({'WA', 'SR'}) do
	for _,auxType in ipairs({"Alt", "Bus", "Byp", "Conn", "Opt", "Scenic", "Spur", "Temp", "Toll", "Truck"}) do
		local spec = WA[" aux "][auxType]
		WA[type .. "-" .. auxType] = {
			shield = WA[type].shield,
			shieldmain = WA[type].shieldmain,
			name = WA[type].name .. " " .. spec.name,
			link = WA[type].base .. " " .. spec.name .. WA[" dab "],
			abbr = WA[type].abbr .. " " .. spec.abbrsuffix,
			banner = spec.banneralt .. " plate.svg",
			aux = spec.aux,
			width = WA[type].width
		}
	end
end
WA["SR-ALT"] = WA["SR-Alt"]

WA["SR-Toll"].link = {
	default = WA.SR.link
}
WA["WA-Toll"].link = WA["SR-Toll"].link

WA.FR.link = ""
WA.FH.link = ""
WA.FFH=WA.FH

-- add new types above this line if you want it to have the state highway browse and maint
for k, v in pairs(WA) do if k:find ("^%a") then
	v.maint = "[[Washington State Department of Transportation|WSDOT]]"
	v.browse = "[[State highways in Washington]]"
	v.browselinks = {
		[1] = "[[List of Interstate Highways in Washington|Interstate]]",
		[2] = "[[List of U.S. Routes in Washington|US]]",
		[3] = "[[List of state routes in Washington|State]]",
		[4] = "[[Washington State Scenic and Recreational Highways|Scenic]]",
		[5] = "[[List of Primary State Highways in Washington|Former PSH]]",
		[6] = "[[1964 state highway renumbering (Washington)|1964 renumbering]]",
		[7] = "[[List of former state routes in Washington|Former]]"
	}
	end
end

for k, v in pairs(WA) do if k:find ("^%a+ %d") then 
	v.maint = "[[Washington State Department of Highways]]"
	end
end

WA.PSH = {
	shield = "WA-PSH%route%.svg",
	name = "Primary State Highway %route%",
	link = "Primary State Highway %route% (Washington)",
	abbr = "PSH&nbsp;%route%",
	orientation = "upright",
	maint = WA["US 1926"].maint
}

WA.SSH = {
	shield = "WA-SSH%route%.svg",
	name = "Secondary State Highway %route%",
	link = "Secondary State Highway %route% (Washington)",
	abbr = "SSH&nbsp;%route%",
	orientation = "upright",
	maint = WA["US 1926"].maint
}

WA.ID = {alias = {module = "USA/ID", type = "SH"}}
WA.OR = {alias = {module = "USA/OR", type = "OR"}}

return WA