"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 DclBehavior_exports = {};
__export(DclBehavior_exports, {
  DclBehavior: () => DclBehavior
});
module.exports = __toCommonJS(DclBehavior_exports);
var import_Behavior = require("#behavior/Behavior.js");
var import_protocol = require("@matter/protocol");
/**
 * @license
 * Copyright 2026 Matter.js Authors
 * SPDX-License-Identifier: Apache-2.0
 */
class DclBehavior extends import_Behavior.Behavior {
  static id = "dcl";
  /** Get DclConfig for production DCL based on current state. */
  get productionConfig() {
    return { url: this.state.productionUrl };
  }
  /** Get DclConfig for test DCL based on current state. */
  get testConfig() {
    return { url: this.state.testUrl };
  }
  /**
   * Get DclConfig based on production flag.
   * @param isProduction - true for production, false for test
   */
  configForProduction(isProduction) {
    return isProduction ? this.productionConfig : this.testConfig;
  }
  /** Get or create the DclCertificateService with current configuration. */
  get certificateService() {
    if (!this.env.has(import_protocol.DclCertificateService)) {
      new import_protocol.DclCertificateService(this.env, {
        fetchTestCertificates: this.state.fetchTestCertificates,
        fetchGithubCertificates: this.state.fetchGithubCertificates,
        dclConfig: this.productionConfig,
        testDclConfig: this.state.fetchTestCertificates ? this.testConfig : void 0
      });
    }
    return this.env.get(import_protocol.DclCertificateService);
  }
  /** Get or create the DclVendorInfoService with current configuration. */
  get vendorInfoService() {
    if (!this.env.has(import_protocol.DclVendorInfoService)) {
      new import_protocol.DclVendorInfoService(this.env, {
        dclConfig: this.productionConfig
      });
    }
    return this.env.get(import_protocol.DclVendorInfoService);
  }
  /** Get or create the DclOtaUpdateService with current configuration. */
  get otaUpdateService() {
    if (!this.env.has(import_protocol.DclOtaUpdateService)) {
      new import_protocol.DclOtaUpdateService(this.env, {
        productionDclConfig: this.productionConfig,
        testDclConfig: this.testConfig
      });
    }
    return this.env.get(import_protocol.DclOtaUpdateService);
  }
}
((DclBehavior2) => {
  class State {
    /**
     * Production DCL API endpoint URL.
     *
     * Swagger docs: https://zigbee-alliance.github.io/distributed-compliance-ledger/#/
     */
    productionUrl = import_protocol.DclConfig.production.url;
    /** Test/Development DCL API endpoint URL. */
    testUrl = import_protocol.DclConfig.test.url;
    /** Whether to fetch test certificates in addition to production ones. */
    fetchTestCertificates = false;
    /** Whether to fetch development certificates from GitHub (only when fetchTestCertificates is true). */
    fetchGithubCertificates = true;
  }
  DclBehavior2.State = State;
})(DclBehavior || (DclBehavior = {}));
//# sourceMappingURL=DclBehavior.js.map
