"use strict";
/* Socket Lib - Built with rolldown */
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
const require_primordials_string = require('../primordials/string.js');
const require_paths_normalize = require('./normalize.js');
const require_node_path = require('../node/path.js');

//#region src/paths/packages.ts
/**
* @file Package.json path resolution utilities.
*/
/**
* Whether `filepath`'s final segment is exactly `package.json`. Accepts both
* POSIX and Windows-style separators so paths captured on either platform
* classify the same regardless of the host we're running on.
*/
/*@__NO_SIDE_EFFECTS__*/
function isPackageJsonFile(filepath) {
	return filepath === "package.json" || require_primordials_string.StringPrototypeEndsWith(filepath, "/package.json") || require_primordials_string.StringPrototypeEndsWith(filepath, "\\package.json");
}
/**
* Resolve directory path from a package.json file path.
*/
/*@__NO_SIDE_EFFECTS__*/
function resolvePackageJsonDirname(filepath) {
	if (/* @__PURE__ */ isPackageJsonFile(filepath)) return /* @__PURE__ */ require_paths_normalize.normalizePath((/* @__PURE__ */ require_node_path.getNodePath()).dirname(filepath));
	return /* @__PURE__ */ require_paths_normalize.normalizePath(filepath);
}
/**
* Resolve full path to package.json from a directory or file path.
*/
/*@__NO_SIDE_EFFECTS__*/
function resolvePackageJsonPath(filepath) {
	if (/* @__PURE__ */ isPackageJsonFile(filepath)) return /* @__PURE__ */ require_paths_normalize.normalizePath(filepath);
	return /* @__PURE__ */ require_paths_normalize.normalizePath((/* @__PURE__ */ require_node_path.getNodePath()).join(filepath, "package.json"));
}

//#endregion
exports.isPackageJsonFile = isPackageJsonFile;
exports.resolvePackageJsonDirname = resolvePackageJsonDirname;
exports.resolvePackageJsonPath = resolvePackageJsonPath;