"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.makeWith = void 0;

var tsplus_module_1 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/core/io/Scope/operations/addFinalizerExit"));

var tsplus_module_2 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/core/io/Scope/operations/close"));

var tsplus_module_3 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/core/io/Scope/ReleaseMap/operations/add"));

var tsplus_module_4 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/core/io/ExecutionStrategy/definition"));

var tsplus_module_5 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/core/io/Effect/operations/do"));

var tsplus_module_6 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/core/io/Effect/operations/tap"));

var tsplus_module_7 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/core/io/Effect/operations/map"));

var tsplus_module_8 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/core/io/Effect/operations/interruption"));

var tsplus_module_9 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/core/io/Effect/operations/unit"));

var tsplus_module_10 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/core/io/Scope/ReleaseMap/operations/releaseAll"));

var tsplus_module_11 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/core/io/Effect/operations/suspendSucceed"));

var tsplus_module_12 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/core/io/Scope/ReleaseMap/operations/make"));

var _CloseableScopeInternal = /*#__PURE__*/require("@effect/core/io/Scope/operations/_internal/CloseableScopeInternal");

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; }

const fileName_1 = "(@effect/core) _src/io/Scope/operations/makeWith.ts";
const makeWith = makeWith_1;
exports.makeWith = makeWith;

/**
 * Makes a scope. Finalizers added to this scope will be run according to the
 * specified `ExecutionStrategy`.
 *
 * @tsplus static ets/Scope/Ops makeWith
 */
function makeWith_1(executionStrategy) {
  return tsplus_module_7.map_(tsplus_module_12.make, releaseMap => new _CloseableScopeInternal.CloseableScopeInternal(tsplus_module_8.uninterruptible(tsplus_module_7.map_(tsplus_module_6.tap_(tsplus_module_5.bind_(tsplus_module_5.bind_(tsplus_module_5.Do(), "scope", () => makeWith_1(() => tsplus_module_4.sequential), fileName_1 + ":16:16"), "finalizer", ({
    scope
  }) => tsplus_module_3.add_(releaseMap, exit => tsplus_module_2.close_(scope, () => exit), fileName_1 + ":17:59"), fileName_1 + ":17:16"), ({
    finalizer,
    scope
  }) => tsplus_module_1.addFinalizerExit_(scope, finalizer), fileName_1 + ":18:15"), ({
    scope
  }) => scope, fileName_1 + ":19:15"), fileName_1 + ":20:27"), finalizer => tsplus_module_9.unit_(tsplus_module_3.add_(releaseMap, finalizer, fileName_1 + ":21:38"), fileName_1 + ":21:54"), exit => tsplus_module_11.suspendSucceed(() => tsplus_module_9.unit_(tsplus_module_10.releaseAll_(releaseMap, exit(), executionStrategy(), fileName_1 + ":24:34"), fileName_1 + ":24:68"), fileName_1 + ":23:32")), fileName_1 + ":12:29");
}
//# sourceMappingURL=makeWith.js.map