package com.google.android.material.bottomsheet;

import android.R;
import android.animation.ValueAnimator;
import android.content.Context;
import android.content.res.ColorStateList;
import android.content.res.TypedArray;
import android.os.Build;
import android.os.Parcel;
import android.os.Parcelable;
import android.util.AttributeSet;
import android.util.Log;
import android.util.TypedValue;
import android.view.MotionEvent;
import android.view.VelocityTracker;
import android.view.View;
import android.view.ViewConfiguration;
import android.view.ViewGroup;
import android.view.ViewParent;
import androidx.coordinatorlayout.widget.CoordinatorLayout;
import androidx.core.view.accessibility.d;
import androidx.core.view.accessibility.g;
import androidx.core.view.y;
import c1.k;
import com.google.android.material.internal.o;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import l0.i;
import l0.j;
import x.c;

/* JADX INFO: loaded from: classes.dex */
public class BottomSheetBehavior<V extends View> extends CoordinatorLayout.c<V> {

    /* JADX INFO: renamed from: c0, reason: collision with root package name */
    private static final int f3642c0 = j.f5448c;
    private ValueAnimator A;
    int B;
    int C;
    int D;
    float E;
    int F;
    float G;
    boolean H;
    private boolean I;
    private boolean J;
    int K;
    x.c L;
    private boolean M;
    private int N;
    private boolean O;
    private int P;
    int Q;
    int R;
    WeakReference<V> S;
    WeakReference<View> T;
    private final ArrayList<f> U;
    private VelocityTracker V;
    int W;
    private int X;
    boolean Y;
    private Map<View, Integer> Z;

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

    /* JADX INFO: renamed from: a0, reason: collision with root package name */
    private int f3644a0;

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

    /* JADX INFO: renamed from: b0, reason: collision with root package name */
    private final c.AbstractC0087c f3646b0;

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

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    private float f3648d;

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

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    private boolean f3650f;

    /* JADX INFO: renamed from: g, reason: collision with root package name */
    private int f3651g;

    /* JADX INFO: renamed from: h, reason: collision with root package name */
    private int f3652h;

    /* JADX INFO: renamed from: i, reason: collision with root package name */
    private c1.g f3653i;

    /* JADX INFO: renamed from: j, reason: collision with root package name */
    private ColorStateList f3654j;

    /* JADX INFO: renamed from: k, reason: collision with root package name */
    private int f3655k;

    /* JADX INFO: renamed from: l, reason: collision with root package name */
    private int f3656l;

    /* JADX INFO: renamed from: m, reason: collision with root package name */
    private int f3657m;

    /* JADX INFO: renamed from: n, reason: collision with root package name */
    private boolean f3658n;

    /* JADX INFO: renamed from: o, reason: collision with root package name */
    private boolean f3659o;

    /* JADX INFO: renamed from: p, reason: collision with root package name */
    private boolean f3660p;

    /* JADX INFO: renamed from: q, reason: collision with root package name */
    private boolean f3661q;

    /* JADX INFO: renamed from: r, reason: collision with root package name */
    private boolean f3662r;

    /* JADX INFO: renamed from: s, reason: collision with root package name */
    private boolean f3663s;

    /* JADX INFO: renamed from: t, reason: collision with root package name */
    private boolean f3664t;

    /* JADX INFO: renamed from: u, reason: collision with root package name */
    private boolean f3665u;

    /* JADX INFO: renamed from: v, reason: collision with root package name */
    private int f3666v;

    /* JADX INFO: renamed from: w, reason: collision with root package name */
    private int f3667w;

    /* JADX INFO: renamed from: x, reason: collision with root package name */
    private k f3668x;

    /* JADX INFO: renamed from: y, reason: collision with root package name */
    private boolean f3669y;

    /* JADX INFO: renamed from: z, reason: collision with root package name */
    private final BottomSheetBehavior<V>.h f3670z;

    class a implements Runnable {

        /* JADX INFO: renamed from: e, reason: collision with root package name */
        final /* synthetic */ View f3671e;

        /* JADX INFO: renamed from: f, reason: collision with root package name */
        final /* synthetic */ int f3672f;

        a(View view, int i3) {
            this.f3671e = view;
            this.f3672f = i3;
        }

        @Override // java.lang.Runnable
        public void run() {
            BottomSheetBehavior.this.J0(this.f3671e, this.f3672f, false);
        }
    }

    class b implements ValueAnimator.AnimatorUpdateListener {
        b() {
        }

        @Override // android.animation.ValueAnimator.AnimatorUpdateListener
        public void onAnimationUpdate(ValueAnimator valueAnimator) {
            float fFloatValue = ((Float) valueAnimator.getAnimatedValue()).floatValue();
            if (BottomSheetBehavior.this.f3653i != null) {
                BottomSheetBehavior.this.f3653i.Y(fFloatValue);
            }
        }
    }

    class c implements o.d {

        /* JADX INFO: renamed from: a, reason: collision with root package name */
        final /* synthetic */ boolean f3675a;

        c(boolean z2) {
            this.f3675a = z2;
        }

        /* JADX WARN: Removed duplicated region for block: B:22:0x0080  */
        /* JADX WARN: Removed duplicated region for block: B:33:0x00a3  */
        @Override // com.google.android.material.internal.o.d
        /*
            Code decompiled incorrectly, please refer to instructions dump.
            To view partially-correct add '--show-bad-code' argument
        */
        public androidx.core.view.j0 a(android.view.View r11, androidx.core.view.j0 r12, com.google.android.material.internal.o.e r13) {
            /*
                Method dump skipped, instruction units count: 205
                To view this dump add '--comments-level debug' option
            */
            throw new UnsupportedOperationException("Method not decompiled: com.google.android.material.bottomsheet.BottomSheetBehavior.c.a(android.view.View, androidx.core.view.j0, com.google.android.material.internal.o$e):androidx.core.view.j0");
        }
    }

    class d extends c.AbstractC0087c {

        /* JADX INFO: renamed from: a, reason: collision with root package name */
        private long f3677a;

        d() {
        }

        private boolean n(View view) {
            int top = view.getTop();
            BottomSheetBehavior bottomSheetBehavior = BottomSheetBehavior.this;
            return top > (bottomSheetBehavior.R + bottomSheetBehavior.f0()) / 2;
        }

        @Override // x.c.AbstractC0087c
        public int a(View view, int i3, int i4) {
            return view.getLeft();
        }

        @Override // x.c.AbstractC0087c
        public int b(View view, int i3, int i4) {
            int iF0 = BottomSheetBehavior.this.f0();
            BottomSheetBehavior bottomSheetBehavior = BottomSheetBehavior.this;
            return t.a.b(i3, iF0, bottomSheetBehavior.H ? bottomSheetBehavior.R : bottomSheetBehavior.F);
        }

        @Override // x.c.AbstractC0087c
        public int e(View view) {
            BottomSheetBehavior bottomSheetBehavior = BottomSheetBehavior.this;
            return bottomSheetBehavior.H ? bottomSheetBehavior.R : bottomSheetBehavior.F;
        }

        @Override // x.c.AbstractC0087c
        public void j(int i3) {
            if (i3 == 1 && BottomSheetBehavior.this.J) {
                BottomSheetBehavior.this.C0(1);
            }
        }

        @Override // x.c.AbstractC0087c
        public void k(View view, int i3, int i4, int i5, int i6) {
            BottomSheetBehavior.this.c0(i4);
        }

        /* JADX WARN: Removed duplicated region for block: B:39:0x00a7  */
        /* JADX WARN: Removed duplicated region for block: B:6:0x0010  */
        @Override // x.c.AbstractC0087c
        /*
            Code decompiled incorrectly, please refer to instructions dump.
            To view partially-correct add '--show-bad-code' argument
        */
        public void l(android.view.View r8, float r9, float r10) {
            /*
                Method dump skipped, instruction units count: 302
                To view this dump add '--comments-level debug' option
            */
            throw new UnsupportedOperationException("Method not decompiled: com.google.android.material.bottomsheet.BottomSheetBehavior.d.l(android.view.View, float, float):void");
        }

        @Override // x.c.AbstractC0087c
        public boolean m(View view, int i3) {
            BottomSheetBehavior bottomSheetBehavior = BottomSheetBehavior.this;
            int i4 = bottomSheetBehavior.K;
            if (i4 == 1 || bottomSheetBehavior.Y) {
                return false;
            }
            if (i4 == 3 && bottomSheetBehavior.W == i3) {
                WeakReference<View> weakReference = bottomSheetBehavior.T;
                View view2 = weakReference != null ? weakReference.get() : null;
                if (view2 != null && view2.canScrollVertically(-1)) {
                    return false;
                }
            }
            this.f3677a = System.currentTimeMillis();
            WeakReference<V> weakReference2 = BottomSheetBehavior.this.S;
            return weakReference2 != null && weakReference2.get() == view;
        }
    }

    class e implements androidx.core.view.accessibility.g {

        /* JADX INFO: renamed from: a, reason: collision with root package name */
        final /* synthetic */ int f3679a;

        e(int i3) {
            this.f3679a = i3;
        }

        @Override // androidx.core.view.accessibility.g
        public boolean a(View view, g.a aVar) {
            BottomSheetBehavior.this.B0(this.f3679a);
            return true;
        }
    }

    public static abstract class f {
        void a(View view) {
        }

        public abstract void b(View view, float f3);

        public abstract void c(View view, int i3);
    }

    public BottomSheetBehavior() {
        this.f3643a = 0;
        this.f3645b = true;
        this.f3647c = false;
        this.f3655k = -1;
        this.f3656l = -1;
        this.f3670z = new h(this, null);
        this.E = 0.5f;
        this.G = -1.0f;
        this.J = true;
        this.K = 4;
        this.U = new ArrayList<>();
        this.f3644a0 = -1;
        this.f3646b0 = new d();
    }

    private void D0(View view) {
        boolean z2 = (Build.VERSION.SDK_INT < 29 || i0() || this.f3650f) ? false : true;
        if (this.f3659o || this.f3660p || this.f3661q || this.f3663s || this.f3664t || this.f3665u || z2) {
            o.a(view, new c(z2));
        }
    }

    private boolean F0() {
        return this.L != null && (this.J || this.K == 1);
    }

    /* JADX INFO: Access modifiers changed from: private */
    public void J0(View view, int i3, boolean z2) {
        int iG0 = g0(i3);
        x.c cVar = this.L;
        if (!(cVar != null && (!z2 ? !cVar.H(view, view.getLeft(), iG0) : !cVar.F(view.getLeft(), iG0)))) {
            C0(i3);
            return;
        }
        C0(2);
        L0(i3);
        this.f3670z.c(i3);
    }

    private void K0() {
        V v2;
        WeakReference<V> weakReference = this.S;
        if (weakReference == null || (v2 = weakReference.get()) == null) {
            return;
        }
        y.l0(v2, 524288);
        y.l0(v2, 262144);
        y.l0(v2, 1048576);
        int i3 = this.f3644a0;
        if (i3 != -1) {
            y.l0(v2, i3);
        }
        if (!this.f3645b && this.K != 6) {
            this.f3644a0 = V(v2, i.f5430a, 6);
        }
        if (this.H && this.K != 5) {
            l0(v2, d.a.f1854j, 5);
        }
        int i4 = this.K;
        if (i4 == 3) {
            l0(v2, d.a.f1853i, this.f3645b ? 4 : 6);
            return;
        }
        if (i4 == 4) {
            l0(v2, d.a.f1852h, this.f3645b ? 3 : 6);
        } else {
            if (i4 != 6) {
                return;
            }
            l0(v2, d.a.f1853i, 4);
            l0(v2, d.a.f1852h, 3);
        }
    }

    private void L0(int i3) {
        ValueAnimator valueAnimator;
        if (i3 == 2) {
            return;
        }
        boolean z2 = i3 == 3;
        if (this.f3669y != z2) {
            this.f3669y = z2;
            if (this.f3653i == null || (valueAnimator = this.A) == null) {
                return;
            }
            if (valueAnimator.isRunning()) {
                this.A.reverse();
                return;
            }
            float f3 = z2 ? 0.0f : 1.0f;
            this.A.setFloatValues(1.0f - f3, f3);
            this.A.start();
        }
    }

    private void M0(boolean z2) {
        Map<View, Integer> map;
        WeakReference<V> weakReference = this.S;
        if (weakReference == null) {
            return;
        }
        ViewParent parent = weakReference.get().getParent();
        if (parent instanceof CoordinatorLayout) {
            CoordinatorLayout coordinatorLayout = (CoordinatorLayout) parent;
            int childCount = coordinatorLayout.getChildCount();
            if (Build.VERSION.SDK_INT >= 16 && z2) {
                if (this.Z != null) {
                    return;
                } else {
                    this.Z = new HashMap(childCount);
                }
            }
            for (int i3 = 0; i3 < childCount; i3++) {
                View childAt = coordinatorLayout.getChildAt(i3);
                if (childAt != this.S.get()) {
                    if (z2) {
                        if (Build.VERSION.SDK_INT >= 16) {
                            this.Z.put(childAt, Integer.valueOf(childAt.getImportantForAccessibility()));
                        }
                        if (this.f3647c) {
                            y.B0(childAt, 4);
                        }
                    } else if (this.f3647c && (map = this.Z) != null && map.containsKey(childAt)) {
                        y.B0(childAt, this.Z.get(childAt).intValue());
                    }
                }
            }
            if (!z2) {
                this.Z = null;
            } else if (this.f3647c) {
                this.S.get().sendAccessibilityEvent(8);
            }
        }
    }

    /* JADX INFO: Access modifiers changed from: private */
    public void N0(boolean z2) {
        V v2;
        if (this.S != null) {
            W();
            if (this.K != 4 || (v2 = this.S.get()) == null) {
                return;
            }
            if (z2) {
                B0(4);
            } else {
                v2.requestLayout();
            }
        }
    }

    private int V(V v2, int i3, int i4) {
        return y.c(v2, v2.getResources().getString(i3), Z(i4));
    }

    private void W() {
        int iY = Y();
        if (this.f3645b) {
            this.F = Math.max(this.R - iY, this.C);
        } else {
            this.F = this.R - iY;
        }
    }

    private void X() {
        this.D = (int) (this.R * (1.0f - this.E));
    }

    private int Y() {
        int iMin;
        int i3;
        int i4;
        if (this.f3650f) {
            iMin = Math.min(Math.max(this.f3651g, this.R - ((this.Q * 9) / 16)), this.P);
            i3 = this.f3666v;
        } else {
            if (!this.f3658n && !this.f3659o && (i4 = this.f3657m) > 0) {
                return Math.max(this.f3649e, i4 + this.f3652h);
            }
            iMin = this.f3649e;
            i3 = this.f3666v;
        }
        return iMin + i3;
    }

    private androidx.core.view.accessibility.g Z(int i3) {
        return new e(i3);
    }

    private void a0(Context context) {
        if (this.f3668x == null) {
            return;
        }
        c1.g gVar = new c1.g(this.f3668x);
        this.f3653i = gVar;
        gVar.N(context);
        ColorStateList colorStateList = this.f3654j;
        if (colorStateList != null) {
            this.f3653i.X(colorStateList);
            return;
        }
        TypedValue typedValue = new TypedValue();
        context.getTheme().resolveAttribute(R.attr.colorBackground, typedValue, true);
        this.f3653i.setTint(typedValue.data);
    }

    private void b0() {
        ValueAnimator valueAnimatorOfFloat = ValueAnimator.ofFloat(0.0f, 1.0f);
        this.A = valueAnimatorOfFloat;
        valueAnimatorOfFloat.setDuration(500L);
        this.A.addUpdateListener(new b());
    }

    private int e0(int i3, int i4, int i5, int i6) {
        int childMeasureSpec = ViewGroup.getChildMeasureSpec(i3, i4, i6);
        if (i5 == -1) {
            return childMeasureSpec;
        }
        int mode = View.MeasureSpec.getMode(childMeasureSpec);
        int size = View.MeasureSpec.getSize(childMeasureSpec);
        if (mode == 1073741824) {
            return View.MeasureSpec.makeMeasureSpec(Math.min(size, i5), 1073741824);
        }
        if (size != 0) {
            i5 = Math.min(size, i5);
        }
        return View.MeasureSpec.makeMeasureSpec(i5, Integer.MIN_VALUE);
    }

    private int g0(int i3) {
        if (i3 == 3) {
            return f0();
        }
        if (i3 == 4) {
            return this.F;
        }
        if (i3 == 5) {
            return this.R;
        }
        if (i3 == 6) {
            return this.D;
        }
        throw new IllegalArgumentException("Invalid state to get top offset: " + i3);
    }

    private float h0() {
        VelocityTracker velocityTracker = this.V;
        if (velocityTracker == null) {
            return 0.0f;
        }
        velocityTracker.computeCurrentVelocity(1000, this.f3648d);
        return this.V.getYVelocity(this.W);
    }

    private boolean j0(V v2) {
        ViewParent parent = v2.getParent();
        return parent != null && parent.isLayoutRequested() && y.U(v2);
    }

    private void l0(V v2, d.a aVar, int i3) {
        y.n0(v2, aVar, null, Z(i3));
    }

    private void m0() {
        this.W = -1;
        VelocityTracker velocityTracker = this.V;
        if (velocityTracker != null) {
            velocityTracker.recycle();
            this.V = null;
        }
    }

    private void n0(g gVar) {
        int i3 = this.f3643a;
        if (i3 == 0) {
            return;
        }
        if (i3 == -1 || (i3 & 1) == 1) {
            this.f3649e = gVar.f3682h;
        }
        if (i3 == -1 || (i3 & 2) == 2) {
            this.f3645b = gVar.f3683i;
        }
        if (i3 == -1 || (i3 & 4) == 4) {
            this.H = gVar.f3684j;
        }
        if (i3 == -1 || (i3 & 8) == 8) {
            this.I = gVar.f3685k;
        }
    }

    private void o0(V v2, Runnable runnable) {
        if (j0(v2)) {
            v2.post(runnable);
        } else {
            runnable.run();
        }
    }

    @Override // androidx.coordinatorlayout.widget.CoordinatorLayout.c
    public boolean A(CoordinatorLayout coordinatorLayout, V v2, View view, View view2, int i3, int i4) {
        this.N = 0;
        this.O = false;
        return (i3 & 2) != 0;
    }

    public void A0(boolean z2) {
        this.I = z2;
    }

    public void B0(int i3) {
        if (i3 == 1 || i3 == 2) {
            StringBuilder sb = new StringBuilder();
            sb.append("STATE_");
            sb.append(i3 == 1 ? "DRAGGING" : "SETTLING");
            sb.append(" should not be set externally.");
            throw new IllegalArgumentException(sb.toString());
        }
        if (!this.H && i3 == 5) {
            Log.w("BottomSheetBehavior", "Cannot set state: " + i3);
            return;
        }
        int i4 = (i3 == 6 && this.f3645b && g0(i3) <= this.C) ? 3 : i3;
        WeakReference<V> weakReference = this.S;
        if (weakReference == null || weakReference.get() == null) {
            C0(i3);
        } else {
            V v2 = this.S.get();
            o0(v2, new a(v2, i4));
        }
    }

    /* JADX WARN: Removed duplicated region for block: B:48:0x0092  */
    /* JADX WARN: Removed duplicated region for block: B:51:0x00a9  */
    @Override // androidx.coordinatorlayout.widget.CoordinatorLayout.c
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    public void C(androidx.coordinatorlayout.widget.CoordinatorLayout r3, V r4, android.view.View r5, int r6) {
        /*
            r2 = this;
            int r3 = r4.getTop()
            int r6 = r2.f0()
            r0 = 3
            if (r3 != r6) goto Lf
            r2.C0(r0)
            return
        Lf:
            boolean r3 = r2.k0()
            if (r3 == 0) goto L24
            java.lang.ref.WeakReference<android.view.View> r3 = r2.T
            if (r3 == 0) goto L23
            java.lang.Object r3 = r3.get()
            if (r5 != r3) goto L23
            boolean r3 = r2.O
            if (r3 != 0) goto L24
        L23:
            return
        L24:
            int r3 = r2.N
            r5 = 6
            r6 = 4
            if (r3 <= 0) goto L3a
            boolean r3 = r2.f3645b
            if (r3 == 0) goto L30
            goto Laa
        L30:
            int r3 = r4.getTop()
            int r6 = r2.D
            if (r3 <= r6) goto Laa
            goto La9
        L3a:
            boolean r3 = r2.H
            if (r3 == 0) goto L4a
            float r3 = r2.h0()
            boolean r3 = r2.G0(r4, r3)
            if (r3 == 0) goto L4a
            r0 = 5
            goto Laa
        L4a:
            int r3 = r2.N
            if (r3 != 0) goto L8e
            int r3 = r4.getTop()
            boolean r1 = r2.f3645b
            if (r1 == 0) goto L68
            int r5 = r2.C
            int r5 = r3 - r5
            int r5 = java.lang.Math.abs(r5)
            int r1 = r2.F
            int r3 = r3 - r1
            int r3 = java.lang.Math.abs(r3)
            if (r5 >= r3) goto L92
            goto Laa
        L68:
            int r1 = r2.D
            if (r3 >= r1) goto L7e
            int r1 = r2.F
            int r1 = r3 - r1
            int r1 = java.lang.Math.abs(r1)
            if (r3 >= r1) goto L77
            goto Laa
        L77:
            boolean r3 = r2.H0()
            if (r3 == 0) goto La9
            goto L92
        L7e:
            int r0 = r3 - r1
            int r0 = java.lang.Math.abs(r0)
            int r1 = r2.F
            int r3 = r3 - r1
            int r3 = java.lang.Math.abs(r3)
            if (r0 >= r3) goto L92
            goto La9
        L8e:
            boolean r3 = r2.f3645b
            if (r3 == 0) goto L94
        L92:
            r0 = r6
            goto Laa
        L94:
            int r3 = r4.getTop()
            int r0 = r2.D
            int r0 = r3 - r0
            int r0 = java.lang.Math.abs(r0)
            int r1 = r2.F
            int r3 = r3 - r1
            int r3 = java.lang.Math.abs(r3)
            if (r0 >= r3) goto L92
        La9:
            r0 = r5
        Laa:
            r3 = 0
            r2.J0(r4, r0, r3)
            r2.O = r3
            return
        */
        throw new UnsupportedOperationException("Method not decompiled: com.google.android.material.bottomsheet.BottomSheetBehavior.C(androidx.coordinatorlayout.widget.CoordinatorLayout, android.view.View, android.view.View, int):void");
    }

    void C0(int i3) {
        V v2;
        if (this.K == i3) {
            return;
        }
        this.K = i3;
        if (i3 != 4 && i3 != 3 && i3 != 6) {
            boolean z2 = this.H;
        }
        WeakReference<V> weakReference = this.S;
        if (weakReference == null || (v2 = weakReference.get()) == null) {
            return;
        }
        if (i3 == 3) {
            M0(true);
        } else if (i3 == 6 || i3 == 5 || i3 == 4) {
            M0(false);
        }
        L0(i3);
        for (int i4 = 0; i4 < this.U.size(); i4++) {
            this.U.get(i4).c(v2, i3);
        }
        K0();
    }

    @Override // androidx.coordinatorlayout.widget.CoordinatorLayout.c
    public boolean D(CoordinatorLayout coordinatorLayout, V v2, MotionEvent motionEvent) {
        if (!v2.isShown()) {
            return false;
        }
        int actionMasked = motionEvent.getActionMasked();
        if (this.K == 1 && actionMasked == 0) {
            return true;
        }
        if (F0()) {
            this.L.z(motionEvent);
        }
        if (actionMasked == 0) {
            m0();
        }
        if (this.V == null) {
            this.V = VelocityTracker.obtain();
        }
        this.V.addMovement(motionEvent);
        if (F0() && actionMasked == 2 && !this.M && Math.abs(this.X - motionEvent.getY()) > this.L.u()) {
            this.L.b(v2, motionEvent.getPointerId(motionEvent.getActionIndex()));
        }
        return !this.M;
    }

    public boolean E0(long j3, float f3) {
        return false;
    }

    boolean G0(View view, float f3) {
        if (this.I) {
            return true;
        }
        if (view.getTop() < this.F) {
            return false;
        }
        return Math.abs((((float) view.getTop()) + (f3 * 0.1f)) - ((float) this.F)) / ((float) Y()) > 0.5f;
    }

    public boolean H0() {
        return false;
    }

    public boolean I0() {
        return true;
    }

    void c0(int i3) {
        float f3;
        float fF0;
        V v2 = this.S.get();
        if (v2 == null || this.U.isEmpty()) {
            return;
        }
        int i4 = this.F;
        if (i3 > i4 || i4 == f0()) {
            int i5 = this.F;
            f3 = i5 - i3;
            fF0 = this.R - i5;
        } else {
            int i6 = this.F;
            f3 = i6 - i3;
            fF0 = i6 - f0();
        }
        float f4 = f3 / fF0;
        for (int i7 = 0; i7 < this.U.size(); i7++) {
            this.U.get(i7).b(v2, f4);
        }
    }

    View d0(View view) {
        if (y.W(view)) {
            return view;
        }
        if (!(view instanceof ViewGroup)) {
            return null;
        }
        ViewGroup viewGroup = (ViewGroup) view;
        int childCount = viewGroup.getChildCount();
        for (int i3 = 0; i3 < childCount; i3++) {
            View viewD0 = d0(viewGroup.getChildAt(i3));
            if (viewD0 != null) {
                return viewD0;
            }
        }
        return null;
    }

    public int f0() {
        if (this.f3645b) {
            return this.C;
        }
        return Math.max(this.B, this.f3662r ? 0 : this.f3667w);
    }

    @Override // androidx.coordinatorlayout.widget.CoordinatorLayout.c
    public void g(CoordinatorLayout.f fVar) {
        super.g(fVar);
        this.S = null;
        this.L = null;
    }

    public boolean i0() {
        return this.f3658n;
    }

    @Override // androidx.coordinatorlayout.widget.CoordinatorLayout.c
    public void j() {
        super.j();
        this.S = null;
        this.L = null;
    }

    @Override // androidx.coordinatorlayout.widget.CoordinatorLayout.c
    public boolean k(CoordinatorLayout coordinatorLayout, V v2, MotionEvent motionEvent) {
        x.c cVar;
        if (!v2.isShown() || !this.J) {
            this.M = true;
            return false;
        }
        int actionMasked = motionEvent.getActionMasked();
        if (actionMasked == 0) {
            m0();
        }
        if (this.V == null) {
            this.V = VelocityTracker.obtain();
        }
        this.V.addMovement(motionEvent);
        if (actionMasked == 0) {
            int x2 = (int) motionEvent.getX();
            this.X = (int) motionEvent.getY();
            if (this.K != 2) {
                WeakReference<View> weakReference = this.T;
                View view = weakReference != null ? weakReference.get() : null;
                if (view != null && coordinatorLayout.B(view, x2, this.X)) {
                    this.W = motionEvent.getPointerId(motionEvent.getActionIndex());
                    this.Y = true;
                }
            }
            this.M = this.W == -1 && !coordinatorLayout.B(v2, x2, this.X);
        } else if (actionMasked == 1 || actionMasked == 3) {
            this.Y = false;
            this.W = -1;
            if (this.M) {
                this.M = false;
                return false;
            }
        }
        if (!this.M && (cVar = this.L) != null && cVar.G(motionEvent)) {
            return true;
        }
        WeakReference<View> weakReference2 = this.T;
        View view2 = weakReference2 != null ? weakReference2.get() : null;
        return (actionMasked != 2 || view2 == null || this.M || this.K == 1 || coordinatorLayout.B(view2, (int) motionEvent.getX(), (int) motionEvent.getY()) || this.L == null || Math.abs(((float) this.X) - motionEvent.getY()) <= ((float) this.L.u())) ? false : true;
    }

    public boolean k0() {
        return true;
    }

    @Override // androidx.coordinatorlayout.widget.CoordinatorLayout.c
    public boolean l(CoordinatorLayout coordinatorLayout, V v2, int i3) {
        if (y.B(coordinatorLayout) && !y.B(v2)) {
            v2.setFitsSystemWindows(true);
        }
        if (this.S == null) {
            this.f3651g = coordinatorLayout.getResources().getDimensionPixelSize(l0.d.f5351b);
            D0(v2);
            this.S = new WeakReference<>(v2);
            c1.g gVar = this.f3653i;
            if (gVar != null) {
                y.v0(v2, gVar);
                c1.g gVar2 = this.f3653i;
                float fY = this.G;
                if (fY == -1.0f) {
                    fY = y.y(v2);
                }
                gVar2.W(fY);
                boolean z2 = this.K == 3;
                this.f3669y = z2;
                this.f3653i.Y(z2 ? 0.0f : 1.0f);
            } else {
                ColorStateList colorStateList = this.f3654j;
                if (colorStateList != null) {
                    y.w0(v2, colorStateList);
                }
            }
            K0();
            if (y.C(v2) == 0) {
                y.B0(v2, 1);
            }
        }
        if (this.L == null) {
            this.L = x.c.m(coordinatorLayout, this.f3646b0);
        }
        int top = v2.getTop();
        coordinatorLayout.I(v2, i3);
        this.Q = coordinatorLayout.getWidth();
        this.R = coordinatorLayout.getHeight();
        int height = v2.getHeight();
        this.P = height;
        int i4 = this.R;
        int i5 = i4 - height;
        int i6 = this.f3667w;
        if (i5 < i6) {
            if (this.f3662r) {
                this.P = i4;
            } else {
                this.P = i4 - i6;
            }
        }
        this.C = Math.max(0, i4 - this.P);
        X();
        W();
        int i7 = this.K;
        if (i7 == 3) {
            y.c0(v2, f0());
        } else if (i7 == 6) {
            y.c0(v2, this.D);
        } else if (this.H && i7 == 5) {
            y.c0(v2, this.R);
        } else if (i7 == 4) {
            y.c0(v2, this.F);
        } else if (i7 == 1 || i7 == 2) {
            y.c0(v2, top - v2.getTop());
        }
        this.T = new WeakReference<>(d0(v2));
        for (int i8 = 0; i8 < this.U.size(); i8++) {
            this.U.get(i8).a(v2);
        }
        return true;
    }

    @Override // androidx.coordinatorlayout.widget.CoordinatorLayout.c
    public boolean m(CoordinatorLayout coordinatorLayout, V v2, int i3, int i4, int i5, int i6) {
        ViewGroup.MarginLayoutParams marginLayoutParams = (ViewGroup.MarginLayoutParams) v2.getLayoutParams();
        v2.measure(e0(i3, coordinatorLayout.getPaddingLeft() + coordinatorLayout.getPaddingRight() + marginLayoutParams.leftMargin + marginLayoutParams.rightMargin + i4, this.f3655k, marginLayoutParams.width), e0(i5, coordinatorLayout.getPaddingTop() + coordinatorLayout.getPaddingBottom() + marginLayoutParams.topMargin + marginLayoutParams.bottomMargin + i6, this.f3656l, marginLayoutParams.height));
        return true;
    }

    @Override // androidx.coordinatorlayout.widget.CoordinatorLayout.c
    public boolean o(CoordinatorLayout coordinatorLayout, V v2, View view, float f3, float f4) {
        WeakReference<View> weakReference;
        if (k0() && (weakReference = this.T) != null && view == weakReference.get()) {
            return this.K != 3 || super.o(coordinatorLayout, v2, view, f3, f4);
        }
        return false;
    }

    public void p0(boolean z2) {
        this.J = z2;
    }

    @Override // androidx.coordinatorlayout.widget.CoordinatorLayout.c
    public void q(CoordinatorLayout coordinatorLayout, V v2, View view, int i3, int i4, int[] iArr, int i5) {
        if (i5 == 1) {
            return;
        }
        WeakReference<View> weakReference = this.T;
        View view2 = weakReference != null ? weakReference.get() : null;
        if (!k0() || view == view2) {
            int top = v2.getTop();
            int i6 = top - i4;
            if (i4 > 0) {
                if (i6 < f0()) {
                    iArr[1] = top - f0();
                    y.c0(v2, -iArr[1]);
                    C0(3);
                } else {
                    if (!this.J) {
                        return;
                    }
                    iArr[1] = i4;
                    y.c0(v2, -i4);
                    C0(1);
                }
            } else if (i4 < 0 && !view.canScrollVertically(-1)) {
                int i7 = this.F;
                if (i6 > i7 && !this.H) {
                    iArr[1] = top - i7;
                    y.c0(v2, -iArr[1]);
                    C0(4);
                } else {
                    if (!this.J) {
                        return;
                    }
                    iArr[1] = i4;
                    y.c0(v2, -i4);
                    C0(1);
                }
            }
            c0(v2.getTop());
            this.N = i4;
            this.O = true;
        }
    }

    public void q0(int i3) {
        if (i3 < 0) {
            throw new IllegalArgumentException("offset must be greater than or equal to 0");
        }
        this.B = i3;
    }

    public void r0(boolean z2) {
        if (this.f3645b == z2) {
            return;
        }
        this.f3645b = z2;
        if (this.S != null) {
            W();
        }
        C0((this.f3645b && this.K == 6) ? 3 : this.K);
        K0();
    }

    public void s0(boolean z2) {
        this.f3658n = z2;
    }

    @Override // androidx.coordinatorlayout.widget.CoordinatorLayout.c
    public void t(CoordinatorLayout coordinatorLayout, V v2, View view, int i3, int i4, int i5, int i6, int i7, int[] iArr) {
    }

    public void t0(float f3) {
        if (f3 <= 0.0f || f3 >= 1.0f) {
            throw new IllegalArgumentException("ratio must be a float value between 0 and 1");
        }
        this.E = f3;
        if (this.S != null) {
            X();
        }
    }

    public void u0(boolean z2) {
        if (this.H != z2) {
            this.H = z2;
            if (!z2 && this.K == 5) {
                B0(4);
            }
            K0();
        }
    }

    public void v0(int i3) {
        this.f3656l = i3;
    }

    public void w0(int i3) {
        this.f3655k = i3;
    }

    @Override // androidx.coordinatorlayout.widget.CoordinatorLayout.c
    public void x(CoordinatorLayout coordinatorLayout, V v2, Parcelable parcelable) {
        g gVar = (g) parcelable;
        super.x(coordinatorLayout, v2, gVar.j());
        n0(gVar);
        int i3 = gVar.f3681g;
        if (i3 == 1 || i3 == 2) {
            this.K = 4;
        } else {
            this.K = i3;
        }
    }

    public void x0(int i3) {
        y0(i3, false);
    }

    @Override // androidx.coordinatorlayout.widget.CoordinatorLayout.c
    public Parcelable y(CoordinatorLayout coordinatorLayout, V v2) {
        return new g(super.y(coordinatorLayout, v2), (BottomSheetBehavior<?>) this);
    }

    /* JADX WARN: Removed duplicated region for block: B:12:0x0015  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    public final void y0(int r4, boolean r5) {
        /*
            r3 = this;
            r0 = 1
            r1 = 0
            r2 = -1
            if (r4 != r2) goto Lc
            boolean r4 = r3.f3650f
            if (r4 != 0) goto L15
            r3.f3650f = r0
            goto L1f
        Lc:
            boolean r2 = r3.f3650f
            if (r2 != 0) goto L17
            int r2 = r3.f3649e
            if (r2 == r4) goto L15
            goto L17
        L15:
            r0 = r1
            goto L1f
        L17:
            r3.f3650f = r1
            int r4 = java.lang.Math.max(r1, r4)
            r3.f3649e = r4
        L1f:
            if (r0 == 0) goto L24
            r3.N0(r5)
        L24:
            return
        */
        throw new UnsupportedOperationException("Method not decompiled: com.google.android.material.bottomsheet.BottomSheetBehavior.y0(int, boolean):void");
    }

    public void z0(int i3) {
        this.f3643a = i3;
    }

    private class h {

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

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

        /* JADX INFO: renamed from: c, reason: collision with root package name */
        private final Runnable f3688c;

        class a implements Runnable {
            a() {
            }

            @Override // java.lang.Runnable
            public void run() {
                h.this.f3687b = false;
                x.c cVar = BottomSheetBehavior.this.L;
                if (cVar != null && cVar.k(true)) {
                    h hVar = h.this;
                    hVar.c(hVar.f3686a);
                    return;
                }
                h hVar2 = h.this;
                BottomSheetBehavior bottomSheetBehavior = BottomSheetBehavior.this;
                if (bottomSheetBehavior.K == 2) {
                    bottomSheetBehavior.C0(hVar2.f3686a);
                }
            }
        }

        private h() {
            this.f3688c = new a();
        }

        void c(int i3) {
            WeakReference<V> weakReference = BottomSheetBehavior.this.S;
            if (weakReference == null || weakReference.get() == null) {
                return;
            }
            this.f3686a = i3;
            if (this.f3687b) {
                return;
            }
            y.j0(BottomSheetBehavior.this.S.get(), this.f3688c);
            this.f3687b = true;
        }

        /* synthetic */ h(BottomSheetBehavior bottomSheetBehavior, a aVar) {
            this();
        }
    }

    protected static class g extends w.a {
        public static final Parcelable.Creator<g> CREATOR = new a();

        /* JADX INFO: renamed from: g, reason: collision with root package name */
        final int f3681g;

        /* JADX INFO: renamed from: h, reason: collision with root package name */
        int f3682h;

        /* JADX INFO: renamed from: i, reason: collision with root package name */
        boolean f3683i;

        /* JADX INFO: renamed from: j, reason: collision with root package name */
        boolean f3684j;

        /* JADX INFO: renamed from: k, reason: collision with root package name */
        boolean f3685k;

        class a implements Parcelable.ClassLoaderCreator<g> {
            a() {
            }

            @Override // android.os.Parcelable.Creator
            /* JADX INFO: renamed from: a, reason: merged with bridge method [inline-methods] */
            public g createFromParcel(Parcel parcel) {
                return new g(parcel, (ClassLoader) null);
            }

            @Override // android.os.Parcelable.ClassLoaderCreator
            /* JADX INFO: renamed from: b, reason: merged with bridge method [inline-methods] */
            public g createFromParcel(Parcel parcel, ClassLoader classLoader) {
                return new g(parcel, classLoader);
            }

            @Override // android.os.Parcelable.Creator
            /* JADX INFO: renamed from: c, reason: merged with bridge method [inline-methods] */
            public g[] newArray(int i3) {
                return new g[i3];
            }
        }

        public g(Parcel parcel, ClassLoader classLoader) {
            super(parcel, classLoader);
            this.f3681g = parcel.readInt();
            this.f3682h = parcel.readInt();
            this.f3683i = parcel.readInt() == 1;
            this.f3684j = parcel.readInt() == 1;
            this.f3685k = parcel.readInt() == 1;
        }

        @Override // w.a, android.os.Parcelable
        public void writeToParcel(Parcel parcel, int i3) {
            super.writeToParcel(parcel, i3);
            parcel.writeInt(this.f3681g);
            parcel.writeInt(this.f3682h);
            parcel.writeInt(this.f3683i ? 1 : 0);
            parcel.writeInt(this.f3684j ? 1 : 0);
            parcel.writeInt(this.f3685k ? 1 : 0);
        }

        public g(Parcelable parcelable, BottomSheetBehavior<?> bottomSheetBehavior) {
            super(parcelable);
            this.f3681g = bottomSheetBehavior.K;
            this.f3682h = ((BottomSheetBehavior) bottomSheetBehavior).f3649e;
            this.f3683i = ((BottomSheetBehavior) bottomSheetBehavior).f3645b;
            this.f3684j = bottomSheetBehavior.H;
            this.f3685k = ((BottomSheetBehavior) bottomSheetBehavior).I;
        }
    }

    public BottomSheetBehavior(Context context, AttributeSet attributeSet) {
        int i3;
        super(context, attributeSet);
        this.f3643a = 0;
        this.f3645b = true;
        this.f3647c = false;
        this.f3655k = -1;
        this.f3656l = -1;
        this.f3670z = new h(this, null);
        this.E = 0.5f;
        this.G = -1.0f;
        this.J = true;
        this.K = 4;
        this.U = new ArrayList<>();
        this.f3644a0 = -1;
        this.f3646b0 = new d();
        this.f3652h = context.getResources().getDimensionPixelSize(l0.d.M);
        TypedArray typedArrayObtainStyledAttributes = context.obtainStyledAttributes(attributeSet, l0.k.f5476e);
        int i4 = l0.k.f5492i;
        if (typedArrayObtainStyledAttributes.hasValue(i4)) {
            this.f3654j = z0.c.a(context, typedArrayObtainStyledAttributes, i4);
        }
        if (typedArrayObtainStyledAttributes.hasValue(l0.k.f5546z)) {
            this.f3668x = k.e(context, attributeSet, l0.b.f5319b, f3642c0).m();
        }
        a0(context);
        b0();
        if (Build.VERSION.SDK_INT >= 21) {
            this.G = typedArrayObtainStyledAttributes.getDimension(l0.k.f5488h, -1.0f);
        }
        int i5 = l0.k.f5480f;
        if (typedArrayObtainStyledAttributes.hasValue(i5)) {
            w0(typedArrayObtainStyledAttributes.getDimensionPixelSize(i5, -1));
        }
        int i6 = l0.k.f5484g;
        if (typedArrayObtainStyledAttributes.hasValue(i6)) {
            v0(typedArrayObtainStyledAttributes.getDimensionPixelSize(i6, -1));
        }
        int i7 = l0.k.f5513o;
        TypedValue typedValuePeekValue = typedArrayObtainStyledAttributes.peekValue(i7);
        if (typedValuePeekValue != null && (i3 = typedValuePeekValue.data) == -1) {
            x0(i3);
        } else {
            x0(typedArrayObtainStyledAttributes.getDimensionPixelSize(i7, -1));
        }
        u0(typedArrayObtainStyledAttributes.getBoolean(l0.k.f5510n, false));
        s0(typedArrayObtainStyledAttributes.getBoolean(l0.k.f5522r, false));
        r0(typedArrayObtainStyledAttributes.getBoolean(l0.k.f5504l, true));
        A0(typedArrayObtainStyledAttributes.getBoolean(l0.k.f5519q, false));
        p0(typedArrayObtainStyledAttributes.getBoolean(l0.k.f5496j, true));
        z0(typedArrayObtainStyledAttributes.getInt(l0.k.f5516p, 0));
        t0(typedArrayObtainStyledAttributes.getFloat(l0.k.f5507m, 0.5f));
        int i8 = l0.k.f5500k;
        TypedValue typedValuePeekValue2 = typedArrayObtainStyledAttributes.peekValue(i8);
        if (typedValuePeekValue2 != null && typedValuePeekValue2.type == 16) {
            q0(typedValuePeekValue2.data);
        } else {
            q0(typedArrayObtainStyledAttributes.getDimensionPixelOffset(i8, 0));
        }
        this.f3659o = typedArrayObtainStyledAttributes.getBoolean(l0.k.f5534v, false);
        this.f3660p = typedArrayObtainStyledAttributes.getBoolean(l0.k.f5537w, false);
        this.f3661q = typedArrayObtainStyledAttributes.getBoolean(l0.k.f5540x, false);
        this.f3662r = typedArrayObtainStyledAttributes.getBoolean(l0.k.f5543y, true);
        this.f3663s = typedArrayObtainStyledAttributes.getBoolean(l0.k.f5525s, false);
        this.f3664t = typedArrayObtainStyledAttributes.getBoolean(l0.k.f5528t, false);
        this.f3665u = typedArrayObtainStyledAttributes.getBoolean(l0.k.f5531u, false);
        typedArrayObtainStyledAttributes.recycle();
        this.f3648d = ViewConfiguration.get(context).getScaledMaximumFlingVelocity();
    }
}
