/**
 * @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(manipulator) {
  const routes = /* @__PURE__ */ new Set();
  const router = function router2(packet) {
    if (manipulator) {
      const manipulatedPacket = manipulator(packet);
      if (manipulatedPacket === null) {
        return;
      }
      packet = manipulatedPacket;
    }
    for (const route of routes) {
      try {
        route(packet);
      } catch (e) {
        logger.error("Unhandled error in network listener", e);
      }
    }
  };
  router.add = routes.add.bind(routes);
  router.delete = routes.delete.bind(routes);
  return router;
}
export {
  MockRouter
};
//# sourceMappingURL=MockRouter.js.map
