// android/build.gradle — RN 0.80 friendly (use apply-plugin to avoid plugin DSL issues)

apply plugin: 'com.android.library'
apply plugin: 'org.jetbrains.kotlin.android'

android {
    namespace 'com.rnthermalprinter'

    // Read from root ext if present; otherwise fall back to sane defaults
    def compileSdk = rootProject.ext.has('compileSdkVersion') ? rootProject.ext.compileSdkVersion : 34
    def minSdk     = rootProject.ext.has('minSdkVersion')     ? rootProject.ext.minSdkVersion     : 23
    def targetSdk  = rootProject.ext.has('targetSdkVersion')  ? rootProject.ext.targetSdkVersion  : 34

    compileSdkVersion compileSdk

    defaultConfig {
        minSdkVersion minSdk
        targetSdkVersion targetSdk
        consumerProguardFiles 'consumer-rules.pro'
    }

    // RN 0.80 (AGP 8.x / Gradle 8) → Java 17
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_17
        targetCompatibility JavaVersion.VERSION_17
    }
    kotlinOptions {
        jvmTarget = '17'
    }

    buildFeatures {
        buildConfig = false
    }

    buildTypes {
        release { minifyEnabled false }
        debug { /* default */ }
    }
}

dependencies {
    // React Native Android artifact (version managed by your RN app)
    implementation "com.facebook.react:react-android"

    // Kotlin standard library (REQUIRED)
    implementation "org.jetbrains.kotlin:kotlin-stdlib:1.9.20"

    // AndroidX for ContextCompat and other support libraries
    implementation "androidx.core:core-ktx:1.10.1"

    // Kotlin coroutines for async operations
    implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.7.1"

    // PosPrinterSDK for high-quality image processing (from zywell)
    implementation files('libs/PosPrinterSDK.jar')
}
