// ets_tracing: off
import * as CK from "../../../../Collections/Immutable/Chunk";
import * as T from "../../../../Effect";
import * as O from "../../../../Option";
import * as CH from "../../Channel";
import * as C from "../core";
/**
 * Finds the first element emitted by this stream that satisfies the provided effectful predicate.
 */

export function findEffect_(self, f) {
  const loop = CH.readWith(in_ => CH.unwrap(T.map_(CK.findM_(in_, f), O.fold(() => loop, i => CH.write(CK.single(i))))), e => CH.fail(e), _ => CH.unit);
  return new C.Stream(self.channel[">>>"](loop));
}
/**
 * Finds the first element emitted by this stream that satisfies the provided effectful predicate.
 * @ets_data_first findEffect_
 */

export function findEffect(f) {
  return self => findEffect_(self, f);
}
//# sourceMappingURL=findEffect.js.map