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











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


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


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



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


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

// src/EitherT.ts
var EitherT_exports = {};
_chunk6C3VEZWHjs.__export.call(void 0, EitherT_exports, {
  alt: () => alt,
  altValidation: () => altValidation,
  ap: () => ap2,
  bimap: () => bimap2,
  chain: () => chain,
  chainNullableK: () => chainNullableK,
  flatMap: () => flatMap,
  fromNullable: () => fromNullable2,
  fromNullableK: () => fromNullableK,
  getEitherM: () => getEitherM,
  getOrElse: () => getOrElse,
  left: () => left2,
  leftF: () => leftF,
  map: () => map2,
  mapBoth: () => mapBoth,
  mapError: () => mapError,
  mapLeft: () => mapLeft2,
  match: () => match2,
  matchE: () => matchE,
  orElse: () => orElse,
  orElseFirst: () => orElseFirst,
  orLeft: () => orLeft,
  right: () => right2,
  rightF: () => rightF,
  swap: () => swap2,
  tapError: () => tapError,
  toUnion: () => toUnion2
});
function right2(F) {
  return _chunkSQA7G4TEjs.flow.call(void 0, _chunkS2Z5L3RBjs.right, F.of);
}
function left2(F) {
  return _chunkSQA7G4TEjs.flow.call(void 0, _chunkS2Z5L3RBjs.left, F.of);
}
function rightF(F) {
  return (fa) => F.map(fa, _chunkS2Z5L3RBjs.right);
}
function leftF(F) {
  return (fe) => F.map(fe, _chunkS2Z5L3RBjs.left);
}
function fromNullable2(F) {
  return (e) => _chunkSQA7G4TEjs.flow.call(void 0, _chunkS2Z5L3RBjs.fromNullable.call(void 0, e), F.of);
}
function fromNullableK(F) {
  const fromNullableF = fromNullable2(F);
  return (e) => {
    const fromNullableFE = fromNullableF(e);
    return (f) => _chunkSQA7G4TEjs.flow.call(void 0, f, fromNullableFE);
  };
}
function chainNullableK(M) {
  const chainM = chain(M);
  const fromNullableKM = fromNullableK(M);
  return (e) => {
    const fromNullableKMe = fromNullableKM(e);
    return (f) => chainM(fromNullableKMe(f));
  };
}
function map2(F) {
  return _chunk7K74W2G3js.map.call(void 0, F, _chunkS2Z5L3RBjs.Functor);
}
function ap2(F) {
  return _chunkQ2LZCTWPjs.ap.call(void 0, F, _chunkS2Z5L3RBjs.Apply);
}
function chain(M) {
  const flatMapM = flatMap(M);
  return (f) => (ma) => flatMapM(ma, f);
}
function flatMap(M) {
  return (ma, f) => M.chain(ma, (e) => _chunkS2Z5L3RBjs.isLeft.call(void 0, e) ? M.of(e) : f(e.right));
}
function alt(M) {
  return (second) => (first) => M.chain(first, (e) => _chunkS2Z5L3RBjs.isLeft.call(void 0, e) ? second() : M.of(e));
}
function bimap2(F) {
  const mapBothF = mapBoth(F);
  return (f, g) => (self) => mapBothF(self, f, g);
}
function mapBoth(F) {
  return (self, f, g) => F.map(self, _chunkS2Z5L3RBjs.bimap.call(void 0, f, g));
}
function mapLeft2(F) {
  const mapErrorF = mapError(F);
  return (f) => (self) => mapErrorF(self, f);
}
function mapError(F) {
  return (self, f) => F.map(self, _chunkS2Z5L3RBjs.mapLeft.call(void 0, f));
}
function altValidation(M, S) {
  return (second) => (first) => M.chain(
    first,
    _chunkS2Z5L3RBjs.match.call(void 0, 
      (e1) => M.map(
        second(),
        _chunkS2Z5L3RBjs.mapLeft.call(void 0, (e2) => S.concat(e1, e2))
      ),
      right2(M)
    )
  );
}
function match2(F) {
  return (onLeft, onRight) => (ma) => F.map(ma, _chunkS2Z5L3RBjs.match.call(void 0, onLeft, onRight));
}
function matchE(M) {
  return (onLeft, onRight) => (ma) => M.chain(ma, _chunkS2Z5L3RBjs.match.call(void 0, onLeft, onRight));
}
function getOrElse(M) {
  return (onLeft) => (ma) => M.chain(ma, _chunkS2Z5L3RBjs.match.call(void 0, onLeft, M.of));
}
function orElse(M) {
  return (onLeft) => (ma) => M.chain(ma, (e) => _chunkS2Z5L3RBjs.isLeft.call(void 0, e) ? onLeft(e.left) : M.of(e));
}
function orElseFirst(M) {
  const tapErrorM = tapError(M);
  return (onLeft) => (ma) => tapErrorM(ma, onLeft);
}
function tapError(M) {
  const orElseM = orElse(M);
  return (ma, onLeft) => _chunkSQA7G4TEjs.pipe.call(void 0, 
    ma,
    orElseM((e) => M.map(onLeft(e), (eb) => _chunkS2Z5L3RBjs.isLeft.call(void 0, eb) ? eb : _chunkS2Z5L3RBjs.left.call(void 0, e)))
  );
}
function orLeft(M) {
  return (onLeft) => (ma) => M.chain(
    ma,
    _chunkS2Z5L3RBjs.match.call(void 0, 
      (e) => M.map(onLeft(e), _chunkS2Z5L3RBjs.left),
      (a) => M.of(_chunkS2Z5L3RBjs.right.call(void 0, a))
    )
  );
}
function swap2(F) {
  return (ma) => F.map(ma, _chunkS2Z5L3RBjs.swap);
}
function toUnion2(F) {
  return (fa) => F.map(fa, _chunkS2Z5L3RBjs.toUnion);
}
function getEitherM(M) {
  const _ap = ap2(M);
  const _map = map2(M);
  const _chain = chain(M);
  const _alt = alt(M);
  const _bimap = bimap2(M);
  const _mapLeft = mapLeft2(M);
  const _fold = matchE(M);
  const _getOrElse = getOrElse(M);
  const _orElse = orElse(M);
  return {
    map: (fa, f) => _chunkSQA7G4TEjs.pipe.call(void 0, fa, _map(f)),
    ap: (fab, fa) => _chunkSQA7G4TEjs.pipe.call(void 0, fab, _ap(fa)),
    of: right2(M),
    chain: (ma, f) => _chunkSQA7G4TEjs.pipe.call(void 0, ma, _chain(f)),
    alt: (fa, that) => _chunkSQA7G4TEjs.pipe.call(void 0, fa, _alt(that)),
    bimap: (fea, f, g) => _chunkSQA7G4TEjs.pipe.call(void 0, fea, _bimap(f, g)),
    mapLeft: (fea, f) => _chunkSQA7G4TEjs.pipe.call(void 0, fea, _mapLeft(f)),
    fold: (fa, onLeft, onRight) => _chunkSQA7G4TEjs.pipe.call(void 0, fa, _fold(onLeft, onRight)),
    getOrElse: (fa, onLeft) => _chunkSQA7G4TEjs.pipe.call(void 0, fa, _getOrElse(onLeft)),
    orElse: (fa, f) => _chunkSQA7G4TEjs.pipe.call(void 0, fa, _orElse(f)),
    swap: swap2(M),
    rightM: rightF(M),
    leftM: leftF(M),
    left: left2(M)
  };
}






























exports.right = right2; exports.left = left2; exports.rightF = rightF; exports.leftF = leftF; exports.fromNullable = fromNullable2; exports.fromNullableK = fromNullableK; exports.chainNullableK = chainNullableK; exports.map = map2; exports.ap = ap2; exports.chain = chain; exports.flatMap = flatMap; exports.alt = alt; exports.bimap = bimap2; exports.mapBoth = mapBoth; exports.mapLeft = mapLeft2; exports.mapError = mapError; exports.altValidation = altValidation; exports.match = match2; exports.matchE = matchE; exports.getOrElse = getOrElse; exports.orElse = orElse; exports.orElseFirst = orElseFirst; exports.tapError = tapError; exports.orLeft = orLeft; exports.swap = swap2; exports.toUnion = toUnion2; exports.getEitherM = getEitherM; exports.EitherT_exports = EitherT_exports;
