apply plugin: "com.android.application"
apply plugin: "org.jetbrains.kotlin.android"
apply plugin: "com.facebook.react"
apply plugin: "com.google.gms.google-services"

react { autolinkLibrariesWithApp() }
def enableProguardInReleaseBuilds=false
def jscFlavor='io.github.react-native-community:jsc-android:2026004.+'
def releaseStoreFile=findProperty("CLICKDELIVERY_KEYSTORE_FILE") ?: System.getenv("CLICKDELIVERY_KEYSTORE_FILE")
def releaseStorePassword=findProperty("CLICKDELIVERY_KEYSTORE_PASSWORD") ?: System.getenv("CLICKDELIVERY_KEYSTORE_PASSWORD")
def releaseKeyAlias=findProperty("CLICKDELIVERY_KEY_ALIAS") ?: System.getenv("CLICKDELIVERY_KEY_ALIAS")
def releaseKeyPassword=findProperty("CLICKDELIVERY_KEY_PASSWORD") ?: System.getenv("CLICKDELIVERY_KEY_PASSWORD")
def apiBase=findProperty("CLICKDELIVERY_API_BASE_URL") ?: System.getenv("CLICKDELIVERY_API_BASE_URL") ?: "https://api.example.invalid"
android {
  ndkVersion rootProject.ext.ndkVersion; buildToolsVersion rootProject.ext.buildToolsVersion; compileSdk rootProject.ext.compileSdkVersion
  namespace "com.clickdelivery.comercio"
  defaultConfig {
    applicationId "com.clickdelivery.comercio"; minSdkVersion rootProject.ext.minSdkVersion; targetSdkVersion rootProject.ext.targetSdkVersion
    versionCode 9; versionName "1.2.0"
    manifestPlaceholders=[clickdeliveryApiBaseUrl:apiBase]
  }
  signingConfigs {
    debug { storeFile file('debug.keystore'); storePassword 'android'; keyAlias 'androiddebugkey'; keyPassword 'android' }
    release { if(releaseStoreFile){ storeFile file(releaseStoreFile); storePassword releaseStorePassword; keyAlias releaseKeyAlias; keyPassword releaseKeyPassword } }
  }
  buildTypes {
    debug { signingConfig signingConfigs.debug; versionNameSuffix "-dev" }
    release { if(releaseStoreFile) signingConfig signingConfigs.release; minifyEnabled enableProguardInReleaseBuilds; proguardFiles getDefaultProguardFile("proguard-android.txt"),"proguard-rules.pro" }
  }
}
dependencies {
  implementation("com.facebook.react:react-android")
  implementation('com.facebook.fresco:animated-gif:3.6.0')
  implementation(platform("com.google.firebase:firebase-bom:34.11.0"))
  implementation("com.google.firebase:firebase-messaging")
  if(hermesEnabled.toBoolean()) implementation("com.facebook.react:hermes-android") else implementation jscFlavor
}
