import * as tsplus_module_1 from "@effect/core/stream/Channel/operations/pipeTo";
import * as tsplus_module_2 from "@effect/core/stream/Channel/operations/write";
import * as tsplus_module_3 from "@effect/core/stream/Channel/operations/fromEffect";
import * as tsplus_module_4 from "@effect/core/stream/Channel/operations/flatMap";
import * as tsplus_module_5 from "@effect/core/stream/Channel/operations/zipRight";
import * as tsplus_module_6 from "@effect/core/stream/Channel/operations/fail";
import * as tsplus_module_7 from "@effect/core/stream/Channel/operations/succeedNow";
import * as tsplus_module_8 from "@effect/core/stream/Channel/operations/readWith";
/**
 * @tsplus fluent ets/Channel contramapInEffect
 */

export function contramapInEffect_(self, f) {
  return tsplus_module_1.pipeTo_(contramapInEffectReader(f), () => self);
}
/**
 * @tsplus static ets/Channel/Aspects contramapInEffect
 */

export const contramapInEffect = f => self => contramapInEffect_(self, f);

function contramapInEffectReader(f) {
  return tsplus_module_8.readWith(inElem => tsplus_module_5.zipRight_(tsplus_module_4.flatMap_(tsplus_module_3.fromEffect(() => f(inElem)), elem => tsplus_module_2.write(() => elem)), () => contramapInEffectReader(f)), inErr => tsplus_module_6.fail(() => inErr), inDone => tsplus_module_7.succeedNow(inDone));
}
//# sourceMappingURL=contramapInEffect.mjs.map