# 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

# 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.

-keepclassmembers class * {
    @com.google.gson.annotations.SerializedName <fields>;
}

-dontwarn java.beans.ConstructorProperties
-dontwarn java.beans.Transient
# Gson specific rules
-keep class sun.misc.Unsafe { *; }
-keep class com.google.gson.stream.** { *; }

-keepattributes Signature
-keepattributes *Annotation*
-keepattributes EnclosingMethod

# For Gson classes
-keep class * implements com.google.gson.** { *; }

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


# This is also needed for R8 in compat mode since multiple
# optimizations will remove the generic signature such as class
# merging and argument removal. See:
# https://r8.googlesource.com/r8/+/refs/heads/main/compatibility-faq.md#troubleshooting-gson-gson
-keep class com.google.gson.reflect.TypeToken { *; }
-keep class * extends com.google.gson.reflect.TypeToken

# AndroidX, Room, and lifecycle components
-keep class androidx.room.** { *; }
-keep class androidx.lifecycle.** { *; }
-keep @androidx.room.* class *
-keepclasseswithmembers class * {
    @androidx.room.* <methods>;
}
-if interface * { @retrofit2.http.* public *** *(...); }
-keep,allowoptimization,allowshrinking,allowobfuscation class <3>

#-printconfiguration /Users/khalodark/Desktop/pringConfiguration.txt
#-printusage /Users/khalodark/Desktop/pringUsage.txt

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

# Retrofit and OkHttp
# Retrofit does reflection on generic parameters. InnerClasses is required to use Signature and
# EnclosingMethod is required to use InnerClasses.
-keepattributes Signature, InnerClasses, EnclosingMethod

# Retrofit does reflection on method and parameter annotations.
-keepattributes RuntimeVisibleAnnotations, RuntimeVisibleParameterAnnotations

# Keep annotation default values (e.g., retrofit2.http.Field.encoded).
-keepattributes AnnotationDefault

# Retain service method parameters when optimizing.
-keepclassmembers,allowshrinking,allowobfuscation interface * {
    @retrofit2.http.* <methods>;
}

# 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

# Top-level functions that can only be used by Kotlin.
-dontwarn retrofit2.KotlinExtensions
-dontwarn retrofit2.KotlinExtensions$*

# With R8 full mode, it sees no subtypes of Retrofit interfaces since they are created with a Proxy
# and replaces all potential values with null. Explicitly keeping the interfaces prevents this.
-if interface * { @retrofit2.http.* <methods>; }
-keep,allowobfuscation interface <1>
# Keep inherited services.
# R8 full mode strips generic signatures from return types if not kept.
-if interface * { @retrofit2.http.* public *** *(...); }
-keep,allowoptimization,allowshrinking,allowobfuscation class <3>
-keep,allowobfuscation interface * extends <1>
# 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

# With R8 full mode generic signatures are stripped for classes that are not kept.
-keep,allowobfuscation,allowshrinking class retrofit2.Response
# For Compose and related libraries
-keep class androidx.compose.** { *; }
-keepclassmembers class androidx.compose.** { *; }

# Miscellaneous libraries
-keep class com.auth0.** { *; }
-keep class com.squareup.retrofit2.** { *; }
-keep class com.google.code.gson.** { *; }
-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.**

# Koin
-keep class org.koin.** { *; }
-dontwarn org.koin.**

# JWT
-keep class com.auth0.android.jwt.** { *; }
-dontwarn com.auth0.android.jwt.**

# Sentry - Optional dependency (compileOnly)
# These classes are accessed via reflection in SentryHelper.kt
# Don't warn about missing Sentry classes when not included by the customer
-dontwarn io.sentry.**
-dontwarn io.sentry.android.**
-dontwarn io.sentry.android.core.**
-dontwarn io.sentry.protocol.**
-dontwarn io.sentry.SentryOptions$BeforeBreadcrumbCallback
-dontwarn io.sentry.SentryOptions$BeforeSendCallback
-dontwarn io.sentry.ScopeCallback
-dontwarn io.sentry.ILogger
-dontwarn io.sentry.Sentry
-dontwarn io.sentry.android.core.SentryAndroid
