import * as tsplus_module_1 from "@tsplus/stdlib/data/AtomicReference";
import * as tsplus_module_2 from "@effect/core/stm/STM/Entry";
import { STMEffect } from "@effect/core/stm/STM/definition/primitives";
import { emptyTodoMap } from "@effect/core/stm/STM/Journal";
import { Versioned } from "@effect/core/stm/STM/Versioned";
import { TRefInternal } from "@effect/core/stm/TRef/operations/_internal/TRefInternal";
/**
 * Makes a new `TRef` that is initialized to the specified value.
 *
 * @tsplus static ets/TRef/Ops make
 */

export function make(a) {
  return new STMEffect(journal => {
    const value = a();
    const versioned = new Versioned(value);
    const todo = new tsplus_module_1.AtomicReference(emptyTodoMap);
    const tref = new TRefInternal(versioned, todo);
    journal.set(tref, tsplus_module_2.makeEntry(tref, true));
    return tref;
  });
}
//# sourceMappingURL=make.mjs.map