package com.strmr.ps.ui.usercollection;

import android.util.Log;
import com.strmr.ps.data.model.ContentItem;
import com.strmr.ps.data.remote.model.mdblist.MdbListItem;
import defpackage.ag8;
import defpackage.ak1;
import defpackage.ck1;
import defpackage.e6a;
import defpackage.gr3;
import defpackage.s38;
import defpackage.vx8;
import defpackage.xf8;
import java.util.concurrent.CancellationException;
import kotlin.Metadata;
import kotlin.coroutines.Continuation;
import kotlin.coroutines.jvm.internal.DebugMetadata;
import kotlin.coroutines.jvm.internal.SuspendLambda;

/* JADX INFO: loaded from: classes3.dex */
@Metadata(d1 = {"\u0000\f\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\u0010\u0002\u001a\u0004\u0018\u00010\u0001*\u00020\u0000H\n¢\u0006\u0004\b\u0002\u0010\u0003"}, d2 = {"Lak1;", "Lcom/strmr/ps/data/model/ContentItem;", "<anonymous>", "(Lak1;)Lcom/strmr/ps/data/model/ContentItem;"}, k = 3, mv = {2, 0, 0})
@DebugMetadata(c = "com.strmr.ps.ui.usercollection.UserCollectionContentViewModel$enrichMdbListItems$2$1$1", f = "UserCollectionContentViewModel.kt", i = {0, 1, 2, 3}, l = {642, 469, 470, 471}, m = "invokeSuspend", n = {"$this$withPermit$iv", "$this$withPermit$iv", "$this$withPermit$iv", "$this$withPermit$iv"}, s = {"L$0", "L$0", "L$0", "L$0"})
@vx8
final class f extends SuspendLambda implements gr3<ak1, Continuation<? super ContentItem>, Object> {
    public xf8 a;
    public Object b;
    public MdbListItem c;
    public boolean d;
    public int e;
    public final /* synthetic */ UserCollectionContentViewModel f;
    public final /* synthetic */ MdbListItem i;
    public final /* synthetic */ boolean j;

    /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
    public f(UserCollectionContentViewModel userCollectionContentViewModel, MdbListItem mdbListItem, boolean z, Continuation continuation) {
        super(2, continuation);
        this.f = userCollectionContentViewModel;
        this.i = mdbListItem;
        this.j = z;
    }

    @Override // kotlin.coroutines.jvm.internal.BaseContinuationImpl
    public final Continuation create(Object obj, Continuation continuation) {
        return new f(this.f, this.i, this.j, continuation);
    }

    @Override // defpackage.gr3
    public final Object invoke(Object obj, Object obj2) {
        return ((f) create((ak1) obj, (Continuation) obj2)).invokeSuspend(e6a.a);
    }

    /* JADX WARN: Can't wrap try/catch for region: R(9:0|2|70|(1:(1:(1:(1:(6:8|9|56|49|65|66)(2:17|18))(6:19|20|48|49|65|66))(9:22|76|23|24|72|40|(4:42|(2:44|(3:47|48|49))(2:52|(3:55|56|49))|71|54)|65|66))(1:31))(3:32|(1:35)|54)|74|36|(6:39|72|40|(0)|65|66)|54|(1:(0))) */
    /* JADX WARN: Code restructure failed: missing block: B:58:0x00ed, code lost:
    
        r12 = th;
     */
    /* JADX WARN: Code restructure failed: missing block: B:59:0x00ee, code lost:
    
        r2 = r9;
     */
    /* JADX WARN: Code restructure failed: missing block: B:60:0x00f0, code lost:
    
        r12 = e;
     */
    /* JADX WARN: Code restructure failed: missing block: B:61:0x00f1, code lost:
    
        r1 = r6;
        r2 = r9;
     */
    /* JADX WARN: Code restructure failed: missing block: B:62:0x00f4, code lost:
    
        r12 = move-exception;
     */
    /* JADX WARN: Code restructure failed: missing block: B:78:?, code lost:
    
        throw r12;
     */
    /* JADX WARN: Multi-variable type inference failed */
    /* JADX WARN: Removed duplicated region for block: B:42:0x00ad A[Catch: all -> 0x0020, CancellationException -> 0x0026, Exception -> 0x00cf, TryCatch #1 {all -> 0x0020, blocks: (B:9:0x001b, B:56:0x00ea, B:64:0x00f7, B:67:0x0110, B:20:0x0037, B:48:0x00cb, B:40:0x00a9, B:42:0x00ad, B:44:0x00b3, B:52:0x00d2), top: B:70:0x000b }] */
    /* JADX WARN: Type inference failed for: r1v0, types: [ck1, java.lang.Object] */
    /* JADX WARN: Type inference failed for: r1v1, types: [com.strmr.ps.data.remote.model.mdblist.MdbListItem] */
    /* JADX WARN: Type inference failed for: r1v3 */
    /* JADX WARN: Type inference failed for: r1v4 */
    /* JADX WARN: Type inference failed for: r1v7 */
    /* JADX WARN: Type inference failed for: r2v0, types: [int] */
    /* JADX WARN: Type inference failed for: r2v1, types: [xf8] */
    /* JADX WARN: Type inference failed for: r2v10 */
    /* JADX WARN: Type inference failed for: r2v11, types: [xf8] */
    /* JADX WARN: Type inference failed for: r2v12 */
    /* JADX WARN: Type inference failed for: r2v13 */
    /* JADX WARN: Type inference failed for: r2v14 */
    /* JADX WARN: Type inference failed for: r2v17 */
    /* JADX WARN: Type inference failed for: r2v18 */
    /* JADX WARN: Type inference failed for: r2v2 */
    /* JADX WARN: Type inference failed for: r2v20 */
    /* JADX WARN: Type inference failed for: r2v23 */
    /* JADX WARN: Type inference failed for: r2v24 */
    /* JADX WARN: Type inference failed for: r2v25 */
    /* JADX WARN: Type inference failed for: r2v26 */
    /* JADX WARN: Type inference failed for: r2v27 */
    /* JADX WARN: Type inference failed for: r2v28 */
    /* JADX WARN: Type inference failed for: r2v29 */
    /* JADX WARN: Type inference failed for: r2v3, types: [xf8] */
    /* JADX WARN: Type inference failed for: r2v30 */
    /* JADX WARN: Type inference failed for: r2v31 */
    /* JADX WARN: Type inference failed for: r2v4, types: [xf8] */
    /* JADX WARN: Type inference failed for: r2v7 */
    /* JADX WARN: Type inference failed for: r2v8 */
    /* JADX WARN: Type inference failed for: r2v9 */
    /* JADX WARN: Type inference failed for: r9v1 */
    /* JADX WARN: Type inference failed for: r9v2, types: [xf8] */
    /* JADX WARN: Type inference failed for: r9v4 */
    @Override // kotlin.coroutines.jvm.internal.BaseContinuationImpl
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object invokeSuspend(Object obj) throws Throwable {
        ?? r2;
        UserCollectionContentViewModel userCollectionContentViewModel;
        ?? r9;
        boolean z;
        MdbListItem mdbListItem;
        UserCollectionContentViewModel userCollectionContentViewModel2;
        MdbListItem mdbListItem2;
        boolean z2;
        Integer num;
        ?? r22;
        ContentItem contentItem;
        ?? r23;
        ?? r24;
        ?? r1 = ck1.a;
        ?? r25 = this.e;
        ContentItem contentItem2 = null;
        try {
            try {
                try {
                } catch (Throwable th) {
                    th = th;
                }
            } catch (Exception e) {
                e = e;
            }
            if (r25 == 0) {
                s38.b(obj);
                userCollectionContentViewModel = this.f;
                ?? r26 = userCollectionContentViewModel.s;
                this.a = r26;
                this.b = userCollectionContentViewModel;
                MdbListItem mdbListItem3 = this.i;
                this.c = mdbListItem3;
                boolean z3 = this.j;
                this.d = z3;
                this.e = 1;
                if (((ag8) r26).b(this) != r1) {
                    r9 = r26;
                    z = z3;
                    mdbListItem = mdbListItem3;
                }
                return r1;
            }
            if (r25 != 1) {
                if (r25 != 2) {
                    if (r25 == 3) {
                        xf8 xf8Var = this.a;
                        s38.b(obj);
                        r22 = xf8Var;
                        contentItem = (ContentItem) obj;
                        r23 = r22;
                        contentItem2 = contentItem;
                        r2 = r23;
                        r2.release();
                        return contentItem2;
                    }
                    if (r25 != 4) {
                        throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                    }
                    xf8 xf8Var2 = this.a;
                    s38.b(obj);
                    r24 = xf8Var2;
                    contentItem = (ContentItem) obj;
                    r23 = r24;
                    contentItem2 = contentItem;
                    r2 = r23;
                    r2.release();
                    return contentItem2;
                }
                boolean z4 = this.d;
                mdbListItem2 = this.c;
                UserCollectionContentViewModel userCollectionContentViewModel3 = (UserCollectionContentViewModel) this.b;
                xf8 xf8Var3 = this.a;
                try {
                    s38.b(obj);
                    z2 = z4;
                    r25 = xf8Var3;
                    userCollectionContentViewModel2 = userCollectionContentViewModel3;
                    try {
                        num = (Integer) obj;
                        r2 = r25;
                        if (num != null) {
                            int iIntValue = num.intValue();
                            if (z2) {
                                String title = mdbListItem2.getTitle();
                                Integer year = mdbListItem2.getYear();
                                this.a = r25;
                                this.b = mdbListItem2;
                                this.c = null;
                                this.e = 3;
                                obj = UserCollectionContentViewModel.e(userCollectionContentViewModel2, iIntValue, title, year, this);
                                if (obj != r1) {
                                    r22 = r25;
                                    contentItem = (ContentItem) obj;
                                    r23 = r22;
                                    contentItem2 = contentItem;
                                    r2 = r23;
                                }
                            } else {
                                String title2 = mdbListItem2.getTitle();
                                Integer year2 = mdbListItem2.getYear();
                                this.a = r25;
                                this.b = mdbListItem2;
                                this.c = null;
                                this.e = 4;
                                obj = UserCollectionContentViewModel.f(userCollectionContentViewModel2, iIntValue, title2, year2, this);
                                if (obj != r1) {
                                    r24 = r25;
                                    contentItem = (ContentItem) obj;
                                    r23 = r24;
                                    contentItem2 = contentItem;
                                    r2 = r23;
                                }
                            }
                            return r1;
                        }
                    } catch (Exception e2) {
                        e = e2;
                        r1 = mdbListItem2;
                        Log.w("UserCollectionVM", "Failed to enrich MDBList item " + r1.getImdbId(), e);
                        r2 = r25;
                    }
                } catch (CancellationException e3) {
                    throw e3;
                } catch (Exception e4) {
                    e = e4;
                    r1 = mdbListItem2;
                    r25 = xf8Var3;
                    Log.w("UserCollectionVM", "Failed to enrich MDBList item " + r1.getImdbId(), e);
                    r2 = r25;
                    r2.release();
                    return contentItem2;
                } catch (Throwable th2) {
                    th = th2;
                    r25 = xf8Var3;
                    r25.release();
                    throw th;
                }
                r2.release();
                return contentItem2;
            }
            z = this.d;
            mdbListItem = this.c;
            UserCollectionContentViewModel userCollectionContentViewModel4 = (UserCollectionContentViewModel) this.b;
            xf8 xf8Var4 = this.a;
            s38.b(obj);
            userCollectionContentViewModel = userCollectionContentViewModel4;
            r9 = xf8Var4;
            String imdbId = mdbListItem.getImdbId();
            this.a = r9;
            this.b = userCollectionContentViewModel;
            this.c = mdbListItem;
            this.d = z;
            this.e = 2;
            Object objG = UserCollectionContentViewModel.g(userCollectionContentViewModel, imdbId, z, this);
            if (objG != r1) {
                userCollectionContentViewModel2 = userCollectionContentViewModel;
                obj = objG;
                mdbListItem2 = mdbListItem;
                z2 = z;
                r25 = r9;
                num = (Integer) obj;
                r2 = r25;
                if (num != null) {
                }
                r2.release();
                return contentItem2;
            }
            return r1;
        } catch (CancellationException e5) {
            throw e5;
        }
    }
}
