const { SetCtor: _p_SetCtor } = require('../primordials/map-set.js')
"use strict";
/**
 * Bundled from pony-cause
 * This is a zero-dependency bundle created by esbuild.
 */
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
var __commonJS = (cb, mod) => function __require() {
  return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
};

// node_modules/.pnpm/pony-cause@2.1.11_patch_hash=39b2eb2567818b7c60126d03e252dbbabd8738082fca850582300d45b0a8cfb8/node_modules/pony-cause/lib/error-with-cause.js
var require_error_with_cause = __commonJS({
  "node_modules/.pnpm/pony-cause@2.1.11_patch_hash=39b2eb2567818b7c60126d03e252dbbabd8738082fca850582300d45b0a8cfb8/node_modules/pony-cause/lib/error-with-cause.js"(exports2, module2) {
    "use strict";
    var ErrorWithCause = class _ErrorWithCause extends Error {
      static {
        __name(this, "ErrorWithCause");
      }
      // linemod-prefix-with: export
      /**
       * @param {string} message
       * @param {{ cause?: T }} options
       */
      constructor(message, { cause } = {}) {
        super(message);
        this.name = _ErrorWithCause.name;
        if (cause) {
          this.cause = cause;
        }
        this.message = message;
      }
    };
    module2.exports = {
      // linemod-remove
      ErrorWithCause
      // linemod-remove
    };
  }
});

// node_modules/.pnpm/pony-cause@2.1.11_patch_hash=39b2eb2567818b7c60126d03e252dbbabd8738082fca850582300d45b0a8cfb8/node_modules/pony-cause/lib/helpers.js
var require_helpers = __commonJS({
  "node_modules/.pnpm/pony-cause@2.1.11_patch_hash=39b2eb2567818b7c60126d03e252dbbabd8738082fca850582300d45b0a8cfb8/node_modules/pony-cause/lib/helpers.js"(exports2, module2) {
    "use strict";
    var isError = typeof Error.isError === "function" ? Error.isError : (v) => v !== null && typeof v === "object" && Object.prototype.toString.call(v) === "[object Error]";
    var findCauseByReference = /* @__PURE__ */ __name((err, reference) => {
      if (!err || !reference) return;
      if (!isError(err)) return;
      if (!(reference.prototype instanceof Error) && // @ts-ignore
      reference !== Error) return;
      const seen = /* @__PURE__ */ new _p_SetCtor();
      let currentErr = err;
      while (currentErr && !seen.has(currentErr)) {
        seen.add(currentErr);
        if (currentErr instanceof reference) {
          return currentErr;
        }
        currentErr = getErrorCause(currentErr);
      }
    }, "findCauseByReference");
    var getErrorCause = /* @__PURE__ */ __name((err) => {
      if (!err || typeof err !== "object" || !("cause" in err)) {
        return;
      }
      if (typeof err.cause === "function") {
        const causeResult = err.cause();
        return isError(causeResult) ? causeResult : void 0;
      } else {
        return isError(err.cause) ? err.cause : void 0;
      }
    }, "getErrorCause");
    var _stackWithCauses = /* @__PURE__ */ __name((err, seen) => {
      if (!isError(err)) return "";
      const stack = err.stack || "";
      if (seen.has(err)) {
        return stack + "\ncauses have become circular...";
      }
      const cause = getErrorCause(err);
      if (cause) {
        seen.add(err);
        return stack + "\ncaused by: " + _stackWithCauses(cause, seen);
      } else {
        return stack;
      }
    }, "_stackWithCauses");
    var stackWithCauses = /* @__PURE__ */ __name((err) => _stackWithCauses(err, /* @__PURE__ */ new Set()), "stackWithCauses");
    var _messageWithCauses = /* @__PURE__ */ __name((err, seen, skip) => {
      if (!isError(err)) return "";
      const message = skip ? "" : err.message || "";
      if (seen.has(err)) {
        return message + ": ...";
      }
      const cause = getErrorCause(err);
      if (cause) {
        seen.add(err);
        const skipIfVErrorStyleCause = "cause" in err && typeof err.cause === "function";
        return message + (skipIfVErrorStyleCause ? "" : ": ") + _messageWithCauses(cause, seen, skipIfVErrorStyleCause);
      } else {
        return message;
      }
    }, "_messageWithCauses");
    var messageWithCauses = /* @__PURE__ */ __name((err) => _messageWithCauses(err, /* @__PURE__ */ new Set()), "messageWithCauses");
    module2.exports = {
      // linemod-remove
      findCauseByReference,
      // linemod-remove
      getErrorCause,
      // linemod-remove
      stackWithCauses,
      // linemod-remove
      messageWithCauses
      // linemod-remove
    };
  }
});

// node_modules/.pnpm/pony-cause@2.1.11_patch_hash=39b2eb2567818b7c60126d03e252dbbabd8738082fca850582300d45b0a8cfb8/node_modules/pony-cause/index.js
var require_pony_cause = __commonJS({
  "node_modules/.pnpm/pony-cause@2.1.11_patch_hash=39b2eb2567818b7c60126d03e252dbbabd8738082fca850582300d45b0a8cfb8/node_modules/pony-cause/index.js"(exports2, module2) {
    "use strict";
    var { ErrorWithCause } = require_error_with_cause();
    var {
      // linemod-replace-with: export {
      findCauseByReference,
      getErrorCause,
      messageWithCauses,
      stackWithCauses
    } = require_helpers();
    module2.exports = {
      // linemod-remove
      ErrorWithCause,
      // linemod-remove
      findCauseByReference,
      // linemod-remove
      getErrorCause,
      // linemod-remove
      stackWithCauses,
      // linemod-remove
      messageWithCauses
      // linemod-remove
    };
  }
});

// src/external/pony-cause.js
module.exports = require_pony_cause();
