package de.arindy.dicetower

import io.quarkus.qute.TemplateInstance
import jakarta.ws.rs.GET
import jakarta.ws.rs.Path
import jakarta.ws.rs.PathParam
import jakarta.ws.rs.Produces
import jakarta.ws.rs.QueryParam
import jakarta.ws.rs.core.MediaType

@Path("chatoverlay")
class ChatOverlayResource {

    @GET
    @Path("/{channel}")
    @Produces(MediaType.TEXT_HTML)
    fun get(
        @PathParam("channel") channel: String,
        @QueryParam("scale") scale: Int? = 7,
        @QueryParam("maxDice") maxDice: Int? = 20,
        @QueryParam("modsAllowed") modsAllowed: Boolean = false,
        @QueryParam("vipAllowed") vipAllowed: Boolean = false,
        @QueryParam("subsAllowed") subsAllowed: Boolean = false,
        @QueryParam("cmd") cmd: String? = "roll",
        @QueryParam("theme") theme: String? = "default",
        @QueryParam("themeColor") themeColor: String? = "default",
        @QueryParam("clearAfter") clearAfter: Long? = -1,
        @QueryParam("timeout") timeout: Long? = -1
    ): TemplateInstance {
        return Templates.chatoverlay(channel, scale ?: 7, maxDice ?: 20, modsAllowed, vipAllowed, subsAllowed, cmd ?: "roll", theme ?: "default", themeColor ?: "ff0202", clearAfter ?: 10, timeout ?: 60)
    }

    @GET
    @Produces(MediaType.TEXT_HTML)
    fun config(
    ): TemplateInstance {
        return Templates.chatoverlayconfig()
    }

}
