"use strict";
/* Socket Lib - Built with esbuild */
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 abort_exports = {};
__export(abort_exports, {
  createCompositeAbortSignal: () => createCompositeAbortSignal,
  createTimeoutSignal: () => createTimeoutSignal
});
module.exports = __toCommonJS(abort_exports);
function createCompositeAbortSignal(...signals) {
  const validSignals = signals.filter((s) => s != null);
  if (validSignals.length === 0) {
    return new AbortController().signal;
  }
  if (validSignals.length === 1) {
    return validSignals[0];
  }
  const controller = new AbortController();
  for (const signal of validSignals) {
    if (signal.aborted) {
      controller.abort();
      return controller.signal;
    }
    signal.addEventListener("abort", () => controller.abort(), { once: true });
  }
  return controller.signal;
}
function createTimeoutSignal(ms) {
  if (typeof ms !== "number" || Number.isNaN(ms)) {
    throw new TypeError("timeout must be a number");
  }
  if (!Number.isFinite(ms)) {
    throw new TypeError("timeout must be a finite number");
  }
  if (ms <= 0) {
    throw new TypeError("timeout must be a positive number");
  }
  const controller = new AbortController();
  setTimeout(() => controller.abort(), ms);
  return controller.signal;
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  createCompositeAbortSignal,
  createTimeoutSignal
});
