import { isFunction } from "../util/isFunction.mjs";
import { operate } from "../util/lift.mjs";
import { innerFrom } from "../observable/innerFrom.mjs";
import { map } from "./map.mjs";
import { mergeInternals } from "./mergeInternals.mjs";

//#region ../../node_modules/.pnpm/rxjs@7.8.2/node_modules/rxjs/dist/esm5/internal/operators/mergeMap.js
function mergeMap(project, resultSelector, concurrent) {
	if (concurrent === void 0) concurrent = Infinity;
	if (isFunction(resultSelector)) return mergeMap(function(a, i) {
		return map(function(b, ii) {
			return resultSelector(a, b, i, ii);
		})(innerFrom(project(a, i)));
	}, concurrent);
	else if (typeof resultSelector === "number") concurrent = resultSelector;
	return operate(function(source, subscriber) {
		return mergeInternals(source, subscriber, project, concurrent);
	});
}

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