package c.k.b;

import android.view.View;
import androidx.fragment.app.Fragment;
import c.f.j.a0;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.WeakHashMap;

/* JADX INFO: compiled from: FragmentTransition.java */
/* JADX INFO: loaded from: classes.dex */
public class k0 {
    public static final int[] a = {0, 3, 0, 1, 5, 4, 7, 6, 9, 8, 10};

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public static final m0 f1677b = new l0();

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public static final m0 f1678c;

    /* JADX INFO: compiled from: FragmentTransition.java */
    public interface a {
    }

    /* JADX INFO: compiled from: FragmentTransition.java */
    public static class b {
        public Fragment a;

        /* JADX INFO: renamed from: b, reason: collision with root package name */
        public boolean f1679b;

        /* JADX INFO: renamed from: c, reason: collision with root package name */
        public c.k.b.a f1680c;

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

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

        /* JADX INFO: renamed from: f, reason: collision with root package name */
        public c.k.b.a f1683f;
    }

    static {
        m0 m0Var;
        try {
            m0Var = (m0) Class.forName("androidx.transition.FragmentTransitionSupport").getDeclaredConstructor(new Class[0]).newInstance(new Object[0]);
        } catch (Exception unused) {
            m0Var = null;
        }
        f1678c = m0Var;
    }

    public static void a(ArrayList<View> arrayList, c.d.a<String, View> aVar, Collection<String> collection) {
        for (int i2 = aVar.f1057j - 1; i2 >= 0; i2--) {
            View viewK = aVar.k(i2);
            WeakHashMap<View, c.f.j.i0> weakHashMap = c.f.j.a0.a;
            if (collection.contains(a0.h.k(viewK))) {
                arrayList.add(viewK);
            }
        }
    }

    /* JADX WARN: Removed duplicated region for block: B:60:0x0077  */
    /* JADX WARN: Removed duplicated region for block: B:61:0x0079  */
    /* JADX WARN: Removed duplicated region for block: B:64:0x007f  */
    /* JADX WARN: Removed duplicated region for block: B:65:0x0082  */
    /* JADX WARN: Removed duplicated region for block: B:69:0x008a  */
    /* JADX WARN: Removed duplicated region for block: B:70:0x008c  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    public static void b(c.k.b.a r8, c.k.b.d0.a r9, android.util.SparseArray<c.k.b.k0.b> r10, boolean r11, boolean r12) {
        /*
            Method dump skipped, instruction units count: 240
            To view this dump add '--comments-level debug' option
        */
        throw new UnsupportedOperationException("Method not decompiled: c.k.b.k0.b(c.k.b.a, c.k.b.d0$a, android.util.SparseArray, boolean, boolean):void");
    }

    public static void c(Fragment fragment, Fragment fragment2, boolean z, c.d.a<String, View> aVar, boolean z2) {
        if ((z ? fragment2.getEnterTransitionCallback() : fragment.getEnterTransitionCallback()) != null) {
            ArrayList arrayList = new ArrayList();
            ArrayList arrayList2 = new ArrayList();
            int i2 = aVar == null ? 0 : aVar.f1057j;
            for (int i3 = 0; i3 < i2; i3++) {
                arrayList2.add(aVar.h(i3));
                arrayList.add(aVar.k(i3));
            }
            if (!z2) {
                throw null;
            }
            throw null;
        }
    }

    public static boolean d(m0 m0Var, List<Object> list) {
        int size = list.size();
        for (int i2 = 0; i2 < size; i2++) {
            if (!m0Var.d(list.get(i2))) {
                return false;
            }
        }
        return true;
    }

    public static c.d.a<String, View> e(m0 m0Var, c.d.a<String, String> aVar, Object obj, b bVar) {
        c.f.b.n enterTransitionCallback;
        ArrayList<String> arrayList;
        Fragment fragment = bVar.a;
        View view = fragment.getView();
        if (aVar.isEmpty() || obj == null || view == null) {
            aVar.clear();
            return null;
        }
        c.d.a<String, View> aVar2 = new c.d.a<>();
        m0Var.h(aVar2, view);
        c.k.b.a aVar3 = bVar.f1680c;
        if (bVar.f1679b) {
            enterTransitionCallback = fragment.getExitTransitionCallback();
            arrayList = aVar3.m;
        } else {
            enterTransitionCallback = fragment.getEnterTransitionCallback();
            arrayList = aVar3.n;
        }
        if (arrayList != null) {
            c.d.g.k(aVar2, arrayList);
            c.d.g.k(aVar2, aVar.values());
        }
        if (enterTransitionCallback != null) {
            throw null;
        }
        n(aVar, aVar2);
        return aVar2;
    }

    public static c.d.a<String, View> f(m0 m0Var, c.d.a<String, String> aVar, Object obj, b bVar) {
        c.f.b.n exitTransitionCallback;
        ArrayList<String> arrayList;
        if (aVar.isEmpty() || obj == null) {
            aVar.clear();
            return null;
        }
        Fragment fragment = bVar.f1681d;
        c.d.a<String, View> aVar2 = new c.d.a<>();
        m0Var.h(aVar2, fragment.requireView());
        c.k.b.a aVar3 = bVar.f1683f;
        if (bVar.f1682e) {
            exitTransitionCallback = fragment.getEnterTransitionCallback();
            arrayList = aVar3.n;
        } else {
            exitTransitionCallback = fragment.getExitTransitionCallback();
            arrayList = aVar3.m;
        }
        if (arrayList != null) {
            c.d.g.k(aVar2, arrayList);
        }
        if (exitTransitionCallback != null) {
            throw null;
        }
        c.d.g.k(aVar, aVar2.keySet());
        return aVar2;
    }

    public static m0 g(Fragment fragment, Fragment fragment2) {
        ArrayList arrayList = new ArrayList();
        if (fragment != null) {
            Object exitTransition = fragment.getExitTransition();
            if (exitTransition != null) {
                arrayList.add(exitTransition);
            }
            Object returnTransition = fragment.getReturnTransition();
            if (returnTransition != null) {
                arrayList.add(returnTransition);
            }
            Object sharedElementReturnTransition = fragment.getSharedElementReturnTransition();
            if (sharedElementReturnTransition != null) {
                arrayList.add(sharedElementReturnTransition);
            }
        }
        if (fragment2 != null) {
            Object enterTransition = fragment2.getEnterTransition();
            if (enterTransition != null) {
                arrayList.add(enterTransition);
            }
            Object reenterTransition = fragment2.getReenterTransition();
            if (reenterTransition != null) {
                arrayList.add(reenterTransition);
            }
            Object sharedElementEnterTransition = fragment2.getSharedElementEnterTransition();
            if (sharedElementEnterTransition != null) {
                arrayList.add(sharedElementEnterTransition);
            }
        }
        if (arrayList.isEmpty()) {
            return null;
        }
        m0 m0Var = f1677b;
        if (d(m0Var, arrayList)) {
            return m0Var;
        }
        m0 m0Var2 = f1678c;
        if (m0Var2 == null || !d(m0Var2, arrayList)) {
            throw new IllegalArgumentException("Invalid Transition types");
        }
        return m0Var2;
    }

    public static ArrayList<View> h(m0 m0Var, Object obj, Fragment fragment, ArrayList<View> arrayList, View view) {
        if (obj == null) {
            return null;
        }
        ArrayList<View> arrayList2 = new ArrayList<>();
        View view2 = fragment.getView();
        if (view2 != null) {
            m0Var.e(arrayList2, view2);
        }
        if (arrayList != null) {
            arrayList2.removeAll(arrayList);
        }
        if (arrayList2.isEmpty()) {
            return arrayList2;
        }
        arrayList2.add(view);
        m0Var.b(obj, arrayList2);
        return arrayList2;
    }

    public static Object i(m0 m0Var, Fragment fragment, boolean z) {
        if (fragment == null) {
            return null;
        }
        return m0Var.f(z ? fragment.getReenterTransition() : fragment.getEnterTransition());
    }

    public static Object j(m0 m0Var, Fragment fragment, boolean z) {
        if (fragment == null) {
            return null;
        }
        return m0Var.f(z ? fragment.getReturnTransition() : fragment.getExitTransition());
    }

    public static View k(c.d.a<String, View> aVar, b bVar, Object obj, boolean z) {
        ArrayList<String> arrayList;
        c.k.b.a aVar2 = bVar.f1680c;
        if (obj == null || aVar == null || (arrayList = aVar2.m) == null || arrayList.isEmpty()) {
            return null;
        }
        return aVar.get(z ? aVar2.m.get(0) : aVar2.n.get(0));
    }

    public static Object l(m0 m0Var, Fragment fragment, Fragment fragment2, boolean z) {
        return m0Var.x(m0Var.f(z ? fragment2.getSharedElementReturnTransition() : fragment.getSharedElementEnterTransition()));
    }

    public static Object m(m0 m0Var, Object obj, Object obj2, Object obj3, Fragment fragment, boolean z) {
        return (obj == null || obj2 == null || fragment == null) ? true : z ? fragment.getAllowReturnTransitionOverlap() : fragment.getAllowEnterTransitionOverlap() ? m0Var.l(obj2, obj, obj3) : m0Var.k(obj2, obj, obj3);
    }

    public static void n(c.d.a<String, String> aVar, c.d.a<String, View> aVar2) {
        int i2 = aVar.f1057j;
        while (true) {
            i2--;
            if (i2 < 0) {
                return;
            }
            if (!aVar2.containsKey(aVar.k(i2))) {
                aVar.i(i2);
            }
        }
    }

    public static void o(m0 m0Var, Object obj, Object obj2, c.d.a<String, View> aVar, boolean z, c.k.b.a aVar2) {
        ArrayList<String> arrayList = aVar2.m;
        if (arrayList == null || arrayList.isEmpty()) {
            return;
        }
        View view = aVar.get(z ? aVar2.n.get(0) : aVar2.m.get(0));
        m0Var.s(obj, view);
        if (obj2 != null) {
            m0Var.s(obj2, view);
        }
    }

    public static void p(ArrayList<View> arrayList, int i2) {
        if (arrayList == null) {
            return;
        }
        for (int size = arrayList.size() - 1; size >= 0; size--) {
            arrayList.get(size).setVisibility(i2);
        }
    }

    /* JADX WARN: Multi-variable type inference failed */
    /* JADX WARN: Removed duplicated region for block: B:137:0x039b  */
    /* JADX WARN: Removed duplicated region for block: B:141:0x03a9  */
    /* JADX WARN: Removed duplicated region for block: B:151:0x03e4  */
    /* JADX WARN: Removed duplicated region for block: B:162:0x0428 A[SYNTHETIC] */
    /* JADX WARN: Removed duplicated region for block: B:86:0x01f8  */
    /* JADX WARN: Removed duplicated region for block: B:95:0x023e  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    public static void q(android.content.Context r39, c.k.b.r r40, java.util.ArrayList<c.k.b.a> r41, java.util.ArrayList<java.lang.Boolean> r42, int r43, int r44, boolean r45, c.k.b.k0.a r46) {
        /*
            Method dump skipped, instruction units count: 1083
            To view this dump add '--comments-level debug' option
        */
        throw new UnsupportedOperationException("Method not decompiled: c.k.b.k0.q(android.content.Context, c.k.b.r, java.util.ArrayList, java.util.ArrayList, int, int, boolean, c.k.b.k0$a):void");
    }
}
