import { identity } from "../util/identity.mjs";
import { EmptyError } from "../util/EmptyError.mjs";
import { filter } from "./filter.mjs";
import { defaultIfEmpty } from "./defaultIfEmpty.mjs";
import { take } from "./take.mjs";
import { throwIfEmpty } from "./throwIfEmpty.mjs";

//#region ../../node_modules/.pnpm/rxjs@7.8.2/node_modules/rxjs/dist/esm5/internal/operators/first.js
function first(predicate, defaultValue) {
	var hasDefaultValue = arguments.length >= 2;
	return function(source) {
		return source.pipe(predicate ? filter(function(v, i) {
			return predicate(v, i, source);
		}) : identity, take(1), hasDefaultValue ? defaultIfEmpty(defaultValue) : throwIfEmpty(function() {
			return new EmptyError();
		}));
	};
}

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