package com.humand.demo.modules.CallService

import com.facebook.react.TurboReactPackage
import com.facebook.react.bridge.NativeModule
import com.facebook.react.bridge.ReactApplicationContext
import com.facebook.react.module.model.ReactModuleInfo
import com.facebook.react.module.model.ReactModuleInfoProvider
import com.facebook.react.uimanager.ViewManager
import com.humand.demo.BuildConfig

class CallServicePackage : TurboReactPackage() {

    override fun getModule(name: String, reactContext: ReactApplicationContext): NativeModule? {
        return when (name) {
            RNCallManager.NAME -> RNCallManager(reactContext)
            else -> null
        }
    }

    override fun createViewManagers(reactContext: ReactApplicationContext): List<ViewManager<*, *>> {
        return listOf(
            CallVideoViewManager(reactContext)
        )
    }

    override fun getReactModuleInfoProvider(): ReactModuleInfoProvider {
        val isTurboModule = BuildConfig.IS_NEW_ARCHITECTURE_ENABLED
        return ReactModuleInfoProvider {
            mapOf(
                RNCallManager.NAME to ReactModuleInfo(
                    RNCallManager.NAME,
                    RNCallManager.NAME,
                    false,
                    false,
                    true,
                    false,
                    isTurboModule
                )
            )
        }
    }
}
