package com.ss.android.ugc.aweme.poi.videolist;

import X.4HR;
import X.4r1;
import X.BEA;
import X.C3266BDq;
import X.C3277BEb;
import X.C3278BEc;
import X.C3279BEd;
import X.C3288BEm;
import X.DWM;
import X.DaP;
import X.M12;
import X.TnV;
import com.bytedance.covode.number.Covode;
import com.ss.android.ugc.aweme.detail.vm.BaseDetailShareVM;
import com.ss.android.ugc.aweme.feed.model.Aweme;
import java.util.Iterator;
import java.util.List;
import kotlin.h.b.n;

public final class PoiVideoListSharedViewModel extends BaseDetailShareVM<C3277BEb, C3266BDq, Long> {
    public static final C3288BEm LJI = new C3288BEm((byte) 0);
    public String LIZ;
    public BEA LIZIZ;
    public C3278BEc LIZJ;
    public long LIZLLL;
    public boolean LJ;
    public boolean LJFF;

    static {
        Covode.recordClassIndex(97575);
    }

    public final int getPageType(int i) {
        return 44;
    }

    public final /* synthetic */ 4HR defaultState() {
        return new C3277BEb();
    }

    public final /* synthetic */ Aweme getAwemeFromItem(DaP daP) {
        C3266BDq bDq = (C3266BDq) daP;
        M12.LIZ(bDq);
        return bDq.LIZIZ;
    }

    public final void newState(DWM<C3266BDq> dwm) {
        M12.LIZ(dwm);
        setState(new C3279BEd(this, dwm));
    }

    public final int deleteItemByAid(String str) {
        M12.LIZ(str);
        List listGetAll = listGetAll();
        int i = -1;
        if (listGetAll != null) {
            int i2 = 0;
            Iterator it = listGetAll.iterator();
            while (true) {
                if (!it.hasNext()) {
                    break;
                } else if (n.LIZ(((C3266BDq) it.next()).LIZIZ.getAid(), str)) {
                    i = i2;
                    if (i >= 0) {
                        listRemoveItemAt(i);
                    }
                } else {
                    i2++;
                }
            }
        }
        return i;
    }

    /* JADX WARNING: Removed duplicated region for block: B:13:0x003a  */
    /* JADX WARNING: Removed duplicated region for block: B:28:0x0091 A[Catch:{ Exception -> 0x0098 }, RETURN] */
    /* JADX WARNING: Removed duplicated region for block: B:7:0x001e  */
    /* Code decompiled incorrectly, please refer to instructions dump. */
    public final java.lang.Object onRefresh(X.4r1<? super X.C0479A4l<java.lang.Long>> r10) {
        /*
            r9 = this;
            boolean r0 = r10 instanceof X.C3286BEk
            if (r0 == 0) goto L_0x0023
            r6 = r10
            X.BEk r6 = (X.C3286BEk) r6
            int r0 = r6.label
            r1 = -2147483648(0xffffffff80000000, float:-0.0)
            r0 = r0 & r1
            if (r0 == 0) goto L_0x0023
            int r0 = r6.label
            int r0 = r0 - r1
            r6.label = r0
        L_0x0013:
            java.lang.Object r1 = r6.result
            X.Cof r7 = X.Cof.COROUTINE_SUSPENDED
            int r0 = r6.label
            r4 = 0
            r3 = 2
            r5 = 1
            if (r0 == 0) goto L_0x003a
            if (r0 == r5) goto L_0x0031
            if (r0 != r3) goto L_0x0029
            goto L_0x0092
        L_0x0023:
            X.BEk r6 = new X.BEk
            r6.<init>(r9, r10)
            goto L_0x0013
        L_0x0029:
            java.lang.IllegalStateException r1 = new java.lang.IllegalStateException
            java.lang.String r0 = "call to 'resume' before 'invoke' with coroutine"
            r1.<init>(r0)
            throw r1
        L_0x0031:
            java.lang.Object r0 = r6.L$1
            com.ss.android.ugc.aweme.poi.videolist.PoiVideoListSharedViewModel r0 = (com.ss.android.ugc.aweme.poi.videolist.PoiVideoListSharedViewModel) r0
            java.lang.Object r8 = r6.L$0
            com.ss.android.ugc.aweme.poi.videolist.PoiVideoListSharedViewModel r8 = (com.ss.android.ugc.aweme.poi.videolist.PoiVideoListSharedViewModel) r8
            goto L_0x007b
        L_0x003a:
            X.2th.LIZ(r1)
            X.8qM r1 = X.2K7.LIZ     // Catch:{ Exception -> 0x0098 }
            java.lang.String r0 = ""
            kotlin.h.b.n.LIZIZ(r1, r0)     // Catch:{ Exception -> 0x0098 }
            X.DcP r1 = r1.LIZIZ     // Catch:{ Exception -> 0x0098 }
            X.DcP r0 = X.DcP.AVAILABLE     // Catch:{ Exception -> 0x0098 }
            if (r1 == r0) goto L_0x0058
            r9.LJ = r4     // Catch:{ Exception -> 0x0098 }
            X.A4n r1 = X.C0479A4l.LIZ     // Catch:{ Exception -> 0x0098 }
            java.lang.Exception r0 = new java.lang.Exception     // Catch:{ Exception -> 0x0098 }
            r0.<init>()     // Catch:{ Exception -> 0x0098 }
            X.A4m r1 = r1.LIZ((java.lang.Exception) r0)     // Catch:{ Exception -> 0x0098 }
            goto L_0x00b4
        L_0x0058:
            r9.LJ = r5     // Catch:{ Exception -> 0x0098 }
            X.BEj r0 = com.ss.android.ugc.aweme.poi.videolist.PoiListApi.LIZ     // Catch:{ Exception -> 0x0098 }
            com.ss.android.ugc.aweme.poi.videolist.PoiListApi r1 = r0.LIZ()     // Catch:{ Exception -> 0x0098 }
            java.lang.String r0 = r9.LIZ     // Catch:{ Exception -> 0x0098 }
            if (r0 != 0) goto L_0x0067
            kotlin.h.b.n.LIZIZ()     // Catch:{ Exception -> 0x0098 }
        L_0x0067:
            X.PgU r0 = r1.getPoiDetail(r0)     // Catch:{ Exception -> 0x0098 }
            r6.L$0 = r9     // Catch:{ Exception -> 0x0098 }
            r6.L$1 = r9     // Catch:{ Exception -> 0x0098 }
            r6.label = r5     // Catch:{ Exception -> 0x0098 }
            java.lang.Object r1 = X.F3Z.LIZ(r0, r6)     // Catch:{ Exception -> 0x0098 }
            if (r1 != r7) goto L_0x0078
            return r7
        L_0x0078:
            r0 = r9
            r8 = r0
            goto L_0x007e
        L_0x007b:
            X.2th.LIZ(r1)     // Catch:{ Exception -> 0x0098 }
        L_0x007e:
            X.BEA r1 = (X.BEA) r1     // Catch:{ Exception -> 0x0098 }
            r0.LIZIZ = r1     // Catch:{ Exception -> 0x0098 }
            r1 = 0
            r0 = 0
            r6.L$0 = r0     // Catch:{ Exception -> 0x0098 }
            r6.L$1 = r0     // Catch:{ Exception -> 0x0098 }
            r6.label = r3     // Catch:{ Exception -> 0x0098 }
            java.lang.Object r1 = r8.LIZ(r1, r6)     // Catch:{ Exception -> 0x0098 }
            if (r1 != r7) goto L_0x0095
            return r7
        L_0x0092:
            X.2th.LIZ(r1)     // Catch:{ Exception -> 0x0098 }
        L_0x0095:
            X.A4l r1 = (X.C0479A4l) r1     // Catch:{ Exception -> 0x0098 }
            goto L_0x00b4
        L_0x0098:
            r3 = move-exception
            X.Cwu[] r2 = new X.Cwu[r5]
            boolean r0 = r3 instanceof com.google.gson.s
            java.lang.Boolean r1 = java.lang.Boolean.valueOf(r0)
            java.lang.String r0 = "json_error"
            X.Cwu r0 = X.CwZ.LIZ(r1, r0)
            r2[r4] = r0
            java.lang.String r0 = "poi_video_list_error"
            X.2nK.LIZ(r0, r2)
            X.A4n r0 = X.C0479A4l.LIZ
            X.A4m r1 = r0.LIZ((java.lang.Exception) r3)
        L_0x00b4:
            return r1
        */
        throw new UnsupportedOperationException("Method not decompiled: com.ss.android.ugc.aweme.poi.videolist.PoiVideoListSharedViewModel.onRefresh(X.4r1):java.lang.Object");
    }

    public final /* synthetic */ Object onLoadMore(Object obj, 4r1 r4) {
        return LIZ(((Number) obj).longValue(), r4);
    }

    /* JADX WARNING: Removed duplicated region for block: B:12:0x0032  */
    /* JADX WARNING: Removed duplicated region for block: B:27:0x007e A[Catch:{ Exception -> 0x00d6 }] */
    /* JADX WARNING: Removed duplicated region for block: B:31:0x00a9 A[Catch:{ Exception -> 0x00d6 }] */
    /* JADX WARNING: Removed duplicated region for block: B:35:0x00b2 A[Catch:{ Exception -> 0x00d6 }] */
    /* JADX WARNING: Removed duplicated region for block: B:38:0x00bf A[Catch:{ Exception -> 0x00d6 }] */
    /* JADX WARNING: Removed duplicated region for block: B:7:0x001d  */
    /* Code decompiled incorrectly, please refer to instructions dump. */
    public final java.lang.Object LIZ(long r10, X.4r1<? super X.C0479A4l<java.lang.Long>> r12) {
        /*
            r9 = this;
            boolean r0 = r12 instanceof X.C3287BEl
            if (r0 == 0) goto L_0x0024
            r3 = r12
            X.BEl r3 = (X.C3287BEl) r3
            int r0 = r3.label
            r1 = -2147483648(0xffffffff80000000, float:-0.0)
            r0 = r0 & r1
            if (r0 == 0) goto L_0x0024
            int r0 = r3.label
            int r0 = r0 - r1
            r3.label = r0
        L_0x0013:
            java.lang.Object r6 = r3.result
            X.Cof r7 = X.Cof.COROUTINE_SUSPENDED
            int r0 = r3.label
            r4 = 0
            r5 = 1
            if (r0 == 0) goto L_0x0032
            if (r0 != r5) goto L_0x002a
            java.lang.Object r7 = r3.L$0
            com.ss.android.ugc.aweme.poi.videolist.PoiVideoListSharedViewModel r7 = (com.ss.android.ugc.aweme.poi.videolist.PoiVideoListSharedViewModel) r7
            goto L_0x0073
        L_0x0024:
            X.BEl r3 = new X.BEl
            r3.<init>(r9, r12)
            goto L_0x0013
        L_0x002a:
            java.lang.IllegalStateException r1 = new java.lang.IllegalStateException
            java.lang.String r0 = "call to 'resume' before 'invoke' with coroutine"
            r1.<init>(r0)
            throw r1
        L_0x0032:
            X.2th.LIZ(r6)
            X.8qM r1 = X.2K7.LIZ     // Catch:{ Exception -> 0x00d6 }
            java.lang.String r0 = ""
            kotlin.h.b.n.LIZIZ(r1, r0)     // Catch:{ Exception -> 0x00d6 }
            X.DcP r1 = r1.LIZIZ     // Catch:{ Exception -> 0x00d6 }
            X.DcP r0 = X.DcP.AVAILABLE     // Catch:{ Exception -> 0x00d6 }
            if (r1 == r0) goto L_0x0051
            r9.LJFF = r4     // Catch:{ Exception -> 0x00d6 }
            X.A4n r1 = X.C0479A4l.LIZ     // Catch:{ Exception -> 0x00d6 }
            java.lang.Exception r0 = new java.lang.Exception     // Catch:{ Exception -> 0x00d6 }
            r0.<init>()     // Catch:{ Exception -> 0x00d6 }
            X.A4m r0 = r1.LIZ((java.lang.Exception) r0)     // Catch:{ Exception -> 0x00d6 }
            goto L_0x00f2
        L_0x0051:
            r9.LJFF = r5     // Catch:{ Exception -> 0x00d6 }
            X.BEj r0 = com.ss.android.ugc.aweme.poi.videolist.PoiListApi.LIZ     // Catch:{ Exception -> 0x00d6 }
            com.ss.android.ugc.aweme.poi.videolist.PoiListApi r2 = r0.LIZ()     // Catch:{ Exception -> 0x00d6 }
            java.lang.String r1 = r9.LIZ     // Catch:{ Exception -> 0x00d6 }
            if (r1 != 0) goto L_0x0060
            kotlin.h.b.n.LIZIZ()     // Catch:{ Exception -> 0x00d6 }
        L_0x0060:
            r0 = 18
            X.PgU r0 = r2.getPoiVideoList(r1, r10, r0)     // Catch:{ Exception -> 0x00d6 }
            r3.L$0 = r9     // Catch:{ Exception -> 0x00d6 }
            r3.label = r5     // Catch:{ Exception -> 0x00d6 }
            java.lang.Object r6 = X.F3Z.LIZ(r0, r3)     // Catch:{ Exception -> 0x00d6 }
            if (r6 != r7) goto L_0x0071
            return r7
        L_0x0071:
            r7 = r9
            goto L_0x0076
        L_0x0073:
            X.2th.LIZ(r6)     // Catch:{ Exception -> 0x00d6 }
        L_0x0076:
            X.BEc r6 = (X.C3278BEc) r6     // Catch:{ Exception -> 0x00d6 }
            r7.LIZJ = r6     // Catch:{ Exception -> 0x00d6 }
            java.util.List<com.ss.android.ugc.aweme.feed.model.Aweme> r1 = r6.LIZ     // Catch:{ Exception -> 0x00d6 }
            if (r1 == 0) goto L_0x00a9
            java.util.ArrayList r3 = new java.util.ArrayList     // Catch:{ Exception -> 0x00d6 }
            r0 = 10
            int r0 = X.9HM.LIZ(r1, r0)     // Catch:{ Exception -> 0x00d6 }
            r3.<init>(r0)     // Catch:{ Exception -> 0x00d6 }
            java.util.Iterator r8 = r1.iterator()     // Catch:{ Exception -> 0x00d6 }
        L_0x008d:
            boolean r0 = r8.hasNext()     // Catch:{ Exception -> 0x00d6 }
            if (r0 == 0) goto L_0x00ac
            java.lang.Object r2 = r8.next()     // Catch:{ Exception -> 0x00d6 }
            com.ss.android.ugc.aweme.feed.model.Aweme r2 = (com.ss.android.ugc.aweme.feed.model.Aweme) r2     // Catch:{ Exception -> 0x00d6 }
            com.ss.android.ugc.aweme.feed.model.LogPbBean r0 = r6.LIZLLL     // Catch:{ Exception -> 0x00d6 }
            r2.setLogPbBean(r0)     // Catch:{ Exception -> 0x00d6 }
            X.BDq r1 = new X.BDq     // Catch:{ Exception -> 0x00d6 }
            java.lang.String r0 = r7.LIZ     // Catch:{ Exception -> 0x00d6 }
            r1.<init>(r0, r2)     // Catch:{ Exception -> 0x00d6 }
            r3.add(r1)     // Catch:{ Exception -> 0x00d6 }
            goto L_0x008d
        L_0x00a9:
            X.Lel r3 = X.Lel.INSTANCE     // Catch:{ Exception -> 0x00d6 }
            goto L_0x00ae
        L_0x00ac:
            java.util.List r3 = (java.util.List) r3     // Catch:{ Exception -> 0x00d6 }
        L_0x00ae:
            java.lang.Integer r0 = r6.LIZJ     // Catch:{ Exception -> 0x00d6 }
            if (r0 != 0) goto L_0x00b9
        L_0x00b2:
            X.A4n r0 = X.C0479A4l.LIZ     // Catch:{ Exception -> 0x00d6 }
            X.A4o r0 = r0.LIZ((java.util.List<? extends X.DaP>) r3)     // Catch:{ Exception -> 0x00d6 }
            goto L_0x00f2
        L_0x00b9:
            int r0 = r0.intValue()     // Catch:{ Exception -> 0x00d6 }
            if (r0 != r5) goto L_0x00b2
            java.lang.Long r0 = r6.LIZIZ     // Catch:{ Exception -> 0x00d6 }
            if (r0 == 0) goto L_0x00d3
            long r0 = r0.longValue()     // Catch:{ Exception -> 0x00d6 }
        L_0x00c7:
            r7.LIZLLL = r0     // Catch:{ Exception -> 0x00d6 }
            X.A4n r2 = X.C0479A4l.LIZ     // Catch:{ Exception -> 0x00d6 }
            r1 = 0
            java.lang.Long r0 = r6.LIZIZ     // Catch:{ Exception -> 0x00d6 }
            X.A4p r0 = X.C0481A4n.LIZ(r2, r1, r0, r3, r5)     // Catch:{ Exception -> 0x00d6 }
            goto L_0x00f2
        L_0x00d3:
            r0 = 0
            goto L_0x00c7
        L_0x00d6:
            r3 = move-exception
            X.Cwu[] r2 = new X.Cwu[r5]
            boolean r0 = r3 instanceof com.google.gson.s
            java.lang.Boolean r1 = java.lang.Boolean.valueOf(r0)
            java.lang.String r0 = "json_error"
            X.Cwu r0 = X.CwZ.LIZ(r1, r0)
            r2[r4] = r0
            java.lang.String r0 = "poi_video_list_error"
            X.2nK.LIZ(r0, r2)
            X.A4n r0 = X.C0479A4l.LIZ
            X.A4m r0 = r0.LIZ((java.lang.Exception) r3)
        L_0x00f2:
            return r0
        */
        throw new UnsupportedOperationException("Method not decompiled: com.ss.android.ugc.aweme.poi.videolist.PoiVideoListSharedViewModel.LIZ(long, X.4r1):java.lang.Object");
    }

    public final /* synthetic */ Object getCursorByFeedParam(int i, TnV tnV, int i2, boolean z) {
        M12.LIZ(tnV);
        return Long.valueOf(this.LIZLLL);
    }
}
