"use strict"
Object.defineProperty(exports, "__esModule", { value: true })
exports.bracketFiber = exports.bracketFiber_ = void 0
const bracket_1 = require("./bracket")
const core_1 = require("./core")
const core_scope_1 = require("./core-scope")
const fiberId_1 = require("./fiberId")
/**
 * Fork the effect into a separate fiber wrapping it in a bracket and returining the
 * `use` handle. Acquisition will fork and release will interrupt the fiber
 */
function bracketFiber_(effect, use, __trace) {
  return (0, bracket_1.bracket_)(
    (0, core_scope_1.forkDaemon)(effect),
    (f) => (0, core_1.chain_)(fiberId_1.fiberId, f.interruptAs),
    use,
    __trace
  )
}
exports.bracketFiber_ = bracketFiber_
/**
 * Fork the effect into a separate fiber wrapping it in a bracket.
 * Acquisition will fork and release will interrupt the fiber.
 *
 * @dataFirst bracketFiber_
 */
function bracketFiber(use, __trace) {
  return (effect) => bracketFiber_(effect, use, __trace)
}
exports.bracketFiber = bracketFiber
//# sourceMappingURL=bracketFiber.js.map
