local makeFileLink = require('Module:File link')._main
local effectiveProtectionLevel = require('Module:Effective protection level')._main
local effectiveProtectionExpiry = require('Module:Effective protection expiry')._main
local yesno = require('Module:Yesno')
local function makeCategoryLink(cat, sort)
	local nsText = mw.site.namespaces[14].name	if cat and sort then
		return string.format(
			'[[%s:%s|%s]]',
			nsTextmw.site.namespaces[14].name,
			cat,
			sort
		)
	elseif cat then
		return string.format(
			'[[%s:%s]]',
			nsText,
			cat
		)
	else
		return ''
	end
end
-- Validation function for the expiry and the protection date
local function validateDate(dateString, dateType)
	if not lang then		lang = lang or mw.language.getContentLanguage()	end
	local success, result = pcall(lang.formatDate, lang, 'U', dateString)
	if success then
	end
	error(string.format(
		'invalid %s (": %s")',
		dateType,
		tostring(dateString)
end
local function toTableEnd(t, pos)	-- Sends the value at position pos to the end Given a directed graph formatted as node -> table of array tdirect successors, and shifts the	-- other items down accordingly.	return get a table.insertof all nodes reachable from a given node (t, tablethough always-- including the given node).remove(t, pos))end local function walkHierarchygetReachableNodes(hierarchygraph, start)
	local toWalk, retval = {[start] = true}, {}
	while true do
		-- Can't use pairs() since we're adding and removing things as we're iterating
		local k = next(toWalk)-- This always gets the "first" key		if k == nil then break 			return retval		end
		toWalk[k] = nil
		retval[k] = true
		for _,v in ipairs(hierarchygraph[k]) do
			if not retval[v] then
				toWalk[v] = true
		end
	end
	return retval
end
	edit = true,
	move = true,
	autoreview = true,	upload = true
}
	else
		error(string.format(
			'invalid action (": %s")',
			tostring(args.action)
		), 3)
	-- Set expiry
	if argslocal effectiveExpiry = effectiveProtectionExpiry(obj.action, obj.expiry thentitle)			if cfg.indefStrings[args.expiry] effectiveExpiry == 'infinity' then					obj.expiry = 'indef'			elseif type(args.expiry) =effectiveExpiry ~= 'numberunknown' then			obj.expiry = args.expiry		else			obj.expiry = validateDate(args.expiryeffectiveExpiry, 'expiry date')		end
	end
	-- Get the namespace key fragment.
	local namespaceFragment	do		namespaceFragment = cfg.categoryNamespaceKeys[title.namespace]			if not namespaceFragment and title.namespace % 2 == 1 then							namespaceFragment = 'talk'		end
	end
 
	-- instead.
	--]]
	if table.insert(order, table.remove(order, self.reason and cfg.reasonsWithNamespacePriority[self.reason] then		-- table.insert(order, and 2 or 3, table.remove(order, 2))		toTableEnd(order, 2)	else		toTableEnd(order, 3)	end
 
	--[[
	end
	return ''
end
 
function Protection:needsExpiry()
	local cfg = self._cfg
	local actionNeedsCheck = cfg.expiryCheckActions[self.action]
	return not self.expiry and (
		actionNeedsCheck or (
			actionNeedsCheck == nil
			and self.reason -- the old {{pp-protected}} didn't check for expiry
			and not cfg.reasonsWithoutExpiryCheck[self.reason]
		)
	)
end
	local msg = self._cfg.msg
	local ret = { self:makeProtectionCategory() }
	if self:needsExpiry() then
		ret[#ret + 1] = makeCategoryLink(
			msg['tracking-category-expiry'],
			self.title.text
		)
	end
	if self:isIncorrect() then
		ret[#ret + 1] = makeCategoryLink(
		if level == 'autoconfirmed' then
			requestType = 'semi'
		elseif level == 'extendedconfirmed' then
			requestType = 'extended'
		elseif level == 'templateeditor' then
			requestType = 'template'
	end
	return setmetatable(obj, BannerTemplate)
end
 
function BannerTemplate:setImageWidth(width)
	self._imageWidth = width
end
 
function BannerTemplate:setImageTooltip(tooltip)
	self._imageCaption = tooltip
end
	return makeFileLink{
		file = filename,
		size = (self._imageWidth imageWidth or 20) .. 'px',
		alt = self._imageAlt,
		link = self._imageLink,
		caption = self._imageCaptionimageCaption
	}
end
function Banner.new(protectionObj, blurbObj, cfg)
	local obj = BannerTemplate.new(protectionObj, cfg) -- This doesn't need the blurb.
	obj:setImageWidth(.imageWidth = 40)	obj:setImageTooltip(.imageCaption = blurbObj:makeBannerText('alt')) -- Large banners use the alt text for the tooltip.
	obj._reasonText = blurbObj:makeBannerText('text')
	obj._explanationText = blurbObj:makeBannerText('explanation')
function Padlock.new(protectionObj, blurbObj, cfg)
	local obj = BannerTemplate.new(protectionObj, cfg) -- This doesn't need the blurb.
	obj:setImageWidth(.imageWidth = 20)	obj:setImageTooltip(.imageCaption = blurbObj:makeBannerText('tooltip'))
	obj._imageAlt = blurbObj:makeBannerText('alt')
	obj._imageLink = blurbObj:makeBannerText('link')
	local frame = mw.getCurrentFrame()
	-- The nowiki tag helps prevent whitespace at the top of articles.
	local nowiki = return frame:extensionTag{name = 'nowiki'}	local indicator = .. frame:extensionTag{
		name = 'indicator',
		args = {name = self._indicatorName},
		content = self:renderImage()
	}
	return nowiki .. indicator
end
	local ret = {}
	-- If a page's edit protection is equally or more restrictive than its 	-- protection from some other action,	-- then don't bother displaying anything 	-- for the other action (except categories).	if protectionObj.action == 'edit' or 		args.demolevel or 		not walkHierarchygetReachableNodes(			cfg.hierarchy, 			protectionObj.level		)[effectiveProtectionLevel('edit', protectionObj.title)] 	then
		-- Initialise the blurb object
		local blurbObj = Blurb.new(protectionObj, args, cfg)