package ῲ.ⁱ.ʬ;

import android.content.Context;
import android.content.res.TypedArray;
import android.util.Log;
import android.util.SparseArray;
import android.util.Xml;
import androidx.constraintlayout.widget.R$styleable;
import java.io.IOException;
import java.util.ArrayList;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;

/* renamed from: ῲ.ⁱ.ʬ.㸾  reason: contains not printable characters */
/* compiled from: StateSet */
public class C2068 {

    /* renamed from: ʬ  reason: contains not printable characters */
    public int f7121 = -1;

    /* renamed from: ῲ  reason: contains not printable characters */
    public int f7122 = -1;

    /* renamed from: K  reason: contains not printable characters */
    public int f7123 = -1;

    /* renamed from: 㸾  reason: contains not printable characters */
    public SparseArray<C2070> f7124 = new SparseArray<>();

    /* renamed from: ῲ.ⁱ.ʬ.㸾$ῲ  reason: contains not printable characters */
    /* compiled from: StateSet */
    public static class C2069 {

        /* renamed from: ʬ  reason: contains not printable characters */
        public float f7125 = Float.NaN;

        /* renamed from: ඓ  reason: contains not printable characters */
        public int f7126 = -1;

        /* renamed from: ῲ  reason: contains not printable characters */
        public float f7127 = Float.NaN;

        /* renamed from: K  reason: contains not printable characters */
        public float f7128 = Float.NaN;

        /* renamed from: 㸾  reason: contains not printable characters */
        public float f7129 = Float.NaN;

        public C2069(Context context, XmlPullParser xmlPullParser) {
            TypedArray obtainStyledAttributes = context.obtainStyledAttributes(Xml.asAttributeSet(xmlPullParser), R$styleable.Variant);
            int indexCount = obtainStyledAttributes.getIndexCount();
            for (int i = 0; i < indexCount; i++) {
                int index = obtainStyledAttributes.getIndex(i);
                if (index == R$styleable.Variant_constraints) {
                    this.f7126 = obtainStyledAttributes.getResourceId(index, this.f7126);
                    String resourceTypeName = context.getResources().getResourceTypeName(this.f7126);
                    context.getResources().getResourceName(this.f7126);
                    "layout".equals(resourceTypeName);
                } else if (index == R$styleable.Variant_region_heightLessThan) {
                    this.f7129 = obtainStyledAttributes.getDimension(index, this.f7129);
                } else if (index == R$styleable.Variant_region_heightMoreThan) {
                    this.f7127 = obtainStyledAttributes.getDimension(index, this.f7127);
                } else if (index == R$styleable.Variant_region_widthLessThan) {
                    this.f7125 = obtainStyledAttributes.getDimension(index, this.f7125);
                } else if (index == R$styleable.Variant_region_widthMoreThan) {
                    this.f7128 = obtainStyledAttributes.getDimension(index, this.f7128);
                } else {
                    Log.v("ConstraintLayoutStates", "Unknown tag");
                }
            }
            obtainStyledAttributes.recycle();
        }

        /* renamed from: K  reason: contains not printable characters */
        public boolean m5396(float f, float f2) {
            if (!Float.isNaN(this.f7128) && f < this.f7128) {
                return false;
            }
            if (!Float.isNaN(this.f7127) && f2 < this.f7127) {
                return false;
            }
            if (!Float.isNaN(this.f7125) && f > this.f7125) {
                return false;
            }
            if (Float.isNaN(this.f7129) || f2 <= this.f7129) {
                return true;
            }
            return false;
        }
    }

    /* renamed from: ῲ.ⁱ.ʬ.㸾$K  reason: contains not printable characters */
    /* compiled from: StateSet */
    public static class C2070 {

        /* renamed from: ʬ  reason: contains not printable characters */
        public int f7130 = -1;

        /* renamed from: ῲ  reason: contains not printable characters */
        public ArrayList<C2069> f7131 = new ArrayList<>();

        /* renamed from: K  reason: contains not printable characters */
        public int f7132;

        public C2070(Context context, XmlPullParser xmlPullParser) {
            TypedArray obtainStyledAttributes = context.obtainStyledAttributes(Xml.asAttributeSet(xmlPullParser), R$styleable.State);
            int indexCount = obtainStyledAttributes.getIndexCount();
            for (int i = 0; i < indexCount; i++) {
                int index = obtainStyledAttributes.getIndex(i);
                if (index == R$styleable.State_android_id) {
                    this.f7132 = obtainStyledAttributes.getResourceId(index, this.f7132);
                } else if (index == R$styleable.State_constraints) {
                    this.f7130 = obtainStyledAttributes.getResourceId(index, this.f7130);
                    String resourceTypeName = context.getResources().getResourceTypeName(this.f7130);
                    context.getResources().getResourceName(this.f7130);
                    "layout".equals(resourceTypeName);
                }
            }
            obtainStyledAttributes.recycle();
        }

        /* renamed from: K  reason: contains not printable characters */
        public int m5397(float f, float f2) {
            for (int i = 0; i < this.f7131.size(); i++) {
                if (this.f7131.get(i).m5396(f, f2)) {
                    return i;
                }
            }
            return -1;
        }
    }

    /* JADX INFO: Can't fix incorrect switch cases order, some code will duplicate */
    public C2068(Context context, XmlPullParser xmlPullParser) {
        char c;
        new SparseArray();
        TypedArray obtainStyledAttributes = context.obtainStyledAttributes(Xml.asAttributeSet(xmlPullParser), R$styleable.StateSet);
        int indexCount = obtainStyledAttributes.getIndexCount();
        for (int i = 0; i < indexCount; i++) {
            int index = obtainStyledAttributes.getIndex(i);
            if (index == R$styleable.StateSet_defaultState) {
                this.f7123 = obtainStyledAttributes.getResourceId(index, this.f7123);
            }
        }
        obtainStyledAttributes.recycle();
        C2070 k = null;
        try {
            int eventType = xmlPullParser.getEventType();
            while (eventType != 1) {
                if (eventType == 0) {
                    xmlPullParser.getName();
                } else if (eventType == 2) {
                    String name = xmlPullParser.getName();
                    switch (name.hashCode()) {
                        case 80204913:
                            if (name.equals("State")) {
                                c = 2;
                                break;
                            }
                            c = 65535;
                            break;
                        case 1301459538:
                            if (name.equals("LayoutDescription")) {
                                c = 0;
                                break;
                            }
                            c = 65535;
                            break;
                        case 1382829617:
                            if (name.equals("StateSet")) {
                                c = 1;
                                break;
                            }
                            c = 65535;
                            break;
                        case 1901439077:
                            if (name.equals("Variant")) {
                                c = 3;
                                break;
                            }
                            c = 65535;
                            break;
                        default:
                            c = 65535;
                            break;
                    }
                    if (!(c == 0 || c == 1)) {
                        if (c == 2) {
                            k = new C2070(context, xmlPullParser);
                            this.f7124.put(k.f7132, k);
                        } else if (c != 3) {
                            Log.v("ConstraintLayoutStates", "unknown tag " + name);
                        } else {
                            C2069 r2 = new C2069(context, xmlPullParser);
                            if (k != null) {
                                k.f7131.add(r2);
                            }
                        }
                    }
                } else if (eventType == 3 && "StateSet".equals(xmlPullParser.getName())) {
                    return;
                }
                eventType = xmlPullParser.next();
            }
        } catch (XmlPullParserException e) {
            e.printStackTrace();
        } catch (IOException e2) {
            e2.printStackTrace();
        }
    }

    /* renamed from: K  reason: contains not printable characters */
    public int m5395(int i, int i2, int i3) {
        int i4;
        C2070 k;
        int r4;
        float f = (float) i2;
        float f2 = (float) i3;
        if (-1 == i) {
            if (i == -1) {
                k = this.f7124.valueAt(0);
            } else {
                k = this.f7124.get(this.f7122);
            }
            if (k == null) {
                return -1;
            }
            if ((this.f7121 != -1 && k.f7131.get(-1).m5396(f, f2)) || -1 == (r4 = k.m5397(f, f2))) {
                return -1;
            }
            i4 = r4 == -1 ? k.f7130 : k.f7131.get(r4).f7126;
        } else {
            C2070 k2 = this.f7124.get(i);
            if (k2 == null) {
                return -1;
            }
            int r42 = k2.m5397(f, f2);
            i4 = r42 == -1 ? k2.f7130 : k2.f7131.get(r42).f7126;
        }
        return i4;
    }
}
