package com.ss.android.ugc.aweme.im.sdk.chat.viewmodel;

import X.0Bt;
import X.0CB;
import X.0CH;
import X.0CN;
import X.2Pr;
import X.4Dd;
import X.4R3;
import X.6Is;
import X.7WA;
import X.C1020IbL;
import X.C1047Ibm;
import X.C1051Ibq;
import X.C1265IfI;
import X.C1270IfN;
import X.C1277IfU;
import X.C1303Ifu;
import X.C1304Ifv;
import X.C1306Ifx;
import X.C1310Ig1;
import X.C1312Ig3;
import X.C1314Ig5;
import X.C1315Ig6;
import X.C1317Ig8;
import X.C1318Ig9;
import X.C1319IgA;
import X.C1320IgB;
import X.C1322IgD;
import X.C1323IgE;
import X.C1324IgF;
import X.C1327IgI;
import X.C1328IgJ;
import X.C1430Ihx;
import X.C4175Jl8;
import X.Ls2;
import X.LsC;
import X.M12;
import X.Mjy;
import X.OJw;
import X.PgU;
import X.PgV;
import X.Ph1;
import X.PlG;
import com.bytedance.covode.number.Covode;
import java.util.List;
import java.util.concurrent.TimeUnit;
import kotlin.h.b.n;

public final class ChatRoomViewModel extends 0Bt implements 6Is {
    public static final C1328IgJ LJIILIIL = new C1328IgJ((byte) 0);
    public final OJw<C1047Ibm> LIZ;
    public final OJw<7WA> LIZIZ;
    public final OJw<2Pr> LIZJ;
    public C1270IfN LIZLLL;
    public final C1265IfI LJ;
    public final C1319IgA LJFF;
    public final C1306Ifx LJI;
    public final C1327IgI LJII;
    public final 4R3 LJIIIIZZ;
    public final C1310Ig1 LJIIIZ;
    public final C1303Ifu LJIIJ;
    public final Mjy LJIIJJI;
    public final PlG LJIIL;
    public final Mjy LJIILJJIL;

    static {
        Covode.recordClassIndex(85295);
    }

    public final void onStateChanged(0CH r2, 0CB r3) {
        if (r3 == 0CB.ON_CREATE) {
            subscribeToEvents$im_base_release();
        } else if (r3 == 0CB.ON_RESUME) {
            onResume$im_base_release();
        } else if (r3 == 0CB.ON_STOP) {
            onStop$im_base_release();
        } else if (r3 == 0CB.ON_DESTROY) {
            onDestroy$im_base_release();
        }
    }

    public final C1430Ihx LIZ() {
        return this.LJFF.LIZ(this.LJ.getConversationId());
    }

    @0CN(LIZ = 0CB.ON_DESTROY)
    public final void onDestroy$im_base_release() {
        this.LIZ.onComplete();
        this.LIZIZ.onComplete();
        this.LJIILJJIL.LIZ();
    }

    @0CN(LIZ = 0CB.ON_RESUME)
    public final void onResume$im_base_release() {
        LIZIZ();
        this.LJFF.LIZJ(this.LJ.getConversationId());
    }

    public final void LIZIZ() {
        PgV LIZIZ2 = this.LJI.LIZJ(this.LJ.getConversationId()).LIZIZ(this.LJIIL);
        n.LIZIZ(LIZIZ2, "");
        4Dd.LIZ(C1020IbL.LIZ(LIZIZ2, (LsC<? super Throwable, 2Pr>) new C1318Ig9(this), new C1320IgB(this)), this.LJIIJJI);
    }

    @0CN(LIZ = 0CB.ON_STOP)
    public final void onStop$im_base_release() {
        String str;
        this.LJFF.LIZLLL(this.LJ.getConversationId());
        C1327IgI igI = this.LJII;
        String conversationId = this.LJ.getConversationId();
        if (this.LJ.isStrangerChat()) {
            str = "stranger";
        } else {
            str = "no_stranger";
        }
        igI.LIZ(conversationId, str);
        this.LJII.LIZ();
        this.LJIIJJI.LIZ();
    }

    @0CN(LIZ = 0CB.ON_CREATE)
    public final void subscribeToEvents$im_base_release() {
        4Dd.LIZ(C1020IbL.LIZ(this.LJI.LIZ(this.LJ.getConversationId()), (LsC) null, (Ls2) null, new C1314Ig5(this.LIZIZ), 3), this.LJIILJJIL);
        PgU LIZ2 = this.LIZIZ.LIZ(this.LJIIL);
        n.LIZIZ(LIZ2, "");
        4Dd.LIZ(C1020IbL.LIZ(LIZ2, new C1322IgD(this), (Ls2) null, new C1277IfU(this), 2), this.LJIILJJIL);
        4Dd.LIZ(C1020IbL.LIZ(this.LJFF.LIZIZ(this.LJ.getConversationId()), new C1323IgE(this), (Ls2) null, new C1315Ig6(this.LIZ), 2), this.LJIILJJIL);
        PgU LIZIZ2 = this.LIZ.LIZIZ(this.LJIIL);
        n.LIZIZ(LIZIZ2, "");
        4Dd.LIZ(C1020IbL.LIZ(LIZIZ2, new C1324IgF(this), (Ls2) null, new C1304Ifv(this), 2), this.LJIILJJIL);
        PgU LIZLLL2 = this.LIZJ.LIZ(this.LJIIL).LIZLLL(100, TimeUnit.MILLISECONDS);
        n.LIZIZ(LIZLLL2, "");
        4Dd.LIZ(C1020IbL.LIZ(LIZLLL2, (LsC) null, (Ls2) null, new C1312Ig3(this), 3), this.LJIILJJIL);
    }

    public final void LIZ(C1270IfN ifN) {
        M12.LIZ(ifN);
        this.LIZLLL = ifN;
    }

    public final void LIZ(int i) {
        this.LIZ.onNext(new C1051Ibq(i));
    }

    /* JADX WARNING: Illegal instructions before constructor call */
    /* Code decompiled incorrectly, please refer to instructions dump. */
    public /* synthetic */ ChatRoomViewModel(X.C1265IfI r12) {
        /*
            r11 = this;
            X.Ihw r2 = new X.Ihw
            r2.<init>()
            X.J7i r3 = new X.J7i
            r3.<init>()
            X.Ij7 r4 = new X.Ij7
            r4.<init>()
            X.4R3 r5 = X.3W2.LIZJ
            X.IgG r6 = new X.IgG
            java.lang.String r0 = "ChatRoomViewModel"
            r6.<init>(r0)
            X.IgS r7 = new X.IgS
            r7.<init>()
            X.Mjy r8 = new X.Mjy
            r8.<init>()
            X.Mjy r9 = new X.Mjy
            r9.<init>()
            X.PlG r0 = X.PlI.LIZJ
            X.PlG r10 = X.PhE.LIZIZ(r0)
            java.lang.String r0 = ""
            kotlin.h.b.n.LIZIZ(r10, r0)
            r0 = r11
            r1 = r12
            r0.<init>(r1, r2, r3, r4, r5, r6, r7, r8, r9, r10)
            return
        */
        throw new UnsupportedOperationException("Method not decompiled: com.ss.android.ugc.aweme.im.sdk.chat.viewmodel.ChatRoomViewModel.<init>(X.IfI):void");
    }

    public final void LIZ(List<C4175Jl8> list) {
        M12.LIZ(list);
        Ph1 LIZIZ2 = this.LJIIJ.LIZ(list).LIZIZ(this.LJIIL).LIZIZ();
        n.LIZIZ(LIZIZ2, "");
        4Dd.LIZ(C1020IbL.LIZ(LIZIZ2, (LsC<? super Throwable, 2Pr>) new C1317Ig8(this), C1020IbL.LIZJ), this.LJIIJJI);
    }

    public ChatRoomViewModel(C1265IfI ifI, C1319IgA igA, C1306Ifx ifx, C1327IgI igI, 4R3 r15, C1310Ig1 ig1, C1303Ifu ifu, Mjy mjy, Mjy mjy2, PlG plG) {
        C1310Ig1 ig12 = ig1;
        4R3 r4 = r15;
        C1327IgI igI2 = igI;
        C1306Ifx ifx2 = ifx;
        Mjy mjy3 = mjy2;
        C1319IgA igA2 = igA;
        PlG plG2 = plG;
        Mjy mjy4 = mjy;
        C1265IfI ifI2 = ifI;
        C1303Ifu ifu2 = ifu;
        M12.LIZ(ifI2, igA2, ifx2, igI2, r4, ig12, ifu2, mjy4, mjy3, plG2);
        this.LJ = ifI2;
        this.LJFF = igA2;
        this.LJI = ifx2;
        this.LJII = igI2;
        this.LJIIIIZZ = r4;
        this.LJIIIZ = ig12;
        this.LJIIJ = ifu2;
        this.LJIIJJI = mjy4;
        this.LJIILJJIL = mjy3;
        this.LJIIL = plG2;
        OJw<C1047Ibm> oJw = new OJw<>();
        n.LIZIZ(oJw, "");
        this.LIZ = oJw;
        OJw<7WA> oJw2 = new OJw<>();
        n.LIZIZ(oJw2, "");
        this.LIZIZ = oJw2;
        OJw<2Pr> oJw3 = new OJw<>();
        n.LIZIZ(oJw3, "");
        this.LIZJ = oJw3;
        this.LIZLLL = C1270IfN.FULL;
    }
}
