package o4;

import C0.J;
import T0.C0606q;
import android.content.Context;
import androidx.navigation.C1134i;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.net.URL;
import java.util.ArrayList;
import java.util.HashMap;
import javax.net.ssl.SSLSocket;
import m1.p;
import p0.InterfaceC2712s;
import q1.AbstractC2831c;
import q1.C2833e;
import q1.C2837i;
import r0.C2863b;
import r1.InterfaceC2870d;
import r3.q;
import t3.InterfaceC2949b;
import v1.C3089b;
import v4.InterfaceC3128a;
import x3.C3216a;
import x3.C3218c;
import x3.C3222g;
import x3.C3223h;
import y3.InterfaceC3267d;

/* JADX INFO: loaded from: classes3.dex */
public final class f implements InterfaceC2949b {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public final /* synthetic */ int f21848a;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public Object f21849b;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public Object f21850c;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public Object f21851d;

    public /* synthetic */ f(Object obj, Object obj2, Object obj3, int i6) {
        this.f21848a = i6;
        this.f21850c = obj;
        this.f21849b = obj2;
        this.f21851d = obj3;
    }

    public static Method e(Class cls, String str, Class[] clsArr) {
        if (cls != null) {
            try {
                if ((cls.getModifiers() & 1) == 0) {
                    return e(cls.getSuperclass(), str, clsArr);
                }
                Method method = cls.getMethod(str, clsArr);
                try {
                    if ((method.getModifiers() & 1) != 0) {
                        return method;
                    }
                } catch (NoSuchMethodException unused) {
                    return method;
                }
            } catch (NoSuchMethodException unused2) {
                return null;
            }
        }
        return null;
    }

    public r3.j a() {
        String strConcat = ((String) this.f21849b) == null ? " backendName" : "";
        if (((o3.c) this.f21851d) == null) {
            strConcat = strConcat.concat(" priority");
        }
        if (strConcat.isEmpty()) {
            return new r3.j((String) this.f21849b, (byte[]) this.f21850c, (o3.c) this.f21851d);
        }
        throw new IllegalStateException("Missing required properties:".concat(strConcat));
    }

    public float b(AbstractC2831c abstractC2831c) {
        if (!(abstractC2831c instanceof C2837i)) {
            if (abstractC2831c instanceof C2833e) {
                return ((C2833e) abstractC2831c).j();
            }
            return 0.0f;
        }
        String strH = ((C2837i) abstractC2831c).h();
        HashMap map = (HashMap) this.f21849b;
        if (map.containsKey(strH)) {
            return ((InterfaceC2870d) map.get(strH)).value();
        }
        HashMap map2 = (HashMap) this.f21850c;
        if (map2.containsKey(strH)) {
            return ((Integer) map2.get(strH)).floatValue();
        }
        return 0.0f;
    }

    public InterfaceC2712s c() {
        return ((C2863b) this.f21851d).f23802a.f23800c;
    }

    public Method d(Class cls) {
        Class cls2;
        Method methodE = e(cls, (String) this.f21849b, (Class[]) this.f21851d);
        if (methodE == null || (cls2 = (Class) this.f21850c) == null || cls2.isAssignableFrom(methodE.getReturnType())) {
            return methodE;
        }
        return null;
    }

    public long f() {
        return ((C2863b) this.f21851d).f23802a.f23801d;
    }

    public Object g(SSLSocket sSLSocket, Object... objArr) {
        Method methodD = d(sSLSocket.getClass());
        if (methodD == null) {
            throw new AssertionError("Method " + ((String) this.f21849b) + " not supported for object " + sSLSocket);
        }
        try {
            return methodD.invoke(sSLSocket, objArr);
        } catch (IllegalAccessException e6) {
            AssertionError assertionError = new AssertionError("Unexpectedly could not call: " + methodD);
            assertionError.initCause(e6);
            throw assertionError;
        }
    }

    @Override // v4.InterfaceC3128a
    public Object get() {
        switch (this.f21848a) {
            case 5:
                return new q(new u4.c(3), new u4.c(2), (w3.b) ((C0606q) this.f21850c).get(), (C3222g) ((R3.a) this.f21849b).get(), (C3223h) ((J) this.f21851d).get());
            default:
                return new C3218c((Context) ((M0.a) this.f21850c).f4197a, (InterfaceC3267d) ((InterfaceC3128a) this.f21849b).get(), (C3216a) ((C1134i) this.f21851d).get());
        }
    }

    public void h(SSLSocket sSLSocket, Object... objArr) {
        try {
            Method methodD = d(sSLSocket.getClass());
            if (methodD == null) {
                return;
            }
            try {
                methodD.invoke(sSLSocket, objArr);
            } catch (IllegalAccessException unused) {
            }
        } catch (InvocationTargetException e6) {
            Throwable targetException = e6.getTargetException();
            if (targetException instanceof RuntimeException) {
                throw ((RuntimeException) targetException);
            }
            AssertionError assertionError = new AssertionError("Unexpected exception");
            assertionError.initCause(targetException);
            throw assertionError;
        }
    }

    public Object i(SSLSocket sSLSocket, Object... objArr) {
        try {
            return g(sSLSocket, objArr);
        } catch (InvocationTargetException e6) {
            Throwable targetException = e6.getTargetException();
            if (targetException instanceof RuntimeException) {
                throw ((RuntimeException) targetException);
            }
            AssertionError assertionError = new AssertionError("Unexpected exception");
            assertionError.initCause(targetException);
            throw assertionError;
        }
    }

    public boolean j(int i6, p pVar, u1.d dVar) {
        int[] iArr = dVar.f24475m0;
        int i7 = iArr[0];
        C3089b c3089b = (C3089b) this.f21849b;
        c3089b.f25242a = i7;
        c3089b.f25243b = iArr[1];
        c3089b.f25244c = dVar.o();
        c3089b.f25245d = dVar.l();
        c3089b.f25250i = false;
        c3089b.f25251j = i6;
        boolean z6 = c3089b.f25242a == 3;
        boolean z7 = c3089b.f25243b == 3;
        boolean z8 = z6 && dVar.f24450T > 0.0f;
        boolean z9 = z7 && dVar.f24450T > 0.0f;
        int[] iArr2 = dVar.f24482t;
        if (z8 && iArr2[0] == 4) {
            c3089b.f25242a = 1;
        }
        if (z9 && iArr2[1] == 4) {
            c3089b.f25243b = 1;
        }
        pVar.a(dVar, c3089b);
        dVar.K(c3089b.f25246e);
        dVar.H(c3089b.f25247f);
        dVar.f24435E = c3089b.f25249h;
        dVar.E(c3089b.f25248g);
        c3089b.f25251j = 0;
        return c3089b.f25250i;
    }

    public void k(String str) {
        if (str == null) {
            throw new NullPointerException("Null backendName");
        }
        this.f21849b = str;
    }

    public void l(InterfaceC2712s interfaceC2712s) {
        ((C2863b) this.f21851d).f23802a.f23800c = interfaceC2712s;
    }

    public void m(h1.c cVar) {
        ((C2863b) this.f21851d).f23802a.f23798a = cVar;
    }

    public void n(h1.m mVar) {
        ((C2863b) this.f21851d).f23802a.f23799b = mVar;
    }

    public void o(long j4) {
        ((C2863b) this.f21851d).f23802a.f23801d = j4;
    }

    public void p(u1.e eVar, int i6, int i7, int i8) {
        eVar.getClass();
        int i9 = eVar.Y;
        int i10 = eVar.f24454Z;
        eVar.Y = 0;
        eVar.f24454Z = 0;
        eVar.K(i7);
        eVar.H(i8);
        if (i9 < 0) {
            eVar.Y = 0;
        } else {
            eVar.Y = i9;
        }
        if (i10 < 0) {
            eVar.f24454Z = 0;
        } else {
            eVar.f24454Z = i10;
        }
        u1.e eVar2 = (u1.e) this.f21851d;
        eVar2.f24496q0 = i6;
        eVar2.P();
    }

    public void q(u1.e eVar) {
        ArrayList arrayList = (ArrayList) this.f21850c;
        arrayList.clear();
        int size = eVar.f24493n0.size();
        for (int i6 = 0; i6 < size; i6++) {
            u1.d dVar = (u1.d) eVar.f24493n0.get(i6);
            int[] iArr = dVar.f24475m0;
            if (iArr[0] == 3 || iArr[1] == 3) {
                arrayList.add(dVar);
            }
        }
        eVar.f24495p0.f25254b = true;
    }

    public f(C2863b c2863b) {
        this.f21848a = 2;
        this.f21851d = c2863b;
        this.f21850c = new l2.c(this, 15);
    }

    public f(u1.e eVar) {
        this.f21848a = 6;
        this.f21850c = new ArrayList();
        this.f21849b = new C3089b();
        this.f21851d = eVar;
    }

    public f(int i6) {
        this.f21848a = i6;
        switch (i6) {
            case 4:
                break;
            default:
                this.f21850c = new HashMap();
                this.f21849b = new HashMap();
                this.f21851d = new HashMap();
                break;
        }
    }

    public f(URL url, q3.n nVar, String str) {
        this.f21848a = 1;
        this.f21850c = url;
        this.f21851d = nVar;
        this.f21849b = str;
    }
}
