package androidx.fragment.app;

import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.content.Context;
import android.graphics.Rect;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.Animation;
import androidx.core.os.d;
import androidx.core.view.x0;
import androidx.fragment.app.l;
import androidx.fragment.app.r0;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

/* loaded from: classes.dex */
class d extends r0 {

    /* loaded from: classes.dex */
    static /* synthetic */ class a {

        /* renamed from: a, reason: collision with root package name */
        static final /* synthetic */ int[] f4435a;

        static {
            int[] iArr = new int[r0.e.c.values().length];
            f4435a = iArr;
            try {
                iArr[r0.e.c.GONE.ordinal()] = 1;
            } catch (NoSuchFieldError unused) {
            }
            try {
                f4435a[r0.e.c.INVISIBLE.ordinal()] = 2;
            } catch (NoSuchFieldError unused2) {
            }
            try {
                f4435a[r0.e.c.REMOVED.ordinal()] = 3;
            } catch (NoSuchFieldError unused3) {
            }
            try {
                f4435a[r0.e.c.VISIBLE.ordinal()] = 4;
            } catch (NoSuchFieldError unused4) {
            }
        }
    }

    /* loaded from: classes.dex */
    class b implements Runnable {

        /* renamed from: p, reason: collision with root package name */
        final /* synthetic */ List f4436p;

        /* renamed from: q, reason: collision with root package name */
        final /* synthetic */ r0.e f4437q;

        b(List list, r0.e eVar) {
            this.f4436p = list;
            this.f4437q = eVar;
        }

        @Override // java.lang.Runnable
        public void run() {
            if (this.f4436p.contains(this.f4437q)) {
                this.f4436p.remove(this.f4437q);
                d.this.s(this.f4437q);
            }
        }
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    /* loaded from: classes.dex */
    public class c extends AnimatorListenerAdapter {

        /* renamed from: a, reason: collision with root package name */
        final /* synthetic */ ViewGroup f4439a;

        /* renamed from: b, reason: collision with root package name */
        final /* synthetic */ View f4440b;

        /* renamed from: c, reason: collision with root package name */
        final /* synthetic */ boolean f4441c;

        /* renamed from: d, reason: collision with root package name */
        final /* synthetic */ r0.e f4442d;

        /* renamed from: e, reason: collision with root package name */
        final /* synthetic */ k f4443e;

        c(ViewGroup viewGroup, View view, boolean z10, r0.e eVar, k kVar) {
            this.f4439a = viewGroup;
            this.f4440b = view;
            this.f4441c = z10;
            this.f4442d = eVar;
            this.f4443e = kVar;
        }

        @Override // android.animation.AnimatorListenerAdapter, android.animation.Animator.AnimatorListener
        public void onAnimationEnd(Animator animator) {
            this.f4439a.endViewTransition(this.f4440b);
            if (this.f4441c) {
                this.f4442d.e().applyState(this.f4440b);
            }
            this.f4443e.a();
            if (z.N0(2)) {
                Log.v("FragmentManager", "Animator from operation " + this.f4442d + " has ended.");
            }
        }
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    /* renamed from: androidx.fragment.app.d$d, reason: collision with other inner class name */
    /* loaded from: classes.dex */
    public class C0114d implements d.a {

        /* renamed from: a, reason: collision with root package name */
        final /* synthetic */ Animator f4445a;

        /* renamed from: b, reason: collision with root package name */
        final /* synthetic */ r0.e f4446b;

        C0114d(Animator animator, r0.e eVar) {
            this.f4445a = animator;
            this.f4446b = eVar;
        }

        @Override // androidx.core.os.d.a
        public void onCancel() {
            this.f4445a.end();
            if (z.N0(2)) {
                Log.v("FragmentManager", "Animator from operation " + this.f4446b + " has been canceled.");
            }
        }
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    /* loaded from: classes.dex */
    public class e implements Animation.AnimationListener {

        /* renamed from: a, reason: collision with root package name */
        final /* synthetic */ r0.e f4448a;

        /* renamed from: b, reason: collision with root package name */
        final /* synthetic */ ViewGroup f4449b;

        /* renamed from: c, reason: collision with root package name */
        final /* synthetic */ View f4450c;

        /* renamed from: d, reason: collision with root package name */
        final /* synthetic */ k f4451d;

        /* loaded from: classes.dex */
        class a implements Runnable {
            a() {
            }

            @Override // java.lang.Runnable
            public void run() {
                e eVar = e.this;
                eVar.f4449b.endViewTransition(eVar.f4450c);
                e.this.f4451d.a();
            }
        }

        e(r0.e eVar, ViewGroup viewGroup, View view, k kVar) {
            this.f4448a = eVar;
            this.f4449b = viewGroup;
            this.f4450c = view;
            this.f4451d = kVar;
        }

        @Override // android.view.animation.Animation.AnimationListener
        public void onAnimationEnd(Animation animation) {
            this.f4449b.post(new a());
            if (z.N0(2)) {
                Log.v("FragmentManager", "Animation from operation " + this.f4448a + " has ended.");
            }
        }

        @Override // android.view.animation.Animation.AnimationListener
        public void onAnimationRepeat(Animation animation) {
        }

        @Override // android.view.animation.Animation.AnimationListener
        public void onAnimationStart(Animation animation) {
            if (z.N0(2)) {
                Log.v("FragmentManager", "Animation from operation " + this.f4448a + " has reached onAnimationStart.");
            }
        }
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    /* loaded from: classes.dex */
    public class f implements d.a {

        /* renamed from: a, reason: collision with root package name */
        final /* synthetic */ View f4454a;

        /* renamed from: b, reason: collision with root package name */
        final /* synthetic */ ViewGroup f4455b;

        /* renamed from: c, reason: collision with root package name */
        final /* synthetic */ k f4456c;

        /* renamed from: d, reason: collision with root package name */
        final /* synthetic */ r0.e f4457d;

        f(View view, ViewGroup viewGroup, k kVar, r0.e eVar) {
            this.f4454a = view;
            this.f4455b = viewGroup;
            this.f4456c = kVar;
            this.f4457d = eVar;
        }

        @Override // androidx.core.os.d.a
        public void onCancel() {
            this.f4454a.clearAnimation();
            this.f4455b.endViewTransition(this.f4454a);
            this.f4456c.a();
            if (z.N0(2)) {
                Log.v("FragmentManager", "Animation from operation " + this.f4457d + " has been cancelled.");
            }
        }
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    /* loaded from: classes.dex */
    public class g implements Runnable {

        /* renamed from: p, reason: collision with root package name */
        final /* synthetic */ r0.e f4459p;

        /* renamed from: q, reason: collision with root package name */
        final /* synthetic */ r0.e f4460q;

        /* renamed from: r, reason: collision with root package name */
        final /* synthetic */ boolean f4461r;

        /* renamed from: s, reason: collision with root package name */
        final /* synthetic */ androidx.collection.a f4462s;

        g(r0.e eVar, r0.e eVar2, boolean z10, androidx.collection.a aVar) {
            this.f4459p = eVar;
            this.f4460q = eVar2;
            this.f4461r = z10;
            this.f4462s = aVar;
        }

        @Override // java.lang.Runnable
        public void run() {
            l0.a(this.f4459p.f(), this.f4460q.f(), this.f4461r, this.f4462s, false);
        }
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    /* loaded from: classes.dex */
    public class h implements Runnable {

        /* renamed from: p, reason: collision with root package name */
        final /* synthetic */ n0 f4464p;

        /* renamed from: q, reason: collision with root package name */
        final /* synthetic */ View f4465q;

        /* renamed from: r, reason: collision with root package name */
        final /* synthetic */ Rect f4466r;

        h(n0 n0Var, View view, Rect rect) {
            this.f4464p = n0Var;
            this.f4465q = view;
            this.f4466r = rect;
        }

        @Override // java.lang.Runnable
        public void run() {
            this.f4464p.h(this.f4465q, this.f4466r);
        }
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    /* loaded from: classes.dex */
    public class i implements Runnable {

        /* renamed from: p, reason: collision with root package name */
        final /* synthetic */ ArrayList f4468p;

        i(ArrayList arrayList) {
            this.f4468p = arrayList;
        }

        @Override // java.lang.Runnable
        public void run() {
            l0.d(this.f4468p, 4);
        }
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    /* loaded from: classes.dex */
    public class j implements Runnable {

        /* renamed from: p, reason: collision with root package name */
        final /* synthetic */ m f4470p;

        /* renamed from: q, reason: collision with root package name */
        final /* synthetic */ r0.e f4471q;

        j(m mVar, r0.e eVar) {
            this.f4470p = mVar;
            this.f4471q = eVar;
        }

        @Override // java.lang.Runnable
        public void run() {
            this.f4470p.a();
            if (z.N0(2)) {
                Log.v("FragmentManager", "Transition for operation " + this.f4471q + "has completed");
            }
        }
    }

    /* JADX INFO: Access modifiers changed from: private */
    /* loaded from: classes.dex */
    public static class k extends l {

        /* renamed from: c, reason: collision with root package name */
        private boolean f4473c;

        /* renamed from: d, reason: collision with root package name */
        private boolean f4474d;

        /* renamed from: e, reason: collision with root package name */
        private l.a f4475e;

        k(r0.e eVar, androidx.core.os.d dVar, boolean z10) {
            super(eVar, dVar);
            this.f4474d = false;
            this.f4473c = z10;
        }

        l.a e(Context context) {
            if (this.f4474d) {
                return this.f4475e;
            }
            l.a b10 = androidx.fragment.app.l.b(context, b().f(), b().e() == r0.e.c.VISIBLE, this.f4473c);
            this.f4475e = b10;
            this.f4474d = true;
            return b10;
        }
    }

    /* JADX INFO: Access modifiers changed from: private */
    /* loaded from: classes.dex */
    public static class l {

        /* renamed from: a, reason: collision with root package name */
        private final r0.e f4476a;

        /* renamed from: b, reason: collision with root package name */
        private final androidx.core.os.d f4477b;

        l(r0.e eVar, androidx.core.os.d dVar) {
            this.f4476a = eVar;
            this.f4477b = dVar;
        }

        void a() {
            this.f4476a.d(this.f4477b);
        }

        r0.e b() {
            return this.f4476a;
        }

        androidx.core.os.d c() {
            return this.f4477b;
        }

        boolean d() {
            r0.e.c cVar;
            r0.e.c from = r0.e.c.from(this.f4476a.f().mView);
            r0.e.c e10 = this.f4476a.e();
            return from == e10 || !(from == (cVar = r0.e.c.VISIBLE) || e10 == cVar);
        }
    }

    /* JADX INFO: Access modifiers changed from: private */
    /* loaded from: classes.dex */
    public static class m extends l {

        /* renamed from: c, reason: collision with root package name */
        private final Object f4478c;

        /* renamed from: d, reason: collision with root package name */
        private final boolean f4479d;

        /* renamed from: e, reason: collision with root package name */
        private final Object f4480e;

        m(r0.e eVar, androidx.core.os.d dVar, boolean z10, boolean z11) {
            super(eVar, dVar);
            if (eVar.e() == r0.e.c.VISIBLE) {
                this.f4478c = z10 ? eVar.f().getReenterTransition() : eVar.f().getEnterTransition();
                this.f4479d = z10 ? eVar.f().getAllowReturnTransitionOverlap() : eVar.f().getAllowEnterTransitionOverlap();
            } else {
                this.f4478c = z10 ? eVar.f().getReturnTransition() : eVar.f().getExitTransition();
                this.f4479d = true;
            }
            if (!z11) {
                this.f4480e = null;
            } else if (z10) {
                this.f4480e = eVar.f().getSharedElementReturnTransition();
            } else {
                this.f4480e = eVar.f().getSharedElementEnterTransition();
            }
        }

        private n0 f(Object obj) {
            if (obj == null) {
                return null;
            }
            n0 n0Var = l0.f4601a;
            if (n0Var != null && n0Var.e(obj)) {
                return n0Var;
            }
            n0 n0Var2 = l0.f4602b;
            if (n0Var2 != null && n0Var2.e(obj)) {
                return n0Var2;
            }
            throw new IllegalArgumentException("Transition " + obj + " for fragment " + b().f() + " is not a valid framework Transition or AndroidX Transition");
        }

        n0 e() {
            n0 f10 = f(this.f4478c);
            n0 f11 = f(this.f4480e);
            if (f10 == null || f11 == null || f10 == f11) {
                return f10 != null ? f10 : f11;
            }
            throw new IllegalArgumentException("Mixing framework transitions and AndroidX transitions is not allowed. Fragment " + b().f() + " returned Transition " + this.f4478c + " which uses a different Transition  type than its shared element transition " + this.f4480e);
        }

        public Object g() {
            return this.f4480e;
        }

        Object h() {
            return this.f4478c;
        }

        public boolean i() {
            return this.f4480e != null;
        }

        boolean j() {
            return this.f4479d;
        }
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    public d(ViewGroup viewGroup) {
        super(viewGroup);
    }

    private void w(List list, List list2, boolean z10, Map map) {
        int i10;
        boolean z11;
        Context context;
        View view;
        int i11;
        r0.e eVar;
        ViewGroup m10 = m();
        Context context2 = m10.getContext();
        ArrayList arrayList = new ArrayList();
        Iterator it = list.iterator();
        boolean z12 = false;
        while (true) {
            i10 = 2;
            if (!it.hasNext()) {
                break;
            }
            k kVar = (k) it.next();
            if (kVar.d()) {
                kVar.a();
            } else {
                l.a e10 = kVar.e(context2);
                if (e10 == null) {
                    kVar.a();
                } else {
                    Animator animator = e10.f4595b;
                    if (animator == null) {
                        arrayList.add(kVar);
                    } else {
                        r0.e b10 = kVar.b();
                        androidx.fragment.app.f f10 = b10.f();
                        if (Boolean.TRUE.equals(map.get(b10))) {
                            if (z.N0(2)) {
                                Log.v("FragmentManager", "Ignoring Animator set on " + f10 + " as this Fragment was involved in a Transition.");
                            }
                            kVar.a();
                        } else {
                            boolean z13 = b10.e() == r0.e.c.GONE;
                            if (z13) {
                                list2.remove(b10);
                            }
                            View view2 = f10.mView;
                            m10.startViewTransition(view2);
                            animator.addListener(new c(m10, view2, z13, b10, kVar));
                            animator.setTarget(view2);
                            animator.start();
                            if (z.N0(2)) {
                                StringBuilder sb2 = new StringBuilder();
                                sb2.append("Animator from operation ");
                                eVar = b10;
                                sb2.append(eVar);
                                sb2.append(" has started.");
                                Log.v("FragmentManager", sb2.toString());
                            } else {
                                eVar = b10;
                            }
                            kVar.c().c(new C0114d(animator, eVar));
                            z12 = true;
                        }
                    }
                }
            }
        }
        Iterator it2 = arrayList.iterator();
        while (it2.hasNext()) {
            k kVar2 = (k) it2.next();
            r0.e b11 = kVar2.b();
            androidx.fragment.app.f f11 = b11.f();
            if (z10) {
                if (z.N0(i10)) {
                    Log.v("FragmentManager", "Ignoring Animation set on " + f11 + " as Animations cannot run alongside Transitions.");
                }
                kVar2.a();
            } else if (z12) {
                if (z.N0(i10)) {
                    Log.v("FragmentManager", "Ignoring Animation set on " + f11 + " as Animations cannot run alongside Animators.");
                }
                kVar2.a();
            } else {
                View view3 = f11.mView;
                Animation animation = (Animation) s3.i.g(((l.a) s3.i.g(kVar2.e(context2))).f4594a);
                if (b11.e() != r0.e.c.REMOVED) {
                    view3.startAnimation(animation);
                    kVar2.a();
                    z11 = z12;
                    context = context2;
                    i11 = i10;
                    view = view3;
                } else {
                    m10.startViewTransition(view3);
                    l.b bVar = new l.b(animation, m10, view3);
                    z11 = z12;
                    context = context2;
                    view = view3;
                    bVar.setAnimationListener(new e(b11, m10, view3, kVar2));
                    view.startAnimation(bVar);
                    i11 = 2;
                    if (z.N0(2)) {
                        Log.v("FragmentManager", "Animation from operation " + b11 + " has started.");
                    }
                }
                kVar2.c().c(new f(view, m10, kVar2, b11));
                i10 = i11;
                z12 = z11;
                context2 = context;
            }
        }
    }

    private Map x(List list, List list2, boolean z10, r0.e eVar, r0.e eVar2) {
        String str;
        String str2;
        String str3;
        View view;
        Object obj;
        ArrayList arrayList;
        Object obj2;
        ArrayList arrayList2;
        HashMap hashMap;
        View view2;
        Object k10;
        androidx.collection.a aVar;
        ArrayList arrayList3;
        r0.e eVar3;
        ArrayList arrayList4;
        Rect rect;
        n0 n0Var;
        HashMap hashMap2;
        r0.e eVar4;
        View view3;
        View view4;
        View view5;
        boolean z11 = z10;
        r0.e eVar5 = eVar;
        r0.e eVar6 = eVar2;
        HashMap hashMap3 = new HashMap();
        Iterator it = list.iterator();
        n0 n0Var2 = null;
        while (it.hasNext()) {
            m mVar = (m) it.next();
            if (!mVar.d()) {
                n0 e10 = mVar.e();
                if (n0Var2 == null) {
                    n0Var2 = e10;
                } else if (e10 != null && n0Var2 != e10) {
                    throw new IllegalArgumentException("Mixing framework transitions and AndroidX transitions is not allowed. Fragment " + mVar.b().f() + " returned Transition " + mVar.h() + " which uses a different Transition  type than other Fragments.");
                }
            }
        }
        if (n0Var2 == null) {
            Iterator it2 = list.iterator();
            while (it2.hasNext()) {
                m mVar2 = (m) it2.next();
                hashMap3.put(mVar2.b(), Boolean.FALSE);
                mVar2.a();
            }
            return hashMap3;
        }
        View view6 = new View(m().getContext());
        Rect rect2 = new Rect();
        ArrayList arrayList5 = new ArrayList();
        ArrayList arrayList6 = new ArrayList();
        androidx.collection.a aVar2 = new androidx.collection.a();
        Iterator it3 = list.iterator();
        Object obj3 = null;
        View view7 = null;
        boolean z12 = false;
        while (true) {
            str = "FragmentManager";
            if (!it3.hasNext()) {
                break;
            }
            m mVar3 = (m) it3.next();
            if (!mVar3.i() || eVar5 == null || eVar6 == null) {
                aVar = aVar2;
                arrayList3 = arrayList6;
                eVar3 = eVar5;
                arrayList4 = arrayList5;
                rect = rect2;
                n0Var = n0Var2;
                hashMap2 = hashMap3;
                View view8 = view6;
                eVar4 = eVar6;
                view3 = view8;
                view7 = view7;
            } else {
                Object u10 = n0Var2.u(n0Var2.f(mVar3.g()));
                ArrayList<String> sharedElementSourceNames = eVar2.f().getSharedElementSourceNames();
                ArrayList<String> sharedElementSourceNames2 = eVar.f().getSharedElementSourceNames();
                ArrayList<String> sharedElementTargetNames = eVar.f().getSharedElementTargetNames();
                View view9 = view7;
                int i10 = 0;
                while (i10 < sharedElementTargetNames.size()) {
                    int indexOf = sharedElementSourceNames.indexOf(sharedElementTargetNames.get(i10));
                    ArrayList<String> arrayList7 = sharedElementTargetNames;
                    if (indexOf != -1) {
                        sharedElementSourceNames.set(indexOf, sharedElementSourceNames2.get(i10));
                    }
                    i10++;
                    sharedElementTargetNames = arrayList7;
                }
                ArrayList<String> sharedElementTargetNames2 = eVar2.f().getSharedElementTargetNames();
                if (z11) {
                    eVar.f().getEnterTransitionCallback();
                    eVar2.f().getExitTransitionCallback();
                } else {
                    eVar.f().getExitTransitionCallback();
                    eVar2.f().getEnterTransitionCallback();
                }
                int i11 = 0;
                for (int size = sharedElementSourceNames.size(); i11 < size; size = size) {
                    aVar2.put(sharedElementSourceNames.get(i11), sharedElementTargetNames2.get(i11));
                    i11++;
                }
                if (z.N0(2)) {
                    Log.v("FragmentManager", ">>> entering view names <<<");
                    for (Iterator<String> it4 = sharedElementTargetNames2.iterator(); it4.hasNext(); it4 = it4) {
                        Log.v("FragmentManager", "Name: " + it4.next());
                    }
                    Log.v("FragmentManager", ">>> exiting view names <<<");
                    for (Iterator<String> it5 = sharedElementSourceNames.iterator(); it5.hasNext(); it5 = it5) {
                        Log.v("FragmentManager", "Name: " + it5.next());
                    }
                }
                androidx.collection.a aVar3 = new androidx.collection.a();
                u(aVar3, eVar.f().mView);
                aVar3.w(sharedElementSourceNames);
                aVar2.w(aVar3.keySet());
                androidx.collection.a aVar4 = new androidx.collection.a();
                u(aVar4, eVar2.f().mView);
                aVar4.w(sharedElementTargetNames2);
                aVar4.w(aVar2.values());
                l0.c(aVar2, aVar4);
                v(aVar3, aVar2.keySet());
                v(aVar4, aVar2.values());
                if (aVar2.isEmpty()) {
                    arrayList5.clear();
                    arrayList6.clear();
                    aVar = aVar2;
                    arrayList3 = arrayList6;
                    eVar3 = eVar5;
                    arrayList4 = arrayList5;
                    rect = rect2;
                    view3 = view6;
                    n0Var = n0Var2;
                    view7 = view9;
                    obj3 = null;
                    eVar4 = eVar2;
                    hashMap2 = hashMap3;
                } else {
                    l0.a(eVar2.f(), eVar.f(), z11, aVar3, true);
                    HashMap hashMap4 = hashMap3;
                    View view10 = view6;
                    aVar = aVar2;
                    ArrayList arrayList8 = arrayList6;
                    androidx.core.view.k0.a(m(), new g(eVar2, eVar, z10, aVar4));
                    arrayList5.addAll(aVar3.values());
                    if (sharedElementSourceNames.isEmpty()) {
                        view7 = view9;
                    } else {
                        View view11 = (View) aVar3.get((String) sharedElementSourceNames.get(0));
                        n0Var2.p(u10, view11);
                        view7 = view11;
                    }
                    arrayList3 = arrayList8;
                    arrayList3.addAll(aVar4.values());
                    if (sharedElementTargetNames2.isEmpty() || (view5 = (View) aVar4.get((String) sharedElementTargetNames2.get(0))) == null) {
                        view4 = view10;
                    } else {
                        androidx.core.view.k0.a(m(), new h(n0Var2, view5, rect2));
                        view4 = view10;
                        z12 = true;
                    }
                    n0Var2.s(u10, view4, arrayList5);
                    arrayList4 = arrayList5;
                    rect = rect2;
                    view3 = view4;
                    n0Var = n0Var2;
                    n0Var2.n(u10, null, null, null, null, u10, arrayList3);
                    Boolean bool = Boolean.TRUE;
                    eVar3 = eVar;
                    hashMap2 = hashMap4;
                    hashMap2.put(eVar3, bool);
                    eVar4 = eVar2;
                    hashMap2.put(eVar4, bool);
                    obj3 = u10;
                }
            }
            eVar5 = eVar3;
            arrayList5 = arrayList4;
            rect2 = rect;
            hashMap3 = hashMap2;
            aVar2 = aVar;
            z11 = z10;
            arrayList6 = arrayList3;
            n0Var2 = n0Var;
            r0.e eVar7 = eVar4;
            view6 = view3;
            eVar6 = eVar7;
        }
        View view12 = view7;
        androidx.collection.a aVar5 = aVar2;
        ArrayList arrayList9 = arrayList6;
        r0.e eVar8 = eVar5;
        ArrayList arrayList10 = arrayList5;
        Rect rect3 = rect2;
        n0 n0Var3 = n0Var2;
        HashMap hashMap5 = hashMap3;
        View view13 = view6;
        r0.e eVar9 = eVar6;
        View view14 = view13;
        ArrayList arrayList11 = new ArrayList();
        Iterator it6 = list.iterator();
        Object obj4 = null;
        Object obj5 = null;
        while (it6.hasNext()) {
            m mVar4 = (m) it6.next();
            if (mVar4.d()) {
                hashMap5.put(mVar4.b(), Boolean.FALSE);
                mVar4.a();
            } else {
                Object f10 = n0Var3.f(mVar4.h());
                r0.e b10 = mVar4.b();
                boolean z13 = obj3 != null && (b10 == eVar8 || b10 == eVar9);
                if (f10 == null) {
                    if (!z13) {
                        hashMap5.put(b10, Boolean.FALSE);
                        mVar4.a();
                    }
                    arrayList2 = arrayList9;
                    str3 = str;
                    arrayList = arrayList10;
                    view = view14;
                    k10 = obj4;
                    hashMap = hashMap5;
                    view2 = view12;
                } else {
                    str3 = str;
                    ArrayList arrayList12 = new ArrayList();
                    Object obj6 = obj4;
                    t(arrayList12, b10.f().mView);
                    if (z13) {
                        if (b10 == eVar8) {
                            arrayList12.removeAll(arrayList10);
                        } else {
                            arrayList12.removeAll(arrayList9);
                        }
                    }
                    if (arrayList12.isEmpty()) {
                        n0Var3.a(f10, view14);
                        arrayList2 = arrayList9;
                        arrayList = arrayList10;
                        view = view14;
                        obj2 = obj5;
                        hashMap = hashMap5;
                        obj = obj6;
                    } else {
                        n0Var3.b(f10, arrayList12);
                        view = view14;
                        obj = obj6;
                        arrayList = arrayList10;
                        obj2 = obj5;
                        arrayList2 = arrayList9;
                        hashMap = hashMap5;
                        n0Var3.n(f10, f10, arrayList12, null, null, null, null);
                        if (b10.e() == r0.e.c.GONE) {
                            list2.remove(b10);
                            ArrayList arrayList13 = new ArrayList(arrayList12);
                            arrayList13.remove(b10.f().mView);
                            n0Var3.m(f10, b10.f().mView, arrayList13);
                            androidx.core.view.k0.a(m(), new i(arrayList12));
                        }
                    }
                    if (b10.e() == r0.e.c.VISIBLE) {
                        arrayList11.addAll(arrayList12);
                        if (z12) {
                            n0Var3.o(f10, rect3);
                        }
                        view2 = view12;
                    } else {
                        view2 = view12;
                        n0Var3.p(f10, view2);
                    }
                    hashMap.put(b10, Boolean.TRUE);
                    if (mVar4.j()) {
                        obj5 = n0Var3.k(obj2, f10, null);
                        k10 = obj;
                    } else {
                        k10 = n0Var3.k(obj, f10, null);
                        obj5 = obj2;
                    }
                }
                eVar9 = eVar2;
                hashMap5 = hashMap;
                obj4 = k10;
                view12 = view2;
                str = str3;
                view14 = view;
                arrayList10 = arrayList;
                arrayList9 = arrayList2;
            }
        }
        ArrayList arrayList14 = arrayList9;
        String str4 = str;
        ArrayList arrayList15 = arrayList10;
        HashMap hashMap6 = hashMap5;
        Object j10 = n0Var3.j(obj5, obj4, obj3);
        if (j10 == null) {
            return hashMap6;
        }
        Iterator it7 = list.iterator();
        while (it7.hasNext()) {
            m mVar5 = (m) it7.next();
            if (!mVar5.d()) {
                Object h10 = mVar5.h();
                r0.e b11 = mVar5.b();
                HashMap hashMap7 = hashMap6;
                boolean z14 = obj3 != null && (b11 == eVar8 || b11 == eVar2);
                if (h10 == null && !z14) {
                    str2 = str4;
                } else if (androidx.core.view.s0.Q(m())) {
                    str2 = str4;
                    n0Var3.q(mVar5.b().f(), j10, mVar5.c(), new j(mVar5, b11));
                } else {
                    if (z.N0(2)) {
                        str2 = str4;
                        Log.v(str2, "SpecialEffectsController: Container " + m() + " has not been laid out. Completing operation " + b11);
                    } else {
                        str2 = str4;
                    }
                    mVar5.a();
                }
                hashMap6 = hashMap7;
                str4 = str2;
            }
        }
        HashMap hashMap8 = hashMap6;
        String str5 = str4;
        if (!androidx.core.view.s0.Q(m())) {
            return hashMap8;
        }
        l0.d(arrayList11, 4);
        ArrayList l10 = n0Var3.l(arrayList14);
        if (z.N0(2)) {
            Log.v(str5, ">>>>> Beginning transition <<<<<");
            Log.v(str5, ">>>>> SharedElementFirstOutViews <<<<<");
            Iterator it8 = arrayList15.iterator();
            while (it8.hasNext()) {
                View view15 = (View) it8.next();
                Log.v(str5, "View: " + view15 + " Name: " + androidx.core.view.s0.H(view15));
            }
            Log.v(str5, ">>>>> SharedElementLastInViews <<<<<");
            Iterator it9 = arrayList14.iterator();
            while (it9.hasNext()) {
                View view16 = (View) it9.next();
                Log.v(str5, "View: " + view16 + " Name: " + androidx.core.view.s0.H(view16));
            }
        }
        n0Var3.c(m(), j10);
        n0Var3.r(m(), arrayList15, arrayList14, l10, aVar5);
        l0.d(arrayList11, 0);
        n0Var3.t(obj3, arrayList15, arrayList14);
        return hashMap8;
    }

    @Override // androidx.fragment.app.r0
    void f(List list, boolean z10) {
        Iterator it = list.iterator();
        r0.e eVar = null;
        r0.e eVar2 = null;
        while (it.hasNext()) {
            r0.e eVar3 = (r0.e) it.next();
            r0.e.c from = r0.e.c.from(eVar3.f().mView);
            int i10 = a.f4435a[eVar3.e().ordinal()];
            if (i10 == 1 || i10 == 2 || i10 == 3) {
                if (from == r0.e.c.VISIBLE && eVar == null) {
                    eVar = eVar3;
                }
            } else if (i10 == 4 && from != r0.e.c.VISIBLE) {
                eVar2 = eVar3;
            }
        }
        if (z.N0(2)) {
            Log.v("FragmentManager", "Executing operations from " + eVar + " to " + eVar2);
        }
        ArrayList arrayList = new ArrayList();
        ArrayList arrayList2 = new ArrayList();
        ArrayList arrayList3 = new ArrayList(list);
        Iterator it2 = list.iterator();
        while (it2.hasNext()) {
            r0.e eVar4 = (r0.e) it2.next();
            androidx.core.os.d dVar = new androidx.core.os.d();
            eVar4.j(dVar);
            arrayList.add(new k(eVar4, dVar, z10));
            androidx.core.os.d dVar2 = new androidx.core.os.d();
            eVar4.j(dVar2);
            boolean z11 = false;
            if (z10) {
                if (eVar4 != eVar) {
                    arrayList2.add(new m(eVar4, dVar2, z10, z11));
                    eVar4.a(new b(arrayList3, eVar4));
                }
                z11 = true;
                arrayList2.add(new m(eVar4, dVar2, z10, z11));
                eVar4.a(new b(arrayList3, eVar4));
            } else {
                if (eVar4 != eVar2) {
                    arrayList2.add(new m(eVar4, dVar2, z10, z11));
                    eVar4.a(new b(arrayList3, eVar4));
                }
                z11 = true;
                arrayList2.add(new m(eVar4, dVar2, z10, z11));
                eVar4.a(new b(arrayList3, eVar4));
            }
        }
        Map x10 = x(arrayList2, arrayList3, z10, eVar, eVar2);
        w(arrayList, arrayList3, x10.containsValue(Boolean.TRUE), x10);
        Iterator it3 = arrayList3.iterator();
        while (it3.hasNext()) {
            s((r0.e) it3.next());
        }
        arrayList3.clear();
        if (z.N0(2)) {
            Log.v("FragmentManager", "Completed executing operations from " + eVar + " to " + eVar2);
        }
    }

    void s(r0.e eVar) {
        eVar.e().applyState(eVar.f().mView);
    }

    void t(ArrayList arrayList, View view) {
        if (!(view instanceof ViewGroup)) {
            if (arrayList.contains(view)) {
                return;
            }
            arrayList.add(view);
            return;
        }
        ViewGroup viewGroup = (ViewGroup) view;
        if (x0.a(viewGroup)) {
            if (arrayList.contains(view)) {
                return;
            }
            arrayList.add(viewGroup);
            return;
        }
        int childCount = viewGroup.getChildCount();
        for (int i10 = 0; i10 < childCount; i10++) {
            View childAt = viewGroup.getChildAt(i10);
            if (childAt.getVisibility() == 0) {
                t(arrayList, childAt);
            }
        }
    }

    void u(Map map, View view) {
        String H = androidx.core.view.s0.H(view);
        if (H != null) {
            map.put(H, view);
        }
        if (view instanceof ViewGroup) {
            ViewGroup viewGroup = (ViewGroup) view;
            int childCount = viewGroup.getChildCount();
            for (int i10 = 0; i10 < childCount; i10++) {
                View childAt = viewGroup.getChildAt(i10);
                if (childAt.getVisibility() == 0) {
                    u(map, childAt);
                }
            }
        }
    }

    void v(androidx.collection.a aVar, Collection collection) {
        Iterator it = aVar.entrySet().iterator();
        while (it.hasNext()) {
            if (!collection.contains(androidx.core.view.s0.H((View) ((Map.Entry) it.next()).getValue()))) {
                it.remove();
            }
        }
    }
}
