-- Return empty string if keys is empty.

function printProps(
	keys: Array<string>,
	props: Record<string, unknown>,
	config: Config,
	indentation: string,
	depth: number,
	refs: Refs,
	printer: Printer
): string
	local indentationNext = indentation .. config.indent

	-- ROBLOX deviation: adding default value as we don't support colors
	local colors = config.colors or DEFAULT_COLORS
	return Array.join(
		Array.map(keys, function(key: string)
			local value = props[key]
			local printed = printer(value, config, indentationNext, depth, refs)

			if typeof(value) ~= "string" then
				if string.find(printed, "\n") ~= nil then
					printed = config.spacingOuter .. indentationNext .. printed .. config.spacingOuter .. indentation
				end
				printed = "{" .. printed .. "}"
			end

			-- ROBLOX deviation: keys can be of type table. eg. when using ReactRoblox.Change
			local key_ = if typeof(key) == "table"
				then (if key.name then key.name else printer(key, config, indentationNext, depth, refs))
				else key

			return config.spacingInner
				.. indentation
				.. colors.prop.open
				.. colors.prop.open
				.. key_
				.. colors.prop.close
				.. "="
				.. colors.value.open
				.. printed
				.. colors.value.close
				.. colors.value.close
		end),
		""
	)
end
exports.printProps = printProps
