package com.strmr.ps.ui.search;

import android.util.Log;
import com.strmr.ps.data.local.dao.RowConfigDao;
import com.strmr.ps.data.local.entity.RowConfigEntity;
import defpackage.ak1;
import defpackage.ck1;
import defpackage.cr4;
import defpackage.e6a;
import defpackage.gr3;
import defpackage.ig6;
import defpackage.ik2;
import defpackage.m02;
import defpackage.m12;
import defpackage.od;
import defpackage.s38;
import defpackage.sc2;
import defpackage.vx8;
import defpackage.wj0;
import defpackage.y41;
import java.util.ArrayList;
import java.util.Iterator;
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\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.ui.search.SearchViewModel$loadAddonSearchRows$1", f = "SearchViewModel.kt", i = {}, l = {125, 127}, m = "invokeSuspend", n = {}, s = {})
@vx8
final class f extends SuspendLambda implements gr3<ak1, Continuation<? super e6a>, Object> {
    public int a;
    public final /* synthetic */ SearchViewModel b;

    /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
    public f(SearchViewModel searchViewModel, Continuation continuation) {
        super(2, continuation);
        this.b = searchViewModel;
    }

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

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

    /* JADX WARN: Code restructure failed: missing block: B:22:0x0047, code lost:
    
        if (r8 == r0) goto L23;
     */
    @Override // kotlin.coroutines.jvm.internal.BaseContinuationImpl
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final Object invokeSuspend(Object obj) throws Throwable {
        ck1 ck1Var = ck1.a;
        int i = this.a;
        e6a e6aVar = e6a.a;
        SearchViewModel searchViewModel = this.b;
        try {
            if (i == 0) {
                s38.b(obj);
                this.a = 1;
                m12 m12Var = sc2.a;
                Object objF = wj0.f(m02.c, new e(searchViewModel, null), this);
                if (objF != ck1Var) {
                    objF = e6aVar;
                }
                if (objF == ck1Var) {
                }
                return ck1Var;
            }
            if (i != 1) {
                if (i != 2) {
                    throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                }
                s38.b(obj);
                ArrayList arrayList = new ArrayList();
                for (Object obj2 : (Iterable) obj) {
                    RowConfigEntity rowConfigEntity = (RowConfigEntity) obj2;
                    if (cr4.b(rowConfigEntity.getRowType(), "addon_search") && rowConfigEntity.getEnabled()) {
                        arrayList.add(obj2);
                    }
                }
                ig6 ig6Var = searchViewModel.s;
                ArrayList arrayList2 = new ArrayList(y41.p(arrayList, 10));
                Iterator it = arrayList.iterator();
                while (it.hasNext()) {
                    arrayList2.add(new od((RowConfigEntity) it.next(), ik2.a));
                }
                ig6Var.setValue(arrayList2);
                arrayList.size();
                return e6aVar;
            }
            s38.b(obj);
            RowConfigDao rowConfigDao = searchViewModel.c;
            this.a = 2;
            obj = rowConfigDao.getAllRowsForScreenSync("search", this);
        } catch (Exception e) {
            Log.e("SearchViewModel", "Failed to load addon search rows: " + e.getMessage());
            return e6aVar;
        }
    }
}
