local J=function(J)local H=require(rep.Modules.Pet.RealPetName)return H.GetRealPetName(J)end local H=function(H,u,G,y)if G=="\080\101\116"then local G=J(tostring(u))if y~=nil then if y.Parent then if y.Parent:FindFirstChild(G)then return true end end else if H.Index:FindFirstChild(G)then return true end end end return false end module.AddPetToIndex=function(u,G,y,V)if u and G~=nil then local f=H(u,G,y,V)if f==false then local H=J(tostring(G))local y=Instance.new("\083\116\114\105\110\103\086\097\108\117\101")y.Name=tostring(H)y.Value=tostring(H)if V~=nil then if V.Parent then y.Parent=V.Parent else y.Parent=u.Index end else y.Parent=u.Index end return true end end end module.LoadIndex=function(J,H,u)for H,G in pairs(H)do for H,G in pairs(G)do module.AddPetToIndex(J,G,"\080\101\116",{Parent=u})end end end return module

local getPetName = function(name)
	local realPetNameMod = require(rep.Modules.Pet.RealPetName)
	return realPetNameMod.GetRealPetName(name)
end

local checkIfInIndex = function(plr, beginPetName, which, params)
	if which == "Pet" then
		local petName = getPetName(tostring(beginPetName))
		if params ~= nil then
			if params.Parent then
				if params.Parent:FindFirstChild(petName) then
					return true
				end
			end
		else
			if plr.Index:FindFirstChild(petName) then
				return true
			end
		end
	end
	return false
end

module.AddPetToIndex = function(plr, beginPetName, which, params)
	if plr and beginPetName ~= nil then
		local isInIndex = checkIfInIndex(plr, beginPetName, which, params)
		if isInIndex == false then
			local petName = getPetName(tostring(beginPetName))
			local petIndex = Instance.new("StringValue")
			petIndex.Name = tostring(petName)
			petIndex.Value = tostring(petName)
			if params ~= nil then
				if params.Parent then
					petIndex.Parent = params.Parent
				else
					petIndex.Parent = plr.Index
				end
			else
				petIndex.Parent = plr.Index
			end
			return true
		end
	end
end

module.LoadIndex = function(plr, tbl, parent)
	for _, v in pairs(tbl) do
		for _, petName in pairs(v) do
			module.AddPetToIndex(plr, petName, "Pet", {Parent = parent})
		end
	end
end

return module
