# ============================================================
# Consumer ProGuard / R8 rules for Adster AppLovin Custom Adapter
# These rules are AUTOMATICALLY applied to any app that includes this AAR.
# The consuming app does NOT need to add any rules manually.
# ============================================================

# ===========================================
# 1. ADAPTER CLASSES (loaded by AppLovin via reflection)
# ===========================================
# AppLovin instantiates the adapter class by its fully qualified name
# configured in the AppLovin dashboard. R8 cannot trace this reflection,
# so we must explicitly keep the class, its constructors, and all members.
-keep public class com.adster.ads.mediation.applovin.AdSterMediationAdapter { *; }

# Keep ALL classes in the adapter package including inner classes.
# Inner classes are used for ad listeners/callbacks that get invoked
# by the Adster SDK via interface dispatch.
-keep class com.adster.ads.mediation.applovin.** { *; }

# Keep Kotlin top-level extension functions (compiled as UtilKt)
-keep class com.adster.ads.mediation.UtilKt { *; }

# ===========================================
# 2. ADSTER SDK PUBLIC API
# ===========================================
# The adapter calls into these classes. Even though references exist,
# R8 aggressive mode or whole-program optimization can strip members
# that appear unused from the app's perspective.
-keep class com.adster.sdk.mediation.** { *; }

# Keep all classes that were repackaged during SDK build.
# The SDK uses -repackageclasses 'com.adster.internal.obfuscated' so internal
# classes end up here. The consumer's R8 must not strip them.
-keep class com.adster.internal.obfuscated.** { *; }

# Room TypeConverters — R8 full mode may not follow @TypeConverters annotation references
-keep class * { @androidx.room.TypeConverter *; }

# ===========================================
# 3. @KEEP ANNOTATION SUPPORT
# ===========================================
# Honor @Keep annotations from both AndroidX and the support library.
-keep @androidx.annotation.Keep class * { *; }
-keepclassmembers class * {
    @androidx.annotation.Keep *;
}

# ===========================================
# 4. KOTLIN METADATA & LANGUAGE FEATURES
# ===========================================
# Kotlin inner classes, companions, extension functions, and data classes
# depend on metadata attributes being preserved.
-keepattributes *Annotation*, Signature, InnerClasses, EnclosingMethod
-keepattributes RuntimeVisibleAnnotations, RuntimeVisibleParameterAnnotations
-keep class kotlin.Metadata { *; }
-dontwarn kotlin.**
-dontwarn kotlinx.coroutines.**

# ===========================================
# 5. GSON SERIALIZATION (used by Adster SDK for API responses)
# ===========================================
# Gson uses reflection to map JSON fields to data class properties.
# @SerializedName annotated fields MUST be preserved.
-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 Gson itself
-keep class com.google.gson.** { *; }
-dontwarn com.google.gson.**

# ===========================================
# 6. RETROFIT & OKHTTP (used by Adster SDK for networking)
# ===========================================
-keepclasseswithmembers interface * {
    @retrofit2.http.* <methods>;
}
-keep class retrofit2.** { *; }
-dontwarn retrofit2.**
-keep class okhttp3.** { *; }
-dontwarn okhttp3.**
-dontwarn okio.**

# ===========================================
# 7. APPLOVIN SDK
# ===========================================
-keep class com.applovin.** { *; }
-dontwarn com.applovin.**

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