import * as tsplus_module_1 from "@effect/core/stream/Channel/operations/unit";
import * as tsplus_module_2 from "@effect/core/stream/Channel/operations/fromEffect";
import * as tsplus_module_3 from "@effect/core/stream/Channel/operations/flatMap";
import * as tsplus_module_4 from "@effect/core/stream/Channel/operations/fail";
import * as tsplus_module_5 from "@effect/core/stream/Channel/operations/readWith";
import { SinkInternal } from "@effect/core/stream/Sink/operations/_internal/SinkInternal";
/**
 * A sink that executes the provided effectful function for every chunk fed to
 * it until `f` evaluates to `false`.
 *
 * @tsplus static ets/Sink/Ops forEachChunkWhile
 */

export function forEachChunkWhile(f, __tsplusTrace) {
  const reader = tsplus_module_5.readWith(input => tsplus_module_3.flatMap_(tsplus_module_2.fromEffect(() => f(input)), cont => cont ? reader : tsplus_module_1.unit), err => tsplus_module_4.fail(() => err), () => tsplus_module_1.unit);
  return new SinkInternal(reader);
}
//# sourceMappingURL=forEachChunkWhile.mjs.map