# Encore SDK Consumer ProGuard Rules
# These rules are bundled into the AAR and applied by the consumer's R8 pass.
# Every public API class uses $* to automatically keep companions, inner classes,
# sealed subclasses, and any nested types.

# ---- Namespace isolation ----
# The SDK's own R8 pass (proguard-rules.pro) moves obfuscated internals to
# com.encorekit.internal. This rule prevents a host app's -repackageclasses ''
# config from scattering those classes back into single-letter root packages,
# which would undo the namespace isolation at the app build stage.
# NOTE: -repackageclasses is intentionally NOT here — it belongs only in the
# library's own R8 pass (proguard-rules.pro), not in consumer rules.
-keeppackagenames com.encorekit.internal

# ---- Public API ----

-keep class com.encorekit.encore.Encore { *; }
-keep class com.encorekit.encore.Encore$* { *; }
-keep class com.encorekit.encore.core.canonical.user.UserAttributes { *; }
-keep class com.encorekit.encore.core.canonical.error.EncoreError { *; }
-keep class com.encorekit.encore.core.canonical.error.EncoreError$* { *; }
-keep class com.encorekit.encore.core.infrastructure.logging.LogLevel { *; }
-keep class com.encorekit.encore.core.infrastructure.billing.BillingPurchaseResult { *; }
-keep class com.encorekit.encore.presentation.PlacementBuilder { *; }
-keep class com.encorekit.encore.presentation.PlacementBuilder$* { *; }
-keep class com.encorekit.encore.presentation.PlacementsManager { *; }
-keep class com.encorekit.encore.presentation.PlacementsManager$* { *; }
-keep class com.encorekit.encore.features.offers.PresentationResult { *; }
-keep class com.encorekit.encore.features.offers.PresentationResult$* { *; }
-keep class com.encorekit.encore.features.offers.DismissReason { *; }
-keep class com.encorekit.encore.features.offers.DismissReason$* { *; }
-keep class com.encorekit.encore.core.canonical.iap.PurchaseRequest { *; }
-keep class com.encorekit.encore.IapEntitlement { *; }
-keep class com.encorekit.encore.IapEntitlement$* { *; }

# ---- Generated API models ----

-keep class com.encorekit.encore.generated.** { *; }

# ---- kotlinx.serialization ----

-keepattributes *Annotation*, InnerClasses
-dontnote kotlinx.serialization.AnnotationsKt

-keepclassmembers @kotlinx.serialization.Serializable class com.encorekit.encore.** {
    *** Companion;
    kotlinx.serialization.KSerializer serializer(...);
}

-keep class com.encorekit.encore.**$$serializer { *; }

# ---- ErrorDto (internal, but deserialized from API responses) ----

-keep class com.encorekit.encore.core.canonical.dto.ErrorDto$ErrorResponse { *; }

# ---- JDK 9+ string concatenation (desugared at runtime) ----

-dontwarn java.lang.invoke.StringConcatFactory

# ---- Compose + Offer Sheet ----

-keep class com.encorekit.encore.presentation.offers.OfferSheetActivity { *; }
-keep class com.encorekit.encore.presentation.offers.OfferSheetActivity$* { *; }
