package g3;

import V2.P2;
import V2.Q2;
import V4.D0;
import V4.E;
import V4.N;
import a.AbstractC0872a;
import android.content.Context;
import com.debridstream.tv.PlayerViewModel;
import java.util.Locale;
import x4.AbstractC3251q;
import x4.AbstractC3252r;

/* JADX INFO: loaded from: classes.dex */
public final class p {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public static final a5.c f16541a;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public static final e5.c f16542b;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public static volatile String f16543c;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public static volatile long f16544d;

    static {
        D0 d0D = E.d();
        c5.e eVar = N.f8259a;
        f16541a = E.c(AbstractC0872a.a0(d0D, c5.d.f13466b));
        f16542b = e5.d.a();
    }

    /* JADX WARN: Removed duplicated region for block: B:18:0x003c  */
    /* JADX WARN: Removed duplicated region for block: B:31:0x0059  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public static final String a(n nVar, long j4, long j6, P2 p22) {
        int iIntValue;
        int iIntValue2;
        String lowerCase = S4.p.o1(nVar.f16514b).toString().toLowerCase(Locale.ROOT);
        kotlin.jvm.internal.o.g(lowerCase, "toLowerCase(...)");
        if (S4.p.Q0(lowerCase)) {
            lowerCase = "movie";
        }
        String str = lowerCase;
        Integer num = null;
        if (p22 == null) {
            iIntValue = 1;
        } else {
            P2 p23 = p22.f7480c ? p22 : null;
            if (p23 != null) {
                int i6 = p23.f7481d;
                Integer numValueOf = Integer.valueOf(i6);
                if (i6 <= 0) {
                    numValueOf = null;
                }
                if (numValueOf != null) {
                    iIntValue = numValueOf.intValue();
                }
            }
        }
        if (p22 == null) {
            iIntValue2 = 1;
        } else {
            P2 p24 = p22.f7480c ? p22 : null;
            if (p24 != null) {
                int i7 = p24.f7482e;
                Integer numValueOf2 = Integer.valueOf(i7);
                if (i7 <= 0) {
                    numValueOf2 = null;
                }
                if (numValueOf2 != null) {
                    iIntValue2 = numValueOf2.intValue();
                }
            }
        }
        if (p22 != null) {
            if (!p22.f7480c) {
                p22 = null;
            }
            if (p22 != null) {
                num = p22.f7483f;
            }
        }
        if (j4 < 0) {
            j4 = 0;
        }
        double d6 = (j4 / j6) * 100.0d;
        return AbstractC3251q.m0(AbstractC3252r.B(Integer.valueOf(nVar.f16513a), str, Integer.valueOf(iIntValue), Integer.valueOf(iIntValue2), Integer.valueOf(num != null ? num.intValue() : 0), Integer.valueOf(L4.a.v((int) d6, 0, 100)), Boolean.valueOf(d6 >= 80.0d)), "|", null, null, null, 62);
    }

    public static void b(Context context, PlayerViewModel playerViewModel, long j4, long j6, String trigger) {
        kotlin.jvm.internal.o.h(trigger, "trigger");
        Context applicationContext = context.getApplicationContext();
        Q2 q22 = (Q2) playerViewModel.getUiState().getValue();
        n nVar = q22.f7502g;
        if (nVar != null && j6 > 0) {
            E.y(f16541a, null, null, new o(nVar, j4, j6, q22.f7500e, applicationContext, playerViewModel, trigger, null), 3);
        }
    }
}
