local function w(w)for G,y in pairs(bodyPartAssetTypeIds)do if not w[y]then return false end end return true end return function(G)return function(y)local g=G.isEditable or w(G.assets)y:dispatch(EquipOutfit(G.assets,g))if true then local w=(y:getState()).AvatarExperience.AvatarScene.TryOn.SelectedItem.itemId if w then y:dispatch(ClearSelectedItem())y:dispatch(CloseAllItemDetails((y:getState()).Navigation.history))end end if g then if not FFlagAvatarEditorKeepYourColor or FFlagAvatarEditorKeepYourColor and not AvatarEditorUtils.isPresetCostume(G)then y:dispatch(SetBodyColors(G.bodyColors))end y:dispatch(SetAvatarScales(G.scales))y:dispatch(SetAvatarType(G.avatarType))end end end
-- A fully qualified outfit is one that has both arms, both legs, and a torso.
local function isFullyQualifiedOutfit(assets)
	for _, assetTypeId in pairs(bodyPartAssetTypeIds) do
		if not assets[assetTypeId] then
			return false
		end
	end

	return true
end

return function(outfit)
	return function(store)
		local fullReset = outfit.isEditable or isFullyQualifiedOutfit(outfit.assets)

		-- Do a full reset on a user costume, or a preset fully qualified one. Otherwise swap the existing parts.
		store:dispatch(EquipOutfit(outfit.assets, fullReset))

		if true then
			local selectedItem = store:getState().AvatarExperience.AvatarScene.TryOn.SelectedItem.itemId
			if selectedItem then
				store:dispatch(ClearSelectedItem())
				store:dispatch(CloseAllItemDetails(store:getState().Navigation.history))
			end
		end

		if fullReset then
			-- Preset costumes should not replace body colors.
			if
				not FFlagAvatarEditorKeepYourColor
				or (FFlagAvatarEditorKeepYourColor and not AvatarEditorUtils.isPresetCostume(outfit))
			then
				store:dispatch(SetBodyColors(outfit.bodyColors))
			end
			store:dispatch(SetAvatarScales(outfit.scales))
			store:dispatch(SetAvatarType(outfit.avatarType))
		end
	end
end
