2021-06-27 20:44:35 +00:00
package com.discord.widgets.bugreports ;
import android.content.Context ;
import android.net.Uri ;
import androidx.annotation.MainThread ;
import c.d.b.a.a ;
import com.discord.api.sticker.Sticker ;
import com.discord.api.sticker.StickerFormatType ;
import com.discord.api.sticker.StickerType ;
import com.discord.app.AppViewModel ;
import com.discord.utilities.error.Error ;
import com.discord.utilities.rest.RestAPI ;
import com.discord.utilities.rx.ObservableExtensionsKt ;
2021-07-19 19:45:22 +00:00
import com.discord.utilities.stickers.StickerUtils ;
2021-06-27 20:44:35 +00:00
import d0.c0.c ;
import d0.d0.f ;
import d0.t.n ;
import d0.z.d.m ;
import java.util.List ;
import java.util.concurrent.TimeUnit ;
import kotlin.jvm.functions.Function0 ;
import kotlin.jvm.functions.Function1 ;
import kotlin.jvm.internal.DefaultConstructorMarker ;
import okhttp3.MultipartBody ;
import okhttp3.RequestBody ;
import rx.Observable ;
import rx.subjects.PublishSubject ;
/* compiled from: BugReportViewModel.kt */
public final class BugReportViewModel extends AppViewModel < ViewState > {
public static final Companion Companion = new Companion ( null ) ;
private static final List < Sticker > sendingStickers ;
private static final List < Sticker > successStickers ;
private final PublishSubject < Event > eventSubject ;
private Integer priority ;
private String reportDescription ;
private String reportName ;
private final RestAPI restApi ;
private final String screenshotName ;
private final Uri screenshotUri ;
private final Sticker sendingSticker ;
private final int stickerCharacterIndex ;
private boolean stickersPrefetched ;
private final Sticker successSticker ;
private boolean useScreenshot ;
/* compiled from: BugReportViewModel.kt */
public static final class Companion {
private Companion ( ) {
}
public /* synthetic */ Companion ( DefaultConstructorMarker defaultConstructorMarker ) {
this ( ) ;
}
public final List < Sticker > getSendingStickers ( ) {
return BugReportViewModel . access$getSendingStickers$cp ( ) ;
}
public final List < Sticker > getSuccessStickers ( ) {
return BugReportViewModel . access$getSuccessStickers$cp ( ) ;
}
}
/* compiled from: BugReportViewModel.kt */
public static abstract class Event {
/* compiled from: BugReportViewModel.kt */
public static final class CloseReport extends Event {
public static final CloseReport INSTANCE = new CloseReport ( ) ;
private CloseReport ( ) {
super ( null ) ;
}
}
private Event ( ) {
}
public /* synthetic */ Event ( DefaultConstructorMarker defaultConstructorMarker ) {
this ( ) ;
}
}
/* compiled from: BugReportViewModel.kt */
public static abstract class ViewState {
/* compiled from: BugReportViewModel.kt */
public static final class Report extends ViewState {
private final Error error ;
private final Integer priority ;
private final String reportDescription ;
private final String reportName ;
private final Uri screenshotUri ;
private final boolean useScreenshot ;
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
public Report ( Uri uri , String str , String str2 , Integer num , boolean z2 , Error error ) {
super ( null ) ;
m . checkNotNullParameter ( uri , " screenshotUri " ) ;
this . screenshotUri = uri ;
this . reportName = str ;
this . reportDescription = str2 ;
this . priority = num ;
this . useScreenshot = z2 ;
this . error = error ;
}
/* JADX INFO: this call moved to the top of the method (can break code semantics) */
public /* synthetic */ Report ( Uri uri , String str , String str2 , Integer num , boolean z2 , Error error , int i , DefaultConstructorMarker defaultConstructorMarker ) {
this ( uri , str , str2 , num , ( i & 16 ) ! = 0 ? true : z2 , ( i & 32 ) ! = 0 ? null : error ) ;
}
public static /* synthetic */ Report copy$default ( Report report , Uri uri , String str , String str2 , Integer num , boolean z2 , Error error , int i , Object obj ) {
if ( ( i & 1 ) ! = 0 ) {
uri = report . screenshotUri ;
}
if ( ( i & 2 ) ! = 0 ) {
str = report . reportName ;
}
if ( ( i & 4 ) ! = 0 ) {
str2 = report . reportDescription ;
}
if ( ( i & 8 ) ! = 0 ) {
num = report . priority ;
}
if ( ( i & 16 ) ! = 0 ) {
z2 = report . useScreenshot ;
}
if ( ( i & 32 ) ! = 0 ) {
error = report . error ;
}
return report . copy ( uri , str , str2 , num , z2 , error ) ;
}
public final Uri component1 ( ) {
return this . screenshotUri ;
}
public final String component2 ( ) {
return this . reportName ;
}
public final String component3 ( ) {
return this . reportDescription ;
}
public final Integer component4 ( ) {
return this . priority ;
}
public final boolean component5 ( ) {
return this . useScreenshot ;
}
public final Error component6 ( ) {
return this . error ;
}
public final Report copy ( Uri uri , String str , String str2 , Integer num , boolean z2 , Error error ) {
m . checkNotNullParameter ( uri , " screenshotUri " ) ;
return new Report ( uri , str , str2 , num , z2 , error ) ;
}
public boolean equals ( Object obj ) {
if ( this = = obj ) {
return true ;
}
if ( ! ( obj instanceof Report ) ) {
return false ;
}
Report report = ( Report ) obj ;
return m . areEqual ( this . screenshotUri , report . screenshotUri ) & & m . areEqual ( this . reportName , report . reportName ) & & m . areEqual ( this . reportDescription , report . reportDescription ) & & m . areEqual ( this . priority , report . priority ) & & this . useScreenshot = = report . useScreenshot & & m . areEqual ( this . error , report . error ) ;
}
public final Error getError ( ) {
return this . error ;
}
public final Integer getPriority ( ) {
return this . priority ;
}
public final String getReportDescription ( ) {
return this . reportDescription ;
}
public final String getReportName ( ) {
return this . reportName ;
}
public final Uri getScreenshotUri ( ) {
return this . screenshotUri ;
}
public final boolean getUseScreenshot ( ) {
return this . useScreenshot ;
}
public int hashCode ( ) {
Uri uri = this . screenshotUri ;
int i = 0 ;
int hashCode = ( uri ! = null ? uri . hashCode ( ) : 0 ) * 31 ;
String str = this . reportName ;
int hashCode2 = ( hashCode + ( str ! = null ? str . hashCode ( ) : 0 ) ) * 31 ;
String str2 = this . reportDescription ;
int hashCode3 = ( hashCode2 + ( str2 ! = null ? str2 . hashCode ( ) : 0 ) ) * 31 ;
Integer num = this . priority ;
int hashCode4 = ( hashCode3 + ( num ! = null ? num . hashCode ( ) : 0 ) ) * 31 ;
boolean z2 = this . useScreenshot ;
if ( z2 ) {
z2 = true ;
}
int i2 = z2 ? 1 : 0 ;
int i3 = z2 ? 1 : 0 ;
int i4 = z2 ? 1 : 0 ;
int i5 = ( hashCode4 + i2 ) * 31 ;
Error error = this . error ;
if ( error ! = null ) {
i = error . hashCode ( ) ;
}
return i5 + i ;
}
public String toString ( ) {
2021-07-19 19:45:22 +00:00
StringBuilder K = a . K ( " Report(screenshotUri= " ) ;
K . append ( this . screenshotUri ) ;
K . append ( " , reportName= " ) ;
K . append ( this . reportName ) ;
K . append ( " , reportDescription= " ) ;
K . append ( this . reportDescription ) ;
K . append ( " , priority= " ) ;
K . append ( this . priority ) ;
K . append ( " , useScreenshot= " ) ;
K . append ( this . useScreenshot ) ;
K . append ( " , error= " ) ;
K . append ( this . error ) ;
K . append ( " ) " ) ;
return K . toString ( ) ;
2021-06-27 20:44:35 +00:00
}
}
/* compiled from: BugReportViewModel.kt */
public static final class Sending extends ViewState {
private final Sticker sendingSticker ;
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
public Sending ( Sticker sticker ) {
super ( null ) ;
m . checkNotNullParameter ( sticker , " sendingSticker " ) ;
this . sendingSticker = sticker ;
}
public static /* synthetic */ Sending copy$default ( Sending sending , Sticker sticker , int i , Object obj ) {
if ( ( i & 1 ) ! = 0 ) {
sticker = sending . sendingSticker ;
}
return sending . copy ( sticker ) ;
}
public final Sticker component1 ( ) {
return this . sendingSticker ;
}
public final Sending copy ( Sticker sticker ) {
m . checkNotNullParameter ( sticker , " sendingSticker " ) ;
return new Sending ( sticker ) ;
}
public boolean equals ( Object obj ) {
if ( this ! = obj ) {
return ( obj instanceof Sending ) & & m . areEqual ( this . sendingSticker , ( ( Sending ) obj ) . sendingSticker ) ;
}
return true ;
}
public final Sticker getSendingSticker ( ) {
return this . sendingSticker ;
}
public int hashCode ( ) {
Sticker sticker = this . sendingSticker ;
if ( sticker ! = null ) {
return sticker . hashCode ( ) ;
}
return 0 ;
}
public String toString ( ) {
2021-07-19 19:45:22 +00:00
StringBuilder K = a . K ( " Sending(sendingSticker= " ) ;
K . append ( this . sendingSticker ) ;
K . append ( " ) " ) ;
return K . toString ( ) ;
2021-06-27 20:44:35 +00:00
}
}
/* compiled from: BugReportViewModel.kt */
public static final class Success extends ViewState {
private final Sticker successSticker ;
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
public Success ( Sticker sticker ) {
super ( null ) ;
m . checkNotNullParameter ( sticker , " successSticker " ) ;
this . successSticker = sticker ;
}
public static /* synthetic */ Success copy$default ( Success success , Sticker sticker , int i , Object obj ) {
if ( ( i & 1 ) ! = 0 ) {
sticker = success . successSticker ;
}
return success . copy ( sticker ) ;
}
public final Sticker component1 ( ) {
return this . successSticker ;
}
public final Success copy ( Sticker sticker ) {
m . checkNotNullParameter ( sticker , " successSticker " ) ;
return new Success ( sticker ) ;
}
public boolean equals ( Object obj ) {
if ( this ! = obj ) {
return ( obj instanceof Success ) & & m . areEqual ( this . successSticker , ( ( Success ) obj ) . successSticker ) ;
}
return true ;
}
public final Sticker getSuccessSticker ( ) {
return this . successSticker ;
}
public int hashCode ( ) {
Sticker sticker = this . successSticker ;
if ( sticker ! = null ) {
return sticker . hashCode ( ) ;
}
return 0 ;
}
public String toString ( ) {
2021-07-19 19:45:22 +00:00
StringBuilder K = a . K ( " Success(successSticker= " ) ;
K . append ( this . successSticker ) ;
K . append ( " ) " ) ;
return K . toString ( ) ;
2021-06-27 20:44:35 +00:00
}
}
private ViewState ( ) {
}
public /* synthetic */ ViewState ( DefaultConstructorMarker defaultConstructorMarker ) {
this ( ) ;
}
}
static {
StickerFormatType stickerFormatType = StickerFormatType . LOTTIE ;
StickerType stickerType = StickerType . STANDARD ;
2021-07-03 23:36:06 +00:00
sendingStickers = n . listOf ( ( Object [ ] ) new Sticker [ ] { new Sticker ( 754107634172297306L , 754103543786504244L , null , " On My Way " , " " , stickerFormatType , " " , stickerType , null , 256 ) , new Sticker ( 751606719611928586L , 751604115435421716L , null , " Nelly flies over on a jetpack " , " " , stickerFormatType , " " , stickerType , null , 256 ) , new Sticker ( 749049128012742676L , 749043879713701898L , null , " Wumpus zipping by on a monowheel " , " " , stickerFormatType , " " , stickerType , null , 256 ) , new Sticker ( 761114619137359892L , 761106686382964758L , null , " Cap running in a hurry " , " " , stickerFormatType , " " , stickerType , null , 256 ) , new Sticker ( 783788733987815434L , 783506493751296033L , null , " Phibi clapping her hands " , " " , stickerFormatType , " " , stickerType , null , 256 ) } ) ;
successStickers = n . listOf ( ( Object [ ] ) new Sticker [ ] { new Sticker ( 754109076933443614L , 754103543786504244L , null , " Clyde cheering with his arms raised " , " " , stickerFormatType , " " , stickerType , null , 256 ) , new Sticker ( 751606065447305216L , 751604115435421716L , null , " Nelly waves her arms cheerfully " , " " , stickerFormatType , " " , stickerType , null , 256 ) , new Sticker ( 749053689419006003L , 749043879713701898L , null , " Wumpus jumps for joy " , " " , stickerFormatType , " " , stickerType , null , 256 ) , new Sticker ( 761108384010862602L , 761106686382964758L , null , " Cap gives a thumbs up " , " " , stickerFormatType , " " , stickerType , null , 256 ) , new Sticker ( 783794979704537108L , 783506493751296033L , null , " Phibi riding a four leaf clover " , " " , stickerFormatType , " " , stickerType , null , 256 ) } ) ;
2021-06-27 20:44:35 +00:00
}
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
public BugReportViewModel ( Uri uri , String str , RestAPI restAPI ) {
super ( null , 1 , null ) ;
m . checkNotNullParameter ( uri , " screenshotUri " ) ;
m . checkNotNullParameter ( restAPI , " restApi " ) ;
this . screenshotUri = uri ;
this . screenshotName = str ;
this . restApi = restAPI ;
List < Sticker > list = sendingStickers ;
int random = f . random ( n . getIndices ( list ) , c . b ) ;
this . stickerCharacterIndex = random ;
this . sendingSticker = list . get ( random ) ;
this . successSticker = successStickers . get ( random ) ;
this . useScreenshot = true ;
2021-07-03 23:36:06 +00:00
this . eventSubject = PublishSubject . k0 ( ) ;
2021-06-27 20:44:35 +00:00
}
/* JADX INFO: this call moved to the top of the method (can break code semantics) */
public /* synthetic */ BugReportViewModel ( Uri uri , String str , RestAPI restAPI , int i , DefaultConstructorMarker defaultConstructorMarker ) {
this ( uri , str , ( i & 4 ) ! = 0 ? RestAPI . Companion . getApi ( ) : restAPI ) ;
}
public static final /* synthetic */ void access$dismissAfterDelay ( BugReportViewModel bugReportViewModel ) {
bugReportViewModel . dismissAfterDelay ( ) ;
}
public static final /* synthetic */ PublishSubject access$getEventSubject$p ( BugReportViewModel bugReportViewModel ) {
return bugReportViewModel . eventSubject ;
}
public static final /* synthetic */ List access$getSendingStickers$cp ( ) {
return sendingStickers ;
}
public static final /* synthetic */ List access$getSuccessStickers$cp ( ) {
return successStickers ;
}
public static final /* synthetic */ void access$updateViewState ( BugReportViewModel bugReportViewModel , ViewState viewState ) {
bugReportViewModel . updateViewState ( ( BugReportViewModel ) viewState ) ;
}
private final void dismissAfterDelay ( ) {
2021-07-03 23:36:06 +00:00
Observable < Long > d02 = Observable . d0 ( 1500 , TimeUnit . MILLISECONDS ) ;
m . checkNotNullExpressionValue ( d02 , " Observable.timer(1500, TimeUnit.MILLISECONDS) " ) ;
ObservableExtensionsKt . appSubscribe$default ( ObservableExtensionsKt . ui$default ( d02 , this , null , 2 , null ) , BugReportViewModel . class , ( Context ) null , ( Function1 ) null , ( Function1 ) null , ( Function0 ) null , ( Function0 ) null , new BugReportViewModel$dismissAfterDelay$1 ( this ) , 62 , ( Object ) null ) ;
2021-06-27 20:44:35 +00:00
}
public static /* synthetic */ void updateViewState$default ( BugReportViewModel bugReportViewModel , Error error , int i , Object obj ) {
if ( ( i & 1 ) ! = 0 ) {
error = null ;
}
bugReportViewModel . updateViewState ( error ) ;
}
public final Integer getPriority ( ) {
return this . priority ;
}
public final String getReportDescription ( ) {
return this . reportDescription ;
}
public final String getReportName ( ) {
return this . reportName ;
}
public final RestAPI getRestApi ( ) {
return this . restApi ;
}
public final String getScreenshotName ( ) {
return this . screenshotName ;
}
public final Uri getScreenshotUri ( ) {
return this . screenshotUri ;
}
public final Sticker getSendingSticker ( ) {
return this . sendingSticker ;
}
public final boolean getStickersPrefetched ( ) {
return this . stickersPrefetched ;
}
public final Sticker getSuccessSticker ( ) {
return this . successSticker ;
}
public final boolean getUseScreenshot ( ) {
return this . useScreenshot ;
}
public final Observable < Event > observeEvents ( ) {
PublishSubject < Event > publishSubject = this . eventSubject ;
m . checkNotNullExpressionValue ( publishSubject , " eventSubject " ) ;
return publishSubject ;
}
public final void prefetchStickers ( Context context ) {
m . checkNotNullParameter ( context , " context " ) ;
if ( ! this . stickersPrefetched ) {
StickerUtils stickerUtils = StickerUtils . INSTANCE ;
ObservableExtensionsKt . appSubscribe$default ( ObservableExtensionsKt . restSubscribeOn$default ( stickerUtils . fetchSticker ( context , this . sendingSticker ) , false , 1 , null ) , BugReportViewModel . class , ( Context ) null , ( Function1 ) null , ( Function1 ) null , ( Function0 ) null , ( Function0 ) null , BugReportViewModel$prefetchStickers$1 . INSTANCE , 62 , ( Object ) null ) ;
ObservableExtensionsKt . appSubscribe$default ( ObservableExtensionsKt . restSubscribeOn$default ( stickerUtils . fetchSticker ( context , this . successSticker ) , false , 1 , null ) , BugReportViewModel . class , ( Context ) null , ( Function1 ) null , ( Function1 ) null , ( Function0 ) null , ( Function0 ) null , BugReportViewModel$prefetchStickers$2 . INSTANCE , 62 , ( Object ) null ) ;
this . stickersPrefetched = true ;
}
}
@MainThread
public final void sendReport ( RequestBody requestBody ) {
Integer num ;
String str = this . reportName ;
if ( str ! = null & & ( num = this . priority ) ! = null ) {
int intValue = num . intValue ( ) ;
MultipartBody . Part b = requestBody ! = null ? MultipartBody . Part . b ( " screenshot " , this . screenshotName , requestBody ) : null ;
updateViewState ( ( BugReportViewModel ) new ViewState . Sending ( this . sendingSticker ) ) ;
ObservableExtensionsKt . appSubscribe$default ( ObservableExtensionsKt . ui ( ObservableExtensionsKt . restSubscribeOn$default ( this . restApi . sendBugReport ( str , this . reportDescription , intValue , b ) , false , 1 , null ) ) , BugReportViewModel . class , ( Context ) null , ( Function1 ) null , new BugReportViewModel$sendReport$2 ( this ) , ( Function0 ) null , ( Function0 ) null , new BugReportViewModel$sendReport$1 ( this ) , 54 , ( Object ) null ) ;
}
}
public final void setPriority ( Integer num ) {
this . priority = num ;
}
public final void setReportDescription ( String str ) {
this . reportDescription = str ;
}
public final void setReportName ( String str ) {
this . reportName = str ;
}
public final void setStickersPrefetched ( boolean z2 ) {
this . stickersPrefetched = z2 ;
}
public final void setUseScreenshot ( boolean z2 ) {
this . useScreenshot = z2 ;
}
@MainThread
public final void updatePriority ( int i ) {
this . priority = Integer . valueOf ( i ) ;
updateViewState$default ( this , null , 1 , null ) ;
}
@MainThread
public final void updateReportDescription ( String str ) {
m . checkNotNullParameter ( str , " description " ) ;
this . reportDescription = str ;
updateViewState$default ( this , null , 1 , null ) ;
}
@MainThread
public final void updateReportName ( String str ) {
m . checkNotNullParameter ( str , " name " ) ;
this . reportName = str ;
updateViewState$default ( this , null , 1 , null ) ;
}
public final void updateViewState ( Error error ) {
updateViewState ( ( BugReportViewModel ) new ViewState . Report ( this . screenshotUri , this . reportName , this . reportDescription , this . priority , this . useScreenshot , error ) ) ;
}
@MainThread
public final void useScreenshot ( boolean z2 ) {
this . useScreenshot = z2 ;
updateViewState$default ( this , null , 1 , null ) ;
}
}