"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var retry_exports = {};
__export(retry_exports, {
  default: () => retry_default,
  getRaxConfig: () => getRaxConfig
});
module.exports = __toCommonJS(retry_exports);
var import_retry_axios = require("./retry-axios.js");
const getRaxConfig = (httpClient) => ({
  // Retry 3 times on requests that return a response (500, etc) before giving up.  Defaults to 3.
  retry: 3,
  // Retry twice on errors that don't return a response (ENOTFOUND, ETIMEDOUT, etc).
  noResponseRetries: 2,
  // Milliseconds to delay at first.  Defaults to 100.
  retryDelay: 100,
  // HTTP methods to automatically retry.  Defaults to:
  // ['GET', 'HEAD', 'OPTIONS', 'DELETE', 'PUT']
  httpMethodsToRetry: ["GET", "HEAD", "OPTIONS", "DELETE", "PUT"],
  // The response status codes to retry.  Supports a double
  // array with a list of ranges.  Defaults to:
  // [[100, 199], [429, 429], [500, 599]]
  statusCodesToRetry: [
    [100, 199],
    [429, 429],
    [500, 599]
  ],
  // If you are using a non static instance of Axios you need
  // to pass that instance here (const ax = axios.create())
  instance: httpClient,
  // You can detect when a retry is happening, and figure out how many
  // retry attempts have been made
  onRetryAttempt: (err) => {
    const cfg = (0, import_retry_axios.getConfig)(err);
    if (cfg && cfg.currentRetryAttempt)
      console.log(`Retry attempt #${cfg.currentRetryAttempt}`);
  }
});
const setupRetry = (httpClient) => {
  if (httpClient?.defaults)
    httpClient.defaults.retryConfig = getRaxConfig(httpClient);
  (0, import_retry_axios.attach)(httpClient);
};
var retry_default = setupRetry;
