"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.FiberState = exports.Executing = exports.Done = void 0;
exports.done = done;
exports.executing = executing;
exports.initial = initial;
exports.interruptorsCause = interruptorsCause;
exports.isInterrupting = isInterrupting;
exports.unifyFiberState = unifyFiberState;

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

var tsplus_module_2 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/core/io/Fiber/status"));

var tsplus_module_3 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@tsplus/stdlib/collections/HashSet/empty"));

var tsplus_module_4 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@tsplus/stdlib/collections/List/empty"));

var tsplus_module_5 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/core/io/Fiber/_internal/cancelerState"));

var tsplus_module_6 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@tsplus/stdlib/collections/HashSet/reduce"));

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 FiberState = {};
/**
 * @tsplus unify ets/Fiber/State
 */

exports.FiberState = FiberState;

function unifyFiberState(self) {
  return self;
}

class Executing {
  constructor(status, observers, suppressed, interruptors, asyncCanceler, mailbox) {
    this.status = status;
    this.observers = observers;
    this.suppressed = suppressed;
    this.interruptors = interruptors;
    this.asyncCanceler = asyncCanceler;
    this.mailbox = mailbox;
    this._tag = "Executing";
  }

}

exports.Executing = Executing;

class Done {
  constructor(value) {
    this.value = value;
    this._tag = "Done";
    this.suppressed = tsplus_module_1.empty;
    this.status = tsplus_module_2.statusDone;
    this.interruptors = tsplus_module_3.empty();
  }

}
/**
 * @tsplus static ets/Fiber/State/Ops Executing
 */


exports.Done = Done;

function executing(status, observers, suppressed, interruptors, asyncCanceler, mailbox) {
  return new Executing(status, observers, suppressed, interruptors, asyncCanceler, mailbox);
}
/**
 * @tsplus static ets/Fiber/State/Ops Done
 */


function done(value) {
  return new Done(value);
}
/**
 * @tsplus static ets/Fiber/State/Ops initial
 */


function initial() {
  return new Executing(tsplus_module_2.statusRunning(false), tsplus_module_4.empty(), tsplus_module_1.empty, tsplus_module_3.empty(), tsplus_module_5.empty, undefined);
}
/**
 * @tsplus getter ets/Fiber/State isInterrupting
 */


function isInterrupting(self) {
  return tsplus_module_2.isInterrupting(self.status);
}
/**
 * @tsplus getter ets/Fiber/State interruptorsCause
 */


function interruptorsCause(state) {
  return tsplus_module_6.reduce_(state.interruptors, tsplus_module_1.empty, (acc, interruptor) => tsplus_module_1.combineSeq(acc, tsplus_module_1.interrupt(interruptor)));
}
//# sourceMappingURL=fiberState.js.map