package androidx.drawerlayout.widget;

import android.R;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Matrix;
import android.graphics.Paint;
import android.graphics.Rect;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.os.Parcelable;
import android.util.AttributeSet;
import android.view.Gravity;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowInsets;
import androidx.annotation.ColorInt;
import androidx.annotation.DrawableRes;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.RestrictTo;
import androidx.core.view.f3;
import androidx.core.view.i1;
import androidx.core.view.s1;
import com.google.android.material.navigation.NavigationView;
import com.google.android.material.navigation.p;
import d1.a;
import d1.b;
import d1.d;
import d1.e;
import d1.f;
import d1.g;
import java.util.ArrayList;
import java.util.Objects;
import java.util.WeakHashMap;
import q0.c;
import u0.k;
import y0.h;

/* JADX INFO: loaded from: classes.dex */
public class DrawerLayout extends ViewGroup {

    /* JADX INFO: renamed from: q0, reason: collision with root package name */
    public static final int[] f2172q0 = {R.attr.colorPrimaryDark};

    /* JADX INFO: renamed from: r0, reason: collision with root package name */
    public static final int[] f2173r0 = {R.attr.layout_gravity};

    /* JADX INFO: renamed from: s0, reason: collision with root package name */
    public static final boolean f2174s0;

    /* JADX INFO: renamed from: t0, reason: collision with root package name */
    public static final boolean f2175t0;

    /* JADX INFO: renamed from: u0, reason: collision with root package name */
    public static final boolean f2176u0;
    public int Q;
    public int R;
    public int S;
    public int T;
    public boolean U;
    public ArrayList V;
    public float W;

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public final k f2177a;

    /* JADX INFO: renamed from: a0, reason: collision with root package name */
    public float f2178a0;

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

    /* JADX INFO: renamed from: b0, reason: collision with root package name */
    public Drawable f2180b0;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public final int f2181c;

    /* JADX INFO: renamed from: c0, reason: collision with root package name */
    public Drawable f2182c0;

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

    /* JADX INFO: renamed from: d0, reason: collision with root package name */
    public Drawable f2184d0;

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

    /* JADX INFO: renamed from: e0, reason: collision with root package name */
    public CharSequence f2186e0;

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    public final Paint f2187f;

    /* JADX INFO: renamed from: f0, reason: collision with root package name */
    public CharSequence f2188f0;

    /* JADX INFO: renamed from: g, reason: collision with root package name */
    public final h f2189g;

    /* JADX INFO: renamed from: g0, reason: collision with root package name */
    public Object f2190g0;

    /* JADX INFO: renamed from: h, reason: collision with root package name */
    public final h f2191h;

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

    /* JADX INFO: renamed from: i, reason: collision with root package name */
    public final g f2193i;

    /* JADX INFO: renamed from: i0, reason: collision with root package name */
    public Drawable f2194i0;

    /* JADX INFO: renamed from: j, reason: collision with root package name */
    public final g f2195j;

    /* JADX INFO: renamed from: j0, reason: collision with root package name */
    public Drawable f2196j0;

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

    /* JADX INFO: renamed from: k0, reason: collision with root package name */
    public Drawable f2198k0;

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

    /* JADX INFO: renamed from: l0, reason: collision with root package name */
    public Drawable f2200l0;

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

    /* JADX INFO: renamed from: m0, reason: collision with root package name */
    public final ArrayList f2202m0;

    @Nullable
    private d mListener;

    /* JADX INFO: renamed from: n0, reason: collision with root package name */
    public Rect f2203n0;

    /* JADX INFO: renamed from: o0, reason: collision with root package name */
    public Matrix f2204o0;

    /* JADX INFO: renamed from: p0, reason: collision with root package name */
    public final a f2205p0;

    static {
        int i10 = Build.VERSION.SDK_INT;
        f2174s0 = true;
        f2175t0 = true;
        f2176u0 = i10 >= 29;
    }

    public DrawerLayout(@NonNull Context context) {
        this(context, null);
    }

    public static boolean i(View view) {
        WeakHashMap weakHashMap = s1.f1815a;
        return (view.getImportantForAccessibility() == 4 || view.getImportantForAccessibility() == 2) ? false : true;
    }

    public static boolean j(View view) {
        return ((e) view.getLayoutParams()).f24917a == 0;
    }

    public static boolean k(View view) {
        if (l(view)) {
            return (((e) view.getLayoutParams()).f24920d & 1) == 1;
        }
        throw new IllegalArgumentException("View " + view + " is not a drawer");
    }

    public static boolean l(View view) {
        int i10 = ((e) view.getLayoutParams()).f24917a;
        WeakHashMap weakHashMap = s1.f1815a;
        int absoluteGravity = Gravity.getAbsoluteGravity(i10, view.getLayoutDirection());
        return ((absoluteGravity & 3) == 0 && (absoluteGravity & 5) == 0) ? false : true;
    }

    public final boolean a(int i10, View view) {
        return (h(view) & i10) == i10;
    }

    @Override // android.view.ViewGroup, android.view.View
    public final void addFocusables(ArrayList arrayList, int i10, int i11) {
        ArrayList arrayList2;
        if (getDescendantFocusability() == 393216) {
            return;
        }
        int childCount = getChildCount();
        int i12 = 0;
        boolean z10 = false;
        while (true) {
            arrayList2 = this.f2202m0;
            if (i12 >= childCount) {
                break;
            }
            View childAt = getChildAt(i12);
            if (!l(childAt)) {
                arrayList2.add(childAt);
            } else if (k(childAt)) {
                childAt.addFocusables(arrayList, i10, i11);
                z10 = true;
            }
            i12++;
        }
        if (!z10) {
            int size = arrayList2.size();
            for (int i13 = 0; i13 < size; i13++) {
                View view = (View) arrayList2.get(i13);
                if (view.getVisibility() == 0) {
                    view.addFocusables(arrayList, i10, i11);
                }
            }
        }
        arrayList2.clear();
    }

    @Override // android.view.ViewGroup
    public final void addView(View view, int i10, ViewGroup.LayoutParams layoutParams) {
        super.addView(view, i10, layoutParams);
        if (e() != null || l(view)) {
            WeakHashMap weakHashMap = s1.f1815a;
            view.setImportantForAccessibility(4);
        } else {
            WeakHashMap weakHashMap2 = s1.f1815a;
            view.setImportantForAccessibility(1);
        }
        if (f2174s0) {
            return;
        }
        s1.setAccessibilityDelegate(view, this.f2177a);
    }

    public final void b(View view, boolean z10) {
        if (!l(view)) {
            throw new IllegalArgumentException("View " + view + " is not a sliding drawer");
        }
        e eVar = (e) view.getLayoutParams();
        if (this.f2201m) {
            eVar.f24918b = 0.0f;
            eVar.f24920d = 0;
        } else if (z10) {
            eVar.f24920d |= 4;
            if (a(3, view)) {
                this.f2189g.s(view, -view.getWidth(), view.getTop());
            } else {
                this.f2191h.s(view, getWidth(), view.getTop());
            }
        } else {
            float f10 = ((e) view.getLayoutParams()).f24918b;
            float width = view.getWidth();
            int i10 = ((int) (width * 0.0f)) - ((int) (f10 * width));
            if (!a(3, view)) {
                i10 = -i10;
            }
            view.offsetLeftAndRight(i10);
            o(0.0f, view);
            r(0, view);
            view.setVisibility(4);
        }
        invalidate();
    }

    public final void c(boolean z10) {
        int childCount = getChildCount();
        boolean zS = false;
        for (int i10 = 0; i10 < childCount; i10++) {
            View childAt = getChildAt(i10);
            e eVar = (e) childAt.getLayoutParams();
            if (l(childAt) && (!z10 || eVar.f24919c)) {
                zS |= a(3, childAt) ? this.f2189g.s(childAt, -childAt.getWidth(), childAt.getTop()) : this.f2191h.s(childAt, getWidth(), childAt.getTop());
                eVar.f24919c = false;
            }
        }
        g gVar = this.f2193i;
        gVar.f24929d.removeCallbacks(gVar.f24928c);
        g gVar2 = this.f2195j;
        gVar2.f24929d.removeCallbacks(gVar2.f24928c);
        if (zS) {
            invalidate();
        }
    }

    @Override // android.view.ViewGroup
    public final boolean checkLayoutParams(ViewGroup.LayoutParams layoutParams) {
        return (layoutParams instanceof e) && super.checkLayoutParams(layoutParams);
    }

    @Override // android.view.View
    public final void computeScroll() {
        int childCount = getChildCount();
        float fMax = 0.0f;
        for (int i10 = 0; i10 < childCount; i10++) {
            fMax = Math.max(fMax, ((e) getChildAt(i10).getLayoutParams()).f24918b);
        }
        this.f2185e = fMax;
        boolean zH = this.f2189g.h();
        boolean zH2 = this.f2191h.h();
        if (zH || zH2) {
            WeakHashMap weakHashMap = s1.f1815a;
            postInvalidateOnAnimation();
        }
    }

    public final View d(int i10) {
        WeakHashMap weakHashMap = s1.f1815a;
        int absoluteGravity = Gravity.getAbsoluteGravity(i10, getLayoutDirection()) & 7;
        int childCount = getChildCount();
        for (int i11 = 0; i11 < childCount; i11++) {
            View childAt = getChildAt(i11);
            if ((h(childAt) & 7) == absoluteGravity) {
                return childAt;
            }
        }
        return null;
    }

    @Override // android.view.View
    public final boolean dispatchGenericMotionEvent(MotionEvent motionEvent) {
        boolean zDispatchGenericMotionEvent;
        if ((motionEvent.getSource() & 2) == 0 || motionEvent.getAction() == 10 || this.f2185e <= 0.0f) {
            return super.dispatchGenericMotionEvent(motionEvent);
        }
        int childCount = getChildCount();
        if (childCount == 0) {
            return false;
        }
        float x10 = motionEvent.getX();
        float y10 = motionEvent.getY();
        for (int i10 = childCount - 1; i10 >= 0; i10--) {
            View childAt = getChildAt(i10);
            if (this.f2203n0 == null) {
                this.f2203n0 = new Rect();
            }
            childAt.getHitRect(this.f2203n0);
            if (this.f2203n0.contains((int) x10, (int) y10) && !j(childAt)) {
                if (childAt.getMatrix().isIdentity()) {
                    float scrollX = getScrollX() - childAt.getLeft();
                    float scrollY = getScrollY() - childAt.getTop();
                    motionEvent.offsetLocation(scrollX, scrollY);
                    zDispatchGenericMotionEvent = childAt.dispatchGenericMotionEvent(motionEvent);
                    motionEvent.offsetLocation(-scrollX, -scrollY);
                } else {
                    float scrollX2 = getScrollX() - childAt.getLeft();
                    float scrollY2 = getScrollY() - childAt.getTop();
                    MotionEvent motionEventObtain = MotionEvent.obtain(motionEvent);
                    motionEventObtain.offsetLocation(scrollX2, scrollY2);
                    Matrix matrix = childAt.getMatrix();
                    if (!matrix.isIdentity()) {
                        if (this.f2204o0 == null) {
                            this.f2204o0 = new Matrix();
                        }
                        matrix.invert(this.f2204o0);
                        motionEventObtain.transform(this.f2204o0);
                    }
                    zDispatchGenericMotionEvent = childAt.dispatchGenericMotionEvent(motionEventObtain);
                    motionEventObtain.recycle();
                }
                if (zDispatchGenericMotionEvent) {
                    return true;
                }
            }
        }
        return false;
    }

    @Override // android.view.ViewGroup
    public final boolean drawChild(Canvas canvas, View view, long j10) {
        Drawable background;
        int height = getHeight();
        boolean zJ = j(view);
        int width = getWidth();
        int iSave = canvas.save();
        int i10 = 0;
        if (zJ) {
            int childCount = getChildCount();
            int i11 = 0;
            for (int i12 = 0; i12 < childCount; i12++) {
                View childAt = getChildAt(i12);
                if (childAt != view && childAt.getVisibility() == 0 && (background = childAt.getBackground()) != null && background.getOpacity() == -1 && l(childAt) && childAt.getHeight() >= height) {
                    if (a(3, childAt)) {
                        int right = childAt.getRight();
                        if (right > i11) {
                            i11 = right;
                        }
                    } else {
                        int left = childAt.getLeft();
                        if (left < width) {
                            width = left;
                        }
                    }
                }
            }
            canvas.clipRect(i11, 0, width, getHeight());
            i10 = i11;
        }
        boolean zDrawChild = super.drawChild(canvas, view, j10);
        canvas.restoreToCount(iSave);
        float f10 = this.f2185e;
        if (f10 > 0.0f && zJ) {
            int i13 = this.f2183d;
            Paint paint = this.f2187f;
            paint.setColor((i13 & 16777215) | (((int) ((((-16777216) & i13) >>> 24) * f10)) << 24));
            canvas.drawRect(i10, 0.0f, width, getHeight(), paint);
        } else if (this.f2182c0 != null && a(3, view)) {
            int intrinsicWidth = this.f2182c0.getIntrinsicWidth();
            int right2 = view.getRight();
            float fMax = Math.max(0.0f, Math.min(right2 / this.f2189g.f36692o, 1.0f));
            this.f2182c0.setBounds(right2, view.getTop(), intrinsicWidth + right2, view.getBottom());
            this.f2182c0.setAlpha((int) (fMax * 255.0f));
            this.f2182c0.draw(canvas);
        } else if (this.f2184d0 != null && a(5, view)) {
            int intrinsicWidth2 = this.f2184d0.getIntrinsicWidth();
            int left2 = view.getLeft();
            float fMax2 = Math.max(0.0f, Math.min((getWidth() - left2) / this.f2191h.f36692o, 1.0f));
            this.f2184d0.setBounds(left2 - intrinsicWidth2, view.getTop(), left2, view.getBottom());
            this.f2184d0.setAlpha((int) (fMax2 * 255.0f));
            this.f2184d0.draw(canvas);
        }
        return zDrawChild;
    }

    public final View e() {
        int childCount = getChildCount();
        for (int i10 = 0; i10 < childCount; i10++) {
            View childAt = getChildAt(i10);
            if ((((e) childAt.getLayoutParams()).f24920d & 1) == 1) {
                return childAt;
            }
        }
        return null;
    }

    public final View f() {
        int childCount = getChildCount();
        for (int i10 = 0; i10 < childCount; i10++) {
            View childAt = getChildAt(i10);
            if (l(childAt)) {
                if (!l(childAt)) {
                    throw new IllegalArgumentException("View " + childAt + " is not a drawer");
                }
                if (((e) childAt.getLayoutParams()).f24918b > 0.0f) {
                    return childAt;
                }
            }
        }
        return null;
    }

    public final int g(View view) {
        if (!l(view)) {
            throw new IllegalArgumentException("View " + view + " is not a drawer");
        }
        int i10 = ((e) view.getLayoutParams()).f24917a;
        WeakHashMap weakHashMap = s1.f1815a;
        int layoutDirection = getLayoutDirection();
        if (i10 == 3) {
            int i11 = this.Q;
            if (i11 != 3) {
                return i11;
            }
            int i12 = layoutDirection == 0 ? this.S : this.T;
            if (i12 != 3) {
                return i12;
            }
        } else if (i10 == 5) {
            int i13 = this.R;
            if (i13 != 3) {
                return i13;
            }
            int i14 = layoutDirection == 0 ? this.T : this.S;
            if (i14 != 3) {
                return i14;
            }
        } else if (i10 == 8388611) {
            int i15 = this.S;
            if (i15 != 3) {
                return i15;
            }
            int i16 = layoutDirection == 0 ? this.Q : this.R;
            if (i16 != 3) {
                return i16;
            }
        } else if (i10 == 8388613) {
            int i17 = this.T;
            if (i17 != 3) {
                return i17;
            }
            int i18 = layoutDirection == 0 ? this.R : this.Q;
            if (i18 != 3) {
                return i18;
            }
        }
        return 0;
    }

    @Override // android.view.ViewGroup
    public final ViewGroup.LayoutParams generateDefaultLayoutParams() {
        e eVar = new e(-1, -1);
        eVar.f24917a = 0;
        return eVar;
    }

    @Override // android.view.ViewGroup
    public final ViewGroup.LayoutParams generateLayoutParams(ViewGroup.LayoutParams layoutParams) {
        if (layoutParams instanceof e) {
            e eVar = (e) layoutParams;
            e eVar2 = new e(eVar);
            eVar2.f24917a = 0;
            eVar2.f24917a = eVar.f24917a;
            return eVar2;
        }
        if (layoutParams instanceof ViewGroup.MarginLayoutParams) {
            e eVar3 = new e((ViewGroup.MarginLayoutParams) layoutParams);
            eVar3.f24917a = 0;
            return eVar3;
        }
        e eVar4 = new e(layoutParams);
        eVar4.f24917a = 0;
        return eVar4;
    }

    public float getDrawerElevation() {
        if (f2175t0) {
            return this.f2179b;
        }
        return 0.0f;
    }

    @Nullable
    public CharSequence getDrawerTitle(int i10) {
        WeakHashMap weakHashMap = s1.f1815a;
        int absoluteGravity = Gravity.getAbsoluteGravity(i10, getLayoutDirection());
        if (absoluteGravity == 3) {
            return this.f2186e0;
        }
        if (absoluteGravity == 5) {
            return this.f2188f0;
        }
        return null;
    }

    @Nullable
    public Drawable getStatusBarBackgroundDrawable() {
        return this.f2180b0;
    }

    public final int h(View view) {
        int i10 = ((e) view.getLayoutParams()).f24917a;
        WeakHashMap weakHashMap = s1.f1815a;
        return Gravity.getAbsoluteGravity(i10, getLayoutDirection());
    }

    public final void m(View view) {
        if (!l(view)) {
            throw new IllegalArgumentException("View " + view + " is not a sliding drawer");
        }
        e eVar = (e) view.getLayoutParams();
        if (this.f2201m) {
            eVar.f24918b = 1.0f;
            eVar.f24920d = 1;
            q(view, true);
            p(view);
        } else {
            eVar.f24920d |= 2;
            if (a(3, view)) {
                this.f2189g.s(view, 0, view.getTop());
            } else {
                this.f2191h.s(view, getWidth() - view.getWidth(), view.getTop());
            }
        }
        invalidate();
    }

    /* JADX WARN: Removed duplicated region for block: B:19:0x002d  */
    /* JADX WARN: Removed duplicated region for block: B:34:0x0057  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final void n() {
        Drawable drawable;
        Drawable drawable2;
        if (f2175t0) {
            return;
        }
        WeakHashMap weakHashMap = s1.f1815a;
        int layoutDirection = getLayoutDirection();
        if (layoutDirection == 0) {
            Drawable drawable3 = this.f2194i0;
            if (drawable3 != null) {
                if (drawable3.isAutoMirrored()) {
                    drawable3.setLayoutDirection(layoutDirection);
                }
                drawable = this.f2194i0;
            } else {
                drawable = this.f2198k0;
            }
        } else {
            Drawable drawable4 = this.f2196j0;
            if (drawable4 != null) {
                if (drawable4.isAutoMirrored()) {
                    drawable4.setLayoutDirection(layoutDirection);
                }
                drawable = this.f2196j0;
            }
        }
        this.f2182c0 = drawable;
        int layoutDirection2 = getLayoutDirection();
        if (layoutDirection2 == 0) {
            Drawable drawable5 = this.f2196j0;
            if (drawable5 != null) {
                if (drawable5.isAutoMirrored()) {
                    drawable5.setLayoutDirection(layoutDirection2);
                }
                drawable2 = this.f2196j0;
            } else {
                drawable2 = this.f2200l0;
            }
        } else {
            Drawable drawable6 = this.f2194i0;
            if (drawable6 != null) {
                if (drawable6.isAutoMirrored()) {
                    drawable6.setLayoutDirection(layoutDirection2);
                }
                drawable2 = this.f2194i0;
            }
        }
        this.f2184d0 = drawable2;
    }

    public final void o(float f10, View view) {
        e eVar = (e) view.getLayoutParams();
        if (f10 == eVar.f24918b) {
            return;
        }
        eVar.f24918b = f10;
        ArrayList arrayList = this.V;
        if (arrayList != null) {
            for (int size = arrayList.size() - 1; size >= 0; size--) {
                ((d) this.V.get(size)).getClass();
            }
        }
    }

    @Override // android.view.ViewGroup, android.view.View
    public final void onAttachedToWindow() {
        super.onAttachedToWindow();
        this.f2201m = true;
    }

    @Override // android.view.ViewGroup, android.view.View
    public final void onDetachedFromWindow() {
        super.onDetachedFromWindow();
        this.f2201m = true;
    }

    @Override // android.view.View
    public final void onDraw(Canvas canvas) {
        super.onDraw(canvas);
        if (!this.f2192h0 || this.f2180b0 == null) {
            return;
        }
        Object obj = this.f2190g0;
        int systemWindowInsetTop = obj != null ? ((WindowInsets) obj).getSystemWindowInsetTop() : 0;
        if (systemWindowInsetTop > 0) {
            this.f2180b0.setBounds(0, 0, getWidth(), systemWindowInsetTop);
            this.f2180b0.draw(canvas);
        }
    }

    /* JADX WARN: Removed duplicated region for block: B:18:0x005e  */
    @Override // android.view.ViewGroup
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final boolean onInterceptTouchEvent(MotionEvent motionEvent) {
        boolean z10;
        View viewFindTopChildUnder;
        int actionMasked = motionEvent.getActionMasked();
        h hVar = this.f2189g;
        boolean zR = hVar.r(motionEvent) | this.f2191h.r(motionEvent);
        if (actionMasked == 0) {
            float x10 = motionEvent.getX();
            float y10 = motionEvent.getY();
            this.W = x10;
            this.f2178a0 = y10;
            z10 = this.f2185e > 0.0f && (viewFindTopChildUnder = hVar.findTopChildUnder((int) x10, (int) y10)) != null && j(viewFindTopChildUnder);
            this.U = false;
        } else if (actionMasked == 1) {
            c(true);
            this.U = false;
            z10 = false;
        } else {
            if (actionMasked == 2) {
                int length = hVar.f36681d.length;
                int i10 = 0;
                while (true) {
                    if (i10 >= length) {
                        break;
                    }
                    if ((hVar.f36688k & (1 << i10)) != 0) {
                        float f10 = hVar.f36683f[i10] - hVar.f36681d[i10];
                        float f11 = hVar.f36684g[i10] - hVar.f36682e[i10];
                        float f12 = (f11 * f11) + (f10 * f10);
                        int i11 = hVar.f36679b;
                        if (f12 > i11 * i11) {
                            g gVar = this.f2193i;
                            gVar.f24929d.removeCallbacks(gVar.f24928c);
                            g gVar2 = this.f2195j;
                            gVar2.f24929d.removeCallbacks(gVar2.f24928c);
                            break;
                        }
                    }
                    i10++;
                }
            } else if (actionMasked == 3) {
            }
            z10 = false;
        }
        if (zR || z10) {
            return true;
        }
        int childCount = getChildCount();
        for (int i12 = 0; i12 < childCount; i12++) {
            if (((e) getChildAt(i12).getLayoutParams()).f24919c) {
                return true;
            }
        }
        return this.U;
    }

    @Override // android.view.View, android.view.KeyEvent.Callback
    public final boolean onKeyDown(int i10, KeyEvent keyEvent) {
        if (i10 != 4 || f() == null) {
            return super.onKeyDown(i10, keyEvent);
        }
        keyEvent.startTracking();
        return true;
    }

    @Override // android.view.View, android.view.KeyEvent.Callback
    public final boolean onKeyUp(int i10, KeyEvent keyEvent) {
        if (i10 != 4) {
            return super.onKeyUp(i10, keyEvent);
        }
        View viewF = f();
        if (viewF != null && g(viewF) == 0) {
            c(false);
        }
        return viewF != null;
    }

    @Override // android.view.ViewGroup, android.view.View
    public final void onLayout(boolean z10, int i10, int i11, int i12, int i13) {
        WindowInsets rootWindowInsets;
        float f10;
        int i14;
        boolean z11 = true;
        this.f2199l = true;
        int i15 = i12 - i10;
        int childCount = getChildCount();
        int i16 = 0;
        while (i16 < childCount) {
            View childAt = getChildAt(i16);
            if (childAt.getVisibility() != 8) {
                e eVar = (e) childAt.getLayoutParams();
                if (j(childAt)) {
                    int i17 = ((ViewGroup.MarginLayoutParams) eVar).leftMargin;
                    childAt.layout(i17, ((ViewGroup.MarginLayoutParams) eVar).topMargin, childAt.getMeasuredWidth() + i17, childAt.getMeasuredHeight() + ((ViewGroup.MarginLayoutParams) eVar).topMargin);
                } else {
                    int measuredWidth = childAt.getMeasuredWidth();
                    int measuredHeight = childAt.getMeasuredHeight();
                    if (a(3, childAt)) {
                        float f11 = measuredWidth;
                        i14 = (-measuredWidth) + ((int) (eVar.f24918b * f11));
                        f10 = (measuredWidth + i14) / f11;
                    } else {
                        float f12 = measuredWidth;
                        f10 = (i15 - r11) / f12;
                        i14 = i15 - ((int) (eVar.f24918b * f12));
                    }
                    boolean z12 = f10 != eVar.f24918b ? z11 : false;
                    int i18 = eVar.f24917a & 112;
                    if (i18 == 16) {
                        int i19 = i13 - i11;
                        int i20 = (i19 - measuredHeight) / 2;
                        int i21 = ((ViewGroup.MarginLayoutParams) eVar).topMargin;
                        if (i20 < i21) {
                            i20 = i21;
                        } else {
                            int i22 = i20 + measuredHeight;
                            int i23 = i19 - ((ViewGroup.MarginLayoutParams) eVar).bottomMargin;
                            if (i22 > i23) {
                                i20 = i23 - measuredHeight;
                            }
                        }
                        childAt.layout(i14, i20, measuredWidth + i14, measuredHeight + i20);
                    } else if (i18 != 80) {
                        int i24 = ((ViewGroup.MarginLayoutParams) eVar).topMargin;
                        childAt.layout(i14, i24, measuredWidth + i14, measuredHeight + i24);
                    } else {
                        int i25 = i13 - i11;
                        childAt.layout(i14, (i25 - ((ViewGroup.MarginLayoutParams) eVar).bottomMargin) - childAt.getMeasuredHeight(), measuredWidth + i14, i25 - ((ViewGroup.MarginLayoutParams) eVar).bottomMargin);
                    }
                    if (z12) {
                        o(f10, childAt);
                    }
                    int i26 = eVar.f24918b > 0.0f ? 0 : 4;
                    if (childAt.getVisibility() != i26) {
                        childAt.setVisibility(i26);
                    }
                }
            }
            i16++;
            z11 = true;
        }
        if (f2176u0 && (rootWindowInsets = getRootWindowInsets()) != null) {
            j0.d dVarI = f3.toWindowInsetsCompat(rootWindowInsets, null).f1747a.i();
            h hVar = this.f2189g;
            hVar.f36692o = Math.max(hVar.f36693p, dVarI.f28502a);
            h hVar2 = this.f2191h;
            hVar2.f36692o = Math.max(hVar2.f36693p, dVarI.f28504c);
        }
        this.f2199l = false;
        this.f2201m = false;
    }

    /* JADX WARN: Removed duplicated region for block: B:17:0x0038  */
    @Override // android.view.View
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final void onMeasure(int i10, int i11) {
        boolean z10;
        int mode = View.MeasureSpec.getMode(i10);
        int mode2 = View.MeasureSpec.getMode(i11);
        int size = View.MeasureSpec.getSize(i10);
        int size2 = View.MeasureSpec.getSize(i11);
        if (mode != 1073741824 || mode2 != 1073741824) {
            if (!isInEditMode()) {
                throw new IllegalArgumentException("DrawerLayout must be measured with MeasureSpec.EXACTLY.");
            }
            if (mode == 0) {
                size = 300;
            }
            if (mode2 == 0) {
                size2 = 300;
            }
        }
        setMeasuredDimension(size, size2);
        if (this.f2190g0 != null) {
            WeakHashMap weakHashMap = s1.f1815a;
            z10 = getFitsSystemWindows();
        }
        WeakHashMap weakHashMap2 = s1.f1815a;
        int layoutDirection = getLayoutDirection();
        int childCount = getChildCount();
        boolean z11 = false;
        boolean z12 = false;
        for (int i12 = 0; i12 < childCount; i12++) {
            View childAt = getChildAt(i12);
            if (childAt.getVisibility() != 8) {
                e eVar = (e) childAt.getLayoutParams();
                if (z10) {
                    int absoluteGravity = Gravity.getAbsoluteGravity(eVar.f24917a, layoutDirection);
                    if (childAt.getFitsSystemWindows()) {
                        WindowInsets windowInsetsReplaceSystemWindowInsets = (WindowInsets) this.f2190g0;
                        if (absoluteGravity == 3) {
                            windowInsetsReplaceSystemWindowInsets = windowInsetsReplaceSystemWindowInsets.replaceSystemWindowInsets(windowInsetsReplaceSystemWindowInsets.getSystemWindowInsetLeft(), windowInsetsReplaceSystemWindowInsets.getSystemWindowInsetTop(), 0, windowInsetsReplaceSystemWindowInsets.getSystemWindowInsetBottom());
                        } else if (absoluteGravity == 5) {
                            windowInsetsReplaceSystemWindowInsets = windowInsetsReplaceSystemWindowInsets.replaceSystemWindowInsets(0, windowInsetsReplaceSystemWindowInsets.getSystemWindowInsetTop(), windowInsetsReplaceSystemWindowInsets.getSystemWindowInsetRight(), windowInsetsReplaceSystemWindowInsets.getSystemWindowInsetBottom());
                        }
                        childAt.dispatchApplyWindowInsets(windowInsetsReplaceSystemWindowInsets);
                    } else {
                        WindowInsets windowInsetsReplaceSystemWindowInsets2 = (WindowInsets) this.f2190g0;
                        if (absoluteGravity == 3) {
                            windowInsetsReplaceSystemWindowInsets2 = windowInsetsReplaceSystemWindowInsets2.replaceSystemWindowInsets(windowInsetsReplaceSystemWindowInsets2.getSystemWindowInsetLeft(), windowInsetsReplaceSystemWindowInsets2.getSystemWindowInsetTop(), 0, windowInsetsReplaceSystemWindowInsets2.getSystemWindowInsetBottom());
                        } else if (absoluteGravity == 5) {
                            windowInsetsReplaceSystemWindowInsets2 = windowInsetsReplaceSystemWindowInsets2.replaceSystemWindowInsets(0, windowInsetsReplaceSystemWindowInsets2.getSystemWindowInsetTop(), windowInsetsReplaceSystemWindowInsets2.getSystemWindowInsetRight(), windowInsetsReplaceSystemWindowInsets2.getSystemWindowInsetBottom());
                        }
                        ((ViewGroup.MarginLayoutParams) eVar).leftMargin = windowInsetsReplaceSystemWindowInsets2.getSystemWindowInsetLeft();
                        ((ViewGroup.MarginLayoutParams) eVar).topMargin = windowInsetsReplaceSystemWindowInsets2.getSystemWindowInsetTop();
                        ((ViewGroup.MarginLayoutParams) eVar).rightMargin = windowInsetsReplaceSystemWindowInsets2.getSystemWindowInsetRight();
                        ((ViewGroup.MarginLayoutParams) eVar).bottomMargin = windowInsetsReplaceSystemWindowInsets2.getSystemWindowInsetBottom();
                    }
                }
                if (j(childAt)) {
                    childAt.measure(View.MeasureSpec.makeMeasureSpec((size - ((ViewGroup.MarginLayoutParams) eVar).leftMargin) - ((ViewGroup.MarginLayoutParams) eVar).rightMargin, 1073741824), View.MeasureSpec.makeMeasureSpec((size2 - ((ViewGroup.MarginLayoutParams) eVar).topMargin) - ((ViewGroup.MarginLayoutParams) eVar).bottomMargin, 1073741824));
                } else {
                    if (!l(childAt)) {
                        throw new IllegalStateException("Child " + childAt + " at index " + i12 + " does not have a valid layout_gravity - must be Gravity.LEFT, Gravity.RIGHT or Gravity.NO_GRAVITY");
                    }
                    if (f2175t0) {
                        float fG = i1.g(childAt);
                        float f10 = this.f2179b;
                        if (fG != f10) {
                            i1.m(childAt, f10);
                        }
                    }
                    int iH = h(childAt);
                    int i13 = iH & 7;
                    boolean z13 = i13 == 3;
                    if ((z13 && z11) || (!z13 && z12)) {
                        throw new IllegalStateException(defpackage.e.o(new StringBuilder("Child drawer has absolute gravity "), (iH & 3) != 3 ? (iH & 5) == 5 ? "RIGHT" : Integer.toHexString(i13) : "LEFT", " but this DrawerLayout already has a drawer view along that edge"));
                    }
                    if (z13) {
                        z11 = true;
                    } else {
                        z12 = true;
                    }
                    childAt.measure(ViewGroup.getChildMeasureSpec(i10, this.f2181c + ((ViewGroup.MarginLayoutParams) eVar).leftMargin + ((ViewGroup.MarginLayoutParams) eVar).rightMargin, ((ViewGroup.MarginLayoutParams) eVar).width), ViewGroup.getChildMeasureSpec(i11, ((ViewGroup.MarginLayoutParams) eVar).topMargin + ((ViewGroup.MarginLayoutParams) eVar).bottomMargin, ((ViewGroup.MarginLayoutParams) eVar).height));
                }
            }
        }
    }

    @Override // android.view.View
    public final void onRestoreInstanceState(Parcelable parcelable) {
        View viewD;
        if (!(parcelable instanceof f)) {
            super.onRestoreInstanceState(parcelable);
            return;
        }
        f fVar = (f) parcelable;
        super.onRestoreInstanceState(fVar.getSuperState());
        int i10 = fVar.f24921c;
        if (i10 != 0 && (viewD = d(i10)) != null) {
            m(viewD);
        }
        int i11 = fVar.f24922d;
        if (i11 != 3) {
            setDrawerLockMode(i11, 3);
        }
        int i12 = fVar.f24923e;
        if (i12 != 3) {
            setDrawerLockMode(i12, 5);
        }
        int i13 = fVar.f24924f;
        if (i13 != 3) {
            setDrawerLockMode(i13, 8388611);
        }
        int i14 = fVar.f24925g;
        if (i14 != 3) {
            setDrawerLockMode(i14, 8388613);
        }
    }

    @Override // android.view.View
    public final void onRtlPropertiesChanged(int i10) {
        n();
    }

    @Override // android.view.View
    public final Parcelable onSaveInstanceState() {
        f fVar = new f(super.onSaveInstanceState());
        fVar.f24921c = 0;
        int childCount = getChildCount();
        for (int i10 = 0; i10 < childCount; i10++) {
            e eVar = (e) getChildAt(i10).getLayoutParams();
            int i11 = eVar.f24920d;
            boolean z10 = i11 == 1;
            boolean z11 = i11 == 2;
            if (z10 || z11) {
                fVar.f24921c = eVar.f24917a;
                break;
            }
        }
        fVar.f24922d = this.Q;
        fVar.f24923e = this.R;
        fVar.f24924f = this.S;
        fVar.f24925g = this.T;
        return fVar;
    }

    /* JADX WARN: Removed duplicated region for block: B:19:0x0054  */
    @Override // android.view.View
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final boolean onTouchEvent(MotionEvent motionEvent) {
        View viewE;
        h hVar = this.f2189g;
        hVar.k(motionEvent);
        this.f2191h.k(motionEvent);
        int action = motionEvent.getAction() & 255;
        boolean z10 = false;
        if (action == 0) {
            float x10 = motionEvent.getX();
            float y10 = motionEvent.getY();
            this.W = x10;
            this.f2178a0 = y10;
            this.U = false;
        } else if (action == 1) {
            float x11 = motionEvent.getX();
            float y11 = motionEvent.getY();
            View viewFindTopChildUnder = hVar.findTopChildUnder((int) x11, (int) y11);
            if (viewFindTopChildUnder == null || !j(viewFindTopChildUnder)) {
                z10 = true;
                c(z10);
            } else {
                float f10 = x11 - this.W;
                float f11 = y11 - this.f2178a0;
                int i10 = hVar.f36679b;
                if ((f11 * f11) + (f10 * f10) >= i10 * i10 || (viewE = e()) == null || g(viewE) == 2) {
                }
                c(z10);
            }
        } else if (action == 3) {
            c(true);
            this.U = false;
        }
        return true;
    }

    public final void p(View view) {
        c cVar = c.f32066l;
        s1.g(cVar.a(), view);
        s1.e(0, view);
        if (!k(view) || g(view) == 2) {
            return;
        }
        s1.replaceAccessibilityAction(view, cVar, null, this.f2205p0);
    }

    public final void q(View view, boolean z10) {
        int childCount = getChildCount();
        for (int i10 = 0; i10 < childCount; i10++) {
            View childAt = getChildAt(i10);
            if ((z10 || l(childAt)) && !(z10 && childAt == view)) {
                WeakHashMap weakHashMap = s1.f1815a;
                childAt.setImportantForAccessibility(4);
            } else {
                WeakHashMap weakHashMap2 = s1.f1815a;
                childAt.setImportantForAccessibility(1);
            }
        }
    }

    public final void r(int i10, View view) {
        int i11;
        View rootView;
        int i12 = this.f2189g.f36678a;
        int i13 = this.f2191h.f36678a;
        if (i12 == 1 || i13 == 1) {
            i11 = 1;
        } else {
            i11 = 2;
            if (i12 != 2 && i13 != 2) {
                i11 = 0;
            }
        }
        if (view != null && i10 == 0) {
            float f10 = ((e) view.getLayoutParams()).f24918b;
            if (f10 == 0.0f) {
                e eVar = (e) view.getLayoutParams();
                if ((eVar.f24920d & 1) == 1) {
                    eVar.f24920d = 0;
                    ArrayList arrayList = this.V;
                    if (arrayList != null) {
                        for (int size = arrayList.size() - 1; size >= 0; size--) {
                            NavigationView navigationView = ((p) ((d) this.V.get(size))).f22963a;
                            if (view == navigationView) {
                                navigationView.f22940b0.c();
                                if (navigationView.U && navigationView.T != 0) {
                                    navigationView.T = 0;
                                    navigationView.g(navigationView.getWidth(), navigationView.getHeight());
                                }
                            }
                        }
                    }
                    q(view, false);
                    p(view);
                    if (hasWindowFocus() && (rootView = getRootView()) != null) {
                        rootView.sendAccessibilityEvent(32);
                    }
                }
            } else if (f10 == 1.0f) {
                e eVar2 = (e) view.getLayoutParams();
                if ((eVar2.f24920d & 1) == 0) {
                    eVar2.f24920d = 1;
                    ArrayList arrayList2 = this.V;
                    if (arrayList2 != null) {
                        for (int size2 = arrayList2.size() - 1; size2 >= 0; size2--) {
                            NavigationView navigationView2 = ((p) ((d) this.V.get(size2))).f22963a;
                            if (view == navigationView2) {
                                n9.g gVar = navigationView2.f22940b0;
                                Objects.requireNonNull(gVar);
                                view.post(new y.a(gVar, 12));
                            }
                        }
                    }
                    q(view, true);
                    p(view);
                    if (hasWindowFocus()) {
                        sendAccessibilityEvent(32);
                    }
                }
            }
        }
        if (i11 != this.f2197k) {
            this.f2197k = i11;
            ArrayList arrayList3 = this.V;
            if (arrayList3 != null) {
                for (int size3 = arrayList3.size() - 1; size3 >= 0; size3--) {
                    ((d) this.V.get(size3)).getClass();
                }
            }
        }
    }

    @Override // android.view.ViewGroup, android.view.ViewParent
    public final void requestDisallowInterceptTouchEvent(boolean z10) {
        super.requestDisallowInterceptTouchEvent(z10);
        if (z10) {
            c(true);
        }
    }

    @Override // android.view.View, android.view.ViewParent
    public final void requestLayout() {
        if (this.f2199l) {
            return;
        }
        super.requestLayout();
    }

    @RestrictTo({RestrictTo.Scope.f557c})
    public void setChildInsets(Object obj, boolean z10) {
        this.f2190g0 = obj;
        this.f2192h0 = z10;
        setWillNotDraw(!z10 && getBackground() == null);
        requestLayout();
    }

    public void setDrawerElevation(float f10) {
        this.f2179b = f10;
        for (int i10 = 0; i10 < getChildCount(); i10++) {
            View childAt = getChildAt(i10);
            if (l(childAt)) {
                float f11 = this.f2179b;
                WeakHashMap weakHashMap = s1.f1815a;
                i1.m(childAt, f11);
            }
        }
    }

    @Deprecated
    public void setDrawerListener(d dVar) {
        ArrayList arrayList;
        d dVar2 = this.mListener;
        if (dVar2 != null && (arrayList = this.V) != null) {
            arrayList.remove(dVar2);
        }
        if (dVar != null) {
            if (this.V == null) {
                this.V = new ArrayList();
            }
            this.V.add(dVar);
        }
        this.mListener = dVar;
    }

    public void setDrawerLockMode(int i10) {
        setDrawerLockMode(i10, 3);
        setDrawerLockMode(i10, 5);
    }

    public void setDrawerShadow(Drawable drawable, int i10) {
        if (f2175t0) {
            return;
        }
        if ((i10 & 8388611) == 8388611) {
            this.f2194i0 = drawable;
        } else if ((i10 & 8388613) == 8388613) {
            this.f2196j0 = drawable;
        } else if ((i10 & 3) == 3) {
            this.f2198k0 = drawable;
        } else if ((i10 & 5) != 5) {
            return;
        } else {
            this.f2200l0 = drawable;
        }
        n();
        invalidate();
    }

    public void setDrawerTitle(int i10, @Nullable CharSequence charSequence) {
        WeakHashMap weakHashMap = s1.f1815a;
        int absoluteGravity = Gravity.getAbsoluteGravity(i10, getLayoutDirection());
        if (absoluteGravity == 3) {
            this.f2186e0 = charSequence;
        } else if (absoluteGravity == 5) {
            this.f2188f0 = charSequence;
        }
    }

    public void setScrimColor(@ColorInt int i10) {
        this.f2183d = i10;
        invalidate();
    }

    public void setStatusBarBackground(@Nullable Drawable drawable) {
        this.f2180b0 = drawable;
        invalidate();
    }

    public void setStatusBarBackgroundColor(@ColorInt int i10) {
        this.f2180b0 = new ColorDrawable(i10);
        invalidate();
    }

    public DrawerLayout(@NonNull Context context, @Nullable AttributeSet attributeSet) {
        this(context, attributeSet, c1.a.drawerLayoutStyle);
    }

    public void setStatusBarBackground(int i10) {
        this.f2180b0 = i10 != 0 ? g0.d.getDrawable(getContext(), i10) : null;
        invalidate();
    }

    public DrawerLayout(@NonNull Context context, @Nullable AttributeSet attributeSet, int i10) {
        super(context, attributeSet, i10);
        this.f2177a = new k(1);
        this.f2183d = -1728053248;
        this.f2187f = new Paint();
        this.f2201m = true;
        this.Q = 3;
        this.R = 3;
        this.S = 3;
        this.T = 3;
        this.f2194i0 = null;
        this.f2196j0 = null;
        this.f2198k0 = null;
        this.f2200l0 = null;
        this.f2205p0 = new a(this);
        setDescendantFocusability(262144);
        float f10 = getResources().getDisplayMetrics().density;
        this.f2181c = (int) ((64.0f * f10) + 0.5f);
        float f11 = f10 * 400.0f;
        g gVar = new g(this, 3);
        this.f2193i = gVar;
        g gVar2 = new g(this, 5);
        this.f2195j = gVar2;
        h hVarI = h.i(this, 1.0f, gVar);
        this.f2189g = hVarI;
        hVarI.f36694q = 1;
        hVarI.f36691n = f11;
        gVar.f24927b = hVarI;
        h hVarI2 = h.i(this, 1.0f, gVar2);
        this.f2191h = hVarI2;
        hVarI2.f36694q = 2;
        hVarI2.f36691n = f11;
        gVar2.f24927b = hVarI2;
        setFocusableInTouchMode(true);
        WeakHashMap weakHashMap = s1.f1815a;
        setImportantForAccessibility(1);
        s1.setAccessibilityDelegate(this, new d1.c(this));
        setMotionEventSplittingEnabled(false);
        if (getFitsSystemWindows()) {
            setOnApplyWindowInsetsListener(new b(this));
            setSystemUiVisibility(1280);
            TypedArray typedArrayObtainStyledAttributes = context.obtainStyledAttributes(f2172q0);
            try {
                this.f2180b0 = typedArrayObtainStyledAttributes.getDrawable(0);
            } finally {
                typedArrayObtainStyledAttributes.recycle();
            }
        }
        TypedArray typedArrayObtainStyledAttributes2 = context.obtainStyledAttributes(attributeSet, c1.c.DrawerLayout, i10, 0);
        try {
            int i11 = c1.c.DrawerLayout_elevation;
            if (typedArrayObtainStyledAttributes2.hasValue(i11)) {
                this.f2179b = typedArrayObtainStyledAttributes2.getDimension(i11, 0.0f);
            } else {
                this.f2179b = getResources().getDimension(c1.b.def_drawer_elevation);
            }
            typedArrayObtainStyledAttributes2.recycle();
            this.f2202m0 = new ArrayList();
        } catch (Throwable th) {
            typedArrayObtainStyledAttributes2.recycle();
            throw th;
        }
    }

    public void setDrawerLockMode(int i10, int i11) {
        View viewD;
        WeakHashMap weakHashMap = s1.f1815a;
        int absoluteGravity = Gravity.getAbsoluteGravity(i11, getLayoutDirection());
        if (i11 == 3) {
            this.Q = i10;
        } else if (i11 == 5) {
            this.R = i10;
        } else if (i11 == 8388611) {
            this.S = i10;
        } else if (i11 == 8388613) {
            this.T = i10;
        }
        if (i10 != 0) {
            (absoluteGravity == 3 ? this.f2189g : this.f2191h).b();
        }
        if (i10 != 1) {
            if (i10 == 2 && (viewD = d(absoluteGravity)) != null) {
                m(viewD);
                return;
            }
            return;
        }
        View viewD2 = d(absoluteGravity);
        if (viewD2 != null) {
            b(viewD2, true);
        }
    }

    public void setDrawerShadow(@DrawableRes int i10, int i11) {
        setDrawerShadow(g0.d.getDrawable(getContext(), i10), i11);
    }

    @Override // android.view.ViewGroup
    public final ViewGroup.LayoutParams generateLayoutParams(AttributeSet attributeSet) {
        return new e(getContext(), attributeSet);
    }

    public void setDrawerLockMode(int i10, @NonNull View view) {
        if (l(view)) {
            setDrawerLockMode(i10, ((e) view.getLayoutParams()).f24917a);
            return;
        }
        throw new IllegalArgumentException("View " + view + " is not a drawer with appropriate layout_gravity");
    }
}
