package jo;

import bo.y;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import kotlin.jvm.internal.t;
import kotlin.jvm.internal.v;
import sm.c0;
import sm.u;

/* loaded from: classes3.dex */
public abstract class a {

    /* JADX INFO: Access modifiers changed from: private */
    /* renamed from: jo.a$a, reason: collision with other inner class name */
    /* loaded from: classes3.dex */
    public static final class C0521a {

        /* renamed from: a, reason: collision with root package name */
        private final jp.i f25100a;

        /* renamed from: b, reason: collision with root package name */
        private final y f25101b;

        /* renamed from: c, reason: collision with root package name */
        private final jp.n f25102c;

        public C0521a(jp.i iVar, y yVar, jp.n nVar) {
            this.f25100a = iVar;
            this.f25101b = yVar;
            this.f25102c = nVar;
        }

        public final y a() {
            return this.f25101b;
        }

        public final jp.i b() {
            return this.f25100a;
        }

        public final jp.n c() {
            return this.f25102c;
        }
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    /* loaded from: classes3.dex */
    public static final class b extends v implements dn.l {

        /* renamed from: p, reason: collision with root package name */
        final /* synthetic */ q f25103p;

        /* renamed from: q, reason: collision with root package name */
        final /* synthetic */ e[] f25104q;

        /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
        b(q qVar, e[] eVarArr) {
            super(1);
            this.f25103p = qVar;
            this.f25104q = eVarArr;
        }

        public final e a(int i10) {
            int Z;
            Map a10;
            e eVar;
            q qVar = this.f25103p;
            if (qVar != null && (a10 = qVar.a()) != null && (eVar = (e) a10.get(Integer.valueOf(i10))) != null) {
                return eVar;
            }
            e[] eVarArr = this.f25104q;
            if (i10 >= 0) {
                Z = sm.p.Z(eVarArr);
                if (i10 <= Z) {
                    return eVarArr[i10];
                }
            }
            return e.f25117e.a();
        }

        @Override // dn.l
        public /* bridge */ /* synthetic */ Object invoke(Object obj) {
            return a(((Number) obj).intValue());
        }
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    /* loaded from: classes3.dex */
    public static final class c extends v implements dn.l {

        /* renamed from: q, reason: collision with root package name */
        final /* synthetic */ C0521a f25106q;

        /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
        c(C0521a c0521a) {
            super(1);
            this.f25106q = c0521a;
        }

        @Override // dn.l
        /* renamed from: a, reason: merged with bridge method [inline-methods] */
        public final Boolean invoke(Object extractNullability) {
            t.g(extractNullability, "$this$extractNullability");
            return Boolean.valueOf(a.this.h(extractNullability, this.f25106q.b()));
        }
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    /* loaded from: classes3.dex */
    public static final class d extends v implements dn.l {

        /* renamed from: q, reason: collision with root package name */
        final /* synthetic */ jp.o f25108q;

        /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
        d(jp.o oVar) {
            super(1);
            this.f25108q = oVar;
        }

        @Override // dn.l
        /* renamed from: a, reason: merged with bridge method [inline-methods] */
        public final Iterable invoke(C0521a it) {
            jp.m d02;
            List w10;
            int v10;
            int v11;
            C0521a c0521a;
            t.g(it, "it");
            ArrayList arrayList = null;
            if (a.this.u()) {
                jp.i b10 = it.b();
                boolean z10 = false;
                if (b10 != null && this.f25108q.U(b10)) {
                    z10 = true;
                }
                if (z10) {
                    return null;
                }
            }
            jp.i b11 = it.b();
            if (b11 != null && (d02 = this.f25108q.d0(b11)) != null && (w10 = this.f25108q.w(d02)) != null) {
                List list = w10;
                List H = this.f25108q.H(it.b());
                jp.o oVar = this.f25108q;
                a aVar = a.this;
                Iterator it2 = list.iterator();
                Iterator it3 = H.iterator();
                v10 = sm.v.v(list, 10);
                v11 = sm.v.v(H, 10);
                ArrayList arrayList2 = new ArrayList(Math.min(v10, v11));
                while (it2.hasNext() && it3.hasNext()) {
                    Object next = it2.next();
                    jp.l lVar = (jp.l) it3.next();
                    jp.n nVar = (jp.n) next;
                    if (oVar.R(lVar)) {
                        c0521a = new C0521a(null, it.a(), nVar);
                    } else {
                        jp.i m02 = oVar.m0(lVar);
                        c0521a = new C0521a(m02, aVar.c(m02, it.a()), nVar);
                    }
                    arrayList2.add(c0521a);
                }
                arrayList = arrayList2;
            }
            return arrayList;
        }
    }

    private final i B(i iVar, i iVar2) {
        return iVar == null ? iVar2 : iVar2 == null ? iVar : (!iVar.d() || iVar2.d()) ? (iVar.d() || !iVar2.d()) ? (iVar.c().compareTo(iVar2.c()) >= 0 && iVar.c().compareTo(iVar2.c()) > 0) ? iVar : iVar2 : iVar : iVar2;
    }

    private final List C(jp.i iVar) {
        return f(new C0521a(iVar, c(iVar, n()), null), new d(v()));
    }

    /* JADX INFO: Access modifiers changed from: private */
    public final y c(jp.i iVar, y yVar) {
        return i().c(yVar, j(iVar));
    }

    private final e d(jp.i iVar) {
        h hVar;
        h t10 = t(iVar);
        f fVar = null;
        if (t10 == null) {
            jp.i q10 = q(iVar);
            hVar = q10 != null ? t(q10) : null;
        } else {
            hVar = t10;
        }
        jp.o v10 = v();
        sn.c cVar = sn.c.f35881a;
        if (cVar.l(s(v10.c0(iVar)))) {
            fVar = f.READ_ONLY;
        } else if (cVar.k(s(v10.l(iVar)))) {
            fVar = f.MUTABLE;
        }
        return new e(hVar, fVar, v().O(iVar) || A(iVar), hVar != t10);
    }

    /* JADX WARN: Code restructure failed: missing block: B:80:0x0130, code lost:
    
        if ((r0 != null && r0.c()) != false) goto L93;
     */
    /* JADX WARN: Removed duplicated region for block: B:92:0x015a  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    private final e e(C0521a c0521a) {
        List k10;
        List list;
        i d10;
        boolean z10;
        jp.n c10;
        i iVar;
        List x02;
        List z02;
        jp.m d02;
        if (c0521a.b() == null) {
            jp.o v10 = v();
            jp.n c11 = c0521a.c();
            if ((c11 != null ? v10.s(c11) : null) == jp.s.IN) {
                return e.f25117e.a();
            }
        }
        boolean z11 = c0521a.c() == null;
        jp.i b10 = c0521a.b();
        if (b10 == null || (list = j(b10)) == null) {
            k10 = u.k();
            list = k10;
        }
        jp.o v11 = v();
        jp.i b11 = c0521a.b();
        jp.n C = (b11 == null || (d02 = v11.d0(b11)) == null) ? null : v11.C(d02);
        boolean z12 = m() == bo.b.TYPE_PARAMETER_BOUNDS;
        if (z11) {
            if (!z12 && p()) {
                jp.i b12 = c0521a.b();
                if (b12 != null && w(b12)) {
                    Iterable l10 = l();
                    ArrayList arrayList = new ArrayList();
                    for (Object obj : l10) {
                        if (!i().m(obj)) {
                            arrayList.add(obj);
                        }
                    }
                    z02 = c0.z0(arrayList, list);
                    list = z02;
                }
            }
            x02 = c0.x0(l(), list);
            list = x02;
        }
        f e10 = i().e(list);
        i f10 = i().f(list, new c(c0521a));
        if (f10 != null) {
            return new e(f10.c(), e10, f10.c() == h.NOT_NULL && C != null, f10.d());
        }
        bo.b m10 = (z11 || z12) ? m() : bo.b.TYPE_USE;
        y a10 = c0521a.a();
        bo.r a11 = a10 != null ? a10.a(m10) : null;
        i k11 = C != null ? k(C) : null;
        if (k11 == null || (d10 = i.b(k11, h.NOT_NULL, false, 2, null)) == null) {
            d10 = a11 != null ? a11.d() : null;
        }
        if ((k11 != null ? k11.c() : null) != h.NOT_NULL) {
            if (C != null) {
            }
            z10 = false;
            c10 = c0521a.c();
            if (c10 != null || (iVar = k(c10)) == null) {
                iVar = null;
            } else if (iVar.c() == h.NULLABLE) {
                iVar = i.b(iVar, h.FORCE_FLEXIBILITY, false, 2, null);
            }
            i B = B(iVar, d10);
            return new e(B != null ? B.c() : null, e10, z10, B == null && B.d());
        }
        z10 = true;
        c10 = c0521a.c();
        if (c10 != null) {
        }
        iVar = null;
        i B2 = B(iVar, d10);
        return new e(B2 != null ? B2.c() : null, e10, z10, B2 == null && B2.d());
    }

    private final List f(Object obj, dn.l lVar) {
        ArrayList arrayList = new ArrayList(1);
        g(obj, arrayList, lVar);
        return arrayList;
    }

    private final void g(Object obj, List list, dn.l lVar) {
        list.add(obj);
        Iterable iterable = (Iterable) lVar.invoke(obj);
        if (iterable != null) {
            Iterator it = iterable.iterator();
            while (it.hasNext()) {
                g(it.next(), list, lVar);
            }
        }
    }

    private final i k(jp.n nVar) {
        boolean z10;
        boolean z11;
        boolean z12;
        List arrayList;
        boolean z13;
        jp.o v10 = v();
        if (!z(nVar)) {
            return null;
        }
        List j10 = v10.j(nVar);
        List list = j10;
        boolean z14 = list instanceof Collection;
        if (!z14 || !list.isEmpty()) {
            Iterator it = list.iterator();
            while (it.hasNext()) {
                if (!v10.s0((jp.i) it.next())) {
                    z10 = false;
                    break;
                }
            }
        }
        z10 = true;
        if (z10) {
            return null;
        }
        if (!z14 || !list.isEmpty()) {
            Iterator it2 = list.iterator();
            while (it2.hasNext()) {
                if (t((jp.i) it2.next()) != null) {
                    z11 = true;
                    break;
                }
            }
        }
        z11 = false;
        if (z11) {
            arrayList = j10;
        } else {
            if (!z14 || !list.isEmpty()) {
                Iterator it3 = list.iterator();
                while (it3.hasNext()) {
                    if (q((jp.i) it3.next()) != null) {
                        z12 = true;
                        break;
                    }
                }
            }
            z12 = false;
            if (!z12) {
                return null;
            }
            arrayList = new ArrayList();
            Iterator it4 = list.iterator();
            while (it4.hasNext()) {
                jp.i q10 = q((jp.i) it4.next());
                if (q10 != null) {
                    arrayList.add(q10);
                }
            }
        }
        List list2 = arrayList;
        if (!(list2 instanceof Collection) || !list2.isEmpty()) {
            Iterator it5 = list2.iterator();
            while (it5.hasNext()) {
                if (!v10.r0((jp.i) it5.next())) {
                    z13 = false;
                    break;
                }
            }
        }
        z13 = true;
        return new i(z13 ? h.NULLABLE : h.NOT_NULL, arrayList != j10);
    }

    private final h t(jp.i iVar) {
        jp.o v10 = v();
        if (v10.p(v10.c0(iVar))) {
            return h.NULLABLE;
        }
        if (v10.p(v10.l(iVar))) {
            return null;
        }
        return h.NOT_NULL;
    }

    public abstract boolean A(jp.i iVar);

    /* JADX WARN: Code restructure failed: missing block: B:15:0x0066, code lost:
    
        if (r10 != false) goto L24;
     */
    /* JADX WARN: Removed duplicated region for block: B:27:0x006e  */
    /* JADX WARN: Removed duplicated region for block: B:30:0x0079  */
    /* JADX WARN: Removed duplicated region for block: B:63:0x0070  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final dn.l b(jp.i iVar, Iterable overrides, q qVar, boolean z10) {
        int v10;
        boolean z11;
        int size;
        int i10;
        Object f02;
        jp.i b10;
        boolean z12;
        t.g(iVar, "<this>");
        t.g(overrides, "overrides");
        List C = C(iVar);
        v10 = sm.v.v(overrides, 10);
        ArrayList arrayList = new ArrayList(v10);
        Iterator it = overrides.iterator();
        while (it.hasNext()) {
            arrayList.add(C((jp.i) it.next()));
        }
        if (!r()) {
            if (x()) {
                if (!(overrides instanceof Collection) || !((Collection) overrides).isEmpty()) {
                    Iterator it2 = overrides.iterator();
                    while (it2.hasNext()) {
                        if (!y(iVar, (jp.i) it2.next())) {
                            z12 = true;
                            break;
                        }
                    }
                }
                z12 = false;
            }
            z11 = false;
            size = !z11 ? 1 : C.size();
            e[] eVarArr = new e[size];
            i10 = 0;
            while (i10 < size) {
                e e10 = e((C0521a) C.get(i10));
                ArrayList arrayList2 = new ArrayList();
                Iterator it3 = arrayList.iterator();
                while (it3.hasNext()) {
                    f02 = c0.f0((List) it3.next(), i10);
                    C0521a c0521a = (C0521a) f02;
                    e d10 = (c0521a == null || (b10 = c0521a.b()) == null) ? null : d(b10);
                    if (d10 != null) {
                        arrayList2.add(d10);
                    }
                }
                eVarArr[i10] = s.a(e10, arrayList2, i10 == 0 && x(), i10 == 0 && o(), z10);
                i10++;
            }
            return new b(qVar, eVarArr);
        }
        z11 = true;
        if (!z11) {
        }
        e[] eVarArr2 = new e[size];
        i10 = 0;
        while (i10 < size) {
        }
        return new b(qVar, eVarArr2);
    }

    public abstract boolean h(Object obj, jp.i iVar);

    public abstract bo.a i();

    public abstract Iterable j(jp.i iVar);

    public abstract Iterable l();

    public abstract bo.b m();

    public abstract y n();

    public abstract boolean o();

    public abstract boolean p();

    public abstract jp.i q(jp.i iVar);

    public boolean r() {
        return false;
    }

    public abstract ro.d s(jp.i iVar);

    public abstract boolean u();

    public abstract jp.o v();

    public abstract boolean w(jp.i iVar);

    public abstract boolean x();

    public abstract boolean y(jp.i iVar, jp.i iVar2);

    public abstract boolean z(jp.n nVar);
}
