package doc

import (
	"reflect"

	"github.com/nicklaw5/helix/v2"

	"git.sr.ht/~ashkeel/strimertul/docs/interfaces"
	"git.sr.ht/~ashkeel/strimertul/twitch"
	"git.sr.ht/~ashkeel/strimertul/twitch/alerts"
	"git.sr.ht/~ashkeel/strimertul/twitch/chat"
	"git.sr.ht/~ashkeel/strimertul/twitch/eventsub"
	"git.sr.ht/~ashkeel/strimertul/twitch/timers"
)

// Documentation stuff, keep updated at all times

var Keys = interfaces.KeyMap{
	twitch.ConfigKey: interfaces.KeyDef{
		Description: "General configuration for the Twitch subsystem",
		Type:        reflect.TypeOf(twitch.Config{}),
	},
	twitch.StreamInfoKey: interfaces.KeyDef{
		Description: "List of active twitch streams (1 element if live, 0 otherwise)",
		Type:        reflect.TypeOf([]helix.Stream{}),
	},
	twitch.AuthKey: interfaces.KeyDef{
		Description: "User access token for the twitch subsystem",
		Type:        reflect.TypeOf(twitch.AuthResponse{}),
	},
	chat.ConfigKey: interfaces.KeyDef{
		Description: "Configuration for chat-related features",
		Type:        reflect.TypeOf(chat.Config{}),
	},
	chat.ActivityKey: interfaces.KeyDef{
		Description: "Number of chat messages in the last minute",
		Type:        reflect.TypeOf(0),
	},
	chat.CustomCommandsKey: interfaces.KeyDef{
		Description: "Chat custom commands",
		Type:        reflect.TypeOf(map[string]chat.CustomCommand{}),
	},
	chat.CustomAccountKey: interfaces.KeyDef{
		Description: "User access token for the chat account (if not using the main one)",
		Type:        reflect.TypeOf(twitch.AuthResponse{}),
	},
	chat.WriteMessageRPC: interfaces.KeyDef{
		Description: "Send chat message with extra options (as reply, whisper, etc)",
		Type:        reflect.TypeOf(chat.WriteMessageRequest{}),
		Tags:        []interfaces.KeyTag{interfaces.TagRPC},
	},
	eventsub.EventKeyPrefix + "[event-name]": interfaces.KeyDef{
		Description: "On Eventsub event [event-name] received",
		Type:        reflect.TypeOf(eventsub.NotificationMessagePayload{}),
		Tags:        []interfaces.KeyTag{interfaces.TagEvent},
	},
	eventsub.HistoryKeyPrefix + "[event-name]": interfaces.KeyDef{
		Description: "Last eventsub notifications received for [event-name]",
		Type:        reflect.TypeOf([]eventsub.NotificationMessagePayload{}),
		Tags:        []interfaces.KeyTag{interfaces.TagHistory},
	},
	alerts.ConfigKey: interfaces.KeyDef{
		Description: "Configuration of chat alerts",
		Type:        reflect.TypeOf(alerts.Config{}),
	},
	timers.ConfigKey: interfaces.KeyDef{
		Description: "Configuration of chat timers",
		Type:        reflect.TypeOf(timers.Config{}),
	},
}

var Enums = interfaces.EnumMap{
	"AccessLevelType": interfaces.Enum{
		Values: []any{
			chat.ALTEveryone,
			chat.ALTSubscribers,
			chat.ALTVIP,
			chat.ALTModerators,
			chat.ALTStreamer,
		},
	},
	"ResponseType": interfaces.Enum{
		Values: []any{
			chat.ResponseTypeChat,
			chat.ResponseTypeReply,
			chat.ResponseTypeWhisper,
			chat.ResponseTypeAnnounce,
		},
	},
}
