"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 temperature_control_exports = {};
__export(temperature_control_exports, {
  TemperatureControl: () => TemperatureControl,
  TemperatureControlCluster: () => TemperatureControlCluster
});
module.exports = __toCommonJS(temperature_control_exports);
var import_MutableCluster = require("../cluster/mutation/MutableCluster.js");
var import_Cluster = require("../cluster/Cluster.js");
var import_TlvNumber = require("../tlv/TlvNumber.js");
var import_TlvArray = require("../tlv/TlvArray.js");
var import_TlvString = require("../tlv/TlvString.js");
var import_BitmapSchema = require("../schema/BitmapSchema.js");
var import_TlvObject = require("../tlv/TlvObject.js");
var import_ClusterRegistry = require("../cluster/ClusterRegistry.js");
/**
 * @license
 * Copyright 2022-2026 Matter.js Authors
 * SPDX-License-Identifier: Apache-2.0
 */
var TemperatureControl;
((TemperatureControl2) => {
  let Feature;
  ((Feature2) => {
    Feature2["TemperatureNumber"] = "TemperatureNumber";
    Feature2["TemperatureLevel"] = "TemperatureLevel";
    Feature2["TemperatureStep"] = "TemperatureStep";
  })(Feature = TemperatureControl2.Feature || (TemperatureControl2.Feature = {}));
  TemperatureControl2.TlvSetTemperatureRequest = (0, import_TlvObject.TlvObject)({
    /**
     * This field shall specify the desired temperature setpoint that the server is to be set to.
     *
     * The TargetTemperature shall be from MinTemperature to MaxTemperature inclusive. If the Step attribute is
     * supported, TargetTemperature shall be such that (TargetTemperature - MinTemperature) % Step == 0.
     *
     * @see {@link MatterSpecification.v142.Cluster} § 8.2.6.1.1
     */
    targetTemperature: (0, import_TlvObject.TlvOptionalField)(0, import_TlvNumber.TlvInt16),
    /**
     * This field shall specify the index of the list item in the SupportedTemperatureLevels list that represents
     * the desired temperature level setting of the server. The value of this field shall be between 0 and the
     * length of the SupportedTemperatureLevels list -1.
     *
     * @see {@link MatterSpecification.v142.Cluster} § 8.2.6.1.2
     */
    targetTemperatureLevel: (0, import_TlvObject.TlvOptionalField)(1, import_TlvNumber.TlvUInt8)
  });
  TemperatureControl2.TemperatureNumberComponent = import_MutableCluster.MutableCluster.Component({
    attributes: {
      /**
       * Indicates the desired Temperature Setpoint on the device.
       *
       * @see {@link MatterSpecification.v142.Cluster} § 8.2.5.1
       */
      temperatureSetpoint: (0, import_Cluster.Attribute)(0, import_TlvNumber.TlvInt16),
      /**
       * Indicates the minimum temperature to which the TemperatureSetpoint attribute may be set.
       *
       * @see {@link MatterSpecification.v142.Cluster} § 8.2.5.2
       */
      minTemperature: (0, import_Cluster.FixedAttribute)(1, import_TlvNumber.TlvInt16),
      /**
       * Indicates the maximum temperature to which the TemperatureSetpoint attribute may be set.
       *
       * If the Step attribute is supported, this attribute shall be such that MaxTemperature = MinTemperature +
       * (Step * n), where n is an integer and n > 0. If the Step attribute is not supported, this attribute shall
       * be such that MaxTemperature > MinTemperature.
       *
       * @see {@link MatterSpecification.v142.Cluster} § 8.2.5.3
       */
      maxTemperature: (0, import_Cluster.FixedAttribute)(2, import_TlvNumber.TlvInt16)
    }
  });
  TemperatureControl2.TemperatureStepComponent = import_MutableCluster.MutableCluster.Component({
    attributes: {
      /**
       * Indicates the discrete value by which the TemperatureSetpoint attribute can be changed via the
       * SetTemperature command.
       *
       * For example, if the value of MinTemperature is 25.00C (2500) and the Step value is 0.50C (50), valid
       * values of the TargetTemperature field of the SetTemperature command would be 25.50C (2550), 26.00C
       * (2600), 26.50C (2650), etc.
       *
       * @see {@link MatterSpecification.v142.Cluster} § 8.2.5.4
       */
      step: (0, import_Cluster.FixedAttribute)(3, import_TlvNumber.TlvInt16.bound({ min: 1 }))
    }
  });
  TemperatureControl2.TemperatureLevelComponent = import_MutableCluster.MutableCluster.Component({
    attributes: {
      /**
       * Indicates the currently selected temperature level setting of the server. This attribute shall be the
       * positional index of the list item in the SupportedTemperatureLevels list that represents the currently
       * selected temperature level setting of the server.
       *
       * @see {@link MatterSpecification.v142.Cluster} § 8.2.5.5
       */
      selectedTemperatureLevel: (0, import_Cluster.Attribute)(4, import_TlvNumber.TlvUInt8.bound({ max: 31 })),
      /**
       * Indicates the list of supported temperature level settings that may be selected via the
       * TargetTemperatureLevel field in the SetTemperature command. Each string is readable text that describes
       * each temperature level setting in a way that can be easily understood by humans. For example, a washing
       * machine can have temperature levels like "Cold", "Warm", and "Hot". Each string is specified by the
       * manufacturer.
       *
       * Each item in this list shall represent a unique temperature level. Each entry in this list shall have a
       * unique value. The entries in this list shall appear in order of increasing temperature level with list
       * item 0 being the setting with the lowest temperature level.
       *
       * @see {@link MatterSpecification.v142.Cluster} § 8.2.5.6
       */
      supportedTemperatureLevels: (0, import_Cluster.Attribute)(5, (0, import_TlvArray.TlvArray)(import_TlvString.TlvString, { maxLength: 32 }), { default: [] })
    }
  });
  TemperatureControl2.Base = import_MutableCluster.MutableCluster.Component({
    id: 86,
    name: "TemperatureControl",
    revision: 1,
    features: {
      /**
       * For devices that use an actual temperature value for the temperature setpoint, such as some water
       * heaters, the feature TN shall be used. Note that this cluster provides and supports temperatures in
       * degrees Celsius via the temperature data type.
       *
       * @see {@link MatterSpecification.v142.Cluster} § 8.2.4.1
       */
      temperatureNumber: (0, import_BitmapSchema.BitFlag)(0),
      /**
       * For devices that use vendor-specific temperature levels for the temperature setpoint, such as some
       * washers, the feature TL shall be used.
       *
       * @see {@link MatterSpecification.v142.Cluster} § 8.2.4.2
       */
      temperatureLevel: (0, import_BitmapSchema.BitFlag)(1),
      /**
       * For devices that support discrete temperature setpoints that are larger than the temperature resolution
       * imposed via the temperature data type, the Step feature may be used.
       *
       * @see {@link MatterSpecification.v142.Cluster} § 8.2.4.3
       */
      temperatureStep: (0, import_BitmapSchema.BitFlag)(2)
    },
    commands: {
      /**
       * This command is used to set the temperature setpoint.
       *
       * @see {@link MatterSpecification.v142.Cluster} § 8.2.6.1
       */
      setTemperature: (0, import_Cluster.Command)(0, TemperatureControl2.TlvSetTemperatureRequest, 0, import_Cluster.TlvNoResponse)
    },
    /**
     * This metadata controls which TemperatureControlCluster elements matter.js activates for specific feature
     * combinations.
     */
    extensions: import_MutableCluster.MutableCluster.Extensions(
      { flags: { temperatureNumber: true }, component: TemperatureControl2.TemperatureNumberComponent },
      { flags: { temperatureStep: true }, component: TemperatureControl2.TemperatureStepComponent },
      { flags: { temperatureLevel: true }, component: TemperatureControl2.TemperatureLevelComponent },
      { flags: { temperatureStep: true, temperatureNumber: false }, component: false },
      { flags: { temperatureNumber: true, temperatureLevel: true }, component: false },
      { flags: { temperatureNumber: false, temperatureLevel: false }, component: false }
    )
  });
  TemperatureControl2.ClusterInstance = import_MutableCluster.MutableCluster.ExtensibleOnly(TemperatureControl2.Base);
  TemperatureControl2.Cluster = TemperatureControl2.ClusterInstance;
  const TN = { temperatureNumber: true };
  const STEP = { temperatureStep: true };
  const TL = { temperatureLevel: true };
  TemperatureControl2.CompleteInstance = (0, import_MutableCluster.MutableCluster)({
    id: TemperatureControl2.Base.id,
    name: TemperatureControl2.Base.name,
    revision: TemperatureControl2.Base.revision,
    features: TemperatureControl2.Base.features,
    attributes: {
      temperatureSetpoint: import_MutableCluster.MutableCluster.AsConditional(
        TemperatureControl2.TemperatureNumberComponent.attributes.temperatureSetpoint,
        { mandatoryIf: [TN] }
      ),
      minTemperature: import_MutableCluster.MutableCluster.AsConditional(
        TemperatureControl2.TemperatureNumberComponent.attributes.minTemperature,
        { mandatoryIf: [TN] }
      ),
      maxTemperature: import_MutableCluster.MutableCluster.AsConditional(
        TemperatureControl2.TemperatureNumberComponent.attributes.maxTemperature,
        { mandatoryIf: [TN] }
      ),
      step: import_MutableCluster.MutableCluster.AsConditional(TemperatureControl2.TemperatureStepComponent.attributes.step, { mandatoryIf: [STEP] }),
      selectedTemperatureLevel: import_MutableCluster.MutableCluster.AsConditional(
        TemperatureControl2.TemperatureLevelComponent.attributes.selectedTemperatureLevel,
        { mandatoryIf: [TL] }
      ),
      supportedTemperatureLevels: import_MutableCluster.MutableCluster.AsConditional(
        TemperatureControl2.TemperatureLevelComponent.attributes.supportedTemperatureLevels,
        { mandatoryIf: [TL] }
      )
    },
    commands: TemperatureControl2.Base.commands
  });
  TemperatureControl2.Complete = TemperatureControl2.CompleteInstance;
})(TemperatureControl || (TemperatureControl = {}));
const TemperatureControlCluster = TemperatureControl.Cluster;
import_ClusterRegistry.ClusterRegistry.register(TemperatureControl.Complete);
//# sourceMappingURL=temperature-control.js.map
