package com.bytedance.android.live.pin;

import X.AnonymousClass2CZ;
import X.C03070Bt;
import X.C10000b0;
import X.C11100cm;
import X.C24990zB;
import X.C25120zO;
import X.C25140zQ;
import X.C25150zR;
import X.C25180zU;
import X.C25190zV;
import X.C25220zY;
import X.C25230zZ;
import X.C255810i;
import X.C28491Bn;
import X.C36471cb;
import X.Fv7;
import X.Fz8;
import X.G2l;
import X.G3X;
import X.GtA;
import X.GuA;
import X.M12;
import android.os.SystemClock;
import androidx.lifecycle.LiveData;
import com.bytedance.android.live.base.model.user.User;
import com.bytedance.android.live.publicscreen.api.IPublicScreenService;
import com.bytedance.android.livesdk.model.message.PinMessage;
import com.bytedance.android.livesdkapi.depend.model.live.Room;
import com.bytedance.covode.number.Covode;
import com.bytedance.ies.sdk.datachannel.DataChannel;
import java.util.List;
import kotlin.h.b.n;

public final class PinMessageViewModel extends C03070Bt implements C25180zU {
    public static final C24990zB LJIIIIZZ = new C24990zB((byte) 0);
    public C255810i LIZ;
    public C25230zZ<AnonymousClass2CZ<? extends GuA>> LIZIZ;
    public C25230zZ<AnonymousClass2CZ<? extends GuA>> LIZJ;
    public C25230zZ<AnonymousClass2CZ<? extends GuA>> LIZLLL;
    public final LiveData<C25230zZ<AnonymousClass2CZ<? extends GuA>>> LJ;
    public long LJFF;
    public Long LJI;
    public DataChannel LJII;
    public final C28491Bn<C25230zZ<AnonymousClass2CZ<? extends GuA>>> LJIIIZ;

    static {
        Covode.recordClassIndex(9642);
    }

    public PinMessageViewModel() {
        C28491Bn<C25230zZ<AnonymousClass2CZ<? extends GuA>>> r0 = new C28491Bn<>();
        this.LJIIIZ = r0;
        this.LJ = r0;
    }

    public final void onCleared() {
        super.onCleared();
        Long l = this.LJI;
        if (l != null) {
            long longValue = l.longValue();
            M12.LIZ(this);
            List list = C25220zY.LIZLLL.get(longValue);
            if (list != null) {
                list.remove(this);
            }
        }
    }

    public final void LJI(C25150zR r3) {
        M12.LIZ(r3);
        C25230zZ<AnonymousClass2CZ<? extends GuA>> r1 = this.LIZJ;
        if (r1 != null && this.LIZ != null && n.LIZ(r1.LIZ, r3)) {
            r1.LIZJ = false;
            if (this.LIZIZ == null) {
                LIZ(r1, (Object) null);
            }
        }
    }

    private final C25230zZ<AnonymousClass2CZ<? extends GuA>> LJIIIIZZ(C25150zR r6) {
        C36471cb r3;
        C255810i r4 = this.LIZ;
        if (r4 == null) {
            return null;
        }
        IPublicScreenService iPublicScreenService = (IPublicScreenService) C11100cm.LIZ(IPublicScreenService.class);
        if (iPublicScreenService != null) {
            r3 = iPublicScreenService.convert(r6.LJFF);
        } else {
            r3 = null;
        }
        if (!(r3 instanceof AnonymousClass2CZ)) {
            r3 = null;
        }
        AnonymousClass2CZ r32 = (AnonymousClass2CZ) r3;
        if (r32 == null) {
            return null;
        }
        r32.LIZ(r4);
        r32.LJFF.LIZ = false;
        r32.LJFF.LIZIZ = true;
        r32.LIZJ = false;
        return new C25230zZ<>(r6, r32, (byte) 0);
    }

    public final void LIZLLL(C25150zR r7) {
        C25230zZ<AnonymousClass2CZ<? extends GuA>> r5;
        PinMessage pinMessage;
        M12.LIZ(r7);
        PinMessage pinMessage2 = r7.LJI;
        if (pinMessage2 != null && (r5 = this.LIZLLL) != null && (pinMessage = r5.LIZ.LJI) != null && pinMessage.LJIILJJIL == pinMessage2.LJIILJJIL && r7.LJ) {
            LIZ(r5, new C25120zO());
        }
    }

    public final void LJFF(C25150zR r6) {
        Long l;
        Long l2;
        M12.LIZ(r6);
        C25230zZ<AnonymousClass2CZ<? extends GuA>> r4 = this.LIZJ;
        if (r4 != null) {
            PinMessage pinMessage = r4.LIZ.LJI;
            if (pinMessage != null) {
                l = Long.valueOf(pinMessage.LJIILJJIL);
            } else {
                l = null;
            }
            PinMessage pinMessage2 = r6.LJI;
            if (pinMessage2 != null) {
                l2 = Long.valueOf(pinMessage2.LJIILJJIL);
            } else {
                l2 = null;
            }
            if (n.LIZ(l, l2)) {
                r4.LIZJ = true;
                if (this.LIZIZ == null) {
                    LIZ(r4, (Object) null);
                }
            }
        }
    }

    public final void LJII(C25150zR r3) {
        M12.LIZ(r3);
        C25230zZ<AnonymousClass2CZ<? extends GuA>> r1 = this.LIZIZ;
        if (r1 == null || !n.LIZ(r1.LIZ, r3)) {
            C25230zZ<AnonymousClass2CZ<? extends GuA>> r12 = this.LIZJ;
            if (r12 != null && n.LIZ(r12.LIZ, r3)) {
                LIZ(r12, new C25140zQ());
                return;
            }
            return;
        }
        LIZ(r1, new C25140zQ());
    }

    public final void LIZ(C25150zR r7) {
        Boolean bool;
        String str;
        Room room;
        Room room2;
        Room room3;
        Long l;
        M12.LIZ(r7);
        C25230zZ<AnonymousClass2CZ<? extends GuA>> LJIIIIZZ2 = LJIIIIZZ(r7);
        if (LJIIIIZZ2 != null) {
            this.LIZIZ = LJIIIIZZ2;
            this.LIZLLL = LJIIIIZZ2;
            C255810i r0 = this.LIZ;
            if (r0 != null && r0.LIZIZ) {
                GtA LIZ2 = GtA.LJFF.LIZ("livesdk_pin_comment_show");
                LIZ2.LIZ(this.LJII);
                C255810i r02 = this.LIZ;
                if (r02 != null) {
                    bool = Boolean.valueOf(r02.LIZLLL);
                } else {
                    bool = null;
                }
                if (G2l.LIZ(bool)) {
                    str = "1";
                } else {
                    str = "0";
                }
                LIZ2.LIZ("is_extended_comment_filed", str);
                DataChannel dataChannel = this.LJII;
                if (dataChannel != null) {
                    room = (Room) dataChannel.LIZIZ(Fv7.class);
                } else {
                    room = null;
                }
                LIZ2.LIZ("admin_type", G3X.LIZ(room, this.LJII));
                LIZ2.LIZ("use_status", "under_review");
                DataChannel dataChannel2 = this.LJII;
                if (dataChannel2 != null) {
                    room2 = (Room) dataChannel2.LIZIZ(Fv7.class);
                } else {
                    room2 = null;
                }
                LIZ2.LIZ("pin_user", G3X.LIZ(room2, r7.LIZIZ));
                DataChannel dataChannel3 = this.LJII;
                if (dataChannel3 != null) {
                    room3 = (Room) dataChannel3.LIZIZ(Fv7.class);
                } else {
                    room3 = null;
                }
                LIZ2.LIZ("msg_sent_user", G3X.LIZ(room3, C25220zY.LJI.LIZ(r7.LJFF)));
                User LIZ3 = C25220zY.LJI.LIZ(r7.LJFF);
                if (LIZ3 != null) {
                    l = Long.valueOf(LIZ3.getId());
                } else {
                    l = null;
                }
                LIZ2.LIZ("msg_sent_user_id", l);
                LIZ2.LIZLLL();
            }
            LIZ(LJIIIIZZ2, (Object) null);
        }
    }

    /* JADX WARNING: Removed duplicated region for block: B:29:0x0078  */
    /* JADX WARNING: Removed duplicated region for block: B:32:0x008f  */
    /* JADX WARNING: Removed duplicated region for block: B:35:0x00a6  */
    /* JADX WARNING: Removed duplicated region for block: B:38:0x00c9  */
    /* JADX WARNING: Removed duplicated region for block: B:42:0x00dc  */
    /* JADX WARNING: Removed duplicated region for block: B:43:0x00de  */
    /* JADX WARNING: Removed duplicated region for block: B:44:0x00e0  */
    /* JADX WARNING: Removed duplicated region for block: B:45:0x00e2  */
    /* Code decompiled incorrectly, please refer to instructions dump. */
    public final void LIZIZ(X.C25150zR r6) {
        /*
            r5 = this;
            X.M12.LIZ(r6)
            long r0 = android.os.SystemClock.uptimeMillis()
            r5.LJFF = r0
            X.0zZ<X.2CZ<? extends X.GuA>> r1 = r5.LIZIZ
            r2 = 0
            if (r1 != 0) goto L_0x00f1
            X.0zZ r0 = r5.LJIIIIZZ(r6)
            r5.LIZJ = r0
            if (r0 == 0) goto L_0x0019
            r5.LIZ(r0, r2)
        L_0x0019:
            X.0zZ<X.2CZ<? extends X.GuA>> r0 = r5.LIZJ
            r5.LIZLLL = r0
            X.10i r4 = r5.LIZ
            if (r4 == 0) goto L_0x00d9
            boolean r0 = r4.LIZIZ
            if (r0 == 0) goto L_0x00d9
            X.GtO r1 = X.GtA.LJFF
            java.lang.String r0 = "livesdk_pin_comment_show"
            X.GtA r3 = r1.LIZ(r0)
            com.bytedance.ies.sdk.datachannel.DataChannel r0 = r5.LJII
            r3.LIZ(r0)
            X.10i r0 = r5.LIZ
            if (r0 == 0) goto L_0x00ee
            boolean r0 = r0.LIZLLL
            java.lang.Boolean r0 = java.lang.Boolean.valueOf(r0)
        L_0x003c:
            boolean r0 = X.G2l.LIZ(r0)
            if (r0 == 0) goto L_0x00ea
            java.lang.String r1 = "1"
        L_0x0044:
            java.lang.String r0 = "is_extended_comment_filed"
            r3.LIZ(r0, r1)
            boolean r0 = r4.LJIILJJIL
            if (r0 != 0) goto L_0x006d
            com.bytedance.ies.sdk.datachannel.DataChannel r1 = r5.LJII
            if (r1 == 0) goto L_0x00e7
            java.lang.Class<X.G2p> r0 = X.G2p.class
            java.lang.Object r0 = r1.LIZIZ(r0)
            com.bytedance.android.live.base.model.user.User r0 = (com.bytedance.android.live.base.model.user.User) r0
            if (r0 == 0) goto L_0x00e7
            com.bytedance.android.livesdk.model.UserAttr r0 = r0.getUserAttr()
            if (r0 == 0) goto L_0x00e7
            boolean r0 = r0.LIZIZ
            java.lang.Boolean r0 = java.lang.Boolean.valueOf(r0)
        L_0x0067:
            boolean r0 = X.G2l.LIZ(r0)
            if (r0 == 0) goto L_0x00e4
        L_0x006d:
            java.lang.String r1 = "pass"
        L_0x006f:
            java.lang.String r0 = "use_status"
            r3.LIZ(r0, r1)
            com.bytedance.ies.sdk.datachannel.DataChannel r1 = r5.LJII
            if (r1 == 0) goto L_0x00e2
            java.lang.Class<X.Fv7> r0 = X.Fv7.class
            java.lang.Object r1 = r1.LIZIZ(r0)
            com.bytedance.android.livesdkapi.depend.model.live.Room r1 = (com.bytedance.android.livesdkapi.depend.model.live.Room) r1
        L_0x0080:
            com.bytedance.ies.sdk.datachannel.DataChannel r0 = r5.LJII
            java.lang.String r1 = X.G3X.LIZ(r1, r0)
            java.lang.String r0 = "admin_type"
            r3.LIZ(r0, r1)
            com.bytedance.ies.sdk.datachannel.DataChannel r1 = r5.LJII
            if (r1 == 0) goto L_0x00e0
            java.lang.Class<X.Fv7> r0 = X.Fv7.class
            java.lang.Object r1 = r1.LIZIZ(r0)
            com.bytedance.android.livesdkapi.depend.model.live.Room r1 = (com.bytedance.android.livesdkapi.depend.model.live.Room) r1
        L_0x0097:
            com.bytedance.android.live.base.model.user.User r0 = r6.LIZIZ
            java.lang.String r1 = X.G3X.LIZ(r1, r0)
            java.lang.String r0 = "pin_user"
            r3.LIZ(r0, r1)
            com.bytedance.ies.sdk.datachannel.DataChannel r1 = r5.LJII
            if (r1 == 0) goto L_0x00de
            java.lang.Class<X.Fv7> r0 = X.Fv7.class
            java.lang.Object r4 = r1.LIZIZ(r0)
            com.bytedance.android.livesdkapi.depend.model.live.Room r4 = (com.bytedance.android.livesdkapi.depend.model.live.Room) r4
        L_0x00ae:
            X.0zY r1 = X.C25220zY.LJI
            X.GuA r0 = r6.LJFF
            com.bytedance.android.live.base.model.user.User r0 = r1.LIZ((X.GuA) r0)
            java.lang.String r1 = X.G3X.LIZ(r4, r0)
            java.lang.String r0 = "msg_sent_user"
            r3.LIZ(r0, r1)
            X.0zY r1 = X.C25220zY.LJI
            X.GuA r0 = r6.LJFF
            com.bytedance.android.live.base.model.user.User r0 = r1.LIZ((X.GuA) r0)
            if (r0 == 0) goto L_0x00dc
            long r0 = r0.getId()
            java.lang.Long r1 = java.lang.Long.valueOf(r0)
        L_0x00d1:
            java.lang.String r0 = "msg_sent_user_id"
            r3.LIZ(r0, r1)
            r3.LIZLLL()
        L_0x00d9:
            r5.LIZIZ = r2
            return
        L_0x00dc:
            r1 = r2
            goto L_0x00d1
        L_0x00de:
            r4 = r2
            goto L_0x00ae
        L_0x00e0:
            r1 = r2
            goto L_0x0097
        L_0x00e2:
            r1 = r2
            goto L_0x0080
        L_0x00e4:
            java.lang.String r1 = ""
            goto L_0x006f
        L_0x00e7:
            r0 = r2
            goto L_0x0067
        L_0x00ea:
            java.lang.String r1 = "0"
            goto L_0x0044
        L_0x00ee:
            r0 = r2
            goto L_0x003c
        L_0x00f1:
            r5.LIZJ = r1
            X.0zQ r0 = new X.0zQ
            r0.<init>()
            r5.LIZ(r1, r0)
            goto L_0x0019
        */
        throw new UnsupportedOperationException("Method not decompiled: com.bytedance.android.live.pin.PinMessageViewModel.LIZIZ(X.0zR):void");
    }

    public final void LIZJ(C25150zR r10) {
        Boolean bool;
        Boolean bool2;
        String str;
        Room room;
        Room room2;
        Long l;
        C25230zZ<AnonymousClass2CZ<? extends GuA>> r0;
        M12.LIZ(r10);
        C255810i r02 = this.LIZ;
        if (r02 != null) {
            bool = Boolean.valueOf(r02.LIZIZ);
        } else {
            bool = null;
        }
        if (G2l.LIZ(bool)) {
            Fz8.LIZ(C10000b0.LJ(), C10000b0.LIZ(2131830052), 0);
        }
        C25230zZ<AnonymousClass2CZ<? extends GuA>> r8 = this.LIZJ;
        if (r8 != null) {
            if (r8.LIZ.LJII != 0) {
                C25230zZ<AnonymousClass2CZ<? extends GuA>> r1 = this.LIZJ;
                if (r1 != null) {
                    this.LIZLLL = r8;
                    r1.LJI = 0;
                    r1.LJFF = true;
                    LIZ(r1, (Object) null);
                }
            } else {
                C25230zZ<AnonymousClass2CZ<? extends GuA>> r03 = this.LIZIZ;
                if (r03 != null) {
                    r03.LIZLLL = true;
                    this.LIZLLL = null;
                    LIZ(r03, (Object) null);
                }
            }
        }
        if (this.LIZJ == null && (r0 = this.LIZIZ) != null) {
            r0.LIZLLL = true;
            this.LIZLLL = null;
            LIZ(r0, (Object) null);
        }
        C255810i r04 = this.LIZ;
        if (r04 != null && r04.LIZIZ && r10.LIZLLL) {
            GtA LIZ2 = GtA.LJFF.LIZ("livesdk_pin_comment_review_fail");
            LIZ2.LIZ(this.LJII);
            C255810i r05 = this.LIZ;
            if (r05 != null) {
                bool2 = Boolean.valueOf(r05.LIZLLL);
            } else {
                bool2 = null;
            }
            if (G2l.LIZ(bool2)) {
                str = "1";
            } else {
                str = "0";
            }
            LIZ2.LIZ("is_extended_comment_filed", str);
            DataChannel dataChannel = this.LJII;
            if (dataChannel != null) {
                room = (Room) dataChannel.LIZIZ(Fv7.class);
            } else {
                room = null;
            }
            LIZ2.LIZ("pin_user", G3X.LIZ(room, r10.LIZIZ));
            DataChannel dataChannel2 = this.LJII;
            if (dataChannel2 != null) {
                room2 = (Room) dataChannel2.LIZIZ(Fv7.class);
            } else {
                room2 = null;
            }
            LIZ2.LIZ("msg_sent_user", G3X.LIZ(room2, C25220zY.LJI.LIZ(r10.LJFF)));
            User LIZ3 = C25220zY.LJI.LIZ(r10.LJFF);
            if (LIZ3 != null) {
                l = Long.valueOf(LIZ3.getId());
            } else {
                l = null;
            }
            LIZ2.LIZ("msg_sent_user_id", l);
            LIZ2.LIZLLL();
        }
        this.LIZIZ = null;
    }

    public final void LJ(C25150zR r13) {
        Boolean bool;
        Boolean bool2;
        String str;
        Room room;
        Room room2;
        Long l;
        Room room3;
        Boolean bool3;
        M12.LIZ(r13);
        C25230zZ<AnonymousClass2CZ<? extends GuA>> r4 = this.LIZIZ;
        if (r4 == null || !n.LIZ(r4.LIZ, r13)) {
            C25230zZ<AnonymousClass2CZ<? extends GuA>> r6 = this.LIZJ;
            if (r6 != null) {
                C255810i r42 = this.LIZ;
                if (r42 != null && r42.LIZIZ) {
                    GtA LIZ2 = GtA.LJFF.LIZ("livesdk_pin_comment_duration");
                    LIZ2.LIZ(this.LJII);
                    boolean LIZ3 = G2l.LIZ(Boolean.valueOf(r42.LIZLLL));
                    String str2 = "1";
                    if (LIZ3) {
                        str = str2;
                    } else {
                        str = "0";
                    }
                    LIZ2.LIZ("is_extended_comment_filed", str);
                    DataChannel dataChannel = this.LJII;
                    if (dataChannel != null) {
                        room = (Room) dataChannel.LIZIZ(Fv7.class);
                    } else {
                        room = null;
                    }
                    LIZ2.LIZ("pin_user", G3X.LIZ(room, r13.LIZIZ));
                    DataChannel dataChannel2 = this.LJII;
                    if (dataChannel2 != null) {
                        room2 = (Room) dataChannel2.LIZIZ(Fv7.class);
                    } else {
                        room2 = null;
                    }
                    LIZ2.LIZ("msg_sent_user", G3X.LIZ(room2, C25220zY.LJI.LIZ(r13.LJFF)));
                    User LIZ4 = C25220zY.LJI.LIZ(r13.LJFF);
                    if (LIZ4 != null) {
                        l = Long.valueOf(LIZ4.getId());
                    } else {
                        l = null;
                    }
                    LIZ2.LIZ("msg_sent_user_id", l);
                    DataChannel dataChannel3 = this.LJII;
                    if (dataChannel3 != null) {
                        room3 = (Room) dataChannel3.LIZIZ(Fv7.class);
                    } else {
                        room3 = null;
                    }
                    LIZ2.LIZ("admin_type", G3X.LIZ(room3, this.LJII));
                    if (r13.LJIIIIZZ != C25190zV.TIME_OUT) {
                        str2 = "0";
                    }
                    LIZ2.LIZ("is_finish", str2);
                    LIZ2.LIZ("duration", (SystemClock.uptimeMillis() - this.LJFF) / 1000);
                    LIZ2.LIZLLL();
                }
                if (n.LIZ(r6.LIZ, r13)) {
                    r6.LIZJ = true;
                    if (r13.LJIIIIZZ == C25190zV.INTERRUPT) {
                        C255810i r0 = this.LIZ;
                        if (r0 != null) {
                            bool = Boolean.valueOf(r0.LIZIZ);
                        } else {
                            bool = null;
                        }
                        if (G2l.LIZ(bool)) {
                            C255810i r02 = this.LIZ;
                            if (r02 != null) {
                                bool2 = Boolean.valueOf(r02.LJIILJJIL);
                            } else {
                                bool2 = null;
                            }
                            if (G2l.LIZ(bool2)) {
                                Fz8.LIZ(C10000b0.LJ(), C10000b0.LIZ(2131830055), 0);
                            }
                        }
                    }
                    this.LIZLLL = null;
                    this.LIZJ = null;
                    if (this.LIZIZ == null) {
                        LIZ(r6, (Object) null);
                        return;
                    }
                    return;
                }
                return;
            }
            return;
        }
        r4.LIZJ = true;
        this.LIZIZ = null;
        this.LIZLLL = null;
        if (r13.LJIIIIZZ == C25190zV.INTERRUPT) {
            C255810i r03 = this.LIZ;
            if (r03 != null) {
                bool3 = Boolean.valueOf(r03.LIZIZ);
            } else {
                bool3 = null;
            }
            if (G2l.LIZ(bool3)) {
                Fz8.LIZ(C10000b0.LJ(), C10000b0.LIZ(2131830055), 0);
            }
        }
        LIZ(r4, (Object) null);
    }

    public final void LIZ(C25230zZ<AnonymousClass2CZ<? extends GuA>> r2, Object obj) {
        M12.LIZ(r2);
        r2.LJ = obj;
        this.LJIIIZ.setValue(r2);
    }
}
