"use strict";

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

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

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

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/Supervisor/operations/and.ts";

/**
 * Returns a new supervisor that performs the function of this supervisor, and
 * the function of the specified supervisor, producing a tuple of the outputs
 * produced by both supervisors.
 *
 * @tsplus operator ets/Supervisor +
 * @tsplus fluent ets/Supervisor and
 */
function and_(self, that) {
  return new tsplus_module_1.Supervisor(tsplus_module_2.zip_(self.value, () => that.value, fileName_1 + ":14:19"), (environment, effect, parent, fiber) => {
    try {
      self.unsafeOnStart(environment, effect, parent, fiber);
    } finally {
      that.unsafeOnStart(environment, effect, parent, fiber);
    }
  }, (exit, fiber) => {
    self.unsafeOnEnd(exit, fiber);
    that.unsafeOnEnd(exit, fiber);
  }, (fiber, effect) => {
    self.unsafeOnEffect(fiber, effect);
    that.unsafeOnEffect(fiber, effect);
  }, fiber => {
    self.unsafeOnSuspend(fiber);
    that.unsafeOnSuspend(fiber);
  }, fiber => {
    self.unsafeOnSuspend(fiber);
    that.unsafeOnSuspend(fiber);
  });
}
/**
 * Returns a new supervisor that performs the function of this supervisor, and
 * the function of the specified supervisor, producing a tuple of the outputs
 * produced by both supervisors.
 */


const and = that => self => and_(self, that);

exports.and = and;
//# sourceMappingURL=and.js.map