const require_rolldown_runtime = require('../../../../../../_virtual/rolldown_runtime.cjs');
const require_rng = require('./rng.cjs');
const require_stringify = require('./stringify.cjs');

//#region ../../node_modules/samlify/node_modules/uuid/dist/esm-node/v1.js
function v1(options, buf, offset) {
	let i = buf && offset || 0;
	const b = buf || new Array(16);
	options = options || {};
	let node = options.node || _nodeId;
	let clockseq = options.clockseq !== void 0 ? options.clockseq : _clockseq;
	if (node == null || clockseq == null) {
		const seedBytes = options.random || (options.rng || require_rng.default)();
		if (node == null) node = _nodeId = [
			seedBytes[0] | 1,
			seedBytes[1],
			seedBytes[2],
			seedBytes[3],
			seedBytes[4],
			seedBytes[5]
		];
		if (clockseq == null) clockseq = _clockseq = (seedBytes[6] << 8 | seedBytes[7]) & 16383;
	}
	let msecs = options.msecs !== void 0 ? options.msecs : Date.now();
	let nsecs = options.nsecs !== void 0 ? options.nsecs : _lastNSecs + 1;
	const dt = msecs - _lastMSecs + (nsecs - _lastNSecs) / 1e4;
	if (dt < 0 && options.clockseq === void 0) clockseq = clockseq + 1 & 16383;
	if ((dt < 0 || msecs > _lastMSecs) && options.nsecs === void 0) nsecs = 0;
	if (nsecs >= 1e4) throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");
	_lastMSecs = msecs;
	_lastNSecs = nsecs;
	_clockseq = clockseq;
	msecs += 0xb1d069b5400;
	const tl = ((msecs & 268435455) * 1e4 + nsecs) % 4294967296;
	b[i++] = tl >>> 24 & 255;
	b[i++] = tl >>> 16 & 255;
	b[i++] = tl >>> 8 & 255;
	b[i++] = tl & 255;
	const tmh = msecs / 4294967296 * 1e4 & 268435455;
	b[i++] = tmh >>> 8 & 255;
	b[i++] = tmh & 255;
	b[i++] = tmh >>> 24 & 15 | 16;
	b[i++] = tmh >>> 16 & 255;
	b[i++] = clockseq >>> 8 | 128;
	b[i++] = clockseq & 255;
	for (let n = 0; n < 6; ++n) b[i + n] = node[n];
	return buf || require_stringify.default(b);
}
var _nodeId, _clockseq, _lastMSecs, _lastNSecs, v1_default;
var init_v1 = require_rolldown_runtime.__esm({ "../../node_modules/samlify/node_modules/uuid/dist/esm-node/v1.js": (() => {
	require_rng.init_rng();
	require_stringify.init_stringify();
	;
	;
	_lastMSecs = 0;
	_lastNSecs = 0;
	v1_default = v1;
}) });

//#endregion
init_v1();
exports.default = v1_default;
Object.defineProperty(exports, 'init_v1', {
  enumerable: true,
  get: function () {
    return init_v1;
  }
});
//# sourceMappingURL=v1.cjs.map