package kotlin.reflect.jvm.internal.impl.util;

import com.google.android.gms.measurement.api.AppMeasurementSdk;
import defpackage.cr4;
import defpackage.kp6;
import defpackage.pq6;
import defpackage.pw7;
import defpackage.sq3;
import defpackage.uz1;
import java.util.Arrays;
import java.util.Collection;
import kotlin.reflect.jvm.internal.impl.descriptors.FunctionDescriptor;
import kotlin.reflect.jvm.internal.impl.name.Name;
import kotlin.reflect.jvm.internal.impl.util.CheckResult;

/* JADX INFO: loaded from: classes3.dex */
public final class Checks {

    @kp6
    private final sq3<FunctionDescriptor, String> additionalCheck;

    @kp6
    private final Check[] checks;

    @pq6
    private final Name name;

    @pq6
    private final Collection<Name> nameList;

    @pq6
    private final pw7 regex;

    /* JADX WARN: Multi-variable type inference failed */
    private Checks(Name name, pw7 pw7Var, Collection<Name> collection, sq3<? super FunctionDescriptor, String> sq3Var, Check... checkArr) {
        this.name = name;
        this.regex = pw7Var;
        this.nameList = collection;
        this.additionalCheck = sq3Var;
        this.checks = checkArr;
    }

    @kp6
    public final CheckResult checkAll(@kp6 FunctionDescriptor functionDescriptor) {
        cr4.g(functionDescriptor, "functionDescriptor");
        for (Check check : this.checks) {
            String strInvoke = check.invoke(functionDescriptor);
            if (strInvoke != null) {
                return new CheckResult.IllegalSignature(strInvoke);
            }
        }
        String str = (String) this.additionalCheck.invoke(functionDescriptor);
        return str != null ? new CheckResult.IllegalSignature(str) : CheckResult.SuccessCheck.INSTANCE;
    }

    public final boolean isApplicable(@kp6 FunctionDescriptor functionDescriptor) {
        cr4.g(functionDescriptor, "functionDescriptor");
        if (this.name != null && !cr4.b(functionDescriptor.getName(), this.name)) {
            return false;
        }
        if (this.regex != null) {
            String strAsString = functionDescriptor.getName().asString();
            cr4.f(strAsString, "asString(...)");
            if (!this.regex.d(strAsString)) {
                return false;
            }
        }
        Collection<Name> collection = this.nameList;
        return collection == null || collection.contains(functionDescriptor.getName());
    }

    public /* synthetic */ Checks(Name name, Check[] checkArr, sq3 sq3Var, int i, uz1 uz1Var) {
        this(name, checkArr, (sq3<? super FunctionDescriptor, String>) ((i & 4) != 0 ? new sq3() { // from class: kotlin.reflect.jvm.internal.impl.util.Checks.2
            @Override // defpackage.sq3
            public final Void invoke(FunctionDescriptor functionDescriptor) {
                cr4.g(functionDescriptor, "<this>");
                return null;
            }
        } : sq3Var));
    }

    /* JADX WARN: 'this' call moved to the top of the method (can break code semantics) */
    public Checks(@kp6 Name name, @kp6 Check[] checkArr, @kp6 sq3<? super FunctionDescriptor, String> sq3Var) {
        this(name, (pw7) null, (Collection<Name>) null, sq3Var, (Check[]) Arrays.copyOf(checkArr, checkArr.length));
        cr4.g(name, AppMeasurementSdk.ConditionalUserProperty.NAME);
        cr4.g(checkArr, "checks");
        cr4.g(sq3Var, "additionalChecks");
    }

    public /* synthetic */ Checks(pw7 pw7Var, Check[] checkArr, sq3 sq3Var, int i, uz1 uz1Var) {
        this(pw7Var, checkArr, (sq3<? super FunctionDescriptor, String>) ((i & 4) != 0 ? new sq3() { // from class: kotlin.reflect.jvm.internal.impl.util.Checks.3
            @Override // defpackage.sq3
            public final Void invoke(FunctionDescriptor functionDescriptor) {
                cr4.g(functionDescriptor, "<this>");
                return null;
            }
        } : sq3Var));
    }

    /* JADX WARN: 'this' call moved to the top of the method (can break code semantics) */
    public Checks(@kp6 pw7 pw7Var, @kp6 Check[] checkArr, @kp6 sq3<? super FunctionDescriptor, String> sq3Var) {
        this((Name) null, pw7Var, (Collection<Name>) null, sq3Var, (Check[]) Arrays.copyOf(checkArr, checkArr.length));
        cr4.g(pw7Var, "regex");
        cr4.g(checkArr, "checks");
        cr4.g(sq3Var, "additionalChecks");
    }

    public /* synthetic */ Checks(Collection collection, Check[] checkArr, sq3 sq3Var, int i, uz1 uz1Var) {
        this((Collection<Name>) collection, checkArr, (sq3<? super FunctionDescriptor, String>) ((i & 4) != 0 ? new sq3() { // from class: kotlin.reflect.jvm.internal.impl.util.Checks.4
            @Override // defpackage.sq3
            public final Void invoke(FunctionDescriptor functionDescriptor) {
                cr4.g(functionDescriptor, "<this>");
                return null;
            }
        } : sq3Var));
    }

    /* JADX WARN: 'this' call moved to the top of the method (can break code semantics) */
    public Checks(@kp6 Collection<Name> collection, @kp6 Check[] checkArr, @kp6 sq3<? super FunctionDescriptor, String> sq3Var) {
        this((Name) null, (pw7) null, collection, sq3Var, (Check[]) Arrays.copyOf(checkArr, checkArr.length));
        cr4.g(collection, "nameList");
        cr4.g(checkArr, "checks");
        cr4.g(sq3Var, "additionalChecks");
    }
}
