"use strict";
/* Socket Lib - Built with esbuild */
"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 internal_exports = {};
__export(internal_exports, {
  WIN32: () => WIN32,
  emit: () => emit,
  getEmitter: () => getEmitter,
  getEvents: () => getEvents,
  getSignals: () => getSignals,
  globalProcess: () => globalProcess,
  isLoaded: () => isLoaded,
  originalProcessEmit: () => originalProcessEmit,
  originalProcessReallyExit: () => originalProcessReallyExit,
  platform: () => platform,
  setLoaded: () => setLoaded,
  setSignals: () => setSignals
});
module.exports = __toCommonJS(internal_exports);
const globalProcess = globalThis.process;
const originalProcessEmit = globalProcess?.emit;
const platform = globalProcess?.platform ?? "";
const originalProcessReallyExit = globalProcess?.reallyExit;
const WIN32 = platform === "win32";
let _events;
let _emitter;
let _loaded = false;
let _signals;
// @__NO_SIDE_EFFECTS__
function emit(event, code, signal) {
  const emitter = /* @__PURE__ */ getEmitter();
  if (emitter.emitted?.[event]) {
    return;
  }
  if (emitter.emitted) {
    emitter.emitted[event] = true;
  }
  emitter.emit(event, code, signal);
}
// @__NO_SIDE_EFFECTS__
function getEmitter() {
  if (_emitter === void 0) {
    if (globalProcess?.__signal_exit_emitter__) {
      _emitter = globalProcess.__signal_exit_emitter__;
    } else if (globalProcess) {
      const EventEmitter = (/* @__PURE__ */ getEvents()).EventEmitter;
      _emitter = globalProcess.__signal_exit_emitter__ = new EventEmitter();
      _emitter.count = 0;
      _emitter.emitted = { __proto__: null };
    }
    if (_emitter && !_emitter.infinite) {
      _emitter.setMaxListeners(Number.POSITIVE_INFINITY);
      _emitter.infinite = true;
    }
  }
  return _emitter;
}
// @__NO_SIDE_EFFECTS__
function getEvents() {
  if (_events === void 0) {
    _events = require("node:events");
  }
  return _events;
}
// @__NO_SIDE_EFFECTS__
function getSignals() {
  if (_signals === void 0) {
    _signals = ["SIGABRT", "SIGALRM", "SIGHUP", "SIGINT", "SIGTERM"];
    if (!WIN32) {
      _signals.push(
        "SIGVTALRM",
        "SIGXCPU",
        "SIGXFSZ",
        "SIGUSR2",
        "SIGTRAP",
        "SIGSYS",
        "SIGQUIT",
        "SIGIOT"
      );
    }
    if (platform === "linux") {
      _signals.push("SIGIO", "SIGPOLL", "SIGPWR", "SIGSTKFLT", "SIGUNUSED");
    }
  }
  return _signals;
}
function isLoaded() {
  return _loaded;
}
function setLoaded(value) {
  _loaded = value;
}
function setSignals(value) {
  _signals = value;
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  WIN32,
  emit,
  getEmitter,
  getEvents,
  getSignals,
  globalProcess,
  isLoaded,
  originalProcessEmit,
  originalProcessReallyExit,
  platform,
  setLoaded,
  setSignals
});
