package r3;

import android.os.Build;
import android.view.ViewGroup;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.Iterator;

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

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public static final a f32369a = new a();

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

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public static final ArrayList f32371c = new ArrayList();

    public static androidx.collection.f a() {
        androidx.collection.f fVar;
        ThreadLocal threadLocal = f32370b;
        WeakReference weakReference = (WeakReference) threadLocal.get();
        if (weakReference != null && (fVar = (androidx.collection.f) weakReference.get()) != null) {
            return fVar;
        }
        androidx.collection.f fVar2 = new androidx.collection.f();
        threadLocal.set(new WeakReference(fVar2));
        return fVar2;
    }

    public static void b(ViewGroup viewGroup, z zVar) {
        ArrayList arrayList = (ArrayList) a().get(viewGroup);
        if (arrayList != null && arrayList.size() > 0) {
            Iterator it = arrayList.iterator();
            while (it.hasNext()) {
                ((z) it.next()).pause(viewGroup);
            }
        }
        if (zVar != null) {
            zVar.h(viewGroup, true);
        }
        p.getCurrentScene(viewGroup);
    }

    public static void beginDelayedTransition(@NonNull ViewGroup viewGroup, @Nullable z zVar) {
        ArrayList arrayList = f32371c;
        if (arrayList.contains(viewGroup) || !viewGroup.isLaidOut()) {
            return;
        }
        arrayList.add(viewGroup);
        if (zVar == null) {
            zVar = f32369a;
        }
        z zVarClone = zVar.clone();
        b(viewGroup, zVarClone);
        p.setCurrentScene(viewGroup, null);
        if (zVarClone != null) {
            c0 c0Var = new c0();
            c0Var.f32360a = zVarClone;
            c0Var.f32361b = viewGroup;
            viewGroup.addOnAttachStateChangeListener(c0Var);
            viewGroup.getViewTreeObserver().addOnPreDrawListener(c0Var);
        }
    }

    @Nullable
    public static f0 controlDelayedTransition(@NonNull ViewGroup viewGroup, @NonNull z zVar) {
        ArrayList arrayList = f32371c;
        if (arrayList.contains(viewGroup) || !viewGroup.isLaidOut() || Build.VERSION.SDK_INT < 34) {
            return null;
        }
        if (!zVar.t()) {
            throw new IllegalArgumentException("The Transition must support seeking.");
        }
        arrayList.add(viewGroup);
        z zVarClone = zVar.clone();
        h0 h0Var = new h0();
        h0Var.H(zVarClone);
        b(viewGroup, h0Var);
        p.setCurrentScene(viewGroup, null);
        c0 c0Var = new c0();
        c0Var.f32360a = h0Var;
        c0Var.f32361b = viewGroup;
        viewGroup.addOnAttachStateChangeListener(c0Var);
        viewGroup.getViewTreeObserver().addOnPreDrawListener(c0Var);
        viewGroup.invalidate();
        w wVar = new w(h0Var);
        h0Var.f32457e0 = wVar;
        h0Var.a(wVar);
        return h0Var.f32457e0;
    }

    @Nullable
    public static f0 createSeekController(@NonNull p pVar, @NonNull z zVar) {
        throw null;
    }

    public static void endTransitions(@Nullable ViewGroup viewGroup) {
        f32371c.remove(viewGroup);
        ArrayList arrayList = (ArrayList) a().get(viewGroup);
        if (arrayList == null || arrayList.isEmpty()) {
            return;
        }
        ArrayList arrayList2 = new ArrayList(arrayList);
        for (int size = arrayList2.size() - 1; size >= 0; size--) {
            ((z) arrayList2.get(size)).forceToEnd(viewGroup);
        }
    }

    public static void go(@NonNull p pVar, @Nullable z zVar) {
        throw null;
    }
}
