package ῲ.ⁱ.ʬ;

import android.content.Context;
import android.content.res.TypedArray;
import android.content.res.XmlResourceParser;
import android.util.Log;
import android.util.SparseArray;
import android.util.Xml;
import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.constraintlayout.widget.R$styleable;
import com.appsflyer.share.Constants;
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: ConstraintLayoutStates */
public class C2065 {

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

    /* renamed from: ඓ  reason: contains not printable characters */
    public SparseArray<C2067> f7106 = new SparseArray<>();

    /* renamed from: ῲ  reason: contains not printable characters */
    public C2059 f7107;

    /* renamed from: K  reason: contains not printable characters */
    public final ConstraintLayout f7108;

    /* renamed from: 㴹  reason: contains not printable characters */
    public SparseArray<C2059> f7109 = new SparseArray<>();

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

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

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

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

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

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

        /* renamed from: 㴹  reason: contains not printable characters */
        public C2059 f7115;

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

        public C2066(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.f7112 = obtainStyledAttributes.getResourceId(index, this.f7112);
                    String resourceTypeName = context.getResources().getResourceTypeName(this.f7112);
                    context.getResources().getResourceName(this.f7112);
                    if ("layout".equals(resourceTypeName)) {
                        this.f7115 = new C2059();
                        this.f7115.m5371(context, this.f7112);
                    }
                } else if (index == R$styleable.Variant_region_heightLessThan) {
                    this.f7116 = obtainStyledAttributes.getDimension(index, this.f7116);
                } else if (index == R$styleable.Variant_region_heightMoreThan) {
                    this.f7113 = obtainStyledAttributes.getDimension(index, this.f7113);
                } else if (index == R$styleable.Variant_region_widthLessThan) {
                    this.f7111 = obtainStyledAttributes.getDimension(index, this.f7111);
                } else if (index == R$styleable.Variant_region_widthMoreThan) {
                    this.f7114 = obtainStyledAttributes.getDimension(index, this.f7114);
                } else {
                    Log.v("ConstraintLayoutStates", "Unknown tag");
                }
            }
            obtainStyledAttributes.recycle();
        }

        /* renamed from: K  reason: contains not printable characters */
        public boolean m5393(float f, float f2) {
            if (!Float.isNaN(this.f7114) && f < this.f7114) {
                return false;
            }
            if (!Float.isNaN(this.f7113) && f2 < this.f7113) {
                return false;
            }
            if (!Float.isNaN(this.f7111) && f > this.f7111) {
                return false;
            }
            if (Float.isNaN(this.f7116) || f2 <= this.f7116) {
                return true;
            }
            return false;
        }
    }

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

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

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

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

        /* renamed from: 㸾  reason: contains not printable characters */
        public C2059 f7120;

        public C2067(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.f7119 = obtainStyledAttributes.getResourceId(index, this.f7119);
                } else if (index == R$styleable.State_constraints) {
                    this.f7117 = obtainStyledAttributes.getResourceId(index, this.f7117);
                    String resourceTypeName = context.getResources().getResourceTypeName(this.f7117);
                    context.getResources().getResourceName(this.f7117);
                    if ("layout".equals(resourceTypeName)) {
                        this.f7120 = new C2059();
                        this.f7120.m5371(context, this.f7117);
                    }
                }
            }
            obtainStyledAttributes.recycle();
        }

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

    public C2065(Context context, ConstraintLayout constraintLayout, int i) {
        char c;
        this.f7108 = constraintLayout;
        XmlResourceParser xml = context.getResources().getXml(i);
        C2067 k = null;
        try {
            for (int eventType = xml.getEventType(); eventType != 1; eventType = xml.next()) {
                if (eventType == 0) {
                    xml.getName();
                } else if (eventType == 2) {
                    String name = xml.getName();
                    switch (name.hashCode()) {
                        case -1349929691:
                            if (name.equals("ConstraintSet")) {
                                c = 4;
                                break;
                            }
                            c = 65535;
                            break;
                        case 80204913:
                            if (name.equals("State")) {
                                c = 2;
                                break;
                            }
                            c = 65535;
                            break;
                        case 1382829617:
                            if (name.equals("StateSet")) {
                                c = 1;
                                break;
                            }
                            c = 65535;
                            break;
                        case 1657696882:
                            if (name.equals("layoutDescription")) {
                                c = 0;
                                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 C2067(context, xml);
                            this.f7106.put(k.f7119, k);
                        } else if (c == 3) {
                            C2066 r1 = new C2066(context, xml);
                            if (k != null) {
                                k.f7118.add(r1);
                            }
                        } else if (c != 4) {
                            Log.v("ConstraintLayoutStates", "unknown tag " + name);
                        } else {
                            m5391(context, xml);
                        }
                    }
                }
            }
        } catch (XmlPullParserException e) {
            e.printStackTrace();
        } catch (IOException e2) {
            e2.printStackTrace();
        }
    }

    /* renamed from: K  reason: contains not printable characters */
    public void m5390(int i, float f, float f2) {
        C2059 r3;
        C2067 k;
        int r6;
        C2059 r7;
        int i2 = this.f7105;
        if (i2 == i) {
            if (i == -1) {
                k = this.f7106.valueAt(0);
            } else {
                k = this.f7106.get(i2);
            }
            int i3 = this.f7110;
            if ((i3 == -1 || !k.f7118.get(i3).m5393(f, f2)) && this.f7110 != (r6 = k.m5394(f, f2))) {
                if (r6 == -1) {
                    r7 = this.f7107;
                } else {
                    r7 = k.f7118.get(r6).f7115;
                }
                if (r6 == -1) {
                    int i4 = k.f7117;
                } else {
                    int i5 = k.f7118.get(r6).f7112;
                }
                if (r7 != null) {
                    this.f7110 = r6;
                    r7.m5368(this.f7108);
                    return;
                }
                return;
            }
            return;
        }
        this.f7105 = i;
        C2067 k2 = this.f7106.get(this.f7105);
        int r2 = k2.m5394(f, f2);
        if (r2 == -1) {
            r3 = k2.f7120;
        } else {
            r3 = k2.f7118.get(r2).f7115;
        }
        if (r2 == -1) {
            int i6 = k2.f7117;
        } else {
            int i7 = k2.f7118.get(r2).f7112;
        }
        if (r3 == null) {
            Log.v("ConstraintLayoutStates", "NO Constraint set found ! id=" + i + ", dim =" + f + ", " + f2);
            return;
        }
        this.f7110 = r2;
        r3.m5368(this.f7108);
    }

    /* renamed from: K  reason: contains not printable characters */
    public void m5392(AbstractC2058 r1) {
    }

    /* renamed from: K  reason: contains not printable characters */
    public final void m5391(Context context, XmlPullParser xmlPullParser) {
        C2059 r0 = new C2059();
        int attributeCount = xmlPullParser.getAttributeCount();
        for (int i = 0; i < attributeCount; i++) {
            if ("id".equals(xmlPullParser.getAttributeName(i))) {
                String attributeValue = xmlPullParser.getAttributeValue(i);
                int identifier = attributeValue.contains(Constants.URL_PATH_DELIMITER) ? 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");
                    }
                }
                r0.m5372(context, xmlPullParser);
                this.f7109.put(identifier, r0);
                return;
            }
        }
    }
}
