setup.entryMatchesFilter ??= function(entry,filter){
	for(const [filterId, filterValue] of Object.entries(filter)){
		if(filterValue === undefined || filterValue === null)
			continue;
		if(Array.isArray(filterValue)){
			if(filterValue.includes(entry[filterId] || 0))
				continue;
			return false;
		}
		if(typeof filterValue == "object"){
			if("min" in filterValue && (entry[filterId] || 0) < filterValue.min)
				return false;
			if("max" in filterValue && (entry[filterId] || 0) > filterValue.max)
				return false;
		}
		if(filterValue != entry[filterId])
			return false;
	}
	return true;
}

setup.filterArray ??= function(arr,filter){
	return arr.filter(entry=>setup.entryMatchesFilter(entry,filter));
}

setup.filterDict ??= function(dict,filter){
	let result = {};
	for(const [itemId, itemData] of Object.entries(dict)){
		if(setup.entryMatchesFilter(itemData,filter))
			result[itemId] = itemData;
	}
	return result;
}