# ============================================================
# Consumer ProGuard / R8 rules for Adster SDK (orchestrationsdk)
# These rules are AUTOMATICALLY applied to any app that includes this AAR.
# ============================================================

# ===========================================
# 1. ADSTER SDK PUBLIC API
# ===========================================
# Keep all public-facing Adster SDK classes.
# Even though the SDK is pre-minified (minifyEnabled=true in its own build),
# the consumer's R8 pass can still strip classes it considers unreachable.
-keep class com.adster.sdk.mediation.** { *; }

# CRITICAL: The SDK build uses -repackageclasses 'com.adster.internal.obfuscated'
# which moves internal classes to this package. The consumer's R8 (especially in
# full mode / AGP 8+) may strip these classes since it can't trace all references
# through reflection, GSON, Room annotations, and coroutine continuations.
-keep class com.adster.internal.obfuscated.** { *; }

# ===========================================
# 2. @KEEP ANNOTATION SUPPORT
# ===========================================
-keep @androidx.annotation.Keep class * { *; }
-keepclassmembers class * {
    @androidx.annotation.Keep *;
}

# ===========================================
# 3. GSON SERIALIZATION
# ===========================================
# Adster SDK uses Gson with @SerializedName for API response parsing.
# R8 can rename/strip these fields, breaking JSON deserialization silently.
-keepclassmembers,allowobfuscation class * {
    @com.google.gson.annotations.SerializedName <fields>;
}
-keep class * implements com.google.gson.TypeAdapterFactory
-keep class * implements com.google.gson.JsonSerializer
-keep class * implements com.google.gson.JsonDeserializer
-keep class com.google.gson.** { *; }
-dontwarn com.google.gson.**

# ===========================================
# 4. RETROFIT & OKHTTP
# ===========================================
-keepclasseswithmembers interface * {
    @retrofit2.http.* <methods>;
}
-keep class retrofit2.** { *; }
-keep class com.squareup.okhttp.** { *; }
-keep class okhttp3.** { *; }
-dontwarn com.squareup.okhttp.**
-dontwarn retrofit2.**
-dontwarn okhttp3.**
-dontwarn okio.**

# ===========================================
# 5. ROOM DATABASE SUPPORT
# ===========================================
# Keep TypeConverters — Room references them via annotation and R8 full mode
# may not trace the @TypeConverters annotation reference chain
-keep class * { @androidx.room.TypeConverter *; }
-keep class com.adster.sdk.mediation.remote_config.db.** { *; }

# ===========================================
# 6. GENERAL RULES
# ===========================================
-keepattributes *Annotation*, Signature, InnerClasses, EnclosingMethod
-keepattributes RuntimeVisibleAnnotations, RuntimeVisibleParameterAnnotations
-keepattributes SourceFile, LineNumberTable

# Keep classes that use JNI
-keepclasseswithmembers class * {
    native <methods>;
}

# Keep enumerations
-keepclassmembers enum * {
    public static **[] values();
    public static ** valueOf(java.lang.String);
}

# Kotlin metadata
-keep class kotlin.Metadata { *; }
-dontwarn kotlin.**
-dontwarn kotlinx.coroutines.**

# ===========================================
# 6. GOOGLE ADMOB & GAM
# ===========================================
-keep class com.google.android.gms.ads.** { *; }
-keep class com.google.ads.** { *; }
-dontwarn com.google.android.gms.ads.**

-keep class com.google.android.gms.ads.AdListener {
    public *;
}

# ===========================================
# 7. FACEBOOK AUDIENCE NETWORK
# ===========================================
-keep class com.facebook.ads.** { *; }
-dontwarn com.facebook.ads.**

# ===========================================
# 8. GLIDE
# ===========================================
-keep public class * implements com.bumptech.glide.module.GlideModule
-keep public enum com.bumptech.glide.load.ImageHeaderParser$** {
  **[] $VALUES;
  public *;
}

# ===========================================
# 11. AMAZON ADS
# ===========================================
-keep class com.amazon.** { *; }
-dontwarn com.amazon.**

# ===========================================
# 12. IAB TCF
# ===========================================
-keep class com.iabtcf.** { *; }
-keep class com.iab.** { *; }
-dontwarn com.iab.**

# ===========================================
# 14. INMOBI
# ===========================================
-keep class com.inmobi.** { *; }
-dontwarn com.inmobi.**

# ===========================================
# 16. MISC SUPPRESSIONS
# ===========================================
-dontwarn java.lang.invoke.StringConcatFactory
