/**
 * @license
 * Copyright 2022-2025 Matter.js Authors
 * SPDX-License-Identifier: Apache-2.0
 */
import { MutableCluster } from "../cluster/mutation/MutableCluster.js";
import { Attribute, OptionalWritableAttribute } from "../cluster/Cluster.js";
import { BitFlag } from "../schema/BitmapSchema.js";
import { TlvUInt8, TlvBitmap, TlvEnum, TlvUInt16 } from "../tlv/TlvNumber.js";
import { AccessLevel } from "#model";
import { ClusterRegistry } from "../cluster/ClusterRegistry.js";
var OccupancySensing;
((OccupancySensing2) => {
  OccupancySensing2.Occupancy = {
    /**
     * Indicates the sensed occupancy state
     *
     * If this bit is set, it shall indicate the occupied state else if the bit if not set, it shall indicate the
     * unoccupied state.
     *
     * @see {@link MatterSpecification.v13.Cluster} § 2.7.4.1.1
     */
    occupied: BitFlag(0)
  };
  let OccupancySensorType;
  ((OccupancySensorType2) => {
    OccupancySensorType2[OccupancySensorType2["Pir"] = 0] = "Pir";
    OccupancySensorType2[OccupancySensorType2["Ultrasonic"] = 1] = "Ultrasonic";
    OccupancySensorType2[OccupancySensorType2["PirAndUltrasonic"] = 2] = "PirAndUltrasonic";
    OccupancySensorType2[OccupancySensorType2["PhysicalContact"] = 3] = "PhysicalContact";
  })(OccupancySensorType = OccupancySensing2.OccupancySensorType || (OccupancySensing2.OccupancySensorType = {}));
  OccupancySensing2.OccupancySensorTypeBitmap = {
    /**
     * Indicates a passive infrared sensor.
     */
    pir: BitFlag(0),
    /**
     * Indicates a ultrasonic sensor.
     */
    ultrasonic: BitFlag(1),
    /**
     * Indicates a physical contact sensor.
     */
    physicalContact: BitFlag(2)
  };
  OccupancySensing2.ClusterInstance = MutableCluster({
    id: 1030,
    name: "OccupancySensing",
    revision: 4,
    attributes: {
      /**
       * This attribute indicates the sensed (processed) status of occupancy.
       *
       * @see {@link MatterSpecification.v13.Cluster} § 2.7.5.1
       */
      occupancy: Attribute(0, TlvBitmap(TlvUInt8, OccupancySensing2.Occupancy)),
      /**
       * This attribute specifies the type of the occupancy sensor.
       *
       * @see {@link MatterSpecification.v13.Cluster} § 2.7.5.2
       */
      occupancySensorType: Attribute(1, TlvEnum()),
      /**
       * This attribute specifies the types of the occupancy sensor. Each bit position, if set, indicates the
       * corresponding sensing capability is implemented.
       *
       * The value of the OccupancySensorType shall be aligned to the value of the OccupancySensorTypeBitmap
       * attribute as defined below.
       *
       * @see {@link MatterSpecification.v13.Cluster} § 2.7.5.3
       */
      occupancySensorTypeBitmap: Attribute(2, TlvBitmap(TlvUInt8, OccupancySensing2.OccupancySensorTypeBitmap)),
      /**
       * This attribute specifies the time delay, in seconds, before the PIR sensor changes to its unoccupied
       * state after the last detection of movement in the sensed area.
       *
       * @see {@link MatterSpecification.v13.Cluster} § 2.7.5.4
       */
      pirOccupiedToUnoccupiedDelay: OptionalWritableAttribute(
        16,
        TlvUInt16,
        { default: 0, writeAcl: AccessLevel.Manage }
      ),
      /**
       * This attribute specifies the time delay, in seconds, before the PIR sensor changes to its occupied state
       * after the detection of movement in the sensed area.
       *
       * @see {@link MatterSpecification.v13.Cluster} § 2.7.5.5
       */
      pirUnoccupiedToOccupiedDelay: OptionalWritableAttribute(
        17,
        TlvUInt16,
        { default: 0, writeAcl: AccessLevel.Manage }
      ),
      /**
       * This attribute specifies the number of movement detection events that must occur in the period
       * PIRUnoccupiedToOccupiedDelay, before the PIR sensor changes to its occupied state.
       *
       * @see {@link MatterSpecification.v13.Cluster} § 2.7.5.6
       */
      pirUnoccupiedToOccupiedThreshold: OptionalWritableAttribute(
        18,
        TlvUInt8.bound({ min: 1, max: 254 }),
        { default: 1, writeAcl: AccessLevel.Manage }
      ),
      /**
       * This attribute specifies the time delay, in seconds, before the Ultrasonic sensor changes to its
       * unoccupied state after the last detection of movement in the sensed area.
       *
       * @see {@link MatterSpecification.v13.Cluster} § 2.7.5.7
       */
      ultrasonicOccupiedToUnoccupiedDelay: OptionalWritableAttribute(
        32,
        TlvUInt16,
        { default: 0, writeAcl: AccessLevel.Manage }
      ),
      /**
       * This attribute specifies the time delay, in seconds, before the Ultrasonic sensor changes to its
       * occupied state after the detection of movement in the sensed area.
       *
       * @see {@link MatterSpecification.v13.Cluster} § 2.7.5.8
       */
      ultrasonicUnoccupiedToOccupiedDelay: OptionalWritableAttribute(
        33,
        TlvUInt16,
        { default: 0, writeAcl: AccessLevel.Manage }
      ),
      /**
       * This attribute specifies the number of movement detection events that must occur in the period
       * UltrasonicUnoccupiedToOccupiedDelay, before the Ultrasonic sensor changes to its occupied state.
       *
       * @see {@link MatterSpecification.v13.Cluster} § 2.7.5.9
       */
      ultrasonicUnoccupiedToOccupiedThreshold: OptionalWritableAttribute(
        34,
        TlvUInt8.bound({ min: 1, max: 254 }),
        { default: 1, writeAcl: AccessLevel.Manage }
      ),
      /**
       * This attribute specifies the time delay, in seconds, before the physical contact occupancy sensor
       * changes to its unoccupied state after detecting the unoccupied event.
       *
       * @see {@link MatterSpecification.v13.Cluster} § 2.7.5.10
       */
      physicalContactOccupiedToUnoccupiedDelay: OptionalWritableAttribute(
        48,
        TlvUInt16,
        { default: 0, writeAcl: AccessLevel.Manage }
      ),
      /**
       * This attribute specifies the time delay, in seconds, before the physical contact sensor changes to its
       * occupied state after the detection of the occupied event.
       *
       * @see {@link MatterSpecification.v13.Cluster} § 2.7.5.11
       */
      physicalContactUnoccupiedToOccupiedDelay: OptionalWritableAttribute(
        49,
        TlvUInt16,
        { default: 0, writeAcl: AccessLevel.Manage }
      ),
      /**
       * This attribute specifies the number of movement detection events that must occur in the period
       * PhysicalContactUnoccupiedToOccupiedDelay, before the PhysicalContact sensor changes to its occupied
       * state.
       *
       * @see {@link MatterSpecification.v13.Cluster} § 2.7.5.12
       */
      physicalContactUnoccupiedToOccupiedThreshold: OptionalWritableAttribute(
        50,
        TlvUInt8.bound({ min: 1, max: 254 }),
        { default: 1, writeAcl: AccessLevel.Manage }
      )
    }
  });
  OccupancySensing2.Cluster = OccupancySensing2.ClusterInstance;
  OccupancySensing2.Complete = OccupancySensing2.Cluster;
})(OccupancySensing || (OccupancySensing = {}));
const OccupancySensingCluster = OccupancySensing.Cluster;
ClusterRegistry.register(OccupancySensing.Complete);
export {
  OccupancySensing,
  OccupancySensingCluster
};
//# sourceMappingURL=occupancy-sensing.js.map
