import * as tsplus_module_1 from "@tsplus/stdlib/data/Tuple/make";
import * as tsplus_module_2 from "@effect/core/io/Effect/operations/map";
import * as tsplus_module_3 from "@effect/core/stream/Stream/operations/mapAccumEffect";
import * as tsplus_module_4 from "@tsplus/stdlib/collections/Chunk/single";
import * as tsplus_module_5 from "@effect/core/stream/Channel/operations/write";
import * as tsplus_module_6 from "@effect/core/stream/Channel/operations/zipRight";
import * as tsplus_module_7 from "@effect/core/stream/Channel/operations/succeed";
import * as tsplus_module_8 from "@effect/core/stream/Channel/operations/flatMap";
import { concreteStream, StreamInternal } from "@effect/core/stream/Stream/operations/_internal/StreamInternal";
/**
 * Statefully and effectfully maps over the elements of this stream to produce
 * all intermediate results of type `S` given an initial S.
 *
 * @tsplus fluent ets/Stream scanEffect
 */

export function scanEffect_(self, s, f, __tsplusTrace) {
  return new StreamInternal(tsplus_module_8.flatMap_(tsplus_module_7.succeed(s), s => tsplus_module_6.zipRight_(tsplus_module_5.write(() => tsplus_module_4.single(s)), () => {
    const stream = tsplus_module_3.mapAccumEffect_(self, () => s, (s, a) => tsplus_module_2.map_(f(s, a), s => tsplus_module_1.make(s, s), __tsplusTrace), __tsplusTrace);
    void 0;
    return stream.channel;
  })));
}
/**
 * Statefully and effectfully maps over the elements of this stream to produce
 * all intermediate results of type `S` given an initial S.
 *
 * @tsplus static ets/Stream/Aspects scanEffect
 */

export const scanEffect = (s, f, __tsplusTrace) => self => scanEffect_(self, s, f, __tsplusTrace);
//# sourceMappingURL=scanEffect.mjs.map