local V={}function module.ApplyBundle(s,c,t)local h=V[t]if not h then local c,s=pcall(function()return main.assetService:GetBundleDetailsAsync(t)end)if c and s then for s,p in next,s.Items do if p.Type=="\085\115\101\114\079\117\116\102\105\116"then c,h=pcall(function()return main.players:GetHumanoidDescriptionFromOutfitId(p.Id)end)V[t]=h break end end end end if not h then return end local p=c:GetAppliedDescription()local U=Instance.new("\072\117\109\097\110\111\105\100\068\101\115\099\114\105\112\116\105\111\110")for V,c in next,{"\066\097\099\107\065\099\099\101\115\115\111\114\121";"\066\111\100\121\084\121\112\101\083\099\097\108\101","\067\108\105\109\098\065\110\105\109\097\116\105\111\110";"\068\101\112\116\104\083\099\097\108\101";"\070\097\099\101";"\070\097\099\101\065\099\099\101\115\115\111\114\121","\070\097\108\108\065\110\105\109\097\116\105\111\110";"\070\114\111\110\116\065\099\099\101\115\115\111\114\121","\071\114\097\112\104\105\099\084\083\104\105\114\116","\072\097\105\114\065\099\099\101\115\115\111\114\121";"\072\097\116\065\099\099\101\115\115\111\114\121";"\072\101\097\100";"\072\101\097\100\067\111\108\111\114";"\072\101\097\100\083\099\097\108\101","\072\101\105\103\104\116\083\099\097\108\101","\073\100\108\101\065\110\105\109\097\116\105\111\110";"\074\117\109\112\065\110\105\109\097\116\105\111\110","\076\101\102\116\065\114\109","\076\101\102\116\065\114\109\067\111\108\111\114","\076\101\102\116\076\101\103","\076\101\102\116\076\101\103\067\111\108\111\114";"\078\101\099\107\065\099\099\101\115\115\111\114\121","\080\097\110\116\115","\080\114\111\112\111\114\116\105\111\110\083\099\097\108\101";"\082\105\103\104\116\065\114\109","\082\105\103\104\116\065\114\109\067\111\108\111\114";"\082\105\103\104\116\076\101\103";"\082\105\103\104\116\076\101\103\067\111\108\111\114","\082\117\110\065\110\105\109\097\116\105\111\110";"\083\104\105\114\116","\083\104\111\117\108\100\101\114\115\065\099\099\101\115\115\111\114\121","\083\119\105\109\065\110\105\109\097\116\105\111\110","\084\111\114\115\111";"\084\111\114\115\111\067\111\108\111\114";"\087\097\105\115\116\065\099\099\101\115\115\111\114\121","\087\097\108\107\065\110\105\109\097\116\105\111\110","\087\105\100\116\104\083\099\097\108\101"}do if h[c]~=U[c]then p[c]=h[c]end end c:ApplyDescription(p)end return module
--[[
for a,b in pairs(game.ServerScriptService.MainModule.Server.Morphs:GetDescendants()) do
	if b:IsA("Decal") and b.Name ~= "face" and b.Parent.Name == "Head" then
		print("CHANGED: ".. b.Name.." | "..b.Parent.Parent.Name)
		b.Name = "face"
	end
end
--]]

local bundleCache = {} -- cache HumanoidDescriptions retrieved from bundles to reduce API calls
function module:ApplyBundle(humanoid, bundleId)
	local HumanoidDescription = bundleCache[bundleId]
	if not HumanoidDescription then
		local success, bundleDetails = pcall(function()
			return main.assetService:GetBundleDetailsAsync(bundleId)
		end)
		if success and bundleDetails then
			for _, item in next, bundleDetails.Items do
				if item.Type == "UserOutfit" then
					success, HumanoidDescription = pcall(function()
						return main.players:GetHumanoidDescriptionFromOutfitId(item.Id)
					end)
					bundleCache[bundleId] = HumanoidDescription
					break
				end
			end
		end
	end
	if not HumanoidDescription then
		return
	end
	local newDescription = humanoid:GetAppliedDescription()
	local defaultDescription = Instance.new("HumanoidDescription")
	for _, property in
		next,
		{
			"BackAccessory",
			"BodyTypeScale",
			"ClimbAnimation",
			"DepthScale",
			"Face",
			"FaceAccessory",
			"FallAnimation",
			"FrontAccessory",
			"GraphicTShirt",
			"HairAccessory",
			"HatAccessory",
			"Head",
			"HeadColor",
			"HeadScale",
			"HeightScale",
			"IdleAnimation",
			"JumpAnimation",
			"LeftArm",
			"LeftArmColor",
			"LeftLeg",
			"LeftLegColor",
			"NeckAccessory",
			"Pants",
			"ProportionScale",
			"RightArm",
			"RightArmColor",
			"RightLeg",
			"RightLegColor",
			"RunAnimation",
			"Shirt",
			"ShouldersAccessory",
			"SwimAnimation",
			"Torso",
			"TorsoColor",
			"WaistAccessory",
			"WalkAnimation",
			"WidthScale",
		}
	do
		if HumanoidDescription[property] ~= defaultDescription[property] then -- property is not the default value
			newDescription[property] = HumanoidDescription[property]
		end
	end
	humanoid:ApplyDescription(newDescription)
end

return module
