import { Hono } from 'hono'

import type { App } from '../context'

// Text sanitization, keepsakes, objectives/events/rewards, and the misc
// analytics/subscription sinks the client hits during load.
export const gameplayRoutes = new Hono<App>({ strict: false })
	// Text sanitization (display names, room names, chat). `v1` echoes the input
	// value back; `isPure` reports the text is clean.
	.post('/api/sanitize/v1', async (c) => {
		const body = await c.req.json<{ Value?: unknown }>().catch(() => ({}) as { Value?: unknown })
		return c.json(typeof body.Value === 'string' ? body.Value : '')
	})
	.post('/api/sanitize/v1/isPure', (c) => c.json({ IsPure: true }))

	// Keepsakes (room mementos). Stubbed empty.
	.get('/api/keepsakes/globalconfig', (c) =>
		c.json({ KeepsakeFeatureEnabled: true, KeepsakeRoomLimit: 10, SocialXpBoostEnabled: false })
	)
	.get('/api/keepsakes/rooms/:roomId', (c) => c.body(null, 204))
	.get('/api/keepsakes/categories', (c) => c.json([]))

	// ---- Objectives / events / rewards ---------------------------------------
	.post('/api/objectives/v1/updateobjective', (c) => c.body(null, 200))
	.get('/api/communityboard/v2/current', (c) => c.json({})) // TODO: hydrate from JSON/communityboard.json
	.get('/api/playerevents/v1/all', (c) => c.json({ Created: [], Responses: [] }))
	.get('/api/announcement/v1/get', (c) => c.json([])) // TODO: hydrate from JSON/announcements.json

	// GameSight attribution/analytics event sink. Accept and ack without persisting.
	.post('/api/gamesight/event', (c) => c.body(null, 200))

	// ---- Subscription ---------------------------------------------------------
	.post('/api/CampusCard/v1/UpdateAndGetSubscription', (c) =>
		c.json({ subscription: null, platformAccountSubscribedPlayerId: null })
	)
