"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 PeerSubscription_exports = {};
__export(PeerSubscription_exports, {
  PeerSubscription: () => PeerSubscription
});
module.exports = __toCommonJS(PeerSubscription_exports);
var import_general = require("#general");
var import_Subscription = require("#interaction/Subscription.js");
var import_ClientSubscription = require("./ClientSubscription.js");
/**
 * @license
 * Copyright 2022-2026 Matter.js Authors
 * SPDX-License-Identifier: Apache-2.0
 */
class PeerSubscription extends import_ClientSubscription.ClientSubscription {
  interactionModelRevision;
  maxInterval;
  #maxPeerResponseTime;
  isReading = false;
  timeoutAt;
  constructor(config) {
    const {
      maxPeerResponseTime,
      response: { subscriptionId, interactionModelRevision, maxInterval }
    } = config;
    super(config);
    this.subscriptionId = subscriptionId;
    this.interactionModelRevision = interactionModelRevision;
    this.maxInterval = maxInterval;
    this.#maxPeerResponseTime = maxPeerResponseTime;
  }
  get timeout() {
    return (0, import_general.Millis)((0, import_general.Seconds)(this.maxInterval) + this.#maxPeerResponseTime * 2);
  }
  timedOut() {
    this.logger.info(
      "Subscription",
      import_general.Diagnostic.strong(import_Subscription.Subscription.idStrOf(this.subscriptionId)),
      "timed out after",
      import_general.Diagnostic.strong(import_general.Duration.format(this.timeout))
    );
    this.close();
  }
}
//# sourceMappingURL=PeerSubscription.js.map
