/**
 * @license
 * Copyright 2022-2026 Matter.js Authors
 * SPDX-License-Identifier: Apache-2.0
 */
import { Environmental } from "#environment/Environmental.js";
import { ImplementationError } from "#MatterError.js";
import { AppAddress } from "#net/AppAddress.js";
import { MqttEndpointFactory } from "./MqttEndpointFactory.js";
class MqttService {
  #factory;
  constructor(factory) {
    this.#factory = factory;
  }
  static [Environmental.create](env) {
    const factory = env.get(MqttEndpointFactory);
    const instance = new this(factory);
    env.set(MqttService, instance);
    return instance;
  }
  connect(options) {
    const addr = AppAddress.for(options.address);
    if (addr.appProtocol !== "mqtt") {
      throw new ImplementationError(`Unsupported address ${addr} for MQTT connection`);
    }
    return this.#factory.connect(options);
  }
}
export {
  MqttService
};
//# sourceMappingURL=MqttService.js.map
