buildscript {
    repositories {
        google()
        mavenCentral()
        maven { url "https://developer.huawei.com/repo/"}
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:8.4.2'
        classpath 'com.facebook.react:react-native-gradle-plugin'
    }
}

apply plugin: 'com.android.library'
apply plugin: 'com.facebook.react'

// Codegen runs on this package's own specs: RNInsiderAppFrameViewManager implements the generated
// interface, so it must exist when the library compiles. libraryName must match codegenConfig.name.
react {
    jsRootDir = file("../src/specs")
    libraryName = "RNInsiderSpec"
    codegenJavaPackageName = "com.useinsider.react"
}

def getVersionFromPartner(config, fallback) {
    rootProject.ext.has(config) ? rootProject.ext.get(config) : fallback
}

android {
    compileSdkVersion getVersionFromPartner('compileSdkVersion', 36)

    defaultConfig {
        minSdkVersion getVersionFromPartner('minSdkVersion', 24)
        multiDexEnabled true
    }

    def gradleVersion = gradle.gradleVersion.tokenize('.')
    def major = gradleVersion[0].toInteger()

    if (major >= 8) {
        namespace "com.useinsider.react"
    }

    testOptions {
        unitTests.includeAndroidResources = true
        unitTests.returnDefaultValues = true
    }
}

repositories {
    google()
    mavenCentral()
    maven { url "https://developer.huawei.com/repo/"}
    maven { url "https://mobilesdk.useinsider.com/android" }
}


dependencies {
    implementation "com.facebook.react:react-native:${getVersionFromPartner('reactNativeVersion', '+')}"
    implementation 'com.useinsider:insider:17.3.2'

    implementation 'androidx.security:security-crypto:1.1.0-alpha06'
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'
    implementation 'androidx.lifecycle:lifecycle-process:2.8.3'
    implementation "androidx.work:work-runtime:2.9.1"

    // App Frames needs webkit at runtime (compileOnly in the native SDK); without it template actions
    // never arrive. Held below 1.16.0, whose kotlin-stdlib 2.1 breaks older-Kotlin hosts (RN 0.76).
    implementation 'androidx.webkit:webkit:1.15.0'

    implementation 'com.google.firebase:firebase-messaging:24.0.0'
    implementation 'com.google.android.gms:play-services-location:21.3.0'
    implementation 'com.google.android.play:review:2.0.1'

    implementation 'com.huawei.hms:push:6.13.0.300'
    implementation 'com.huawei.hms:ads-identifier:3.4.62.300'
    implementation 'com.huawei.hms:location:6.16.0.302'

    testImplementation 'junit:junit:4.13.2'
    testImplementation 'org.mockito:mockito-core:5.12.0'
    testImplementation 'org.mockito:mockito-inline:5.2.0'
}
