"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 BleAdvertiser_exports = {};
__export(BleAdvertiser_exports, {
  BleAdvertiser: () => BleAdvertiser
});
module.exports = __toCommonJS(BleAdvertiser_exports);
var import_general = require("@matter/general");
var import_model = require("@matter/model");
var import_types = require("@matter/types");
var import_Advertiser = require("../Advertiser.js");
var import_CommissioningMode = require("../CommissioningMode.js");
var import_BleAdvertisement = require("./BleAdvertisement.js");
/**
 * @license
 * Copyright 2022-2026 Matter.js Authors
 * SPDX-License-Identifier: Apache-2.0
 */
class BleAdvertiser extends import_Advertiser.Advertiser {
  #peripheral;
  #config;
  #isClosed = false;
  constructor(peripheral, options) {
    super(options?.lifetime);
    this.#peripheral = peripheral;
    this.#config = BleAdvertiser.Configuration(options);
  }
  get peripheral() {
    return this.#peripheral;
  }
  get config() {
    return this.#config;
  }
  getAdvertisement(description) {
    this.#assertOpen();
    if (description.kind !== "commissionable" || description.mode !== import_CommissioningMode.CommissioningMode.Basic) {
      return;
    }
    return new import_BleAdvertisement.BleAdvertisement(this, description);
  }
  #assertOpen() {
    if (this.#isClosed) {
      throw new import_general.ImplementationError("Illegal operation on closed BleBroadcaster");
    }
  }
}
((BleAdvertiser2) => {
  function Configuration(options) {
    return {
      timeout: import_types.MAXIMUM_COMMISSIONING_TIMEOUT,
      earlyInterval: (0, import_general.Millis)(20),
      lateInterval: (0, import_general.Millis)(150),
      extendedInterval: (0, import_general.Millis)(1285),
      ...options
    };
  }
  BleAdvertiser2.Configuration = Configuration;
  BleAdvertiser2.OptionsSchema = new import_model.DatatypeModel(
    { name: "BleAdvertiserOptions", type: "struct" },
    (0, import_model.FieldElement)({ name: "add", type: "octstr" }),
    (0, import_model.FieldElement)({ name: "timeout", type: "uint32" }),
    (0, import_model.FieldElement)({ name: "earlyInterval", type: "uint32" }),
    (0, import_model.FieldElement)({ name: "lateInterval", type: "uint32" }),
    (0, import_model.FieldElement)({ name: "extendedInterval", type: "uint32" })
  );
})(BleAdvertiser || (BleAdvertiser = {}));
//# sourceMappingURL=BleAdvertiser.js.map
