--[==[
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))
To inspect a particular route type, change `p` above to include the route type,
e.g., `p.I` and `p["US-Hist"]`.
]==]

-- Oklahoma
local OK = {}

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

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

OK.I.shield = {hook = "splitlen",
                        	split = 3,
                        	above = "I-%route% (long).svg",
                        	below = "I-%route%.svg"}
OK.I.link	= {	["244"] = "Interstate 244",
				["440"] = "Interstate 44 in Oklahoma#Interstate 440",
				["444"] = "Interstate 444",
				default = {hook = "splitlen",
                           split = 3,
                           above = "Interstate %route% (Oklahoma)",
                           below = "Interstate %route% in Oklahoma"}}

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

OK.BL.link = "Interstate %route% Business" .. suffix
OK["I-Bus"] = OK.BL

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

OK.US.name = "U.S. Highway %route%"
OK.US.link = "U.S. Route %route% in Oklahoma"

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

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



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 = OK[" aux "][auxType]
		OK[type .. "-" .. auxType] = {
			shield = OK[type].shield,
			shieldmain = OK[type].shieldmain,
			name = OK[type].name .. " " .. spec.name,
			link = OK[type].base .. " " .. spec.name .. suffix,
			abbr = OK[type].abbr .. " " .. spec.abbrsuffix,
			banner = spec.bannerprefix .. " plate " .. year .. ".svg",
			aux = spec.aux,
			width = "square"
		}
	end
end

OK.SH = {
	base = "Oklahoma State Highway %route%",
	shield = "Oklahoma State Highway %route%.svg",
	name = "State Highway %route%",
	link = "Oklahoma State Highway %route% [dab||(%dab%)|]",
	abbr = "SH-%route%",
	width = "expand"
}
OK.OK = OK.SH

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

OK["SH-Spur"].shield = {
	["7"] = 'Oklahoma State Highway 7 Spur.svg',
	default = OK.SH.shield
}
OK["SH-Spur"].banner = {
	["7"] = '',
	default = "Spur plate.svg"
}
OK["SH-Toll"].banner = "Toll plate yellow.svg"

for _,year in ipairs({"1924", "1948", "1961"}) do
	OK["SH " .. year] = {
		shield = format("Oklahoma %%route%% %s.svg", year),
		name = OK.SH.name,
		link = OK.SH.link,
		abbr = OK.SH.abbr,
		width = "square",
	}
end

OK["SH 1961"].shield = {
	hook = "splitlen",
	split = 3,
	above = "Elongated circle %route%.svg",
	below = "Circle sign %route%.svg"
	
}

OK["SH-old"] = OK["SH 1961"]
OK["OK-old"] = OK["SH 1961"]

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

OK.Turnpike = {
	shield = {
		Cherokee = {"%route% Turnpike.svg"},
		Chickasaw = {"%route% Turnpike.svg", "Oklahoma State Highway 301.svg"},
		Cimarron = {"%route% Turnpike.svg"},
		Creek = {"%route% Turnpike.svg", "Oklahoma State Highway 364.svg"},
		["Eastern Oklahoma County"] = "", -- for the time being
		["H.E. Bailey"] = {"%route% Turnpike.svg"},
		["Indian Nation"] = {"%route% Turnpike.svg", "Oklahoma State Highway 375.svg"},
		Kickapoo = {"%route% Turnpike.svg"},
		Kilpatrick = {"%route% Turnpike.svg"},
		Muskogee = {"%route% Turnpike.svg", "Oklahoma State Highway 351.svg"},
		Turner = {"%route% Turnpike.svg"},
		["Will Rogers"] = {"%route% Turnpike.svg"},
		default = "%route% Turnpike.svg"
	},
	shieldmain = {
		Cherokee = {"%route% Turnpike.svg", "US 412.svg"},
		Chickasaw = {"%route% Turnpike.svg", "Oklahoma State Highway 301.svg"},
		Cimarron = {"%route% Turnpike.svg", "US 412.svg"},
		Creek = {"%route% Turnpike.svg", "Oklahoma State Highway 364.svg"},
		["Eastern Oklahoma County"] = "", -- for the time being
		["H.E. Bailey"] = {"%route% Turnpike.svg", "I-44 (OK).svg"},
		["Indian Nation"] = {"%route% Turnpike.svg", "Oklahoma State Highway 375.svg"},
		Kickapoo = {"%route% Turnpike.svg", "I-335 (OK).svg"},
		Kilpatrick = {"%route% Turnpike.svg", "I-344 (OK).svg"},
		Muskogee = {"%route% Turnpike.svg", "Oklahoma State Highway 351.svg"},
		Turner = {"%route% Turnpike.svg", "I-44 (OK).svg"},
		["Will Rogers"] = {"%route% Turnpike.svg", "I-44 (OK).svg"},
		default = "%route% Turnpike.svg"
	},
	name = "%route% Turnpike",
	link = "%route% Turnpike",
	abbr = "%route% Turnpike",
	maint = "[[Oklahoma Turnpike Authority]]"
}

OK.AR = {alias = {module = "USA/AR", type = "Hwy"}}
OK.TX = {alias = {module = "USA/TX", type = "TX"}}
OK.NM = {alias = {module = "USA/NM", type = "NM"}}
OK.CO = {alias = {module = "USA/CO", type = "SH"}}
OK.KS = {alias = {module = "USA/KS", type = "K"}}
OK.MO = {alias = {module = "USA/MO", type = "Route"}}

return OK