package com.ss.android.ugc.aweme.comment.gift.model;

import X.0Bt;
import X.1Bn;
import X.2UX;
import X.2nK;
import X.4AY;
import X.7he;
import X.AnonymousClass9sO;
import X.AnonymousClass9sR;
import X.AnonymousClass9sS;
import X.AnonymousClass9sU;
import X.AnonymousClass9sV;
import X.AnonymousClass9sW;
import X.AnonymousClass9sX;
import X.AnonymousClass9sY;
import X.AnonymousClass9sZ;
import X.Crj;
import X.Hwe;
import X.LeS;
import X.M12;
import X.Mjy;
import X.Mk2;
import X.Mk3;
import X.PhE;
import X.PlI;
import X.Q4b;
import android.content.Context;
import android.text.TextUtils;
import com.bytedance.covode.number.Covode;
import com.ss.android.ugc.aweme.base.model.UrlModel;
import com.ss.android.ugc.aweme.comment.gift.api.GiftListApi;
import com.ss.android.ugc.aweme.feed.model.Aweme;
import com.ss.android.ugc.aweme.live.ILiveOuterService;
import com.ss.android.ugc.aweme.live.LiveOuterService;
import java.util.HashMap;
import java.util.List;
import kotlin.h.b.n;

public final class GiftViewModel extends 0Bt {
    public static final AnonymousClass9sY LJIIJJI = new AnonymousClass9sY((byte) 0);
    public String LIZ = "";
    public String LIZIZ = "";
    public String LIZJ = "";
    public String LIZLLL = "";
    public Integer LJ = 0;
    public String LJFF = "";
    public String LJI = "";
    public Long LJII;
    public final 1Bn<Integer> LJIIIIZZ = new 1Bn<>();
    public boolean LJIIIZ;
    public Aweme LJIIJ;
    public final Crj LJIIL = 7he.LIZ(AnonymousClass9sV.LIZ);
    public final Crj LJIILIIL = 7he.LIZ(AnonymousClass9sU.LIZ);
    public final Crj LJIILJJIL = 7he.LIZ(AnonymousClass9sS.LIZ);
    public final Crj LJIILL = 7he.LIZ(AnonymousClass9sR.LIZ);

    static {
        Covode.recordClassIndex(57064);
    }

    public final 1Bn<GiftResponse> LIZ() {
        return (1Bn) this.LJIIL.getValue();
    }

    public final 1Bn<GiftStruct> LIZIZ() {
        return (1Bn) this.LJIILIIL.getValue();
    }

    public final 1Bn<HashMap<Long, String>> LIZJ() {
        return (1Bn) this.LJIILJJIL.getValue();
    }

    public final 1Bn<Long> LIZLLL() {
        return (1Bn) this.LJIILL.getValue();
    }

    public final void LJFF() {
        String str = this.LJI;
        if (str != null && str.length() != 0) {
            2UX r2 = new 2UX();
            r2.LIZ("enter_from", this.LIZ);
            r2.LIZ("group_id", this.LIZIZ);
            r2.LIZ("author_id", this.LIZJ);
            r2.LIZ("is_follow", 4AY.LIZIZ(this.LJIIJ));
            r2.LIZ("is_like", 4AY.LIZIZ(this.LJIIJ));
            r2.LIZ("enter_method", this.LJI);
            r2.LIZ("is_success", this.LJ);
            r2.LIZ("error_code", this.LJFF);
            n.LIZIZ(r2, "");
            2nK.LIZ("show_gift_panel_result", r2.LIZ);
        }
    }

    public final void LJ() {
        GiftResult giftPageList;
        List<GiftPage> giftPageList2;
        int i = 0;
        if (this.LJII == null) {
            this.LJIIIIZZ.setValue(0);
            return;
        }
        GiftResponse giftResponse = (GiftResponse) LIZ().getValue();
        if (giftResponse != null && (giftPageList = giftResponse.getGiftPageList()) != null && (giftPageList2 = giftPageList.getGiftPageList()) != null) {
            for (T next : giftPageList2) {
                int i2 = i + 1;
                if (i < 0) {
                    LeS.LIZIZ();
                }
                List<GiftStruct> giftList = ((GiftPage) next).getGiftList();
                if (giftList != null) {
                    for (GiftStruct giftStruct : giftList) {
                        long id = giftStruct.getId();
                        Long l = this.LJII;
                        if (l != null && id == l.longValue()) {
                            this.LJII = null;
                            this.LJIIIIZZ.setValue(Integer.valueOf(i));
                            LIZIZ().setValue(giftStruct);
                            LIZ(giftStruct.getId(), giftStruct.getEffectAsset());
                        }
                    }
                }
                i = i2;
            }
        }
    }

    private final boolean LIZ(UrlModel urlModel) {
        List urlList;
        if (urlModel != null && !TextUtils.isEmpty(urlModel.getFileHash()) && (urlList = urlModel.getUrlList()) != null && !urlList.isEmpty()) {
            return true;
        }
        return false;
    }

    /* JADX WARNING: Code restructure failed: missing block: B:12:0x0029, code lost:
        if (r6 != null) goto L_0x0020;
     */
    /* Code decompiled incorrectly, please refer to instructions dump. */
    private final X.Hwe LIZIZ(long r4, com.ss.android.ugc.aweme.base.model.UrlModel r6) {
        /*
            r3 = this;
            boolean r1 = r3.LIZ(r6)
            r0 = 0
            if (r1 != 0) goto L_0x0008
            return r0
        L_0x0008:
            X.Hwe r2 = new X.Hwe
            if (r6 == 0) goto L_0x0028
            java.util.List r1 = r6.getUrlList()
            if (r1 == 0) goto L_0x0028
            r0 = 0
            java.lang.String[] r0 = new java.lang.String[r0]
            java.lang.Object[] r1 = r1.toArray(r0)
            java.lang.String r0 = "null cannot be cast to non-null type kotlin.Array<T>"
            java.util.Objects.requireNonNull(r1, r0)
            java.lang.String[] r1 = (java.lang.String[]) r1
        L_0x0020:
            java.lang.String r0 = r6.getFileHash()
        L_0x0024:
            r2.<init>(r4, r1, r0)
            return r2
        L_0x0028:
            r1 = r0
            if (r6 == 0) goto L_0x0024
            goto L_0x0020
        */
        throw new UnsupportedOperationException("Method not decompiled: com.ss.android.ugc.aweme.comment.gift.model.GiftViewModel.LIZIZ(long, com.ss.android.ugc.aweme.base.model.UrlModel):X.Hwe");
    }

    public final void LIZ(long j, UrlModel urlModel) {
        Hwe LIZIZ2;
        if (urlModel != null && (LIZIZ2 = LIZIZ(j, urlModel)) != null) {
            Q4b.LJI.LIZ(LIZIZ2, new AnonymousClass9sZ(this, j));
        }
    }

    public final void LIZ(String str, String str2) {
        M12.LIZ(str, str2);
        LIZ().getValue();
        new Mjy().LIZ(GiftListApi.LIZIZ.LIZ(str, str2).LIZIZ(PhE.LIZIZ(PlI.LIZJ)).LIZ(Mk2.LIZ(Mk3.LIZ)).LIZ(new AnonymousClass9sW(this), new AnonymousClass9sX(this)));
    }

    public final void LIZ(Integer num, Long l, Long l2) {
        Object value = LIZLLL().getValue();
        2UX r2 = new 2UX();
        r2.LIZ("enter_from", this.LIZ);
        r2.LIZ("group_id", this.LIZIZ);
        r2.LIZ("author_id", this.LIZJ);
        r2.LIZ("product_id", l);
        r2.LIZ("is_success", num);
        r2.LIZ("previous_balance", l2);
        r2.LIZ("new_balance", value);
        n.LIZIZ(r2, "");
        2nK.LIZ("confirm_coin_recharge", r2.LIZ);
    }

    public final void LIZ(String str, Context context, int i, long j) {
        String str2 = str;
        M12.LIZ(str2);
        LIZLLL().setValue(Long.MIN_VALUE);
        ILiveOuterService LJJI = LiveOuterService.LJJI();
        n.LIZIZ(LJJI, "");
        int i2 = i;
        LJJI.LJ().LIZ(new AnonymousClass9sO(this, str2, i2, j, (Long) LIZLLL().getValue(), context));
    }
}
