package com.ss.android.ugc.aweme.profile.assem.VM;

import X.1Bn;
import X.1hK;
import X.2K7;
import X.4HR;
import X.4r1;
import X.C0479A4l;
import X.C1914Aju;
import X.C2274Api;
import X.C2275Apj;
import X.C2281App;
import X.C2282Apq;
import X.Crj;
import X.D65;
import X.DWM;
import X.KEM;
import X.M12;
import androidx.fragment.app.Fragment;
import com.bytedance.covode.number.Covode;
import com.bytedance.ext_power_list.AssemListViewModel;
import com.ss.android.ugc.aweme.commercialize.profile.talent.ITalentAdRevenueShareService;
import com.ss.android.ugc.aweme.commercialize.profile.talent.TalentAdRevenueShareServiceImpl;
import com.ss.android.ugc.aweme.feed.model.Aweme;
import com.ss.android.ugc.aweme.feed.model.AwemeRawAd;
import java.util.ArrayList;
import java.util.List;
import kotlin.h.b.n;

public final class MyVideoListVM extends AssemListViewModel<C2274Api, C1914Aju, Long> {
    public static final C2281App LJ = new C2281App((byte) 0);
    public String LIZ;
    public String LIZIZ;
    public final 1Bn<List<C1914Aju>> LIZJ = new 1Bn<>();
    public Fragment LIZLLL;
    public final Crj LJFF = D65.LIZ(this, KEM.LIZ.LIZ(C2282Apq.class));

    static {
        Covode.recordClassIndex(98328);
    }

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

    public static boolean LIZ() {
        try {
            return 2K7.LIZ.LIZJ();
        } catch (Exception unused) {
            return false;
        }
    }

    public final 1hK LIZIZ() {
        Fragment fragment = this.LIZLLL;
        if (fragment != null) {
            return fragment.getActivity();
        }
        return null;
    }

    public final void LIZ(List<C1914Aju> list) {
        this.LIZJ.setValue(list);
    }

    public final void newState(DWM<C1914Aju> dwm) {
        M12.LIZ(dwm);
        setState(new C2275Apj(dwm));
    }

    public final Object onRefresh(4r1<? super C0479A4l<Long>> r7) {
        return LIZ(0, this.LIZIZ, 20, r7);
    }

    private final List<Aweme> LIZIZ(List<? extends Aweme> list) {
        ITalentAdRevenueShareService LJ2 = TalentAdRevenueShareServiceImpl.LJ();
        if (list == null || LJ2 == null || LJ2.LIZIZ() == null || LJ2.LIZIZ().isEmpty()) {
            return list;
        }
        ArrayList arrayList = new ArrayList();
        for (Aweme next : list) {
            if (next != null) {
                if (next.getAwemeRawAd() != null) {
                    List LIZIZ2 = LJ2.LIZIZ();
                    AwemeRawAd awemeRawAd = next.getAwemeRawAd();
                    if (awemeRawAd == null) {
                        n.LIZIZ();
                    }
                    n.LIZIZ(awemeRawAd, "");
                    if (LIZIZ2.contains(awemeRawAd.getCreativeIdStr())) {
                    }
                }
                arrayList.add(next);
            }
        }
        return arrayList;
    }

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

    /* JADX WARNING: Removed duplicated region for block: B:14:0x0043  */
    /* JADX WARNING: Removed duplicated region for block: B:23:0x0086 A[Catch:{ Exception -> 0x00e0 }, RETURN] */
    /* JADX WARNING: Removed duplicated region for block: B:31:0x00ae A[Catch:{ Exception -> 0x00e0 }] */
    /* JADX WARNING: Removed duplicated region for block: B:36:0x00c5 A[Catch:{ Exception -> 0x00e0 }] */
    /* JADX WARNING: Removed duplicated region for block: B:40:0x00d9 A[Catch:{ Exception -> 0x00e0 }] */
    /* JADX WARNING: Removed duplicated region for block: B:7:0x001f  */
    /* Code decompiled incorrectly, please refer to instructions dump. */
    public final java.lang.Object LIZ(long r10, java.lang.String r12, int r13, X.4r1<? super X.C0479A4l<java.lang.Long>> r14) {
        /*
            r9 = this;
            boolean r0 = r14 instanceof X.C2278Apm
            if (r0 == 0) goto L_0x002c
            r6 = r14
            X.Apm r6 = (X.C2278Apm) r6
            int r0 = r6.label
            r1 = -2147483648(0xffffffff80000000, float:-0.0)
            r0 = r0 & r1
            if (r0 == 0) goto L_0x002c
            int r0 = r6.label
            int r0 = r0 - r1
            r6.label = r0
        L_0x0013:
            java.lang.Object r5 = r6.result
            X.Cof r8 = X.Cof.COROUTINE_SUSPENDED
            int r0 = r6.label
            java.lang.String r2 = ""
            r1 = 2
            r4 = 1
            if (r0 == 0) goto L_0x0043
            if (r0 == r4) goto L_0x003a
            if (r0 != r1) goto L_0x0032
            java.lang.Object r3 = r6.L$1
            java.util.ArrayList r3 = (java.util.ArrayList) r3
            java.lang.Object r7 = r6.L$0
            com.ss.android.ugc.aweme.profile.assem.VM.MyVideoListVM r7 = (com.ss.android.ugc.aweme.profile.assem.VM.MyVideoListVM) r7
            goto L_0x0087
        L_0x002c:
            X.Apm r6 = new X.Apm
            r6.<init>(r9, r14)
            goto L_0x0013
        L_0x0032:
            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_0x003a:
            java.lang.Object r3 = r6.L$1
            java.util.ArrayList r3 = (java.util.ArrayList) r3
            java.lang.Object r7 = r6.L$0
            com.ss.android.ugc.aweme.profile.assem.VM.MyVideoListVM r7 = (com.ss.android.ugc.aweme.profile.assem.VM.MyVideoListVM) r7
            goto L_0x0068
        L_0x0043:
            X.2th.LIZ(r5)
            java.util.ArrayList r3 = new java.util.ArrayList     // Catch:{ Exception -> 0x00e0 }
            r3.<init>()     // Catch:{ Exception -> 0x00e0 }
            X.Crj r0 = r9.LJFF     // Catch:{ Exception -> 0x00e0 }
            java.lang.Object r0 = r0.getValue()     // Catch:{ Exception -> 0x00e0 }
            X.Cw3 r0 = (X.Cw3) r0     // Catch:{ Exception -> 0x00e0 }
            X.2eS r0 = r0.getOperator()     // Catch:{ Exception -> 0x00e0 }
            X.Apo r0 = (X.C2280Apo) r0     // Catch:{ Exception -> 0x00e0 }
            r6.L$0 = r9     // Catch:{ Exception -> 0x00e0 }
            r6.L$1 = r3     // Catch:{ Exception -> 0x00e0 }
            r6.label = r4     // Catch:{ Exception -> 0x00e0 }
            java.lang.Object r5 = r0.LIZ(r10, r12, r13)     // Catch:{ Exception -> 0x00e0 }
            if (r5 != r8) goto L_0x0066
            return r8
        L_0x0066:
            r7 = r9
            goto L_0x006b
        L_0x0068:
            X.2th.LIZ(r5)     // Catch:{ Exception -> 0x00e0 }
        L_0x006b:
            X.PgU r5 = (X.PgU) r5     // Catch:{ Exception -> 0x00e0 }
            X.PlG r0 = X.PlI.LIZJ     // Catch:{ Exception -> 0x00e0 }
            X.PlG r0 = X.PhE.LIZIZ(r0)     // Catch:{ Exception -> 0x00e0 }
            X.PgU r0 = r5.LIZIZ(r0)     // Catch:{ Exception -> 0x00e0 }
            kotlin.h.b.n.LIZIZ(r0, r2)     // Catch:{ Exception -> 0x00e0 }
            r6.L$0 = r7     // Catch:{ Exception -> 0x00e0 }
            r6.L$1 = r3     // Catch:{ Exception -> 0x00e0 }
            r6.label = r1     // Catch:{ Exception -> 0x00e0 }
            java.lang.Object r5 = X.F3Z.LIZ(r0, r6)     // Catch:{ Exception -> 0x00e0 }
            if (r5 != r8) goto L_0x008a
            return r8
        L_0x0087:
            X.2th.LIZ(r5)     // Catch:{ Exception -> 0x00e0 }
        L_0x008a:
            com.ss.android.ugc.aweme.feed.model.FeedItemList r5 = (com.ss.android.ugc.aweme.feed.model.FeedItemList) r5     // Catch:{ Exception -> 0x00e0 }
            kotlin.h.b.n.LIZIZ(r5, r2)     // Catch:{ Exception -> 0x00e0 }
            java.util.List r0 = r5.getItems()     // Catch:{ Exception -> 0x00e0 }
            java.util.List r1 = r7.LIZIZ(r0)     // Catch:{ Exception -> 0x00e0 }
            r6 = 0
            if (r1 == 0) goto L_0x00a0
            boolean r0 = r1.isEmpty()     // Catch:{ Exception -> 0x00e0 }
            if (r0 == 0) goto L_0x00bb
        L_0x00a0:
            X.Apl r0 = new X.Apl     // Catch:{ Exception -> 0x00e0 }
            r0.<init>(r7)     // Catch:{ Exception -> 0x00e0 }
            r7.withState(r0)     // Catch:{ Exception -> 0x00e0 }
            boolean r0 = r5.isHasMore()     // Catch:{ Exception -> 0x00e0 }
            if (r0 == 0) goto L_0x00d9
            X.A4n r2 = X.C0479A4l.LIZ     // Catch:{ Exception -> 0x00e0 }
            long r0 = r5.maxCursor     // Catch:{ Exception -> 0x00e0 }
            java.lang.Long r0 = X.ILJ.LIZ(r0)     // Catch:{ Exception -> 0x00e0 }
            X.A4p r0 = X.C0481A4n.LIZ(r2, r6, r0, r3, r4)     // Catch:{ Exception -> 0x00e0 }
            return r0
        L_0x00bb:
            java.util.Iterator r2 = r1.iterator()     // Catch:{ Exception -> 0x00e0 }
        L_0x00bf:
            boolean r0 = r2.hasNext()     // Catch:{ Exception -> 0x00e0 }
            if (r0 == 0) goto L_0x00a0
            java.lang.Object r1 = r2.next()     // Catch:{ Exception -> 0x00e0 }
            com.ss.android.ugc.aweme.feed.model.Aweme r1 = (com.ss.android.ugc.aweme.feed.model.Aweme) r1     // Catch:{ Exception -> 0x00e0 }
            X.Aju r0 = new X.Aju     // Catch:{ Exception -> 0x00e0 }
            if (r1 != 0) goto L_0x00d2
            kotlin.h.b.n.LIZIZ()     // Catch:{ Exception -> 0x00e0 }
        L_0x00d2:
            r0.<init>(r1)     // Catch:{ Exception -> 0x00e0 }
            r3.add(r0)     // Catch:{ Exception -> 0x00e0 }
            goto L_0x00bf
        L_0x00d9:
            X.A4n r0 = X.C0479A4l.LIZ     // Catch:{ Exception -> 0x00e0 }
            X.A4o r0 = r0.LIZ((java.util.List<? extends X.DaP>) r3)     // Catch:{ Exception -> 0x00e0 }
            return r0
        L_0x00e0:
            r2 = move-exception
            X.A4n r1 = X.C0479A4l.LIZ
            java.lang.Exception r0 = new java.lang.Exception
            r0.<init>(r2)
            X.A4m r0 = r1.LIZ((java.lang.Exception) r0)
            return r0
        */
        throw new UnsupportedOperationException("Method not decompiled: com.ss.android.ugc.aweme.profile.assem.VM.MyVideoListVM.LIZ(long, java.lang.String, int, X.4r1):java.lang.Object");
    }
}
