//#region src/session/patch-metadata.ts
function applySessionPatchToMetadata(existing, patch) {
	const out = {};
	if (typeof patch.name === "string") {
		const t = patch.name.trim();
		if (t.length > 0) out.name = t;
		else out.name = void 0;
	}
	if (patch.tags !== void 0 && Array.isArray(patch.tags)) {
		const normalized = [...new Set(patch.tags.map((t) => String(t).trim()).filter(Boolean))];
		if (patch.replaceTags) out.tags = normalized;
		else out.tags = [...new Set([...existing.tags, ...normalized])];
	}
	if (patch.customData !== void 0 && typeof patch.customData === "object" && patch.customData !== null) out.customData = {
		...existing.customData ?? {},
		...patch.customData
	};
	return out;
}
//#endregion
export { applySessionPatchToMetadata };

//# sourceMappingURL=patch-metadata.js.map