pragma ComponentBehavior: Bound

import QtQuick
import QtQuick.Layouts
import ZShell.Config
import qs.Components
import qs.Modules.Settings.Common

PageBase {
	id: root

	readonly property var schemes: [
		{
			id: "oneDark",
			label: qsTr("One Dark")
		},
		{
			id: "nord",
			label: qsTr("Nord")
		},
		{
			id: "dracula",
			label: qsTr("Dracula")
		},
		{
			id: "githubDark",
			label: qsTr("Github Dark")
		},
		{
			id: "solarizedDark",
			label: qsTr("Solarized Dark")
		},
		{
			id: "monokai",
			label: qsTr("Monokai")
		},
		{
			id: "gruvboxDark",
			label: qsTr("Gruvbox Dark")
		},
		{
			id: "catppuccinMocha",
			label: qsTr("Catppuccin Mocha")
		},
		{
			id: "tokyoNight",
			label: qsTr("Tokyo Night")
		},
		{
			id: "ayuDark",
			label: qsTr("Ayu Dark")
		},
		{
			id: "palenight",
			label: qsTr("Pale Night")
		}
	]

	isSubPage: true
	title: qsTr("Sidebar")

	ColumnLayout {
		anchors.horizontalCenter: parent.horizontalCenter
		anchors.top: parent.top
		spacing: Tokens.spacing.extraSmall / 2
		width: root.cappedWidth

		SectionHeader {
			first: true
			text: qsTr("General")
		}

		ToggleRow {
			settingAnchor: "panels-sidebar-llm-enabled"
			checked: Config.llm.enabled
			text: qsTr("Enabled")
			first: true
			last: true

			onToggled: Config.llm.enabled = checked
		}

		SectionHeader {
			text: qsTr("Appearance")
		}

		DialogSelectButton {
			id: selectScheme

			acceptLabel: qsTr("Confirm")
			enabled: Object.keys(model).length > 0
			settingAnchor: "panels-sidebar-select-scheme"
			separateContent: false
			header: qsTr("Select scheme")
			first: true
			last: true
			icon: "format_paint"
			iconLabel.font.pointSize: Tokens.font.size.large
			rowButton.trailingIcon: "open_in_new"
			onOpenChanged: {
				root.sState.dimmed = open;
			}
			rowButton.activeItem: root.schemes.find(s => s.id === Config.llm.appearance.scheme).label
			label: qsTr("Color scheme")
			subtext: qsTr("Select the color scheme used for code blocks")
			model: root.schemes
			rootParent: root.flickable

			initialSelect: Config.llm.appearance.scheme

			onAccepted: {
				if (!selectedItem)
					return;

				Config.llm.appearance.scheme = selectedItem;
			}
		}
	}
}
