discord-jadx/app/src/main/java/com/discord/widgets/guildscheduledevent/WidgetGuildScheduledEventLo...

482 lines
23 KiB
Java

package com.discord.widgets.guildscheduledevent;
import android.content.Context;
import androidx.annotation.MainThread;
import c.d.b.a.a;
import com.airbnb.lottie.parser.AnimatableValueParser;
import com.discord.api.channel.Channel;
import com.discord.api.guildscheduledevent.GuildScheduledEventEntityType;
import com.discord.app.AppViewModel;
import com.discord.stores.StoreChannels;
import com.discord.stores.StorePermissions;
import com.discord.stores.StoreStream;
import com.discord.stores.updates.ObservationDeck;
import com.discord.stores.updates.ObservationDeckProvider;
import com.discord.utilities.guildscheduledevent.GuildScheduledEventUtilities;
import com.discord.utilities.rx.ObservableExtensionsKt;
import d0.z.d.m;
import d0.z.d.o;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Set;
import kotlin.Unit;
import kotlin.jvm.functions.Function0;
import kotlin.jvm.functions.Function1;
import kotlin.jvm.internal.DefaultConstructorMarker;
import rx.Observable;
/* compiled from: WidgetGuildScheduledEventLocationSelectViewModal.kt */
public final class WidgetGuildScheduledEventLocationSelectViewModal extends AppViewModel<ViewState> {
public static final Companion Companion = new Companion(null);
private final StoreChannels channelsStore;
private StoreState currentStoreState;
private final Long initialChannelId;
/* compiled from: WidgetGuildScheduledEventLocationSelectViewModal.kt */
/* renamed from: com.discord.widgets.guildscheduledevent.WidgetGuildScheduledEventLocationSelectViewModal$1 reason: invalid class name */
public static final class AnonymousClass1 extends o implements Function1<StoreState, Unit> {
public final /* synthetic */ WidgetGuildScheduledEventLocationSelectViewModal this$0;
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
public AnonymousClass1(WidgetGuildScheduledEventLocationSelectViewModal widgetGuildScheduledEventLocationSelectViewModal) {
super(1);
this.this$0 = widgetGuildScheduledEventLocationSelectViewModal;
}
/* Return type fixed from 'java.lang.Object' to match base method */
/* JADX DEBUG: Method arguments types fixed to match base method, original types: [java.lang.Object] */
@Override // kotlin.jvm.functions.Function1
public /* bridge */ /* synthetic */ Unit invoke(StoreState storeState) {
invoke(storeState);
return Unit.a;
}
public final void invoke(StoreState storeState) {
WidgetGuildScheduledEventLocationSelectViewModal widgetGuildScheduledEventLocationSelectViewModal = this.this$0;
m.checkNotNullExpressionValue(storeState, "it");
WidgetGuildScheduledEventLocationSelectViewModal.access$handleStoreState(widgetGuildScheduledEventLocationSelectViewModal, storeState);
}
}
/* compiled from: WidgetGuildScheduledEventLocationSelectViewModal.kt */
public static final class Companion {
private Companion() {
}
public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) {
this();
}
public static final /* synthetic */ Observable access$observeStores(Companion companion, long j, StoreChannels storeChannels, StorePermissions storePermissions) {
return companion.observeStores(j, storeChannels, storePermissions);
}
private final Observable<StoreState> observeStores(long j, StoreChannels storeChannels, StorePermissions storePermissions) {
return ObservationDeck.connectRx$default(ObservationDeckProvider.get(), new ObservationDeck.UpdateSource[]{storeChannels, storePermissions}, false, null, null, new WidgetGuildScheduledEventLocationSelectViewModal$Companion$observeStores$1(storeChannels, j, storePermissions), 14, null);
}
}
/* compiled from: WidgetGuildScheduledEventLocationSelectViewModal.kt */
public static final class StoreState {
private final Map<Long, Long> channelPermissions;
private final Map<Long, Channel> channels;
private final Long guildPermissions;
public StoreState(Map<Long, Channel> map, Map<Long, Long> map2, Long l) {
m.checkNotNullParameter(map, "channels");
m.checkNotNullParameter(map2, "channelPermissions");
this.channels = map;
this.channelPermissions = map2;
this.guildPermissions = l;
}
/* JADX DEBUG: Multi-variable search result rejected for r0v0, resolved type: com.discord.widgets.guildscheduledevent.WidgetGuildScheduledEventLocationSelectViewModal$StoreState */
/* JADX WARN: Multi-variable type inference failed */
public static /* synthetic */ StoreState copy$default(StoreState storeState, Map map, Map map2, Long l, int i, Object obj) {
if ((i & 1) != 0) {
map = storeState.channels;
}
if ((i & 2) != 0) {
map2 = storeState.channelPermissions;
}
if ((i & 4) != 0) {
l = storeState.guildPermissions;
}
return storeState.copy(map, map2, l);
}
public final Map<Long, Channel> component1() {
return this.channels;
}
public final Map<Long, Long> component2() {
return this.channelPermissions;
}
public final Long component3() {
return this.guildPermissions;
}
public final StoreState copy(Map<Long, Channel> map, Map<Long, Long> map2, Long l) {
m.checkNotNullParameter(map, "channels");
m.checkNotNullParameter(map2, "channelPermissions");
return new StoreState(map, map2, l);
}
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (!(obj instanceof StoreState)) {
return false;
}
StoreState storeState = (StoreState) obj;
return m.areEqual(this.channels, storeState.channels) && m.areEqual(this.channelPermissions, storeState.channelPermissions) && m.areEqual(this.guildPermissions, storeState.guildPermissions);
}
public final Map<Long, Long> getChannelPermissions() {
return this.channelPermissions;
}
public final Map<Long, Channel> getChannels() {
return this.channels;
}
public final Long getGuildPermissions() {
return this.guildPermissions;
}
public int hashCode() {
Map<Long, Channel> map = this.channels;
int i = 0;
int hashCode = (map != null ? map.hashCode() : 0) * 31;
Map<Long, Long> map2 = this.channelPermissions;
int hashCode2 = (hashCode + (map2 != null ? map2.hashCode() : 0)) * 31;
Long l = this.guildPermissions;
if (l != null) {
i = l.hashCode();
}
return hashCode2 + i;
}
public String toString() {
StringBuilder P = a.P("StoreState(channels=");
P.append(this.channels);
P.append(", channelPermissions=");
P.append(this.channelPermissions);
P.append(", guildPermissions=");
return a.F(P, this.guildPermissions, ")");
}
}
/* compiled from: WidgetGuildScheduledEventLocationSelectViewModal.kt */
public static abstract class ViewState {
/* compiled from: WidgetGuildScheduledEventLocationSelectViewModal.kt */
public static final class Invalid extends ViewState {
public static final Invalid INSTANCE = new Invalid();
private Invalid() {
super(null);
}
}
/* compiled from: WidgetGuildScheduledEventLocationSelectViewModal.kt */
public static final class Valid extends ViewState {
private final Map<Long, Channel> availableChannels;
private final Set<Long> availableStageChannelIds;
private final Set<Long> availableVoiceChannelIds;
private final boolean canCreateExternalEvent;
private final String externalLocation;
private final Channel selectedChannel;
private final GuildScheduledEventEntityType selectedLocationOption;
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
public Valid(GuildScheduledEventEntityType guildScheduledEventEntityType, Channel channel, String str, Map<Long, Channel> map, Set<Long> set, Set<Long> set2, boolean z2) {
super(null);
m.checkNotNullParameter(guildScheduledEventEntityType, "selectedLocationOption");
m.checkNotNullParameter(str, "externalLocation");
m.checkNotNullParameter(map, "availableChannels");
m.checkNotNullParameter(set, "availableVoiceChannelIds");
m.checkNotNullParameter(set2, "availableStageChannelIds");
this.selectedLocationOption = guildScheduledEventEntityType;
this.selectedChannel = channel;
this.externalLocation = str;
this.availableChannels = map;
this.availableVoiceChannelIds = set;
this.availableStageChannelIds = set2;
this.canCreateExternalEvent = z2;
}
/* JADX DEBUG: Multi-variable search result rejected for r5v0, resolved type: com.discord.widgets.guildscheduledevent.WidgetGuildScheduledEventLocationSelectViewModal$ViewState$Valid */
/* JADX WARN: Multi-variable type inference failed */
public static /* synthetic */ Valid copy$default(Valid valid, GuildScheduledEventEntityType guildScheduledEventEntityType, Channel channel, String str, Map map, Set set, Set set2, boolean z2, int i, Object obj) {
if ((i & 1) != 0) {
guildScheduledEventEntityType = valid.selectedLocationOption;
}
if ((i & 2) != 0) {
channel = valid.selectedChannel;
}
if ((i & 4) != 0) {
str = valid.externalLocation;
}
if ((i & 8) != 0) {
map = valid.availableChannels;
}
if ((i & 16) != 0) {
set = valid.availableVoiceChannelIds;
}
if ((i & 32) != 0) {
set2 = valid.availableStageChannelIds;
}
if ((i & 64) != 0) {
z2 = valid.canCreateExternalEvent;
}
return valid.copy(guildScheduledEventEntityType, channel, str, map, set, set2, z2);
}
public final GuildScheduledEventEntityType component1() {
return this.selectedLocationOption;
}
public final Channel component2() {
return this.selectedChannel;
}
public final String component3() {
return this.externalLocation;
}
public final Map<Long, Channel> component4() {
return this.availableChannels;
}
public final Set<Long> component5() {
return this.availableVoiceChannelIds;
}
public final Set<Long> component6() {
return this.availableStageChannelIds;
}
public final boolean component7() {
return this.canCreateExternalEvent;
}
public final Valid copy(GuildScheduledEventEntityType guildScheduledEventEntityType, Channel channel, String str, Map<Long, Channel> map, Set<Long> set, Set<Long> set2, boolean z2) {
m.checkNotNullParameter(guildScheduledEventEntityType, "selectedLocationOption");
m.checkNotNullParameter(str, "externalLocation");
m.checkNotNullParameter(map, "availableChannels");
m.checkNotNullParameter(set, "availableVoiceChannelIds");
m.checkNotNullParameter(set2, "availableStageChannelIds");
return new Valid(guildScheduledEventEntityType, channel, str, map, set, set2, z2);
}
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (!(obj instanceof Valid)) {
return false;
}
Valid valid = (Valid) obj;
return m.areEqual(this.selectedLocationOption, valid.selectedLocationOption) && m.areEqual(this.selectedChannel, valid.selectedChannel) && m.areEqual(this.externalLocation, valid.externalLocation) && m.areEqual(this.availableChannels, valid.availableChannels) && m.areEqual(this.availableVoiceChannelIds, valid.availableVoiceChannelIds) && m.areEqual(this.availableStageChannelIds, valid.availableStageChannelIds) && this.canCreateExternalEvent == valid.canCreateExternalEvent;
}
public final Map<Long, Channel> getAvailableChannels() {
return this.availableChannels;
}
public final Set<Long> getAvailableStageChannelIds() {
return this.availableStageChannelIds;
}
public final Set<Long> getAvailableVoiceChannelIds() {
return this.availableVoiceChannelIds;
}
public final boolean getCanCreateExternalEvent() {
return this.canCreateExternalEvent;
}
public final String getExternalLocation() {
return this.externalLocation;
}
public final Channel getSelectedChannel() {
return this.selectedChannel;
}
public final GuildScheduledEventEntityType getSelectedLocationOption() {
return this.selectedLocationOption;
}
public int hashCode() {
GuildScheduledEventEntityType guildScheduledEventEntityType = this.selectedLocationOption;
int i = 0;
int hashCode = (guildScheduledEventEntityType != null ? guildScheduledEventEntityType.hashCode() : 0) * 31;
Channel channel = this.selectedChannel;
int hashCode2 = (hashCode + (channel != null ? channel.hashCode() : 0)) * 31;
String str = this.externalLocation;
int hashCode3 = (hashCode2 + (str != null ? str.hashCode() : 0)) * 31;
Map<Long, Channel> map = this.availableChannels;
int hashCode4 = (hashCode3 + (map != null ? map.hashCode() : 0)) * 31;
Set<Long> set = this.availableVoiceChannelIds;
int hashCode5 = (hashCode4 + (set != null ? set.hashCode() : 0)) * 31;
Set<Long> set2 = this.availableStageChannelIds;
if (set2 != null) {
i = set2.hashCode();
}
int i2 = (hashCode5 + i) * 31;
boolean z2 = this.canCreateExternalEvent;
if (z2) {
z2 = true;
}
int i3 = z2 ? 1 : 0;
int i4 = z2 ? 1 : 0;
int i5 = z2 ? 1 : 0;
return i2 + i3;
}
public String toString() {
StringBuilder P = a.P("Valid(selectedLocationOption=");
P.append(this.selectedLocationOption);
P.append(", selectedChannel=");
P.append(this.selectedChannel);
P.append(", externalLocation=");
P.append(this.externalLocation);
P.append(", availableChannels=");
P.append(this.availableChannels);
P.append(", availableVoiceChannelIds=");
P.append(this.availableVoiceChannelIds);
P.append(", availableStageChannelIds=");
P.append(this.availableStageChannelIds);
P.append(", canCreateExternalEvent=");
return a.L(P, this.canCreateExternalEvent, ")");
}
}
private ViewState() {
}
public /* synthetic */ ViewState(DefaultConstructorMarker defaultConstructorMarker) {
this();
}
}
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
public WidgetGuildScheduledEventLocationSelectViewModal(long j, Long l, StoreChannels storeChannels, StorePermissions storePermissions, Observable<StoreState> observable) {
super(null, 1, null);
m.checkNotNullParameter(storeChannels, "channelsStore");
m.checkNotNullParameter(storePermissions, "permissionsStore");
m.checkNotNullParameter(observable, "storeStateObservable");
this.initialChannelId = l;
this.channelsStore = storeChannels;
Observable<StoreState> W = observable.W(j0.p.a.a());
m.checkNotNullExpressionValue(W, "storeStateObservable\n …Schedulers.computation())");
ObservableExtensionsKt.appSubscribe$default(ObservableExtensionsKt.ui$default(W, this, null, 2, null), WidgetGuildScheduledEventLocationSelectViewModal.class, (Context) null, (Function1) null, (Function1) null, (Function0) null, (Function0) null, new AnonymousClass1(this), 62, (Object) null);
}
/* JADX WARNING: Illegal instructions before constructor call */
public /* synthetic */ WidgetGuildScheduledEventLocationSelectViewModal(long j, Long l, StoreChannels storeChannels, StorePermissions storePermissions, Observable observable, int i, DefaultConstructorMarker defaultConstructorMarker) {
this(j, l, storeChannels, storePermissions, (i & 16) != 0 ? Companion.access$observeStores(Companion, j, storeChannels, storePermissions) : observable);
storeChannels = (i & 4) != 0 ? StoreStream.Companion.getChannels() : storeChannels;
storePermissions = (i & 8) != 0 ? StoreStream.Companion.getPermissions() : storePermissions;
}
public static final /* synthetic */ void access$handleStoreState(WidgetGuildScheduledEventLocationSelectViewModal widgetGuildScheduledEventLocationSelectViewModal, StoreState storeState) {
widgetGuildScheduledEventLocationSelectViewModal.handleStoreState(storeState);
}
@MainThread
private final void handleStoreState(StoreState storeState) {
GuildScheduledEventEntityType guildScheduledEventEntityType;
String str;
this.currentStoreState = storeState;
ViewState viewState = getViewState();
Long l = null;
if (!(viewState instanceof ViewState.Valid)) {
viewState = null;
}
ViewState.Valid valid = (ViewState.Valid) viewState;
boolean canCreateExternalEvent = GuildScheduledEventUtilities.Companion.canCreateExternalEvent(storeState.getGuildPermissions());
Map<Long, Channel> channels = storeState.getChannels();
LinkedHashMap linkedHashMap = new LinkedHashMap();
for (Map.Entry<Long, Channel> entry : channels.entrySet()) {
Channel value = entry.getValue();
if (GuildScheduledEventUtilities.Companion.canStartEventInChannel(value, (Long) a.c(value, storeState.getChannelPermissions()))) {
linkedHashMap.put(entry.getKey(), entry.getValue());
}
}
HashSet hashSet = new HashSet();
HashSet hashSet2 = new HashSet();
for (Channel channel : linkedHashMap.values()) {
if (AnimatableValueParser.D1(channel)) {
hashSet2.add(Long.valueOf(channel.h()));
} else if (AnimatableValueParser.x1(channel)) {
hashSet.add(Long.valueOf(channel.h()));
}
}
if (valid == null) {
l = this.initialChannelId;
} else {
Channel selectedChannel = valid.getSelectedChannel();
if (selectedChannel != null) {
l = Long.valueOf(selectedChannel.h());
}
}
Channel channel2 = (Channel) linkedHashMap.get(l);
if (valid == null || (guildScheduledEventEntityType = valid.getSelectedLocationOption()) == null) {
guildScheduledEventEntityType = GuildScheduledEventEntityType.NONE;
}
if (guildScheduledEventEntityType == GuildScheduledEventEntityType.STAGE_INSTANCE && hashSet.isEmpty()) {
guildScheduledEventEntityType = GuildScheduledEventEntityType.NONE;
} else if (guildScheduledEventEntityType == GuildScheduledEventEntityType.VOICE && hashSet2.isEmpty()) {
guildScheduledEventEntityType = GuildScheduledEventEntityType.NONE;
} else if (guildScheduledEventEntityType == GuildScheduledEventEntityType.EXTERNAL && !canCreateExternalEvent) {
guildScheduledEventEntityType = GuildScheduledEventEntityType.NONE;
}
if (valid == null || (str = valid.getExternalLocation()) == null) {
str = "";
}
updateViewState(new ViewState.Valid(guildScheduledEventEntityType, channel2, str, linkedHashMap, hashSet2, hashSet, canCreateExternalEvent));
}
public final StoreState getCurrentStoreState() {
return this.currentStoreState;
}
public final void selectChannel(long j) {
StoreState storeState;
Map<Long, Channel> channels;
Channel channel;
ViewState viewState = getViewState();
if ((viewState instanceof ViewState.Valid) && (storeState = this.currentStoreState) != null && (channels = storeState.getChannels()) != null && (channel = channels.get(Long.valueOf(j))) != null) {
updateViewState(ViewState.Valid.copy$default((ViewState.Valid) viewState, null, channel, null, null, null, null, false, 125, null));
}
}
public final void selectLocationOption(GuildScheduledEventEntityType guildScheduledEventEntityType) {
m.checkNotNullParameter(guildScheduledEventEntityType, "locationOption");
ViewState viewState = getViewState();
if (viewState instanceof ViewState.Valid) {
ViewState.Valid valid = (ViewState.Valid) viewState;
if (guildScheduledEventEntityType != valid.getSelectedLocationOption()) {
updateViewState(ViewState.Valid.copy$default(valid, guildScheduledEventEntityType, null, "", null, null, null, false, 120, null));
}
}
}
public final void setCurrentStoreState(StoreState storeState) {
this.currentStoreState = storeState;
}
public final void setExternalLocation(String str) {
m.checkNotNullParameter(str, "newExternalLocation");
ViewState viewState = getViewState();
if (viewState instanceof ViewState.Valid) {
updateViewState(ViewState.Valid.copy$default((ViewState.Valid) viewState, null, null, str, null, null, null, false, 123, null));
}
}
}