package com.aegir.demo.ui

import androidx.compose.material3.MaterialTheme
import androidx.compose.ui.platform.ComposeView
import com.aegir.vmms.vmd.model.BaseMapBuildingFloor

/**
 * Java-friendly entry point for binding a Compose overlay layer onto an existing XML layout.
 */
object MapOverlayHost {

    interface Callbacks {
        fun selectFloor(floor: BaseMapBuildingFloor)
        fun toggleWayfinding()
        fun wayfindingGo()
        fun wayfindingClear()
        fun showSteps()
        fun dismissSteps()
        fun back()
        fun reload()
        fun selectBasemap(mode: BasemapMode)
        fun showFloorList()
        fun dismissFloorList()
    }

    @JvmStatic
    fun install(view: ComposeView, state: MapOverlayState, callbacks: Callbacks) {
        view.setContent {
            MaterialTheme {
                MapOverlays(
                    state = state,
                    onSelectFloor = { callbacks.selectFloor(it) },
                    onToggleWayfinding = { callbacks.toggleWayfinding() },
                    onWayfindingGo = { callbacks.wayfindingGo() },
                    onWayfindingClear = { callbacks.wayfindingClear() },
                    onShowSteps = { callbacks.showSteps() },
                    onDismissSteps = { callbacks.dismissSteps() },
                    onBack = { callbacks.back() },
                    onReload = { callbacks.reload() },
                    onSelectBasemap = { callbacks.selectBasemap(it) },
                    onShowFloorList = { callbacks.showFloorList() },
                    onDismissFloorList = { callbacks.dismissFloorList() },
                )
            }
        }
    }
}
