package s7;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/* JADX INFO: loaded from: classes.dex */
public final class i implements InvocationHandler {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public final ArrayList f16926a;

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

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

    public i(ArrayList arrayList) {
        this.f16926a = arrayList;
    }

    @Override // java.lang.reflect.InvocationHandler
    public final Object invoke(Object obj, Method method, Object[] objArr) {
        P6.g.e(obj, "proxy");
        P6.g.e(method, "method");
        if (objArr == null) {
            objArr = new Object[0];
        }
        String name = method.getName();
        Class<?> returnType = method.getReturnType();
        if (P6.g.a(name, "supports") && P6.g.a(Boolean.TYPE, returnType)) {
            return Boolean.TRUE;
        }
        if (P6.g.a(name, "unsupported") && P6.g.a(Void.TYPE, returnType)) {
            this.f16927b = true;
            return null;
        }
        boolean zA = P6.g.a(name, "protocols");
        ArrayList arrayList = this.f16926a;
        if (zA && objArr.length == 0) {
            return arrayList;
        }
        if ((P6.g.a(name, "selectProtocol") || P6.g.a(name, "select")) && String.class.equals(returnType) && objArr.length == 1) {
            Object obj2 = objArr[0];
            if (obj2 instanceof List) {
                P6.g.c(obj2, "null cannot be cast to non-null type kotlin.collections.List<*>");
                List list = (List) obj2;
                int size = list.size();
                if (size >= 0) {
                    int i = 0;
                    while (true) {
                        Object obj3 = list.get(i);
                        P6.g.c(obj3, "null cannot be cast to non-null type kotlin.String");
                        String str = (String) obj3;
                        if (!arrayList.contains(str)) {
                            if (i == size) {
                                break;
                            }
                            i++;
                        } else {
                            this.f16928c = str;
                            return str;
                        }
                    }
                }
                String str2 = (String) arrayList.get(0);
                this.f16928c = str2;
                return str2;
            }
        }
        if ((!P6.g.a(name, "protocolSelected") && !P6.g.a(name, "selected")) || objArr.length != 1) {
            return method.invoke(this, Arrays.copyOf(objArr, objArr.length));
        }
        Object obj4 = objArr[0];
        P6.g.c(obj4, "null cannot be cast to non-null type kotlin.String");
        this.f16928c = (String) obj4;
        return null;
    }
}
