package httproutes

import (
	"net/http"

	"hyapp/services/gateway-service/internal/transport/http/httpkit"
)

const APIV1Prefix = "/api/v1"

type Wrapper func(http.HandlerFunc) http.Handler

type Config struct {
	PublicWrap  Wrapper
	AuthWrap    Wrapper
	ProfileWrap Wrapper
	Auth        AuthHandlers
	App         AppHandlers
	User        UserHandlers
	Manager     ManagerHandlers
	Room        RoomHandlers
	Message     MessageHandlers
	Task        TaskHandlers
	Level       LevelHandlers
	Achievement AchievementHandlers
	Wallet      WalletHandlers
	VIP         VIPHandlers
	Game        GameHandlers
}

type AuthHandlers struct {
	LoginPassword      http.HandlerFunc
	SetPassword        http.HandlerFunc
	QuickCreateAccount http.HandlerFunc
	LoginThirdParty    http.HandlerFunc
	RefreshToken       http.HandlerFunc
	Logout             http.HandlerFunc
}

type AppHandlers struct {
	ListRegistrationCountries     http.HandlerFunc
	ListLoginRiskBlockedCountries http.HandlerFunc
	GetAppBootstrap               http.HandlerFunc
	ListH5Links                   http.HandlerFunc
	ListExploreTabs               http.HandlerFunc
	ListAppBanners                http.HandlerFunc
	ListSplashScreens             http.HandlerFunc
	GetAppVersion                 http.HandlerFunc
	GetResourceGroup              http.HandlerFunc
	ListResourceShopItems         http.HandlerFunc
	PurchaseResourceShopItem      http.HandlerFunc
	ListGifts                     http.HandlerFunc
	ListGiftTabs                  http.HandlerFunc
	ListEmojiPacks                http.HandlerFunc
	IssueTencentIMUserSig         http.HandlerFunc
	IssueTencentRTCToken          http.HandlerFunc
	HandleTencentIMCallback       http.HandlerFunc
	HandleTencentRTCCallback      http.HandlerFunc
	UploadFile                    http.HandlerFunc
	UploadAvatar                  http.HandlerFunc
	ProxyEffectMedia              http.HandlerFunc
	HandlePushToken               http.HandlerFunc
	AppHeartbeat                  http.HandlerFunc
}

type UserHandlers struct {
	ResolveDisplayUserID          http.HandlerFunc
	BatchUserProfiles             http.HandlerFunc
	BatchRoomDisplayProfiles      http.HandlerFunc
	GetMyOverview                 http.HandlerFunc
	GetMyGiftWall                 http.HandlerFunc
	GetMyIdentity                 http.HandlerFunc
	GetMyHostIdentity             http.HandlerFunc
	GetMyRoleSummary              http.HandlerFunc
	SearchHostAgencies            http.HandlerFunc
	ApplyToHostAgency             http.HandlerFunc
	GetHostCenterAgency           http.HandlerFunc
	GetHostCenterPlatformPolicy   http.HandlerFunc
	GetAgencyCenterOverview       http.HandlerFunc
	GetAgencyCenterPlatformPolicy http.HandlerFunc
	ListAgencyCenterHosts         http.HandlerFunc
	ListAgencyCenterApplications  http.HandlerFunc
	ReviewAgencyCenterApplication http.HandlerFunc
	RemoveAgencyCenterHost        http.HandlerFunc
	GetBDLeaderCenterOverview     http.HandlerFunc
	ListBDLeaderCenterBDs         http.HandlerFunc
	ListBDLeaderCenterAgencies    http.HandlerFunc
	InviteBDLeaderBD              http.HandlerFunc
	InviteBDLeaderAgency          http.HandlerFunc
	GetBDCenterOverview           http.HandlerFunc
	ListBDCenterAgencies          http.HandlerFunc
	InviteBDAgency                http.HandlerFunc
	CompleteMyOnboarding          http.HandlerFunc
	UpdateMyProfile               http.HandlerFunc
	ChangeMyCountry               http.HandlerFunc
	ChangeMyDisplayUserID         http.HandlerFunc
	ApplyMyPrettyDisplayUserID    http.HandlerFunc
	ListMyProfileVisitors         http.HandlerFunc
	ListMyFollowing               http.HandlerFunc
	ListMyFriends                 http.HandlerFunc
	ListMyFriendApplications      http.HandlerFunc
	ListCPApplications            http.HandlerFunc
	AcceptCPApplication           http.HandlerFunc
	RejectCPApplication           http.HandlerFunc
	ListCPRelationships           http.HandlerFunc
	BreakCPRelationship           http.HandlerFunc
	GetMyProfile                  http.HandlerFunc
	GetMyAppearance               http.HandlerFunc
	GetUserAppearance             http.HandlerFunc
	ListMyResources               http.HandlerFunc
	EquipMyResource               http.HandlerFunc
	UnequipMyResource             http.HandlerFunc
	UserSocialAction              http.HandlerFunc
	SubmitReport                  http.HandlerFunc
}

type ManagerHandlers struct {
	ListManagerGrantResources http.HandlerFunc
	GrantManagerResource      http.HandlerFunc
	LookupBusinessUsers       http.HandlerFunc
	GetManagerOverview        http.HandlerFunc
	SearchManagerUsers        http.HandlerFunc
	GrantManagerVIP           http.HandlerFunc
	ManagerBlocks             http.HandlerFunc
	ListManagerBlocks         http.HandlerFunc
	CreateManagerBlock        http.HandlerFunc
	UnblockManagerBlock       http.HandlerFunc
	SetManagerUserLevel       http.HandlerFunc
}

type RoomHandlers struct {
	GetMyRoom            http.HandlerFunc
	ListRoomFeeds        http.HandlerFunc
	ListRooms            http.HandlerFunc
	GetCurrentRoom       http.HandlerFunc
	GetRoomSnapshot      http.HandlerFunc
	GetRoomDetail        http.HandlerFunc
	ListRoomOnlineUsers  http.HandlerFunc
	ListRoomBannedUsers  http.HandlerFunc
	GetRoomGiftPanel     http.HandlerFunc
	GetRoomRocket        http.HandlerFunc
	FollowRoom           http.HandlerFunc
	CreateRoom           http.HandlerFunc
	UpdateRoomProfile    http.HandlerFunc
	SaveRoomBackground   http.HandlerFunc
	ListRoomBackgrounds  http.HandlerFunc
	SetRoomBackground    http.HandlerFunc
	JoinRoom             http.HandlerFunc
	RoomHeartbeat        http.HandlerFunc
	LeaveRoom            http.HandlerFunc
	CloseRoom            http.HandlerFunc
	MicUp                http.HandlerFunc
	MicDown              http.HandlerFunc
	ChangeMicSeat        http.HandlerFunc
	ConfirmMicPublishing http.HandlerFunc
	MicHeartbeat         http.HandlerFunc
	SetMicMute           http.HandlerFunc
	SetMicSeatLock       http.HandlerFunc
	SetChatEnabled       http.HandlerFunc
	SetRoomPassword      http.HandlerFunc
	SetRoomAdmin         http.HandlerFunc
	MuteUser             http.HandlerFunc
	KickUser             http.HandlerFunc
	UnbanUser            http.HandlerFunc
	SendGift             http.HandlerFunc
}

type MessageHandlers struct {
	ListMessageTabs          http.HandlerFunc
	MarkInboxSectionRead     http.HandlerFunc
	MarkInboxMessageReadPath http.HandlerFunc
	DeleteInboxMessagePath   http.HandlerFunc
	ListInboxMessages        http.HandlerFunc
}

type TaskHandlers struct {
	ListTaskTabs                      http.HandlerFunc
	ClaimTaskReward                   http.HandlerFunc
	GetRegistrationRewardEligibility  http.HandlerFunc
	GetFirstRechargeRewardStatus      http.HandlerFunc
	GetCumulativeRechargeRewardStatus http.HandlerFunc
	GetSevenDayCheckInStatus          http.HandlerFunc
	SignSevenDayCheckIn               http.HandlerFunc
	ListUserLeaderboards              http.HandlerFunc
	CheckLuckyGift                    http.HandlerFunc
	GetRoomTurnoverRewardStatus       http.HandlerFunc
	GetWeeklyStarCurrent              http.HandlerFunc
	ListWeeklyStarLeaderboard         http.HandlerFunc
	ListWeeklyStarHistory             http.HandlerFunc
}

type LevelHandlers struct {
	GetMyLevelOverview http.HandlerFunc
	GetLevelTrack      http.HandlerFunc
	ListLevelRewards   http.HandlerFunc
}

type AchievementHandlers struct {
	ListAchievements http.HandlerFunc
	ListMyBadges     http.HandlerFunc
	SetBadgeDisplay  http.HandlerFunc
}

type WalletHandlers struct {
	GetWalletOverview        http.HandlerFunc
	GetMyBalances            http.HandlerFunc
	ListRechargeProducts     http.HandlerFunc
	ConfirmGooglePayment     http.HandlerFunc
	GetDiamondExchangeConfig http.HandlerFunc
	ListCoinTransactions     http.HandlerFunc
	ListWalletTransactions   http.HandlerFunc
	ListCoinSellers          http.HandlerFunc
	TransferCoinFromSeller   http.HandlerFunc
	GetSalaryWalletOverview  http.HandlerFunc
	SearchSalaryWalletSeller http.HandlerFunc
	ExchangeSalaryToCoin     http.HandlerFunc
	TransferSalaryToSeller   http.HandlerFunc
	GetRedPacketConfig       http.HandlerFunc
	ListRoomRedPackets       http.HandlerFunc
	CreateRoomRedPacket      http.HandlerFunc
	GetRedPacket             http.HandlerFunc
	ClaimRedPacket           http.HandlerFunc
	GetCurrentRegionIMGroup  http.HandlerFunc
	GetRedPacketIMGroup      http.HandlerFunc
	SendVoiceRoomRedPacket   http.HandlerFunc
	ListActiveRedPackets     http.HandlerFunc
	ClaimVoiceRoomRedPacket  http.HandlerFunc
	GetVoiceRoomRedPacket    http.HandlerFunc
	ListRedPacketClaims      http.HandlerFunc
	ListSentRedPackets       http.HandlerFunc
}

type VIPHandlers struct {
	GetMyVIP        http.HandlerFunc
	ListVIPPackages http.HandlerFunc
	PurchaseVIP     http.HandlerFunc
}

type GameHandlers struct {
	ListGames       http.HandlerFunc
	ListRecentGames http.HandlerFunc
	GetBridgeScript http.HandlerFunc
	LaunchGame      http.HandlerFunc
	HandleCallback  http.HandlerFunc
}

type routes struct {
	mux    *http.ServeMux
	config Config
}

// New 只维护 gateway 对外 HTTP 路径到 transport handler 的绑定。
// 业务状态和命令执行仍然全部下沉到 owner service，路由层不承载业务规则。
func New(config Config) http.Handler {
	mux := http.NewServeMux()
	routes := routes{mux: mux, config: config}

	routes.registerAuthRoutes()
	routes.registerAppRoutes()
	routes.registerUserRoutes()
	routes.registerManagerRoutes()
	routes.registerRoomRoutes()
	routes.registerMessageRoutes()
	routes.registerTaskRoutes()
	routes.registerLevelRoutes()
	routes.registerAchievementRoutes()
	routes.registerWalletRoutes()
	routes.registerVIPRoutes()
	routes.registerGameRoutes()

	return mux
}

func (r routes) public(path string, method string, next http.HandlerFunc) {
	r.register(path, method, r.config.PublicWrap, next)
}

func (r routes) auth(path string, method string, next http.HandlerFunc) {
	r.register(path, method, r.config.AuthWrap, next)
}

func (r routes) profile(path string, method string, next http.HandlerFunc) {
	r.register(path, method, r.config.ProfileWrap, next)
}

func (r routes) register(path string, method string, wrap Wrapper, next http.HandlerFunc) {
	if method != "" {
		// method 继续走 gateway envelope，而不是使用 ServeMux 自动 405。
		next = httpkit.RequireMethod(method, next)
	}
	r.mux.Handle(APIV1Prefix+path, wrap(next))
}

func (r routes) registerAuthRoutes() {
	h := r.config.Auth
	r.public("/auth/account/login", "", h.LoginPassword)
	r.auth("/auth/password/set", "", h.SetPassword)
	r.public("/auth/account/quick-create", http.MethodPost, h.QuickCreateAccount)
	r.public("/auth/third-party/login", "", h.LoginThirdParty)
	r.public("/auth/token/refresh", "", h.RefreshToken)
	r.public("/auth/logout", "", h.Logout)
}

func (r routes) registerAppRoutes() {
	h := r.config.App
	r.public("/countries", "", h.ListRegistrationCountries)
	r.public("/login-risk/blocked-countries", http.MethodGet, h.ListLoginRiskBlockedCountries)
	r.public("/app/bootstrap", "", h.GetAppBootstrap)
	r.public("/app/h5-links", "", h.ListH5Links)
	r.public("/app/explore-tabs", http.MethodGet, h.ListExploreTabs)
	r.public("/app/banners", "", h.ListAppBanners)
	r.public("/app/splash-screens", http.MethodGet, h.ListSplashScreens)
	r.public("/app/version", http.MethodGet, h.GetAppVersion)
	r.public("/resource-groups/{group_id}", "", h.GetResourceGroup)
	r.public("/resource-shop/items", http.MethodGet, h.ListResourceShopItems)
	r.profile("/resource-shop/items/{shop_item_id}/purchase", http.MethodPost, h.PurchaseResourceShopItem)
	r.public("/gifts", "", h.ListGifts)
	r.public("/gift-tabs", http.MethodGet, h.ListGiftTabs)
	r.public("/emoji-packs", http.MethodGet, h.ListEmojiPacks)
	r.profile("/im/usersig", http.MethodGet, h.IssueTencentIMUserSig)
	r.profile("/rtc/token", http.MethodPost, h.IssueTencentRTCToken)
	r.public("/tencent-im/callback", "", h.HandleTencentIMCallback)
	r.public("/tencent-rtc/callback", "", h.HandleTencentRTCCallback)
	r.auth("/files/upload", "", h.UploadFile)
	r.auth("/files/avatar/upload", "", h.UploadAvatar)
	r.public("/media/effects/proxy", http.MethodGet, h.ProxyEffectMedia)
	r.auth("/app/heartbeat", http.MethodPost, h.AppHeartbeat)
	r.profile("/devices/push-token", "", h.HandlePushToken)
}

func (r routes) registerUserRoutes() {
	h := r.config.User
	r.public("/users/by-display-user-id/{display_user_id}", "", h.ResolveDisplayUserID)
	r.profile("/users/profiles:batch", "", h.BatchUserProfiles)
	r.profile("/users/room-display-profiles:batch", http.MethodGet, h.BatchRoomDisplayProfiles)
	r.profile("/users/me/overview", "", h.GetMyOverview)
	r.profile("/users/me/gift-wall", http.MethodGet, h.GetMyGiftWall)
	r.auth("/users/me/identity", "", h.GetMyIdentity)
	r.profile("/users/me/host-identity", "", h.GetMyHostIdentity)
	r.profile("/users/me/role-summary", "", h.GetMyRoleSummary)
	r.profile("/host/agencies/search", http.MethodGet, h.SearchHostAgencies)
	r.profile("/host/agency-applications", http.MethodPost, h.ApplyToHostAgency)
	r.profile("/host-center/agency", http.MethodGet, h.GetHostCenterAgency)
	r.profile("/host-center/platform-policy", http.MethodGet, h.GetHostCenterPlatformPolicy)
	r.profile("/agency-center/overview", http.MethodGet, h.GetAgencyCenterOverview)
	r.profile("/agency-center/platform-policy", http.MethodGet, h.GetAgencyCenterPlatformPolicy)
	r.profile("/agency-center/hosts", http.MethodGet, h.ListAgencyCenterHosts)
	r.profile("/agency-center/applications", http.MethodGet, h.ListAgencyCenterApplications)
	r.profile("/agency-center/applications/{application_id}/review", http.MethodPost, h.ReviewAgencyCenterApplication)
	r.profile("/agency-center/hosts/{host_user_id}/remove", http.MethodPost, h.RemoveAgencyCenterHost)
	r.profile("/bd-leader-center/overview", http.MethodGet, h.GetBDLeaderCenterOverview)
	r.profile("/bd-leader-center/bds", http.MethodGet, h.ListBDLeaderCenterBDs)
	r.profile("/bd-leader-center/agencies", http.MethodGet, h.ListBDLeaderCenterAgencies)
	r.profile("/bd-leader/invitations/bd", http.MethodPost, h.InviteBDLeaderBD)
	r.profile("/bd-leader/invitations/agency", http.MethodPost, h.InviteBDLeaderAgency)
	r.profile("/bd-center/overview", http.MethodGet, h.GetBDCenterOverview)
	r.profile("/bd-center/agencies", http.MethodGet, h.ListBDCenterAgencies)
	r.profile("/bd/invitations/agency", http.MethodPost, h.InviteBDAgency)
	r.auth("/users/me/onboarding/complete", "", h.CompleteMyOnboarding)
	r.profile("/users/me/profile/update", "", h.UpdateMyProfile)
	r.profile("/users/me/country/change", "", h.ChangeMyCountry)
	r.auth("/users/me/display-id/change", "", h.ChangeMyDisplayUserID)
	r.auth("/users/me/display-id/pretty/apply", "", h.ApplyMyPrettyDisplayUserID)
	r.profile("/users/me/visitors", http.MethodGet, h.ListMyProfileVisitors)
	r.profile("/users/me/following", http.MethodGet, h.ListMyFollowing)
	r.profile("/users/me/friends", http.MethodGet, h.ListMyFriends)
	r.profile("/users/me/friend-requests", http.MethodGet, h.ListMyFriendApplications)
	r.profile("/cp/applications", http.MethodGet, h.ListCPApplications)
	r.profile("/cp/applications/{application_id}/accept", http.MethodPost, h.AcceptCPApplication)
	r.profile("/cp/applications/{application_id}/reject", http.MethodPost, h.RejectCPApplication)
	r.profile("/cp/relationships", http.MethodGet, h.ListCPRelationships)
	r.profile("/cp/relationships/{relationship_id}/break", http.MethodPost, h.BreakCPRelationship)
	r.profile("/appearance", http.MethodGet, h.GetMyAppearance)
	r.profile("/users/me/appearance", http.MethodGet, h.GetMyAppearance)
	r.profile("/users/me", "", h.GetMyProfile)
	r.profile("/users/me/resources", "", h.ListMyResources)
	r.profile("/users/me/resources/{resource_id}/equip", "", h.EquipMyResource)
	r.profile("/users/me/resources/{resource_type}/unequip", http.MethodDelete, h.UnequipMyResource)
	r.profile("/reports", http.MethodPost, h.SubmitReport)
	r.profile("/users/{user_id}/{action...}", "", h.UserSocialAction)
}

func (r routes) registerManagerRoutes() {
	h := r.config.Manager
	r.profile("/manager-center/overview", http.MethodGet, h.GetManagerOverview)
	r.profile("/manager-center/users/search", http.MethodGet, h.SearchManagerUsers)
	r.profile("/manager-center/resource-grants/resources", http.MethodGet, h.ListManagerGrantResources)
	r.profile("/manager-center/resource-grants", http.MethodPost, h.GrantManagerResource)
	r.profile("/manager-center/vip-grants", http.MethodPost, h.GrantManagerVIP)
	r.profile("/manager-center/blocks", "", h.ManagerBlocks)
	r.profile("/manager-center/blocks/{block_id}/unblock", http.MethodPost, h.UnblockManagerBlock)
	r.profile("/manager-center/levels", http.MethodPost, h.SetManagerUserLevel)
	r.profile("/business/users/lookup", http.MethodGet, h.LookupBusinessUsers)
}

func (r routes) registerRoomRoutes() {
	h := r.config.Room
	r.profile("/rooms/me", http.MethodGet, h.GetMyRoom)
	r.profile("/rooms/feeds", http.MethodGet, h.ListRoomFeeds)
	r.profile("/rooms", http.MethodGet, h.ListRooms)
	r.profile("/rooms/current", http.MethodGet, h.GetCurrentRoom)
	r.profile("/rooms/snapshot", http.MethodGet, h.GetRoomSnapshot)
	r.profile("/rooms/{room_id}/detail", http.MethodGet, h.GetRoomDetail)
	r.profile("/rooms/{room_id}/online-users", http.MethodGet, h.ListRoomOnlineUsers)
	r.profile("/rooms/{room_id}/banned-users", http.MethodGet, h.ListRoomBannedUsers)
	r.profile("/rooms/{room_id}/gift-panel", http.MethodGet, h.GetRoomGiftPanel)
	r.profile("/rooms/{room_id}/rocket", http.MethodGet, h.GetRoomRocket)
	r.profile("/rooms/{room_id}/follow", "", h.FollowRoom)
	r.profile("/rooms/{room_id}/backgrounds", http.MethodGet, h.ListRoomBackgrounds)
	r.profile("/rooms/create", http.MethodPost, h.CreateRoom)
	r.profile("/rooms/profile/update", http.MethodPost, h.UpdateRoomProfile)
	r.profile("/rooms/backgrounds/save", http.MethodPost, h.SaveRoomBackground)
	r.profile("/rooms/backgrounds/set", http.MethodPost, h.SetRoomBackground)
	r.profile("/rooms/join", http.MethodPost, h.JoinRoom)
	r.profile("/rooms/heartbeat", http.MethodPost, h.RoomHeartbeat)
	r.profile("/rooms/leave", http.MethodPost, h.LeaveRoom)
	r.profile("/rooms/close", http.MethodPost, h.CloseRoom)
	r.profile("/rooms/mic/up", http.MethodPost, h.MicUp)
	r.profile("/rooms/mic/down", http.MethodPost, h.MicDown)
	r.profile("/rooms/mic/change", http.MethodPost, h.ChangeMicSeat)
	r.profile("/rooms/mic/publishing/confirm", http.MethodPost, h.ConfirmMicPublishing)
	r.profile("/rooms/mic/heartbeat", http.MethodPost, h.MicHeartbeat)
	r.profile("/rooms/mic/mute", http.MethodPost, h.SetMicMute)
	r.profile("/rooms/mic/lock", http.MethodPost, h.SetMicSeatLock)
	r.profile("/rooms/chat/enabled", http.MethodPost, h.SetChatEnabled)
	r.profile("/rooms/password", http.MethodPost, h.SetRoomPassword)
	r.profile("/rooms/admin/set", http.MethodPost, h.SetRoomAdmin)
	r.profile("/rooms/user/mute", http.MethodPost, h.MuteUser)
	r.profile("/rooms/user/kick", http.MethodPost, h.KickUser)
	r.profile("/rooms/user/unban", http.MethodPost, h.UnbanUser)
	r.profile("/rooms/gift/send", http.MethodPost, h.SendGift)
}

func (r routes) registerMessageRoutes() {
	h := r.config.Message
	r.profile("/messages/tabs", "", h.ListMessageTabs)
	r.profile("/messages/read-all", "", h.MarkInboxSectionRead)
	r.profile("/messages/{message_id}/read", "", h.MarkInboxMessageReadPath)
	r.profile("/messages/{message_id}", "", h.DeleteInboxMessagePath)
	r.profile("/messages", "", h.ListInboxMessages)
}

func (r routes) registerTaskRoutes() {
	h := r.config.Task
	r.profile("/activities/registration-reward/eligibility", http.MethodGet, h.GetRegistrationRewardEligibility)
	r.profile("/activities/first-recharge-reward", http.MethodGet, h.GetFirstRechargeRewardStatus)
	r.profile("/activities/cumulative-recharge-reward", http.MethodGet, h.GetCumulativeRechargeRewardStatus)
	r.profile("/activities/seven-day-checkin", http.MethodGet, h.GetSevenDayCheckInStatus)
	r.profile("/activities/seven-day-checkin/sign", http.MethodPost, h.SignSevenDayCheckIn)
	r.profile("/activities/user-leaderboards", http.MethodGet, h.ListUserLeaderboards)
	r.profile("/activities/room-turnover-reward", http.MethodGet, h.GetRoomTurnoverRewardStatus)
	r.profile("/activities/weekly-star/current", http.MethodGet, h.GetWeeklyStarCurrent)
	r.profile("/activities/weekly-star/leaderboard", http.MethodGet, h.ListWeeklyStarLeaderboard)
	r.profile("/activities/weekly-star/history", http.MethodGet, h.ListWeeklyStarHistory)
	// App 侧接口保持稳定；内部仍按 pool_id 走当前 v2 规则、抽奖和返奖实现。
	r.profile("/activities/lucky-gifts/check", http.MethodPost, h.CheckLuckyGift)
	r.profile("/tasks/tabs", http.MethodGet, h.ListTaskTabs)
	r.profile("/tasks/claim", http.MethodPost, h.ClaimTaskReward)
}

func (r routes) registerLevelRoutes() {
	h := r.config.Level
	r.profile("/levels/me/overview", http.MethodGet, h.GetMyLevelOverview)
	r.profile("/levels/tracks/{track}", http.MethodGet, h.GetLevelTrack)
	r.profile("/levels/rewards", http.MethodGet, h.ListLevelRewards)
}

func (r routes) registerAchievementRoutes() {
	h := r.config.Achievement
	r.profile("/achievements", http.MethodGet, h.ListAchievements)
	r.profile("/badges/me", http.MethodGet, h.ListMyBadges)
	r.profile("/badges/display", http.MethodPost, h.SetBadgeDisplay)
}

func (r routes) registerWalletRoutes() {
	h := r.config.Wallet
	r.profile("/wallet/me/overview", http.MethodGet, h.GetWalletOverview)
	r.profile("/wallet/me/balances", "", h.GetMyBalances)
	r.profile("/wallet/recharge/products", http.MethodGet, h.ListRechargeProducts)
	r.profile("/wallet/payments/google/confirm", http.MethodPost, h.ConfirmGooglePayment)
	r.profile("/wallet/diamond-exchange/config", http.MethodGet, h.GetDiamondExchangeConfig)
	r.profile("/wallet/coin-transactions", http.MethodGet, h.ListCoinTransactions)
	r.profile("/wallet/transactions", http.MethodGet, h.ListWalletTransactions)
	r.profile("/wallet/coin-sellers", http.MethodGet, h.ListCoinSellers)
	r.profile("/wallet/coin-seller/transfer", "", h.TransferCoinFromSeller)
	r.profile("/salary-wallet/overview", http.MethodGet, h.GetSalaryWalletOverview)
	r.profile("/salary-wallet/coin-sellers/search", http.MethodGet, h.SearchSalaryWalletSeller)
	r.profile("/salary-wallet/exchange", http.MethodPost, h.ExchangeSalaryToCoin)
	r.profile("/salary-wallet/transfer-to-coin-seller", http.MethodPost, h.TransferSalaryToSeller)
	r.profile("/red-packets/config", http.MethodGet, h.GetRedPacketConfig)
	r.profile("/rooms/{room_id}/red-packets", http.MethodGet, h.ListRoomRedPackets)
	r.profile("/rooms/{room_id}/red-packets/create", http.MethodPost, h.CreateRoomRedPacket)
	r.profile("/red-packets/{packet_id}", http.MethodGet, h.GetRedPacket)
	r.profile("/red-packets/{packet_id}/claim", http.MethodPost, h.ClaimRedPacket)
	r.profile("/app/region-im-group/current", http.MethodGet, h.GetCurrentRegionIMGroup)
	r.profile("/app/voice-room/red-packet/im-group", http.MethodGet, h.GetRedPacketIMGroup)
	r.profile("/app/voice-room/red-packet/config", http.MethodGet, h.GetRedPacketConfig)
	r.profile("/app/voice-room/red-packet/send", http.MethodPost, h.SendVoiceRoomRedPacket)
	r.profile("/app/voice-room/red-packet/active", http.MethodGet, h.ListActiveRedPackets)
	r.profile("/app/voice-room/red-packet/claim", http.MethodPost, h.ClaimVoiceRoomRedPacket)
	r.profile("/app/voice-room/red-packet/detail", http.MethodGet, h.GetVoiceRoomRedPacket)
	r.profile("/app/voice-room/red-packet/claim-records", http.MethodGet, h.ListRedPacketClaims)
	r.profile("/app/voice-room/red-packet/sent-records", http.MethodGet, h.ListSentRedPackets)
}

func (r routes) registerVIPRoutes() {
	h := r.config.VIP
	r.profile("/vip/me", http.MethodGet, h.GetMyVIP)
	r.profile("/vip/packages", http.MethodGet, h.ListVIPPackages)
	r.profile("/vip/purchase", http.MethodPost, h.PurchaseVIP)
}

func (r routes) registerGameRoutes() {
	h := r.config.Game
	r.profile("/games", http.MethodGet, h.ListGames)
	r.profile("/games/recent", http.MethodGet, h.ListRecentGames)
	r.profile("/games/bridge-script", http.MethodGet, h.GetBridgeScript)
	r.profile("/games/{game_id}/launch", http.MethodPost, h.LaunchGame)
	r.public("/game-callbacks/{platform_code}/{operation}", http.MethodPost, h.HandleCallback)
}
