import * as tsplus_module_1 from "@tsplus/stdlib/collections/Chunk/unsafeGet";
import * as tsplus_module_2 from "@effect/core/stm/TRef/operations/update";
import * as tsplus_module_3 from "@tsplus/stdlib/exceptions";
import * as tsplus_module_4 from "@effect/core/stm/STM/operations/die";
import { concreteTArray } from "@effect/core/stm/TArray/operations/_internal/InternalTArray";
/**
 * Updates element in the array with given function.
 *
 * @tsplus fluent ets/TArray update
 */

export function update_(self, index, f) {
  void 0;

  if (0 <= index && index < self.chunk.length) {
    return tsplus_module_2.update_(tsplus_module_1.unsafeGet_(self.chunk, index), f);
  } else {
    return tsplus_module_4.die(() => new tsplus_module_3.IndexOutOfBounds(index, 0, self.chunk.length));
  }
}
/**
 * Updates element in the array with given function.
 *
 * @tsplus static ets/TArray/Aspects update
 */

export const update = (index, f) => self => update_(self, index, f);
//# sourceMappingURL=update.mjs.map