/**
 * @license
 * Copyright 2022-2026 Matter.js Authors
 * SPDX-License-Identifier: Apache-2.0
 */
import { MutableCluster } from "../cluster/mutation/MutableCluster.js";
import {
  OptionalAttribute,
  FixedAttribute,
  OptionalFixedAttribute,
  OptionalEvent,
  Attribute
} from "../cluster/Cluster.js";
import { TlvUInt32, TlvUInt16, TlvEnum, TlvUInt8 } from "../tlv/TlvNumber.js";
import { TlvNullable } from "../tlv/TlvNullable.js";
import { TlvBoolean } from "../tlv/TlvBoolean.js";
import { TlvArray } from "../tlv/TlvArray.js";
import { Priority } from "../globals/Priority.js";
import { TlvField, TlvObject } from "../tlv/TlvObject.js";
import { TlvString } from "../tlv/TlvString.js";
import { BitFlag } from "../schema/BitmapSchema.js";
import { TlvEndpointNumber } from "../datatype/EndpointNumber.js";
import { ClusterRegistry } from "../cluster/ClusterRegistry.js";
var PowerSource;
((PowerSource2) => {
  let Feature;
  ((Feature2) => {
    Feature2["Wired"] = "Wired";
    Feature2["Battery"] = "Battery";
    Feature2["Rechargeable"] = "Rechargeable";
    Feature2["Replaceable"] = "Replaceable";
  })(Feature = PowerSource2.Feature || (PowerSource2.Feature = {}));
  let WiredCurrentType;
  ((WiredCurrentType2) => {
    WiredCurrentType2[WiredCurrentType2["Ac"] = 0] = "Ac";
    WiredCurrentType2[WiredCurrentType2["Dc"] = 1] = "Dc";
  })(WiredCurrentType = PowerSource2.WiredCurrentType || (PowerSource2.WiredCurrentType = {}));
  let WiredFault;
  ((WiredFault2) => {
    WiredFault2[WiredFault2["Unspecified"] = 0] = "Unspecified";
    WiredFault2[WiredFault2["OverVoltage"] = 1] = "OverVoltage";
    WiredFault2[WiredFault2["UnderVoltage"] = 2] = "UnderVoltage";
  })(WiredFault = PowerSource2.WiredFault || (PowerSource2.WiredFault = {}));
  PowerSource2.TlvWiredFaultChangeEvent = TlvObject({
    /**
     * This field shall represent the set of faults currently detected, as per ActiveWiredFaults.
     *
     * @see {@link MatterSpecification.v142.Core} § 11.7.8.1.1
     */
    current: TlvField(0, TlvArray(TlvEnum(), { maxLength: 8 })),
    /**
     * This field shall represent the set of faults detected prior to this change event, as per ActiveWiredFaults.
     *
     * @see {@link MatterSpecification.v142.Core} § 11.7.8.1.2
     */
    previous: TlvField(1, TlvArray(TlvEnum(), { maxLength: 8 }))
  });
  let BatChargeLevel;
  ((BatChargeLevel2) => {
    BatChargeLevel2[BatChargeLevel2["Ok"] = 0] = "Ok";
    BatChargeLevel2[BatChargeLevel2["Warning"] = 1] = "Warning";
    BatChargeLevel2[BatChargeLevel2["Critical"] = 2] = "Critical";
  })(BatChargeLevel = PowerSource2.BatChargeLevel || (PowerSource2.BatChargeLevel = {}));
  let BatReplaceability;
  ((BatReplaceability2) => {
    BatReplaceability2[BatReplaceability2["Unspecified"] = 0] = "Unspecified";
    BatReplaceability2[BatReplaceability2["NotReplaceable"] = 1] = "NotReplaceable";
    BatReplaceability2[BatReplaceability2["UserReplaceable"] = 2] = "UserReplaceable";
    BatReplaceability2[BatReplaceability2["FactoryReplaceable"] = 3] = "FactoryReplaceable";
  })(BatReplaceability = PowerSource2.BatReplaceability || (PowerSource2.BatReplaceability = {}));
  let BatFault;
  ((BatFault2) => {
    BatFault2[BatFault2["Unspecified"] = 0] = "Unspecified";
    BatFault2[BatFault2["OverTemp"] = 1] = "OverTemp";
    BatFault2[BatFault2["UnderTemp"] = 2] = "UnderTemp";
  })(BatFault = PowerSource2.BatFault || (PowerSource2.BatFault = {}));
  PowerSource2.TlvBatFaultChangeEvent = TlvObject({
    /**
     * This field shall represent the set of faults currently detected, as per ActiveBatFaults.
     *
     * @see {@link MatterSpecification.v142.Core} § 11.7.8.2.1
     */
    current: TlvField(0, TlvArray(TlvEnum(), { maxLength: 8 })),
    /**
     * This field shall represent the set of faults detected prior to this change event, as per ActiveBatFaults.
     *
     * @see {@link MatterSpecification.v142.Core} § 11.7.8.2.2
     */
    previous: TlvField(1, TlvArray(TlvEnum(), { maxLength: 8 }))
  });
  let BatCommonDesignation;
  ((BatCommonDesignation2) => {
    BatCommonDesignation2[BatCommonDesignation2["Unspecified"] = 0] = "Unspecified";
    BatCommonDesignation2[BatCommonDesignation2["Aaa"] = 1] = "Aaa";
    BatCommonDesignation2[BatCommonDesignation2["Aa"] = 2] = "Aa";
    BatCommonDesignation2[BatCommonDesignation2["C"] = 3] = "C";
    BatCommonDesignation2[BatCommonDesignation2["D"] = 4] = "D";
    BatCommonDesignation2[BatCommonDesignation2["4V5"] = 5] = "4V5";
    BatCommonDesignation2[BatCommonDesignation2["6V0"] = 6] = "6V0";
    BatCommonDesignation2[BatCommonDesignation2["9V0"] = 7] = "9V0";
    BatCommonDesignation2[BatCommonDesignation2["12Aa"] = 8] = "12Aa";
    BatCommonDesignation2[BatCommonDesignation2["Aaaa"] = 9] = "Aaaa";
    BatCommonDesignation2[BatCommonDesignation2["A"] = 10] = "A";
    BatCommonDesignation2[BatCommonDesignation2["B"] = 11] = "B";
    BatCommonDesignation2[BatCommonDesignation2["F"] = 12] = "F";
    BatCommonDesignation2[BatCommonDesignation2["N"] = 13] = "N";
    BatCommonDesignation2[BatCommonDesignation2["No6"] = 14] = "No6";
    BatCommonDesignation2[BatCommonDesignation2["SubC"] = 15] = "SubC";
    BatCommonDesignation2[BatCommonDesignation2["A23"] = 16] = "A23";
    BatCommonDesignation2[BatCommonDesignation2["A27"] = 17] = "A27";
    BatCommonDesignation2[BatCommonDesignation2["Ba5800"] = 18] = "Ba5800";
    BatCommonDesignation2[BatCommonDesignation2["Duplex"] = 19] = "Duplex";
    BatCommonDesignation2[BatCommonDesignation2["4Sr44"] = 20] = "4Sr44";
    BatCommonDesignation2[BatCommonDesignation2["E523"] = 21] = "E523";
    BatCommonDesignation2[BatCommonDesignation2["E531"] = 22] = "E531";
    BatCommonDesignation2[BatCommonDesignation2["15V0"] = 23] = "15V0";
    BatCommonDesignation2[BatCommonDesignation2["22V5"] = 24] = "22V5";
    BatCommonDesignation2[BatCommonDesignation2["30V0"] = 25] = "30V0";
    BatCommonDesignation2[BatCommonDesignation2["45V0"] = 26] = "45V0";
    BatCommonDesignation2[BatCommonDesignation2["67V5"] = 27] = "67V5";
    BatCommonDesignation2[BatCommonDesignation2["J"] = 28] = "J";
    BatCommonDesignation2[BatCommonDesignation2["Cr123A"] = 29] = "Cr123A";
    BatCommonDesignation2[BatCommonDesignation2["Cr2"] = 30] = "Cr2";
    BatCommonDesignation2[BatCommonDesignation2["2Cr5"] = 31] = "2Cr5";
    BatCommonDesignation2[BatCommonDesignation2["CrP2"] = 32] = "CrP2";
    BatCommonDesignation2[BatCommonDesignation2["CrV3"] = 33] = "CrV3";
    BatCommonDesignation2[BatCommonDesignation2["Sr41"] = 34] = "Sr41";
    BatCommonDesignation2[BatCommonDesignation2["Sr43"] = 35] = "Sr43";
    BatCommonDesignation2[BatCommonDesignation2["Sr44"] = 36] = "Sr44";
    BatCommonDesignation2[BatCommonDesignation2["Sr45"] = 37] = "Sr45";
    BatCommonDesignation2[BatCommonDesignation2["Sr48"] = 38] = "Sr48";
    BatCommonDesignation2[BatCommonDesignation2["Sr54"] = 39] = "Sr54";
    BatCommonDesignation2[BatCommonDesignation2["Sr55"] = 40] = "Sr55";
    BatCommonDesignation2[BatCommonDesignation2["Sr57"] = 41] = "Sr57";
    BatCommonDesignation2[BatCommonDesignation2["Sr58"] = 42] = "Sr58";
    BatCommonDesignation2[BatCommonDesignation2["Sr59"] = 43] = "Sr59";
    BatCommonDesignation2[BatCommonDesignation2["Sr60"] = 44] = "Sr60";
    BatCommonDesignation2[BatCommonDesignation2["Sr63"] = 45] = "Sr63";
    BatCommonDesignation2[BatCommonDesignation2["Sr64"] = 46] = "Sr64";
    BatCommonDesignation2[BatCommonDesignation2["Sr65"] = 47] = "Sr65";
    BatCommonDesignation2[BatCommonDesignation2["Sr66"] = 48] = "Sr66";
    BatCommonDesignation2[BatCommonDesignation2["Sr67"] = 49] = "Sr67";
    BatCommonDesignation2[BatCommonDesignation2["Sr68"] = 50] = "Sr68";
    BatCommonDesignation2[BatCommonDesignation2["Sr69"] = 51] = "Sr69";
    BatCommonDesignation2[BatCommonDesignation2["Sr516"] = 52] = "Sr516";
    BatCommonDesignation2[BatCommonDesignation2["Sr731"] = 53] = "Sr731";
    BatCommonDesignation2[BatCommonDesignation2["Sr712"] = 54] = "Sr712";
    BatCommonDesignation2[BatCommonDesignation2["Lr932"] = 55] = "Lr932";
    BatCommonDesignation2[BatCommonDesignation2["A5"] = 56] = "A5";
    BatCommonDesignation2[BatCommonDesignation2["A10"] = 57] = "A10";
    BatCommonDesignation2[BatCommonDesignation2["A13"] = 58] = "A13";
    BatCommonDesignation2[BatCommonDesignation2["A312"] = 59] = "A312";
    BatCommonDesignation2[BatCommonDesignation2["A675"] = 60] = "A675";
    BatCommonDesignation2[BatCommonDesignation2["Ac41E"] = 61] = "Ac41E";
    BatCommonDesignation2[BatCommonDesignation2["E10180"] = 62] = "E10180";
    BatCommonDesignation2[BatCommonDesignation2["E10280"] = 63] = "E10280";
    BatCommonDesignation2[BatCommonDesignation2["E10440"] = 64] = "E10440";
    BatCommonDesignation2[BatCommonDesignation2["E14250"] = 65] = "E14250";
    BatCommonDesignation2[BatCommonDesignation2["E14430"] = 66] = "E14430";
    BatCommonDesignation2[BatCommonDesignation2["E14500"] = 67] = "E14500";
    BatCommonDesignation2[BatCommonDesignation2["E14650"] = 68] = "E14650";
    BatCommonDesignation2[BatCommonDesignation2["E15270"] = 69] = "E15270";
    BatCommonDesignation2[BatCommonDesignation2["E16340"] = 70] = "E16340";
    BatCommonDesignation2[BatCommonDesignation2["Rcr123A"] = 71] = "Rcr123A";
    BatCommonDesignation2[BatCommonDesignation2["E17500"] = 72] = "E17500";
    BatCommonDesignation2[BatCommonDesignation2["E17670"] = 73] = "E17670";
    BatCommonDesignation2[BatCommonDesignation2["E18350"] = 74] = "E18350";
    BatCommonDesignation2[BatCommonDesignation2["E18500"] = 75] = "E18500";
    BatCommonDesignation2[BatCommonDesignation2["E18650"] = 76] = "E18650";
    BatCommonDesignation2[BatCommonDesignation2["E19670"] = 77] = "E19670";
    BatCommonDesignation2[BatCommonDesignation2["E25500"] = 78] = "E25500";
    BatCommonDesignation2[BatCommonDesignation2["E26650"] = 79] = "E26650";
    BatCommonDesignation2[BatCommonDesignation2["E32600"] = 80] = "E32600";
  })(BatCommonDesignation = PowerSource2.BatCommonDesignation || (PowerSource2.BatCommonDesignation = {}));
  let BatApprovedChemistry;
  ((BatApprovedChemistry2) => {
    BatApprovedChemistry2[BatApprovedChemistry2["Unspecified"] = 0] = "Unspecified";
    BatApprovedChemistry2[BatApprovedChemistry2["Alkaline"] = 1] = "Alkaline";
    BatApprovedChemistry2[BatApprovedChemistry2["LithiumCarbonFluoride"] = 2] = "LithiumCarbonFluoride";
    BatApprovedChemistry2[BatApprovedChemistry2["LithiumChromiumOxide"] = 3] = "LithiumChromiumOxide";
    BatApprovedChemistry2[BatApprovedChemistry2["LithiumCopperOxide"] = 4] = "LithiumCopperOxide";
    BatApprovedChemistry2[BatApprovedChemistry2["LithiumIronDisulfide"] = 5] = "LithiumIronDisulfide";
    BatApprovedChemistry2[BatApprovedChemistry2["LithiumManganeseDioxide"] = 6] = "LithiumManganeseDioxide";
    BatApprovedChemistry2[BatApprovedChemistry2["LithiumThionylChloride"] = 7] = "LithiumThionylChloride";
    BatApprovedChemistry2[BatApprovedChemistry2["Magnesium"] = 8] = "Magnesium";
    BatApprovedChemistry2[BatApprovedChemistry2["MercuryOxide"] = 9] = "MercuryOxide";
    BatApprovedChemistry2[BatApprovedChemistry2["NickelOxyhydride"] = 10] = "NickelOxyhydride";
    BatApprovedChemistry2[BatApprovedChemistry2["SilverOxide"] = 11] = "SilverOxide";
    BatApprovedChemistry2[BatApprovedChemistry2["ZincAir"] = 12] = "ZincAir";
    BatApprovedChemistry2[BatApprovedChemistry2["ZincCarbon"] = 13] = "ZincCarbon";
    BatApprovedChemistry2[BatApprovedChemistry2["ZincChloride"] = 14] = "ZincChloride";
    BatApprovedChemistry2[BatApprovedChemistry2["ZincManganeseDioxide"] = 15] = "ZincManganeseDioxide";
    BatApprovedChemistry2[BatApprovedChemistry2["LeadAcid"] = 16] = "LeadAcid";
    BatApprovedChemistry2[BatApprovedChemistry2["LithiumCobaltOxide"] = 17] = "LithiumCobaltOxide";
    BatApprovedChemistry2[BatApprovedChemistry2["LithiumIon"] = 18] = "LithiumIon";
    BatApprovedChemistry2[BatApprovedChemistry2["LithiumIonPolymer"] = 19] = "LithiumIonPolymer";
    BatApprovedChemistry2[BatApprovedChemistry2["LithiumIronPhosphate"] = 20] = "LithiumIronPhosphate";
    BatApprovedChemistry2[BatApprovedChemistry2["LithiumSulfur"] = 21] = "LithiumSulfur";
    BatApprovedChemistry2[BatApprovedChemistry2["LithiumTitanate"] = 22] = "LithiumTitanate";
    BatApprovedChemistry2[BatApprovedChemistry2["NickelCadmium"] = 23] = "NickelCadmium";
    BatApprovedChemistry2[BatApprovedChemistry2["NickelHydrogen"] = 24] = "NickelHydrogen";
    BatApprovedChemistry2[BatApprovedChemistry2["NickelIron"] = 25] = "NickelIron";
    BatApprovedChemistry2[BatApprovedChemistry2["NickelMetalHydride"] = 26] = "NickelMetalHydride";
    BatApprovedChemistry2[BatApprovedChemistry2["NickelZinc"] = 27] = "NickelZinc";
    BatApprovedChemistry2[BatApprovedChemistry2["SilverZinc"] = 28] = "SilverZinc";
    BatApprovedChemistry2[BatApprovedChemistry2["SodiumIon"] = 29] = "SodiumIon";
    BatApprovedChemistry2[BatApprovedChemistry2["SodiumSulfur"] = 30] = "SodiumSulfur";
    BatApprovedChemistry2[BatApprovedChemistry2["ZincBromide"] = 31] = "ZincBromide";
    BatApprovedChemistry2[BatApprovedChemistry2["ZincCerium"] = 32] = "ZincCerium";
  })(BatApprovedChemistry = PowerSource2.BatApprovedChemistry || (PowerSource2.BatApprovedChemistry = {}));
  let BatChargeState;
  ((BatChargeState2) => {
    BatChargeState2[BatChargeState2["Unknown"] = 0] = "Unknown";
    BatChargeState2[BatChargeState2["IsCharging"] = 1] = "IsCharging";
    BatChargeState2[BatChargeState2["IsAtFullCharge"] = 2] = "IsAtFullCharge";
    BatChargeState2[BatChargeState2["IsNotCharging"] = 3] = "IsNotCharging";
  })(BatChargeState = PowerSource2.BatChargeState || (PowerSource2.BatChargeState = {}));
  let BatChargeFault;
  ((BatChargeFault2) => {
    BatChargeFault2[BatChargeFault2["Unspecified"] = 0] = "Unspecified";
    BatChargeFault2[BatChargeFault2["AmbientTooHot"] = 1] = "AmbientTooHot";
    BatChargeFault2[BatChargeFault2["AmbientTooCold"] = 2] = "AmbientTooCold";
    BatChargeFault2[BatChargeFault2["BatteryTooHot"] = 3] = "BatteryTooHot";
    BatChargeFault2[BatChargeFault2["BatteryTooCold"] = 4] = "BatteryTooCold";
    BatChargeFault2[BatChargeFault2["BatteryAbsent"] = 5] = "BatteryAbsent";
    BatChargeFault2[BatChargeFault2["BatteryOverVoltage"] = 6] = "BatteryOverVoltage";
    BatChargeFault2[BatChargeFault2["BatteryUnderVoltage"] = 7] = "BatteryUnderVoltage";
    BatChargeFault2[BatChargeFault2["ChargerOverVoltage"] = 8] = "ChargerOverVoltage";
    BatChargeFault2[BatChargeFault2["ChargerUnderVoltage"] = 9] = "ChargerUnderVoltage";
    BatChargeFault2[BatChargeFault2["SafetyTimeout"] = 10] = "SafetyTimeout";
  })(BatChargeFault = PowerSource2.BatChargeFault || (PowerSource2.BatChargeFault = {}));
  PowerSource2.TlvBatChargeFaultChangeEvent = TlvObject({
    /**
     * This field shall represent the set of faults currently detected, as per ActiveBatChargeFaults.
     *
     * @see {@link MatterSpecification.v142.Core} § 11.7.8.3.1
     */
    current: TlvField(0, TlvArray(TlvEnum(), { maxLength: 16 })),
    /**
     * This field shall represent the set of faults detected prior to this change event, as per
     * ActiveBatChargeFaults.
     *
     * @see {@link MatterSpecification.v142.Core} § 11.7.8.3.2
     */
    previous: TlvField(1, TlvArray(TlvEnum(), { maxLength: 16 }))
  });
  let PowerSourceStatus;
  ((PowerSourceStatus2) => {
    PowerSourceStatus2[PowerSourceStatus2["Unspecified"] = 0] = "Unspecified";
    PowerSourceStatus2[PowerSourceStatus2["Active"] = 1] = "Active";
    PowerSourceStatus2[PowerSourceStatus2["Standby"] = 2] = "Standby";
    PowerSourceStatus2[PowerSourceStatus2["Unavailable"] = 3] = "Unavailable";
  })(PowerSourceStatus = PowerSource2.PowerSourceStatus || (PowerSource2.PowerSourceStatus = {}));
  PowerSource2.WiredComponent = MutableCluster.Component({
    attributes: {
      /**
       * Indicates the assessed RMS or DC voltage currently provided by the hard-wired source, in mV (millivolts).
       * A value of NULL shall indicate the Node is currently unable to assess the value. If the wired source is
       * not connected, but the Node is still able to assess a value, then the assessed value may be reported.
       *
       * @see {@link MatterSpecification.v142.Core} § 11.7.7.4
       */
      wiredAssessedInputVoltage: OptionalAttribute(3, TlvNullable(TlvUInt32), { omitChanges: true }),
      /**
       * Indicates the assessed frequency of the voltage, currently provided by the hard-wired source, in Hz. A
       * value of NULL shall indicate the Node is currently unable to assess the value. If the wired source is not
       * connected, but the Node is still able to assess a value, then the assessed value may be reported.
       *
       * @see {@link MatterSpecification.v142.Core} § 11.7.7.5
       */
      wiredAssessedInputFrequency: OptionalAttribute(4, TlvNullable(TlvUInt16), { omitChanges: true }),
      /**
       * Indicates the type of current the Node expects to be provided by the hard-wired source as specified in
       * WiredCurrentTypeEnum.
       *
       * @see {@link MatterSpecification.v142.Core} § 11.7.7.6
       */
      wiredCurrentType: FixedAttribute(5, TlvEnum()),
      /**
       * Indicates the assessed instantaneous current draw of the Node on the hard-wired source, in mA
       * (milliamps). A value of NULL shall indicate the Node is currently unable to assess the value. If the
       * wired source is not connected, but the Node is still able to assess a value, then the assessed value may
       * be reported.
       *
       * @see {@link MatterSpecification.v142.Core} § 11.7.7.7
       */
      wiredAssessedCurrent: OptionalAttribute(6, TlvNullable(TlvUInt32), { omitChanges: true }),
      /**
       * Indicates the nominal voltage, printed as part of the Node’s regulatory compliance label in mV
       * (millivolts), expected to be provided by the hard-wired source.
       *
       * @see {@link MatterSpecification.v142.Core} § 11.7.7.8
       */
      wiredNominalVoltage: OptionalFixedAttribute(7, TlvUInt32),
      /**
       * Indicates the maximum current, printed as part of the Node’s regulatory compliance label in mA
       * (milliamps), expected to be provided by the hard-wired source.
       *
       * @see {@link MatterSpecification.v142.Core} § 11.7.7.9
       */
      wiredMaximumCurrent: OptionalFixedAttribute(8, TlvUInt32),
      /**
       * Indicates if the Node detects that the hard-wired power source is properly connected.
       *
       * @see {@link MatterSpecification.v142.Core} § 11.7.7.10
       */
      wiredPresent: OptionalAttribute(9, TlvBoolean),
      /**
       * Indicates the set of wired faults currently detected by the Node on this power source. This set is
       * represented as a list of WiredFaultEnum. When the Node detects a fault has been raised, the appropriate
       * WiredFaultEnum value shall be added to this list, provided it is not already present. This list shall NOT
       * contain more than one instance of a specific WiredFaultEnum value. When the Node detects all conditions
       * contributing to a fault have been cleared, the corresponding WiredFaultEnum value shall be removed from
       * this list. An empty list shall indicate there are currently noactivefaults. The order of this list SHOULD
       * have no significance. Clients interested in monitoring changes in active faults may subscribe to this
       * attribute, or they may subscribe to WiredFaultChange.
       *
       * @see {@link MatterSpecification.v142.Core} § 11.7.7.11
       */
      activeWiredFaults: OptionalAttribute(
        10,
        TlvArray(TlvEnum(), { maxLength: 8 }),
        { default: [] }
      )
    },
    events: {
      /**
       * The WiredFaultChange Event shall be generated when the set of wired faults currently detected by the Node
       * on this wired power source changes. This event shall correspond to a change in value of
       * ActiveWiredFaults.
       *
       * @see {@link MatterSpecification.v142.Core} § 11.7.8.1
       */
      wiredFaultChange: OptionalEvent(0, Priority.Info, PowerSource2.TlvWiredFaultChangeEvent)
    }
  });
  PowerSource2.BatteryComponent = MutableCluster.Component({
    attributes: {
      /**
       * Indicates the currently measured output voltage of the battery in mV (millivolts). A value of NULL shall
       * indicate the Node is currently unable to assess the value.
       *
       * @see {@link MatterSpecification.v142.Core} § 11.7.7.12
       */
      batVoltage: OptionalAttribute(11, TlvNullable(TlvUInt32), { omitChanges: true }),
      /**
       * Indicates the estimated percentage of battery charge remaining until the battery will no longer be able
       * to provide power to the Node. Values are expressed in half percent units, ranging from 0 to200. E.g. a
       * value of 48 is equivalent to 24%. A value of NULL shall indicate the Node is currently unable to assess
       * the value.
       *
       * Changes to this attribute shall only be marked as reportable in the following cases:
       *
       *   - At most once every 10 seconds, or
       *
       *   - When it changes from null to any other value and vice versa.
       *
       * Since reporting consumes power, devices SHOULD be careful not to over-report.
       *
       * @see {@link MatterSpecification.v142.Core} § 11.7.7.13
       */
      batPercentRemaining: OptionalAttribute(12, TlvNullable(TlvUInt8.bound({ max: 200 }))),
      /**
       * Indicates the estimated time in seconds before the battery will no longer be able to provide power to the
       * Node. A value of NULL shall indicate the Node is currently unable to assess the value.
       *
       * Changes to this attribute shall only be marked as reportable in the following cases:
       *
       *   - At most once every 10 seconds, or
       *
       *   - When it changes from null to any other value and vice versa.
       *
       * Since reporting consumes power, devices SHOULD be careful not to over-report.
       *
       * @see {@link MatterSpecification.v142.Core} § 11.7.7.14
       */
      batTimeRemaining: OptionalAttribute(13, TlvNullable(TlvUInt32)),
      /**
       * Indicates a coarse ranking of the charge level of the battery, used to indicate when intervention is
       * required as specified in BatChargeLevelEnum.
       *
       * @see {@link MatterSpecification.v142.Core} § 11.7.7.15
       */
      batChargeLevel: Attribute(14, TlvEnum()),
      /**
       * Indicates if the battery needs to be replaced. Replacement may be simple routine maintenance, such as
       * with a single use, non-rechargeable cell. Replacement, however, may also indicate end of life, or serious
       * fault with a rechargeable or even non-replaceable cell.
       *
       * @see {@link MatterSpecification.v142.Core} § 11.7.7.16
       */
      batReplacementNeeded: Attribute(15, TlvBoolean),
      /**
       * Indicates the replaceability of the battery as specified in BatReplaceabilityEnum.
       *
       * @see {@link MatterSpecification.v142.Core} § 11.7.7.17
       */
      batReplaceability: FixedAttribute(16, TlvEnum()),
      /**
       * Indicates whether the Node detects that the batteries are properly installed.
       *
       * @see {@link MatterSpecification.v142.Core} § 11.7.7.18
       */
      batPresent: OptionalAttribute(17, TlvBoolean),
      /**
       * Indicates the set of battery faults currently detected by the Node on this power source. This set is
       * represented as a list of BatFaultEnum. When the Node detects a fault has been raised, the appropriate
       * BatFaultEnum value shall be added to this list, provided it is not already present. This list shall NOT
       * contain more than one instance of a specific BatFaultEnum value. When the Node detects all conditions
       * contributing to a fault have been cleared, the corresponding BatFaultEnum value shall be removed from
       * this list. An empty list shall indicate there are currently noactivefaults. The order of this list SHOULD
       * have no significance. Clients interested in monitoring changes in active faults may subscribe to this
       * attribute, or they may subscribe to BatFaultChange.
       *
       * @see {@link MatterSpecification.v142.Core} § 11.7.7.19
       */
      activeBatFaults: OptionalAttribute(18, TlvArray(TlvEnum(), { maxLength: 8 }), { default: [] })
    },
    events: {
      /**
       * The BatFaultChange Event shall be generated when the set of battery faults currently detected by the Node
       * on this battery power source changes. This event shall correspond to a change in value of
       * ActiveBatFaults.
       *
       * @see {@link MatterSpecification.v142.Core} § 11.7.8.2
       */
      batFaultChange: OptionalEvent(1, Priority.Info, PowerSource2.TlvBatFaultChangeEvent)
    }
  });
  PowerSource2.ReplaceableComponent = MutableCluster.Component({
    attributes: {
      /**
       * This attribute shall provide a user-facing description of this battery, which SHOULD contain information
       * required to identify a replacement, such as form factor, chemistry or preferred manufacturer.
       *
       * @see {@link MatterSpecification.v142.Core} § 11.7.7.20
       */
      batReplacementDescription: FixedAttribute(19, TlvString.bound({ maxLength: 60 })),
      /**
       * Indicates the ID of the common or colloquial designation of the battery, as specified in
       * BatCommonDesignationEnum.
       *
       * @see {@link MatterSpecification.v142.Core} § 11.7.7.21
       */
      batCommonDesignation: OptionalFixedAttribute(20, TlvEnum()),
      /**
       * Indicates the string representing the ANSI designation for the battery as specified in ANSI C18.
       *
       * @see {@link MatterSpecification.v142.Core} § 11.7.7.22
       */
      batAnsiDesignation: OptionalFixedAttribute(21, TlvString.bound({ maxLength: 20 })),
      /**
       * Indicates the string representing the IEC designation for the battery as specified in IEC 60086.
       *
       * @see {@link MatterSpecification.v142.Core} § 11.7.7.23
       */
      batIecDesignation: OptionalFixedAttribute(22, TlvString.bound({ maxLength: 20 })),
      /**
       * Indicates the ID of the preferred chemistry of the battery source as specified in
       * BatApprovedChemistryEnum.
       *
       * @see {@link MatterSpecification.v142.Core} § 11.7.7.24
       */
      batApprovedChemistry: OptionalFixedAttribute(23, TlvEnum()),
      /**
       * Indicates the quantity of individual, user- or factory-serviceable battery cells or packs in the battery
       * source.
       *
       * @see {@link MatterSpecification.v142.Core} § 11.7.7.26
       */
      batQuantity: FixedAttribute(25, TlvUInt8)
    }
  });
  PowerSource2.ReplaceableOrRechargeableComponent = MutableCluster.Component({
    attributes: {
      /**
       * Indicates the preferred minimum charge capacity rating in mAh of individual, user- or factory-serviceable
       * battery cells or packs in the battery source.
       *
       * @see {@link MatterSpecification.v142.Core} § 11.7.7.25
       */
      batCapacity: OptionalFixedAttribute(24, TlvUInt32)
    }
  });
  PowerSource2.RechargeableComponent = MutableCluster.Component({
    attributes: {
      /**
       * Indicates the current state of the battery source with respect to charging as specified in
       * BatChargeStateEnum.
       *
       * @see {@link MatterSpecification.v142.Core} § 11.7.7.27
       */
      batChargeState: Attribute(26, TlvEnum()),
      /**
       * Indicates the estimated time in seconds before the battery source will be at full charge. A value of NULL
       * shall indicate the Node is currently unable to assess the value.
       *
       * Changes to this attribute shall only be marked as reportable in the following cases:
       *
       *   - At most once every 10 seconds, or
       *
       *   - When it changes from null to any other value and vice versa.
       *
       * Since reporting consumes power, devices SHOULD be careful not to over-report.
       *
       * @see {@link MatterSpecification.v142.Core} § 11.7.7.28
       */
      batTimeToFullCharge: OptionalAttribute(27, TlvNullable(TlvUInt32)),
      /**
       * Indicates whether the Node can remain operational while the battery source is charging.
       *
       * @see {@link MatterSpecification.v142.Core} § 11.7.7.29
       */
      batFunctionalWhileCharging: Attribute(28, TlvBoolean),
      /**
       * Indicates assessed current in mA (milliamps) presently supplied to charge the battery source. A value of
       * NULL shall indicate the Node is currently unable to assess the value.
       *
       * @see {@link MatterSpecification.v142.Core} § 11.7.7.30
       */
      batChargingCurrent: OptionalAttribute(29, TlvNullable(TlvUInt32), { omitChanges: true }),
      /**
       * Indicates the set of charge faults currently detected by the Node on this power source. This set is
       * represented as a list of BatChargeFaultEnum. When the Node detects a fault has been raised, the
       * appropriate BatChargeFaultEnum value shall be added to this list, provided it is not alreadypresent. This
       * list shall NOT contain more than one instance of a specific BatChargeFaultEnum value. When the Node
       * detects all conditions contributing to a fault have been cleared, the corresponding BatChargeFaultEnum
       * value shall be removed from this list. An empty list shall indicate there are currently no active faults.
       * The order of this list SHOULD have no significance. Clients interested in monitoring changes in active
       * faults may subscribe to this attribute, or they may subscribe to the BatFaultChange event.
       *
       * @see {@link MatterSpecification.v142.Core} § 11.7.7.31
       */
      activeBatChargeFaults: OptionalAttribute(
        30,
        TlvArray(TlvEnum(), { maxLength: 16 }),
        { default: [] }
      )
    },
    events: {
      /**
       * The BatChargeFaultChange Event shall be generated when the set of charge faults currently detected by the
       * Node on this battery power source changes. This event shall correspond to a change in value of
       * ActiveBatChargeFaults.
       *
       * @see {@link MatterSpecification.v142.Core} § 11.7.8.3
       */
      batChargeFaultChange: OptionalEvent(2, Priority.Info, PowerSource2.TlvBatChargeFaultChangeEvent)
    }
  });
  PowerSource2.Base = MutableCluster.Component({
    id: 47,
    name: "PowerSource",
    revision: 3,
    features: {
      /**
       * A wired power source
       */
      wired: BitFlag(0),
      /**
       * A battery power source
       */
      battery: BitFlag(1),
      /**
       * A rechargeable battery power source
       */
      rechargeable: BitFlag(2),
      /**
       * A replaceable battery power source
       */
      replaceable: BitFlag(3)
    },
    attributes: {
      /**
       * Indicates the participation of this power source in providing power to the Node as specified in
       * PowerSourceStatusEnum.
       *
       * @see {@link MatterSpecification.v142.Core} § 11.7.7.1
       */
      status: Attribute(0, TlvEnum()),
      /**
       * Indicates the relative preference with which the Node will select this source to provide power. A source
       * with a lower order shall be selected by the Node to provide power before any other source with a higher
       * order, if the lower order source is available (see Section 11.7.7.1, “Status Attribute”).
       *
       * Note, Order is read-only and therefore NOT intended to allow clients control over power source selection.
       *
       * @see {@link MatterSpecification.v142.Core} § 11.7.7.2
       */
      order: Attribute(1, TlvUInt8, { persistent: true }),
      /**
       * This attribute shall provide a user-facing description of this source, used to distinguish it from other
       * power sources, e.g. "DC Power", "Primary Battery" or "Battery back-up". This attribute shall NOT be used
       * to convey information such as battery form factor, or chemistry.
       *
       * @see {@link MatterSpecification.v142.Core} § 11.7.7.3
       */
      description: FixedAttribute(2, TlvString.bound({ maxLength: 60 })),
      /**
       * Indicates a list of endpoints that are powered by the source defined by this cluster. Multiple instances
       * of this cluster may list the same endpoint, because it is possible for power for an endpoint to come from
       * multiple sources. In that case the Order attribute indicates their priority.
       *
       * For each power source on a node, there shall only be one instance of this cluster.
       *
       * A cluster instance with an empty list shall indicate that the power source is for the entire node, which
       * includes all endpoints.
       *
       * A cluster instance with a non-empty list shall include the endpoint, upon which the cluster instance
       * resides.
       *
       * The above rules allow that some endpoints can have an unknown power source, and therefore would not be
       * indicated by any instance of this cluster.
       *
       * ### Legacy Implementations
       *
       * Legacy implementations of this cluster before revision 2, before this attribute was defined, would have
       * implemented this cluster on an application endpoint without indicating it in EndpointList (since that
       * attribute did not exist in revision 1), because it represented a power source for the endpoint, not the
       * entire node.
       *
       * For example: Bridge implementations support endpoints for bridged devices that have different power
       * sources.
       *
       * Such implementations followed device type requirements and semantics outside of this cluster, because
       * this attribute did not exist.
       *
       * Future updates of such a cluster instance on the same endpoint, would allow that same endpoint to be an
       * entry in the EndpointList attribute. Therefore it is valid to list the endpoint upon which the cluster
       * instance exists.
       *
       * Typically, there is one power source for the node. Also common is mains power for the node with battery
       * backup power for the node. In both these common cases, for each cluster instance described, the list is
       * empty.
       *
       * A node has a mains power source with Order as 0 (zero), but some application endpoints (not all) have a
       * battery back up source with Order as 1, which means this list is empty for the Power Source cluster
       * associated with the mains power, because it indicates the entire node, but the Power Source cluster
       * instance associated with the battery backup would list the endpoints that have a battery backup.
       *
       * @see {@link MatterSpecification.v142.Core} § 11.7.7.32
       */
      endpointList: Attribute(31, TlvArray(TlvEndpointNumber), { default: [] })
    },
    /**
     * This metadata controls which PowerSourceCluster elements matter.js activates for specific feature
     * combinations.
     */
    extensions: MutableCluster.Extensions(
      { flags: { wired: true }, component: PowerSource2.WiredComponent },
      { flags: { battery: true }, component: PowerSource2.BatteryComponent },
      { flags: { replaceable: true }, component: PowerSource2.ReplaceableComponent },
      { flags: { replaceable: true }, component: PowerSource2.ReplaceableOrRechargeableComponent },
      { flags: { rechargeable: true }, component: PowerSource2.ReplaceableOrRechargeableComponent },
      { flags: { rechargeable: true }, component: PowerSource2.RechargeableComponent },
      { flags: { rechargeable: true, battery: false }, component: false },
      { flags: { replaceable: true, battery: false }, component: false },
      { flags: { wired: true, battery: true }, component: false },
      { flags: { wired: false, battery: false }, component: false }
    )
  });
  PowerSource2.ClusterInstance = MutableCluster.ExtensibleOnly(PowerSource2.Base);
  PowerSource2.Cluster = PowerSource2.ClusterInstance;
  const WIRED = { wired: true };
  const BAT = { battery: true };
  const REPLC = { replaceable: true };
  const RECHG = { rechargeable: true };
  PowerSource2.CompleteInstance = MutableCluster({
    id: PowerSource2.Base.id,
    name: PowerSource2.Base.name,
    revision: PowerSource2.Base.revision,
    features: PowerSource2.Base.features,
    attributes: {
      ...PowerSource2.Base.attributes,
      wiredAssessedInputVoltage: MutableCluster.AsConditional(
        PowerSource2.WiredComponent.attributes.wiredAssessedInputVoltage,
        { optionalIf: [WIRED] }
      ),
      wiredAssessedInputFrequency: MutableCluster.AsConditional(
        PowerSource2.WiredComponent.attributes.wiredAssessedInputFrequency,
        { optionalIf: [WIRED] }
      ),
      wiredCurrentType: MutableCluster.AsConditional(
        PowerSource2.WiredComponent.attributes.wiredCurrentType,
        { mandatoryIf: [WIRED] }
      ),
      wiredAssessedCurrent: MutableCluster.AsConditional(
        PowerSource2.WiredComponent.attributes.wiredAssessedCurrent,
        { optionalIf: [WIRED] }
      ),
      wiredNominalVoltage: MutableCluster.AsConditional(
        PowerSource2.WiredComponent.attributes.wiredNominalVoltage,
        { optionalIf: [WIRED] }
      ),
      wiredMaximumCurrent: MutableCluster.AsConditional(
        PowerSource2.WiredComponent.attributes.wiredMaximumCurrent,
        { optionalIf: [WIRED] }
      ),
      wiredPresent: MutableCluster.AsConditional(PowerSource2.WiredComponent.attributes.wiredPresent, { optionalIf: [WIRED] }),
      activeWiredFaults: MutableCluster.AsConditional(
        PowerSource2.WiredComponent.attributes.activeWiredFaults,
        { optionalIf: [WIRED] }
      ),
      batVoltage: MutableCluster.AsConditional(PowerSource2.BatteryComponent.attributes.batVoltage, { optionalIf: [BAT] }),
      batPercentRemaining: MutableCluster.AsConditional(
        PowerSource2.BatteryComponent.attributes.batPercentRemaining,
        { optionalIf: [BAT] }
      ),
      batTimeRemaining: MutableCluster.AsConditional(
        PowerSource2.BatteryComponent.attributes.batTimeRemaining,
        { optionalIf: [BAT] }
      ),
      batChargeLevel: MutableCluster.AsConditional(
        PowerSource2.BatteryComponent.attributes.batChargeLevel,
        { mandatoryIf: [BAT] }
      ),
      batReplacementNeeded: MutableCluster.AsConditional(
        PowerSource2.BatteryComponent.attributes.batReplacementNeeded,
        { mandatoryIf: [BAT] }
      ),
      batReplaceability: MutableCluster.AsConditional(
        PowerSource2.BatteryComponent.attributes.batReplaceability,
        { mandatoryIf: [BAT] }
      ),
      batPresent: MutableCluster.AsConditional(PowerSource2.BatteryComponent.attributes.batPresent, { optionalIf: [BAT] }),
      activeBatFaults: MutableCluster.AsConditional(
        PowerSource2.BatteryComponent.attributes.activeBatFaults,
        { optionalIf: [BAT] }
      ),
      batReplacementDescription: MutableCluster.AsConditional(
        PowerSource2.ReplaceableComponent.attributes.batReplacementDescription,
        { mandatoryIf: [REPLC] }
      ),
      batCommonDesignation: MutableCluster.AsConditional(
        PowerSource2.ReplaceableComponent.attributes.batCommonDesignation,
        { optionalIf: [REPLC] }
      ),
      batAnsiDesignation: MutableCluster.AsConditional(
        PowerSource2.ReplaceableComponent.attributes.batAnsiDesignation,
        { optionalIf: [REPLC] }
      ),
      batIecDesignation: MutableCluster.AsConditional(
        PowerSource2.ReplaceableComponent.attributes.batIecDesignation,
        { optionalIf: [REPLC] }
      ),
      batApprovedChemistry: MutableCluster.AsConditional(
        PowerSource2.ReplaceableComponent.attributes.batApprovedChemistry,
        { optionalIf: [REPLC] }
      ),
      batCapacity: MutableCluster.AsConditional(
        PowerSource2.ReplaceableOrRechargeableComponent.attributes.batCapacity,
        { optionalIf: [REPLC, RECHG] }
      ),
      batQuantity: MutableCluster.AsConditional(
        PowerSource2.ReplaceableComponent.attributes.batQuantity,
        { mandatoryIf: [REPLC] }
      ),
      batChargeState: MutableCluster.AsConditional(
        PowerSource2.RechargeableComponent.attributes.batChargeState,
        { mandatoryIf: [RECHG] }
      ),
      batTimeToFullCharge: MutableCluster.AsConditional(
        PowerSource2.RechargeableComponent.attributes.batTimeToFullCharge,
        { optionalIf: [RECHG] }
      ),
      batFunctionalWhileCharging: MutableCluster.AsConditional(
        PowerSource2.RechargeableComponent.attributes.batFunctionalWhileCharging,
        { mandatoryIf: [RECHG] }
      ),
      batChargingCurrent: MutableCluster.AsConditional(
        PowerSource2.RechargeableComponent.attributes.batChargingCurrent,
        { optionalIf: [RECHG] }
      ),
      activeBatChargeFaults: MutableCluster.AsConditional(
        PowerSource2.RechargeableComponent.attributes.activeBatChargeFaults,
        { optionalIf: [RECHG] }
      )
    },
    events: {
      wiredFaultChange: MutableCluster.AsConditional(
        PowerSource2.WiredComponent.events.wiredFaultChange,
        { optionalIf: [WIRED] }
      ),
      batFaultChange: MutableCluster.AsConditional(PowerSource2.BatteryComponent.events.batFaultChange, { optionalIf: [BAT] }),
      batChargeFaultChange: MutableCluster.AsConditional(
        PowerSource2.RechargeableComponent.events.batChargeFaultChange,
        { optionalIf: [RECHG] }
      )
    }
  });
  PowerSource2.Complete = PowerSource2.CompleteInstance;
})(PowerSource || (PowerSource = {}));
const PowerSourceCluster = PowerSource.Cluster;
ClusterRegistry.register(PowerSource.Complete);
export {
  PowerSource,
  PowerSourceCluster
};
//# sourceMappingURL=power-source.js.map
