/**
 * @license
 * Copyright 2022-2026 Matter.js Authors
 * SPDX-License-Identifier: Apache-2.0
 */
import { Seconds, UINT16_MAX } from "#general";
import { MalformedRequestError } from "./MalformedRequestError.js";
import { Read } from "./Read.js";
function Subscribe(options, ...selectors) {
  const subscribe = Read(options, ...selectors);
  const { keepSubscriptions, minIntervalFloor, maxIntervalCeiling } = options;
  subscribe.keepSubscriptions = keepSubscriptions ?? true;
  if (minIntervalFloor !== void 0) {
    if (minIntervalFloor < 0 || Seconds.of(minIntervalFloor) > UINT16_MAX) {
      throw new MalformedRequestError(`Minimum interval floor ${Seconds.of(minIntervalFloor)} is out of range`);
    }
    subscribe.minIntervalFloor = minIntervalFloor;
  }
  if (maxIntervalCeiling !== void 0) {
    if (maxIntervalCeiling < 0 || Seconds.of(maxIntervalCeiling) > UINT16_MAX) {
      throw new MalformedRequestError(
        `Maximum interval ceiling ${Seconds.of(maxIntervalCeiling)} is out of range`
      );
    }
    subscribe.maxIntervalCeiling = maxIntervalCeiling;
  }
  return subscribe;
}
export {
  Subscribe
};
//# sourceMappingURL=Subscribe.js.map
