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

-- North Carolina
local NC = require("Module:Road data/strings/USA")

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

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

NC.I.link = {
	["87"] =  "Interstate 87 (North Carolina)",
	["485"] = "Interstate 485",
	["540"] = "Interstate 540 (North Carolina)",
	["785"] = "Interstate 785",
	default = {
		hook = "splitlen",
		split = 3,
		above = "Interstate %route% (North Carolina)",
		below = "Interstate %route% in North Carolina"
	}
}

for k, v in pairs(NC) do if k:find ("^I") then 
	v.link = NC.I.link
	end
end
NC["Future"].shield = "I-%route%.svg"
NC["I-Future"].shield = NC["Future"].shield
NC["Future"].shieldmain = NC["Future"].shield
NC["I-Future"].shieldmain = NC["Future"].shield
NC["I-Future"].banner = "Future plate blue.svg"

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

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

NC.US.name = "U.S. Highway %route%"
NC.US.link = {
	["17-1"] = "U.S. Route 17-1" .. suffix,
	["74"] = "U.S. Route 74" .. suffix,
	["117"] = "U.S. Route 117" .. suffix,
	["158"] = "U.S. Route 158" .. suffix,
	["178"] = "U.S. Route 178" .. suffix,
	["258"] = "U.S. Route 258" .. suffix,
	["264"] = "U.S. Route 264" .. suffix,
	["276"] = "U.S. Route 276" .. suffix,
	["311"] = "U.S. Route 311" .. suffix,
	["321"] = "U.S. Route 321" .. suffix,
	["401"] = "U.S. Route 401" .. suffix,
	["521"] = "U.S. Route 521" .. suffix,
	["601"] = "U.S. Route 601" .. suffix,
	default = "U.S. Route %route% [dab||(%dab%, North Carolina)|in North Carolina]"
}

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

NC["US 1950"] = {
	shield = "US %route% North Carolina 1950.svg",
	name = NC.US.name,
	link = NC.US.link,
	abbr = NC.US.abbr,
	width = "square",
}

for _,auxType in ipairs({"Alt", "Bus", "Byp", "City", "Conn", "Emerg", "Opt", "Scenic", "Spur", "Temp", "Toll", "Truck"}) do
	local spec = NC[" aux "][auxType]
		for k, v in pairs(NC) do if k:find (auxType) then if k:find ("^US") then
			v.name = NC.US.name .. " " .. spec.name
			v.link = NC.US.base .. " " .. spec.name .. " ([dab||%dab%, |]North Carolina)"
			end
		end
	end
end

NC["US-Toll-Byp"] = {
	shield = NC.US.shield,
	name = NC["US-Byp"].name,
	link = NC["US-Byp"].link,
	abbr = NC["US-Byp"].abbr,
	banner = "By-pass plate white and toll plate yellow.svg",
	width = "expand",
	aux = NC[" aux "].Byp
}

NC["US-Bus-Truck"] = {
	shield = NC.US.shield,
	name = NC["US-Bus"].name .. " Truck",
	link = NC["US-Bus"].link,
	abbr = NC["US-Bus"].abbr.. " Truck",
	banner = "Truck business plate.svg",
	width = "expand",
	aux = NC[" aux "].Truck
}

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

for _,type in ipairs({'US 1950'}) do
	for _,auxType in ipairs({"Alt", "Bus", "Byp", "Conn", "Opt", "Scenic", "Spur", "Temp", "Toll", "Truck"}) do
		local spec = NC[" aux "][auxType]
		NC[type .. "-" .. auxType] = {
			shield = NC[type].shield,
			shieldmain = NC[type].shieldmain,
			name = NC[type].name .. " " .. spec.name,
			link = NC.US.base .. " " .. spec.name .. suffix,
			abbr = NC[type].abbr .. " " .. spec.abbrsuffix,
			banner = spec.bannerprefix .. " plate 1948.svg",
			aux = spec.aux,
			width = "square",
			nbrowse = NC.US.nbrowse,
			nbrowselinks = NC.US.nbrowselinks
		}
	end
end

NC.NC = {
	base = "North Carolina Highway %route%",
	shield = "NC %route%.svg",
	shieldmain = {
		["106"] = {"Georgia 246.svg", "NC %route%.svg"},
		default = "NC %route%.svg",
	},
	name = {
		default = "North Carolina Highway %route%",
		["106"] = "Georgia State Route 246 and<br>North Carolina Highway %route%"
	},
	link = "North Carolina Highway %route% [dab||(%dab%)|]",
	abbr = "NC&nbsp;%route%",
	width = "square"
}

for _,type in ipairs({"NC"}) do
	for _,year in ipairs({"1945", "1957"}) do
		NC["NC " .. year] = {
			shield = format("NC %%route%% %s.svg", year),
			name = NC.NC.base,
			name = NC.NC.name,
			link = NC.NC.link,
			abbr = NC.NC.abbr,
			width = "square"
		}
	end
end
NC["NC 1921"] = NC["NC 1945"]
NC["NC 1949"] = NC["NC 1957"]

for _,type in ipairs({'NC'}) do
	for _,auxType in ipairs({"Alt", "Bus", "Byp", "Conn", "Opt", "Scenic", "Spur", "Temp", "Toll", "Truck"}) do
		local spec = NC[" aux "][auxType]
		NC["NC-" .. auxType] = {
			shield = NC.NC.shield,
			shieldmain = NC.NC.shieldmain,
			name = "North Carolina Highway %route%" .. " " .. spec.name,
			link = NC.NC.base .. " " .. spec.name .. suffix2,
			abbr = NC.NC.abbr .. " " .. spec.abbrsuffix,
			banner = spec.bannerprefix .. " plate.svg",
			aux = spec.aux,
			width = NC.NC.width
		}
	end
end
NC["NC-Toll"].banner = "Toll plate yellow.svg"

NC.NCBR = {
	shield = "US Bike %route% (M1-8).svg",
	name = {
		["LN"] = "Lake Norman Bicycle Route",
		["PL"] = "Pottery Loop",
		default = "North Carolina Bicycle Route %route%"
	},
	link = "North Carolina Bicycle Route %route%",
	abbr = "NC Bike Route %route%",
	orientation = "upright"
}

NC.SR = {	abbr = "SR&nbsp;%route%"}
NC.Sec = NC.SR

NC.INC = {
	shield = {NC.I.shield, NC.NC.shield},
	shieldmain = {NC.I.shieldmain, NC.NC.shield},
	name = NC.I.name .. " and " .. NC.NC.name.default,
	link = "Interstate %route% (North Carolina)",
	abbr = "I-%route% / NC &route%",
	bannersuffix = {"blue", ""}
}

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

NC.Charlotte = {
	shield = "Charlotte Route %route% shield.svg",
	name = "Charlotte Route %route%",
	link = "Charlotte Route %route%",
	abbr = "Charlotte Route&nbsp;%route%"
}

return NC