package com.strmr.ps.data.service;

import com.strmr.ps.data.local.dao.MediaDao;
import com.strmr.ps.data.service.TmdbEnrichmentService;
import defpackage.ak1;
import defpackage.ck1;
import defpackage.e6a;
import defpackage.gr3;
import defpackage.q81;
import defpackage.s38;
import defpackage.s81;
import defpackage.vx8;
import defpackage.zg0;
import java.util.ArrayList;
import java.util.Iterator;
import kotlin.Metadata;
import kotlin.coroutines.Continuation;
import kotlin.coroutines.jvm.internal.Boxing;
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\u00020\u0001*\u00020\u0000H\n¢\u0006\u0004\b\u0002\u0010\u0003"}, d2 = {"Lak1;", "Le6a;", "<anonymous>", "(Lak1;)V"}, k = 3, mv = {2, 0, 0})
@DebugMetadata(c = "com.strmr.ps.data.service.TmdbEnrichmentService$preload$1", f = "TmdbEnrichmentService.kt", i = {0}, l = {176, 179}, m = "invokeSuspend", n = {"tmdbId"}, s = {"I$0"})
@vx8
final class ad extends SuspendLambda implements gr3<ak1, Continuation<? super e6a>, Object> {
    public TmdbEnrichmentService a;
    public TmdbEnrichmentService.b b;
    public Iterator c;
    public int d;
    public int e;
    public final /* synthetic */ ArrayList f;
    public final /* synthetic */ TmdbEnrichmentService i;
    public final /* synthetic */ TmdbEnrichmentService.b j;

    /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
    public ad(ArrayList arrayList, TmdbEnrichmentService tmdbEnrichmentService, TmdbEnrichmentService.b bVar, Continuation continuation) {
        super(2, continuation);
        this.f = arrayList;
        this.i = tmdbEnrichmentService;
        this.j = bVar;
    }

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

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

    /* JADX WARN: Removed duplicated region for block: B:13:0x003e  */
    /* JADX WARN: Removed duplicated region for block: B:20:0x006f  */
    /* JADX WARN: Removed duplicated region for block: B:25:0x0098  */
    /* JADX WARN: Unsupported multi-entry loop pattern (BACK_EDGE: B:23:0x0092 -> B:24:0x0095). Please report as a decompilation issue!!! */
    /* JADX WARN: Unsupported multi-entry loop pattern (BACK_EDGE: B:25:0x0098 -> B:11:0x0038). Please report as a decompilation issue!!! */
    @Override // kotlin.coroutines.jvm.internal.BaseContinuationImpl
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object invokeSuspend(Object obj) {
        Iterator it;
        TmdbEnrichmentService tmdbEnrichmentService;
        TmdbEnrichmentService.b bVar;
        TmdbEnrichmentService tmdbEnrichmentService2;
        TmdbEnrichmentService.b bVar2;
        Iterator it2;
        int i;
        ck1 ck1Var = ck1.a;
        int i2 = this.e;
        if (i2 == 0) {
            s38.b(obj);
            it = this.f.iterator();
            tmdbEnrichmentService = this.i;
            bVar = this.j;
            while (it.hasNext()) {
            }
            return e6a.a;
        }
        if (i2 != 1) {
            if (i2 != 2) {
                throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
            }
            Iterator it3 = this.c;
            bVar = this.b;
            TmdbEnrichmentService tmdbEnrichmentService3 = this.a;
            s38.b(obj);
            it = it3;
            tmdbEnrichmentService = tmdbEnrichmentService3;
            while (it.hasNext()) {
                int iIntValue = ((Number) it.next()).intValue();
                if (tmdbEnrichmentService.e.get(Boxing.boxInt(iIntValue)) == null) {
                    MediaDao mediaDao = tmdbEnrichmentService.b;
                    this.a = tmdbEnrichmentService;
                    this.b = bVar;
                    this.c = it;
                    this.d = iIntValue;
                    this.e = 1;
                    Object enrichmentByTmdbId = mediaDao.getEnrichmentByTmdbId(iIntValue, this);
                    if (enrichmentByTmdbId != ck1Var) {
                        TmdbEnrichmentService.b bVar3 = bVar;
                        it2 = it;
                        obj = enrichmentByTmdbId;
                        tmdbEnrichmentService2 = tmdbEnrichmentService;
                        i = iIntValue;
                        bVar2 = bVar3;
                        if (obj != null) {
                            q81 q81VarA = s81.a();
                            tmdbEnrichmentService2.e.put(Boxing.boxInt(i), q81VarA);
                            zg0 zg0Var = tmdbEnrichmentService2.f;
                            TmdbEnrichmentService.c cVar = new TmdbEnrichmentService.c(i, bVar2, q81VarA);
                            this.a = tmdbEnrichmentService2;
                            this.b = bVar2;
                            this.c = it2;
                            this.e = 2;
                            if (zg0Var.s(cVar, this) != ck1Var) {
                                it3 = it2;
                                bVar = bVar2;
                                tmdbEnrichmentService3 = tmdbEnrichmentService2;
                                it = it3;
                                tmdbEnrichmentService = tmdbEnrichmentService3;
                                while (it.hasNext()) {
                                }
                            }
                        } else {
                            it = it2;
                            bVar = bVar2;
                            tmdbEnrichmentService = tmdbEnrichmentService2;
                            while (it.hasNext()) {
                            }
                        }
                    }
                    return ck1Var;
                }
            }
            return e6a.a;
        }
        i = this.d;
        it2 = this.c;
        bVar2 = this.b;
        tmdbEnrichmentService2 = this.a;
        s38.b(obj);
        if (obj != null) {
        }
    }
}
