"use strict";
/* Socket Lib - Built with rolldown */
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
const require_runtime = require('../_virtual/_rolldown/runtime.js');
const require_node_path = require('../node/path.js');
let node_module = require("node:module");
let node_process = require("node:process");
node_process = require_runtime.__toESM(node_process);

//#region src/fs/resolve-module.ts
/**
* @file `require.resolve`-from-an-arbitrary-base. Node's bare
*   `require.resolve(spec)` resolves relative to the calling module; these
*   helpers resolve a specifier as if required from a DIFFERENT directory —
*   useful for "find the copy of `typescript` that THIS project would load,"
*   not the copy socket-lib itself loads. Returns the resolved absolute file
*   path, or (in `nothrow` form) `undefined` when the specifier can't be
*   resolved.
*/
function requireResolveFrom(fromDir, specifier, options) {
	const { nothrow = false } = {
		__proto__: null,
		...options
	};
	const path = /* @__PURE__ */ require_node_path.getNodePath();
	const anchor = path.join(path.resolve(fromDir), "noop.js");
	try {
		return (0, node_module.createRequire)(anchor).resolve(specifier);
	} catch (e) {
		if (nothrow) return;
		throw e;
	}
}
function requireResolveFromCwd(specifier, options) {
	return options && options.nothrow ? requireResolveFrom(node_process.default.cwd(), specifier, { nothrow: true }) : requireResolveFrom(node_process.default.cwd(), specifier);
}

//#endregion
exports.requireResolveFrom = requireResolveFrom;
exports.requireResolveFromCwd = requireResolveFromCwd;