package androidx.core.view;

import android.view.View;
import android.view.WindowInsets;
import android.view.WindowInsetsAnimation;
import android.view.animation.Interpolator;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;

/* loaded from: classes.dex */
public final class g1 {

    /* renamed from: a, reason: collision with root package name */
    private d f3838a;

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

        /* renamed from: a, reason: collision with root package name */
        private final androidx.core.graphics.b f3839a;

        /* renamed from: b, reason: collision with root package name */
        private final androidx.core.graphics.b f3840b;

        private a(WindowInsetsAnimation.Bounds bounds) {
            this.f3839a = c.e(bounds);
            this.f3840b = c.d(bounds);
        }

        public static a d(WindowInsetsAnimation.Bounds bounds) {
            return new a(bounds);
        }

        public androidx.core.graphics.b a() {
            return this.f3839a;
        }

        public androidx.core.graphics.b b() {
            return this.f3840b;
        }

        public WindowInsetsAnimation.Bounds c() {
            return c.c(this);
        }

        public String toString() {
            return "Bounds{lower=" + this.f3839a + " upper=" + this.f3840b + "}";
        }
    }

    /* loaded from: classes.dex */
    public static abstract class b {

        /* renamed from: p, reason: collision with root package name */
        private final int f3841p;

        public b(int i10) {
            this.f3841p = i10;
        }

        public final int b() {
            return this.f3841p;
        }

        public void c(g1 g1Var) {
        }

        public void d(g1 g1Var) {
        }

        public abstract h1 e(h1 h1Var, List list);

        public a f(g1 g1Var, a aVar) {
            return aVar;
        }
    }

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

        /* renamed from: a, reason: collision with root package name */
        private final int f3847a;

        /* renamed from: b, reason: collision with root package name */
        private final Interpolator f3848b;

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

        d(int i10, Interpolator interpolator, long j10) {
            this.f3847a = i10;
            this.f3848b = interpolator;
            this.f3849c = j10;
        }

        public abstract long a();

        public abstract void b(float f10);
    }

    public g1(int i10, Interpolator interpolator, long j10) {
        this.f3838a = new c(i10, interpolator, j10);
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    public static void b(View view, b bVar) {
        c.f(view, bVar);
    }

    static g1 d(WindowInsetsAnimation windowInsetsAnimation) {
        return new g1(windowInsetsAnimation);
    }

    public long a() {
        return this.f3838a.a();
    }

    public void c(float f10) {
        this.f3838a.b(f10);
    }

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

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

        /* JADX INFO: Access modifiers changed from: private */
        /* loaded from: classes.dex */
        public static class a extends WindowInsetsAnimation.Callback {

            /* renamed from: a, reason: collision with root package name */
            private final b f3843a;

            /* renamed from: b, reason: collision with root package name */
            private List f3844b;

            /* renamed from: c, reason: collision with root package name */
            private ArrayList f3845c;

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

            a(b bVar) {
                super(bVar.b());
                this.f3846d = new HashMap();
                this.f3843a = bVar;
            }

            private g1 a(WindowInsetsAnimation windowInsetsAnimation) {
                g1 g1Var = (g1) this.f3846d.get(windowInsetsAnimation);
                if (g1Var != null) {
                    return g1Var;
                }
                g1 d10 = g1.d(windowInsetsAnimation);
                this.f3846d.put(windowInsetsAnimation, d10);
                return d10;
            }

            @Override // android.view.WindowInsetsAnimation.Callback
            public void onEnd(WindowInsetsAnimation windowInsetsAnimation) {
                this.f3843a.c(a(windowInsetsAnimation));
                this.f3846d.remove(windowInsetsAnimation);
            }

            @Override // android.view.WindowInsetsAnimation.Callback
            public void onPrepare(WindowInsetsAnimation windowInsetsAnimation) {
                this.f3843a.d(a(windowInsetsAnimation));
            }

            @Override // android.view.WindowInsetsAnimation.Callback
            public WindowInsets onProgress(WindowInsets windowInsets, List list) {
                ArrayList arrayList = this.f3845c;
                if (arrayList == null) {
                    ArrayList arrayList2 = new ArrayList(list.size());
                    this.f3845c = arrayList2;
                    this.f3844b = Collections.unmodifiableList(arrayList2);
                } else {
                    arrayList.clear();
                }
                for (int size = list.size() - 1; size >= 0; size--) {
                    WindowInsetsAnimation windowInsetsAnimation = (WindowInsetsAnimation) list.get(size);
                    g1 a10 = a(windowInsetsAnimation);
                    a10.c(windowInsetsAnimation.getFraction());
                    this.f3845c.add(a10);
                }
                return this.f3843a.e(h1.v(windowInsets), this.f3844b).u();
            }

            @Override // android.view.WindowInsetsAnimation.Callback
            public WindowInsetsAnimation.Bounds onStart(WindowInsetsAnimation windowInsetsAnimation, WindowInsetsAnimation.Bounds bounds) {
                return this.f3843a.f(a(windowInsetsAnimation), a.d(bounds)).c();
            }
        }

        c(WindowInsetsAnimation windowInsetsAnimation) {
            super(0, null, 0L);
            this.f3842d = windowInsetsAnimation;
        }

        public static WindowInsetsAnimation.Bounds c(a aVar) {
            return new WindowInsetsAnimation.Bounds(aVar.a().e(), aVar.b().e());
        }

        public static androidx.core.graphics.b d(WindowInsetsAnimation.Bounds bounds) {
            return androidx.core.graphics.b.d(bounds.getUpperBound());
        }

        public static androidx.core.graphics.b e(WindowInsetsAnimation.Bounds bounds) {
            return androidx.core.graphics.b.d(bounds.getLowerBound());
        }

        public static void f(View view, b bVar) {
            view.setWindowInsetsAnimationCallback(bVar != null ? new a(bVar) : null);
        }

        @Override // androidx.core.view.g1.d
        public long a() {
            return this.f3842d.getDurationMillis();
        }

        @Override // androidx.core.view.g1.d
        public void b(float f10) {
            this.f3842d.setFraction(f10);
        }

        c(int i10, Interpolator interpolator, long j10) {
            this(new WindowInsetsAnimation(i10, interpolator, j10));
        }
    }

    private g1(WindowInsetsAnimation windowInsetsAnimation) {
        this(0, null, 0L);
        this.f3838a = new c(windowInsetsAnimation);
    }
}
