package com.ss.android.ugc.aweme.story.avatar.entry;

import X.0CB;
import X.0CH;
import X.0CN;
import X.1Bn;
import X.6Is;
import X.C0215Coh;
import X.C0220Com;
import X.C0225Cor;
import X.Cl7;
import X.ClF;
import X.ClK;
import X.ClO;
import X.ClT;
import X.CmK;
import X.Cp3;
import X.Cp7;
import X.CpC;
import X.CpT;
import X.DMH;
import X.M12;
import com.bytedance.covode.number.Covode;
import com.ss.android.ugc.aweme.feed.model.Aweme;
import com.ss.android.ugc.aweme.profile.model.User;
import kotlin.h.b.n;

public class StoryRingStatusViewModel implements 6Is, ClT {
    public static final CmK LIZJ = new CmK((byte) 0);
    public final 1Bn<C0225Cor> LIZ;
    public Aweme LIZIZ;
    public final CpT LIZLLL;
    public final boolean LJ;
    public boolean LJFF;

    static {
        Covode.recordClassIndex(116911);
    }

    public final void LIZ(int i) {
    }

    public final void LIZ(String str, ClF clF) {
        M12.LIZ(str, clF);
    }

    public final void LIZIZ(String str, ClF clF) {
        M12.LIZ(str, clF);
    }

    public void onStateChanged(0CH r2, 0CB r3) {
        if (r3 == 0CB.ON_DESTROY) {
            clear();
        }
    }

    @0CN(LIZ = 0CB.ON_DESTROY)
    public final void clear() {
        LIZ(false);
    }

    private final boolean LIZJ() {
        if (!this.LJFF || !this.LJ) {
            return false;
        }
        return true;
    }

    public final void LIZIZ() {
        LIZ(new C0225Cor(true, DMH.PRORGRESS, 0.0f, 4));
    }

    public final void LIZ() {
        C0225Cor cor;
        Aweme aweme = this.LIZIZ;
        if (LIZJ() && ClK.LJ) {
            DMH dmh = DMH.PRORGRESS;
            float LJI = ClK.LJIIIIZZ.LJI();
            C0225Cor cor2 = (C0225Cor) this.LIZ.getValue();
            if (cor2 != null && LJI == cor2.LIZJ) {
                LJI += Float.MIN_VALUE;
            }
            cor = new C0225Cor(true, dmh, LJI);
        } else if (!LIZJ() || !ClK.LJIIIIZZ.LIZLLL()) {
            CmK cmK = LIZJ;
            if (cmK.LIZ(aweme) || !cmK.LIZIZ(aweme)) {
                cor = new C0225Cor(false, (DMH) null, 0.0f, 6);
            } else {
                C0215Coh coh = C0215Coh.LIZLLL;
                if (aweme == null) {
                    n.LIZIZ();
                }
                if (coh.LIZ(aweme)) {
                    cor = new C0225Cor(true, DMH.GRAY_RING, 0.0f, 4);
                } else {
                    cor = new C0225Cor(true, DMH.BRAND_RING, 0.0f, 4);
                }
            }
        } else {
            cor = new C0225Cor(true, DMH.RED_RING, 0.0f, 4);
        }
        LIZ(cor);
    }

    public final void LIZ(float f) {
        LIZ(new C0225Cor(true, DMH.PRORGRESS, f));
    }

    private final void LIZ(C0225Cor cor) {
        if (!n.LIZ(this.LIZ.getValue(), cor)) {
            this.LIZ.setValue(cor);
        }
    }

    public StoryRingStatusViewModel(Cp3 cp3) {
        this.LIZ = new 1Bn<>();
        CpT LIZJ2 = cp3.LIZJ();
        this.LIZLLL = LIZJ2;
        boolean mayShowPublishProgress = CpC.LIZ(LIZJ2).getMayShowPublishProgress();
        this.LJ = mayShowPublishProgress;
        if (mayShowPublishProgress) {
            cp3.LIZIZ().getLifecycle().LIZ(this);
        }
    }

    /* access modifiers changed from: private */
    public final void LIZ(boolean z) {
        String valueOf = String.valueOf(hashCode());
        if (z) {
            ClK.LJIIIIZZ.LIZ((Object) valueOf, (ClT) this);
        } else {
            ClK.LJIIIIZZ.LJ(valueOf);
        }
    }

    private final void LIZIZ(User user) {
        C0225Cor cor;
        if (user != null) {
            if (LIZJ.LIZ(user) || !C0220Com.LIZ(user)) {
                cor = new C0225Cor(false, (DMH) null, 0.0f, 6);
            } else if (LIZJ() && ClK.LJ) {
                cor = new C0225Cor(true, DMH.PRORGRESS, ClK.LJIIIIZZ.LJII());
            } else if (LIZJ() && ClK.LJIIIIZZ.LIZLLL()) {
                cor = new C0225Cor(true, DMH.RED_RING, 0.0f, 4);
            } else if (C0220Com.LIZIZ(user)) {
                cor = new C0225Cor(true, DMH.GRAY_RING, 0.0f, 4);
            } else {
                cor = new C0225Cor(true, DMH.BRAND_RING, 0.0f, 4);
            }
            LIZ(cor);
        }
    }

    public final void LIZ(ClO clO) {
        M12.LIZ(clO);
        LIZ();
    }

    public final void LIZ(User user) {
        boolean z;
        float f;
        String str;
        String str2;
        User author;
        if (this.LIZLLL == CpT.INBOX_TOP_LIST || StoryRingUserStoryViewModel.LJFF.LIZ(user)) {
            z = true;
        } else {
            z = false;
        }
        String str3 = null;
        if (!Cp7.LIZIZ.LIZ() || user == null || Integer.valueOf(user.getStoryStatus()) == null) {
            if (z) {
                if (user != null) {
                    str = user.getUid();
                } else {
                    str = null;
                }
                Aweme aweme = this.LIZIZ;
                if (aweme == null || (author = aweme.getAuthor()) == null) {
                    str2 = null;
                } else {
                    str2 = author.getUid();
                }
                if (n.LIZ(str, str2)) {
                    LIZ();
                }
            }
            C0225Cor cor = (C0225Cor) this.LIZ.getValue();
            if (cor != null) {
                f = cor.LIZJ;
            } else {
                f = Float.MIN_VALUE;
            }
            LIZ(new C0225Cor(z, (DMH) null, f, 2));
        } else {
            LIZIZ(user);
        }
        if (user != null) {
            str3 = user.getUid();
        }
        this.LJFF = Cl7.LIZ(str3);
        LIZ(LIZJ());
    }

    public final void LIZ(String str) {
        M12.LIZ(str);
        LIZ();
    }

    public /* synthetic */ StoryRingStatusViewModel(Cp3 cp3, byte b) {
        this(cp3);
    }

    public final void LIZJ(String str, ClF clF) {
        M12.LIZ(str, clF);
        M12.LIZ(str, clF);
    }
}
