local T=script.Parent local A=T.Parent local u=require(A.t)local S=u.tuple(u.table,u.optional(u.intersection(u.integer,u.numberMin(0))))local function b(T,A)assert(S(T,A))local u={}for T,S in pairs(T)do if type(S)=="\116\097\098\108\101"and(not A or A>0)then local T=b(S,A and A-1)for A,u in pairs(u)do T[A]=u end u=T else u[T]=S end end return u end return b
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