# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
#   http://developer.android.com/guide/developing/tools/proguard.html

# Repackage obfuscated classes to prevent collisions with other SDKs.
# Without this, R8 (especially in full mode) repackages synthetic/anonymous
# classes into `a/`, the default package, or other ultra-short names that
# collide with other minified SDKs in the host app (Pia, Braintree, etc.
# all land on `a.a`). Forcing every obfuscated class into a Kindly-owned
# namespace eliminates the collision by construction.
# Originally added in commit 11e8c109 (Pia SDK collision); accidentally
# removed in a8e49fa9 (Sentry-themed cleanup); restored to fix the same
# bug surfacing again with Braintree (SDK-XXX, Rebtel report 2026-05-20).
-repackageclasses 'no.kindly.chatsdk.obfuscated'

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
#   public *;
#}

# Uncomment this to preserve the line number information for
# debugging stack traces.
-keepattributes SourceFile,LineNumberTable
#coroutines https://github.com/Kotlin/kotlinx.coroutines/blob/master/kotlinx-coroutines-core/jvm/resources/META-INF/proguard/coroutines.pro
# ServiceLoader support
-keepnames class kotlinx.coroutines.internal.MainDispatcherFactory {}
-keepnames class kotlinx.coroutines.CoroutineExceptionHandler {}
# Most of volatile fields are updated with AFU and should not be mangled
-keepclassmembers class kotlinx.coroutines.** {
    volatile <fields>;
}
# Same story for the standard library's SafeContinuation that also uses AtomicReferenceFieldUpdater
-keepclassmembers class kotlin.coroutines.SafeContinuation {
    volatile <fields>;
}
# Only used in `kotlinx.coroutines.internal.ExceptionsConstructor`.
# The case when it is not available is hidden in a `try`-`catch`, as well as a check for Android.
-dontwarn java.lang.ClassValue

# OkHttp https://github.com/square/okhttp/blob/master/okhttp/src/main/resources/META-INF/proguard/okhttp3.pro
# JSR 305 annotations are for embedding nullability information.
-dontwarn javax.annotation.**

# A resource is loaded with a relative path so the package of this class must be preserved.
-keeppackagenames okhttp3.internal.publicsuffix.*
-adaptresourcefilenames okhttp3/internal/publicsuffix/PublicSuffixDatabase.gz

# Animal Sniffer compileOnly dependency to ensure APIs are compatible with older versions of Java.
-dontwarn org.codehaus.mojo.animal_sniffer.*

# OkHttp platform used only on JVM and when Conscrypt and other security providers are available.
-keep class okhttp3.** { *; }
-dontwarn okhttp3.internal.platform.**
-dontwarn org.conscrypt.**
-dontwarn org.bouncycastle.**
-dontwarn org.openjsse.**

# keep all classes
-keep class no.kindly.chatsdk.chat.** { *; }
# Keep applications' and activities' constructors.
-keepclasseswithmembers class no.kindly.chatsdk.chat.** {
    public <init>(android.content.Context);
}

# Keep all classes that extend GenericClass, to preserve generic type information
-keep class * extends no.kindly.chatsdk.chat.* {*;}
# Keep names of classes and members accessed via reflection
-keepclassmembers class no.kindly.chatsdk.chat.** {*;}
# Keep names of classes and class members that are accessed via reflection.

-dontwarn java.beans.ConstructorProperties
-dontwarn java.beans.Transient

-keepattributes Signature
-keepattributes *Annotation*
-keepattributes EnclosingMethod

# Keep enum classes used with kotlinx.serialization.
-keepclassmembers enum * {
    public static **[] values();
    public static ** valueOf(java.lang.String);
}

# AndroidX, Room, and lifecycle components
-keep class androidx.room.** { *; }
-keep class androidx.lifecycle.** { *; }
-keep @androidx.room.* class *
-keepclasseswithmembers class * {
    @androidx.room.* <methods>;
}
#-printconfiguration /Users/khalodark/Desktop/pringConfiguration.txt
#-printusage /Users/khalodark/Desktop/pringUsage.txt

# For Kotlin coroutines
-keep class kotlinx.coroutines.** { *; }

# OkHttp
-keepattributes Signature, InnerClasses, EnclosingMethod
-keepattributes RuntimeVisibleAnnotations, RuntimeVisibleParameterAnnotations
-keepattributes AnnotationDefault

# Ignore annotation used for build tooling.
-dontwarn org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement

# Ignore JSR 305 annotations for embedding nullability information.
-dontwarn javax.annotation.**

# Guarded by a NoClassDefFoundError try/catch and only used when on the classpath.
-dontwarn kotlin.Unit

# With R8 full mode generic signatures are stripped for classes that are not
# kept. Suspend functions are wrapped in continuations where the type argument
# is used.
-keep,allowobfuscation,allowshrinking class kotlin.coroutines.Continuation

# For Compose: rely on the consumer-proguard rules shipped inside each
# androidx.compose.* AAR (they cover the runtime's actual reflection paths —
# state holders, savers, composer slot table, etc). The previous blanket
# `-keep class androidx.compose.** { *; }` plus its matching `-keepclassmembers`
# both override Compose's nuanced internal rules, conflict with R8's Compose
# stack-trace tokenizer (the "Failed to collect Compose stack trace mapping"
# warnings host devs see), and force every consuming app to keep all Compose
# internals.

# Miscellaneous libraries
-keep class com.pusher.client.** { *; }

# Prevent R8 from removing default constructors required by Firebase and others
-keepclassmembers class * {
    public protected <init>();
}

# Prevent runtime crashes from use of class.java.getName()
-dontwarn javax.naming.**

# General Android ProGuard rules
-keep class * extends android.app.Activity
-keep class * extends android.app.Application
-keep class * extends android.app.Service
-keep class * extends android.content.BroadcastReceiver
-keep class * extends android.content.ContentProvider
-keep class * extends android.app.backup.BackupAgentHelper
-keep class * extends android.preference.Preference
-keep class com.android.vending.licensing.ILicensingService
-dontnote com.android.vending.licensing.ILicensingService

# Simple Logging Facade for Java (SLF4J)
-keep class org.slf4j.** { *; }
-dontwarn org.slf4j.**

# Navigation
-keep class androidx.navigation.** { *; }
-dontwarn androidx.navigation.**

# Sentry - accessed via reflection in SentryHelper.kt
# Without these -keep rules, R8 minifies Sentry class/method names (e.g.
# io.sentry.Sentry -> io.sentry.l4) and every reflective lookup by name fails
# at runtime ("Failed to configure scope: io.sentry.l4.configureScope ...").
-keep class io.sentry.** { *; }
-keep interface io.sentry.** { *; }
-dontwarn io.sentry.**
