import Quickshell
import Quickshell.Io
import QtQuick
import QtQuick.Layouts
import Quickshell.Widgets
import Quickshell.Services.Pipewire
import QtQuick.VectorImage
import QtQuick.Effects
import QtQuick.Shapes 1.10
import QtQuick.Effects
import "common" as Common

Rectangle {
    id: root
    property PwNode speakerNode: Pipewire.defaultAudioSink
    property PwNode microphoneNode: Pipewire.defaultAudioSource
    PwObjectTracker {
        objects: [root.microphoneNode, root.speakerNode]
    }
    implicitWidth: itemContent.width + 8
    implicitHeight: 24
    radius: 5.5
    Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter
    color: Common.Colors.colors.secondary // Define item color
		// color: "#2a2a2a"
    RowLayout {
        id: itemContent
				anchors.centerIn: parent
				// spacing: 100
        Repeater {
            model: [
                {
                    on: Common.Icons.audioIcons["speaker"],
                    off: Common.Icons.audioIcons["speakerMuted"],
                    node: root.speakerNode
                },
                {
                    on: Common.Icons.audioIcons["microphone"],
                    off: Common.Icons.audioIcons["microphoneMuted"],
                    node: root.microphoneNode
                },
            ]
            Item {
							id: meow
                implicitWidth: 24
								Layout.alignment: Qt.AlignHCenter
                implicitHeight: 24
								Text {
									id: textElement
									anchors.centerIn: parent // Ensure the text fills the parent item
									text: modelData.node.audio.muted ? modelData.off : modelData.on
									font.pointSize: 18.25
									font.weight: Font.DemiBold
									color: modelData.node.audio.muted ? Common.Colors.colors.critial2 : Common.Colors.colors.primary
								}
            }
        }
    }
}
