-- ROBLOX deviation END


exports.default = function(snapshots: SnapshotSummary, globalConfig: Config_GlobalConfig, updateCommand: string)
	local summary = {}
	table.insert(summary, SNAPSHOT_SUMMARY("Snapshot Summary"))

	if Boolean.toJSBoolean(snapshots.added) then
		table.insert(
			summary,
			SNAPSHOT_ADDED(ARROW .. pluralize("snapshot", snapshots.added) .. " written ")
				.. "from "
				.. pluralize("test suite", snapshots.filesAdded)
				.. "."
		)
	end

	if Boolean.toJSBoolean(snapshots.unmatched) then
		table.insert(
			summary,
			FAIL_COLOR(ARROW .. pluralize("snapshot", snapshots.unmatched) .. " failed")
				.. " from "
				.. pluralize("test suite", snapshots.filesUnmatched)
				.. ". "
				.. SNAPSHOT_NOTE("Inspect your code changes or " .. updateCommand .. " to update them.")
		)
	end

	if Boolean.toJSBoolean(snapshots.updated) then
		table.insert(
			summary,
			SNAPSHOT_UPDATED(ARROW .. pluralize("snapshot", snapshots.updated) .. " updated ")
				.. "from "
				.. pluralize("test suite", snapshots.filesUpdated)
				.. "."
		)
	end

	if Boolean.toJSBoolean(snapshots.filesRemoved) then
		if snapshots.didUpdate then
			table.insert(
				summary,
				SNAPSHOT_REMOVED(ARROW .. pluralize("snapshot file", snapshots.filesRemoved) .. " removed ")
					.. "from "
					.. pluralize("test suite", snapshots.filesRemoved)
					.. "."
			)
		else
			table.insert(
				summary,
				OBSOLETE_COLOR(ARROW .. pluralize("snapshot file", snapshots.filesRemoved) .. " obsolete ")
					.. "from "
					.. pluralize("test suite", snapshots.filesRemoved)
					.. ". "
					.. SNAPSHOT_NOTE(
						"To remove "
							.. (if snapshots.filesRemoved == 1 then "it" else "them all")
							.. ", "
							.. updateCommand
							.. "."
					)
			)
		end
	end

	if snapshots.filesRemovedList and #snapshots.filesRemovedList > 0 then
		local head = snapshots.filesRemovedList[1]
		local tail = table.pack(table.unpack(snapshots.filesRemovedList, 2))
		table.insert(summary, "  " .. DOWN_ARROW .. " " .. DOT .. formatTestPath(globalConfig, head))
		Array.forEach(tail, function(key)
			table.insert(summary, "    " .. DOT .. formatTestPath(globalConfig, key))
		end)
	end

	if Boolean.toJSBoolean(snapshots.unchecked) then
		if snapshots.didUpdate then
			table.insert(
				summary,
				SNAPSHOT_REMOVED(ARROW .. pluralize("snapshot", snapshots.unchecked) .. " removed ")
					.. "from "
					.. pluralize("test suite", #snapshots.uncheckedKeysByFile)
					.. "."
			)
		else
			table.insert(
				summary,
				OBSOLETE_COLOR(ARROW .. pluralize("snapshot", snapshots.unchecked) .. " obsolete ")
					.. "from "
					.. pluralize("test suite", #snapshots.uncheckedKeysByFile)
					.. ". "
					.. SNAPSHOT_NOTE(
						"To remove "
							.. (if snapshots.unchecked == 1 then "it" else "them all")
							.. ", "
							.. updateCommand
							.. "."
					)
			)
		end
	end

	Array.forEach(snapshots.uncheckedKeysByFile, function(uncheckedFile)
		table.insert(summary, "  " .. DOWN_ARROW .. formatTestPath(globalConfig, uncheckedFile.filePath))

		Array.forEach(uncheckedFile.keys, function(key)
			table.insert(summary, "    " .. DOT .. key)
		end)
	end)

	return summary
end

return exports
