"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 predicates_exports = {};
__export(predicates_exports, {
  isAbsolute: () => isAbsolute,
  isNodeModules: () => isNodeModules,
  isPath: () => isPath,
  isPathSeparator: () => isPathSeparator,
  isRelative: () => isRelative,
  isUnixPath: () => isUnixPath,
  isWindowsDeviceRoot: () => isWindowsDeviceRoot
});
module.exports = __toCommonJS(predicates_exports);
var import_platform = require("../constants/platform");
var import_regexp = require("../primordials/regexp");
var import_string = require("../primordials/string");
var import_internal = require("./_internal");
// @__NO_SIDE_EFFECTS__
function isAbsolute(pathLike) {
  const filepath = (0, import_internal.pathLikeToString)(pathLike);
  const { length } = filepath;
  if (length === 0) {
    return false;
  }
  const code = (0, import_string.StringPrototypeCharCodeAt)(filepath, 0);
  if (code === import_internal.CHAR_FORWARD_SLASH) {
    return true;
  }
  if (code === import_internal.CHAR_BACKWARD_SLASH) {
    return true;
  }
  if (import_platform.WIN32 && length > 2) {
    if (/* @__PURE__ */ isWindowsDeviceRoot(code) && (0, import_string.StringPrototypeCharCodeAt)(filepath, 1) === import_internal.CHAR_COLON && /* @__PURE__ */ isPathSeparator((0, import_string.StringPrototypeCharCodeAt)(filepath, 2))) {
      return true;
    }
  }
  return false;
}
// @__NO_SIDE_EFFECTS__
function isNodeModules(pathLike) {
  const filepath = (0, import_internal.pathLikeToString)(pathLike);
  return (0, import_regexp.RegExpPrototypeTest)(import_internal.nodeModulesPathRegExp, filepath);
}
// @__NO_SIDE_EFFECTS__
function isPath(pathLike) {
  const filepath = (0, import_internal.pathLikeToString)(pathLike);
  if (typeof filepath !== "string" || filepath.length === 0) {
    return false;
  }
  if (/^[a-z][a-z0-9+.-]+:/i.test(filepath)) {
    return false;
  }
  if (filepath === "." || filepath === "..") {
    return true;
  }
  if (/* @__PURE__ */ isAbsolute(filepath)) {
    return true;
  }
  if (filepath.includes("/") || filepath.includes("\\")) {
    if ((0, import_string.StringPrototypeStartsWith)(filepath, "@") && !(0, import_string.StringPrototypeStartsWith)(filepath, "@/")) {
      const parts = filepath.split("/");
      if (parts.length <= 2 && !parts[1]?.includes("\\")) {
        return false;
      }
    }
    return true;
  }
  return false;
}
// @__NO_SIDE_EFFECTS__
function isPathSeparator(code) {
  return code === import_internal.CHAR_FORWARD_SLASH || code === import_internal.CHAR_BACKWARD_SLASH;
}
// @__NO_SIDE_EFFECTS__
function isRelative(pathLike) {
  const filepath = (0, import_internal.pathLikeToString)(pathLike);
  if (typeof filepath !== "string") {
    return false;
  }
  if (filepath.length === 0) {
    return true;
  }
  return !/* @__PURE__ */ isAbsolute(filepath);
}
// @__NO_SIDE_EFFECTS__
function isUnixPath(pathLike) {
  const filepath = (0, import_internal.pathLikeToString)(pathLike);
  return typeof filepath === "string" && (0, import_regexp.RegExpPrototypeTest)(import_internal.msysDriveRegExp, filepath);
}
// @__NO_SIDE_EFFECTS__
function isWindowsDeviceRoot(code) {
  return code >= import_internal.CHAR_UPPERCASE_A && code <= import_internal.CHAR_UPPERCASE_Z || code >= import_internal.CHAR_LOWERCASE_A && code <= import_internal.CHAR_LOWERCASE_Z;
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  isAbsolute,
  isNodeModules,
  isPath,
  isPathSeparator,
  isRelative,
  isUnixPath,
  isWindowsDeviceRoot
});
