"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 number_exports = {};
__export(number_exports, {
  envAsNumber: () => envAsNumber
});
module.exports = __toCommonJS(number_exports);
var import_number = require("../primordials/number");
// @__NO_SIDE_EFFECTS__
function envAsNumber(value, defaultValueOrOptions = 0) {
  const opts = typeof defaultValueOrOptions === "number" ? { defaultValue: defaultValueOrOptions } : defaultValueOrOptions ?? {};
  const { allowInfinity = false, defaultValue = 0, mode = "int" } = opts;
  if (value === void 0 || value === null) {
    return defaultValue;
  }
  if (typeof value === "string") {
    if (!value) {
      return defaultValue;
    }
    const num = mode === "float" ? (0, import_number.NumberCtor)(value) : (0, import_number.NumberParseInt)(value, 10);
    if ((0, import_number.NumberIsNaN)(num)) {
      return defaultValue;
    }
    if (!(0, import_number.NumberIsFinite)(num)) {
      return allowInfinity ? num : defaultValue;
    }
    return num || 0;
  }
  const numOrNaN = mode === "float" ? (0, import_number.NumberCtor)(String(value)) : (0, import_number.NumberParseInt)(String(value), 10);
  const numMayBeNegZero = (0, import_number.NumberIsFinite)(numOrNaN) ? numOrNaN : (0, import_number.NumberCtor)(defaultValue);
  return numMayBeNegZero || 0;
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  envAsNumber
});
