"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var MockNetwork_exports = {};
__export(MockNetwork_exports, {
  MockNetwork: () => MockNetwork
});
module.exports = __toCommonJS(MockNetwork_exports);
var import_Channel = require("#net/Channel.js");
var import_Ip = require("../../util/Ip.js");
var import_Network = require("../Network.js");
var import_MockRouter = require("./MockRouter.js");
var import_MockUdpChannel = require("./MockUdpChannel.js");
/**
 * @license
 * Copyright 2022-2026 Matter.js Authors
 * SPDX-License-Identifier: Apache-2.0
 */
class MockNetwork extends import_Network.Network {
  router = (0, import_MockRouter.MockRouter)();
  #simulator;
  #intf;
  constructor(simulator, mac, ips) {
    super();
    this.#simulator = simulator;
    this.#intf = {
      mac,
      ipV4: ips.filter((ip) => (0, import_Ip.isIPv4)(ip)),
      ipV6: ips.filter((ip) => !(0, import_Ip.isIPv4)(ip))
    };
    this.#simulator.router.add(this.router);
  }
  get simulator() {
    return this.#simulator;
  }
  getNetInterfaces() {
    return [{ name: "fake0" }];
  }
  getIpMac(name) {
    if (name !== "fake0") {
      throw new import_Network.NetworkError(`No such interface ${name}`);
    }
    return this.#intf;
  }
  createUdpChannel(options) {
    return Promise.resolve(new import_MockUdpChannel.MockUdpChannel(this, options));
  }
  supports(type, _address) {
    return type === import_Channel.ChannelType.UDP;
  }
  async close() {
    this.#simulator.router.delete(this.router);
  }
}
//# sourceMappingURL=MockNetwork.js.map
