/**
 * @license
 * Copyright 2022-2025 Matter.js Authors
 * SPDX-License-Identifier: Apache-2.0
 */
import { MutableCluster } from "../cluster/mutation/MutableCluster.js";
import { Attribute, OptionalAttribute, Command, OptionalEvent } from "../cluster/Cluster.js";
import { TlvArray } from "../tlv/TlvArray.js";
import { TlvField, TlvObject, TlvOptionalField } from "../tlv/TlvObject.js";
import { TlvUInt8, TlvEnum } from "../tlv/TlvNumber.js";
import { TlvString, TlvByteString } from "../tlv/TlvString.js";
import { StatusResponseError } from "../common/StatusResponseError.js";
import { Status as GlobalStatus } from "../globals/Status.js";
import { Priority } from "../globals/Priority.js";
import { ClusterRegistry } from "../cluster/ClusterRegistry.js";
var TargetNavigator;
((TargetNavigator2) => {
  TargetNavigator2.TlvTargetInfo = TlvObject({
    /**
     * This field shall contain an unique id within the TargetList.
     *
     * @see {@link MatterSpecification.v142.Cluster} § 6.11.4.2.1
     */
    identifier: TlvField(0, TlvUInt8.bound({ max: 254 })),
    /**
     * This field shall contain a name string for the TargetInfoStruct.
     *
     * @see {@link MatterSpecification.v142.Cluster} § 6.11.4.2.2
     */
    name: TlvField(1, TlvString)
  });
  TargetNavigator2.TlvNavigateTargetRequest = TlvObject({
    /**
     * This field shall indicate the Identifier for the target for UX navigation. The Target shall be an Identifier
     * value contained within one of the TargetInfoStruct objects in the TargetList attribute.
     *
     * @see {@link MatterSpecification.v142.Cluster} § 6.11.6.1.1
     */
    target: TlvField(0, TlvUInt8),
    /**
     * This field shall indicate Optional app-specific data.
     *
     * @see {@link MatterSpecification.v142.Cluster} § 6.11.6.1.2
     */
    data: TlvOptionalField(1, TlvString)
  });
  let Status;
  ((Status2) => {
    Status2[Status2["Success"] = 0] = "Success";
    Status2[Status2["TargetNotFound"] = 1] = "TargetNotFound";
    Status2[Status2["NotAllowed"] = 2] = "NotAllowed";
  })(Status = TargetNavigator2.Status || (TargetNavigator2.Status = {}));
  class TargetNotFoundError extends StatusResponseError {
    constructor(message = "Requested target was not found in the TargetList", code = GlobalStatus.Failure, clusterCode = 1 /* TargetNotFound */) {
      super(message, code, clusterCode);
    }
  }
  TargetNavigator2.TargetNotFoundError = TargetNotFoundError;
  class NotAllowedError extends StatusResponseError {
    constructor(message = "Target request is not allowed in current state", code = GlobalStatus.Failure, clusterCode = 2 /* NotAllowed */) {
      super(message, code, clusterCode);
    }
  }
  TargetNavigator2.NotAllowedError = NotAllowedError;
  TargetNavigator2.TlvNavigateTargetResponse = TlvObject({
    /**
     * This field shall indicate the of the command.
     *
     * @see {@link MatterSpecification.v142.Cluster} § 6.11.6.2.1
     */
    status: TlvField(0, TlvEnum()),
    /**
     * This field shall indicate Optional app-specific data.
     *
     * @see {@link MatterSpecification.v142.Cluster} § 6.11.6.2.2
     */
    data: TlvOptionalField(1, TlvString)
  });
  TargetNavigator2.TlvTargetUpdatedEvent = TlvObject({
    targetList: TlvOptionalField(0, TlvArray(TargetNavigator2.TlvTargetInfo)),
    currentTarget: TlvOptionalField(1, TlvUInt8),
    data: TlvOptionalField(2, TlvByteString.bound({ maxLength: 900 }))
  });
  TargetNavigator2.ClusterInstance = MutableCluster({
    id: 1285,
    name: "TargetNavigator",
    revision: 2,
    attributes: {
      /**
       * Indicates a list of targets that can be navigated to within the experience presented to the user by the
       * Endpoint (Video Player or Content App). The list shall NOT contain any entries with the same Identifier
       * in the TargetInfoStruct object.
       *
       * @see {@link MatterSpecification.v142.Cluster} § 6.11.5.1
       */
      targetList: Attribute(0, TlvArray(TargetNavigator2.TlvTargetInfo), { default: [] }),
      /**
       * Indicates the Identifier for the target which is currently in foreground on the corresponding Endpoint
       * (Video Player or Content App), or 0xFF to indicate that no target is in the foreground.
       *
       * When not 0xFF, the CurrentTarget shall be an Identifier value contained within one of the
       * TargetInfoStruct objects in the TargetList attribute.
       *
       * @see {@link MatterSpecification.v142.Cluster} § 6.11.5.2
       */
      currentTarget: OptionalAttribute(1, TlvUInt8, { default: 255 })
    },
    commands: {
      /**
       * Upon receipt, this shall navigation the UX to the target identified.
       *
       * @see {@link MatterSpecification.v142.Cluster} § 6.11.6.1
       */
      navigateTarget: Command(0, TargetNavigator2.TlvNavigateTargetRequest, 1, TargetNavigator2.TlvNavigateTargetResponse)
    },
    events: {
      /**
       * This event shall be generated when there is a change in either the active target or the list of available
       * targets or both.
       *
       * @see {@link MatterSpecification.v142.Cluster} § 6.11.7.1
       */
      targetUpdated: OptionalEvent(0, Priority.Info, TargetNavigator2.TlvTargetUpdatedEvent)
    }
  });
  TargetNavigator2.Cluster = TargetNavigator2.ClusterInstance;
  TargetNavigator2.Complete = TargetNavigator2.Cluster;
})(TargetNavigator || (TargetNavigator = {}));
const TargetNavigatorCluster = TargetNavigator.Cluster;
ClusterRegistry.register(TargetNavigator.Complete);
export {
  TargetNavigator,
  TargetNavigatorCluster
};
//# sourceMappingURL=target-navigator.js.map
