"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.ignore = exports.if = exports.head = exports.getFiberRefs = exports.gen = exports.fromFiberEffect = exports.fromFiber = exports.forkWithErrorHandler = exports.forkScoped = exports.forkIn = exports.forkDaemon = exports.forkAll = exports.fork = exports.forever = exports.forEach = exports.flipWith = exports.flip = exports.flatten = exports.flatMapStep = exports.flatMap = exports.firstSuccessOf = exports.findFirst = exports.filterOrFail = exports.filterOrElse = exports.filterOrDieMessage = exports.filterOrDie = exports.filter = exports.fiberIdWith = exports.fiberId = exports.failSync = exports.failCauseSync = exports.failCause = exports.fail = exports.exit = exports.exists = exports.every = exports.eventually = exports.ensuringChildren = exports.ensuringChild = exports.ensuring = exports.either = exports.dropWhile = exports.dropUntil = exports.disconnect = exports.diffFiberRefs = exports.dieSync = exports.dieMessage = exports.die = exports.descriptorWith = exports.descriptor = exports.delay = exports.daemonChildren = exports.currentSpan = exports.contextWithEffect = exports.contextWith = exports.context = exports.configProviderWith = exports.config = exports.clockWith = exports.clock = exports.checkInterruptible = exports.cause = exports.catchTags = exports.catchTag = exports.catchSomeDefect = exports.catchSomeCause = exports.catchSome = exports.catchAllDefect = exports.catchAllCause = exports.catchAll = exports.catch = exports.cachedWithTTL = exports.cachedInvalidateWithTTL = exports.cachedFunction = exports.cached = exports.cacheRequestResult = exports.blocked = exports.bindTo = exports.bind = exports.awaitAllChildren = exports.asyncOption = exports.asyncInterruptEither = exports.asyncInterrupt = exports.asyncEffect = exports.async = exports.asUnit = exports.asSomeError = exports.asSome = exports.as = exports.annotateSpans = exports.annotateLogs = exports.allowInterrupt = exports.allWith = exports.allSuccesses = exports.all = exports.addFinalizer = exports.acquireUseRelease = exports.acquireRelease = exports.EffectTypeId = exports.Do = void 0;
exports.runtime = exports.runSyncExit = exports.runSync = exports.runRequestBlock = exports.runPromiseExit = exports.runPromise = exports.runFork = exports.runCallback = exports.retryWhileEffect = exports.retryWhile = exports.retryUntilEffect = exports.retryUntil = exports.retryOrElse = exports.retryN = exports.retry = exports.request = exports.replicateEffect = exports.replicate = exports.repeatWhileEffect = exports.repeatWhile = exports.repeatUntilEffect = exports.repeatUntil = exports.repeatOrElse = exports.repeatN = exports.repeat = exports.reduceWhile = exports.reduceRight = exports.reduceEffect = exports.reduce = exports.randomWith = exports.random = exports.raceWith = exports.raceFirst = exports.raceFibersWith = exports.raceAwait = exports.raceAll = exports.race = exports.provideSomeLayer = exports.provideSomeContext = exports.provideServiceEffect = exports.provideService = exports.provideLayer = exports.provideContext = exports.promiseInterrupt = exports.promise = exports.patchFiberRefs = exports.partition = exports.parallelFinalizers = exports.parallelErrors = exports.orElseSucceed = exports.orElseFail = exports.orElse = exports.orDieWith = exports.orDie = exports.option = exports.once = exports.onInterrupt = exports.onExit = exports.onError = exports.none = exports.never = exports.negate = exports.metricLabels = exports.mergeAll = exports.merge = exports.matchEffect = exports.matchCauseEffect = exports.matchCause = exports.match = exports.mapInputContext = exports.mapErrorCause = exports.mapError = exports.mapBoth = exports.mapAccum = exports.map = exports.makeSemaphore = exports.loop = exports.logCause = exports.logAnnotations = exports.log = exports.locallyWith = exports.locallyScopedWith = exports.locallyScoped = exports.locally = exports.let = exports.labelMetricsSet = exports.labelMetricsScopedSet = exports.labelMetricsScoped = exports.labelMetrics = exports.iterate = exports.isSuccess = exports.isFailure = exports.isEffect = exports.intoDeferred = exports.interruptibleMask = exports.interruptible = exports.interruptWith = exports.interrupt = exports.inheritFiberRefs = exports.ignoreLogged = void 0;
exports.withTracer = exports.withSpan = exports.withSchedulingPriority = exports.withScheduler = exports.withRuntimeFlagsScoped = exports.withRuntimeFlags = exports.withRequestCaching = exports.withRequestCache = exports.withRequestBatching = exports.withMetric = exports.withMaxFiberOps = exports.withLogSpan = exports.withLogCause = exports.withLog = exports.withEarlyRelease = exports.withConfigProviderScoped = exports.withConfigProvider = exports.withConcurrency = exports.withClockScoped = exports.withClock = exports.whileLoop = exports.whenRef = exports.whenFiberRef = exports.whenEffect = exports.when = exports.validateWith = exports.validateFirst = exports.validateAll = exports.validate = exports.using = exports.useSpan = exports.updateService = exports.updateRuntimeFlags = exports.updateFiberRefs = exports.unsome = exports.unsandbox = exports.unsafeMakeSemaphore = exports.unlessEffect = exports.unless = exports.unit = exports.uninterruptibleMask = exports.uninterruptible = exports.unifiedFn = exports.unified = exports.tryPromiseInterrupt = exports.tryPromise = exports.tryMapPromiseInterrupt = exports.tryMapPromise = exports.tryMap = exports.try = exports.transplant = exports.tracerWith = exports.tracer = exports.timeoutTo = exports.timeoutFailCause = exports.timeoutFail = exports.timeout = exports.timedWith = exports.timed = exports.tapErrorCause = exports.tapError = exports.tapDefect = exports.tapBoth = exports.tap = exports.takeWhile = exports.takeUntil = exports.tagMetricsScoped = exports.tagMetrics = exports.sync = exports.suspend = exports.supervised = exports.summarized = exports.succeedSome = exports.succeedNone = exports.succeed = exports.step = exports.spanAnnotations = exports.some = exports.sleep = exports.setUnhandledErrorLogLevel = exports.setTracer = exports.setScheduler = exports.setRequestCaching = exports.setRequestCache = exports.setRequestBatching = exports.setFiberRefs = exports.setConfigProvider = exports.setClock = exports.serviceOption = exports.serviceFunctionEffect = exports.serviceFunction = exports.sequentialFinalizers = exports.scoped = exports.scopeWith = exports.scope = exports.scheduleFrom = exports.scheduleForked = exports.schedule = exports.sandbox = exports.runtimeFlags = void 0;
exports.zipWith = exports.zipRight = exports.zipLeft = exports.zip = exports.yieldNow = exports.withUnhandledErrorLogLevel = exports.withTracerScoped = void 0;
var Context = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/data/Context"));
var _Function = /*#__PURE__*/require("@effect/data/Function");
var _clock = /*#__PURE__*/require("@effect/io/internal/clock");
var core = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/io/internal/core"));
var defaultServices = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/io/internal/defaultServices"));
var effect = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/io/internal/effect"));
var circular = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/io/internal/effect/circular"));
var fiberRuntime = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/io/internal/fiberRuntime"));
var layer = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/io/internal/layer"));
var circularLayer = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/io/internal/layer/circular"));
var query = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/io/internal/query"));
var _runtime = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/io/internal/runtime"));
var _schedule = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/io/internal/schedule"));
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
/**
 * @since 1.0.0
 */

/**
 * @since 1.0.0
 * @category symbols
 */
const EffectTypeId = core.EffectTypeId;
// -------------------------------------------------------------------------------------
// refinements
// -------------------------------------------------------------------------------------
/**
 * This function returns `true` if the specified value is an `Effect` value,
 * `false` otherwise.
 *
 * This function can be useful for checking the type of a value before
 * attempting to operate on it as an `Effect` value. For example, you could
 * use `isEffect` to check the type of a value before using it as an
 * argument to a function that expects an `Effect` value.
 *
 * @param u - The value to check for being an `Effect` value.
 *
 * @returns `true` if the specified value is an `Effect` value, `false`
 * otherwise.
 *
 * @since 1.0.0
 * @category refinements
 */
exports.EffectTypeId = EffectTypeId;
const isEffect = core.isEffect;
// -------------------------------------------------------------------------------------
// caching
// -------------------------------------------------------------------------------------
/**
 * Returns an effect that, if evaluated, will return the cached result of this
 * effect. Cached results will expire after `timeToLive` duration.
 *
 * @since 1.0.0
 * @category caching
 */
exports.isEffect = isEffect;
const cachedWithTTL = circular.cached;
/**
 * Returns an effect that, if evaluated, will return the cached result of this
 * effect. Cached results will expire after `timeToLive` duration. In
 * addition, returns an effect that can be used to invalidate the current
 * cached value before the `timeToLive` duration expires.
 *
 * @since 1.0.0
 * @category caching
 */
exports.cachedWithTTL = cachedWithTTL;
const cachedInvalidateWithTTL = circular.cachedInvalidate;
/**
 * Returns an effect that, if evaluated, will return the lazily computed
 * result of this effect.
 *
 * @since 1.0.0
 * @category caching
 */
exports.cachedInvalidateWithTTL = cachedInvalidateWithTTL;
const cached = effect.memoize;
/**
 * Returns a memoized version of the specified effectual function.
 *
 * @since 1.0.0
 * @category caching
 */
exports.cached = cached;
const cachedFunction = circular.memoizeFunction;
/**
 * Returns an effect that will be executed at most once, even if it is
 * evaluated multiple times.
 *
 * @since 1.0.0
 * @category caching
 */
exports.cachedFunction = cachedFunction;
const once = effect.once;
// -------------------------------------------------------------------------------------
// collecting & elements
// -------------------------------------------------------------------------------------
/**
 * Runs all the provided effects in sequence respecting the structure provided in input.
 *
 * Supports multiple arguments, a single argument tuple / array or record / struct.
 *
 * @since 1.0.0
 * @category collecting & elements
 */
exports.once = once;
const all = fiberRuntime.all;
/**
 * Data-last variant of `Effect.all`.
 *
 * Runs all the provided effects in sequence respecting the structure provided in input.
 *
 * Supports multiple arguments, a single argument tuple / array or record / struct.
 *
 * @since 1.0.0
 * @category collecting & elements
 */
exports.all = all;
const allWith = fiberRuntime.allWith;
/**
 * Evaluate and run each effect in the structure and collect the results,
 * discarding results from failed effects.
 *
 * @since 1.0.0
 * @category collecting & elements
 */
exports.allWith = allWith;
const allSuccesses = fiberRuntime.allSuccesses;
/**
 * Drops all elements until the effectful predicate returns true.
 *
 * @since 1.0.0
 * @category collecting & elements
 */
exports.allSuccesses = allSuccesses;
const dropUntil = effect.dropUntil;
/**
 * Drops all elements so long as the predicate returns true.
 *
 * @since 1.0.0
 * @category collecting & elements
 */
exports.dropUntil = dropUntil;
const dropWhile = effect.dropWhile;
/**
 * Determines whether all elements of the `Collection<A>` satisfies the effectual
 * predicate `f`.
 *
 * @since 1.0.0
 * @category collecting & elements
 */
exports.dropWhile = dropWhile;
const every = effect.every;
/**
 * Determines whether any element of the `Iterable<A>` satisfies the effectual
 * predicate `f`.
 *
 * @since 1.0.0
 * @category collecting & elements
 */
exports.every = every;
const exists = fiberRuntime.exists;
/**
 * Filters the collection using the specified effectful predicate.
 *
 * @since 1.0.0
 * @category collecting & elements
 */
exports.exists = exists;
const filter = fiberRuntime.filter;
/**
 * Returns the first element that satisfies the effectful predicate.
 *
 * @since 1.0.0
 * @category collecting & elements
 */
exports.filter = filter;
const findFirst = effect.findFirst;
/**
 * This function takes an iterable of `Effect` values and returns a new
 * `Effect` value that represents the first `Effect` value in the iterable
 * that succeeds. If all of the `Effect` values in the iterable fail, then
 * the resulting `Effect` value will fail as well.
 *
 * This function is sequential, meaning that the `Effect` values in the
 * iterable will be executed in sequence, and the first one that succeeds
 * will determine the outcome of the resulting `Effect` value.
 *
 * @param effects - The iterable of `Effect` values to evaluate.
 *
 * @returns A new `Effect` value that represents the first successful
 * `Effect` value in the iterable, or a failed `Effect` value if all of the
 * `Effect` values in the iterable fail.
 *
 * @since 1.0.0
 * @category collecting & elements
 */
exports.findFirst = findFirst;
const firstSuccessOf = effect.firstSuccessOf;
/**
 * @since 1.0.0
 * @category collecting & elements
 */
exports.firstSuccessOf = firstSuccessOf;
const forEach = fiberRuntime.forEachOptions;
/**
 * Returns a successful effect with the head of the collection if the collection
 * is non-empty, or fails with the error `None` if the collection is empty.
 *
 * @since 1.0.0
 * @category collecting & elements
 */
exports.forEach = forEach;
const head = effect.head;
/**
 * Merges an `Iterable<Effect<R, E, A>>` to a single effect, working
 * sequentially.
 *
 * @since 1.0.0
 * @category collecting & elements
 */
exports.head = head;
const mergeAll = fiberRuntime.mergeAll;
/**
 * Feeds elements of type `A` to a function `f` that returns an effect.
 * Collects all successes and failures in a tupled fashion.
 *
 * @since 1.0.0
 * @category collecting & elements
 */
exports.mergeAll = mergeAll;
const partition = fiberRuntime.partition;
/**
 * Folds an `Iterable<A>` using an effectual function f, working sequentially
 * from left to right.
 *
 * @since 1.0.0
 * @category collecting & elements
 */
exports.partition = partition;
const reduce = effect.reduce;
/**
 * Reduces an `Iterable<Effect<R, E, A>>` to a single effect.
 *
 * @since 1.0.0
 * @category collecting & elements
 */
exports.reduce = reduce;
const reduceEffect = fiberRuntime.reduceEffect;
/**
 * Folds an `Iterable<A>` using an effectual function f, working sequentially from left to right.
 *
 * @since 1.0.0
 * @category collecting & elements
 */
exports.reduceEffect = reduceEffect;
const reduceRight = effect.reduceRight;
/**
 * Folds over the elements in this chunk from the left, stopping the fold early
 * when the predicate is not satisfied.
 *
 * @since 1.0.0
 * @category collecting & elements
 */
exports.reduceRight = reduceRight;
const reduceWhile = effect.reduceWhile;
/**
 * Replicates the given effect `n` times.
 *
 * @since 1.0.0
 * @category collecting & elements
 */
exports.reduceWhile = reduceWhile;
const replicate = fiberRuntime.replicate;
/**
 * Performs this effect the specified number of times and collects the
 * results.
 *
 * @since 1.0.0
 * @category collecting & elements
 */
exports.replicate = replicate;
const replicateEffect = fiberRuntime.replicateEffect;
/**
 * Takes elements until the effectual predicate returns true.
 *
 * @since 1.0.0
 * @category collecting & elements
 */
exports.replicateEffect = replicateEffect;
const takeUntil = effect.takeUntil;
/**
 * Takes all elements so long as the effectual predicate returns true.
 *
 * @since 1.0.0
 * @category collecting & elements
 */
exports.takeUntil = takeUntil;
const takeWhile = effect.takeWhile;
/**
 * Feeds elements of type `A` to `f` and accumulates all errors in error
 * channel or successes in success channel.
 *
 * This combinator is lossy meaning that if there are errors all successes
 * will be lost. To retain all information please use `partition`.
 *
 * @since 1.0.0
 * @category collecting & elements
 */
exports.takeWhile = takeWhile;
const validateAll = fiberRuntime.validateAll;
/**
 * Feeds elements of type `A` to `f` until it succeeds. Returns first success
 * or the accumulation of all errors.
 *
 * If `elements` is empty then `Effect.fail([])` is returned.
 *
 * @example
 * import * as Effect from "@effect/io/Effect"
 * import * as Exit from "@effect/io/Exit"
 *
 * const f = (n: number) => (n > 0 ? Effect.succeed(n) : Effect.fail(`${n} is negative`))
 *
 * assert.deepStrictEqual(Exit.unannotate(Effect.runSyncExit(Effect.validateFirst([], f))), Exit.fail([]))
 * assert.deepStrictEqual(Exit.unannotate(Effect.runSyncExit(Effect.validateFirst([1, 2], f))), Exit.succeed(1))
 * assert.deepStrictEqual(Exit.unannotate(Effect.runSyncExit(Effect.validateFirst([1, -1], f))), Exit.succeed(1))
 * assert.deepStrictEqual(Exit.unannotate(Effect.runSyncExit(Effect.validateFirst([-1, 2], f))), Exit.succeed(2))
 * assert.deepStrictEqual(Exit.unannotate(Effect.runSyncExit(Effect.validateFirst([-1, -2], f))), Exit.fail(['-1 is negative', '-2 is negative']))
 *
 * @since 1.0.0
 * @category collecting & elements
 */
exports.validateAll = validateAll;
const validateFirst = fiberRuntime.validateFirst;
// -------------------------------------------------------------------------------------
// constructors
// -------------------------------------------------------------------------------------
/**
 * Imports an asynchronous side-effect into a pure `Effect` value. See
 * `asyncMaybe` for the more expressive variant of this function that can
 * return a value synchronously.
 *
 * The callback function `Effect<R, E, A> => void` must be called at most once.
 *
 * The `FiberId` of the fiber that may complete the async callback may be
 * provided to allow for better diagnostics.
 *
 * @since 1.0.0
 * @category constructors
 */
exports.validateFirst = validateFirst;
const async = core.async;
/**
 * Converts an asynchronous, callback-style API into an `Effect`, which will
 * be executed asynchronously.
 *
 * With this variant, the registration function may return a an `Effect`.
 *
 * @since 1.0.0
 * @category constructors
 */
exports.async = async;
const asyncEffect = _runtime.asyncEffect;
/**
 * Imports an asynchronous effect into a pure `Effect` value, possibly returning
 * the value synchronously.
 *
 * If the register function returns a value synchronously, then the callback
 * function `Effect<R, E, A> => void` must not be called. Otherwise the callback
 * function must be called at most once.
 *
 * The `FiberId` of the fiber that may complete the async callback may be
 * provided to allow for better diagnostics.
 *
 * @since 1.0.0
 * @category constructors
 */
exports.asyncEffect = asyncEffect;
const asyncOption = effect.asyncOption;
/**
 * Imports an asynchronous side-effect into an effect. It has the option of
 * returning the value synchronously, which is useful in cases where it cannot
 * be determined if the effect is synchronous or asynchronous until the register
 * is actually executed. It also has the option of returning a canceler,
 * which will be used by the runtime to cancel the asynchronous effect if the fiber
 * executing the effect is interrupted.
 *
 * If the register function returns a value synchronously, then the callback
 * function `Effect<R, E, A> => void` must not be called. Otherwise the callback
 * function must be called at most once.
 *
 * The `FiberId` of the fiber that may complete the async callback may be
 * provided to allow for better diagnostics.
 *
 * @since 1.0.0
 * @category constructors
 */
exports.asyncOption = asyncOption;
const asyncInterruptEither = core.asyncInterruptEither;
/**
 * Imports an asynchronous side-effect into an effect allowing control of interruption.
 *
 * The `FiberId` of the fiber that may complete the async callback may be
 * provided to allow for better diagnostics.
 *
 * @since 1.0.0
 * @category constructors
 */
exports.asyncInterruptEither = asyncInterruptEither;
const asyncInterrupt = core.asyncInterrupt;
/**
 * @since 1.0.0
 * @category constructors
 */
exports.asyncInterrupt = asyncInterrupt;
const fail = core.fail;
/**
 * @since 1.0.0
 * @category constructors
 */
exports.fail = fail;
const failSync = core.failSync;
/**
 * @since 1.0.0
 * @category constructors
 */
exports.failSync = failSync;
const failCause = core.failCause;
/**
 * @since 1.0.0
 * @category constructors
 */
exports.failCause = failCause;
const failCauseSync = core.failCauseSync;
/**
 * @since 1.0.0
 * @category constructors
 */
exports.failCauseSync = failCauseSync;
const die = core.die;
/**
 * Returns an effect that dies with a `RuntimeException` having the specified
 * text message. This method can be used for terminating a fiber because a
 * defect has been detected in the code.
 *
 * @since 1.0.0
 * @category constructors
 */
exports.die = die;
const dieMessage = core.dieMessage;
/**
 * @since 1.0.0
 * @category constructors
 */
exports.dieMessage = dieMessage;
const dieSync = core.dieSync;
/**
 * @since 1.0.0
 * @category constructors
 */
exports.dieSync = dieSync;
const gen = effect.gen;
/**
 * Returns a effect that will never produce anything. The moral equivalent of
 * `while(true) {}`, only without the wasted CPU cycles.
 *
 * @since 1.0.0
 * @category constructors
 */
exports.gen = gen;
const never = core.never;
/**
 * Requires the option produced by this value to be `None`.
 *
 * @since 1.0.0
 * @category constructors
 */
exports.never = never;
const none = effect.none;
/**
 * Like `tryPromise` but produces a defect in case of errors.
 *
 * @since 1.0.0
 * @category constructors
 */
exports.none = none;
const promise = effect.promise;
/**
 * Like `promise` but allows for interruption via AbortSignal
 *
 * @since 1.0.0
 * @category constructors
 */
exports.promise = promise;
const promiseInterrupt = effect.promiseInterrupt;
/**
 * @since 1.0.0
 * @category constructors
 */
exports.promiseInterrupt = promiseInterrupt;
const succeed = core.succeed;
/**
 * Returns an effect which succeeds with `None`.
 *
 * @since 1.0.0
 * @category constructors
 */
exports.succeed = succeed;
const succeedNone = effect.succeedNone;
/**
 * Returns an effect which succeeds with the value wrapped in a `Some`.
 *
 * @since 1.0.0
 * @category constructors
 */
exports.succeedNone = succeedNone;
const succeedSome = effect.succeedSome;
/**
 * @since 1.0.0
 * @category constructors
 */
exports.succeedSome = succeedSome;
const suspend = core.suspend;
/**
 * @since 1.0.0
 * @category constructors
 */
exports.suspend = suspend;
const sync = core.sync;
/**
 * @since 1.0.0
 * @category constructors
 */
exports.sync = sync;
const unit = core.unit;
/**
 * @since 1.0.0
 * @category constructors
 */
exports.unit = unit;
const yieldNow = core.yieldNow;
// -------------------------------------------------------------------------------------
// error handling
// -------------------------------------------------------------------------------------
exports.yieldNow = yieldNow;
const _catch = effect._catch;
exports.catch = _catch;
/**
 * Recovers from all recoverable errors.
 *
 * **Note**: that `Effect.catchAll` will not recover from unrecoverable defects. To
 * recover from both recoverable and unrecoverable errors use
 * `Effect.catchAllCause`.
 *
 * @since 1.0.0
 * @category error handling
 */
const catchAll = core.catchAll;
/**
 * Recovers from both recoverable and unrecoverable errors.
 *
 * See `absorb`, `sandbox`, `mapErrorCause` for other functions that can
 * recover from defects.
 *
 * @since 1.0.0
 * @category error handling
 */
exports.catchAll = catchAll;
const catchAllCause = core.catchAllCause;
/**
 * Recovers from all defects with provided function.
 *
 * **WARNING**: There is no sensible way to recover from defects. This
 * method should be used only at the boundary between Effect and an external
 * system, to transmit information on a defect for diagnostic or explanatory
 * purposes.
 *
 * @since 1.0.0
 * @category error handling
 */
exports.catchAllCause = catchAllCause;
const catchAllDefect = effect.catchAllDefect;
/**
 * Recovers from some or all of the error cases.
 *
 * @since 1.0.0
 * @category error handling
 */
exports.catchAllDefect = catchAllDefect;
const catchSome = core.catchSome;
/**
 * Recovers from some or all of the error cases with provided cause.
 *
 * @since 1.0.0
 * @category error handling
 */
exports.catchSome = catchSome;
const catchSomeCause = effect.catchSomeCause;
/**
 * Recovers from some or all of the defects with provided partial function.
 *
 * **WARNING**: There is no sensible way to recover from defects. This
 * method should be used only at the boundary between Effect and an external
 * system, to transmit information on a defect for diagnostic or explanatory
 * purposes.
 *
 * @since 1.0.0
 * @category error handling
 */
exports.catchSomeCause = catchSomeCause;
const catchSomeDefect = effect.catchSomeDefect;
/**
 * Recovers from the specified tagged error.
 *
 * @since 1.0.0
 * @category error handling
 */
exports.catchSomeDefect = catchSomeDefect;
const catchTag = effect.catchTag;
/**
 * Recovers from the specified tagged errors.
 *
 * @since 1.0.0
 * @category error handling
 */
exports.catchTag = catchTag;
const catchTags = effect.catchTags;
/**
 * Returns an effect that succeeds with the cause of failure of this effect,
 * or `Cause.empty` if the effect did succeed.
 *
 * @since 1.0.0
 * @category error handling
 */
exports.catchTags = catchTags;
const cause = effect.cause;
/**
 * Returns an effect that ignores errors and runs repeatedly until it
 * eventually succeeds.
 *
 * @since 1.0.0
 * @category error handling
 */
exports.cause = cause;
const eventually = effect.eventually;
/**
 * Returns a new effect that ignores the success or failure of this effect.
 *
 * @since 1.0.0
 * @category error handling
 */
exports.eventually = eventually;
const ignore = effect.ignore;
/**
 * Returns a new effect that ignores the success or failure of this effect,
 * but which also logs failures at the Debug level, just in case the failure
 * turns out to be important.
 *
 * @since 1.0.0
 * @category error handling
 */
exports.ignore = ignore;
const ignoreLogged = effect.ignoreLogged;
/**
 * Exposes all parallel errors in a single call.
 *
 * @since 1.0.0
 * @category error handling
 */
exports.ignoreLogged = ignoreLogged;
const parallelErrors = effect.parallelErrors;
/**
 * Exposes the full `Cause` of failure for the specified effect.
 *
 * @since 1.0.0
 * @category error handling
 */
exports.parallelErrors = parallelErrors;
const sandbox = effect.sandbox;
/**
 * Retries with the specified retry policy. Retries are done following the
 * failure of the original `io` (up to a fixed maximum with `once` or `recurs`
 * for example), so that that `io.retry(Schedule.once)` means "execute `io`
 * and in case of failure, try again once".
 *
 * @since 1.0.0
 * @category error handling
 */
exports.sandbox = sandbox;
const retry = _schedule.retry_Effect;
/**
 * Retries this effect the specified number of times.
 *
 * @since 1.0.0
 * @category error handling
 */
exports.retry = retry;
const retryN = _schedule.retryN_Effect;
/**
 * Retries with the specified schedule, until it fails, and then both the
 * value produced by the schedule together with the last error are passed to
 * the recovery function.
 *
 * @since 1.0.0
 * @category error handling
 */
exports.retryN = retryN;
const retryOrElse = _schedule.retryOrElse_Effect;
/**
 * Retries this effect until its error satisfies the specified predicate.
 *
 * @since 1.0.0
 * @category error handling
 */
exports.retryOrElse = retryOrElse;
const retryUntil = _schedule.retryUntil_Effect;
/**
 * Retries this effect until its error satisfies the specified effectful
 * predicate.
 *
 * @since 1.0.0
 * @category error handling
 */
exports.retryUntil = retryUntil;
const retryUntilEffect = _schedule.retryUntilEffect_Effect;
/**
 * Retries this effect while its error satisfies the specified predicate.
 *
 * @since 1.0.0
 * @category error handling
 */
exports.retryUntilEffect = retryUntilEffect;
const retryWhile = _schedule.retryWhile_Effect;
/**
 * Retries this effect while its error satisfies the specified effectful
 * predicate.
 *
 * @since 1.0.0
 * @category error handling
 */
exports.retryWhile = retryWhile;
const retryWhileEffect = _schedule.retryWhileEffect_Effect;
exports.retryWhileEffect = retryWhileEffect;
const try_ = effect.try_;
exports.try = try_;
/**
 * Returns an effect whose success is mapped by the specified side effecting
 * `f` function, translating any thrown exceptions into typed failed effects.
 *
 * @since 1.0.0
 * @category error handling
 */
const tryMap = effect.tryMap;
/**
 * Returns an effect whose success is mapped by the specified side effecting
 * `f` function, translating any promise rejections into typed failed effects.
 *
 * @since 1.0.0
 * @category error handling
 */
exports.tryMap = tryMap;
const tryMapPromise = effect.tryMapPromise;
/**
 * Like `tryMapPromise` but allows for interruption via AbortSignal
 *
 * @since 1.0.0
 * @category error handling
 */
exports.tryMapPromise = tryMapPromise;
const tryMapPromiseInterrupt = effect.tryMapPromiseInterrupt;
/**
 * Create an `Effect` that when executed will construct `promise` and wait for
 * its result, errors will produce failure as `unknown`.
 *
 * @since 1.0.0
 * @category error handling
 */
exports.tryMapPromiseInterrupt = tryMapPromiseInterrupt;
const tryPromise = effect.tryPromise;
/**
 * Like `tryPromise` but allows for interruption via AbortSignal
 *
 * @since 1.0.0
 * @category error handling
 */
exports.tryPromise = tryPromise;
const tryPromiseInterrupt = effect.tryPromiseInterrupt;
/**
 * The inverse operation `sandbox(effect)`
 *
 * Terminates with exceptions on the `Left` side of the `Either` error, if it
 * exists. Otherwise extracts the contained `Effect<R, E, A>`
 *
 * @since 1.0.0
 * @category error handling
 */
exports.tryPromiseInterrupt = tryPromiseInterrupt;
const unsandbox = effect.unsandbox;
// -------------------------------------------------------------------------------------
// interuption
// -------------------------------------------------------------------------------------
/**
 * This function checks if any fibers are attempting to interrupt the current
 * fiber, and if so, performs self-interruption.
 *
 * Note that this allows for interruption to occur in uninterruptible regions.
 *
 * @returns A new `Effect` value that represents the check for interruption
 * and the potential self-interruption of the current fiber.
 *
 * @since 1.0.0
 * @category interruption
 */
exports.unsandbox = unsandbox;
const allowInterrupt = effect.allowInterrupt;
/**
 * Checks the interrupt status, and produces the effect returned by the
 * specified callback.
 *
 * @since 1.0.0
 * @category interruption
 */
exports.allowInterrupt = allowInterrupt;
const checkInterruptible = core.checkInterruptible;
/**
 * Returns an effect whose interruption will be disconnected from the
 * fiber's own interruption, being performed in the background without
 * slowing down the fiber's interruption.
 *
 * This method is useful to create "fast interrupting" effects. For
 * example, if you call this on a bracketed effect, then even if the
 * effect is "stuck" in acquire or release, its interruption will return
 * immediately, while the acquire / release are performed in the
 * background.
 *
 * See timeout and race for other applications.
 *
 * @since 1.0.0
 * @category interruption
 */
exports.checkInterruptible = checkInterruptible;
const disconnect = fiberRuntime.disconnect;
/**
 * @since 1.0.0
 * @category interruption
 */
exports.disconnect = disconnect;
const interrupt = core.interrupt;
/**
 * @since 1.0.0
 * @category interruption
 */
exports.interrupt = interrupt;
const interruptWith = core.interruptWith;
/**
 * @since 1.0.0
 * @category interruption
 */
exports.interruptWith = interruptWith;
const interruptible = core.interruptible;
/**
 * @since 1.0.0
 * @category interruption
 */
exports.interruptible = interruptible;
const interruptibleMask = core.interruptibleMask;
/**
 * @since 1.0.0
 * @category interruption
 */
exports.interruptibleMask = interruptibleMask;
const onInterrupt = core.onInterrupt;
/**
 * @since 1.0.0
 * @category interruption
 */
exports.onInterrupt = onInterrupt;
const uninterruptible = core.uninterruptible;
/**
 * @since 1.0.0
 * @category interruption
 */
exports.uninterruptible = uninterruptible;
const uninterruptibleMask = core.uninterruptibleMask;
// -------------------------------------------------------------------------------------
// mapping
// -------------------------------------------------------------------------------------
/**
 * This function maps the success value of an `Effect` value to a specified
 * constant value.
 *
 * @param value - The constant value that the success value of the `Effect`
 * value will be mapped to.
 * @param self - The `Effect` value whose success value will be mapped to the
 * specified constant value.
 *
 * @returns A new `Effect` value that represents the mapping of the success
 * value of the original `Effect` value to the specified constant value.
 *
 * @since 1.0.0
 * @category mapping
 */
exports.uninterruptibleMask = uninterruptibleMask;
const as = core.as;
/**
 * This function maps the success value of an `Effect` value to a `Some` value
 * in an `Option` value. If the original `Effect` value fails, the returned
 * `Effect` value will also fail.
 *
 * @param self - The `Effect` value whose success value will be mapped to a
 * `Some` value in an `Option` value.
 *
 * @returns A new `Effect` value that represents the mapping of the success
 * value of the original `Effect` value to a `Some` value in an `Option`
 * value. The returned `Effect` value may fail if the original `Effect` value
 * fails.
 *
 * @category mapping
 * @since 1.0.0
 */
exports.as = as;
const asSome = effect.asSome;
/**
 * This function maps the error value of an `Effect` value to a `Some` value
 * in an `Option` value. If the original `Effect` value succeeds, the returned
 * `Effect` value will also succeed.
 *
 * @param self - The `Effect` value whose error value will be mapped to a
 * `Some` value in an `Option` value.
 *
 * @returns A new `Effect` value that represents the mapping of the error
 * value of the original `Effect` value to a `Some` value in an `Option`
 * value. The returned `Effect` value may succeed if the original `Effect`
 * value succeeds.
 *
 * @category mapping
 * @since 1.0.0
 */
exports.asSome = asSome;
const asSomeError = effect.asSomeError;
/**
 * This function maps the success value of an `Effect` value to `void`. If the
 * original `Effect` value succeeds, the returned `Effect` value will also
 * succeed. If the original `Effect` value fails, the returned `Effect` value
 * will fail with the same error.
 *
 * @param self - The `Effect` value whose success value will be mapped to `void`.
 *
 * @returns A new `Effect` value that represents the mapping of the success
 * value of the original `Effect` value to `void`.
 *
 * @since 1.0.0
 * @category mapping
 */
exports.asSomeError = asSomeError;
const asUnit = core.asUnit;
/**
 * Returns an effect that swaps the error/success cases. This allows you to
 * use all methods on the error channel, possibly before flipping back.
 *
 * @since 1.0.0
 * @category mapping
 */
exports.asUnit = asUnit;
const flip = core.flip;
/**
 * Swaps the error/value parameters, applies the function `f` and flips the
 * parameters back
 *
 * @since 1.0.0
 * @category mapping
 */
exports.flip = flip;
const flipWith = effect.flipWith;
/**
 * @since 1.0.0
 * @category mapping
 */
exports.flipWith = flipWith;
const map = core.map;
/**
 * Statefully and effectfully maps over the elements of this chunk to produce
 * new elements.
 *
 * @since 1.0.0
 * @category mapping
 */
exports.map = map;
const mapAccum = effect.mapAccum;
/**
 * Returns an effect whose failure and success channels have been mapped by
 * the specified pair of functions, `f` and `g`.
 *
 * @since 1.0.0
 * @category mapping
 */
exports.mapAccum = mapAccum;
const mapBoth = core.mapBoth;
/**
 * Returns an effect with its error channel mapped using the specified function.
 *
 * @since 1.0.0
 * @category mapping
 */
exports.mapBoth = mapBoth;
const mapError = core.mapError;
/**
 * Returns an effect with its full cause of failure mapped using the specified
 * function. This can be used to transform errors while preserving the
 * original structure of `Cause`.
 *
 * See `absorb`, `sandbox`, `catchAllCause` for other functions for dealing
 * with defects.
 *
 * @since 1.0.0
 * @category mapping
 */
exports.mapError = mapError;
const mapErrorCause = effect.mapErrorCause;
/**
 * Returns a new effect where the error channel has been merged into the
 * success channel to their common combined type.
 *
 * @since 1.0.0
 * @category mapping
 */
exports.mapErrorCause = mapErrorCause;
const merge = effect.merge;
/**
 * Returns a new effect where boolean value of this effect is negated.
 *
 * @since 1.0.0
 * @category mapping
 */
exports.merge = merge;
const negate = effect.negate;
// -------------------------------------------------------------------------------------
// scoping, resources & finalization
// -------------------------------------------------------------------------------------
/**
 * This function constructs a scoped resource from an `acquire` and `release`
 * `Effect` value.
 *
 * If the `acquire` `Effect` value successfully completes execution, then the
 * `release` `Effect` value will be added to the finalizers associated with the
 * scope of this `Effect` value, and it is guaranteed to be run when the scope
 * is closed.
 *
 * The `acquire` and `release` `Effect` values will be run uninterruptibly.
 * Additionally, the `release` `Effect` value may depend on the `Exit` value
 * specified when the scope is closed.
 *
 * @param acquire - The `Effect` value that acquires the resource.
 * @param release - The `Effect` value that releases the resource.
 * @param interruptible - Whether the `acquire` Effect can be interrupted
 *
 * @returns A new `Effect` value that represents the scoped resource.
 *
 * @since 1.0.0
 * @category scoping, resources & finalization
 */
exports.negate = negate;
const acquireRelease = fiberRuntime.acquireRelease;
/**
 * This function is used to ensure that an `Effect` value that represents the
 * acquisition of a resource (for example, opening a file, launching a thread,
 * etc.) will not be interrupted, and that the resource will always be released
 * when the `Effect` value completes execution.
 *
 * `acquireUseRelease` does the following:
 *
 *   1. Ensures that the `Effect` value that acquires the resource will not be
 *      interrupted. Note that acquisition may still fail due to internal
 *      reasons (such as an uncaught exception).
 *   2. Ensures that the `release` `Effect` value will not be interrupted,
 *      and will be executed as long as the acquisition `Effect` value
 *      successfully acquires the resource.
 *
 * During the time period between the acquisition and release of the resource,
 * the `use` `Effect` value will be executed.
 *
 * If the `release` `Effect` value fails, then the entire `Effect` value will
 * fail, even if the `use` `Effect` value succeeds. If this fail-fast behavior
 * is not desired, errors produced by the `release` `Effect` value can be caught
 * and ignored.
 *
 * @param acquire - The `Effect` value that acquires the resource.
 * @param use - The `Effect` value that is executed between the acquisition
 * and release of the resource.
 * @param release - The `Effect` value that releases the resource.
 *
 * @returns A new `Effect` value that represents the acquisition, use, and
 * release of the resource.
 *
 * @since 1.0.0
 * @category scoping, resources & finalization
 */
exports.acquireRelease = acquireRelease;
const acquireUseRelease = core.acquireUseRelease;
/**
 * This function adds a finalizer to the scope of the calling `Effect` value.
 * The finalizer is guaranteed to be run when the scope is closed, and it may
 * depend on the `Exit` value that the scope is closed with.
 *
 * @param finalizer - The finalizer to add to the scope of the calling
 * `Effect` value. This function must take an `Exit` value as its parameter,
 * and return a new `Effect` value.
 *
 * @returns A new `Effect` value that represents the addition of the finalizer
 * to the scope of the calling `Effect` value.
 *
 * @since 1.0.0
 * @category scoping, resources & finalization
 */
exports.acquireUseRelease = acquireUseRelease;
const addFinalizer = fiberRuntime.addFinalizer;
/**
 * Returns an effect that, if this effect _starts_ execution, then the
 * specified `finalizer` is guaranteed to be executed, whether this effect
 * succeeds, fails, or is interrupted.
 *
 * For use cases that need access to the effect's result, see `onExit`.
 *
 * Finalizers offer very powerful guarantees, but they are low-level, and
 * should generally not be used for releasing resources. For higher-level
 * logic built on `ensuring`, see the `acquireRelease` family of methods.
 *
 * @since 1.0.0
 * @category scoping, resources & finalization
 */
exports.addFinalizer = addFinalizer;
const ensuring = fiberRuntime.ensuring;
/**
 * Runs the specified effect if this effect fails, providing the error to the
 * effect if it exists. The provided effect will not be interrupted.
 *
 * @since 1.0.0
 * @category scoping, resources & finalization
 */
exports.ensuring = ensuring;
const onError = core.onError;
/**
 * Ensures that a cleanup functions runs, whether this effect succeeds, fails,
 * or is interrupted.
 *
 * @since 1.0.0
 * @category scoping, resources & finalization
 */
exports.onError = onError;
const onExit = core.onExit;
/**
 * @since 1.0.0
 * @category scoping, resources & finalization
 */
exports.onExit = onExit;
const parallelFinalizers = fiberRuntime.parallelFinalizers;
/**
 * Returns a new scoped workflow that runs finalizers added to the scope of
 * this workflow sequentially in the reverse of the order in which they were
 * added. Note that finalizers are run sequentially by default so this only
 * has meaning if used within a scope where finalizers are being run in
 * parallel.
 *
 * @since 1.0.0
 * @category scoping, resources & finalization
 */
exports.parallelFinalizers = parallelFinalizers;
const sequentialFinalizers = fiberRuntime.sequentialFinalizers;
/**
 * @since 1.0.0
 * @category scoping, resources & finalization
 */
exports.sequentialFinalizers = sequentialFinalizers;
const scope = fiberRuntime.scope;
/**
 * Accesses the current scope and uses it to perform the specified effect.
 *
 * @since 1.0.0
 * @category scoping, resources & finalization
 */
exports.scope = scope;
const scopeWith = fiberRuntime.scopeWith;
/**
 * Scopes all resources uses in this workflow to the lifetime of the workflow,
 * ensuring that their finalizers are run as soon as this workflow completes
 * execution, whether by success, failure, or interruption.
 *
 * @since 1.0.0
 * @category scoping, resources & finalization
 */
exports.scopeWith = scopeWith;
const scoped = fiberRuntime.scopedEffect;
/**
 * Scopes all resources acquired by `resource` to the lifetime of `use`
 * without effecting the scope of any resources acquired by `use`.
 *
 * @since 1.0.0
 * @category scoping, resources & finalization
 */
exports.scoped = scoped;
const using = fiberRuntime.using;
/**
 * Returns a new scoped workflow that returns the result of this workflow as
 * well as a finalizer that can be run to close the scope of this workflow.
 *
 * @since 1.0.0
 * @category scoping, resources & finalization
 */
exports.using = using;
const withEarlyRelease = fiberRuntime.withEarlyRelease;
// -------------------------------------------------------------------------------------
// supervision & fibers
// -------------------------------------------------------------------------------------
/**
 * Returns a new effect that will not succeed with its value before first
 * waiting for the end of all child fibers forked by the effect.
 *
 * @since 1.0.0
 * @category supervision & fibers
 */
exports.withEarlyRelease = withEarlyRelease;
const awaitAllChildren = circular.awaitAllChildren;
/**
 * Returns a new workflow that will not supervise any fibers forked by this
 * workflow.
 *
 * @since 1.0.0
 * @category supervision & fibers
 */
exports.awaitAllChildren = awaitAllChildren;
const daemonChildren = fiberRuntime.daemonChildren;
/**
 * Constructs an effect with information about the current `Fiber`.
 *
 * @since 1.0.0
 * @category supervision & fibers
 */
exports.daemonChildren = daemonChildren;
const descriptor = effect.descriptor;
/**
 * Constructs an effect based on information about the current `Fiber`.
 *
 * @since 1.0.0
 * @category supervision & fibers
 */
exports.descriptor = descriptor;
const descriptorWith = effect.descriptorWith;
/**
 * Returns a new workflow that executes this one and captures the changes in
 * `FiberRef` values.
 *
 * @since 1.0.0
 * @category supervision & fibers
 */
exports.descriptorWith = descriptorWith;
const diffFiberRefs = effect.diffFiberRefs;
/**
 * Acts on the children of this fiber (collected into a single fiber),
 * guaranteeing the specified callback will be invoked, whether or not this
 * effect succeeds.
 *
 * @since 1.0.0
 * @category supervision & fibers
 */
exports.diffFiberRefs = diffFiberRefs;
const ensuringChild = circular.ensuringChild;
/**
 * Acts on the children of this fiber, guaranteeing the specified callback
 * will be invoked, whether or not this effect succeeds.
 *
 * @since 1.0.0
 * @category supervision & fibers
 */
exports.ensuringChild = ensuringChild;
const ensuringChildren = circular.ensuringChildren;
/**
 * @since 1.0.0
 * @category supervision & fibers
 */
exports.ensuringChildren = ensuringChildren;
const fiberId = core.fiberId;
/**
 * @since 1.0.0
 * @category supervision & fibers
 */
exports.fiberId = fiberId;
const fiberIdWith = core.fiberIdWith;
/**
 * Returns an effect that forks this effect into its own separate fiber,
 * returning the fiber immediately, without waiting for it to begin executing
 * the effect.
 *
 * You can use the `fork` method whenever you want to execute an effect in a
 * new fiber, concurrently and without "blocking" the fiber executing other
 * effects. Using fibers can be tricky, so instead of using this method
 * directly, consider other higher-level methods, such as `raceWith`,
 * `zipPar`, and so forth.
 *
 * The fiber returned by this method has methods to interrupt the fiber and to
 * wait for it to finish executing the effect. See `Fiber` for more
 * information.
 *
 * Whenever you use this method to launch a new fiber, the new fiber is
 * attached to the parent fiber's scope. This means when the parent fiber
 * terminates, the child fiber will be terminated as well, ensuring that no
 * fibers leak. This behavior is called "auto supervision", and if this
 * behavior is not desired, you may use the `forkDaemon` or `forkIn` methods.
 *
 * @since 1.0.0
 * @category supervision & fibers
 */
exports.fiberIdWith = fiberIdWith;
const fork = fiberRuntime.fork;
/**
 * Forks the effect into a new fiber attached to the global scope. Because the
 * new fiber is attached to the global scope, when the fiber executing the
 * returned effect terminates, the forked fiber will continue running.
 *
 * @since 1.0.0
 * @category supervision & fibers
 */
exports.fork = fork;
const forkDaemon = fiberRuntime.forkDaemon;
/**
 * Returns an effect that forks all of the specified values, and returns a
 * composite fiber that produces a list of their results, in order.
 *
 * @since 1.0.0
 * @category supervision & fibers
 */
exports.forkDaemon = forkDaemon;
const forkAll = circular.forkAll;
/**
 * Forks the effect in the specified scope. The fiber will be interrupted
 * when the scope is closed.
 *
 * @since 1.0.0
 * @category supervision & fibers
 */
exports.forkAll = forkAll;
const forkIn = circular.forkIn;
/**
 * Forks the fiber in a `Scope`, interrupting it when the scope is closed.
 *
 * @since 1.0.0
 * @category supervision & fibers
 */
exports.forkIn = forkIn;
const forkScoped = circular.forkScoped;
/**
 * Like fork but handles an error with the provided handler.
 *
 * @since 1.0.0
 * @category supervision & fibers
 */
exports.forkScoped = forkScoped;
const forkWithErrorHandler = fiberRuntime.forkWithErrorHandler;
/**
 * Creates an `Effect` value that represents the exit value of the specified
 * fiber.
 *
 * @since 1.0.0
 * @category supervision & fibers
 */
exports.forkWithErrorHandler = forkWithErrorHandler;
const fromFiber = circular.fromFiber;
/**
 * Creates an `Effect` value that represents the exit value of the specified
 * fiber.
 *
 * @since 1.0.0
 * @category supervision & fibers
 */
exports.fromFiber = fromFiber;
const fromFiberEffect = circular.fromFiberEffect;
/**
 * Returns an effect with the behavior of this one, but where all child fibers
 * forked in the effect are reported to the specified supervisor.
 *
 * @since 1.0.0
 * @category supervision & fibers
 */
exports.fromFiberEffect = fromFiberEffect;
const supervised = circular.supervised;
/**
 * Transplants specified effects so that when those effects fork other
 * effects, the forked effects will be governed by the scope of the fiber that
 * executes this effect.
 *
 * This can be used to "graft" deep grandchildren onto a higher-level scope,
 * effectively extending their lifespans into the parent scope.
 *
 * @since 1.0.0
 * @category supervision & fibers
 */
exports.supervised = supervised;
const transplant = core.transplant;
/**
 * @since 1.0.0
 * @category supervision & fibers
 */
exports.transplant = transplant;
const withConcurrency = core.withConcurrency;
// ---------------------------------------------------------------------------------------
// scheduler
// ---------------------------------------------------------------------------------------
/**
 * @since 1.0.0
 * @category scheduler
 */
exports.withConcurrency = withConcurrency;
const setScheduler = scheduler => layer.scopedDiscard(fiberRuntime.fiberRefLocallyScoped(core.currentScheduler, scheduler));
/**
 * Sets the child effect's maximum number of ops before yield
 *
 * @since 1.0.0
 * @category scheduler
 */
exports.setScheduler = setScheduler;
const withMaxFiberOps = core.withMaxFiberOps;
/**
 * Sets the provided scheduler for usage in the wrapped effect
 *
 * @since 1.0.0
 * @category scheduler
 */
exports.withMaxFiberOps = withMaxFiberOps;
const withScheduler = core.withScheduler;
/**
 * Sets the scheduling priority used when yielding
 *
 * @since 1.0.0
 * @category utils
 */
exports.withScheduler = withScheduler;
const withSchedulingPriority = core.withSchedulingPriority;
// ---------------------------------------------------------------------------------------
// clock
// ---------------------------------------------------------------------------------------
/**
 * Retreives the `Clock` service from the context
 *
 * @since 1.0.0
 * @category clock
 */
exports.withSchedulingPriority = withSchedulingPriority;
const clock = effect.clock;
/**
 * Retreives the `Clock` service from the context and provides it to the
 * specified effectful function.
 *
 * @since 1.0.0
 * @category clock
 */
exports.clock = clock;
const clockWith = effect.clockWith;
/**
 * @since 1.0.0
 * @category clock
 */
exports.clockWith = clockWith;
const setClock = clock => layer.scopedDiscard(fiberRuntime.fiberRefLocallyScopedWith(defaultServices.currentServices, Context.add(_clock.clockTag, clock)));
/**
 * Sets the implementation of the clock service to the specified value and
 * restores it to its original value when the scope is closed.
 *
 * @since 1.0.0
 * @category constructors
 */
exports.setClock = setClock;
const withClockScoped = fiberRuntime.withClockScoped;
/**
 * Executes the specified workflow with the specified implementation of the
 * clock service.
 *
 * @since 1.0.0
 * @category clock
 */
exports.withClockScoped = withClockScoped;
const withClock = defaultServices.withClock;
// ---------------------------------------------------------------------------------------
// delays & timeouts
// ---------------------------------------------------------------------------------------
/**
 * Returns an effect that is delayed from this effect by the specified
 * `Duration`.
 *
 * @since 1.0.0
 * @category delays & timeouts
 */
exports.withClock = withClock;
const delay = effect.delay;
/**
 * Returns an effect that suspends for the specified duration. This method is
 * asynchronous, and does not actually block the fiber executing the effect.
 *
 * @since 1.0.0
 * @category delays & timeouts
 */
exports.delay = delay;
const sleep = effect.sleep;
/**
 * Returns a new effect that executes this one and times the execution.
 *
 * @since 1.0.0
 * @category delays & timeouts
 */
exports.sleep = sleep;
const timed = effect.timed;
/**
 * A more powerful variation of `timed` that allows specifying the clock.
 *
 * @since 1.0.0
 * @category delays & timeouts
 */
exports.timed = timed;
const timedWith = effect.timedWith;
/**
 * Returns an effect that will timeout this effect, returning `None` if the
 * timeout elapses before the effect has produced a value; and returning
 * `Some` of the produced value otherwise.
 *
 * If the timeout elapses without producing a value, the running effect will
 * be safely interrupted.
 *
 * WARNING: The effect returned by this method will not itself return until
 * the underlying effect is actually interrupted. This leads to more
 * predictable resource utilization. If early return is desired, then instead
 * of using `effect.timeout(d)`, use `effect.disconnect.timeout(d)`, which
 * first disconnects the effect's interruption signal before performing the
 * timeout, resulting in earliest possible return, before an underlying effect
 * has been successfully interrupted.
 *
 * @since 1.0.0
 * @category delays & timeouts
 */
exports.timedWith = timedWith;
const timeout = circular.timeout;
/**
 * The same as `timeout`, but instead of producing a `None` in the event of
 * timeout, it will produce the specified error.
 *
 * @since 1.0.0
 * @category delays & timeouts
 */
exports.timeout = timeout;
const timeoutFail = circular.timeoutFail;
/**
 * The same as `timeout`, but instead of producing a `None` in the event of
 * timeout, it will produce the specified failure.
 *
 * @since 1.0.0
 * @category delays & timeouts
 */
exports.timeoutFail = timeoutFail;
const timeoutFailCause = circular.timeoutFailCause;
/**
 * Returns an effect that will timeout this effect, returning either the
 * default value if the timeout elapses before the effect has produced a
 * value or returning the result of applying the function `f` to the
 * success value of the effect.
 *
 * If the timeout elapses without producing a value, the running effect will
 * be safely interrupted.
 *
 * @since 1.0.0
 * @category delays & timeouts
 */
exports.timeoutFailCause = timeoutFailCause;
const timeoutTo = circular.timeoutTo;
// -------------------------------------------------------------------------------------
// config
// -------------------------------------------------------------------------------------
/**
 * Uses the default config provider to load the specified config, or fail with
 * an error of type Config.Error.
 *
 * @since 1.0.0
 * @category config
 */
exports.timeoutTo = timeoutTo;
const config = defaultServices.config;
/**
 * Retrieves the default config provider, and passes it to the specified
 * function, which may return an effect that uses the provider to perform some
 * work or compute some value.
 *
 * @since 1.0.0
 * @category config
 */
exports.config = config;
const configProviderWith = defaultServices.configProviderWith;
/**
 * Sets the current `ConfigProvider`.
 *
 * @since 1.0.0
 * @category config
 */
exports.configProviderWith = configProviderWith;
const setConfigProvider = circularLayer.setConfigProvider;
/**
 * Executes the specified workflow with the specified configuration provider.
 *
 * @since 1.0.0
 * @category config
 */
exports.setConfigProvider = setConfigProvider;
const withConfigProvider = defaultServices.withConfigProvider;
/**
 * Sets the configuration provider to the specified value and restores it to its original value
 * when the scope is closed.
 *
 * @since 1.0.0
 * @category config
 */
exports.withConfigProvider = withConfigProvider;
const withConfigProviderScoped = fiberRuntime.withConfigProviderScoped;
// -------------------------------------------------------------------------------------
// context
// -------------------------------------------------------------------------------------
/**
 * @since 1.0.0
 * @category context
 */
exports.withConfigProviderScoped = withConfigProviderScoped;
const context = core.context;
/**
 * Accesses the context of the effect.
 *
 * @since 1.0.0
 * @category context
 */
exports.context = context;
const contextWith = effect.contextWith;
/**
 * Effectually accesses the context of the effect.
 *
 * @since 1.0.0
 * @category context
 */
exports.contextWith = contextWith;
const contextWithEffect = core.contextWithEffect;
/**
 * Provides some of the context required to run this effect,
 * leaving the remainder `R0`.
 *
 * @since 1.0.0
 * @category context
 */
exports.contextWithEffect = contextWithEffect;
const mapInputContext = core.mapInputContext;
/**
 * Provides the effect with its required context, which eliminates its
 * dependency on `R`.
 *
 * @since 1.0.0
 * @category context
 */
exports.mapInputContext = mapInputContext;
const provideContext = core.provideContext;
/**
 * Splits the context into two parts, providing one part using the
 * specified layer and leaving the remainder `R0`.
 *
 * @since 1.0.0
 * @category context
 */
exports.provideContext = provideContext;
const provideSomeContext = core.provideSomeContext;
/**
 * Provides a layer to the effect, which translates it to another level.
 *
 * @since 1.0.0
 * @category context
 */
exports.provideSomeContext = provideSomeContext;
const provideLayer = layer.provideLayer;
/**
 * Provides the effect with the single service it requires. If the effect
 * requires more than one service use `provideContext` instead.
 *
 * @since 1.0.0
 * @category context
 */
exports.provideLayer = provideLayer;
const provideService = effect.provideService;
/**
 * Provides the effect with the single service it requires. If the effect
 * requires more than one service use `provideContext` instead.
 *
 * @since 1.0.0
 * @category context
 */
exports.provideService = provideService;
const provideServiceEffect = effect.provideServiceEffect;
/**
 * Splits the context into two parts, providing one part using the
 * specified layer and leaving the remainder `R0`.
 *
 * @since 1.0.0
 * @category context
 */
exports.provideServiceEffect = provideServiceEffect;
const provideSomeLayer = layer.provideSomeLayer;
/**
 * @since 1.0.0
 * @category context
 */
exports.provideSomeLayer = provideSomeLayer;
const serviceFunction = effect.serviceFunction;
/**
 * @since 1.0.0
 * @category context
 */
exports.serviceFunction = serviceFunction;
const serviceFunctionEffect = effect.serviceFunctionEffect;
/**
 * @since 1.0.0
 * @category context
 */
exports.serviceFunctionEffect = serviceFunctionEffect;
const serviceOption = tag => contextWith(_ => Context.getOption(_, tag));
/**
 * Updates the service with the required service entry.
 *
 * @since 1.0.0
 * @category context
 */
exports.serviceOption = serviceOption;
const updateService = effect.updateService;
// -------------------------------------------------------------------------------------
// do notation
// -------------------------------------------------------------------------------------
/**
 * @since 1.0.0
 * @category do notation
 */
exports.updateService = updateService;
const Do = effect.Do;
/**
 * Binds an effectful value in a `do` scope
 *
 * @since 1.0.0
 * @category do notation
 */
exports.Do = Do;
const bind = effect.bind;
/**
 * @category do notation
 * @since 1.0.0
 */
exports.bind = bind;
const bindTo = effect.bindTo;
exports.bindTo = bindTo;
const let_ = effect.bindValue;
exports.let = let_;
// -------------------------------------------------------------------------------------
// conversions
// -------------------------------------------------------------------------------------
/**
 * Returns an effect whose failure and success have been lifted into an
 * `Either`. The resulting effect cannot fail, because the failure case has
 * been exposed as part of the `Either` success case.
 *
 * This method is useful for recovering from effects that may fail.
 *
 * The error parameter of the returned `Effect` is `never`, since it is
 * guaranteed the effect does not model failure.
 *
 * @since 1.0.0
 * @category conversions
 */
const either = core.either;
/**
 * @since 1.0.0
 * @category conversions
 */
exports.either = either;
const exit = core.exit;
/**
 * @since 1.0.0
 * @category conversions
 */
exports.exit = exit;
const intoDeferred = core.intoDeferred;
/**
 * Executes this effect, skipping the error but returning optionally the
 * success.
 *
 * @since 1.0.0
 * @category conversions
 */
exports.intoDeferred = intoDeferred;
const option = effect.option;
/**
 * Converts an option on values into an option on errors.
 *
 * @since 1.0.0
 * @category conversions
 */
exports.option = option;
const some = effect.some;
/**
 * Converts an option on errors into an option on values.
 *
 * @since 1.0.0
 * @category conversions
 */
exports.some = some;
const unsome = fiberRuntime.unsome;
// -------------------------------------------------------------------------------------
// filtering & conditionals
// -------------------------------------------------------------------------------------
exports.unsome = unsome;
const if_ = core.if_;
exports.if = if_;
/**
 * Filter the specified effect with the provided function, dying with specified
 * defect if the predicate fails.
 *
 * @since 1.0.0
 * @category filtering & conditionals
 */
const filterOrDie = effect.filterOrDie;
/**
 * Filter the specified effect with the provided function, dying with specified
 * message if the predicate fails.
 *
 * @since 1.0.0
 * @category filtering & conditionals
 */
exports.filterOrDie = filterOrDie;
const filterOrDieMessage = effect.filterOrDieMessage;
/**
 * Filters the specified effect with the provided function returning the value
 * of the effect if it is successful, otherwise returns the value of `orElse`.
 *
 * @since 1.0.0
 * @category filtering & conditionals
 */
exports.filterOrDieMessage = filterOrDieMessage;
const filterOrElse = effect.filterOrElse;
/**
 * Filter the specified effect with the provided function, failing with specified
 * error if the predicate fails.
 *
 * @since 1.0.0
 * @category filtering & conditionals
 */
exports.filterOrElse = filterOrElse;
const filterOrFail = effect.filterOrFail;
/**
 * The moral equivalent of `if (!p) exp`.
 *
 * @since 1.0.0
 * @category filtering & conditionals
 */
exports.filterOrFail = filterOrFail;
const unless = effect.unless;
/**
 * The moral equivalent of `if (!p) exp` when `p` has side-effects.
 *
 * @since 1.0.0
 * @category filtering & conditionals
 */
exports.unless = unless;
const unlessEffect = effect.unlessEffect;
/**
 * The moral equivalent of `if (p) exp`.
 *
 * @since 1.0.0
 * @category filtering & conditionals
 */
exports.unlessEffect = unlessEffect;
const when = effect.when;
/**
 * @since 1.0.0
 * @category filtering & conditionals
 */
exports.when = when;
const whenEffect = core.whenEffect;
/**
 * Executes this workflow when value of the specified `FiberRef` satisfies the
 * predicate.
 *
 * @since 1.0.0
 * @category filtering & conditionals
 */
exports.whenEffect = whenEffect;
const whenFiberRef = effect.whenFiberRef;
/**
 * Executes this workflow when the value of the `Ref` satisfies the predicate.
 *
 * @since 1.0.0
 * @category filtering & conditionals
 */
exports.whenFiberRef = whenFiberRef;
const whenRef = effect.whenRef;
// -------------------------------------------------------------------------------------
// sequencing
// -------------------------------------------------------------------------------------
/**
 * This function is a pipeable operator that maps over an `Effect` value,
 * flattening the result of the mapping function into a new `Effect` value.
 *
 * @param f - The mapping function to apply to the `Effect` value.
 * This function must return another `Effect` value.
 *
 * @returns A new `Effect` value that is the result of flattening the
 * mapped `Effect` value.
 *
 * @since 1.0.0
 * @category sequencing
 */
exports.whenRef = whenRef;
const flatMap = core.flatMap;
/**
 * @since 1.0.0
 * @category sequencing
 */
exports.flatMap = flatMap;
const flatten = core.flatten;
/**
 * Returns an effect that races this effect with the specified effect,
 * returning the first successful `A` from the faster side. If one effect
 * succeeds, the other will be interrupted. If neither succeeds, then the
 * effect will fail with some error.
 *
 * Note that both effects are disconnected before being raced. This means that
 * interruption of the loser will always be performed in the background. If this
 * behavior is not desired, you can use `Effect.raceWith`, which will not
 * disconnect or interrupt losers.
 *
 * @since 1.0.0
 * @category sequencing
 */
exports.flatten = flatten;
const race = fiberRuntime.race;
/**
 * Returns an effect that races this effect with all the specified effects,
 * yielding the value of the first effect to succeed with a value. Losers of
 * the race will be interrupted immediately
 *
 * @since 1.0.0
 * @category sequencing
 */
exports.race = race;
const raceAll = fiberRuntime.raceAll;
/**
 * Returns an effect that races this effect with the specified effect,
 * returning the first successful `A` from the faster side. If one effect
 * succeeds, the other will be interrupted. If neither succeeds, then the
 * effect will fail with some error.
 *
 * @since 1.0.0
 * @category sequencing
 */
exports.raceAll = raceAll;
const raceAwait = fiberRuntime.raceAwait;
/**
 * Forks this effect and the specified effect into their own fibers, and races
 * them, calling one of two specified callbacks depending on which fiber wins
 * the race. This method does not interrupt, join, or otherwise do anything
 * with the fibers. It can be considered a low-level building block for
 * higher-level operators like `race`.
 *
 * @since 1.0.0
 * @category sequencing
 */
exports.raceAwait = raceAwait;
const raceFibersWith = fiberRuntime.raceFibersWith;
/**
 * Returns an effect that races this effect with the specified effect,
 * yielding the first result to complete, whether by success or failure. If
 * neither effect completes, then the composed effect will not complete.
 *
 * WARNING: The raced effect will safely interrupt the "loser", but will not
 * resume until the loser has been cleanly terminated. If early return is
 * desired, then instead of performing `l raceFirst r`, perform
 * `l.disconnect raceFirst r.disconnect`, which disconnects left and right
 * interrupt signal, allowing a fast return, with interruption performed
 * in the background.
 *
 * @since 1.0.0
 * @category sequencing
 */
exports.raceFibersWith = raceFibersWith;
const raceFirst = circular.raceFirst;
/**
 * Returns an effect that races this effect with the specified effect, calling
 * the specified finisher as soon as one result or the other has been computed.
 *
 * @since 1.0.0
 * @category sequencing
 */
exports.raceFirst = raceFirst;
const raceWith = fiberRuntime.raceWith;
/**
 * Summarizes a effect by computing some value before and after execution, and
 * then combining the values to produce a summary, together with the result of
 * execution.
 *
 * @since 1.0.0
 * @category sequencing
 */
exports.raceWith = raceWith;
const summarized = effect.summarized;
/**
 * @since 1.0.0
 * @category sequencing
 */
exports.summarized = summarized;
const tap = core.tap;
/**
 * Returns an effect that effectfully "peeks" at the failure or success of
 * this effect.
 *
 * @since 1.0.0
 * @category sequencing
 */
exports.tap = tap;
const tapBoth = effect.tapBoth;
/**
 * Returns an effect that effectually "peeks" at the defect of this effect.
 *
 * @since 1.0.0
 * @category sequencing
 */
exports.tapBoth = tapBoth;
const tapDefect = effect.tapDefect;
/**
 * Returns an effect that effectfully "peeks" at the failure of this effect.
 *
 * @since 1.0.0
 * @category sequencing
 */
exports.tapDefect = tapDefect;
const tapError = effect.tapError;
/**
 * Returns an effect that effectually "peeks" at the cause of the failure of
 * this effect.
 *
 * @since 1.0.0
 * @category sequencing
 */
exports.tapError = tapError;
const tapErrorCause = effect.tapErrorCause;
// -------------------------------------------------------------------------------------
// repetition / recursion
// -------------------------------------------------------------------------------------
/**
 * Repeats this effect forever (until the first error).
 *
 * @since 1.0.0
 * @category repetition / recursion
 */
exports.tapErrorCause = tapErrorCause;
const forever = effect.forever;
/**
 * Iterates with the specified effectual function. The moral equivalent of:
 *
 * ```ts
 * let s = initial
 *
 * while (cont(s)) {
 *   s = body(s)
 * }
 *
 * return s
 * ```
 *
 * @since 1.0.0
 * @category repetition / recursion
 */
exports.forever = forever;
const iterate = effect.iterate;
/**
 * Loops with the specified effectual function, collecting the results into a
 * list. The moral equivalent of:
 *
 * ```ts
 * let s  = initial
 * let as = [] as readonly A[]
 *
 * while (cont(s)) {
 *   as = [body(s), ...as]
 *   s  = inc(s)
 * }
 *
 * A.reverse(as)
 * ```
 *
 * @since 1.0.0
 * @category repetition / recursion
 */
exports.iterate = iterate;
const loop = effect.loop;
/**
 * Returns a new effect that repeats this effect according to the specified
 * schedule or until the first failure. Scheduled recurrences are in addition
 * to the first execution, so that `io.repeat(Schedule.once)` yields an effect
 * that executes `io`, and then if that succeeds, executes `io` an additional
 * time.
 *
 * @since 1.0.0
 * @category repetition / recursion
 */
exports.loop = loop;
const repeat = _schedule.repeat_Effect;
/**
 * Returns a new effect that repeats this effect the specified number of times
 * or until the first failure. Repeats are in addition to the first execution,
 * so that `io.repeatN(1)` yields an effect that executes `io`, and then if
 * that succeeds, executes `io` an additional time.
 *
 * @since 1.0.0
 * @category repetition / recursion
 */
exports.repeat = repeat;
const repeatN = effect.repeatN;
/**
 * Returns a new effect that repeats this effect according to the specified
 * schedule or until the first failure, at which point, the failure value and
 * schedule output are passed to the specified handler.
 *
 * Scheduled recurrences are in addition to the first execution, so that
 * `pipe(effect, Effect.repeat(Schedule.once()))` yields an effect that executes
 * `effect`, and then if that succeeds, executes `effect` an additional time.
 *
 * @since 1.0.0
 * @category repetition / recursion
 */
exports.repeatN = repeatN;
const repeatOrElse = _schedule.repeatOrElse_Effect;
/**
 * Repeats this effect until its value satisfies the specified predicate or
 * until the first failure.
 *
 * @since 1.0.0
 * @category repetition / recursion
 */
exports.repeatOrElse = repeatOrElse;
const repeatUntil = _schedule.repeatUntil_Effect;
/**
 * Repeats this effect until its value satisfies the specified effectful
 * predicate or until the first failure.
 *
 * @since 1.0.0
 * @category repetition / recursion
 */
exports.repeatUntil = repeatUntil;
const repeatUntilEffect = _schedule.repeatUntilEffect_Effect;
/**
 * Repeats this effect while its value satisfies the specified effectful
 * predicate or until the first failure.
 *
 * @since 1.0.0
 * @category repetition / recursion
 */
exports.repeatUntilEffect = repeatUntilEffect;
const repeatWhile = _schedule.repeatWhile_Effect;
/**
 * Repeats this effect while its value satisfies the specified effectful
 * predicate or until the first failure.
 *
 * @since 1.0.0
 * @category repetition / recursion
 */
exports.repeatWhile = repeatWhile;
const repeatWhileEffect = _schedule.repeatWhileEffect_Effect;
/**
 * Runs this effect according to the specified schedule.
 *
 * See `scheduleFrom` for a variant that allows the schedule's decision to
 * depend on the result of this effect.
 *
 * @since 1.0.0
 * @category repetition / recursion
 */
exports.repeatWhileEffect = repeatWhileEffect;
const schedule = _schedule.schedule_Effect;
/**
 * Runs this effect according to the specified schedule in a new fiber
 * attached to the current scope.
 *
 * @since 1.0.0
 * @category repetition / recursion
 */
exports.schedule = schedule;
const scheduleForked = circular.scheduleForked;
/**
 * Runs this effect according to the specified schedule starting from the
 * specified input value.
 *
 * @since 1.0.0
 * @category repetition / recursion
 */
exports.scheduleForked = scheduleForked;
const scheduleFrom = _schedule.scheduleFrom_Effect;
/**
 * @since 1.0.0
 * @category repetition / recursion
 */
exports.scheduleFrom = scheduleFrom;
const whileLoop = core.whileLoop;
// -------------------------------------------------------------------------------------
// fiber refs
// -------------------------------------------------------------------------------------
/**
 * Returns a collection of all `FiberRef` values for the fiber running this
 * effect.
 *
 * @since 1.0.0
 * @category fiber refs
 */
exports.whileLoop = whileLoop;
const getFiberRefs = effect.getFiberRefs;
/**
 * Inherits values from all `FiberRef` instances into current fiber.
 *
 * @since 1.0.0
 * @category fiber refs
 */
exports.getFiberRefs = getFiberRefs;
const inheritFiberRefs = effect.inheritFiberRefs;
/**
 * @since 1.0.0
 * @category fiber refs
 */
exports.inheritFiberRefs = inheritFiberRefs;
const locally = core.fiberRefLocally;
/**
 * @since 1.0.0
 * @category fiber refs
 */
exports.locally = locally;
const locallyWith = core.fiberRefLocallyWith;
/**
 * @since 1.0.0
 * @category fiber refs
 */
exports.locallyWith = locallyWith;
const locallyScoped = fiberRuntime.fiberRefLocallyScoped;
/**
 * @since 1.0.0
 * @category fiber refs
 */
exports.locallyScoped = locallyScoped;
const locallyScopedWith = fiberRuntime.fiberRefLocallyScopedWith;
/**
 * Applies the specified changes to the `FiberRef` values for the fiber
 * running this workflow.
 *
 * @since 1.0.0
 * @category fiber refs
 */
exports.locallyScopedWith = locallyScopedWith;
const patchFiberRefs = effect.patchFiberRefs;
/**
 * Sets the `FiberRef` values for the fiber running this effect to the values
 * in the specified collection of `FiberRef` values.
 *
 * @since 1.0.0
 * @category fiber refs
 */
exports.patchFiberRefs = patchFiberRefs;
const setFiberRefs = effect.setFiberRefs;
/**
 * Updates the `FiberRef` values for the fiber running this effect using the
 * specified function.
 *
 * @since 1.0.0
 * @category constructors
 */
exports.setFiberRefs = setFiberRefs;
const updateFiberRefs = effect.updateFiberRefs;
// -------------------------------------------------------------------------------------
// getters & folding
// -------------------------------------------------------------------------------------
/**
 * Returns `true` if this effect is a failure, `false` otherwise.
 *
 * @since 1.0.0
 * @category getters & folding
 */
exports.updateFiberRefs = updateFiberRefs;
const isFailure = effect.isFailure;
/**
 * Returns `true` if this effect is a success, `false` otherwise.
 *
 * @since 1.0.0
 * @category getters & folding
 */
exports.isFailure = isFailure;
const isSuccess = effect.isSuccess;
/**
 * Folds over the failure value or the success value to yield an effect that
 * does not fail, but succeeds with the value returned by the left or right
 * function passed to `match`.
 *
 * @since 1.0.0
 * @category getters & folding
 */
exports.isSuccess = isSuccess;
const match = effect.match;
/**
 * @since 1.0.0
 * @category getters & folding
 */
exports.match = match;
const matchCause = core.matchCause;
/**
 * @since 1.0.0
 * @category getters & folding
 */
exports.matchCause = matchCause;
const matchCauseEffect = core.matchCauseEffect;
/**
 * @since 1.0.0
 * @category getters & folding
 */
exports.matchCauseEffect = matchCauseEffect;
const matchEffect = core.matchEffect;
// -------------------------------------------------------------------------------------
// logging
// -------------------------------------------------------------------------------------
/**
 * Logs the specified message. You can optionally provide the log level
 * and a cause.
 *
 * @since 1.0.0
 * @category logging
 */
exports.matchEffect = matchEffect;
const log = effect.log;
/**
 * Logs the specified cause at the current log level.
 *
 * @since 1.0.0
 * @category logging
 */
exports.log = log;
const logCause = effect.logCause;
/**
 * Logs the specified message at the current log level.
 *
 * @since 1.0.0
 * @category logging
 */
exports.logCause = logCause;
const withLog = effect.withLog;
/**
 * Logs any Cause of failure for this effect with the given `message` and `level`.
 *
 * @since 1.0.0
 * @category logging
 */
exports.withLog = withLog;
const withLogCause = effect.withLogCause;
/**
 * Adjusts the label for the current logging span.
 *
 * @since 1.0.0
 * @category logging
 */
exports.withLogCause = withLogCause;
const withLogSpan = effect.withLogSpan;
/**
 * Annotates each log in this effect with the specified log annotation.
 *
 * @since 1.0.0
 * @category logging
 */
exports.withLogSpan = withLogSpan;
const annotateLogs = effect.annotateLogs;
/**
 * Retrieves the log annotations associated with the current scope.
 *
 * @since 1.0.0
 * @category logging
 */
exports.annotateLogs = annotateLogs;
const logAnnotations = effect.logAnnotations;
/**
 * Decides wether child fibers will report or not unhandled errors via the logger
 *
 * @since 1.0.0
 * @category logging
 */
exports.logAnnotations = logAnnotations;
const withUnhandledErrorLogLevel = core.withUnhandledErrorLogLevel;
/**
 * @since 1.0.0
 * @category logging
 */
exports.withUnhandledErrorLogLevel = withUnhandledErrorLogLevel;
const setUnhandledErrorLogLevel = level => layer.scopedDiscard(fiberRuntime.fiberRefLocallyScoped(core.currentUnhandledErrorLogLevel, level));
// -------------------------------------------------------------------------------------
// alternatives
// -------------------------------------------------------------------------------------
/**
 * Translates effect failure into death of the fiber, making all failures
 * unchecked and not a part of the type of the effect.
 *
 * @since 1.0.0
 * @category alternatives
 */
exports.setUnhandledErrorLogLevel = setUnhandledErrorLogLevel;
const orDie = core.orDie;
/**
 * Keeps none of the errors, and terminates the fiber with them, using the
 * specified function to convert the `E` into a `Throwable`.
 *
 * @since 1.0.0
 * @category alternatives
 */
exports.orDie = orDie;
const orDieWith = core.orDieWith;
/**
 * Executes this effect and returns its value, if it succeeds, but otherwise
 * executes the specified effect.
 *
 * @since 1.0.0
 * @category alternatives
 */
exports.orDieWith = orDieWith;
const orElse = core.orElse;
/**
 * Executes this effect and returns its value, if it succeeds, but otherwise
 * fails with the specified error.
 *
 * @since 1.0.0
 * @category alternatives
 */
exports.orElse = orElse;
const orElseFail = effect.orElseFail;
/**
 * Executes this effect and returns its value, if it succeeds, but
 * otherwise succeeds with the specified value.
 *
 * @since 1.0.0
 * @category alternatives
 */
exports.orElseFail = orElseFail;
const orElseSucceed = effect.orElseSucceed;
// -------------------------------------------------------------------------------------
// random
// -------------------------------------------------------------------------------------
/**
 * Retreives the `Random` service from the context.
 *
 * @since 1.0.0
 * @category random
 */
exports.orElseSucceed = orElseSucceed;
const random = effect.random;
/**
 * Retreives the `Random` service from the context and uses it to run the
 * specified workflow.
 *
 * @since 1.0.0
 * @category random
 */
exports.random = random;
const randomWith = defaultServices.randomWith;
// -------------------------------------------------------------------------------------
// runtime
// -------------------------------------------------------------------------------------
/**
 * Returns an effect that accesses the runtime, which can be used to
 * (unsafely) execute tasks. This is useful for integration with legacy code
 * that must call back into Effect code.
 *
 * @since 1.0.0
 * @category runtime
 */
exports.randomWith = randomWith;
const runtime = _runtime.runtime;
/**
 * Retrieves an effect that succeeds with the current runtime flags, which
 * govern behavior and features of the runtime system.
 *
 * @since 1.0.0
 * @category runtime
 */
exports.runtime = runtime;
const runtimeFlags = core.runtimeFlags;
/**
 * @since 1.0.0
 * @category runtime
 */
exports.runtimeFlags = runtimeFlags;
const updateRuntimeFlags = core.updateRuntimeFlags;
/**
 * @since 1.0.0
 * @category runtime
 */
exports.updateRuntimeFlags = updateRuntimeFlags;
const withRuntimeFlags = core.withRuntimeFlags;
/**
 * @since 1.0.0
 * @category runtime
 */
exports.withRuntimeFlags = withRuntimeFlags;
const withRuntimeFlagsScoped = fiberRuntime.withRuntimeFlagsScoped;
// -------------------------------------------------------------------------------------
// metrics
// -------------------------------------------------------------------------------------
/**
 * Tags each metric in this effect with the specific tag.
 *
 * @since 1.0.0
 * @category metrics
 */
exports.withRuntimeFlagsScoped = withRuntimeFlagsScoped;
const tagMetrics = effect.tagMetrics;
/**
 * Tags each metric in this effect with the specific tag.
 *
 * @since 1.0.0
 * @category metrics
 */
exports.tagMetrics = tagMetrics;
const labelMetrics = effect.labelMetrics;
/**
 * Tags each metric in this effect with the specific tag.
 *
 * @since 1.0.0
 * @category metrics
 */
exports.labelMetrics = labelMetrics;
const labelMetricsSet = effect.labelMetricsSet;
/**
 * Tags each metric in a scope with a the specific tag.
 *
 * @since 1.0.0
 * @category metrics
 */
exports.labelMetricsSet = labelMetricsSet;
const tagMetricsScoped = fiberRuntime.tagMetricsScoped;
/**
 * Tags each metric in a scope with a the specific tag.
 *
 * @since 1.0.0
 * @category metrics
 */
exports.tagMetricsScoped = tagMetricsScoped;
const labelMetricsScoped = fiberRuntime.labelMetricsScoped;
/**
 * Tags each metric in a scope with a the specific tag.
 *
 * @since 1.0.0
 * @category metrics
 */
exports.labelMetricsScoped = labelMetricsScoped;
const labelMetricsScopedSet = fiberRuntime.labelMetricsScopedSet;
/**
 * Retrieves the metric labels associated with the current scope.
 *
 * @since 1.0.0
 * @category metrics
 */
exports.labelMetricsScopedSet = labelMetricsScopedSet;
const metricLabels = core.metricLabels;
/**
 * @since 1.0.0
 * @category metrics
 */
exports.metricLabels = metricLabels;
const withMetric = effect.withMetric;
// -------------------------------------------------------------------------------------
// unify
// -------------------------------------------------------------------------------------
/**
 * Used to unify functions that would otherwise return `Effect<A, B, C> | Effect<D, E, F>`
 *
 * @category unify
 * @since 1.0.0
 */
exports.withMetric = withMetric;
const unifiedFn = core.unified;
/**
 * Used to unify effects that would otherwise be `Effect<A, B, C> | Effect<D, E, F>`
 *
 * @category unify
 * @since 1.0.0
 */
exports.unifiedFn = unifiedFn;
const unified = _Function.identity;
/**
 * Unsafely creates a new Semaphore
 *
 * @since 1.0.0
 * @category semaphore
 */
exports.unified = unified;
const unsafeMakeSemaphore = circular.unsafeMakeSemaphore;
/**
 * Creates a new Semaphore
 *
 * @since 1.0.0
 * @category semaphore
 */
exports.unsafeMakeSemaphore = unsafeMakeSemaphore;
const makeSemaphore = circular.makeSemaphore;
// -------------------------------------------------------------------------------------
// execution
// -------------------------------------------------------------------------------------
/**
 * @since 1.0.0
 * @category execution
 */
exports.makeSemaphore = makeSemaphore;
const runFork = _runtime.unsafeForkEffect;
/**
 * @since 1.0.0
 * @category execution
 */
exports.runFork = runFork;
const runCallback = _runtime.unsafeRunEffect;
/**
 * Runs an `Effect` workflow, returning a `Promise` which resolves with the
 * result of the workflow or rejects with an error.
 *
 * @since 1.0.0
 * @category execution
 */
exports.runCallback = runCallback;
const runPromise = _runtime.unsafeRunPromiseEffect;
/**
 * Runs an `Effect` workflow, returning a `Promise` which resolves with the
 * `Exit` value of the workflow.
 *
 * @since 1.0.0
 * @category execution
 */
exports.runPromise = runPromise;
const runPromiseExit = _runtime.unsafeRunPromiseExitEffect;
/**
 * @since 1.0.0
 * @category execution
 */
exports.runPromiseExit = runPromiseExit;
const runSync = _runtime.unsafeRunSyncEffect;
/**
 * @since 1.0.0
 * @category execution
 */
exports.runSync = runSync;
const runSyncExit = _runtime.unsafeRunSyncExitEffect;
// -------------------------------------------------------------------------------------
// zipping
// -------------------------------------------------------------------------------------
/**
 * Sequentially zips the this result with the specified result. Combines both
 * `Cause`s when both effects fail.
 *
 * @since 1.0.0
 * @category zipping
 */
exports.runSyncExit = runSyncExit;
const validate = fiberRuntime.validate;
/**
 * Sequentially zips this effect with the specified effect using the specified
 * combiner function. Combines the causes in case both effect fail.
 *
 * @since 1.0.0
 * @category zipping
 */
exports.validate = validate;
const validateWith = fiberRuntime.validateWith;
/**
 * @since 1.0.0
 * @category zipping
 */
exports.validateWith = validateWith;
const zip = fiberRuntime.zipOptions;
/**
 * @since 1.0.0
 * @category zipping
 */
exports.zip = zip;
const zipLeft = fiberRuntime.zipLeftOptions;
/**
 * @since 1.0.0
 * @category zipping
 */
exports.zipLeft = zipLeft;
const zipRight = fiberRuntime.zipRightOptions;
/**
 * @since 1.0.0
 * @category zipping
 */
exports.zipRight = zipRight;
const zipWith = fiberRuntime.zipWithOptions;
// -------------------------------------------------------------------------------------
// requests & batching
// -------------------------------------------------------------------------------------
/**
 * @category requests & batching
 * @since 1.0.0
 */
exports.zipWith = zipWith;
const blocked = core.blocked;
/**
 * @category requests & batching
 * @since 1.0.0
 */
exports.blocked = blocked;
const runRequestBlock = core.runRequestBlock;
/**
 * @category requests & batching
 * @since 1.0.0
 */
exports.runRequestBlock = runRequestBlock;
const step = core.step;
/**
 * @category requests & batching
 * @since 1.0.0
 */
exports.step = step;
const flatMapStep = core.flatMapStep;
/**
 * @since 1.0.0
 * @category requests & batching
 */
exports.flatMapStep = flatMapStep;
const request = query.fromRequest;
/**
 * @since 1.0.0
 * @category requests & batching
 */
exports.request = request;
const cacheRequestResult = query.cacheRequest;
/**
 * @since 1.0.0
 * @category requests & batching
 */
exports.cacheRequestResult = cacheRequestResult;
const withRequestBatching = core.withRequestBatching;
/**
 * @since 1.0.0
 * @category requests & batching
 */
exports.withRequestBatching = withRequestBatching;
const setRequestBatching = requestBatching => layer.scopedDiscard(fiberRuntime.fiberRefLocallyScoped(core.currentRequestBatching, requestBatching));
/**
 * @since 1.0.0
 * @category requests & batching
 */
exports.setRequestBatching = setRequestBatching;
const setRequestCaching = requestCaching => layer.scopedDiscard(fiberRuntime.fiberRefLocallyScoped(query.currentCacheEnabled, requestCaching));
/**
 * @since 1.0.0
 * @category requests & batching
 */
exports.setRequestCaching = setRequestCaching;
const setRequestCache = cache => layer.scopedDiscard(core.isEffect(cache) ? core.flatMap(cache, x => fiberRuntime.fiberRefLocallyScoped(query.currentCache, x)) : fiberRuntime.fiberRefLocallyScoped(query.currentCache, cache));
/**
 * @since 1.0.0
 * @category requests & batching
 */
exports.setRequestCache = setRequestCache;
const withRequestCaching = query.withRequestCaching;
/**
 * @since 1.0.0
 * @category requests & batching
 */
exports.withRequestCaching = withRequestCaching;
const withRequestCache = query.withRequestCache;
// -------------------------------------------------------------------------------------
// tracing
// -------------------------------------------------------------------------------------
/**
 * Create a Layer that sets the current Tracer
 *
 * @since 1.0.0
 * @category tracing
 */
exports.withRequestCache = withRequestCache;
const setTracer = circularLayer.setTracer;
/**
 * @since 1.0.0
 * @category tracing
 */
exports.setTracer = setTracer;
const tracer = effect.tracer;
/**
 * @since 1.0.0
 * @category tracing
 */
exports.tracer = tracer;
const tracerWith = defaultServices.tracerWith;
/**
 * @since 1.0.0
 * @category tracing
 */
exports.tracerWith = tracerWith;
const withTracer = defaultServices.withTracer;
/**
 * @since 1.0.0
 * @category tracing
 */
exports.withTracer = withTracer;
const withTracerScoped = fiberRuntime.withTracerScoped;
/**
 * Adds an annotation to each span in this effect.
 *
 * @since 1.0.0
 * @category tracing
 */
exports.withTracerScoped = withTracerScoped;
const annotateSpans = effect.annotateSpans;
/**
 * @since 1.0.0
 * @category tracing
 */
exports.annotateSpans = annotateSpans;
const currentSpan = effect.currentSpan;
/**
 * @since 1.0.0
 * @category tracing
 */
exports.currentSpan = currentSpan;
const spanAnnotations = effect.spanAnnotations;
/**
 * Create a new span for tracing, and automatically close it when the effect
 * completes.
 *
 * The span is not added to the current span stack, so no child spans will be
 * created for it.
 *
 * @since 1.0.0
 * @category tracing
 */
exports.spanAnnotations = spanAnnotations;
const useSpan = effect.useSpan;
/**
 * Wraps the effect with a new span for tracing.
 *
 * @since 1.0.0
 * @category tracing
 */
exports.useSpan = useSpan;
const withSpan = effect.withSpan;
exports.withSpan = withSpan;
//# sourceMappingURL=Effect.js.map