"use strict";
/* Socket Lib - Built with rolldown */
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
const require_primordials_error = require('../primordials/error.js');
const require_primordials_object = require('../primordials/object.js');
const require_primordials_json = require('../primordials/json.js');
const require_primordials_globals = require('../primordials/globals.js');
const require_temporal_slots = require('./slots.js');

//#region src/temporal/instant.ts
/**
* @file Spec clause 8 — Temporal.Instant Objects. Implements the class,
*   constructor, and the validity predicate. Pass 1 of the rollout; statics
*   (`from`, `fromEpochMilliseconds`, `compare`) and prototype operations
*   (`epochMilliseconds`, `toString`, arithmetic) follow in pass 2. Spec:
*   https://tc39.es/proposal-temporal/#sec-temporal-instant-objects Ref:
*   js-temporal/temporal-polyfill `lib/instant.ts` Operations implemented (✓)
*   and intentionally absent (✗), in section order so a reader can scan against
*   the spec: ✓ 8.1.1 Temporal.Instant ( epochNanoseconds ) — constructor ✓
*   8.1.1.x IsValidEpochNanoseconds ( epochNanoseconds ) — abstract op ✓ 8.5.6
*   get Temporal.Instant.prototype.epochNanoseconds — prototype ✗ 8.4.2
*   Temporal.Instant.from ( item ) — pass 2 ✗ 8.4.3
*   Temporal.Instant.fromEpochMilliseconds ( ms ) — pass 2 ✗ 8.4.7
*   Temporal.Instant.compare ( one, two ) — pass 2 ✗ 8.5.5 get
*   Temporal.Instant.prototype.epochMilliseconds — pass 2 ✗ 8.5.13
*   Temporal.Instant.prototype.toString ( [ options ] ) — pass 2 ✗ 8.5.x add /
*   subtract / until / since / round / equals / etc. — later.
*/
const NS_MAX_INSTANT = 8640000000000000000000n;
const NS_MIN_INSTANT = -8640000000000000000000n;
/**
* Spec's IsValidEpochNanoseconds. Exported for testability.
*/
function isValidEpochNanoseconds(epochNanoseconds) {
	if (epochNanoseconds < NS_MIN_INSTANT || epochNanoseconds > NS_MAX_INSTANT) return false;
	return true;
}
/**
* Temporal.Instant — an exact, nanosecond-resolution point on the UTC timeline.
* Backed by a `bigint` `[[Nanoseconds]]` slot in the range ±8.64e21 (±100
* million days from the Unix epoch).
*
* Construct via `new Temporal.Instant(epochNanoseconds)` or, in pass 2, the
* various `from*` statics.
*/
var Instant = class {
	constructor(epochNanoseconds) {
		let ns;
		try {
			ns = require_primordials_globals.BigIntCtor(epochNanoseconds);
		} catch {
			throw new require_primordials_error.TypeErrorCtor(`Temporal.Instant: epochNanoseconds must be coercible to BigInt; saw ${describe(epochNanoseconds)}. Pass a bigint literal (e.g. 1700000000000000000n) or a numeric string.`);
		}
		if (!isValidEpochNanoseconds(ns)) throw new require_primordials_error.RangeErrorCtor(`Temporal.Instant: epochNanoseconds out of range; saw ${ns}n. Must be in [-8.64e21, 8.64e21] (±100,000,000 days from 1970-01-01T00:00:00Z).`);
		require_temporal_slots.setInstantSlots(this, ns);
	}
};
function epochNanosecondsImpl() {
	const instant = this;
	if (!require_temporal_slots.hasInstantSlot(instant)) throw new require_primordials_error.TypeErrorCtor(`Temporal.Instant.prototype.epochNanoseconds: receiver lacks [[InitializedTemporalInstant]] internal slot; saw ${describe(instant)}. Call on a Temporal.Instant instance constructed via 'new Temporal.Instant(…)'.`);
	return require_temporal_slots.getInstantNanoseconds(instant);
}
require_primordials_object.ObjectDefineProperty(Instant.prototype, "epochNanoseconds", {
	get: epochNanosecondsImpl,
	configurable: true
});
/**
* One-line description of an arbitrary value for error messages.
*/
function describe(value) {
	if (value === null) return "null";
	if (typeof value === "bigint") return `${value}n`;
	if (typeof value === "object") {
		const ctor = value.constructor;
		return ctor && ctor.name ? `<${ctor.name}>` : "<object>";
	}
	return typeof value === "string" ? require_primordials_json.JSONStringify(value) : String(value);
}

//#endregion
exports.Instant = Instant;
exports.describe = describe;
exports.epochNanosecondsImpl = epochNanosecondsImpl;
exports.isValidEpochNanoseconds = isValidEpochNanoseconds;