import { Temporal } from "@js-temporal/polyfill";
import "urlpattern-polyfill";
globalThis.addEventListener = () => {};
import { t as test } from "../testing-BQeTO4ss.mjs";
import { l as AssertionError, t as assertEquals } from "../assert_equals-Ew3jOFa3.mjs";
import { t as assertNotEquals } from "../assert_not_equals--wG9hV7u.mjs";
import { t as createExponentialBackoffPolicy } from "../retry-B_E3V_Dx.mjs";
//#region src/federation/retry.test.ts
test("createExponentialBackoffPolicy()", () => {
	const policy = createExponentialBackoffPolicy({ maxAttempts: 4 });
	const noMatter = Temporal.Duration.from({ seconds: 0 });
	for (let i = 0; i < 10; i++) assertDurationRange(policy({
		elapsedTime: noMatter,
		attempts: 0
	}), { seconds: 1 }, { seconds: 2 });
	for (let i = 0; i < 10; i++) assertDurationRange(policy({
		elapsedTime: noMatter,
		attempts: 1
	}), { seconds: 2 }, { seconds: 4 });
	for (let i = 0; i < 10; i++) assertDurationRange(policy({
		elapsedTime: noMatter,
		attempts: 2
	}), { seconds: 4 }, { seconds: 8 });
	for (let i = 0; i < 10; i++) assertDurationRange(policy({
		elapsedTime: noMatter,
		attempts: 3
	}), { seconds: 8 }, { seconds: 16 });
	assertEquals(policy({
		elapsedTime: noMatter,
		attempts: 4
	}), null);
});
function assertDurationRange(actual, min, max) {
	assertNotEquals(actual, null);
	if (actual == null) return;
	const minDuration = Temporal.Duration.from(min);
	const maxDuration = Temporal.Duration.from(max);
	if (Temporal.Duration.compare(actual, minDuration) < 0 || Temporal.Duration.compare(actual, maxDuration) > 0) throw new AssertionError(`Expected ${actual} to be between ${min} and ${max}`);
}
//#endregion
export {};
