import * as tsplus_module_1 from "@effect/core/io/FiberRef/operations/set";
import * as tsplus_module_2 from "@effect/core/io/Effect/operations/as";
import * as tsplus_module_3 from "@effect/core/io/FiberRef/operations/get";
import * as tsplus_module_4 from "@effect/core/io/Effect/operations/flatMap";
import * as tsplus_module_5 from "@effect/core/io/Effect/operations/acquireRelease";
import * as tsplus_module_6 from "@effect/core/io/Effect/operations/unit";
/**
 * Returns a managed effect that sets the value associated with the curent
 * fiber to the specified value as its `acquire` action and restores it to its
 * original value as its `release` action.
 *
 * @tsplus fluent ets/FiberRef locallyScoped
 */

export function locallyScoped_(self, value, __tsplusTrace) {
  return tsplus_module_6.unit_(tsplus_module_5.acquireRelease(() => tsplus_module_4.flatMap_(tsplus_module_3.get(self, __tsplusTrace), old => tsplus_module_2.as_(tsplus_module_1.set_(self, value, __tsplusTrace), () => old, __tsplusTrace), __tsplusTrace), a => tsplus_module_1.set_(self, a, __tsplusTrace), __tsplusTrace), __tsplusTrace);
}
/**
 * Returns a managed effect that sets the value associated with the curent
 * fiber to the specified value as its `acquire` action and restores it to its
 * original value as its `release` action.
 *
 * @tsplus static ets/FiberRef/Aspects locallyScoped
 */

export const locallyScoped = (value, __tsplusTrace) => self => locallyScoped_(self, value, __tsplusTrace);
//# sourceMappingURL=locallyScoped.mjs.map