/**
 * @license
 * Copyright 2026 Matter.js Authors
 * SPDX-License-Identifier: Apache-2.0
 */
import { Behavior } from "#behavior/Behavior.js";
import { DclCertificateService, DclConfig, DclOtaUpdateService, DclVendorInfoService } from "@matter/protocol";
class DclBehavior extends 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(DclCertificateService)) {
      new 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(DclCertificateService);
  }
  /** Get or create the DclVendorInfoService with current configuration. */
  get vendorInfoService() {
    if (!this.env.has(DclVendorInfoService)) {
      new DclVendorInfoService(this.env, {
        dclConfig: this.productionConfig
      });
    }
    return this.env.get(DclVendorInfoService);
  }
  /** Get or create the DclOtaUpdateService with current configuration. */
  get otaUpdateService() {
    if (!this.env.has(DclOtaUpdateService)) {
      new DclOtaUpdateService(this.env, {
        productionDclConfig: this.productionConfig,
        testDclConfig: this.testConfig
      });
    }
    return this.env.get(DclOtaUpdateService);
  }
}
((DclBehavior2) => {
  class State {
    /**
     * Production DCL API endpoint URL.
     *
     * Swagger docs: https://zigbee-alliance.github.io/distributed-compliance-ledger/#/
     */
    productionUrl = DclConfig.production.url;
    /** Test/Development DCL API endpoint URL. */
    testUrl = 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 = {}));
export {
  DclBehavior
};
//# sourceMappingURL=DclBehavior.js.map
