"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 power_topology_exports = {};
__export(power_topology_exports, {
  PowerTopology: () => PowerTopology,
  PowerTopologyCluster: () => PowerTopologyCluster
});
module.exports = __toCommonJS(power_topology_exports);
var import_MutableCluster = require("../cluster/mutation/MutableCluster.js");
var import_Cluster = require("../cluster/Cluster.js");
var import_TlvArray = require("../tlv/TlvArray.js");
var import_EndpointNumber = require("../datatype/EndpointNumber.js");
var import_BitmapSchema = require("../schema/BitmapSchema.js");
var import_ClusterRegistry = require("../cluster/ClusterRegistry.js");
/**
 * @license
 * Copyright 2022-2025 Matter.js Authors
 * SPDX-License-Identifier: Apache-2.0
 */
var PowerTopology;
((PowerTopology2) => {
  let Feature;
  ((Feature2) => {
    Feature2["NodeTopology"] = "NodeTopology";
    Feature2["TreeTopology"] = "TreeTopology";
    Feature2["SetTopology"] = "SetTopology";
    Feature2["DynamicPowerFlow"] = "DynamicPowerFlow";
  })(Feature = PowerTopology2.Feature || (PowerTopology2.Feature = {}));
  PowerTopology2.SetTopologyComponent = import_MutableCluster.MutableCluster.Component({
    attributes: {
      /**
       * Indicates the list of endpoints capable of providing power to and/or consuming power from the endpoint
       * hosting this server.
       *
       * @see {@link MatterSpecification.v142.Core} § 11.8.5.1
       */
      availableEndpoints: (0, import_Cluster.FixedAttribute)(0, (0, import_TlvArray.TlvArray)(import_EndpointNumber.TlvEndpointNumber, { maxLength: 20 }), { default: [] })
    }
  });
  PowerTopology2.DynamicPowerFlowComponent = import_MutableCluster.MutableCluster.Component({
    attributes: {
      /**
       * Indicates the current list of endpoints currently providing or consuming power to or from the endpoint
       * hosting this server. This list shall be a subset of the value of the AvailableEndpoints attribute.
       *
       * @see {@link MatterSpecification.v142.Core} § 11.8.5.2
       */
      activeEndpoints: (0, import_Cluster.Attribute)(
        1,
        (0, import_TlvArray.TlvArray)(import_EndpointNumber.TlvEndpointNumber, { maxLength: 20 }),
        { persistent: true, default: [] }
      )
    }
  });
  PowerTopology2.Base = import_MutableCluster.MutableCluster.Component({
    id: 156,
    name: "PowerTopology",
    revision: 1,
    features: {
      /**
       * This endpoint provides or consumes power to/from the entire node
       */
      nodeTopology: (0, import_BitmapSchema.BitFlag)(0),
      /**
       * This endpoint provides or consumes power to/from itself and its child endpoints
       */
      treeTopology: (0, import_BitmapSchema.BitFlag)(1),
      /**
       * This endpoint provides or consumes power to/from a specified set of endpoints
       */
      setTopology: (0, import_BitmapSchema.BitFlag)(2),
      /**
       * The specified set of endpoints may change
       */
      dynamicPowerFlow: (0, import_BitmapSchema.BitFlag)(3)
    },
    /**
     * This metadata controls which PowerTopologyCluster elements matter.js activates for specific feature
     * combinations.
     */
    extensions: import_MutableCluster.MutableCluster.Extensions(
      { flags: { setTopology: true }, component: PowerTopology2.SetTopologyComponent },
      { flags: { dynamicPowerFlow: true }, component: PowerTopology2.DynamicPowerFlowComponent },
      { flags: { dynamicPowerFlow: true, setTopology: false }, component: false },
      { flags: { nodeTopology: true, treeTopology: true }, component: false },
      { flags: { nodeTopology: true, setTopology: true }, component: false },
      { flags: { treeTopology: true, setTopology: true }, component: false },
      { flags: { nodeTopology: false, treeTopology: false, setTopology: false }, component: false }
    )
  });
  PowerTopology2.ClusterInstance = import_MutableCluster.MutableCluster.ExtensibleOnly(PowerTopology2.Base);
  PowerTopology2.Cluster = PowerTopology2.ClusterInstance;
  const SET = { setTopology: true };
  const DYPF = { dynamicPowerFlow: true };
  PowerTopology2.CompleteInstance = (0, import_MutableCluster.MutableCluster)({
    id: PowerTopology2.Base.id,
    name: PowerTopology2.Base.name,
    revision: PowerTopology2.Base.revision,
    features: PowerTopology2.Base.features,
    attributes: {
      availableEndpoints: import_MutableCluster.MutableCluster.AsConditional(
        PowerTopology2.SetTopologyComponent.attributes.availableEndpoints,
        { mandatoryIf: [SET] }
      ),
      activeEndpoints: import_MutableCluster.MutableCluster.AsConditional(
        PowerTopology2.DynamicPowerFlowComponent.attributes.activeEndpoints,
        { mandatoryIf: [DYPF] }
      )
    }
  });
  PowerTopology2.Complete = PowerTopology2.CompleteInstance;
})(PowerTopology || (PowerTopology = {}));
const PowerTopologyCluster = PowerTopology.Cluster;
import_ClusterRegistry.ClusterRegistry.register(PowerTopology.Complete);
//# sourceMappingURL=power-topology.js.map
