import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.ui.window.ComposeUIViewController
import com.nate.posedetection.App
import com.nate.posedetection.ExperimentLaunchSpec
import com.nate.posedetection.LocalExperimentAutoSpec
import platform.UIKit.UIViewController

fun MainViewController(): UIViewController = ComposeUIViewController { App() }

fun MainViewControllerWithAutoSpec(
    modelName: String?,
    startAtWallMs: Long,
    durationMs: Long,
    finishOnStop: Boolean,
): UIViewController {
    val spec = if (!modelName.isNullOrBlank() && durationMs > 0L) {
        ExperimentLaunchSpec(
            modelName = modelName,
            startAtWallMs = startAtWallMs,
            durationMs = durationMs,
            finishOnStop = finishOnStop,
        )
    } else null
    return ComposeUIViewController {
        CompositionLocalProvider(LocalExperimentAutoSpec provides spec) {
            App()
        }
    }
}
