/**
 * @license
 * Copyright 2022-2026 Matter.js Authors
 * SPDX-License-Identifier: Apache-2.0
 */
import { Ble } from "#protocol";
import { BlenoBleServer } from "./BlenoBleServer.js";
import { BlenoPeripheralInterface } from "./BlenoPeripheralInterface.js";
import { BleScanner } from "./BleScanner.js";
import { NobleBleCentralInterface } from "./NobleBleChannel.js";
import { NobleBleClient } from "./NobleBleClient.js";
class NodeJsBle extends Ble {
  #options;
  #blePeripheralInstance;
  #bleCentralInstance;
  #bleScanner;
  #bleCentralInterface;
  #blePeripheralInterface;
  constructor(options) {
    super();
    this.#options = options;
    if (options?.environment && options.hciId === void 0) {
      const hciId = options.environment.vars.number("ble.hci.id");
      if (hciId !== void 0) {
        this.#options = {
          ...options,
          hciId
        };
      }
    }
  }
  get #blePeripheralServer() {
    if (this.#blePeripheralInstance === void 0) {
      this.#blePeripheralInstance = new BlenoBleServer(this.#options);
    }
    return this.#blePeripheralInstance;
  }
  get #bleCentralClient() {
    if (this.#bleCentralInstance === void 0) {
      this.#bleCentralInstance = new NobleBleClient(this.#options);
    }
    return this.#bleCentralInstance;
  }
  get peripheralInterface() {
    if (this.#blePeripheralInterface === void 0) {
      this.#blePeripheralInterface = new BlenoPeripheralInterface(this.#blePeripheralServer);
    }
    return this.#blePeripheralInterface;
  }
  get centralInterface() {
    if (this.#bleCentralInterface === void 0) {
      this.#bleCentralInterface = new NobleBleCentralInterface(this.scanner);
    }
    return this.#bleCentralInterface;
  }
  get scanner() {
    if (this.#bleScanner === void 0) {
      this.#bleScanner = new BleScanner(this.#bleCentralClient);
    }
    return this.#bleScanner;
  }
}
export {
  NodeJsBle
};
//# sourceMappingURL=NodeJsBle.js.map
