import * as tsplus_module_1 from "@tsplus/stdlib/collections/SortedMap/entries";
import * as tsplus_module_2 from "@tsplus/stdlib/collections/ImmutableArray/from";
import * as tsplus_module_3 from "@tsplus/stdlib/data/Tuple/make";
import * as tsplus_module_4 from "@effect/core/stm/TRef/operations/modify";
import { concreteTPriorityQueue } from "@effect/core/stm/TPriorityQueue/operations/_internal/InternalTPriorityQueue";
/**
 * Collects all values into an array.
 *
 * @tsplus getter ets/TPriorityQueue toImmutableArray
 */

export function toArray(self) {
  void 0;
  return tsplus_module_4.modify_(self.map, map => {
    const entries = tsplus_module_1.entries(map);
    const result = [];
    let e;

    while (!(e = entries.next()).done) {
      const {
        tuple: [, as]
      } = e.value;
      result.push(...Array.from(as));
    }

    return tsplus_module_3.make(tsplus_module_2.from(result), map);
  });
}
//# sourceMappingURL=toImmutableArray.mjs.map