"use strict";
/* Socket Lib - Built with rolldown */
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
const require_primordials_buffer = require('../primordials/buffer.js');
const require_primordials_string = require('../primordials/string.js');
const require_constants_platform = require('../constants/platform.js');

//#region src/paths/_internal.ts
/**
* @file Shared internals for the `paths/` module — the leaf-level primitives
*   every other path leaf depends on. Kept as a single file so `normalize`,
*   `predicates`, `conversion`, and `resolve` can layer above it without
*   circular imports.
*
*   - char-code constants + shared regexps
*   - `getUrl` — lazy `node:url` loader
*   - `pathLikeToString` — `string | Buffer | URL` → `string`
*/
const CHAR_BACKWARD_SLASH = 92;
const CHAR_COLON = 58;
const CHAR_FORWARD_SLASH = 47;
const CHAR_LOWERCASE_A = 97;
const CHAR_LOWERCASE_Z = 122;
const CHAR_UPPERCASE_A = 65;
const CHAR_UPPERCASE_Z = 90;
const msysDriveRegExp = /^\/([a-zA-Z])(\/|$)/;
const nodeModulesPathRegExp = /(?:^|[/\\])node_modules(?:[/\\]|$)/;
const slashRegExp = /[/\\]/;
let _url;
/**
* Lazily load the url module.
*
* Performs on-demand loading of Node.js url module to avoid initialization
* overhead and potential Webpack bundling errors.
*
* @private
*/
/*@__NO_SIDE_EFFECTS__*/
function getUrl() {
	if (_url === void 0) _url = /*@__PURE__*/ require("node:url");
	return _url;
}
/**
* Convert a path-like value to a string.
*
* Converts various path-like types (string, Buffer, URL) into a normalized
* string representation. Handles different input formats and provides
* consistent string output for path operations.
*
* @example
*   ;```typescript
*   pathLikeToString('/home/user') // '/home/user'
*   pathLikeToString(Buffer.from('/tmp/file')) // '/tmp/file'
*   pathLikeToString(new URL('file:///home/user')) // '/home/user'
*   pathLikeToString(null) // ''
*   ```
*
* @param {string | Buffer | URL | null | undefined} pathLike - The value to
*   convert.
*
* @returns {string} The string representation, or empty string for
*   null/undefined.
*/
/*@__NO_SIDE_EFFECTS__*/
function pathLikeToString(pathLike) {
	if (pathLike === null || pathLike === void 0) return "";
	if (typeof pathLike === "string") return pathLike;
	if (require_primordials_buffer.BufferIsBuffer(pathLike)) return pathLike.toString("utf8");
	const url = /* @__PURE__ */ getUrl();
	if (pathLike instanceof URL) try {
		return url.fileURLToPath(pathLike);
	} catch {
		const pathname = pathLike.pathname;
		const decodedPathname = decodeURIComponent(pathname);
		/* c8 ignore start - Windows-only URL drive-letter handling. */
		if (require_constants_platform.WIN32 && require_primordials_string.StringPrototypeStartsWith(decodedPathname, "/")) {
			const letter = require_primordials_string.StringPrototypeCharCodeAt(decodedPathname, 1) | 32;
			if (!(decodedPathname.length >= 3 && letter >= 97 && letter <= 122 && require_primordials_string.StringPrototypeCharAt(decodedPathname, 2) === ":")) return decodedPathname;
		}
		/* c8 ignore stop */
		return decodedPathname;
	}
	return String(pathLike);
}

//#endregion
exports.CHAR_BACKWARD_SLASH = CHAR_BACKWARD_SLASH;
exports.CHAR_COLON = CHAR_COLON;
exports.CHAR_FORWARD_SLASH = CHAR_FORWARD_SLASH;
exports.CHAR_LOWERCASE_A = CHAR_LOWERCASE_A;
exports.CHAR_LOWERCASE_Z = CHAR_LOWERCASE_Z;
exports.CHAR_UPPERCASE_A = CHAR_UPPERCASE_A;
exports.CHAR_UPPERCASE_Z = CHAR_UPPERCASE_Z;
exports.getUrl = getUrl;
exports.msysDriveRegExp = msysDriveRegExp;
exports.nodeModulesPathRegExp = nodeModulesPathRegExp;
exports.pathLikeToString = pathLikeToString;
exports.slashRegExp = slashRegExp;