"use strict";Object.defineProperty(exports, "__esModule", {value: true});


var _chunkDLEEPDK7js = require('./chunk-DLEEPDK7.js');


var _chunkS2Z5L3RBjs = require('./chunk-S2Z5L3RB.js');


var _chunkS3T27X3Ujs = require('./chunk-S3T27X3U.js');






var _chunk7K74W2G3js = require('./chunk-7K74W2G3.js');





var _chunkQ2LZCTWPjs = require('./chunk-Q2LZCTWP.js');



var _chunkEBISTSVAjs = require('./chunk-EBISTSVA.js');









var _chunkOTKMOSH2js = require('./chunk-OTKMOSH2.js');




var _chunkSQA7G4TEjs = require('./chunk-SQA7G4TE.js');


var _chunk6C3VEZWHjs = require('./chunk-6C3VEZWH.js');

// src/Task.ts
var Task_exports = {};
_chunk6C3VEZWHjs.__export.call(void 0, Task_exports, {
  ApT: () => ApT,
  ApplicativePar: () => ApplicativePar,
  ApplicativeSeq: () => ApplicativeSeq,
  ApplyPar: () => ApplyPar,
  ApplySeq: () => ApplySeq,
  Chain: () => Chain,
  ChainRec: () => ChainRec,
  Do: () => Do,
  FromIO: () => FromIO,
  FromTask: () => FromTask,
  Functor: () => Functor,
  Monad: () => Monad,
  MonadIO: () => MonadIO,
  MonadTask: () => MonadTask,
  Pointed: () => Pointed,
  URI: () => URI,
  ap: () => ap,
  apFirst: () => apFirst2,
  apS: () => apS2,
  apSecond: () => apSecond2,
  as: () => as2,
  asUnit: () => asUnit2,
  bind: () => bind2,
  bindTo: () => bindTo2,
  chain: () => chain,
  chainFirst: () => chainFirst,
  chainFirstIOK: () => chainFirstIOK,
  chainIOK: () => chainIOK,
  chainRec: () => chainRec,
  delay: () => delay,
  do: () => do_2,
  flap: () => flap2,
  flatMap: () => flatMap,
  flatMapIO: () => flatMapIO2,
  flatten: () => flatten,
  fromIO: () => fromIO,
  fromIOK: () => fromIOK2,
  fromTask: () => fromTask,
  getMonoid: () => getMonoid,
  getRaceMonoid: () => getRaceMonoid,
  getSemigroup: () => getSemigroup,
  let: () => let_2,
  map: () => map,
  never: () => never,
  of: () => of,
  sequenceArray: () => sequenceArray,
  sequenceSeqArray: () => sequenceSeqArray,
  tap: () => tap2,
  tapIO: () => tapIO2,
  task: () => task,
  taskSeq: () => taskSeq,
  traverseArray: () => traverseArray,
  traverseArrayWithIndex: () => traverseArrayWithIndex,
  traverseReadonlyArrayWithIndex: () => traverseReadonlyArrayWithIndex,
  traverseReadonlyArrayWithIndexSeq: () => traverseReadonlyArrayWithIndexSeq,
  traverseReadonlyNonEmptyArrayWithIndex: () => traverseReadonlyNonEmptyArrayWithIndex,
  traverseReadonlyNonEmptyArrayWithIndexSeq: () => traverseReadonlyNonEmptyArrayWithIndexSeq,
  traverseSeqArray: () => traverseSeqArray,
  traverseSeqArrayWithIndex: () => traverseSeqArrayWithIndex
});
var fromIO = (ma) => () => Promise.resolve().then(ma);
function delay(millis) {
  return (ma) => () => new Promise((resolve) => {
    setTimeout(() => {
      Promise.resolve().then(ma).then(resolve);
    }, millis);
  });
}
var _map = (fa, f) => _chunkSQA7G4TEjs.pipe.call(void 0, fa, map(f));
var _apPar = (fab, fa) => _chunkSQA7G4TEjs.pipe.call(void 0, fab, ap(fa));
var _apSeq = (fab, fa) => flatMap(fab, (f) => _chunkSQA7G4TEjs.pipe.call(void 0, fa, map(f)));
var map = (f) => (fa) => () => Promise.resolve().then(fa).then(f);
var ap = (fa) => (fab) => () => Promise.all([Promise.resolve().then(fab), Promise.resolve().then(fa)]).then(([f, a]) => f(a));
var of = (a) => () => Promise.resolve(a);
var flatMap = /* @__PURE__ */ _chunkSQA7G4TEjs.dual.call(void 0, 
  2,
  (ma, f) => () => Promise.resolve().then(ma).then((a) => f(a)())
);
var flatten = /* @__PURE__ */ flatMap(_chunkSQA7G4TEjs.identity);
var URI = "Task";
function getRaceMonoid() {
  return {
    concat: (x, y) => () => Promise.race([Promise.resolve().then(x), Promise.resolve().then(y)]),
    empty: never
  };
}
var Functor = {
  URI,
  map: _map
};
var as2 = _chunkSQA7G4TEjs.dual.call(void 0, 2, _chunk7K74W2G3js.as.call(void 0, Functor));
var asUnit2 = _chunk7K74W2G3js.asUnit.call(void 0, Functor);
var flap2 = /* @__PURE__ */ _chunk7K74W2G3js.flap.call(void 0, Functor);
var Pointed = {
  URI,
  of
};
var ApplyPar = {
  URI,
  map: _map,
  ap: _apPar
};
var apFirst2 = /* @__PURE__ */ _chunkQ2LZCTWPjs.apFirst.call(void 0, ApplyPar);
var apSecond2 = /* @__PURE__ */ _chunkQ2LZCTWPjs.apSecond.call(void 0, ApplyPar);
var ApplicativePar = {
  URI,
  map: _map,
  ap: _apPar,
  of
};
var ApplySeq = {
  URI,
  map: _map,
  ap: _apSeq
};
var ApplicativeSeq = {
  URI,
  map: _map,
  ap: _apSeq,
  of
};
var Chain = {
  URI,
  map: _map,
  ap: _apPar,
  chain: flatMap
};
var chainRec = (a, f) => async () => {
  let current = await f(a)();
  while (_chunkOTKMOSH2js.isLeft.call(void 0, current)) {
    current = await f(current.left)();
  }
  return current.right;
};
var ChainRec = {
  ...Chain,
  chainRec
};
var Monad = {
  URI,
  map: _map,
  of,
  ap: _apPar,
  chain: flatMap
};
var MonadIO = {
  URI,
  map: _map,
  of,
  ap: _apPar,
  chain: flatMap,
  fromIO
};
var fromTask = _chunkSQA7G4TEjs.identity;
var MonadTask = {
  URI,
  map: _map,
  of,
  ap: _apPar,
  chain: flatMap,
  fromIO,
  fromTask
};
var FromIO = {
  URI,
  fromIO
};
var _FlatMap = {
  flatMap
};
var _FromIO = {
  fromIO: FromIO.fromIO
};
var flatMapIO2 = _chunkOTKMOSH2js.flatMapIO.call(void 0, _FromIO, _FlatMap);
var tap2 = /* @__PURE__ */ _chunkSQA7G4TEjs.dual.call(void 0, 2, _chunkEBISTSVAjs.tap.call(void 0, Chain));
var tapIO2 = /* @__PURE__ */ _chunkSQA7G4TEjs.dual.call(void 0, 2, _chunkDLEEPDK7js.tapIO.call(void 0, FromIO, Chain));
var fromIOK2 = /* @__PURE__ */ _chunkDLEEPDK7js.fromIOK.call(void 0, FromIO);
var chainIOK = flatMapIO2;
var chainFirstIOK = tapIO2;
var FromTask = {
  URI,
  fromIO,
  fromTask
};
var never = () => new Promise((_) => void 0);
var Do = /* @__PURE__ */ of(_chunkOTKMOSH2js.emptyRecord);
var bindTo2 = /* @__PURE__ */ _chunk7K74W2G3js.bindTo.call(void 0, Functor);
var let_2 = /* @__PURE__ */ _chunk7K74W2G3js.let_.call(void 0, Functor);
var bind2 = /* @__PURE__ */ _chunkEBISTSVAjs.bind.call(void 0, Chain);
var do_2 = _chunkS2Z5L3RBjs.do_3.call(void 0, Pointed, ChainRec);
var apS2 = /* @__PURE__ */ _chunkQ2LZCTWPjs.apS.call(void 0, ApplyPar);
var ApT = /* @__PURE__ */ of(_chunkOTKMOSH2js.emptyReadonlyArray);
var traverseReadonlyNonEmptyArrayWithIndex = (f) => (as3) => () => Promise.all(as3.map((a, i) => Promise.resolve().then(() => f(i, a)())));
var traverseReadonlyArrayWithIndex = (f) => {
  const g = traverseReadonlyNonEmptyArrayWithIndex(f);
  return (as3) => _chunkOTKMOSH2js.isNonEmpty.call(void 0, as3) ? g(as3) : ApT;
};
var traverseReadonlyNonEmptyArrayWithIndexSeq = (f) => (as3) => () => _chunkOTKMOSH2js.tail.call(void 0, as3).reduce(
  (acc, a, i) => acc.then(
    (bs) => Promise.resolve().then(f(i + 1, a)).then((b) => {
      bs.push(b);
      return bs;
    })
  ),
  Promise.resolve().then(f(0, _chunkOTKMOSH2js.head.call(void 0, as3))).then(_chunkOTKMOSH2js.singleton)
);
var traverseReadonlyArrayWithIndexSeq = (f) => {
  const g = traverseReadonlyNonEmptyArrayWithIndexSeq(f);
  return (as3) => _chunkOTKMOSH2js.isNonEmpty.call(void 0, as3) ? g(as3) : ApT;
};
var traverseArrayWithIndex = traverseReadonlyArrayWithIndex;
var traverseArray = (f) => traverseReadonlyArrayWithIndex((_, a) => f(a));
var sequenceArray = /* @__PURE__ */ traverseArray(_chunkSQA7G4TEjs.identity);
var traverseSeqArrayWithIndex = traverseReadonlyArrayWithIndexSeq;
var traverseSeqArray = (f) => traverseReadonlyArrayWithIndexSeq((_, a) => f(a));
var sequenceSeqArray = /* @__PURE__ */ traverseSeqArray(_chunkSQA7G4TEjs.identity);
var chain = flatMap;
var chainFirst = tap2;
var task = {
  URI,
  map: _map,
  of,
  ap: _apPar,
  chain: flatMap,
  fromIO,
  fromTask
};
var taskSeq = {
  URI,
  map: _map,
  of,
  ap: _apSeq,
  chain: flatMap,
  fromIO,
  fromTask
};
var getSemigroup = /* @__PURE__ */ _chunkQ2LZCTWPjs.getApplySemigroup.call(void 0, ApplySeq);
var getMonoid = /* @__PURE__ */ _chunkS3T27X3Ujs.getApplicativeMonoid.call(void 0, ApplicativeSeq);






























































exports.fromIO = fromIO; exports.delay = delay; exports.map = map; exports.ap = ap; exports.of = of; exports.flatMap = flatMap; exports.flatten = flatten; exports.URI = URI; exports.getRaceMonoid = getRaceMonoid; exports.Functor = Functor; exports.as = as2; exports.asUnit = asUnit2; exports.flap = flap2; exports.Pointed = Pointed; exports.ApplyPar = ApplyPar; exports.apFirst = apFirst2; exports.apSecond = apSecond2; exports.ApplicativePar = ApplicativePar; exports.ApplySeq = ApplySeq; exports.ApplicativeSeq = ApplicativeSeq; exports.Chain = Chain; exports.chainRec = chainRec; exports.ChainRec = ChainRec; exports.Monad = Monad; exports.MonadIO = MonadIO; exports.fromTask = fromTask; exports.MonadTask = MonadTask; exports.FromIO = FromIO; exports.flatMapIO = flatMapIO2; exports.tap = tap2; exports.tapIO = tapIO2; exports.fromIOK = fromIOK2; exports.chainIOK = chainIOK; exports.chainFirstIOK = chainFirstIOK; exports.FromTask = FromTask; exports.never = never; exports.Do = Do; exports.bindTo = bindTo2; exports.let_ = let_2; exports.bind = bind2; exports.do_ = do_2; exports.apS = apS2; exports.ApT = ApT; exports.traverseReadonlyNonEmptyArrayWithIndex = traverseReadonlyNonEmptyArrayWithIndex; exports.traverseReadonlyArrayWithIndex = traverseReadonlyArrayWithIndex; exports.traverseReadonlyNonEmptyArrayWithIndexSeq = traverseReadonlyNonEmptyArrayWithIndexSeq; exports.traverseReadonlyArrayWithIndexSeq = traverseReadonlyArrayWithIndexSeq; exports.traverseArrayWithIndex = traverseArrayWithIndex; exports.traverseArray = traverseArray; exports.sequenceArray = sequenceArray; exports.traverseSeqArrayWithIndex = traverseSeqArrayWithIndex; exports.traverseSeqArray = traverseSeqArray; exports.sequenceSeqArray = sequenceSeqArray; exports.chain = chain; exports.chainFirst = chainFirst; exports.task = task; exports.taskSeq = taskSeq; exports.getSemigroup = getSemigroup; exports.getMonoid = getMonoid; exports.Task_exports = Task_exports;
