import * as tsplus_module_1 from "@effect/core/stm/TRef/operations/unsafeGet";
import * as tsplus_module_2 from "@tsplus/stdlib/structure/Equals";
import * as tsplus_module_3 from "@tsplus/stdlib/collections/ImmutableQueue/empty";
import * as tsplus_module_4 from "@effect/core/stm/TRef/operations/unsafeSet";
import * as tsplus_module_5 from "@tsplus/stdlib/collections/Chunk/definition";
import * as tsplus_module_6 from "@effect/core/stm/STM/operations/effect";
import { STMInterruptException } from "@effect/core/stm/STM";
import { concreteTQueue } from "@effect/core/stm/TQueue/operations/_internal/InternalTQueue";
/**
 * takeAlls all the values from the queue.
 *
 * @tsplus getter ets/TQueue takeAll
 */

export function takeAll(self) {
  void 0;
  return tsplus_module_6.effect((journal, fiberId) => {
    const queue = tsplus_module_1.unsafeGet_(self.ref, journal);

    if (tsplus_module_2.equals(queue, null)) {
      throw new STMInterruptException(fiberId);
    }

    tsplus_module_4.unsafeSet_(self.ref, tsplus_module_3.empty(), journal);
    return tsplus_module_5.from(queue);
  });
}
//# sourceMappingURL=takeAll.mjs.map