"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('../paths/normalize.js');
const require_node_path = require('../node/path.js');
const require_paths_socket = require('../paths/socket.js');

//#region src/dlx/paths.ts
/**
* @file Path utilities for DLX package installations.
*/
/**
* Get the installed package directory within DLX node_modules.
*
* @example
*   ;```typescript
*   const dir = getDlxInstalledPackageDir('prettier')
*   ```
*/
function getDlxInstalledPackageDir(packageName) {
	return /* @__PURE__ */ require_paths_normalize.normalizePath((/* @__PURE__ */ require_node_path.getNodePath()).join(getDlxPackageNodeModulesDir(packageName), packageName));
}
/**
* Get the DLX installation directory for a specific package.
*
* @example
*   ;```typescript
*   const dir = getDlxPackageDir('a1b2c3d4')
*   ```
*/
function getDlxPackageDir(packageName) {
	return /* @__PURE__ */ require_paths_normalize.normalizePath((/* @__PURE__ */ require_node_path.getNodePath()).join(require_paths_socket.getSocketDlxDir(), packageName));
}
/**
* Get the package.json path for a DLX installed package.
*
* @example
*   ;```typescript
*   const jsonPath = getDlxPackageJsonPath('prettier')
*   ```
*/
function getDlxPackageJsonPath(packageName) {
	return /* @__PURE__ */ require_paths_normalize.normalizePath((/* @__PURE__ */ require_node_path.getNodePath()).join(getDlxInstalledPackageDir(packageName), "package.json"));
}
/**
* Get the node_modules directory for a DLX package installation.
*
* @example
*   ;```typescript
*   const nmDir = getDlxPackageNodeModulesDir('a1b2c3d4')
*   ```
*/
function getDlxPackageNodeModulesDir(packageName) {
	return /* @__PURE__ */ require_paths_normalize.normalizePath((/* @__PURE__ */ require_node_path.getNodePath()).join(getDlxPackageDir(packageName), "node_modules"));
}
/**
* Check if a file path is within the Socket DLX directory. This is useful for
* determining if a binary or file is managed by Socket's DLX system.
*
* @example
*   ;```typescript
*   isInSocketDlx('/home/<user>/.socket/_dlx/abc123/bin/socket') // true
*   isInSocketDlx('/usr/local/bin/socket') // false
*   isInSocketDlx(process.argv[0]) // Check if current binary is in DLX
*   ```
*
* @param filePath - Absolute or relative path to check.
*
* @returns True if the path is within ~/.socket/_dlx/, false otherwise
*/
function isInSocketDlx(filePath) {
	if (!filePath) return false;
	const path = /* @__PURE__ */ require_node_path.getNodePath();
	const dlxDir = /* @__PURE__ */ require_paths_normalize.normalizePath(require_paths_socket.getSocketDlxDir());
	return require_primordials_string.StringPrototypeStartsWith(/* @__PURE__ */ require_paths_normalize.normalizePath(path.resolve(filePath)), `${dlxDir}/`);
}

//#endregion
exports.getDlxInstalledPackageDir = getDlxInstalledPackageDir;
exports.getDlxPackageDir = getDlxPackageDir;
exports.getDlxPackageJsonPath = getDlxPackageJsonPath;
exports.getDlxPackageNodeModulesDir = getDlxPackageNodeModulesDir;
exports.isInSocketDlx = isInSocketDlx;