package com.google.android.flexbox;

import android.content.Context;
import android.graphics.PointF;
import android.graphics.Rect;
import android.os.Parcel;
import android.os.Parcelable;
import android.util.AttributeSet;
import android.util.SparseArray;
import android.view.View;
import android.view.ViewGroup;
import androidx.recyclerview.widget.RecyclerView;
import androidx.recyclerview.widget.k;
import androidx.recyclerview.widget.n;
import com.google.android.flexbox.d;
import com.google.android.gms.maps.model.BitmapDescriptorFactory;
import java.util.ArrayList;
import java.util.List;

/* loaded from: classes.dex */
public class FlexboxLayoutManager extends RecyclerView.p implements com.google.android.flexbox.a, RecyclerView.a0.b {

    /* renamed from: h0, reason: collision with root package name */
    private static final Rect f12712h0 = new Rect();
    private int H;
    private int I;
    private int J;
    private int K;
    private boolean M;
    private boolean N;
    private RecyclerView.w Q;
    private RecyclerView.b0 R;
    private d S;
    private n U;
    private n V;
    private e W;

    /* renamed from: b0, reason: collision with root package name */
    private boolean f12714b0;

    /* renamed from: d0, reason: collision with root package name */
    private final Context f12716d0;

    /* renamed from: e0, reason: collision with root package name */
    private View f12717e0;
    private int L = -1;
    private List O = new ArrayList();
    private final com.google.android.flexbox.d P = new com.google.android.flexbox.d(this);
    private b T = new b();
    private int X = -1;
    private int Y = Integer.MIN_VALUE;
    private int Z = Integer.MIN_VALUE;

    /* renamed from: a0, reason: collision with root package name */
    private int f12713a0 = Integer.MIN_VALUE;

    /* renamed from: c0, reason: collision with root package name */
    private SparseArray f12715c0 = new SparseArray();

    /* renamed from: f0, reason: collision with root package name */
    private int f12718f0 = -1;

    /* renamed from: g0, reason: collision with root package name */
    private d.b f12719g0 = new d.b();

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

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

        /* renamed from: b, reason: collision with root package name */
        private int f12721b;

        /* renamed from: c, reason: collision with root package name */
        private int f12722c;

        /* renamed from: d, reason: collision with root package name */
        private int f12723d;

        /* renamed from: e, reason: collision with root package name */
        private boolean f12724e;

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

        /* renamed from: g, reason: collision with root package name */
        private boolean f12726g;

        private b() {
            this.f12723d = 0;
        }

        static /* synthetic */ int l(b bVar, int i10) {
            int i11 = bVar.f12723d + i10;
            bVar.f12723d = i11;
            return i11;
        }

        /* JADX INFO: Access modifiers changed from: private */
        public void r() {
            if (FlexboxLayoutManager.this.j() || !FlexboxLayoutManager.this.M) {
                this.f12722c = this.f12724e ? FlexboxLayoutManager.this.U.i() : FlexboxLayoutManager.this.U.m();
            } else {
                this.f12722c = this.f12724e ? FlexboxLayoutManager.this.U.i() : FlexboxLayoutManager.this.u0() - FlexboxLayoutManager.this.U.m();
            }
        }

        /* JADX INFO: Access modifiers changed from: private */
        public void s(View view) {
            n nVar = FlexboxLayoutManager.this.I == 0 ? FlexboxLayoutManager.this.V : FlexboxLayoutManager.this.U;
            if (FlexboxLayoutManager.this.j() || !FlexboxLayoutManager.this.M) {
                if (this.f12724e) {
                    this.f12722c = nVar.d(view) + nVar.o();
                } else {
                    this.f12722c = nVar.g(view);
                }
            } else if (this.f12724e) {
                this.f12722c = nVar.g(view) + nVar.o();
            } else {
                this.f12722c = nVar.d(view);
            }
            this.f12720a = FlexboxLayoutManager.this.n0(view);
            this.f12726g = false;
            int[] iArr = FlexboxLayoutManager.this.P.f12767c;
            int i10 = this.f12720a;
            if (i10 == -1) {
                i10 = 0;
            }
            int i11 = iArr[i10];
            this.f12721b = i11 != -1 ? i11 : 0;
            if (FlexboxLayoutManager.this.O.size() > this.f12721b) {
                this.f12720a = ((com.google.android.flexbox.c) FlexboxLayoutManager.this.O.get(this.f12721b)).f12761o;
            }
        }

        /* JADX INFO: Access modifiers changed from: private */
        public void t() {
            this.f12720a = -1;
            this.f12721b = -1;
            this.f12722c = Integer.MIN_VALUE;
            this.f12725f = false;
            this.f12726g = false;
            if (FlexboxLayoutManager.this.j()) {
                if (FlexboxLayoutManager.this.I == 0) {
                    this.f12724e = FlexboxLayoutManager.this.H == 1;
                    return;
                } else {
                    this.f12724e = FlexboxLayoutManager.this.I == 2;
                    return;
                }
            }
            if (FlexboxLayoutManager.this.I == 0) {
                this.f12724e = FlexboxLayoutManager.this.H == 3;
            } else {
                this.f12724e = FlexboxLayoutManager.this.I == 2;
            }
        }

        public String toString() {
            return "AnchorInfo{mPosition=" + this.f12720a + ", mFlexLinePosition=" + this.f12721b + ", mCoordinate=" + this.f12722c + ", mPerpendicularCoordinate=" + this.f12723d + ", mLayoutFromEnd=" + this.f12724e + ", mValid=" + this.f12725f + ", mAssignedFromSavedState=" + this.f12726g + '}';
        }
    }

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

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

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

        /* renamed from: c, reason: collision with root package name */
        private int f12737c;

        /* renamed from: d, reason: collision with root package name */
        private int f12738d;

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

        /* renamed from: f, reason: collision with root package name */
        private int f12740f;

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

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

        /* renamed from: i, reason: collision with root package name */
        private int f12743i;

        /* renamed from: j, reason: collision with root package name */
        private boolean f12744j;

        private d() {
            this.f12742h = 1;
            this.f12743i = 1;
        }

        /* JADX INFO: Access modifiers changed from: private */
        public boolean D(RecyclerView.b0 b0Var, List list) {
            int i10;
            int i11 = this.f12738d;
            return i11 >= 0 && i11 < b0Var.b() && (i10 = this.f12737c) >= 0 && i10 < list.size();
        }

        static /* synthetic */ int c(d dVar, int i10) {
            int i11 = dVar.f12739e + i10;
            dVar.f12739e = i11;
            return i11;
        }

        static /* synthetic */ int d(d dVar, int i10) {
            int i11 = dVar.f12739e - i10;
            dVar.f12739e = i11;
            return i11;
        }

        static /* synthetic */ int i(d dVar, int i10) {
            int i11 = dVar.f12735a - i10;
            dVar.f12735a = i11;
            return i11;
        }

        static /* synthetic */ int l(d dVar) {
            int i10 = dVar.f12737c;
            dVar.f12737c = i10 + 1;
            return i10;
        }

        static /* synthetic */ int m(d dVar) {
            int i10 = dVar.f12737c;
            dVar.f12737c = i10 - 1;
            return i10;
        }

        static /* synthetic */ int n(d dVar, int i10) {
            int i11 = dVar.f12737c + i10;
            dVar.f12737c = i11;
            return i11;
        }

        static /* synthetic */ int q(d dVar, int i10) {
            int i11 = dVar.f12740f + i10;
            dVar.f12740f = i11;
            return i11;
        }

        static /* synthetic */ int u(d dVar, int i10) {
            int i11 = dVar.f12738d + i10;
            dVar.f12738d = i11;
            return i11;
        }

        static /* synthetic */ int v(d dVar, int i10) {
            int i11 = dVar.f12738d - i10;
            dVar.f12738d = i11;
            return i11;
        }

        public String toString() {
            return "LayoutState{mAvailable=" + this.f12735a + ", mFlexLinePosition=" + this.f12737c + ", mPosition=" + this.f12738d + ", mOffset=" + this.f12739e + ", mScrollingOffset=" + this.f12740f + ", mLastScrollDelta=" + this.f12741g + ", mItemDirection=" + this.f12742h + ", mLayoutDirection=" + this.f12743i + '}';
        }
    }

    public FlexboxLayoutManager(Context context, AttributeSet attributeSet, int i10, int i11) {
        RecyclerView.p.d o02 = RecyclerView.p.o0(context, attributeSet, i10, i11);
        int i12 = o02.f5232a;
        if (i12 != 0) {
            if (i12 == 1) {
                if (o02.f5234c) {
                    M2(3);
                } else {
                    M2(2);
                }
            }
        } else if (o02.f5234c) {
            M2(1);
        } else {
            M2(0);
        }
        N2(1);
        L2(4);
        this.f12716d0 = context;
    }

    private int A2(int i10) {
        int i11;
        if (T() == 0 || i10 == 0) {
            return 0;
        }
        i2();
        boolean j10 = j();
        View view = this.f12717e0;
        int width = j10 ? view.getWidth() : view.getHeight();
        int u02 = j10 ? u0() : g0();
        if (!(j0() == 1)) {
            if (i10 > 0) {
                return Math.min((u02 - this.T.f12723d) - width, i10);
            }
            if (this.T.f12723d + i10 < 0) {
                i11 = this.T.f12723d;
                i10 = -i11;
            }
            return i10;
        }
        int abs = Math.abs(i10);
        if (i10 < 0) {
            return -Math.min((u02 + this.T.f12723d) - width, abs);
        }
        if (this.T.f12723d + i10 > 0) {
            i11 = this.T.f12723d;
            i10 = -i11;
        }
        return i10;
    }

    private boolean B2(View view, boolean z10) {
        int paddingLeft = getPaddingLeft();
        int paddingTop = getPaddingTop();
        int u02 = u0() - getPaddingRight();
        int g02 = g0() - getPaddingBottom();
        int w22 = w2(view);
        int y22 = y2(view);
        int x22 = x2(view);
        int u22 = u2(view);
        return z10 ? (paddingLeft <= w22 && u02 >= x22) && (paddingTop <= y22 && g02 >= u22) : (w22 >= u02 || x22 >= paddingLeft) && (y22 >= g02 || u22 >= paddingTop);
    }

    private int C2(com.google.android.flexbox.c cVar, d dVar) {
        return j() ? D2(cVar, dVar) : E2(cVar, dVar);
    }

    private static boolean D0(int i10, int i11, int i12) {
        int mode = View.MeasureSpec.getMode(i11);
        int size = View.MeasureSpec.getSize(i11);
        if (i12 > 0 && i10 != i12) {
            return false;
        }
        if (mode == Integer.MIN_VALUE) {
            return size >= i10;
        }
        if (mode != 0) {
            return mode == 1073741824 && size == i10;
        }
        return true;
    }

    /* JADX WARN: Removed duplicated region for block: B:22:0x00ce  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    private int D2(com.google.android.flexbox.c cVar, d dVar) {
        float f10;
        float f11;
        float f12;
        int b10;
        int i10;
        c cVar2;
        int paddingLeft = getPaddingLeft();
        int paddingRight = getPaddingRight();
        int u02 = u0();
        int i11 = dVar.f12739e;
        if (dVar.f12743i == -1) {
            i11 -= cVar.f12753g;
        }
        int i12 = i11;
        int i13 = dVar.f12738d;
        int i14 = this.J;
        int i15 = 1;
        if (i14 != 0) {
            if (i14 == 1) {
                int i16 = cVar.f12751e;
                float f13 = (u02 - i16) + paddingRight;
                f12 = 0.0f;
                f11 = i16 - paddingLeft;
                f10 = f13;
            } else if (i14 == 2) {
                int i17 = cVar.f12751e;
                f10 = paddingLeft + ((u02 - i17) / 2.0f);
                f11 = (u02 - paddingRight) - ((u02 - i17) / 2.0f);
            } else if (i14 == 3) {
                f10 = paddingLeft;
                f12 = (u02 - cVar.f12751e) / (cVar.f12754h != 1 ? r4 - 1 : 1.0f);
                f11 = u02 - paddingRight;
            } else if (i14 == 4) {
                int i18 = cVar.f12754h;
                f12 = i18 != 0 ? (u02 - cVar.f12751e) / i18 : 0.0f;
                float f14 = f12 / 2.0f;
                f10 = paddingLeft + f14;
                f11 = (u02 - paddingRight) - f14;
            } else {
                if (i14 != 5) {
                    throw new IllegalStateException("Invalid justifyContent is set: " + this.J);
                }
                f12 = cVar.f12754h != 0 ? (u02 - cVar.f12751e) / (r4 + 1) : 0.0f;
                f10 = paddingLeft + f12;
                f11 = (u02 - paddingRight) - f12;
            }
            float f15 = f10 - this.T.f12723d;
            float f16 = f11 - this.T.f12723d;
            float max = Math.max(f12, BitmapDescriptorFactory.HUE_RED);
            b10 = cVar.b();
            int i19 = 0;
            i10 = i13;
            while (i10 < i13 + b10) {
                View g10 = g(i10);
                if (g10 != null) {
                    if (dVar.f12743i == i15) {
                        t(g10, f12712h0);
                        n(g10);
                    } else {
                        t(g10, f12712h0);
                        o(g10, i19);
                        i19++;
                    }
                    int i20 = i19;
                    com.google.android.flexbox.d dVar2 = this.P;
                    long j10 = dVar2.f12768d[i10];
                    int y10 = dVar2.y(j10);
                    int x10 = this.P.x(j10);
                    c cVar3 = (c) g10.getLayoutParams();
                    if (N1(g10, y10, x10, cVar3)) {
                        g10.measure(y10, x10);
                    }
                    float k02 = f15 + ((ViewGroup.MarginLayoutParams) cVar3).leftMargin + k0(g10);
                    float p02 = f16 - (((ViewGroup.MarginLayoutParams) cVar3).rightMargin + p0(g10));
                    int s02 = i12 + s0(g10);
                    if (this.M) {
                        cVar2 = cVar3;
                        this.P.Q(g10, cVar, Math.round(p02) - g10.getMeasuredWidth(), s02, Math.round(p02), s02 + g10.getMeasuredHeight());
                    } else {
                        cVar2 = cVar3;
                        this.P.Q(g10, cVar, Math.round(k02), s02, Math.round(k02) + g10.getMeasuredWidth(), s02 + g10.getMeasuredHeight());
                    }
                    i19 = i20;
                    f15 = k02 + g10.getMeasuredWidth() + ((ViewGroup.MarginLayoutParams) cVar2).rightMargin + p0(g10) + max;
                    f16 = p02 - (((g10.getMeasuredWidth() + ((ViewGroup.MarginLayoutParams) cVar2).leftMargin) + k0(g10)) + max);
                }
                i10++;
                i15 = 1;
            }
            d.n(dVar, this.S.f12743i);
            return cVar.a();
        }
        f10 = paddingLeft;
        f11 = u02 - paddingRight;
        f12 = 0.0f;
        float f152 = f10 - this.T.f12723d;
        float f162 = f11 - this.T.f12723d;
        float max2 = Math.max(f12, BitmapDescriptorFactory.HUE_RED);
        b10 = cVar.b();
        int i192 = 0;
        i10 = i13;
        while (i10 < i13 + b10) {
        }
        d.n(dVar, this.S.f12743i);
        return cVar.a();
    }

    /* JADX WARN: Removed duplicated region for block: B:22:0x00d4  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    private int E2(com.google.android.flexbox.c cVar, d dVar) {
        float f10;
        float f11;
        float f12;
        int b10;
        int i10;
        boolean z10;
        View view;
        int i11;
        int paddingTop = getPaddingTop();
        int paddingBottom = getPaddingBottom();
        int g02 = g0();
        int i12 = dVar.f12739e;
        int i13 = dVar.f12739e;
        if (dVar.f12743i == -1) {
            int i14 = cVar.f12753g;
            i12 -= i14;
            i13 += i14;
        }
        int i15 = i12;
        int i16 = i13;
        int i17 = dVar.f12738d;
        int i18 = this.J;
        boolean z11 = true;
        if (i18 != 0) {
            if (i18 == 1) {
                int i19 = cVar.f12751e;
                float f13 = (g02 - i19) + paddingBottom;
                f12 = 0.0f;
                f11 = i19 - paddingTop;
                f10 = f13;
            } else if (i18 == 2) {
                int i20 = cVar.f12751e;
                f10 = paddingTop + ((g02 - i20) / 2.0f);
                f11 = (g02 - paddingBottom) - ((g02 - i20) / 2.0f);
            } else if (i18 == 3) {
                f10 = paddingTop;
                f12 = (g02 - cVar.f12751e) / (cVar.f12754h != 1 ? r4 - 1 : 1.0f);
                f11 = g02 - paddingBottom;
            } else if (i18 == 4) {
                int i21 = cVar.f12754h;
                f12 = i21 != 0 ? (g02 - cVar.f12751e) / i21 : 0.0f;
                float f14 = f12 / 2.0f;
                f10 = paddingTop + f14;
                f11 = (g02 - paddingBottom) - f14;
            } else {
                if (i18 != 5) {
                    throw new IllegalStateException("Invalid justifyContent is set: " + this.J);
                }
                f12 = cVar.f12754h != 0 ? (g02 - cVar.f12751e) / (r4 + 1) : 0.0f;
                f10 = paddingTop + f12;
                f11 = (g02 - paddingBottom) - f12;
            }
            float f15 = f10 - this.T.f12723d;
            float f16 = f11 - this.T.f12723d;
            float max = Math.max(f12, BitmapDescriptorFactory.HUE_RED);
            b10 = cVar.b();
            int i22 = 0;
            i10 = i17;
            while (i10 < i17 + b10) {
                View g10 = g(i10);
                if (g10 == null) {
                    i11 = i10;
                    z10 = z11;
                } else {
                    com.google.android.flexbox.d dVar2 = this.P;
                    long j10 = dVar2.f12768d[i10];
                    int y10 = dVar2.y(j10);
                    int x10 = this.P.x(j10);
                    if (N1(g10, y10, x10, (c) g10.getLayoutParams())) {
                        g10.measure(y10, x10);
                    }
                    float s02 = f15 + ((ViewGroup.MarginLayoutParams) r13).topMargin + s0(g10);
                    float R = f16 - (((ViewGroup.MarginLayoutParams) r13).rightMargin + R(g10));
                    if (dVar.f12743i == 1) {
                        t(g10, f12712h0);
                        n(g10);
                    } else {
                        t(g10, f12712h0);
                        o(g10, i22);
                        i22++;
                    }
                    int i23 = i22;
                    int k02 = i15 + k0(g10);
                    int p02 = i16 - p0(g10);
                    boolean z12 = this.M;
                    if (!z12) {
                        z10 = true;
                        view = g10;
                        i11 = i10;
                        if (this.N) {
                            this.P.R(view, cVar, z12, k02, Math.round(R) - view.getMeasuredHeight(), k02 + view.getMeasuredWidth(), Math.round(R));
                        } else {
                            this.P.R(view, cVar, z12, k02, Math.round(s02), k02 + view.getMeasuredWidth(), Math.round(s02) + view.getMeasuredHeight());
                        }
                    } else if (this.N) {
                        z10 = true;
                        view = g10;
                        i11 = i10;
                        this.P.R(g10, cVar, z12, p02 - g10.getMeasuredWidth(), Math.round(R) - g10.getMeasuredHeight(), p02, Math.round(R));
                    } else {
                        z10 = true;
                        view = g10;
                        i11 = i10;
                        this.P.R(view, cVar, z12, p02 - view.getMeasuredWidth(), Math.round(s02), p02, Math.round(s02) + view.getMeasuredHeight());
                    }
                    View view2 = view;
                    i22 = i23;
                    f15 = s02 + view.getMeasuredHeight() + ((ViewGroup.MarginLayoutParams) r13).topMargin + R(view2) + max;
                    f16 = R - (((view2.getMeasuredHeight() + ((ViewGroup.MarginLayoutParams) r13).bottomMargin) + s0(view2)) + max);
                }
                i10 = i11 + 1;
                z11 = z10;
            }
            d.n(dVar, this.S.f12743i);
            return cVar.a();
        }
        f10 = paddingTop;
        f11 = g02 - paddingBottom;
        f12 = 0.0f;
        float f152 = f10 - this.T.f12723d;
        float f162 = f11 - this.T.f12723d;
        float max2 = Math.max(f12, BitmapDescriptorFactory.HUE_RED);
        b10 = cVar.b();
        int i222 = 0;
        i10 = i17;
        while (i10 < i17 + b10) {
        }
        d.n(dVar, this.S.f12743i);
        return cVar.a();
    }

    private void F2(RecyclerView.w wVar, d dVar) {
        if (dVar.f12744j) {
            if (dVar.f12743i == -1) {
                H2(wVar, dVar);
            } else {
                I2(wVar, dVar);
            }
        }
    }

    private void G2(RecyclerView.w wVar, int i10, int i11) {
        while (i11 >= i10) {
            v1(i11, wVar);
            i11--;
        }
    }

    private void H2(RecyclerView.w wVar, d dVar) {
        int T;
        int i10;
        View S;
        int i11;
        if (dVar.f12740f < 0 || (T = T()) == 0 || (S = S(T - 1)) == null || (i11 = this.P.f12767c[n0(S)]) == -1) {
            return;
        }
        com.google.android.flexbox.c cVar = (com.google.android.flexbox.c) this.O.get(i11);
        int i12 = i10;
        while (true) {
            if (i12 < 0) {
                break;
            }
            View S2 = S(i12);
            if (S2 != null) {
                if (!b2(S2, dVar.f12740f)) {
                    break;
                }
                if (cVar.f12761o != n0(S2)) {
                    continue;
                } else if (i11 <= 0) {
                    T = i12;
                    break;
                } else {
                    i11 += dVar.f12743i;
                    cVar = (com.google.android.flexbox.c) this.O.get(i11);
                    T = i12;
                }
            }
            i12--;
        }
        G2(wVar, T, i10);
    }

    private void I2(RecyclerView.w wVar, d dVar) {
        int T;
        View S;
        if (dVar.f12740f < 0 || (T = T()) == 0 || (S = S(0)) == null) {
            return;
        }
        int i10 = this.P.f12767c[n0(S)];
        int i11 = -1;
        if (i10 == -1) {
            return;
        }
        com.google.android.flexbox.c cVar = (com.google.android.flexbox.c) this.O.get(i10);
        int i12 = 0;
        while (true) {
            if (i12 >= T) {
                break;
            }
            View S2 = S(i12);
            if (S2 != null) {
                if (!c2(S2, dVar.f12740f)) {
                    break;
                }
                if (cVar.f12762p != n0(S2)) {
                    continue;
                } else if (i10 >= this.O.size() - 1) {
                    i11 = i12;
                    break;
                } else {
                    i10 += dVar.f12743i;
                    cVar = (com.google.android.flexbox.c) this.O.get(i10);
                    i11 = i12;
                }
            }
            i12++;
        }
        G2(wVar, 0, i11);
    }

    private void J2() {
        int h02 = j() ? h0() : v0();
        this.S.f12736b = h02 == 0 || h02 == Integer.MIN_VALUE;
    }

    private void K2() {
        int j02 = j0();
        int i10 = this.H;
        if (i10 == 0) {
            this.M = j02 == 1;
            this.N = this.I == 2;
            return;
        }
        if (i10 == 1) {
            this.M = j02 != 1;
            this.N = this.I == 2;
            return;
        }
        if (i10 == 2) {
            boolean z10 = j02 == 1;
            this.M = z10;
            if (this.I == 2) {
                this.M = !z10;
            }
            this.N = false;
            return;
        }
        if (i10 != 3) {
            this.M = false;
            this.N = false;
            return;
        }
        boolean z11 = j02 == 1;
        this.M = z11;
        if (this.I == 2) {
            this.M = !z11;
        }
        this.N = true;
    }

    private boolean N1(View view, int i10, int i11, RecyclerView.q qVar) {
        return (!view.isLayoutRequested() && C0() && D0(view.getWidth(), i10, ((ViewGroup.MarginLayoutParams) qVar).width) && D0(view.getHeight(), i11, ((ViewGroup.MarginLayoutParams) qVar).height)) ? false : true;
    }

    private boolean O2(RecyclerView.b0 b0Var, b bVar) {
        if (T() == 0) {
            return false;
        }
        View n22 = bVar.f12724e ? n2(b0Var.b()) : k2(b0Var.b());
        if (n22 == null) {
            return false;
        }
        bVar.s(n22);
        if (!b0Var.e() && T1()) {
            if (this.U.g(n22) >= this.U.i() || this.U.d(n22) < this.U.m()) {
                bVar.f12722c = bVar.f12724e ? this.U.i() : this.U.m();
            }
        }
        return true;
    }

    private boolean P2(RecyclerView.b0 b0Var, b bVar, e eVar) {
        int i10;
        View S;
        if (!b0Var.e() && (i10 = this.X) != -1) {
            if (i10 >= 0 && i10 < b0Var.b()) {
                bVar.f12720a = this.X;
                bVar.f12721b = this.P.f12767c[bVar.f12720a];
                e eVar2 = this.W;
                if (eVar2 != null && eVar2.g(b0Var.b())) {
                    bVar.f12722c = this.U.m() + eVar.f12746q;
                    bVar.f12726g = true;
                    bVar.f12721b = -1;
                    return true;
                }
                if (this.Y != Integer.MIN_VALUE) {
                    if (j() || !this.M) {
                        bVar.f12722c = this.U.m() + this.Y;
                    } else {
                        bVar.f12722c = this.Y - this.U.j();
                    }
                    return true;
                }
                View M = M(this.X);
                if (M == null) {
                    if (T() > 0 && (S = S(0)) != null) {
                        bVar.f12724e = this.X < n0(S);
                    }
                    bVar.r();
                } else {
                    if (this.U.e(M) > this.U.n()) {
                        bVar.r();
                        return true;
                    }
                    if (this.U.g(M) - this.U.m() < 0) {
                        bVar.f12722c = this.U.m();
                        bVar.f12724e = false;
                        return true;
                    }
                    if (this.U.i() - this.U.d(M) < 0) {
                        bVar.f12722c = this.U.i();
                        bVar.f12724e = true;
                        return true;
                    }
                    bVar.f12722c = bVar.f12724e ? this.U.d(M) + this.U.o() : this.U.g(M);
                }
                return true;
            }
            this.X = -1;
            this.Y = Integer.MIN_VALUE;
        }
        return false;
    }

    private void Q2(RecyclerView.b0 b0Var, b bVar) {
        if (P2(b0Var, bVar, this.W) || O2(b0Var, bVar)) {
            return;
        }
        bVar.r();
        bVar.f12720a = 0;
        bVar.f12721b = 0;
    }

    private void R2(int i10) {
        if (i10 >= p2()) {
            return;
        }
        int T = T();
        this.P.t(T);
        this.P.u(T);
        this.P.s(T);
        if (i10 >= this.P.f12767c.length) {
            return;
        }
        this.f12718f0 = i10;
        View v22 = v2();
        if (v22 == null) {
            return;
        }
        this.X = n0(v22);
        if (j() || !this.M) {
            this.Y = this.U.g(v22) - this.U.m();
        } else {
            this.Y = this.U.d(v22) + this.U.j();
        }
    }

    private void S2(int i10) {
        boolean z10;
        int i11;
        int makeMeasureSpec = View.MeasureSpec.makeMeasureSpec(u0(), v0());
        int makeMeasureSpec2 = View.MeasureSpec.makeMeasureSpec(g0(), h0());
        int u02 = u0();
        int g02 = g0();
        if (j()) {
            int i12 = this.Z;
            z10 = (i12 == Integer.MIN_VALUE || i12 == u02) ? false : true;
            i11 = this.S.f12736b ? this.f12716d0.getResources().getDisplayMetrics().heightPixels : this.S.f12735a;
        } else {
            int i13 = this.f12713a0;
            z10 = (i13 == Integer.MIN_VALUE || i13 == g02) ? false : true;
            i11 = this.S.f12736b ? this.f12716d0.getResources().getDisplayMetrics().widthPixels : this.S.f12735a;
        }
        int i14 = i11;
        this.Z = u02;
        this.f12713a0 = g02;
        int i15 = this.f12718f0;
        if (i15 == -1 && (this.X != -1 || z10)) {
            if (this.T.f12724e) {
                return;
            }
            this.O.clear();
            this.f12719g0.a();
            if (j()) {
                this.P.e(this.f12719g0, makeMeasureSpec, makeMeasureSpec2, i14, this.T.f12720a, this.O);
            } else {
                this.P.h(this.f12719g0, makeMeasureSpec, makeMeasureSpec2, i14, this.T.f12720a, this.O);
            }
            this.O = this.f12719g0.f12770a;
            this.P.p(makeMeasureSpec, makeMeasureSpec2);
            this.P.X();
            b bVar = this.T;
            bVar.f12721b = this.P.f12767c[bVar.f12720a];
            this.S.f12737c = this.T.f12721b;
            return;
        }
        int min = i15 != -1 ? Math.min(i15, this.T.f12720a) : this.T.f12720a;
        this.f12719g0.a();
        if (j()) {
            if (this.O.size() > 0) {
                this.P.j(this.O, min);
                this.P.b(this.f12719g0, makeMeasureSpec, makeMeasureSpec2, i14, min, this.T.f12720a, this.O);
            } else {
                this.P.s(i10);
                this.P.d(this.f12719g0, makeMeasureSpec, makeMeasureSpec2, i14, 0, this.O);
            }
        } else if (this.O.size() > 0) {
            this.P.j(this.O, min);
            this.P.b(this.f12719g0, makeMeasureSpec2, makeMeasureSpec, i14, min, this.T.f12720a, this.O);
        } else {
            this.P.s(i10);
            this.P.g(this.f12719g0, makeMeasureSpec, makeMeasureSpec2, i14, 0, this.O);
        }
        this.O = this.f12719g0.f12770a;
        this.P.q(makeMeasureSpec, makeMeasureSpec2, min);
        this.P.Y(min);
    }

    private void T2(int i10, int i11) {
        this.S.f12743i = i10;
        boolean j10 = j();
        int makeMeasureSpec = View.MeasureSpec.makeMeasureSpec(u0(), v0());
        int makeMeasureSpec2 = View.MeasureSpec.makeMeasureSpec(g0(), h0());
        boolean z10 = !j10 && this.M;
        if (i10 == 1) {
            View S = S(T() - 1);
            if (S == null) {
                return;
            }
            this.S.f12739e = this.U.d(S);
            int n02 = n0(S);
            View o22 = o2(S, (com.google.android.flexbox.c) this.O.get(this.P.f12767c[n02]));
            this.S.f12742h = 1;
            d dVar = this.S;
            dVar.f12738d = n02 + dVar.f12742h;
            if (this.P.f12767c.length <= this.S.f12738d) {
                this.S.f12737c = -1;
            } else {
                d dVar2 = this.S;
                dVar2.f12737c = this.P.f12767c[dVar2.f12738d];
            }
            if (z10) {
                this.S.f12739e = this.U.g(o22);
                this.S.f12740f = (-this.U.g(o22)) + this.U.m();
                d dVar3 = this.S;
                dVar3.f12740f = Math.max(dVar3.f12740f, 0);
            } else {
                this.S.f12739e = this.U.d(o22);
                this.S.f12740f = this.U.d(o22) - this.U.i();
            }
            if ((this.S.f12737c == -1 || this.S.f12737c > this.O.size() - 1) && this.S.f12738d <= getFlexItemCount()) {
                int i12 = i11 - this.S.f12740f;
                this.f12719g0.a();
                if (i12 > 0) {
                    if (j10) {
                        this.P.d(this.f12719g0, makeMeasureSpec, makeMeasureSpec2, i12, this.S.f12738d, this.O);
                    } else {
                        this.P.g(this.f12719g0, makeMeasureSpec, makeMeasureSpec2, i12, this.S.f12738d, this.O);
                    }
                    this.P.q(makeMeasureSpec, makeMeasureSpec2, this.S.f12738d);
                    this.P.Y(this.S.f12738d);
                }
            }
        } else {
            View S2 = S(0);
            if (S2 == null) {
                return;
            }
            this.S.f12739e = this.U.g(S2);
            int n03 = n0(S2);
            View l22 = l2(S2, (com.google.android.flexbox.c) this.O.get(this.P.f12767c[n03]));
            this.S.f12742h = 1;
            int i13 = this.P.f12767c[n03];
            if (i13 == -1) {
                i13 = 0;
            }
            if (i13 > 0) {
                this.S.f12738d = n03 - ((com.google.android.flexbox.c) this.O.get(i13 - 1)).b();
            } else {
                this.S.f12738d = -1;
            }
            this.S.f12737c = i13 > 0 ? i13 - 1 : 0;
            if (z10) {
                this.S.f12739e = this.U.d(l22);
                this.S.f12740f = this.U.d(l22) - this.U.i();
                d dVar4 = this.S;
                dVar4.f12740f = Math.max(dVar4.f12740f, 0);
            } else {
                this.S.f12739e = this.U.g(l22);
                this.S.f12740f = (-this.U.g(l22)) + this.U.m();
            }
        }
        d dVar5 = this.S;
        dVar5.f12735a = i11 - dVar5.f12740f;
    }

    private void U2(b bVar, boolean z10, boolean z11) {
        if (z11) {
            J2();
        } else {
            this.S.f12736b = false;
        }
        if (j() || !this.M) {
            this.S.f12735a = this.U.i() - bVar.f12722c;
        } else {
            this.S.f12735a = bVar.f12722c - getPaddingRight();
        }
        this.S.f12738d = bVar.f12720a;
        this.S.f12742h = 1;
        this.S.f12743i = 1;
        this.S.f12739e = bVar.f12722c;
        this.S.f12740f = Integer.MIN_VALUE;
        this.S.f12737c = bVar.f12721b;
        if (!z10 || this.O.size() <= 1 || bVar.f12721b < 0 || bVar.f12721b >= this.O.size() - 1) {
            return;
        }
        com.google.android.flexbox.c cVar = (com.google.android.flexbox.c) this.O.get(bVar.f12721b);
        d.l(this.S);
        d.u(this.S, cVar.b());
    }

    private void V2(b bVar, boolean z10, boolean z11) {
        if (z11) {
            J2();
        } else {
            this.S.f12736b = false;
        }
        if (j() || !this.M) {
            this.S.f12735a = bVar.f12722c - this.U.m();
        } else {
            this.S.f12735a = (this.f12717e0.getWidth() - bVar.f12722c) - this.U.m();
        }
        this.S.f12738d = bVar.f12720a;
        this.S.f12742h = 1;
        this.S.f12743i = -1;
        this.S.f12739e = bVar.f12722c;
        this.S.f12740f = Integer.MIN_VALUE;
        this.S.f12737c = bVar.f12721b;
        if (!z10 || bVar.f12721b <= 0 || this.O.size() <= bVar.f12721b) {
            return;
        }
        com.google.android.flexbox.c cVar = (com.google.android.flexbox.c) this.O.get(bVar.f12721b);
        d.m(this.S);
        d.v(this.S, cVar.b());
    }

    private boolean b2(View view, int i10) {
        return (j() || !this.M) ? this.U.g(view) >= this.U.h() - i10 : this.U.d(view) <= i10;
    }

    private boolean c2(View view, int i10) {
        return (j() || !this.M) ? this.U.d(view) <= i10 : this.U.h() - this.U.g(view) <= i10;
    }

    private void d2() {
        this.O.clear();
        this.T.t();
        this.T.f12723d = 0;
    }

    private int e2(RecyclerView.b0 b0Var) {
        if (T() == 0) {
            return 0;
        }
        int b10 = b0Var.b();
        i2();
        View k22 = k2(b10);
        View n22 = n2(b10);
        if (b0Var.b() == 0 || k22 == null || n22 == null) {
            return 0;
        }
        return Math.min(this.U.n(), this.U.d(n22) - this.U.g(k22));
    }

    private int f2(RecyclerView.b0 b0Var) {
        if (T() == 0) {
            return 0;
        }
        int b10 = b0Var.b();
        View k22 = k2(b10);
        View n22 = n2(b10);
        if (b0Var.b() != 0 && k22 != null && n22 != null) {
            int n02 = n0(k22);
            int n03 = n0(n22);
            int abs = Math.abs(this.U.d(n22) - this.U.g(k22));
            int i10 = this.P.f12767c[n02];
            if (i10 != 0 && i10 != -1) {
                return Math.round((i10 * (abs / ((r4[n03] - i10) + 1))) + (this.U.m() - this.U.g(k22)));
            }
        }
        return 0;
    }

    private int g2(RecyclerView.b0 b0Var) {
        if (T() == 0) {
            return 0;
        }
        int b10 = b0Var.b();
        View k22 = k2(b10);
        View n22 = n2(b10);
        if (b0Var.b() == 0 || k22 == null || n22 == null) {
            return 0;
        }
        int m22 = m2();
        return (int) ((Math.abs(this.U.d(n22) - this.U.g(k22)) / ((p2() - m22) + 1)) * b0Var.b());
    }

    private void h2() {
        if (this.S == null) {
            this.S = new d();
        }
    }

    private void i2() {
        if (this.U != null) {
            return;
        }
        if (j()) {
            if (this.I == 0) {
                this.U = n.a(this);
                this.V = n.c(this);
                return;
            } else {
                this.U = n.c(this);
                this.V = n.a(this);
                return;
            }
        }
        if (this.I == 0) {
            this.U = n.c(this);
            this.V = n.a(this);
        } else {
            this.U = n.a(this);
            this.V = n.c(this);
        }
    }

    private int j2(RecyclerView.w wVar, RecyclerView.b0 b0Var, d dVar) {
        if (dVar.f12740f != Integer.MIN_VALUE) {
            if (dVar.f12735a < 0) {
                d.q(dVar, dVar.f12735a);
            }
            F2(wVar, dVar);
        }
        int i10 = dVar.f12735a;
        int i11 = dVar.f12735a;
        boolean j10 = j();
        int i12 = 0;
        while (true) {
            if ((i11 > 0 || this.S.f12736b) && dVar.D(b0Var, this.O)) {
                com.google.android.flexbox.c cVar = (com.google.android.flexbox.c) this.O.get(dVar.f12737c);
                dVar.f12738d = cVar.f12761o;
                i12 += C2(cVar, dVar);
                if (j10 || !this.M) {
                    d.c(dVar, cVar.a() * dVar.f12743i);
                } else {
                    d.d(dVar, cVar.a() * dVar.f12743i);
                }
                i11 -= cVar.a();
            }
        }
        d.i(dVar, i12);
        if (dVar.f12740f != Integer.MIN_VALUE) {
            d.q(dVar, i12);
            if (dVar.f12735a < 0) {
                d.q(dVar, dVar.f12735a);
            }
            F2(wVar, dVar);
        }
        return i10 - dVar.f12735a;
    }

    private View k2(int i10) {
        View r22 = r2(0, T(), i10);
        if (r22 == null) {
            return null;
        }
        int i11 = this.P.f12767c[n0(r22)];
        if (i11 == -1) {
            return null;
        }
        return l2(r22, (com.google.android.flexbox.c) this.O.get(i11));
    }

    private View l2(View view, com.google.android.flexbox.c cVar) {
        boolean j10 = j();
        int i10 = cVar.f12754h;
        for (int i11 = 1; i11 < i10; i11++) {
            View S = S(i11);
            if (S != null && S.getVisibility() != 8) {
                if (!this.M || j10) {
                    if (this.U.g(view) <= this.U.g(S)) {
                    }
                    view = S;
                } else {
                    if (this.U.d(view) >= this.U.d(S)) {
                    }
                    view = S;
                }
            }
        }
        return view;
    }

    private View n2(int i10) {
        View r22 = r2(T() - 1, -1, i10);
        if (r22 == null) {
            return null;
        }
        return o2(r22, (com.google.android.flexbox.c) this.O.get(this.P.f12767c[n0(r22)]));
    }

    private View o2(View view, com.google.android.flexbox.c cVar) {
        boolean j10 = j();
        int T = (T() - cVar.f12754h) - 1;
        for (int T2 = T() - 2; T2 > T; T2--) {
            View S = S(T2);
            if (S != null && S.getVisibility() != 8) {
                if (!this.M || j10) {
                    if (this.U.d(view) >= this.U.d(S)) {
                    }
                    view = S;
                } else {
                    if (this.U.g(view) <= this.U.g(S)) {
                    }
                    view = S;
                }
            }
        }
        return view;
    }

    private View q2(int i10, int i11, boolean z10) {
        int i12 = i11 > i10 ? 1 : -1;
        while (i10 != i11) {
            View S = S(i10);
            if (B2(S, z10)) {
                return S;
            }
            i10 += i12;
        }
        return null;
    }

    private View r2(int i10, int i11, int i12) {
        int n02;
        i2();
        h2();
        int m10 = this.U.m();
        int i13 = this.U.i();
        int i14 = i11 > i10 ? 1 : -1;
        View view = null;
        View view2 = null;
        while (i10 != i11) {
            View S = S(i10);
            if (S != null && (n02 = n0(S)) >= 0 && n02 < i12) {
                if (((RecyclerView.q) S.getLayoutParams()).c()) {
                    if (view2 == null) {
                        view2 = S;
                    }
                } else {
                    if (this.U.g(S) >= m10 && this.U.d(S) <= i13) {
                        return S;
                    }
                    if (view == null) {
                        view = S;
                    }
                }
            }
            i10 += i14;
        }
        return view != null ? view : view2;
    }

    private int s2(int i10, RecyclerView.w wVar, RecyclerView.b0 b0Var, boolean z10) {
        int i11;
        int i12;
        if (!j() && this.M) {
            int m10 = i10 - this.U.m();
            if (m10 <= 0) {
                return 0;
            }
            i11 = z2(m10, wVar, b0Var);
        } else {
            int i13 = this.U.i() - i10;
            if (i13 <= 0) {
                return 0;
            }
            i11 = -z2(-i13, wVar, b0Var);
        }
        int i14 = i10 + i11;
        if (!z10 || (i12 = this.U.i() - i14) <= 0) {
            return i11;
        }
        this.U.r(i12);
        return i12 + i11;
    }

    private int t2(int i10, RecyclerView.w wVar, RecyclerView.b0 b0Var, boolean z10) {
        int i11;
        int m10;
        if (j() || !this.M) {
            int m11 = i10 - this.U.m();
            if (m11 <= 0) {
                return 0;
            }
            i11 = -z2(m11, wVar, b0Var);
        } else {
            int i12 = this.U.i() - i10;
            if (i12 <= 0) {
                return 0;
            }
            i11 = z2(-i12, wVar, b0Var);
        }
        int i13 = i10 + i11;
        if (!z10 || (m10 = i13 - this.U.m()) <= 0) {
            return i11;
        }
        this.U.r(-m10);
        return i11 - m10;
    }

    private int u2(View view) {
        return Y(view) + ((ViewGroup.MarginLayoutParams) ((RecyclerView.q) view.getLayoutParams())).bottomMargin;
    }

    private View v2() {
        return S(0);
    }

    private int w2(View view) {
        return a0(view) - ((ViewGroup.MarginLayoutParams) ((RecyclerView.q) view.getLayoutParams())).leftMargin;
    }

    private int x2(View view) {
        return d0(view) + ((ViewGroup.MarginLayoutParams) ((RecyclerView.q) view.getLayoutParams())).rightMargin;
    }

    private int y2(View view) {
        return e0(view) - ((ViewGroup.MarginLayoutParams) ((RecyclerView.q) view.getLayoutParams())).topMargin;
    }

    private int z2(int i10, RecyclerView.w wVar, RecyclerView.b0 b0Var) {
        if (T() == 0 || i10 == 0) {
            return 0;
        }
        i2();
        int i11 = 1;
        this.S.f12744j = true;
        boolean z10 = !j() && this.M;
        if (!z10 ? i10 <= 0 : i10 >= 0) {
            i11 = -1;
        }
        int abs = Math.abs(i10);
        T2(i11, abs);
        int j22 = this.S.f12740f + j2(wVar, b0Var, this.S);
        if (j22 < 0) {
            return 0;
        }
        if (z10) {
            if (abs > j22) {
                i10 = (-i11) * j22;
            }
        } else if (abs > j22) {
            i10 = i11 * j22;
        }
        this.U.r(-i10);
        this.S.f12741g = i10;
        return i10;
    }

    @Override // androidx.recyclerview.widget.RecyclerView.p
    public int A(RecyclerView.b0 b0Var) {
        return e2(b0Var);
    }

    @Override // androidx.recyclerview.widget.RecyclerView.p
    public int B(RecyclerView.b0 b0Var) {
        return f2(b0Var);
    }

    @Override // androidx.recyclerview.widget.RecyclerView.p
    public int C(RecyclerView.b0 b0Var) {
        return g2(b0Var);
    }

    @Override // androidx.recyclerview.widget.RecyclerView.p
    public int D(RecyclerView.b0 b0Var) {
        return e2(b0Var);
    }

    @Override // androidx.recyclerview.widget.RecyclerView.p
    public int E(RecyclerView.b0 b0Var) {
        return f2(b0Var);
    }

    @Override // androidx.recyclerview.widget.RecyclerView.p
    public int E1(int i10, RecyclerView.w wVar, RecyclerView.b0 b0Var) {
        if (!j() || this.I == 0) {
            int z22 = z2(i10, wVar, b0Var);
            this.f12715c0.clear();
            return z22;
        }
        int A2 = A2(i10);
        b.l(this.T, A2);
        this.V.r(-A2);
        return A2;
    }

    @Override // androidx.recyclerview.widget.RecyclerView.p
    public int F(RecyclerView.b0 b0Var) {
        return g2(b0Var);
    }

    @Override // androidx.recyclerview.widget.RecyclerView.p
    public void F1(int i10) {
        this.X = i10;
        this.Y = Integer.MIN_VALUE;
        e eVar = this.W;
        if (eVar != null) {
            eVar.h();
        }
        B1();
    }

    @Override // androidx.recyclerview.widget.RecyclerView.p
    public int G1(int i10, RecyclerView.w wVar, RecyclerView.b0 b0Var) {
        if (j() || (this.I == 0 && !j())) {
            int z22 = z2(i10, wVar, b0Var);
            this.f12715c0.clear();
            return z22;
        }
        int A2 = A2(i10);
        b.l(this.T, A2);
        this.V.r(-A2);
        return A2;
    }

    @Override // androidx.recyclerview.widget.RecyclerView.p
    public void L0(RecyclerView.h hVar, RecyclerView.h hVar2) {
        r1();
    }

    public void L2(int i10) {
        int i11 = this.K;
        if (i11 != i10) {
            if (i11 == 4 || i10 == 4) {
                r1();
                d2();
            }
            this.K = i10;
            B1();
        }
    }

    public void M2(int i10) {
        if (this.H != i10) {
            r1();
            this.H = i10;
            this.U = null;
            this.V = null;
            d2();
            B1();
        }
    }

    @Override // androidx.recyclerview.widget.RecyclerView.p
    public RecyclerView.q N() {
        return new c(-2, -2);
    }

    @Override // androidx.recyclerview.widget.RecyclerView.p
    public void N0(RecyclerView recyclerView) {
        super.N0(recyclerView);
        this.f12717e0 = (View) recyclerView.getParent();
    }

    public void N2(int i10) {
        if (i10 == 2) {
            throw new UnsupportedOperationException("wrap_reverse is not supported in FlexboxLayoutManager");
        }
        int i11 = this.I;
        if (i11 != i10) {
            if (i11 == 0 || i10 == 0) {
                r1();
                d2();
            }
            this.I = i10;
            this.U = null;
            this.V = null;
            B1();
        }
    }

    @Override // androidx.recyclerview.widget.RecyclerView.p
    public RecyclerView.q O(Context context, AttributeSet attributeSet) {
        return new c(context, attributeSet);
    }

    @Override // androidx.recyclerview.widget.RecyclerView.p
    public void P0(RecyclerView recyclerView, RecyclerView.w wVar) {
        super.P0(recyclerView, wVar);
        if (this.f12714b0) {
            s1(wVar);
            wVar.c();
        }
    }

    @Override // androidx.recyclerview.widget.RecyclerView.p
    public void Q1(RecyclerView recyclerView, RecyclerView.b0 b0Var, int i10) {
        k kVar = new k(recyclerView.getContext());
        kVar.p(i10);
        R1(kVar);
    }

    @Override // androidx.recyclerview.widget.RecyclerView.p
    public void Y0(RecyclerView recyclerView, int i10, int i11) {
        super.Y0(recyclerView, i10, i11);
        R2(i10);
    }

    @Override // androidx.recyclerview.widget.RecyclerView.a0.b
    public PointF a(int i10) {
        View S;
        if (T() == 0 || (S = S(0)) == null) {
            return null;
        }
        int i11 = i10 < n0(S) ? -1 : 1;
        return j() ? new PointF(BitmapDescriptorFactory.HUE_RED, i11) : new PointF(i11, BitmapDescriptorFactory.HUE_RED);
    }

    @Override // androidx.recyclerview.widget.RecyclerView.p
    public void a1(RecyclerView recyclerView, int i10, int i11, int i12) {
        super.a1(recyclerView, i10, i11, i12);
        R2(Math.min(i10, i11));
    }

    @Override // com.google.android.flexbox.a
    public void b(View view, int i10, int i11, com.google.android.flexbox.c cVar) {
        t(view, f12712h0);
        if (j()) {
            int k02 = k0(view) + p0(view);
            cVar.f12751e += k02;
            cVar.f12752f += k02;
        } else {
            int s02 = s0(view) + R(view);
            cVar.f12751e += s02;
            cVar.f12752f += s02;
        }
    }

    @Override // androidx.recyclerview.widget.RecyclerView.p
    public void b1(RecyclerView recyclerView, int i10, int i11) {
        super.b1(recyclerView, i10, i11);
        R2(i10);
    }

    @Override // com.google.android.flexbox.a
    public void c(com.google.android.flexbox.c cVar) {
    }

    @Override // androidx.recyclerview.widget.RecyclerView.p
    public void c1(RecyclerView recyclerView, int i10, int i11) {
        super.c1(recyclerView, i10, i11);
        R2(i10);
    }

    @Override // com.google.android.flexbox.a
    public View d(int i10) {
        return g(i10);
    }

    @Override // androidx.recyclerview.widget.RecyclerView.p
    public void d1(RecyclerView recyclerView, int i10, int i11, Object obj) {
        super.d1(recyclerView, i10, i11, obj);
        R2(i10);
    }

    @Override // com.google.android.flexbox.a
    public int e(int i10, int i11, int i12) {
        return RecyclerView.p.U(u0(), v0(), i11, i12, u());
    }

    @Override // androidx.recyclerview.widget.RecyclerView.p
    public void e1(RecyclerView.w wVar, RecyclerView.b0 b0Var) {
        int i10;
        int i11;
        this.Q = wVar;
        this.R = b0Var;
        int b10 = b0Var.b();
        if (b10 == 0 && b0Var.e()) {
            return;
        }
        K2();
        i2();
        h2();
        this.P.t(b10);
        this.P.u(b10);
        this.P.s(b10);
        this.S.f12744j = false;
        e eVar = this.W;
        if (eVar != null && eVar.g(b10)) {
            this.X = this.W.f12745p;
        }
        if (!this.T.f12725f || this.X != -1 || this.W != null) {
            this.T.t();
            Q2(b0Var, this.T);
            this.T.f12725f = true;
        }
        G(wVar);
        if (this.T.f12724e) {
            V2(this.T, false, true);
        } else {
            U2(this.T, false, true);
        }
        S2(b10);
        j2(wVar, b0Var, this.S);
        if (this.T.f12724e) {
            i11 = this.S.f12739e;
            U2(this.T, true, false);
            j2(wVar, b0Var, this.S);
            i10 = this.S.f12739e;
        } else {
            i10 = this.S.f12739e;
            V2(this.T, true, false);
            j2(wVar, b0Var, this.S);
            i11 = this.S.f12739e;
        }
        if (T() > 0) {
            if (this.T.f12724e) {
                t2(i11 + s2(i10, wVar, b0Var, true), wVar, b0Var, false);
            } else {
                s2(i10 + t2(i11, wVar, b0Var, true), wVar, b0Var, false);
            }
        }
    }

    @Override // com.google.android.flexbox.a
    public void f(int i10, View view) {
        this.f12715c0.put(i10, view);
    }

    @Override // androidx.recyclerview.widget.RecyclerView.p
    public void f1(RecyclerView.b0 b0Var) {
        super.f1(b0Var);
        this.W = null;
        this.X = -1;
        this.Y = Integer.MIN_VALUE;
        this.f12718f0 = -1;
        this.T.t();
        this.f12715c0.clear();
    }

    @Override // com.google.android.flexbox.a
    public View g(int i10) {
        View view = (View) this.f12715c0.get(i10);
        return view != null ? view : this.Q.o(i10);
    }

    @Override // com.google.android.flexbox.a
    public int getAlignContent() {
        return 5;
    }

    @Override // com.google.android.flexbox.a
    public int getAlignItems() {
        return this.K;
    }

    @Override // com.google.android.flexbox.a
    public int getFlexDirection() {
        return this.H;
    }

    @Override // com.google.android.flexbox.a
    public int getFlexItemCount() {
        return this.R.b();
    }

    @Override // com.google.android.flexbox.a
    public List getFlexLinesInternal() {
        return this.O;
    }

    @Override // com.google.android.flexbox.a
    public int getFlexWrap() {
        return this.I;
    }

    @Override // com.google.android.flexbox.a
    public int getLargestMainSize() {
        if (this.O.size() == 0) {
            return 0;
        }
        int size = this.O.size();
        int i10 = Integer.MIN_VALUE;
        for (int i11 = 0; i11 < size; i11++) {
            i10 = Math.max(i10, ((com.google.android.flexbox.c) this.O.get(i11)).f12751e);
        }
        return i10;
    }

    @Override // com.google.android.flexbox.a
    public int getMaxLine() {
        return this.L;
    }

    @Override // com.google.android.flexbox.a
    public int getSumOfCrossSize() {
        int size = this.O.size();
        int i10 = 0;
        for (int i11 = 0; i11 < size; i11++) {
            i10 += ((com.google.android.flexbox.c) this.O.get(i11)).f12753g;
        }
        return i10;
    }

    @Override // com.google.android.flexbox.a
    public int h(View view, int i10, int i11) {
        int s02;
        int R;
        if (j()) {
            s02 = k0(view);
            R = p0(view);
        } else {
            s02 = s0(view);
            R = R(view);
        }
        return s02 + R;
    }

    @Override // com.google.android.flexbox.a
    public int i(int i10, int i11, int i12) {
        return RecyclerView.p.U(g0(), h0(), i11, i12, v());
    }

    @Override // com.google.android.flexbox.a
    public boolean j() {
        int i10 = this.H;
        return i10 == 0 || i10 == 1;
    }

    @Override // androidx.recyclerview.widget.RecyclerView.p
    public void j1(Parcelable parcelable) {
        if (parcelable instanceof e) {
            this.W = (e) parcelable;
            B1();
        }
    }

    @Override // com.google.android.flexbox.a
    public int k(View view) {
        int k02;
        int p02;
        if (j()) {
            k02 = s0(view);
            p02 = R(view);
        } else {
            k02 = k0(view);
            p02 = p0(view);
        }
        return k02 + p02;
    }

    @Override // androidx.recyclerview.widget.RecyclerView.p
    public Parcelable k1() {
        if (this.W != null) {
            return new e(this.W);
        }
        e eVar = new e();
        if (T() > 0) {
            View v22 = v2();
            eVar.f12745p = n0(v22);
            eVar.f12746q = this.U.g(v22) - this.U.m();
        } else {
            eVar.h();
        }
        return eVar;
    }

    public int m2() {
        View q22 = q2(0, T(), false);
        if (q22 == null) {
            return -1;
        }
        return n0(q22);
    }

    public int p2() {
        View q22 = q2(T() - 1, -1, false);
        if (q22 == null) {
            return -1;
        }
        return n0(q22);
    }

    @Override // com.google.android.flexbox.a
    public void setFlexLines(List list) {
        this.O = list;
    }

    @Override // androidx.recyclerview.widget.RecyclerView.p
    public boolean u() {
        if (this.I == 0) {
            return j();
        }
        if (j()) {
            int u02 = u0();
            View view = this.f12717e0;
            if (u02 <= (view != null ? view.getWidth() : 0)) {
                return false;
            }
        }
        return true;
    }

    @Override // androidx.recyclerview.widget.RecyclerView.p
    public boolean v() {
        if (this.I == 0) {
            return !j();
        }
        if (j()) {
            return true;
        }
        int g02 = g0();
        View view = this.f12717e0;
        return g02 > (view != null ? view.getHeight() : 0);
    }

    @Override // androidx.recyclerview.widget.RecyclerView.p
    public boolean w(RecyclerView.q qVar) {
        return qVar instanceof c;
    }

    @Override // androidx.recyclerview.widget.RecyclerView.p
    public boolean y0() {
        return true;
    }

    /* JADX INFO: Access modifiers changed from: private */
    /* loaded from: classes.dex */
    public static class e implements Parcelable {
        public static final Parcelable.Creator<e> CREATOR = new a();

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

        /* renamed from: q, reason: collision with root package name */
        private int f12746q;

        /* loaded from: classes.dex */
        class a implements Parcelable.Creator {
            a() {
            }

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

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

        /* JADX INFO: Access modifiers changed from: private */
        public boolean g(int i10) {
            int i11 = this.f12745p;
            return i11 >= 0 && i11 < i10;
        }

        /* JADX INFO: Access modifiers changed from: private */
        public void h() {
            this.f12745p = -1;
        }

        @Override // android.os.Parcelable
        public int describeContents() {
            return 0;
        }

        public String toString() {
            return "SavedState{mAnchorPosition=" + this.f12745p + ", mAnchorOffset=" + this.f12746q + '}';
        }

        @Override // android.os.Parcelable
        public void writeToParcel(Parcel parcel, int i10) {
            parcel.writeInt(this.f12745p);
            parcel.writeInt(this.f12746q);
        }

        e() {
        }

        private e(Parcel parcel) {
            this.f12745p = parcel.readInt();
            this.f12746q = parcel.readInt();
        }

        private e(e eVar) {
            this.f12745p = eVar.f12745p;
            this.f12746q = eVar.f12746q;
        }
    }

    /* loaded from: classes.dex */
    public static class c extends RecyclerView.q implements com.google.android.flexbox.b {
        public static final Parcelable.Creator<c> CREATOR = new a();
        private int A;
        private boolean B;

        /* renamed from: t, reason: collision with root package name */
        private float f12728t;

        /* renamed from: u, reason: collision with root package name */
        private float f12729u;

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

        /* renamed from: w, reason: collision with root package name */
        private float f12731w;

        /* renamed from: x, reason: collision with root package name */
        private int f12732x;

        /* renamed from: y, reason: collision with root package name */
        private int f12733y;

        /* renamed from: z, reason: collision with root package name */
        private int f12734z;

        /* loaded from: classes.dex */
        class a implements Parcelable.Creator {
            a() {
            }

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

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

        public c(Context context, AttributeSet attributeSet) {
            super(context, attributeSet);
            this.f12728t = BitmapDescriptorFactory.HUE_RED;
            this.f12729u = 1.0f;
            this.f12730v = -1;
            this.f12731w = -1.0f;
            this.f12734z = 16777215;
            this.A = 16777215;
        }

        @Override // com.google.android.flexbox.b
        public int A0() {
            return ((ViewGroup.MarginLayoutParams) this).rightMargin;
        }

        @Override // com.google.android.flexbox.b
        public int C() {
            return this.f12730v;
        }

        @Override // com.google.android.flexbox.b
        public int C0() {
            return this.f12733y;
        }

        @Override // com.google.android.flexbox.b
        public boolean D0() {
            return this.B;
        }

        @Override // com.google.android.flexbox.b
        public int F0() {
            return this.A;
        }

        @Override // com.google.android.flexbox.b
        public float G() {
            return this.f12729u;
        }

        @Override // com.google.android.flexbox.b
        public int L() {
            return this.f12732x;
        }

        @Override // com.google.android.flexbox.b
        public int Q0() {
            return this.f12734z;
        }

        @Override // com.google.android.flexbox.b
        public void S(int i10) {
            this.f12732x = i10;
        }

        @Override // com.google.android.flexbox.b
        public int T() {
            return ((ViewGroup.MarginLayoutParams) this).bottomMargin;
        }

        @Override // com.google.android.flexbox.b
        public int V() {
            return ((ViewGroup.MarginLayoutParams) this).leftMargin;
        }

        @Override // com.google.android.flexbox.b
        public int a0() {
            return ((ViewGroup.MarginLayoutParams) this).topMargin;
        }

        @Override // android.os.Parcelable
        public int describeContents() {
            return 0;
        }

        @Override // com.google.android.flexbox.b
        public void g0(int i10) {
            this.f12733y = i10;
        }

        @Override // com.google.android.flexbox.b
        public int getHeight() {
            return ((ViewGroup.MarginLayoutParams) this).height;
        }

        @Override // com.google.android.flexbox.b
        public int getOrder() {
            return 1;
        }

        @Override // com.google.android.flexbox.b
        public int getWidth() {
            return ((ViewGroup.MarginLayoutParams) this).width;
        }

        @Override // com.google.android.flexbox.b
        public float j0() {
            return this.f12728t;
        }

        @Override // com.google.android.flexbox.b
        public float o0() {
            return this.f12731w;
        }

        @Override // android.os.Parcelable
        public void writeToParcel(Parcel parcel, int i10) {
            parcel.writeFloat(this.f12728t);
            parcel.writeFloat(this.f12729u);
            parcel.writeInt(this.f12730v);
            parcel.writeFloat(this.f12731w);
            parcel.writeInt(this.f12732x);
            parcel.writeInt(this.f12733y);
            parcel.writeInt(this.f12734z);
            parcel.writeInt(this.A);
            parcel.writeByte(this.B ? (byte) 1 : (byte) 0);
            parcel.writeInt(((ViewGroup.MarginLayoutParams) this).bottomMargin);
            parcel.writeInt(((ViewGroup.MarginLayoutParams) this).leftMargin);
            parcel.writeInt(((ViewGroup.MarginLayoutParams) this).rightMargin);
            parcel.writeInt(((ViewGroup.MarginLayoutParams) this).topMargin);
            parcel.writeInt(((ViewGroup.MarginLayoutParams) this).height);
            parcel.writeInt(((ViewGroup.MarginLayoutParams) this).width);
        }

        public c(int i10, int i11) {
            super(i10, i11);
            this.f12728t = BitmapDescriptorFactory.HUE_RED;
            this.f12729u = 1.0f;
            this.f12730v = -1;
            this.f12731w = -1.0f;
            this.f12734z = 16777215;
            this.A = 16777215;
        }

        protected c(Parcel parcel) {
            super(-2, -2);
            this.f12728t = BitmapDescriptorFactory.HUE_RED;
            this.f12729u = 1.0f;
            this.f12730v = -1;
            this.f12731w = -1.0f;
            this.f12734z = 16777215;
            this.A = 16777215;
            this.f12728t = parcel.readFloat();
            this.f12729u = parcel.readFloat();
            this.f12730v = parcel.readInt();
            this.f12731w = parcel.readFloat();
            this.f12732x = parcel.readInt();
            this.f12733y = parcel.readInt();
            this.f12734z = parcel.readInt();
            this.A = parcel.readInt();
            this.B = parcel.readByte() != 0;
            ((ViewGroup.MarginLayoutParams) this).bottomMargin = parcel.readInt();
            ((ViewGroup.MarginLayoutParams) this).leftMargin = parcel.readInt();
            ((ViewGroup.MarginLayoutParams) this).rightMargin = parcel.readInt();
            ((ViewGroup.MarginLayoutParams) this).topMargin = parcel.readInt();
            ((ViewGroup.MarginLayoutParams) this).height = parcel.readInt();
            ((ViewGroup.MarginLayoutParams) this).width = parcel.readInt();
        }
    }
}
