package androidx.constraintlayout.widget;

import android.content.Context;
import android.content.res.TypedArray;
import android.util.Log;
import android.util.SparseArray;
import android.util.Xml;
import java.util.ArrayList;
import org.xmlpull.v1.XmlPullParser;

/* JADX INFO: compiled from: ConstraintLayoutStates.java */
/* JADX INFO: loaded from: classes.dex */
public class c {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    private final ConstraintLayout f1328a;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    d f1329b;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    int f1330c = -1;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    int f1331d = -1;

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    private SparseArray<a> f1332e = new SparseArray<>();

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    private SparseArray<d> f1333f = new SparseArray<>();

    /* JADX INFO: compiled from: ConstraintLayoutStates.java */
    static class a {

        /* JADX INFO: renamed from: a, reason: collision with root package name */
        int f1334a;

        /* JADX INFO: renamed from: b, reason: collision with root package name */
        ArrayList<b> f1335b = new ArrayList<>();

        /* JADX INFO: renamed from: c, reason: collision with root package name */
        int f1336c;

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

        public a(Context context, XmlPullParser xmlPullParser) {
            this.f1336c = -1;
            TypedArray typedArrayObtainStyledAttributes = context.obtainStyledAttributes(Xml.asAttributeSet(xmlPullParser), i.S5);
            int indexCount = typedArrayObtainStyledAttributes.getIndexCount();
            for (int i3 = 0; i3 < indexCount; i3++) {
                int index = typedArrayObtainStyledAttributes.getIndex(i3);
                if (index == i.T5) {
                    this.f1334a = typedArrayObtainStyledAttributes.getResourceId(index, this.f1334a);
                } else if (index == i.U5) {
                    this.f1336c = typedArrayObtainStyledAttributes.getResourceId(index, this.f1336c);
                    String resourceTypeName = context.getResources().getResourceTypeName(this.f1336c);
                    context.getResources().getResourceName(this.f1336c);
                    if ("layout".equals(resourceTypeName)) {
                        d dVar = new d();
                        this.f1337d = dVar;
                        dVar.f(context, this.f1336c);
                    }
                }
            }
            typedArrayObtainStyledAttributes.recycle();
        }

        void a(b bVar) {
            this.f1335b.add(bVar);
        }

        public int b(float f3, float f4) {
            for (int i3 = 0; i3 < this.f1335b.size(); i3++) {
                if (this.f1335b.get(i3).a(f3, f4)) {
                    return i3;
                }
            }
            return -1;
        }
    }

    /* JADX INFO: compiled from: ConstraintLayoutStates.java */
    static class b {

        /* JADX INFO: renamed from: a, reason: collision with root package name */
        float f1338a;

        /* JADX INFO: renamed from: b, reason: collision with root package name */
        float f1339b;

        /* JADX INFO: renamed from: c, reason: collision with root package name */
        float f1340c;

        /* JADX INFO: renamed from: d, reason: collision with root package name */
        float f1341d;

        /* JADX INFO: renamed from: e, reason: collision with root package name */
        int f1342e;

        /* JADX INFO: renamed from: f, reason: collision with root package name */
        d f1343f;

        public b(Context context, XmlPullParser xmlPullParser) {
            this.f1338a = Float.NaN;
            this.f1339b = Float.NaN;
            this.f1340c = Float.NaN;
            this.f1341d = Float.NaN;
            this.f1342e = -1;
            TypedArray typedArrayObtainStyledAttributes = context.obtainStyledAttributes(Xml.asAttributeSet(xmlPullParser), i.i6);
            int indexCount = typedArrayObtainStyledAttributes.getIndexCount();
            for (int i3 = 0; i3 < indexCount; i3++) {
                int index = typedArrayObtainStyledAttributes.getIndex(i3);
                if (index == i.j6) {
                    this.f1342e = typedArrayObtainStyledAttributes.getResourceId(index, this.f1342e);
                    String resourceTypeName = context.getResources().getResourceTypeName(this.f1342e);
                    context.getResources().getResourceName(this.f1342e);
                    if ("layout".equals(resourceTypeName)) {
                        d dVar = new d();
                        this.f1343f = dVar;
                        dVar.f(context, this.f1342e);
                    }
                } else if (index == i.k6) {
                    this.f1341d = typedArrayObtainStyledAttributes.getDimension(index, this.f1341d);
                } else if (index == i.l6) {
                    this.f1339b = typedArrayObtainStyledAttributes.getDimension(index, this.f1339b);
                } else if (index == i.m6) {
                    this.f1340c = typedArrayObtainStyledAttributes.getDimension(index, this.f1340c);
                } else if (index == i.n6) {
                    this.f1338a = typedArrayObtainStyledAttributes.getDimension(index, this.f1338a);
                } else {
                    Log.v("ConstraintLayoutStates", "Unknown tag");
                }
            }
            typedArrayObtainStyledAttributes.recycle();
        }

        boolean a(float f3, float f4) {
            if (!Float.isNaN(this.f1338a) && f3 < this.f1338a) {
                return false;
            }
            if (!Float.isNaN(this.f1339b) && f4 < this.f1339b) {
                return false;
            }
            if (Float.isNaN(this.f1340c) || f3 <= this.f1340c) {
                return Float.isNaN(this.f1341d) || f4 <= this.f1341d;
            }
            return false;
        }
    }

    c(Context context, ConstraintLayout constraintLayout, int i3) {
        this.f1328a = constraintLayout;
        a(context, i3);
    }

    /* JADX WARN: Failed to restore switch over string. Please report as a decompilation issue */
    /* JADX WARN: Removed duplicated region for block: B:28:0x0057  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    private void a(android.content.Context r9, int r10) {
        /*
            r8 = this;
            android.content.res.Resources r0 = r9.getResources()
            android.content.res.XmlResourceParser r10 = r0.getXml(r10)
            r0 = 0
            int r1 = r10.getEventType()     // Catch: java.io.IOException -> L83 org.xmlpull.v1.XmlPullParserException -> L88
        Ld:
            r2 = 1
            if (r1 == r2) goto L8c
            if (r1 == 0) goto L7b
            r3 = 2
            if (r1 == r3) goto L17
            goto L7e
        L17:
            java.lang.String r1 = r10.getName()     // Catch: java.io.IOException -> L83 org.xmlpull.v1.XmlPullParserException -> L88
            r4 = -1
            int r5 = r1.hashCode()     // Catch: java.io.IOException -> L83 org.xmlpull.v1.XmlPullParserException -> L88
            r6 = 4
            r7 = 3
            switch(r5) {
                case -1349929691: goto L4d;
                case 80204913: goto L43;
                case 1382829617: goto L3a;
                case 1657696882: goto L30;
                case 1901439077: goto L26;
                default: goto L25;
            }     // Catch: java.io.IOException -> L83 org.xmlpull.v1.XmlPullParserException -> L88
        L25:
            goto L57
        L26:
            java.lang.String r2 = "Variant"
            boolean r1 = r1.equals(r2)     // Catch: java.io.IOException -> L83 org.xmlpull.v1.XmlPullParserException -> L88
            if (r1 == 0) goto L57
            r2 = r7
            goto L58
        L30:
            java.lang.String r2 = "layoutDescription"
            boolean r1 = r1.equals(r2)     // Catch: java.io.IOException -> L83 org.xmlpull.v1.XmlPullParserException -> L88
            if (r1 == 0) goto L57
            r2 = 0
            goto L58
        L3a:
            java.lang.String r5 = "StateSet"
            boolean r1 = r1.equals(r5)     // Catch: java.io.IOException -> L83 org.xmlpull.v1.XmlPullParserException -> L88
            if (r1 == 0) goto L57
            goto L58
        L43:
            java.lang.String r2 = "State"
            boolean r1 = r1.equals(r2)     // Catch: java.io.IOException -> L83 org.xmlpull.v1.XmlPullParserException -> L88
            if (r1 == 0) goto L57
            r2 = r3
            goto L58
        L4d:
            java.lang.String r2 = "ConstraintSet"
            boolean r1 = r1.equals(r2)     // Catch: java.io.IOException -> L83 org.xmlpull.v1.XmlPullParserException -> L88
            if (r1 == 0) goto L57
            r2 = r6
            goto L58
        L57:
            r2 = r4
        L58:
            if (r2 == r3) goto L6e
            if (r2 == r7) goto L63
            if (r2 == r6) goto L5f
            goto L7e
        L5f:
            r8.b(r9, r10)     // Catch: java.io.IOException -> L83 org.xmlpull.v1.XmlPullParserException -> L88
            goto L7e
        L63:
            androidx.constraintlayout.widget.c$b r1 = new androidx.constraintlayout.widget.c$b     // Catch: java.io.IOException -> L83 org.xmlpull.v1.XmlPullParserException -> L88
            r1.<init>(r9, r10)     // Catch: java.io.IOException -> L83 org.xmlpull.v1.XmlPullParserException -> L88
            if (r0 == 0) goto L7e
            r0.a(r1)     // Catch: java.io.IOException -> L83 org.xmlpull.v1.XmlPullParserException -> L88
            goto L7e
        L6e:
            androidx.constraintlayout.widget.c$a r0 = new androidx.constraintlayout.widget.c$a     // Catch: java.io.IOException -> L83 org.xmlpull.v1.XmlPullParserException -> L88
            r0.<init>(r9, r10)     // Catch: java.io.IOException -> L83 org.xmlpull.v1.XmlPullParserException -> L88
            android.util.SparseArray<androidx.constraintlayout.widget.c$a> r1 = r8.f1332e     // Catch: java.io.IOException -> L83 org.xmlpull.v1.XmlPullParserException -> L88
            int r2 = r0.f1334a     // Catch: java.io.IOException -> L83 org.xmlpull.v1.XmlPullParserException -> L88
            r1.put(r2, r0)     // Catch: java.io.IOException -> L83 org.xmlpull.v1.XmlPullParserException -> L88
            goto L7e
        L7b:
            r10.getName()     // Catch: java.io.IOException -> L83 org.xmlpull.v1.XmlPullParserException -> L88
        L7e:
            int r1 = r10.next()     // Catch: java.io.IOException -> L83 org.xmlpull.v1.XmlPullParserException -> L88
            goto Ld
        L83:
            r8 = move-exception
            r8.printStackTrace()
            goto L8c
        L88:
            r8 = move-exception
            r8.printStackTrace()
        L8c:
            return
        */
        throw new UnsupportedOperationException("Method not decompiled: androidx.constraintlayout.widget.c.a(android.content.Context, int):void");
    }

    private void b(Context context, XmlPullParser xmlPullParser) {
        d dVar = new d();
        int attributeCount = xmlPullParser.getAttributeCount();
        for (int i3 = 0; i3 < attributeCount; i3++) {
            String attributeName = xmlPullParser.getAttributeName(i3);
            String attributeValue = xmlPullParser.getAttributeValue(i3);
            if (attributeName != null && attributeValue != null && "id".equals(attributeName)) {
                int identifier = attributeValue.contains("/") ? context.getResources().getIdentifier(attributeValue.substring(attributeValue.indexOf(47) + 1), "id", context.getPackageName()) : -1;
                if (identifier == -1) {
                    if (attributeValue.length() > 1) {
                        identifier = Integer.parseInt(attributeValue.substring(1));
                    } else {
                        Log.e("ConstraintLayoutStates", "error in parsing id");
                    }
                }
                dVar.n(context, xmlPullParser);
                this.f1333f.put(identifier, dVar);
                return;
            }
        }
    }

    public void c(f fVar) {
    }

    public void d(int i3, float f3, float f4) {
        int iB;
        int i4 = this.f1330c;
        if (i4 == i3) {
            a aVarValueAt = i3 == -1 ? this.f1332e.valueAt(0) : this.f1332e.get(i4);
            int i5 = this.f1331d;
            if ((i5 == -1 || !aVarValueAt.f1335b.get(i5).a(f3, f4)) && this.f1331d != (iB = aVarValueAt.b(f3, f4))) {
                d dVar = iB == -1 ? this.f1329b : aVarValueAt.f1335b.get(iB).f1343f;
                if (iB != -1) {
                    int i6 = aVarValueAt.f1335b.get(iB).f1342e;
                }
                if (dVar == null) {
                    return;
                }
                this.f1331d = iB;
                dVar.c(this.f1328a);
                return;
            }
            return;
        }
        this.f1330c = i3;
        a aVar = this.f1332e.get(i3);
        int iB2 = aVar.b(f3, f4);
        d dVar2 = iB2 == -1 ? aVar.f1337d : aVar.f1335b.get(iB2).f1343f;
        if (iB2 != -1) {
            int i7 = aVar.f1335b.get(iB2).f1342e;
        }
        if (dVar2 != null) {
            this.f1331d = iB2;
            dVar2.c(this.f1328a);
            return;
        }
        Log.v("ConstraintLayoutStates", "NO Constraint set found ! id=" + i3 + ", dim =" + f3 + ", " + f4);
    }
}
