const fileName_1 = "(@effect/core) _src/stream/Channel/operations/toQueue.ts";
import * as tsplus_module_1 from "@effect/core/stream/Channel/operations/suspend";
import * as tsplus_module_2 from "@tsplus/stdlib/data/Either/definition";
import * as tsplus_module_3 from "@effect/core/stream/Channel/operations/fromEffect";
import * as tsplus_module_4 from "@effect/core/stream/Channel/operations/zipRight";
import * as tsplus_module_5 from "@effect/core/io/Exit/operations/failCause";
import * as tsplus_module_6 from "@effect/core/io/Exit/operations/succeed";
import * as tsplus_module_7 from "@effect/core/stream/Channel/operations/readWithCause";
/**
 * @tsplus static ets/Channel/Ops toQueue
 */

export function toQueue(queue) {
  return tsplus_module_1.suspend(() => toQueueInternal(queue()));
}

function toQueueInternal(queue) {
  return tsplus_module_7.readWithCause(elem => tsplus_module_4.zipRight_(tsplus_module_3.fromEffect(() => queue.offer(tsplus_module_2.right(elem), fileName_1 + ":14:45")), () => toQueueInternal(queue)), cause => tsplus_module_3.fromEffect(() => queue.offer(tsplus_module_2.left(tsplus_module_5.failCause(cause)), fileName_1 + ":15:46")), done => tsplus_module_3.fromEffect(() => queue.offer(tsplus_module_2.left(tsplus_module_6.succeed(done)), fileName_1 + ":16:45")));
}
//# sourceMappingURL=toQueue.mjs.map