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/zipRight";
import * as tsplus_module_4 from "@effect/core/stream/Channel/operations/fail";
import * as tsplus_module_5 from "@effect/core/stream/Channel/operations/succeedNow";
import * as tsplus_module_6 from "@effect/core/stream/Channel/operations/readWith";
/**
 * @tsplus fluent ets/Channel contramapIn
 */

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

export const contramapIn = f => self => contramapIn_(self, f);

function contramapInReader(f) {
  return tsplus_module_6.readWith(inElem => tsplus_module_3.zipRight_(tsplus_module_2.write(() => f(inElem)), () => contramapInReader(f)), inErr => tsplus_module_4.fail(() => inErr), inDone => tsplus_module_5.succeedNow(inDone));
}
//# sourceMappingURL=contramapIn.mjs.map