plugins {
    id("com.android.application")
    id("org.jetbrains.kotlin.plugin.compose")
}

android {
    namespace = "com.jidan.jiaoyi"
    compileSdk = 37

    defaultConfig {
        applicationId = "cn.jiaoyi123.app"
        minSdk = 23
        targetSdk = 37
        versionCode = 3
        versionName = "1.0.2"
    }

    val releaseStore = System.getenv("JIAOYI_AI_KEYSTORE")
    val releaseStorePassword = System.getenv("JIAOYI_AI_STORE_PASSWORD")
    val releaseKeyAlias = System.getenv("JIAOYI_AI_KEY_ALIAS")
    val releaseKeyPassword = System.getenv("JIAOYI_AI_KEY_PASSWORD")

    signingConfigs {
        if (
            !releaseStore.isNullOrBlank() &&
            !releaseStorePassword.isNullOrBlank() &&
            !releaseKeyAlias.isNullOrBlank() &&
            !releaseKeyPassword.isNullOrBlank()
        ) {
            create("privateRelease") {
                storeFile = file(releaseStore)
                storePassword = releaseStorePassword
                keyAlias = releaseKeyAlias
                keyPassword = releaseKeyPassword
            }
        }
    }

    buildTypes {
        release {
            isMinifyEnabled = false
            signingConfig = signingConfigs.findByName("privateRelease")
        }
    }

    compileOptions {
        sourceCompatibility = JavaVersion.VERSION_17
        targetCompatibility = JavaVersion.VERSION_17
    }

    buildFeatures {
        compose = true
        buildConfig = true
    }
}

dependencies {
    val composeBom = platform("androidx.compose:compose-bom:2026.06.00")
    implementation(composeBom)
    androidTestImplementation(composeBom)

    implementation("androidx.activity:activity-compose:1.13.0")
    implementation("androidx.lifecycle:lifecycle-runtime-compose:2.9.4")
    implementation("androidx.compose.foundation:foundation")
    implementation("androidx.compose.material3:material3")
    implementation("androidx.compose.ui:ui-tooling-preview")
    implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.10.2")
    debugImplementation("androidx.compose.ui:ui-tooling")
}
