--[==[
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"]`.
]==]

-- South Carolina
local SC = {}

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

local suffix = " ([dab||%dab%, |]South Carolina)"
local suffix2 = " [dab||(%dab%)|]"

SC.I.link = {
	["185"] = "Interstate 185 (South Carolina)",
	["326"] = "Interstate 326 (South Carolina)",
	default = {
		hook = "splitlen",
		split = 3,
		above = "Interstate %route% (South Carolina)",
		below = "Interstate %route% in South Carolina"
	}
}

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

SC.BL.link = "Interstate %route% Business ([dab||%dab%, |]South Carolina)"

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

SC.US.name = "U.S. Highway %route%"
SC.US.link = {
	["217"] = "U.S. Route 217 in South Carolina",
	["221"] = "U.S. Route 221 in South Carolina",
	["278"] = "U.S. Route 278 in South Carolina",
	["301"] = "U.S. Route 301 in South Carolina",
	default = {
		hook = "splitlen",
		split = 3,
		above = "U.S. Route %route%",
		below = "U.S. Route %route% in South Carolina"
	}
}

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

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


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

SC["US-Alt-Truck"] = {
	shield = SC.US.shield,
	name = SC.US.name .. " Alternate Truck",
	link = SC.US.base .. " Alternate Truck" .. suffix,
	abbr = SC["US-Alt"].abbr .. " Truck",
	banner = "Truck alternate plate.svg",
	width = 'expand',
	aux = SC[" aux "].Truck,
	nbrowse = SC.US.nbrowse,
	nbrowselinks = SC.US.nbrowselinks
}

SC.SC = {
	base = "South Carolina Highway %route%",
	shield = "South Carolina %route%.svg",
	shieldmain = "South Carolina %route%.svg",
	name = "South Carolina Highway %route%",
	link = "South Carolina Highway %route%" .. suffix2,
	abbr = "SC&nbsp;%route%",
	width = "wide"
}

for _,type in ipairs({'SC'}) do
	for _,year in ipairs({"1920", "1926", "1955", "1971"}) do
		SC["SC " .. year] = {
			shield = format("SC-%%route%% (%s).svg", year),
			name = SC.SC.name,
			link = SC.SC.link,
			abbr = SC.SC.abbr,
			width = "square",
		}
	end
end
SC["SC 1920"].shield = SC["SC 1926"].shield
SC["SC 1971"].shield = "SC-%route%.svg"
SC["SC 1971"].width = "expand"
SC["SC 1948"] = SC["SC 1971"]

for _,type in ipairs({'SC'}) do
	for _,auxType in ipairs({"Alt", "Bus", "Byp", "Conn", "Opt", "Scenic", "Spur", "Temp", "Truck"}) do
		local spec = SC[" aux "][auxType]
		SC["SC-" .. auxType] = {
			shield = SC.SC.shield,
			name = SC.SC.name .. " " .. spec.name,
			link = SC.SC.base .. " " .. spec.name .. suffix2,
			abbr = SC.SC.abbr .. " " .. spec.abbrsuffix,
			banner = spec.banneralt .. " plate South Carolina.svg",
			aux = spec.aux,
			width = "wide"
		}
	end
end

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

-- add new types above this line if you want it to have the state highway browse and maint
for k, v in pairs(SC) do if k:find ("^%a") then
	v.maint = "[[South Carolina Department of Transportation|SCDOT]]"
	v.browse = "[[South Carolina State Highway System]]"
	v.browselinks = {
		[1] = "[[List of Interstate Highways in South Carolina|Interstate]]",
		[2] = "[[List of U.S. Highways in South Carolina|US]]",
		[3] = "[[List of state highways in South Carolina|State]]",
		[4] = "[[List of South Carolina Scenic Byways|Scenic]]"
	}
	end
end

local secName = {
	hook = "mask",
	mask = "Road data/masks/USA/SC",
	base = "county",
	masked = "number",
	default = "S-%number%-%route%"
}

SC.Sec = {
	shield = "",
	name = secName,
	link = "",
	abbr = secName
	
}

SC.GA = {alias = {module = "USA/GA", type = "GA"}}
SC["GA-Spur"] = {alias = {module = "USA/GA", type = "SR-Spur"}}
SC.NC = {alias = {module = "USA/NC", type = "NC"}}

return SC