package a0;

import android.content.Context;
import android.content.res.TypedArray;
import android.content.res.XmlResourceParser;
import android.util.Xml;
import android.view.View;
import android.view.animation.AccelerateDecelerateInterpolator;
import android.view.animation.AccelerateInterpolator;
import android.view.animation.AnimationUtils;
import android.view.animation.AnticipateInterpolator;
import android.view.animation.BounceInterpolator;
import android.view.animation.DecelerateInterpolator;
import android.view.animation.Interpolator;
import android.view.animation.OvershootInterpolator;
import androidx.constraintlayout.motion.widget.MotionLayout;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import org.xmlpull.v1.XmlPullParserException;

/* JADX INFO: loaded from: classes.dex */
public final class d0 {

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

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

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    public final h f49f;

    /* JADX INFO: renamed from: g, reason: collision with root package name */
    public final androidx.constraintlayout.widget.j f50g;

    /* JADX INFO: renamed from: j, reason: collision with root package name */
    public int f53j;

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

    /* JADX INFO: renamed from: o, reason: collision with root package name */
    public final Context f58o;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public int f45b = -1;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public boolean f46c = false;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public int f47d = 0;

    /* JADX INFO: renamed from: h, reason: collision with root package name */
    public int f51h = -1;

    /* JADX INFO: renamed from: i, reason: collision with root package name */
    public int f52i = -1;

    /* JADX INFO: renamed from: l, reason: collision with root package name */
    public int f55l = 0;

    /* JADX INFO: renamed from: m, reason: collision with root package name */
    public String f56m = null;

    /* JADX INFO: renamed from: n, reason: collision with root package name */
    public int f57n = -1;

    /* JADX INFO: renamed from: p, reason: collision with root package name */
    public int f59p = -1;

    /* JADX INFO: renamed from: q, reason: collision with root package name */
    public int f60q = -1;

    /* JADX INFO: renamed from: r, reason: collision with root package name */
    public int f61r = -1;

    /* JADX INFO: renamed from: s, reason: collision with root package name */
    public int f62s = -1;

    /* JADX INFO: renamed from: t, reason: collision with root package name */
    public int f63t = -1;

    /* JADX INFO: renamed from: u, reason: collision with root package name */
    public int f64u = -1;

    /* JADX WARN: Failed to restore switch over string. Please report as a decompilation issue */
    /* JADX WARN: Removed duplicated region for block: B:31:0x007d  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public d0(Context context, XmlResourceParser xmlResourceParser) {
        byte b10;
        this.f58o = context;
        try {
            int eventType = xmlResourceParser.getEventType();
            while (eventType != 1) {
                if (eventType == 2) {
                    String name = xmlResourceParser.getName();
                    switch (name.hashCode()) {
                        case -1962203927:
                            b10 = !name.equals("ConstraintOverride") ? (byte) -1 : (byte) 2;
                            break;
                        case -1239391468:
                            if (name.equals("KeyFrameSet")) {
                                b10 = 1;
                                break;
                            }
                            break;
                        case 61998586:
                            if (name.equals("ViewTransition")) {
                                b10 = 0;
                                break;
                            }
                            break;
                        case 366511058:
                            if (name.equals("CustomMethod")) {
                                b10 = 4;
                                break;
                            }
                            break;
                        case 1791837707:
                            if (name.equals("CustomAttribute")) {
                                b10 = 3;
                                break;
                            }
                            break;
                        default:
                            break;
                    }
                    if (b10 == 0) {
                        d(context, xmlResourceParser);
                    } else if (b10 == 1) {
                        this.f49f = new h(context, xmlResourceParser);
                    } else if (b10 == 2) {
                        this.f50g = androidx.constraintlayout.widget.o.d(context, xmlResourceParser);
                    } else if (b10 == 3 || b10 == 4) {
                        androidx.constraintlayout.widget.a.d(context, xmlResourceParser, this.f50g.f1393g);
                    } else {
                        o6.b.n();
                        xmlResourceParser.getLineNumber();
                    }
                } else if (eventType != 3) {
                    continue;
                } else if ("ViewTransition".equals(xmlResourceParser.getName())) {
                    return;
                }
                eventType = xmlResourceParser.next();
            }
        } catch (IOException | XmlPullParserException unused) {
        }
    }

    public final void a(l.b0 b0Var, MotionLayout motionLayout, int i10, androidx.constraintlayout.widget.o oVar, View... viewArr) {
        Interpolator interpolatorLoadInterpolator;
        Interpolator interpolator;
        if (this.f46c) {
            return;
        }
        int i11 = this.f48e;
        h hVar = this.f49f;
        int i12 = 1;
        int i13 = 0;
        if (i11 != 2) {
            androidx.constraintlayout.widget.j jVar = this.f50g;
            if (i11 == 1) {
                int[] constraintSetIds = motionLayout.getConstraintSetIds();
                int i14 = 0;
                while (i14 < constraintSetIds.length) {
                    int i15 = constraintSetIds[i14];
                    if (i15 != i10) {
                        androidx.constraintlayout.motion.widget.b bVar = motionLayout.R;
                        androidx.constraintlayout.widget.o oVarB = bVar == null ? null : bVar.b(i15);
                        int length = viewArr.length;
                        for (int i16 = i13; i16 < length; i16++) {
                            androidx.constraintlayout.widget.j jVarI = oVarB.i(viewArr[i16].getId());
                            if (jVar != null) {
                                androidx.constraintlayout.widget.i iVar = jVar.f1394h;
                                if (iVar != null) {
                                    iVar.e(jVarI);
                                }
                                jVarI.f1393g.putAll(jVar.f1393g);
                            }
                        }
                    }
                    i14++;
                    i13 = 0;
                }
            }
            androidx.constraintlayout.widget.o oVar2 = new androidx.constraintlayout.widget.o();
            HashMap map = oVar2.f1481g;
            map.clear();
            for (Integer num : oVar.f1481g.keySet()) {
                androidx.constraintlayout.widget.j jVar2 = (androidx.constraintlayout.widget.j) oVar.f1481g.get(num);
                if (jVar2 != null) {
                    map.put(num, jVar2.clone());
                }
            }
            for (View view : viewArr) {
                androidx.constraintlayout.widget.j jVarI2 = oVar2.i(view.getId());
                if (jVar != null) {
                    androidx.constraintlayout.widget.i iVar2 = jVar.f1394h;
                    if (iVar2 != null) {
                        iVar2.e(jVarI2);
                    }
                    jVarI2.f1393g.putAll(jVar.f1393g);
                }
            }
            motionLayout.w(i10, oVar2);
            int i17 = androidx.constraintlayout.widget.r.view_transition;
            motionLayout.w(i17, oVar);
            motionLayout.setState(i17, -1, -1);
            b0 b0Var2 = new b0(motionLayout.R, i17, i10);
            for (View view2 : viewArr) {
                int i18 = this.f51h;
                if (i18 != -1) {
                    b0Var2.f15h = Math.max(i18, 8);
                }
                b0Var2.f23p = this.f47d;
                int i19 = this.f55l;
                String str = this.f56m;
                int i20 = this.f57n;
                b0Var2.f12e = i19;
                b0Var2.f13f = str;
                b0Var2.f14g = i20;
                int id2 = view2.getId();
                if (hVar != null) {
                    ArrayList arrayList = (ArrayList) hVar.f101a.get(-1);
                    h hVar2 = new h();
                    hVar2.f101a = new HashMap();
                    Iterator it = arrayList.iterator();
                    while (it.hasNext()) {
                        c cVarB = ((c) it.next()).clone();
                        cVarB.f27b = id2;
                        hVar2.b(cVarB);
                    }
                    b0Var2.f18k.add(hVar2);
                }
            }
            motionLayout.setTransition(b0Var2);
            e.t tVar = new e.t(this, viewArr, i12);
            motionLayout.h(1.0f);
            motionLayout.W0 = tVar;
            return;
        }
        View view3 = viewArr[0];
        q qVar = new q(view3);
        y yVar = qVar.f171f;
        yVar.f223c = 0.0f;
        yVar.f224d = 0.0f;
        qVar.H = true;
        yVar.g(view3.getX(), view3.getY(), view3.getWidth(), view3.getHeight());
        qVar.f172g.g(view3.getX(), view3.getY(), view3.getWidth(), view3.getHeight());
        o oVar3 = qVar.f173h;
        oVar3.getClass();
        view3.getX();
        view3.getY();
        view3.getWidth();
        view3.getHeight();
        oVar3.f154c = view3.getVisibility();
        oVar3.f156e = view3.getVisibility() != 0 ? 0.0f : view3.getAlpha();
        oVar3.f157f = view3.getElevation();
        oVar3.f158g = view3.getRotation();
        oVar3.f159h = view3.getRotationX();
        oVar3.f152a = view3.getRotationY();
        oVar3.f160i = view3.getScaleX();
        oVar3.f161j = view3.getScaleY();
        oVar3.f162k = view3.getPivotX();
        oVar3.f163l = view3.getPivotY();
        oVar3.f164m = view3.getTranslationX();
        oVar3.Q = view3.getTranslationY();
        oVar3.R = view3.getTranslationZ();
        o oVar4 = qVar.f174i;
        oVar4.getClass();
        view3.getX();
        view3.getY();
        view3.getWidth();
        view3.getHeight();
        oVar4.f154c = view3.getVisibility();
        oVar4.f156e = view3.getVisibility() == 0 ? view3.getAlpha() : 0.0f;
        oVar4.f157f = view3.getElevation();
        oVar4.f158g = view3.getRotation();
        oVar4.f159h = view3.getRotationX();
        oVar4.f152a = view3.getRotationY();
        oVar4.f160i = view3.getScaleX();
        oVar4.f161j = view3.getScaleY();
        oVar4.f162k = view3.getPivotX();
        oVar4.f163l = view3.getPivotY();
        oVar4.f164m = view3.getTranslationX();
        oVar4.Q = view3.getTranslationY();
        oVar4.R = view3.getTranslationZ();
        ArrayList arrayList2 = (ArrayList) hVar.f101a.get(-1);
        if (arrayList2 != null) {
            qVar.f188w.addAll(arrayList2);
        }
        qVar.i(motionLayout.getWidth(), motionLayout.getHeight(), System.nanoTime());
        int i21 = this.f51h;
        int i22 = this.f52i;
        int i23 = this.f45b;
        Context context = motionLayout.getContext();
        int i24 = this.f55l;
        if (i24 == -2) {
            interpolatorLoadInterpolator = AnimationUtils.loadInterpolator(context, this.f57n);
        } else if (i24 == -1) {
            interpolatorLoadInterpolator = new z(this, v.f.c(this.f56m), 1);
        } else if (i24 == 0) {
            interpolatorLoadInterpolator = new AccelerateDecelerateInterpolator();
        } else if (i24 == 1) {
            interpolatorLoadInterpolator = new AccelerateInterpolator();
        } else if (i24 == 2) {
            interpolatorLoadInterpolator = new DecelerateInterpolator();
        } else if (i24 == 4) {
            interpolatorLoadInterpolator = new BounceInterpolator();
        } else if (i24 == 5) {
            interpolatorLoadInterpolator = new OvershootInterpolator();
        } else {
            if (i24 != 6) {
                interpolator = null;
                new c0(b0Var, qVar, i21, i22, i23, interpolator, this.f59p, this.f60q);
            }
            interpolatorLoadInterpolator = new AnticipateInterpolator();
        }
        interpolator = interpolatorLoadInterpolator;
        new c0(b0Var, qVar, i21, i22, i23, interpolator, this.f59p, this.f60q);
    }

    public final boolean b(View view) {
        int i10 = this.f61r;
        boolean z10 = i10 == -1 || view.getTag(i10) != null;
        int i11 = this.f62s;
        return z10 && (i11 == -1 || view.getTag(i11) == null);
    }

    public final boolean c(View view) {
        String str;
        if (view == null) {
            return false;
        }
        if ((this.f53j == -1 && this.f54k == null) || !b(view)) {
            return false;
        }
        if (view.getId() == this.f53j) {
            return true;
        }
        return this.f54k != null && (view.getLayoutParams() instanceof androidx.constraintlayout.widget.c) && (str = ((androidx.constraintlayout.widget.c) view.getLayoutParams()).Y) != null && str.matches(this.f54k);
    }

    public final void d(Context context, XmlResourceParser xmlResourceParser) {
        TypedArray typedArrayObtainStyledAttributes = context.obtainStyledAttributes(Xml.asAttributeSet(xmlResourceParser), androidx.constraintlayout.widget.s.ViewTransition);
        int indexCount = typedArrayObtainStyledAttributes.getIndexCount();
        for (int i10 = 0; i10 < indexCount; i10++) {
            int index = typedArrayObtainStyledAttributes.getIndex(i10);
            if (index == androidx.constraintlayout.widget.s.ViewTransition_android_id) {
                this.f44a = typedArrayObtainStyledAttributes.getResourceId(index, this.f44a);
            } else if (index == androidx.constraintlayout.widget.s.ViewTransition_motionTarget) {
                if (MotionLayout.f1093g1) {
                    int resourceId = typedArrayObtainStyledAttributes.getResourceId(index, this.f53j);
                    this.f53j = resourceId;
                    if (resourceId == -1) {
                        this.f54k = typedArrayObtainStyledAttributes.getString(index);
                    }
                } else if (typedArrayObtainStyledAttributes.peekValue(index).type == 3) {
                    this.f54k = typedArrayObtainStyledAttributes.getString(index);
                } else {
                    this.f53j = typedArrayObtainStyledAttributes.getResourceId(index, this.f53j);
                }
            } else if (index == androidx.constraintlayout.widget.s.ViewTransition_onStateTransition) {
                this.f45b = typedArrayObtainStyledAttributes.getInt(index, this.f45b);
            } else if (index == androidx.constraintlayout.widget.s.ViewTransition_transitionDisable) {
                this.f46c = typedArrayObtainStyledAttributes.getBoolean(index, this.f46c);
            } else if (index == androidx.constraintlayout.widget.s.ViewTransition_pathMotionArc) {
                this.f47d = typedArrayObtainStyledAttributes.getInt(index, this.f47d);
            } else if (index == androidx.constraintlayout.widget.s.ViewTransition_duration) {
                this.f51h = typedArrayObtainStyledAttributes.getInt(index, this.f51h);
            } else if (index == androidx.constraintlayout.widget.s.ViewTransition_upDuration) {
                this.f52i = typedArrayObtainStyledAttributes.getInt(index, this.f52i);
            } else if (index == androidx.constraintlayout.widget.s.ViewTransition_viewTransitionMode) {
                this.f48e = typedArrayObtainStyledAttributes.getInt(index, this.f48e);
            } else if (index == androidx.constraintlayout.widget.s.ViewTransition_motionInterpolator) {
                int i11 = typedArrayObtainStyledAttributes.peekValue(index).type;
                if (i11 == 1) {
                    int resourceId2 = typedArrayObtainStyledAttributes.getResourceId(index, -1);
                    this.f57n = resourceId2;
                    if (resourceId2 != -1) {
                        this.f55l = -2;
                    }
                } else if (i11 == 3) {
                    String string = typedArrayObtainStyledAttributes.getString(index);
                    this.f56m = string;
                    if (string == null || string.indexOf("/") <= 0) {
                        this.f55l = -1;
                    } else {
                        this.f57n = typedArrayObtainStyledAttributes.getResourceId(index, -1);
                        this.f55l = -2;
                    }
                } else {
                    this.f55l = typedArrayObtainStyledAttributes.getInteger(index, this.f55l);
                }
            } else if (index == androidx.constraintlayout.widget.s.ViewTransition_setsTag) {
                this.f59p = typedArrayObtainStyledAttributes.getResourceId(index, this.f59p);
            } else if (index == androidx.constraintlayout.widget.s.ViewTransition_clearsTag) {
                this.f60q = typedArrayObtainStyledAttributes.getResourceId(index, this.f60q);
            } else if (index == androidx.constraintlayout.widget.s.ViewTransition_ifTagSet) {
                this.f61r = typedArrayObtainStyledAttributes.getResourceId(index, this.f61r);
            } else if (index == androidx.constraintlayout.widget.s.ViewTransition_ifTagNotSet) {
                this.f62s = typedArrayObtainStyledAttributes.getResourceId(index, this.f62s);
            } else if (index == androidx.constraintlayout.widget.s.ViewTransition_SharedValueId) {
                this.f64u = typedArrayObtainStyledAttributes.getResourceId(index, this.f64u);
            } else if (index == androidx.constraintlayout.widget.s.ViewTransition_SharedValue) {
                this.f63t = typedArrayObtainStyledAttributes.getInteger(index, this.f63t);
            }
        }
        typedArrayObtainStyledAttributes.recycle();
    }

    public final String toString() {
        return "ViewTransition(" + o6.b.p(this.f58o, this.f44a) + ")";
    }
}
