"use strict";
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
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 __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
  // If the importer is in node compatibility mode or this is not an ESM
  // file that has been converted to a CommonJS file using a Babel-
  // compatible transform (i.e. "__esModule" has not been set), then set
  // "default" to the CommonJS "module.exports" for node compatibility.
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
  mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var integrationTestSuiteShared_exports = {};
__export(integrationTestSuiteShared_exports, {
  prepareDriver: () => prepareDriver,
  prepareMocks: () => prepareMocks
});
module.exports = __toCommonJS(integrationTestSuiteShared_exports);
var __import_meta_url = typeof document === "undefined" ? new (require("url".replace("", ""))).URL("file:" + __filename).href : document.currentScript && document.currentScript.src || new URL("main.js", document.baseURI).href;
var import_shared = require("@zwave-js/shared");
var import_testing = require("@zwave-js/testing");
var import_node_path = __toESM(require("node:path"), 1);
var import_node_url = require("node:url");
var import_Testing = require("../../Testing.js");
var import_DriverMock = require("../driver/DriverMock.js");
const __dirname = import_node_path.default.dirname((0, import_node_url.fileURLToPath)(__import_meta_url));
function prepareDriver(cacheDir = import_node_path.default.join(__dirname, "cache"), logToFile = false, additionalOptions = {}) {
  additionalOptions.testingHooks ??= {};
  additionalOptions.testingHooks.skipFirmwareIdentification = additionalOptions.bootloaderMode === "recover" || additionalOptions.bootloaderMode == void 0;
  const logConfig = additionalOptions.logConfig ?? {};
  if (logToFile) {
    logConfig.enabled = true;
    logConfig.logToFile = true;
    logConfig.filename = import_node_path.default.join(cacheDir, "logs", "zwavejs_%DATE%.log");
    logConfig.level ??= "debug";
  }
  return (0, import_DriverMock.createAndStartDriverWithMockPort)({
    ...additionalOptions,
    logConfig,
    securityKeys: {
      S0_Legacy: import_shared.Bytes.from("0102030405060708090a0b0c0d0e0f10", "hex"),
      S2_Unauthenticated: import_shared.Bytes.from("11111111111111111111111111111111", "hex"),
      S2_Authenticated: import_shared.Bytes.from("22222222222222222222222222222222", "hex"),
      S2_AccessControl: import_shared.Bytes.from("33333333333333333333333333333333", "hex")
    },
    storage: {
      ...additionalOptions.storage,
      cacheDir,
      lockDir: import_node_path.default.join(cacheDir, "locks")
    }
  });
}
__name(prepareDriver, "prepareDriver");
async function prepareMocks(mockPort, serial, controller = {}, nodes = []) {
  const mockController = await import_testing.MockController.create({
    homeId: 2119630849,
    ownNodeId: 1,
    ...controller,
    mockPort,
    serial
  });
  mockController.defineBehavior(...(0, import_Testing.createDefaultMockControllerBehaviors)());
  const mockNodes = [];
  for (const node of nodes) {
    const mockNode = await import_testing.MockNode.create({
      ...node,
      controller: mockController
    });
    mockController.addNode(mockNode);
    mockNodes.push(mockNode);
    mockNode.defineBehavior(...(0, import_Testing.createDefaultMockNodeBehaviors)());
  }
  return { mockController, mockNodes };
}
__name(prepareMocks, "prepareMocks");
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  prepareDriver,
  prepareMocks
});
//# sourceMappingURL=integrationTestSuiteShared.js.map
