local q=script.Parent local O=q.Parent local S=require(O.t)local Y=S.tuple(S.table,S.optional(S.intersection(S.integer,S.numberMin(0))))local function u(q,O)assert(Y(q,O))local S={}for q,Y in pairs(q)do if type(Y)=="\116\097\098\108\101"and(not O or O>0)then local q=u(Y,O and O-1)for O,S in pairs(S)do q[O]=S end S=q else S[q]=Y end end return S end return u
local Dictionary = script.Parent

local Llama = Dictionary.Parent
local t = require(Llama.t)

local validate = t.tuple(t.table, t.optional(t.intersection(t.integer, t.numberMin(0))))

local function flatten(dictionary, depth)
	assert(validate(dictionary, depth))
	
	local new = {}

	for key, value in pairs(dictionary) do
		if type(value) == "table" and (not depth or depth > 0) then
			local subDictionary = flatten(value, depth and depth - 1)

			for newKey, newValue in pairs(new) do
				subDictionary[newKey] = newValue
			end

			new = subDictionary
		else
			new[key] = value
		end
	end

	return new
end

return flatten