package com.ss.android.ugc.aweme.upvote.service;

import X.0CH;
import X.1hK;
import X.2Pr;
import X.2nK;
import X.2sG;
import X.3QA;
import X.4nb;
import X.4ns;
import X.4o4;
import X.A01;
import X.A12;
import X.A16;
import X.A17;
import X.A1F;
import X.A1L;
import X.A7H;
import X.AnonymousClass9o4;
import X.AnonymousClass9oC;
import X.AnonymousClass9t5;
import X.AnonymousClass9zF;
import X.AnonymousClass9zS;
import X.C01799sx;
import X.C03319yt;
import X.C03369yy;
import X.C03599zv;
import X.C03609zw;
import X.C03639zz;
import X.C0369A0f;
import X.C0374A0k;
import X.C0378A0o;
import X.C2188AoK;
import X.Csc;
import X.Css;
import X.CwZ;
import X.Cwu;
import X.Ivo;
import X.KEM;
import X.LWw;
import X.Lea;
import X.Lel;
import X.Lnj;
import X.Ls2;
import X.M12;
import X.Ph1;
import X.PhE;
import X.PlI;
import android.app.Activity;
import com.bytedance.assem.arch.viewModel.AssemViewModel;
import com.bytedance.covode.number.Covode;
import com.bytedance.frameworks.apm.trace.MethodCollector;
import com.ss.android.ugc.aweme.feed.model.Aweme;
import com.ss.android.ugc.aweme.feed.model.upvote.UpvoteList;
import com.ss.android.ugc.aweme.feed.model.upvote.UpvoteReason;
import com.ss.android.ugc.aweme.model.TextExtraStruct;
import com.ss.android.ugc.aweme.upvote.dispatcher.UpvoteEventObservable;
import com.ss.android.ugc.aweme.upvote.event.UpvotePublishMobParam;
import com.ss.android.ugc.aweme.upvote.publish.UpvotePublishVM;
import com.ss.android.ugc.aweme.utils.ActivityStack;
import java.util.List;
import kotlin.h.b.n;

public final class UpvoteServiceImpl implements IUpvoteService {
    static {
        Covode.recordClassIndex(121841);
    }

    public final A1F LIZ() {
        return C0374A0k.LIZ;
    }

    public final C03319yt LIZLLL() {
        return 4o4.LIZ;
    }

    public final AnonymousClass9oC LJ() {
        return AnonymousClass9zF.LIZ;
    }

    public final C0378A0o LJFF() {
        return C0369A0f.LIZ;
    }

    public final Ivo LJI() {
        return C01799sx.LIZ;
    }

    public final 4nb LJII() {
        return 4ns.LIZ;
    }

    public final void LIZJ() {
        C03369yy r1 = C03369yy.LIZ;
        r1.LIZ().clear();
        r1.LIZIZ().clear();
        r1.LJ().evictAll();
        r1.LIZLLL().clear();
        r1.LIZJ().clear();
    }

    public static IUpvoteService LJIIIIZZ() {
        MethodCollector.i(6402);
        IUpvoteService iUpvoteService = (IUpvoteService) Lnj.LIZ(IUpvoteService.class, false);
        if (iUpvoteService != null) {
            MethodCollector.o(6402);
            return iUpvoteService;
        }
        Object LIZIZ = Lnj.LIZIZ(IUpvoteService.class, false);
        if (LIZIZ != null) {
            IUpvoteService iUpvoteService2 = (IUpvoteService) LIZIZ;
            MethodCollector.o(6402);
            return iUpvoteService2;
        }
        if (Lnj.bM == null) {
            synchronized (IUpvoteService.class) {
                try {
                    if (Lnj.bM == null) {
                        Lnj.bM = new UpvoteServiceImpl();
                    }
                } catch (Throwable th) {
                    MethodCollector.o(6402);
                    throw th;
                }
            }
        }
        UpvoteServiceImpl upvoteServiceImpl = (UpvoteServiceImpl) Lnj.bM;
        MethodCollector.o(6402);
        return upvoteServiceImpl;
    }

    public final void LIZIZ() {
        C03599zv r2 = C03599zv.LIZ;
        2sG r1 = new 2sG();
        r1.element = Lel.INSTANCE;
        if (AnonymousClass9t5.LIZ.LIZ()) {
            r1.element = r2.LIZ();
        }
        3QA.LIZ(new C03609zw(r1));
    }

    public final UpvoteList LIZ(String str) {
        M12.LIZ(str);
        return C03369yy.LIZ.LIZJ(str);
    }

    public final UpvoteReason LIZLLL(String str) {
        C03369yy r0 = C03369yy.LIZ;
        if (str == null) {
            str = "";
        }
        return r0.LIZ(str);
    }

    public final boolean LIZJ(String str) {
        Boolean LIZIZ;
        if (str == null || str.length() == 0 || (LIZIZ = C03369yy.LIZ.LIZIZ(str)) == null) {
            return false;
        }
        return LIZIZ.booleanValue();
    }

    public final AnonymousClass9o4 LIZ(0CH r5) {
        if (r5 == null) {
            return null;
        }
        M12.LIZ(r5);
        int hashCode = r5.hashCode();
        AnonymousClass9o4 r2 = UpvoteEventObservable.LIZIZ.get(Integer.valueOf(hashCode));
        if (r2 != null) {
            return r2;
        }
        UpvoteEventObservable upvoteEventObservable = new UpvoteEventObservable(r5);
        UpvoteEventObservable.LIZIZ.put(Integer.valueOf(hashCode), upvoteEventObservable);
        return upvoteEventObservable;
    }

    public final int LIZIZ(String str) {
        if (str == null || str.length() == 0) {
            return 1;
        }
        C03369yy r0 = C03369yy.LIZ;
        M12.LIZ(str);
        Integer num = r0.LIZIZ().get(str);
        if (num != null) {
            return num.intValue();
        }
        return 1;
    }

    public final AssemViewModel<A12> LIZ(1hK r11) {
        M12.LIZ(r11);
        return (UpvotePublishVM) new Csc(KEM.LIZ.LIZ(UpvotePublishVM.class), (Ls2) null, Css.LIZ, C2188AoK.LIZ((0CH) r11, false), A7H.LIZ, C03639zz.INSTANCE, C2188AoK.LIZ(r11), C2188AoK.LIZIZ(r11)).getValue();
    }

    public final void LIZ(List<? extends Aweme> list) {
        M12.LIZ(list);
        Ph1.LIZIZ(new AnonymousClass9zS(Lea.LJIIJJI(list))).LIZIZ(PhE.LIZIZ(PlI.LIZJ)).LIZIZ();
    }

    public final void LIZ(String str, int i) {
        M12.LIZ(str);
        C03369yy.LIZ.LIZ(str, i);
    }

    public final void LIZ(String str, boolean z, UpvotePublishMobParam upvotePublishMobParam, boolean z2, Ls2<2Pr> ls2) {
        String str2 = str;
        UpvotePublishMobParam upvotePublishMobParam2 = upvotePublishMobParam;
        M12.LIZ(str2, upvotePublishMobParam2);
        C03599zv.LIZ.LIZ(str2, z, upvotePublishMobParam2, z2, ls2);
    }

    public final void LIZ(String str, UpvotePublishMobParam upvotePublishMobParam, String str2, List<? extends TextExtraStruct> list, boolean z, Ls2<2Pr> ls2) {
        String str3;
        M12.LIZ(str, upvotePublishMobParam);
        if (str2 == null || str2.length() == 0) {
            C03599zv.LIZ.LIZ(str, upvotePublishMobParam, ls2);
            return;
        }
        M12.LIZ(str, upvotePublishMobParam);
        Activity topActivity = ActivityStack.getTopActivity();
        if (!(topActivity instanceof 1hK)) {
            topActivity = null;
        }
        1hK r2 = (1hK) topActivity;
        if (r2 != null) {
            A17 LIZ = A16.LIZ(str);
            String str4 = "0";
            if (A1L.LIZ.LIZIZ()) {
                str3 = str4;
            } else {
                str3 = "1";
            }
            upvotePublishMobParam.LIZIZ(str3);
            if (LIZ.LIZ) {
                str4 = "1";
            }
            upvotePublishMobParam.LIZJ(str4);
            upvotePublishMobParam.LIZLLL(String.valueOf(LIZ.LIZIZ));
            if (!n.LIZ(upvotePublishMobParam.LIZIZ, "click_repost_button")) {
                2nK.LIZ("recommend", LWw.LIZ(new Cwu[]{CwZ.LIZ("enter_from", upvotePublishMobParam.LIZ), CwZ.LIZ("enter_method", upvotePublishMobParam.LIZIZ), CwZ.LIZ("group_id", upvotePublishMobParam.LIZJ), CwZ.LIZ("author_id", upvotePublishMobParam.LIZLLL), CwZ.LIZ("follow_status", upvotePublishMobParam.LJ), CwZ.LIZ("is_first", upvotePublishMobParam.LJFF), CwZ.LIZ("is_recommend", upvotePublishMobParam.LJI), CwZ.LIZ("recommend_cnt", upvotePublishMobParam.LJII)}));
            }
            Csc csc = new Csc(KEM.LIZ.LIZ(UpvotePublishVM.class), (Ls2) null, Css.LIZ, C2188AoK.LIZ((0CH) r2, false), A7H.LIZ, A01.INSTANCE, C2188AoK.LIZ(r2), C2188AoK.LIZIZ(r2));
            String str5 = "";
            List<? extends TextExtraStruct> list2 = list;
            if (z) {
                UpvotePublishVM upvotePublishVM = (UpvotePublishVM) csc.getValue();
                if (str2 != null) {
                    str5 = str2;
                }
                upvotePublishVM.LIZIZ(str, str5, upvotePublishMobParam, list2);
                return;
            }
            UpvotePublishVM upvotePublishVM2 = (UpvotePublishVM) csc.getValue();
            if (str2 != null) {
                str5 = str2;
            }
            upvotePublishVM2.LIZ(str, str5, upvotePublishMobParam, list2);
        }
    }
}
