//https://stackoverflow.com/a/34749873
setup.mergeDeep = function (target, ...sources) {

	function isObject(item) {
		return (item && typeof item === 'object' && !Array.isArray(item));
	}

	if (!sources.length) return target;
	const source = sources.shift();

	if (isObject(target) && isObject(source)) {
		for (const key in source) {
			if (isObject(source[key])) {
				if (!target[key]) 
					Object.assign(target, { [key]: {} });
				setup.mergeDeep(target[key], source[key]);
			}
			else if(Array.isArray(source[key])){
				if (!target[key]) 
					Object.assign(target, { [key]: source[key] });
				else if(Array.isArray(target[key]))
					Object.assign(target, { [key]: [...target[key],...source[key]]});
				else
					console.error('Error in setup.mergeDeep: cant maerge array with non-array');
				
			}
			else {
				Object.assign(target, { [key]: source[key] });
			}
		}
	}

	return setup.mergeDeep(target, ...sources);
}