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



var _chunkR2MJP25Ojs = require('./chunk-R2MJP25O.js');


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


var _chunkTGVEPLW2js = require('./chunk-TGVEPLW2.js');







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



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


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

// src/These.ts
var These_exports = {};
_chunk6C3VEZWHjs.__export.call(void 0, These_exports, {
  ApT: () => ApT,
  Bifunctor: () => Bifunctor,
  Foldable: () => Foldable,
  FromEither: () => FromEither,
  FromThese: () => FromThese,
  Functor: () => Functor,
  Pointed: () => Pointed,
  Traversable: () => Traversable,
  URI: () => URI,
  bimap: () => bimap,
  both: () => both,
  elem: () => elem,
  exists: () => exists,
  flap: () => flap2,
  fold: () => fold,
  foldMap: () => foldMap,
  foldW: () => foldW,
  fromOption: () => fromOption2,
  fromOptionK: () => fromOptionK2,
  fromOptions: () => fromOptions,
  fromPredicate: () => fromPredicate2,
  getApplicative: () => getApplicative,
  getApply: () => getApply,
  getChain: () => getChain,
  getEq: () => getEq,
  getLeft: () => getLeft,
  getLeftOnly: () => getLeftOnly,
  getMonad: () => getMonad,
  getRight: () => getRight,
  getRightOnly: () => getRightOnly,
  getSemigroup: () => getSemigroup,
  getShow: () => getShow,
  isBoth: () => isBoth,
  isLeft: () => isLeft,
  isRight: () => isRight,
  left: () => left,
  leftOrBoth: () => leftOrBoth,
  map: () => map,
  mapLeft: () => mapLeft,
  match: () => match,
  matchW: () => matchW,
  of: () => of,
  reduce: () => reduce,
  reduceRight: () => reduceRight,
  right: () => right,
  rightOrBoth: () => rightOrBoth,
  sequence: () => sequence,
  swap: () => swap,
  these: () => these,
  toTuple: () => toTuple,
  toTuple2: () => toTuple2,
  traverse: () => traverse,
  traverseReadonlyArrayWithIndex: () => traverseReadonlyArrayWithIndex,
  traverseReadonlyNonEmptyArrayWithIndex: () => traverseReadonlyNonEmptyArrayWithIndex
});
var isLeft = (fa) => fa._tag === "Left";
var isRight = (fa) => fa._tag === "Right";
function isBoth(fa) {
  return fa._tag === "Both";
}
function left(left2) {
  return { _tag: "Left", left: left2 };
}
function right(right2) {
  return { _tag: "Right", right: right2 };
}
function both(left2, right2) {
  return { _tag: "Both", left: left2, right: right2 };
}
var matchW = (onLeft, onRight, onBoth) => (fa) => {
  switch (fa._tag) {
    case "Left":
      return onLeft(fa.left);
    case "Right":
      return onRight(fa.right);
    case "Both":
      return onBoth(fa.left, fa.right);
  }
};
var foldW = matchW;
var match = matchW;
var fold = match;
var swap = match(right, left, (e, a) => both(a, e));
function getShow(SE, SA) {
  return {
    show: match(
      (l) => `left(${SE.show(l)})`,
      (a) => `right(${SA.show(a)})`,
      (l, a) => `both(${SE.show(l)}, ${SA.show(a)})`
    )
  };
}
function getEq(EE, EA) {
  return _chunkTGVEPLW2js.fromEquals.call(void 0, 
    (x, y) => isLeft(x) ? isLeft(y) && EE.equals(x.left, y.left) : isRight(x) ? isRight(y) && EA.equals(x.right, y.right) : isBoth(y) && EE.equals(x.left, y.left) && EA.equals(x.right, y.right)
  );
}
function getSemigroup(SE, SA) {
  return {
    concat: (x, y) => isLeft(x) ? isLeft(y) ? left(SE.concat(x.left, y.left)) : isRight(y) ? both(x.left, y.right) : both(SE.concat(x.left, y.left), y.right) : isRight(x) ? isLeft(y) ? both(y.left, x.right) : isRight(y) ? right(SA.concat(x.right, y.right)) : both(y.left, SA.concat(x.right, y.right)) : isLeft(y) ? both(SE.concat(x.left, y.left), x.right) : isRight(y) ? both(x.left, SA.concat(x.right, y.right)) : both(SE.concat(x.left, y.left), SA.concat(x.right, y.right))
  };
}
var getApply = (S) => ({
  URI,
  _E: void 0,
  map: _map,
  ap: (fab, fa) => isLeft(fab) ? isLeft(fa) ? left(S.concat(fab.left, fa.left)) : isRight(fa) ? left(fab.left) : left(S.concat(fab.left, fa.left)) : isRight(fab) ? isLeft(fa) ? left(fa.left) : isRight(fa) ? right(fab.right(fa.right)) : both(fa.left, fab.right(fa.right)) : isLeft(fa) ? left(S.concat(fab.left, fa.left)) : isRight(fa) ? both(fab.left, fab.right(fa.right)) : both(S.concat(fab.left, fa.left), fab.right(fa.right))
});
function getApplicative(S) {
  const A = getApply(S);
  return {
    URI,
    _E: void 0,
    map: _map,
    ap: A.ap,
    of
  };
}
function getChain(S) {
  const A = getApply(S);
  const chain = (ma, f) => {
    if (isLeft(ma)) {
      return ma;
    }
    if (isRight(ma)) {
      return f(ma.right);
    }
    const fb = f(ma.right);
    return isLeft(fb) ? left(S.concat(ma.left, fb.left)) : isRight(fb) ? both(ma.left, fb.right) : both(S.concat(ma.left, fb.left), fb.right);
  };
  return {
    URI,
    _E: void 0,
    map: _map,
    ap: A.ap,
    chain
  };
}
function getMonad(S) {
  const C = getChain(S);
  return {
    URI,
    _E: void 0,
    map: _map,
    of,
    ap: C.ap,
    chain: C.chain,
    throwError: left
  };
}
function getLeft(fa) {
  return isLeft(fa) ? _chunkOTKMOSH2js.some.call(void 0, fa.left) : isRight(fa) ? _chunkOTKMOSH2js.none : _chunkOTKMOSH2js.some.call(void 0, fa.left);
}
function getRight(fa) {
  return isLeft(fa) ? _chunkOTKMOSH2js.none : isRight(fa) ? _chunkOTKMOSH2js.some.call(void 0, fa.right) : _chunkOTKMOSH2js.some.call(void 0, fa.right);
}
function leftOrBoth(e) {
  return (ma) => _chunkOTKMOSH2js.isNone.call(void 0, ma) ? left(e) : both(e, ma.value);
}
function rightOrBoth(a) {
  return (me) => _chunkOTKMOSH2js.isNone.call(void 0, me) ? right(a) : both(me.value, a);
}
function getLeftOnly(fa) {
  return isLeft(fa) ? _chunkOTKMOSH2js.some.call(void 0, fa.left) : _chunkOTKMOSH2js.none;
}
function getRightOnly(fa) {
  return isRight(fa) ? _chunkOTKMOSH2js.some.call(void 0, fa.right) : _chunkOTKMOSH2js.none;
}
var fromOptions = (fe, fa) => _chunkOTKMOSH2js.isNone.call(void 0, fe) ? _chunkOTKMOSH2js.isNone.call(void 0, fa) ? _chunkOTKMOSH2js.none : _chunkOTKMOSH2js.some.call(void 0, right(fa.value)) : _chunkOTKMOSH2js.isNone.call(void 0, fa) ? _chunkOTKMOSH2js.some.call(void 0, left(fe.value)) : _chunkOTKMOSH2js.some.call(void 0, both(fe.value, fa.value));
var _map = (fa, f) => _chunkSQA7G4TEjs.pipe.call(void 0, fa, map(f));
var _bimap = (fa, f, g) => _chunkSQA7G4TEjs.pipe.call(void 0, fa, bimap(f, g));
var _mapLeft = (fa, f) => _chunkSQA7G4TEjs.pipe.call(void 0, fa, mapLeft(f));
var _reduce = (fa, b, f) => _chunkSQA7G4TEjs.pipe.call(void 0, fa, reduce(b, f));
var _foldMap = (M) => {
  const foldMapM = foldMap(M);
  return (fa, f) => _chunkSQA7G4TEjs.pipe.call(void 0, fa, foldMapM(f));
};
var _reduceRight = (fa, b, f) => _chunkSQA7G4TEjs.pipe.call(void 0, fa, reduceRight(b, f));
var _traverse = (F) => {
  const traverseF = traverse(F);
  return (ta, f) => _chunkSQA7G4TEjs.pipe.call(void 0, ta, traverseF(f));
};
var bimap = (f, g) => (fa) => isLeft(fa) ? left(f(fa.left)) : isRight(fa) ? right(g(fa.right)) : both(f(fa.left), g(fa.right));
var mapLeft = (f) => (fa) => isLeft(fa) ? left(f(fa.left)) : isBoth(fa) ? both(f(fa.left), fa.right) : fa;
var map = (f) => (fa) => isLeft(fa) ? fa : isRight(fa) ? right(f(fa.right)) : both(fa.left, f(fa.right));
var reduce = (b, f) => (fa) => isLeft(fa) ? b : f(b, fa.right);
var foldMap = (M) => (f) => (fa) => isLeft(fa) ? M.empty : f(fa.right);
var reduceRight = (b, f) => (fa) => isLeft(fa) ? b : f(fa.right, b);
var traverse = (F) => (f) => (ta) => isLeft(ta) ? F.of(ta) : isRight(ta) ? F.map(f(ta.right), right) : F.map(f(ta.right), (b) => both(ta.left, b));
var sequence = (F) => (ta) => {
  return isLeft(ta) ? F.of(ta) : isRight(ta) ? F.map(ta.right, right) : F.map(ta.right, (b) => both(ta.left, b));
};
var of = right;
var URI = "These";
var Functor = {
  URI,
  map: _map
};
var flap2 = /* @__PURE__ */ _chunk7K74W2G3js.flap.call(void 0, Functor);
var Pointed = {
  URI,
  of
};
var Bifunctor = {
  URI,
  bimap: _bimap,
  mapLeft: _mapLeft
};
var FromThese = {
  URI,
  fromThese: _chunkSQA7G4TEjs.identity
};
var Foldable = {
  URI,
  reduce: _reduce,
  foldMap: _foldMap,
  reduceRight: _reduceRight
};
var Traversable = {
  URI,
  map: _map,
  reduce: _reduce,
  foldMap: _foldMap,
  reduceRight: _reduceRight,
  traverse: _traverse,
  sequence
};
var FromEither = {
  URI,
  fromEither: _chunkSQA7G4TEjs.identity
};
var fromPredicate2 = /* @__PURE__ */ _chunkR2MJP25Ojs.fromPredicate.call(void 0, FromEither);
var fromOption2 = /* @__PURE__ */ _chunkR2MJP25Ojs.fromOption.call(void 0, FromEither);
var fromOptionK2 = /* @__PURE__ */ _chunkR2MJP25Ojs.fromOptionK.call(void 0, FromEither);
var elem = (E) => (a) => (ma) => isLeft(ma) ? false : E.equals(a, ma.right);
var exists = (predicate) => (ma) => isLeft(ma) ? false : predicate(ma.right);
var toTuple2 = (e, a) => (fa) => isLeft(fa) ? [fa.left, a()] : isRight(fa) ? [e(), fa.right] : [fa.left, fa.right];
var toTuple = (e, a) => toTuple2(
  () => e,
  () => a
);
var ApT = /* @__PURE__ */ of(_chunkOTKMOSH2js.emptyReadonlyArray);
var traverseReadonlyNonEmptyArrayWithIndex = (S) => (f) => (as) => {
  let e = _chunkOTKMOSH2js.none;
  const t = f(0, _chunkOTKMOSH2js.head.call(void 0, as));
  if (isLeft(t)) {
    return t;
  }
  if (isBoth(t)) {
    e = _chunkOTKMOSH2js.some.call(void 0, t.left);
  }
  const out = [t.right];
  for (let i = 1; i < as.length; i++) {
    const t2 = f(i, as[i]);
    if (isLeft(t2)) {
      return t2;
    }
    if (isBoth(t2)) {
      e = _chunkOTKMOSH2js.isNone.call(void 0, e) ? _chunkOTKMOSH2js.some.call(void 0, t2.left) : _chunkOTKMOSH2js.some.call(void 0, S.concat(e.value, t2.left));
    }
    out.push(t2.right);
  }
  return _chunkOTKMOSH2js.isNone.call(void 0, e) ? right(out) : both(e.value, out);
};
var traverseReadonlyArrayWithIndex = (S) => (f) => {
  const g = traverseReadonlyNonEmptyArrayWithIndex(S)(f);
  return (as) => _chunkOTKMOSH2js.isNonEmpty.call(void 0, as) ? g(as) : ApT;
};
var these = {
  URI,
  map: _map,
  bimap: _bimap,
  mapLeft: _mapLeft,
  reduce: _reduce,
  foldMap: _foldMap,
  reduceRight: _reduceRight,
  traverse: _traverse,
  sequence
};

























































exports.isLeft = isLeft; exports.isRight = isRight; exports.isBoth = isBoth; exports.left = left; exports.right = right; exports.both = both; exports.matchW = matchW; exports.foldW = foldW; exports.match = match; exports.fold = fold; exports.swap = swap; exports.getShow = getShow; exports.getEq = getEq; exports.getSemigroup = getSemigroup; exports.getApply = getApply; exports.getApplicative = getApplicative; exports.getChain = getChain; exports.getMonad = getMonad; exports.getLeft = getLeft; exports.getRight = getRight; exports.leftOrBoth = leftOrBoth; exports.rightOrBoth = rightOrBoth; exports.getLeftOnly = getLeftOnly; exports.getRightOnly = getRightOnly; exports.fromOptions = fromOptions; exports.bimap = bimap; exports.mapLeft = mapLeft; exports.map = map; exports.reduce = reduce; exports.foldMap = foldMap; exports.reduceRight = reduceRight; exports.traverse = traverse; exports.sequence = sequence; exports.of = of; exports.URI = URI; exports.Functor = Functor; exports.flap = flap2; exports.Pointed = Pointed; exports.Bifunctor = Bifunctor; exports.FromThese = FromThese; exports.Foldable = Foldable; exports.Traversable = Traversable; exports.FromEither = FromEither; exports.fromPredicate = fromPredicate2; exports.fromOption = fromOption2; exports.fromOptionK = fromOptionK2; exports.elem = elem; exports.exists = exists; exports.toTuple2 = toTuple2; exports.toTuple = toTuple; exports.ApT = ApT; exports.traverseReadonlyNonEmptyArrayWithIndex = traverseReadonlyNonEmptyArrayWithIndex; exports.traverseReadonlyArrayWithIndex = traverseReadonlyArrayWithIndex; exports.these = these; exports.These_exports = These_exports;
