
      import { Temporal } from "@js-temporal/polyfill";
      import { URLPattern } from "urlpattern-polyfill";
      globalThis.addEventListener = () => {};
    
import { Router, RouterError } from "../lookup-Dvhilldd.js";
import { assertEquals } from "../assert_equals-DSbWqCm3.js";
import { assert } from "../assert-MZs1qjMx.js";
import "../assert_instance_of-DHz7EHNU.js";
import { test } from "../testing-cwlO8Sns.js";
import "../std__assert-DWivtrGR.js";
import { assertFalse } from "../assert_rejects-Ce45JcFg.js";
import { assertThrows } from "../assert_throws-BNXdRGWP.js";
import "../assert_not_equals-C80BG-_5.js";

//#region src/federation/router.test.ts
function setUp(options = {}) {
	const router = new Router(options);
	router.add("/users/{name}", "user");
	router.add("/users/{name}/posts/{postId}" + (options.trailingSlashInsensitive ? "/" : ""), "post");
	return router;
}
test("Router.clone()", () => {
	const original = setUp();
	const clone = original.clone();
	clone.add("/users/{name}/friends", "friends");
	assert(clone.has("friends"));
	assertEquals(clone.route("/users/alice/friends"), {
		name: "friends",
		template: "/users/{name}/friends",
		values: { name: "alice" }
	});
	assertFalse(original.has("friends"));
	assertEquals(original.route("/users/alice/friends"), null);
});
test("Router.add()", () => {
	const router = new Router();
	assertEquals(router.add("/users", "users"), /* @__PURE__ */ new Set());
	assertEquals(router.add("/users/{name}", "user"), new Set(["name"]));
	assertEquals(router.add("/users/{name}/posts/{postId}", "post"), new Set(["name", "postId"]));
	assertThrows(() => router.add("foo", "name"), RouterError);
});
test("Router.route()", () => {
	let router = setUp();
	assertEquals(router.route("/users/alice"), {
		name: "user",
		template: "/users/{name}",
		values: { name: "alice" }
	});
	assertEquals(router.route("/users/bob/"), null);
	assertEquals(router.route("/users/alice/posts/123"), {
		name: "post",
		template: "/users/{name}/posts/{postId}",
		values: {
			name: "alice",
			postId: "123"
		}
	});
	assertEquals(router.route("/users/bob/posts/456/"), null);
	router = setUp({ trailingSlashInsensitive: true });
	assertEquals(router.route("/users/alice"), {
		name: "user",
		template: "/users/{name}",
		values: { name: "alice" }
	});
	assertEquals(router.route("/users/bob/"), {
		name: "user",
		template: "/users/{name}",
		values: { name: "bob" }
	});
	assertEquals(router.route("/users/alice/posts/123"), {
		name: "post",
		template: "/users/{name}/posts/{postId}/",
		values: {
			name: "alice",
			postId: "123"
		}
	});
	assertEquals(router.route("/users/bob/posts/456/"), {
		name: "post",
		template: "/users/{name}/posts/{postId}/",
		values: {
			name: "bob",
			postId: "456"
		}
	});
});
test("Router.build()", () => {
	const router = setUp();
	assertEquals(router.build("user", { name: "alice" }), "/users/alice");
	assertEquals(router.build("post", {
		name: "alice",
		postId: "123"
	}), "/users/alice/posts/123");
});

//#endregion