2021-08-03 07:33:18 +00:00
package com.discord.widgets.guilds.invite ;
import c.d.b.a.a ;
import com.airbnb.lottie.parser.AnimatableValueParser ;
import com.discord.api.channel.Channel ;
import com.discord.models.user.User ;
import com.discord.widgets.guilds.invite.InviteSuggestion ;
import com.discord.widgets.guilds.invite.InviteSuggestionItem ;
import com.discord.widgets.guilds.invite.WidgetGuildInviteShareViewModel ;
import d0.g0.t ;
import d0.g0.w ;
import d0.t.h0 ;
import d0.t.n0 ;
import d0.t.o ;
import d0.t.u ;
import d0.z.d.m ;
import java.util.ArrayList ;
import java.util.List ;
import java.util.Map ;
import java.util.Set ;
import kotlin.NoWhenBranchMatchedException ;
import kotlin.Unit ;
import rx.functions.Func5 ;
/* compiled from: WidgetGuildInviteShareViewModel.kt */
public final class WidgetGuildInviteShareViewModel$observeViewStateFromStores$1 < T1 , T2 , T3 , T4 , T5 , R > implements Func5 < WidgetInviteModel , List < ? extends InviteSuggestion > , String , Map < String , ? extends Set < ? extends Long > > , Unit , WidgetGuildInviteShareViewModel . ViewState . Loaded > {
public final /* synthetic */ WidgetGuildInviteShareViewModel this $0 ;
public WidgetGuildInviteShareViewModel$observeViewStateFromStores$1 ( WidgetGuildInviteShareViewModel widgetGuildInviteShareViewModel ) {
this . this$0 = widgetGuildInviteShareViewModel ;
}
2021-08-31 06:34:54 +00:00
/* JADX WARNING: Removed duplicated region for block: B:58:0x014c */
/* JADX WARNING: Removed duplicated region for block: B:64:0x015f */
2021-08-03 07:33:18 +00:00
public final WidgetGuildInviteShareViewModel . ViewState . Loaded call ( WidgetInviteModel widgetInviteModel , List < ? extends InviteSuggestion > list , String str , Map < String , ? extends Set < Long > > map , Unit unit ) {
ArrayList arrayList ;
boolean z2 ;
2021-08-31 06:34:54 +00:00
Object obj ;
boolean z3 ;
2021-08-03 07:33:18 +00:00
m . checkNotNullExpressionValue ( map , " sentInvites " ) ;
String access$getInviteLink$p = WidgetGuildInviteShareViewModel . access$getInviteLink$p ( this . this$0 , widgetInviteModel . getInvite ( ) ) ;
m . checkNotNullExpressionValue ( access$getInviteLink$p , " widgetInviteModel.invite.inviteLink " ) ;
Object obj2 = map . get ( access$getInviteLink$p ) ;
if ( obj2 = = null ) {
obj2 = n0 . emptySet ( ) ;
}
Set set = ( Set ) obj2 ;
2021-08-31 06:34:54 +00:00
boolean z4 = false ;
2021-08-03 07:33:18 +00:00
if ( str = = null | | t . isBlank ( str ) ) {
m . checkNotNullExpressionValue ( list , " inviteSuggestions " ) ;
} else {
2021-08-28 06:29:07 +00:00
ArrayList X = a . X ( list , " inviteSuggestions " ) ;
2021-08-03 07:33:18 +00:00
for ( Object obj3 : list ) {
InviteSuggestion inviteSuggestion = ( InviteSuggestion ) obj3 ;
if ( inviteSuggestion instanceof InviteSuggestion . ChannelItem ) {
2021-08-31 06:34:54 +00:00
z3 = w . contains ( ( CharSequence ) AnimatableValueParser . y0 ( ( ( InviteSuggestion . ChannelItem ) inviteSuggestion ) . getChannel ( ) ) , ( CharSequence ) str , true ) ;
2021-08-03 07:33:18 +00:00
} else if ( inviteSuggestion instanceof InviteSuggestion . UserSuggestion ) {
2021-08-31 06:34:54 +00:00
z3 = w . contains ( ( CharSequence ) ( ( InviteSuggestion . UserSuggestion ) inviteSuggestion ) . getUser ( ) . getUsername ( ) , ( CharSequence ) str , true ) ;
2021-08-03 07:33:18 +00:00
} else {
throw new NoWhenBranchMatchedException ( ) ;
}
2021-08-31 06:34:54 +00:00
if ( z3 ) {
2021-08-28 06:29:07 +00:00
X . add ( obj3 ) ;
2021-08-03 07:33:18 +00:00
}
}
2021-08-28 06:29:07 +00:00
list = X ;
2021-08-03 07:33:18 +00:00
}
List < Channel > dms = widgetInviteModel . getDms ( ) ;
ArrayList arrayList2 = new ArrayList ( o . collectionSizeOrDefault ( dms , 10 ) ) ;
for ( Channel channel : dms ) {
User v0 = AnimatableValueParser . v0 ( channel ) ;
arrayList2 . add ( d0 . o . to ( v0 ! = null ? Long . valueOf ( v0 . getId ( ) ) : null , Long . valueOf ( channel . h ( ) ) ) ) ;
}
Map map2 = h0 . toMap ( arrayList2 ) ;
2021-08-31 06:34:54 +00:00
if ( ! ( true ^ list . isEmpty ( ) ) ) {
if ( ! ( str = = null | | t . isBlank ( str ) ) ) {
2021-08-03 07:33:18 +00:00
arrayList = d0 . t . m . listOf ( InviteSuggestionItem . SearchNoResultsItem ) ;
2021-08-31 06:34:54 +00:00
if ( widgetInviteModel . getInvite ( ) = = null ) {
if ( ! widgetInviteModel . getInvite ( ) . isStatic ( ) & & ! widgetInviteModel . isInviteFromStore ( ) ) {
z4 = true ;
}
z2 = z4 ;
} else {
z2 = true ;
}
2021-08-03 07:33:18 +00:00
m . checkNotNullExpressionValue ( widgetInviteModel , " widgetInviteModel " ) ;
m . checkNotNullExpressionValue ( str , " filter " ) ;
2021-08-31 06:34:54 +00:00
return new WidgetGuildInviteShareViewModel . ViewState . Loaded ( widgetInviteModel , arrayList , str , map , z2 ) ;
2021-08-03 07:33:18 +00:00
}
}
ArrayList arrayList3 = new ArrayList ( o . collectionSizeOrDefault ( list , 10 ) ) ;
for ( InviteSuggestion inviteSuggestion2 : list ) {
if ( inviteSuggestion2 instanceof InviteSuggestion . ChannelItem ) {
InviteSuggestion . ChannelItem channelItem = ( InviteSuggestion . ChannelItem ) inviteSuggestion2 ;
obj = new InviteSuggestionItem . ChannelItem ( channelItem . getChannel ( ) , set . contains ( Long . valueOf ( channelItem . getChannel ( ) . h ( ) ) ) ) ;
} else if ( inviteSuggestion2 instanceof InviteSuggestion . UserSuggestion ) {
InviteSuggestion . UserSuggestion userSuggestion = ( InviteSuggestion . UserSuggestion ) inviteSuggestion2 ;
obj = new InviteSuggestionItem . UserItem ( userSuggestion . getUser ( ) , u . contains ( set , map2 . get ( Long . valueOf ( userSuggestion . getUser ( ) . getId ( ) ) ) ) ) ;
} else {
throw new NoWhenBranchMatchedException ( ) ;
}
arrayList3 . add ( obj ) ;
}
arrayList = arrayList3 ;
if ( widgetInviteModel . getInvite ( ) = = null ) {
}
m . checkNotNullExpressionValue ( widgetInviteModel , " widgetInviteModel " ) ;
m . checkNotNullExpressionValue ( str , " filter " ) ;
2021-08-31 06:34:54 +00:00
return new WidgetGuildInviteShareViewModel . ViewState . Loaded ( widgetInviteModel , arrayList , str , map , z2 ) ;
2021-08-03 07:33:18 +00:00
}
/* 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, java.lang.Object, java.lang.Object, java.lang.Object, java.lang.Object] */
@Override // rx.functions.Func5
public /* bridge */ /* synthetic */ WidgetGuildInviteShareViewModel . ViewState . Loaded call ( WidgetInviteModel widgetInviteModel , List < ? extends InviteSuggestion > list , String str , Map < String , ? extends Set < ? extends Long > > map , Unit unit ) {
return call ( widgetInviteModel , list , str , ( Map < String , ? extends Set < Long > > ) map , unit ) ;
}
}