/**
 * @license
 * Copyright 2022-2026 Matter.js Authors
 * SPDX-License-Identifier: Apache-2.0
 */
import { MutableCluster } from "../cluster/mutation/MutableCluster.js";
import { Command, TlvNoResponse, Attribute } from "../cluster/Cluster.js";
import { TlvField, TlvObject } from "../tlv/TlvObject.js";
import { TlvUInt8, TlvEnum } from "../tlv/TlvNumber.js";
import { TlvString } from "../tlv/TlvString.js";
import { AccessLevel } from "@matter/model";
import { BitFlag } from "../schema/BitmapSchema.js";
import { TlvArray } from "../tlv/TlvArray.js";
import { ClusterRegistry } from "../cluster/ClusterRegistry.js";
var AudioOutput;
((AudioOutput2) => {
  let Feature;
  ((Feature2) => {
    Feature2["NameUpdates"] = "NameUpdates";
  })(Feature = AudioOutput2.Feature || (AudioOutput2.Feature = {}));
  AudioOutput2.TlvRenameOutputRequest = TlvObject({ index: TlvField(0, TlvUInt8), name: TlvField(1, TlvString) });
  let OutputType;
  ((OutputType2) => {
    OutputType2[OutputType2["Hdmi"] = 0] = "Hdmi";
    OutputType2[OutputType2["Bt"] = 1] = "Bt";
    OutputType2[OutputType2["Optical"] = 2] = "Optical";
    OutputType2[OutputType2["Headphone"] = 3] = "Headphone";
    OutputType2[OutputType2["Internal"] = 4] = "Internal";
    OutputType2[OutputType2["Other"] = 5] = "Other";
  })(OutputType = AudioOutput2.OutputType || (AudioOutput2.OutputType = {}));
  AudioOutput2.TlvOutputInfo = TlvObject({
    /**
     * This field shall indicate the unique index into the list of outputs.
     *
     * @see {@link MatterSpecification.v142.Cluster} § 6.5.5.2.1
     */
    index: TlvField(0, TlvUInt8),
    /**
     * This field shall indicate the type of output.
     *
     * @see {@link MatterSpecification.v142.Cluster} § 6.5.5.2.2
     */
    outputType: TlvField(1, TlvEnum()),
    /**
     * The device defined and user editable output name, such as “Soundbar”, “Speakers”. This field may be blank,
     * but SHOULD be provided when known.
     *
     * @see {@link MatterSpecification.v142.Cluster} § 6.5.5.2.3
     */
    name: TlvField(2, TlvString)
  });
  AudioOutput2.TlvSelectOutputRequest = TlvObject({
    /**
     * This shall indicate the index field of the OutputInfoStruct from the OutputList attribute in which to change
     * to.
     *
     * @see {@link MatterSpecification.v142.Cluster} § 6.5.7.1.1
     */
    index: TlvField(0, TlvUInt8)
  });
  AudioOutput2.NameUpdatesComponent = MutableCluster.Component({
    commands: {
      /**
       * Upon receipt, this shall rename the output at a specific index in the Output List.
       *
       * Updates to the output name shall appear in the device’s settings menus. Name updates may automatically be
       * sent to the actual device to which the output connects.
       *
       * @see {@link MatterSpecification.v142.Cluster} § 6.5.7.2
       */
      renameOutput: Command(1, AudioOutput2.TlvRenameOutputRequest, 1, TlvNoResponse, { invokeAcl: AccessLevel.Manage })
    }
  });
  AudioOutput2.Base = MutableCluster.Component({
    id: 1291,
    name: "AudioOutput",
    revision: 1,
    features: {
      /**
       * Supports updates to output names
       */
      nameUpdates: BitFlag(0)
    },
    attributes: {
      /**
       * This attribute provides the list of outputs supported by the device.
       *
       * @see {@link MatterSpecification.v142.Cluster} § 6.5.6.1
       */
      outputList: Attribute(0, TlvArray(AudioOutput2.TlvOutputInfo), { default: [] }),
      /**
       * This attribute contains the value of the index field of the currently selected OutputInfoStruct.
       *
       * @see {@link MatterSpecification.v142.Cluster} § 6.5.6.2
       */
      currentOutput: Attribute(1, TlvUInt8)
    },
    commands: {
      /**
       * Upon receipt, this shall change the output on the device to the output at a specific index in the Output
       * List.
       *
       * Note that when the current output is set to an output of type HDMI, adjustments to volume via a Speaker
       * endpoint on the same node may cause HDMI volume up/down commands to be sent to the given HDMI output.
       *
       * @see {@link MatterSpecification.v142.Cluster} § 6.5.7.1
       */
      selectOutput: Command(0, AudioOutput2.TlvSelectOutputRequest, 0, TlvNoResponse)
    },
    /**
     * This metadata controls which AudioOutputCluster elements matter.js activates for specific feature
     * combinations.
     */
    extensions: MutableCluster.Extensions({ flags: { nameUpdates: true }, component: AudioOutput2.NameUpdatesComponent })
  });
  AudioOutput2.ClusterInstance = MutableCluster(AudioOutput2.Base);
  AudioOutput2.Cluster = AudioOutput2.ClusterInstance;
  const NU = { nameUpdates: true };
  AudioOutput2.CompleteInstance = MutableCluster({
    id: AudioOutput2.Cluster.id,
    name: AudioOutput2.Cluster.name,
    revision: AudioOutput2.Cluster.revision,
    features: AudioOutput2.Cluster.features,
    attributes: AudioOutput2.Cluster.attributes,
    commands: {
      ...AudioOutput2.Cluster.commands,
      renameOutput: MutableCluster.AsConditional(
        AudioOutput2.NameUpdatesComponent.commands.renameOutput,
        { mandatoryIf: [NU] }
      )
    }
  });
  AudioOutput2.Complete = AudioOutput2.CompleteInstance;
})(AudioOutput || (AudioOutput = {}));
const AudioOutputCluster = AudioOutput.Cluster;
ClusterRegistry.register(AudioOutput.Complete);
export {
  AudioOutput,
  AudioOutputCluster
};
//# sourceMappingURL=audio-output.js.map
