277 lines
12 KiB
Java
277 lines
12 KiB
Java
package com.discord.models.domain.premium;
|
|
|
|
import androidx.room.RoomDatabase;
|
|
import b.d.b.a.a;
|
|
import com.discord.api.premium.PremiumTier;
|
|
import com.discord.api.premium.SubscriptionInterval;
|
|
import com.discord.models.domain.ModelSubscription;
|
|
import d0.t.n0;
|
|
import d0.t.o;
|
|
import d0.t.o0;
|
|
import d0.t.u;
|
|
import d0.z.d.m;
|
|
import java.util.ArrayList;
|
|
import java.util.Iterator;
|
|
import java.util.List;
|
|
import java.util.Set;
|
|
import kotlin.jvm.internal.DefaultConstructorMarker;
|
|
/* JADX WARN: Init of enum NONE_3_MONTH can be incorrect */
|
|
/* JADX WARN: Init of enum NONE_6_MONTH can be incorrect */
|
|
/* JADX WARN: Init of enum NONE_MONTH can be incorrect */
|
|
/* JADX WARN: Init of enum NONE_YEAR can be incorrect */
|
|
/* JADX WARN: Init of enum PREMIUM_3_MONTH_TIER_2 can be incorrect */
|
|
/* JADX WARN: Init of enum PREMIUM_6_MONTH_TIER_2 can be incorrect */
|
|
/* JADX WARN: Init of enum PREMIUM_GUILD_3_MONTH can be incorrect */
|
|
/* JADX WARN: Init of enum PREMIUM_GUILD_6_MONTH can be incorrect */
|
|
/* JADX WARN: Init of enum PREMIUM_GUILD_MONTH can be incorrect */
|
|
/* JADX WARN: Init of enum PREMIUM_GUILD_YEAR can be incorrect */
|
|
/* JADX WARN: Init of enum PREMIUM_MONTH_LEGACY can be incorrect */
|
|
/* JADX WARN: Init of enum PREMIUM_MONTH_TIER_1 can be incorrect */
|
|
/* JADX WARN: Init of enum PREMIUM_MONTH_TIER_2 can be incorrect */
|
|
/* JADX WARN: Init of enum PREMIUM_YEAR_LEGACY can be incorrect */
|
|
/* JADX WARN: Init of enum PREMIUM_YEAR_TIER_1 can be incorrect */
|
|
/* JADX WARN: Init of enum PREMIUM_YEAR_TIER_2 can be incorrect */
|
|
/* compiled from: SubscriptionPlanType.kt */
|
|
/* loaded from: classes.dex */
|
|
public enum SubscriptionPlanType {
|
|
NONE_MONTH(0, r12, 1, "none_month", 628379151761408000L, r13),
|
|
NONE_3_MONTH(0, r12, 3, "none_3_month", 944265614527037440L, r13),
|
|
NONE_6_MONTH(0, r12, 6, "none_6_month", 944265636643602432L, r13),
|
|
NONE_YEAR(0, r26, 1, "none_year", 628381571568631808L, r13),
|
|
PREMIUM_MONTH_LEGACY(499, r12, 1, "premium_month", 511651856145973248L, r27),
|
|
PREMIUM_YEAR_LEGACY(4999, r26, 1, "premium_year", 511651860671627264L, r27),
|
|
PREMIUM_MONTH_TIER_1(499, r12, 1, "premium_month_tier_1", 511651871736201216L, r25),
|
|
PREMIUM_YEAR_TIER_1(4999, r26, 1, "premium_year_tier_1", 511651876987469824L, r25),
|
|
PREMIUM_MONTH_TIER_2(RoomDatabase.MAX_BIND_PARAMETER_CNT, r12, 1, "premium_month_tier_2", 511651880837840896L, r27),
|
|
PREMIUM_3_MONTH_TIER_2(2849, r12, 3, "premium_3_month_tier_2", 642251038925127690L, r27),
|
|
PREMIUM_6_MONTH_TIER_2(5499, r12, 6, "premium_6_month_tier_2", 944037208325619722L, r27),
|
|
PREMIUM_YEAR_TIER_2(9999, r26, 1, "premium_year_tier_2", 511651885459963904L, r27),
|
|
PREMIUM_GUILD_MONTH(499, r12, 1, null, 590665532894740483L, null),
|
|
PREMIUM_GUILD_3_MONTH(1427, r12, 3, null, 944037355453415424L, null),
|
|
PREMIUM_GUILD_6_MONTH(2750, r12, 6, null, 944037391444738048L, null),
|
|
PREMIUM_GUILD_YEAR(4999, r26, 1, null, 590665538238152709L, null);
|
|
|
|
public static final Companion Companion = new Companion(null);
|
|
private static final Set<SubscriptionPlanType> LEGACY_PLANS;
|
|
private static final Set<SubscriptionPlanType> PREMIUM_GUILD_PLANS;
|
|
private static final Set<SubscriptionPlanType> PREMIUM_PLANS;
|
|
private static final Set<SubscriptionPlanType> TIER_1_PLANS;
|
|
private static final Set<SubscriptionPlanType> TIER_2_PLANS;
|
|
private final SubscriptionInterval interval;
|
|
private final int intervalCount;
|
|
private final long planId;
|
|
private final String planTypeString;
|
|
private final PremiumTier premiumTier;
|
|
private final int price;
|
|
|
|
/* compiled from: SubscriptionPlanType.kt */
|
|
/* loaded from: classes.dex */
|
|
public static final class Companion {
|
|
|
|
/* loaded from: classes.dex */
|
|
public final /* synthetic */ class WhenMappings {
|
|
public static final /* synthetic */ int[] $EnumSwitchMapping$0;
|
|
|
|
static {
|
|
SubscriptionInterval.values();
|
|
int[] iArr = new int[2];
|
|
$EnumSwitchMapping$0 = iArr;
|
|
iArr[SubscriptionInterval.MONTHLY.ordinal()] = 1;
|
|
iArr[SubscriptionInterval.YEARLY.ordinal()] = 2;
|
|
}
|
|
}
|
|
|
|
private Companion() {
|
|
}
|
|
|
|
public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) {
|
|
this();
|
|
}
|
|
|
|
private final SubscriptionPlanType getNonePlanForIntervalType(SubscriptionInterval subscriptionInterval, int i) {
|
|
int ordinal = subscriptionInterval.ordinal();
|
|
if (ordinal == 0) {
|
|
return i != 3 ? i != 6 ? SubscriptionPlanType.NONE_MONTH : SubscriptionPlanType.NONE_6_MONTH : SubscriptionPlanType.NONE_3_MONTH;
|
|
}
|
|
if (ordinal == 1) {
|
|
return SubscriptionPlanType.NONE_YEAR;
|
|
}
|
|
throw new IllegalArgumentException("unsupported plan interval: " + subscriptionInterval);
|
|
}
|
|
|
|
public final SubscriptionPlanType from(long j) {
|
|
SubscriptionPlanType subscriptionPlanType;
|
|
SubscriptionPlanType[] values = SubscriptionPlanType.values();
|
|
int i = 0;
|
|
while (true) {
|
|
if (i >= 16) {
|
|
subscriptionPlanType = null;
|
|
break;
|
|
}
|
|
subscriptionPlanType = values[i];
|
|
if (subscriptionPlanType.getPlanId() == j) {
|
|
break;
|
|
}
|
|
i++;
|
|
}
|
|
if (subscriptionPlanType != null) {
|
|
return subscriptionPlanType;
|
|
}
|
|
throw new IllegalArgumentException(a.s("unsupported type plan id: ", j));
|
|
}
|
|
|
|
public final SubscriptionPlanType from(String str) {
|
|
SubscriptionPlanType subscriptionPlanType;
|
|
m.checkNotNullParameter(str, "planTypeString");
|
|
SubscriptionPlanType[] values = SubscriptionPlanType.values();
|
|
int i = 0;
|
|
while (true) {
|
|
if (i >= 16) {
|
|
subscriptionPlanType = null;
|
|
break;
|
|
}
|
|
subscriptionPlanType = values[i];
|
|
if (m.areEqual(subscriptionPlanType.getPlanTypeString(), str)) {
|
|
break;
|
|
}
|
|
i++;
|
|
}
|
|
if (subscriptionPlanType != null) {
|
|
return subscriptionPlanType;
|
|
}
|
|
throw new IllegalArgumentException(a.v("unsupported planTypeString: ", str));
|
|
}
|
|
|
|
public final SubscriptionPlanType getBasePlanFromSubscriptionItems(List<ModelSubscription.SubscriptionItem> list, SubscriptionInterval subscriptionInterval, int i) {
|
|
Object obj;
|
|
boolean z2;
|
|
SubscriptionInterval interval;
|
|
m.checkNotNullParameter(list, "items");
|
|
m.checkNotNullParameter(subscriptionInterval, "interval");
|
|
ArrayList arrayList = new ArrayList(o.collectionSizeOrDefault(list, 10));
|
|
for (ModelSubscription.SubscriptionItem subscriptionItem : list) {
|
|
arrayList.add(SubscriptionPlanType.Companion.from(subscriptionItem.getPlanId()));
|
|
}
|
|
SubscriptionPlanType subscriptionPlanType = (SubscriptionPlanType) u.firstOrNull((List<? extends Object>) arrayList);
|
|
if (!(subscriptionPlanType == null || (interval = subscriptionPlanType.getInterval()) == null)) {
|
|
subscriptionInterval = interval;
|
|
}
|
|
Iterator it = arrayList.iterator();
|
|
while (true) {
|
|
if (!it.hasNext()) {
|
|
obj = null;
|
|
break;
|
|
}
|
|
obj = it.next();
|
|
if (((SubscriptionPlanType) obj).getPremiumTier() != null) {
|
|
z2 = true;
|
|
continue;
|
|
} else {
|
|
z2 = false;
|
|
continue;
|
|
}
|
|
if (z2) {
|
|
break;
|
|
}
|
|
}
|
|
SubscriptionPlanType subscriptionPlanType2 = (SubscriptionPlanType) obj;
|
|
return subscriptionPlanType2 != null ? subscriptionPlanType2 : getNonePlanForIntervalType(subscriptionInterval, i);
|
|
}
|
|
|
|
public final Set<SubscriptionPlanType> getLEGACY_PLANS() {
|
|
return SubscriptionPlanType.access$getLEGACY_PLANS$cp();
|
|
}
|
|
|
|
public final Set<SubscriptionPlanType> getPREMIUM_GUILD_PLANS() {
|
|
return SubscriptionPlanType.access$getPREMIUM_GUILD_PLANS$cp();
|
|
}
|
|
|
|
public final Set<SubscriptionPlanType> getPREMIUM_PLANS() {
|
|
return SubscriptionPlanType.access$getPREMIUM_PLANS$cp();
|
|
}
|
|
}
|
|
|
|
static {
|
|
SubscriptionInterval subscriptionInterval = SubscriptionInterval.MONTHLY;
|
|
PremiumTier premiumTier = PremiumTier.PREMIUM_GUILD_SUBSCRIPTION_ONLY;
|
|
SubscriptionInterval subscriptionInterval2 = SubscriptionInterval.YEARLY;
|
|
PremiumTier premiumTier2 = PremiumTier.TIER_2;
|
|
SubscriptionPlanType subscriptionPlanType = PREMIUM_MONTH_LEGACY;
|
|
SubscriptionPlanType subscriptionPlanType2 = PREMIUM_YEAR_LEGACY;
|
|
PremiumTier premiumTier3 = PremiumTier.TIER_1;
|
|
SubscriptionPlanType subscriptionPlanType3 = PREMIUM_MONTH_TIER_1;
|
|
SubscriptionPlanType subscriptionPlanType4 = PREMIUM_YEAR_TIER_1;
|
|
SubscriptionPlanType subscriptionPlanType5 = PREMIUM_MONTH_TIER_2;
|
|
SubscriptionPlanType subscriptionPlanType6 = PREMIUM_3_MONTH_TIER_2;
|
|
SubscriptionPlanType subscriptionPlanType7 = PREMIUM_6_MONTH_TIER_2;
|
|
SubscriptionPlanType subscriptionPlanType8 = PREMIUM_YEAR_TIER_2;
|
|
SubscriptionPlanType subscriptionPlanType9 = PREMIUM_GUILD_MONTH;
|
|
SubscriptionPlanType subscriptionPlanType10 = PREMIUM_GUILD_YEAR;
|
|
Set<SubscriptionPlanType> of = n0.setOf((Object[]) new SubscriptionPlanType[]{subscriptionPlanType4, subscriptionPlanType3});
|
|
TIER_1_PLANS = of;
|
|
Set<SubscriptionPlanType> of2 = n0.setOf((Object[]) new SubscriptionPlanType[]{subscriptionPlanType2, subscriptionPlanType});
|
|
LEGACY_PLANS = of2;
|
|
Set<SubscriptionPlanType> plus = o0.plus(n0.setOf((Object[]) new SubscriptionPlanType[]{subscriptionPlanType5, subscriptionPlanType6, subscriptionPlanType7, subscriptionPlanType8}), (Iterable) of2);
|
|
TIER_2_PLANS = plus;
|
|
PREMIUM_PLANS = o0.plus((Set) of, (Iterable) plus);
|
|
PREMIUM_GUILD_PLANS = n0.setOf((Object[]) new SubscriptionPlanType[]{subscriptionPlanType9, subscriptionPlanType6, subscriptionPlanType7, subscriptionPlanType10});
|
|
}
|
|
|
|
SubscriptionPlanType(int i, SubscriptionInterval subscriptionInterval, int i2, String str, long j, PremiumTier premiumTier) {
|
|
this.price = i;
|
|
this.interval = subscriptionInterval;
|
|
this.intervalCount = i2;
|
|
this.planTypeString = str;
|
|
this.planId = j;
|
|
this.premiumTier = premiumTier;
|
|
}
|
|
|
|
public static final /* synthetic */ Set access$getLEGACY_PLANS$cp() {
|
|
return LEGACY_PLANS;
|
|
}
|
|
|
|
public static final /* synthetic */ Set access$getPREMIUM_GUILD_PLANS$cp() {
|
|
return PREMIUM_GUILD_PLANS;
|
|
}
|
|
|
|
public static final /* synthetic */ Set access$getPREMIUM_PLANS$cp() {
|
|
return PREMIUM_PLANS;
|
|
}
|
|
|
|
public final SubscriptionInterval getInterval() {
|
|
return this.interval;
|
|
}
|
|
|
|
public final int getIntervalCount() {
|
|
return this.intervalCount;
|
|
}
|
|
|
|
public final long getPlanId() {
|
|
return this.planId;
|
|
}
|
|
|
|
public final String getPlanTypeString() {
|
|
return this.planTypeString;
|
|
}
|
|
|
|
public final PremiumTier getPremiumTier() {
|
|
return this.premiumTier;
|
|
}
|
|
|
|
public final int getPrice() {
|
|
return this.price;
|
|
}
|
|
|
|
public final boolean isGrandfathered() {
|
|
return LEGACY_PLANS.contains(this);
|
|
}
|
|
|
|
public final boolean isMonthlyInterval() {
|
|
return this.interval == SubscriptionInterval.MONTHLY;
|
|
}
|
|
|
|
public final boolean isPremiumSubscription() {
|
|
return PREMIUM_PLANS.contains(this);
|
|
}
|
|
}
|