/**
 * @license
 * Copyright 2022-2026 Matter.js Authors
 * SPDX-License-Identifier: Apache-2.0
 */
import { Logger } from "#log/Logger.js";
const logger = Logger.get("MockRouter");
function MockRouter() {
  const routes = /* @__PURE__ */ new Set();
  let route = (packet) => {
    for (const route2 of routes) {
      Promise.resolve().then(() => route2(packet)).catch((e) => logger.error("Unhandled error in network listener", e));
    }
  };
  const router = function router2(packet) {
    route(packet);
  };
  router.intercept = (intercept) => {
    const next = route;
    route = (packet) => {
      intercept(packet, next);
    };
  };
  router.add = routes.add.bind(routes);
  router.delete = routes.delete.bind(routes);
  return router;
}
export {
  MockRouter
};
//# sourceMappingURL=MockRouter.js.map
