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/head";
import * as tsplus_module_4 from "@effect/core/stm/STM/operations/effect";
import { STMInterruptException } from "@effect/core/stm/STM";
import { concreteTQueue } from "@effect/core/stm/TQueue/operations/_internal/InternalTQueue";
/**
 * Views the next element in the queue without removing it, returning `None`
 * if the queue is empty.
 *
 * @tsplus getter ets/TQueue peekMaybe
 */

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

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

    return tsplus_module_3.head(queue);
  });
}
//# sourceMappingURL=peekMaybe.mjs.map