//#region ../chokidar/dist/esm/utils/reduceObjectFormat.mjs
/**
* Reduce an object to only the shape provided by a format object.
* Values are always taken from the source object; the format is used only for structure.
*
* Examples:
* reduceObjectFormat({ a: 1, b: 2 }, { a: 0 }) => { a: 1 }
* reduceObjectFormat({ a: { x: 1, y: 2 } }, { a: { x: 0 } }) => { a: { x: 1 } }
*/
const reduceObjectFormat = (source, format) => {
	if (Array.isArray(format)) {
		const sourceArray = Array.isArray(source) ? source : [];
		return format.map((formatItem, index) => reduceObjectFormat(sourceArray[index], formatItem));
	}
	if (typeof format === "object" && format !== null) {
		const result = {};
		const sourceObject = typeof source === "object" && source !== null && !Array.isArray(source) ? source : {};
		for (const key of Object.keys(format)) {
			const nextSource = sourceObject[key];
			const nextFormat = format[key];
			result[key] = reduceObjectFormat(nextSource, nextFormat);
		}
		return result;
	}
	return source;
};

//#endregion
export { reduceObjectFormat };
//# sourceMappingURL=reduceObjectFormat.mjs.map