package o;

import com.google.android.gms.common.internal.Preconditions;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.regex.Pattern;
import java.util.regex.PatternSyntaxException;

/* compiled from: r8-map-id-3b7cc9102578c509342fa2f0fabed2bfc72239cd258d579fc679bfcbc198b048 */
/* loaded from: classes.dex */
public final class Ln0 {
    public final String a;
    public final int b;
    public Boolean c;
    public Boolean d;
    public Long e;
    public Long f;
    public final /* synthetic */ int g;
    public final /* synthetic */ Nn0 h;
    public final AbstractC2665ut0 i;

    public Ln0(Nn0 nn0, String str, int i, AbstractC2665ut0 abstractC2665ut0, int i2) {
        this.g = i2;
        this.h = nn0;
        this.a = str;
        this.b = i;
        this.i = abstractC2665ut0;
    }

    public static Boolean c(Boolean bool, boolean z) {
        if (bool == null) {
            return null;
        }
        return Boolean.valueOf(bool.booleanValue() != z);
    }

    /* JADX WARN: Can't fix incorrect switch cases order, some code will duplicate */
    public static Boolean d(String str, C1520iq0 c1520iq0, Nq0 nq0) {
        List listU;
        Preconditions.checkNotNull(c1520iq0);
        if (str != null && c1520iq0.p() && c1520iq0.x() != 1 && (c1520iq0.x() != 7 ? c1520iq0.q() : c1520iq0.v() != 0)) {
            int iX = c1520iq0.x();
            boolean zT = c1520iq0.t();
            String strR = (zT || iX == 2 || iX == 7) ? c1520iq0.r() : c1520iq0.r().toUpperCase(Locale.ENGLISH);
            if (c1520iq0.v() == 0) {
                listU = null;
            } else {
                listU = c1520iq0.u();
                if (!zT) {
                    ArrayList arrayList = new ArrayList(listU.size());
                    Iterator it = listU.iterator();
                    while (it.hasNext()) {
                        arrayList.add(((String) it.next()).toUpperCase(Locale.ENGLISH));
                    }
                    listU = Collections.unmodifiableList(arrayList);
                }
            }
            String str2 = iX == 2 ? strR : null;
            if (iX != 7 ? strR != null : listU != null && !listU.isEmpty()) {
                if (!zT && iX != 2) {
                    str = str.toUpperCase(Locale.ENGLISH);
                }
                switch (iX - 1) {
                    case 1:
                        if (str2 != null) {
                            try {
                                return Boolean.valueOf(Pattern.compile(str2, true != zT ? 66 : 0).matcher(str).matches());
                            } catch (PatternSyntaxException unused) {
                                if (nq0 != null) {
                                    nq0.i.c(str2, "Invalid regular expression in REGEXP audience filter. expression");
                                    break;
                                }
                            }
                        }
                        break;
                    case 2:
                        return Boolean.valueOf(str.startsWith(strR));
                    case 3:
                        return Boolean.valueOf(str.endsWith(strR));
                    case 4:
                        return Boolean.valueOf(str.contains(strR));
                    case 5:
                        return Boolean.valueOf(str.equals(strR));
                    case 6:
                        if (listU != null) {
                            return Boolean.valueOf(listU.contains(str));
                        }
                        break;
                }
            }
        }
        return null;
    }

    /* JADX WARN: Removed duplicated region for block: B:38:0x0089  */
    /* JADX WARN: Removed duplicated region for block: B:80:0x0107  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    public static java.lang.Boolean e(java.math.BigDecimal r8, o.C1233fq0 r9, double r10) {
        /*
            Method dump skipped, instructions count: 280
            To view this dump add '--comments-level debug' option
        */
        throw new UnsupportedOperationException("Method not decompiled: o.Ln0.e(java.math.BigDecimal, o.fq0, double):java.lang.Boolean");
    }

    /* JADX WARN: Removed duplicated region for block: B:150:0x035f  */
    /* JADX WARN: Removed duplicated region for block: B:163:0x03ce  */
    /* JADX WARN: Removed duplicated region for block: B:164:0x03d1  */
    /* JADX WARN: Removed duplicated region for block: B:167:0x03da A[RETURN] */
    /* JADX WARN: Removed duplicated region for block: B:169:0x03dc  */
    /* JADX WARN: Removed duplicated region for block: B:234:0x03c9 A[EDGE_INSN: B:234:0x03c9->B:161:0x03c9 BREAK  A[LOOP:3: B:89:0x0246->B:238:0x0246], SYNTHETIC] */
    /* JADX WARN: Removed duplicated region for block: B:58:0x017c  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    public boolean a(java.lang.Long r22, java.lang.Long r23, o.C2756vr0 r24, long r25, o.Jo0 r27, boolean r28) {
        /*
            Method dump skipped, instructions count: 1085
            To view this dump add '--comments-level debug' option
        */
        throw new UnsupportedOperationException("Method not decompiled: o.Ln0.a(java.lang.Long, java.lang.Long, o.vr0, long, o.Jo0, boolean):boolean");
    }

    public boolean b(Long l, Long l2, Zr0 zr0, boolean z) {
        boolean z2;
        Boolean boolC;
        Boolean boolE;
        Boolean boolE2;
        Boolean boolE3;
        C3144zv0.a();
        Kr0 kr0 = (Kr0) this.h.a;
        C1421ho0 c1421ho0 = kr0.d;
        Eq0 eq0 = kr0.j;
        Nq0 nq0 = kr0.f;
        boolean zC = c1421ho0.C(this.a, AbstractC1900mq0.D0);
        C1425hq0 c1425hq0 = (C1425hq0) this.i;
        boolean zT = c1425hq0.t();
        boolean zU = c1425hq0.u();
        boolean zW = c1425hq0.w();
        boolean z3 = zT || zU || zW;
        if (z && !z3) {
            Kr0.l(nq0);
            nq0.n.d("Property filter already evaluated true and it is not associated with an enhanced audience. audience ID, filter ID", Integer.valueOf(this.b), c1425hq0.p() ? Integer.valueOf(c1425hq0.q()) : null);
            return true;
        }
        C0946cq0 c0946cq0S = c1425hq0.s();
        boolean zU2 = c0946cq0S.u();
        if (!zr0.u()) {
            z2 = zW;
            if (!zr0.y()) {
                if (!zr0.s()) {
                    Kr0.l(nq0);
                    nq0.i.c(eq0.c(zr0.r()), "User property has no value, property");
                } else if (c0946cq0S.p()) {
                    String strT = zr0.t();
                    C1520iq0 c1520iq0Q = c0946cq0S.q();
                    Kr0.l(nq0);
                    boolC = c(d(strT, c1520iq0Q, nq0), zU2);
                } else if (!c0946cq0S.r()) {
                    Kr0.l(nq0);
                    nq0.i.c(eq0.c(zr0.r()), "No string or number filter defined. property");
                } else if (C1720kv0.T(zr0.t())) {
                    String strT2 = zr0.t();
                    C1233fq0 c1233fq0S = c0946cq0S.s();
                    if (C1720kv0.T(strT2)) {
                        try {
                            boolE = e(new BigDecimal(strT2), c1233fq0S, 0.0d);
                        } catch (NumberFormatException unused) {
                        }
                        boolC = c(boolE, zU2);
                    } else {
                        boolE = null;
                        boolC = c(boolE, zU2);
                    }
                } else {
                    Kr0.l(nq0);
                    nq0.i.d("Invalid user property value for Numeric number filter. property, value", eq0.c(zr0.r()), zr0.t());
                }
                boolC = null;
            } else if (c0946cq0S.r()) {
                double dZ = zr0.z();
                try {
                    boolE2 = e(new BigDecimal(dZ), c0946cq0S.s(), Math.ulp(dZ));
                } catch (NumberFormatException unused2) {
                    boolE2 = null;
                }
                boolC = c(boolE2, zU2);
            } else {
                Kr0.l(nq0);
                nq0.i.c(eq0.c(zr0.r()), "No number filter for double property. property");
                boolC = null;
            }
        } else if (c0946cq0S.r()) {
            z2 = zW;
            try {
                boolE3 = e(new BigDecimal(zr0.v()), c0946cq0S.s(), 0.0d);
            } catch (NumberFormatException unused3) {
                boolE3 = null;
            }
            boolC = c(boolE3, zU2);
        } else {
            Kr0.l(nq0);
            nq0.i.c(eq0.c(zr0.r()), "No number filter for long property. property");
            z2 = zW;
            boolC = null;
        }
        Kr0.l(nq0);
        nq0.n.c(boolC == null ? "null" : boolC, "Property filter result");
        if (boolC == null) {
            return false;
        }
        this.c = Boolean.TRUE;
        if (!z2 || boolC.booleanValue()) {
            if (!z || c1425hq0.t()) {
                this.d = boolC;
            }
            if (boolC.booleanValue() && z3 && zr0.p()) {
                long jQ = zr0.q();
                if (l != null) {
                    jQ = l.longValue();
                }
                if (zC && c1425hq0.t() && !c1425hq0.u() && l2 != null) {
                    jQ = l2.longValue();
                }
                if (c1425hq0.u()) {
                    this.f = Long.valueOf(jQ);
                } else {
                    this.e = Long.valueOf(jQ);
                }
            }
        }
        return true;
    }
}
