-- ROBLOX deviation END


local function extractValidTemplateHeadings(headings: string): string
	-- ROBLOX deviation START: get lines with value, return the first one, check for spaces in headings
	local match = headings:match(HEADINGS_FORMAT)
	local matches, hasEmptySpacesInHeading
	if match then
		matches = Array.filter(String.split(match, "\n"), function(line)
			return String.trim(line) ~= ""
		end)
	end
	if matches and #matches > 0 then
		local headings_ = Array.map(String.split(matches[1], "|"), function(heading)
			return String.trim(heading)
		end)
		hasEmptySpacesInHeading = Array.some(headings_, function(heading)
			return heading:match("%s") ~= nil
		end)
	end

	if match == nil or hasEmptySpacesInHeading then
		error(
			Error.new(
				"Table headings do not conform to expected format:\n\n"
					.. EXPECTED_COLOR("heading1 | headingN")
					.. "\n\n"
					.. "Received:\n\n"
					.. RECEIVED_COLOR(pretty(headings))
			)
		)
	end
	-- ROBLOX deviation END
	return matches[1]
end
exports.extractValidTemplateHeadings = extractValidTemplateHeadings

return exports
