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

-- California
local CA = {}

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

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

CA.I.shield = CA["I 1961"].shield
CA.I.link = {
	["8"] = "Interstate 8",
	["505"] = "Interstate 505",
	["605"] = "Interstate 605",
	["805"] = "Interstate 805",
	["905"] = "Interstate 905",
	["710"] = "Interstate 710",
	["238"] = "Interstate 238",
	["780"] = "Interstate 780",
	["980"] = "Interstate 980",
	default = {
		hook = "split",
		split = 100,
		above = "Interstate %route% (California)",
		below = "Interstate %route% in California"
	}
}
CA.I.law = "[[wikisource:California Streets and Highways Code/Section 301-635#Route %route%|SHC § %section%]]"

for k, v in pairs(CA) do if k:find ("^I%-") then
	v.shield = CA.I.shield
	v.shieldmain = CA.I.shieldmain
	end
end

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

CA.BL.shield = "Business Loop %route% (CA).svg"
CA.BL.shieldmain = CA.BL.shield
CA.BL.link = CA.I.base .. " Business" .. suffix

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

-- The 405 Express Lanes do not use the I abbreviation, but others do 
CA["I-Express"] = {
	shield = CA.I.shield,
	name = {
		["405"] = "405 Express Lanes",
		default = "I-%route% Express Lanes"
	},
	link = {
		-- ["10"] = "El Monte Busway", - disabled after the 2024 opening of the I-10 San Bernardino Express Lanes  
		["110"] = "Harbor Transitway",
		default = CA.I.link
	},
	abbr = {
		["405"] = "405 Express Lanes",
		default = "I-%route% Express Lanes"
	},
	bannersuffix = "blue 1961",
	banner = "Express plate.svg" --  Caltrans does not use the yellow express plates, opting instead for white signage
}

-- I-5/SR 14/Newhall Pass and I-5/I-405/Mission Hills use "Truck Route"
-- I-5/SR 99/Wheeler Ridge, I-15/I-215/Devore, and I-580/I-205 instead use "Truck Bypass"
CA["I-Truck"].link = "Interstate %route% Truck ([dab||%dab%, |]California)"
CA["I-Truck"].banner = "Truck plate.svg" --  Caltrans does not use the blue truck plates, opting instead for white signage

CA.US.link = {
	["199"] = "U.S. Route 199",
	["299"] = "U.S. Route 299",
	["399"] = "U.S. Route 399",
	["466"] = "U.S. Route 466",
	default ="U.S. Route %route% in California"
}
CA.US.law = CA.I.law
CA.US.bannersuffix = "1961"
CA.US.color = {
	["66"] = "hist",
	["80"] = "hist",
	default = 'USA'
}

CA["US-Express"] = {
	shield = CA.US.shield,
	name = "US&nbsp;%route% Express Lanes",
	link = CA.US.link,
	abbr = "US&nbsp;%route% Express Lanes",
	bannersuffix = "1961",
	banner = "Express plate.svg", --  Caltrans does not use the yellow express plates, opting instead for white signage
	width = "expand"
}

CA["US 1926-Alt"] = {
	shield = CA["US 1926"].shield,
	shieldmain = CA["US 1926"].shieldmain,
	name = CA["US-Alt"].name,
	link = CA["US-Alt"].link,
	abbr = CA["US-Alt"].abbr,
	banner = "Alternate plate 1927.svg",
}
CA["US-Alt 1926"] = CA["US 1926-Alt"]
	     
CA["US 1948-Alt"] = {
	shield = CA["US 1948"].shield,
	shieldmain = CA["US 1948"].shieldmain,
	name = CA["US-Alt"].name,
	link = CA["US-Alt"].link,
	abbr = CA["US-Alt"].abbr,
	banner = "Alternate plate 1948.svg",
	width = "expand"
}

CA["US 1948-Bus"] = {
	shield = CA["US 1948"].shield,
	shieldmain = CA["US 1948"].shieldmain,
	name = CA["US-Bus"].name,
	link = CA["US-Bus"].link,
	abbr = CA["US-Bus"].abbr,
	banner = "Business plate 1948.svg"
}

for _,auxType in ipairs({"Alt", "Bus", "Byp", "Conn", "Detour", "Future", "Old", "Opt", "Scenic", "Spur", "Temp", "Toll", "Truck"}) do
	local spec = CA[" aux "][auxType]
	CA["US-" .. auxType] = {
		shield = CA.US.shield,
		name = CA.US.name .. " " .. spec.name,
		link = CA.US.base .. " " .. spec.name .. suffix,
		abbr = CA.US.abbr .. " " .. spec.abbrsuffix,
		banner = spec.bannerprefix .. " plate 1961.svg",
		bannersuffix = "1961",
		aux = spec.aux,
		width = "expand"
	}
end

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

CA["US-Hist"].link = "Historic " .. CA.US.base .. " (California)"

CA.SR = {
	base = "California State Route %route%",
	shield = "California %route%.svg",
	shieldmain = {
		["162"] = {"California %route%.svg", "Forest Route 7.svg"},
		["185"] = {"California %route%.svg", "California 77.svg"},
		default = "California %route%.svg"
	},
	name = {
		["162"] = "State Route %route% and<br>Forest Highway 7",
		["185"] = "State Route %route% and<br>State Route 77",
		default = "State Route %route%"
	},
	link = "California State Route %route% [dab||(%dab%)|]",
	abbr = "SR&nbsp;%route%",
	bannersuffix = "California",
	law = CA.I.law
}
CA.CA = CA.SR

for _,type in ipairs({'SR', 'CA'}) do
	for _,year in ipairs({"1934 S", "1948", "1957"}) do
		CA[type .. " " .. year] = {
			shield = format("California %%route%% %s.svg", year),
			name = CA.SR.name.default,
			link = CA.SR.link,
			abbr = CA.SR.abbr,
			bannersuffix = "California"
		}
	end
end

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

CA["SR-Toll"].link = {
	["125"] = "South Bay Expressway",
	default = CA.SR.link
}
CA["CA-Toll"].link = CA["SR-Toll"].link


-- The 91 Express Lanes do not use the SR abbreviation, but those in the Bay Area do 
CA["SR-Express"] = {
	shield = CA.SR.shield,
	name = {
		["91"] = "91 Express Lanes",
		default = "SR&nbsp;%route% Express Lanes"
	},
	link = {
		["91"] = "91 Express Lanes",
		default = CA.SR.link
	},
	abbr = {
		["91"] = "91 Express Lanes",
		default = "SR&nbsp;%route% Express Lanes"
	},
	bannersuffix = "California",
	banner = "Express plate.svg" --  Caltrans does not use the yellow express plates, opting instead for white signage
}
CA["CA-Express"] = CA["SR-Express"]

CA["SR-Hist"] = {	shield = CA.SR.shield,
	name = "Historic State Route %route%",
	link = "Historic " .. CA.SR.base,
	abbr = "Historic SR&nbsp;%route%",
	bannersuffix = "California",
	banner = "Historic plate California.svg"
	}
CA["CA-Hist"] = CA["SR-Hist"]

CA.FH.shieldmain = {
	["59"] = {"Los Angeles County N3.svg", CA.FH.shield},
	default = CA.FH.shield
}

CA.ISR = {
	shield = {CA.I.shield, CA.SR.shield},
	shieldmain = {CA.I.shieldmain, CA.SR.shield},
	name = CA.I.name .. " and " .. CA.SR.name.default,
	link = CA.I.link,
	abbr = "Route %route%",
	bannersuffix = {"blue 1961", "California"},
	law = CA.I.law
}

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

CA["CA 1934 S"].maint = "[[California Department of Public Works]]"
CA["CA 1948"].maint = CA["CA 1934 S"].maint

CA.CR.link = "County Route %route% (California)"
CA.CR.maint = ""

CA["I-OR"] = {alias = {module = "USA/OR", type = "I"}}
CA["US-NV"] = {alias = {module = "USA/NV", type = "US"}}
CA.AZ = {alias = {module = "USA/AZ", type = "SR"}}
CA.NV = {alias = {module = "USA/NV", type = "SR"}}
CA.OR = {alias = {module = "USA/OR", type = "OR"}}
CA.MEX = {alias = {module = "MEX", type = "FH"}}
CA["US-NV"].bannersuffix = "1961"

return CA