"use strict"
var __createBinding =
  (this && this.__createBinding) ||
  (Object.create
    ? function (o, m, k, k2) {
        if (k2 === undefined) k2 = k
        Object.defineProperty(o, k2, {
          enumerable: true,
          get: function () {
            return m[k]
          }
        })
      }
    : function (o, m, k, k2) {
        if (k2 === undefined) k2 = k
        o[k2] = m[k]
      })
var __setModuleDefault =
  (this && this.__setModuleDefault) ||
  (Object.create
    ? function (o, v) {
        Object.defineProperty(o, "default", { enumerable: true, value: v })
      }
    : function (o, v) {
        o["default"] = v
      })
var __importStar =
  (this && this.__importStar) ||
  function (mod) {
    if (mod && mod.__esModule) return mod
    var result = {}
    if (mod != null)
      for (var k in mod)
        if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k))
          __createBinding(result, mod, k)
    __setModuleDefault(result, mod)
    return result
  }
Object.defineProperty(exports, "__esModule", { value: true })
exports.retryWhile_ =
  exports.retryWhile =
  exports.retryWhileM_ =
  exports.retryWhileM =
    void 0
// tracing: off
const Function_1 = require("../Function")
const catchAll = __importStar(require("./catchAll"))
const core = __importStar(require("./core"))
const fail = __importStar(require("./fail"))
/**
 * Retries this effect while its error satisfies the specified effectful predicate.
 *
 * @dataFirst retryWhileM_
 */
function retryWhileM(f, __trace) {
  return (self) => retryWhileM_(self, f)
}
exports.retryWhileM = retryWhileM
/**
 * Retries this effect while its error satisfies the specified effectful predicate.
 */
function retryWhileM_(self, f, __trace) {
  return core.suspend(
    () =>
      catchAll.catchAll_(self, (e) =>
        core.chain_(f(e), (b) => (b ? retryWhileM_(self, f) : fail.fail(e)))
      ),
    __trace
  )
}
exports.retryWhileM_ = retryWhileM_
/**
 * Retries this effect while its error satisfies the specified predicate.
 *
 * @dataFirst retryWhile_
 */
function retryWhile(f, __trace) {
  return (self) => retryWhile_(self, f, __trace)
}
exports.retryWhile = retryWhile
/**
 * Retries this effect while its error satisfies the specified predicate.
 */
function retryWhile_(self, f, __trace) {
  return retryWhileM_(self, (a) => core.succeed(f(a)), __trace)
}
exports.retryWhile_ = retryWhile_
//# sourceMappingURL=retryWhile.js.map
