buildscript {
  ext.getExtOrDefault = {name ->
    return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties['VideoEditorSdk_' + name]
  }

  repositories {
    google()
    mavenCentral()
  }

  dependencies {
    classpath "com.android.tools.build:gradle:8.7.2"
    // noinspection DifferentKotlinGradleVersion
    classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${getExtOrDefault('kotlinVersion')}"
  }
}


apply plugin: "com.android.library"
apply plugin: "kotlin-android"

apply plugin: "com.facebook.react"

def getExtOrIntegerDefault(name) {
  return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties["VideoEditorSdk_" + name]).toInteger()
}

android {
  namespace "com.videoeditorsdk"

  compileSdkVersion getExtOrIntegerDefault("compileSdkVersion")

  defaultConfig {
    minSdkVersion getExtOrIntegerDefault("minSdkVersion")
    targetSdkVersion getExtOrIntegerDefault("targetSdkVersion")
  }

  buildFeatures {
    buildConfig true
  }

  buildTypes {
    release {
      minifyEnabled false
    }
  }

  lintOptions {
    disable "GradleCompatible"
  }

  compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
  }

  sourceSets {
    main {
      java.srcDirs += [
        "generated/java",
        "generated/jni"
      ]
    }
  }
}

repositories {
  mavenCentral()
  google()
}

def kotlin_version = getExtOrDefault("kotlinVersion")

dependencies {
  // React Native bridge
  implementation "com.facebook.react:react-android"

  // Kotlin
  implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"


    def media3Version = getExtOrDefault("media3Version") ?: "1.8.0"
    def appCompatVersion = getExtOrDefault("appCompatVersion") ?: "1.7.1"
    def coroutinesVersion = getExtOrDefault("coroutinesVersion") ?: "1.7.3"

  // ===============================
  // Media3 (REQUIRED for your SDK)
  // ===============================
  implementation "androidx.media3:media3-common:$media3Version"
  implementation "androidx.media3:media3-common-ktx:$media3Version"
  implementation "androidx.media3:media3-exoplayer:$media3Version"
  implementation "androidx.media3:media3-ui:$media3Version"
  implementation "androidx.media3:media3-transformer:$media3Version"
  implementation "androidx.media3:media3-effect:$media3Version"

  // ===============================
  // AndroidX helpers (USED in code)
  // ===============================
  implementation "androidx.appcompat:appcompat:$appCompatVersion"

  // ===============================
  // Coroutines (YOU USE THESE)
  // ===============================
  implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutinesVersion"
  implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutinesVersion"
}
