/**
 * @license
 * Copyright 2022-2026 Matter.js Authors
 * SPDX-License-Identifier: Apache-2.0
 */
import { NodeSession } from "#session/NodeSession.js";
import { INTERACTION_PROTOCOL_ID } from "@matter/types";
import { MRP } from "./MRP.js";
class ExchangeProvider {
  constructor(exchangeManager) {
    this.exchangeManager = exchangeManager;
  }
  /**
   * Ensure the peer is reachable without creating an exchange.
   *
   * The default implementation is a no-op (already connected).
   */
  async connect(_options) {
  }
}
class DedicatedChannelExchangeProvider extends ExchangeProvider {
  #session;
  constructor(exchangeManager, session) {
    super(exchangeManager);
    this.#session = session;
  }
  get maxPathsPerInvoke() {
    return this.#session.parameters.maxPathsPerInvoke;
  }
  async initiateExchange() {
    return this.exchangeManager.initiateExchangeForSession(this.#session, INTERACTION_PROTOCOL_ID);
  }
  get channelType() {
    return this.#session.channel.channel.type;
  }
  get session() {
    return this.#session;
  }
  maximumPeerResponseTime(expectedProcessingTime = MRP.DEFAULT_EXPECTED_PROCESSING_TIME, includeMaximumSendingTime) {
    return this.exchangeManager.calculateMaximumPeerResponseTimeMsFor(
      this.#session,
      expectedProcessingTime,
      includeMaximumSendingTime
    );
  }
  get peerAddress() {
    if (NodeSession.is(this.#session)) {
      return this.#session.peerAddress;
    }
  }
}
export {
  DedicatedChannelExchangeProvider,
  ExchangeProvider
};
//# sourceMappingURL=ExchangeProvider.js.map
