package androidx.appcompat.widget;

import A1.y;
import D1.N;
import M.J;
import M4.k;
import android.content.Context;
import android.content.res.ColorStateList;
import android.content.res.TypedArray;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.os.Parcelable;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.view.ContextThemeWrapper;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import android.window.OnBackInvokedCallback;
import android.window.OnBackInvokedDispatcher;
import com.martsnew.tv.R;
import h0.C0999G;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.concurrent.CopyOnWriteArrayList;
import l.e;
import m.MenuC1147h;
import m.MenuItemC1148i;
import n.C1190H;
import n.C1206e;
import n.C1212h;
import n.C1235t;
import n.C1237u;
import n.C1238u0;
import n.J0;
import n.K0;
import n.L0;
import n.M0;
import n.N0;
import n.O0;
import n.P0;
import n.Q;
import n.Q0;
import n.X0;
import n4.u0;

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

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

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

    /* JADX INFO: renamed from: C, reason: collision with root package name */
    public int f7851C;
    public final int D;

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

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

    /* JADX INFO: renamed from: G, reason: collision with root package name */
    public int f7854G;
    public int H;

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

    /* JADX INFO: renamed from: J, reason: collision with root package name */
    public C1238u0 f7856J;

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

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

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

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

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

    /* JADX INFO: renamed from: P, reason: collision with root package name */
    public ColorStateList f7862P;

    /* JADX INFO: renamed from: Q, reason: collision with root package name */
    public ColorStateList f7863Q;

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

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

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

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

    /* JADX INFO: renamed from: V, reason: collision with root package name */
    public final int[] f7868V;

    /* JADX INFO: renamed from: W, reason: collision with root package name */
    public final y f7869W;

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

    /* JADX INFO: renamed from: b0, reason: collision with root package name */
    public final K0 f7871b0;

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

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

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

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

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

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

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

    /* JADX INFO: renamed from: q, reason: collision with root package name */
    public ActionMenuView f7879q;

    /* JADX INFO: renamed from: r, reason: collision with root package name */
    public C1190H f7880r;

    /* JADX INFO: renamed from: s, reason: collision with root package name */
    public C1190H f7881s;

    /* JADX INFO: renamed from: t, reason: collision with root package name */
    public C1235t f7882t;

    /* JADX INFO: renamed from: u, reason: collision with root package name */
    public C1237u f7883u;

    /* JADX INFO: renamed from: v, reason: collision with root package name */
    public final Drawable f7884v;

    /* JADX INFO: renamed from: w, reason: collision with root package name */
    public final CharSequence f7885w;

    /* JADX INFO: renamed from: x, reason: collision with root package name */
    public C1235t f7886x;

    /* JADX INFO: renamed from: y, reason: collision with root package name */
    public View f7887y;

    /* JADX INFO: renamed from: z, reason: collision with root package name */
    public Context f7888z;

    public Toolbar(Context context, AttributeSet attributeSet) {
        this(context, attributeSet, 0);
    }

    public static N0 g() {
        N0 n02 = new N0(-2, -2);
        n02.f14746b = 0;
        n02.f14745a = 8388627;
        return n02;
    }

    private ArrayList<MenuItem> getCurrentMenuItems() {
        ArrayList<MenuItem> arrayList = new ArrayList<>();
        Menu menu = getMenu();
        for (int i = 0; i < menu.size(); i++) {
            arrayList.add(menu.getItem(i));
        }
        return arrayList;
    }

    private MenuInflater getMenuInflater() {
        return new e(getContext());
    }

    public static N0 h(ViewGroup.LayoutParams layoutParams) {
        boolean z8 = layoutParams instanceof N0;
        if (z8) {
            N0 n02 = (N0) layoutParams;
            N0 n03 = new N0(n02);
            n03.f14746b = 0;
            n03.f14746b = n02.f14746b;
            return n03;
        }
        if (z8) {
            N0 n04 = new N0((N0) layoutParams);
            n04.f14746b = 0;
            return n04;
        }
        if (!(layoutParams instanceof ViewGroup.MarginLayoutParams)) {
            N0 n05 = new N0(layoutParams);
            n05.f14746b = 0;
            return n05;
        }
        ViewGroup.MarginLayoutParams marginLayoutParams = (ViewGroup.MarginLayoutParams) layoutParams;
        N0 n06 = new N0(marginLayoutParams);
        n06.f14746b = 0;
        ((ViewGroup.MarginLayoutParams) n06).leftMargin = marginLayoutParams.leftMargin;
        ((ViewGroup.MarginLayoutParams) n06).topMargin = marginLayoutParams.topMargin;
        ((ViewGroup.MarginLayoutParams) n06).rightMargin = marginLayoutParams.rightMargin;
        ((ViewGroup.MarginLayoutParams) n06).bottomMargin = marginLayoutParams.bottomMargin;
        return n06;
    }

    public static int j(View view) {
        ViewGroup.MarginLayoutParams marginLayoutParams = (ViewGroup.MarginLayoutParams) view.getLayoutParams();
        return marginLayoutParams.getMarginEnd() + marginLayoutParams.getMarginStart();
    }

    public static int k(View view) {
        ViewGroup.MarginLayoutParams marginLayoutParams = (ViewGroup.MarginLayoutParams) view.getLayoutParams();
        return marginLayoutParams.topMargin + marginLayoutParams.bottomMargin;
    }

    public final void a(int i, ArrayList arrayList) {
        Field field = J.f4065a;
        boolean z8 = getLayoutDirection() == 1;
        int childCount = getChildCount();
        int absoluteGravity = Gravity.getAbsoluteGravity(i, getLayoutDirection());
        arrayList.clear();
        if (!z8) {
            for (int i5 = 0; i5 < childCount; i5++) {
                View childAt = getChildAt(i5);
                N0 n02 = (N0) childAt.getLayoutParams();
                if (n02.f14746b == 0 && r(childAt)) {
                    int i8 = n02.f14745a;
                    Field field2 = J.f4065a;
                    int layoutDirection = getLayoutDirection();
                    int absoluteGravity2 = Gravity.getAbsoluteGravity(i8, layoutDirection) & 7;
                    if (absoluteGravity2 != 1 && absoluteGravity2 != 3 && absoluteGravity2 != 5) {
                        absoluteGravity2 = layoutDirection == 1 ? 5 : 3;
                    }
                    if (absoluteGravity2 == absoluteGravity) {
                        arrayList.add(childAt);
                    }
                }
            }
            return;
        }
        for (int i9 = childCount - 1; i9 >= 0; i9--) {
            View childAt2 = getChildAt(i9);
            N0 n03 = (N0) childAt2.getLayoutParams();
            if (n03.f14746b == 0 && r(childAt2)) {
                int i10 = n03.f14745a;
                Field field3 = J.f4065a;
                int layoutDirection2 = getLayoutDirection();
                int absoluteGravity3 = Gravity.getAbsoluteGravity(i10, layoutDirection2) & 7;
                if (absoluteGravity3 != 1 && absoluteGravity3 != 3 && absoluteGravity3 != 5) {
                    absoluteGravity3 = layoutDirection2 == 1 ? 5 : 3;
                }
                if (absoluteGravity3 == absoluteGravity) {
                    arrayList.add(childAt2);
                }
            }
        }
    }

    public final void b(View view, boolean z8) {
        ViewGroup.LayoutParams layoutParams = view.getLayoutParams();
        N0 n0G = layoutParams == null ? g() : !checkLayoutParams(layoutParams) ? h(layoutParams) : (N0) layoutParams;
        n0G.f14746b = 1;
        if (!z8 || this.f7887y == null) {
            addView(view, n0G);
        } else {
            view.setLayoutParams(n0G);
            this.f7867U.add(view);
        }
    }

    public final void c() {
        if (this.f7886x == null) {
            C1235t c1235t = new C1235t(getContext(), null, R.attr.toolbarNavigationButtonStyle);
            this.f7886x = c1235t;
            c1235t.setImageDrawable(this.f7884v);
            this.f7886x.setContentDescription(this.f7885w);
            N0 n0G = g();
            n0G.f14745a = (this.D & 112) | 8388611;
            n0G.f14746b = 2;
            this.f7886x.setLayoutParams(n0G);
            this.f7886x.setOnClickListener(new N(4, this));
        }
    }

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

    public final void d() {
        if (this.f7856J == null) {
            C1238u0 c1238u0 = new C1238u0();
            c1238u0.f14945a = 0;
            c1238u0.f14946b = 0;
            c1238u0.f14947c = Integer.MIN_VALUE;
            c1238u0.f14948d = Integer.MIN_VALUE;
            c1238u0.f14949e = 0;
            c1238u0.f14950f = 0;
            c1238u0.f14951g = false;
            c1238u0.f14952h = false;
            this.f7856J = c1238u0;
        }
    }

    public final void e() {
        if (this.f7879q == null) {
            ActionMenuView actionMenuView = new ActionMenuView(getContext(), null);
            this.f7879q = actionMenuView;
            actionMenuView.setPopupTheme(this.f7849A);
            this.f7879q.setOnMenuItemClickListener(this.f7871b0);
            ActionMenuView actionMenuView2 = this.f7879q;
            K0 k02 = new K0(this);
            actionMenuView2.getClass();
            actionMenuView2.f7789J = k02;
            N0 n0G = g();
            n0G.f14745a = (this.D & 112) | 8388613;
            this.f7879q.setLayoutParams(n0G);
            b(this.f7879q, false);
        }
        ActionMenuView actionMenuView3 = this.f7879q;
        if (actionMenuView3.f7786F == null) {
            MenuC1147h menuC1147h = (MenuC1147h) actionMenuView3.getMenu();
            if (this.f7873d0 == null) {
                this.f7873d0 = new M0(this);
            }
            this.f7879q.setExpandedActionViewsExclusive(true);
            menuC1147h.b(this.f7873d0, this.f7888z);
            s();
        }
    }

    public final void f() {
        if (this.f7882t == null) {
            this.f7882t = new C1235t(getContext(), null, R.attr.toolbarNavigationButtonStyle);
            N0 n0G = g();
            n0G.f14745a = (this.D & 112) | 8388611;
            this.f7882t.setLayoutParams(n0G);
        }
    }

    @Override // android.view.ViewGroup
    public final /* bridge */ /* synthetic */ ViewGroup.LayoutParams generateDefaultLayoutParams() {
        return g();
    }

    @Override // android.view.ViewGroup
    public final /* bridge */ /* synthetic */ ViewGroup.LayoutParams generateLayoutParams(ViewGroup.LayoutParams layoutParams) {
        return h(layoutParams);
    }

    public CharSequence getCollapseContentDescription() {
        C1235t c1235t = this.f7886x;
        if (c1235t != null) {
            return c1235t.getContentDescription();
        }
        return null;
    }

    public Drawable getCollapseIcon() {
        C1235t c1235t = this.f7886x;
        if (c1235t != null) {
            return c1235t.getDrawable();
        }
        return null;
    }

    public int getContentInsetEnd() {
        C1238u0 c1238u0 = this.f7856J;
        if (c1238u0 != null) {
            return c1238u0.f14951g ? c1238u0.f14945a : c1238u0.f14946b;
        }
        return 0;
    }

    public int getContentInsetEndWithActions() {
        int i = this.f7858L;
        return i != Integer.MIN_VALUE ? i : getContentInsetEnd();
    }

    public int getContentInsetLeft() {
        C1238u0 c1238u0 = this.f7856J;
        if (c1238u0 != null) {
            return c1238u0.f14945a;
        }
        return 0;
    }

    public int getContentInsetRight() {
        C1238u0 c1238u0 = this.f7856J;
        if (c1238u0 != null) {
            return c1238u0.f14946b;
        }
        return 0;
    }

    public int getContentInsetStart() {
        C1238u0 c1238u0 = this.f7856J;
        if (c1238u0 != null) {
            return c1238u0.f14951g ? c1238u0.f14946b : c1238u0.f14945a;
        }
        return 0;
    }

    public int getContentInsetStartWithNavigation() {
        int i = this.f7857K;
        return i != Integer.MIN_VALUE ? i : getContentInsetStart();
    }

    public int getCurrentContentInsetEnd() {
        MenuC1147h menuC1147h;
        ActionMenuView actionMenuView = this.f7879q;
        return (actionMenuView == null || (menuC1147h = actionMenuView.f7786F) == null || !menuC1147h.hasVisibleItems()) ? getContentInsetEnd() : Math.max(getContentInsetEnd(), Math.max(this.f7858L, 0));
    }

    public int getCurrentContentInsetLeft() {
        Field field = J.f4065a;
        return getLayoutDirection() == 1 ? getCurrentContentInsetEnd() : getCurrentContentInsetStart();
    }

    public int getCurrentContentInsetRight() {
        Field field = J.f4065a;
        return getLayoutDirection() == 1 ? getCurrentContentInsetStart() : getCurrentContentInsetEnd();
    }

    public int getCurrentContentInsetStart() {
        return getNavigationIcon() != null ? Math.max(getContentInsetStart(), Math.max(this.f7857K, 0)) : getContentInsetStart();
    }

    public Drawable getLogo() {
        C1237u c1237u = this.f7883u;
        if (c1237u != null) {
            return c1237u.getDrawable();
        }
        return null;
    }

    public CharSequence getLogoDescription() {
        C1237u c1237u = this.f7883u;
        if (c1237u != null) {
            return c1237u.getContentDescription();
        }
        return null;
    }

    public Menu getMenu() {
        e();
        return this.f7879q.getMenu();
    }

    public View getNavButtonView() {
        return this.f7882t;
    }

    public CharSequence getNavigationContentDescription() {
        C1235t c1235t = this.f7882t;
        if (c1235t != null) {
            return c1235t.getContentDescription();
        }
        return null;
    }

    public Drawable getNavigationIcon() {
        C1235t c1235t = this.f7882t;
        if (c1235t != null) {
            return c1235t.getDrawable();
        }
        return null;
    }

    public C1212h getOuterActionMenuPresenter() {
        return null;
    }

    public Drawable getOverflowIcon() {
        e();
        return this.f7879q.getOverflowIcon();
    }

    public Context getPopupContext() {
        return this.f7888z;
    }

    public int getPopupTheme() {
        return this.f7849A;
    }

    public CharSequence getSubtitle() {
        return this.f7861O;
    }

    public final TextView getSubtitleTextView() {
        return this.f7881s;
    }

    public CharSequence getTitle() {
        return this.f7860N;
    }

    public int getTitleMarginBottom() {
        return this.f7855I;
    }

    public int getTitleMarginEnd() {
        return this.f7854G;
    }

    public int getTitleMarginStart() {
        return this.f7853F;
    }

    public int getTitleMarginTop() {
        return this.H;
    }

    public final TextView getTitleTextView() {
        return this.f7880r;
    }

    public Q getWrapper() {
        Drawable drawable;
        if (this.f7872c0 == null) {
            Q0 q0 = new Q0();
            q0.f14771l = 0;
            q0.f14761a = this;
            q0.f14768h = getTitle();
            q0.i = getSubtitle();
            q0.f14767g = q0.f14768h != null;
            q0.f14766f = getNavigationIcon();
            com.google.android.material.datepicker.c cVarZ = com.google.android.material.datepicker.c.z(getContext(), null, h.a.f13005a, R.attr.actionBarStyle);
            q0.f14772m = cVarZ.u(15);
            TypedArray typedArray = (TypedArray) cVarZ.f10220s;
            CharSequence text = typedArray.getText(27);
            if (!TextUtils.isEmpty(text)) {
                q0.f14767g = true;
                q0.f14768h = text;
                if ((q0.f14762b & 8) != 0) {
                    Toolbar toolbar = q0.f14761a;
                    toolbar.setTitle(text);
                    if (q0.f14767g) {
                        J.k(toolbar.getRootView(), text);
                    }
                }
            }
            CharSequence text2 = typedArray.getText(25);
            if (!TextUtils.isEmpty(text2)) {
                q0.i = text2;
                if ((q0.f14762b & 8) != 0) {
                    setSubtitle(text2);
                }
            }
            Drawable drawableU = cVarZ.u(20);
            if (drawableU != null) {
                q0.f14765e = drawableU;
                q0.c();
            }
            Drawable drawableU2 = cVarZ.u(17);
            if (drawableU2 != null) {
                q0.f14764d = drawableU2;
                q0.c();
            }
            if (q0.f14766f == null && (drawable = q0.f14772m) != null) {
                q0.f14766f = drawable;
                int i = q0.f14762b & 4;
                Toolbar toolbar2 = q0.f14761a;
                if (i != 0) {
                    toolbar2.setNavigationIcon(drawable);
                } else {
                    toolbar2.setNavigationIcon((Drawable) null);
                }
            }
            q0.a(typedArray.getInt(10, 0));
            int resourceId = typedArray.getResourceId(9, 0);
            if (resourceId != 0) {
                View viewInflate = LayoutInflater.from(getContext()).inflate(resourceId, (ViewGroup) this, false);
                View view = q0.f14763c;
                if (view != null && (q0.f14762b & 16) != 0) {
                    removeView(view);
                }
                q0.f14763c = viewInflate;
                if (viewInflate != null && (q0.f14762b & 16) != 0) {
                    addView(viewInflate);
                }
                q0.a(q0.f14762b | 16);
            }
            int layoutDimension = typedArray.getLayoutDimension(13, 0);
            if (layoutDimension > 0) {
                ViewGroup.LayoutParams layoutParams = getLayoutParams();
                layoutParams.height = layoutDimension;
                setLayoutParams(layoutParams);
            }
            int dimensionPixelOffset = typedArray.getDimensionPixelOffset(7, -1);
            int dimensionPixelOffset2 = typedArray.getDimensionPixelOffset(3, -1);
            if (dimensionPixelOffset >= 0 || dimensionPixelOffset2 >= 0) {
                int iMax = Math.max(dimensionPixelOffset, 0);
                int iMax2 = Math.max(dimensionPixelOffset2, 0);
                d();
                this.f7856J.a(iMax, iMax2);
            }
            int resourceId2 = typedArray.getResourceId(28, 0);
            if (resourceId2 != 0) {
                Context context = getContext();
                this.f7850B = resourceId2;
                C1190H c1190h = this.f7880r;
                if (c1190h != null) {
                    c1190h.setTextAppearance(context, resourceId2);
                }
            }
            int resourceId3 = typedArray.getResourceId(26, 0);
            if (resourceId3 != 0) {
                Context context2 = getContext();
                this.f7851C = resourceId3;
                C1190H c1190h2 = this.f7881s;
                if (c1190h2 != null) {
                    c1190h2.setTextAppearance(context2, resourceId3);
                }
            }
            int resourceId4 = typedArray.getResourceId(22, 0);
            if (resourceId4 != 0) {
                setPopupTheme(resourceId4);
            }
            cVarZ.B();
            if (R.string.abc_action_bar_up_description != q0.f14771l) {
                q0.f14771l = R.string.abc_action_bar_up_description;
                if (TextUtils.isEmpty(getNavigationContentDescription())) {
                    int i5 = q0.f14771l;
                    q0.f14769j = i5 != 0 ? getContext().getString(i5) : null;
                    q0.b();
                }
            }
            q0.f14769j = getNavigationContentDescription();
            setNavigationOnClickListener(new N(q0));
            this.f7872c0 = q0;
        }
        return this.f7872c0;
    }

    public final int i(View view, int i) {
        N0 n02 = (N0) view.getLayoutParams();
        int measuredHeight = view.getMeasuredHeight();
        int i5 = i > 0 ? (measuredHeight - i) / 2 : 0;
        int i8 = n02.f14745a & 112;
        if (i8 != 16 && i8 != 48 && i8 != 80) {
            i8 = this.f7859M & 112;
        }
        if (i8 == 48) {
            return getPaddingTop() - i5;
        }
        if (i8 == 80) {
            return (((getHeight() - getPaddingBottom()) - measuredHeight) - ((ViewGroup.MarginLayoutParams) n02).bottomMargin) - i5;
        }
        int paddingTop = getPaddingTop();
        int paddingBottom = getPaddingBottom();
        int height = getHeight();
        int iMax = (((height - paddingTop) - paddingBottom) - measuredHeight) / 2;
        int i9 = ((ViewGroup.MarginLayoutParams) n02).topMargin;
        if (iMax < i9) {
            iMax = i9;
        } else {
            int i10 = (((height - paddingBottom) - measuredHeight) - iMax) - paddingTop;
            int i11 = ((ViewGroup.MarginLayoutParams) n02).bottomMargin;
            if (i10 < i11) {
                iMax = Math.max(0, iMax - (i11 - i10));
            }
        }
        return paddingTop + iMax;
    }

    public final void l() {
        ArrayList arrayList = this.f7870a0;
        int size = arrayList.size();
        int i = 0;
        while (i < size) {
            Object obj = arrayList.get(i);
            i++;
            getMenu().removeItem(((MenuItem) obj).getItemId());
        }
        getMenu();
        ArrayList<MenuItem> currentMenuItems = getCurrentMenuItems();
        getMenuInflater();
        Iterator it = ((CopyOnWriteArrayList) this.f7869W.f364s).iterator();
        while (it.hasNext()) {
            ((C0999G) it.next()).f13040a.k();
        }
        ArrayList<MenuItem> currentMenuItems2 = getCurrentMenuItems();
        currentMenuItems2.removeAll(currentMenuItems);
        this.f7870a0 = currentMenuItems2;
    }

    public final boolean m(View view) {
        return view.getParent() == this || this.f7867U.contains(view);
    }

    public final int n(View view, int i, int i5, int[] iArr) {
        N0 n02 = (N0) view.getLayoutParams();
        int i8 = ((ViewGroup.MarginLayoutParams) n02).leftMargin - iArr[0];
        int iMax = Math.max(0, i8) + i;
        iArr[0] = Math.max(0, -i8);
        int i9 = i(view, i5);
        int measuredWidth = view.getMeasuredWidth();
        view.layout(iMax, i9, iMax + measuredWidth, view.getMeasuredHeight() + i9);
        return measuredWidth + ((ViewGroup.MarginLayoutParams) n02).rightMargin + iMax;
    }

    public final int o(View view, int i, int i5, int[] iArr) {
        N0 n02 = (N0) view.getLayoutParams();
        int i8 = ((ViewGroup.MarginLayoutParams) n02).rightMargin - iArr[1];
        int iMax = i - Math.max(0, i8);
        iArr[1] = Math.max(0, -i8);
        int i9 = i(view, i5);
        int measuredWidth = view.getMeasuredWidth();
        view.layout(iMax - measuredWidth, i9, iMax, view.getMeasuredHeight() + i9);
        return iMax - (measuredWidth + ((ViewGroup.MarginLayoutParams) n02).leftMargin);
    }

    @Override // android.view.ViewGroup, android.view.View
    public void onAttachedToWindow() {
        super.onAttachedToWindow();
        s();
    }

    @Override // android.view.ViewGroup, android.view.View
    public final void onDetachedFromWindow() {
        super.onDetachedFromWindow();
        removeCallbacks(this.f7878i0);
        s();
    }

    @Override // android.view.View
    public final boolean onHoverEvent(MotionEvent motionEvent) {
        int actionMasked = motionEvent.getActionMasked();
        if (actionMasked == 9) {
            this.f7865S = false;
        }
        if (!this.f7865S) {
            boolean zOnHoverEvent = super.onHoverEvent(motionEvent);
            if (actionMasked == 9 && !zOnHoverEvent) {
                this.f7865S = true;
            }
        }
        if (actionMasked != 10 && actionMasked != 3) {
            return true;
        }
        this.f7865S = false;
        return true;
    }

    /* JADX WARN: Removed duplicated region for block: B:105:0x0295 A[LOOP:0: B:104:0x0293->B:105:0x0295, LOOP_END] */
    /* JADX WARN: Removed duplicated region for block: B:108:0x02ad A[LOOP:1: B:107:0x02ab->B:108:0x02ad, LOOP_END] */
    /* JADX WARN: Removed duplicated region for block: B:111:0x02cd A[LOOP:2: B:110:0x02cb->B:111:0x02cd, LOOP_END] */
    /* JADX WARN: Removed duplicated region for block: B:115:0x0313  */
    /* JADX WARN: Removed duplicated region for block: B:120:0x0321 A[LOOP:3: B:119:0x031f->B:120:0x0321, LOOP_END] */
    /* JADX WARN: Removed duplicated region for block: B:19:0x0062  */
    /* JADX WARN: Removed duplicated region for block: B:24:0x0079  */
    /* JADX WARN: Removed duplicated region for block: B:29:0x00b6  */
    /* JADX WARN: Removed duplicated region for block: B:34:0x00cd  */
    /* JADX WARN: Removed duplicated region for block: B:39:0x00ea  */
    /* JADX WARN: Removed duplicated region for block: B:40:0x0101  */
    /* JADX WARN: Removed duplicated region for block: B:42:0x0106  */
    /* JADX WARN: Removed duplicated region for block: B:43:0x011f  */
    /* JADX WARN: Removed duplicated region for block: B:48:0x012a  */
    /* JADX WARN: Removed duplicated region for block: B:49:0x012c  */
    /* JADX WARN: Removed duplicated region for block: B:50:0x012f  */
    /* JADX WARN: Removed duplicated region for block: B:52:0x0133  */
    /* JADX WARN: Removed duplicated region for block: B:53:0x0136  */
    /* JADX WARN: Removed duplicated region for block: B:65:0x0169  */
    /* JADX WARN: Removed duplicated region for block: B:75:0x01a2  */
    /* JADX WARN: Removed duplicated region for block: B:77:0x01af  */
    /* JADX WARN: Removed duplicated region for block: B:89:0x021c  */
    @Override // android.view.ViewGroup, android.view.View
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public void onLayout(boolean z8, int i, int i5, int i8, int i9) {
        int iN;
        int iO;
        boolean zR;
        boolean zR2;
        int i10;
        int measuredHeight;
        int i11;
        boolean z9;
        int paddingTop;
        int i12;
        int i13;
        int iMax;
        int i14;
        int i15;
        int size;
        int iN2;
        int i16;
        int size2;
        int i17;
        int size3;
        int i18;
        int i19;
        int size4;
        int i20;
        Field field = J.f4065a;
        boolean z10 = getLayoutDirection() == 1;
        int width = getWidth();
        int height = getHeight();
        int paddingLeft = getPaddingLeft();
        int paddingRight = getPaddingRight();
        int paddingTop2 = getPaddingTop();
        int paddingBottom = getPaddingBottom();
        int i21 = width - paddingRight;
        int[] iArr = this.f7868V;
        iArr[1] = 0;
        iArr[0] = 0;
        int minimumHeight = getMinimumHeight();
        int iMin = minimumHeight >= 0 ? Math.min(minimumHeight, i9 - i5) : 0;
        if (!r(this.f7882t)) {
            iN = paddingLeft;
        } else {
            if (z10) {
                iO = o(this.f7882t, i21, iMin, iArr);
                iN = paddingLeft;
                if (r(this.f7886x)) {
                    if (z10) {
                        iO = o(this.f7886x, iO, iMin, iArr);
                    } else {
                        iN = n(this.f7886x, iN, iMin, iArr);
                    }
                }
                if (r(this.f7879q)) {
                    if (z10) {
                        iN = n(this.f7879q, iN, iMin, iArr);
                    } else {
                        iO = o(this.f7879q, iO, iMin, iArr);
                    }
                }
                int currentContentInsetLeft = getCurrentContentInsetLeft();
                int currentContentInsetRight = getCurrentContentInsetRight();
                iArr[0] = Math.max(0, currentContentInsetLeft - iN);
                iArr[1] = Math.max(0, currentContentInsetRight - (i21 - iO));
                int iMax2 = Math.max(iN, currentContentInsetLeft);
                int iMin2 = Math.min(iO, i21 - currentContentInsetRight);
                if (r(this.f7887y)) {
                    if (z10) {
                        iMin2 = o(this.f7887y, iMin2, iMin, iArr);
                    } else {
                        iMax2 = n(this.f7887y, iMax2, iMin, iArr);
                    }
                }
                if (r(this.f7883u)) {
                    if (z10) {
                        iMin2 = o(this.f7883u, iMin2, iMin, iArr);
                    } else {
                        iMax2 = n(this.f7883u, iMax2, iMin, iArr);
                    }
                }
                zR = r(this.f7880r);
                zR2 = r(this.f7881s);
                if (zR) {
                    i10 = iMax2;
                    measuredHeight = 0;
                } else {
                    N0 n02 = (N0) this.f7880r.getLayoutParams();
                    i10 = iMax2;
                    measuredHeight = this.f7880r.getMeasuredHeight() + ((ViewGroup.MarginLayoutParams) n02).topMargin + ((ViewGroup.MarginLayoutParams) n02).bottomMargin;
                }
                if (!zR2) {
                    N0 n03 = (N0) this.f7881s.getLayoutParams();
                    measuredHeight = this.f7881s.getMeasuredHeight() + ((ViewGroup.MarginLayoutParams) n03).topMargin + ((ViewGroup.MarginLayoutParams) n03).bottomMargin + measuredHeight;
                }
                if (!zR || zR2) {
                    C1190H c1190h = !zR ? this.f7880r : this.f7881s;
                    C1190H c1190h2 = !zR2 ? this.f7881s : this.f7880r;
                    N0 n04 = (N0) c1190h.getLayoutParams();
                    N0 n05 = (N0) c1190h2.getLayoutParams();
                    int i22 = measuredHeight;
                    boolean z11 = (zR && this.f7880r.getMeasuredWidth() > 0) || (zR2 && this.f7881s.getMeasuredWidth() > 0);
                    i11 = this.f7859M & 112;
                    z9 = z10;
                    if (i11 == 48) {
                        paddingTop = getPaddingTop() + ((ViewGroup.MarginLayoutParams) n04).topMargin + this.H;
                    } else if (i11 != 80) {
                        int iMax3 = (((height - paddingTop2) - paddingBottom) - i22) / 2;
                        int i23 = ((ViewGroup.MarginLayoutParams) n04).topMargin + this.H;
                        if (iMax3 < i23) {
                            iMax3 = i23;
                        } else {
                            int i24 = (((height - paddingBottom) - i22) - iMax3) - paddingTop2;
                            int i25 = ((ViewGroup.MarginLayoutParams) n04).bottomMargin;
                            int i26 = this.f7855I;
                            if (i24 < i25 + i26) {
                                iMax3 = Math.max(0, iMax3 - ((((ViewGroup.MarginLayoutParams) n05).bottomMargin + i26) - i24));
                            }
                        }
                        paddingTop = paddingTop2 + iMax3;
                    } else {
                        paddingTop = (((height - paddingBottom) - ((ViewGroup.MarginLayoutParams) n05).bottomMargin) - this.f7855I) - i22;
                    }
                    if (z9) {
                        int i27 = (z11 ? this.f7853F : 0) - iArr[1];
                        iMin2 -= Math.max(0, i27);
                        iArr[1] = Math.max(0, -i27);
                        if (zR) {
                            N0 n06 = (N0) this.f7880r.getLayoutParams();
                            int measuredWidth = iMin2 - this.f7880r.getMeasuredWidth();
                            int measuredHeight2 = this.f7880r.getMeasuredHeight() + paddingTop;
                            this.f7880r.layout(measuredWidth, paddingTop, iMin2, measuredHeight2);
                            i14 = measuredWidth - this.f7854G;
                            paddingTop = measuredHeight2 + ((ViewGroup.MarginLayoutParams) n06).bottomMargin;
                        } else {
                            i14 = iMin2;
                        }
                        if (zR2) {
                            int i28 = paddingTop + ((ViewGroup.MarginLayoutParams) ((N0) this.f7881s.getLayoutParams())).topMargin;
                            this.f7881s.layout(iMin2 - this.f7881s.getMeasuredWidth(), i28, iMin2, this.f7881s.getMeasuredHeight() + i28);
                            i15 = iMin2 - this.f7854G;
                        } else {
                            i15 = iMin2;
                        }
                        if (z11) {
                            iMin2 = Math.min(i14, i15);
                        }
                        iMax = i10;
                    } else {
                        int i29 = (z11 ? this.f7853F : 0) - iArr[0];
                        int iMax4 = Math.max(0, i29) + i10;
                        iArr[0] = Math.max(0, -i29);
                        if (zR) {
                            N0 n07 = (N0) this.f7880r.getLayoutParams();
                            int measuredWidth2 = this.f7880r.getMeasuredWidth() + iMax4;
                            int measuredHeight3 = this.f7880r.getMeasuredHeight() + paddingTop;
                            this.f7880r.layout(iMax4, paddingTop, measuredWidth2, measuredHeight3);
                            i12 = measuredWidth2 + this.f7854G;
                            paddingTop = measuredHeight3 + ((ViewGroup.MarginLayoutParams) n07).bottomMargin;
                        } else {
                            i12 = iMax4;
                        }
                        if (zR2) {
                            int i30 = paddingTop + ((ViewGroup.MarginLayoutParams) ((N0) this.f7881s.getLayoutParams())).topMargin;
                            int measuredWidth3 = this.f7881s.getMeasuredWidth() + iMax4;
                            this.f7881s.layout(iMax4, i30, measuredWidth3, this.f7881s.getMeasuredHeight() + i30);
                            i13 = measuredWidth3 + this.f7854G;
                        } else {
                            i13 = iMax4;
                        }
                        iMax = z11 ? Math.max(i12, i13) : iMax4;
                    }
                } else {
                    iMax = i10;
                }
                ArrayList arrayList = this.f7866T;
                a(3, arrayList);
                size = arrayList.size();
                iN2 = iMax;
                for (i16 = 0; i16 < size; i16++) {
                    iN2 = n((View) arrayList.get(i16), iN2, iMin, iArr);
                }
                a(5, arrayList);
                size2 = arrayList.size();
                for (i17 = 0; i17 < size2; i17++) {
                    iMin2 = o((View) arrayList.get(i17), iMin2, iMin, iArr);
                }
                a(1, arrayList);
                int i31 = iArr[0];
                int i32 = iArr[1];
                size3 = arrayList.size();
                int i33 = i31;
                i18 = 0;
                int measuredWidth4 = 0;
                while (i18 < size3) {
                    View view = (View) arrayList.get(i18);
                    N0 n08 = (N0) view.getLayoutParams();
                    int i34 = i32;
                    int i35 = ((ViewGroup.MarginLayoutParams) n08).leftMargin - i33;
                    int i36 = ((ViewGroup.MarginLayoutParams) n08).rightMargin - i34;
                    int iMax5 = Math.max(0, i35);
                    int iMax6 = Math.max(0, i36);
                    int iMax7 = Math.max(0, -i35);
                    int iMax8 = Math.max(0, -i36);
                    measuredWidth4 += view.getMeasuredWidth() + iMax5 + iMax6;
                    i18++;
                    i33 = iMax7;
                    i32 = iMax8;
                }
                i19 = ((((width - paddingLeft) - paddingRight) / 2) + paddingLeft) - (measuredWidth4 / 2);
                int i37 = measuredWidth4 + i19;
                if (i19 >= iN2) {
                    iN2 = i37 > iMin2 ? i19 - (i37 - iMin2) : i19;
                }
                size4 = arrayList.size();
                for (i20 = 0; i20 < size4; i20++) {
                    iN2 = n((View) arrayList.get(i20), iN2, iMin, iArr);
                }
                arrayList.clear();
            }
            iN = n(this.f7882t, paddingLeft, iMin, iArr);
        }
        iO = i21;
        if (r(this.f7886x)) {
        }
        if (r(this.f7879q)) {
        }
        int currentContentInsetLeft2 = getCurrentContentInsetLeft();
        int currentContentInsetRight2 = getCurrentContentInsetRight();
        iArr[0] = Math.max(0, currentContentInsetLeft2 - iN);
        iArr[1] = Math.max(0, currentContentInsetRight2 - (i21 - iO));
        int iMax22 = Math.max(iN, currentContentInsetLeft2);
        int iMin22 = Math.min(iO, i21 - currentContentInsetRight2);
        if (r(this.f7887y)) {
        }
        if (r(this.f7883u)) {
        }
        zR = r(this.f7880r);
        zR2 = r(this.f7881s);
        if (zR) {
        }
        if (!zR2) {
        }
        if (zR) {
            if (!zR) {
            }
            if (!zR2) {
            }
            N0 n042 = (N0) c1190h.getLayoutParams();
            N0 n052 = (N0) c1190h2.getLayoutParams();
            int i222 = measuredHeight;
            if (zR) {
                i11 = this.f7859M & 112;
                z9 = z10;
                if (i11 == 48) {
                }
                if (z9) {
                }
            } else {
                i11 = this.f7859M & 112;
                z9 = z10;
                if (i11 == 48) {
                }
                if (z9) {
                }
            }
        }
        ArrayList arrayList2 = this.f7866T;
        a(3, arrayList2);
        size = arrayList2.size();
        iN2 = iMax;
        while (i16 < size) {
        }
        a(5, arrayList2);
        size2 = arrayList2.size();
        while (i17 < size2) {
        }
        a(1, arrayList2);
        int i312 = iArr[0];
        int i322 = iArr[1];
        size3 = arrayList2.size();
        int i332 = i312;
        i18 = 0;
        int measuredWidth42 = 0;
        while (i18 < size3) {
        }
        i19 = ((((width - paddingLeft) - paddingRight) / 2) + paddingLeft) - (measuredWidth42 / 2);
        int i372 = measuredWidth42 + i19;
        if (i19 >= iN2) {
        }
        size4 = arrayList2.size();
        while (i20 < size4) {
        }
        arrayList2.clear();
    }

    @Override // android.view.View
    public final void onMeasure(int i, int i5) {
        int iJ;
        int iMax;
        int iCombineMeasuredStates;
        int iJ2;
        int iK;
        int iCombineMeasuredStates2;
        int iMax2;
        boolean zA = X0.a(this);
        int i8 = !zA ? 1 : 0;
        int i9 = 0;
        if (r(this.f7882t)) {
            q(this.f7882t, i, 0, i5, this.f7852E);
            iJ = j(this.f7882t) + this.f7882t.getMeasuredWidth();
            iMax = Math.max(0, k(this.f7882t) + this.f7882t.getMeasuredHeight());
            iCombineMeasuredStates = View.combineMeasuredStates(0, this.f7882t.getMeasuredState());
        } else {
            iJ = 0;
            iMax = 0;
            iCombineMeasuredStates = 0;
        }
        if (r(this.f7886x)) {
            q(this.f7886x, i, 0, i5, this.f7852E);
            iJ = j(this.f7886x) + this.f7886x.getMeasuredWidth();
            iMax = Math.max(iMax, k(this.f7886x) + this.f7886x.getMeasuredHeight());
            iCombineMeasuredStates = View.combineMeasuredStates(iCombineMeasuredStates, this.f7886x.getMeasuredState());
        }
        int currentContentInsetStart = getCurrentContentInsetStart();
        int iMax3 = Math.max(currentContentInsetStart, iJ);
        int iMax4 = Math.max(0, currentContentInsetStart - iJ);
        int[] iArr = this.f7868V;
        iArr[zA ? 1 : 0] = iMax4;
        if (r(this.f7879q)) {
            q(this.f7879q, i, iMax3, i5, this.f7852E);
            iJ2 = j(this.f7879q) + this.f7879q.getMeasuredWidth();
            iMax = Math.max(iMax, k(this.f7879q) + this.f7879q.getMeasuredHeight());
            iCombineMeasuredStates = View.combineMeasuredStates(iCombineMeasuredStates, this.f7879q.getMeasuredState());
        } else {
            iJ2 = 0;
        }
        int currentContentInsetEnd = getCurrentContentInsetEnd();
        int iMax5 = iMax3 + Math.max(currentContentInsetEnd, iJ2);
        iArr[i8] = Math.max(0, currentContentInsetEnd - iJ2);
        if (r(this.f7887y)) {
            iMax5 += p(this.f7887y, i, iMax5, i5, 0, iArr);
            iMax = Math.max(iMax, k(this.f7887y) + this.f7887y.getMeasuredHeight());
            iCombineMeasuredStates = View.combineMeasuredStates(iCombineMeasuredStates, this.f7887y.getMeasuredState());
        }
        if (r(this.f7883u)) {
            iMax5 += p(this.f7883u, i, iMax5, i5, 0, iArr);
            iMax = Math.max(iMax, k(this.f7883u) + this.f7883u.getMeasuredHeight());
            iCombineMeasuredStates = View.combineMeasuredStates(iCombineMeasuredStates, this.f7883u.getMeasuredState());
        }
        int childCount = getChildCount();
        for (int i10 = 0; i10 < childCount; i10++) {
            View childAt = getChildAt(i10);
            if (((N0) childAt.getLayoutParams()).f14746b == 0 && r(childAt)) {
                iMax5 += p(childAt, i, iMax5, i5, 0, iArr);
                int iMax6 = Math.max(iMax, k(childAt) + childAt.getMeasuredHeight());
                iCombineMeasuredStates = View.combineMeasuredStates(iCombineMeasuredStates, childAt.getMeasuredState());
                iMax = iMax6;
            } else {
                iMax5 = iMax5;
            }
        }
        int i11 = iMax5;
        int i12 = this.H + this.f7855I;
        int i13 = this.f7853F + this.f7854G;
        if (r(this.f7880r)) {
            p(this.f7880r, i, i11 + i13, i5, i12, iArr);
            int iJ3 = j(this.f7880r) + this.f7880r.getMeasuredWidth();
            iK = k(this.f7880r) + this.f7880r.getMeasuredHeight();
            iCombineMeasuredStates2 = View.combineMeasuredStates(iCombineMeasuredStates, this.f7880r.getMeasuredState());
            iMax2 = iJ3;
        } else {
            iK = 0;
            iCombineMeasuredStates2 = iCombineMeasuredStates;
            iMax2 = 0;
        }
        if (r(this.f7881s)) {
            iMax2 = Math.max(iMax2, p(this.f7881s, i, i11 + i13, i5, i12 + iK, iArr));
            iK += k(this.f7881s) + this.f7881s.getMeasuredHeight();
            iCombineMeasuredStates2 = View.combineMeasuredStates(iCombineMeasuredStates2, this.f7881s.getMeasuredState());
        }
        int iMax7 = Math.max(iMax, iK);
        int paddingRight = getPaddingRight() + getPaddingLeft() + i11 + iMax2;
        int paddingBottom = getPaddingBottom() + getPaddingTop() + iMax7;
        int iResolveSizeAndState = View.resolveSizeAndState(Math.max(paddingRight, getSuggestedMinimumWidth()), i, (-16777216) & iCombineMeasuredStates2);
        int iResolveSizeAndState2 = View.resolveSizeAndState(Math.max(paddingBottom, getSuggestedMinimumHeight()), i5, iCombineMeasuredStates2 << 16);
        if (!this.f7874e0) {
            i9 = iResolveSizeAndState2;
            break;
        }
        int childCount2 = getChildCount();
        for (int i14 = 0; i14 < childCount2; i14++) {
            View childAt2 = getChildAt(i14);
            if (r(childAt2) && childAt2.getMeasuredWidth() > 0 && childAt2.getMeasuredHeight() > 0) {
                i9 = iResolveSizeAndState2;
                break;
            }
        }
        setMeasuredDimension(iResolveSizeAndState, i9);
    }

    @Override // android.view.View
    public final void onRestoreInstanceState(Parcelable parcelable) {
        MenuItem menuItemFindItem;
        if (!(parcelable instanceof P0)) {
            super.onRestoreInstanceState(parcelable);
            return;
        }
        P0 p02 = (P0) parcelable;
        super.onRestoreInstanceState(p02.f6203q);
        ActionMenuView actionMenuView = this.f7879q;
        MenuC1147h menuC1147h = actionMenuView != null ? actionMenuView.f7786F : null;
        int i = p02.f14759s;
        if (i != 0 && this.f7873d0 != null && menuC1147h != null && (menuItemFindItem = menuC1147h.findItem(i)) != null) {
            menuItemFindItem.expandActionView();
        }
        if (p02.f14760t) {
            k kVar = this.f7878i0;
            removeCallbacks(kVar);
            post(kVar);
        }
    }

    @Override // android.view.View
    public final void onRtlPropertiesChanged(int i) {
        super.onRtlPropertiesChanged(i);
        d();
        C1238u0 c1238u0 = this.f7856J;
        boolean z8 = i == 1;
        if (z8 == c1238u0.f14951g) {
            return;
        }
        c1238u0.f14951g = z8;
        if (!c1238u0.f14952h) {
            c1238u0.f14945a = c1238u0.f14949e;
            c1238u0.f14946b = c1238u0.f14950f;
            return;
        }
        if (z8) {
            int i5 = c1238u0.f14948d;
            if (i5 == Integer.MIN_VALUE) {
                i5 = c1238u0.f14949e;
            }
            c1238u0.f14945a = i5;
            int i8 = c1238u0.f14947c;
            if (i8 == Integer.MIN_VALUE) {
                i8 = c1238u0.f14950f;
            }
            c1238u0.f14946b = i8;
            return;
        }
        int i9 = c1238u0.f14947c;
        if (i9 == Integer.MIN_VALUE) {
            i9 = c1238u0.f14949e;
        }
        c1238u0.f14945a = i9;
        int i10 = c1238u0.f14948d;
        if (i10 == Integer.MIN_VALUE) {
            i10 = c1238u0.f14950f;
        }
        c1238u0.f14946b = i10;
    }

    @Override // android.view.View
    public final Parcelable onSaveInstanceState() {
        C1212h c1212h;
        C1206e c1206e;
        MenuItemC1148i menuItemC1148i;
        P0 p02 = new P0(super.onSaveInstanceState());
        M0 m02 = this.f7873d0;
        if (m02 != null && (menuItemC1148i = m02.f14743r) != null) {
            p02.f14759s = menuItemC1148i.f14487a;
        }
        ActionMenuView actionMenuView = this.f7879q;
        p02.f14760t = (actionMenuView == null || (c1212h = actionMenuView.f7788I) == null || (c1206e = c1212h.H) == null || !c1206e.b()) ? false : true;
        return p02;
    }

    @Override // android.view.View
    public final boolean onTouchEvent(MotionEvent motionEvent) {
        int actionMasked = motionEvent.getActionMasked();
        if (actionMasked == 0) {
            this.f7864R = false;
        }
        if (!this.f7864R) {
            boolean zOnTouchEvent = super.onTouchEvent(motionEvent);
            if (actionMasked == 0 && !zOnTouchEvent) {
                this.f7864R = true;
            }
        }
        if (actionMasked != 1 && actionMasked != 3) {
            return true;
        }
        this.f7864R = false;
        return true;
    }

    public final int p(View view, int i, int i5, int i8, int i9, int[] iArr) {
        ViewGroup.MarginLayoutParams marginLayoutParams = (ViewGroup.MarginLayoutParams) view.getLayoutParams();
        int i10 = marginLayoutParams.leftMargin - iArr[0];
        int i11 = marginLayoutParams.rightMargin - iArr[1];
        int iMax = Math.max(0, i11) + Math.max(0, i10);
        iArr[0] = Math.max(0, -i10);
        iArr[1] = Math.max(0, -i11);
        view.measure(ViewGroup.getChildMeasureSpec(i, getPaddingRight() + getPaddingLeft() + iMax + i5, marginLayoutParams.width), ViewGroup.getChildMeasureSpec(i8, getPaddingBottom() + getPaddingTop() + marginLayoutParams.topMargin + marginLayoutParams.bottomMargin + i9, marginLayoutParams.height));
        return view.getMeasuredWidth() + iMax;
    }

    public final void q(View view, int i, int i5, int i8, int i9) {
        ViewGroup.MarginLayoutParams marginLayoutParams = (ViewGroup.MarginLayoutParams) view.getLayoutParams();
        int childMeasureSpec = ViewGroup.getChildMeasureSpec(i, getPaddingRight() + getPaddingLeft() + marginLayoutParams.leftMargin + marginLayoutParams.rightMargin + i5, marginLayoutParams.width);
        int childMeasureSpec2 = ViewGroup.getChildMeasureSpec(i8, getPaddingBottom() + getPaddingTop() + marginLayoutParams.topMargin + marginLayoutParams.bottomMargin, marginLayoutParams.height);
        int mode = View.MeasureSpec.getMode(childMeasureSpec2);
        if (mode != 1073741824 && i9 >= 0) {
            if (mode != 0) {
                i9 = Math.min(View.MeasureSpec.getSize(childMeasureSpec2), i9);
            }
            childMeasureSpec2 = View.MeasureSpec.makeMeasureSpec(i9, 1073741824);
        }
        view.measure(childMeasureSpec, childMeasureSpec2);
    }

    public final boolean r(View view) {
        return (view == null || view.getParent() != this || view.getVisibility() == 8) ? false : true;
    }

    /* JADX WARN: Removed duplicated region for block: B:14:0x0023  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final void s() {
        boolean z8;
        OnBackInvokedDispatcher onBackInvokedDispatcher;
        int i = 0;
        if (Build.VERSION.SDK_INT >= 33) {
            OnBackInvokedDispatcher onBackInvokedDispatcherA = L0.a(this);
            M0 m02 = this.f7873d0;
            if (m02 == null || m02.f14743r == null || onBackInvokedDispatcherA == null) {
                z8 = false;
            } else {
                Field field = J.f4065a;
                if (isAttachedToWindow() && this.f7877h0) {
                    z8 = true;
                }
            }
            if (z8 && this.f7876g0 == null) {
                if (this.f7875f0 == null) {
                    this.f7875f0 = L0.b(new J0(this, i));
                }
                L0.c(onBackInvokedDispatcherA, this.f7875f0);
                this.f7876g0 = onBackInvokedDispatcherA;
                return;
            }
            if (z8 || (onBackInvokedDispatcher = this.f7876g0) == null) {
                return;
            }
            L0.d(onBackInvokedDispatcher, this.f7875f0);
            this.f7876g0 = null;
        }
    }

    public void setBackInvokedCallbackEnabled(boolean z8) {
        if (this.f7877h0 != z8) {
            this.f7877h0 = z8;
            s();
        }
    }

    public void setCollapseContentDescription(int i) {
        setCollapseContentDescription(i != 0 ? getContext().getText(i) : null);
    }

    public void setCollapseIcon(int i) {
        setCollapseIcon(android.support.v4.media.session.a.l(getContext(), i));
    }

    public void setCollapsible(boolean z8) {
        this.f7874e0 = z8;
        requestLayout();
    }

    public void setContentInsetEndWithActions(int i) {
        if (i < 0) {
            i = Integer.MIN_VALUE;
        }
        if (i != this.f7858L) {
            this.f7858L = i;
            if (getNavigationIcon() != null) {
                requestLayout();
            }
        }
    }

    public void setContentInsetStartWithNavigation(int i) {
        if (i < 0) {
            i = Integer.MIN_VALUE;
        }
        if (i != this.f7857K) {
            this.f7857K = i;
            if (getNavigationIcon() != null) {
                requestLayout();
            }
        }
    }

    public void setLogo(int i) {
        setLogo(android.support.v4.media.session.a.l(getContext(), i));
    }

    public void setLogoDescription(int i) {
        setLogoDescription(getContext().getText(i));
    }

    public void setNavigationContentDescription(int i) {
        setNavigationContentDescription(i != 0 ? getContext().getText(i) : null);
    }

    public void setNavigationIcon(int i) {
        setNavigationIcon(android.support.v4.media.session.a.l(getContext(), i));
    }

    public void setNavigationOnClickListener(View.OnClickListener onClickListener) {
        f();
        this.f7882t.setOnClickListener(onClickListener);
    }

    public void setOverflowIcon(Drawable drawable) {
        e();
        this.f7879q.setOverflowIcon(drawable);
    }

    public void setPopupTheme(int i) {
        if (this.f7849A != i) {
            this.f7849A = i;
            if (i == 0) {
                this.f7888z = getContext();
            } else {
                this.f7888z = new ContextThemeWrapper(getContext(), i);
            }
        }
    }

    public void setSubtitle(int i) {
        setSubtitle(getContext().getText(i));
    }

    public void setSubtitleTextColor(int i) {
        setSubtitleTextColor(ColorStateList.valueOf(i));
    }

    public void setTitle(int i) {
        setTitle(getContext().getText(i));
    }

    public void setTitleMarginBottom(int i) {
        this.f7855I = i;
        requestLayout();
    }

    public void setTitleMarginEnd(int i) {
        this.f7854G = i;
        requestLayout();
    }

    public void setTitleMarginStart(int i) {
        this.f7853F = i;
        requestLayout();
    }

    public void setTitleMarginTop(int i) {
        this.H = i;
        requestLayout();
    }

    public void setTitleTextColor(int i) {
        setTitleTextColor(ColorStateList.valueOf(i));
    }

    public Toolbar(Context context, AttributeSet attributeSet, int i) {
        super(context, attributeSet, R.attr.toolbarStyle);
        this.f7859M = 8388627;
        this.f7866T = new ArrayList();
        this.f7867U = new ArrayList();
        this.f7868V = new int[2];
        this.f7869W = new y(new J0(this, 1));
        this.f7870a0 = new ArrayList();
        this.f7871b0 = new K0(this);
        this.f7878i0 = new k(27, this);
        Context context2 = getContext();
        int[] iArr = h.a.f13023t;
        com.google.android.material.datepicker.c cVarZ = com.google.android.material.datepicker.c.z(context2, attributeSet, iArr, R.attr.toolbarStyle);
        J.i(this, context, iArr, attributeSet, (TypedArray) cVarZ.f10220s, R.attr.toolbarStyle);
        TypedArray typedArray = (TypedArray) cVarZ.f10220s;
        this.f7850B = typedArray.getResourceId(28, 0);
        this.f7851C = typedArray.getResourceId(19, 0);
        this.f7859M = typedArray.getInteger(0, 8388627);
        this.D = typedArray.getInteger(2, 48);
        int dimensionPixelOffset = typedArray.getDimensionPixelOffset(22, 0);
        dimensionPixelOffset = typedArray.hasValue(27) ? typedArray.getDimensionPixelOffset(27, dimensionPixelOffset) : dimensionPixelOffset;
        this.f7855I = dimensionPixelOffset;
        this.H = dimensionPixelOffset;
        this.f7854G = dimensionPixelOffset;
        this.f7853F = dimensionPixelOffset;
        int dimensionPixelOffset2 = typedArray.getDimensionPixelOffset(25, -1);
        if (dimensionPixelOffset2 >= 0) {
            this.f7853F = dimensionPixelOffset2;
        }
        int dimensionPixelOffset3 = typedArray.getDimensionPixelOffset(24, -1);
        if (dimensionPixelOffset3 >= 0) {
            this.f7854G = dimensionPixelOffset3;
        }
        int dimensionPixelOffset4 = typedArray.getDimensionPixelOffset(26, -1);
        if (dimensionPixelOffset4 >= 0) {
            this.H = dimensionPixelOffset4;
        }
        int dimensionPixelOffset5 = typedArray.getDimensionPixelOffset(23, -1);
        if (dimensionPixelOffset5 >= 0) {
            this.f7855I = dimensionPixelOffset5;
        }
        this.f7852E = typedArray.getDimensionPixelSize(13, -1);
        int dimensionPixelOffset6 = typedArray.getDimensionPixelOffset(9, Integer.MIN_VALUE);
        int dimensionPixelOffset7 = typedArray.getDimensionPixelOffset(5, Integer.MIN_VALUE);
        int dimensionPixelSize = typedArray.getDimensionPixelSize(7, 0);
        int dimensionPixelSize2 = typedArray.getDimensionPixelSize(8, 0);
        d();
        C1238u0 c1238u0 = this.f7856J;
        c1238u0.f14952h = false;
        if (dimensionPixelSize != Integer.MIN_VALUE) {
            c1238u0.f14949e = dimensionPixelSize;
            c1238u0.f14945a = dimensionPixelSize;
        }
        if (dimensionPixelSize2 != Integer.MIN_VALUE) {
            c1238u0.f14950f = dimensionPixelSize2;
            c1238u0.f14946b = dimensionPixelSize2;
        }
        if (dimensionPixelOffset6 != Integer.MIN_VALUE || dimensionPixelOffset7 != Integer.MIN_VALUE) {
            c1238u0.a(dimensionPixelOffset6, dimensionPixelOffset7);
        }
        this.f7857K = typedArray.getDimensionPixelOffset(10, Integer.MIN_VALUE);
        this.f7858L = typedArray.getDimensionPixelOffset(6, Integer.MIN_VALUE);
        this.f7884v = cVarZ.u(4);
        this.f7885w = typedArray.getText(3);
        CharSequence text = typedArray.getText(21);
        if (!TextUtils.isEmpty(text)) {
            setTitle(text);
        }
        CharSequence text2 = typedArray.getText(18);
        if (!TextUtils.isEmpty(text2)) {
            setSubtitle(text2);
        }
        this.f7888z = getContext();
        setPopupTheme(typedArray.getResourceId(17, 0));
        Drawable drawableU = cVarZ.u(16);
        if (drawableU != null) {
            setNavigationIcon(drawableU);
        }
        CharSequence text3 = typedArray.getText(15);
        if (!TextUtils.isEmpty(text3)) {
            setNavigationContentDescription(text3);
        }
        Drawable drawableU2 = cVarZ.u(11);
        if (drawableU2 != null) {
            setLogo(drawableU2);
        }
        CharSequence text4 = typedArray.getText(12);
        if (!TextUtils.isEmpty(text4)) {
            setLogoDescription(text4);
        }
        if (typedArray.hasValue(29)) {
            setTitleTextColor(cVarZ.t(29));
        }
        if (typedArray.hasValue(20)) {
            setSubtitleTextColor(cVarZ.t(20));
        }
        if (typedArray.hasValue(14)) {
            getMenuInflater().inflate(typedArray.getResourceId(14, 0), getMenu());
        }
        cVarZ.B();
    }

    @Override // android.view.ViewGroup
    public final ViewGroup.LayoutParams generateLayoutParams(AttributeSet attributeSet) {
        Context context = getContext();
        N0 n02 = new N0(context, attributeSet);
        n02.f14745a = 0;
        TypedArray typedArrayObtainStyledAttributes = context.obtainStyledAttributes(attributeSet, h.a.f13006b);
        n02.f14745a = typedArrayObtainStyledAttributes.getInt(0, 0);
        typedArrayObtainStyledAttributes.recycle();
        n02.f14746b = 0;
        return n02;
    }

    public void setCollapseContentDescription(CharSequence charSequence) {
        if (!TextUtils.isEmpty(charSequence)) {
            c();
        }
        C1235t c1235t = this.f7886x;
        if (c1235t != null) {
            c1235t.setContentDescription(charSequence);
        }
    }

    public void setCollapseIcon(Drawable drawable) {
        if (drawable != null) {
            c();
            this.f7886x.setImageDrawable(drawable);
        } else {
            C1235t c1235t = this.f7886x;
            if (c1235t != null) {
                c1235t.setImageDrawable(this.f7884v);
            }
        }
    }

    public void setLogo(Drawable drawable) {
        if (drawable != null) {
            if (this.f7883u == null) {
                this.f7883u = new C1237u(getContext(), 0);
            }
            if (!m(this.f7883u)) {
                b(this.f7883u, true);
            }
        } else {
            C1237u c1237u = this.f7883u;
            if (c1237u != null && m(c1237u)) {
                removeView(this.f7883u);
                this.f7867U.remove(this.f7883u);
            }
        }
        C1237u c1237u2 = this.f7883u;
        if (c1237u2 != null) {
            c1237u2.setImageDrawable(drawable);
        }
    }

    public void setLogoDescription(CharSequence charSequence) {
        if (!TextUtils.isEmpty(charSequence) && this.f7883u == null) {
            this.f7883u = new C1237u(getContext(), 0);
        }
        C1237u c1237u = this.f7883u;
        if (c1237u != null) {
            c1237u.setContentDescription(charSequence);
        }
    }

    public void setNavigationContentDescription(CharSequence charSequence) {
        if (!TextUtils.isEmpty(charSequence)) {
            f();
        }
        C1235t c1235t = this.f7882t;
        if (c1235t != null) {
            c1235t.setContentDescription(charSequence);
            u0.z(this.f7882t, charSequence);
        }
    }

    public void setNavigationIcon(Drawable drawable) {
        if (drawable != null) {
            f();
            if (!m(this.f7882t)) {
                b(this.f7882t, true);
            }
        } else {
            C1235t c1235t = this.f7882t;
            if (c1235t != null && m(c1235t)) {
                removeView(this.f7882t);
                this.f7867U.remove(this.f7882t);
            }
        }
        C1235t c1235t2 = this.f7882t;
        if (c1235t2 != null) {
            c1235t2.setImageDrawable(drawable);
        }
    }

    public void setSubtitle(CharSequence charSequence) {
        if (TextUtils.isEmpty(charSequence)) {
            C1190H c1190h = this.f7881s;
            if (c1190h != null && m(c1190h)) {
                removeView(this.f7881s);
                this.f7867U.remove(this.f7881s);
            }
        } else {
            if (this.f7881s == null) {
                Context context = getContext();
                C1190H c1190h2 = new C1190H(context, null);
                this.f7881s = c1190h2;
                c1190h2.setSingleLine();
                this.f7881s.setEllipsize(TextUtils.TruncateAt.END);
                int i = this.f7851C;
                if (i != 0) {
                    this.f7881s.setTextAppearance(context, i);
                }
                ColorStateList colorStateList = this.f7863Q;
                if (colorStateList != null) {
                    this.f7881s.setTextColor(colorStateList);
                }
            }
            if (!m(this.f7881s)) {
                b(this.f7881s, true);
            }
        }
        C1190H c1190h3 = this.f7881s;
        if (c1190h3 != null) {
            c1190h3.setText(charSequence);
        }
        this.f7861O = charSequence;
    }

    public void setSubtitleTextColor(ColorStateList colorStateList) {
        this.f7863Q = colorStateList;
        C1190H c1190h = this.f7881s;
        if (c1190h != null) {
            c1190h.setTextColor(colorStateList);
        }
    }

    public void setTitle(CharSequence charSequence) {
        if (TextUtils.isEmpty(charSequence)) {
            C1190H c1190h = this.f7880r;
            if (c1190h != null && m(c1190h)) {
                removeView(this.f7880r);
                this.f7867U.remove(this.f7880r);
            }
        } else {
            if (this.f7880r == null) {
                Context context = getContext();
                C1190H c1190h2 = new C1190H(context, null);
                this.f7880r = c1190h2;
                c1190h2.setSingleLine();
                this.f7880r.setEllipsize(TextUtils.TruncateAt.END);
                int i = this.f7850B;
                if (i != 0) {
                    this.f7880r.setTextAppearance(context, i);
                }
                ColorStateList colorStateList = this.f7862P;
                if (colorStateList != null) {
                    this.f7880r.setTextColor(colorStateList);
                }
            }
            if (!m(this.f7880r)) {
                b(this.f7880r, true);
            }
        }
        C1190H c1190h3 = this.f7880r;
        if (c1190h3 != null) {
            c1190h3.setText(charSequence);
        }
        this.f7860N = charSequence;
    }

    public void setTitleTextColor(ColorStateList colorStateList) {
        this.f7862P = colorStateList;
        C1190H c1190h = this.f7880r;
        if (c1190h != null) {
            c1190h.setTextColor(colorStateList);
        }
    }

    public void setOnMenuItemClickListener(O0 o02) {
    }
}
