"use strict";
/* Socket Lib - Built with rolldown */
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
const require_node_module = require('../node/module.js');

//#region src/smol/detect.ts
/**
* @file Smol detection + lazy-loader for `node:smol-util`. Two
*   responsibilities:
*
*   1. `isSmol()` — memoized boolean detector for socket-btm's smol Node binary.
*      Mirrors `isSeaBinary()` from `src/sea.ts`. Probes via
*      `node:module.isBuiltin('node:smol-util')` since only the smol binary
*      registers any `node:smol-*` builtins.
*   2. `getSmolUtil()` — lazy-loader for the `node:smol-util` binding, which
*      provides native `uncurryThis` and `applyBind` (single V8 dispatch via
*      `args.Data()` + `v8::Function::Call`, skipping the BoundFunction adapter
*      + `Function.prototype.call` trampoline that the JS form
*      `bind.bind(call)(fn)` hits twice per invocation). ~2x faster on hot
*      uncurried-call sites. `getSmolUtil()` returns `undefined` on stock Node
*      + non-Node runtimes. Result is cached across calls; the lazy-loader
*      follows the same shape as `src/node/fs.ts` etc.
*
* @see https://github.com/SocketDev/socket-btm — socket-btm builds
*   the smol binary that exposes the `node:smol-util` binding.
*/
/**
* Cached smol-binary detection result.
*/
let _isSmol;
/**
* Cached `node:smol-util` binding. `null` = probed and unavailable; `undefined`
* = not yet probed. JS truthiness collapses both to "no binding" at the call
* site.
*/
let _smolUtil;
let _smolUtilProbed = false;
/**
* Returns `node:smol-util` when running on the smol Node binary, otherwise
* `undefined`. Result is cached across calls.
*/
/*@__NO_SIDE_EFFECTS__*/
function getSmolUtil() {
	if (!_smolUtilProbed) {
		_smolUtilProbed = true;
		/* c8 ignore start - smol Node binary only. */
		if (/* @__PURE__ */ require_node_module.isNodeBuiltin("node:smol-util")) _smolUtil = require("node:smol-util");
	}
	return _smolUtil;
}
/**
* Detect if the current process is running on socket-btm's smol Node binary.
* Memoized on first call.
*
* Defensive across runtimes: returns `false` on stock Node, browsers (no
* `node:module`), Deno / Bun (different module resolution), and worker threads
* (each has its own builtin table).
*
* @example
*   ;```ts
*   import { isSmol } from '@socketsecurity/lib/smol/detect'
*
*   if (isSmol()) {
*     // running on the smol binary; native fast paths available
*   }
*   ```
*/
function isSmol() {
	if (_isSmol === void 0) _isSmol = /* @__PURE__ */ require_node_module.isNodeBuiltin("node:smol-util");
	return _isSmol;
}

//#endregion
exports.getSmolUtil = getSmolUtil;
exports.isSmol = isSmol;